Salome HOME
8dc6dcedfaa68fff15aa6beff97cff6b08b3c6a9
[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    * Replace current polyline data by new sections list
66    * \param theSections the sections list
67    */
68   HYDRODATA_EXPORT void setPolylineData( const PolylineData& theSections );
69
70   /**
71    * Return polyline data
72    * \return polyline section list
73    */
74   HYDRODATA_EXPORT PolylineData getPolylineData() const;
75    
76   /**
77    * Return polyline dimension
78    * \return polyline dimension (2 or 3)
79    */
80   HYDRODATA_EXPORT int getDimension() const;
81
82   /**
83    * Set polyline dimension (2 or 3)
84    * \param theDimension the polyline dimension
85    */
86   HYDRODATA_EXPORT void setDimension( int theDimension );
87
88   /**
89    * Remove all sections from polyline
90    */
91   HYDRODATA_EXPORT void removeAll();
92
93
94   /**
95    * Returns the painter path. The painter path is construct by lines
96    */
97   HYDRODATA_EXPORT QPainterPath painterPath();
98
99
100 protected:
101
102   friend class HYDROData_Iterator;
103
104   /**
105    * Creates new object in the internal data structure. Use higher level objects 
106    * to create objects with real content.
107    */
108   HYDROData_Polyline();
109
110   /**
111    * Destructs properties of the object and object itself, removes it from the document.
112    */
113   ~HYDROData_Polyline();
114 };
115
116 #endif