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