Salome HOME
#refs 522 (very draft) //import only
[modules/hydro.git] / src / HYDROData / HYDROData_Polyline.h
1 // Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef HYDROData_Polyline_HeaderFile
24 #define HYDROData_Polyline_HeaderFile
25
26 #include <HYDROData_Object.h>
27
28 #include <TCollection_ExtendedString.hxx>
29
30 #include <QPointF>
31 #include <QPainterPath>
32 #include <QList>
33
34 class TopoDS_Wire;
35
36 DEFINE_STANDARD_HANDLE(HYDROData_Polyline, HYDROData_Object)
37
38 struct HYDRODATA_EXPORT PolylineSection
39 {
40 public:
41   enum SectionType{ SECTION_POLYLINE=0, SECTION_SPLINE=1 };
42
43   PolylineSection(){ myIsClosed=true; myType=SECTION_POLYLINE; mySectionName="Section";}
44   TCollection_ExtendedString  mySectionName;
45   SectionType                 myType;
46   bool                        myIsClosed;
47   QList<double>               myCoords;
48 };
49
50 /**\class HYDROData_Polyline
51  * \brief Class that stores/retreives information about the painter path.
52  *
53  * Keeps path as binary array of element type and coordinates
54  * of image with correspondent API for forkind wit hthese properties.
55  */
56 class HYDROData_Polyline : public HYDROData_Object
57 {
58 public:
59
60   typedef QList<PolylineSection> PolylineData;
61
62 protected:
63   /**
64    * Enumeration of tags corresponding to the persistent object parameters.
65    */
66   enum DataTag
67   {
68     DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
69     DataTag_SectionsName,
70     DataTag_SectionsClosed,
71     DataTag_SectionsSize,
72     DataTag_SectionsType,
73     DataTag_ZValue
74   };
75
76 public:
77   DEFINE_STANDARD_RTTI(HYDROData_Polyline);
78
79   /**
80    * Returns the kind of this object. Must be redefined in all objects of known type.
81    */
82   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_POLYLINE;}
83
84   /**
85    * Returns the top shape of the object.
86    */
87   HYDRODATA_EXPORT virtual TopoDS_Shape GetTopShape() const;
88
89   /**
90    * Returns the 3d shape of the object.
91    */
92   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
93
94   /**
95    * Dump object to Python script representation.
96    */
97   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
98
99   /**
100    * Returns data of object wrapped to QVariant.
101    * Reimplemented to wrap and return saved path.
102    */
103   HYDRODATA_EXPORT virtual QVariant GetDataVariant();
104
105   /**
106    * Replace current polyline data by new sections list
107    * \param theSections the sections list
108    */
109   HYDRODATA_EXPORT void SetPolylineData( const PolylineData& theSections );
110
111   /**
112    * Return polyline data
113    * \return polyline section list
114    */
115   HYDRODATA_EXPORT PolylineData GetPolylineData() const;
116    
117   /**
118    * Returns true if polyline is closed
119    */
120   HYDRODATA_EXPORT bool IsClosed() const;
121
122   /**
123    * Return polyline dimension
124    * \return polyline dimension (2 or 3)
125    */
126   HYDRODATA_EXPORT int GetDimension() const;
127
128   /**
129    * Set polyline dimension (2 or 3)
130    * \param theDimension the polyline dimension
131    */
132   HYDRODATA_EXPORT void SetDimension( int theDimension );
133
134   /**
135    * Remove all sections from polyline
136    */
137   HYDRODATA_EXPORT void RemoveAll();
138
139   /**
140    * Returns the painter path.
141    * Note: currently only the first section of the polyline data is taken into account.
142    */
143   HYDRODATA_EXPORT QPainterPath GetPainterPath() const;
144
145   HYDRODATA_EXPORT void   SetZValue( const double theZValue );
146   HYDRODATA_EXPORT double ZValue() const;
147
148 protected:
149
150   /**
151    * Update the wire contour on the basis of the polyline data.
152    */
153   void UpdateWire( const PolylineData& theSections );
154
155 protected:
156
157   friend class HYDROData_Iterator;
158
159   /**
160    * Creates new object in the internal data structure. Use higher level objects 
161    * to create objects with real content.
162    */
163   HYDRODATA_EXPORT HYDROData_Polyline();
164
165   /**
166    * Destructs properties of the object and object itself, removes it from the document.
167    */
168   HYDRODATA_EXPORT ~HYDROData_Polyline();
169 };
170
171 #endif