Salome HOME
3c56846fa142f933433b07a7cce68611d22c3feb
[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   /**
69    * Returns default filling color for new profile.
70    */
71   HYDRODATA_EXPORT static QColor DefaultFillingColor();
72
73   /**
74    * Returns default border color for new profile.
75    */
76   HYDRODATA_EXPORT static QColor DefaultBorderColor();
77
78
79 public:
80
81   /**
82    * Check profile data and returns true if profile is valid.
83    * Validity is determined by:
84    *   - First(left) and Last(right) point was set
85    *   - Parametric points size is more than 1
86    */
87   HYDRODATA_EXPORT bool IsValid() const;
88
89   /**
90    * Invalidate profile first and last points.
91    */
92   HYDRODATA_EXPORT void Invalidate();
93   
94 public:
95
96   // Public methods to work with profile points.
97
98   /**
99    * Set first(left) point for profile.
100    * \param thePoint the point
101    */
102   HYDRODATA_EXPORT void SetLeftPoint( const gp_XY& thePoint );
103
104   /**
105    * Returns first(left) point of profile.
106    * \param thePoint[out] profile first point
107    * \return true if point has been set
108    */
109   HYDRODATA_EXPORT bool GetLeftPoint( gp_XY& thePoint ) const;
110
111   /**
112    * Set last(right) point for profile.
113    * \param thePoint the point
114    */
115   HYDRODATA_EXPORT void SetRightPoint( const gp_XY& thePoint );
116
117   /**
118    * Returns last(right) point of profile.
119    * \param thePoint[out] profile last point
120    * \return true if point has been set
121    */
122   HYDRODATA_EXPORT bool GetRightPoint( gp_XY& thePoint ) const;
123
124
125   /**
126    * Returns object which store parametric presentation of profile points.
127    * \return profile U,Z
128    */
129   HYDRODATA_EXPORT Handle(HYDROData_ProfileUZ) GetProfileUZ( const bool theIsCreate = true ) const;
130
131
132   /**
133    * Return number of profile points.
134    * \return number of points
135    */
136   HYDRODATA_EXPORT int NbPoints() const;
137
138   /**
139    * Remove all profile points.
140    */
141   HYDRODATA_EXPORT void RemovePoints();
142
143
144   /**
145    * Replace current profile parametric points by new one.
146    * \param thePoints the list with new points in parametric form
147    */
148   HYDRODATA_EXPORT void SetParametricPoints( const HYDROData_ProfileUZ::PointsList& thePoints );
149
150   /**
151    * Returns profile points in parametric form.
152    * \return points list
153    */
154   HYDRODATA_EXPORT HYDROData_ProfileUZ::PointsList GetParametricPoints() const;
155
156
157   /**
158    * Replace current profile points by new one.
159    * First and last points will be automatically updated.
160    * \param thePoints the list with new profile points
161    */
162   HYDRODATA_EXPORT void SetProfilePoints( const ProfilePoints& thePoints );
163
164   /**
165    * Returns profile points.
166    * Empty sequence is returned if first or last point was not set.
167    * \return profile points list
168    */
169   HYDRODATA_EXPORT ProfilePoints GetProfilePoints() const;
170
171
172 public:
173   // Public methods to work with files.
174
175   /**
176    * Stores the profile file path
177    * \param theFilePath profile file path
178    */
179   HYDRODATA_EXPORT void SetFilePath( const TCollection_AsciiString& theFilePath );
180
181   /**
182    * Returns uploaded profile file path
183    */
184   HYDRODATA_EXPORT TCollection_AsciiString  GetFilePath() const;
185
186   /**
187    * Imports Profile data from file. The supported file types:
188    *  - parametric presentation of profile (2 points in line U,Z)
189    *  - georeferenced presentation of profile (3 points in line X,Y,Z)
190    * Create as many objects as many profiles in the file are defined.
191    * \param theFileName the path to file
192    * \return \c number of successfully imported profiles
193    */
194   HYDRODATA_EXPORT static int ImportFromFile( const Handle(HYDROData_Document)& theDoc,
195                                                const TCollection_AsciiString&    theFileName,
196                                                NCollection_Sequence<int>&        theBadProfilesIds );
197
198   /**
199    * Imports Profile data from file.
200    * \param theFileName the path to file
201    * \param theIsRead set to true if at least one non empty string was read from file
202    * \return \c true if file has been successfully read
203    */
204   HYDRODATA_EXPORT virtual bool ImportFromFile( const TCollection_AsciiString& theFileName,
205                                                 bool*                          theIsRead = 0 );
206
207   /**
208    * Imports Profile data from file. 
209    * \param theFile file to read
210    * \param theIsRead set to true if at least one non empty string was read from file
211    * \return \c true if file has been successfully read
212    */
213   HYDRODATA_EXPORT virtual bool ImportFromFile( OSD_File& theFile,
214                                                 bool*      theIsRead = 0 );
215
216 protected:
217
218   /**
219    * Returns default filling color for new object.
220    */
221   HYDRODATA_EXPORT virtual QColor getDefaultFillingColor() const;
222
223   /**
224    * Returns default border color for new object.
225    */
226   HYDRODATA_EXPORT virtual QColor getDefaultBorderColor() const;
227
228   /**
229    * Checks and if necessary create child 3D object.
230    * Reimplemented to prevent creation of 3D child object.
231    */
232   HYDRODATA_EXPORT virtual void checkAndSetObject3D() {}
233
234
235 protected:
236
237   friend class HYDROData_Iterator;
238
239   /**
240    * Creates new object in the internal data structure. Use higher level objects 
241    * to create objects with real content.
242    */
243   HYDRODATA_EXPORT HYDROData_Profile();
244
245   /**
246    * Destructs properties of the object and object itself, removes it from the document.
247    */
248   HYDRODATA_EXPORT ~HYDROData_Profile();
249 };
250
251 #endif