QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 = 0 );
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 override );
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, QString key );
98 
99  protected:
102 
104 
106  QStringList mCustomLayerOrder;
107 
110 
114 };
115 
116 #endif // QGSLAYERTREEMAPCANVASBRIDGE_H
Layer tree group node serves as a container for layers and further groups.
Definition: qgslayertreegroup.h:31
bool mLastLayerCount
Definition: qgslayertreemapcanvasbridge.h:112
QgsLayerTreeGroup * mRoot
Definition: qgslayertreemapcanvasbridge.h:100
bool mHasCustomLayerOrder
Definition: qgslayertreemapcanvasbridge.h:105
bool autoSetupOnFirstLayer() const
Definition: qgslayertreemapcanvasbridge.h:64
The QgsLayerTreeMapCanvasBridge class takes care of updates of layer set for QgsMapCanvas from a laye...
Definition: qgslayertreemapcanvasbridge.h:44
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:104
QgsLayerTreeGroup * rootGroup() const
Definition: qgslayertreemapcanvasbridge.h:53
void setAutoEnableCrsTransform(bool enabled)
if enabled, will automatically turn on on-the-fly reprojection of layers if a layer with different so...
Definition: qgslayertreemapcanvasbridge.h:68
bool mAutoEnableCrsTransform
Definition: qgslayertreemapcanvasbridge.h:109
This class is a base class for nodes in a layer tree.
Definition: qgslayertreenode.h:63
void setAutoSetupOnFirstLayer(bool enabled)
if enabled, will automatically set full canvas extent and destination CRS + map units when first laye...
Definition: qgslayertreemapcanvasbridge.h:63
QgsMapCanvas * mapCanvas() const
Definition: qgslayertreemapcanvasbridge.h:54
QgsMapCanvas * mCanvas
Definition: qgslayertreemapcanvasbridge.h:101
bool mHasFirstLayer
Definition: qgslayertreemapcanvasbridge.h:111
QStringList customLayerOrder() const
Definition: qgslayertreemapcanvasbridge.h:57
bool mPendingCanvasUpdate
Definition: qgslayertreemapcanvasbridge.h:103
QStringList mCustomLayerOrder
Definition: qgslayertreemapcanvasbridge.h:106
bool mAutoSetupOnFirstLayer
Definition: qgslayertreemapcanvasbridge.h:108
Class for storing a coordinate reference system (CRS)
Definition: qgscoordinatereferencesystem.h:50
bool autoEnableCrsTransform() const
Definition: qgslayertreemapcanvasbridge.h:69
bool hasCustomLayerOrder() const
Definition: qgslayertreemapcanvasbridge.h:56
QgsCoordinateReferenceSystem mFirstCRS
Definition: qgslayertreemapcanvasbridge.h:113