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;
195 // Public methods to work with files.
198 * Stores the profile file path
199 * \param theFilePath profile file path
201 HYDRODATA_EXPORT void SetFilePath( const TCollection_AsciiString& theFilePath );
204 * Returns uploaded profile file path
206 HYDRODATA_EXPORT TCollection_AsciiString GetFilePath() const;
209 * Imports Profile data from file. The supported file types:
210 * - parametric presentation of profile (2 points in line U,Z)
211 * - georeferenced presentation of profile (3 points in line X,Y,Z)
212 * Create as many objects as many profiles in the file are defined.
213 * \param theFileName the path to file
214 * \return \c number of successfully imported profiles
216 HYDRODATA_EXPORT static int ImportFromFile( const Handle(HYDROData_Document)& theDoc,
217 const TCollection_AsciiString& theFileName,
218 NCollection_Sequence<int>& theBadProfilesIds );
221 * Imports Profile data from file.
222 * \param theFileName the path to file
223 * \param theIsRead set to true if at least one non empty string was read from file
224 * \return \c true if file has been successfully read
226 HYDRODATA_EXPORT virtual bool ImportFromFile( const TCollection_AsciiString& theFileName,
227 bool* theIsRead = 0 );
230 * Imports Profile data from file.
231 * \param theFile file to read
232 * \param theIsRead set to true if at least one non empty string was read from file
233 * \return \c true if file has been successfully read
235 HYDRODATA_EXPORT virtual bool ImportFromFile( OSD_File& theFile,
236 bool* theIsRead = 0 );
241 * Returns default filling color for new object.
243 HYDRODATA_EXPORT virtual QColor getDefaultFillingColor() const;
246 * Returns default border color for new object.
248 HYDRODATA_EXPORT virtual QColor getDefaultBorderColor() const;
251 * Checks and if necessary create child 3D object.
252 * Reimplemented to prevent creation of 3D child object.
254 HYDRODATA_EXPORT virtual void checkAndSetObject3D() {}
259 friend class HYDROData_Iterator;
262 * Creates new object in the internal data structure. Use higher level objects
263 * to create objects with real content.
265 HYDRODATA_EXPORT HYDROData_Profile();
268 * Destructs properties of the object and object itself, removes it from the document.
270 HYDRODATA_EXPORT ~HYDROData_Profile();