QGIS API Documentation 3.99.0-Master (8e76e220402)
Loading...
Searching...
No Matches
qgsmaptoolmodifyannotation.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmaptoolmodifyannotation.h
3 ----------------
4 copyright : (C) 2021 by Nyall Dawson
5 email : nyall dot dawson at gmail dot com
6 ***************************************************************************/
7
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#ifndef QGSMAPTOOLMODIFYANNOTATION_H
18#define QGSMAPTOOLMODIFYANNOTATION_H
19
20#include "qgis_gui.h"
21#include "qgis_sip.h"
24#include "qgspointxy.h"
25#include "qgsrectangle.h"
26#include "qobjectuniqueptr.h"
27
28class QgsRubberBand;
32class QgsAnnotationItemNodesSpatialIndex;
34
35#define SIP_NO_FILE
36
44{
45 Q_OBJECT
46
47 public:
53
54 void deactivate() override;
55 void cadCanvasMoveEvent( QgsMapMouseEvent *event ) override;
56 void cadCanvasPressEvent( QgsMapMouseEvent *event ) override;
57 void canvasDoubleClickEvent( QgsMapMouseEvent *event ) override;
58 void keyPressEvent( QKeyEvent *event ) override;
59
60 signals:
61
65 void itemSelected( QgsAnnotationLayer *layer, const QString &itemId );
66
71
72 private slots:
73 void onCanvasRefreshed();
74
75 private:
76 enum class Action
77 {
78 NoAction,
79 MoveItem,
80 MoveNode
81 };
82
83 void clearHoveredItem();
84 void clearSelectedItem();
85 void createHoverBand();
86 void createHoveredNodeBand();
87 void createSelectedItemBand();
88
89 void setHoveredItemFromPoint( const QgsPointXY &mapPoint );
90 void setHoveredItem( const QgsRenderedAnnotationItemDetails *item, const QgsRectangle &itemMapBounds );
91
96 QSizeF deltaForKeyEvent( QgsAnnotationLayer *layer, const QgsPointXY &originalCanvasPoint, QKeyEvent *event );
97
98 Action mCurrentAction = Action::NoAction;
99
100 std::unique_ptr<QgsSnapIndicator> mSnapIndicator;
101
102 QObjectUniquePtr<QgsRubberBand> mHoverRubberBand;
103 std::vector<QObjectUniquePtr<QgsRubberBand>> mHoveredItemNodeRubberBands;
104
105 // nodes from the current hovered item, reprojected onto the map canvas' CRS
106 QList<QgsAnnotationItemNode> mHoveredItemNodes;
107
108 QObjectUniquePtr<QgsRubberBand> mHoveredNodeRubberBand;
109
110 QObjectUniquePtr<QgsRubberBand> mSelectedRubberBand;
111 QObjectUniquePtr<QgsRubberBand> mTemporaryRubberBand;
112
113 QPoint mLastHoverPoint;
114 QString mHoveredItemId;
115 QString mHoveredItemLayerId;
116 QgsRectangle mHoveredItemBounds;
117
118 QString mSelectedItemId;
119 QString mSelectedItemLayerId;
120 QgsRectangle mSelectedItemBounds;
121
122 std::unique_ptr<QgsAnnotationItemNodesSpatialIndex> mHoveredItemNodesSpatialIndex;
123
124 QgsPointXY mMoveStartPointCanvasCrs;
125 QgsPointXY mMoveStartPointLayerCrs;
126 QgsPointXY mMoveStartPointPixels;
127
128 bool mRefreshSelectedItemAfterRedraw = false;
129
130 QgsAnnotationItemNode mTargetNode;
131};
132
133#endif // QGSMAPTOOLMODIFYANNOTATION_H
Keeps a pointer to a QObject and deletes it whenever this object is deleted.
A dockable widget used to handle the CAD tools on top of a selection of map tools.
Contains information about a node used for editing an annotation item.
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
Represents a map layer containing a set of georeferenced annotations, e.g.
QgsAnnotationMapTool(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget)
Constructor for QgsAnnotationMapTool.
Map canvas is a class for displaying all GIS data types on a canvas.
A mouse event which is the result of a user interaction with a QgsMapCanvas.
virtual void cadCanvasMoveEvent(QgsMapMouseEvent *e)
Override this method when subclassing this class.
void deactivate() override
Unregisters this maptool from the cad dock widget.
virtual void cadCanvasPressEvent(QgsMapMouseEvent *e)
Override this method when subclassing this class.
virtual QgsMapLayer * layer() const
Returns the layer associated with the map tool.
QgsAdvancedDigitizingDockWidget * cadDockWidget() const
void itemSelected(QgsAnnotationLayer *layer, const QString &itemId)
Emitted when the selected item is changed.
~QgsMapToolModifyAnnotation() override
void selectionCleared()
Emitted when the selected item is cleared;.
QgsMapToolModifyAnnotation(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget)
Constructor for QgsMapToolModifyAnnotation.
QgsMapCanvas * canvas() const
returns pointer to the tool's map canvas
virtual void canvasDoubleClickEvent(QgsMapMouseEvent *e)
Mouse double-click event for overriding. Default implementation does nothing.
virtual void keyPressEvent(QKeyEvent *e)
Key event for overriding. Default implementation does nothing.
Represents a 2D point.
Definition qgspointxy.h:62
A rectangle specified with double values.
Contains information about a rendered annotation item.
Responsible for drawing transient features (e.g.
Shows a snapping marker on map canvas for the current snapping match.