1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef HYDROData_Image_HeaderFile
24 #define HYDROData_Image_HeaderFile
26 #include <HYDROData_Entity.h>
31 DEFINE_STANDARD_HANDLE(HYDROData_Image, HYDROData_Entity)
33 /**\class HYDROData_Image
34 * \brief Class that stores/retreives information about the image.
36 * Keeps image as binary array, transformation and other properties
37 * of image with correspondent API for forkind wit hthese properties.
39 class HYDROData_Image : public HYDROData_Entity
44 enum TransformationMode
54 * Enumeration of tags corresponding to the persistent object parameters.
58 DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
59 DataTag_Operator, ///< name of the operator that must be executed for image update
60 DataTag_TrsfMode, ///< transformation mode (0 - Lambert93, 1 - Cartesian, 2 - on other Image)
61 DataTag_TrsfPoints, ///< image transformation points
62 DataTag_TrsfImage, ///< reference transformation image
63 DataTag_FilePath ///< image imported file path
67 DEFINE_STANDARD_RTTI(HYDROData_Image);
70 * Returns the kind of this object. Must be redefined in all objects of known type.
72 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_IMAGE;}
75 * Dump Image object to Python script representation.
77 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
80 * Updates object state.
81 * Reimplemented to update an Image object in the data structure.
82 * Call this method whenever you made changes for operator or reference objects.
83 * If it is changed, sets "MustBeUpdated" flag to other depended images.
85 HYDRODATA_EXPORT virtual void Update();
88 * Checks that object has 2D presentation. Reimlemented to retun true.
90 HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
93 * Returns data of object wrapped to QVariant.
94 * Reimplemented to wrap and return saved image.
95 * Transformation are applied to result image.
97 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
100 * Returns the list of all reference objects of this object.
102 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
107 * \param theImage new image
109 HYDRODATA_EXPORT void SetImage(const QImage& theImage);
112 * Load the image from file
113 * \param theFilePath path to image
115 HYDRODATA_EXPORT bool LoadImage(const QString& theFilePath);
118 * Returns the kept image
120 HYDRODATA_EXPORT QImage Image();
123 * Stores the image file path
124 * \param theFilePath image file path
126 HYDRODATA_EXPORT void SetFilePath(const QString& theFilePath);
129 * Returns uploaded image file path
131 HYDRODATA_EXPORT QString GetFilePath() const;
134 * Stores the image transformation
135 * \param theTrsf new transformation
137 HYDRODATA_EXPORT void SetTrsf(const QTransform& theTrsf);
140 * Returns the kept transformation, or "identity" if not yet stored
142 HYDRODATA_EXPORT QTransform Trsf() const;
145 * Updates the matrix of transformation in accordance with reference points.
146 * \param theTrsf new transformation
148 HYDRODATA_EXPORT void UpdateTrsf();
152 * Returns true if transformation is done by two points only
154 HYDRODATA_EXPORT bool IsByTwoPoints() const;
158 * Removes all references from this image.
160 HYDRODATA_EXPORT bool HasReferences() const;
163 * Removes all references from this image.
165 HYDRODATA_EXPORT void RemoveAllReferences();
169 * Stores the transformation points in local cs of image
170 * \param thePointA point A
171 * \param thePointB point B
172 * \param thePointC point C
174 HYDRODATA_EXPORT void SetLocalPoints( const QPoint& thePointA,
175 const QPoint& thePointB,
176 const QPoint& thePointC = QPoint( INT_MIN, INT_MIN ),
177 const bool theIsUpdate = true );
180 * Returns the transformation points in local cs of image
181 * \param thePointA point A
182 * \param thePointB point B
183 * \param thePointC point C
184 * \return true if all parameters has been set before
186 HYDRODATA_EXPORT bool GetLocalPoints( QPoint& thePointA,
188 QPoint& thePointC ) const;
191 * Returns true if local points has been set before
193 HYDRODATA_EXPORT bool HasLocalPoints() const;
197 * Stores the transformation points in global cs
198 * \param theMode transformation mode
199 * \param thePointA point A
200 * \param thePointB point B
201 * \param thePointC point C
203 HYDRODATA_EXPORT void SetGlobalPoints( const TransformationMode& theMode,
204 const QPointF& thePointA,
205 const QPointF& thePointB,
206 const QPointF& thePointC = QPoint( INT_MIN, INT_MIN ),
207 const bool theIsUpdate = true );
210 * Returns the transformation points in global cs
211 * \param theMode transformation mode
212 * \param thePointA point A
213 * \param thePointB point B
214 * \param thePointC point C
215 * \return true if all parameters has been set before
217 HYDRODATA_EXPORT bool GetGlobalPoints( TransformationMode& theMode,
220 QPointF& thePointC ) const;
223 * Get transformation points from the file and stores them in global cs
224 * \param theFileName the image georeferencement file name
225 * \return true in case of success
227 HYDRODATA_EXPORT bool SetGlobalPointsFromFile( const QString& theFileName );
230 * Returns true if global points has been set before
232 HYDRODATA_EXPORT bool HasGlobalPoints() const;
236 * Stores the transformation points in reference image local cs
237 * \param theRefImage reference image
238 * \param thePointA point A
239 * \param thePointB point B
240 * \param thePointC point C
242 HYDRODATA_EXPORT void SetReferencePoints( const Handle(HYDROData_Image)& theRefImage,
243 const QPointF& thePointA,
244 const QPointF& thePointB,
245 const QPointF& thePointC = QPoint( INT_MIN, INT_MIN ),
246 const bool theIsUpdate = true );
249 * Returns the transformation points in reference image local cs
250 * \param theRefImage reference image
251 * \param thePointA point A
252 * \param thePointB point B
253 * \param thePointC point C
254 * \return true if all parameters has been set correctly
256 HYDRODATA_EXPORT bool GetReferencePoints( Handle(HYDROData_Image)& theRefImage,
259 QPointF& thePointC ) const;
262 * Returns true if reference points has been set before
264 HYDRODATA_EXPORT bool HasReferencePoints() const;
268 * Stores the reference image for transformation
269 * \param theRefImage reference image
271 HYDRODATA_EXPORT void SetTrsfReferenceImage( const Handle(HYDROData_Image)& theRefImage );
274 * Returns the reference image for transformation
276 HYDRODATA_EXPORT Handle(HYDROData_Image) GetTrsfReferenceImage() const;
279 * Removes the reference image for transformation
281 HYDRODATA_EXPORT void RemoveTrsfReferenceImage();
285 * Stores the transformation mode
287 HYDRODATA_EXPORT void SetTrsfMode( const TransformationMode& theMode );
290 * Returns the transformation mode
292 HYDRODATA_EXPORT TransformationMode GetTrsfMode() const;
296 * Returns the number of referenced objects
297 * \return zero if there is no references
299 HYDRODATA_EXPORT int NbReferences() const;
302 * Appends reference to other object (image or polyline).
303 * \param theReferenced the object referenced by this
305 HYDRODATA_EXPORT void AppendReference( const Handle(HYDROData_Entity)& theReferenced );
308 * Returns reference by index.
309 * \param theIndex number of reference [0; NbReference)
310 * \returns the referenced object, or Null if index is invalid
312 HYDRODATA_EXPORT Handle(HYDROData_Entity) Reference(const int theIndex) const;
315 * Updates reference by index. If index is one-bigger than \a NbReferences,
316 * this method appends it to the end (NbReferences is incremented).
317 * \param theIndex number of reference [0; NbReference]
318 * \param theReferenced the object referenced by this
320 HYDRODATA_EXPORT void ChangeReference(
321 const int theIndex, Handle(HYDROData_Entity) theReferenced);
324 * Removes reference by index
325 * \param theIndex number of reference [0; NbReference)
327 HYDRODATA_EXPORT void RemoveReference(const int theIndex);
330 * Removes all references.
332 HYDRODATA_EXPORT void ClearReferences();
336 * Stores the operator name
337 * \param theOpName name of the operator that must be executed for image update
339 HYDRODATA_EXPORT void SetOperatorName(const QString theOpName);
342 * Returns the operator name
343 * \returns the name of the operator that must be executed for image update
345 HYDRODATA_EXPORT QString OperatorName() const;
348 * Stores the operator arguments
349 * \param theArgs array that stores the operator arguments, needed for execution
351 HYDRODATA_EXPORT void SetArgs(const QByteArray& theArgs);
354 * Returns the operator arguments
355 * \returns array that stores the operator arguments, needed for execution
357 HYDRODATA_EXPORT QByteArray Args() const;
361 * Marks the image as self-splitted.
362 * \param theFlag is true for self-splitted image
364 HYDRODATA_EXPORT void SetIsSelfSplitted(bool theFlag);
367 * Checks that the image is self-splitted.
368 * \returns true if image is self-splitted
370 HYDRODATA_EXPORT bool IsSelfSplitted() const;
374 QPointF generateThirdPoint( const QPointF& thePointA,
375 const QPointF& thePointB,
376 const bool& theIsLocal ) const;
380 friend class HYDROData_Iterator;
383 * Creates new object in the internal data structure. Use higher level objects
384 * to create objects with real content.
386 HYDRODATA_EXPORT HYDROData_Image();
389 * Destructs properties of the object and object itself, removes it from the document.
391 HYDRODATA_EXPORT ~HYDROData_Image();