QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgslayertreemapcanvasbridge.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayertreemapcanvasbridge.h
3  --------------------------------------
4  Date : May 2014
5  Copyright : (C) 2014 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSLAYERTREEMAPCANVASBRIDGE_H
17 #define QGSLAYERTREEMAPCANVASBRIDGE_H
18 
19 #include <QObject>
20 #include "qgis.h"
21 #include <QStringList>
22 
24 #include "qgis_gui.h"
25 
26 class QgsMapCanvas;
27 class QgsMapLayer;
29 class QgsLayerTreeGroup;
30 class QgsLayerTreeNode;
31 class QgsLayerTree;
32 
49 class GUI_EXPORT QgsLayerTreeMapCanvasBridge : public QObject
50 {
51  Q_OBJECT
52  public:
54  QgsLayerTreeMapCanvasBridge( QgsLayerTree *root, QgsMapCanvas *canvas, QObject *parent SIP_TRANSFERTHIS = nullptr );
55 
56  QgsLayerTree *rootGroup() const { return mRoot; }
57  QgsMapCanvas *mapCanvas() const { return mCanvas; }
58 
63  void setOvervewCanvas( QgsMapOverviewCanvas *overviewCanvas ) { mOverviewCanvas = overviewCanvas; }
64 
69  QgsMapOverviewCanvas *overviewCanvas() const { return mOverviewCanvas; }
70 
75  void setAutoSetupOnFirstLayer( bool enabled ) { mAutoSetupOnFirstLayer = enabled; }
76  bool autoSetupOnFirstLayer() const { return mAutoSetupOnFirstLayer; }
77 
79  Q_INVOKABLE void setCanvasLayers();
80 
81  signals:
82 
88  void canvasLayersChanged( const QList< QgsMapLayer * > &layers );
89 
90  private slots:
91  void nodeVisibilityChanged();
92  void nodeCustomPropertyChanged( QgsLayerTreeNode *node, const QString &key );
93 
94  private:
96  void setCanvasLayers( QgsLayerTreeNode *node, QList<QgsMapLayer *> &canvasLayers, QList<QgsMapLayer *> &overviewLayers,
97  QList<QgsMapLayer *> &allLayers );
98 
99  void deferredSetCanvasLayers();
100 
101  QgsLayerTree *mRoot = nullptr;
102  QgsMapCanvas *mCanvas = nullptr;
103  QgsMapOverviewCanvas *mOverviewCanvas = nullptr;
104 
105  bool mPendingCanvasUpdate;
106 
107  bool mAutoSetupOnFirstLayer;
108 
109  bool mHasFirstLayer;
110  bool mLastLayerCount;
111  bool mUpdatingProjectLayerOrder = false;
112 
114 };
115 
116 #endif // QGSLAYERTREEMAPCANVASBRIDGE_H
QgsMapOverviewCanvas * overviewCanvas() const
Returns associated overview canvas (may be null)
Layer tree group node serves as a container for layers and further groups.
Base class for all map layer types.
Definition: qgsmaplayer.h:63
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
A widget that displays an overview map.
The QgsLayerTreeMapCanvasBridge class takes care of updates of layer set for QgsMapCanvas from a laye...
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:74
Namespace with helper functions for layer tree operations.
Definition: qgslayertree.h:32
This class is a base class for nodes in a layer tree.
void setAutoSetupOnFirstLayer(bool enabled)
if enabled, will automatically set full canvas extent and destination CRS + map units when first laye...
This class represents a coordinate reference system (CRS).
void setOvervewCanvas(QgsMapOverviewCanvas *overviewCanvas)
Associates overview canvas with the bridge, so the overview will be updated whenever main canvas is u...