Salome HOME
Refs #279 - Copy for the view position coordinates
[modules/hydro.git] / src / HYDROPy / HYDROData_Profile.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_Profile.h"
25 %End
26
27 class HYDROData_Profile : public HYDROData_Object
28 {
29 %TypeHeaderCode
30 #include "HYDROData_Profile.h"
31 %End
32
33 public:
34   /**
35    * Returns default filling color for new profile.
36    */
37   static QColor DefaultFillingColor();
38
39   /**
40    * Returns default border color for new profile.
41    */
42   static QColor DefaultBorderColor();
43
44
45 public:
46
47   /**
48    * Check profile data and returns true if profile is valid.
49    * Validity is determined by:
50    *   - First(left) and Last(right) point was set
51    *   - Parametric points size is more than 1
52    */
53   bool IsValid() const;
54
55   /**
56    * Invalidate profile first and last points.
57    */
58   void Invalidate();
59   
60 public:
61
62   // Public methods to work with profile points.
63
64   /**
65    * Set first(left) point for profile.
66    * \param thePoint the point
67    */
68   void SetLeftPoint( const QPointF& thePoint ) [void (const gp_XY&)];
69   %MethodCode
70   
71     // The C++ API gets the gp_XY object, we convert it from QPointF.
72     gp_XY aPoint( a0->x(), a0->y() );
73     
74     Py_BEGIN_ALLOW_THREADS
75     if ( sipSelfWasArg )
76     {
77       sipCpp->HYDROData_Profile::SetLeftPoint( aPoint );
78     }
79     else
80     {
81       sipCpp->SetLeftPoint( aPoint );
82     }
83     Py_END_ALLOW_THREADS
84   %End
85
86   /**
87    * Returns first(left) point of profile.
88    * \param thePoint[out] profile first point
89    * \return true if point has been set
90    */
91   bool GetLeftPoint( QPointF& thePoint ) const [bool (gp_XY&)];
92   %MethodCode
93   
94     // The C++ API gets the gp_XY object, then we convert it to QPointF.
95     gp_XY aPoint();
96     
97     Py_BEGIN_ALLOW_THREADS
98     sipRes = sipSelfWasArg ? sipCpp->HYDROData_Profile::GetLeftPoint( aPoint ) : 
99                              sipCpp->GetLeftPoint( aPoint );
100     Py_END_ALLOW_THREADS
101     
102     a0->SetX( aPoint.X() );
103     a0->SetY( aPoint.Y() );
104   %End
105
106   /**
107    * Set last(right) point for profile.
108    * \param thePoint the point
109    */
110   void SetRightPoint( const QPointF& thePoint ) [void (const gp_XY&)];
111   %MethodCode
112   
113     // The C++ API gets the gp_XY object, we convert it from QPointF.
114     gp_XY aPoint( a0->x(), a0->y() );
115     
116     Py_BEGIN_ALLOW_THREADS
117     {
118       sipCpp->HYDROData_Profile::SetRightPoint( aPoint );
119     }
120     else
121     {
122       sipCpp->SetRightPoint( aPoint );
123     }
124     Py_END_ALLOW_THREADS
125   %End
126
127   /**
128    * Returns last(right) point of profile.
129    * \param thePoint[out] profile last point
130    * \return true if point has been set
131    */
132   bool GetRightPoint( QPointF& thePoint ) const [bool (gp_XY&)];
133   %MethodCode
134   
135     // The C++ API gets the gp_XY object, then we convert it to QPointF.
136     gp_XY aPoint();
137     
138     Py_BEGIN_ALLOW_THREADS
139     sipRes = sipSelfWasArg ? sipCpp->HYDROData_Profile::GetRightPoint( aPoint ) : 
140                              sipCpp->GetRightPoint( aPoint );
141     Py_END_ALLOW_THREADS
142     
143     a0->SetX( aPoint.X() );
144     a0->SetY( aPoint.Y() );
145   %End
146
147
148   /**
149    * Returns object which store parametric presentation of profile points.
150    * \return profile U,Z
151    */
152   HYDROData_ProfileUZ GetProfileUZ( const bool theIsCreate = true ) const 
153     [Handle_HYDROData_ProfileUZ ( const bool theIsCreate = true )];
154   %MethodCode
155
156     Handle(HYDROData_ProfileUZ) aRefProfileUZ;
157     
158     Py_BEGIN_ALLOW_THREADS
159     aRefProfileUZ = sipSelfWasArg ? sipCpp->HYDROData_ImmersibleZone::GetProfileUZ() : 
160                                    sipCpp->GetProfileUZ();
161     Py_END_ALLOW_THREADS
162     
163     sipRes = (HYDROData_ProfileUZ*)createPointer( aRefProfileUZ );
164   
165   %End
166
167
168   /**
169    * Return number of profile points.
170    * \return number of points
171    */
172   int NbPoints() const;
173
174   /**
175    * Remove all profile points.
176    */
177   void RemovePoints();
178
179
180   /**
181    * Replace current profile parametric points by new one.
182    * \param thePoints the list with new points in parametric form
183    */
184   void SetParametricPoints( SIP_PYLIST thePoints ) [void ( const HYDROData_ProfileUZ::PointsList& )];
185
186   /**
187    * Returns profile points in parametric form.
188    * \return points list
189    */
190   SIP_PYLIST GetParametricPoints() const [HYDROData_ProfileUZ::PointsList ()];
191
192
193   /**
194    * Replace current profile points by new one.
195    * First and last points will be automatically updated.
196    * \param thePoints the list with new profile points
197    */
198   void SetProfilePoints( const SIP_PYLIST thePoints ) [void ( const ProfilePoints& )];
199
200   /**
201    * Returns profile points.
202    * Empty sequence is returned if first or last point was not set.
203    * \return profile points list
204    */
205   SIP_PYLIST GetProfilePoints() const [ProfilePoints ()];
206
207
208 public:
209   // Public methods to work with files.
210
211   /**
212    * Stores the profile file path
213    * \param theFilePath profile file path
214    */
215   void SetFilePath( const QString& theFilePath ) [void ( const TCollection_AsciiString& )];
216
217   /**
218    * Returns uploaded profile file path
219    */
220   QString GetFilePath() const [TCollection_AsciiString ()];
221
222   /**
223    * Imports Profile data from file. The supported file types:
224    *  - parametric presentation of profile (2 points in line U,Z)
225    *  - georeferenced presentation of profile (3 points in line X,Y,Z)
226    * Create as many objects as many profiles in the file are defined.
227    * \param theFileName the path to file
228    * \return \c true if file has been successfully read
229    */
230   static bool ImportFromFile( HYDROData_Document theDoc,
231                               const QString& theFileName )
232   [bool ( const Handle_HYDROData_Document&,
233           const TCollection_AsciiString& )];
234
235   /**
236    * Imports Profile data from file.
237    * \param theFileName the path to file
238    * \return \c true if file has been successfully read
239    */
240   virtual bool ImportFromFile( const QString& theFileName ) [ bool ( const TCollection_AsciiString& ) ];
241
242   /**
243    * Imports Profile data from file. 
244    * \param theFile file to read
245    * \return \c true if file has been successfully read
246    */
247 //  virtual bool ImportFromFile( OSD_File& theFile );
248
249 protected:
250   /**
251    * Creates new object in the internal data structure. Use higher level objects 
252    * to create objects with real content.
253    */
254   HYDROData_Profile();
255
256   /**
257    * Destructs properties of the object and object itself, removes it from the document.
258    */
259   ~HYDROData_Profile();
260 };