25 mIconSize( 5 ), mIconType( ICON_BOX ), mGeometryType( geomType )
27 mPen = QPen( QColor( 255, 0, 0 ) );
28 mBrush = QBrush( QColor( 255, 0, 0 ) );
38 if ( !mGeometry || !painter )
44 painter->translate( -pos() );
48 painter->setBrush( mBrush );
52 painter->setBrush( Qt::NoBrush );
54 painter->setPen( mPen );
60 paintGeom->
draw( *painter );
65 while ( paintGeom->
nextVertex( vertexId, vertex ) )
67 drawVertex( painter, vertex.
x(), vertex.
y() );
74 void QgsGeometryRubberBand::drawVertex( QPainter *p,
double x,
double y )
76 qreal s = ( mIconSize - 1 ) / 2.0;
84 p->drawLine( QLineF( x - s, y, x + s, y ) );
85 p->drawLine( QLineF( x, y - s, x, y + s ) );
89 p->drawLine( QLineF( x - s, y - s, x + s, y + s ) );
90 p->drawLine( QLineF( x - s, y + s, x + s, y - s ) );
94 p->drawLine( QLineF( x - s, y - s, x + s, y - s ) );
95 p->drawLine( QLineF( x + s, y - s, x + s, y + s ) );
96 p->drawLine( QLineF( x + s, y + s, x - s, y + s ) );
97 p->drawLine( QLineF( x - s, y + s, x - s, y - s ) );
101 p->drawRect( x - s, y - s, mIconSize, mIconSize );
105 p->drawEllipse( x - s, y - s, mIconSize, mIconSize );
117 setRect( rubberBandRectangle() );
126 setRect( rubberBandRectangle() );
132 mBrush.setColor( c );
142 mPen.setWidth( width );
147 mPen.setStyle( penStyle );
152 mBrush.setStyle( brushStyle );
155 QgsRectangle QgsGeometryRubberBand::rubberBandRectangle()
const 158 qreal s = ( mIconSize - 1 ) / 2.0 * scale;
159 qreal p = mPen.width() * scale;
A circle is used to highlight points (○)
A rectangle specified with double values.
virtual void transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) SIP_THROW(QgsCsException)=0
Transforms the geometry using a coordinate transform.
double mapUnitsPerPixel() const
Returns the mapUnitsPerPixel (map units per pixel) for the canvas.
void setGeometry(QgsAbstractGeometry *geom)
Sets geometry (takes ownership). Geometry is expected to be in map coordinates.
A cross is used to highlight points (+)
A box is used to highlight points (□)
An abstract class for items that can be placed on the map canvas.
void setFillColor(const QColor &c)
Sets fill color for vertex markers.
void setStrokeWidth(int width)
Sets stroke width.
virtual bool nextVertex(QgsVertexId &id, QgsPoint &vertex) const =0
Returns next vertex id and coordinates.
virtual QgsRectangle boundingBox() const =0
Returns the minimal bounding box for the geometry.
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
Map canvas is a class for displaying all GIS data types on a canvas.
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
~QgsGeometryRubberBand() override
void moveVertex(QgsVertexId id, const QgsPoint &newPos)
Moves vertex to new position (in map coordinates)
A full box is used to highlight points (■)
Utility class for identifying a unique vertex within a geometry.
QgsRectangle buffered(double width) const
Gets rectangle enlarged by buffer.
void setStrokeColor(const QColor &c)
Sets stroke color for vertex markers.
void setRect(const QgsRectangle &r, bool resetRotation=true)
sets canvas item rectangle in map units
QgsGeometryRubberBand(QgsMapCanvas *mapCanvas, QgsWkbTypes::GeometryType geomType=QgsWkbTypes::LineGeometry)
Abstract base class for all geometries.
Point geometry type, with support for z-dimension and m-values.
void setBrushStyle(Qt::BrushStyle brushStyle)
Sets brush style.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
virtual bool moveVertex(QgsVertexId position, const QgsPoint &newPos)=0
Moves a vertex within the geometry.
virtual void draw(QPainter &p) const =0
Draws the geometry using the specified QPainter.
QgsMapCanvas * mMapCanvas
pointer to map canvas
const QgsMapToPixel * getCoordinateTransform()
Gets the current coordinate transform.
void paint(QPainter *painter) override
function to be implemented by derived classes
void setLineStyle(Qt::PenStyle penStyle)
Sets pen style.
A cross is used to highlight points (x)
QgsPointXY transform(const QgsPointXY &p) const
Transform the point from map (world) coordinates to device coordinates.