Salome HOME
Debug minor changes.
[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   /**
78    * Invalidate profile first and last points.
79    */
80   HYDRODATA_EXPORT void Invalidate();
81   
82 public:
83
84   // Public methods to work with profile points.
85
86   /**
87    * Set first(left) point for profile.
88    * \param thePoint the point
89    */
90   HYDRODATA_EXPORT void SetFirstPoint( const gp_XY& thePoint );
91
92   /**
93    * Returns first(left) point of profile.
94    * \param thePoint[out] profile first point
95    * \return true if point has been set
96    */
97   HYDRODATA_EXPORT bool GetFirstPoint( gp_XY& thePoint ) const;
98
99   /**
100    * Set last(right) point for profile.
101    * \param thePoint the point
102    */
103   HYDRODATA_EXPORT void SetLastPoint( const gp_XY& thePoint );
104
105   /**
106    * Returns last(right) point of profile.
107    * \param thePoint[out] profile last point
108    * \return true if point has been set
109    */
110   HYDRODATA_EXPORT bool GetLastPoint( gp_XY& thePoint ) const;
111
112
113   /**
114    * Returns object which store parametric presentation of profile points.
115    * \return profile U,Z
116    */
117   HYDRODATA_EXPORT Handle(HYDROData_ProfileUZ) GetProfileUZ( const bool theIsCreate = true ) const;
118
119
120   /**
121    * Return number of profile points.
122    * \return number of points
123    */
124   HYDRODATA_EXPORT int NbPoints() const;
125
126   /**
127    * Remove all profile points.
128    */
129   HYDRODATA_EXPORT void RemovePoints();
130
131
132   /**
133    * Replace current profile parametric points by new one.
134    * \param thePoints the list with new points in parametric form
135    */
136   HYDRODATA_EXPORT void SetParametricPoints( const HYDROData_ProfileUZ::PointsList& thePoints );
137
138   /**
139    * Returns profile points in parametric form.
140    * \return points list
141    */
142   HYDRODATA_EXPORT HYDROData_ProfileUZ::PointsList GetParametricPoints() const;
143
144
145   /**
146    * Replace current profile points by new one.
147    * First and last points will be automatically updated.
148    * \param thePoints the list with new profile points
149    */
150   HYDRODATA_EXPORT void SetProfilePoints( const ProfilePoints& thePoints );
151
152   /**
153    * Returns profile points.
154    * Empty sequence is returned if first or last point was not set.
155    * \return profile points list
156    */
157   HYDRODATA_EXPORT ProfilePoints GetProfilePoints() const;
158
159
160 public:
161   // Public methods to work with files.
162
163   /**
164    * Stores the profile file path
165    * \param theFilePath profile file path
166    */
167   HYDRODATA_EXPORT void SetFilePath( const TCollection_AsciiString& theFilePath );
168
169   /**
170    * Returns uploaded profile file path
171    */
172   HYDRODATA_EXPORT TCollection_AsciiString  GetFilePath() const;
173
174   /**
175    * Imports Profile data from file. The supported file types:
176    *  - parametric presentation of profile (2 points in line U,Z)
177    *  - georeferenced presentation of profile (3 points in line X,Y,Z)
178    * Create as many objects as many profiles in the file are defined.
179    * \param theFileName the path to file
180    * \return \c true if file has been successfully read
181    */
182   HYDRODATA_EXPORT static bool ImportFromFile( const Handle(HYDROData_Document)& theDoc,
183                                                const TCollection_AsciiString&    theFileName );
184
185   /**
186    * Imports Profile data from file.
187    * \param theFileName the path to file
188    * \return \c true if file has been successfully read
189    */
190   HYDRODATA_EXPORT virtual bool ImportFromFile( const TCollection_AsciiString& theFileName );
191
192   /**
193    * Imports Profile data from file. 
194    * \param theFile file to read
195    * \return \c true if file has been successfully read
196    */
197   HYDRODATA_EXPORT virtual bool ImportFromFile( OSD_File& theFile );
198
199 protected:
200
201   friend class HYDROData_Iterator;
202
203   /**
204    * Creates new object in the internal data structure. Use higher level objects 
205    * to create objects with real content.
206    */
207   HYDROData_Profile();
208
209   /**
210    * Destructs properties of the object and object itself, removes it from the document.
211    */
212   ~HYDROData_Profile();
213 };
214
215 #endif