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>
25 #pragma warning ( disable: 4251 )
32 #pragma warning ( default: 4251 )
35 DEFINE_STANDARD_HANDLE(HYDROData_Image, HYDROData_Entity)
37 /**\class HYDROData_Image
38 * \brief Class that stores/retreives information about the image.
40 * Keeps image as binary array, transformation and other properties
41 * of image with correspondent API for forkind wit hthese properties.
43 class HYDROData_Image : public HYDROData_Entity
48 enum TransformationMode
58 * Enumeration of tags corresponding to the persistent object parameters.
62 DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
63 DataTag_Operator, ///< name of the operator that must be executed for image update
64 DataTag_TrsfMode, ///< transformation mode (0 - Lambert93, 1 - Cartesian, 2 - on other Image)
65 DataTag_TrsfPoints, ///< image transformation points
66 DataTag_TrsfImage, ///< reference transformation image
67 DataTag_FilePath ///< image imported file path
71 DEFINE_STANDARD_RTTI(HYDROData_Image);
74 * Returns the kind of this object. Must be redefined in all objects of known type.
76 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_IMAGE;}
79 * Dump Image object to Python script representation.
81 HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
82 MapOfTreatedObjects& theTreatedObjects ) const;
85 * Updates object state.
86 * Reimplemented to update an Image object in the data structure.
87 * Call this method whenever you made changes for operator or reference objects.
88 * If it is changed, sets "MustBeUpdated" flag to other depended images.
90 HYDRODATA_EXPORT virtual void Update();
93 * Checks that object has 2D presentation. Reimlemented to retun true.
95 HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
98 * Returns data of object wrapped to QVariant.
99 * Reimplemented to wrap and return saved image.
100 * Transformation are applied to result image.
102 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
105 * Returns the list of all reference objects of this object.
107 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
112 * \param theImage new image
114 HYDRODATA_EXPORT void SetImage(const QImage& theImage);
117 * Load the image from file
118 * \param theFilePath path to image
120 HYDRODATA_EXPORT bool LoadImage(const QString& theFilePath);
123 * Returns the kept image
125 HYDRODATA_EXPORT QImage Image();
128 * Stores the image file path
129 * \param theFilePath image file path
131 HYDRODATA_EXPORT void SetFilePath(const QString& theFilePath);
134 * Returns uploaded image file path
136 HYDRODATA_EXPORT QString GetFilePath() const;
139 * Stores the image transformation
140 * \param theTrsf new transformation
142 HYDRODATA_EXPORT void SetTrsf(const QTransform& theTrsf);
145 * Returns the kept transformation, or "identity" if not yet stored
147 HYDRODATA_EXPORT QTransform Trsf() const;
150 * Updates the matrix of transformation in accordance with reference points.
151 * \param theTrsf new transformation
153 HYDRODATA_EXPORT void UpdateTrsf();
157 * Returns true if transformation is done by two points only
159 HYDRODATA_EXPORT bool IsByTwoPoints() const;
163 * Removes all references from this image.
165 HYDRODATA_EXPORT bool HasReferences() const;
168 * Removes all references from this image.
170 HYDRODATA_EXPORT void RemoveAllReferences();
174 * Stores the transformation points in local cs of image
175 * \param thePointA point A
176 * \param thePointB point B
177 * \param thePointC point C
179 HYDRODATA_EXPORT void SetLocalPoints( const QPoint& thePointA,
180 const QPoint& thePointB,
181 const QPoint& thePointC = QPoint( INT_MIN, INT_MIN ),
182 const bool theIsUpdate = true );
185 * Returns the transformation points in local cs of image
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 GetLocalPoints( QPoint& thePointA,
193 QPoint& thePointC ) const;
196 * Returns true if local points has been set before
198 HYDRODATA_EXPORT bool HasLocalPoints() const;
202 * Stores the transformation points in global cs
203 * \param theMode transformation mode
204 * \param thePointA point A
205 * \param thePointB point B
206 * \param thePointC point C
208 HYDRODATA_EXPORT void SetGlobalPoints( const TransformationMode& theMode,
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 global cs
216 * \param theMode transformation mode
217 * \param thePointA point A
218 * \param thePointB point B
219 * \param thePointC point C
220 * \return true if all parameters has been set before
222 HYDRODATA_EXPORT bool GetGlobalPoints( TransformationMode& theMode,
225 QPointF& thePointC ) const;
228 * Get transformation points from the file and stores them in global cs
229 * \param theFileName the image georeferencement file name
230 * \return true in case of success
232 HYDRODATA_EXPORT bool SetGlobalPointsFromFile( const QString& theFileName );
235 * Returns true if global points has been set before
237 HYDRODATA_EXPORT bool HasGlobalPoints() const;
241 * Stores the transformation points in reference image local cs
242 * \param theRefImage reference image
243 * \param thePointA point A
244 * \param thePointB point B
245 * \param thePointC point C
247 HYDRODATA_EXPORT void SetReferencePoints( const Handle(HYDROData_Image)& theRefImage,
248 const QPointF& thePointA,
249 const QPointF& thePointB,
250 const QPointF& thePointC = QPoint( INT_MIN, INT_MIN ),
251 const bool theIsUpdate = true );
254 * Returns the transformation points in reference image local cs
255 * \param theRefImage reference image
256 * \param thePointA point A
257 * \param thePointB point B
258 * \param thePointC point C
259 * \return true if all parameters has been set correctly
261 HYDRODATA_EXPORT bool GetReferencePoints( Handle(HYDROData_Image)& theRefImage,
264 QPointF& thePointC ) const;
267 * Returns true if reference points has been set before
269 HYDRODATA_EXPORT bool HasReferencePoints() const;
273 * Stores the reference image for transformation
274 * \param theRefImage reference image
276 HYDRODATA_EXPORT void SetTrsfReferenceImage( const Handle(HYDROData_Image)& theRefImage );
279 * Returns the reference image for transformation
281 HYDRODATA_EXPORT Handle(HYDROData_Image) GetTrsfReferenceImage() const;
284 * Removes the reference image for transformation
286 HYDRODATA_EXPORT void RemoveTrsfReferenceImage();
290 * Stores the transformation mode
292 HYDRODATA_EXPORT void SetTrsfMode( const TransformationMode& theMode );
295 * Returns the transformation mode
297 HYDRODATA_EXPORT TransformationMode GetTrsfMode() const;
301 * Returns the number of referenced objects
302 * \return zero if there is no references
304 HYDRODATA_EXPORT int NbReferences() const;
307 * Appends reference to other object (image or polyline).
308 * \param theReferenced the object referenced by this
310 HYDRODATA_EXPORT void AppendReference( const Handle(HYDROData_Entity)& theReferenced );
313 * Returns reference by index.
314 * \param theIndex number of reference [0; NbReference)
315 * \returns the referenced object, or Null if index is invalid
317 HYDRODATA_EXPORT Handle(HYDROData_Entity) Reference(const int theIndex) const;
320 * Updates reference by index. If index is one-bigger than \a NbReferences,
321 * this method appends it to the end (NbReferences is incremented).
322 * \param theIndex number of reference [0; NbReference]
323 * \param theReferenced the object referenced by this
325 HYDRODATA_EXPORT void ChangeReference(
326 const int theIndex, Handle(HYDROData_Entity) theReferenced);
329 * Removes reference by index
330 * \param theIndex number of reference [0; NbReference)
332 HYDRODATA_EXPORT void RemoveReference(const int theIndex);
335 * Removes all references.
337 HYDRODATA_EXPORT void ClearReferences();
341 * Stores the operator name
342 * \param theOpName name of the operator that must be executed for image update
344 HYDRODATA_EXPORT void SetOperatorName(const QString theOpName);
347 * Returns the operator name
348 * \returns the name of the operator that must be executed for image update
350 HYDRODATA_EXPORT QString OperatorName() const;
353 * Stores the operator arguments
354 * \param theArgs array that stores the operator arguments, needed for execution
356 HYDRODATA_EXPORT void SetArgs(const QByteArray& theArgs);
359 * Returns the operator arguments
360 * \returns array that stores the operator arguments, needed for execution
362 HYDRODATA_EXPORT QByteArray Args() const;
366 * Marks the image as self-splitted.
367 * \param theFlag is true for self-splitted image
369 HYDRODATA_EXPORT void SetIsSelfSplitted(bool theFlag);
372 * Checks that the image is self-splitted.
373 * \returns true if image is self-splitted
375 HYDRODATA_EXPORT bool IsSelfSplitted() const;
379 QPointF generateThirdPoint( const QPointF& thePointA,
380 const QPointF& thePointB,
381 const bool& theIsLocal ) const;
385 friend class HYDROData_Iterator;
388 * Creates new object in the internal data structure. Use higher level objects
389 * to create objects with real content.
391 HYDRODATA_EXPORT HYDROData_Image();
394 * Destructs properties of the object and object itself, removes it from the document.
396 HYDRODATA_EXPORT ~HYDROData_Image();