ACF $AcfVersion:0$
CPolypoint.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// ACF includes
7#include <iser/CArchiveTag.h>
8#include <i2d/CObject2dBase.h>
9#include <i2d/CVector2d.h>
10#include <i2d/CRectangle.h>
11
12
13namespace i2d
14{
15
16
21{
22public:
23 static QByteArray GetTypeName();
24
28 virtual void Clear();
29
33 virtual void SetNodesCount(int nodesCount);
34
38 virtual int GetNodesCount() const;
39
43 bool IsEmpty() const;
44
49 virtual const i2d::CVector2d& GetNodePos(int index) const;
50
56 i2d::CVector2d& GetNodePosRef(int index);
57
63 virtual void SetNodePos(int index, const i2d::CVector2d& position);
64
68 virtual bool InsertNode(const i2d::CVector2d& position);
69
73 virtual bool InsertNode(int index, const i2d::CVector2d& position);
74
78 virtual bool RemoveNode(int index);
79
80 // reimplemented (i2d::IObject2d)
81 virtual CVector2d GetCenter() const override;
82 virtual void MoveCenterTo(const CVector2d& position) override;
83 virtual i2d::CRectangle GetBoundingBox() const override;
84 virtual bool Transform(
85 const ITransformation2d& transformation,
87 double* errorFactorPtr = NULL) override;
88 virtual bool InvTransform(
89 const ITransformation2d& transformation,
91 double* errorFactorPtr = NULL) override;
92 virtual bool GetTransformed(
93 const ITransformation2d& transformation,
94 IObject2d& result,
96 double* errorFactorPtr = NULL) const override;
97 virtual bool GetInvTransformed(
98 const ITransformation2d& transformation,
99 IObject2d& result,
101 double* errorFactorPtr = NULL) const override;
102
103 // reimplemented (iser::IObject)
104 virtual QByteArray GetFactoryId() const override;
105
106 // reimplemented (iser::ISerializable)
107 virtual bool Serialize(iser::IArchive& archive) override;
108
109 // reimplemented (istd::IChangeable)
110 virtual int GetSupportedOperations() const override;
111 virtual bool CopyFrom(const IChangeable& object, CompatibilityMode mode = CM_WITHOUT_REFS) override;
113 virtual bool IsEqual(const IChangeable& object) const override;
114
115protected:
120
121private:
122 // std::vector can be faster than QVector
123 typedef std::vector<i2d::CVector2d> Nodes;
124
128 static bool ApplyTransform(Nodes& nodes,
129 const ITransformation2d& transformation,
131 double* errorFactorPtr = NULL);
132
136 static bool ApplyInverseTransform(
137 Nodes& nodes,
138 const ITransformation2d& transformation,
140 double* errorFactorPtr = NULL);
141
142 Nodes m_positions;
143};
144
145
146// inline functions
147
149{
150 return int(m_positions.size());
151}
152
153
154inline bool CPolypoint::IsEmpty() const
155{
156 return m_positions.empty();
157}
158
159
160inline const i2d::CVector2d& CPolypoint::GetNodePos(int index) const
161{
162 Q_ASSERT(index >= 0 && index < int(m_positions.size()));
163
164 return m_positions[index];
165}
166
167
169{
170 Q_ASSERT(index >= 0 && index < int(m_positions.size()));
171
172 return m_positions[index];
173}
174
175
176inline void CPolypoint::SetNodePos(int index, const i2d::CVector2d& position)
177{
178 Q_ASSERT(index >= 0 && index < int(m_positions.size()));
179
180 istd::CChangeNotifier changeNotifier(this);
181 Q_UNUSED(changeNotifier);
182
183 m_positions[index] = position;
184}
185
186
187} // namespace i2d
188
189
190
191
Base class for 2D-objects implementing interface i2d::IObject2d.
Definition of the data model for a polygon.
Definition CPolypoint.h:21
static QByteArray GetTypeName()
static const istd::IChangeable::ChangeSet s_removePolygonNodeChange
Definition CPolypoint.h:119
virtual bool InsertNode(const i2d::CVector2d &position)
Insert a node at the end of node table.
virtual const i2d::CVector2d & GetNodePos(int index) const
Return position of node at specified index.
Definition CPolypoint.h:160
virtual void Clear()
Removes all nodes.
virtual void SetNodePos(int index, const i2d::CVector2d &position)
Set node at specified index.
Definition CPolypoint.h:176
virtual void MoveCenterTo(const CVector2d &position) override
Move object to position position.
bool IsEmpty() const
Return true if there are no points.
Definition CPolypoint.h:154
virtual int GetNodesCount() const
Return size of node table.
Definition CPolypoint.h:148
virtual bool InvTransform(const ITransformation2d &transformation, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=NULL) override
Do inverse transformation of this object.
virtual bool CopyFrom(const IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS) override
i2d::CVector2d & GetNodePosRef(int index)
Get reference to position object for node.
Definition CPolypoint.h:168
virtual bool IsEqual(const IChangeable &object) const override
virtual void SetNodesCount(int nodesCount)
Set new nodes count.
static const istd::IChangeable::ChangeSet s_insertPolygonNodeChange
Definition CPolypoint.h:118
virtual bool Transform(const ITransformation2d &transformation, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=NULL) override
Transform this object using some transformation.
virtual QByteArray GetFactoryId() const override
virtual i2d::CRectangle GetBoundingBox() const override
Get bounding box of this shape.
virtual CVector2d GetCenter() const override
Returns center of this 2D-object.
virtual bool GetTransformed(const ITransformation2d &transformation, IObject2d &result, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=NULL) const override
Calulate transformation of the object into second one.
static const istd::IChangeable::ChangeSet s_clearAllNodesChange
Definition CPolypoint.h:116
virtual bool RemoveNode(int index)
Remove a node at specified index.
virtual bool InsertNode(int index, const i2d::CVector2d &position)
Insert a node at specified index.
static const istd::IChangeable::ChangeSet s_createPolygonNodesChange
Definition CPolypoint.h:117
virtual bool Serialize(iser::IArchive &archive) override
Load or store state of this object as a archive stream.
virtual int GetSupportedOperations() const override
Get set of flags for supported operations.
virtual istd::TUniqueInterfacePtr< istd::IChangeable > CloneMe(CompatibilityMode mode=CM_WITHOUT_REFS) const override
Make a copy of this object.
virtual bool GetInvTransformed(const ITransformation2d &transformation, IObject2d &result, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=NULL) const override
Calulate inverse transformation of the object into second one.
Definition of rectangle area orthogonal to axis of coordination system.
Definition CRectangle.h:27
Definition of position or mathematical vector on 2D plane.
Definition CVector2d.h:29
Common interface for describing the 2D-objects.
Definition IObject2d.h:26
Common interface for all calibration objects.
@ EM_NONE
There are no preferences, should be automatically selected.
Represents an input/output persistence archive for object serialization.
Definition IArchive.h:164
Help class which provides the automatic update mechanism of the model.
Set of change flags (its IDs).
Definition IChangeable.h:36
CompatibilityMode
Control how relationship betweeen objects are interpreted.
@ CM_WITHOUT_REFS
External references are simple ignored.
Unique ownership smart pointer for interface types.
#define NULL
Definition istd.h:74
Contains the 2D objects.
Definition CAffine2d.h:11