26 setVertexDrawingEnabled(
false );
29 QgsCurve *QgsMapToolCaptureRubberBand::curve()
31 if ( mPoints.empty() )
34 switch ( mStringType )
40 if ( mPoints.count() != 3 )
52 bool QgsMapToolCaptureRubberBand::curveIsComplete()
const
64 mFirstPolygonPoint = firstPolygonPoint;
65 setStringType( stringType );
66 setRubberBandGeometryType( geomType );
75 void QgsMapToolCaptureRubberBand::addPoint(
const QgsPoint &point,
bool doUpdate )
77 if ( mPoints.count() == 0 )
78 mPoints.append( point );
80 mPoints.append( point );
86 void QgsMapToolCaptureRubberBand::movePoint(
const QgsPoint &point )
88 if ( mPoints.count() > 0 )
89 mPoints.last() = point ;
94 void QgsMapToolCaptureRubberBand::movePoint(
int index,
const QgsPoint &point )
96 if ( mPoints.count() > 0 && mPoints.size() > index )
97 mPoints[index] = point;
102 int QgsMapToolCaptureRubberBand::pointsCount()
104 return mPoints.size();
120 mPoints.removeAt( 1 );
127 QgsPoint QgsMapToolCaptureRubberBand::lastPoint()
const
129 if ( mPoints.empty() )
132 return mPoints.last();
135 QgsPoint QgsMapToolCaptureRubberBand::pointFromEnd(
int posFromEnd )
const
137 if ( posFromEnd < mPoints.size() )
138 return mPoints.at( mPoints.size() - 1 - posFromEnd );
143 void QgsMapToolCaptureRubberBand::removeLastPoint()
145 if ( mPoints.count() > 1 )
146 mPoints.removeLast();
156 void QgsMapToolCaptureRubberBand::updateCurve()
158 std::unique_ptr<QgsCurve> curve;
159 switch ( mStringType )
162 curve.reset( createLinearString() );
165 curve.reset( createCircularString() );
175 geom->setExteriorRing( curve.release() );
176 setGeometry( geom.release() );
180 setGeometry( curve.release() );
184 QgsCurve *QgsMapToolCaptureRubberBand::createLinearString()
190 points.prepend( mFirstPolygonPoint );
191 curve->setPoints( points );
194 curve->setPoints( mPoints );
196 return curve.release();
199 QgsCurve *QgsMapToolCaptureRubberBand::createCircularString()
202 curve->setPoints( mPoints );
207 polygonCurve->addVertex( mFirstPolygonPoint );
208 if ( !mPoints.empty() )
209 polygonCurve->addVertex( mPoints.first() );
210 polygonCurve->addCurve( curve.release() );
211 return polygonCurve.release();
214 return curve.release();