QGIS API Documentation 3.41.0-Master (45a0abf3bec)
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"
23#include "qobjectuniqueptr.h"
24#include "qgspointxy.h"
26#include "qgsrectangle.h"
27
28class QgsRubberBand;
32class QgsAnnotationItemNodesSpatialIndex;
34
35#define SIP_NO_FILE
36
44{
45 Q_OBJECT
46
47 public:
48
53
55
56 void deactivate() override;
57 void cadCanvasMoveEvent( QgsMapMouseEvent *event ) override;
58 void cadCanvasPressEvent( QgsMapMouseEvent *event ) override;
59 void canvasDoubleClickEvent( QgsMapMouseEvent *event ) override;
60 void keyPressEvent( QKeyEvent *event ) override;
61
62 signals:
63
67 void itemSelected( QgsAnnotationLayer *layer, const QString &itemId );
68
73
74 private slots:
75 void onCanvasRefreshed();
76
77 private:
78 enum class Action
79 {
80 NoAction,
81 MoveItem,
82 MoveNode
83 };
84
85 void clearHoveredItem();
86 void clearSelectedItem();
87 void createHoverBand();
88 void createHoveredNodeBand();
89 void createSelectedItemBand();
90 const QgsRenderedAnnotationItemDetails *findClosestItemToPoint( const QgsPointXY &mapPoint, const QList<const QgsRenderedAnnotationItemDetails *> &items, QgsRectangle &bounds );
91 QgsAnnotationLayer *annotationLayerFromId( const QString &layerId );
92 QgsAnnotationItem *annotationItemFromId( const QString &layerId, const QString &itemId );
93
94 void setHoveredItemFromPoint( const QgsPointXY &mapPoint );
95 void setHoveredItem( const QgsRenderedAnnotationItemDetails *item, const QgsRectangle &itemMapBounds );
96
101 QSizeF deltaForKeyEvent( QgsAnnotationLayer *layer, const QgsPointXY &originalCanvasPoint, QKeyEvent *event );
102
103 Action mCurrentAction = Action::NoAction;
104
105 std::unique_ptr<QgsSnapIndicator> mSnapIndicator;
106
107 QObjectUniquePtr<QgsRubberBand> mHoverRubberBand;
108 std::vector< QObjectUniquePtr<QgsRubberBand> > mHoveredItemNodeRubberBands;
109
110 // nodes from the current hovered item, reprojected onto the map canvas' CRS
111 QList< QgsAnnotationItemNode > mHoveredItemNodes;
112
113 QObjectUniquePtr<QgsRubberBand> mHoveredNodeRubberBand;
114
115 QObjectUniquePtr<QgsRubberBand> mSelectedRubberBand;
116 QObjectUniquePtr<QgsRubberBand> mTemporaryRubberBand;
117
118 QPoint mLastHoverPoint;
119 QString mHoveredItemId;
120 QString mHoveredItemLayerId;
121 QgsRectangle mHoveredItemBounds;
122
123 QString mSelectedItemId;
124 QString mSelectedItemLayerId;
125 QgsRectangle mSelectedItemBounds;
126
127 std::unique_ptr< QgsAnnotationItemNodesSpatialIndex > mHoveredItemNodesSpatialIndex;
128
129 QgsPointXY mMoveStartPointCanvasCrs;
130 QgsPointXY mMoveStartPointLayerCrs;
131 QgsPointXY mMoveStartPointPixels;
132
133 bool mRefreshSelectedItemAfterRedraw = false;
134
135 QgsAnnotationItemNode mTargetNode;
136
137};
138
139#endif // QGSMAPTOOLMODIFYANNOTATION_H
Keeps a pointer to a QObject and deletes it whenever this object is deleted.
The QgsAdvancedDigitizingDockWidget class is a dockable widget used to handle the CAD tools on top of...
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.
Map canvas is a class for displaying all GIS data types on a canvas.
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
The QgsMapToolAdvancedDigitizing class is a QgsMapTool which gives event directly in map coordinates ...
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.
A map tool for modifying annotations in a QgsAnnotationLayer.
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;.
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.
A class to represent a 2D point.
Definition qgspointxy.h:60
A rectangle specified with double values.
Contains information about a rendered annotation item.
A class for drawing transient features (e.g.
Class that shows snapping marker on map canvas for the current snapping match.