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