QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
Public Slots | Signals | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | List of all members
QgsLayerTreeMapCanvasBridge Class Reference

The QgsLayerTreeMapCanvasBridge class takes care of updates of layer set for QgsMapCanvas from a layer tree. More...

#include <qgslayertreemapcanvasbridge.h>

Inheritance diagram for QgsLayerTreeMapCanvasBridge:
Inheritance graph
[legend]

Public Slots

void readProject (const QDomDocument &doc)
 
void setCanvasLayers ()
 force update of canvas layers from the layer tree. Normally this should not be needed to be called. More...
 
void setCustomLayerOrder (const QStringList &order)
 
void setHasCustomLayerOrder (bool state)
 
void writeProject (QDomDocument &doc)
 

Signals

void customLayerOrderChanged (const QStringList &order)
 
void hasCustomLayerOrderChanged (bool)
 

Public Member Functions

 QgsLayerTreeMapCanvasBridge (QgsLayerTreeGroup *root, QgsMapCanvas *canvas, QObject *parent=nullptr)
 Constructor: does not take ownership of the layer tree nor canvas. More...
 
bool autoEnableCrsTransform () const
 
bool autoSetupOnFirstLayer () const
 
void clear ()
 
QStringList customLayerOrder () const
 
QStringList defaultLayerOrder () const
 
bool hasCustomLayerOrder () const
 
QgsMapCanvasmapCanvas () const
 
QgsLayerTreeGrouprootGroup () const
 
void setAutoEnableCrsTransform (bool enabled)
 if enabled, will automatically turn on on-the-fly reprojection of layers if a layer with different source CRS is added More...
 
void setAutoSetupOnFirstLayer (bool enabled)
 if enabled, will automatically set full canvas extent and destination CRS + map units when first layer(s) are added More...
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
 QObject (QObject *parent, const char *name)
 
virtual ~QObject ()
 
bool blockSignals (bool block)
 
QObjectchild (const char *objName, const char *inheritsClass, bool recursiveSearch) const
 
const QObjectList & children () const
 
const char * className () const
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const QObject *receiver, const char *method)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method)
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QByteArraydynamicPropertyNames () const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) const
 
QList< T > findChildren (const QString &name) const
 
bool inherits (const char *className) const
 
void insertChild (QObject *object)
 
void installEventFilter (QObject *filterObj)
 
bool isA (const char *className) const
 
bool isWidgetType () const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
const char * name () const
 
const char * name (const char *defaultName) const
 
QString objectName () const
 
QObjectparent () const
 
QVariant property (const char *name) const
 
void removeChild (QObject *object)
 
void removeEventFilter (QObject *obj)
 
void setName (const char *name)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval)
 
QThreadthread () const
 

Protected Slots

void nodeAddedChildren (QgsLayerTreeNode *node, int indexFrom, int indexTo)
 
void nodeCustomPropertyChanged (QgsLayerTreeNode *node, const QString &key)
 
void nodeRemovedChildren ()
 
void nodeVisibilityChanged ()
 

Protected Member Functions

void defaultLayerOrder (QgsLayerTreeNode *node, QStringList &order) const
 
void deferredSetCanvasLayers ()
 
void setCanvasLayers (QgsLayerTreeNode *node, QList< QgsMapCanvasLayer > &layers)
 
- Protected Member Functions inherited from QObject
bool checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const char *signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const char *signal)
 
int receivers (const char *signal) const
 
QObjectsender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Protected Attributes

bool mAutoEnableCrsTransform
 
bool mAutoSetupOnFirstLayer
 
QgsMapCanvasmCanvas
 
QStringList mCustomLayerOrder
 
QgsCoordinateReferenceSystem mFirstCRS
 
bool mHasCustomLayerOrder
 
bool mHasFirstLayer
 
bool mLastLayerCount
 
bool mPendingCanvasUpdate
 
QgsLayerTreeGroupmRoot
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Static Protected Member Functions inherited from QObject
QByteArray normalizeSignalSlot (const char *signalSlot)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

The QgsLayerTreeMapCanvasBridge class takes care of updates of layer set for QgsMapCanvas from a layer tree.

The class listens to the updates in the layer tree and updates the list of layers for rendering whenever some layers are added, removed, or their visibility changes.

The update of layers is not done immediately - it is postponed, so a series of updates to the layer tree will trigger just one update of canvas layers.

Also allows the client to override the default order of layers. This is useful in advanced cases where the grouping in layer tree should be independent from the actual order in the canvas.

Note
added in 2.4

Definition at line 45 of file qgslayertreemapcanvasbridge.h.

Constructor & Destructor Documentation

◆ QgsLayerTreeMapCanvasBridge()

QgsLayerTreeMapCanvasBridge::QgsLayerTreeMapCanvasBridge ( QgsLayerTreeGroup root,
QgsMapCanvas canvas,
QObject parent = nullptr 
)

Constructor: does not take ownership of the layer tree nor canvas.

Definition at line 24 of file qgslayertreemapcanvasbridge.cpp.

Member Function Documentation

◆ autoEnableCrsTransform()

bool QgsLayerTreeMapCanvasBridge::autoEnableCrsTransform ( ) const
inline

Definition at line 70 of file qgslayertreemapcanvasbridge.h.

◆ autoSetupOnFirstLayer()

bool QgsLayerTreeMapCanvasBridge::autoSetupOnFirstLayer ( ) const
inline

Definition at line 65 of file qgslayertreemapcanvasbridge.h.

◆ clear()

void QgsLayerTreeMapCanvasBridge::clear ( )

Definition at line 42 of file qgslayertreemapcanvasbridge.cpp.

◆ customLayerOrder()

QStringList QgsLayerTreeMapCanvasBridge::customLayerOrder ( ) const
inline

Definition at line 58 of file qgslayertreemapcanvasbridge.h.

◆ customLayerOrderChanged

void QgsLayerTreeMapCanvasBridge::customLayerOrderChanged ( const QStringList order)
signal

◆ defaultLayerOrder() [1/2]

QStringList QgsLayerTreeMapCanvasBridge::defaultLayerOrder ( ) const

Definition at line 48 of file qgslayertreemapcanvasbridge.cpp.

◆ defaultLayerOrder() [2/2]

void QgsLayerTreeMapCanvasBridge::defaultLayerOrder ( QgsLayerTreeNode node,
QStringList order 
) const
protected

Definition at line 55 of file qgslayertreemapcanvasbridge.cpp.

◆ deferredSetCanvasLayers()

void QgsLayerTreeMapCanvasBridge::deferredSetCanvasLayers ( )
protected

Definition at line 260 of file qgslayertreemapcanvasbridge.cpp.

◆ hasCustomLayerOrder()

bool QgsLayerTreeMapCanvasBridge::hasCustomLayerOrder ( ) const
inline

Definition at line 57 of file qgslayertreemapcanvasbridge.h.

◆ hasCustomLayerOrderChanged

void QgsLayerTreeMapCanvasBridge::hasCustomLayerOrderChanged ( bool  )
signal

◆ mapCanvas()

QgsMapCanvas* QgsLayerTreeMapCanvasBridge::mapCanvas ( ) const
inline

Definition at line 55 of file qgslayertreemapcanvasbridge.h.

◆ nodeAddedChildren

void QgsLayerTreeMapCanvasBridge::nodeAddedChildren ( QgsLayerTreeNode node,
int  indexFrom,
int  indexTo 
)
protectedslot

Definition at line 269 of file qgslayertreemapcanvasbridge.cpp.

◆ nodeCustomPropertyChanged

void QgsLayerTreeMapCanvasBridge::nodeCustomPropertyChanged ( QgsLayerTreeNode node,
const QString key 
)
protectedslot

Definition at line 325 of file qgslayertreemapcanvasbridge.cpp.

◆ nodeRemovedChildren

void QgsLayerTreeMapCanvasBridge::nodeRemovedChildren ( )
protectedslot

Definition at line 301 of file qgslayertreemapcanvasbridge.cpp.

◆ nodeVisibilityChanged

void QgsLayerTreeMapCanvasBridge::nodeVisibilityChanged ( )
protectedslot

Definition at line 320 of file qgslayertreemapcanvasbridge.cpp.

◆ readProject

void QgsLayerTreeMapCanvasBridge::readProject ( const QDomDocument doc)
slot

Definition at line 198 of file qgslayertreemapcanvasbridge.cpp.

◆ rootGroup()

QgsLayerTreeGroup* QgsLayerTreeMapCanvasBridge::rootGroup ( ) const
inline

Definition at line 54 of file qgslayertreemapcanvasbridge.h.

◆ setAutoEnableCrsTransform()

void QgsLayerTreeMapCanvasBridge::setAutoEnableCrsTransform ( bool  enabled)
inline

if enabled, will automatically turn on on-the-fly reprojection of layers if a layer with different source CRS is added

Definition at line 69 of file qgslayertreemapcanvasbridge.h.

◆ setAutoSetupOnFirstLayer()

void QgsLayerTreeMapCanvasBridge::setAutoSetupOnFirstLayer ( bool  enabled)
inline

if enabled, will automatically set full canvas extent and destination CRS + map units when first layer(s) are added

Definition at line 64 of file qgslayertreemapcanvasbridge.h.

◆ setCanvasLayers [1/2]

void QgsLayerTreeMapCanvasBridge::setCanvasLayers ( )
slot

force update of canvas layers from the layer tree. Normally this should not be needed to be called.

Definition at line 116 of file qgslayertreemapcanvasbridge.cpp.

◆ setCanvasLayers() [2/2]

void QgsLayerTreeMapCanvasBridge::setCanvasLayers ( QgsLayerTreeNode node,
QList< QgsMapCanvasLayer > &  layers 
)
protected

Definition at line 248 of file qgslayertreemapcanvasbridge.cpp.

◆ setCustomLayerOrder

void QgsLayerTreeMapCanvasBridge::setCustomLayerOrder ( const QStringList order)
slot

Definition at line 79 of file qgslayertreemapcanvasbridge.cpp.

◆ setHasCustomLayerOrder

void QgsLayerTreeMapCanvasBridge::setHasCustomLayerOrder ( bool  state)
slot

Definition at line 68 of file qgslayertreemapcanvasbridge.cpp.

◆ writeProject

void QgsLayerTreeMapCanvasBridge::writeProject ( QDomDocument doc)
slot

Definition at line 231 of file qgslayertreemapcanvasbridge.cpp.

Member Data Documentation

◆ mAutoEnableCrsTransform

bool QgsLayerTreeMapCanvasBridge::mAutoEnableCrsTransform
protected

Definition at line 110 of file qgslayertreemapcanvasbridge.h.

◆ mAutoSetupOnFirstLayer

bool QgsLayerTreeMapCanvasBridge::mAutoSetupOnFirstLayer
protected

Definition at line 109 of file qgslayertreemapcanvasbridge.h.

◆ mCanvas

QgsMapCanvas* QgsLayerTreeMapCanvasBridge::mCanvas
protected

Definition at line 102 of file qgslayertreemapcanvasbridge.h.

◆ mCustomLayerOrder

QStringList QgsLayerTreeMapCanvasBridge::mCustomLayerOrder
protected

Definition at line 107 of file qgslayertreemapcanvasbridge.h.

◆ mFirstCRS

QgsCoordinateReferenceSystem QgsLayerTreeMapCanvasBridge::mFirstCRS
protected

Definition at line 114 of file qgslayertreemapcanvasbridge.h.

◆ mHasCustomLayerOrder

bool QgsLayerTreeMapCanvasBridge::mHasCustomLayerOrder
protected

Definition at line 106 of file qgslayertreemapcanvasbridge.h.

◆ mHasFirstLayer

bool QgsLayerTreeMapCanvasBridge::mHasFirstLayer
protected

Definition at line 112 of file qgslayertreemapcanvasbridge.h.

◆ mLastLayerCount

bool QgsLayerTreeMapCanvasBridge::mLastLayerCount
protected

Definition at line 113 of file qgslayertreemapcanvasbridge.h.

◆ mPendingCanvasUpdate

bool QgsLayerTreeMapCanvasBridge::mPendingCanvasUpdate
protected

Definition at line 104 of file qgslayertreemapcanvasbridge.h.

◆ mRoot

QgsLayerTreeGroup* QgsLayerTreeMapCanvasBridge::mRoot
protected

Definition at line 101 of file qgslayertreemapcanvasbridge.h.


The documentation for this class was generated from the following files: