QGIS API Documentation 4.3.0-Master (90cb4ecf9ef)
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 <optional>
21
22#include "qgis_gui.h"
23#include "qgis_sip.h"
26#include "qgspointxy.h"
27#include "qgsrectangle.h"
28#include "qobjectuniqueptr.h"
29
30#define SIP_NO_FILE
31
32class QgsRubberBand;
37class QgsAnnotationItemNodesSpatialIndex;
39class QgsMapToPixel;
40
41
49{
50 Q_OBJECT
51
52 public:
58
59 void deactivate() override;
60 void cadCanvasMoveEvent( QgsMapMouseEvent *event ) override;
61 void cadCanvasPressEvent( QgsMapMouseEvent *event ) override;
62 void canvasDoubleClickEvent( QgsMapMouseEvent *event ) override;
63 void keyPressEvent( QKeyEvent *event ) override;
64
65 signals:
66
70 void itemSelected( QgsAnnotationLayer *layer, const QString &itemId );
71
76
77 private slots:
78 void onCanvasRefreshed();
79
80 private:
81 enum class Action
82 {
83 NoAction,
84 MoveItem,
85 MoveNode
86 };
87
88 void clearHoveredItem();
89 void clearSelectedItem();
90 void createHoverBand();
91 void createHoveredNodeBand();
92 void createSelectedItemBand();
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
109 static QgsRectangle reconstructRotatedResizeBounds( const QgsMapToPixel *mapToPixel, double angle, const QgsPointXY &fixedMapPoint, const QgsPointXY &cursorMapPoint );
110
115 static QgsPointXY oppositeVertexMapPoint( const QList<QgsAnnotationItemNode> &nodes, int draggedVertex, bool &found );
116
122 std::optional<QgsRectangle> rotatedResizeLayerBounds( const QgsAnnotationRectItem *rectItem, QgsAnnotationLayer *layer, const QgsPointXY &cursorMapPoint );
123
124 Action mCurrentAction = Action::NoAction;
125
126 std::unique_ptr<QgsSnapIndicator> mSnapIndicator;
127
128 QObjectUniquePtr<QgsRubberBand> mHoverRubberBand;
129 std::vector<QObjectUniquePtr<QgsRubberBand>> mHoveredItemNodeRubberBands;
130
131 // nodes from the current hovered item, reprojected onto the map canvas' CRS
132 QList<QgsAnnotationItemNode> mHoveredItemNodes;
133
134 QObjectUniquePtr<QgsRubberBand> mHoveredNodeRubberBand;
135
136 QObjectUniquePtr<QgsRubberBand> mSelectedRubberBand;
137 QObjectUniquePtr<QgsRubberBand> mTemporaryRubberBand;
138
139 QPoint mLastHoverPoint;
140 QString mHoveredItemId;
141 QString mHoveredItemLayerId;
142 QgsRectangle mHoveredItemBounds;
143
144 QString mSelectedItemId;
145 QString mSelectedItemLayerId;
146 QgsRectangle mSelectedItemBounds;
147
148 std::unique_ptr<QgsAnnotationItemNodesSpatialIndex> mHoveredItemNodesSpatialIndex;
149
150 QgsPointXY mMoveStartPointCanvasCrs;
151 QgsPointXY mMoveStartPointLayerCrs;
152 QgsPointXY mMoveStartPointPixels;
153
154 bool mRefreshSelectedItemAfterRedraw = false;
155
156 QgsAnnotationItemNode mTargetNode;
157};
158
159#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.
Abstract base class for annotation items which render annotations in a rectangular shape.
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.
Perform transforms between map coordinates and device 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.
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.