QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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 <QImage>
17
19#include "qgslinesymbollayer.h"
20
22#include "qgsfillsymbollayer.h"
23#include "qgsgeometry.h"
24#include "qgshighlight.h"
25#include "qgsmapcanvas.h"
26#include "qgsmaplayer.h"
27#include "qgsrendercontext.h"
28#include "qgssymbollayer.h"
29#include "qgssymbol.h"
30#include "qgsvectorlayer.h"
31#include "qgsrenderer.h"
33#include "qgspointcloudlayer.h"
35
36/* Few notes about highlighting (RB):
37 - The highlight fill must always be partially transparent because above highlighted layer
38 may be another layer which must remain partially visible.
39 - Because single highlight color does not work well with layers using similar layer color
40 there were considered various possibilities but no optimal solution was found.
41 What does not work:
42 - lighter/darker color: it would work more or less for fully opaque highlight, but
43 overlaying transparent lighter color over original has small visual effect.
44 - complemetary color: mixing transparent (128) complement color with original color
45 results in grey for all colors
46 - contrast line style/ fill pattern: impression is not highligh but just different style
47 - line buffer with contrast (or 2 contrast) color: the same as with patterns, no highlight impression
48 - fill with highlight or contrast color but opaque and using pattern
49 (e.g. Qt::Dense7Pattern): again no highlight impression
50*/
51
53 : QgsMapCanvasItem( mapCanvas )
54 , mGeometry( geom )
55 , mLayer( layer )
56
57{
58 init();
59}
60
62 : QgsMapCanvasItem( mapCanvas )
63 , mLayer( layer )
64 , mFeature( feature )
65{
66 init();
67}
68
69void QgsHighlight::init()
70{
71 mOriginalGeometry = mGeometry.isNull() ? mFeature.geometry() : mGeometry;
72 setColor( QColor( Qt::lightGray ) );
73
74 connect( mMapCanvas, &QgsMapCanvas::destinationCrsChanged, this, &QgsHighlight::updateTransformedGeometry );
75 updateTransformedGeometry();
76
77 if ( mGeometry.type() == Qgis::GeometryType::Point )
78 {
79 mRenderContext = createRenderContext();
80 }
81}
82
83void QgsHighlight::updateTransformedGeometry()
84{
86
87 // we don't auto-transform if we are highlighting a feature -- the renderer will take care
88 // of that for us
89 if ( ct.isValid() && !mGeometry.isNull() )
90 {
91 // reset to original geometry and transform
92 mGeometry = mOriginalGeometry;
93 try
94 {
95 mGeometry.transform( ct );
96 }
97 catch ( QgsCsException & )
98 {
99 QgsDebugError( QStringLiteral( "Could not transform highlight geometry to canvas CRS" ) );
100 }
101 }
102 updateRect();
103 update();
104}
105
107
108void QgsHighlight::setColor( const QColor &color )
109{
110 mColor = color;
111 mPen.setColor( color );
112 QColor fillColor( color.red(), color.green(), color.blue(), 63 );
113 mBrush.setColor( fillColor );
114 mBrush.setStyle( Qt::SolidPattern );
115}
116
117void QgsHighlight::setFillColor( const QColor &fillColor )
118{
119 mFillColor = fillColor;
120 mBrush.setColor( fillColor );
121 mBrush.setStyle( Qt::SolidPattern );
122}
123
124std::unique_ptr<QgsFeatureRenderer> QgsHighlight::createRenderer( QgsRenderContext &context, const QColor &color, const QColor &fillColor )
125{
126 std::unique_ptr<QgsFeatureRenderer> renderer;
127 QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( mLayer );
128 if ( layer && layer->renderer() )
129 {
130 renderer.reset( layer->renderer()->clone() );
131 }
132 if ( renderer )
133 {
134 const QgsSymbolList symbols = renderer->symbols( context );
135 for ( QgsSymbol *symbol : symbols )
136 {
137 if ( !symbol )
138 continue;
139 setSymbol( symbol, context, color, fillColor );
140 }
141 }
142 return renderer;
143}
144
145void QgsHighlight::setSymbol( QgsSymbol *symbol, const QgsRenderContext &context, const QColor &color, const QColor &fillColor )
146{
147 if ( !symbol )
148 return;
149
150 for ( int i = symbol->symbolLayerCount() - 1; i >= 0; i-- )
151 {
152 QgsSymbolLayer *symbolLayer = symbol->symbolLayer( i );
153 if ( !symbolLayer )
154 continue;
155
156 if ( symbolLayer->subSymbol() )
157 {
158 setSymbol( symbolLayer->subSymbol(), context, color, fillColor );
159 }
160 else
161 {
162 symbolLayer->setColor( color ); // line symbology layers
163 symbolLayer->setStrokeColor( color ); // marker and fill symbology layers
164 symbolLayer->setFillColor( fillColor ); // marker and fill symbology layers
165
166 // Data defined widths overwrite what we set here (widths do not work with data defined)
167 QgsSimpleMarkerSymbolLayer *simpleMarker = dynamic_cast<QgsSimpleMarkerSymbolLayer *>( symbolLayer );
168 if ( simpleMarker )
169 {
170 simpleMarker->setStrokeWidth( getSymbolWidth( context, simpleMarker->strokeWidth(), simpleMarker->strokeWidthUnit() ) );
171 }
172 QgsSimpleLineSymbolLayer *simpleLine = dynamic_cast<QgsSimpleLineSymbolLayer *>( symbolLayer );
173 if ( simpleLine )
174 {
175 simpleLine->setWidth( getSymbolWidth( context, simpleLine->width(), simpleLine->widthUnit() ) );
176 }
177 QgsSimpleFillSymbolLayer *simpleFill = dynamic_cast<QgsSimpleFillSymbolLayer *>( symbolLayer );
178 if ( simpleFill )
179 {
180 simpleFill->setStrokeWidth( getSymbolWidth( context, simpleFill->strokeWidth(), simpleFill->outputUnit() ) );
181 }
184 }
185 }
186}
187
188double QgsHighlight::getSymbolWidth( const QgsRenderContext &context, double width, Qgis::RenderUnit unit )
189{
190 // if necessary scale mm to map units
191 double scale = 1.;
192 if ( unit == Qgis::RenderUnit::MapUnits )
193 {
195 }
196 width = std::max( width + 2 * mBuffer * scale, mMinWidth * scale );
197 return width;
198}
199
200void QgsHighlight::setWidth( int width )
201{
202 mWidth = width;
203 mPen.setWidth( width );
204}
205
206void QgsHighlight::paintPoint( QgsRenderContext &context, const QgsPoint *point, double size, Qgis::RenderUnit sizeUnit, PointSymbol symbol )
207{
208 if ( !point )
209 return;
210
211 const double radius = context.convertToPainterUnits( size, sizeUnit );
212 const double xMin = toCanvasCoordinates( *point ).x() - radius - pos().x();
213 const double yMin = toCanvasCoordinates( *point ).y() - radius - pos().y();
214
215 switch ( symbol )
216 {
217 case QgsHighlight::Square:
218 {
219 const double xMax = xMin + 2 * radius;
220 const double yMax = yMin + 2 * radius;
221 QPolygonF r( QVector<QPointF> { QPointF( xMin, yMin ),
222 QPointF( xMax, yMin ),
223 QPointF( xMax, yMax ),
224 QPointF( xMin, yMax ),
225 QPointF( xMin, yMin )
226 } );
227 context.painter()->drawPolygon( r );
228 break;
229 }
230
231 case QgsHighlight::Circle:
232 {
233 context.painter()->drawEllipse( QRectF( xMin, yMin, radius * 2, radius * 2 ) );
234 break;
235 }
236 }
237}
238
239void QgsHighlight::paintLine( QPainter *p, QgsPolylineXY line )
240{
241 QPolygonF polygon( line.size() );
242
243 for ( int i = 0; i < line.size(); i++ )
244 {
245 polygon[i] = toCanvasCoordinates( line[i] ) - pos();
246 }
247
248 p->drawPolyline( polygon );
249}
250
251void QgsHighlight::paintPolygon( QPainter *p, const QgsPolygonXY &polygon )
252{
253 // OddEven fill rule by default
254 QPainterPath path;
255
256 p->setPen( mPen );
257 p->setBrush( mBrush );
258
259 for ( const auto &sourceRing : polygon )
260 {
261 if ( sourceRing.empty() )
262 continue;
263
264 QPolygonF ring;
265 ring.reserve( sourceRing.size() + 1 );
266
267 QPointF lastVertex;
268 for ( const auto &sourceVertex : sourceRing )
269 {
270 //adding point only if it is more than a pixel apart from the previous one
271 const QPointF curVertex = toCanvasCoordinates( sourceVertex ) - pos();
272 if ( ring.isEmpty() || std::abs( ring.back().x() - curVertex.x() ) > 1 || std::abs( ring.back().y() - curVertex.y() ) > 1 )
273 {
274 ring.push_back( curVertex );
275 }
276 lastVertex = curVertex;
277 }
278
279 ring.push_back( ring.at( 0 ) );
280
281 path.addPolygon( ring );
282 }
283
284 p->drawPath( path );
285}
286
287QgsRenderContext QgsHighlight::createRenderContext()
288{
289 QgsMapSettings mapSettings = mMapCanvas->mapSettings();
292 return context;
293}
294
296{
297 if ( !isVisible() )
298 return;
299
300 if ( mGeometry.type() == Qgis::GeometryType::Point )
301 {
302 mRenderContext = createRenderContext();
303 }
304
305 updateRect();
306}
307
309{
310 const QgsSettings settings;
311 QColor color = QColor( settings.value( QStringLiteral( "Map/highlight/color" ), Qgis::DEFAULT_HIGHLIGHT_COLOR.name() ).toString() );
312 const int alpha = settings.value( QStringLiteral( "Map/highlight/colorAlpha" ), Qgis::DEFAULT_HIGHLIGHT_COLOR.alpha() ).toInt();
313 const double buffer = settings.value( QStringLiteral( "Map/highlight/buffer" ), Qgis::DEFAULT_HIGHLIGHT_BUFFER_MM ).toDouble();
314 const double minWidth = settings.value( QStringLiteral( "Map/highlight/minWidth" ), Qgis::DEFAULT_HIGHLIGHT_MIN_WIDTH_MM ).toDouble();
315
316 setColor( color ); // sets also fill with default alpha
317 color.setAlpha( alpha );
318 setFillColor( color ); // sets fill with alpha
319 setBuffer( buffer );
320 setMinWidth( minWidth );
321}
322
323void QgsHighlight::paint( QPainter *p )
324{
325 if ( mFeature.hasGeometry() )
326 {
327 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mLayer );
328 if ( !vlayer )
329 return;
330
331 QgsRenderContext context = createRenderContext();
332 const QgsCoordinateTransform layerToCanvasTransform = mMapCanvas->mapSettings().layerTransform( mLayer );
333 context.setCoordinateTransform( layerToCanvasTransform );
334 QgsRectangle mapExtentInLayerCrs = mMapCanvas->mapSettings().visibleExtent();
335 if ( layerToCanvasTransform.isValid() )
336 {
337 QgsCoordinateTransform approxTransform = layerToCanvasTransform;
338 approxTransform.setBallparkTransformsAreAppropriate( true );
339 try
340 {
341 mapExtentInLayerCrs = approxTransform.transformBoundingBox( mapExtentInLayerCrs, Qgis::TransformDirection::Reverse );
342 }
343 catch ( QgsCsException & )
344 {
345 QgsDebugError( QStringLiteral( "Error transforming canvas extent to layer CRS" ) );
346 }
347 }
348 if ( !mapExtentInLayerCrs.isFinite() )
349 {
350 return;
351 }
352 context.setExtent( mapExtentInLayerCrs );
353
354 // Because lower level outlines must be covered by upper level fill color
355 // we render first with temporary opaque color, which is then replaced
356 // by final transparent fill color.
357 QColor tmpColor( 255, 0, 0, 255 );
358 QColor tmpFillColor( 0, 255, 0, 255 );
359
360 std::unique_ptr< QgsFeatureRenderer > renderer = createRenderer( context, tmpColor, tmpFillColor );
361 if ( renderer )
362 {
363
364 QSize imageSize( mMapCanvas->mapSettings().outputSize() );
365 QImage image = QImage( imageSize.width(), imageSize.height(), QImage::Format_ARGB32 );
366 image.fill( 0 );
367 QPainter imagePainter( &image );
368 imagePainter.setRenderHint( QPainter::Antialiasing, true );
369
370 context.setPainter( &imagePainter );
371 renderer->startRender( context, mFeature.fields() );
372 context.expressionContext().setFeature( mFeature );
373 renderer->renderFeature( mFeature, context );
374 renderer->stopRender( context );
375
376 imagePainter.end();
377
378 // true output color
379 int penRed = mPen.color().red();
380 int penGreen = mPen.color().green();
381 int penBlue = mPen.color().blue();
382 // coefficient to subtract alpha using green (temporary fill)
383 double k = ( 255. - mBrush.color().alpha() ) / 255.;
384 QRgb *line = nullptr;
385 const int height = image.height();
386 const int width = image.width();
387 for ( int r = 0; r < height; r++ )
388 {
389 line = reinterpret_cast<QRgb *>( image.scanLine( r ) );
390 for ( int c = 0; c < width; c++ )
391 {
392 int alpha = qAlpha( line[c] );
393 if ( alpha > 0 )
394 {
395 int green = qGreen( line[c] );
396 line[c] = qRgba( penRed, penGreen, penBlue, std::clamp( static_cast< int >( alpha - ( green * k ) ), 30, 255 ) );
397 }
398 }
399 }
400
401 p->drawImage( 0, 0, image );
402 }
403 }
404 else if ( !mGeometry.isNull() )
405 {
406 p->setPen( mPen );
407 p->setBrush( mBrush );
408
409 switch ( mGeometry.type() )
410 {
412 {
413 setRenderContextVariables( p, mRenderContext );
414
415 // default to 1.5 mm radius square points
416 double pointSizeRadius = mPointSizeRadiusMM;
418 PointSymbol symbol = mPointSymbol;
419
420 // but for point clouds, use actual sizes (+a little margin!)
421 if ( QgsPointCloudLayer *pcLayer = qobject_cast<QgsPointCloudLayer *>( mLayer ) )
422 {
423 if ( QgsPointCloudRenderer *pcRenderer = pcLayer->renderer() )
424 {
425 pointSizeRadius = 1.2 * 0.5 * mRenderContext.convertToPainterUnits( pcRenderer->pointSize(), pcRenderer->pointSizeUnit(), pcRenderer->pointSizeMapUnitScale() );
426 sizeUnit = Qgis::RenderUnit::Pixels;
427 switch ( pcRenderer->pointSymbol() )
428 {
430 symbol = Circle;
431 break;
433 symbol = Square;
434 break;
435 }
436 }
437 }
438
439 for ( auto it = mGeometry.const_parts_begin(); it != mGeometry.const_parts_end(); ++it )
440 {
441 paintPoint( mRenderContext, qgsgeometry_cast< const QgsPoint *>( *it ), pointSizeRadius, sizeUnit, symbol );
442 }
443 }
444 break;
445
447 {
448 if ( !mGeometry.isMultipart() )
449 {
450 paintLine( p, mGeometry.asPolyline() );
451 }
452 else
453 {
454 QgsMultiPolylineXY m = mGeometry.asMultiPolyline();
455
456 for ( int i = 0; i < m.size(); i++ )
457 {
458 paintLine( p, m[i] );
459 }
460 }
461 break;
462 }
463
465 {
466 if ( !mGeometry.isMultipart() )
467 {
468 paintPolygon( p, mGeometry.asPolygon() );
469 }
470 else
471 {
472 QgsMultiPolygonXY m = mGeometry.asMultiPolygon();
473 for ( int i = 0; i < m.size(); i++ )
474 {
475 paintPolygon( p, m[i] );
476 }
477 }
478 break;
479 }
480
483 return;
484 }
485 }
486}
487
489{
490 if ( qobject_cast<QgsPointCloudLayer *>( mLayer ) || mFeature.hasGeometry() )
491 {
492 // We are currently using full map canvas extent for two reasons:
493 // 1) currently there is no method in QgsFeatureRenderer to get rendered feature
494 // bounding box
495 // 2) using different extent would result in shifted fill patterns
496
497 // This is an hack to pass QgsMapCanvasItem::setRect what it
498 // expects (encoding of position and size of the item)
500 QgsPointXY topLeft = m2p.toMapCoordinates( 0, 0 );
501 double res = m2p.mapUnitsPerPixel();
502 QSizeF imageSize = mMapCanvas->mapSettings().outputSize();
503 QgsRectangle rect( topLeft.x(), topLeft.y(), topLeft.x() + imageSize.width()*res, topLeft.y() - imageSize.height()*res );
504 setRect( rect );
505
506 setVisible( true );
507 }
508 else if ( !mGeometry.isNull() )
509 {
510 QgsRectangle r = mGeometry.boundingBox();
511
512 if ( r.isEmpty() )
513 {
514 double d = mMapCanvas->extent().width() * 0.005;
515 r.setXMinimum( r.xMinimum() - d );
516 r.setYMinimum( r.yMinimum() - d );
517 r.setXMaximum( r.xMaximum() + d );
518 r.setYMaximum( r.yMaximum() + d );
519 }
520
521 setRect( r );
522 setVisible( true );
523 }
524 else
525 {
527 }
528}
@ Circle
Renders points as circles.
@ Square
Renders points as squares.
static const double DEFAULT_HIGHLIGHT_MIN_WIDTH_MM
Default highlight line/stroke minimum width in mm.
Definition: qgis.h:4901
static const double DEFAULT_HIGHLIGHT_BUFFER_MM
Default highlight buffer in mm.
Definition: qgis.h:4896
static const QColor DEFAULT_HIGHLIGHT_COLOR
Default highlight color.
Definition: qgis.h:4891
@ Polygon
Polygons.
@ Unknown
Unknown types.
@ Null
No geometry.
RenderUnit
Rendering size units.
Definition: qgis.h:4255
@ Millimeters
Millimeters.
@ MapUnits
Map units.
@ Reverse
Reverse/inverse transform (from destination to source)
Class for doing transforms between two map 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.
Definition: qgsexception.h:67
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:56
QgsFields fields
Definition: qgsfeature.h:66
QgsGeometry geometry
Definition: qgsfeature.h:67
bool hasGeometry() const
Returns true if the feature has an associated geometry.
Definition: qgsfeature.cpp:230
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:162
QgsMultiPolygonXY asMultiPolygon() const
Returns the contents of the geometry as a multi-polygon.
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.
QgsPolygonXY asPolygon() const
Returns the contents of the geometry as a polygon.
Q_GADGET bool isNull
Definition: qgsgeometry.h:164
QgsPolylineXY asPolyline() const
Returns the contents of the geometry as a polyline.
Qgis::GeometryType type
Definition: qgsgeometry.h:165
QgsMultiPolylineXY asMultiPolyline() const
Returns the contents of the geometry as a multi-linestring.
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
QgsAbstractGeometry::const_part_iterator const_parts_end() const
Returns STL-style iterator pointing to the imaginary part after the last part of the geometry.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
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.
Definition: qgshighlight.h:168
QgsHighlight(QgsMapCanvas *mapCanvas, const QgsGeometry &geom, QgsMapLayer *layer)
Constructor for QgsHighlight.
void setBuffer(double buffer)
Set line / stroke buffer in millimeters.
Definition: qgshighlight.h:157
QColor fillColor
Definition: qgshighlight.h:87
~QgsHighlight() override
QColor color
Definition: qgshighlight.h:86
void setMinWidth(double width)
Set minimum line / stroke width in millimeters.
Definition: qgshighlight.h:163
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.
An abstract class for items that can be placed on the map canvas.
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
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.
Definition: qgsmapcanvas.h:93
void destinationCrsChanged()
Emitted when map CRS has changed.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
QgsRectangle extent() const
Returns the current zoom extent of the map canvas.
Base class for all map layer types.
Definition: qgsmaplayer.h:75
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
The QgsMapSettings class contains configuration for rendering of the map.
QgsCoordinateTransform layerTransform(const QgsMapLayer *layer) const
Returns the coordinate transform from layer's CRS to destination CRS.
const QgsMapToPixel & mapToPixel() const
QSize outputSize() const
Returns the size of the resulting map image, in pixels.
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes output image size into account.
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:39
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.
A class to represent a 2D point.
Definition: qgspointxy.h:60
double y
Definition: qgspointxy.h:64
Q_GADGET double x
Definition: qgspointxy.h:63
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:49
A store for object properties.
Definition: qgsproperty.h:228
A rectangle specified with double values.
Definition: qgsrectangle.h:42
double xMinimum() const
Returns the x minimum value (left side of rectangle).
Definition: qgsrectangle.h:201
void setYMinimum(double y)
Set the minimum y value.
Definition: qgsrectangle.h:159
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
Definition: qgsrectangle.h:211
void setXMinimum(double x)
Set the minimum x value.
Definition: qgsrectangle.h:149
double width() const
Returns the width of the rectangle.
Definition: qgsrectangle.h:236
double xMaximum() const
Returns the x maximum value (right side of rectangle).
Definition: qgsrectangle.h:196
double yMaximum() const
Returns the y maximum value (top side of rectangle).
Definition: qgsrectangle.h:206
void setYMaximum(double y)
Set the maximum y value.
Definition: qgsrectangle.h:164
void setXMaximum(double x)
Set the maximum x value.
Definition: qgsrectangle.h:154
bool isEmpty() const
Returns true if the rectangle has no area.
Definition: qgsrectangle.h:492
bool isFinite() const
Returns true if the rectangle has finite boundaries.
Definition: qgsrectangle.h:588
Contains information about the context of a rendering operation.
void setCoordinateTransform(const QgsCoordinateTransform &t)
Sets the current coordinate transform for the context.
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
This class is a composition of two QSettings instances:
Definition: qgssettings.h:64
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.
A simple line symbol layer, which renders lines using a line in a variety of styles (e....
Simple marker symbol layer, consisting of a rendered shape with solid fill color and an stroke.
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.
@ StrokeColor
Stroke color.
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:94
QgsSymbolLayer * symbolLayer(int layer)
Returns the symbol layer at the specified index.
Definition: qgssymbol.cpp:760
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
Definition: qgssymbol.h:215
Represents a vector layer which manages a vector based data sets.
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
QVector< QgsPolylineXY > QgsPolygonXY
Polygon: first item of the list is outer ring, inner rings (if any) start from second item.
Definition: qgsgeometry.h:74
QVector< QgsPolylineXY > QgsMultiPolylineXY
A collection of QgsPolylines that share a common collection of attributes.
Definition: qgsgeometry.h:84
QVector< QgsPointXY > QgsPolylineXY
Polyline as represented as a vector of two-dimensional points.
Definition: qgsgeometry.h:62
QVector< QgsPolygonXY > QgsMultiPolygonXY
A collection of QgsPolygons that share a common collection of attributes.
Definition: qgsgeometry.h:91
#define QgsDebugError(str)
Definition: qgslogger.h:38
QList< QgsSymbol * > QgsSymbolList
Definition: qgsrenderer.h:44