QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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"
25 #include "qgsannotationitemnode.h"
26 
27 class QgsRubberBand;
29 class QgsAnnotationItem;
30 class QgsAnnotationLayer;
31 class QgsAnnotationItemNodesSpatialIndex;
32 class QgsSnapIndicator;
33 
34 #define SIP_NO_FILE
35 
43 {
44  Q_OBJECT
45 
46  public:
47 
52 
54 
55  void deactivate() override;
56  void cadCanvasMoveEvent( QgsMapMouseEvent *event ) override;
57  void cadCanvasPressEvent( QgsMapMouseEvent *event ) override;
58  void canvasDoubleClickEvent( QgsMapMouseEvent *event ) override;
59  void keyPressEvent( QKeyEvent *event ) override;
60 
61  signals:
62 
66  void itemSelected( QgsAnnotationLayer *layer, const QString &itemId );
67 
72 
73  private slots:
74  void onCanvasRefreshed();
75 
76  private:
77  enum class Action
78  {
79  NoAction,
80  MoveItem,
81  MoveNode
82  };
83 
84  void clearHoveredItem();
85  void clearSelectedItem();
86  void createHoverBand();
87  void createHoveredNodeBand();
88  void createSelectedItemBand();
89  const QgsRenderedAnnotationItemDetails *findClosestItemToPoint( const QgsPointXY &mapPoint, const QList<const QgsRenderedAnnotationItemDetails *> &items, QgsRectangle &bounds );
90  QgsAnnotationLayer *annotationLayerFromId( const QString &layerId );
91  QgsAnnotationItem *annotationItemFromId( const QString &layerId, const QString &itemId );
92 
93  void setHoveredItem( const QgsRenderedAnnotationItemDetails *item, const QgsRectangle &itemMapBounds );
94 
99  QSizeF deltaForKeyEvent( QgsAnnotationLayer *layer, const QgsPointXY &originalCanvasPoint, QKeyEvent *event );
100 
101  Action mCurrentAction = Action::NoAction;
102 
103  std::unique_ptr<QgsSnapIndicator> mSnapIndicator;
104 
105  QObjectUniquePtr<QgsRubberBand> mHoverRubberBand;
106  std::vector< QObjectUniquePtr<QgsRubberBand> > mHoveredItemNodeRubberBands;
107 
108  // nodes from the current hovered item, reprojected onto the map canvas' CRS
109  QList< QgsAnnotationItemNode > mHoveredItemNodes;
110 
111  QObjectUniquePtr<QgsRubberBand> mHoveredNodeRubberBand;
112 
113  QObjectUniquePtr<QgsRubberBand> mSelectedRubberBand;
114  QObjectUniquePtr<QgsRubberBand> mTemporaryRubberBand;
115 
116  QString mHoveredItemId;
117  QString mHoveredItemLayerId;
118 
119  QString mSelectedItemId;
120  QString mSelectedItemLayerId;
121 
122  std::unique_ptr< QgsAnnotationItemNodesSpatialIndex > mHoveredItemNodesSpatialIndex;
123 
124  QgsPointXY mMoveStartPointCanvasCrs;
125  QgsPointXY mMoveStartPointLayerCrs;
126 
127  bool mRefreshSelectedItemAfterRedraw = false;
128 
129  QgsAnnotationItemNode mTargetNode;
130 
131 };
132 
133 #endif // QGSMAPTOOLMODIFYANNOTATION_H
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.
Definition: qgsmapcanvas.h:90
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.
Definition: qgsmaptool.cpp:173
virtual void keyPressEvent(QKeyEvent *e)
Key event for overriding. Default implementation does nothing.
Definition: qgsmaptool.cpp:193
A class to represent a 2D point.
Definition: qgspointxy.h:59
A rectangle specified with double values.
Definition: qgsrectangle.h:42
Contains information about a rendered annotation item.
A class for drawing transient features (e.g.
Definition: qgsrubberband.h:52
Class that shows snapping marker on map canvas for the current snapping match.