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
33 * Enumeration of tags corresponding to the persistent object parameters.
37 DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
38 DataTag_Operator, ///< name of the operator that must be executed for image update
39 DataTag_TrsfMode, ///< transformation mode (0 - Lambert93, 1 - Cartesian, 2 - on other Image)
40 DataTag_TrsfPoints, ///< image transformation points
41 DataTag_TrsfImage, ///< reference transformation image
42 DataTag_FilePath ///< image imported file path
46 DEFINE_STANDARD_RTTI(HYDROData_Image);
49 * Returns the kind of this object. Must be redefined in all objects of known type.
51 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_IMAGE;}
54 * Dump Image object to Python script representation.
56 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
59 * Updates object state.
60 * Reimplemented to update an Image object in the data structure.
61 * Call this method whenever you made changes for operator or reference objects.
62 * If it is changed, sets "MustBeUpdated" flag to other depended images.
64 HYDRODATA_EXPORT virtual void Update();
67 * Returns data of object wrapped to QVariant.
68 * Reimplemented to wrap and return saved image.
69 * Transformation are applied to result image.
71 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
74 * Returns the list of all reference objects of this object.
76 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
81 * \param theImage new image
83 HYDRODATA_EXPORT void SetImage(const QImage& theImage);
86 * Load the image from file
87 * \param theFilePath path to image
89 HYDRODATA_EXPORT bool LoadImage(const QString& theFilePath);
92 * Returns the kept image
94 HYDRODATA_EXPORT QImage Image();
97 * Stores the image file path
98 * \param theFilePath image file path
100 HYDRODATA_EXPORT void SetFilePath(const QString& theFilePath);
103 * Returns uploaded image file path
105 HYDRODATA_EXPORT QString GetFilePath() const;
108 * Stores the image transformation
109 * \param theTrsf new transformation
111 HYDRODATA_EXPORT void SetTrsf(const QTransform& theTrsf);
114 * Returns the kept transformation, or "identity" if not yet stored
116 HYDRODATA_EXPORT QTransform Trsf() const;
119 * Updates the matrix of transformation in accordance with reference points.
120 * \param theTrsf new transformation
122 HYDRODATA_EXPORT void UpdateTrsf();
126 * Returns true if transformation is done by two points only
128 HYDRODATA_EXPORT bool IsByTwoPoints() const;
132 * Removes all references from this image.
134 HYDRODATA_EXPORT bool HasReferences() const;
137 * Removes all references from this image.
139 HYDRODATA_EXPORT void RemoveAllReferences();
143 * Stores the transformation points in local cs of image
144 * \param thePointA point A
145 * \param thePointB point B
146 * \param thePointC point C
148 HYDRODATA_EXPORT void SetLocalPoints( const QPoint& thePointA,
149 const QPoint& thePointB,
150 const QPoint& thePointC = QPoint( INT_MIN, INT_MIN ),
151 const bool theIsUpdate = true );
154 * Returns the transformation points in local cs of image
155 * \param thePointA point A
156 * \param thePointB point B
157 * \param thePointC point C
158 * \return true if all parameters has been set before
160 HYDRODATA_EXPORT bool GetLocalPoints( QPoint& thePointA,
162 QPoint& thePointC ) const;
165 * Returns true if local points has been set before
167 HYDRODATA_EXPORT bool HasLocalPoints() const;
171 * Stores the transformation points in global cs
172 * \param theMode transformation mode
173 * \param thePointA point A
174 * \param thePointB point B
175 * \param thePointC point C
177 HYDRODATA_EXPORT void SetGlobalPoints( const TransformationMode& theMode,
178 const QPointF& thePointA,
179 const QPointF& thePointB,
180 const QPointF& thePointC = QPoint( INT_MIN, INT_MIN ),
181 const bool theIsUpdate = true );
184 * Returns the transformation points in global cs
185 * \param theMode transformation mode
186 * \param thePointA point A
187 * \param thePointB point B
188 * \param thePointC point C
189 * \return true if all parameters has been set before
191 HYDRODATA_EXPORT bool GetGlobalPoints( TransformationMode& theMode,
194 QPointF& thePointC ) const;
197 * Get transformation points from the file and stores them in global cs
198 * \param theFileName the image georeferencement file name
199 * \return true in case of success
201 HYDRODATA_EXPORT bool SetGlobalPointsFromFile( const QString& theFileName );
204 * Returns true if global points has been set before
206 HYDRODATA_EXPORT bool HasGlobalPoints() const;
210 * Stores the transformation points in reference image local cs
211 * \param theRefImage reference image
212 * \param thePointA point A
213 * \param thePointB point B
214 * \param thePointC point C
216 HYDRODATA_EXPORT void SetReferencePoints( const Handle(HYDROData_Image)& theRefImage,
217 const QPointF& thePointA,
218 const QPointF& thePointB,
219 const QPointF& thePointC = QPoint( INT_MIN, INT_MIN ),
220 const bool theIsUpdate = true );
223 * Returns the transformation points in reference image local cs
224 * \param theRefImage reference image
225 * \param thePointA point A
226 * \param thePointB point B
227 * \param thePointC point C
228 * \return true if all parameters has been set correctly
230 HYDRODATA_EXPORT bool GetReferencePoints( Handle(HYDROData_Image)& theRefImage,
233 QPointF& thePointC ) const;
236 * Returns true if reference points has been set before
238 HYDRODATA_EXPORT bool HasReferencePoints() const;
242 * Stores the reference image for transformation
243 * \param theRefImage reference image
245 HYDRODATA_EXPORT void SetTrsfReferenceImage( const Handle(HYDROData_Image)& theRefImage );
248 * Returns the reference image for transformation
250 HYDRODATA_EXPORT Handle(HYDROData_Image) GetTrsfReferenceImage() const;
253 * Removes the reference image for transformation
255 HYDRODATA_EXPORT void RemoveTrsfReferenceImage();
259 * Stores the transformation mode
261 HYDRODATA_EXPORT void SetTrsfMode( const TransformationMode& theMode );
264 * Returns the transformation mode
266 HYDRODATA_EXPORT TransformationMode GetTrsfMode() const;
270 * Returns the number of referenced objects
271 * \return zero if there is no references
273 HYDRODATA_EXPORT int NbReferences() const;
276 * Appends reference to other object (image or polyline).
277 * \param theReferenced the object referenced by this
279 HYDRODATA_EXPORT void AppendReference( const Handle(HYDROData_Entity)& theReferenced );
282 * Returns reference by index.
283 * \param theIndex number of reference [0; NbReference)
284 * \returns the referenced object, or Null if index is invalid
286 HYDRODATA_EXPORT Handle(HYDROData_Entity) Reference(const int theIndex) const;
289 * Updates reference by index. If index is one-bigger than \a NbReferences,
290 * this method appends it to the end (NbReferences is incremented).
291 * \param theIndex number of reference [0; NbReference]
292 * \param theReferenced the object referenced by this
294 HYDRODATA_EXPORT void ChangeReference(
295 const int theIndex, Handle(HYDROData_Entity) theReferenced);
298 * Removes reference by index
299 * \param theIndex number of reference [0; NbReference)
301 HYDRODATA_EXPORT void RemoveReference(const int theIndex);
304 * Removes all references.
306 HYDRODATA_EXPORT void ClearReferences();
310 * Stores the operator name
311 * \param theOpName name of the operator that must be executed for image update
313 HYDRODATA_EXPORT void SetOperatorName(const QString theOpName);
316 * Returns the operator name
317 * \returns the name of the operator that must be executed for image update
319 HYDRODATA_EXPORT QString OperatorName() const;
322 * Stores the operator arguments
323 * \param theArgs array that stores the operator arguments, needed for execution
325 HYDRODATA_EXPORT void SetArgs(const QByteArray& theArgs);
328 * Returns the operator arguments
329 * \returns array that stores the operator arguments, needed for execution
331 HYDRODATA_EXPORT QByteArray Args() const;
335 * Marks the image as self-splitted.
336 * \param theFlag is true for self-splitted image
338 HYDRODATA_EXPORT void SetIsSelfSplitted(bool theFlag);
341 * Checks that the image is self-splitted.
342 * \returns true if image is self-splitted
344 HYDRODATA_EXPORT bool IsSelfSplitted() const;
348 QPointF generateThirdPoint( const QPointF& thePointA,
349 const QPointF& thePointB,
350 const bool& theIsLocal ) const;
354 friend class HYDROData_Iterator;
357 * Creates new object in the internal data structure. Use higher level objects
358 * to create objects with real content.
360 HYDRODATA_EXPORT HYDROData_Image();
363 * Destructs properties of the object and object itself, removes it from the document.
365 HYDRODATA_EXPORT ~HYDROData_Image();