QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgsvectortilebasicrenderer.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectortilebasicrenderer.h
3 --------------------------------------
4 Date : March 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 QGSVECTORTILEBASICRENDERER_H
17#define QGSVECTORTILEBASICRENDERER_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21
23
24class QgsLineSymbol;
25class QgsFillSymbol;
26class QgsMarkerSymbol;
27
28class QgsSymbol;
29
48{
49 public:
51 QgsVectorTileBasicRendererStyle( const QString &stName = QString(), const QString &laName = QString(), Qgis::GeometryType geomType = Qgis::GeometryType::Unknown );
56
58 void setStyleName( const QString &name ) { mStyleName = name; }
60 QString styleName() const { return mStyleName; }
61
63 void setLayerName( const QString &name ) { mLayerName = name; }
65 QString layerName() const { return mLayerName; }
66
68 void setGeometryType( Qgis::GeometryType geomType ) { mGeometryType = geomType; }
70 Qgis::GeometryType geometryType() const { return mGeometryType; }
71
73 void setFilterExpression( const QString &expr ) { mExpression = expr; }
75 QString filterExpression() const { return mExpression; }
76
78 void setSymbol( QgsSymbol *sym SIP_TRANSFER );
80 QgsSymbol *symbol() const { return mSymbol.get(); }
81
83 void setEnabled( bool enabled ) { mEnabled = enabled; }
85 bool isEnabled() const { return mEnabled; }
86
96 void setMinZoomLevel( int minZoom ) { mMinZoomLevel = minZoom; }
97
107 int minZoomLevel() const { return mMinZoomLevel; }
108
122 void setMaxZoomLevel( int maxZoom ) { mMaxZoomLevel = maxZoom; }
123
137 int maxZoomLevel() const { return mMaxZoomLevel; }
138
140 bool isActive( int zoomLevel ) const
141 {
142 return mEnabled && ( mMinZoomLevel == -1 || zoomLevel >= mMinZoomLevel ) && ( mMaxZoomLevel == -1 || zoomLevel <= mMaxZoomLevel );
143 }
144
146 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const;
148 void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
149
150 private:
151 QString mStyleName;
152 QString mLayerName;
153 Qgis::GeometryType mGeometryType;
154 std::unique_ptr<QgsSymbol> mSymbol;
155 bool mEnabled = true;
156 QString mExpression;
157 int mMinZoomLevel = -1;
158 int mMaxZoomLevel = -1;
159};
160
161
170{
171 public:
174
175 QString type() const override;
176 QgsVectorTileBasicRenderer *clone() const override SIP_FACTORY;
177 void startRender( QgsRenderContext &context, int tileZoom, const QgsTileRange &tileRange ) override;
178 QMap<QString, QSet<QString> > usedAttributes( const QgsRenderContext & ) override SIP_SKIP;
179 QSet< QString > requiredLayers( QgsRenderContext &context, int tileZoom ) const override;
180 void stopRender( QgsRenderContext &context ) override;
181 void renderBackground( QgsRenderContext &context ) override;
182 void renderTile( const QgsVectorTileRendererData &tile, QgsRenderContext &context ) override;
183 void renderSelectedFeatures( const QList< QgsFeature > &selection, QgsRenderContext &context ) override;
184 bool willRenderFeature( const QgsFeature &feature, int tileZoom, const QString &layerName, QgsRenderContext &context ) override;
185 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
186 void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
187
189 void setStyles( const QList<QgsVectorTileBasicRendererStyle> &styles );
191 QList<QgsVectorTileBasicRendererStyle> styles() const;
193 void setStyle( int index, const QgsVectorTileBasicRendererStyle &style ) { mStyles[index] = style; }
195 QgsVectorTileBasicRendererStyle style( int index ) const { return mStyles[index]; }
196
198 static QList<QgsVectorTileBasicRendererStyle> simpleStyle(
199 const QColor &polygonFillColor, const QColor &polygonStrokeColor, double polygonStrokeWidth,
200 const QColor &lineStrokeColor, double lineStrokeWidth,
201 const QColor &pointFillColor, const QColor &pointStrokeColor, double pointSize );
202
204 static QList<QgsVectorTileBasicRendererStyle> simpleStyleWithRandomColors();
205
206 private:
207 void setDefaultStyle();
208
209 private:
211 QList<QgsVectorTileBasicRendererStyle> mStyles;
212
213 // temporary bits
214
216 QMap<QString, QSet<QString> > mRequiredFields;
217
218};
219
220#endif // QGSVECTORTILEBASICRENDERER_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:255
@ Unknown
Unknown types.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:56
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
A line symbol type, for rendering LineString and MultiLineString geometries.
A marker symbol type, for rendering Point and MultiPoint geometries.
The class is used as a container of context for various read/write operations on other objects.
Contains information about the context of a rendering operation.
Abstract base class for all rendered symbols.
Definition qgssymbol.h:94
Range of tiles in a tile matrix to be rendered.
Definition qgstiles.h:97
Definition of map rendering of a subset of vector tile data.
void setEnabled(bool enabled)
Sets whether this style is enabled (used for rendering)
void setMinZoomLevel(int minZoom)
Sets minimum zoom level index (negative number means no limit).
void setLayerName(const QString &name)
Sets name of the sub-layer to render (empty layer means that all layers match)
Qgis::GeometryType geometryType() const
Returns type of the geometry that will be used (point / line / polygon)
QgsSymbol * symbol() const
Returns symbol for rendering.
QString filterExpression() const
Returns filter expression (empty filter means that all features match)
QString styleName() const
Returns human readable name of this style.
void setFilterExpression(const QString &expr)
Sets filter expression (empty filter means that all features match)
void setStyleName(const QString &name)
Sets human readable name of this style.
bool isEnabled() const
Returns whether this style is enabled (used for rendering)
void setMaxZoomLevel(int maxZoom)
Sets maximum zoom level index (negative number means no limit).
int minZoomLevel() const
Returns the minimum zoom level index (negative number means no limit).
int maxZoomLevel() const
Returns the maximum zoom level index (negative number means no limit).
QString layerName() const
Returns name of the sub-layer to render (empty layer means that all layers match)
bool isActive(int zoomLevel) const
Returns whether the style is active at given zoom level (also checks "enabled" flag)
void setGeometryType(Qgis::GeometryType geomType)
Sets type of the geometry that will be used (point / line / polygon)
The default vector tile renderer implementation.
void setStyle(int index, const QgsVectorTileBasicRendererStyle &style)
Updates style definition at the paricular index of the list (the index must be in interval [0,...
QgsVectorTileBasicRendererStyle style(int index) const
Returns style definition at the particular index.
Contains decoded features of a single vector tile and any other data necessary for rendering of it.
Abstract base class for all vector tile renderer implementations.
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:76