1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef HYDROData_Profile_HeaderFile
24 #define HYDROData_Profile_HeaderFile
26 #include "HYDROData_Object.h"
28 #include "HYDROData_ProfileUZ.h"
30 DEFINE_STANDARD_HANDLE(HYDROData_Profile, HYDROData_Object)
34 class Handle(HYDROData_Document);
36 /**\class HYDROData_Profile
37 * \brief Class that stores/retreives information about the profile.
39 class HYDROData_Profile : public HYDROData_Object
43 typedef gp_XYZ ProfilePoint;
44 typedef NCollection_Sequence<ProfilePoint> ProfilePoints;
48 * Enumeration of tags corresponding to the persistent object parameters.
52 DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
53 DataTag_FirstPoint, ///< first(left) point
54 DataTag_LastPoint, ///< last(right) point
55 DataTag_ChildProfileUZ, ///< child parametric profile
56 DataTag_FilePath ///< profile imported file path
60 DEFINE_STANDARD_RTTI(HYDROData_Profile);
63 * Returns the kind of this object. Must be redefined in all objects of known type.
65 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_PROFILE; }
68 * Dump object to Python script representation.
70 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
73 * Returns the top shape of the object.
75 HYDRODATA_EXPORT virtual TopoDS_Shape GetTopShape() const;
78 * Returns the 3d shape of the object.
80 HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
83 * Updates profile 3D presentation.
84 * Call this method whenever you made changes in data structure.
85 * This method does not called automatically since it may take a very long time.
87 HYDRODATA_EXPORT virtual void Update();
89 HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
92 * Returns default filling color for new profile.
94 HYDRODATA_EXPORT static QColor DefaultFillingColor();
97 * Returns default border color for new profile.
99 HYDRODATA_EXPORT static QColor DefaultBorderColor();
105 * Check profile data and returns true if profile is valid.
106 * Validity is determined by:
107 * - First(left) and Last(right) point was set
108 * - Parametric points size is more than 1
110 HYDRODATA_EXPORT bool IsValid() const;
113 * Invalidate profile first and last points.
115 HYDRODATA_EXPORT void Invalidate();
119 // Public methods to work with profile points.
122 * Set first(left) point for profile.
123 * \param thePoint the point
125 HYDRODATA_EXPORT void SetLeftPoint( const gp_XY& thePoint, bool IsConvertFromGlobal = false );
128 * Returns first(left) point of profile.
129 * \param thePoint[out] profile first point
130 * \return true if point has been set
132 HYDRODATA_EXPORT bool GetLeftPoint( gp_XY& thePoint, bool IsConvertToGlobal = false ) const;
135 * Set last(right) point for profile.
136 * \param thePoint the point
138 HYDRODATA_EXPORT void SetRightPoint( const gp_XY& thePoint, bool IsConvertFromGlobal = false );
141 * Returns last(right) point of profile.
142 * \param thePoint[out] profile last point
143 * \return true if point has been set
145 HYDRODATA_EXPORT bool GetRightPoint( gp_XY& thePoint, bool IsConvertToGlobal = false ) const;
149 * Returns object which store parametric presentation of profile points.
150 * \return profile U,Z
152 HYDRODATA_EXPORT Handle(HYDROData_ProfileUZ) GetProfileUZ( const bool theIsCreate = true ) const;
156 * Return number of profile points.
157 * \return number of points
159 HYDRODATA_EXPORT int NbPoints() const;
162 * Remove all profile points.
164 HYDRODATA_EXPORT void RemovePoints();
168 * Replace current profile parametric points by new one.
169 * \param thePoints the list with new points in parametric form
171 HYDRODATA_EXPORT void SetParametricPoints( const HYDROData_ProfileUZ::PointsList& thePoints );
174 * Returns profile points in parametric form.
175 * \return points list
177 HYDRODATA_EXPORT HYDROData_ProfileUZ::PointsList GetParametricPoints() const;
181 * Replace current profile points by new one.
182 * First and last points will be automatically updated.
183 * \param thePoints the list with new profile points
185 HYDRODATA_EXPORT void SetProfilePoints( const ProfilePoints& thePoints, bool IsConvertFromGlobal = true );
188 * Returns profile points.
189 * Empty sequence is returned if first or last point was not set.
190 * \return profile points list
192 HYDRODATA_EXPORT ProfilePoints GetProfilePoints( bool IsConvertToGlobal = false ) const;
196 * Return profile point with minimal Z value.
197 * \return non-parametric profile point
199 HYDRODATA_EXPORT ProfilePoint GetBottomPoint() const;
202 // Public methods to work with files.
205 * Stores the profile file path
206 * \param theFilePath profile file path
208 HYDRODATA_EXPORT void SetFilePath( const TCollection_AsciiString& theFilePath );
211 * Returns uploaded profile file path
213 HYDRODATA_EXPORT TCollection_AsciiString GetFilePath() const;
216 * Imports Profile data from file. The supported file types:
217 * - parametric presentation of profile (2 points in line U,Z)
218 * - georeferenced presentation of profile (3 points in line X,Y,Z)
219 * Create as many objects as many profiles in the file are defined.
220 * \param theFileName the path to file
221 * \return \c number of successfully imported profiles
223 HYDRODATA_EXPORT static int ImportFromFile( const Handle(HYDROData_Document)& theDoc,
224 const TCollection_AsciiString& theFileName,
225 NCollection_Sequence<int>& theBadProfilesIds );
228 * Imports Profile data from file.
229 * \param theFileName the path to file
230 * \param theIsRead set to true if at least one non empty string was read from file
231 * \return \c true if file has been successfully read
233 HYDRODATA_EXPORT virtual bool ImportFromFile( const TCollection_AsciiString& theFileName,
234 bool* theIsRead = 0 );
237 * Imports Profile data from file.
238 * \param theFile file to read
239 * \param theIsRead set to true if at least one non empty string was read from file
240 * \return \c true if file has been successfully read
242 HYDRODATA_EXPORT virtual bool ImportFromFile( OSD_File& theFile,
243 bool* theIsRead = 0 );
248 * Returns default filling color for new object.
250 HYDRODATA_EXPORT virtual QColor getDefaultFillingColor() const;
253 * Returns default border color for new object.
255 HYDRODATA_EXPORT virtual QColor getDefaultBorderColor() const;
258 * Checks and if necessary create child 3D object.
259 * Reimplemented to prevent creation of 3D child object.
261 HYDRODATA_EXPORT virtual void checkAndSetObject3D() {}
266 friend class HYDROData_Iterator;
269 * Creates new object in the internal data structure. Use higher level objects
270 * to create objects with real content.
272 HYDRODATA_EXPORT HYDROData_Profile();
275 * Destructs properties of the object and object itself, removes it from the document.
277 HYDRODATA_EXPORT ~HYDROData_Profile();