Skip to content

Commit

Permalink
Fix automatically set anchor point isn't cleared after applying action
Browse files Browse the repository at this point in the history
(cherry picked from commit a445771)
  • Loading branch information
nyalldawson committed Jan 15, 2021
1 parent c698939 commit c8d690e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/app/qgsmaptoolrotatefeature.cpp
Expand Up @@ -234,12 +234,12 @@ void QgsMapToolRotateFeature::canvasReleaseEvent( QgsMapMouseEvent *e )
QgsRectangle selectRect( layerCoords.x() - searchRadius, layerCoords.y() - searchRadius,
layerCoords.x() + searchRadius, layerCoords.y() + searchRadius );

bool autoCalculateAnchorPoint = false;
mAutoSetAnchorPoint = false;
if ( !mAnchorPoint )
{
mAnchorPoint = qgis::make_unique<QgsVertexMarker>( mCanvas );
mAnchorPoint->setIconType( QgsVertexMarker::ICON_CROSS );
autoCalculateAnchorPoint = true;
mAutoSetAnchorPoint = true;
}

if ( vlayer->selectedFeatureCount() == 0 )
Expand Down Expand Up @@ -277,7 +277,7 @@ void QgsMapToolRotateFeature::canvasReleaseEvent( QgsMapMouseEvent *e )
}

QgsRectangle bound = cf.geometry().boundingBox();
if ( autoCalculateAnchorPoint )
if ( mAutoSetAnchorPoint )
{
mStartPointMapCoords = toMapCoordinates( vlayer, bound.center() );
mAnchorPoint->setCenter( mStartPointMapCoords );
Expand Down Expand Up @@ -337,7 +337,7 @@ void QgsMapToolRotateFeature::cancel()
deleteRotationWidget();
deleteRubberband();
QgsVectorLayer *vlayer = currentVectorLayer();
if ( vlayer->selectedFeatureCount() == 0 )
if ( vlayer->selectedFeatureCount() == 0 || mAutoSetAnchorPoint )
{
mAnchorPoint.reset();
}
Expand Down Expand Up @@ -422,6 +422,9 @@ void QgsMapToolRotateFeature::applyRotation( double rotation )
deleteRotationWidget();
deleteRubberband();

if ( mAutoSetAnchorPoint )
mAnchorPoint.reset();

vlayer->endEditCommand();
vlayer->triggerRepaint();
}
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsmaptoolrotatefeature.h
Expand Up @@ -112,6 +112,7 @@ class APP_EXPORT QgsMapToolRotateFeature: public QgsMapToolEdit

QPoint mStPoint;
std::unique_ptr<QgsVertexMarker> mAnchorPoint = nullptr;
bool mAutoSetAnchorPoint = false;

bool mRotationActive;

Expand Down

0 comments on commit c8d690e

Please sign in to comment.