ICF 3.0.5.47
Technical documentation of ICF Libraries
CPolypoint.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#pragma once
7
8
9// ICF includes
11#include <iser/CArchiveTag.h>
12#include <i2d/CObject2dBase.h>
13#include <i2d/CVector2d.h>
14#include <i2d/CRectangle.h>
15
16
17namespace i2d
18{
19
20
25{
26public:
27 static QByteArray GetTypeName();
28
32 virtual void Clear();
33
37 virtual void SetNodesCount(int nodesCount);
38
42 virtual int GetNodesCount() const;
43
47 bool IsEmpty() const;
48
53 virtual const i2d::CVector2d& GetNodePos(int index) const;
54
60 i2d::CVector2d& GetNodePosRef(int index);
61
67 virtual void SetNodePos(int index, const i2d::CVector2d& position);
68
72 virtual bool InsertNode(const i2d::CVector2d& position);
73
77 virtual bool InsertNode(int index, const i2d::CVector2d& position);
78
82 virtual bool RemoveNode(int index);
83
84 // reimplemented (i2d::IObject2d)
85 CVector2d GetCenter() const override;
86 void MoveCenterTo(const CVector2d& position) override;
89 const ITransformation2d& transformation,
91 double* errorFactorPtr = nullptr) override;
93 const ITransformation2d& transformation,
95 double* errorFactorPtr = nullptr) override;
97 const ITransformation2d& transformation,
98 IObject2d& result,
100 double* errorFactorPtr = nullptr) const override;
102 const ITransformation2d& transformation,
103 IObject2d& result,
105 double* errorFactorPtr = nullptr) const override;
106
107 // reimplemented (iser::IObject)
108 QByteArray GetFactoryId() const override;
109
110 // reimplemented (iser::ISerializable)
111 bool Serialize(iser::IArchive& archive) override;
112
113 // reimplemented (istd::IChangeable)
114 int GetSupportedOperations() const override;
115 bool CopyFrom(const IChangeable& object, CompatibilityMode mode = CM_WITHOUT_REFS) override;
116 std::unique_ptr<istd::IChangeable> CloneMe(CompatibilityMode mode = CM_WITHOUT_REFS) const override;
117 bool IsEqual(const IChangeable& object) const override;
118
119protected:
124
125private:
126 // std::vector can be faster than QVector
127 typedef std::vector<i2d::CVector2d> Nodes;
128
132 static bool ApplyTransform(Nodes& nodes,
133 const ITransformation2d& transformation,
135 double* errorFactorPtr = nullptr);
136
140 static bool ApplyInverseTransform(
141 Nodes& nodes,
142 const ITransformation2d& transformation,
144 double* errorFactorPtr = nullptr);
145
146 Nodes m_positions;
147};
148
149
150// inline functions
151
153{
154 return int(m_positions.size());
155}
156
157
158inline bool CPolypoint::IsEmpty() const
159{
160 return m_positions.empty();
161}
162
163
164inline const i2d::CVector2d& CPolypoint::GetNodePos(int index) const
165{
166 Q_ASSERT(index >= 0 && index < int(m_positions.size()));
167
168 return m_positions[index];
169}
170
171
173{
174 Q_ASSERT(index >= 0 && index < int(m_positions.size()));
175
176 return m_positions[index];
177}
178
179
180inline void CPolypoint::SetNodePos(int index, const i2d::CVector2d& position)
181{
182 Q_ASSERT(index >= 0 && index < int(m_positions.size()));
183
184 istd::CChangeNotifier changeNotifier(this);
185
186 m_positions[index] = position;
187}
188
189
190} // namespace i2d
191
192
Base class for 2D-objects implementing interface i2d::IObject2d.
Definition of the data model for a polygon.
Definition CPolypoint.h:25
static QByteArray GetTypeName()
static const istd::IChangeable::ChangeSet s_removePolygonNodeChange
Definition CPolypoint.h:123
QByteArray GetFactoryId() const override
bool InvTransform(const ITransformation2d &transformation, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=nullptr) override
Do inverse transformation of this object.
i2d::CRectangle GetBoundingBox() const override
Get bounding box of this shape.
virtual bool InsertNode(const i2d::CVector2d &position)
Insert a node at the end of node table.
bool CopyFrom(const IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS) override
virtual const i2d::CVector2d & GetNodePos(int index) const
Return position of node at specified index.
Definition CPolypoint.h:164
virtual void Clear()
Removes all nodes.
bool Transform(const ITransformation2d &transformation, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=nullptr) override
Transform this object using some transformation.
std::unique_ptr< istd::IChangeable > CloneMe(CompatibilityMode mode=CM_WITHOUT_REFS) const override
Make a copy of this object.
virtual void SetNodePos(int index, const i2d::CVector2d &position)
Set node at specified index.
Definition CPolypoint.h:180
bool IsEmpty() const
Return true if there are no points.
Definition CPolypoint.h:158
virtual int GetNodesCount() const
Return size of node table.
Definition CPolypoint.h:152
bool GetTransformed(const ITransformation2d &transformation, IObject2d &result, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=nullptr) const override
Calulate transformation of the object into second one.
bool Serialize(iser::IArchive &archive) override
Load or store state of this object as a archive stream.
i2d::CVector2d & GetNodePosRef(int index)
Get reference to position object for node.
Definition CPolypoint.h:172
bool GetInvTransformed(const ITransformation2d &transformation, IObject2d &result, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=nullptr) const override
Calulate inverse transformation of the object into second one.
virtual void SetNodesCount(int nodesCount)
Set new nodes count.
static const istd::IChangeable::ChangeSet s_insertPolygonNodeChange
Definition CPolypoint.h:122
static const istd::IChangeable::ChangeSet s_clearAllNodesChange
Definition CPolypoint.h:120
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:121
CVector2d GetCenter() const override
Returns center of this 2D-object.
void MoveCenterTo(const CVector2d &position) override
Move object to position position.
bool IsEqual(const IChangeable &object) const override
int GetSupportedOperations() const override
Get set of flags for supported operations.
Definition of rectangle area orthogonal to axis of coordination system.
Definition CRectangle.h:31
Definition of position or mathematical vector on 2D plane.
Definition CVector2d.h:29
Common interface for describing the 2D-objects.
Definition IObject2d.h:30
Common interface for all calibration objects.
@ EM_NONE
There are no preferences, should be automatically selected.
Represent input/output persistence archive.
Definition IArchive.h:33
Help class which provides the automatic update mechanism of the model.
Set of change flags (its IDs).
Definition IChangeable.h:38
CompatibilityMode
Control how relationship betweeen objects are interpreted.
@ CM_WITHOUT_REFS
External references are simple ignored.
Contains the 2D objects.
Definition CAffine2d.h:15

© Witold Gantzke and Kirill Lepskiy