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