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