QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
qgsannotationitemeditoperation.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsannotationitemeditoperation.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 QGSANNOTATIONITEMEDITOPERATION_H
18#define QGSANNOTATIONITEMEDITOPERATION_H
19
20#include "qgis_core.h"
21#include "qgis_sip.h"
22#include "qgis.h"
23#include "qgspointxy.h"
24#include "qgsvertexid.h"
25#include "qgsgeometry.h"
26#include "qgsrendercontext.h"
27
34{
35 public:
36
38
44 QgsRectangle currentItemBounds() const;
45
51 void setCurrentItemBounds( const QgsRectangle &bounds );
52
58 QgsRenderContext renderContext() const;
59
65 void setRenderContext( const QgsRenderContext &context );
66
67 private:
68
69 QgsRectangle mCurrentItemBounds;
70 QgsRenderContext mRenderContext;
71
72};
73
80{
81 public:
82
86 enum class Type : int
87 {
88 MoveNode,
89 DeleteNode,
90 AddNode,
91 TranslateItem,
92 };
93
97 QgsAbstractAnnotationItemEditOperation( const QString &itemId );
98
100
104 virtual Type type() const = 0;
105
109 QString itemId() const { return mItemId; }
110
111 protected:
112
113 QString mItemId;
114
115};
116
123{
124 public:
125
132 QgsAnnotationItemEditOperationMoveNode( const QString &itemId, QgsVertexId nodeId, const QgsPoint &before, const QgsPoint &after,
133 double translatePixelsX = 0, double translatePixelsY = 0 );
134
135 Type type() const override;
136
140 QgsVertexId nodeId() const { return mNodeId; }
141
147 QgsPoint before() const { return mBefore; }
148
154 QgsPoint after() const { return mAfter; }
155
162 double translationXPixels() const { return mTranslatePixelsX; }
163
170 double translationYPixels() const { return mTranslatePixelsY; }
171
172 private:
173
174 QgsVertexId mNodeId;
175 QgsPoint mBefore;
176 QgsPoint mAfter;
177
178 double mTranslatePixelsX = 0;
179 double mTranslatePixelsY = 0;
180};
181
182
189{
190 public:
191
196 QgsAnnotationItemEditOperationDeleteNode( const QString &itemId, QgsVertexId nodeId, const QgsPoint &before );
197
198 Type type() const override;
199
203 QgsVertexId nodeId() const { return mNodeId; }
204
208 QgsPoint before() const { return mBefore; }
209
210 private:
211
212 QgsVertexId mNodeId;
213 QgsPoint mBefore;
214
215};
216
223{
224 public:
225
229 QgsAnnotationItemEditOperationAddNode( const QString &itemId, const QgsPoint &point );
230
231 Type type() const override;
232
236 QgsPoint point() const { return mPoint; }
237
238 private:
239
240 QgsPoint mPoint;
241
242};
243
244
251{
252 public:
253
260 QgsAnnotationItemEditOperationTranslateItem( const QString &itemId, double translateX, double translateY,
261 double translatePixelsX = 0, double translatePixelsY = 0 );
262
263 Type type() const override;
264
268 QgsVertexId nodeId() const { return mNodeId; }
269
275 double translationX() const { return mTranslateX; }
276
282 double translationY() const { return mTranslateY; }
283
290 double translationXPixels() const { return mTranslatePixelsX; }
291
298 double translationYPixels() const { return mTranslatePixelsY; }
299
300 private:
301
302 QgsVertexId mNodeId;
303 double mTranslateX = 0;
304 double mTranslateY = 0;
305 double mTranslatePixelsX = 0;
306 double mTranslatePixelsY = 0;
307
308};
309
316{
317 public:
318
327 : mRepresentativeGeometry( representativeGeometry )
328 {}
329
335 QgsGeometry representativeGeometry() const { return mRepresentativeGeometry; }
336
337 private:
338
339 QgsGeometry mRepresentativeGeometry;
340
341};
342
343#endif // QGSANNOTATIONITEMEDITOPERATION_H
Abstract base class for annotation item edit operations.
virtual Type type() const =0
Returns the operation type.
QString itemId() const
Returns the associated item ID.
Encapsulates the context for an annotation item edit operation.
Annotation item edit operation consisting of adding a node.
QgsPoint point() const
Returns the node position (in layer coordinates).
Annotation item edit operation consisting of deleting a node.
QgsPoint before() const
Returns the node position before the delete occurred (in layer coordinates).
QgsVertexId nodeId() const
Returns the deleted node ID.
Annotation item edit operation consisting of moving a node.
double translationYPixels() const
Returns the y-axis translation, in pixels.
QgsPoint before() const
Returns the node position before the move occurred (in layer coordinates).
QgsPoint after() const
Returns the node position after the move occurred (in layer coordinates).
double translationXPixels() const
Returns the x-axis translation, in pixels.
QgsVertexId nodeId() const
Returns the associated node ID.
Encapsulates the transient results of an in-progress annotation edit operation.
QgsAnnotationItemEditOperationTransientResults(const QgsGeometry &representativeGeometry)
Constructor for QgsAnnotationItemEditOperationTransientResults.
QgsGeometry representativeGeometry() const
Returns the geometry (in layer CRS) which represents the shape of the item if the operation were to b...
Annotation item edit operation consisting of translating (moving) an item.
double translationY() const
Returns the y-axis translation, in layer units.
QgsVertexId nodeId() const
Returns the deleted node ID.
double translationX() const
Returns the x-axis translation, in layer units.
double translationYPixels() const
Returns the y-axis translation, in pixels.
double translationXPixels() const
Returns the x-axis translation, in pixels.
A geometry is the spatial representation of a feature.
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:49
A rectangle specified with double values.
Contains information about the context of a rendering operation.
Utility class for identifying a unique vertex within a geometry.
Definition qgsvertexid.h:30