QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgslayertreefiltersettings.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayertreefiltersettings.h
3 --------------------------------------
4 Date : March 2023
5 Copyright : (C) 2023 by Nyall Dawson
6 Email : nyall dot dawson 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 QGSLAYERTREEFILTERSETTINGS_H
17#define QGSLAYERTREEFILTERSETTINGS_H
18
19#include <memory>
20
21#include "qgis.h"
22#include "qgis_core.h"
24#include "qgsgeometry.h"
25#include "qgsmaplayer.h"
26
27#include <QMap>
28#include <QString>
29
30class QgsMapSettings;
31class QgsLayerTree;
33
41{
42 public:
43
47 explicit QgsLayerTreeFilterSettings( const QgsMapSettings &settings );
48
50
52
54
59
66 QMap<QString, QString> layerFilterExpressions() const;
67
73 void setLayerFilterExpressions( const QMap<QString, QString> &expressions );
74
79
87 QString layerFilterExpression( const QString &layerId ) const;
88
100
111 void setFilterPolygon( const QgsGeometry &polygon );
112
119
126
135 void addVisibleExtentForLayer( QgsMapLayer *layer, const QgsReferencedGeometry &polygon );
136
148
157 QList<QgsMapLayer *> layers() const;
158
159 private:
160
161 QMap<QString, QString> mLayerFilterExpressions;
162
163 std::unique_ptr<QgsMapSettings> mMapSettings;
164
165 QgsGeometry mFilterPolygon;
166
168
170
171 // geometry must be in layer CRS
172 QMap<QString, QVector< QgsGeometry > > mLayerExtents;
173
174};
175
176#endif // QGSLAYERTREEFILTERSETTINGS_H
QFlags< LayerTreeFilterFlag > LayerTreeFilterFlags
Layer tree filter flags.
Definition qgis.h:4545
A geometry is the spatial representation of a feature.
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.
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.
Namespace with helper functions for layer tree operations.
Base class for all map layer types.
Definition qgsmaplayer.h:80
Contains configuration for rendering maps.
A QgsGeometry with associated coordinate reference system.
QList< QgsWeakMapLayerPointer > QgsWeakMapLayerPointerList
A list of weak pointers to QgsMapLayers.