Salome HOME
Dump Image 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   /**
116    * Appends reference to other image.
117    * \param theReferenced the image referenced by this
118    */
119   HYDRODATA_EXPORT void AppendReference(Handle(HYDROData_Image) theReferenced);
120
121   /**
122    * Returns the number of referenced images
123    * \return zero if there is no references
124    */
125   HYDRODATA_EXPORT int NbReferences() const;
126
127   /**
128    * Returns reference by index.
129    * \param theIndex number of reference [0; NbReference)
130    * \returns the referenced image, or Null if index is invalid
131    */
132   HYDRODATA_EXPORT Handle(HYDROData_Image) Reference(const int theIndex) const;
133
134   /**
135    * Updates reference by index. If index is one-bigger than \a NbReferences, 
136    * this method appends it to the end (NbReferences is incremented).
137    * \param theIndex number of reference [0; NbReference]
138    * \param theReferenced the image referenced by this
139    */
140   HYDRODATA_EXPORT void ChangeReference(
141     const int theIndex, Handle(HYDROData_Image) theReferenced);
142
143   /**
144    * Removes reference by index
145    * \param theIndex number of reference [0; NbReference)
146    */
147   HYDRODATA_EXPORT void RemoveReference(const int theIndex);
148
149   /**
150    * Removes all references.
151    */
152   HYDRODATA_EXPORT void ClearReferences();
153
154   /**
155    * Stores the operator name
156    * \param theOpName name of the operator that must be executed for image update
157    */
158   HYDRODATA_EXPORT void SetOperatorName(const QString theOpName);
159
160   /**
161    * Returns the operator name
162    * \returns the name of the operator that must be executed for image update
163    */
164   HYDRODATA_EXPORT QString OperatorName() const;
165
166   /**
167    * Stores the operator arguments
168    * \param theArgs array that stores the operator arguments, needed for execution
169    */
170   HYDRODATA_EXPORT void SetArgs(const QByteArray& theArgs);
171
172   /**
173    * Returns the operator arguments
174    * \returns array that stores the operator arguments, needed for execution
175    */
176   HYDRODATA_EXPORT QByteArray Args() const;
177   
178   /**
179    * Sets the "MustBeUpdated" flag: if image is depended on updated features.
180    * \param theFlag is true for images that must be updated, false for up-to-date
181    */
182   HYDRODATA_EXPORT void MustBeUpdated(bool theFlag);
183
184   /**
185    * Returns the "MustBeUpdated" flag: is image must be recomputed or not
186    * \returns false if image is up to date
187    */
188   HYDRODATA_EXPORT bool MustBeUpdated();
189
190 protected:
191
192   friend class HYDROData_Iterator;
193
194   /**
195    * Creates new object in the internal data structure. Use higher level objects 
196    * to create objects with real content.
197    */
198   HYDROData_Image();
199
200   /**
201    * Destructs properties of the object and object itself, removes it from the document.
202    */
203   ~HYDROData_Image();
204
205 };
206
207 #endif