Skip to content
Permalink
Browse files

Make move callout tool play nice with CAD dock

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 6f6b0b0a79ec087d8b5cadbd3be07cfc7a263ee1
Showing with 14 additions and 0 deletions.
  1. +13 −0 src/app/labeling/qgsmaptoolmovelabel.cpp
  2. +1 −0 src/app/labeling/qgsmaptoolmovelabel.h
@@ -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
@@ -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 )
@@ -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;

0 comments on commit 6f6b0b0

Please sign in to comment.