Salome HOME
Checkbox for the point C is added in Import Image dialog.
[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 class TopoDS_Wire;
13
14 DEFINE_STANDARD_HANDLE(HYDROData_Polyline, HYDROData_Object)
15
16 struct PolylineSection
17 {
18 public:
19   enum SectionType{ SECTION_POLYLINE=0, SECTION_SPLINE=1 };
20
21   PolylineSection(){ myIsClosed=true; myType=SECTION_POLYLINE; mySectionName="Section";}
22   TCollection_ExtendedString  mySectionName;
23   SectionType                 myType;
24   bool                        myIsClosed;
25   QList<double>               myCoords;
26 };
27
28 /**\class HYDROData_Polyline
29  * \brief Class that stores/retreives information about the painter path.
30  *
31  * Keeps path as binary array of element type and coordinates
32  * of image with correspondent API for forkind wit hthese properties.
33  */
34 class HYDROData_Polyline : public HYDROData_Object
35 {
36 public:
37
38   typedef QList<PolylineSection> PolylineData;
39
40 protected:
41   /**
42    * Enumeration of tags corresponding to the persistent object parameters.
43    */
44   enum DataTag
45   {
46     DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
47     DataTag_SectionsName,
48     DataTag_SectionsClosed,
49     DataTag_SectionsSize,
50     DataTag_SectionsType,
51     DataTag_Wire,
52     DataTag_ZValue
53   };
54
55 public:
56   DEFINE_STANDARD_RTTI(HYDROData_Polyline);
57
58   /**
59    * Returns the kind of this object. Must be redefined in all objects of known type.
60    */
61   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_POLYLINE;}
62
63   /**
64    * Dump object to Python script representation.
65    */
66   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
67
68   /**
69    * Returns data of object wrapped to QVariant.
70    * Reimplemented to wrap and return saved path.
71    */
72   HYDRODATA_EXPORT virtual QVariant GetDataVariant();
73
74   /**
75    * Replace current polyline data by new sections list
76    * \param theSections the sections list
77    */
78   HYDRODATA_EXPORT void setPolylineData( const PolylineData& theSections );
79
80   /**
81    * Return polyline data
82    * \return polyline section list
83    */
84   HYDRODATA_EXPORT PolylineData getPolylineData() const;
85    
86   /**
87    * Returns true if polyline is closed
88    */
89   HYDRODATA_EXPORT bool isClosed() const;
90
91   /**
92    * Return polyline dimension
93    * \return polyline dimension (2 or 3)
94    */
95   HYDRODATA_EXPORT int getDimension() const;
96
97   /**
98    * Set polyline dimension (2 or 3)
99    * \param theDimension the polyline dimension
100    */
101   HYDRODATA_EXPORT void setDimension( int theDimension );
102
103   /**
104    * Remove all sections from polyline
105    */
106   HYDRODATA_EXPORT void removeAll();
107
108   /**
109    * Returns the painter path.
110    * Note: currently only the first section of the polyline data is taken into account.
111    */
112   HYDRODATA_EXPORT QPainterPath painterPath() const;
113
114   HYDRODATA_EXPORT void SetZValue( const double theZValue );
115   HYDRODATA_EXPORT double ZValue() const;
116
117   /**
118    * Sets the wire contour of the object.
119    */
120   HYDRODATA_EXPORT void SetWire( const TopoDS_Wire& theWire );
121
122   /**
123    * Returns the wire contour of the object.
124    */
125   HYDRODATA_EXPORT TopoDS_Wire Wire() const;
126
127 protected:
128   /**
129    * Update the wire contour on the basis of the polyline data.
130    */
131   void UpdateWire( const PolylineData& theSections );
132
133 protected:
134
135   friend class HYDROData_Iterator;
136
137   /**
138    * Creates new object in the internal data structure. Use higher level objects 
139    * to create objects with real content.
140    */
141   HYDROData_Polyline();
142
143   /**
144    * Destructs properties of the object and object itself, removes it from the document.
145    */
146   ~HYDROData_Polyline();
147 };
148
149 #endif