Salome HOME
refs #482: new function for export calculation case
[modules/hydro.git] / src / HYDROData / HYDROData_Profile.h
1
2 #ifndef HYDROData_Profile_HeaderFile
3 #define HYDROData_Profile_HeaderFile
4
5 #include "HYDROData_Object.h"
6
7 #include "HYDROData_ProfileUZ.h"
8
9 DEFINE_STANDARD_HANDLE(HYDROData_Profile, HYDROData_Object)
10
11 class gp_XYZ;
12 class OSD_File;
13 class Handle(HYDROData_Document);
14
15 /**\class HYDROData_Profile
16  * \brief Class that stores/retreives information about the profile.
17  */
18 class HYDROData_Profile : public HYDROData_Object
19 {
20 public:
21
22   typedef gp_XYZ                             ProfilePoint;
23   typedef NCollection_Sequence<ProfilePoint> ProfilePoints;
24
25 protected:
26   /**
27    * Enumeration of tags corresponding to the persistent object parameters.
28    */
29   enum DataTag
30   {
31     DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
32     DataTag_FirstPoint,       ///< first(left) point
33     DataTag_LastPoint,        ///< last(right) point
34     DataTag_ChildProfileUZ,   ///< child parametric profile
35     DataTag_FilePath          ///< profile imported file path
36   };
37
38 public:
39   DEFINE_STANDARD_RTTI(HYDROData_Profile);
40
41   /**
42    * Returns the kind of this object. Must be redefined in all objects of known type.
43    */
44   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_PROFILE; }
45
46   /**
47    * Dump object to Python script representation.
48    */
49   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
50
51   /**
52    * Returns the top shape of the object.
53    */
54   HYDRODATA_EXPORT virtual TopoDS_Shape GetTopShape() const;
55
56   /**
57    * Returns the 3d shape of the object.
58    */
59   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
60
61   /**
62    * Updates profile 3D presentation.
63    * Call this method whenever you made changes in data structure.
64    * This method does not called automatically since it may take a very long time.
65    */
66   HYDRODATA_EXPORT virtual void Update();
67
68   HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
69
70   /**
71    * Returns default filling color for new profile.
72    */
73   HYDRODATA_EXPORT static QColor DefaultFillingColor();
74
75   /**
76    * Returns default border color for new profile.
77    */
78   HYDRODATA_EXPORT static QColor DefaultBorderColor();
79
80
81 public:
82
83   /**
84    * Check profile data and returns true if profile is valid.
85    * Validity is determined by:
86    *   - First(left) and Last(right) point was set
87    *   - Parametric points size is more than 1
88    */
89   HYDRODATA_EXPORT bool IsValid() const;
90
91   /**
92    * Invalidate profile first and last points.
93    */
94   HYDRODATA_EXPORT void Invalidate();
95   
96 public:
97
98   // Public methods to work with profile points.
99
100   /**
101    * Set first(left) point for profile.
102    * \param thePoint the point
103    */
104   HYDRODATA_EXPORT void SetLeftPoint( const gp_XY& thePoint, bool IsConvertFromGlobal = false );
105
106   /**
107    * Returns first(left) point of profile.
108    * \param thePoint[out] profile first point
109    * \return true if point has been set
110    */
111   HYDRODATA_EXPORT bool GetLeftPoint( gp_XY& thePoint, bool IsConvertToGlobal = false ) const;
112
113   /**
114    * Set last(right) point for profile.
115    * \param thePoint the point
116    */
117   HYDRODATA_EXPORT void SetRightPoint( const gp_XY& thePoint, bool IsConvertFromGlobal = false );
118
119   /**
120    * Returns last(right) point of profile.
121    * \param thePoint[out] profile last point
122    * \return true if point has been set
123    */
124   HYDRODATA_EXPORT bool GetRightPoint( gp_XY& thePoint, bool IsConvertToGlobal = false ) const;
125
126
127   /**
128    * Returns object which store parametric presentation of profile points.
129    * \return profile U,Z
130    */
131   HYDRODATA_EXPORT Handle(HYDROData_ProfileUZ) GetProfileUZ( const bool theIsCreate = true ) const;
132
133
134   /**
135    * Return number of profile points.
136    * \return number of points
137    */
138   HYDRODATA_EXPORT int NbPoints() const;
139
140   /**
141    * Remove all profile points.
142    */
143   HYDRODATA_EXPORT void RemovePoints();
144
145
146   /**
147    * Replace current profile parametric points by new one.
148    * \param thePoints the list with new points in parametric form
149    */
150   HYDRODATA_EXPORT void SetParametricPoints( const HYDROData_ProfileUZ::PointsList& thePoints );
151
152   /**
153    * Returns profile points in parametric form.
154    * \return points list
155    */
156   HYDRODATA_EXPORT HYDROData_ProfileUZ::PointsList GetParametricPoints() const;
157
158
159   /**
160    * Replace current profile points by new one.
161    * First and last points will be automatically updated.
162    * \param thePoints the list with new profile points
163    */
164   HYDRODATA_EXPORT void SetProfilePoints( const ProfilePoints& thePoints, bool IsConvertFromGlobal = true );
165
166   /**
167    * Returns profile points.
168    * Empty sequence is returned if first or last point was not set.
169    * \return profile points list
170    */
171   HYDRODATA_EXPORT ProfilePoints GetProfilePoints( bool IsConvertToGlobal = false ) const;
172
173 public:
174   // Public methods to work with files.
175
176   /**
177    * Stores the profile file path
178    * \param theFilePath profile file path
179    */
180   HYDRODATA_EXPORT void SetFilePath( const TCollection_AsciiString& theFilePath );
181
182   /**
183    * Returns uploaded profile file path
184    */
185   HYDRODATA_EXPORT TCollection_AsciiString  GetFilePath() const;
186
187   /**
188    * Imports Profile data from file. The supported file types:
189    *  - parametric presentation of profile (2 points in line U,Z)
190    *  - georeferenced presentation of profile (3 points in line X,Y,Z)
191    * Create as many objects as many profiles in the file are defined.
192    * \param theFileName the path to file
193    * \return \c number of successfully imported profiles
194    */
195   HYDRODATA_EXPORT static int ImportFromFile( const Handle(HYDROData_Document)& theDoc,
196                                                const TCollection_AsciiString&    theFileName,
197                                                NCollection_Sequence<int>&        theBadProfilesIds );
198
199   /**
200    * Imports Profile data from file.
201    * \param theFileName the path to file
202    * \param theIsRead set to true if at least one non empty string was read from file
203    * \return \c true if file has been successfully read
204    */
205   HYDRODATA_EXPORT virtual bool ImportFromFile( const TCollection_AsciiString& theFileName,
206                                                 bool*                          theIsRead = 0 );
207
208   /**
209    * Imports Profile data from file. 
210    * \param theFile file to read
211    * \param theIsRead set to true if at least one non empty string was read from file
212    * \return \c true if file has been successfully read
213    */
214   HYDRODATA_EXPORT virtual bool ImportFromFile( OSD_File& theFile,
215                                                 bool*      theIsRead = 0 );
216
217 protected:
218
219   /**
220    * Returns default filling color for new object.
221    */
222   HYDRODATA_EXPORT virtual QColor getDefaultFillingColor() const;
223
224   /**
225    * Returns default border color for new object.
226    */
227   HYDRODATA_EXPORT virtual QColor getDefaultBorderColor() const;
228
229   /**
230    * Checks and if necessary create child 3D object.
231    * Reimplemented to prevent creation of 3D child object.
232    */
233   HYDRODATA_EXPORT virtual void checkAndSetObject3D() {}
234
235
236 protected:
237
238   friend class HYDROData_Iterator;
239
240   /**
241    * Creates new object in the internal data structure. Use higher level objects 
242    * to create objects with real content.
243    */
244   HYDRODATA_EXPORT HYDROData_Profile();
245
246   /**
247    * Destructs properties of the object and object itself, removes it from the document.
248    */
249   HYDRODATA_EXPORT ~HYDROData_Profile();
250 };
251
252 #endif