Salome HOME
17.12.2013. Added Partition algorithm (draft version).
[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   /**
49    * Returns default wire color for new polyline.
50    */
51   HYDRODATA_EXPORT static QColor DefaultWireColor();
52
53 public:
54
55   /**
56    * Returns the presentation of polyline section in CAS maner.
57    */
58   HYDRODATA_EXPORT static TopoDS_Wire BuildWire( const SectionType&                  theType,
59                                                  const bool&                         theIsClosed,
60                                                  const NCollection_Sequence<gp_XYZ>& thePoints );
61
62   /**
63    * Returns the presentation of polyline section in Qt maner.
64    */
65   HYDRODATA_EXPORT static void BuildPainterPath( QPainterPath&                       thePath,
66                                                  const SectionType&                  theType,
67                                                  const bool&                         theIsClosed,
68                                                  const NCollection_Sequence<gp_XYZ>& thePoints );
69
70 public:
71
72   /**
73    * Returns the 3D presentation of all points.
74    */
75   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape();
76
77   /**
78    * Update the wire contour on the basis of the polyline data.
79    * Call this method whenever you made changes for polyline data.
80    */
81   HYDRODATA_EXPORT virtual void Update();
82
83
84    /**
85    * Returns true if polyline is closed
86    */
87   HYDRODATA_EXPORT bool IsClosed() const;
88
89    /**
90    * Returns the distance beetwen first and point with index thePointIndex
91    * at the section with index theSectionIndex. -1 is returned if error is occurred.
92    */
93   HYDRODATA_EXPORT double GetDistance( const int theSectionIndex,
94                                        const int thePointIndex ) const;
95
96
97   /**
98    * Returns number of sections.
99    */
100   HYDRODATA_EXPORT virtual int NbSections() const;
101
102   /**
103    * Adds new one section.
104    * \param theSectName name of the section
105    * \param theSectionType type of section
106    * \param theIsClosed flag indicates closures of section
107    */
108   HYDRODATA_EXPORT virtual void AddSection( const TCollection_AsciiString& theSectName,
109                                             const SectionType              theSectionType,
110                                             const bool                     theIsClosed );
111
112   /**
113    * Returns name of section with given index.
114    * \param theSectionIndex index of section
115    */
116   HYDRODATA_EXPORT virtual TCollection_AsciiString GetSectionName( const int theSectionIndex ) const;
117
118   /**
119    * Set name for section with given index.
120    * \param theSectionIndex index of section
121    * \param theSectionName new section name
122    */
123   HYDRODATA_EXPORT virtual void SetSectionName( const int                      theSectionIndex, 
124                                                 const TCollection_AsciiString& theSectionName );
125
126   /**
127    * Returns type of section with given index.
128    * \param theSectionIndex index of section
129    */
130   HYDRODATA_EXPORT virtual SectionType GetSectionType( const int theSectionIndex ) const;
131
132   /**
133    * Set type for section with given index.
134    * \param theSectionIndex index of section
135    * \param theSectionType new section type
136    */
137   HYDRODATA_EXPORT virtual void SetSectionType( const int         theSectionIndex, 
138                                                 const SectionType theSectionType );
139
140   /**
141    * Returns true if section with given index is closed.
142    * \param theSectionIndex index of section
143    */
144   HYDRODATA_EXPORT virtual bool IsClosedSection( const int theSectionIndex ) const;
145
146   /**
147    * Set closed flag for section with given index.
148    * \param theSectionIndex index of section
149    * \param theIsClosed new closures state
150    */
151   HYDRODATA_EXPORT virtual void SetSectionClosed( const int  theSectionIndex, 
152                                                   const bool theIsClosed );
153
154   /**
155    * Adds new one section.
156    * \param theSectName name of the section
157    * \param theSectionType type of section
158    * \param theIsClosed flag indicates closures of section
159    */
160   HYDRODATA_EXPORT virtual void GetSections( NCollection_Sequence<TCollection_AsciiString>& theSectNames,
161                                              NCollection_Sequence<SectionType>&             theSectTypes,
162                                              NCollection_Sequence<bool>&                    theSectClosures ) const;
163
164   /**
165    * Removes section with given index.
166    * \param theSectionIndex index of section
167    */
168   HYDRODATA_EXPORT virtual void RemoveSection( const int theSectionIndex );
169
170   /**
171    * Removes all sections.
172    */
173   HYDRODATA_EXPORT virtual void RemoveSections();
174
175
176   /**
177    * Adds new point for section with index "theSectionIndex".
178    * \param theSectionIndex index of section
179    * \param thePoint point to add
180    * \param theBeforeIndex if not equal -1 then insert point in this pos
181    */
182   HYDRODATA_EXPORT virtual void AddPoint( const int    theSectionIndex,
183                                           const Point& thePoint,
184                                           const int    thePointIndex = -1 );
185
186   /**
187    * Replaces point for section with index "theSectionIndex".
188    * \param theSectionIndex index of section
189    * \param thePoint new point
190    * \param thePointIndex index of point to replace
191    */
192   HYDRODATA_EXPORT virtual void SetPoint( const int    theSectionIndex,
193                                           const Point& thePoint,
194                                           const int    thePointIndex );
195
196   /**
197    * Removes point from section with index "theSectionIndex".
198    * \param theSectionIndex index of section
199    * \param thePointIndex index of point
200    */
201   HYDRODATA_EXPORT virtual void RemovePoint( const int theSectionIndex,
202                                              const int thePointIndex );
203
204
205   /**
206    * Returns list of points.
207    * \param theSectionIndex if not equal -1 then list of points returned
208    *                        only for section with this index
209    * \return list of points
210    */
211   HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1 ) const;
212
213
214   /**
215    * Returns the painter path.
216    * Note: currently only the first section of the polyline data is taken into account.
217    * \return polyline painter path.
218    */
219   HYDRODATA_EXPORT virtual QPainterPath GetPainterPath() const;
220
221
222 protected:
223
224   friend class HYDROData_Profile;
225   friend class HYDROData_Iterator;
226
227   /**
228    * Creates new object in the internal data structure. Use higher level objects 
229    * to create objects with real content.
230    */
231   HYDRODATA_EXPORT HYDROData_PolylineXY();
232
233   /**
234    * Destructs properties of the object and object itself, removes it from the document.
235    */
236   HYDRODATA_EXPORT ~HYDROData_PolylineXY();
237 };
238
239 #endif