Salome HOME
Dump to python corrected.
[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 2D presentation of all points.
74    */
75   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape() const;
76
77   /**
78    * Returns the 3D presentation of all points.
79    */
80   HYDRODATA_EXPORT virtual bool ImportShape( const TopoDS_Shape& theShape );
81
82   /**
83    * Update the wire contour on the basis of the polyline data.
84    * Call this method whenever you made changes for polyline data.
85    */
86   HYDRODATA_EXPORT virtual void Update();
87
88
89   /**
90    * Returns flag indicating that polyline can be edited or not.
91    */
92   HYDRODATA_EXPORT virtual bool IsEditable() const;
93
94   
95   /**
96    * Returns true if polyline is closed
97    * \param theIsSimpleCheck flag indicating the type of checking
98    *        - if true then all wires checked on closures
99    *        - if false then for positive result polyline should consist of
100    *          only one wire and which must be closed
101    */
102   HYDRODATA_EXPORT bool IsClosed( const bool theIsSimpleCheck = true ) const;
103
104    /**
105    * Returns the distance beetwen first and point with index thePointIndex
106    * at the section with index theSectionIndex. -1 is returned if error is occurred.
107    */
108   HYDRODATA_EXPORT double GetDistance( const int theSectionIndex,
109                                        const int thePointIndex ) const;
110
111
112   /**
113    * Returns number of sections.
114    */
115   HYDRODATA_EXPORT virtual int NbSections() const;
116
117   /**
118    * Adds new one section.
119    * \param theSectName name of the section
120    * \param theSectionType type of section
121    * \param theIsClosed flag indicates closures of section
122    */
123   HYDRODATA_EXPORT virtual void AddSection( const TCollection_AsciiString& theSectName,
124                                             const SectionType              theSectionType,
125                                             const bool                     theIsClosed );
126
127   /**
128    * Returns name of section with given index.
129    * \param theSectionIndex index of section
130    */
131   HYDRODATA_EXPORT virtual TCollection_AsciiString GetSectionName( const int theSectionIndex ) const;
132
133   /**
134    * Set name for section with given index.
135    * \param theSectionIndex index of section
136    * \param theSectionName new section name
137    */
138   HYDRODATA_EXPORT virtual void SetSectionName( const int                      theSectionIndex, 
139                                                 const TCollection_AsciiString& theSectionName );
140
141   /**
142    * Returns type of section with given index.
143    * \param theSectionIndex index of section
144    */
145   HYDRODATA_EXPORT virtual SectionType GetSectionType( const int theSectionIndex ) const;
146
147   /**
148    * Set type for section with given index.
149    * \param theSectionIndex index of section
150    * \param theSectionType new section type
151    */
152   HYDRODATA_EXPORT virtual void SetSectionType( const int         theSectionIndex, 
153                                                 const SectionType theSectionType );
154
155   /**
156    * Returns true if section with given index is closed.
157    * \param theSectionIndex index of section
158    */
159   HYDRODATA_EXPORT virtual bool IsClosedSection( const int theSectionIndex ) const;
160
161   /**
162    * Set closed flag for section with given index.
163    * \param theSectionIndex index of section
164    * \param theIsClosed new closures state
165    */
166   HYDRODATA_EXPORT virtual void SetSectionClosed( const int  theSectionIndex, 
167                                                   const bool theIsClosed );
168
169   /**
170    * Adds new one section.
171    * \param theSectName name of the section
172    * \param theSectionType type of section
173    * \param theIsClosed flag indicates closures of section
174    */
175   HYDRODATA_EXPORT virtual void GetSections( NCollection_Sequence<TCollection_AsciiString>& theSectNames,
176                                              NCollection_Sequence<SectionType>&             theSectTypes,
177                                              NCollection_Sequence<bool>&                    theSectClosures ) const;
178
179   /**
180    * Removes section with given index.
181    * \param theSectionIndex index of section
182    */
183   HYDRODATA_EXPORT virtual void RemoveSection( const int theSectionIndex );
184
185   /**
186    * Removes all sections.
187    */
188   HYDRODATA_EXPORT virtual void RemoveSections();
189
190
191   /**
192    * Adds new point for section with index "theSectionIndex".
193    * \param theSectionIndex index of section
194    * \param thePoint point to add
195    * \param theBeforeIndex if not equal -1 then insert point in this pos
196    */
197   HYDRODATA_EXPORT virtual void AddPoint( const int    theSectionIndex,
198                                           const Point& thePoint,
199                                           const int    thePointIndex = -1 );
200
201   /**
202    * Replaces point for section with index "theSectionIndex".
203    * \param theSectionIndex index of section
204    * \param thePoint new point
205    * \param thePointIndex index of point to replace
206    */
207   HYDRODATA_EXPORT virtual void SetPoint( const int    theSectionIndex,
208                                           const Point& thePoint,
209                                           const int    thePointIndex );
210
211   /**
212    * Replaces point for section with index "theSectionIndex".
213    * \param theSectionIndex index of section
214    * \param thePoints new points
215    */
216   HYDRODATA_EXPORT virtual void SetPoints( const int         theSectionIndex,
217                                            const PointsList& thePoints );
218
219   /**
220    * Removes point from section with index "theSectionIndex".
221    * \param theSectionIndex index of section
222    * \param thePointIndex index of point
223    */
224   HYDRODATA_EXPORT virtual void RemovePoint( const int theSectionIndex,
225                                              const int thePointIndex );
226
227
228   /**
229    * Returns list of points.
230    * \param theSectionIndex if not equal -1 then list of points returned
231    *                        only for section with this index
232    * \return list of points
233    */
234   HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1 ) const;
235
236
237   /**
238    * Returns the painter path.
239    * Note: currently only the first section of the polyline data is taken into account.
240    * \return polyline painter path.
241    */
242   HYDRODATA_EXPORT virtual QPainterPath GetPainterPath() const;
243
244
245 protected:
246
247   /**
248    * Sets the flag indicating that polyline can be edited or not.
249    */
250   HYDRODATA_EXPORT virtual void setEditable( const bool theIsEditable );
251
252 protected:
253
254   friend class HYDROData_Profile;
255   friend class HYDROData_Iterator;
256
257   /**
258    * Creates new object in the internal data structure. Use higher level objects 
259    * to create objects with real content.
260    */
261   HYDRODATA_EXPORT HYDROData_PolylineXY();
262
263   /**
264    * Destructs properties of the object and object itself, removes it from the document.
265    */
266   HYDRODATA_EXPORT ~HYDROData_PolylineXY();
267 };
268
269 #endif