Salome HOME
1) Improved visibility management
[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 public:
16   enum SectionType{ SECTION_POLYLINE=0, SECTION_SPLINE=1 };
17
18   PolylineSection(){ myIsClosed=true; myType=SECTION_POLYLINE; mySectionName="Section";}
19   TCollection_ExtendedString  mySectionName;
20   SectionType                 myType;
21   bool                        myIsClosed;
22   QList<double>               myCoords;
23 };
24
25 /**\class HYDROData_Polyline
26  * \brief Class that stores/retreives information about the painter path.
27  *
28  * Keeps path as binary array of element type and coordinates
29  * of image with correspondent API for forkind wit hthese properties.
30  */
31 class HYDROData_Polyline : public HYDROData_Object
32 {
33 protected:
34   /**
35    * Enumeration of tags corresponding to the persistent object parameters.
36    */
37   enum DataTag
38   {
39     DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
40     DataTag_SectionsName,
41     DataTag_SectionsClosed,
42     DataTag_SectionsSize,
43     DataTag_SectionsType
44   };
45
46 public:
47   DEFINE_STANDARD_RTTI(HYDROData_Polyline);
48
49   /**
50    * Returns the kind of this object. Must be redefined in all objects of known type.
51    */
52   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_POLYLINE;}
53
54   /**
55    * Replace current polyline data by new sections list
56    * \param theSections the sections list
57    */
58   HYDRODATA_EXPORT void setPolylineData( const QList<PolylineSection>& theSections );
59
60   /**
61    * Return polyline data
62    * \return polyline section list
63    */
64   HYDRODATA_EXPORT QList<PolylineSection> getPolylineData();
65    
66   /**
67    * Return polyline dimension
68    * \return polyline dimension (2 or 3)
69    */
70   HYDRODATA_EXPORT int getDimension() const;
71
72   /**
73    * Set polyline dimension (2 or 3)
74    * \param theDimension the polyline dimension
75    */
76   HYDRODATA_EXPORT void setDimension( int theDimension );
77
78   /**
79    * Remove all sections from polyline
80    */
81   HYDRODATA_EXPORT void removeAll();
82
83
84   /**
85    * Returns the painter path. The painter path is construct by lines
86    */
87   HYDRODATA_EXPORT QPainterPath painterPath();
88
89
90 protected:
91
92   friend class HYDROData_Iterator;
93
94   /**
95    * Creates new object in the internal data structure. Use higher level objects 
96    * to create objects with real content.
97    */
98   HYDROData_Polyline();
99
100   /**
101    * Destructs properties of the object and object itself, removes it from the document.
102    */
103   ~HYDROData_Polyline();
104 };
105
106 #endif