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 * Checks that object has 2D presentation. Reimlemented to retun true.
69 HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
72 * Returns data of object wrapped to QVariant.
73 * Reimplemented to wrap and return saved image.
74 * Transformation are applied to result image.
76 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
79 * Returns the list of all reference objects of this object.
81 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
86 * \param theImage new image
88 HYDRODATA_EXPORT void SetImage(const QImage& theImage);
91 * Load the image from file
92 * \param theFilePath path to image
94 HYDRODATA_EXPORT bool LoadImage(const QString& theFilePath);
97 * Returns the kept image
99 HYDRODATA_EXPORT QImage Image();
102 * Stores the image file path
103 * \param theFilePath image file path
105 HYDRODATA_EXPORT void SetFilePath(const QString& theFilePath);
108 * Returns uploaded image file path
110 HYDRODATA_EXPORT QString GetFilePath() const;
113 * Stores the image transformation
114 * \param theTrsf new transformation
116 HYDRODATA_EXPORT void SetTrsf(const QTransform& theTrsf);
119 * Returns the kept transformation, or "identity" if not yet stored
121 HYDRODATA_EXPORT QTransform Trsf() const;
124 * Updates the matrix of transformation in accordance with reference points.
125 * \param theTrsf new transformation
127 HYDRODATA_EXPORT void UpdateTrsf();
131 * Returns true if transformation is done by two points only
133 HYDRODATA_EXPORT bool IsByTwoPoints() const;
137 * Removes all references from this image.
139 HYDRODATA_EXPORT bool HasReferences() const;
142 * Removes all references from this image.
144 HYDRODATA_EXPORT void RemoveAllReferences();
148 * Stores the transformation points in local cs of image
149 * \param thePointA point A
150 * \param thePointB point B
151 * \param thePointC point C
153 HYDRODATA_EXPORT void SetLocalPoints( const QPoint& thePointA,
154 const QPoint& thePointB,
155 const QPoint& thePointC = QPoint( INT_MIN, INT_MIN ),
156 const bool theIsUpdate = true );
159 * Returns the transformation points in local cs of image
160 * \param thePointA point A
161 * \param thePointB point B
162 * \param thePointC point C
163 * \return true if all parameters has been set before
165 HYDRODATA_EXPORT bool GetLocalPoints( QPoint& thePointA,
167 QPoint& thePointC ) const;
170 * Returns true if local points has been set before
172 HYDRODATA_EXPORT bool HasLocalPoints() const;
176 * Stores the transformation points in global cs
177 * \param theMode transformation mode
178 * \param thePointA point A
179 * \param thePointB point B
180 * \param thePointC point C
182 HYDRODATA_EXPORT void SetGlobalPoints( const TransformationMode& theMode,
183 const QPointF& thePointA,
184 const QPointF& thePointB,
185 const QPointF& thePointC = QPoint( INT_MIN, INT_MIN ),
186 const bool theIsUpdate = true );
189 * Returns the transformation points in global cs
190 * \param theMode transformation mode
191 * \param thePointA point A
192 * \param thePointB point B
193 * \param thePointC point C
194 * \return true if all parameters has been set before
196 HYDRODATA_EXPORT bool GetGlobalPoints( TransformationMode& theMode,
199 QPointF& thePointC ) const;
202 * Get transformation points from the file and stores them in global cs
203 * \param theFileName the image georeferencement file name
204 * \return true in case of success
206 HYDRODATA_EXPORT bool SetGlobalPointsFromFile( const QString& theFileName );
209 * Returns true if global points has been set before
211 HYDRODATA_EXPORT bool HasGlobalPoints() const;
215 * Stores 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
221 HYDRODATA_EXPORT void SetReferencePoints( const Handle(HYDROData_Image)& theRefImage,
222 const QPointF& thePointA,
223 const QPointF& thePointB,
224 const QPointF& thePointC = QPoint( INT_MIN, INT_MIN ),
225 const bool theIsUpdate = true );
228 * Returns the transformation points in reference image local cs
229 * \param theRefImage reference image
230 * \param thePointA point A
231 * \param thePointB point B
232 * \param thePointC point C
233 * \return true if all parameters has been set correctly
235 HYDRODATA_EXPORT bool GetReferencePoints( Handle(HYDROData_Image)& theRefImage,
238 QPointF& thePointC ) const;
241 * Returns true if reference points has been set before
243 HYDRODATA_EXPORT bool HasReferencePoints() const;
247 * Stores the reference image for transformation
248 * \param theRefImage reference image
250 HYDRODATA_EXPORT void SetTrsfReferenceImage( const Handle(HYDROData_Image)& theRefImage );
253 * Returns the reference image for transformation
255 HYDRODATA_EXPORT Handle(HYDROData_Image) GetTrsfReferenceImage() const;
258 * Removes the reference image for transformation
260 HYDRODATA_EXPORT void RemoveTrsfReferenceImage();
264 * Stores the transformation mode
266 HYDRODATA_EXPORT void SetTrsfMode( const TransformationMode& theMode );
269 * Returns the transformation mode
271 HYDRODATA_EXPORT TransformationMode GetTrsfMode() const;
275 * Returns the number of referenced objects
276 * \return zero if there is no references
278 HYDRODATA_EXPORT int NbReferences() const;
281 * Appends reference to other object (image or polyline).
282 * \param theReferenced the object referenced by this
284 HYDRODATA_EXPORT void AppendReference( const Handle(HYDROData_Entity)& theReferenced );
287 * Returns reference by index.
288 * \param theIndex number of reference [0; NbReference)
289 * \returns the referenced object, or Null if index is invalid
291 HYDRODATA_EXPORT Handle(HYDROData_Entity) Reference(const int theIndex) const;
294 * Updates reference by index. If index is one-bigger than \a NbReferences,
295 * this method appends it to the end (NbReferences is incremented).
296 * \param theIndex number of reference [0; NbReference]
297 * \param theReferenced the object referenced by this
299 HYDRODATA_EXPORT void ChangeReference(
300 const int theIndex, Handle(HYDROData_Entity) theReferenced);
303 * Removes reference by index
304 * \param theIndex number of reference [0; NbReference)
306 HYDRODATA_EXPORT void RemoveReference(const int theIndex);
309 * Removes all references.
311 HYDRODATA_EXPORT void ClearReferences();
315 * Stores the operator name
316 * \param theOpName name of the operator that must be executed for image update
318 HYDRODATA_EXPORT void SetOperatorName(const QString theOpName);
321 * Returns the operator name
322 * \returns the name of the operator that must be executed for image update
324 HYDRODATA_EXPORT QString OperatorName() const;
327 * Stores the operator arguments
328 * \param theArgs array that stores the operator arguments, needed for execution
330 HYDRODATA_EXPORT void SetArgs(const QByteArray& theArgs);
333 * Returns the operator arguments
334 * \returns array that stores the operator arguments, needed for execution
336 HYDRODATA_EXPORT QByteArray Args() const;
340 * Marks the image as self-splitted.
341 * \param theFlag is true for self-splitted image
343 HYDRODATA_EXPORT void SetIsSelfSplitted(bool theFlag);
346 * Checks that the image is self-splitted.
347 * \returns true if image is self-splitted
349 HYDRODATA_EXPORT bool IsSelfSplitted() const;
353 QPointF generateThirdPoint( const QPointF& thePointA,
354 const QPointF& thePointB,
355 const bool& theIsLocal ) const;
359 friend class HYDROData_Iterator;
362 * Creates new object in the internal data structure. Use higher level objects
363 * to create objects with real content.
365 HYDRODATA_EXPORT HYDROData_Image();
368 * Destructs properties of the object and object itself, removes it from the document.
370 HYDRODATA_EXPORT ~HYDROData_Image();