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