Salome HOME
Merge branch 'BR_HYDRO_IMPS_WIN' of ssh://gitolite3@git.salome-platform.org/modules...
[modules/hydro.git] / src / HYDROPy / HYDROData_Image.sip
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 %ExportedHeaderCode
20 #include <HYDROData_Image.h>
21 %End
22
23 class HYDROData_Image : public HYDROData_Entity
24 {
25
26 %ConvertToSubClassCode
27     switch ( sipCpp->GetKind() )
28     {
29       case KIND_IMAGE:
30         sipClass = sipClass_HYDROData_Image;
31         break;
32
33       default:
34         // We don't recognise the type.
35         sipClass = NULL;
36     }
37 %End
38
39 %TypeHeaderCode
40 #include <HYDROData_Image.h>
41 %End
42
43 public:
44
45   enum TransformationMode
46   {
47     ManualGeodesic = 0,
48     ManualCartesian,
49     CartesianFromFile,
50     ReferenceImage
51   };
52
53 public:      
54
55   /**
56    * Stores the image
57    * \param theImage new image
58    */
59   void SetImage( const QImage& theImage );
60
61   /**
62    * Load the image from file
63    * \param theFilePath path to image
64    */
65   bool LoadImage( const QString& theFilePath );
66
67   /**
68    * Returns the kept image
69    */
70   QImage Image();
71
72
73   /**
74    * Stores the image file path
75    * \param theFilePath image file path
76    */
77   void SetFilePath( const QString& theFilePath );
78
79   /**
80    * Returns uploaded image file path
81    */
82   QString GetFilePath() const;
83
84   
85   /**
86    * Stores the image transformation
87    * \param theTrsf new transformation
88    */
89   void SetTrsf( const QTransform& theTrsf );
90
91   /**
92    * Returns the kept transformation, or "identity" if not yet stored
93    */
94   QTransform Trsf() const;
95
96   /**
97    * Updates the matrix of transformation in accordance with reference points.
98    * \param theTrsf new transformation
99    */
100   void UpdateTrsf();
101
102
103   /**
104    * Returns true if transformation is done by two points only
105    */
106   bool IsByTwoPoints() const;
107
108
109   /**
110    * Removes all references from this image.
111    */
112   bool HasReferences() const;
113
114   /**
115    * Removes all references from this image.
116    */
117   void RemoveAllReferences();
118
119
120   /**
121    * Stores the transformation points in local cs of image
122    * \param thePointA point A
123    * \param thePointB point B
124    * \param thePointC point C
125    */
126   void SetLocalPoints( const QPoint& thePointA,
127                        const QPoint& thePointB,
128                        const QPoint& thePointC = QPoint( INT_MIN, INT_MIN ),
129                        const bool    theIsUpdate = true );
130
131   /**
132    * Returns the transformation points in local cs of image
133    * \param thePointA point A
134    * \param thePointB point B
135    * \param thePointC point C
136    * \return true if all parameters has been set before
137    */
138   bool GetLocalPoints( QPoint& thePointA /Out/,
139                        QPoint& thePointB /Out/,
140                        QPoint& thePointC /Out/ ) const;
141
142   /**
143    * Returns true if local points has been set before
144    */
145   bool HasLocalPoints() const;
146
147
148   /**
149    * Stores the transformation points in global cs
150    * \param theMode transformation mode
151    * \param thePointA point A
152    * \param thePointB point B
153    * \param thePointC point C
154    */
155   void SetGlobalPoints( const TransformationMode& theMode,
156                         const QPointF&            thePointA,
157                         const QPointF&            thePointB,
158                         const QPointF&            thePointC = QPoint( INT_MIN, INT_MIN ),
159                         const bool                theIsUpdate = true  );
160
161   /**
162    * Returns the transformation points in global cs
163    * \param theMode transformation mode
164    * \param thePointA point A
165    * \param thePointB point B
166    * \param thePointC point C
167    * \return true if all parameters has been set before
168    */
169   bool GetGlobalPoints( TransformationMode& theMode,
170                         QPointF&            thePointA /Out/,
171                         QPointF&            thePointB /Out/,
172                         QPointF&            thePointC /Out/ ) const;
173
174   /**
175    * Get transformation points from the file and stores them in global cs
176    * \param theFileName the image georeferencement file name
177    * \return true in case of success
178    */
179   bool SetGlobalPointsFromFile( const QString& theFileName );
180
181   /**
182    * Returns true if global points has been set before
183    */
184   bool HasGlobalPoints() const;
185
186
187   /**
188    * Stores the transformation points in reference image local cs
189    * \param theRefImage reference image
190    * \param thePointA point A
191    * \param thePointB point B
192    * \param thePointC point C
193    */
194   void SetReferencePoints( HYDROData_Image theRefImage,
195                            const QPointF&  thePointA,
196                            const QPointF&  thePointB,
197                            const QPointF&  thePointC = QPoint( INT_MIN, INT_MIN ),
198                            const bool      theIsUpdate = true )
199   [void ( const Handle_HYDROData_Image&, const QPointF&, const QPointF&, const QPointF&, const bool )];
200   %MethodCode
201     Handle(HYDROData_Image) aRefImage =
202       Handle(HYDROData_Image)::DownCast( createHandle( a0 ) );
203     if ( !aRefImage.IsNull() )
204     {
205       Py_BEGIN_ALLOW_THREADS
206       sipSelfWasArg ? sipCpp->HYDROData_Image::SetReferencePoints( aRefImage, *a1, *a2, *a3, a4 ) :
207                       sipCpp->SetReferencePoints( aRefImage, *a1, *a2, *a3, a4 );
208       Py_END_ALLOW_THREADS
209     }
210   %End
211
212   /**
213    * Returns the transformation points in reference image local cs
214    * \param theRefImage reference image
215    * \param thePointA point A
216    * \param thePointB point B
217    * \param thePointC point C
218    * \return true if all parameters has been set correctly
219    */
220   bool GetReferencePoints( HYDROData_Image theRefImage,
221                            QPointF&        thePointA /Out/,
222                            QPointF&        thePointB /Out/,
223                            QPointF&        thePointC /Out/ ) const
224   [bool ( const Handle_HYDROData_Image&, QPointF&, QPointF&, QPointF& )];
225   %MethodCode
226     Handle(HYDROData_Image) aRefImage =
227       Handle(HYDROData_Image)::DownCast( createHandle( a0 ) );
228     if ( !aRefImage.IsNull() )
229     {
230       Py_BEGIN_ALLOW_THREADS
231       sipRes = sipSelfWasArg ? sipCpp->HYDROData_Image::GetReferencePoints( aRefImage, *a1, *a2, *a3 ) :
232                                sipCpp->GetReferencePoints( aRefImage, *a1, *a2, *a3 );
233       Py_END_ALLOW_THREADS
234     }
235   %End
236
237   /**
238    * Returns true if reference points has been set before
239    */
240   bool HasReferencePoints() const;
241
242
243   /**
244    * Stores the reference image for transformation
245    * \param theRefImage reference image
246    */
247   void SetTrsfReferenceImage( HYDROData_Image theRefImage ) [void ( const Handle_HYDROData_Image& )];
248   %MethodCode
249     Handle(HYDROData_Image) aRefImage =
250       Handle(HYDROData_Image)::DownCast( createHandle( a0 ) );
251     if ( !aRefImage.IsNull() )
252     {
253       Py_BEGIN_ALLOW_THREADS
254       sipSelfWasArg ? sipCpp->HYDROData_Image::SetTrsfReferenceImage( aRefImage ) :
255                       sipCpp->SetTrsfReferenceImage( aRefImage );
256       Py_END_ALLOW_THREADS
257     }
258   %End
259
260   /**
261    * Returns the reference image for transformation
262    */
263   HYDROData_Image GetTrsfReferenceImage() const [Handle_HYDROData_Image ()];
264   %MethodCode
265     Handle(HYDROData_Image) aRefImage;
266     
267     Py_BEGIN_ALLOW_THREADS
268     aRefImage = sipSelfWasArg ? sipCpp->HYDROData_Image::GetTrsfReferenceImage() : 
269                                 sipCpp->GetTrsfReferenceImage();
270     Py_END_ALLOW_THREADS
271     
272     sipRes = (HYDROData_Image*)createPointer( aRefImage );
273   %End
274
275   /**
276    * Removes the reference image for transformation
277    */
278   void                       RemoveTrsfReferenceImage();
279
280
281   /**
282    * Stores the transformation mode
283    */
284   void                       SetTrsfMode( const TransformationMode& theMode );
285
286   /**
287    * Returns the transformation mode
288    */
289   TransformationMode         GetTrsfMode() const;
290
291
292   /**
293    * Returns the number of referenced objects
294    * \return zero if there is no references
295    */
296   int                        NbReferences() const;
297
298   /**
299    * Appends reference to other object (image or polyline).
300    * \param theReferenced the object referenced by this
301    */
302   void AppendReference( HYDROData_Entity theReferenced ) [void ( const Handle_HYDROData_Entity& )];
303   %MethodCode
304     Handle(HYDROData_Entity) aRef = createHandle( a0 );
305     if ( !aRef.IsNull() )
306     {
307       Py_BEGIN_ALLOW_THREADS
308       sipSelfWasArg ? sipCpp->HYDROData_Image::AppendReference( aRef ) :
309                       sipCpp->AppendReference( aRef );
310       Py_END_ALLOW_THREADS
311     }
312   %End
313
314   /**
315    * Returns reference by index.
316    * \param theIndex number of reference [0; NbReference)
317    * \returns the referenced object, or Null if index is invalid
318    */
319   HYDROData_Entity Reference( const int theIndex ) const [Handle_HYDROData_Entity ()];
320   %MethodCode
321     Handle(HYDROData_Entity) aRef;
322     
323     Py_BEGIN_ALLOW_THREADS
324     aRef = sipSelfWasArg ? sipCpp->HYDROData_Image::Reference( a0 ) : 
325                            sipCpp->Reference( a0 );
326     Py_END_ALLOW_THREADS
327     
328     sipRes = createPointer( aRef );
329   %End
330
331   /**
332    * Updates reference by index. If index is one-bigger than \a NbReferences, 
333    * this method appends it to the end (NbReferences is incremented).
334    * \param theIndex number of reference [0; NbReference]
335    * \param theReferenced the object referenced by this
336    */
337   void ChangeReference( const int theIndex, HYDROData_Entity theReferenced )
338   [void ( const int, const Handle_HYDROData_Entity& )];
339   %MethodCode
340     Handle(HYDROData_Entity) aRef = createHandle( a1 );
341     if ( !aRef.IsNull() )
342     {
343       Py_BEGIN_ALLOW_THREADS
344       sipSelfWasArg ? sipCpp->HYDROData_Image::ChangeReference( a0, aRef ) :
345                       sipCpp->ChangeReference( a0, aRef );
346       Py_END_ALLOW_THREADS
347     }
348   %End
349
350   /**
351    * Removes reference by index
352    * \param theIndex number of reference [0; NbReference)
353    */
354   void RemoveReference( const int theIndex );
355
356   /**
357    * Removes all references.
358    */
359   void ClearReferences();
360
361
362   /**
363    * Stores the operator name
364    * \param theOpName name of the operator that must be executed for image update
365    */
366   void SetOperatorName(const QString theOpName);
367
368   /**
369    * Returns the operator name
370    * \returns the name of the operator that must be executed for image update
371    */
372   QString OperatorName() const;
373
374   /**
375    * Stores the operator arguments
376    * \param theArgs array that stores the operator arguments, needed for execution
377    */
378   void SetArgs(const QByteArray& theArgs);
379
380   /**
381    * Returns the operator arguments
382    * \returns array that stores the operator arguments, needed for execution
383    */
384   QByteArray Args() const;
385   
386
387   /**
388    * Marks the image as self-split.
389    * \param theFlag is true for self-split image
390    */
391   void SetIsSelfSplit(bool theFlag);
392
393   /**
394    * Checks that the image is self-split.
395    * \returns true if image is self-split
396    */
397   bool IsSelfSplit() const;
398
399 protected:
400
401   /**
402    * Creates new object in the internal data structure. Use higher level objects 
403    * to create objects with real content.
404    */
405   HYDROData_Image();
406
407   /**
408    * Destructs properties of the object and object itself, removes it from the document.
409    */
410   ~HYDROData_Image();
411 };
412
413