Skip to content
Permalink
Browse files
Add snap indicator
  • Loading branch information
nyalldawson committed Sep 10, 2021
1 parent e0c5cce commit f66eeebd60e4375ae4692ae79265376c09cd18af
@@ -26,6 +26,7 @@
#include "qgsannotationitem.h"
#include "qgsannotationitemnode.h"
#include "qgsannotationitemeditoperation.h"
#include "qgssnapindicator.h"
#include "RTree.h"
#include <QTransform>
#include <QWindow>
@@ -104,6 +105,7 @@ class QgsAnnotationItemNodesSpatialIndex : public RTree<int, float, 2, float>

QgsMapToolModifyAnnotation::QgsMapToolModifyAnnotation( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget )
: QgsMapToolAdvancedDigitizing( canvas, cadDockWidget )
, mSnapIndicator( new QgsSnapIndicator( canvas ) )
{

connect( QgsMapToolModifyAnnotation::canvas(), &QgsMapCanvas::mapCanvasRefreshed, this, &QgsMapToolModifyAnnotation::onCanvasRefreshed );
@@ -113,12 +115,17 @@ QgsMapToolModifyAnnotation::~QgsMapToolModifyAnnotation() = default;

void QgsMapToolModifyAnnotation::deactivate()
{
mSnapIndicator->setMatch( QgsPointLocator::Match() );

clearHoveredItem();
QgsMapToolAdvancedDigitizing::deactivate();
}

void QgsMapToolModifyAnnotation::cadCanvasMoveEvent( QgsMapMouseEvent *event )
{
event->snapPoint();
mSnapIndicator->setMatch( event->mapPointMatch() );

const QgsPointXY mapPoint = event->mapPoint();

switch ( mCurrentAction )
@@ -417,7 +424,7 @@ void QgsMapToolModifyAnnotation::canvasDoubleClickEvent( QgsMapMouseEvent *event
mCurrentAction = Action::NoAction;
if ( mHoveredItemId == mSelectedItemId && mHoveredItemLayerId == mSelectedItemLayerId )
{
// double click on selected item => add node
// double-click on selected item => add node
if ( QgsAnnotationLayer *layer = annotationLayerFromId( mSelectedItemLayerId ) )
{
const QgsPointXY layerPoint = toLayerCoordinates( layer, event->mapPoint() );
@@ -29,6 +29,7 @@ class QgsRenderedAnnotationItemDetails;
class QgsAnnotationItem;
class QgsAnnotationLayer;
class QgsAnnotationItemNodesSpatialIndex;
class QgsSnapIndicator;

#define SIP_NO_FILE

@@ -99,6 +100,8 @@ class GUI_EXPORT QgsMapToolModifyAnnotation : public QgsMapToolAdvancedDigitizin

Action mCurrentAction = Action::NoAction;

std::unique_ptr<QgsSnapIndicator> mSnapIndicator;

QObjectUniquePtr<QgsRubberBand> mHoverRubberBand;
std::vector< QObjectUniquePtr<QgsRubberBand> > mHoveredItemNodeRubberBands;

@@ -540,7 +540,7 @@ void TestQgsMapToolEditAnnotation::testAddNode()
QCOMPARE( spy.count(), 1 );
QCOMPARE( spy.at( 0 ).at( 1 ).toString(), i1id );

// double click a segment
// double-click a segment
utils.mouseMove( 5, 3 );
utils.mouseDoubleClick( 5, 3, Qt::LeftButton, Qt::KeyboardModifiers(), true );
// second click isn't selecting an item, so no new signals should be emitted

0 comments on commit f66eeeb

Please sign in to comment.