Salome HOME
Minor changes.
[modules/hydro.git] / src / HYDROData / HYDROData_PolylineXY.h
1
2 #ifndef HYDROData_PolylineXY_HeaderFile
3 #define HYDROData_PolylineXY_HeaderFile
4
5 #include "HYDROData_IPolyline.h"
6
7 DEFINE_STANDARD_HANDLE(HYDROData_PolylineXY, HYDROData_IPolyline)
8
9 class QPainterPath;
10 class TopoDS_Wire;
11 class gp_XYZ;
12
13 /**\class HYDROData_PolylineXY
14  * \brief Class that stores/retreives information about the 
15  *        parametric profile points.
16  */
17 class HYDROData_PolylineXY : public HYDROData_IPolyline
18 {
19 protected:
20   /**
21    * Enumeration of tags corresponding to the persistent object parameters.
22    */
23   enum DataTag
24   {
25     DataTag_First = HYDROData_IPolyline::DataTag_First + 100, ///< first tag, to reserve
26   };
27
28 public:
29   DEFINE_STANDARD_RTTI(HYDROData_PolylineXY);
30
31
32   /**
33    * Returns the kind of this object. Must be redefined in all objects of known type.
34    */
35   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_POLYLINEXY;}
36
37   /**
38    * Dump object to Python script representation.
39    */
40   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
41
42   /**
43    * Returns data of object wrapped to QVariant.
44    * Reimplemented to wrap and return saved path.
45    */
46   HYDRODATA_EXPORT virtual QVariant GetDataVariant();
47
48 public:
49
50   /**
51    * Returns the presentation of polyline section in CAS maner.
52    */
53   HYDRODATA_EXPORT static TopoDS_Wire BuildWire( const SectionType&                  theType,
54                                                  const bool&                         theIsClosed,
55                                                  const NCollection_Sequence<gp_XYZ>& thePoints );
56
57   /**
58    * Returns the presentation of polyline section in Qt maner.
59    */
60   HYDRODATA_EXPORT static QPainterPath BuildPainterPath( const SectionType&                  theType,
61                                                          const bool&                         theIsClosed,
62                                                          const NCollection_Sequence<gp_XYZ>& thePoints );
63
64 public:
65
66   /**
67    * Returns the 3D presentation of all points.
68    */
69   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape();
70
71   /**
72    * Update the wire contour on the basis of the polyline data.
73    * Call this method whenever you made changes for polyline data.
74    */
75   HYDRODATA_EXPORT virtual void Update();
76
77
78    /**
79    * Returns true if polyline is closed
80    */
81   HYDRODATA_EXPORT bool IsClosed() const;
82
83    /**
84    * Returns the distance beetwen first and point with index thePointIndex
85    * at the section with index theSectionIndex. -1 is returned if error is occurred.
86    */
87   HYDRODATA_EXPORT double GetDistance( const int theSectionIndex,
88                                        const int thePointIndex ) const;
89
90
91   /**
92    * Returns number of sections.
93    */
94   HYDRODATA_EXPORT virtual int NbSections() const;
95
96   /**
97    * Adds new one section.
98    * \param theSectName name of the section
99    * \param theSectionType type of section
100    * \param theIsClosed flag indicates closures of section
101    */
102   HYDRODATA_EXPORT virtual void AddSection( const TCollection_AsciiString& theSectName,
103                                             const SectionType              theSectionType,
104                                             const bool                     theIsClosed );
105
106   /**
107    * Returns name of section with given index.
108    * \param theSectionIndex index of section
109    */
110   HYDRODATA_EXPORT virtual TCollection_AsciiString GetSectionName( const int theSectionIndex ) const;
111
112   /**
113    * Set name for section with given index.
114    * \param theSectionIndex index of section
115    * \param theSectionName new section name
116    */
117   HYDRODATA_EXPORT virtual void SetSectionName( const int                      theSectionIndex, 
118                                                 const TCollection_AsciiString& theSectionName );
119
120   /**
121    * Returns type of section with given index.
122    * \param theSectionIndex index of section
123    */
124   HYDRODATA_EXPORT virtual SectionType GetSectionType( const int theSectionIndex ) const;
125
126   /**
127    * Set type for section with given index.
128    * \param theSectionIndex index of section
129    * \param theSectionType new section type
130    */
131   HYDRODATA_EXPORT virtual void SetSectionType( const int         theSectionIndex, 
132                                                 const SectionType theSectionType );
133
134   /**
135    * Returns true if section with given index is closed.
136    * \param theSectionIndex index of section
137    */
138   HYDRODATA_EXPORT virtual bool IsClosedSection( const int theSectionIndex ) const;
139
140   /**
141    * Set closed flag for section with given index.
142    * \param theSectionIndex index of section
143    * \param theIsClosed new closures state
144    */
145   HYDRODATA_EXPORT virtual void SetSectionClosed( const int  theSectionIndex, 
146                                                   const bool theIsClosed );
147
148   /**
149    * Adds new one section.
150    * \param theSectName name of the section
151    * \param theSectionType type of section
152    * \param theIsClosed flag indicates closures of section
153    */
154   HYDRODATA_EXPORT virtual void GetSections( NCollection_Sequence<TCollection_AsciiString>& theSectNames,
155                                              NCollection_Sequence<SectionType>&             theSectTypes,
156                                              NCollection_Sequence<bool>&                    theSectClosures ) const;
157
158   /**
159    * Removes section with given index.
160    * \param theSectionIndex index of section
161    */
162   HYDRODATA_EXPORT virtual void RemoveSection( const int theSectionIndex );
163
164   /**
165    * Removes all sections.
166    */
167   HYDRODATA_EXPORT virtual void RemoveSections();
168
169
170   /**
171    * Adds new point for section with index "theSectionIndex".
172    * \param theSectionIndex index of section
173    * \param thePoint point to add
174    * \param theBeforeIndex if not equal -1 then insert point in this pos
175    */
176   HYDRODATA_EXPORT virtual void AddPoint( const int    theSectionIndex,
177                                           const Point& thePoint,
178                                           const int    thePointIndex = -1 );
179
180   /**
181    * Replaces point for section with index "theSectionIndex".
182    * \param theSectionIndex index of section
183    * \param thePoint new point
184    * \param thePointIndex index of point to replace
185    */
186   HYDRODATA_EXPORT virtual void SetPoint( const int    theSectionIndex,
187                                           const Point& thePoint,
188                                           const int    thePointIndex );
189
190   /**
191    * Removes point from section with index "theSectionIndex".
192    * \param theSectionIndex index of section
193    * \param thePointIndex index of point
194    */
195   HYDRODATA_EXPORT virtual void RemovePoint( const int theSectionIndex,
196                                              const int thePointIndex );
197
198
199   /**
200    * Returns list of points.
201    * \param theSectionIndex if not equal -1 then list of points returned
202    *                        only for section with this index
203    * \return list of points
204    */
205   HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1 ) const;
206
207
208   /**
209    * Returns the painter path.
210    * Note: currently only the first section of the polyline data is taken into account.
211    * \return polyline painter path.
212    */
213   HYDRODATA_EXPORT virtual QPainterPath GetPainterPath() const;
214
215
216 protected:
217
218   friend class HYDROData_Profile;
219   friend class HYDROData_Iterator;
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_PolylineXY();
226
227   /**
228    * Destructs properties of the object and object itself, removes it from the document.
229    */
230   HYDRODATA_EXPORT ~HYDROData_PolylineXY();
231 };
232
233 #endif