Salome HOME
The region object has been added for HYDRO data model.
[modules/hydro.git] / src / HYDROData / HYDROData_Polyline.h
1 #ifndef HYDROData_Polyline_HeaderFile
2 #define HYDROData_Polyline_HeaderFile
3
4 #include <HYDROData_Object.h>
5
6 #include <TCollection_ExtendedString.hxx>
7
8 #include <QPointF>
9 #include <QPainterPath>
10 #include <QList>
11
12 DEFINE_STANDARD_HANDLE(HYDROData_Polyline, HYDROData_Object)
13
14 struct PolylineSection
15 {
16 public:
17   enum SectionType{ SECTION_POLYLINE=0, SECTION_SPLINE=1 };
18
19   PolylineSection(){ myIsClosed=true; myType=SECTION_POLYLINE; mySectionName="Section";}
20   TCollection_ExtendedString  mySectionName;
21   SectionType                 myType;
22   bool                        myIsClosed;
23   QList<double>               myCoords;
24 };
25
26 /**\class HYDROData_Polyline
27  * \brief Class that stores/retreives information about the painter path.
28  *
29  * Keeps path as binary array of element type and coordinates
30  * of image with correspondent API for forkind wit hthese properties.
31  */
32 class HYDROData_Polyline : public HYDROData_Object
33 {
34 public:
35
36   typedef QList<PolylineSection> PolylineData;
37
38 protected:
39   /**
40    * Enumeration of tags corresponding to the persistent object parameters.
41    */
42   enum DataTag
43   {
44     DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
45     DataTag_SectionsName,
46     DataTag_SectionsClosed,
47     DataTag_SectionsSize,
48     DataTag_SectionsType
49   };
50
51 public:
52   DEFINE_STANDARD_RTTI(HYDROData_Polyline);
53
54   /**
55    * Returns the kind of this object. Must be redefined in all objects of known type.
56    */
57   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_POLYLINE;}
58
59   /**
60    * Dump object to Python script representation.
61    */
62   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
63
64   /**
65    * Returns data of object wrapped to QVariant.
66    * Reimplemented to wrap and return saved path.
67    */
68   HYDRODATA_EXPORT virtual QVariant GetDataVariant();
69
70   /**
71    * Replace current polyline data by new sections list
72    * \param theSections the sections list
73    */
74   HYDRODATA_EXPORT void setPolylineData( const PolylineData& theSections );
75
76   /**
77    * Return polyline data
78    * \return polyline section list
79    */
80   HYDRODATA_EXPORT PolylineData getPolylineData() const;
81    
82   /**
83    * Returns true if polyline is closed
84    */
85   HYDRODATA_EXPORT bool isClosed() const;
86
87   /**
88    * Return polyline dimension
89    * \return polyline dimension (2 or 3)
90    */
91   HYDRODATA_EXPORT int getDimension() const;
92
93   /**
94    * Set polyline dimension (2 or 3)
95    * \param theDimension the polyline dimension
96    */
97   HYDRODATA_EXPORT void setDimension( int theDimension );
98
99   /**
100    * Remove all sections from polyline
101    */
102   HYDRODATA_EXPORT void removeAll();
103
104
105   /**
106    * Returns the painter path. The painter path is construct by lines
107    */
108   HYDRODATA_EXPORT QPainterPath painterPath() const;
109
110
111 protected:
112
113   friend class HYDROData_Iterator;
114
115   /**
116    * Creates new object in the internal data structure. Use higher level objects 
117    * to create objects with real content.
118    */
119   HYDROData_Polyline();
120
121   /**
122    * Destructs properties of the object and object itself, removes it from the document.
123    */
124   ~HYDROData_Polyline();
125 };
126
127 #endif