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