Salome HOME
Merge remote-tracking branch 'origin/BR_DEMO' into BR_2017
[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 opencascade::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 opencascade::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    * Stores the reference image for transformation
244    * \param theRefImage reference image
245    */
246   void SetTrsfReferenceImage( HYDROData_Image theRefImage ) [void ( const opencascade::handle<HYDROData_Image>& )];
247   %MethodCode
248     Handle(HYDROData_Image) aRefImage =
249       Handle(HYDROData_Image)::DownCast( createHandle( a0 ) );
250     if ( !aRefImage.IsNull() )
251     {
252       Py_BEGIN_ALLOW_THREADS
253       sipSelfWasArg ? sipCpp->HYDROData_Image::SetTrsfReferenceImage( aRefImage ) :
254                       sipCpp->SetTrsfReferenceImage( aRefImage );
255       Py_END_ALLOW_THREADS
256     }
257   %End
258
259   /**
260    * Returns the reference image for transformation
261    */
262   HYDROData_Image GetTrsfReferenceImage() const [opencascade::handle<HYDROData_Image> ()];
263   %MethodCode
264     Handle(HYDROData_Image) aRefImage;
265     
266     Py_BEGIN_ALLOW_THREADS
267     aRefImage = sipSelfWasArg ? sipCpp->HYDROData_Image::GetTrsfReferenceImage() : 
268                                 sipCpp->GetTrsfReferenceImage();
269     Py_END_ALLOW_THREADS
270     
271     sipRes = (HYDROData_Image*)createPointer( aRefImage );
272   %End
273
274   /**
275    * Removes the reference image for transformation
276    */
277   void                       RemoveTrsfReferenceImage();
278
279
280   /**
281    * Stores the transformation mode
282    */
283   void                       SetTrsfMode( const TransformationMode& theMode );
284
285   /**
286    * Returns the transformation mode
287    */
288   TransformationMode         GetTrsfMode() const;
289
290
291   /**
292    * Returns the number of referenced objects
293    * \return zero if there is no references
294    */
295   int                        NbReferences() const;
296
297   /**
298    * Appends reference to other object (image or polyline).
299    * \param theReferenced the object referenced by this
300    */
301   void AppendReference( HYDROData_Entity theReferenced ) [void ( const opencascade::handle<HYDROData_Entity>& )];
302   %MethodCode
303     Handle(HYDROData_Entity) aRef = createHandle( a0 );
304     if ( !aRef.IsNull() )
305     {
306       Py_BEGIN_ALLOW_THREADS
307       sipSelfWasArg ? sipCpp->HYDROData_Image::AppendReference( aRef ) :
308                       sipCpp->AppendReference( aRef );
309       Py_END_ALLOW_THREADS
310     }
311   %End
312
313   /**
314    * Returns reference by index.
315    * \param theIndex number of reference [0; NbReference)
316    * \returns the referenced object, or Null if index is invalid
317    */
318   HYDROData_Entity Reference( const int theIndex ) const [opencascade::handle<HYDROData_Entity> ()];
319   %MethodCode
320     Handle(HYDROData_Entity) aRef;
321     
322     Py_BEGIN_ALLOW_THREADS
323     aRef = sipSelfWasArg ? sipCpp->HYDROData_Image::Reference( a0 ) : 
324                            sipCpp->Reference( a0 );
325     Py_END_ALLOW_THREADS
326     
327     sipRes = createPointer( aRef );
328   %End
329
330   /**
331    * Updates reference by index. If index is one-bigger than \a NbReferences, 
332    * this method appends it to the end (NbReferences is incremented).
333    * \param theIndex number of reference [0; NbReference]
334    * \param theReferenced the object referenced by this
335    */
336   void ChangeReference( const int theIndex, HYDROData_Entity theReferenced )
337   [void ( const int, const opencascade::handle<HYDROData_Entity>& )];
338   %MethodCode
339     Handle(HYDROData_Entity) aRef = createHandle( a1 );
340     if ( !aRef.IsNull() )
341     {
342       Py_BEGIN_ALLOW_THREADS
343       sipSelfWasArg ? sipCpp->HYDROData_Image::ChangeReference( a0, aRef ) :
344                       sipCpp->ChangeReference( a0, aRef );
345       Py_END_ALLOW_THREADS
346     }
347   %End
348
349   /**
350    * Removes reference by index
351    * \param theIndex number of reference [0; NbReference)
352    */
353   void RemoveReference( const int theIndex );
354
355   /**
356    * Removes all references.
357    */
358   void ClearReferences();
359
360
361   /**
362    * Stores the operator name
363    * \param theOpName name of the operator that must be executed for image update
364    */
365   void SetOperatorName(const QString theOpName);
366
367   /**
368    * Returns the operator name
369    * \returns the name of the operator that must be executed for image update
370    */
371   QString OperatorName() const;
372
373   /**
374    * Stores the operator arguments
375    * \param theArgs array that stores the operator arguments, needed for execution
376    */
377   void SetArgs(const QByteArray& theArgs);
378
379   /**
380    * Returns the operator arguments
381    * \returns array that stores the operator arguments, needed for execution
382    */
383   QByteArray Args() const;
384   
385
386   /**
387    * Marks the image as self-split.
388    * \param theFlag is true for self-split image
389    */
390   void SetIsSelfSplit(bool theFlag);
391
392   /**
393    * Checks that the image is self-split.
394    * \returns true if image is self-split
395    */
396   bool IsSelfSplit() const;
397
398 protected:
399
400   /**
401    * Creates new object in the internal data structure. Use higher level objects 
402    * to create objects with real content.
403    */
404   HYDROData_Image();
405
406   /**
407    * Destructs properties of the object and object itself, removes it from the document.
408    */
409   ~HYDROData_Image();
410 };
411
412