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( MapOfTreatedObjects& theTreatedObjects ) const;
63 * Update the wire contour on the basis of the polyline data.
64 * Call this method whenever you made changes for polyline data.
66 HYDRODATA_EXPORT virtual void Update();
68 HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
71 * Checks that object has 2D presentation. Reimlemented to retun true.
73 HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
76 * Returns data of object wrapped to QVariant.
77 * Reimplemented to wrap and return saved path.
79 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
82 * Returns default wire color for new polyline.
84 HYDRODATA_EXPORT static QColor DefaultWireColor();
86 HYDRODATA_EXPORT bool IsCustom() const;
91 * Returns the presentation of polyline section in CAS maner.
93 HYDRODATA_EXPORT static TopoDS_Wire BuildWire( const SectionType& theType,
94 const bool& theIsClosed,
95 const NCollection_Sequence<gp_XYZ>& thePoints );
98 * Returns the presentation of polyline section in Qt maner.
100 HYDRODATA_EXPORT static void BuildPainterPath( QPainterPath& thePath,
101 const SectionType& theType,
102 const bool& theIsClosed,
103 const NCollection_Sequence<gp_XYZ>& thePoints );
108 * Imports shape from IOR.
109 * \param theIOR the IOR of Geom object
110 * \return \c true if shape has been successfully imported
112 HYDRODATA_EXPORT virtual bool ImportFromGeomIOR( const TCollection_AsciiString& theIOR );
115 * Stores the study entry of the imported GEOM object.
116 * \param theEntry GEOM object entry
118 HYDRODATA_EXPORT void SetGeomObjectEntry( const TCollection_AsciiString& theEntry );
121 * Returns the imported GEOM object entry.
123 HYDRODATA_EXPORT TCollection_AsciiString GetGeomObjectEntry() const;
128 * Returns the 3D presentation of all points.
130 HYDRODATA_EXPORT virtual bool ImportShape( const TopoDS_Shape& theShape );
133 * Returns flag indicating that polyline can be edited or not.
135 HYDRODATA_EXPORT virtual bool IsEditable() const;
139 * Returns true if polyline is closed
140 * \param theIsSimpleCheck flag indicating the type of checking
141 * - if true then all wires checked on closures
142 * - if false then for positive result polyline should consist of
143 * only one wire and which must be closed
145 HYDRODATA_EXPORT bool IsClosed( const bool theIsSimpleCheck = true ) const;
148 * Returns the distance beetwen first and point with index thePointIndex
149 * at the section with index theSectionIndex. -1 is returned if error is occurred.
151 HYDRODATA_EXPORT double GetDistance( const int theSectionIndex,
152 const int thePointIndex ) const;
156 * Returns number of sections.
158 HYDRODATA_EXPORT virtual int NbSections() const;
161 * Adds new one section.
162 * \param theSectName name of the section
163 * \param theSectionType type of section
164 * \param theIsClosed flag indicates closures of section
166 HYDRODATA_EXPORT virtual void AddSection( const TCollection_AsciiString& theSectName,
167 const SectionType theSectionType,
168 const bool theIsClosed );
171 * Returns name of section with given index.
172 * \param theSectionIndex index of section
174 HYDRODATA_EXPORT virtual TCollection_AsciiString GetSectionName( const int theSectionIndex ) const;
177 * Set name for section with given index.
178 * \param theSectionIndex index of section
179 * \param theSectionName new section name
181 HYDRODATA_EXPORT virtual void SetSectionName( const int theSectionIndex,
182 const TCollection_AsciiString& theSectionName );
185 * Returns type of section with given index.
186 * \param theSectionIndex index of section
188 HYDRODATA_EXPORT virtual SectionType GetSectionType( const int theSectionIndex ) const;
191 * Set type for section with given index.
192 * \param theSectionIndex index of section
193 * \param theSectionType new section type
195 HYDRODATA_EXPORT virtual void SetSectionType( const int theSectionIndex,
196 const SectionType theSectionType );
199 * Returns true if section with given index is closed.
200 * \param theSectionIndex index of section
202 HYDRODATA_EXPORT virtual bool IsClosedSection( const int theSectionIndex ) const;
205 * Set closed flag for section with given index.
206 * \param theSectionIndex index of section
207 * \param theIsClosed new closures state
209 HYDRODATA_EXPORT virtual void SetSectionClosed( const int theSectionIndex,
210 const bool theIsClosed );
213 * Adds new one section.
214 * \param theSectName name of the section
215 * \param theSectionType type of section
216 * \param theIsClosed flag indicates closures of section
218 HYDRODATA_EXPORT virtual void GetSections( NCollection_Sequence<TCollection_AsciiString>& theSectNames,
219 NCollection_Sequence<SectionType>& theSectTypes,
220 NCollection_Sequence<bool>& theSectClosures ) const;
223 * Removes section with given index.
224 * \param theSectionIndex index of section
226 HYDRODATA_EXPORT virtual void RemoveSection( const int theSectionIndex );
229 * Removes all sections.
231 HYDRODATA_EXPORT virtual void RemoveSections();
235 * Adds new point for section with index "theSectionIndex".
236 * \param theSectionIndex index of section
237 * \param thePoint point to add
238 * \param theBeforeIndex if not equal -1 then insert point in this pos
240 HYDRODATA_EXPORT virtual void AddPoint( const int theSectionIndex,
241 const Point& thePoint,
242 const int thePointIndex = -1 );
245 * Replaces point for section with index "theSectionIndex".
246 * \param theSectionIndex index of section
247 * \param thePoint new point
248 * \param thePointIndex index of point to replace
250 HYDRODATA_EXPORT virtual void SetPoint( const int theSectionIndex,
251 const Point& thePoint,
252 const int thePointIndex );
255 * Replaces point for section with index "theSectionIndex".
256 * \param theSectionIndex index of section
257 * \param thePoints new points
259 HYDRODATA_EXPORT virtual void SetPoints( const int theSectionIndex,
260 const PointsList& thePoints );
263 * Removes point from section with index "theSectionIndex".
264 * \param theSectionIndex index of section
265 * \param thePointIndex index of point
267 HYDRODATA_EXPORT virtual void RemovePoint( const int theSectionIndex,
268 const int thePointIndex );
272 * Returns list of points.
273 * \param theSectionIndex if not equal -1 then list of points returned
274 * only for section with this index
275 * \return list of points
277 HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1, bool IsConvertToGlobal = false ) const;
281 * Returns the painter path.
282 * Note: currently only the first section of the polyline data is taken into account.
283 * \return polyline painter path.
285 HYDRODATA_EXPORT virtual QPainterPath GetPainterPath() const;
288 * Transform the polyline points.
289 * @param theTrsf the transformation
291 HYDRODATA_EXPORT void Transform( const QTransform& theTrsf );
296 * Sets the flag indicating that polyline can be edited or not.
298 HYDRODATA_EXPORT virtual void setEditable( const bool theIsEditable );
302 friend class HYDROData_Profile;
303 friend class HYDROData_Iterator;
306 * Creates new object in the internal data structure. Use higher level objects
307 * to create objects with real content.
309 HYDRODATA_EXPORT HYDROData_PolylineXY();
312 * Destructs properties of the object and object itself, removes it from the document.
314 HYDRODATA_EXPORT ~HYDROData_PolylineXY();