QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
24 class QgsMapCanvas;
25 class QgsMapCanvasLayer;
26 class QgsLayerTreeGroup;
27 class QgsLayerTreeNode;
28 
45 class GUI_EXPORT QgsLayerTreeMapCanvasBridge : public QObject
46 {
47  Q_OBJECT
48  public:
50  QgsLayerTreeMapCanvasBridge( QgsLayerTreeGroup* root, QgsMapCanvas* canvas, QObject* parent = nullptr );
51 
52  void clear();
53 
54  QgsLayerTreeGroup* rootGroup() const { return mRoot; }
55  QgsMapCanvas* mapCanvas() const { return mCanvas; }
56 
57  bool hasCustomLayerOrder() const { return mHasCustomLayerOrder; }
58  QStringList customLayerOrder() const { return mCustomLayerOrder; }
59 
60  QStringList defaultLayerOrder() const;
61 
64  void setAutoSetupOnFirstLayer( bool enabled ) { mAutoSetupOnFirstLayer = enabled; }
65  bool autoSetupOnFirstLayer() const { return mAutoSetupOnFirstLayer; }
66 
69  void setAutoEnableCrsTransform( bool enabled ) { mAutoEnableCrsTransform = enabled; }
70  bool autoEnableCrsTransform() const { return mAutoEnableCrsTransform; }
71 
72  public slots:
73  void setHasCustomLayerOrder( bool state );
74  void setCustomLayerOrder( const QStringList& order );
75 
77  void setCanvasLayers();
78 
79  void readProject( const QDomDocument& doc );
80  void writeProject( QDomDocument& doc );
81 
82  signals:
83  void hasCustomLayerOrderChanged( bool );
84  void customLayerOrderChanged( const QStringList& order );
85 
86  protected:
87 
88  void defaultLayerOrder( QgsLayerTreeNode* node, QStringList& order ) const;
89 
90  void setCanvasLayers( QgsLayerTreeNode* node, QList<QgsMapCanvasLayer>& layers );
91 
92  void deferredSetCanvasLayers();
93 
94  protected slots:
95  void nodeAddedChildren( QgsLayerTreeNode* node, int indexFrom, int indexTo );
96  void nodeRemovedChildren();
97  void nodeVisibilityChanged();
98  void nodeCustomPropertyChanged( QgsLayerTreeNode* node, const QString& key );
99 
100  protected:
103 
105 
108 
111 
115 };
116 
117 #endif // QGSLAYERTREEMAPCANVASBRIDGE_H
Layer tree group node serves as a container for layers and further groups.
The QgsLayerTreeMapCanvasBridge class takes care of updates of layer set for QgsMapCanvas from a laye...
A class that stores visibility and presence in overview flags together with pointer to the layer...
Definition: qgsmapcanvas.h:75
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:109
void setAutoEnableCrsTransform(bool enabled)
if enabled, will automatically turn on on-the-fly reprojection of layers if a layer with different so...
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...
QgsLayerTreeGroup * rootGroup() const
Class for storing a coordinate reference system (CRS)
QgsCoordinateReferenceSystem mFirstCRS