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 #include <QStringList>
32 class HYDROData_Document;
34 /**\class HYDROData_PolylineXY
35 * \brief Class that stores/retrieves information about the
36 * parametric profile points.
38 class HYDROData_PolylineXY : public HYDROData_IPolyline
42 * Enumeration of tags corresponding to the persistent object parameters.
46 DataTag_First = HYDROData_IPolyline::DataTag_First + 100, ///< first tag, to reserve
47 DataTag_GeomObjectEntry, ///< study entry of the imported GEOM object
52 DEFINE_STANDARD_RTTIEXT(HYDROData_PolylineXY, HYDROData_IPolyline);
56 * Returns the kind of this object. Must be redefined in all objects of known type.
58 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_POLYLINEXY;}
61 * Dump object to Python script representation.
63 HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
64 MapOfTreatedObjects& theTreatedObjects ) const;
67 * Update the wire contour on the basis of the polyline data.
68 * Call this method whenever you made changes for polyline data.
70 HYDRODATA_EXPORT virtual void Update();
72 HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
75 * Checks that object has 2D presentation. Re-implemented to return true.
77 HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
80 * Returns data of object wrapped to QVariant.
81 * Re-implemented to wrap and return saved path.
83 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
86 * Returns default wire color for new polyline.
88 HYDRODATA_EXPORT static QColor DefaultWireColor();
90 HYDRODATA_EXPORT bool IsCustom() const;
91 HYDRODATA_EXPORT bool GetIsInCustomFlag() const;
92 HYDRODATA_EXPORT void SetIsInCustomFlag( bool theValue );
97 * Returns the presentation of polyline section in CAS manner.
99 HYDRODATA_EXPORT static TopoDS_Wire BuildWire( const SectionType& theType,
100 const bool& theIsClosed,
101 const NCollection_Sequence<gp_XYZ>& thePoints );
104 * Returns the presentation of polyline section in Qt manner.
106 HYDRODATA_EXPORT static void BuildPainterPath( QPainterPath& thePath,
107 const SectionType& theType,
108 const bool& theIsClosed,
109 const NCollection_Sequence<gp_XYZ>& thePoints );
114 * Imports shape from IOR.
115 * \param theIOR the IOR of Geom object
116 * \return \c true if shape has been successfully imported
118 HYDRODATA_EXPORT virtual bool ImportFromGeomIOR( const TCollection_AsciiString& theIOR );
121 * Stores the study entry of the imported GEOM object.
122 * \param theEntry GEOM object entry
124 HYDRODATA_EXPORT void SetGeomObjectEntry( const TCollection_AsciiString& theEntry );
127 * Returns the imported GEOM object entry.
129 HYDRODATA_EXPORT TCollection_AsciiString GetGeomObjectEntry() const;
134 * Returns the 3D presentation of all points.
136 HYDRODATA_EXPORT virtual bool ImportShape( const TopoDS_Shape& theShape,
137 bool IsInterpolationAllowed,
138 const Handle( HYDROData_PolylineXY )& theOldPolyline,
139 bool IsClosureAllowed = true,
140 double theDeviation = 1.);
143 * Returns flag indicating that polyline can be edited or not.
145 HYDRODATA_EXPORT virtual bool IsEditable() const;
149 * Returns true if polyline is closed
150 * \param theIsSimpleCheck flag indicating the type of checking
151 * - if true then all wires checked on closures
152 * - if false then for positive result polyline should consist of
153 * only one wire and which must be closed
155 HYDRODATA_EXPORT bool IsClosed( const bool theIsSimpleCheck = true ) const;
158 * Returns connected wires and their number, by rebuild of the wires from the edges, looking for connections
160 HYDRODATA_EXPORT int GetNbConnectedWires(Handle(TopTools_HSequenceOfShape)& aConnectedWires) const;
163 * Returns the distance between first and point with index thePointIndex
164 * at the section with index theSectionIndex. -1 is returned if error is occurred.
166 HYDRODATA_EXPORT double GetDistance( const int theSectionIndex,
167 const int thePointIndex ) const;
170 * Returns number of sections.
172 HYDRODATA_EXPORT virtual int NbSections() const;
175 * Adds new one section.
176 * \param theSectName name of the section
177 * \param theSectionType type of section
178 * \param theIsClosed flag indicates closures of section
180 HYDRODATA_EXPORT virtual void AddSection( const TCollection_AsciiString& theSectName,
181 const SectionType theSectionType,
182 const bool theIsClosed );
185 * Returns name of section with given index.
186 * \param theSectionIndex index of section
188 HYDRODATA_EXPORT virtual TCollection_AsciiString GetSectionName( const int theSectionIndex ) const;
191 * Set name for section with given index.
192 * \param theSectionIndex index of section
193 * \param theSectionName new section name
195 HYDRODATA_EXPORT virtual void SetSectionName( const int theSectionIndex,
196 const TCollection_AsciiString& theSectionName );
199 * Returns type of section with given index.
200 * \param theSectionIndex index of section
202 HYDRODATA_EXPORT virtual SectionType GetSectionType( const int theSectionIndex ) const;
205 * Set type for section with given index.
206 * \param theSectionIndex index of section
207 * \param theSectionType new section type
209 HYDRODATA_EXPORT virtual void SetSectionType( const int theSectionIndex,
210 const SectionType theSectionType );
213 * Returns true if section with given index is closed.
214 * \param theSectionIndex index of section
216 HYDRODATA_EXPORT virtual bool IsClosedSection( const int theSectionIndex ) const;
219 * Set closed flag for section with given index.
220 * \param theSectionIndex index of section
221 * \param theIsClosed new closures state
223 HYDRODATA_EXPORT virtual void SetSectionClosed( const int theSectionIndex,
224 const bool theIsClosed );
227 * Adds new one section.
228 * \param theSectName name of the section
229 * \param theSectionType type of section
230 * \param theIsClosed flag indicates closures of section
232 HYDRODATA_EXPORT virtual void GetSections( NCollection_Sequence<TCollection_AsciiString>& theSectNames,
233 NCollection_Sequence<SectionType>& theSectTypes,
234 NCollection_Sequence<bool>& theSectClosures ) const;
237 * Removes section with given index.
238 * \param theSectionIndex index of section
240 HYDRODATA_EXPORT virtual void RemoveSection( const int theSectionIndex );
243 * Removes all sections.
245 HYDRODATA_EXPORT virtual void RemoveSections();
249 * Adds new point for section with index "theSectionIndex".
250 * \param theSectionIndex index of section
251 * \param thePoint point to add
252 * \param theBeforeIndex if not equal -1 then insert point in this pos
254 HYDRODATA_EXPORT virtual void AddPoint( const int theSectionIndex,
255 const Point& thePoint,
256 const int thePointIndex = -1 );
259 * Replaces point for section with index "theSectionIndex".
260 * \param theSectionIndex index of section
261 * \param thePoint new point
262 * \param thePointIndex index of point to replace
264 HYDRODATA_EXPORT virtual void SetPoint( const int theSectionIndex,
265 const Point& thePoint,
266 const int thePointIndex );
269 * Replaces point for section with index "theSectionIndex".
270 * \param theSectionIndex index of section
271 * \param thePoints new points
273 HYDRODATA_EXPORT virtual void SetPoints( const int theSectionIndex,
274 const PointsList& thePoints );
277 * Removes point from section with index "theSectionIndex".
278 * \param theSectionIndex index of section
279 * \param thePointIndex index of point
281 HYDRODATA_EXPORT virtual void RemovePoint( const int theSectionIndex,
282 const int thePointIndex );
286 * Returns list of points.
287 * \param theSectionIndex if not equal -1 then list of points returned
288 * only for section with this index
289 * \return list of points
291 HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1, bool IsConvertToGlobal = false ) const;
295 * Returns the painter path.
296 * Note: currently only the first section of the polyline data is taken into account.
297 * \return polyline painter path.
299 HYDRODATA_EXPORT virtual QPainterPath GetPainterPath() const;
302 * Transform the polyline points.
303 * @param theTrsf the transformation
305 HYDRODATA_EXPORT void Transform( const QTransform& theTrsf );
307 HYDRODATA_EXPORT void SetDBFInfo(const QStringList& theDBFTable);
309 HYDRODATA_EXPORT bool GetDBFInfo(QStringList& theDBFTable) const;
311 HYDRODATA_EXPORT static bool ImportShapesFromFile( const QString& theFileName );
313 HYDRODATA_EXPORT static void ExportShapeXY(Handle(HYDROData_Document) theDocument,
314 const QString& aFileName,
315 const NCollection_Sequence<Handle(HYDROData_PolylineXY)>& aPolyXYSeq,
316 QStringList& aNonExpList);
321 * Sets the flag indicating that polyline can be edited or not.
323 HYDRODATA_EXPORT virtual void setEditable( const bool theIsEditable );
325 HYDRODATA_EXPORT void Interpolate();
329 friend class HYDROData_Profile;
330 friend class HYDROData_Iterator;
333 * Creates new object in the internal data structure. Use higher level objects
334 * to create objects with real content.
336 HYDRODATA_EXPORT HYDROData_PolylineXY();
339 * Destructs properties of the object and object itself, removes it from the document.
341 HYDRODATA_EXPORT ~HYDROData_PolylineXY();
344 bool myIsInCustomFlag;