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