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.
62 * \param theIsForce force reupdating of data object
64 HYDRODATA_EXPORT virtual void Update( const bool theIsForce = true );
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();
75 * \param theImage new image
77 HYDRODATA_EXPORT void SetImage(const QImage& theImage);
80 * Load the image from file
81 * \param theFilePath path to image
83 HYDRODATA_EXPORT bool LoadImage(const QString& theFilePath);
86 * Returns the kept image
88 HYDRODATA_EXPORT QImage Image();
91 * Stores the image file path
92 * \param theFilePath image file path
94 HYDRODATA_EXPORT void SetFilePath(const QString& theFilePath);
97 * Returns uploaded image file path
99 HYDRODATA_EXPORT QString GetFilePath() const;
102 * Stores the image transformation
103 * \param theTrsf new transformation
105 HYDRODATA_EXPORT void SetTrsf(const QTransform& theTrsf);
108 * Returns the kept transformation, or "identity" if not yet stored
110 HYDRODATA_EXPORT QTransform Trsf() const;
113 * Updates the matrix of transformation in accordance with reference points.
114 * \param theTrsf new transformation
116 HYDRODATA_EXPORT void UpdateTrsf();
120 * Returns true if transformation is done by two points only
122 HYDRODATA_EXPORT bool IsByTwoPoints() const;
126 * Stores the transformation points in local cs of image
127 * \param thePointA point A
128 * \param thePointB point B
129 * \param thePointC point C
131 HYDRODATA_EXPORT void SetLocalPoints( const QPoint& thePointA,
132 const QPoint& thePointB,
133 const QPoint& thePointC = QPoint( INT_MIN, INT_MIN ) );
136 * Returns the transformation points in local cs of image
137 * \param thePointA point A
138 * \param thePointB point B
139 * \param thePointC point C
140 * \return true if all parameters has been set before
142 HYDRODATA_EXPORT bool GetLocalPoints( QPoint& thePointA,
144 QPoint& thePointC ) const;
147 * Returns true if local points has been set before
149 HYDRODATA_EXPORT bool HasLocalPoints() const;
153 * Stores the transformation points in global cs
154 * \param theMode transformation mode
155 * \param thePointA point A
156 * \param thePointB point B
157 * \param thePointC point C
159 HYDRODATA_EXPORT void SetGlobalPoints( const TransformationMode& theMode,
160 const QPointF& thePointA,
161 const QPointF& thePointB,
162 const QPointF& thePointC = QPoint( INT_MIN, INT_MIN ) );
165 * Returns the transformation points in global cs
166 * \param theMode transformation mode
167 * \param thePointA point A
168 * \param thePointB point B
169 * \param thePointC point C
170 * \return true if all parameters has been set before
172 HYDRODATA_EXPORT bool GetGlobalPoints( TransformationMode& theMode,
175 QPointF& thePointC ) const;
178 * Returns true if global points has been set before
180 HYDRODATA_EXPORT bool HasGlobalPoints() const;
184 * Stores the transformation points in reference image local cs
185 * \param theRefImage reference image
186 * \param thePointA point A
187 * \param thePointB point B
188 * \param thePointC point C
190 HYDRODATA_EXPORT void SetReferencePoints( const Handle(HYDROData_Image)& theRefImage,
191 const QPointF& thePointA,
192 const QPointF& thePointB,
193 const QPointF& thePointC = QPoint( INT_MIN, INT_MIN ) );
196 * Returns 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
201 * \return true if all parameters has been set correctly
203 HYDRODATA_EXPORT bool GetReferencePoints( Handle(HYDROData_Image)& theRefImage,
206 QPointF& thePointC ) const;
209 * Returns true if reference points has been set before
211 HYDRODATA_EXPORT bool HasReferencePoints() const;
215 * Stores the reference image for transformation
216 * \param theRefImage reference image
218 HYDRODATA_EXPORT void SetTrsfReferenceImage( const Handle(HYDROData_Image)& theRefImage );
221 * Returns the reference image for transformation
223 HYDRODATA_EXPORT Handle(HYDROData_Image) GetTrsfReferenceImage() const;
227 * Stores the transformation mode
229 HYDRODATA_EXPORT void SetTrsfMode( const TransformationMode& theMode );
232 * Returns the transformation mode
234 HYDRODATA_EXPORT TransformationMode GetTrsfMode() const;
238 * Returns the number of referenced objects
239 * \return zero if there is no references
241 HYDRODATA_EXPORT int NbReferences() const;
244 * Appends reference to other object (image or polyline).
245 * \param theReferenced the object referenced by this
247 HYDRODATA_EXPORT void AppendReference( const Handle(HYDROData_Entity)& theReferenced );
250 * Returns reference by index.
251 * \param theIndex number of reference [0; NbReference)
252 * \returns the referenced object, or Null if index is invalid
254 HYDRODATA_EXPORT Handle(HYDROData_Entity) Reference(const int theIndex) const;
257 * Updates reference by index. If index is one-bigger than \a NbReferences,
258 * this method appends it to the end (NbReferences is incremented).
259 * \param theIndex number of reference [0; NbReference]
260 * \param theReferenced the object referenced by this
262 HYDRODATA_EXPORT void ChangeReference(
263 const int theIndex, Handle(HYDROData_Entity) theReferenced);
266 * Removes reference by index
267 * \param theIndex number of reference [0; NbReference)
269 HYDRODATA_EXPORT void RemoveReference(const int theIndex);
272 * Removes all references.
274 HYDRODATA_EXPORT void ClearReferences();
277 * Stores the operator name
278 * \param theOpName name of the operator that must be executed for image update
280 HYDRODATA_EXPORT void SetOperatorName(const QString theOpName);
283 * Returns the operator name
284 * \returns the name of the operator that must be executed for image update
286 HYDRODATA_EXPORT QString OperatorName() const;
289 * Stores the operator arguments
290 * \param theArgs array that stores the operator arguments, needed for execution
292 HYDRODATA_EXPORT void SetArgs(const QByteArray& theArgs);
295 * Returns the operator arguments
296 * \returns array that stores the operator arguments, needed for execution
298 HYDRODATA_EXPORT QByteArray Args() const;
301 * Sets the "MustBeUpdated" flag: if image is depended on updated features.
302 * \param theFlag is true for images that must be updated, false for up-to-date
304 HYDRODATA_EXPORT void MustBeUpdated(bool theFlag);
307 * Returns the "MustBeUpdated" flag: is image must be recomputed or not
308 * \returns false if image is up to date
310 HYDRODATA_EXPORT bool MustBeUpdated() const;
313 * Marks the image as self-splitted.
314 * \param theFlag is true for self-splitted image
316 HYDRODATA_EXPORT void SetIsSelfSplitted(bool theFlag);
319 * Checks that the image is self-splitted.
320 * \returns true if image is self-splitted
322 HYDRODATA_EXPORT bool IsSelfSplitted() const;
326 QPointF generateThirdPoint( const QPointF& thePointA,
327 const QPointF& thePointB,
328 const bool& theIsLocal ) const;
332 friend class HYDROData_Iterator;
335 * Creates new object in the internal data structure. Use higher level objects
336 * to create objects with real content.
341 * Destructs properties of the object and object itself, removes it from the document.