Salome HOME
Dump Polyline data to python script (Feature #13).
[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_TrsfPoints,  ///< image transformation points (3 input + 3 output)
28     DataTag_FilePath     ///< image imported file path
29   };
30
31 public:
32   DEFINE_STANDARD_RTTI(HYDROData_Image);
33
34   /**
35    * Returns the kind of this object. Must be redefined in all objects of known type.
36    */
37   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_IMAGE;}
38
39   /**
40    * Dump Image object to Python script representation.
41    */
42   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
43
44   /**
45    * Stores the image
46    * \param theImage new image
47    */
48   HYDRODATA_EXPORT void SetImage(const QImage& theImage);
49
50   /**
51    * Load the image from file
52    * \param theFilePath path to image
53    */
54   HYDRODATA_EXPORT bool LoadImage(const QString& theFilePath);
55
56   /**
57    * Returns the kept image
58    */
59   HYDRODATA_EXPORT QImage Image();
60
61   /**
62    * Stores the image file path
63    * \param theFilePath image file path
64    */
65   HYDRODATA_EXPORT void SetFilePath(const QString& theFilePath);
66
67   /**
68    * Returns uploaded image file path
69    */
70   HYDRODATA_EXPORT QString GetFilePath() const;
71
72   /**
73    * Stores the image transformation
74    * \param theTrsf new transformation
75    */
76   HYDRODATA_EXPORT void SetTrsf(const QTransform& theTrsf);
77
78   /**
79    * Returns the kept transformation, or "identity" if not yet stored
80    */
81   HYDRODATA_EXPORT QTransform Trsf() const;
82
83   /**
84    * Stores the image transformation points (3 input + 3 output)
85    * \param thePointAIn input point A
86    * \param thePointBIn input point B
87    * \param thePointCIn input point C
88    * \param thePointAOut output point A
89    * \param thePointBOut output point B
90    * \param thePointCOut output point C
91    */
92   HYDRODATA_EXPORT void SetTrsfPoints(const QPoint& thePointAIn,
93                                       const QPoint& thePointBIn,
94                                       const QPoint& thePointCIn,
95                                       const QPointF& thePointAOut,
96                                       const QPointF& thePointBOut,
97                                       const QPointF& thePointCOut);
98
99   /**
100    * Returns the image transformation points (3 input + 3 output)
101    * \param thePointAIn input point A
102    * \param thePointBIn input point B
103    * \param thePointCIn input point C
104    * \param thePointAOut output point A
105    * \param thePointBOut output point B
106    * \param thePointCOut output point C
107    */
108   HYDRODATA_EXPORT void TrsfPoints(QPoint& thePointAIn,
109                                    QPoint& thePointBIn,
110                                    QPoint& thePointCIn,
111                                    QPointF& thePointAOut,
112                                    QPointF& thePointBOut,
113                                    QPointF& thePointCOut) const;
114
115   HYDRODATA_EXPORT bool HasTrsfPoints() const;
116
117   /**
118    * Appends reference to other object (image or polyline).
119    * \param theReferenced the object referenced by this
120    */
121   HYDRODATA_EXPORT void AppendReference(Handle(HYDROData_Object) theReferenced);
122
123   /**
124    * Returns the number of referenced objects
125    * \return zero if there is no references
126    */
127   HYDRODATA_EXPORT int NbReferences() const;
128
129   /**
130    * Returns reference by index.
131    * \param theIndex number of reference [0; NbReference)
132    * \returns the referenced object, or Null if index is invalid
133    */
134   HYDRODATA_EXPORT Handle(HYDROData_Object) Reference(const int theIndex) const;
135
136   /**
137    * Updates reference by index. If index is one-bigger than \a NbReferences, 
138    * this method appends it to the end (NbReferences is incremented).
139    * \param theIndex number of reference [0; NbReference]
140    * \param theReferenced the object referenced by this
141    */
142   HYDRODATA_EXPORT void ChangeReference(
143     const int theIndex, Handle(HYDROData_Object) theReferenced);
144
145   /**
146    * Removes reference by index
147    * \param theIndex number of reference [0; NbReference)
148    */
149   HYDRODATA_EXPORT void RemoveReference(const int theIndex);
150
151   /**
152    * Removes all references.
153    */
154   HYDRODATA_EXPORT void ClearReferences();
155
156   /**
157    * Stores the operator name
158    * \param theOpName name of the operator that must be executed for image update
159    */
160   HYDRODATA_EXPORT void SetOperatorName(const QString theOpName);
161
162   /**
163    * Returns the operator name
164    * \returns the name of the operator that must be executed for image update
165    */
166   HYDRODATA_EXPORT QString OperatorName() const;
167
168   /**
169    * Stores the operator arguments
170    * \param theArgs array that stores the operator arguments, needed for execution
171    */
172   HYDRODATA_EXPORT void SetArgs(const QByteArray& theArgs);
173
174   /**
175    * Returns the operator arguments
176    * \returns array that stores the operator arguments, needed for execution
177    */
178   HYDRODATA_EXPORT QByteArray Args() const;
179   
180   /**
181    * Sets the "MustBeUpdated" flag: if image is depended on updated features.
182    * \param theFlag is true for images that must be updated, false for up-to-date
183    */
184   HYDRODATA_EXPORT void MustBeUpdated(bool theFlag);
185
186   /**
187    * Returns the "MustBeUpdated" flag: is image must be recomputed or not
188    * \returns false if image is up to date
189    */
190   HYDRODATA_EXPORT bool MustBeUpdated() const;
191
192   /**
193    * Marks the image as self-splitted.
194    * \param theFlag is true for self-splitted image
195    */
196   HYDRODATA_EXPORT void SetIsSelfSplitted(bool theFlag);
197
198   /**
199    * Checks that the image is self-splitted.
200    * \returns true if image is self-splitted
201    */
202   HYDRODATA_EXPORT bool IsSelfSplitted() const;
203
204 protected:
205
206   friend class HYDROData_Iterator;
207
208   /**
209    * Creates new object in the internal data structure. Use higher level objects 
210    * to create objects with real content.
211    */
212   HYDROData_Image();
213
214   /**
215    * Destructs properties of the object and object itself, removes it from the document.
216    */
217   ~HYDROData_Image();
218
219 };
220
221 #endif