QGIS API Documentation 4.1.0-Master (60fea48833c)
Loading...
Searching...
No Matches
qgsvectortilebasiclabeling.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectortilebasiclabeling.h
3 --------------------------------------
4 Date : April 2020
5 Copyright : (C) 2020 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 QGSVECTORTILEBASICLABELING_H
17#define QGSVECTORTILEBASICLABELING_H
18
19
21
23
31{
32 public:
34 void setLabelSettings( const QgsPalLayerSettings &settings ) { mLabelSettings = settings; }
36 QgsPalLayerSettings labelSettings() const { return mLabelSettings; }
37
39 void setStyleName( const QString &name ) { mStyleName = name; }
41 QString styleName() const { return mStyleName; }
42
44 void setLayerName( const QString &name ) { mLayerName = name; }
46 QString layerName() const { return mLayerName; }
47
49 void setGeometryType( Qgis::GeometryType geomType ) { mGeometryType = geomType; }
51 Qgis::GeometryType geometryType() const { return mGeometryType; }
52
54 void setFilterExpression( const QString &expr ) { mExpression = expr; }
56 QString filterExpression() const { return mExpression; }
57
59 void setEnabled( bool enabled ) { mEnabled = enabled; }
61 bool isEnabled() const { return mEnabled; }
62
72 void setMinZoomLevel( int minZoom ) { mMinZoomLevel = minZoom; }
73
83 int minZoomLevel() const { return mMinZoomLevel; }
84
98 void setMaxZoomLevel( int maxZoom ) { mMaxZoomLevel = maxZoom; }
99
113 int maxZoomLevel() const { return mMaxZoomLevel; }
114
115
117 bool isActive( int zoomLevel ) const { return mEnabled && ( mMinZoomLevel == -1 || zoomLevel >= mMinZoomLevel ) && ( mMaxZoomLevel == -1 || zoomLevel <= mMaxZoomLevel ); }
118
120 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const;
122 void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
123
124 private:
125 QString mStyleName;
126 QString mLayerName;
128 bool mEnabled = true;
129 QString mExpression;
130 int mMinZoomLevel = -1;
131 int mMaxZoomLevel = -1;
132
133 QgsPalLayerSettings mLabelSettings;
134};
135
136
148{
149 public:
151
152 QString type() const override;
153 QgsVectorTileLabeling *clone() const override SIP_FACTORY;
155 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
156 void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
157
159 void setStyles( const QList<QgsVectorTileBasicLabelingStyle> &styles ) { mStyles = styles; }
161 QList<QgsVectorTileBasicLabelingStyle> styles() const { return mStyles; }
163 void setStyle( int index, const QgsVectorTileBasicLabelingStyle &style ) { mStyles[index] = style; }
165 QgsVectorTileBasicLabelingStyle style( int index ) const { return mStyles[index]; }
166
167 private:
169 QList<QgsVectorTileBasicLabelingStyle> mStyles;
170};
171
172
173#ifndef SIP_RUN
174
182{
183 public:
185 QgsVectorTileBasicLabelProvider( QgsVectorTileLayer *layer, const QList<QgsVectorTileBasicLabelingStyle> &styles );
186
187 QList<QgsAbstractLabelProvider *> subProviders() override;
188 bool prepare( QgsRenderContext &context, QSet<QString> &attributeNames ) override;
189
190 // virtual functions from QgsVectorTileLabelProvider
191 void registerTileFeatures( const QgsVectorTileRendererData &tile, QgsRenderContext &context ) override;
192 QMap<QString, QSet<QString> > usedAttributes( const QgsRenderContext &context, int tileZoom ) const override;
193 QSet< QString > requiredLayers( QgsRenderContext &context, int tileZoom ) const override;
194 void setFields( const QMap<QString, QgsFields> &perLayerFields ) override;
195
196 private:
197 QList<QgsVectorTileBasicLabelingStyle> mStyles;
198
200 QList<QgsVectorLayerLabelProvider *> mSubProviders;
201
202 public:
204 QMap<QString, QgsFields> mPerLayerFields;
205};
206
207#endif
208
209
210#endif // QGSVECTORTILEBASICLABELING_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:379
@ Unknown
Unknown types.
Definition qgis.h:383
QgsMapLayer * layer() const
Returns the associated layer, or nullptr if no layer is associated with the provider.
Contains settings for how a map layer will be labeled.
A container for the context for various read/write operations on objects.
Contains information about the context of a rendering operation.
QMap< QString, QgsFields > mPerLayerFields
Names of required fields for each sub-layer (only valid between startRender/stopRender calls).
bool prepare(QgsRenderContext &context, QSet< QString > &attributeNames) override
Prepare for registration of features.
void setFields(const QMap< QString, QgsFields > &perLayerFields) override
Sets fields for each sub-layer.
QgsVectorTileBasicLabelProvider(QgsVectorTileLayer *layer, const QList< QgsVectorTileBasicLabelingStyle > &styles)
Constructs a label provider for the given vector tile layer and using styling from QgsVectorTileBasic...
void registerTileFeatures(const QgsVectorTileRendererData &tile, QgsRenderContext &context) override
Registers label features for given tile to the labeling engine.
QMap< QString, QSet< QString > > usedAttributes(const QgsRenderContext &context, int tileZoom) const override
Returns field names for each sub-layer that are required for labeling.
QSet< QString > requiredLayers(QgsRenderContext &context, int tileZoom) const override
Returns a list of the layers required for labeling.
QList< QgsAbstractLabelProvider * > subProviders() override
Returns list of child providers - useful if the provider needs to put labels into more layers with di...
Configuration of a single style within QgsVectorTileBasicLabeling.
QgsPalLayerSettings labelSettings() const
Returns labeling configuration of this style.
QString layerName() const
Returns name of the sub-layer to render (empty layer means that all layers match).
void setLayerName(const QString &name)
Sets name of the sub-layer to render (empty layer means that all layers match).
QString filterExpression() const
Returns filter expression (empty filter means that all features match).
void setMinZoomLevel(int minZoom)
Sets minimum zoom level index (negative number means no limit).
int maxZoomLevel() const
Returns the maximum zoom level index (negative number means no limit).
void setFilterExpression(const QString &expr)
Sets filter expression (empty filter means that all features match).
int minZoomLevel() const
Returns the minimum zoom level index (negative number means no limit).
void setMaxZoomLevel(int maxZoom)
Sets maximum zoom level index (negative number means no limit).
void setStyleName(const QString &name)
Sets human readable name of this style.
void setGeometryType(Qgis::GeometryType geomType)
Sets type of the geometry that will be used (point / line / polygon).
bool isActive(int zoomLevel) const
Returns whether the style is active at given zoom level (also checks "enabled" flag).
void setLabelSettings(const QgsPalLayerSettings &settings)
Sets labeling configuration of this style.
Qgis::GeometryType geometryType() const
Returns type of the geometry that will be used (point / line / polygon).
void setEnabled(bool enabled)
Sets whether this style is enabled (used for rendering).
QString styleName() const
Returns human readable name of this style.
bool isEnabled() const
Returns whether this style is enabled (used for rendering).
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads labeling properties from given XML element.
QgsVectorTileLabelProvider * provider(QgsVectorTileLayer *layer) const override SIP_SKIP
Factory for label provider implementation.
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
Writes labeling properties to given XML element.
QgsVectorTileLabeling * clone() const override SIP_FACTORY
Returns a new copy of the object.
QList< QgsVectorTileBasicLabelingStyle > styles() const
Returns list of styles of the renderer.
void setStyles(const QList< QgsVectorTileBasicLabelingStyle > &styles)
Sets list of styles of the renderer.
void setStyle(int index, const QgsVectorTileBasicLabelingStyle &style)
Updates style definition at the paricular index of the list (the index must be in interval [0,...
QgsVectorTileBasicLabelingStyle style(int index) const
Returns style definition at the particular index.
QString type() const override
Unique type string of the labeling configuration implementation.
Internal base class for implementation of label providers for vector tile labeling.
QgsVectorTileLabelProvider(QgsVectorTileLayer *layer)
Constructs base label provider class for the given vector tile layer.
Base class for labeling configuration classes for vector tile layers.
Implements a map layer that is dedicated to rendering of vector tiles.
Contains decoded features of a single vector tile and any other data necessary for rendering of it.
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_FACTORY
Definition qgis_sip.h:83