1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #ifndef HYDROData_Image_HeaderFile
20 #define HYDROData_Image_HeaderFile
22 #include <HYDROData_Entity.h>
27 DEFINE_STANDARD_HANDLE(HYDROData_Image, HYDROData_Entity)
29 /**\class HYDROData_Image
30 * \brief Class that stores/retreives information about the image.
32 * Keeps image as binary array, transformation and other properties
33 * of image with correspondent API for forkind wit hthese properties.
35 class HYDROData_Image : public HYDROData_Entity
40 enum TransformationMode
50 * Enumeration of tags corresponding to the persistent object parameters.
54 DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
55 DataTag_Operator, ///< name of the operator that must be executed for image update
56 DataTag_TrsfMode, ///< transformation mode (0 - Lambert93, 1 - Cartesian, 2 - on other Image)
57 DataTag_TrsfPoints, ///< image transformation points
58 DataTag_TrsfImage, ///< reference transformation image
59 DataTag_FilePath ///< image imported file path
63 DEFINE_STANDARD_RTTI(HYDROData_Image);
66 * Returns the kind of this object. Must be redefined in all objects of known type.
68 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_IMAGE;}
71 * Dump Image object to Python script representation.
73 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
76 * Updates object state.
77 * Reimplemented to update an Image object in the data structure.
78 * Call this method whenever you made changes for operator or reference objects.
79 * If it is changed, sets "MustBeUpdated" flag to other depended images.
81 HYDRODATA_EXPORT virtual void Update();
84 * Checks that object has 2D presentation. Reimlemented to retun true.
86 HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
89 * Returns data of object wrapped to QVariant.
90 * Reimplemented to wrap and return saved image.
91 * Transformation are applied to result image.
93 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
96 * Returns the list of all reference objects of this object.
98 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
103 * \param theImage new image
105 HYDRODATA_EXPORT void SetImage(const QImage& theImage);
108 * Load the image from file
109 * \param theFilePath path to image
111 HYDRODATA_EXPORT bool LoadImage(const QString& theFilePath);
114 * Returns the kept image
116 HYDRODATA_EXPORT QImage Image();
119 * Stores the image file path
120 * \param theFilePath image file path
122 HYDRODATA_EXPORT void SetFilePath(const QString& theFilePath);
125 * Returns uploaded image file path
127 HYDRODATA_EXPORT QString GetFilePath() const;
130 * Stores the image transformation
131 * \param theTrsf new transformation
133 HYDRODATA_EXPORT void SetTrsf(const QTransform& theTrsf);
136 * Returns the kept transformation, or "identity" if not yet stored
138 HYDRODATA_EXPORT QTransform Trsf() const;
141 * Updates the matrix of transformation in accordance with reference points.
142 * \param theTrsf new transformation
144 HYDRODATA_EXPORT void UpdateTrsf();
148 * Returns true if transformation is done by two points only
150 HYDRODATA_EXPORT bool IsByTwoPoints() const;
154 * Removes all references from this image.
156 HYDRODATA_EXPORT bool HasReferences() const;
159 * Removes all references from this image.
161 HYDRODATA_EXPORT void RemoveAllReferences();
165 * Stores the transformation points in local cs of image
166 * \param thePointA point A
167 * \param thePointB point B
168 * \param thePointC point C
170 HYDRODATA_EXPORT void SetLocalPoints( const QPoint& thePointA,
171 const QPoint& thePointB,
172 const QPoint& thePointC = QPoint( INT_MIN, INT_MIN ),
173 const bool theIsUpdate = true );
176 * Returns the transformation points in local cs of image
177 * \param thePointA point A
178 * \param thePointB point B
179 * \param thePointC point C
180 * \return true if all parameters has been set before
182 HYDRODATA_EXPORT bool GetLocalPoints( QPoint& thePointA,
184 QPoint& thePointC ) const;
187 * Returns true if local points has been set before
189 HYDRODATA_EXPORT bool HasLocalPoints() const;
193 * Stores the transformation points in global cs
194 * \param theMode transformation mode
195 * \param thePointA point A
196 * \param thePointB point B
197 * \param thePointC point C
199 HYDRODATA_EXPORT void SetGlobalPoints( const TransformationMode& theMode,
200 const QPointF& thePointA,
201 const QPointF& thePointB,
202 const QPointF& thePointC = QPoint( INT_MIN, INT_MIN ),
203 const bool theIsUpdate = true );
206 * Returns the transformation points in global cs
207 * \param theMode transformation mode
208 * \param thePointA point A
209 * \param thePointB point B
210 * \param thePointC point C
211 * \return true if all parameters has been set before
213 HYDRODATA_EXPORT bool GetGlobalPoints( TransformationMode& theMode,
216 QPointF& thePointC ) const;
219 * Get transformation points from the file and stores them in global cs
220 * \param theFileName the image georeferencement file name
221 * \return true in case of success
223 HYDRODATA_EXPORT bool SetGlobalPointsFromFile( const QString& theFileName );
226 * Returns true if global points has been set before
228 HYDRODATA_EXPORT bool HasGlobalPoints() const;
232 * Stores the transformation points in reference image local cs
233 * \param theRefImage reference image
234 * \param thePointA point A
235 * \param thePointB point B
236 * \param thePointC point C
238 HYDRODATA_EXPORT void SetReferencePoints( const Handle(HYDROData_Image)& theRefImage,
239 const QPointF& thePointA,
240 const QPointF& thePointB,
241 const QPointF& thePointC = QPoint( INT_MIN, INT_MIN ),
242 const bool theIsUpdate = true );
245 * Returns the transformation points in reference image local cs
246 * \param theRefImage reference image
247 * \param thePointA point A
248 * \param thePointB point B
249 * \param thePointC point C
250 * \return true if all parameters has been set correctly
252 HYDRODATA_EXPORT bool GetReferencePoints( Handle(HYDROData_Image)& theRefImage,
255 QPointF& thePointC ) const;
258 * Returns true if reference points has been set before
260 HYDRODATA_EXPORT bool HasReferencePoints() const;
264 * Stores the reference image for transformation
265 * \param theRefImage reference image
267 HYDRODATA_EXPORT void SetTrsfReferenceImage( const Handle(HYDROData_Image)& theRefImage );
270 * Returns the reference image for transformation
272 HYDRODATA_EXPORT Handle(HYDROData_Image) GetTrsfReferenceImage() const;
275 * Removes the reference image for transformation
277 HYDRODATA_EXPORT void RemoveTrsfReferenceImage();
281 * Stores the transformation mode
283 HYDRODATA_EXPORT void SetTrsfMode( const TransformationMode& theMode );
286 * Returns the transformation mode
288 HYDRODATA_EXPORT TransformationMode GetTrsfMode() const;
292 * Returns the number of referenced objects
293 * \return zero if there is no references
295 HYDRODATA_EXPORT int NbReferences() const;
298 * Appends reference to other object (image or polyline).
299 * \param theReferenced the object referenced by this
301 HYDRODATA_EXPORT void AppendReference( const Handle(HYDROData_Entity)& theReferenced );
304 * Returns reference by index.
305 * \param theIndex number of reference [0; NbReference)
306 * \returns the referenced object, or Null if index is invalid
308 HYDRODATA_EXPORT Handle(HYDROData_Entity) Reference(const int theIndex) const;
311 * Updates reference by index. If index is one-bigger than \a NbReferences,
312 * this method appends it to the end (NbReferences is incremented).
313 * \param theIndex number of reference [0; NbReference]
314 * \param theReferenced the object referenced by this
316 HYDRODATA_EXPORT void ChangeReference(
317 const int theIndex, Handle(HYDROData_Entity) theReferenced);
320 * Removes reference by index
321 * \param theIndex number of reference [0; NbReference)
323 HYDRODATA_EXPORT void RemoveReference(const int theIndex);
326 * Removes all references.
328 HYDRODATA_EXPORT void ClearReferences();
332 * Stores the operator name
333 * \param theOpName name of the operator that must be executed for image update
335 HYDRODATA_EXPORT void SetOperatorName(const QString theOpName);
338 * Returns the operator name
339 * \returns the name of the operator that must be executed for image update
341 HYDRODATA_EXPORT QString OperatorName() const;
344 * Stores the operator arguments
345 * \param theArgs array that stores the operator arguments, needed for execution
347 HYDRODATA_EXPORT void SetArgs(const QByteArray& theArgs);
350 * Returns the operator arguments
351 * \returns array that stores the operator arguments, needed for execution
353 HYDRODATA_EXPORT QByteArray Args() const;
357 * Marks the image as self-splitted.
358 * \param theFlag is true for self-splitted image
360 HYDRODATA_EXPORT void SetIsSelfSplitted(bool theFlag);
363 * Checks that the image is self-splitted.
364 * \returns true if image is self-splitted
366 HYDRODATA_EXPORT bool IsSelfSplitted() const;
370 QPointF generateThirdPoint( const QPointF& thePointA,
371 const QPointF& thePointB,
372 const bool& theIsLocal ) const;
376 friend class HYDROData_Iterator;
379 * Creates new object in the internal data structure. Use higher level objects
380 * to create objects with real content.
382 HYDRODATA_EXPORT HYDROData_Image();
385 * Destructs properties of the object and object itself, removes it from the document.
387 HYDRODATA_EXPORT ~HYDROData_Image();