Skip to content

Commit

Permalink
Make move callout tool play nice with CAD dock
Browse files Browse the repository at this point in the history
Means that if the cad dock is enabled, callout lines will auto-snap
to nice angles, etc.
  • Loading branch information
nyalldawson committed Feb 23, 2021
1 parent f6c93de commit 6f6b0b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/app/labeling/qgsmaptoolmovelabel.cpp
Expand Up @@ -131,6 +131,11 @@ void QgsMapToolMoveLabel::cadCanvasPressEvent( QgsMapMouseEvent *e )
mCalloutMoveRubberBand->setWidth( 3 );
mCalloutMoveRubberBand->show();

// set initial cad point as the other side of the callout -- NOTE we have to add two points here!
cadDockWidget()->addPoint( mCurrentCalloutMoveOrigin ? mCurrentCallout.destination() : mCurrentCallout.origin() );
cadDockWidget()->addPoint( e->mapPoint() );
cadDockWidget()->releaseLocks( false );

return;
}
else
Expand Down Expand Up @@ -348,6 +353,14 @@ void QgsMapToolMoveLabel::cadCanvasReleaseEvent( QgsMapMouseEvent * )
}
}

void QgsMapToolMoveLabel::canvasReleaseEvent( QgsMapMouseEvent *e )
{
if ( mCalloutMoveRubberBand )
return; // don't allow cad dock widget points to be cleared after starting to move a callout endpoint

QgsMapToolLabel::canvasReleaseEvent( e );
}

void QgsMapToolMoveLabel::keyPressEvent( QKeyEvent *e )
{
if ( mLabelRubberBand || mCalloutMoveRubberBand )
Expand Down
1 change: 1 addition & 0 deletions src/app/labeling/qgsmaptoolmovelabel.h
Expand Up @@ -35,6 +35,7 @@ class APP_EXPORT QgsMapToolMoveLabel: public QgsMapToolLabel
void cadCanvasMoveEvent( QgsMapMouseEvent *e ) override;
void cadCanvasPressEvent( QgsMapMouseEvent *e ) override;
void cadCanvasReleaseEvent( QgsMapMouseEvent *e ) override;
void canvasReleaseEvent( QgsMapMouseEvent *e ) override;
void keyPressEvent( QKeyEvent *e ) override;
void keyReleaseEvent( QKeyEvent *e ) override;

Expand Down

0 comments on commit 6f6b0b0

Please sign in to comment.