Salome HOME
Compilation errors.
[modules/hydro.git] / src / HYDROData / HYDROData_Image.h
1 #ifndef HYDROData_Image_HeaderFile
2 #define HYDROData_Image_HeaderFile
3
4 #include <HYDROData_Object.h>
5
6 #include <QImage>
7 #include <QTransform>
8
9 DEFINE_STANDARD_HANDLE(HYDROData_Image, HYDROData_Object)
10
11 /**\class HYDROData_Image
12  * \brief Class that stores/retreives information about the image.
13  *
14  * Keeps image as binary array, transformation and other properties
15  * of image with correspondent API for forkind wit hthese properties.
16  */
17 class HYDROData_Image : public HYDROData_Object
18 {
19 protected:
20   /**
21    * Enumeration of tags corresponding to the persistent object parameters.
22    */
23   enum DataTag
24   {
25     DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
26     DataTag_Operator,    ///< name of the operator that must be executed for image update
27     DataTag_TrsfMode,    ///< transformation mode (0 - Lambert93, 1 - Cartesian)
28     DataTag_TrsfPoints,  ///< image transformation points (3 input + 3 output lambert + 3 output cartesian)
29     DataTag_FilePath     ///< image imported file path
30   };
31
32 public:
33   DEFINE_STANDARD_RTTI(HYDROData_Image);
34
35   /**
36    * Returns the kind of this object. Must be redefined in all objects of known type.
37    */
38   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_IMAGE;}
39
40   /**
41    * Dump Image object to Python script representation.
42    */
43   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
44
45   /**
46    * Updates object state.
47    * Reimplemented to update an Image object in the data structure.
48    * Call this method whenever you made changes for operator or reference objects.
49    * If it is changed, sets "MustBeUpdated" flag to other depended images.
50    * \param theIsForce force reupdating of data object
51    */
52   HYDRODATA_EXPORT virtual void Update( const bool theIsForce = true );
53
54   /**
55    * Returns data of object wrapped to QVariant.
56    * Reimplemented to wrap and return saved image.
57    * Transformation are applied to result image.
58    */
59   HYDRODATA_EXPORT virtual QVariant GetDataVariant();
60
61   /**
62    * Stores the image
63    * \param theImage new image
64    */
65   HYDRODATA_EXPORT void SetImage(const QImage& theImage);
66
67   /**
68    * Load the image from file
69    * \param theFilePath path to image
70    */
71   HYDRODATA_EXPORT bool LoadImage(const QString& theFilePath);
72
73   /**
74    * Returns the kept image
75    */
76   HYDRODATA_EXPORT QImage Image();
77
78   /**
79    * Stores the image file path
80    * \param theFilePath image file path
81    */
82   HYDRODATA_EXPORT void SetFilePath(const QString& theFilePath);
83
84   /**
85    * Returns uploaded image file path
86    */
87   HYDRODATA_EXPORT QString GetFilePath() const;
88
89   /**
90    * Stores the image transformation
91    * \param theTrsf new transformation
92    */
93   HYDRODATA_EXPORT void SetTrsf(const QTransform& theTrsf);
94
95   /**
96    * Returns the kept transformation, or "identity" if not yet stored
97    */
98   HYDRODATA_EXPORT QTransform Trsf() const;
99
100   /**
101    * Stores the image transformation points (3 input + 3 output)
102    * \param thePointA input point A
103    * \param thePointB input point B
104    * \param thePointC input point C
105    * \param theLambertPointA output point A in Lambert93 coordinates
106    * \param theLambertPointB output point B in Lambert93 coordinates
107    * \param theLambertPointC output point C in Lambert93 coordinates
108    * \param theCartesianPointA output point A in Cartesian coordinates
109    * \param theCartesianPointB output point B in Cartesian coordinates
110    * \param theCartesianPointC output point C in Cartesian coordinates
111    */
112   HYDRODATA_EXPORT void SetTrsfPoints(const QPoint& thePointA,
113                                       const QPoint& thePointB,
114                                       const QPoint& thePointC,
115                                       const QPointF& theLambertPointA,
116                                       const QPointF& theLambertPointB,
117                                       const QPointF& theLambertPointC,
118                                       const QPointF& theCartesianPointA,
119                                       const QPointF& theCartesianPointB,
120                                       const QPointF& theCartesianPointC);
121
122   /**
123    * Returns the image transformation points (3 input + 3 output)
124    * \param thePointA input point A
125    * \param thePointB input point B
126    * \param thePointC input point C
127    * \param theLambertPointA output point A in Lambert93 coordinates
128    * \param theLambertPointB output point B in Lambert93 coordinates
129    * \param theLambertPointC output point C in Lambert93 coordinates
130    * \param theCartesianPointA output point A in Cartesian coordinates
131    * \param theCartesianPointB output point B in Cartesian coordinates
132    * \param theCartesianPointC output point C in Cartesian coordinates
133    */
134   HYDRODATA_EXPORT void TrsfPoints(QPoint& thePointA,
135                                    QPoint& thePointB,
136                                    QPoint& thePointC,
137                                    QPointF& theLambertPointA,
138                                    QPointF& theLambertPointB,
139                                    QPointF& theLambertPointC,
140                                    QPointF& theCartesianPointA,
141                                    QPointF& theCartesianPointB,
142                                    QPointF& theCartesianPointC) const;
143
144   /**
145    * Returns true if the image has stored transformation points
146    */
147   HYDRODATA_EXPORT bool HasTrsfPoints() const;
148
149   /**
150    * Stores the transformation mode (0 - Lambert93, 1 - Cartesian)
151    */
152   HYDRODATA_EXPORT void SetTrsfMode(const int theMode);
153
154   /**
155    * Returns the transformation mode (0 - Lambert93, 1 - Cartesian)
156    */
157   HYDRODATA_EXPORT int TrsfMode() const;
158
159   /**
160    * Appends reference to other object (image or polyline).
161    * \param theReferenced the object referenced by this
162    */
163   HYDRODATA_EXPORT void AppendReference( const Handle(HYDROData_Object)& theReferenced );
164
165   /**
166    * Returns the number of referenced objects
167    * \return zero if there is no references
168    */
169   HYDRODATA_EXPORT int NbReferences() const;
170
171   /**
172    * Returns reference by index.
173    * \param theIndex number of reference [0; NbReference)
174    * \returns the referenced object, or Null if index is invalid
175    */
176   HYDRODATA_EXPORT Handle(HYDROData_Object) Reference(const int theIndex) const;
177
178   /**
179    * Updates reference by index. If index is one-bigger than \a NbReferences, 
180    * this method appends it to the end (NbReferences is incremented).
181    * \param theIndex number of reference [0; NbReference]
182    * \param theReferenced the object referenced by this
183    */
184   HYDRODATA_EXPORT void ChangeReference(
185     const int theIndex, Handle(HYDROData_Object) theReferenced);
186
187   /**
188    * Removes reference by index
189    * \param theIndex number of reference [0; NbReference)
190    */
191   HYDRODATA_EXPORT void RemoveReference(const int theIndex);
192
193   /**
194    * Removes all references.
195    */
196   HYDRODATA_EXPORT void ClearReferences();
197
198   /**
199    * Stores the operator name
200    * \param theOpName name of the operator that must be executed for image update
201    */
202   HYDRODATA_EXPORT void SetOperatorName(const QString theOpName);
203
204   /**
205    * Returns the operator name
206    * \returns the name of the operator that must be executed for image update
207    */
208   HYDRODATA_EXPORT QString OperatorName() const;
209
210   /**
211    * Stores the operator arguments
212    * \param theArgs array that stores the operator arguments, needed for execution
213    */
214   HYDRODATA_EXPORT void SetArgs(const QByteArray& theArgs);
215
216   /**
217    * Returns the operator arguments
218    * \returns array that stores the operator arguments, needed for execution
219    */
220   HYDRODATA_EXPORT QByteArray Args() const;
221   
222   /**
223    * Sets the "MustBeUpdated" flag: if image is depended on updated features.
224    * \param theFlag is true for images that must be updated, false for up-to-date
225    */
226   HYDRODATA_EXPORT void MustBeUpdated(bool theFlag);
227
228   /**
229    * Returns the "MustBeUpdated" flag: is image must be recomputed or not
230    * \returns false if image is up to date
231    */
232   HYDRODATA_EXPORT bool MustBeUpdated() const;
233
234   /**
235    * Marks the image as self-splitted.
236    * \param theFlag is true for self-splitted image
237    */
238   HYDRODATA_EXPORT void SetIsSelfSplitted(bool theFlag);
239
240   /**
241    * Checks that the image is self-splitted.
242    * \returns true if image is self-splitted
243    */
244   HYDRODATA_EXPORT bool IsSelfSplitted() const;
245
246 protected:
247
248   friend class HYDROData_Iterator;
249
250   /**
251    * Creates new object in the internal data structure. Use higher level objects 
252    * to create objects with real content.
253    */
254   HYDROData_Image();
255
256   /**
257    * Destructs properties of the object and object itself, removes it from the document.
258    */
259   ~HYDROData_Image();
260
261 };
262
263 #endif