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_Polyline_HeaderFile
20 #define HYDROData_Polyline_HeaderFile
22 #include <HYDROData_Object.h>
24 #include <TCollection_ExtendedString.hxx>
27 #include <QPainterPath>
32 DEFINE_STANDARD_HANDLE(HYDROData_Polyline, HYDROData_Object)
34 struct HYDRODATA_EXPORT PolylineSection
37 enum SectionType{ SECTION_POLYLINE=0, SECTION_SPLINE=1 };
39 PolylineSection(){ myIsClosed=true; myType=SECTION_POLYLINE; mySectionName="Section";}
40 TCollection_ExtendedString mySectionName;
43 QList<double> myCoords;
46 /**\class HYDROData_Polyline
47 * \brief Class that stores/retreives information about the painter path.
49 * Keeps path as binary array of element type and coordinates
50 * of image with correspondent API for forkind wit hthese properties.
52 class HYDROData_Polyline : public HYDROData_Object
56 typedef QList<PolylineSection> PolylineData;
60 * Enumeration of tags corresponding to the persistent object parameters.
64 DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
66 DataTag_SectionsClosed,
73 DEFINE_STANDARD_RTTI(HYDROData_Polyline);
76 * Returns the kind of this object. Must be redefined in all objects of known type.
78 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_POLYLINE;}
81 * Returns the top shape of the object.
83 HYDRODATA_EXPORT virtual TopoDS_Shape GetTopShape() const;
86 * Returns the 3d shape of the object.
88 HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
91 * Dump object to Python script representation.
93 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
96 * Returns data of object wrapped to QVariant.
97 * Reimplemented to wrap and return saved path.
99 HYDRODATA_EXPORT virtual QVariant GetDataVariant();
102 * Replace current polyline data by new sections list
103 * \param theSections the sections list
105 HYDRODATA_EXPORT void SetPolylineData( const PolylineData& theSections );
108 * Return polyline data
109 * \return polyline section list
111 HYDRODATA_EXPORT PolylineData GetPolylineData() const;
114 * Returns true if polyline is closed
116 HYDRODATA_EXPORT bool IsClosed() const;
119 * Return polyline dimension
120 * \return polyline dimension (2 or 3)
122 HYDRODATA_EXPORT int GetDimension() const;
125 * Set polyline dimension (2 or 3)
126 * \param theDimension the polyline dimension
128 HYDRODATA_EXPORT void SetDimension( int theDimension );
131 * Remove all sections from polyline
133 HYDRODATA_EXPORT void RemoveAll();
136 * Returns the painter path.
137 * Note: currently only the first section of the polyline data is taken into account.
139 HYDRODATA_EXPORT QPainterPath GetPainterPath() const;
141 HYDRODATA_EXPORT void SetZValue( const double theZValue );
142 HYDRODATA_EXPORT double ZValue() const;
147 * Update the wire contour on the basis of the polyline data.
149 void UpdateWire( const PolylineData& theSections );
153 friend class HYDROData_Iterator;
156 * Creates new object in the internal data structure. Use higher level objects
157 * to create objects with real content.
159 HYDRODATA_EXPORT HYDROData_Polyline();
162 * Destructs properties of the object and object itself, removes it from the document.
164 HYDRODATA_EXPORT ~HYDROData_Polyline();