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"
23 #include <TopTools_HSequenceOfShape.hxx>
31 /**\class HYDROData_PolylineXY
32 * \brief Class that stores/retrieves information about the
33 * parametric profile points.
35 class HYDROData_PolylineXY : public HYDROData_IPolyline
39 * Enumeration of tags corresponding to the persistent object parameters.
43 DataTag_First = HYDROData_IPolyline::DataTag_First + 100, ///< first tag, to reserve
44 DataTag_GeomObjectEntry, ///< study entry of the imported GEOM object
48 DEFINE_STANDARD_RTTIEXT(HYDROData_PolylineXY, HYDROData_IPolyline);
52 * Returns the kind of this object. Must be redefined in all objects of known type.
54 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_POLYLINEXY;}
57 * Dump object to Python script representation.
59 HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
60 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. Re-implemented to return true.
73 HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
76 * Returns data of object wrapped to QVariant.
77 * Re-implemented 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;
87 HYDRODATA_EXPORT bool GetIsInCustomFlag() const;
88 HYDRODATA_EXPORT void SetIsInCustomFlag( bool theValue );
93 * Returns the presentation of polyline section in CAS manner.
95 HYDRODATA_EXPORT static TopoDS_Wire BuildWire( const SectionType& theType,
96 const bool& theIsClosed,
97 const NCollection_Sequence<gp_XYZ>& thePoints );
100 * Returns the presentation of polyline section in Qt manner.
102 HYDRODATA_EXPORT static void BuildPainterPath( QPainterPath& thePath,
103 const SectionType& theType,
104 const bool& theIsClosed,
105 const NCollection_Sequence<gp_XYZ>& thePoints );
110 * Imports shape from IOR.
111 * \param theIOR the IOR of Geom object
112 * \return \c true if shape has been successfully imported
114 HYDRODATA_EXPORT virtual bool ImportFromGeomIOR( const TCollection_AsciiString& theIOR );
117 * Stores the study entry of the imported GEOM object.
118 * \param theEntry GEOM object entry
120 HYDRODATA_EXPORT void SetGeomObjectEntry( const TCollection_AsciiString& theEntry );
123 * Returns the imported GEOM object entry.
125 HYDRODATA_EXPORT TCollection_AsciiString GetGeomObjectEntry() const;
130 * Returns the 3D presentation of all points.
132 HYDRODATA_EXPORT virtual bool ImportShape( const TopoDS_Shape& theShape,
133 bool IsInterpolationAllowed,
134 const Handle( HYDROData_PolylineXY )& theOldPolyline,
135 bool IsClosureAllowed = true,
136 double theDeviation = 1.);
139 * Returns flag indicating that polyline can be edited or not.
141 HYDRODATA_EXPORT virtual bool IsEditable() const;
145 * Returns true if polyline is closed
146 * \param theIsSimpleCheck flag indicating the type of checking
147 * - if true then all wires checked on closures
148 * - if false then for positive result polyline should consist of
149 * only one wire and which must be closed
151 HYDRODATA_EXPORT bool IsClosed( const bool theIsSimpleCheck = true ) const;
154 * Returns connected wires and their number, by rebuild of the wires from the edges, looking for connections
156 HYDRODATA_EXPORT int GetNbConnectedWires(Handle(TopTools_HSequenceOfShape)& aConnectedWires) const;
159 * Returns the distance between first and point with index thePointIndex
160 * at the section with index theSectionIndex. -1 is returned if error is occurred.
162 HYDRODATA_EXPORT double GetDistance( const int theSectionIndex,
163 const int thePointIndex ) const;
166 * Returns number of sections.
168 HYDRODATA_EXPORT virtual int NbSections() const;
171 * Adds new one section.
172 * \param theSectName name of the section
173 * \param theSectionType type of section
174 * \param theIsClosed flag indicates closures of section
176 HYDRODATA_EXPORT virtual void AddSection( const TCollection_AsciiString& theSectName,
177 const SectionType theSectionType,
178 const bool theIsClosed );
181 * Returns name of section with given index.
182 * \param theSectionIndex index of section
184 HYDRODATA_EXPORT virtual TCollection_AsciiString GetSectionName( const int theSectionIndex ) const;
187 * Set name for section with given index.
188 * \param theSectionIndex index of section
189 * \param theSectionName new section name
191 HYDRODATA_EXPORT virtual void SetSectionName( const int theSectionIndex,
192 const TCollection_AsciiString& theSectionName );
195 * Returns type of section with given index.
196 * \param theSectionIndex index of section
198 HYDRODATA_EXPORT virtual SectionType GetSectionType( const int theSectionIndex ) const;
201 * Set type for section with given index.
202 * \param theSectionIndex index of section
203 * \param theSectionType new section type
205 HYDRODATA_EXPORT virtual void SetSectionType( const int theSectionIndex,
206 const SectionType theSectionType );
209 * Returns true if section with given index is closed.
210 * \param theSectionIndex index of section
212 HYDRODATA_EXPORT virtual bool IsClosedSection( const int theSectionIndex ) const;
215 * Set closed flag for section with given index.
216 * \param theSectionIndex index of section
217 * \param theIsClosed new closures state
219 HYDRODATA_EXPORT virtual void SetSectionClosed( const int theSectionIndex,
220 const bool theIsClosed );
223 * Adds new one section.
224 * \param theSectName name of the section
225 * \param theSectionType type of section
226 * \param theIsClosed flag indicates closures of section
228 HYDRODATA_EXPORT virtual void GetSections( NCollection_Sequence<TCollection_AsciiString>& theSectNames,
229 NCollection_Sequence<SectionType>& theSectTypes,
230 NCollection_Sequence<bool>& theSectClosures ) const;
233 * Removes section with given index.
234 * \param theSectionIndex index of section
236 HYDRODATA_EXPORT virtual void RemoveSection( const int theSectionIndex );
239 * Removes all sections.
241 HYDRODATA_EXPORT virtual void RemoveSections();
245 * Adds new point for section with index "theSectionIndex".
246 * \param theSectionIndex index of section
247 * \param thePoint point to add
248 * \param theBeforeIndex if not equal -1 then insert point in this pos
250 HYDRODATA_EXPORT virtual void AddPoint( const int theSectionIndex,
251 const Point& thePoint,
252 const int thePointIndex = -1 );
255 * Replaces point for section with index "theSectionIndex".
256 * \param theSectionIndex index of section
257 * \param thePoint new point
258 * \param thePointIndex index of point to replace
260 HYDRODATA_EXPORT virtual void SetPoint( const int theSectionIndex,
261 const Point& thePoint,
262 const int thePointIndex );
265 * Replaces point for section with index "theSectionIndex".
266 * \param theSectionIndex index of section
267 * \param thePoints new points
269 HYDRODATA_EXPORT virtual void SetPoints( const int theSectionIndex,
270 const PointsList& thePoints );
273 * Removes point from section with index "theSectionIndex".
274 * \param theSectionIndex index of section
275 * \param thePointIndex index of point
277 HYDRODATA_EXPORT virtual void RemovePoint( const int theSectionIndex,
278 const int thePointIndex );
282 * Returns list of points.
283 * \param theSectionIndex if not equal -1 then list of points returned
284 * only for section with this index
285 * \return list of points
287 HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1, bool IsConvertToGlobal = false ) const;
291 * Returns the painter path.
292 * Note: currently only the first section of the polyline data is taken into account.
293 * \return polyline painter path.
295 HYDRODATA_EXPORT virtual QPainterPath GetPainterPath() const;
298 * Transform the polyline points.
299 * @param theTrsf the transformation
301 HYDRODATA_EXPORT void Transform( const QTransform& theTrsf );
306 * Sets the flag indicating that polyline can be edited or not.
308 HYDRODATA_EXPORT virtual void setEditable( const bool theIsEditable );
310 HYDRODATA_EXPORT void Interpolate();
314 friend class HYDROData_Profile;
315 friend class HYDROData_Iterator;
318 * Creates new object in the internal data structure. Use higher level objects
319 * to create objects with real content.
321 HYDRODATA_EXPORT HYDROData_PolylineXY();
324 * Destructs properties of the object and object itself, removes it from the document.
326 HYDRODATA_EXPORT ~HYDROData_PolylineXY();
329 bool myIsInCustomFlag;