2 #ifndef HYDROData_Profile_HeaderFile
3 #define HYDROData_Profile_HeaderFile
5 #include "HYDROData_Object.h"
7 #include "HYDROData_ProfileUZ.h"
9 DEFINE_STANDARD_HANDLE(HYDROData_Profile, HYDROData_Object)
13 class Handle(HYDROData_Document);
15 /**\class HYDROData_Profile
16 * \brief Class that stores/retreives information about the profile.
18 class HYDROData_Profile : public HYDROData_Object
22 typedef gp_XYZ ProfilePoint;
23 typedef NCollection_Sequence<ProfilePoint> ProfilePoints;
27 * Enumeration of tags corresponding to the persistent object parameters.
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
39 DEFINE_STANDARD_RTTI(HYDROData_Profile);
42 * Returns the kind of this object. Must be redefined in all objects of known type.
44 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_PROFILE; }
47 * Dump object to Python script representation.
49 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
52 * Returns the top shape of the object.
54 HYDRODATA_EXPORT virtual TopoDS_Shape GetTopShape() const;
57 * Returns the 3d shape of the object.
59 HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
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.
66 HYDRODATA_EXPORT virtual void Update();
68 HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
71 * Returns default filling color for new profile.
73 HYDRODATA_EXPORT static QColor DefaultFillingColor();
76 * Returns default border color for new profile.
78 HYDRODATA_EXPORT static QColor DefaultBorderColor();
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
89 HYDRODATA_EXPORT bool IsValid() const;
92 * Invalidate profile first and last points.
94 HYDRODATA_EXPORT void Invalidate();
98 // Public methods to work with profile points.
101 * Set first(left) point for profile.
102 * \param thePoint the point
104 HYDRODATA_EXPORT void SetLeftPoint( const gp_XY& thePoint, bool IsConvertFromGlobal = false );
107 * Returns first(left) point of profile.
108 * \param thePoint[out] profile first point
109 * \return true if point has been set
111 HYDRODATA_EXPORT bool GetLeftPoint( gp_XY& thePoint, bool IsConvertToGlobal = false ) const;
114 * Set last(right) point for profile.
115 * \param thePoint the point
117 HYDRODATA_EXPORT void SetRightPoint( const gp_XY& thePoint, bool IsConvertFromGlobal = false );
120 * Returns last(right) point of profile.
121 * \param thePoint[out] profile last point
122 * \return true if point has been set
124 HYDRODATA_EXPORT bool GetRightPoint( gp_XY& thePoint, bool IsConvertToGlobal = false ) const;
128 * Returns object which store parametric presentation of profile points.
129 * \return profile U,Z
131 HYDRODATA_EXPORT Handle(HYDROData_ProfileUZ) GetProfileUZ( const bool theIsCreate = true ) const;
135 * Return number of profile points.
136 * \return number of points
138 HYDRODATA_EXPORT int NbPoints() const;
141 * Remove all profile points.
143 HYDRODATA_EXPORT void RemovePoints();
147 * Replace current profile parametric points by new one.
148 * \param thePoints the list with new points in parametric form
150 HYDRODATA_EXPORT void SetParametricPoints( const HYDROData_ProfileUZ::PointsList& thePoints );
153 * Returns profile points in parametric form.
154 * \return points list
156 HYDRODATA_EXPORT HYDROData_ProfileUZ::PointsList GetParametricPoints() const;
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
164 HYDRODATA_EXPORT void SetProfilePoints( const ProfilePoints& thePoints, bool IsConvertFromGlobal = true );
167 * Returns profile points.
168 * Empty sequence is returned if first or last point was not set.
169 * \return profile points list
171 HYDRODATA_EXPORT ProfilePoints GetProfilePoints( bool IsConvertToGlobal = false ) const;
174 // Public methods to work with files.
177 * Stores the profile file path
178 * \param theFilePath profile file path
180 HYDRODATA_EXPORT void SetFilePath( const TCollection_AsciiString& theFilePath );
183 * Returns uploaded profile file path
185 HYDRODATA_EXPORT TCollection_AsciiString GetFilePath() const;
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
195 HYDRODATA_EXPORT static int ImportFromFile( const Handle(HYDROData_Document)& theDoc,
196 const TCollection_AsciiString& theFileName,
197 NCollection_Sequence<int>& theBadProfilesIds );
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
205 HYDRODATA_EXPORT virtual bool ImportFromFile( const TCollection_AsciiString& theFileName,
206 bool* theIsRead = 0 );
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
214 HYDRODATA_EXPORT virtual bool ImportFromFile( OSD_File& theFile,
215 bool* theIsRead = 0 );
220 * Returns default filling color for new object.
222 HYDRODATA_EXPORT virtual QColor getDefaultFillingColor() const;
225 * Returns default border color for new object.
227 HYDRODATA_EXPORT virtual QColor getDefaultBorderColor() const;
230 * Checks and if necessary create child 3D object.
231 * Reimplemented to prevent creation of 3D child object.
233 HYDRODATA_EXPORT virtual void checkAndSetObject3D() {}
238 friend class HYDROData_Iterator;
241 * Creates new object in the internal data structure. Use higher level objects
242 * to create objects with real content.
244 HYDRODATA_EXPORT HYDROData_Profile();
247 * Destructs properties of the object and object itself, removes it from the document.
249 HYDRODATA_EXPORT ~HYDROData_Profile();