QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
53  ~QgsMapToolModifyAnnotation() override;
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 
71  void selectionCleared();
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
qgsmaptooladvanceddigitizing.h
QgsMapTool::canvasDoubleClickEvent
virtual void canvasDoubleClickEvent(QgsMapMouseEvent *e)
Mouse double-click event for overriding. Default implementation does nothing.
Definition: qgsmaptool.cpp:173
QgsRubberBand
A class for drawing transient features (e.g. digitizing lines) on the map.
Definition: qgsrubberband.h:51
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:89
QgsMapToolModifyAnnotation
A map tool for modifying annotations in a QgsAnnotationLayer.
Definition: qgsmaptoolmodifyannotation.h:42
QgsMapTool::keyPressEvent
virtual void keyPressEvent(QKeyEvent *e)
Key event for overriding. Default implementation does nothing.
Definition: qgsmaptool.cpp:193
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsSnapIndicator
Class that shows snapping marker on map canvas for the current snapping match.
Definition: qgssnapindicator.h:32
QObjectUniquePtr< QgsRubberBand >
qobjectuniqueptr.h
qgis_sip.h
QgsRenderedAnnotationItemDetails
Contains information about a rendered annotation item.
Definition: qgsrenderedannotationitemdetails.h:29
QgsAdvancedDigitizingDockWidget
The QgsAdvancedDigitizingDockWidget class is a dockable widget used to handle the CAD tools on top of...
Definition: qgsadvanceddigitizingdockwidget.h:50
qgsannotationitemnode.h
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:58
QgsMapMouseEvent
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas....
Definition: qgsmapmouseevent.h:35
QgsAnnotationItemNode
Contains information about a node used for editing an annotation item.
Definition: qgsannotationitemnode.h:31
QgsAnnotationLayer
Represents a map layer containing a set of georeferenced annotations, e.g. markers,...
Definition: qgsannotationlayer.h:46
QgsMapToolAdvancedDigitizing::cadCanvasMoveEvent
virtual void cadCanvasMoveEvent(QgsMapMouseEvent *e)
Override this method when subclassing this class.
Definition: qgsmaptooladvanceddigitizing.h:154
QgsMapToolAdvancedDigitizing::deactivate
void deactivate() override
Unregisters this maptool from the cad dock widget.
Definition: qgsmaptooladvanceddigitizing.cpp:136
QgsMapToolAdvancedDigitizing
The QgsMapToolAdvancedDigitizing class is a QgsMapTool which gives event directly in map coordinates ...
Definition: qgsmaptooladvanceddigitizing.h:36
QgsMapToolAdvancedDigitizing::cadCanvasPressEvent
virtual void cadCanvasPressEvent(QgsMapMouseEvent *e)
Override this method when subclassing this class.
Definition: qgsmaptooladvanceddigitizing.h:132
QgsAnnotationItem
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
Definition: qgsannotationitem.h:42
qgspointxy.h