25 mIconSize( 5 ), mIconType( ICON_BOX ), mGeometryType( geomType )
27 mPen = QPen( QColor( 255, 0, 0 ) );
28 mBrush = QBrush( QColor( 255, 0, 0 ) );
37 if ( !mGeometry || !painter )
43 painter->translate( -pos() );
47 painter->setBrush( mBrush );
51 painter->setBrush( Qt::NoBrush );
53 painter->setPen( mPen );
56 std::unique_ptr< QgsAbstractGeometry > paintGeom( mGeometry->clone() );
59 paintGeom->draw( *painter );
67 while ( paintGeom->nextVertex( vertexId, vertex ) )
69 drawVertex( painter, vertex.
x(), vertex.
y() );
83 void QgsGeometryRubberBand::drawVertex( QPainter *p,
double x,
double y )
85 qreal s = ( mIconSize - 1 ) / 2.0;
93 p->drawLine( QLineF( x - s, y, x + s, y ) );
94 p->drawLine( QLineF( x, y - s, x, y + s ) );
98 p->drawLine( QLineF( x - s, y - s, x + s, y + s ) );
99 p->drawLine( QLineF( x - s, y + s, x + s, y - s ) );
103 p->drawLine( QLineF( x - s, y - s, x + s, y - s ) );
104 p->drawLine( QLineF( x + s, y - s, x + s, y + s ) );
105 p->drawLine( QLineF( x + s, y + s, x - s, y + s ) );
106 p->drawLine( QLineF( x - s, y + s, x - s, y - s ) );
110 p->drawRect( x - s, y - s, mIconSize, mIconSize );
114 p->drawEllipse( x - s, y - s, mIconSize, mIconSize );
121 mGeometry.reset( geom );
125 setRect( rubberBandRectangle() );
133 mGeometry->moveVertex(
id, newPos );
134 setRect( rubberBandRectangle() );
140 mBrush.setColor(
c );
150 mPen.setWidth( width );
155 mPen.setStyle( penStyle );
160 mBrush.setStyle( brushStyle );
165 mDrawVertices = isVerticesDrawn;
168 QgsRectangle QgsGeometryRubberBand::rubberBandRectangle()
const
171 qreal s = ( mIconSize - 1 ) / 2.0 * scale;
172 qreal p = mPen.width() * scale;
173 return mGeometry->boundingBox().buffered( s + p );