Salome HOME
Merge branch 'BR_HYDRO_IMPS_WIN' of ssh://gitolite3@git.salome-platform.org/modules...
[modules/hydro.git] / src / HYDROPy / HYDROData_Profile.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_Profile.h"
21 %End
22
23 class HYDROData_Profile : public HYDROData_Object
24 {
25 %TypeHeaderCode
26 #include "HYDROData_Profile.h"
27 %End
28 public:
29
30   typedef gp_XYZ                       ProfilePoint;
31   typedef NCollection_Sequence<gp_XYZ> ProfilePoints;
32
33 public:
34   /**
35    * Returns default filling color for new profile.
36    */
37   virtual QColor DefaultFillingColor() const;
38
39   /**
40    * Returns default border color for new profile.
41    */
42   virtual QColor DefaultBorderColor() const;
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 gp_XY& thePoint );
69
70   /**
71    * Returns first(left) point of profile.
72    * \param thePoint[out] profile first point
73    * \return true if point has been set
74    */
75   bool GetLeftPoint( gp_XY& thePoint ) const;
76   
77   /**
78    * Set last(right) point for profile.
79    * \param thePoint the point
80    */
81   void SetRightPoint( const gp_XY& thePoint );
82
83   /**
84    * Returns last(right) point of profile.
85    * \param thePoint[out] profile last point
86    * \return true if point has been set
87    */
88   bool GetRightPoint( gp_XY& thePoint ) const;
89
90
91   /**
92    * Returns object which store parametric presentation of profile points.
93    * \return profile U,Z
94    */
95   HYDROData_ProfileUZ GetProfileUZ( const bool theIsCreate = true ) const 
96     [Handle_HYDROData_ProfileUZ ( const bool theIsCreate = true )];
97   %MethodCode
98
99     Handle(HYDROData_ProfileUZ) aRefProfileUZ;
100     
101     Py_BEGIN_ALLOW_THREADS
102     aRefProfileUZ = sipSelfWasArg ? sipCpp->HYDROData_Profile::GetProfileUZ() : 
103                                    sipCpp->GetProfileUZ();
104     Py_END_ALLOW_THREADS
105     
106     sipRes = (HYDROData_ProfileUZ*)createPointer( aRefProfileUZ );
107   
108   %End
109
110
111   /**
112    * Return number of profile points.
113    * \return number of points
114    */
115   int NbPoints() const;
116
117   /**
118    * Remove all profile points.
119    */
120   void RemovePoints();
121
122
123   /**
124    * Replace current profile parametric points by new one.
125    * \param thePoints the list with new points in parametric form
126    */
127   void SetParametricPoints( const HYDROData_IPolyline::PointsList& thePoints );
128
129   /**
130    * Returns profile points in parametric form.
131    * \return points list
132    */
133   HYDROData_IPolyline::PointsList GetParametricPoints() const;
134
135
136   /**
137    * Replace current profile points by new one.
138    * First and last points will be automatically updated.
139    * \param thePoints the list with new profile points
140    */
141   void SetProfilePoints( const HYDROData_Profile::ProfilePoints thePoints );
142
143   /**
144    * Returns profile points.
145    * Empty sequence is returned if first or last point was not set.
146    * \return profile points list
147    */
148   HYDROData_Profile::ProfilePoints GetProfilePoints() const;
149
150
151 public:
152   // Public methods to work with files.
153
154   /**
155    * Stores the profile file path
156    * \param theFilePath profile file path
157    */
158   void SetFilePath( const TCollection_AsciiString& theFilePath );
159
160   /**
161    * Returns uploaded profile file path
162    */
163   TCollection_AsciiString GetFilePath() const;
164
165   /**
166    * Imports Profile data from file. The supported file types:
167    *  - parametric presentation of profile (2 points in line U,Z)
168    *  - georeferenced presentation of profile (3 points in line X,Y,Z)
169    * Create as many objects as many profiles in the file are defined.
170    * \param theFileName the path to file
171    * \return \c number of successfully imported profiles
172    */
173   static int ImportFromFile( HYDROData_Document             theDoc,
174                              const TCollection_AsciiString& theFileName,
175                              NCollection_Sequence<int>&     theBadProfilesIds,
176                                                          bool isToProject = true )
177   [int ( const Handle_HYDROData_Document&,
178          const TCollection_AsciiString&,
179          NCollection_Sequence<int>& )];
180   %MethodCode
181     Py_BEGIN_ALLOW_THREADS
182     sipRes = HYDROData_Profile::ImportFromFile( a0, *a1, *a2, a3 );
183     Py_END_ALLOW_THREADS
184   %End
185
186   /**
187    * Imports Profile data from file.
188    * \param theFileName the path to file
189    * \param theIsRead set to true if at least one non empty string was read from file
190    * \return \c true if file has been successfully read
191    */
192   virtual bool ImportFromFile( const TCollection_AsciiString& theFileName,
193                                                            bool isToProject = true,
194                                bool* isNotEmpty = 0 );
195
196 protected:
197   /**
198    * Creates new object in the internal data structure. Use higher level objects 
199    * to create objects with real content.
200    */
201   HYDROData_Profile();
202
203   /**
204    * Destructs properties of the object and object itself, removes it from the document.
205    */
206   ~HYDROData_Profile();
207 };