2 #ifndef HYDROData_Image_HeaderFile
3 #define HYDROData_Image_HeaderFile
5 #include <HYDROData_Entity.h>
10 DEFINE_STANDARD_HANDLE(HYDROData_Image, HYDROData_Entity)
12 /**\class HYDROData_Image
13 * \brief Class that stores/retreives information about the image.
15 * Keeps image as binary array, transformation and other properties
16 * of image with correspondent API for forkind wit hthese properties.
18 class HYDROData_Image : public HYDROData_Entity
23 enum TransformationMode
32 * Enumeration of tags corresponding to the persistent object parameters.
36 DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
37 DataTag_Operator, ///< name of the operator that must be executed for image update
38 DataTag_TrsfMode, ///< transformation mode (0 - Lambert93, 1 - Cartesian, 2 - on other Image)
39 DataTag_TrsfPoints, ///< image transformation points
40 DataTag_TrsfImage, ///< reference transformation image
41 DataTag_FilePath ///< image imported file path
45 DEFINE_STANDARD_RTTI(HYDROData_Image);
48 * Returns the kind of this object. Must be redefined in all objects of known type.
50 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_IMAGE;}
53 * Dump Image object to Python script representation.
55 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
58 * Updates object state.
59 * Reimplemented to update an Image object in the data structure.
60 * Call this method whenever you made changes for operator or reference objects.
61 * If it is changed, sets "MustBeUpdated" flag to other depended images.
63 HYDRODATA_EXPORT virtual void Update();
66 * Returns data of object wrapped to QVariant.
67 * Reimplemented to wrap and return saved image.
68 * Transformation are applied to result image.
70 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
74 * \param theImage new image
76 HYDRODATA_EXPORT void SetImage(const QImage& theImage);
79 * Load the image from file
80 * \param theFilePath path to image
82 HYDRODATA_EXPORT bool LoadImage(const QString& theFilePath);
85 * Returns the kept image
87 HYDRODATA_EXPORT QImage Image();
90 * Stores the image file path
91 * \param theFilePath image file path
93 HYDRODATA_EXPORT void SetFilePath(const QString& theFilePath);
96 * Returns uploaded image file path
98 HYDRODATA_EXPORT QString GetFilePath() const;
101 * Stores the image transformation
102 * \param theTrsf new transformation
104 HYDRODATA_EXPORT void SetTrsf(const QTransform& theTrsf);
107 * Returns the kept transformation, or "identity" if not yet stored
109 HYDRODATA_EXPORT QTransform Trsf() const;
112 * Updates the matrix of transformation in accordance with reference points.
113 * \param theTrsf new transformation
115 HYDRODATA_EXPORT void UpdateTrsf();
119 * Returns true if transformation is done by two points only
121 HYDRODATA_EXPORT bool IsByTwoPoints() const;
125 * Removes all references from this image.
127 HYDRODATA_EXPORT bool HasReferences() const;
130 * Removes all references from this image.
132 HYDRODATA_EXPORT void RemoveAllReferences();
136 * Stores the transformation points in local cs of image
137 * \param thePointA point A
138 * \param thePointB point B
139 * \param thePointC point C
141 HYDRODATA_EXPORT void SetLocalPoints( const QPoint& thePointA,
142 const QPoint& thePointB,
143 const QPoint& thePointC = QPoint( INT_MIN, INT_MIN ),
144 const bool theIsUpdate = true );
147 * Returns the transformation points in local cs of image
148 * \param thePointA point A
149 * \param thePointB point B
150 * \param thePointC point C
151 * \return true if all parameters has been set before
153 HYDRODATA_EXPORT bool GetLocalPoints( QPoint& thePointA,
155 QPoint& thePointC ) const;
158 * Returns true if local points has been set before
160 HYDRODATA_EXPORT bool HasLocalPoints() const;
164 * Stores the transformation points in global cs
165 * \param theMode transformation mode
166 * \param thePointA point A
167 * \param thePointB point B
168 * \param thePointC point C
170 HYDRODATA_EXPORT void SetGlobalPoints( const TransformationMode& theMode,
171 const QPointF& thePointA,
172 const QPointF& thePointB,
173 const QPointF& thePointC = QPoint( INT_MIN, INT_MIN ),
174 const bool theIsUpdate = true );
177 * Returns the transformation points in global cs
178 * \param theMode transformation mode
179 * \param thePointA point A
180 * \param thePointB point B
181 * \param thePointC point C
182 * \return true if all parameters has been set before
184 HYDRODATA_EXPORT bool GetGlobalPoints( TransformationMode& theMode,
187 QPointF& thePointC ) const;
190 * Returns true if global points has been set before
192 HYDRODATA_EXPORT bool HasGlobalPoints() const;
196 * Stores the transformation points in reference image local cs
197 * \param theRefImage reference image
198 * \param thePointA point A
199 * \param thePointB point B
200 * \param thePointC point C
202 HYDRODATA_EXPORT void SetReferencePoints( const Handle(HYDROData_Image)& theRefImage,
203 const QPointF& thePointA,
204 const QPointF& thePointB,
205 const QPointF& thePointC = QPoint( INT_MIN, INT_MIN ),
206 const bool theIsUpdate = true );
209 * Returns the transformation points in reference image local cs
210 * \param theRefImage reference image
211 * \param thePointA point A
212 * \param thePointB point B
213 * \param thePointC point C
214 * \return true if all parameters has been set correctly
216 HYDRODATA_EXPORT bool GetReferencePoints( Handle(HYDROData_Image)& theRefImage,
219 QPointF& thePointC ) const;
222 * Returns true if reference points has been set before
224 HYDRODATA_EXPORT bool HasReferencePoints() const;
228 * Stores the reference image for transformation
229 * \param theRefImage reference image
231 HYDRODATA_EXPORT void SetTrsfReferenceImage( const Handle(HYDROData_Image)& theRefImage );
234 * Returns the reference image for transformation
236 HYDRODATA_EXPORT Handle(HYDROData_Image) GetTrsfReferenceImage() const;
239 * Removes the reference image for transformation
241 HYDRODATA_EXPORT void RemoveTrsfReferenceImage();
245 * Stores the transformation mode
247 HYDRODATA_EXPORT void SetTrsfMode( const TransformationMode& theMode );
250 * Returns the transformation mode
252 HYDRODATA_EXPORT TransformationMode GetTrsfMode() const;
256 * Returns the number of referenced objects
257 * \return zero if there is no references
259 HYDRODATA_EXPORT int NbReferences() const;
262 * Appends reference to other object (image or polyline).
263 * \param theReferenced the object referenced by this
265 HYDRODATA_EXPORT void AppendReference( const Handle(HYDROData_Entity)& theReferenced );
268 * Returns reference by index.
269 * \param theIndex number of reference [0; NbReference)
270 * \returns the referenced object, or Null if index is invalid
272 HYDRODATA_EXPORT Handle(HYDROData_Entity) Reference(const int theIndex) const;
275 * Updates reference by index. If index is one-bigger than \a NbReferences,
276 * this method appends it to the end (NbReferences is incremented).
277 * \param theIndex number of reference [0; NbReference]
278 * \param theReferenced the object referenced by this
280 HYDRODATA_EXPORT void ChangeReference(
281 const int theIndex, Handle(HYDROData_Entity) theReferenced);
284 * Removes reference by index
285 * \param theIndex number of reference [0; NbReference)
287 HYDRODATA_EXPORT void RemoveReference(const int theIndex);
290 * Removes all references.
292 HYDRODATA_EXPORT void ClearReferences();
296 * Stores the operator name
297 * \param theOpName name of the operator that must be executed for image update
299 HYDRODATA_EXPORT void SetOperatorName(const QString theOpName);
302 * Returns the operator name
303 * \returns the name of the operator that must be executed for image update
305 HYDRODATA_EXPORT QString OperatorName() const;
308 * Stores the operator arguments
309 * \param theArgs array that stores the operator arguments, needed for execution
311 HYDRODATA_EXPORT void SetArgs(const QByteArray& theArgs);
314 * Returns the operator arguments
315 * \returns array that stores the operator arguments, needed for execution
317 HYDRODATA_EXPORT QByteArray Args() const;
321 * Marks the image as self-splitted.
322 * \param theFlag is true for self-splitted image
324 HYDRODATA_EXPORT void SetIsSelfSplitted(bool theFlag);
327 * Checks that the image is self-splitted.
328 * \returns true if image is self-splitted
330 HYDRODATA_EXPORT bool IsSelfSplitted() const;
334 QPointF generateThirdPoint( const QPointF& thePointA,
335 const QPointF& thePointB,
336 const bool& theIsLocal ) const;
340 friend class HYDROData_Iterator;
343 * Creates new object in the internal data structure. Use higher level objects
344 * to create objects with real content.
349 * Destructs properties of the object and object itself, removes it from the document.