QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
qgspointdistancerenderer.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgspointdistancerenderer.cpp
3 ----------------------------
4 begin : January 26, 2010
5 copyright : (C) 2010 by Marco Hugentobler
6 email : marco at hugis dot net
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
19
20#include <cmath>
21
23#include "qgsgeometry.h"
24#include "qgslogger.h"
25#include "qgsmarkersymbol.h"
26#include "qgsmultipoint.h"
27#include "qgssldexportcontext.h"
28#include "qgsspatialindex.h"
30#include "qgssymbollayerutils.h"
31
32#include <QDomElement>
33#include <QPainter>
34
41
42void QgsPointDistanceRenderer::toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const
43{
44 QgsSldExportContext context;
45 context.setExtraProperties( props );
46 toSld( doc, element, context );
47}
48
49bool QgsPointDistanceRenderer::toSld( QDomDocument &doc, QDomElement &element, QgsSldExportContext &context ) const
50{
51 return mRenderer->toSld( doc, element, context );
52}
53
54bool QgsPointDistanceRenderer::renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker )
55{
56 Q_UNUSED( drawVertexMarker )
57 Q_UNUSED( context )
58 Q_UNUSED( layer )
59
60 /*
61 * IMPORTANT: This algorithm is ported to Python in the processing "Points Displacement" algorithm.
62 * Please port any changes/improvements to that algorithm too!
63 */
64
65 //check if there is already a point at that position
66 if ( !feature.hasGeometry() )
67 return false;
68
69 QgsMarkerSymbol *symbol = firstSymbolForFeature( feature, context );
70
71 //if the feature has no symbol (e.g., no matching rule in a rule-based renderer), skip it
72 if ( !symbol )
73 return false;
74
75 //point position in screen coords
76 QgsGeometry geom = feature.geometry();
77 const Qgis::WkbType geomType = geom.wkbType();
79 {
80 //can only render point type
81 return false;
82 }
83
84 QString label;
85 if ( mDrawLabels )
86 {
87 label = getLabel( feature );
88 }
89
90 const QgsCoordinateTransform xform = context.coordinateTransform();
91 QgsFeature transformedFeature = feature;
92 if ( xform.isValid() )
93 {
94 geom.transform( xform );
95 transformedFeature.setGeometry( geom );
96 }
97
98 const double searchDistance = context.convertToMapUnits( mTolerance, mToleranceUnit, mToleranceMapUnitScale );
99
100 const QgsGeometry transformedGeometry = transformedFeature.geometry();
101 for ( auto partIt = transformedGeometry.const_parts_begin(); partIt != transformedGeometry.const_parts_end(); ++partIt )
102 {
103 const QgsPoint *point = qgsgeometry_cast< const QgsPoint * >( *partIt );
104 // create a new feature which is JUST this point, no other parts from the multi-point
105 QgsFeature pointFeature = transformedFeature;
106 pointFeature.setGeometry( QgsGeometry( point->clone() ) );
107 const QList<QgsFeatureId> intersectList = mSpatialIndex->intersects( searchRect( point, searchDistance ) );
108 if ( intersectList.empty() )
109 {
110 mSpatialIndex->addFeature( pointFeature );
111 // create new group
112 ClusteredGroup newGroup;
113 newGroup << GroupedFeature( pointFeature, symbol->clone(), selected, label );
114 mClusteredGroups.push_back( newGroup );
115 // add to group index
116 mGroupIndex.insert( pointFeature.id(), mClusteredGroups.count() - 1 );
117 mGroupLocations.insert( pointFeature.id(), QgsPointXY( *point ) );
118 }
119 else
120 {
121 // find group with closest location to this point (may be more than one within search tolerance)
122 QgsFeatureId minDistFeatureId = intersectList.at( 0 );
123 double minDist = mGroupLocations.value( minDistFeatureId ).distance( point->x(), point->y() );
124 for ( int i = 1; i < intersectList.count(); ++i )
125 {
126 const QgsFeatureId candidateId = intersectList.at( i );
127 const double newDist = mGroupLocations.value( candidateId ).distance( point->x(), point->y() );
128 if ( newDist < minDist )
129 {
130 minDist = newDist;
131 minDistFeatureId = candidateId;
132 }
133 }
134
135 const int groupIdx = mGroupIndex[minDistFeatureId];
136 ClusteredGroup &group = mClusteredGroups[groupIdx];
137
138 // calculate new centroid of group
139 const QgsPointXY oldCenter = mGroupLocations.value( minDistFeatureId );
140 mGroupLocations[minDistFeatureId] = QgsPointXY( ( oldCenter.x() * group.size() + point->x() ) / ( group.size() + 1.0 ), ( oldCenter.y() * group.size() + point->y() ) / ( group.size() + 1.0 ) );
141
142 // add to a group
143 group << GroupedFeature( pointFeature, symbol->clone(), selected, label );
144 // add to group index
145 mGroupIndex.insert( pointFeature.id(), groupIdx );
146 }
147 }
148
149 return true;
150}
151
152void QgsPointDistanceRenderer::drawGroup( const ClusteredGroup &group, QgsRenderContext &context ) const
153{
154 //calculate centroid of all points, this will be center of group
155 QgsMultiPoint *groupMultiPoint = new QgsMultiPoint();
156 const auto constGroup = group;
157 for ( const GroupedFeature &f : constGroup )
158 {
159 groupMultiPoint->addGeometry( f.feature.geometry().constGet()->clone() );
160 }
161 const QgsGeometry groupGeom( groupMultiPoint );
162 const QgsGeometry centroid = groupGeom.centroid();
163 QPointF pt = centroid.asQPointF();
164 context.mapToPixel().transformInPlace( pt.rx(), pt.ry() );
165
166 const QgsExpressionContextScopePopper scopePopper( context.expressionContext(), createGroupScope( group ) );
167 drawGroup( pt, context, group );
168}
169
174
179
181{
182 if ( !mRenderer )
183 return;
184
185 mRenderer->setLegendSymbolItem( key, symbol );
186}
187
189{
190 if ( !mRenderer )
191 return false;
192
193 return mRenderer->legendSymbolItemsCheckable();
194}
195
197{
198 if ( !mRenderer )
199 return false;
200
201 return mRenderer->legendSymbolItemChecked( key );
202}
203
204void QgsPointDistanceRenderer::checkLegendSymbolItem( const QString &key, bool state )
205{
206 if ( !mRenderer )
207 return;
208
209 mRenderer->checkLegendSymbolItem( key, state );
210}
211
213{
214 if ( !mRenderer )
215 return QgsFeatureRenderer::filter( fields );
216 else
217 return mRenderer->filter( fields );
218}
219
221{
222 if ( mRenderer )
223 if ( !mRenderer->accept( visitor ) )
224 return false;
225
226 return true;
227}
228
230{
231 QSet<QString> attributeList;
232 if ( !mLabelAttributeName.isEmpty() )
233 {
234 attributeList.insert( mLabelAttributeName );
235 }
236 if ( mRenderer )
237 {
238 attributeList += mRenderer->usedAttributes( context );
239 }
240 return attributeList;
241}
242
244{
245 return mRenderer ? mRenderer->filterNeedsGeometry() : false;
246}
247
249{
250 if ( !mRenderer )
251 {
252 return Capabilities();
253 }
254 return mRenderer->capabilities();
255}
256
258{
259 if ( !mRenderer )
260 {
261 return QgsSymbolList();
262 }
263 return mRenderer->symbols( context );
264}
265
267{
268 if ( !mRenderer )
269 {
270 return nullptr;
271 }
272 return mRenderer->symbolForFeature( feature, context );
273}
274
276{
277 if ( !mRenderer )
278 return nullptr;
279 return mRenderer->originalSymbolForFeature( feature, context );
280}
281
283{
284 if ( !mRenderer )
285 {
286 return QgsSymbolList();
287 }
288 return mRenderer->symbolsForFeature( feature, context );
289}
290
292{
293 if ( !mRenderer )
294 return QgsSymbolList();
295 return mRenderer->originalSymbolsForFeature( feature, context );
296}
297
298QSet< QString > QgsPointDistanceRenderer::legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
299{
300 if ( !mRenderer )
301 return QSet< QString >() << QString();
302 return mRenderer->legendKeysForFeature( feature, context );
303}
304
305QString QgsPointDistanceRenderer::legendKeyToExpression( const QString &key, QgsVectorLayer *layer, bool &ok ) const
306{
307 ok = false;
308 if ( !mRenderer )
309 return QString();
310 return mRenderer->legendKeyToExpression( key, layer, ok );
311}
312
314{
315 if ( !mRenderer )
316 {
317 return false;
318 }
319 return mRenderer->willRenderFeature( feature, context );
320}
321
322
324{
325 QgsFeatureRenderer::startRender( context, fields );
326
327 mRenderer->startRender( context, fields );
328
329 mClusteredGroups.clear();
330 mGroupIndex.clear();
331 mGroupLocations.clear();
333
334 if ( mLabelAttributeName.isEmpty() )
335 {
336 mLabelIndex = -1;
337 }
338 else
339 {
341 }
342
343 if ( mMinLabelScale <= 0 || context.rendererScale() < mMinLabelScale )
344 {
345 mDrawLabels = true;
346 }
347 else
348 {
349 mDrawLabels = false;
350 }
351}
352
354{
356
357 //printInfoDisplacementGroups(); //just for debugging
358
359 if ( !context.renderingStopped() )
360 {
361 const auto constMClusteredGroups = mClusteredGroups;
362 for ( const ClusteredGroup &group : constMClusteredGroups )
363 {
364 drawGroup( group, context );
365 }
366 }
367
368 mClusteredGroups.clear();
369 mGroupIndex.clear();
370 mGroupLocations.clear();
371 delete mSpatialIndex;
372 mSpatialIndex = nullptr;
373
374 mRenderer->stopRender( context );
375}
376
378{
379 if ( mRenderer )
380 {
381 return mRenderer->legendSymbolItems();
382 }
383 return QgsLegendSymbolList();
384}
385
386QgsRectangle QgsPointDistanceRenderer::searchRect( const QgsPoint *p, double distance ) const
387{
388 return QgsRectangle( p->x() - distance, p->y() - distance, p->x() + distance, p->y() + distance );
389}
390
391void QgsPointDistanceRenderer::printGroupInfo() const
392{
393#ifdef QGISDEBUG
394 const int nGroups = mClusteredGroups.size();
395 QgsDebugMsgLevel( "number of displacement groups:" + QString::number( nGroups ), 3 );
396 for ( int i = 0; i < nGroups; ++i )
397 {
398 QgsDebugMsgLevel( "***************displacement group " + QString::number( i ), 3 );
399 const auto constAt = mClusteredGroups.at( i );
400 for ( const GroupedFeature &feature : constAt )
401 {
402 QgsDebugMsgLevel( FID_TO_STRING( feature.feature.id() ), 3 );
403 }
404 }
405#endif
406}
407
408QString QgsPointDistanceRenderer::getLabel( const QgsFeature &feature ) const
409{
410 QString attribute;
411 const QgsAttributes attrs = feature.attributes();
412 if ( mLabelIndex >= 0 && mLabelIndex < attrs.count() )
413 {
414 attribute = attrs.at( mLabelIndex ).toString();
415 }
416 return attribute;
417}
418
419void QgsPointDistanceRenderer::drawLabels( QPointF centerPoint, QgsSymbolRenderContext &context, const QList<QPointF> &labelShifts, const ClusteredGroup &group ) const
420{
421 QPainter *p = context.renderContext().painter();
422 if ( !p )
423 {
424 return;
425 }
426
427 const QPen labelPen( mLabelColor );
428 p->setPen( labelPen );
429
430 //scale font (for printing)
431 QFont pixelSizeFont = mLabelFont;
432
433 const double fontSizeInPixels = context.renderContext().convertToPainterUnits( mLabelFont.pointSizeF(), Qgis::RenderUnit::Points );
434 pixelSizeFont.setPixelSize( static_cast< int >( std::round( fontSizeInPixels ) ) );
435 QFont scaledFont = pixelSizeFont;
436 scaledFont.setPixelSize( pixelSizeFont.pixelSize() );
437 p->setFont( scaledFont );
438
439 const QFontMetricsF fontMetrics( pixelSizeFont );
440 QPointF currentLabelShift; //considers the signs to determine the label position
441
442 QList<QPointF>::const_iterator labelPosIt = labelShifts.constBegin();
443 ClusteredGroup::const_iterator groupIt = group.constBegin();
444
445 for ( ; labelPosIt != labelShifts.constEnd() && groupIt != group.constEnd(); ++labelPosIt, ++groupIt )
446 {
447 currentLabelShift = *labelPosIt;
448 if ( currentLabelShift.x() < 0 )
449 {
450 currentLabelShift.setX( currentLabelShift.x() - fontMetrics.horizontalAdvance( groupIt->label ) );
451 }
452 if ( currentLabelShift.y() > 0 )
453 {
454 currentLabelShift.setY( currentLabelShift.y() + fontMetrics.ascent() );
455 }
456
457 const QPointF drawingPoint( centerPoint + currentLabelShift );
458 const QgsScopedQPainterState painterState( p );
459 p->translate( drawingPoint.x(), drawingPoint.y() );
460 p->drawText( QPointF( 0, 0 ), groupIt->label );
461 }
462}
463
464QgsExpressionContextScope *QgsPointDistanceRenderer::createGroupScope( const ClusteredGroup &group ) const
465{
467 if ( group.size() > 1 )
468 {
469 //scan through symbols to check color, e.g., if all clustered symbols are same color
470 QColor groupColor;
471 ClusteredGroup::const_iterator groupIt = group.constBegin();
472 for ( ; groupIt != group.constEnd(); ++groupIt )
473 {
474 if ( !groupIt->symbol() )
475 continue;
476
477 if ( !groupColor.isValid() )
478 {
479 groupColor = groupIt->symbol()->color();
480 }
481 else
482 {
483 if ( groupColor != groupIt->symbol()->color() )
484 {
485 groupColor = QColor();
486 break;
487 }
488 }
489 }
490
491 if ( groupColor.isValid() )
492 {
493 clusterScope->addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_CLUSTER_COLOR, QgsSymbolLayerUtils::encodeColor( groupColor ), true ) );
494 }
495 else
496 {
497 //mixed colors
498 clusterScope->addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_CLUSTER_COLOR, QVariant(), true ) );
499 }
500
501 clusterScope->addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_CLUSTER_SIZE, group.size(), true ) );
502 }
503 if ( !group.empty() )
504 {
505 // data defined properties may require a feature in the expression context, so just use first feature in group
506 clusterScope->setFeature( group.at( 0 ).feature );
507 }
508 return clusterScope;
509}
510
511QgsMarkerSymbol *QgsPointDistanceRenderer::firstSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context )
512{
513 if ( !mRenderer )
514 {
515 return nullptr;
516 }
517
518 const QgsSymbolList symbolList = mRenderer->symbolsForFeature( feature, context );
519 if ( symbolList.isEmpty() )
520 {
521 return nullptr;
522 }
523
524 return dynamic_cast< QgsMarkerSymbol * >( symbolList.at( 0 ) );
525}
526
533
@ Point
Points.
Definition qgis.h:380
@ Points
Points (e.g., for font sizes).
Definition qgis.h:5345
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:294
Handles coordinate transforms between two coordinate systems.
bool isValid() const
Returns true if the coordinate transform is valid, ie both the source and destination CRS have been s...
Single scope for storing variables and functions for use within a QgsExpressionContext.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the scope.
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
static const QString EXPR_CLUSTER_SIZE
Inbuilt variable name for cluster size variable.
static const QString EXPR_CLUSTER_COLOR
Inbuilt variable name for cluster color variable.
virtual QString filter(const QgsFields &fields=QgsFields())
If a renderer does not require all the features this method may be overridden and return an expressio...
QgsFeatureRenderer(const QString &type)
static QgsFeatureRenderer * defaultRenderer(Qgis::GeometryType geomType)
Returns a new renderer - used by default in vector layers.
virtual void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
QFlags< Capability > Capabilities
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:60
QgsAttributes attributes
Definition qgsfeature.h:69
QgsFeatureId id
Definition qgsfeature.h:68
QgsGeometry geometry
Definition qgsfeature.h:71
bool hasGeometry() const
Returns true if the feature has an associated geometry.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
Container of fields for a vector layer.
Definition qgsfields.h:46
Q_INVOKABLE int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
A geometry is the spatial representation of a feature.
QgsAbstractGeometry::const_part_iterator const_parts_begin() const
Returns STL-style const iterator pointing to the first part of the geometry.
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.
QPointF asQPointF() const
Returns contents of the geometry as a QPointF if wkbType is WKBPoint, otherwise returns a null QPoint...
QgsAbstractGeometry::const_part_iterator const_parts_end() const
Returns STL-style iterator pointing to the imaginary part after the last part of the geometry.
Qgis::WkbType wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.).
void transformInPlace(double &x, double &y) const
Transforms map coordinates to device coordinates.
A marker symbol type, for rendering Point and MultiPoint geometries.
QgsMarkerSymbol * clone() const override
Returns a deep copy of this symbol.
Multi point geometry collection.
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
QMap< QgsFeatureId, QgsPointXY > mGroupLocations
Mapping of feature ID to approximate group location.
double mMinLabelScale
Maximum scale denominator for label display. A zero value indicates no scale limitation.
int mLabelIndex
Label attribute index (or -1 if none). This index is not stored, it is requested in the startRender()...
bool legendSymbolItemChecked(const QString &key) override
Returns true if the legend symbology item with the specified key is checked.
QgsSpatialIndex * mSpatialIndex
Spatial index for fast lookup of nearby points.
QgsSymbolList symbols(QgsRenderContext &context) const override
Returns list of symbols used by the renderer.
QColor mLabelColor
Label text color.
QgsMapUnitScale mToleranceMapUnitScale
Map unit scale for distance tolerance.
QString filter(const QgsFields &fields=QgsFields()) override
If a renderer does not require all the features this method may be overridden and return an expressio...
QList< ClusteredGroup > mClusteredGroups
Groups of features that are considered clustered together.
QMap< QgsFeatureId, int > mGroupIndex
Mapping of feature ID to the feature's group index.
Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props=QVariantMap()) const override
Used from subclasses to create SLD Rule elements following SLD v1.1 specs.
QgsPointDistanceRenderer(const QString &rendererName, const QString &labelAttributeName=QString())
Constructor for QgsPointDistanceRenderer.
void drawLabels(QPointF centerPoint, QgsSymbolRenderContext &context, const QList< QPointF > &labelShifts, const ClusteredGroup &group) const
Renders the labels for a group.
bool renderFeature(const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false) override
Render a feature using this renderer in the given context.
void stopRender(QgsRenderContext &context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.
QString legendKeyToExpression(const QString &key, QgsVectorLayer *layer, bool &ok) const override
Attempts to convert the specified legend rule key to a QGIS expression matching the features displaye...
QgsSymbol * symbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
To be overridden.
QgsLegendSymbolList legendSymbolItems() const override
Returns a list of symbology items for the legend.
QString labelAttributeName() const
Returns the attribute name used for labeling points, or an empty string if no labeling will be done b...
bool legendSymbolItemsCheckable() const override
Returns true if symbology items in legend are checkable.
QgsSymbolList originalSymbolsForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbol...
void startRender(QgsRenderContext &context, const QgsFields &fields) override
Must be called when a new render cycle is started.
void setEmbeddedRenderer(QgsFeatureRenderer *r) override
Sets an embedded renderer (subrenderer) for this feature renderer.
QgsFeatureRenderer::Capabilities capabilities() override
Returns details about internals of this renderer.
const QgsFeatureRenderer * embeddedRenderer() const override
Returns the current embedded renderer (subrenderer) for this feature renderer.
QString mLabelAttributeName
Attribute name for labeling. An empty string indicates that no labels should be rendered.
void checkLegendSymbolItem(const QString &key, bool state) override
Sets whether the legend symbology item with the specified ley should be checked.
QgsSymbolList symbolsForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
Returns list of symbols used for rendering the feature.
double mTolerance
Distance tolerance. Points that are closer together than this distance are considered clustered.
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns a list of attributes required by this renderer.
bool mDrawLabels
Whether labels should be drawn for points. This is set internally from startRender() depending on sca...
std::unique_ptr< QgsFeatureRenderer > mRenderer
Embedded base renderer. This can be used for rendering individual, isolated points.
QgsSymbol * originalSymbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
Returns symbol for feature.
void setLegendSymbolItem(const QString &key, QgsSymbol *symbol) override
Sets the symbol to be used for a legend symbol item.
QList< QgsPointDistanceRenderer::GroupedFeature > ClusteredGroup
A group of clustered points (ie features within the distance tolerance).
Qgis::RenderUnit mToleranceUnit
Unit for distance tolerance.
bool willRenderFeature(const QgsFeature &feature, QgsRenderContext &context) const override
Returns whether the renderer will render a feature or not.
bool filterNeedsGeometry() const override
Returns true if this renderer requires the geometry to apply the filter.
QSet< QString > legendKeysForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
Returns legend keys matching a specified feature.
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
Represents a 2D point.
Definition qgspointxy.h:62
double y
Definition qgspointxy.h:66
double x
Definition qgspointxy.h:65
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:53
QgsPoint * clone() const override
Clones the geometry by performing a deep copy.
Definition qgspoint.cpp:138
double x
Definition qgspoint.h:56
double y
Definition qgspoint.h:57
A rectangle specified with double values.
Contains information about the context of a rendering operation.
double convertToMapUnits(double size, Qgis::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to map units.
double convertToPainterUnits(double size, Qgis::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
QPainter * painter()
Returns the destination QPainter for the render operation.
double rendererScale() const
Returns the renderer map scale.
QgsExpressionContext & expressionContext()
Gets the expression context.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
bool renderingStopped() const
Returns true if the rendering operation has been stopped and any ongoing rendering should be canceled...
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
Scoped object for saving and restoring a QPainter object's state.
Holds SLD export options and other information related to SLD export of a QGIS layer style.
void setExtraProperties(const QVariantMap &properties)
Sets the open ended set of properties that can drive/inform the SLD encoding.
A spatial index for QgsFeature objects.
An interface for classes which can visit style entity (e.g.
static QString encodeColor(const QColor &color)
Encapsulates the context in which a symbol is being rendered.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
Abstract base class for all rendered symbols.
Definition qgssymbol.h:227
Represents a vector layer which manages a vector based dataset.
static Qgis::GeometryType geometryType(Qgis::WkbType type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
T qgsgeometry_cast(QgsAbstractGeometry *geom)
#define FID_TO_STRING(fid)
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
QList< QgsLegendSymbolItem > QgsLegendSymbolList
#define QgsDebugMsgLevel(str, level)
Definition qgslogger.h:63
QList< QgsSymbol * > QgsSymbolList
Definition qgsrenderer.h:51
Contains properties for a feature within a clustered group.
GroupedFeature(const QgsFeature &feature, QgsMarkerSymbol *symbol, bool isSelected, const QString &label=QString())
Constructor for GroupedFeature.
bool isSelected
True if feature is selected and should be rendered in a selected state.
QgsMarkerSymbol * symbol() const
Base symbol for rendering feature.