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