Salome HOME
e31e6fd4ac9144b2860b844113a7c6fd4d865ff2
[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    * Returns the top shape of the object.
48    */
49   HYDRODATA_EXPORT virtual TopoDS_Shape GetTopShape() const;
50
51   /**
52    * Returns the 3d shape of the object.
53    */
54   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
55
56   /**
57    * Updates profile 3D presentation.
58    * Call this method whenever you made changes in data structure.
59    * This method does not called automatically since it may take a very long time.
60    */
61   HYDRODATA_EXPORT virtual void UpdateShape3D();
62
63   /**
64    * Dump object to Python script representation.
65    */
66   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
67
68
69   /**
70    * Check profile data and returns true if profile is valid.
71    * Validity is determined by:
72    *   - First(left) and Last(right) point was set
73    *   - Parametric points size is more than 1
74    */
75   HYDRODATA_EXPORT bool IsValid() const;
76
77 public:
78
79   // Public methods to work with profile points.
80
81   /**
82    * Set first(left) point for profile.
83    * \param thePoint the point
84    */
85   HYDRODATA_EXPORT void SetFirstPoint( const gp_XY& thePoint );
86
87   /**
88    * Returns first(left) point of profile.
89    * \param thePoint[out] profile first point
90    * \return true if point has been set
91    */
92   HYDRODATA_EXPORT bool GetFirstPoint( gp_XY& thePoint ) const;
93
94   /**
95    * Set last(right) point for profile.
96    * \param thePoint the point
97    */
98   HYDRODATA_EXPORT void SetLastPoint( const gp_XY& thePoint );
99
100   /**
101    * Returns last(right) point of profile.
102    * \param thePoint[out] profile last point
103    * \return true if point has been set
104    */
105   HYDRODATA_EXPORT bool GetLastPoint( gp_XY& thePoint ) const;
106
107
108   /**
109    * Returns object which store parametric presentation of profile points.
110    * \return profile U,Z
111    */
112   HYDRODATA_EXPORT Handle(HYDROData_ProfileUZ) GetProfileUZ( const bool theIsCreate = true ) const;
113
114
115   /**
116    * Return number of profile points.
117    * \return number of points
118    */
119   HYDRODATA_EXPORT int NbPoints() const;
120
121   /**
122    * Remove all profile points.
123    */
124   HYDRODATA_EXPORT void RemovePoints();
125
126
127   /**
128    * Replace current profile parametric points by new one.
129    * \param thePoints the list with new points in parametric form
130    */
131   HYDRODATA_EXPORT void SetParametricPoints( const HYDROData_ProfileUZ::PointsList& thePoints );
132
133   /**
134    * Returns profile points in parametric form.
135    * \return points list
136    */
137   HYDRODATA_EXPORT HYDROData_ProfileUZ::PointsList GetParametricPoints() const;
138
139
140   /**
141    * Replace current profile points by new one.
142    * First and last points will be automatically updated.
143    * \param thePoints the list with new profile points
144    */
145   HYDRODATA_EXPORT void SetProfilePoints( const ProfilePoints& thePoints );
146
147   /**
148    * Returns profile points.
149    * Empty sequence is returned if first or last point was not set.
150    * \return profile points list
151    */
152   HYDRODATA_EXPORT ProfilePoints GetProfilePoints() const;
153
154
155 public:
156   // Public methods to work with files.
157
158   /**
159    * Stores the profile file path
160    * \param theFilePath profile file path
161    */
162   HYDRODATA_EXPORT void SetFilePath( const TCollection_AsciiString& theFilePath );
163
164   /**
165    * Returns uploaded profile file path
166    */
167   HYDRODATA_EXPORT TCollection_AsciiString  GetFilePath() const;
168
169   /**
170    * Imports Profile data from file. The supported file types:
171    *  - parametric presentation of profile (2 points in line U,Z)
172    *  - georeferenced presentation of profile (3 points in line X,Y,Z)
173    * Create as many objects as many profiles in the file are defined.
174    * \param theFileName the path to file
175    * \return \c true if file has been successfully read
176    */
177   HYDRODATA_EXPORT static bool ImportFromFile( const Handle(HYDROData_Document)& theDoc,
178                                                const TCollection_AsciiString&    theFileName );
179
180   /**
181    * Imports Profile data from file.
182    * \param theFileName the path to file
183    * \return \c true if file has been successfully read
184    */
185   HYDRODATA_EXPORT virtual bool ImportFromFile( const TCollection_AsciiString& theFileName );
186
187   /**
188    * Imports Profile data from file. 
189    * \param theFile file to read
190    * \return \c true if file has been successfully read
191    */
192   HYDRODATA_EXPORT virtual bool ImportFromFile( OSD_File& theFile );
193
194 protected:
195
196   friend class HYDROData_Iterator;
197
198   /**
199    * Creates new object in the internal data structure. Use higher level objects 
200    * to create objects with real content.
201    */
202   HYDROData_Profile();
203
204   /**
205    * Destructs properties of the object and object itself, removes it from the document.
206    */
207   ~HYDROData_Profile();
208 };
209
210 #endif