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>
25 DEFINE_STANDARD_HANDLE(HYDROData_PolylineXY, HYDROData_IPolyline)
33 /**\class HYDROData_PolylineXY
34 * \brief Class that stores/retrieves information about the
35 * parametric profile points.
37 class HYDROData_PolylineXY : public HYDROData_IPolyline
41 * Enumeration of tags corresponding to the persistent object parameters.
45 DataTag_First = HYDROData_IPolyline::DataTag_First + 100, ///< first tag, to reserve
46 DataTag_GeomObjectEntry, ///< study entry of the imported GEOM object
50 DEFINE_STANDARD_RTTI(HYDROData_PolylineXY);
54 * Returns the kind of this object. Must be redefined in all objects of known type.
56 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_POLYLINEXY;}
59 * Dump object to Python script representation.
61 HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
62 MapOfTreatedObjects& theTreatedObjects ) const;
65 * Update the wire contour on the basis of the polyline data.
66 * Call this method whenever you made changes for polyline data.
68 HYDRODATA_EXPORT virtual void Update();
70 HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
73 * Checks that object has 2D presentation. Re-implemented to return true.
75 HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
78 * Returns data of object wrapped to QVariant.
79 * Re-implemented to wrap and return saved path.
81 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
84 * Returns default wire color for new polyline.
86 HYDRODATA_EXPORT static QColor DefaultWireColor();
88 HYDRODATA_EXPORT bool IsCustom() const;
89 HYDRODATA_EXPORT bool GetIsInCustomFlag() const;
90 HYDRODATA_EXPORT void SetIsInCustomFlag( bool theValue );
95 * Returns the presentation of polyline section in CAS manner.
97 HYDRODATA_EXPORT static TopoDS_Wire BuildWire( const SectionType& theType,
98 const bool& theIsClosed,
99 const NCollection_Sequence<gp_XYZ>& thePoints );
102 * Returns the presentation of polyline section in Qt manner.
104 HYDRODATA_EXPORT static void BuildPainterPath( QPainterPath& thePath,
105 const SectionType& theType,
106 const bool& theIsClosed,
107 const NCollection_Sequence<gp_XYZ>& thePoints );
112 * Imports shape from IOR.
113 * \param theIOR the IOR of Geom object
114 * \return \c true if shape has been successfully imported
116 HYDRODATA_EXPORT virtual bool ImportFromGeomIOR( const TCollection_AsciiString& theIOR );
119 * Stores the study entry of the imported GEOM object.
120 * \param theEntry GEOM object entry
122 HYDRODATA_EXPORT void SetGeomObjectEntry( const TCollection_AsciiString& theEntry );
125 * Returns the imported GEOM object entry.
127 HYDRODATA_EXPORT TCollection_AsciiString GetGeomObjectEntry() const;
132 * Returns the 3D presentation of all points.
134 HYDRODATA_EXPORT virtual bool ImportShape( const TopoDS_Shape& theShape,
135 bool IsInterpolationAllowed,
136 const Handle( HYDROData_PolylineXY )& theOldPolyline,
137 bool IsClosureAllowed = true,
138 double theDeviation = 1.);
141 * Returns flag indicating that polyline can be edited or not.
143 HYDRODATA_EXPORT virtual bool IsEditable() const;
147 * Returns true if polyline is closed
148 * \param theIsSimpleCheck flag indicating the type of checking
149 * - if true then all wires checked on closures
150 * - if false then for positive result polyline should consist of
151 * only one wire and which must be closed
153 HYDRODATA_EXPORT bool IsClosed( const bool theIsSimpleCheck = true ) const;
156 * Returns connected wires and their number, by rebuild of the wires from the edges, looking for connections
158 HYDRODATA_EXPORT int GetNbConnectedWires(Handle(TopTools_HSequenceOfShape)& aConnectedWires) const;
161 * Returns the distance between first and point with index thePointIndex
162 * at the section with index theSectionIndex. -1 is returned if error is occurred.
164 HYDRODATA_EXPORT double GetDistance( const int theSectionIndex,
165 const int thePointIndex ) const;
168 * Returns number of sections.
170 HYDRODATA_EXPORT virtual int NbSections() const;
173 * Adds new one section.
174 * \param theSectName name of the section
175 * \param theSectionType type of section
176 * \param theIsClosed flag indicates closures of section
178 HYDRODATA_EXPORT virtual void AddSection( const TCollection_AsciiString& theSectName,
179 const SectionType theSectionType,
180 const bool theIsClosed );
183 * Returns name of section with given index.
184 * \param theSectionIndex index of section
186 HYDRODATA_EXPORT virtual TCollection_AsciiString GetSectionName( const int theSectionIndex ) const;
189 * Set name for section with given index.
190 * \param theSectionIndex index of section
191 * \param theSectionName new section name
193 HYDRODATA_EXPORT virtual void SetSectionName( const int theSectionIndex,
194 const TCollection_AsciiString& theSectionName );
197 * Returns type of section with given index.
198 * \param theSectionIndex index of section
200 HYDRODATA_EXPORT virtual SectionType GetSectionType( const int theSectionIndex ) const;
203 * Set type for section with given index.
204 * \param theSectionIndex index of section
205 * \param theSectionType new section type
207 HYDRODATA_EXPORT virtual void SetSectionType( const int theSectionIndex,
208 const SectionType theSectionType );
211 * Returns true if section with given index is closed.
212 * \param theSectionIndex index of section
214 HYDRODATA_EXPORT virtual bool IsClosedSection( const int theSectionIndex ) const;
217 * Set closed flag for section with given index.
218 * \param theSectionIndex index of section
219 * \param theIsClosed new closures state
221 HYDRODATA_EXPORT virtual void SetSectionClosed( const int theSectionIndex,
222 const bool theIsClosed );
225 * Adds new one section.
226 * \param theSectName name of the section
227 * \param theSectionType type of section
228 * \param theIsClosed flag indicates closures of section
230 HYDRODATA_EXPORT virtual void GetSections( NCollection_Sequence<TCollection_AsciiString>& theSectNames,
231 NCollection_Sequence<SectionType>& theSectTypes,
232 NCollection_Sequence<bool>& theSectClosures ) const;
235 * Removes section with given index.
236 * \param theSectionIndex index of section
238 HYDRODATA_EXPORT virtual void RemoveSection( const int theSectionIndex );
241 * Removes all sections.
243 HYDRODATA_EXPORT virtual void RemoveSections();
247 * Adds new point for section with index "theSectionIndex".
248 * \param theSectionIndex index of section
249 * \param thePoint point to add
250 * \param theBeforeIndex if not equal -1 then insert point in this pos
252 HYDRODATA_EXPORT virtual void AddPoint( const int theSectionIndex,
253 const Point& thePoint,
254 const int thePointIndex = -1 );
257 * Replaces point for section with index "theSectionIndex".
258 * \param theSectionIndex index of section
259 * \param thePoint new point
260 * \param thePointIndex index of point to replace
262 HYDRODATA_EXPORT virtual void SetPoint( const int theSectionIndex,
263 const Point& thePoint,
264 const int thePointIndex );
267 * Replaces point for section with index "theSectionIndex".
268 * \param theSectionIndex index of section
269 * \param thePoints new points
271 HYDRODATA_EXPORT virtual void SetPoints( const int theSectionIndex,
272 const PointsList& thePoints );
275 * Removes point from section with index "theSectionIndex".
276 * \param theSectionIndex index of section
277 * \param thePointIndex index of point
279 HYDRODATA_EXPORT virtual void RemovePoint( const int theSectionIndex,
280 const int thePointIndex );
284 * Returns list of points.
285 * \param theSectionIndex if not equal -1 then list of points returned
286 * only for section with this index
287 * \return list of points
289 HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1, bool IsConvertToGlobal = false ) const;
293 * Returns the painter path.
294 * Note: currently only the first section of the polyline data is taken into account.
295 * \return polyline painter path.
297 HYDRODATA_EXPORT virtual QPainterPath GetPainterPath() const;
300 * Transform the polyline points.
301 * @param theTrsf the transformation
303 HYDRODATA_EXPORT void Transform( const QTransform& theTrsf );
308 * Sets the flag indicating that polyline can be edited or not.
310 HYDRODATA_EXPORT virtual void setEditable( const bool theIsEditable );
312 HYDRODATA_EXPORT void Interpolate();
316 friend class HYDROData_Profile;
317 friend class HYDROData_Iterator;
320 * Creates new object in the internal data structure. Use higher level objects
321 * to create objects with real content.
323 HYDRODATA_EXPORT HYDROData_PolylineXY();
326 * Destructs properties of the object and object itself, removes it from the document.
328 HYDRODATA_EXPORT ~HYDROData_PolylineXY();
331 bool myIsInCustomFlag;