QGIS API Documentation  2.99.0-Master (5169e0d)
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 = nullptr );
54 
55  QgsLayerTree *rootGroup() const { return mRoot; }
56  QgsMapCanvas *mapCanvas() const { return mCanvas; }
57 
60  void setOvervewCanvas( QgsMapOverviewCanvas *overviewCanvas ) { mOverviewCanvas = overviewCanvas; }
63  QgsMapOverviewCanvas *overviewCanvas() const { return mOverviewCanvas; }
64 
67  void setAutoSetupOnFirstLayer( bool enabled ) { mAutoSetupOnFirstLayer = enabled; }
68  bool autoSetupOnFirstLayer() const { return mAutoSetupOnFirstLayer; }
69 
71  Q_INVOKABLE void setCanvasLayers();
72 
73  signals:
74 
80  void canvasLayersChanged( const QList< QgsMapLayer * > &layers );
81 
82  private slots:
83  void nodeVisibilityChanged();
84  void nodeCustomPropertyChanged( QgsLayerTreeNode *node, const QString &key );
85 
86  private:
88  void setCanvasLayers( QgsLayerTreeNode *node, QList<QgsMapLayer *> &canvasLayers, QList<QgsMapLayer *> &overviewLayers,
89  QList<QgsMapLayer *> &allLayers );
90 
91  void deferredSetCanvasLayers();
92 
93  QgsLayerTree *mRoot = nullptr;
94  QgsMapCanvas *mCanvas = nullptr;
95  QgsMapOverviewCanvas *mOverviewCanvas = nullptr;
96 
97  bool mPendingCanvasUpdate;
98 
99  bool mAutoSetupOnFirstLayer;
100 
101  bool mHasFirstLayer;
102  bool mLastLayerCount;
103  bool mUpdatingProjectLayerOrder = false;
104 
106 };
107 
108 #endif // QGSLAYERTREEMAPCANVASBRIDGE_H
Layer tree group node serves as a container for layers and further groups.
Base class for all map layer types.
Definition: qgsmaplayer.h:53
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:72
Namespace with helper functions for layer tree operations.
Definition: qgslayertree.h:31
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...
QgsMapOverviewCanvas * overviewCanvas() const
Returns associated overview canvas (may be null)