Salome HOME
#refs 585: polylines operations GUI
[modules/hydro.git] / src / HYDROData / HYDROData_IPolyline.h
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #ifndef HYDROData_IPolyline_HeaderFile
20 #define HYDROData_IPolyline_HeaderFile
21
22 #include "HYDROData_Entity.h"
23
24
25 DEFINE_STANDARD_HANDLE(HYDROData_IPolyline, HYDROData_Entity)
26
27 class gp_XY;
28 class TopoDS_Shape;
29 class Handle(TDataStd_RealList);
30 class Handle(TDataStd_ExtStringList);
31 class Handle(TDataStd_BooleanList);
32 class Handle(TDataStd_IntegerList);
33
34
35 /**\class HYDROData_IPolyline
36  * \brief Base class that stores/retreives information about the 2D points.
37  */
38 class HYDROData_IPolyline : public HYDROData_Entity
39 {
40 public:
41
42   enum SectionType{ SECTION_POLYLINE = 0, SECTION_SPLINE = 1 };
43
44   typedef gp_XY                       Point;
45   typedef NCollection_Sequence<Point> PointsList;
46
47 protected:
48   /**
49    * Enumeration of tags corresponding to the persistent object parameters.
50    */
51   enum DataTag
52   {
53     DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
54     DataTag_Points,
55     DataTag_Sections,
56     DataTag_PolylineShape,
57     DataTag_WireColor,
58   };
59
60 public:
61   DEFINE_STANDARD_RTTI(HYDROData_IPolyline);
62
63 public:
64
65   /**
66    * Sets wire color for object.
67    */
68   HYDRODATA_EXPORT virtual void SetWireColor( const QColor& theColor );
69
70   /**
71    * Returns wire color of object.
72    */
73   HYDRODATA_EXPORT virtual QColor GetWireColor() const;
74
75   /**
76    * Returns default wire color for new object.
77    */
78   HYDRODATA_EXPORT static QColor DefaultWireColor();
79
80 public:
81
82   /**
83    * Returns the 3D presentation of all points.
84    */
85   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape() const = 0;
86
87
88   /**
89    * Returns number of sections.
90    */
91   HYDRODATA_EXPORT virtual int NbSections() const = 0;
92
93   /**
94    * Adds new one section.
95    * \param theSectName name of the section
96    * \param theSectionType type of section
97    * \param theIsClosed flag indicates closures of section
98    */
99   HYDRODATA_EXPORT virtual void AddSection( const TCollection_AsciiString& theSectName,
100                                             const SectionType              theSectionType,
101                                             const bool                     theIsClosed ) = 0;
102
103   /**
104    * Returns name of section with given index.
105    * \param theSectionIndex index of section
106    */
107   HYDRODATA_EXPORT virtual TCollection_AsciiString GetSectionName( const int theSectionIndex ) const = 0;
108
109   /**
110    * Set name for section with given index.
111    * \param theSectionIndex index of section
112    * \param theSectionName new section name
113    */
114   HYDRODATA_EXPORT virtual void SetSectionName( const int                      theSectionIndex, 
115                                                 const TCollection_AsciiString& theSectionName ) = 0;
116
117   /**
118    * Returns type of section with given index.
119    * \param theSectionIndex index of section
120    */
121   HYDRODATA_EXPORT virtual SectionType GetSectionType( const int theSectionIndex ) const = 0;
122
123   /** 
124    * Set type for section with given index.
125    * \param theSectionIndex index of section
126    * \param theSectionType new section type
127    */
128   HYDRODATA_EXPORT virtual void SetSectionType( const int         theSectionIndex, 
129                                                 const SectionType theSectionType ) = 0;
130
131   /**
132    * Returns true if section with given index is closed.
133    * \param theSectionIndex index of section
134    */
135   HYDRODATA_EXPORT virtual bool IsClosedSection( const int theSectionIndex ) const = 0;
136
137   /**
138    * Set closed flag for section with given index.
139    * \param theSectionIndex index of section
140    * \param theIsClosed new closures state
141    */
142   HYDRODATA_EXPORT virtual void SetSectionClosed( const int  theSectionIndex, 
143                                                   const bool theIsClosed ) = 0;
144
145   /**
146    * Removes section with given index.
147    * \param theSectionIndex index of section
148    */
149   HYDRODATA_EXPORT virtual void RemoveSection( const int theSectionIndex ) = 0;
150
151   /**
152    * Removes all sections.
153    */
154   HYDRODATA_EXPORT virtual void RemoveSections() = 0;
155
156
157   /**
158    * Return number of profile points.
159    * \return number of points
160    */
161   HYDRODATA_EXPORT int NbPoints( const int theSectionIndex = -1 ) const;
162
163   /**
164    * Adds new point for section with index "theSectionIndex".
165    * \param theSectionIndex index of section
166    * \param thePoint point to add
167    * \param theBeforeIndex if not equal -1 then insert point before this index
168    */
169   HYDRODATA_EXPORT virtual void AddPoint( const int    theSectionIndex,
170                                           const Point& thePoint,
171                                           const int    theBeforeIndex = -1 ) = 0;
172
173   /**
174    * Replaces point for section with index "theSectionIndex".
175    * \param theSectionIndex index of section
176    * \param thePoint new point
177    * \param thePointIndex index of point to replace
178    */
179   HYDRODATA_EXPORT virtual void SetPoint( const int    theSectionIndex,
180                                           const Point& thePoint,
181                                           const int    thePointIndex ) = 0;
182
183   /**
184    * Removes point from section with index "theSectionIndex".
185    * \param theSectionIndex index of section
186    * \param thePointIndex index of point
187    */
188   HYDRODATA_EXPORT virtual void RemovePoint( const int theSectionIndex,
189                                              const int thePointIndex ) = 0;
190
191
192   /**
193    * Returns list of points.
194    * \param theSectionIndex if not equal -1 then list of points returned
195    *                        only for section with this index
196    * \return list of points
197    */
198   HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1 ) const = 0;
199
200 protected:
201
202   TopoDS_Shape getPolylineShape() const;
203
204   void setPolylineShape( const TopoDS_Shape& theShape );
205
206   void removePolylineShape();
207
208
209   void getSectionsLists( Handle(TDataStd_ExtStringList)& theNamesList,
210                          Handle(TDataStd_IntegerList)&   theTypesList,
211                          Handle(TDataStd_BooleanList)&   theClosuresList,
212                          const bool                      theIsCreate = true ) const;
213
214   void removeSectionsLists();
215
216   void getPointsLists( const int                  theSectionIndex,
217                        Handle(TDataStd_RealList)& theListX,
218                        Handle(TDataStd_RealList)& theListY,
219                        const bool                 theIsCreate = true ) const;
220
221   void removePointsLists( const int theSectionIndex = -1 ) const;
222
223 protected:
224
225   /**
226    * Creates new object in the internal data structure. Use higher level objects 
227    * to create objects with real content.
228    */
229   HYDRODATA_EXPORT HYDROData_IPolyline();
230
231   /**
232    * Destructs properties of the object and object itself, removes it from the document.
233    */
234   HYDRODATA_EXPORT ~HYDROData_IPolyline();
235 };
236
237 #endif