]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_PolylineXY.h
Salome HOME
5e050cf9e929274893c60fc71d91293766f3f5ae
[modules/hydro.git] / src / HYDROData / HYDROData_PolylineXY.h
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #ifndef HYDROData_PolylineXY_HeaderFile
20 #define HYDROData_PolylineXY_HeaderFile
21
22 #include "HYDROData_IPolyline.h"
23
24 DEFINE_STANDARD_HANDLE(HYDROData_PolylineXY, HYDROData_IPolyline)
25
26 class QPainterPath;
27 class QTransform;
28 class TopoDS_Wire;
29 class gp_XYZ;
30 class gp_Pnt;
31
32 /**\class HYDROData_PolylineXY
33  * \brief Class that stores/retrieves information about the
34  *        parametric profile points.
35  */
36 class HYDROData_PolylineXY : public HYDROData_IPolyline
37 {
38 protected:
39   /**
40    * Enumeration of tags corresponding to the persistent object parameters.
41    */
42   enum DataTag
43   {
44     DataTag_First = HYDROData_IPolyline::DataTag_First + 100, ///< first tag, to reserve
45     DataTag_GeomObjectEntry,  ///< study entry of the imported GEOM object
46   };
47
48 public:
49   DEFINE_STANDARD_RTTI(HYDROData_PolylineXY);
50
51
52   /**
53    * Returns the kind of this object. Must be redefined in all objects of known type.
54    */
55   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_POLYLINEXY;}
56
57   /**
58    * Dump object to Python script representation.
59    */
60   HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
61                                                      MapOfTreatedObjects& theTreatedObjects ) const;
62
63   /**
64    * Update the wire contour on the basis of the polyline data.
65    * Call this method whenever you made changes for polyline data.
66    */
67   HYDRODATA_EXPORT virtual void Update();
68
69   HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
70
71   /**
72    * Checks that object has 2D presentation. Re-implemented to return true.
73    */
74   HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
75
76   /**
77    * Returns data of object wrapped to QVariant.
78    * Re-implemented to wrap and return saved path.
79    */
80   HYDRODATA_EXPORT virtual QVariant GetDataVariant();
81
82   /**
83    * Returns default wire color for new polyline.
84    */
85   HYDRODATA_EXPORT static QColor DefaultWireColor();
86
87   HYDRODATA_EXPORT bool IsCustom() const;
88   HYDRODATA_EXPORT bool GetIsInCustomFlag() const;
89   HYDRODATA_EXPORT void SetIsInCustomFlag( bool theValue );
90
91 public:
92
93   /**
94    * Returns the presentation of polyline section in CAS manner.
95    */
96   HYDRODATA_EXPORT static TopoDS_Wire BuildWire( const SectionType&                  theType,
97                                                  const bool&                         theIsClosed,
98                                                  const NCollection_Sequence<gp_XYZ>& thePoints );
99
100   /**
101    * Returns the presentation of polyline section in Qt manner.
102    */
103   HYDRODATA_EXPORT static void BuildPainterPath( QPainterPath&                       thePath,
104                                                  const SectionType&                  theType,
105                                                  const bool&                         theIsClosed,
106                                                  const NCollection_Sequence<gp_XYZ>& thePoints );
107
108 public:
109
110   /**
111    * Imports shape from IOR.
112    * \param theIOR the IOR of Geom object
113    * \return \c true if shape has been successfully imported
114    */
115   HYDRODATA_EXPORT virtual bool ImportFromGeomIOR( const TCollection_AsciiString& theIOR );
116
117   /**
118    * Stores the study entry of the imported GEOM object.
119    * \param theEntry GEOM object entry
120    */
121   HYDRODATA_EXPORT void SetGeomObjectEntry( const TCollection_AsciiString& theEntry );
122
123   /**
124    * Returns the imported GEOM object entry.
125    */
126   HYDRODATA_EXPORT TCollection_AsciiString GetGeomObjectEntry() const;
127
128 public:
129
130   /**
131    * Returns the 3D presentation of all points.
132    */
133   HYDRODATA_EXPORT virtual bool ImportShape( const TopoDS_Shape& theShape,
134                                              bool IsInterpolationAllowed,
135                                              const Handle( HYDROData_PolylineXY )& theOldPolyline = NULL,
136                                              bool IsClosureAllowed = true,
137                                              double theDeviation = 1.);
138
139   /**
140    * Returns flag indicating that polyline can be edited or not.
141    */
142   HYDRODATA_EXPORT virtual bool IsEditable() const;
143
144   
145   /**
146    * Returns true if polyline is closed
147    * \param theIsSimpleCheck flag indicating the type of checking
148    *        - if true then all wires checked on closures
149    *        - if false then for positive result polyline should consist of
150    *          only one wire and which must be closed
151    */
152   HYDRODATA_EXPORT bool IsClosed( const bool theIsSimpleCheck = true ) const;
153
154    /**
155    * Returns the distance beetwen first and point with index thePointIndex
156    * at the section with index theSectionIndex. -1 is returned if error is occurred.
157    */
158   HYDRODATA_EXPORT double GetDistance( const int theSectionIndex,
159                                        const int thePointIndex ) const;
160
161   /**
162   * Returns the distance between a section and a point
163   */
164 // HYDRODATA_EXPORT double GetMinDistance( const int theSectionIndex,
165 //                                         const Point& thePoint ) const;
166
167
168   /**
169    * Returns number of sections.
170    */
171   HYDRODATA_EXPORT virtual int NbSections() const;
172
173   /**
174    * Adds new one section.
175    * \param theSectName name of the section
176    * \param theSectionType type of section
177    * \param theIsClosed flag indicates closures of section
178    */
179   HYDRODATA_EXPORT virtual void AddSection( const TCollection_AsciiString& theSectName,
180                                             const SectionType              theSectionType,
181                                             const bool                     theIsClosed );
182
183   /**
184    * Returns name of section with given index.
185    * \param theSectionIndex index of section
186    */
187   HYDRODATA_EXPORT virtual TCollection_AsciiString GetSectionName( const int theSectionIndex ) const;
188
189   /**
190    * Set name for section with given index.
191    * \param theSectionIndex index of section
192    * \param theSectionName new section name
193    */
194   HYDRODATA_EXPORT virtual void SetSectionName( const int                      theSectionIndex, 
195                                                 const TCollection_AsciiString& theSectionName );
196
197   /**
198    * Returns type of section with given index.
199    * \param theSectionIndex index of section
200    */
201   HYDRODATA_EXPORT virtual SectionType GetSectionType( const int theSectionIndex ) const;
202
203   /**
204    * Set type for section with given index.
205    * \param theSectionIndex index of section
206    * \param theSectionType new section type
207    */
208   HYDRODATA_EXPORT virtual void SetSectionType( const int         theSectionIndex, 
209                                                 const SectionType theSectionType );
210
211   /**
212    * Returns true if section with given index is closed.
213    * \param theSectionIndex index of section
214    */
215   HYDRODATA_EXPORT virtual bool IsClosedSection( const int theSectionIndex ) const;
216
217   /**
218    * Set closed flag for section with given index.
219    * \param theSectionIndex index of section
220    * \param theIsClosed new closures state
221    */
222   HYDRODATA_EXPORT virtual void SetSectionClosed( const int  theSectionIndex, 
223                                                   const bool theIsClosed );
224
225   /**
226    * Adds new one section.
227    * \param theSectName name of the section
228    * \param theSectionType type of section
229    * \param theIsClosed flag indicates closures of section
230    */
231   HYDRODATA_EXPORT virtual void GetSections( NCollection_Sequence<TCollection_AsciiString>& theSectNames,
232                                              NCollection_Sequence<SectionType>&             theSectTypes,
233                                              NCollection_Sequence<bool>&                    theSectClosures ) const;
234
235   /**
236    * Removes section with given index.
237    * \param theSectionIndex index of section
238    */
239   HYDRODATA_EXPORT virtual void RemoveSection( const int theSectionIndex );
240
241   /**
242    * Removes all sections.
243    */
244   HYDRODATA_EXPORT virtual void RemoveSections();
245
246
247   /**
248    * Adds new point for section with index "theSectionIndex".
249    * \param theSectionIndex index of section
250    * \param thePoint point to add
251    * \param theBeforeIndex if not equal -1 then insert point in this pos
252    */
253   HYDRODATA_EXPORT virtual void AddPoint( const int    theSectionIndex,
254                                           const Point& thePoint,
255                                           const int    thePointIndex = -1 );
256
257   /**
258    * Replaces point for section with index "theSectionIndex".
259    * \param theSectionIndex index of section
260    * \param thePoint new point
261    * \param thePointIndex index of point to replace
262    */
263   HYDRODATA_EXPORT virtual void SetPoint( const int    theSectionIndex,
264                                           const Point& thePoint,
265                                           const int    thePointIndex );
266
267   /**
268    * Replaces point for section with index "theSectionIndex".
269    * \param theSectionIndex index of section
270    * \param thePoints new points
271    */
272   HYDRODATA_EXPORT virtual void SetPoints( const int         theSectionIndex,
273                                            const PointsList& thePoints );
274
275   /**
276    * Removes point from section with index "theSectionIndex".
277    * \param theSectionIndex index of section
278    * \param thePointIndex index of point
279    */
280   HYDRODATA_EXPORT virtual void RemovePoint( const int theSectionIndex,
281                                              const int thePointIndex );
282
283
284   /**
285    * Returns list of points.
286    * \param theSectionIndex if not equal -1 then list of points returned
287    *                        only for section with this index
288    * \return list of points
289    */
290   HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1, bool IsConvertToGlobal = false ) const;
291
292
293   /**
294    * Returns the painter path.
295    * Note: currently only the first section of the polyline data is taken into account.
296    * \return polyline painter path.
297    */
298   HYDRODATA_EXPORT virtual QPainterPath GetPainterPath() const;
299
300   /**
301    * Transform the polyline points.
302    * @param theTrsf the transformation
303    */
304   HYDRODATA_EXPORT void Transform( const QTransform& theTrsf );
305
306 protected:
307
308   /**
309    * Sets the flag indicating that polyline can be edited or not.
310    */
311   HYDRODATA_EXPORT virtual void setEditable( const bool theIsEditable );
312
313   HYDRODATA_EXPORT void Interpolate();
314
315 protected:
316
317   friend class HYDROData_Profile;
318   friend class HYDROData_Iterator;
319
320   /**
321    * Creates new object in the internal data structure. Use higher level objects 
322    * to create objects with real content.
323    */
324   HYDRODATA_EXPORT HYDROData_PolylineXY();
325
326   /**
327    * Destructs properties of the object and object itself, removes it from the document.
328    */
329   HYDRODATA_EXPORT ~HYDROData_PolylineXY();
330
331 private:
332   bool myIsInCustomFlag;
333 };
334
335 #endif