QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 
18 #include "qgsmarkersymbollayer.h"
19 #include "qgslinesymbollayer.h"
20 
21 #include "qgscoordinatetransform.h"
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 
34 /* Few notes about highlighting (RB):
35  - The highlight fill must always be partially transparent because above highlighted layer
36  may be another layer which must remain partially visible.
37  - Because single highlight color does not work well with layers using similar layer color
38  there were considered various possibilities but no optimal solution was found.
39  What does not work:
40  - lighter/darker color: it would work more or less for fully opaque highlight, but
41  overlaying transparent lighter color over original has small visual effect.
42  - complemetary color: mixing transparent (128) complement color with original color
43  results in grey for all colors
44  - contrast line style/ fill pattern: impression is not highligh but just different style
45  - line buffer with contrast (or 2 contrast) color: the same as with patterns, no highlight impression
46  - fill with highlight or contrast color but opaque and using pattern
47  (e.g. Qt::Dense7Pattern): again no highlight impression
48 */
49 
51  : QgsMapCanvasItem( mapCanvas )
52  , mLayer( layer )
53 {
54  mGeometry = !geom.isNull() ? new QgsGeometry( geom ) : nullptr;
55  init();
56 }
57 
59  : QgsMapCanvasItem( mapCanvas )
60  , mLayer( layer )
61  , mFeature( feature )
62 {
63  init();
64 }
65 
66 void QgsHighlight::init()
67 {
69  if ( ct.isValid() )
70  {
71  if ( mGeometry )
72  {
73  mGeometry->transform( ct );
74  }
75  else if ( mFeature.hasGeometry() )
76  {
77  QgsGeometry g = mFeature.geometry();
78  g.transform( ct );
79  mFeature.setGeometry( g );
80  }
81  }
82 
83  updateRect();
84  update();
85  setColor( QColor( Qt::lightGray ) );
86 }
87 
89 {
90  delete mGeometry;
91 }
92 
93 
94 void QgsHighlight::setColor( const QColor &color )
95 {
96  mColor = color;
97  mPen.setColor( color );
98  QColor fillColor( color.red(), color.green(), color.blue(), 63 );
99  mBrush.setColor( fillColor );
100  mBrush.setStyle( Qt::SolidPattern );
101 }
102 
103 void QgsHighlight::setFillColor( const QColor &fillColor )
104 {
105  mFillColor = fillColor;
106  mBrush.setColor( fillColor );
107  mBrush.setStyle( Qt::SolidPattern );
108 }
109 
110 std::unique_ptr<QgsFeatureRenderer> QgsHighlight::createRenderer( QgsRenderContext &context, const QColor &color, const QColor &fillColor )
111 {
112  std::unique_ptr<QgsFeatureRenderer> renderer;
113  QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( mLayer );
114  if ( layer && layer->renderer() )
115  {
116  renderer.reset( layer->renderer()->clone() );
117  }
118  if ( renderer )
119  {
120  const auto constSymbols = renderer->symbols( context );
121  for ( QgsSymbol *symbol : constSymbols )
122  {
123  if ( !symbol ) continue;
124  setSymbol( symbol, context, color, fillColor );
125  }
126  }
127  return renderer;
128 }
129 
130 void QgsHighlight::setSymbol( QgsSymbol *symbol, const QgsRenderContext &context, const QColor &color, const QColor &fillColor )
131 {
132  if ( !symbol ) return;
133 
134 
135  for ( int i = symbol->symbolLayerCount() - 1; i >= 0; i-- )
136  {
137  QgsSymbolLayer *symbolLayer = symbol->symbolLayer( i );
138  if ( !symbolLayer ) continue;
139 
140  if ( symbolLayer->subSymbol() )
141  {
142  setSymbol( symbolLayer->subSymbol(), context, color, fillColor );
143  }
144  else
145  {
146  symbolLayer->setColor( color ); // line symbology layers
147  symbolLayer->setStrokeColor( color ); // marker and fill symbology layers
148  symbolLayer->setFillColor( fillColor ); // marker and fill symbology layers
149 
150  // Data defined widths overwrite what we set here (widths do not work with data defined)
151  QgsSimpleMarkerSymbolLayer *simpleMarker = dynamic_cast<QgsSimpleMarkerSymbolLayer *>( symbolLayer );
152  if ( simpleMarker )
153  {
154  simpleMarker->setStrokeWidth( getSymbolWidth( context, simpleMarker->strokeWidth(), simpleMarker->strokeWidthUnit() ) );
155  }
156  QgsSimpleLineSymbolLayer *simpleLine = dynamic_cast<QgsSimpleLineSymbolLayer *>( symbolLayer );
157  if ( simpleLine )
158  {
159  simpleLine->setWidth( getSymbolWidth( context, simpleLine->width(), simpleLine->widthUnit() ) );
160  }
161  QgsSimpleFillSymbolLayer *simpleFill = dynamic_cast<QgsSimpleFillSymbolLayer *>( symbolLayer );
162  if ( simpleFill )
163  {
164  simpleFill->setStrokeWidth( getSymbolWidth( context, simpleFill->strokeWidth(), simpleFill->outputUnit() ) );
165  }
168  }
169  }
170 }
171 
172 double QgsHighlight::getSymbolWidth( const QgsRenderContext &context, double width, QgsUnitTypes::RenderUnit unit )
173 {
174  // if necessary scale mm to map units
175  double scale = 1.;
176  if ( unit == QgsUnitTypes::RenderMapUnits )
177  {
179  }
180  width = std::max( width + 2 * mBuffer * scale, mMinWidth * scale );
181  return width;
182 }
183 
184 void QgsHighlight::setWidth( int width )
185 {
186  mWidth = width;
187  mPen.setWidth( width );
188 }
189 
190 void QgsHighlight::paintPoint( QPainter *p, const QgsPointXY &point )
191 {
192  QPolygonF r( 5 );
193 
194  double d = mMapCanvas->extent().width() * 0.005;
195  r[0] = toCanvasCoordinates( point + QgsVector( -d, -d ) ) - pos();
196  r[1] = toCanvasCoordinates( point + QgsVector( d, -d ) ) - pos();
197  r[2] = toCanvasCoordinates( point + QgsVector( d, d ) ) - pos();
198  r[3] = toCanvasCoordinates( point + QgsVector( -d, d ) ) - pos();
199  r[4] = r[0];
200 
201  p->drawPolygon( r );
202 }
203 
204 void QgsHighlight::paintLine( QPainter *p, QgsPolylineXY line )
205 {
206  QPolygonF polygon( line.size() );
207 
208  for ( int i = 0; i < line.size(); i++ )
209  {
210  polygon[i] = toCanvasCoordinates( line[i] ) - pos();
211  }
212 
213  p->drawPolyline( polygon );
214 }
215 
216 void QgsHighlight::paintPolygon( QPainter *p, const QgsPolygonXY &polygon )
217 {
218  // OddEven fill rule by default
219  QPainterPath path;
220 
221  p->setPen( mPen );
222  p->setBrush( mBrush );
223 
224  for ( const auto &sourceRing : polygon )
225  {
226  if ( sourceRing.empty() )
227  continue;
228 
229  QPolygonF ring;
230  ring.reserve( sourceRing.size() + 1 );
231 
232  QPointF lastVertex;
233  for ( const auto &sourceVertex : sourceRing )
234  {
235  //adding point only if it is more than a pixel apart from the previous one
236  const QPointF curVertex = toCanvasCoordinates( sourceVertex ) - pos();
237  if ( ring.isEmpty() || std::abs( ring.back().x() - curVertex.x() ) > 1 || std::abs( ring.back().y() - curVertex.y() ) > 1 )
238  {
239  ring.push_back( curVertex );
240  }
241  lastVertex = curVertex;
242  }
243 
244  ring.push_back( ring.at( 0 ) );
245 
246  path.addPolygon( ring );
247  }
248 
249  p->drawPath( path );
250 }
251 
253 {
254  if ( isVisible() ) updateRect();
255 }
256 
257 void QgsHighlight::paint( QPainter *p )
258 {
259  if ( mGeometry )
260  {
261  p->setPen( mPen );
262  p->setBrush( mBrush );
263 
264  switch ( mGeometry->type() )
265  {
267  {
268  if ( !mGeometry->isMultipart() )
269  {
270  paintPoint( p, mGeometry->asPoint() );
271  }
272  else
273  {
274  QgsMultiPointXY m = mGeometry->asMultiPoint();
275  for ( int i = 0; i < m.size(); i++ )
276  {
277  paintPoint( p, m[i] );
278  }
279  }
280  }
281  break;
282 
284  {
285  if ( !mGeometry->isMultipart() )
286  {
287  paintLine( p, mGeometry->asPolyline() );
288  }
289  else
290  {
291  QgsMultiPolylineXY m = mGeometry->asMultiPolyline();
292 
293  for ( int i = 0; i < m.size(); i++ )
294  {
295  paintLine( p, m[i] );
296  }
297  }
298  break;
299  }
300 
302  {
303  if ( !mGeometry->isMultipart() )
304  {
305  paintPolygon( p, mGeometry->asPolygon() );
306  }
307  else
308  {
309  QgsMultiPolygonXY m = mGeometry->asMultiPolygon();
310  for ( int i = 0; i < m.size(); i++ )
311  {
312  paintPolygon( p, m[i] );
313  }
314  }
315  break;
316  }
317 
320  return;
321  }
322  }
323  else if ( mFeature.hasGeometry() )
324  {
325  QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( mLayer );
326  if ( !layer )
327  return;
328  QgsMapSettings mapSettings = mMapCanvas->mapSettings();
329  QgsRenderContext context = QgsRenderContext::fromMapSettings( mapSettings );
331 
332 
333  // Because lower level outlines must be covered by upper level fill color
334  // we render first with temporary opaque color, which is then replaced
335  // by final transparent fill color.
336  QColor tmpColor( 255, 0, 0, 255 );
337  QColor tmpFillColor( 0, 255, 0, 255 );
338 
339  std::unique_ptr< QgsFeatureRenderer > renderer = createRenderer( context, tmpColor, tmpFillColor );
340  if ( layer && renderer )
341  {
342 
343  QSize imageSize( mMapCanvas->mapSettings().outputSize() );
344  QImage image = QImage( imageSize.width(), imageSize.height(), QImage::Format_ARGB32 );
345  image.fill( 0 );
346  QPainter imagePainter( &image );
347  imagePainter.setRenderHint( QPainter::Antialiasing, true );
348 
349  context.setPainter( &imagePainter );
350 
351  renderer->startRender( context, layer->fields() );
352  context.expressionContext().setFeature( mFeature );
353  renderer->renderFeature( mFeature, context );
354  renderer->stopRender( context );
355 
356  imagePainter.end();
357 
358  // true output color
359  int penRed = mPen.color().red();
360  int penGreen = mPen.color().green();
361  int penBlue = mPen.color().blue();
362  // coefficient to subtract alpha using green (temporary fill)
363  double k = ( 255. - mBrush.color().alpha() ) / 255.;
364  QRgb *line = nullptr;
365  const int height = image.height();
366  const int width = image.width();
367  for ( int r = 0; r < height; r++ )
368  {
369  line = reinterpret_cast<QRgb *>( image.scanLine( r ) );
370  for ( int c = 0; c < width; c++ )
371  {
372  int alpha = qAlpha( line[c] );
373  if ( alpha > 0 )
374  {
375  int green = qGreen( line[c] );
376  line[c] = qRgba( penRed, penGreen, penBlue, qBound<int>( 0, alpha - ( green * k ), 255 ) );
377  }
378  }
379  }
380 
381  p->drawImage( 0, 0, image );
382  }
383  }
384 }
385 
387 {
388  if ( mGeometry )
389  {
390  QgsRectangle r = mGeometry->boundingBox();
391 
392  if ( r.isEmpty() )
393  {
394  double d = mMapCanvas->extent().width() * 0.005;
395  r.setXMinimum( r.xMinimum() - d );
396  r.setYMinimum( r.yMinimum() - d );
397  r.setXMaximum( r.xMaximum() + d );
398  r.setYMaximum( r.yMaximum() + d );
399  }
400 
401  setRect( r );
402  setVisible( mGeometry );
403  }
404  else if ( mFeature.hasGeometry() )
405  {
406  // We are currently using full map canvas extent for two reasons:
407  // 1) currently there is no method in QgsFeatureRenderer to get rendered feature
408  // bounding box
409  // 2) using different extent would result in shifted fill patterns
410 
411  // This is an hack to pass QgsMapCanvasItem::setRect what it
412  // expects (encoding of position and size of the item)
414  QgsPointXY topLeft = m2p.toMapCoordinates( 0, 0 );
415  double res = m2p.mapUnitsPerPixel();
416  QSizeF imageSize = mMapCanvas->mapSettings().outputSize();
417  QgsRectangle rect( topLeft.x(), topLeft.y(), topLeft.x() + imageSize.width()*res, topLeft.y() - imageSize.height()*res );
418  setRect( rect );
419 
420  setVisible( true );
421  }
422  else
423  {
424  setRect( QgsRectangle() );
425  }
426 }
QgsHighlight::setColor
void setColor(const QColor &color)
Set line/stroke to color, polygon fill to color with alpha = 63.
Definition: qgshighlight.cpp:94
qgsexpressioncontextutils.h
QgsPointXY::y
double y
Definition: qgspointxy.h:48
QgsGeometry::transform
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
Definition: qgsgeometry.cpp:2813
QgsMapCanvas::extent
QgsRectangle extent() const
Returns the current zoom extent of the map canvas.
Definition: qgsmapcanvas.cpp:1056
QgsRenderContext::convertToPainterUnits
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
Definition: qgsrendercontext.cpp:318
QgsProperty
A store for object properties.
Definition: qgsproperty.h:232
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
QgsRenderContext::expressionContext
QgsExpressionContext & expressionContext()
Gets the expression context.
Definition: qgsrendercontext.h:596
QgsMapToPixel::mapUnitsPerPixel
double mapUnitsPerPixel() const
Returns current map units per pixel.
Definition: qgsmaptopixel.cpp:128
QgsLineSymbolLayer::width
virtual double width() const
Returns the estimated width for the line symbol layer.
Definition: qgssymbollayer.h:965
QgsMapSettings::outputSize
QSize outputSize() const
Returns the size of the resulting map image.
Definition: qgsmapsettings.cpp:235
QgsMapSettings::layerTransform
QgsCoordinateTransform layerTransform(const QgsMapLayer *layer) const
Returns the coordinate transform from layer's CRS to destination CRS.
Definition: qgsmapsettings.cpp:419
QgsPolygonXY
QVector< QgsPolylineXY > QgsPolygonXY
Polygon: first item of the list is outer ring, inner rings (if any) start from second item.
Definition: qgsgeometry.h:75
qgsmapcanvas.h
QgsWkbTypes::NullGeometry
@ NullGeometry
Definition: qgswkbtypes.h:146
QgsRenderContext::fromMapSettings
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
Definition: qgsrendercontext.cpp:197
QgsMapCanvasItem::mMapCanvas
QgsMapCanvas * mMapCanvas
pointer to map canvas
Definition: qgsmapcanvasitem.h:82
QgsMapLayer::clone
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
QgsMapCanvas::mapSettings
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
Definition: qgsmapcanvas.cpp:391
QgsGeometry::isNull
Q_GADGET bool isNull
Definition: qgsgeometry.h:126
QgsPointXY::x
Q_GADGET double x
Definition: qgspointxy.h:47
QgsHighlight::width
int width
Definition: qgshighlight.h:78
QgsSymbolLayer::setColor
virtual void setColor(const QColor &color)
The fill color.
Definition: qgssymbollayer.h:232
QgsSymbolLayer::PropertyFillColor
@ PropertyFillColor
Fill color.
Definition: qgssymbollayer.h:135
QgsPolylineXY
QVector< QgsPointXY > QgsPolylineXY
Polyline as represented as a vector of two-dimensional points.
Definition: qgsgeometry.h:51
QgsLineSymbolLayer::setWidth
virtual void setWidth(double width)
Sets the width of the line symbol layer.
Definition: qgssymbollayer.h:954
QgsRenderContext::setPainter
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
Definition: qgsrendercontext.h:491
QgsRectangle::yMinimum
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
Definition: qgsrectangle.h:177
QgsExpressionContextUtils::layerScope
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
Definition: qgsexpressioncontextutils.cpp:265
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:85
qgsmarkersymbollayer.h
QgsFeature::geometry
QgsGeometry geometry
Definition: qgsfeature.h:67
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:58
QgsMultiPolygonXY
QVector< QgsPolygonXY > QgsMultiPolygonXY
A collection of QgsPolygons that share a common collection of attributes.
Definition: qgsgeometry.h:92
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:168
QgsSymbol
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:64
QgsMapToPixel::toMapCoordinates
QgsPointXY toMapCoordinates(int x, int y) const
Transform device coordinates to map (world) coordinates.
Definition: qgsmaptopixel.cpp:108
QgsSymbolLayer::PropertyStrokeColor
@ PropertyStrokeColor
Stroke color.
Definition: qgssymbollayer.h:136
QgsSymbol::symbolLayer
QgsSymbolLayer * symbolLayer(int layer)
Returns the symbol layer at the specified index.
Definition: qgssymbol.cpp:385
QgsCoordinateTransform::isValid
bool isValid() const
Returns true if the coordinate transform is valid, ie both the source and destination CRS have been s...
Definition: qgscoordinatetransform.cpp:892
QgsHighlight::color
QColor color
Definition: qgshighlight.h:76
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:42
QgsGeometry::asMultiPolyline
QgsMultiPolylineXY asMultiPolyline() const
Returns the contents of the geometry as a multi-linestring.
Definition: qgsgeometry.cpp:1664
QgsMultiPointXY
QVector< QgsPointXY > QgsMultiPointXY
A collection of QgsPoints that share a common collection of attributes.
Definition: qgsgeometry.h:81
QgsWkbTypes::PolygonGeometry
@ PolygonGeometry
Definition: qgswkbtypes.h:144
QgsMapCanvasItem::setRect
void setRect(const QgsRectangle &r, bool resetRotation=true)
sets canvas item rectangle in map units
Definition: qgsmapcanvasitem.cpp:74
QgsGeometry::isMultipart
bool isMultipart() const SIP_HOLDGIL
Returns true if WKB of the geometry is of WKBMulti* type.
Definition: qgsgeometry.cpp:377
QgsSymbolLayer::setFillColor
virtual void setFillColor(const QColor &color)
Set fill color.
Definition: qgssymbollayer.h:250
QgsSimpleFillSymbolLayer::setStrokeWidth
void setStrokeWidth(double strokeWidth)
Definition: qgsfillsymbollayer.h:91
QgsRectangle::xMaximum
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
Definition: qgsrectangle.h:162
QgsHighlight::fillColor
QColor fillColor
Definition: qgshighlight.h:77
QgsGeometry::asPolygon
QgsPolygonXY asPolygon() const
Returns the contents of the geometry as a polygon.
Definition: qgsgeometry.cpp:1605
QgsSymbolLayer
Definition: qgssymbollayer.h:53
QgsMapCanvasItem
An abstract class for items that can be placed on the map canvas.
Definition: qgsmapcanvasitem.h:34
QgsMapCanvasItem::toCanvasCoordinates
QPointF toCanvasCoordinates(const QgsPointXY &point) const
transformation from map coordinates to screen coordinates
Definition: qgsmapcanvasitem.cpp:61
QgsFeature::setGeometry
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
Definition: qgsfeature.cpp:139
QgsSimpleLineSymbolLayer
A simple line symbol layer, which renders lines using a line in a variety of styles (e....
Definition: qgslinesymbollayer.h:40
QgsSimpleFillSymbolLayer::strokeWidth
double strokeWidth() const
Definition: qgsfillsymbollayer.h:90
qgsmaplayer.h
QgsSimpleMarkerSymbolLayer
Simple marker symbol layer, consisting of a rendered shape with solid fill color and an stroke.
Definition: qgsmarkersymbollayer.h:199
qgsrendercontext.h
QgsSimpleFillSymbolLayer::outputUnit
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
Definition: qgsfillsymbollayer.cpp:66
QgsSimpleMarkerSymbolLayer::strokeWidth
double strokeWidth() const
Returns the width of the marker's stroke.
Definition: qgsmarkersymbollayer.h:319
QgsRectangle::setXMinimum
void setXMinimum(double x) SIP_HOLDGIL
Set the minimum x value.
Definition: qgsrectangle.h:130
QgsMultiPolylineXY
QVector< QgsPolylineXY > QgsMultiPolylineXY
A collection of QgsPolylines that share a common collection of attributes.
Definition: qgsgeometry.h:85
qgscoordinatetransform.h
qgssymbollayer.h
QgsRectangle::xMinimum
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
Definition: qgsrectangle.h:167
qgsrenderer.h
QgsSimpleMarkerSymbolLayer::strokeWidthUnit
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the unit for the width of the marker's stroke.
Definition: qgsmarkersymbollayer.h:345
qgsfillsymbollayer.h
QgsSimpleMarkerSymbolLayer::setStrokeWidth
void setStrokeWidth(double w)
Sets the width of the marker's stroke.
Definition: qgsmarkersymbollayer.h:328
QgsRectangle::setXMaximum
void setXMaximum(double x) SIP_HOLDGIL
Set the maximum x value.
Definition: qgsrectangle.h:135
QgsSymbolLayer::subSymbol
virtual QgsSymbol * subSymbol()
Returns the symbol's sub symbol, if present.
Definition: qgssymbollayer.h:353
QgsHighlight::updatePosition
void updatePosition() override
called on changed extent or resize event to update position of the item
Definition: qgshighlight.cpp:252
QgsHighlight::setFillColor
void setFillColor(const QColor &fillColor)
Fill color for the highlight.
Definition: qgshighlight.cpp:103
qgsvectorlayer.h
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:44
QgsRectangle::setYMaximum
void setYMaximum(double y) SIP_HOLDGIL
Set the maximum y value.
Definition: qgsrectangle.h:145
QgsGeometry::asPoint
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
Definition: qgsgeometry.cpp:1544
QgsWkbTypes::LineGeometry
@ LineGeometry
Definition: qgswkbtypes.h:143
QgsWkbTypes::PointGeometry
@ PointGeometry
Definition: qgswkbtypes.h:142
QgsRectangle::yMaximum
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
Definition: qgsrectangle.h:172
qgsgeometry.h
qgslinesymbollayer.h
qgshighlight.h
QgsHighlight::layer
QgsMapLayer * layer() const
Returns the layer for which this highlight has been created.
Definition: qgshighlight.h:161
QgsRectangle::setYMinimum
void setYMinimum(double y) SIP_HOLDGIL
Set the minimum y value.
Definition: qgsrectangle.h:140
QgsMapCanvasItem::rect
QgsRectangle rect() const
returns canvas item rectangle in map units
Definition: qgsmapcanvasitem.cpp:68
c
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
Definition: porting_processing.dox:1
QgsGeometry
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
QgsMapToPixel
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:38
QgsSymbolLayer::setStrokeColor
virtual void setStrokeColor(const QColor &color)
Set stroke color.
Definition: qgssymbollayer.h:238
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsFeature::hasGeometry
bool hasGeometry() const
Returns true if the feature has an associated geometry.
Definition: qgsfeature.cpp:199
QgsRectangle::width
double width() const SIP_HOLDGIL
Returns the width of the rectangle.
Definition: qgsrectangle.h:202
QgsMapLayer
Base class for all map layer types.
Definition: qgsmaplayer.h:83
QgsVector
A class to represent a vector.
Definition: qgsvector.h:30
QgsSimpleFillSymbolLayer
Definition: qgsfillsymbollayer.h:40
QgsHighlight::QgsHighlight
QgsHighlight(QgsMapCanvas *mapCanvas, const QgsGeometry &geom, QgsMapLayer *layer)
Constructor for QgsHighlight.
Definition: qgshighlight.cpp:50
QgsHighlight::setWidth
void setWidth(int width)
Set stroke width.
Definition: qgshighlight.cpp:184
QgsWkbTypes::UnknownGeometry
@ UnknownGeometry
Definition: qgswkbtypes.h:145
QgsGeometry::asPolyline
QgsPolylineXY asPolyline() const
Returns the contents of the geometry as a polyline.
Definition: qgsgeometry.cpp:1559
QgsGeometry::asMultiPoint
QgsMultiPointXY asMultiPoint() const
Returns the contents of the geometry as a multi-point.
Definition: qgsgeometry.cpp:1640
QgsGeometry::boundingBox
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
Definition: qgsgeometry.cpp:996
QgsFeature
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:56
QgsHighlight::~QgsHighlight
~QgsHighlight() override
Definition: qgshighlight.cpp:88
QgsLineSymbolLayer::widthUnit
QgsUnitTypes::RenderUnit widthUnit() const
Returns the units for the line's width.
Definition: qgssymbollayer.h:1047
QgsMapSettings
The QgsMapSettings class contains configuration for rendering of the map.
Definition: qgsmapsettings.h:88
QgsCoordinateTransform
Class for doing transforms between two map coordinate systems.
Definition: qgscoordinatetransform.h:53
QgsGeometry::type
QgsWkbTypes::GeometryType type
Definition: qgsgeometry.h:127
QgsRectangle::isEmpty
bool isEmpty() const
Returns true if the rectangle is empty.
Definition: qgsrectangle.h:437
qgssymbol.h
QgsMapSettings::mapToPixel
const QgsMapToPixel & mapToPixel() const
Definition: qgsmapsettings.h:436
QgsHighlight::updateRect
void updateRect()
recalculates needed rectangle
Definition: qgshighlight.cpp:386
QgsUnitTypes::RenderMapUnits
@ RenderMapUnits
Map units.
Definition: qgsunittypes.h:169
QgsSymbolLayer::setDataDefinedProperty
virtual void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the layer.
Definition: qgssymbollayer.cpp:113
QgsGeometry::asMultiPolygon
QgsMultiPolygonXY asMultiPolygon() const
Returns the contents of the geometry as a multi-polygon.
Definition: qgsgeometry.cpp:1717
QgsSymbol::symbolLayerCount
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
Definition: qgssymbol.h:183
QgsExpressionContext::setFeature
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
Definition: qgsexpressioncontext.cpp:521
QgsHighlight::paint
void paint(QPainter *p) override
function to be implemented by derived classes
Definition: qgshighlight.cpp:257