]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_IPolyline.h
Salome HOME
Merge remote-tracking branch 'origin/master' into BR_LAND_COVER_MAP
[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    * Returns number of sections.
83    */
84   HYDRODATA_EXPORT virtual int NbSections() const = 0;
85
86   /**
87    * Adds new one section.
88    * \param theSectName name of the section
89    * \param theSectionType type of section
90    * \param theIsClosed flag indicates closures of section
91    */
92   HYDRODATA_EXPORT virtual void AddSection( const TCollection_AsciiString& theSectName,
93                                             const SectionType              theSectionType,
94                                             const bool                     theIsClosed ) = 0;
95
96   /**
97    * Returns name of section with given index.
98    * \param theSectionIndex index of section
99    */
100   HYDRODATA_EXPORT virtual TCollection_AsciiString GetSectionName( const int theSectionIndex ) const = 0;
101
102   /**
103    * Set name for section with given index.
104    * \param theSectionIndex index of section
105    * \param theSectionName new section name
106    */
107   HYDRODATA_EXPORT virtual void SetSectionName( const int                      theSectionIndex, 
108                                                 const TCollection_AsciiString& theSectionName ) = 0;
109
110   /**
111    * Returns type of section with given index.
112    * \param theSectionIndex index of section
113    */
114   HYDRODATA_EXPORT virtual SectionType GetSectionType( const int theSectionIndex ) const = 0;
115
116   /** 
117    * Set type for section with given index.
118    * \param theSectionIndex index of section
119    * \param theSectionType new section type
120    */
121   HYDRODATA_EXPORT virtual void SetSectionType( const int         theSectionIndex, 
122                                                 const SectionType theSectionType ) = 0;
123
124   /**
125    * Returns true if section with given index is closed.
126    * \param theSectionIndex index of section
127    */
128   HYDRODATA_EXPORT virtual bool IsClosedSection( const int theSectionIndex ) const = 0;
129
130   /**
131    * Set closed flag for section with given index.
132    * \param theSectionIndex index of section
133    * \param theIsClosed new closures state
134    */
135   HYDRODATA_EXPORT virtual void SetSectionClosed( const int  theSectionIndex, 
136                                                   const bool theIsClosed ) = 0;
137
138   /**
139    * Removes section with given index.
140    * \param theSectionIndex index of section
141    */
142   HYDRODATA_EXPORT virtual void RemoveSection( const int theSectionIndex ) = 0;
143
144   /**
145    * Removes all sections.
146    */
147   HYDRODATA_EXPORT virtual void RemoveSections() = 0;
148
149
150   /**
151    * Return number of profile points.
152    * \return number of points
153    */
154   HYDRODATA_EXPORT int NbPoints( const int theSectionIndex = -1 ) const;
155
156   /**
157    * Adds new point for section with index "theSectionIndex".
158    * \param theSectionIndex index of section
159    * \param thePoint point to add
160    * \param theBeforeIndex if not equal -1 then insert point before this index
161    */
162   HYDRODATA_EXPORT virtual void AddPoint( const int    theSectionIndex,
163                                           const Point& thePoint,
164                                           const int    theBeforeIndex = -1 ) = 0;
165
166   /**
167    * Replaces point for section with index "theSectionIndex".
168    * \param theSectionIndex index of section
169    * \param thePoint new point
170    * \param thePointIndex index of point to replace
171    */
172   HYDRODATA_EXPORT virtual void SetPoint( const int    theSectionIndex,
173                                           const Point& thePoint,
174                                           const int    thePointIndex ) = 0;
175
176   /**
177    * Removes point from section with index "theSectionIndex".
178    * \param theSectionIndex index of section
179    * \param thePointIndex index of point
180    */
181   HYDRODATA_EXPORT virtual void RemovePoint( const int theSectionIndex,
182                                              const int thePointIndex ) = 0;
183
184
185   /**
186    * Returns list of points.
187    * \param theSectionIndex if not equal -1 then list of points returned
188    *                        only for section with this index
189    * \return list of points
190    */
191   HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1, bool IsConvertToGlobal = false ) const = 0;
192
193   HYDRODATA_EXPORT TopoDS_Shape GetShape() const;
194   HYDRODATA_EXPORT void SetShape( const TopoDS_Shape& theShape );
195
196 protected:
197   void RemovePolylineShape();
198
199   void getSectionsLists( Handle(TDataStd_ExtStringList)& theNamesList,
200                          Handle(TDataStd_IntegerList)&   theTypesList,
201                          Handle(TDataStd_BooleanList)&   theClosuresList,
202                          const bool                      theIsCreate = true ) const;
203
204   void removeSectionsLists();
205
206   void getPointsLists( const int                  theSectionIndex,
207                        Handle(TDataStd_RealList)& theListX,
208                        Handle(TDataStd_RealList)& theListY,
209                        const bool                 theIsCreate = true ) const;
210
211   void removePointsLists( const int theSectionIndex = -1 ) const;
212
213 protected:
214
215   /**
216    * Creates new object in the internal data structure. Use higher level objects 
217    * to create objects with real content.
218    */
219   HYDRODATA_EXPORT HYDROData_IPolyline();
220
221   /**
222    * Destructs properties of the object and object itself, removes it from the document.
223    */
224   HYDRODATA_EXPORT ~HYDROData_IPolyline();
225 };
226
227 #endif