QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
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
25class QgsMapCanvas;
26class QgsMapLayer;
30class QgsLayerTree;
31
47class GUI_EXPORT QgsLayerTreeMapCanvasBridge : public QObject
48{
49 Q_OBJECT
50 public:
52 QgsLayerTreeMapCanvasBridge( QgsLayerTree *root, QgsMapCanvas *canvas, QObject *parent SIP_TRANSFERTHIS = nullptr );
53
54 QgsLayerTree *rootGroup() const { return mRoot; }
55 QgsMapCanvas *mapCanvas() const { return mCanvas; }
56
61 void setOverviewCanvas( QgsMapOverviewCanvas *overviewCanvas ) { mOverviewCanvas = overviewCanvas; }
62
63#ifdef SIP_RUN
64
69 void setOvervewCanvas( QgsMapOverviewCanvas *overviewCanvas ) SIP_DEPRECATED; // TODO QGIS 4.0 remove
70 % MethodCode
71 sipCpp->setOverviewCanvas( a0 );
72 % End
73#endif
74
78 QgsMapOverviewCanvas *overviewCanvas() const { return mOverviewCanvas; }
79
84 void setAutoSetupOnFirstLayer( bool enabled ) { mAutoSetupOnFirstLayer = enabled; }
85 bool autoSetupOnFirstLayer() const { return mAutoSetupOnFirstLayer; }
86
88 Q_INVOKABLE void setCanvasLayers();
89
90 signals:
91
96 void canvasLayersChanged( const QList< QgsMapLayer * > &layers );
97
98 private slots:
99 void nodeVisibilityChanged();
100 void nodeCustomPropertyChanged( QgsLayerTreeNode *node, const QString &key );
101 void layersAdded( const QList<QgsMapLayer *> &layers );
102
103 private:
105 void setCanvasLayers( QgsLayerTreeNode *node, QList<QgsMapLayer *> &canvasLayers, QList<QgsMapLayer *> &overviewLayers,
106 QList<QgsMapLayer *> &allLayers );
107
108 void deferredSetCanvasLayers();
109
110 QgsLayerTree *mRoot = nullptr;
111 QgsMapCanvas *mCanvas = nullptr;
112 QgsMapOverviewCanvas *mOverviewCanvas = nullptr;
113
114 bool mPendingCanvasUpdate;
115
116 bool mAutoSetupOnFirstLayer;
117
118 bool mHasLayersLoaded;
119 bool mHasValidLayersLoaded = false;
120
122};
123
124#endif // QGSLAYERTREEMAPCANVASBRIDGE_H
This class represents a coordinate reference system (CRS).
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...
void setAutoSetupOnFirstLayer(bool enabled)
if enabled, will automatically set full canvas extent and destination CRS + map units when first laye...
void canvasLayersChanged(const QList< QgsMapLayer * > &layers)
Emitted when the set of layers (or order of layers) visible in the canvas changes.
QgsMapOverviewCanvas * overviewCanvas() const
Returns associated overview canvas (may be nullptr)
void setOverviewCanvas(QgsMapOverviewCanvas *overviewCanvas)
Associates overview canvas with the bridge, so the overview will be updated whenever main canvas is u...
This class is a base class for nodes in a layer tree.
Namespace with helper functions for layer tree operations.
Map canvas is a class for displaying all GIS data types on a canvas.
Base class for all map layer types.
Definition qgsmaplayer.h:76
A widget that displays an overview map.
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53