Salome HOME
Drawing of zones in OCC view improved.
[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    * Updates object state.
46    * Reimplemented to update an Image object in the data structure.
47    * Call this method whenever you made changes for operator or reference objects.
48    * If it is changed, sets "MustBeUpdated" flag to other depended images.
49    * \param theIsForce force reupdating of data object
50    */
51   HYDRODATA_EXPORT virtual void Update( const bool theIsForce = true );
52
53   /**
54    * Returns data of object wrapped to QVariant.
55    * Reimplemented to wrap and return saved image.
56    * Transformation are applied to result image.
57    */
58   HYDRODATA_EXPORT virtual QVariant GetDataVariant();
59
60   /**
61    * Stores the image
62    * \param theImage new image
63    */
64   HYDRODATA_EXPORT void SetImage(const QImage& theImage);
65
66   /**
67    * Load the image from file
68    * \param theFilePath path to image
69    */
70   HYDRODATA_EXPORT bool LoadImage(const QString& theFilePath);
71
72   /**
73    * Returns the kept image
74    */
75   HYDRODATA_EXPORT QImage Image();
76
77   /**
78    * Stores the image file path
79    * \param theFilePath image file path
80    */
81   HYDRODATA_EXPORT void SetFilePath(const QString& theFilePath);
82
83   /**
84    * Returns uploaded image file path
85    */
86   HYDRODATA_EXPORT QString GetFilePath() const;
87
88   /**
89    * Stores the image transformation
90    * \param theTrsf new transformation
91    */
92   HYDRODATA_EXPORT void SetTrsf(const QTransform& theTrsf);
93
94   /**
95    * Returns the kept transformation, or "identity" if not yet stored
96    */
97   HYDRODATA_EXPORT QTransform Trsf() const;
98
99   /**
100    * Stores 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 SetTrsfPoints(const QPoint& thePointAIn,
109                                       const QPoint& thePointBIn,
110                                       const QPoint& thePointCIn,
111                                       const QPointF& thePointAOut,
112                                       const QPointF& thePointBOut,
113                                       const QPointF& thePointCOut);
114
115   /**
116    * Returns the image transformation points (3 input + 3 output)
117    * \param thePointAIn input point A
118    * \param thePointBIn input point B
119    * \param thePointCIn input point C
120    * \param thePointAOut output point A
121    * \param thePointBOut output point B
122    * \param thePointCOut output point C
123    */
124   HYDRODATA_EXPORT void TrsfPoints(QPoint& thePointAIn,
125                                    QPoint& thePointBIn,
126                                    QPoint& thePointCIn,
127                                    QPointF& thePointAOut,
128                                    QPointF& thePointBOut,
129                                    QPointF& thePointCOut) const;
130
131   HYDRODATA_EXPORT bool HasTrsfPoints() const;
132
133   /**
134    * Appends reference to other object (image or polyline).
135    * \param theReferenced the object referenced by this
136    */
137   HYDRODATA_EXPORT void AppendReference( const Handle(HYDROData_Object)& theReferenced );
138
139   /**
140    * Returns the number of referenced objects
141    * \return zero if there is no references
142    */
143   HYDRODATA_EXPORT int NbReferences() const;
144
145   /**
146    * Returns reference by index.
147    * \param theIndex number of reference [0; NbReference)
148    * \returns the referenced object, or Null if index is invalid
149    */
150   HYDRODATA_EXPORT Handle(HYDROData_Object) Reference(const int theIndex) const;
151
152   /**
153    * Updates reference by index. If index is one-bigger than \a NbReferences, 
154    * this method appends it to the end (NbReferences is incremented).
155    * \param theIndex number of reference [0; NbReference]
156    * \param theReferenced the object referenced by this
157    */
158   HYDRODATA_EXPORT void ChangeReference(
159     const int theIndex, Handle(HYDROData_Object) theReferenced);
160
161   /**
162    * Removes reference by index
163    * \param theIndex number of reference [0; NbReference)
164    */
165   HYDRODATA_EXPORT void RemoveReference(const int theIndex);
166
167   /**
168    * Removes all references.
169    */
170   HYDRODATA_EXPORT void ClearReferences();
171
172   /**
173    * Stores the operator name
174    * \param theOpName name of the operator that must be executed for image update
175    */
176   HYDRODATA_EXPORT void SetOperatorName(const QString theOpName);
177
178   /**
179    * Returns the operator name
180    * \returns the name of the operator that must be executed for image update
181    */
182   HYDRODATA_EXPORT QString OperatorName() const;
183
184   /**
185    * Stores the operator arguments
186    * \param theArgs array that stores the operator arguments, needed for execution
187    */
188   HYDRODATA_EXPORT void SetArgs(const QByteArray& theArgs);
189
190   /**
191    * Returns the operator arguments
192    * \returns array that stores the operator arguments, needed for execution
193    */
194   HYDRODATA_EXPORT QByteArray Args() const;
195   
196   /**
197    * Sets the "MustBeUpdated" flag: if image is depended on updated features.
198    * \param theFlag is true for images that must be updated, false for up-to-date
199    */
200   HYDRODATA_EXPORT void MustBeUpdated(bool theFlag);
201
202   /**
203    * Returns the "MustBeUpdated" flag: is image must be recomputed or not
204    * \returns false if image is up to date
205    */
206   HYDRODATA_EXPORT bool MustBeUpdated() const;
207
208   /**
209    * Marks the image as self-splitted.
210    * \param theFlag is true for self-splitted image
211    */
212   HYDRODATA_EXPORT void SetIsSelfSplitted(bool theFlag);
213
214   /**
215    * Checks that the image is self-splitted.
216    * \returns true if image is self-splitted
217    */
218   HYDRODATA_EXPORT bool IsSelfSplitted() const;
219
220 protected:
221
222   friend class HYDROData_Iterator;
223
224   /**
225    * Creates new object in the internal data structure. Use higher level objects 
226    * to create objects with real content.
227    */
228   HYDROData_Image();
229
230   /**
231    * Destructs properties of the object and object itself, removes it from the document.
232    */
233   ~HYDROData_Image();
234
235 };
236
237 #endif