Salome HOME
patch for crash in channel
[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     DataTag_GeomObjectEntry,  ///< study entry of the imported GEOM object
27   };
28
29 public:
30   DEFINE_STANDARD_RTTI(HYDROData_PolylineXY);
31
32
33   /**
34    * Returns the kind of this object. Must be redefined in all objects of known type.
35    */
36   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_POLYLINEXY;}
37
38   /**
39    * Dump object to Python script representation.
40    */
41   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
42
43   /**
44    * Returns data of object wrapped to QVariant.
45    * Reimplemented to wrap and return saved path.
46    */
47   HYDRODATA_EXPORT virtual QVariant GetDataVariant();
48
49   /**
50    * Returns default wire color for new polyline.
51    */
52   HYDRODATA_EXPORT static QColor DefaultWireColor();
53
54 public:
55
56   /**
57    * Returns the presentation of polyline section in CAS maner.
58    */
59   HYDRODATA_EXPORT static TopoDS_Wire BuildWire( const SectionType&                  theType,
60                                                  const bool&                         theIsClosed,
61                                                  const NCollection_Sequence<gp_XYZ>& thePoints );
62
63   /**
64    * Returns the presentation of polyline section in Qt maner.
65    */
66   HYDRODATA_EXPORT static void BuildPainterPath( QPainterPath&                       thePath,
67                                                  const SectionType&                  theType,
68                                                  const bool&                         theIsClosed,
69                                                  const NCollection_Sequence<gp_XYZ>& thePoints );
70
71 public:
72
73   /**
74    * Imports shape from IOR.
75    * \param theIOR the IOR of Geom object
76    * \return \c true if shape has been successfully imported
77    */
78   HYDRODATA_EXPORT virtual bool ImportFromGeomIOR( const TCollection_AsciiString& theIOR );
79
80   /**
81    * Stores the study entry of the imported GEOM object.
82    * \param theEntry GEOM object entry
83    */
84   HYDRODATA_EXPORT void SetGeomObjectEntry( const TCollection_AsciiString& theEntry );
85
86   /**
87    * Returns the imported GEOM object entry.
88    */
89   HYDRODATA_EXPORT TCollection_AsciiString GetGeomObjectEntry() const;
90
91 public:
92
93   /**
94    * Returns the 2D presentation of all points.
95    */
96   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape() const;
97
98   /**
99    * Returns the 3D presentation of all points.
100    */
101   HYDRODATA_EXPORT virtual bool ImportShape( const TopoDS_Shape& theShape );
102
103   /**
104    * Update the wire contour on the basis of the polyline data.
105    * Call this method whenever you made changes for polyline data.
106    */
107   HYDRODATA_EXPORT virtual void Update();
108
109
110   /**
111    * Returns flag indicating that polyline can be edited or not.
112    */
113   HYDRODATA_EXPORT virtual bool IsEditable() const;
114
115   
116   /**
117    * Returns true if polyline is closed
118    * \param theIsSimpleCheck flag indicating the type of checking
119    *        - if true then all wires checked on closures
120    *        - if false then for positive result polyline should consist of
121    *          only one wire and which must be closed
122    */
123   HYDRODATA_EXPORT bool IsClosed( const bool theIsSimpleCheck = true ) const;
124
125    /**
126    * Returns the distance beetwen first and point with index thePointIndex
127    * at the section with index theSectionIndex. -1 is returned if error is occurred.
128    */
129   HYDRODATA_EXPORT double GetDistance( const int theSectionIndex,
130                                        const int thePointIndex ) const;
131
132
133   /**
134    * Returns number of sections.
135    */
136   HYDRODATA_EXPORT virtual int NbSections() const;
137
138   /**
139    * Adds new one section.
140    * \param theSectName name of the section
141    * \param theSectionType type of section
142    * \param theIsClosed flag indicates closures of section
143    */
144   HYDRODATA_EXPORT virtual void AddSection( const TCollection_AsciiString& theSectName,
145                                             const SectionType              theSectionType,
146                                             const bool                     theIsClosed );
147
148   /**
149    * Returns name of section with given index.
150    * \param theSectionIndex index of section
151    */
152   HYDRODATA_EXPORT virtual TCollection_AsciiString GetSectionName( const int theSectionIndex ) const;
153
154   /**
155    * Set name for section with given index.
156    * \param theSectionIndex index of section
157    * \param theSectionName new section name
158    */
159   HYDRODATA_EXPORT virtual void SetSectionName( const int                      theSectionIndex, 
160                                                 const TCollection_AsciiString& theSectionName );
161
162   /**
163    * Returns type of section with given index.
164    * \param theSectionIndex index of section
165    */
166   HYDRODATA_EXPORT virtual SectionType GetSectionType( const int theSectionIndex ) const;
167
168   /**
169    * Set type for section with given index.
170    * \param theSectionIndex index of section
171    * \param theSectionType new section type
172    */
173   HYDRODATA_EXPORT virtual void SetSectionType( const int         theSectionIndex, 
174                                                 const SectionType theSectionType );
175
176   /**
177    * Returns true if section with given index is closed.
178    * \param theSectionIndex index of section
179    */
180   HYDRODATA_EXPORT virtual bool IsClosedSection( const int theSectionIndex ) const;
181
182   /**
183    * Set closed flag for section with given index.
184    * \param theSectionIndex index of section
185    * \param theIsClosed new closures state
186    */
187   HYDRODATA_EXPORT virtual void SetSectionClosed( const int  theSectionIndex, 
188                                                   const bool theIsClosed );
189
190   /**
191    * Adds new one section.
192    * \param theSectName name of the section
193    * \param theSectionType type of section
194    * \param theIsClosed flag indicates closures of section
195    */
196   HYDRODATA_EXPORT virtual void GetSections( NCollection_Sequence<TCollection_AsciiString>& theSectNames,
197                                              NCollection_Sequence<SectionType>&             theSectTypes,
198                                              NCollection_Sequence<bool>&                    theSectClosures ) const;
199
200   /**
201    * Removes section with given index.
202    * \param theSectionIndex index of section
203    */
204   HYDRODATA_EXPORT virtual void RemoveSection( const int theSectionIndex );
205
206   /**
207    * Removes all sections.
208    */
209   HYDRODATA_EXPORT virtual void RemoveSections();
210
211
212   /**
213    * Adds new point for section with index "theSectionIndex".
214    * \param theSectionIndex index of section
215    * \param thePoint point to add
216    * \param theBeforeIndex if not equal -1 then insert point in this pos
217    */
218   HYDRODATA_EXPORT virtual void AddPoint( const int    theSectionIndex,
219                                           const Point& thePoint,
220                                           const int    thePointIndex = -1 );
221
222   /**
223    * Replaces point for section with index "theSectionIndex".
224    * \param theSectionIndex index of section
225    * \param thePoint new point
226    * \param thePointIndex index of point to replace
227    */
228   HYDRODATA_EXPORT virtual void SetPoint( const int    theSectionIndex,
229                                           const Point& thePoint,
230                                           const int    thePointIndex );
231
232   /**
233    * Replaces point for section with index "theSectionIndex".
234    * \param theSectionIndex index of section
235    * \param thePoints new points
236    */
237   HYDRODATA_EXPORT virtual void SetPoints( const int         theSectionIndex,
238                                            const PointsList& thePoints );
239
240   /**
241    * Removes point from section with index "theSectionIndex".
242    * \param theSectionIndex index of section
243    * \param thePointIndex index of point
244    */
245   HYDRODATA_EXPORT virtual void RemovePoint( const int theSectionIndex,
246                                              const int thePointIndex );
247
248
249   /**
250    * Returns list of points.
251    * \param theSectionIndex if not equal -1 then list of points returned
252    *                        only for section with this index
253    * \return list of points
254    */
255   HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1 ) const;
256
257
258   /**
259    * Returns the painter path.
260    * Note: currently only the first section of the polyline data is taken into account.
261    * \return polyline painter path.
262    */
263   HYDRODATA_EXPORT virtual QPainterPath GetPainterPath() const;
264
265
266 protected:
267
268   /**
269    * Sets the flag indicating that polyline can be edited or not.
270    */
271   HYDRODATA_EXPORT virtual void setEditable( const bool theIsEditable );
272
273 protected:
274
275   friend class HYDROData_Profile;
276   friend class HYDROData_Iterator;
277
278   /**
279    * Creates new object in the internal data structure. Use higher level objects 
280    * to create objects with real content.
281    */
282   HYDRODATA_EXPORT HYDROData_PolylineXY();
283
284   /**
285    * Destructs properties of the object and object itself, removes it from the document.
286    */
287   HYDRODATA_EXPORT ~HYDROData_PolylineXY();
288 };
289
290 #endif