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();
69 * Returns default filling color for new profile.
71 HYDRODATA_EXPORT static QColor DefaultFillingColor();
74 * Returns default border color for new profile.
76 HYDRODATA_EXPORT static QColor DefaultBorderColor();
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
87 HYDRODATA_EXPORT bool IsValid() const;
90 * Invalidate profile first and last points.
92 HYDRODATA_EXPORT void Invalidate();
96 // Public methods to work with profile points.
99 * Set first(left) point for profile.
100 * \param thePoint the point
102 HYDRODATA_EXPORT void SetLeftPoint( const gp_XY& thePoint );
105 * Returns first(left) point of profile.
106 * \param thePoint[out] profile first point
107 * \return true if point has been set
109 HYDRODATA_EXPORT bool GetLeftPoint( gp_XY& thePoint ) const;
112 * Set last(right) point for profile.
113 * \param thePoint the point
115 HYDRODATA_EXPORT void SetRightPoint( const gp_XY& thePoint );
118 * Returns last(right) point of profile.
119 * \param thePoint[out] profile last point
120 * \return true if point has been set
122 HYDRODATA_EXPORT bool GetRightPoint( gp_XY& thePoint ) const;
126 * Returns object which store parametric presentation of profile points.
127 * \return profile U,Z
129 HYDRODATA_EXPORT Handle(HYDROData_ProfileUZ) GetProfileUZ( const bool theIsCreate = true ) const;
133 * Return number of profile points.
134 * \return number of points
136 HYDRODATA_EXPORT int NbPoints() const;
139 * Remove all profile points.
141 HYDRODATA_EXPORT void RemovePoints();
145 * Replace current profile parametric points by new one.
146 * \param thePoints the list with new points in parametric form
148 HYDRODATA_EXPORT void SetParametricPoints( const HYDROData_ProfileUZ::PointsList& thePoints );
151 * Returns profile points in parametric form.
152 * \return points list
154 HYDRODATA_EXPORT HYDROData_ProfileUZ::PointsList GetParametricPoints() const;
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
162 HYDRODATA_EXPORT void SetProfilePoints( const ProfilePoints& thePoints );
165 * Returns profile points.
166 * Empty sequence is returned if first or last point was not set.
167 * \return profile points list
169 HYDRODATA_EXPORT ProfilePoints GetProfilePoints() const;
173 // Public methods to work with files.
176 * Stores the profile file path
177 * \param theFilePath profile file path
179 HYDRODATA_EXPORT void SetFilePath( const TCollection_AsciiString& theFilePath );
182 * Returns uploaded profile file path
184 HYDRODATA_EXPORT TCollection_AsciiString GetFilePath() const;
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
194 HYDRODATA_EXPORT static int ImportFromFile( const Handle(HYDROData_Document)& theDoc,
195 const TCollection_AsciiString& theFileName,
196 NCollection_Sequence<int>& theBadProfilesIds );
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
204 HYDRODATA_EXPORT virtual bool ImportFromFile( const TCollection_AsciiString& theFileName,
205 bool* theIsRead = 0 );
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
213 HYDRODATA_EXPORT virtual bool ImportFromFile( OSD_File& theFile,
214 bool* theIsRead = 0 );
219 * Returns default filling color for new object.
221 HYDRODATA_EXPORT virtual QColor getDefaultFillingColor() const;
224 * Returns default border color for new object.
226 HYDRODATA_EXPORT virtual QColor getDefaultBorderColor() const;
229 * Checks and if necessary create child 3D object.
230 * Reimplemented to prevent creation of 3D child object.
232 HYDRODATA_EXPORT virtual void checkAndSetObject3D() {}
237 friend class HYDROData_Iterator;
240 * Creates new object in the internal data structure. Use higher level objects
241 * to create objects with real content.
246 * Destructs properties of the object and object itself, removes it from the document.
248 ~HYDROData_Profile();