QGIS API Documentation 3.41.0-Master (cea29feecf2)
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:
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 setHoveredItemFromPoint( const QgsPointXY &mapPoint );
94 void setHoveredItem( const QgsRenderedAnnotationItemDetails *item, const QgsRectangle &itemMapBounds );
95
100 QSizeF deltaForKeyEvent( QgsAnnotationLayer *layer, const QgsPointXY &originalCanvasPoint, QKeyEvent *event );
101
102 Action mCurrentAction = Action::NoAction;
103
104 std::unique_ptr<QgsSnapIndicator> mSnapIndicator;
105
106 QObjectUniquePtr<QgsRubberBand> mHoverRubberBand;
107 std::vector<QObjectUniquePtr<QgsRubberBand>> mHoveredItemNodeRubberBands;
108
109 // nodes from the current hovered item, reprojected onto the map canvas' CRS
110 QList<QgsAnnotationItemNode> mHoveredItemNodes;
111
112 QObjectUniquePtr<QgsRubberBand> mHoveredNodeRubberBand;
113
114 QObjectUniquePtr<QgsRubberBand> mSelectedRubberBand;
115 QObjectUniquePtr<QgsRubberBand> mTemporaryRubberBand;
116
117 QPoint mLastHoverPoint;
118 QString mHoveredItemId;
119 QString mHoveredItemLayerId;
120 QgsRectangle mHoveredItemBounds;
121
122 QString mSelectedItemId;
123 QString mSelectedItemLayerId;
124 QgsRectangle mSelectedItemBounds;
125
126 std::unique_ptr<QgsAnnotationItemNodesSpatialIndex> mHoveredItemNodesSpatialIndex;
127
128 QgsPointXY mMoveStartPointCanvasCrs;
129 QgsPointXY mMoveStartPointLayerCrs;
130 QgsPointXY mMoveStartPointPixels;
131
132 bool mRefreshSelectedItemAfterRedraw = false;
133
134 QgsAnnotationItemNode mTargetNode;
135};
136
137#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.