25 mGeometry( nullptr ), mIconSize( 5 ), mIconType( ICON_BOX ), mGeometryType( geomType )
38 if ( !mGeometry || !painter )
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;
101 p->
drawRect(
x - s, y - s, mIconSize, mIconSize );
117 setRect( rubberBandRectangle() );
126 setRect( rubberBandRectangle() );
155 QgsRectangle QgsGeometryRubberBand::rubberBandRectangle()
const 158 qreal s = ( mIconSize - 1 ) / 2.0 * scale;
A circle is used to highlight points (○)
A rectangle specified with double values.
void setStyle(Qt::PenStyle style)
void setGeometry(QgsAbstractGeometryV2 *geom)
Sets geometry (takes ownership).
A cross is used to highlight points (+)
A box is used to highlight points (□)
QgsRectangle buffer(double width)
Get rectangle enlarged by buffer.
void setOutlineWidth(int width)
Sets outline width.
An abstract class for items that can be placed on the map canvas.
void setOutlineColor(const QColor &c)
Sets outline color for vertex markes.
void setFillColor(const QColor &c)
Sets fill color for vertex markers.
Abstract base class for all geometries.
void drawLine(const QLineF &line)
double y() const
Returns the point's y-coordinate.
void setStyle(Qt::BrushStyle style)
Map canvas is a class for displaying all GIS data types on a canvas.
QgsPoint transform(const QgsPoint &p) const
Transform the point from map (world) coordinates to device coordinates.
void drawRect(const QRectF &rectangle)
A full box is used to highlight points (■)
double mapUnitsPerPixel() const
Returns the mapUnitsPerPixel (map units per pixel) for the canvas.
Utility class for identifying a unique vertex within a geometry.
void setPen(const QColor &color)
void drawEllipse(const QRectF &rectangle)
Point geometry type, with support for z-dimension and m-values.
void setRect(const QgsRectangle &r, bool resetRotation=true)
sets canvas item rectangle in map units
void setBrush(const QBrush &brush)
double x() const
Returns the point's x-coordinate.
virtual bool nextVertex(QgsVertexId &id, QgsPointV2 &vertex) const =0
Returns next vertex id and coordinates.
void setColor(const QColor &color)
void setBrushStyle(Qt::BrushStyle brushStyle)
Sets brush style.
virtual QgsRectangle boundingBox() const =0
Returns the minimal bounding box for the geometry.
QgsMapCanvas * mMapCanvas
pointer to map canvas
void translate(const QPointF &offset)
const QgsMapToPixel * getCoordinateTransform()
Get the current coordinate transform.
virtual void draw(QPainter &p) const =0
Draws the geometry using the specified QPainter.
virtual QgsAbstractGeometryV2 * clone() const =0
Clones the geometry by performing a deep copy.
virtual void paint(QPainter *painter) override
function to be implemented by derived classes
void setLineStyle(Qt::PenStyle penStyle)
Sets pen style.
virtual bool moveVertex(QgsVertexId position, const QgsPointV2 &newPos)=0
Moves a vertex within the geometry.
A cross is used to highlight points (x)
QgsGeometryRubberBand(QgsMapCanvas *mapCanvas, QGis::GeometryType geomType=QGis::Line)
void setColor(const QColor &color)
void moveVertex(QgsVertexId id, const QgsPointV2 &newPos)
Moves vertex to new position (in map coordinates)
virtual void transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform, bool transformZ=false)=0
Transforms the geometry using a coordinate transform.