QGIS API Documentation  2.14.0-Essen
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 
44 class GUI_EXPORT QgsLayerTreeMapCanvasBridge : public QObject
45 {
46  Q_OBJECT
47  public:
49  QgsLayerTreeMapCanvasBridge( QgsLayerTreeGroup* root, QgsMapCanvas* canvas, QObject* parent = nullptr );
50 
51  void clear();
52 
53  QgsLayerTreeGroup* rootGroup() const { return mRoot; }
54  QgsMapCanvas* mapCanvas() const { return mCanvas; }
55 
56  bool hasCustomLayerOrder() const { return mHasCustomLayerOrder; }
57  QStringList customLayerOrder() const { return mCustomLayerOrder; }
58 
59  QStringList defaultLayerOrder() const;
60 
63  void setAutoSetupOnFirstLayer( bool enabled ) { mAutoSetupOnFirstLayer = enabled; }
64  bool autoSetupOnFirstLayer() const { return mAutoSetupOnFirstLayer; }
65 
68  void setAutoEnableCrsTransform( bool enabled ) { mAutoEnableCrsTransform = enabled; }
69  bool autoEnableCrsTransform() const { return mAutoEnableCrsTransform; }
70 
71  public slots:
72  void setHasCustomLayerOrder( bool state );
73  void setCustomLayerOrder( const QStringList& order );
74 
76  void setCanvasLayers();
77 
78  void readProject( const QDomDocument& doc );
79  void writeProject( QDomDocument& doc );
80 
81  signals:
82  void hasCustomLayerOrderChanged( bool );
83  void customLayerOrderChanged( const QStringList& order );
84 
85  protected:
86 
87  void defaultLayerOrder( QgsLayerTreeNode* node, QStringList& order ) const;
88 
89  void setCanvasLayers( QgsLayerTreeNode* node, QList<QgsMapCanvasLayer>& layers );
90 
91  void deferredSetCanvasLayers();
92 
93  protected slots:
94  void nodeAddedChildren( QgsLayerTreeNode* node, int indexFrom, int indexTo );
95  void nodeRemovedChildren();
96  void nodeVisibilityChanged();
97  void nodeCustomPropertyChanged( QgsLayerTreeNode* node, const QString& key );
98 
99  protected:
102 
104 
107 
110 
114 };
115 
116 #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:74
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:105
QgsLayerTreeGroup * rootGroup() const
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...
Class for storing a coordinate reference system (CRS)
QgsCoordinateReferenceSystem mFirstCRS