CPolypoint.h
Go to the documentation of this file.
1 #ifndef i2d_CPolypoint_included
2 #define i2d_CPolypoint_included
3 
4 
5 // ACF includes
6 #include <istd/CChangeNotifier.h>
7 #include <iser/CArchiveTag.h>
8 #include <i2d/CObject2dBase.h>
9 #include <i2d/CVector2d.h>
10 #include <i2d/CRectangle.h>
11 
12 
13 namespace i2d
14 {
15 
16 
21 {
22 public:
23  static QByteArray GetTypeName();
24 
28  virtual void Clear();
29 
33  virtual void SetNodesCount(int nodesCount);
34 
38  virtual int GetNodesCount() const;
39 
44  virtual const i2d::CVector2d& GetNodePos(int index) const;
45 
51  i2d::CVector2d& GetNodePosRef(int index);
52 
58  virtual void SetNodePos(int index, const i2d::CVector2d& position);
59 
63  virtual bool InsertNode(const i2d::CVector2d& position);
64 
68  virtual bool InsertNode(int index, const i2d::CVector2d& position);
69 
73  virtual bool RemoveNode(int index);
74 
75  // reimplemented (i2d::IObject2d)
76  virtual CVector2d GetCenter() const;
77  virtual void MoveCenterTo(const CVector2d& position);
78  virtual i2d::CRectangle GetBoundingBox() const;
79  virtual bool Transform(
80  const ITransformation2d& transformation,
82  double* errorFactorPtr = NULL);
83  virtual bool InvTransform(
84  const ITransformation2d& transformation,
86  double* errorFactorPtr = NULL);
87  virtual bool GetTransformed(
88  const ITransformation2d& transformation,
89  IObject2d& result,
91  double* errorFactorPtr = NULL) const;
92  virtual bool GetInvTransformed(
93  const ITransformation2d& transformation,
94  IObject2d& result,
96  double* errorFactorPtr = NULL) const;
97 
98  // reimplemented (iser::IObject)
99  virtual QByteArray GetFactoryId() const;
100 
101  // reimplemented (iser::ISerializable)
102  virtual bool Serialize(iser::IArchive& archive);
103 
104  // reimplemented (istd::IChangeable)
105  virtual int GetSupportedOperations() const;
106  virtual bool CopyFrom(const IChangeable& object, CompatibilityMode mode = CM_WITHOUT_REFS);
108  virtual bool IsEqual(const IChangeable& object) const;
109 
110 protected:
115 
116 private:
117  // std::vector can be faster than QVector
118  typedef std::vector<i2d::CVector2d> Nodes;
119 
123  static bool ApplyTransform(Nodes& nodes,
124  const ITransformation2d& transformation,
126  double* errorFactorPtr = NULL);
127 
131  static bool ApplyInverseTransform(
132  Nodes& nodes,
133  const ITransformation2d& transformation,
135  double* errorFactorPtr = NULL);
136 
137  Nodes m_positions;
138 };
139 
140 
141 // inline functions
142 
143 inline int CPolypoint::GetNodesCount() const
144 {
145  return int(m_positions.size());
146 }
147 
148 
149 inline const i2d::CVector2d& CPolypoint::GetNodePos(int index) const
150 {
151  Q_ASSERT(index >= 0 && index < int(m_positions.size()));
152 
153  return m_positions[index];
154 }
155 
156 
158 {
159  Q_ASSERT(index >= 0 && index < int(m_positions.size()));
160 
161  return m_positions[index];
162 }
163 
164 
165 inline void CPolypoint::SetNodePos(int index, const i2d::CVector2d& position)
166 {
167  Q_ASSERT(index >= 0 && index < int(m_positions.size()));
168 
169  istd::CChangeNotifier changeNotifier(this);
170  Q_UNUSED(changeNotifier);
171 
172  m_positions[index] = position;
173 }
174 
175 
176 } // namespace i2d
177 
178 
179 #endif // !i2d_CPolypoint_included
180 
181 
static const istd::IChangeable::ChangeSet s_createPolygonNodesChange
Definition: CPolypoint.h:112
virtual bool GetInvTransformed(const ITransformation2d &transformation, IObject2d &result, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=NULL) const
Calulate inverse transformation of the object into second one.
virtual void Clear()
Removes all nodes.
External references are simple ignored.
Definition: IChangeable.h:197
CompatibilityMode
Control how relationship betweeen objects are interpreted.
Definition: IChangeable.h:186
static const istd::IChangeable::ChangeSet s_removePolygonNodeChange
Definition: CPolypoint.h:114
virtual CVector2d GetCenter() const
Returns center of this 2D-object.
virtual istd::IChangeable * CloneMe(CompatibilityMode mode=CM_WITHOUT_REFS) const
Make a copy of this object.
virtual int GetSupportedOperations() const
Get set of flags for supported operations.
Common interface for all calibration objects.
virtual bool Serialize(iser::IArchive &archive)
Load or store state of this object as a archive stream.
virtual bool CopyFrom(const IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS)
virtual bool RemoveNode(int index)
Remove a node at specified index.
virtual i2d::CRectangle GetBoundingBox() const
Get bounding box of this shape.
There are no preferences, should be automatically selected.
virtual const i2d::CVector2d & GetNodePos(int index) const
Return position of node at specified index.
Definition: CPolypoint.h:149
virtual bool IsEqual(const IChangeable &object) const
Represent input/output persistence archive.
Definition: IArchive.h:30
Common interface for data model objects, which can be changed.
Definition: IChangeable.h:24
Definition of rectangle area orthogonal to axis of coordination system.
Definition: CRectangle.h:26
Definition of position or mathematical vector on 2D plane.
Definition: CVector2d.h:28
virtual bool Transform(const ITransformation2d &transformation, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=NULL)
Transform this object using some transformation.
Help class which provides the automatic update mechanism of the model.
virtual bool InsertNode(const i2d::CVector2d &position)
Insert a node at the end of node table.
Base class for 2D-objects implementing interface i2d::IObject2d.
Definition: CObject2dBase.h:18
static QByteArray GetTypeName()
virtual void SetNodePos(int index, const i2d::CVector2d &position)
Set node at specified index.
Definition: CPolypoint.h:165
#define NULL
Definition: istd.h:64
virtual bool InvTransform(const ITransformation2d &transformation, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=NULL)
Do inverse transformation of this object.
Definition of the data model for a polygon.
Definition: CPolypoint.h:20
i2d::CVector2d & GetNodePosRef(int index)
Get reference to position object for node.
Definition: CPolypoint.h:157
Common interface for describing the 2D-objects.
Definition: IObject2d.h:22
virtual int GetNodesCount() const
Return size of node table.
Definition: CPolypoint.h:143
Set of change flags (its IDs).
Definition: IChangeable.h:30
virtual bool GetTransformed(const ITransformation2d &transformation, IObject2d &result, ITransformation2d::ExactnessMode mode=ITransformation2d::EM_NONE, double *errorFactorPtr=NULL) const
Calulate transformation of the object into second one.
virtual void MoveCenterTo(const CVector2d &position)
Move object to position position.
static const istd::IChangeable::ChangeSet s_insertPolygonNodeChange
Definition: CPolypoint.h:113
virtual void SetNodesCount(int nodesCount)
Set new nodes count.
static const istd::IChangeable::ChangeSet s_clearAllNodesChange
Definition: CPolypoint.h:111
virtual QByteArray GetFactoryId() const

© 2007-2017 Witold Gantzke and Kirill Lepskiy