QGIS API Documentation 4.1.0-Master (60fea48833c)
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.h"
21#include "qgis_core.h"
22#include "qgis_sip.h"
23#include "qgsgeometry.h"
24#include "qgspointxy.h"
25#include "qgsrendercontext.h"
26#include "qgsvertexid.h"
27
34{
35 public:
37
44
50 void setCurrentItemBounds( const QgsRectangle &bounds );
51
58
64 void setRenderContext( const QgsRenderContext &context );
65
66 private:
67 QgsRectangle mCurrentItemBounds;
68 QgsRenderContext mRenderContext;
69};
70
77{
78 public:
82 enum class Type : int
83 {
84 MoveNode,
85 DeleteNode,
86 AddNode,
87 TranslateItem,
88 RotateItem,
89 };
90
94 QgsAbstractAnnotationItemEditOperation( const QString &itemId );
95
97
101 virtual Type type() const = 0;
102
106 QString itemId() const { return mItemId; }
107
108 protected:
109 QString mItemId;
110};
111
118{
119 public:
126 QgsAnnotationItemEditOperationMoveNode( const QString &itemId, QgsVertexId nodeId, const QgsPoint &before, const QgsPoint &after, double translatePixelsX = 0, double translatePixelsY = 0 );
127
128 Type type() const override;
129
133 QgsVertexId nodeId() const { return mNodeId; }
134
140 QgsPoint before() const { return mBefore; }
141
147 QgsPoint after() const { return mAfter; }
148
155 double translationXPixels() const { return mTranslatePixelsX; }
156
163 double translationYPixels() const { return mTranslatePixelsY; }
164
165 private:
166 QgsVertexId mNodeId;
167 QgsPoint mBefore;
168 QgsPoint mAfter;
169
170 double mTranslatePixelsX = 0;
171 double mTranslatePixelsY = 0;
172};
173
174
181{
182 public:
188
189 Type type() const override;
190
194 QgsVertexId nodeId() const { return mNodeId; }
195
199 QgsPoint before() const { return mBefore; }
200
201 private:
202 QgsVertexId mNodeId;
203 QgsPoint mBefore;
204};
205
212{
213 public:
218
219 Type type() const override;
220
224 QgsPoint point() const { return mPoint; }
225
226 private:
227 QgsPoint mPoint;
228};
229
230
237{
238 public:
245 QgsAnnotationItemEditOperationTranslateItem( const QString &itemId, double translateX, double translateY, double translatePixelsX = 0, double translatePixelsY = 0 );
246
247 Type type() const override;
248
252 QgsVertexId nodeId() const { return mNodeId; }
253
259 double translationX() const { return mTranslateX; }
260
266 double translationY() const { return mTranslateY; }
267
274 double translationXPixels() const { return mTranslatePixelsX; }
275
282 double translationYPixels() const { return mTranslatePixelsY; }
283
284 private:
285 QgsVertexId mNodeId;
286 double mTranslateX = 0;
287 double mTranslateY = 0;
288 double mTranslatePixelsX = 0;
289 double mTranslatePixelsY = 0;
290};
291
292
299{
300 public:
305 QgsAnnotationItemEditOperationRotateItem( const QString &itemId, double angle );
306
307 Type type() const override;
308
312 double angle() const { return mAngle; }
313
314 private:
315 double mAngle = 0;
316};
317
318
325{
326 public:
337
343 QgsGeometry representativeGeometry() const { return mRepresentativeGeometry; }
344
345 private:
346 QgsGeometry mRepresentativeGeometry;
347};
348
349#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.
QgsAbstractAnnotationItemEditOperation(const QString &itemId)
Constructor for QgsAbstractAnnotationItemEditOperation, for the specified item id.
void setCurrentItemBounds(const QgsRectangle &bounds)
Sets the current rendered bounds of the item, in the annotation layer's CRS.
QgsRectangle currentItemBounds() const
Returns the current rendered bounds of the item, in the annotation layer's CRS.
QgsRenderContext renderContext() const
Returns the render context associated with the edit operation.
void setRenderContext(const QgsRenderContext &context)
Sets the render context associated with the edit operation.
QgsAnnotationItemEditOperationAddNode(const QString &itemId, const QgsPoint &point)
Constructor for QgsAnnotationItemEditOperationAddNode at the specified point.
QgsPoint point() const
Returns the node position (in layer coordinates).
Type type() const override
Returns the operation type.
QgsPoint before() const
Returns the node position before the delete occurred (in layer coordinates).
QgsVertexId nodeId() const
Returns the deleted node ID.
QgsAnnotationItemEditOperationDeleteNode(const QString &itemId, QgsVertexId nodeId, const QgsPoint &before)
Constructor for QgsAnnotationItemEditOperationDeleteNode, where the node with the specified id and pr...
Type type() const override
Returns the operation type.
Type type() const override
Returns the operation type.
double translationYPixels() const
Returns the y-axis translation, in pixels.
QgsAnnotationItemEditOperationMoveNode(const QString &itemId, QgsVertexId nodeId, const QgsPoint &before, const QgsPoint &after, double translatePixelsX=0, double translatePixelsY=0)
Constructor for QgsAnnotationItemEditOperationMoveNode, where the node with the specified id moves fr...
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.
QgsAnnotationItemEditOperationRotateItem(const QString &itemId, double angle)
Constructor for QgsAnnotationItemEditOperationRotateItem, where the item with the specified itemId an...
double angle() const
Returns the rotation angle value (in degrees clockwise).
Type type() const override
Returns the operation type.
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...
double translationY() const
Returns the y-axis translation, in layer units.
QgsVertexId nodeId() const
Returns the deleted node ID.
Type type() const override
Returns the operation type.
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.
QgsAnnotationItemEditOperationTranslateItem(const QString &itemId, double translateX, double translateY, double translatePixelsX=0, double translatePixelsY=0)
Constructor for QgsAnnotationItemEditOperationTranslateItem, where the node with the specified id and...
A geometry is the spatial representation of a feature.
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:53
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:34