1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #ifndef HYDROData_Profile_HeaderFile
20 #define HYDROData_Profile_HeaderFile
22 #include "HYDROData_Object.h"
23 #include "HYDROData_ProfileUZ.h"
27 class HYDROData_Document;
29 /**\class HYDROData_Profile
30 * \brief Class that stores/retreives information about the profile.
32 class HYDROData_Profile : public HYDROData_Object
36 typedef gp_XYZ ProfilePoint;
37 typedef NCollection_Sequence<ProfilePoint> ProfilePoints;
41 * Enumeration of tags corresponding to the persistent object parameters.
45 DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
46 DataTag_FirstPoint, ///< first(left) point
47 DataTag_LastPoint, ///< last(right) point
48 DataTag_ChildProfileUZ, ///< child parametric profile
49 DataTag_FilePath, ///< profile imported file path
50 DataTag_ProfileColor ///< color of profile
54 DEFINE_STANDARD_RTTIEXT(HYDROData_Profile, HYDROData_Object);
57 * Returns the kind of this object. Must be redefined in all objects of known type.
59 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_PROFILE; }
62 * Dump object to Python script representation.
64 HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
65 MapOfTreatedObjects& theTreatedObjects ) const;
68 * Returns the top shape of the object.
70 HYDRODATA_EXPORT virtual TopoDS_Shape GetTopShape() const;
73 * Returns the 3d shape of the object.
75 HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
78 * Updates profile 3D presentation.
79 * Call this method whenever you made changes in data structure.
80 * This method does not called automatically since it may take a very long time.
82 HYDRODATA_EXPORT virtual void Update();
84 HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
87 * Returns default filling color for new profile.
89 HYDRODATA_EXPORT virtual QColor DefaultFillingColor() const;
92 * Returns default border color for new profile.
94 HYDRODATA_EXPORT virtual QColor DefaultBorderColor() const;
100 * Check profile data and returns true if profile is valid.
101 * Validity is determined by:
102 * - First(left) and Last(right) point was set
103 * - Parametric points size is more than 1
105 HYDRODATA_EXPORT bool IsValid() const;
108 * Invalidate profile first and last points.
110 HYDRODATA_EXPORT void Invalidate();
114 // Public methods to work with profile points.
117 * Set first(left) point for profile.
118 * \param thePoint the point
120 HYDRODATA_EXPORT void SetLeftPoint( const gp_XY& thePoint, bool IsConvertFromGlobal = false );
123 * Returns first(left) point of profile.
124 * \param thePoint[out] profile first point
125 * \return true if point has been set
127 HYDRODATA_EXPORT bool GetLeftPoint( gp_XY& thePoint, bool IsConvertToGlobal = false,
128 bool CanUseDefault = false ) const;
131 * Set last(right) point for profile.
132 * \param thePoint the point
134 HYDRODATA_EXPORT void SetRightPoint( const gp_XY& thePoint, bool IsConvertFromGlobal = false );
137 * Returns last(right) point of profile.
138 * \param thePoint[out] profile last point
139 * \return true if point has been set
141 HYDRODATA_EXPORT bool GetRightPoint( gp_XY& thePoint, bool IsConvertToGlobal = false,
142 bool CanUseDefault = false ) const;
145 * Returns object which store parametric presentation of profile points.
146 * \return profile U,Z
148 HYDRODATA_EXPORT Handle(HYDROData_ProfileUZ) GetProfileUZ( const bool theIsCreate = true ) const;
152 * Return number of profile points.
153 * \return number of points
155 HYDRODATA_EXPORT int NbPoints() const;
158 * Remove all profile points.
160 HYDRODATA_EXPORT void RemovePoints();
164 * Replace current profile parametric points by new one.
165 * \param thePoints the list with new points in parametric form
167 HYDRODATA_EXPORT void SetParametricPoints( const HYDROData_ProfileUZ::PointsList& thePoints );
170 * Returns profile points in parametric form.
171 * \return points list
173 HYDRODATA_EXPORT HYDROData_ProfileUZ::PointsList GetParametricPoints() const;
177 * Replace current profile points by new one.
178 * First and last points will be automatically updated.
179 * \param thePoints the list with new profile points
181 HYDRODATA_EXPORT void SetProfilePoints( const ProfilePoints& thePoints, bool IsConvertFromGlobal = true );
184 * Returns profile points.
185 * Empty sequence is returned if first or last point was not set.
186 * \return profile points list
188 HYDRODATA_EXPORT ProfilePoints GetProfilePoints( bool IsConvertToGlobal = false,
189 bool CanUseDefaultLeftRight = false ) const;
193 * Return profile point with minimal Z value.
194 * \return non-parametric profile point
196 HYDRODATA_EXPORT ProfilePoint GetBottomPoint(bool IsConvertToGlobal = false) const;
199 * Return profile middle point.
200 * \return non-parametric profile point
202 HYDRODATA_EXPORT ProfilePoint GetMiddlePoint( bool CanUseDefault ) const;
205 // Public methods to work with files.
208 * Stores the profile file path
209 * \param theFilePath profile file path
211 HYDRODATA_EXPORT void SetFilePath( const TCollection_AsciiString& theFilePath );
214 * Returns uploaded profile file path
216 HYDRODATA_EXPORT TCollection_AsciiString GetFilePath() const;
219 HYDRODATA_EXPORT void SetProfileColor( const QColor& theColor );
221 HYDRODATA_EXPORT bool GetProfileColor(QColor&) const;
225 * Imports Profile data from file. The supported file types:
226 * - parametric presentation of profile (2 points in line U,Z)
227 * - georeferenced presentation of profile (3 points in line X,Y,Z)
228 * Create as many objects as many profiles in the file are defined.
229 * \param theFileName the path to file
230 * \return \c number of successfully imported profiles
232 HYDRODATA_EXPORT static int ImportFromFile( const Handle(HYDROData_Document)& theDoc,
233 const TCollection_AsciiString& theFileName,
234 NCollection_Sequence<int>& theBadProfilesIds,
235 bool isToProject = true );
238 * Imports Profile data from file.
239 * \param theFileName the path to file
240 * \param theIsRead set to true if at least one non empty string was read from file
241 * \return \c true if file has been successfully read
243 HYDRODATA_EXPORT virtual bool ImportFromFile( const TCollection_AsciiString& theFileName,
244 bool isToProject = true,
245 bool* isNotEmpty = 0 );
248 * Imports Profile data from file.
249 * \param theFile file to read
250 * \param theIsRead set to true if at least one non empty string was read from file
251 * \return \c true if file has been successfully read
253 HYDRODATA_EXPORT virtual bool ImportFromFile( OSD_File& theFile,
254 bool isToProject = true,
255 bool* isNotEmpty = 0 );
259 * Checks and if necessary create child 3D object.
260 * Reimplemented to prevent creation of 3D child object.
262 HYDRODATA_EXPORT virtual void checkAndSetObject3D() {}
264 TopoDS_Shape CreateProfileWire( bool canUseDefaultPoints ) const;
266 static void ProjectProfilePoints( ProfilePoints& thePoints );
270 friend class HYDROData_Iterator;
273 * Creates new object in the internal data structure. Use higher level objects
274 * to create objects with real content.
276 HYDRODATA_EXPORT HYDROData_Profile();
279 * Destructs properties of the object and object itself, removes it from the document.
281 HYDRODATA_EXPORT ~HYDROData_Profile();