28 mLayers = _qgis_listRawToQPointer( mMapSettings->layers(
true ) );
34 : mLayerFilterExpressions( other.mLayerFilterExpressions )
35 , mMapSettings( other.mMapSettings ? new
QgsMapSettings( *other.mMapSettings ) : nullptr )
36 , mFilterPolygon( other.mFilterPolygon )
37 , mFlags( other.mFlags )
38 , mLayers( other.mLayers )
39 , mLayerExtents( other.mLayerExtents )
46 mLayerFilterExpressions = other.mLayerFilterExpressions;
47 mMapSettings.reset( other.mMapSettings ?
new QgsMapSettings( *other.mMapSettings ) : nullptr );
48 mFilterPolygon = other.mFilterPolygon;
49 mFlags = other.mFlags;
50 mLayers = other.mLayers;
51 mLayerExtents = other.mLayerExtents;
57 return *mMapSettings.get();
62 return mLayerFilterExpressions;
67 mLayerFilterExpressions = expressions;
72 QMap<QString, QString> legendFilterExpressions;
78 if ( enabled && !legendFilterExpression.isEmpty() )
80 legendFilterExpressions[nodeLayer->layerId()] = legendFilterExpression;
83 mLayerFilterExpressions = legendFilterExpressions;
88 return mLayerFilterExpressions.value( layerId );
93 return mFilterPolygon;
98 mFilterPolygon = newFilterPolygon;
117 transformedPoly.
transform( polygonToLayerTransform );
118 mLayerExtents[ layer->
id() ].append( transformedPoly );
122 QgsDebugError( QStringLiteral(
"Error transforming polygon to layer CRS for legend filtering" ) );
124 if ( !mLayers.contains( layer ) )
130 QVector< QgsGeometry > parts;
132 if ( mMapSettings->layerIds(
true ).contains( layer->
id() ) )
149 QgsDebugError( QStringLiteral(
"Error transforming map extent to layer CRS for legend filtering" ) );
153 auto additionalIt = mLayerExtents.constFind( layer->
id() );
154 if ( additionalIt != mLayerExtents.constEnd() )
156 parts.append( additionalIt.value() );
159 if ( !parts.empty() )
167 return _qgis_listQPointerToRaw( mLayers );
@ Reverse
Reverse/inverse transform (from destination to source)
Custom exception class for Coordinate Reference System related exceptions.
A geometry is the spatial representation of a feature.
static QgsGeometry fromQPolygonF(const QPolygonF &polygon)
Construct geometry from a QPolygonF.
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
static QgsGeometry unaryUnion(const QVector< QgsGeometry > &geometries, const QgsGeometryParameters ¶meters=QgsGeometryParameters())
Compute the unary union on a list of geometries.
Contains settings relating to filtering the contents of QgsLayerTreeModel and views.
QgsMapSettings & mapSettings()
Returns the map settings used to filter the legend content.
QgsGeometry filterPolygon() const
Returns the optional filter polygon, used when testing for symbols to show in the legend.
void addVisibleExtentForLayer(QgsMapLayer *layer, const QgsReferencedGeometry &polygon)
Adds a visible extent polygon for a map layer.
QString layerFilterExpression(const QString &layerId) const
Returns the filter expression to use for the layer with the specified layerId, or an empty string if ...
QList< QgsMapLayer * > layers() const
Returns the layers which should be shown in the legend.
Qgis::LayerTreeFilterFlags flags() const
Returns the filter flags.
QMap< QString, QString > layerFilterExpressions() const
Returns the map of layer IDs to legend filter expression.
~QgsLayerTreeFilterSettings()
void setFilterPolygon(const QgsGeometry &polygon)
Sets the optional filter polygon, used when testing for symbols to show in the legend.
void setLayerFilterExpressionsFromLayerTree(QgsLayerTree *tree)
Sets layer filter expressions using a layer tree.
QgsLayerTreeFilterSettings(const QgsMapSettings &settings)
Constructor for QgsLayerTreeFilterSettings, using the specified map settings.
void setFlags(Qgis::LayerTreeFilterFlags flags)
Sets the filter flags.
void setLayerFilterExpressions(const QMap< QString, QString > &expressions)
Sets the map of layer IDs to legend filter expression.
QgsLayerTreeFilterSettings & operator=(const QgsLayerTreeFilterSettings &other)
QgsGeometry combinedVisibleExtentForLayer(const QgsMapLayer *layer)
Returns the combined visible extent for a layer.
QList< QgsLayerTreeLayer * > findLayers() const
Find all layer nodes.
Layer tree node points to a map layer.
static QString legendFilterByExpression(const QgsLayerTreeLayer &layer, bool *enabled=nullptr)
Returns the expression filter of a legend layer.
Namespace with helper functions for layer tree operations.
Base class for all map layer types.
QgsCoordinateReferenceSystem crs
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
The QgsMapSettings class contains configuration for rendering of the map.
QgsCoordinateReferenceSystem crs() const
Returns the associated coordinate reference system, or an invalid CRS if no reference system is set.
A QgsGeometry with associated coordinate reference system.
#define QgsDebugError(str)