]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_IPolyline.h
Salome HOME
Coloring of objects (Bug #219).
[modules/hydro.git] / src / HYDROData / HYDROData_IPolyline.h
1
2 #ifndef HYDROData_IPolyline_HeaderFile
3 #define HYDROData_IPolyline_HeaderFile
4
5 #include "HYDROData_Entity.h"
6
7
8 DEFINE_STANDARD_HANDLE(HYDROData_IPolyline, HYDROData_Entity)
9
10 class gp_XY;
11 class TopoDS_Shape;
12 class Handle(TDataStd_RealList);
13 class Handle(TDataStd_ExtStringList);
14 class Handle(TDataStd_BooleanList);
15 class Handle(TDataStd_IntegerList);
16
17
18 /**\class HYDROData_IPolyline
19  * \brief Base class that stores/retreives information about the 2D points.
20  */
21 class HYDROData_IPolyline : public HYDROData_Entity
22 {
23 public:
24
25   enum SectionType{ SECTION_POLYLINE = 0, SECTION_SPLINE = 1 };
26
27   typedef gp_XY                       Point;
28   typedef NCollection_Sequence<Point> PointsList;
29
30 protected:
31   /**
32    * Enumeration of tags corresponding to the persistent object parameters.
33    */
34   enum DataTag
35   {
36     DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
37     DataTag_Points,
38     DataTag_Sections,
39     DataTag_PolylineShape,
40     DataTag_WireColor,
41   };
42
43 public:
44   DEFINE_STANDARD_RTTI(HYDROData_IPolyline);
45
46 public:
47
48   /**
49    * Sets wire color for object.
50    */
51   HYDRODATA_EXPORT virtual void SetWireColor( const QColor& theColor );
52
53   /**
54    * Returns wire color of object.
55    */
56   HYDRODATA_EXPORT virtual QColor GetWireColor() const;
57
58   /**
59    * Returns default wire color for new object.
60    */
61   HYDRODATA_EXPORT static QColor DefaultWireColor();
62
63 public:
64
65   /**
66    * Returns the 3D presentation of all points.
67    */
68   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape() = 0;
69
70
71   /**
72    * Returns number of sections.
73    */
74   HYDRODATA_EXPORT virtual int NbSections() const = 0;
75
76   /**
77    * Adds new one section.
78    * \param theSectName name of the section
79    * \param theSectionType type of section
80    * \param theIsClosed flag indicates closures of section
81    */
82   HYDRODATA_EXPORT virtual void AddSection( const TCollection_AsciiString& theSectName,
83                                             const SectionType              theSectionType,
84                                             const bool                     theIsClosed ) = 0;
85
86   /**
87    * Returns name of section with given index.
88    * \param theSectionIndex index of section
89    */
90   HYDRODATA_EXPORT virtual TCollection_AsciiString GetSectionName( const int theSectionIndex ) const = 0;
91
92   /**
93    * Set name for section with given index.
94    * \param theSectionIndex index of section
95    * \param theSectionName new section name
96    */
97   HYDRODATA_EXPORT virtual void SetSectionName( const int                      theSectionIndex, 
98                                                 const TCollection_AsciiString& theSectionName ) = 0;
99
100   /**
101    * Returns type of section with given index.
102    * \param theSectionIndex index of section
103    */
104   HYDRODATA_EXPORT virtual SectionType GetSectionType( const int theSectionIndex ) const = 0;
105
106   /**
107    * Set type for section with given index.
108    * \param theSectionIndex index of section
109    * \param theSectionType new section type
110    */
111   HYDRODATA_EXPORT virtual void SetSectionType( const int         theSectionIndex, 
112                                                 const SectionType theSectionType ) = 0;
113
114   /**
115    * Returns true if section with given index is closed.
116    * \param theSectionIndex index of section
117    */
118   HYDRODATA_EXPORT virtual bool IsClosedSection( const int theSectionIndex ) const = 0;
119
120   /**
121    * Set closed flag for section with given index.
122    * \param theSectionIndex index of section
123    * \param theIsClosed new closures state
124    */
125   HYDRODATA_EXPORT virtual void SetSectionClosed( const int  theSectionIndex, 
126                                                   const bool theIsClosed ) = 0;
127
128   /**
129    * Removes section with given index.
130    * \param theSectionIndex index of section
131    */
132   HYDRODATA_EXPORT virtual void RemoveSection( const int theSectionIndex ) = 0;
133
134   /**
135    * Removes all sections.
136    */
137   HYDRODATA_EXPORT virtual void RemoveSections() = 0;
138
139
140   /**
141    * Return number of profile points.
142    * \return number of points
143    */
144   HYDRODATA_EXPORT int NbPoints( const int theSectionIndex = -1 ) const;
145
146   /**
147    * Adds new point for section with index "theSectionIndex".
148    * \param theSectionIndex index of section
149    * \param thePoint point to add
150    * \param theBeforeIndex if not equal -1 then insert point before this index
151    */
152   HYDRODATA_EXPORT virtual void AddPoint( const int    theSectionIndex,
153                                           const Point& thePoint,
154                                           const int    theBeforeIndex = -1 ) = 0;
155
156   /**
157    * Replaces point for section with index "theSectionIndex".
158    * \param theSectionIndex index of section
159    * \param thePoint new point
160    * \param thePointIndex index of point to replace
161    */
162   HYDRODATA_EXPORT virtual void SetPoint( const int    theSectionIndex,
163                                           const Point& thePoint,
164                                           const int    thePointIndex ) = 0;
165
166   /**
167    * Removes point from section with index "theSectionIndex".
168    * \param theSectionIndex index of section
169    * \param thePointIndex index of point
170    */
171   HYDRODATA_EXPORT virtual void RemovePoint( const int theSectionIndex,
172                                              const int thePointIndex ) = 0;
173
174
175   /**
176    * Returns list of points.
177    * \param theSectionIndex if not equal -1 then list of points returned
178    *                        only for section with this index
179    * \return list of points
180    */
181   HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1 ) const = 0;
182
183 protected:
184
185   TopoDS_Shape getPolylineShape() const;
186
187   void setPolylineShape( const TopoDS_Shape& theShape );
188
189   void removePolylineShape();
190
191
192   void getSectionsLists( Handle(TDataStd_ExtStringList)& theNamesList,
193                          Handle(TDataStd_IntegerList)&   theTypesList,
194                          Handle(TDataStd_BooleanList)&   theClosuresList,
195                          const bool                      theIsCreate = true ) const;
196
197   void removeSectionsLists();
198
199   void getPointsLists( const int                  theSectionIndex,
200                        Handle(TDataStd_RealList)& theListX,
201                        Handle(TDataStd_RealList)& theListY,
202                        const bool                 theIsCreate = true ) const;
203
204   void removePointsLists( const int theSectionIndex = -1 ) const;
205
206 protected:
207
208   /**
209    * Creates new object in the internal data structure. Use higher level objects 
210    * to create objects with real content.
211    */
212   HYDRODATA_EXPORT HYDROData_IPolyline();
213
214   /**
215    * Destructs properties of the object and object itself, removes it from the document.
216    */
217   HYDRODATA_EXPORT ~HYDROData_IPolyline();
218 };
219
220 #endif