QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 <QStringList>
21 
23 #include "qgis_gui.h"
24 
25 class QgsMapCanvas;
26 class QgsMapLayer;
28 class QgsLayerTreeGroup;
29 class QgsLayerTreeNode;
30 class QgsLayerTree;
31 
48 class GUI_EXPORT QgsLayerTreeMapCanvasBridge : public QObject
49 {
50  Q_OBJECT
51  public:
53  QgsLayerTreeMapCanvasBridge( QgsLayerTree *root, QgsMapCanvas *canvas, QObject *parent SIP_TRANSFERTHIS = nullptr );
54 
55  QgsLayerTree *rootGroup() const { return mRoot; }
56  QgsMapCanvas *mapCanvas() const { return mCanvas; }
57 
62  void setOverviewCanvas( QgsMapOverviewCanvas *overviewCanvas ) { mOverviewCanvas = overviewCanvas; }
63 
64 #ifdef SIP_RUN
65 
71  void setOvervewCanvas( QgsMapOverviewCanvas *overviewCanvas ) SIP_DEPRECATED; // TODO QGIS 4.0 remove
72  % MethodCode
73  sipCpp->setOverviewCanvas( a0 );
74  % End
75 #endif
76 
81  QgsMapOverviewCanvas *overviewCanvas() const { return mOverviewCanvas; }
82 
87  void setAutoSetupOnFirstLayer( bool enabled ) { mAutoSetupOnFirstLayer = enabled; }
88  bool autoSetupOnFirstLayer() const { return mAutoSetupOnFirstLayer; }
89 
91  Q_INVOKABLE void setCanvasLayers();
92 
93  signals:
94 
100  void canvasLayersChanged( const QList< QgsMapLayer * > &layers );
101 
102  private slots:
103  void nodeVisibilityChanged();
104  void nodeCustomPropertyChanged( QgsLayerTreeNode *node, const QString &key );
105  void layersAdded( const QList<QgsMapLayer *> &layers );
106 
107  private:
109  void setCanvasLayers( QgsLayerTreeNode *node, QList<QgsMapLayer *> &canvasLayers, QList<QgsMapLayer *> &overviewLayers,
110  QList<QgsMapLayer *> &allLayers );
111 
112  void deferredSetCanvasLayers();
113 
114  QgsLayerTree *mRoot = nullptr;
115  QgsMapCanvas *mCanvas = nullptr;
116  QgsMapOverviewCanvas *mOverviewCanvas = nullptr;
117 
118  bool mPendingCanvasUpdate;
119 
120  bool mAutoSetupOnFirstLayer;
121 
122  bool mHasFirstLayer;
123  bool mHasLayersLoaded;
124  bool mHasValidLayersLoaded = false;
125  bool mUpdatingProjectLayerOrder = false;
126 
128 };
129 
130 #endif // QGSLAYERTREEMAPCANVASBRIDGE_H
QgsLayerTreeMapCanvasBridge::overviewCanvas
QgsMapOverviewCanvas * overviewCanvas() const
Returns associated overview canvas (may be nullptr)
Definition: qgslayertreemapcanvasbridge.h:81
QgsLayerTreeNode
Definition: qgslayertreenode.h:74
QgsMapCanvas
Definition: qgsmapcanvas.h:83
SIP_DEPRECATED
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
QgsLayerTree
Definition: qgslayertree.h:32
QgsLayerTreeMapCanvasBridge::mapCanvas
QgsMapCanvas * mapCanvas() const
Definition: qgslayertreemapcanvasbridge.h:56
QgsLayerTreeGroup
Definition: qgslayertreegroup.h:34
QgsLayerTreeMapCanvasBridge::rootGroup
QgsLayerTree * rootGroup() const
Definition: qgslayertreemapcanvasbridge.h:55
QgsMapOverviewCanvas
Definition: qgsmapoverviewcanvas.h:38
QgsCoordinateReferenceSystem
Definition: qgscoordinatereferencesystem.h:206
QgsMapLayer
Definition: qgsmaplayer.h:81
QgsLayerTreeMapCanvasBridge::setAutoSetupOnFirstLayer
void setAutoSetupOnFirstLayer(bool enabled)
if enabled, will automatically set full canvas extent and destination CRS + map units when first laye...
Definition: qgslayertreemapcanvasbridge.h:87
QgsLayerTreeMapCanvasBridge::autoSetupOnFirstLayer
bool autoSetupOnFirstLayer() const
Definition: qgslayertreemapcanvasbridge.h:88
QgsLayerTreeMapCanvasBridge::setOverviewCanvas
void setOverviewCanvas(QgsMapOverviewCanvas *overviewCanvas)
Associates overview canvas with the bridge, so the overview will be updated whenever main canvas is u...
Definition: qgslayertreemapcanvasbridge.h:62
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
qgscoordinatereferencesystem.h
QgsLayerTreeMapCanvasBridge
Definition: qgslayertreemapcanvasbridge.h:48