Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Circular string tools: Remove temporary rubber band of parent tool wh…
…en activating circular string tool
  • Loading branch information
mhugent committed Aug 27, 2015
1 parent 7fb27d4 commit 632656e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/app/qgsmaptooladdcircularstring.cpp
Expand Up @@ -109,6 +109,16 @@ void QgsMapToolAddCircularString::deactivate()
mPoints.clear();
delete mRubberBand; mRubberBand = 0;
removeCenterPointRubberBand();
QgsMapToolCapture::deactivate();
}

void QgsMapToolAddCircularString::activate()
{
if ( mParentTool )
{
mParentTool->deleteTempRubberBand();
}
QgsMapToolCapture::activate();
}

void QgsMapToolAddCircularString::createCenterPointRubberBand()
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsmaptooladdcircularstring.h
Expand Up @@ -32,6 +32,8 @@ class QgsMapToolAddCircularString: public QgsMapToolCapture

void deactivate();

void activate();

private slots:
void setParentTool( QgsMapTool* newTool, QgsMapTool* oldTool );

Expand Down
8 changes: 8 additions & 0 deletions src/app/qgsmaptoolcapture.cpp
Expand Up @@ -134,6 +134,14 @@ void QgsMapToolCapture::canvasMapMoveEvent( QgsMapMouseEvent * e )
mSnappingMarker->setCenter( point );
}

if ( !mTempRubberBand && mCaptureCurve.numPoints() > 0 )
{
mTempRubberBand = createRubberBand( mCaptureMode == CapturePolygon ? QGis::Polygon : QGis::Line, true );
QgsPointV2 pt = mCaptureCurve.endPoint();
mTempRubberBand->addPoint( QgsPoint( pt.x(), pt.y() ) );
mTempRubberBand->addPoint( point );
}

if ( mCaptureMode != CapturePoint && mTempRubberBand && mCapturing )
{
mTempRubberBand->movePoint( point );
Expand Down
3 changes: 2 additions & 1 deletion src/app/qgsmaptoolcapture.h
Expand Up @@ -58,6 +58,8 @@ class APP_EXPORT QgsMapToolCapture : public QgsMapToolEdit

const QgsCompoundCurveV2* captureCurve() const { return &mCaptureCurve; }

void deleteTempRubberBand();

public slots:
void currentLayerChanged( QgsMapLayer *layer );
void addError( QgsGeometry::Error );
Expand All @@ -77,7 +79,6 @@ class APP_EXPORT QgsMapToolCapture : public QgsMapToolEdit
void startCapturing();
bool isCapturing() const;
void stopCapturing();
void deleteTempRubberBand();

int size();
QList<QgsPoint> points();
Expand Down
5 changes: 5 additions & 0 deletions src/core/geometry/qgscompoundcurvev2.cpp
Expand Up @@ -314,6 +314,11 @@ int QgsCompoundCurveV2::numPoints() const
{
int nPoints = 0;
int nCurves = mCurves.size();
if ( nCurves < 1 )
{
return 0;
}

for ( int i = 0; i < nCurves; ++i )
{
nPoints += mCurves.at( i )->numPoints() - 1; //last vertex is equal to first of next section
Expand Down

0 comments on commit 632656e

Please sign in to comment.