QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
qgshighlight.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgshighlight.cpp - widget to highlight features on the map
3 --------------------------------------
4 Date : 02-03-2011
5 Copyright : (C) 2011 by Juergen E. Fischer, norBIT GmbH
6 Email : jef at norbit dot de
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#include "qgshighlight.h"
17
20#include "qgsfillsymbollayer.h"
21#include "qgsgeometry.h"
22#include "qgslinesymbollayer.h"
23#include "qgsmapcanvas.h"
24#include "qgsmaplayer.h"
26#include "qgspointcloudlayer.h"
28#include "qgsrendercontext.h"
29#include "qgsrenderer.h"
30#include "qgssymbol.h"
31#include "qgssymbollayer.h"
32#include "qgsvectorlayer.h"
33
34#include <QImage>
35#include <QString>
36
37#include "moc_qgshighlight.cpp"
38
39using namespace Qt::StringLiterals;
40
41/* Few notes about highlighting (RB):
42 - The highlight fill must always be partially transparent because above highlighted layer
43 may be another layer which must remain partially visible.
44 - Because single highlight color does not work well with layers using similar layer color
45 there were considered various possibilities but no optimal solution was found.
46 What does not work:
47 - lighter/darker color: it would work more or less for fully opaque highlight, but
48 overlaying transparent lighter color over original has small visual effect.
49 - complemetary color: mixing transparent (128) complement color with original color
50 results in grey for all colors
51 - contrast line style/ fill pattern: impression is not highligh but just different style
52 - line buffer with contrast (or 2 contrast) color: the same as with patterns, no highlight impression
53 - fill with highlight or contrast color but opaque and using pattern
54 (e.g. Qt::Dense7Pattern): again no highlight impression
55*/
56
58 : QgsMapCanvasItem( mapCanvas )
59 , mGeometry( geom )
60 , mLayer( layer )
61
62{
63 init();
64}
65
67 : QgsMapCanvasItem( mapCanvas )
68 , mLayer( layer )
69 , mFeature( feature )
70{
71 init();
72}
73
74void QgsHighlight::init()
75{
76 mOriginalGeometry = mGeometry.isNull() ? mFeature.geometry() : mGeometry;
77 setColor( QColor( Qt::lightGray ) );
78
79 connect( mMapCanvas, &QgsMapCanvas::destinationCrsChanged, this, &QgsHighlight::updateTransformedGeometry );
80 updateTransformedGeometry();
81
82 if ( mGeometry.type() == Qgis::GeometryType::Point )
83 {
84 mRenderContext = createRenderContext();
85 }
86}
87
88void QgsHighlight::updateTransformedGeometry()
89{
90 const QgsCoordinateTransform ct = mMapCanvas->mapSettings().layerTransform( mLayer );
91
92 // we don't auto-transform if we are highlighting a feature -- the renderer will take care
93 // of that for us
94 if ( ct.isValid() && !mGeometry.isNull() )
95 {
96 // reset to original geometry and transform
97 mGeometry = mOriginalGeometry;
98 try
99 {
100 mGeometry.transform( ct );
101 }
102 catch ( QgsCsException & )
103 {
104 QgsDebugError( u"Could not transform highlight geometry to canvas CRS"_s );
105 }
106 }
107 updateRect();
108 update();
109}
110
112
113void QgsHighlight::setColor( const QColor &color )
114{
115 mColor = color;
116 mPen.setColor( color );
117 QColor fillColor( color.red(), color.green(), color.blue(), 63 );
118 mBrush.setColor( fillColor );
119 mBrush.setStyle( Qt::SolidPattern );
120}
121
123{
124 mFillColor = fillColor;
125 mBrush.setColor( fillColor );
126 mBrush.setStyle( Qt::SolidPattern );
127}
128
129std::unique_ptr<QgsFeatureRenderer> QgsHighlight::createRenderer( QgsRenderContext &context, const QColor &color, const QColor &fillColor )
130{
131 std::unique_ptr<QgsFeatureRenderer> renderer;
132 QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( mLayer );
133 if ( layer && layer->renderer() )
134 {
135 renderer.reset( layer->renderer()->clone() );
136 }
137 if ( renderer )
138 {
139 const QgsSymbolList symbols = renderer->symbols( context );
140 for ( QgsSymbol *symbol : symbols )
141 {
142 if ( !symbol )
143 continue;
144 setSymbol( symbol, context, color, fillColor );
145 }
146 }
147 return renderer;
148}
149
150void QgsHighlight::setSymbol( QgsSymbol *symbol, const QgsRenderContext &context, const QColor &color, const QColor &fillColor )
151{
152 if ( !symbol )
153 return;
154
155 for ( int i = symbol->symbolLayerCount() - 1; i >= 0; i-- )
156 {
157 QgsSymbolLayer *symbolLayer = symbol->symbolLayer( i );
158 if ( !symbolLayer )
159 continue;
160
161 if ( symbolLayer->subSymbol() )
162 {
163 setSymbol( symbolLayer->subSymbol(), context, color, fillColor );
164 }
165 else
166 {
167 symbolLayer->setColor( color ); // line symbology layers
168 symbolLayer->setStrokeColor( color ); // marker and fill symbology layers
169 symbolLayer->setFillColor( fillColor ); // marker and fill symbology layers
170
171 // Data defined widths overwrite what we set here (widths do not work with data defined)
172 QgsSimpleMarkerSymbolLayer *simpleMarker = dynamic_cast<QgsSimpleMarkerSymbolLayer *>( symbolLayer );
173 if ( simpleMarker )
174 {
175 simpleMarker->setStrokeWidth( getSymbolWidth( context, simpleMarker->strokeWidth(), simpleMarker->strokeWidthUnit() ) );
176 }
177 QgsSimpleLineSymbolLayer *simpleLine = dynamic_cast<QgsSimpleLineSymbolLayer *>( symbolLayer );
178 if ( simpleLine )
179 {
180 simpleLine->setWidth( getSymbolWidth( context, simpleLine->width(), simpleLine->widthUnit() ) );
181 }
182 QgsSimpleFillSymbolLayer *simpleFill = dynamic_cast<QgsSimpleFillSymbolLayer *>( symbolLayer );
183 if ( simpleFill )
184 {
185 simpleFill->setStrokeWidth( getSymbolWidth( context, simpleFill->strokeWidth(), simpleFill->outputUnit() ) );
186 }
187 symbolLayer->setDataDefinedProperty( QgsSymbolLayer::Property::FillColor, QgsProperty() );
189 }
190 }
191}
192
193double QgsHighlight::getSymbolWidth( const QgsRenderContext &context, double width, Qgis::RenderUnit unit )
194{
195 const double widthInPainterUnits = context.convertToPainterUnits( width, unit );
196 const double bufferInPainterUnits = context.convertToPainterUnits( mBuffer, Qgis::RenderUnit::Millimeters );
197 const double minWidthInPainterUnits = context.convertToPainterUnits( mMinWidth, Qgis::RenderUnit::Millimeters );
198
199 const double adjustedWidthInPainterUnits = std::max( widthInPainterUnits + 2 * bufferInPainterUnits, minWidthInPainterUnits );
200 return context.convertFromPainterUnits( adjustedWidthInPainterUnits, unit ) / mMapCanvas->magnificationFactor();
201}
202
204{
205 mWidth = width;
206 mPen.setWidth( width );
207}
208
209void QgsHighlight::paintPoint( QgsRenderContext &context, const QgsPoint *point, double size, Qgis::RenderUnit sizeUnit, PointSymbol symbol )
210{
211 if ( !point )
212 return;
213
214 const double radius = context.convertToPainterUnits( size, sizeUnit );
215 const double xMin = toCanvasCoordinates( *point ).x() - radius - pos().x();
216 const double yMin = toCanvasCoordinates( *point ).y() - radius - pos().y();
217
218 switch ( symbol )
219 {
220 case QgsHighlight::Square:
221 {
222 const double xMax = xMin + 2 * radius;
223 const double yMax = yMin + 2 * radius;
224 QPolygonF r( QVector<QPointF> { QPointF( xMin, yMin ), QPointF( xMax, yMin ), QPointF( xMax, yMax ), QPointF( xMin, yMax ), QPointF( xMin, yMin ) } );
225 context.painter()->drawPolygon( r );
226 break;
227 }
228
229 case QgsHighlight::Circle:
230 {
231 context.painter()->drawEllipse( QRectF( xMin, yMin, radius * 2, radius * 2 ) );
232 break;
233 }
234 }
235}
236
237void QgsHighlight::paintLine( QPainter *p, QgsPolylineXY line )
238{
239 QPolygonF polygon( line.size() );
240
241 for ( int i = 0; i < line.size(); i++ )
242 {
243 polygon[i] = toCanvasCoordinates( line[i] ) - pos();
244 }
245
246 p->drawPolyline( polygon );
247}
248
249void QgsHighlight::paintPolygon( QPainter *p, const QgsPolygonXY &polygon )
250{
251 // OddEven fill rule by default
252 QPainterPath path;
253
254 p->setPen( mPen );
255 p->setBrush( mBrush );
256
257 for ( const auto &sourceRing : polygon )
258 {
259 if ( sourceRing.empty() )
260 continue;
261
262 QPolygonF ring;
263 ring.reserve( sourceRing.size() + 1 );
264
265 QPointF lastVertex;
266 for ( const auto &sourceVertex : sourceRing )
267 {
268 //adding point only if it is more than a pixel apart from the previous one
269 const QPointF curVertex = toCanvasCoordinates( sourceVertex ) - pos();
270 if ( ring.isEmpty() || std::abs( ring.back().x() - curVertex.x() ) > 1 || std::abs( ring.back().y() - curVertex.y() ) > 1 )
271 {
272 ring.push_back( curVertex );
273 }
274 lastVertex = curVertex;
275 }
276
277 ring.push_back( ring.at( 0 ) );
278
279 path.addPolygon( ring );
280 }
281
282 p->drawPath( path );
283}
284
285QgsRenderContext QgsHighlight::createRenderContext()
286{
287 QgsMapSettings mapSettings = mMapCanvas->mapSettings();
288 QgsRenderContext context = QgsRenderContext::fromMapSettings( mapSettings );
290 return context;
291}
292
294{
295 if ( !isVisible() )
296 return;
297
298 if ( mGeometry.type() == Qgis::GeometryType::Point )
299 {
300 mRenderContext = createRenderContext();
301 }
302
303 updateRect();
304}
305
307{
308 const QgsSettings settings;
309 QColor color = QColor( settings.value( u"Map/highlight/color"_s, Qgis::DEFAULT_HIGHLIGHT_COLOR.name() ).toString() );
310 const int alpha = settings.value( u"Map/highlight/colorAlpha"_s, Qgis::DEFAULT_HIGHLIGHT_COLOR.alpha() ).toInt();
311 const double buffer = settings.value( u"Map/highlight/buffer"_s, Qgis::DEFAULT_HIGHLIGHT_BUFFER_MM ).toDouble();
312 const double minWidth = settings.value( u"Map/highlight/minWidth"_s, Qgis::DEFAULT_HIGHLIGHT_MIN_WIDTH_MM ).toDouble();
313
314 setColor( color ); // sets also fill with default alpha
315 color.setAlpha( alpha );
316 setFillColor( color ); // sets fill with alpha
317 setBuffer( buffer );
318 setMinWidth( minWidth );
319}
320
321void QgsHighlight::paint( QPainter *p )
322{
323 if ( mFeature.hasGeometry() )
324 {
325 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mLayer );
326 if ( !vlayer )
327 return;
328
329 QgsRenderContext context = createRenderContext();
330 const QgsCoordinateTransform layerToCanvasTransform = mMapCanvas->mapSettings().layerTransform( mLayer );
331 context.setCoordinateTransform( layerToCanvasTransform );
332 QgsRectangle mapExtentInLayerCrs = mMapCanvas->mapSettings().visibleExtent();
333 if ( layerToCanvasTransform.isValid() )
334 {
335 QgsCoordinateTransform approxTransform = layerToCanvasTransform;
336 approxTransform.setBallparkTransformsAreAppropriate( true );
337 try
338 {
339 mapExtentInLayerCrs = approxTransform.transformBoundingBox( mapExtentInLayerCrs, Qgis::TransformDirection::Reverse );
340 }
341 catch ( QgsCsException & )
342 {
343 QgsDebugError( u"Error transforming canvas extent to layer CRS"_s );
344 }
345 }
346 if ( !mapExtentInLayerCrs.isFinite() )
347 {
348 return;
349 }
350 context.setExtent( mapExtentInLayerCrs );
351
352 // Because lower level outlines must be covered by upper level fill color
353 // we render first with temporary opaque color, which is then replaced
354 // by final transparent fill color.
355 QColor tmpColor( 255, 0, 0, 255 );
356 QColor tmpFillColor( 0, 255, 0, 255 );
357
358 std::unique_ptr<QgsFeatureRenderer> renderer = createRenderer( context, tmpColor, tmpFillColor );
359 if ( renderer )
360 {
361 QSize imageSize( mMapCanvas->mapSettings().outputSize() );
362 QImage image = QImage( imageSize.width(), imageSize.height(), QImage::Format_ARGB32 );
363 image.fill( 0 );
364 QPainter imagePainter( &image );
365 imagePainter.setRenderHint( QPainter::Antialiasing, true );
366
367 context.setPainter( &imagePainter );
368 renderer->startRender( context, mFeature.fields() );
369 context.expressionContext().setFeature( mFeature );
370 renderer->renderFeature( mFeature, context );
371 renderer->stopRender( context );
372
373 imagePainter.end();
374
375 // true output color
376 int penRed = mPen.color().red();
377 int penGreen = mPen.color().green();
378 int penBlue = mPen.color().blue();
379 // coefficient to subtract alpha using green (temporary fill)
380 double k = ( 255. - mBrush.color().alpha() ) / 255.;
381 QRgb *line = nullptr;
382 const int height = image.height();
383 const int width = image.width();
384 for ( int r = 0; r < height; r++ )
385 {
386 line = reinterpret_cast<QRgb *>( image.scanLine( r ) );
387 for ( int c = 0; c < width; c++ )
388 {
389 int alpha = qAlpha( line[c] );
390 if ( alpha > 0 )
391 {
392 int green = qGreen( line[c] );
393 line[c] = qRgba( penRed, penGreen, penBlue, std::clamp( static_cast<int>( alpha - ( green * k ) ), 30, 255 ) );
394 }
395 }
396 }
397
398 p->drawImage( 0, 0, image );
399 }
400 }
401 else if ( !mGeometry.isNull() )
402 {
403 p->setPen( mPen );
404 p->setBrush( mBrush );
405
406 switch ( mGeometry.type() )
407 {
409 {
410 setRenderContextVariables( p, mRenderContext );
411
412 // default to 1.5 mm radius square points
413 double pointSizeRadius = mPointSizeRadiusMM;
415 PointSymbol symbol = mPointSymbol;
416
417 // but for point clouds, use actual sizes (+a little margin!)
418 if ( QgsPointCloudLayer *pcLayer = qobject_cast<QgsPointCloudLayer *>( mLayer ) )
419 {
420 if ( QgsPointCloudRenderer *pcRenderer = pcLayer->renderer() )
421 {
422 pointSizeRadius = 1.2 * 0.5 * mRenderContext.convertToPainterUnits( pcRenderer->pointSize(), pcRenderer->pointSizeUnit(), pcRenderer->pointSizeMapUnitScale() );
423 sizeUnit = Qgis::RenderUnit::Pixels;
424 switch ( pcRenderer->pointSymbol() )
425 {
427 symbol = Circle;
428 break;
430 symbol = Square;
431 break;
432 }
433 }
434 }
435
436 for ( auto it = mGeometry.const_parts_begin(); it != mGeometry.const_parts_end(); ++it )
437 {
438 paintPoint( mRenderContext, qgsgeometry_cast<const QgsPoint *>( *it ), pointSizeRadius, sizeUnit, symbol );
439 }
440 }
441 break;
442
444 {
445 if ( !mGeometry.isMultipart() )
446 {
447 paintLine( p, mGeometry.asPolyline() );
448 }
449 else
450 {
451 QgsMultiPolylineXY m = mGeometry.asMultiPolyline();
452
453 for ( int i = 0; i < m.size(); i++ )
454 {
455 paintLine( p, m[i] );
456 }
457 }
458 break;
459 }
460
462 {
463 if ( !mGeometry.isMultipart() )
464 {
465 paintPolygon( p, mGeometry.asPolygon() );
466 }
467 else
468 {
469 QgsMultiPolygonXY m = mGeometry.asMultiPolygon();
470 for ( int i = 0; i < m.size(); i++ )
471 {
472 paintPolygon( p, m[i] );
473 }
474 }
475 break;
476 }
477
480 return;
481 }
482 }
483}
484
486{
487 if ( qobject_cast<QgsPointCloudLayer *>( mLayer ) || mFeature.hasGeometry() )
488 {
489 // We are currently using full map canvas extent for two reasons:
490 // 1) currently there is no method in QgsFeatureRenderer to get rendered feature
491 // bounding box
492 // 2) using different extent would result in shifted fill patterns
493
494 // This is an hack to pass QgsMapCanvasItem::setRect what it
495 // expects (encoding of position and size of the item)
496 const QgsMapToPixel &m2p = mMapCanvas->mapSettings().mapToPixel();
497 QgsPointXY topLeft = m2p.toMapCoordinates( 0, 0 );
498 double res = m2p.mapUnitsPerPixel();
499 QSizeF imageSize = mMapCanvas->mapSettings().outputSize();
500 QgsRectangle rect( topLeft.x(), topLeft.y(), topLeft.x() + imageSize.width() * res, topLeft.y() - imageSize.height() * res );
501 setRect( rect );
502
503 setVisible( true );
504 }
505 else if ( !mGeometry.isNull() )
506 {
507 QgsRectangle r = mGeometry.boundingBox();
508
509 if ( r.isEmpty() )
510 {
511 double d = mMapCanvas->extent().width() * 0.005;
512 r.setXMinimum( r.xMinimum() - d );
513 r.setYMinimum( r.yMinimum() - d );
514 r.setXMaximum( r.xMaximum() + d );
515 r.setYMaximum( r.yMaximum() + d );
516 }
517
518 setRect( r );
519 setVisible( true );
520 }
521 else
522 {
524 }
525}
@ Circle
Renders points as circles.
Definition qgis.h:4307
@ Square
Renders points as squares.
Definition qgis.h:4306
static const double DEFAULT_HIGHLIGHT_MIN_WIDTH_MM
Default highlight line/stroke minimum width in mm.
Definition qgis.h:6471
static const double DEFAULT_HIGHLIGHT_BUFFER_MM
Default highlight buffer in mm.
Definition qgis.h:6466
static const QColor DEFAULT_HIGHLIGHT_COLOR
Default highlight color.
Definition qgis.h:6461
@ Point
Points.
Definition qgis.h:366
@ Line
Lines.
Definition qgis.h:367
@ Polygon
Polygons.
Definition qgis.h:368
@ Unknown
Unknown types.
Definition qgis.h:369
@ Null
No geometry.
Definition qgis.h:370
RenderUnit
Rendering size units.
Definition qgis.h:5255
@ Millimeters
Millimeters.
Definition qgis.h:5256
@ Pixels
Pixels.
Definition qgis.h:5258
@ Reverse
Reverse/inverse transform (from destination to source).
Definition qgis.h:2731
Handles coordinate transforms between two coordinate systems.
void setBallparkTransformsAreAppropriate(bool appropriate)
Sets whether approximate "ballpark" results are appropriate for this coordinate transform.
QgsRectangle transformBoundingBox(const QgsRectangle &rectangle, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool handle180Crossover=false) const
Transforms a rectangle from the source CRS to the destination CRS.
bool isValid() const
Returns true if the coordinate transform is valid, ie both the source and destination CRS have been s...
Custom exception class for Coordinate Reference System related exceptions.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:60
QgsGeometry geometry
Definition qgsfeature.h:71
A geometry is the spatial representation of a feature.
Qgis::GeometryType type
void updatePosition() override
called on changed extent or resize event to update position of the item
QgsMapLayer * layer() const
Returns the layer for which this highlight has been created.
QgsHighlight(QgsMapCanvas *mapCanvas, const QgsGeometry &geom, QgsMapLayer *layer)
Constructor for QgsHighlight.
void setBuffer(double buffer)
Sets the line/stroke buffer size (in millimeters).
QColor fillColor
~QgsHighlight() override
void setMinWidth(double width)
Sets the minimum line/stroke width (in millimeters).
void setFillColor(const QColor &fillColor)
Fill color for the highlight.
void applyDefaultStyle()
Applies the default style from the user settings to the highlight.
void setWidth(int width)
Set stroke width.
void paint(QPainter *p) override
function to be implemented by derived classes
void updateRect()
recalculates needed rectangle
void setColor(const QColor &color)
Set line/stroke to color, polygon fill to color with alpha = 63.
virtual void setWidth(double width)
Sets the width of the line symbol layer.
virtual double width() const
Returns the estimated width for the line symbol layer.
Qgis::RenderUnit widthUnit() const
Returns the units for the line's width.
QgsRectangle rect() const
returns canvas item rectangle in map units
QPointF toCanvasCoordinates(const QgsPointXY &point) const
transformation from map coordinates to screen coordinates
QgsMapCanvas * mMapCanvas
pointer to map canvas
void setRect(const QgsRectangle &r, bool resetRotation=true)
sets canvas item rectangle in map units
QgsMapCanvasItem(QgsMapCanvas *mapCanvas)
protected constructor: cannot be constructed directly
bool setRenderContextVariables(QPainter *p, QgsRenderContext &context) const
Sets render context parameters.
Map canvas is a class for displaying all GIS data types on a canvas.
void destinationCrsChanged()
Emitted when map CRS has changed.
Base class for all map layer types.
Definition qgsmaplayer.h:83
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
Perform transforms between map coordinates and device coordinates.
double mapUnitsPerPixel() const
Returns the current map units per pixel.
QgsPointXY toMapCoordinates(int x, int y) const
Transforms device coordinates to map (world) coordinates.
Represents a map layer supporting display of point clouds.
Abstract base class for 2d point cloud renderers.
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
A rectangle specified with double values.
double xMinimum
double yMinimum
double xMaximum
void setYMinimum(double y)
Set the minimum y value.
void setXMinimum(double x)
Set the minimum x value.
void setYMaximum(double y)
Set the maximum y value.
void setXMaximum(double x)
Set the maximum x value.
double yMaximum
bool isFinite() const
Returns true if the rectangle has finite boundaries.
Contains information about the context of a rendering operation.
void setCoordinateTransform(const QgsCoordinateTransform &t)
Sets the current coordinate transform for the context.
double convertFromPainterUnits(double size, Qgis::RenderUnit unit) const
Converts a size from painter units (pixels) to the specified render unit.
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.
QgsExpressionContext & expressionContext()
Gets the expression context.
void setExtent(const QgsRectangle &extent)
When rendering a map layer, calling this method sets the "clipping" extent for the layer (in the laye...
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
Stores settings for use within QGIS.
Definition qgssettings.h:68
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setStrokeWidth(double strokeWidth)
Qgis::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
void setStrokeWidth(double w)
Sets the width of the marker's stroke.
Qgis::RenderUnit strokeWidthUnit() const
Returns the unit for the width of the marker's stroke.
double strokeWidth() const
Returns the width of the marker's stroke.
virtual void setStrokeColor(const QColor &color)
Sets the stroke color for the symbol layer.
virtual void setFillColor(const QColor &color)
Sets the fill color for the symbol layer.
virtual void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the layer.
virtual void setColor(const QColor &color)
Sets the "representative" color for the symbol layer.
virtual QgsSymbol * subSymbol()
Returns the symbol's sub symbol, if present.
Abstract base class for all rendered symbols.
Definition qgssymbol.h:231
QgsSymbolLayer * symbolLayer(int layer)
Returns the symbol layer at the specified index.
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
Definition qgssymbol.h:353
Represents a vector layer which manages a vector based dataset.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
T qgsgeometry_cast(QgsAbstractGeometry *geom)
QVector< QgsPolylineXY > QgsPolygonXY
Polygon: first item of the list is outer ring, inner rings (if any) start from second item.
Definition qgsgeometry.h:92
QVector< QgsPolylineXY > QgsMultiPolylineXY
A collection of QgsPolylines that share a common collection of attributes.
QVector< QgsPointXY > QgsPolylineXY
Polyline as represented as a vector of two-dimensional points.
Definition qgsgeometry.h:63
QVector< QgsPolygonXY > QgsMultiPolygonXY
A collection of QgsPolygons that share a common collection of attributes.
#define QgsDebugError(str)
Definition qgslogger.h:59
QList< QgsSymbol * > QgsSymbolList
Definition qgsrenderer.h:51