Salome HOME
Update mechanism is corrected (Bug #182).
[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 void BuildPainterPath( QPainterPath&                       thePath,
61                                                  const SectionType&                  theType,
62                                                  const bool&                         theIsClosed,
63                                                  const NCollection_Sequence<gp_XYZ>& thePoints );
64
65 public:
66
67   /**
68    * Returns the 3D presentation of all points.
69    */
70   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape();
71
72   /**
73    * Update the wire contour on the basis of the polyline data.
74    * Call this method whenever you made changes for polyline data.
75    */
76   HYDRODATA_EXPORT virtual void Update();
77
78
79    /**
80    * Returns true if polyline is closed
81    */
82   HYDRODATA_EXPORT bool IsClosed() const;
83
84    /**
85    * Returns the distance beetwen first and point with index thePointIndex
86    * at the section with index theSectionIndex. -1 is returned if error is occurred.
87    */
88   HYDRODATA_EXPORT double GetDistance( const int theSectionIndex,
89                                        const int thePointIndex ) const;
90
91
92   /**
93    * Returns number of sections.
94    */
95   HYDRODATA_EXPORT virtual int NbSections() const;
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 );
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;
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 );
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;
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 );
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;
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 );
148
149   /**
150    * Adds new one section.
151    * \param theSectName name of the section
152    * \param theSectionType type of section
153    * \param theIsClosed flag indicates closures of section
154    */
155   HYDRODATA_EXPORT virtual void GetSections( NCollection_Sequence<TCollection_AsciiString>& theSectNames,
156                                              NCollection_Sequence<SectionType>&             theSectTypes,
157                                              NCollection_Sequence<bool>&                    theSectClosures ) const;
158
159   /**
160    * Removes section with given index.
161    * \param theSectionIndex index of section
162    */
163   HYDRODATA_EXPORT virtual void RemoveSection( const int theSectionIndex );
164
165   /**
166    * Removes all sections.
167    */
168   HYDRODATA_EXPORT virtual void RemoveSections();
169
170
171   /**
172    * Adds new point for section with index "theSectionIndex".
173    * \param theSectionIndex index of section
174    * \param thePoint point to add
175    * \param theBeforeIndex if not equal -1 then insert point in this pos
176    */
177   HYDRODATA_EXPORT virtual void AddPoint( const int    theSectionIndex,
178                                           const Point& thePoint,
179                                           const int    thePointIndex = -1 );
180
181   /**
182    * Replaces point for section with index "theSectionIndex".
183    * \param theSectionIndex index of section
184    * \param thePoint new point
185    * \param thePointIndex index of point to replace
186    */
187   HYDRODATA_EXPORT virtual void SetPoint( const int    theSectionIndex,
188                                           const Point& thePoint,
189                                           const int    thePointIndex );
190
191   /**
192    * Removes point from section with index "theSectionIndex".
193    * \param theSectionIndex index of section
194    * \param thePointIndex index of point
195    */
196   HYDRODATA_EXPORT virtual void RemovePoint( const int theSectionIndex,
197                                              const int thePointIndex );
198
199
200   /**
201    * Returns list of points.
202    * \param theSectionIndex if not equal -1 then list of points returned
203    *                        only for section with this index
204    * \return list of points
205    */
206   HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1 ) const;
207
208
209   /**
210    * Returns the painter path.
211    * Note: currently only the first section of the polyline data is taken into account.
212    * \return polyline painter path.
213    */
214   HYDRODATA_EXPORT virtual QPainterPath GetPainterPath() const;
215
216
217 protected:
218
219   friend class HYDROData_Profile;
220   friend class HYDROData_Iterator;
221
222   /**
223    * Creates new object in the internal data structure. Use higher level objects 
224    * to create objects with real content.
225    */
226   HYDRODATA_EXPORT HYDROData_PolylineXY();
227
228   /**
229    * Destructs properties of the object and object itself, removes it from the document.
230    */
231   HYDRODATA_EXPORT ~HYDROData_PolylineXY();
232 };
233
234 #endif