Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes the activation of the shape map tools when digitizing is finish…
…ed (#34905)

* Fixes the activation of the shape map tools when digitizing is finished. Fixes #25168

The digitizing logic for these tools is to deactivate them when digitizing is complete (right-click). However, the tool remains active, but the icon is not pushed in, and the Advanced Digitizing Tool is not active. To fix it, activate the tool again.
  • Loading branch information
lbartoletti committed Mar 12, 2020
1 parent 3ccc3b8 commit 76e7f76
Show file tree
Hide file tree
Showing 27 changed files with 83 additions and 85 deletions.
10 changes: 10 additions & 0 deletions src/app/qgsmaptooladdcircle.cpp
Expand Up @@ -139,3 +139,13 @@ void QgsMapToolAddCircle::clean()
if ( vLayer )
mLayerType = vLayer->geometryType();
}

void QgsMapToolAddCircle::release( QgsMapMouseEvent *e )
{
deactivate();
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
activate();
}
3 changes: 3 additions & 0 deletions src/app/qgsmaptooladdcircle.h
Expand Up @@ -46,6 +46,9 @@ class APP_EXPORT QgsMapToolAddCircle: public QgsMapToolCapture
protected:
explicit QgsMapToolAddCircle( QgsMapCanvas *canvas ) = delete; //forbidden

//! Convenient method to release (activate/deactivate) tools
void release( QgsMapMouseEvent *e );

/**
* The parent map tool, e.g. the add feature tool.
* Completed circle will be added to this tool by calling its addCurve() method.
Expand Down
10 changes: 10 additions & 0 deletions src/app/qgsmaptooladdcircularstring.cpp
Expand Up @@ -242,3 +242,13 @@ void QgsMapToolAddCircularString::removeCenterPointRubberBand()
delete mCenterPointRubberBand;
mCenterPointRubberBand = nullptr;
}

void QgsMapToolAddCircularString::release( QgsMapMouseEvent *e )
{
deactivate();
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
activate();
}
3 changes: 3 additions & 0 deletions src/app/qgsmaptooladdcircularstring.h
Expand Up @@ -41,6 +41,9 @@ class APP_EXPORT QgsMapToolAddCircularString: public QgsMapToolCapture

protected:

//! Convenient method to release (activate/deactivate) tools
void release( QgsMapMouseEvent *e );

/**
* The parent map tool, e.g. the add feature tool.
* Completed circular strings will be added to this tool by calling its addCurve() method.
Expand Down
10 changes: 10 additions & 0 deletions src/app/qgsmaptooladdellipse.cpp
Expand Up @@ -139,3 +139,13 @@ void QgsMapToolAddEllipse::clean()
if ( vLayer )
mLayerType = vLayer->geometryType();
}

void QgsMapToolAddEllipse::release( QgsMapMouseEvent *e )
{
deactivate();
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
activate();
}
3 changes: 3 additions & 0 deletions src/app/qgsmaptooladdellipse.h
Expand Up @@ -42,6 +42,9 @@ class APP_EXPORT QgsMapToolAddEllipse: public QgsMapToolCapture
protected:
explicit QgsMapToolAddEllipse( QgsMapCanvas *canvas ) = delete; //forbidden

//! Convenient method to release (activate/deactivate) tools
void release( QgsMapMouseEvent *e );

/**
* The parent map tool, e.g. the add feature tool.
* Completed ellipse will be added to this tool by calling its toLineString() method.
Expand Down
10 changes: 10 additions & 0 deletions src/app/qgsmaptooladdrectangle.cpp
Expand Up @@ -139,3 +139,13 @@ void QgsMapToolAddRectangle::clean()
if ( vLayer )
mLayerType = vLayer->geometryType();
}

void QgsMapToolAddRectangle::release( QgsMapMouseEvent *e )
{
deactivate();
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
activate();
}
3 changes: 3 additions & 0 deletions src/app/qgsmaptooladdrectangle.h
Expand Up @@ -43,6 +43,9 @@ class APP_EXPORT QgsMapToolAddRectangle: public QgsMapToolCapture
protected:
explicit QgsMapToolAddRectangle( QgsMapCanvas *canvas ) = delete; //forbidden

//! Convenient method to release (activate/deactivate) tools
void release( QgsMapMouseEvent *e );

/**
* The parent map tool, e.g. the add feature tool.
* Completed regular shape will be added to this tool by calling its addCurve() method.
Expand Down
10 changes: 10 additions & 0 deletions src/app/qgsmaptooladdregularpolygon.cpp
Expand Up @@ -163,3 +163,13 @@ void QgsMapToolAddRegularPolygon::clean()
if ( vLayer )
mLayerType = vLayer->geometryType();
}

void QgsMapToolAddRegularPolygon::release( QgsMapMouseEvent *e )
{
deactivate();
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
activate();
}
3 changes: 3 additions & 0 deletions src/app/qgsmaptooladdregularpolygon.h
Expand Up @@ -51,6 +51,9 @@ class APP_EXPORT QgsMapToolAddRegularPolygon: public QgsMapToolCapture
//! delete the spin box to enter the number of sides, if it exists
void deleteNumberSidesSpinBox();

//! Convenient method to release (activate/deactivate) tools
void release( QgsMapMouseEvent *e );

/**
* The parent map tool, e.g. the add feature tool.
* Completed regular polygon will be added to this tool by calling its addCurve() method.
Expand Down
6 changes: 1 addition & 5 deletions src/app/qgsmaptoolcircle2points.cpp
Expand Up @@ -56,11 +56,7 @@ void QgsMapToolCircle2Points::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
{
mPoints.append( point );

deactivate();
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
release( e );
}
}

Expand Down
7 changes: 2 additions & 5 deletions src/app/qgsmaptoolcircle2tangentspoint.cpp
Expand Up @@ -83,6 +83,7 @@ void QgsMapToolCircle2TangentsPoint::cadCanvasReleaseEvent( QgsMapMouseEvent *e
QgisApp::instance()->messageBar()->pushMessage( tr( "Error" ), tr( "Segments are parallels" ),
Qgis::Critical, QgisApp::instance()->messageTimeout() );
deactivate();
activate();
}
else
createRadiusSpinBox();
Expand All @@ -100,13 +101,9 @@ void QgsMapToolCircle2TangentsPoint::cadCanvasReleaseEvent( QgsMapMouseEvent *e
qDeleteAll( mRubberBands );
mRubberBands.clear();

deactivate();
deleteRadiusSpinBox();
mCenters.clear();
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
release( e );
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/app/qgsmaptoolcircle3points.cpp
Expand Up @@ -53,11 +53,7 @@ void QgsMapToolCircle3Points::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
}
else if ( e->button() == Qt::RightButton )
{
deactivate();
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
release( e );
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/app/qgsmaptoolcircle3tangents.cpp
Expand Up @@ -76,11 +76,7 @@ void QgsMapToolCircle3Tangents::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
mTempRubberBand = nullptr;
}
}
deactivate();
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
release( e );
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/app/qgsmaptoolcirclecenterpoint.cpp
Expand Up @@ -57,11 +57,7 @@ void QgsMapToolCircleCenterPoint::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
{
mPoints.append( point );

deactivate();
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
release( e );
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/app/qgsmaptoolcircularstringcurvepoint.cpp
Expand Up @@ -82,11 +82,7 @@ void QgsMapToolCircularStringCurvePoint::cadCanvasReleaseEvent( QgsMapMouseEvent
}
else if ( e->button() == Qt::RightButton )
{
deactivate();
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
release( e );
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/app/qgsmaptoolcircularstringradius.cpp
Expand Up @@ -95,11 +95,7 @@ void QgsMapToolCircularStringRadius::cadCanvasReleaseEvent( QgsMapMouseEvent *e
{
if ( !( mPoints.size() % 2 ) )
mPoints.removeLast();
deactivate();
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
release( e );
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/app/qgsmaptoolellipsecenter2points.cpp
Expand Up @@ -56,11 +56,7 @@ void QgsMapToolEllipseCenter2Points::cadCanvasReleaseEvent( QgsMapMouseEvent *e
}
else if ( e->button() == Qt::RightButton )
{
deactivate();
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
release( e );
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/app/qgsmaptoolellipsecenterpoint.cpp
Expand Up @@ -54,11 +54,7 @@ void QgsMapToolEllipseCenterPoint::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
}
else if ( e->button() == Qt::RightButton )
{
deactivate();
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
release( e );
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/app/qgsmaptoolellipseextent.cpp
Expand Up @@ -56,11 +56,7 @@ void QgsMapToolEllipseExtent::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
}
else if ( e->button() == Qt::RightButton )
{
deactivate();
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
release( e );
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/app/qgsmaptoolellipsefoci.cpp
Expand Up @@ -55,11 +55,7 @@ void QgsMapToolEllipseFoci::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
}
else if ( e->button() == Qt::RightButton )
{
deactivate();
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
release( e );
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/app/qgsmaptoolrectangle3points.cpp
Expand Up @@ -66,11 +66,7 @@ void QgsMapToolRectangle3Points::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
}
else if ( e->button() == Qt::RightButton )
{
deactivate( );
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
release( e );
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/app/qgsmaptoolrectanglecenter.cpp
Expand Up @@ -60,11 +60,7 @@ void QgsMapToolRectangleCenter::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
{
mPoints.append( point );

deactivate();
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
release( e );
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/app/qgsmaptoolrectangleextent.cpp
Expand Up @@ -58,11 +58,7 @@ void QgsMapToolRectangleExtent::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
{
mPoints.append( point );

deactivate();
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
release( e );
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/app/qgsmaptoolregularpolygon2points.cpp
Expand Up @@ -65,11 +65,7 @@ void QgsMapToolRegularPolygon2Points::cadCanvasReleaseEvent( QgsMapMouseEvent *e
{
mPoints.append( point );

deactivate();
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
release( e );
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/app/qgsmaptoolregularpolygoncentercorner.cpp
Expand Up @@ -63,11 +63,7 @@ void QgsMapToolRegularPolygonCenterCorner::cadCanvasReleaseEvent( QgsMapMouseEve
{
mPoints.append( point );

deactivate();
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
release( e );
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/app/qgsmaptoolregularpolygoncenterpoint.cpp
Expand Up @@ -65,11 +65,7 @@ void QgsMapToolRegularPolygonCenterPoint::cadCanvasReleaseEvent( QgsMapMouseEven
{
mPoints.append( point );

deactivate();
if ( mParentTool )
{
mParentTool->canvasReleaseEvent( e );
}
release( e );
}
}

Expand Down

0 comments on commit 76e7f76

Please sign in to comment.