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();
73 * Returns the list of all reference objects of this object.
75 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
80 * \param theImage new image
82 HYDRODATA_EXPORT void SetImage(const QImage& theImage);
85 * Load the image from file
86 * \param theFilePath path to image
88 HYDRODATA_EXPORT bool LoadImage(const QString& theFilePath);
91 * Returns the kept image
93 HYDRODATA_EXPORT QImage Image();
96 * Stores the image file path
97 * \param theFilePath image file path
99 HYDRODATA_EXPORT void SetFilePath(const QString& theFilePath);
102 * Returns uploaded image file path
104 HYDRODATA_EXPORT QString GetFilePath() const;
107 * Stores the image transformation
108 * \param theTrsf new transformation
110 HYDRODATA_EXPORT void SetTrsf(const QTransform& theTrsf);
113 * Returns the kept transformation, or "identity" if not yet stored
115 HYDRODATA_EXPORT QTransform Trsf() const;
118 * Updates the matrix of transformation in accordance with reference points.
119 * \param theTrsf new transformation
121 HYDRODATA_EXPORT void UpdateTrsf();
125 * Returns true if transformation is done by two points only
127 HYDRODATA_EXPORT bool IsByTwoPoints() const;
131 * Removes all references from this image.
133 HYDRODATA_EXPORT bool HasReferences() const;
136 * Removes all references from this image.
138 HYDRODATA_EXPORT void RemoveAllReferences();
142 * Stores the transformation points in local cs of image
143 * \param thePointA point A
144 * \param thePointB point B
145 * \param thePointC point C
147 HYDRODATA_EXPORT void SetLocalPoints( const QPoint& thePointA,
148 const QPoint& thePointB,
149 const QPoint& thePointC = QPoint( INT_MIN, INT_MIN ),
150 const bool theIsUpdate = true );
153 * Returns the transformation points in local cs of image
154 * \param thePointA point A
155 * \param thePointB point B
156 * \param thePointC point C
157 * \return true if all parameters has been set before
159 HYDRODATA_EXPORT bool GetLocalPoints( QPoint& thePointA,
161 QPoint& thePointC ) const;
164 * Returns true if local points has been set before
166 HYDRODATA_EXPORT bool HasLocalPoints() const;
170 * Stores the transformation points in global cs
171 * \param theMode transformation mode
172 * \param thePointA point A
173 * \param thePointB point B
174 * \param thePointC point C
176 HYDRODATA_EXPORT void SetGlobalPoints( const TransformationMode& theMode,
177 const QPointF& thePointA,
178 const QPointF& thePointB,
179 const QPointF& thePointC = QPoint( INT_MIN, INT_MIN ),
180 const bool theIsUpdate = true );
183 * Returns the transformation points in global cs
184 * \param theMode transformation mode
185 * \param thePointA point A
186 * \param thePointB point B
187 * \param thePointC point C
188 * \return true if all parameters has been set before
190 HYDRODATA_EXPORT bool GetGlobalPoints( TransformationMode& theMode,
193 QPointF& thePointC ) const;
196 * Returns true if global points has been set before
198 HYDRODATA_EXPORT bool HasGlobalPoints() const;
202 * Stores the transformation points in reference image local cs
203 * \param theRefImage reference image
204 * \param thePointA point A
205 * \param thePointB point B
206 * \param thePointC point C
208 HYDRODATA_EXPORT void SetReferencePoints( const Handle(HYDROData_Image)& theRefImage,
209 const QPointF& thePointA,
210 const QPointF& thePointB,
211 const QPointF& thePointC = QPoint( INT_MIN, INT_MIN ),
212 const bool theIsUpdate = true );
215 * Returns the transformation points in reference image local cs
216 * \param theRefImage reference image
217 * \param thePointA point A
218 * \param thePointB point B
219 * \param thePointC point C
220 * \return true if all parameters has been set correctly
222 HYDRODATA_EXPORT bool GetReferencePoints( Handle(HYDROData_Image)& theRefImage,
225 QPointF& thePointC ) const;
228 * Returns true if reference points has been set before
230 HYDRODATA_EXPORT bool HasReferencePoints() const;
234 * Stores the reference image for transformation
235 * \param theRefImage reference image
237 HYDRODATA_EXPORT void SetTrsfReferenceImage( const Handle(HYDROData_Image)& theRefImage );
240 * Returns the reference image for transformation
242 HYDRODATA_EXPORT Handle(HYDROData_Image) GetTrsfReferenceImage() const;
245 * Removes the reference image for transformation
247 HYDRODATA_EXPORT void RemoveTrsfReferenceImage();
251 * Stores the transformation mode
253 HYDRODATA_EXPORT void SetTrsfMode( const TransformationMode& theMode );
256 * Returns the transformation mode
258 HYDRODATA_EXPORT TransformationMode GetTrsfMode() const;
262 * Returns the number of referenced objects
263 * \return zero if there is no references
265 HYDRODATA_EXPORT int NbReferences() const;
268 * Appends reference to other object (image or polyline).
269 * \param theReferenced the object referenced by this
271 HYDRODATA_EXPORT void AppendReference( const Handle(HYDROData_Entity)& theReferenced );
274 * Returns reference by index.
275 * \param theIndex number of reference [0; NbReference)
276 * \returns the referenced object, or Null if index is invalid
278 HYDRODATA_EXPORT Handle(HYDROData_Entity) Reference(const int theIndex) const;
281 * Updates reference by index. If index is one-bigger than \a NbReferences,
282 * this method appends it to the end (NbReferences is incremented).
283 * \param theIndex number of reference [0; NbReference]
284 * \param theReferenced the object referenced by this
286 HYDRODATA_EXPORT void ChangeReference(
287 const int theIndex, Handle(HYDROData_Entity) theReferenced);
290 * Removes reference by index
291 * \param theIndex number of reference [0; NbReference)
293 HYDRODATA_EXPORT void RemoveReference(const int theIndex);
296 * Removes all references.
298 HYDRODATA_EXPORT void ClearReferences();
302 * Stores the operator name
303 * \param theOpName name of the operator that must be executed for image update
305 HYDRODATA_EXPORT void SetOperatorName(const QString theOpName);
308 * Returns the operator name
309 * \returns the name of the operator that must be executed for image update
311 HYDRODATA_EXPORT QString OperatorName() const;
314 * Stores the operator arguments
315 * \param theArgs array that stores the operator arguments, needed for execution
317 HYDRODATA_EXPORT void SetArgs(const QByteArray& theArgs);
320 * Returns the operator arguments
321 * \returns array that stores the operator arguments, needed for execution
323 HYDRODATA_EXPORT QByteArray Args() const;
327 * Marks the image as self-splitted.
328 * \param theFlag is true for self-splitted image
330 HYDRODATA_EXPORT void SetIsSelfSplitted(bool theFlag);
333 * Checks that the image is self-splitted.
334 * \returns true if image is self-splitted
336 HYDRODATA_EXPORT bool IsSelfSplitted() const;
340 QPointF generateThirdPoint( const QPointF& thePointA,
341 const QPointF& thePointB,
342 const bool& theIsLocal ) const;
346 friend class HYDROData_Iterator;
349 * Creates new object in the internal data structure. Use higher level objects
350 * to create objects with real content.
352 HYDRODATA_EXPORT HYDROData_Image();
355 * Destructs properties of the object and object itself, removes it from the document.
357 HYDRODATA_EXPORT ~HYDROData_Image();