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