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