1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef HYDROData_Polyline_HeaderFile
24 #define HYDROData_Polyline_HeaderFile
26 #include <HYDROData_Object.h>
28 #include <TCollection_ExtendedString.hxx>
31 #include <QPainterPath>
36 DEFINE_STANDARD_HANDLE(HYDROData_Polyline, HYDROData_Object)
38 struct HYDRODATA_EXPORT PolylineSection
41 enum SectionType{ SECTION_POLYLINE=0, SECTION_SPLINE=1 };
43 PolylineSection(){ myIsClosed=true; myType=SECTION_POLYLINE; mySectionName="Section";}
44 TCollection_ExtendedString mySectionName;
47 QList<double> myCoords;
50 /**\class HYDROData_Polyline
51 * \brief Class that stores/retreives information about the painter path.
53 * Keeps path as binary array of element type and coordinates
54 * of image with correspondent API for forkind wit hthese properties.
56 class HYDROData_Polyline : public HYDROData_Object
60 typedef QList<PolylineSection> PolylineData;
64 * Enumeration of tags corresponding to the persistent object parameters.
68 DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
70 DataTag_SectionsClosed,
77 DEFINE_STANDARD_RTTI(HYDROData_Polyline);
80 * Returns the kind of this object. Must be redefined in all objects of known type.
82 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_POLYLINE;}
85 * Returns the top shape of the object.
87 HYDRODATA_EXPORT virtual TopoDS_Shape GetTopShape() const;
90 * Returns the 3d shape of the object.
92 HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
95 * Dump object to Python script representation.
97 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
100 * Returns data of object wrapped to QVariant.
101 * Reimplemented to wrap and return saved path.
103 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
106 * Replace current polyline data by new sections list
107 * \param theSections the sections list
109 HYDRODATA_EXPORT void SetPolylineData( const PolylineData& theSections );
112 * Return polyline data
113 * \return polyline section list
115 HYDRODATA_EXPORT PolylineData GetPolylineData() const;
118 * Returns true if polyline is closed
120 HYDRODATA_EXPORT bool IsClosed() const;
123 * Return polyline dimension
124 * \return polyline dimension (2 or 3)
126 HYDRODATA_EXPORT int GetDimension() const;
129 * Set polyline dimension (2 or 3)
130 * \param theDimension the polyline dimension
132 HYDRODATA_EXPORT void SetDimension( int theDimension );
135 * Remove all sections from polyline
137 HYDRODATA_EXPORT void RemoveAll();
140 * Returns the painter path.
141 * Note: currently only the first section of the polyline data is taken into account.
143 HYDRODATA_EXPORT QPainterPath GetPainterPath() const;
145 HYDRODATA_EXPORT void SetZValue( const double theZValue );
146 HYDRODATA_EXPORT double ZValue() const;
151 * Update the wire contour on the basis of the polyline data.
153 void UpdateWire( const PolylineData& theSections );
157 friend class HYDROData_Iterator;
160 * Creates new object in the internal data structure. Use higher level objects
161 * to create objects with real content.
163 HYDRODATA_EXPORT HYDROData_Polyline();
166 * Destructs properties of the object and object itself, removes it from the document.
168 HYDRODATA_EXPORT ~HYDROData_Polyline();