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