QGIS API Documentation  2.99.0-Master (9f5e33a)
qgsrubberband.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrubberband.cpp - Rubberband widget for drawing multilines and polygons
3  --------------------------------------
4  Date : 07-Jan-2006
5  Copyright : (C) 2006 by Tom Elwertowski
6  Email : telwertowski at users dot sourceforge dot net
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 "qgsrubberband.h"
17 #include "qgsfeature.h"
18 #include "qgsgeometry.h"
19 #include "qgslogger.h"
20 #include "qgsmapcanvas.h"
21 #include "qgsvectorlayer.h"
22 #include <QPainter>
23 
25  : QgsMapCanvasItem( mapCanvas )
26  , mIconSize( 5 )
27  , mIconType( ICON_CIRCLE )
28  , mGeometryType( geometryType )
29  , mTranslationOffsetX( 0.0 )
30  , mTranslationOffsetY( 0.0 )
31 {
32  reset( geometryType );
33  QColor color( Qt::lightGray );
34  color.setAlpha( 63 );
35  setColor( color );
36  setWidth( 1 );
37  setLineStyle( Qt::SolidLine );
38  setBrushStyle( Qt::SolidPattern );
39  setSecondaryStrokeColor( QColor() );
40 }
41 
43  : QgsMapCanvasItem( nullptr )
44  , mIconSize( 5 )
45  , mIconType( ICON_CIRCLE )
46  , mGeometryType( QgsWkbTypes::PolygonGeometry )
47  , mTranslationOffsetX( 0.0 )
48  , mTranslationOffsetY( 0.0 )
49 {
50 }
51 
52 void QgsRubberBand::setColor( const QColor &color )
53 {
54  setStrokeColor( color );
55  setFillColor( color );
56 }
57 
58 void QgsRubberBand::setFillColor( const QColor &color )
59 {
60  mBrush.setColor( color );
61 }
62 
63 void QgsRubberBand::setStrokeColor( const QColor &color )
64 {
65  mPen.setColor( color );
66 }
67 
68 void QgsRubberBand::setSecondaryStrokeColor( const QColor &color )
69 {
70  mSecondaryPen.setColor( color );
71 }
72 
74 {
75  mPen.setWidth( width );
76 }
77 
79 {
80  mIconType = icon;
81 }
82 
84 {
85  mIconSize = iconSize;
86 }
87 
88 void QgsRubberBand::setLineStyle( Qt::PenStyle penStyle )
89 {
90  mPen.setStyle( penStyle );
91 }
92 
93 void QgsRubberBand::setBrushStyle( Qt::BrushStyle brushStyle )
94 {
95  mBrush.setStyle( brushStyle );
96 }
97 
99 {
100  mPoints.clear();
101  mGeometryType = geometryType;
102  updateRect();
103  update();
104 }
105 
106 void QgsRubberBand::addPoint( const QgsPointXY &p, bool doUpdate /* = true */, int geometryIndex )
107 {
108  if ( geometryIndex < 0 )
109  {
110  geometryIndex = mPoints.size() - 1;
111  }
112 
113  if ( geometryIndex < 0 || geometryIndex > mPoints.size() )
114  {
115  return;
116  }
117 
118  if ( geometryIndex == mPoints.size() )
119  {
120  mPoints.push_back( QList<QgsPointXY>() << p );
121  }
122 
123  if ( mPoints.at( geometryIndex ).size() == 2 &&
124  mPoints.at( geometryIndex ).at( 0 ) == mPoints.at( geometryIndex ).at( 1 ) )
125  {
126  mPoints[geometryIndex].last() = p;
127  }
128  else
129  {
130  mPoints[geometryIndex] << p;
131  }
132 
133 
134  if ( doUpdate )
135  {
136  setVisible( true );
137  updateRect();
138  update();
139  }
140 }
141 
142 void QgsRubberBand::closePoints( bool doUpdate, int geometryIndex )
143 {
144  if ( geometryIndex < 0 || geometryIndex >= mPoints.size() )
145  {
146  return;
147  }
148 
149  if ( mPoints.at( geometryIndex ).at( 0 ) != mPoints.at( geometryIndex ).at( mPoints.at( geometryIndex ).size() - 1 ) )
150  {
151  mPoints[geometryIndex] << mPoints.at( geometryIndex ).at( 0 );
152  }
153 
154  if ( doUpdate )
155  {
156  setVisible( true );
157  updateRect();
158  update();
159  }
160 }
161 
162 
163 void QgsRubberBand::removePoint( int index, bool doUpdate/* = true*/, int geometryIndex/* = 0*/ )
164 {
165 
166  if ( mPoints.size() < geometryIndex + 1 )
167  {
168  return;
169  }
170 
171 
172  if ( !mPoints[geometryIndex].isEmpty() )
173  {
174  // negative index removes from end, e.g., -1 removes last one
175  if ( index < 0 )
176  {
177  index = mPoints.at( geometryIndex ).size() + index;
178  }
179  mPoints[geometryIndex].removeAt( index );
180  }
181 
182  if ( doUpdate )
183  {
184  updateRect();
185  update();
186  }
187 }
188 
189 void QgsRubberBand::removeLastPoint( int geometryIndex, bool doUpdate/* = true*/ )
190 {
191  removePoint( -1, doUpdate, geometryIndex );
192 }
193 
194 void QgsRubberBand::movePoint( const QgsPointXY &p, int geometryIndex )
195 {
196  if ( mPoints.size() < geometryIndex + 1 )
197  {
198  return;
199  }
200 
201  if ( mPoints.at( geometryIndex ).size() < 1 )
202  {
203  return;
204  }
205 
206  mPoints[geometryIndex].last() = p;
207 
208  updateRect();
209  update();
210 }
211 
212 void QgsRubberBand::movePoint( int index, const QgsPointXY &p, int geometryIndex )
213 {
214  if ( mPoints.size() < geometryIndex + 1 )
215  {
216  return;
217  }
218 
219  if ( mPoints.at( geometryIndex ).size() < index )
220  {
221  return;
222  }
223 
224  mPoints[geometryIndex][index] = p;
225 
226  updateRect();
227  update();
228 }
229 
231 {
232  if ( geom.isNull() )
233  {
234  reset( mGeometryType );
235  return;
236  }
237 
238  reset( geom.type() );
239  addGeometry( geom, layer );
240 }
241 
243 {
244  if ( geom.isNull() )
245  {
246  return;
247  }
248 
249  //maprender object of canvas
250  const QgsMapSettings &ms = mMapCanvas->mapSettings();
251 
252  int idx = mPoints.size();
253 
254  switch ( geom.wkbType() )
255  {
256 
257  case QgsWkbTypes::Point:
259  {
260  QgsPointXY pt;
261  if ( layer )
262  {
263  pt = ms.layerToMapCoordinates( layer, geom.asPoint() );
264  }
265  else
266  {
267  pt = geom.asPoint();
268  }
269  addPoint( pt, false, idx );
270  removeLastPoint( idx, false );
271  }
272  break;
273 
276  {
277  QgsMultiPoint mpt = geom.asMultiPoint();
278  for ( int i = 0; i < mpt.size(); ++i, ++idx )
279  {
280  QgsPointXY pt = mpt[i];
281  if ( layer )
282  {
283  addPoint( ms.layerToMapCoordinates( layer, pt ), false, idx );
284  removeLastPoint( idx, false );
285  }
286  else
287  {
288  addPoint( pt, false, idx );
289  removeLastPoint( idx, false );
290  }
291  }
292  }
293  break;
294 
297  {
298  QgsPolyline line = geom.asPolyline();
299  for ( int i = 0; i < line.count(); i++ )
300  {
301  if ( layer )
302  {
303  addPoint( ms.layerToMapCoordinates( layer, line[i] ), false, idx );
304  }
305  else
306  {
307  addPoint( line[i], false, idx );
308  }
309  }
310  }
311  break;
312 
315  {
316 
317  QgsMultiPolyline mline = geom.asMultiPolyline();
318  for ( int i = 0; i < mline.size(); ++i, ++idx )
319  {
320  QgsPolyline line = mline[i];
321 
322  if ( line.isEmpty() )
323  {
324  --idx;
325  }
326 
327  for ( int j = 0; j < line.size(); ++j )
328  {
329  if ( layer )
330  {
331  addPoint( ms.layerToMapCoordinates( layer, line[j] ), false, idx );
332  }
333  else
334  {
335  addPoint( line[j], false, idx );
336  }
337  }
338  }
339  }
340  break;
341 
344  {
345  QgsPolygon poly = geom.asPolygon();
346  QgsPolyline line = poly[0];
347  for ( int i = 0; i < line.count(); i++ )
348  {
349  if ( layer )
350  {
351  addPoint( ms.layerToMapCoordinates( layer, line[i] ), false, idx );
352  }
353  else
354  {
355  addPoint( line[i], false, idx );
356  }
357  }
358  }
359  break;
360 
363  {
364 
365  QgsMultiPolygon multipoly = geom.asMultiPolygon();
366  for ( int i = 0; i < multipoly.size(); ++i, ++idx )
367  {
368  QgsPolygon poly = multipoly[i];
369  QgsPolyline line = poly[0];
370  for ( int j = 0; j < line.count(); ++j )
371  {
372  if ( layer )
373  {
374  addPoint( ms.layerToMapCoordinates( layer, line[j] ), false, idx );
375  }
376  else
377  {
378  addPoint( line[j], false, idx );
379  }
380  }
381  }
382  }
383  break;
384 
386  default:
387  return;
388  }
389 
390  setVisible( true );
391  updateRect();
392  update();
393 }
394 
396 {
397  if ( !mMapCanvas )
398  {
399  return;
400  }
401 
402  const QgsMapToPixel *transform = mMapCanvas->getCoordinateTransform();
403  QgsPointXY ll = transform->toMapCoordinates( rect.left(), rect.bottom() );
404  QgsPointXY lr = transform->toMapCoordinates( rect.right(), rect.bottom() );
405  QgsPointXY ul = transform->toMapCoordinates( rect.left(), rect.top() );
406  QgsPointXY ur = transform->toMapCoordinates( rect.right(), rect.top() );
407 
409  addPoint( ll, false );
410  addPoint( lr, false );
411  addPoint( ur, false );
412  addPoint( ul, true );
413 }
414 
415 void QgsRubberBand::paint( QPainter *p )
416 {
417  if ( !mPoints.isEmpty() )
418  {
419  Q_FOREACH ( const QList<QgsPointXY> &line, mPoints )
420  {
421  QVector<QPointF> pts;
422  Q_FOREACH ( const QgsPointXY &pt, line )
423  {
424  const QPointF cur = toCanvasCoordinates( QgsPointXY( pt.x() + mTranslationOffsetX, pt.y() + mTranslationOffsetY ) ) - pos();
425  if ( pts.empty() || std::abs( pts.back().x() - cur.x() ) > 1 || std::abs( pts.back().y() - cur.y() ) > 1 )
426  pts.append( cur );
427  }
428 
429  if ( mSecondaryPen.color().isValid() )
430  {
431  mSecondaryPen.setWidth( mPen.width() + 2 );
432 
433  p->setBrush( Qt::NoBrush );
434  p->setPen( mSecondaryPen );
435  drawShape( p, pts );
436  }
437 
438  p->setBrush( mBrush );
439  p->setPen( mPen );
440  drawShape( p, pts );
441  }
442  }
443 }
444 
445 void QgsRubberBand::drawShape( QPainter *p, QVector<QPointF> &pts )
446 {
447  switch ( mGeometryType )
448  {
450  {
451  p->drawPolygon( pts );
452  }
453  break;
454 
456  {
457  Q_FOREACH ( QPointF pt, pts )
458  {
459  double x = pt.x();
460  double y = pt.y();
461 
462  qreal s = ( mIconSize - 1 ) / 2.0;
463 
464  switch ( mIconType )
465  {
466  case ICON_NONE:
467  break;
468 
469  case ICON_CROSS:
470  p->drawLine( QLineF( x - s, y, x + s, y ) );
471  p->drawLine( QLineF( x, y - s, x, y + s ) );
472  break;
473 
474  case ICON_X:
475  p->drawLine( QLineF( x - s, y - s, x + s, y + s ) );
476  p->drawLine( QLineF( x - s, y + s, x + s, y - s ) );
477  break;
478 
479  case ICON_BOX:
480  p->drawLine( QLineF( x - s, y - s, x + s, y - s ) );
481  p->drawLine( QLineF( x + s, y - s, x + s, y + s ) );
482  p->drawLine( QLineF( x + s, y + s, x - s, y + s ) );
483  p->drawLine( QLineF( x - s, y + s, x - s, y - s ) );
484  break;
485 
486  case ICON_FULL_BOX:
487  p->drawRect( x - s, y - s, mIconSize, mIconSize );
488  break;
489 
490  case ICON_CIRCLE:
491  p->drawEllipse( x - s, y - s, mIconSize, mIconSize );
492  break;
493 
494  case ICON_DIAMOND:
495  case ICON_FULL_DIAMOND:
496  {
497  QPointF pts[] =
498  {
499  QPointF( x, y - s ),
500  QPointF( x + s, y ),
501  QPointF( x, y + s ),
502  QPointF( x - s, y )
503  };
504  if ( mIconType == ICON_FULL_DIAMOND )
505  p->drawPolygon( pts, 4 );
506  else
507  p->drawPolyline( pts, 4 );
508  }
509  }
510  }
511  }
512  break;
513 
515  default:
516  {
517  p->drawPolyline( pts );
518  }
519  break;
520  }
521 }
522 
524 {
525  if ( mPoints.empty() )
526  {
527  setRect( QgsRectangle() );
528  setVisible( false );
529  return;
530  }
531 
532  const QgsMapToPixel &m2p = *( mMapCanvas->getCoordinateTransform() );
533 
534  qreal w = ( ( mIconSize - 1 ) / 2 + mPen.width() ); // in canvas units
535 
536  QgsRectangle r; // in canvas units
537  for ( int i = 0; i < mPoints.size(); ++i )
538  {
539  QList<QgsPointXY>::const_iterator it = mPoints.at( i ).constBegin(),
540  itE = mPoints.at( i ).constEnd();
541  for ( ; it != itE; ++it )
542  {
543  QgsPointXY p( it->x() + mTranslationOffsetX, it->y() + mTranslationOffsetY );
544  p = m2p.transform( p );
545  QgsRectangle rect( p.x() - w, p.y() - w, p.x() + w, p.y() + w );
546 
547  if ( r.isEmpty() )
548  {
549  // Get rectangle of the first point
550  r = rect;
551  }
552  else
553  {
554  r.combineExtentWith( rect );
555  }
556  }
557  }
558 
559  // This is an hack to pass QgsMapCanvasItem::setRect what it
560  // expects (encoding of position and size of the item)
561  qreal res = m2p.mapUnitsPerPixel();
562  QgsPointXY topLeft = m2p.toMapPoint( r.xMinimum(), r.yMinimum() );
563  QgsRectangle rect( topLeft.x(), topLeft.y(), topLeft.x() + r.width()*res, topLeft.y() - r.height()*res );
564 
565  setRect( rect );
566 }
567 
569 {
570  // re-compute rectangle
571  // See https://issues.qgis.org/issues/12392
572  // NOTE: could be optimized by saving map-extent
573  // of rubberband and simply re-projecting
574  // that to device-rectangle on "updatePosition"
575  updateRect();
576 }
577 
578 void QgsRubberBand::setTranslationOffset( double dx, double dy )
579 {
580  mTranslationOffsetX = dx;
581  mTranslationOffsetY = dy;
582  updateRect();
583 }
584 
586 {
587  return mPoints.size();
588 }
589 
590 int QgsRubberBand::partSize( int geometryIndex ) const
591 {
592  if ( geometryIndex < 0 || geometryIndex >= mPoints.size() ) return 0;
593  return mPoints[geometryIndex].size();
594 }
595 
597 {
598  int count = 0;
599  QList<QList<QgsPointXY> >::const_iterator it = mPoints.constBegin();
600  for ( ; it != mPoints.constEnd(); ++it )
601  {
602  QList<QgsPointXY>::const_iterator iter = it->constBegin();
603  for ( ; iter != it->constEnd(); ++iter )
604  {
605  ++count;
606  }
607  }
608  return count;
609 }
610 
611 const QgsPointXY *QgsRubberBand::getPoint( int i, int j ) const
612 {
613  if ( i < mPoints.size() && j < mPoints[i].size() )
614  return &mPoints[i][j];
615  else
616  return nullptr;
617 }
618 
620 {
621  QgsGeometry geom;
622 
623  switch ( mGeometryType )
624  {
626  {
627  QgsPolygon polygon;
628  QList< QList<QgsPointXY> >::const_iterator it = mPoints.constBegin();
629  for ( ; it != mPoints.constEnd(); ++it )
630  {
631  polygon.append( getPolyline( *it ) );
632  }
633  geom = QgsGeometry::fromPolygon( polygon );
634  break;
635  }
636 
638  {
639  QgsMultiPoint multiPoint;
640 
641  QList< QList<QgsPointXY> >::const_iterator it = mPoints.constBegin();
642  for ( ; it != mPoints.constEnd(); ++it )
643  {
644  multiPoint += getPolyline( *it );
645  }
646  geom = QgsGeometry::fromMultiPoint( multiPoint );
647  break;
648  }
649 
651  default:
652  {
653  if ( !mPoints.isEmpty() )
654  {
655  if ( mPoints.size() > 1 )
656  {
657  QgsMultiPolyline multiPolyline;
658  QList< QList<QgsPointXY> >::const_iterator it = mPoints.constBegin();
659  for ( ; it != mPoints.constEnd(); ++it )
660  {
661  multiPolyline.append( getPolyline( *it ) );
662  }
663  geom = QgsGeometry::fromMultiPolyline( multiPolyline );
664  }
665  else
666  {
667  geom = QgsGeometry::fromPolyline( getPolyline( mPoints.at( 0 ) ) );
668  }
669  }
670  break;
671  }
672  }
673  return geom;
674 }
675 
676 QgsPolyline QgsRubberBand::getPolyline( const QList<QgsPointXY> &points )
677 {
678  QgsPolyline polyline;
679  QList<QgsPointXY>::const_iterator iter = points.constBegin();
680  for ( ; iter != points.constEnd(); ++iter )
681  {
682  polyline.append( *iter );
683  }
684  return polyline;
685 }
QgsPolygon asPolygon() const
Return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list...
A cross is used to highlight points (x)
Definition: qgsrubberband.h:57
void setIconSize(int iconSize)
Sets the size of the point icons.
void setWidth(int width)
Sets the width of the line.
QgsMultiPolyline asMultiPolyline() const
Return contents of the geometry as a multi linestring if wkbType is WKBMultiLineString, otherwise an empty list.
A rectangle specified with double values.
Definition: qgsrectangle.h:38
int numberOfVertices() const
Returns count of vertices in all lists of mPoint.
QgsRectangle rect() const
returns canvas item rectangle in map units
void setToCanvasRectangle(QRect rect)
Sets this rubber band to a map canvas rectangle.
static QgsGeometry fromPolyline(const QgsPolyline &polyline)
Creates a new geometry from a QgsPolyline object.
void setStrokeColor(const QColor &color)
Sets the stroke color for the rubberband.
IconType icon() const
Returns the current icon type to highlight point geometries.
bool isNull() const
Returns true if the geometry is null (ie, contains no underlying geometry accessible via geometry() )...
void setTranslationOffset(double dx, double dy)
Adds translation to original coordinates (all in map coordinates)
void setLineStyle(Qt::PenStyle penStyle)
Sets the style of the line.
QgsWkbTypes::Type wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
double y
Definition: qgspointxy.h:47
A class to represent a 2D point.
Definition: qgspointxy.h:42
An abstract class for items that can be placed on the map canvas.
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:96
void setSecondaryStrokeColor(const QColor &color)
Sets a secondary stroke color for the rubberband which will be drawn under the main stroke color...
A diamond is used to highlight points (◇)
Definition: qgsrubberband.h:78
virtual void updatePosition() override
called on changed extent or resize event to update position of the item
A cross is used to highlight points (+)
Definition: qgsrubberband.h:52
const QgsPointXY * getPoint(int i, int j=0) const
Returns a vertex.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:73
QgsPolyline asPolyline() const
Return contents of the geometry as a polyline if wkbType is WKBLineString, otherwise an empty list...
QVector< QgsPointXY > QgsPolyline
Polyline is represented as a vector of points.
Definition: qgsgeometry.h:48
virtual void paint(QPainter *p) override
Paints the rubber band in response to an update event.
int width() const
Returns the current width of the line or stroke width for polygon.
The QgsMapSettings class contains configuration for rendering of the map.
void drawShape(QPainter *p, QVector< QPointF > &pts)
Draws shape of the rubber band.
void setToGeometry(const QgsGeometry &geom, QgsVectorLayer *layer)
Sets this rubber band to the geometry of an existing feature.
QgsRubberBand(QgsMapCanvas *mapCanvas, QgsWkbTypes::GeometryType geometryType=QgsWkbTypes::LineGeometry)
Creates a new RubberBand.
QgsMultiPoint asMultiPoint() const
Return contents of the geometry as a multi point if wkbType is WKBMultiPoint, otherwise an empty list...
void closePoints(bool doUpdate=true, int geometryIndex=0)
Ensures that a polygon geometry is closed and that the last vertex equals the first vertex...
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:35
QgsPointXY transform(const QgsPointXY &p) const
Transform the point from map (world) coordinates to device coordinates.
QgsGeometry asGeometry() const
Returns the rubberband as a Geometry.
bool isEmpty() const
Returns true if the rectangle is empty.
A circle is used to highlight points (○)
Definition: qgsrubberband.h:67
void addGeometry(const QgsGeometry &geom, QgsVectorLayer *layer)
Adds the geometry of an existing feature to a rubberband This is useful for multi feature highlightin...
void removePoint(int index=0, bool doUpdate=true, int geometryIndex=0)
Removes a vertex from the rubberband and (optionally) updates canvas.
double width() const
Returns the width of the rectangle.
Definition: qgsrectangle.h:118
void addPoint(const QgsPointXY &p, bool doUpdate=true, int geometryIndex=0)
Adds a vertex to the rubberband and update canvas.
void movePoint(const QgsPointXY &p, int geometryIndex=0)
Moves the rubber band point specified by index.
void setRect(const QgsRectangle &r, bool resetRotation=true)
sets canvas item rectangle in map units
QVector< QgsPolygon > QgsMultiPolygon
A collection of QgsPolygons that share a common collection of attributes.
Definition: qgsgeometry.h:76
void setFillColor(const QColor &color)
Sets the fill color for the rubberband.
QVector< QgsPolyline > QgsPolygon
Polygon: first item of the list is outer ring, inner rings (if any) start from second item...
Definition: qgsgeometry.h:55
double mapUnitsPerPixel() const
Return current map units per pixel.
QgsWkbTypes::GeometryType type() const
Returns type of the geometry as a QgsWkbTypes::GeometryType.
double x
Definition: qgspointxy.h:46
static QgsGeometry fromPolygon(const QgsPolygon &polygon)
Creates a new geometry from a QgsPolygon.
QgsMapCanvasItem(QgsMapCanvas *mapCanvas)
protected constructor: cannot be constructed directly
void setBrushStyle(Qt::BrushStyle brushStyle)
Sets the style of the brush.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
Definition: qgsrectangle.h:106
QVector< QgsPolyline > QgsMultiPolyline
A collection of QgsPolylines that share a common collection of attributes.
Definition: qgsgeometry.h:69
const QgsMapSettings & mapSettings() const
Get access to properties used for map rendering.
void combineExtentWith(const QgsRectangle &rect)
Expand the rectangle so that covers both the original rectangle and the given rectangle.
void setIcon(IconType icon)
Sets the icon type to highlight point geometries.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:136
A box is used to highlight points (□)
Definition: qgsrubberband.h:62
QgsPointXY toMapPoint(double x, double y) const
QgsPointXY asPoint() const
Return contents of the geometry as a point if wkbType is WKBPoint, otherwise returns [0...
static QgsGeometry fromMultiPoint(const QgsMultiPoint &multipoint)
Creates a new geometry from a QgsMultiPoint object.
int iconSize() const
Returns the current icon size of the point icons.
QgsPointXY layerToMapCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from layer&#39;s CRS to output CRS
QgsMultiPolygon asMultiPolygon() const
Return contents of the geometry as a multi polygon if wkbType is WKBMultiPolygon, otherwise an empty ...
int partSize(int geometryIndex) const
Returns number of vertices in feature part.
QgsMapCanvas * mMapCanvas
pointer to map canvas
QVector< QgsPointXY > QgsMultiPoint
A collection of QgsPoints that share a common collection of attributes.
Definition: qgsgeometry.h:62
A diamond is used to highlight points (◆)
Definition: qgsrubberband.h:84
double xMinimum() const
Returns the x minimum value (left side of rectangle).
Definition: qgsrectangle.h:96
const QgsMapToPixel * getCoordinateTransform()
Get the current coordinate transform.
void reset(QgsWkbTypes::GeometryType geometryType=QgsWkbTypes::LineGeometry)
Clears all the geometries in this rubberband.
void setColor(const QColor &color)
Sets the color for the rubberband.
No icon is used.
Definition: qgsrubberband.h:47
int size() const
Returns number of geometries.
QPointF toCanvasCoordinates(const QgsPointXY &point) const
transformation from map coordinates to screen coordinates
Represents a vector layer which manages a vector based data sets.
void removeLastPoint(int geometryIndex=0, bool doUpdate=true)
Removes the last point.
QgsPointXY toMapCoordinates(int x, int y) const
void updateRect()
Recalculates needed rectangle.
double height() const
Returns the height of the rectangle.
Definition: qgsrectangle.h:125
A full box is used to highlight points (■)
Definition: qgsrubberband.h:72
static QgsGeometry fromMultiPolyline(const QgsMultiPolyline &multiline)
Creates a new geometry from a QgsMultiPolyline object.