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_PolylineXY_HeaderFile
20 #define HYDROData_PolylineXY_HeaderFile
22 #include "HYDROData_IPolyline.h"
24 DEFINE_STANDARD_HANDLE(HYDROData_PolylineXY, HYDROData_IPolyline)
32 /**\class HYDROData_PolylineXY
33 * \brief Class that stores/retreives information about the
34 * parametric profile points.
36 class HYDROData_PolylineXY : public HYDROData_IPolyline
40 * Enumeration of tags corresponding to the persistent object parameters.
44 DataTag_First = HYDROData_IPolyline::DataTag_First + 100, ///< first tag, to reserve
45 DataTag_GeomObjectEntry, ///< study entry of the imported GEOM object
49 DEFINE_STANDARD_RTTI(HYDROData_PolylineXY);
53 * Returns the kind of this object. Must be redefined in all objects of known type.
55 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_POLYLINEXY;}
58 * Dump object to Python script representation.
60 HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
61 MapOfTreatedObjects& theTreatedObjects ) const;
64 * Update the wire contour on the basis of the polyline data.
65 * Call this method whenever you made changes for polyline data.
67 HYDRODATA_EXPORT virtual void Update();
69 HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
72 * Checks that object has 2D presentation. Reimlemented to retun true.
74 HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
77 * Returns data of object wrapped to QVariant.
78 * Reimplemented to wrap and return saved path.
80 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
83 * Returns default wire color for new polyline.
85 HYDRODATA_EXPORT static QColor DefaultWireColor();
87 HYDRODATA_EXPORT bool IsCustom() const;
88 HYDRODATA_EXPORT bool GetIsInCustomFlag() const;
89 HYDRODATA_EXPORT void SetIsInCustomFlag( bool theValue );
94 * Returns the presentation of polyline section in CAS maner.
96 HYDRODATA_EXPORT static TopoDS_Wire BuildWire( const SectionType& theType,
97 const bool& theIsClosed,
98 const NCollection_Sequence<gp_XYZ>& thePoints );
101 * Returns the presentation of polyline section in Qt maner.
103 HYDRODATA_EXPORT static void BuildPainterPath( QPainterPath& thePath,
104 const SectionType& theType,
105 const bool& theIsClosed,
106 const NCollection_Sequence<gp_XYZ>& thePoints );
111 * Imports shape from IOR.
112 * \param theIOR the IOR of Geom object
113 * \return \c true if shape has been successfully imported
115 HYDRODATA_EXPORT virtual bool ImportFromGeomIOR( const TCollection_AsciiString& theIOR );
118 * Stores the study entry of the imported GEOM object.
119 * \param theEntry GEOM object entry
121 HYDRODATA_EXPORT void SetGeomObjectEntry( const TCollection_AsciiString& theEntry );
124 * Returns the imported GEOM object entry.
126 HYDRODATA_EXPORT TCollection_AsciiString GetGeomObjectEntry() const;
131 * Returns the 3D presentation of all points.
133 HYDRODATA_EXPORT virtual bool ImportShape( const TopoDS_Shape& theShape,
134 bool IsInterpolationAllowed = false,
135 double theDeviation = 1E-3 );
138 * Returns flag indicating that polyline can be edited or not.
140 HYDRODATA_EXPORT virtual bool IsEditable() const;
144 * Returns true if polyline is closed
145 * \param theIsSimpleCheck flag indicating the type of checking
146 * - if true then all wires checked on closures
147 * - if false then for positive result polyline should consist of
148 * only one wire and which must be closed
150 HYDRODATA_EXPORT bool IsClosed( const bool theIsSimpleCheck = true ) const;
153 * Returns the distance beetwen first and point with index thePointIndex
154 * at the section with index theSectionIndex. -1 is returned if error is occurred.
156 HYDRODATA_EXPORT double GetDistance( const int theSectionIndex,
157 const int thePointIndex ) const;
161 * Returns number of sections.
163 HYDRODATA_EXPORT virtual int NbSections() const;
166 * Adds new one section.
167 * \param theSectName name of the section
168 * \param theSectionType type of section
169 * \param theIsClosed flag indicates closures of section
171 HYDRODATA_EXPORT virtual void AddSection( const TCollection_AsciiString& theSectName,
172 const SectionType theSectionType,
173 const bool theIsClosed );
176 * Returns name of section with given index.
177 * \param theSectionIndex index of section
179 HYDRODATA_EXPORT virtual TCollection_AsciiString GetSectionName( const int theSectionIndex ) const;
182 * Set name for section with given index.
183 * \param theSectionIndex index of section
184 * \param theSectionName new section name
186 HYDRODATA_EXPORT virtual void SetSectionName( const int theSectionIndex,
187 const TCollection_AsciiString& theSectionName );
190 * Returns type of section with given index.
191 * \param theSectionIndex index of section
193 HYDRODATA_EXPORT virtual SectionType GetSectionType( const int theSectionIndex ) const;
196 * Set type for section with given index.
197 * \param theSectionIndex index of section
198 * \param theSectionType new section type
200 HYDRODATA_EXPORT virtual void SetSectionType( const int theSectionIndex,
201 const SectionType theSectionType );
204 * Returns true if section with given index is closed.
205 * \param theSectionIndex index of section
207 HYDRODATA_EXPORT virtual bool IsClosedSection( const int theSectionIndex ) const;
210 * Set closed flag for section with given index.
211 * \param theSectionIndex index of section
212 * \param theIsClosed new closures state
214 HYDRODATA_EXPORT virtual void SetSectionClosed( const int theSectionIndex,
215 const bool theIsClosed );
218 * Adds new one section.
219 * \param theSectName name of the section
220 * \param theSectionType type of section
221 * \param theIsClosed flag indicates closures of section
223 HYDRODATA_EXPORT virtual void GetSections( NCollection_Sequence<TCollection_AsciiString>& theSectNames,
224 NCollection_Sequence<SectionType>& theSectTypes,
225 NCollection_Sequence<bool>& theSectClosures ) const;
228 * Removes section with given index.
229 * \param theSectionIndex index of section
231 HYDRODATA_EXPORT virtual void RemoveSection( const int theSectionIndex );
234 * Removes all sections.
236 HYDRODATA_EXPORT virtual void RemoveSections();
240 * Adds new point for section with index "theSectionIndex".
241 * \param theSectionIndex index of section
242 * \param thePoint point to add
243 * \param theBeforeIndex if not equal -1 then insert point in this pos
245 HYDRODATA_EXPORT virtual void AddPoint( const int theSectionIndex,
246 const Point& thePoint,
247 const int thePointIndex = -1 );
250 * Replaces point for section with index "theSectionIndex".
251 * \param theSectionIndex index of section
252 * \param thePoint new point
253 * \param thePointIndex index of point to replace
255 HYDRODATA_EXPORT virtual void SetPoint( const int theSectionIndex,
256 const Point& thePoint,
257 const int thePointIndex );
260 * Replaces point for section with index "theSectionIndex".
261 * \param theSectionIndex index of section
262 * \param thePoints new points
264 HYDRODATA_EXPORT virtual void SetPoints( const int theSectionIndex,
265 const PointsList& thePoints );
268 * Removes point from section with index "theSectionIndex".
269 * \param theSectionIndex index of section
270 * \param thePointIndex index of point
272 HYDRODATA_EXPORT virtual void RemovePoint( const int theSectionIndex,
273 const int thePointIndex );
277 * Returns list of points.
278 * \param theSectionIndex if not equal -1 then list of points returned
279 * only for section with this index
280 * \return list of points
282 HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1, bool IsConvertToGlobal = false ) const;
286 * Returns the painter path.
287 * Note: currently only the first section of the polyline data is taken into account.
288 * \return polyline painter path.
290 HYDRODATA_EXPORT virtual QPainterPath GetPainterPath() const;
293 * Transform the polyline points.
294 * @param theTrsf the transformation
296 HYDRODATA_EXPORT void Transform( const QTransform& theTrsf );
301 * Sets the flag indicating that polyline can be edited or not.
303 HYDRODATA_EXPORT virtual void setEditable( const bool theIsEditable );
305 HYDRODATA_EXPORT void Interpolate();
309 friend class HYDROData_Profile;
310 friend class HYDROData_Iterator;
313 * Creates new object in the internal data structure. Use higher level objects
314 * to create objects with real content.
316 HYDRODATA_EXPORT HYDROData_PolylineXY();
319 * Destructs properties of the object and object itself, removes it from the document.
321 HYDRODATA_EXPORT ~HYDROData_PolylineXY();
324 bool myIsInCustomFlag;