Salome HOME
Corrections of examples path after install with scbi
[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 #include <TopTools_HSequenceOfShape.hxx>
24 #include <QString>
25 #include <QStringList>
26
27 class QPainterPath;
28 class QTransform;
29 class TopoDS_Wire;
30 class gp_XYZ;
31 class gp_Pnt;
32 class HYDROData_Document;
33
34 /**\class HYDROData_PolylineXY
35  * \brief Class that stores/retrieves information about the
36  *        parametric profile points.
37  */
38 class HYDROData_PolylineXY : public HYDROData_IPolyline
39 {
40 protected:
41   /**
42    * Enumeration of tags corresponding to the persistent object parameters.
43    */
44   enum DataTag
45   {
46     DataTag_First = HYDROData_IPolyline::DataTag_First + 100, ///< first tag, to reserve
47     DataTag_GeomObjectEntry,  ///< study entry of the imported GEOM object
48     DataTag_DBFTableInfo
49   };
50
51 public:
52   DEFINE_STANDARD_RTTIEXT(HYDROData_PolylineXY, HYDROData_IPolyline);
53
54
55   /**
56    * Returns the kind of this object. Must be redefined in all objects of known type.
57    */
58   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_POLYLINEXY;}
59
60   /**
61    * Dump object to Python script representation.
62    */
63   HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
64                                                      MapOfTreatedObjects& theTreatedObjects ) const;
65
66   /**
67    * Update the wire contour on the basis of the polyline data.
68    * Call this method whenever you made changes for polyline data.
69    */
70   HYDRODATA_EXPORT virtual void Update();
71
72   HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
73
74   /**
75    * Checks that object has 2D presentation. Re-implemented to return true.
76    */
77   HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
78
79   /**
80    * Returns data of object wrapped to QVariant.
81    * Re-implemented to wrap and return saved path.
82    */
83   HYDRODATA_EXPORT virtual QVariant GetDataVariant();
84
85   /**
86    * Returns default wire color for new polyline.
87    */
88   HYDRODATA_EXPORT static QColor DefaultWireColor();
89
90   HYDRODATA_EXPORT bool IsCustom() const;
91   HYDRODATA_EXPORT bool GetIsInCustomFlag() const;
92   HYDRODATA_EXPORT void SetIsInCustomFlag( bool theValue );
93
94 public:
95
96   /**
97    * Returns the presentation of polyline section in CAS manner.
98    */
99   HYDRODATA_EXPORT static TopoDS_Wire BuildWire( const SectionType&                  theType,
100                                                  const bool&                         theIsClosed,
101                                                  const NCollection_Sequence<gp_XYZ>& thePoints );
102
103   /**
104    * Returns the presentation of polyline section in Qt manner.
105    */
106   HYDRODATA_EXPORT static void BuildPainterPath( QPainterPath&                       thePath,
107                                                  const SectionType&                  theType,
108                                                  const bool&                         theIsClosed,
109                                                  const NCollection_Sequence<gp_XYZ>& thePoints );
110
111 public:
112
113   /**
114    * Imports shape from IOR.
115    * \param theIOR the IOR of Geom object
116    * \return \c true if shape has been successfully imported
117    */
118   HYDRODATA_EXPORT virtual bool ImportFromGeomIOR( const TCollection_AsciiString& theIOR );
119
120   /**
121    * Stores the study entry of the imported GEOM object.
122    * \param theEntry GEOM object entry
123    */
124   HYDRODATA_EXPORT void SetGeomObjectEntry( const TCollection_AsciiString& theEntry );
125
126   /**
127    * Returns the imported GEOM object entry.
128    */
129   HYDRODATA_EXPORT TCollection_AsciiString GetGeomObjectEntry() const;
130
131 public:
132
133   /**
134    * Returns the 3D presentation of all points.
135    */
136   HYDRODATA_EXPORT virtual bool ImportShape( const TopoDS_Shape& theShape,
137                                              bool IsInterpolationAllowed,
138                                              const Handle( HYDROData_PolylineXY )& theOldPolyline,
139                                              bool IsClosureAllowed = true,
140                                              double theDeviation = 1.);
141
142   /**
143    * Returns flag indicating that polyline can be edited or not.
144    */
145   HYDRODATA_EXPORT virtual bool IsEditable() const;
146
147   
148   /**
149    * Returns true if polyline is closed
150    * \param theIsSimpleCheck flag indicating the type of checking
151    *        - if true then all wires checked on closures
152    *        - if false then for positive result polyline should consist of
153    *          only one wire and which must be closed
154    */
155   HYDRODATA_EXPORT bool IsClosed( const bool theIsSimpleCheck = true ) const;
156
157   /**
158    * Returns connected wires and their number, by rebuild of the wires from the edges, looking for connections
159    */
160   HYDRODATA_EXPORT int GetNbConnectedWires(Handle(TopTools_HSequenceOfShape)& aConnectedWires) const;
161
162    /**
163    * Returns the distance between first and point with index thePointIndex
164    * at the section with index theSectionIndex. -1 is returned if error is occurred.
165    */
166   HYDRODATA_EXPORT double GetDistance( const int theSectionIndex,
167                                        const int thePointIndex ) const;
168
169   /**
170    * Returns number of sections.
171    */
172   HYDRODATA_EXPORT virtual int NbSections() const;
173
174   /**
175    * Adds new one section.
176    * \param theSectName name of the section
177    * \param theSectionType type of section
178    * \param theIsClosed flag indicates closures of section
179    */
180   HYDRODATA_EXPORT virtual void AddSection( const TCollection_AsciiString& theSectName,
181                                             const SectionType              theSectionType,
182                                             const bool                     theIsClosed );
183
184   /**
185    * Returns name of section with given index.
186    * \param theSectionIndex index of section
187    */
188   HYDRODATA_EXPORT virtual TCollection_AsciiString GetSectionName( const int theSectionIndex ) const;
189
190   /**
191    * Set name for section with given index.
192    * \param theSectionIndex index of section
193    * \param theSectionName new section name
194    */
195   HYDRODATA_EXPORT virtual void SetSectionName( const int                      theSectionIndex, 
196                                                 const TCollection_AsciiString& theSectionName );
197
198   /**
199    * Returns type of section with given index.
200    * \param theSectionIndex index of section
201    */
202   HYDRODATA_EXPORT virtual SectionType GetSectionType( const int theSectionIndex ) const;
203
204   /**
205    * Set type for section with given index.
206    * \param theSectionIndex index of section
207    * \param theSectionType new section type
208    */
209   HYDRODATA_EXPORT virtual void SetSectionType( const int         theSectionIndex, 
210                                                 const SectionType theSectionType );
211
212   /**
213    * Returns true if section with given index is closed.
214    * \param theSectionIndex index of section
215    */
216   HYDRODATA_EXPORT virtual bool IsClosedSection( const int theSectionIndex ) const;
217
218   /**
219    * Set closed flag for section with given index.
220    * \param theSectionIndex index of section
221    * \param theIsClosed new closures state
222    */
223   HYDRODATA_EXPORT virtual void SetSectionClosed( const int  theSectionIndex, 
224                                                   const bool theIsClosed );
225
226   /**
227    * Adds new one section.
228    * \param theSectName name of the section
229    * \param theSectionType type of section
230    * \param theIsClosed flag indicates closures of section
231    */
232   HYDRODATA_EXPORT virtual void GetSections( NCollection_Sequence<TCollection_AsciiString>& theSectNames,
233                                              NCollection_Sequence<SectionType>&             theSectTypes,
234                                              NCollection_Sequence<bool>&                    theSectClosures ) const;
235
236   /**
237    * Removes section with given index.
238    * \param theSectionIndex index of section
239    */
240   HYDRODATA_EXPORT virtual void RemoveSection( const int theSectionIndex );
241
242   /**
243    * Removes all sections.
244    */
245   HYDRODATA_EXPORT virtual void RemoveSections();
246
247
248   /**
249    * Adds new point for section with index "theSectionIndex".
250    * \param theSectionIndex index of section
251    * \param thePoint point to add
252    * \param theBeforeIndex if not equal -1 then insert point in this pos
253    */
254   HYDRODATA_EXPORT virtual void AddPoint( const int    theSectionIndex,
255                                           const Point& thePoint,
256                                           const int    thePointIndex = -1 );
257
258   /**
259    * Replaces point for section with index "theSectionIndex".
260    * \param theSectionIndex index of section
261    * \param thePoint new point
262    * \param thePointIndex index of point to replace
263    */
264   HYDRODATA_EXPORT virtual void SetPoint( const int    theSectionIndex,
265                                           const Point& thePoint,
266                                           const int    thePointIndex );
267
268   /**
269    * Replaces point for section with index "theSectionIndex".
270    * \param theSectionIndex index of section
271    * \param thePoints new points
272    */
273   HYDRODATA_EXPORT virtual void SetPoints( const int         theSectionIndex,
274                                            const PointsList& thePoints );
275
276   /**
277    * Removes point from section with index "theSectionIndex".
278    * \param theSectionIndex index of section
279    * \param thePointIndex index of point
280    */
281   HYDRODATA_EXPORT virtual void RemovePoint( const int theSectionIndex,
282                                              const int thePointIndex );
283
284
285   /**
286    * Returns list of points.
287    * \param theSectionIndex if not equal -1 then list of points returned
288    *                        only for section with this index
289    * \return list of points
290    */
291   HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1, bool IsConvertToGlobal = false ) const;
292
293
294   /**
295    * Returns the painter path.
296    * Note: currently only the first section of the polyline data is taken into account.
297    * \return polyline painter path.
298    */
299   HYDRODATA_EXPORT virtual QPainterPath GetPainterPath() const;
300
301   /**
302    * Transform the polyline points.
303    * @param theTrsf the transformation
304    */
305   HYDRODATA_EXPORT void Transform( const QTransform& theTrsf );
306
307   HYDRODATA_EXPORT void SetDBFInfo(const QStringList& theDBFTable);  
308
309   HYDRODATA_EXPORT bool GetDBFInfo(QStringList& theDBFTable) const;
310
311   HYDRODATA_EXPORT static HYDROData_SequenceOfObjects ImportShapesFromFile( const QString& theFileName );
312
313   HYDRODATA_EXPORT static void ExportShapeXY(Handle(HYDROData_Document) theDocument,
314                                              const QString& aFileName,
315                                              const NCollection_Sequence<Handle(HYDROData_PolylineXY)>& aPolyXYSeq,
316                                              QStringList& aNonExpList);
317
318 protected:
319
320   /**
321    * Sets the flag indicating that polyline can be edited or not.
322    */
323   HYDRODATA_EXPORT virtual void setEditable( const bool theIsEditable );
324
325   HYDRODATA_EXPORT void Interpolate();
326
327 protected:
328
329   friend class HYDROData_Profile;
330   friend class HYDROData_Iterator;
331
332   /**
333    * Creates new object in the internal data structure. Use higher level objects 
334    * to create objects with real content.
335    */
336   HYDRODATA_EXPORT HYDROData_PolylineXY();
337
338   /**
339    * Destructs properties of the object and object itself, removes it from the document.
340    */
341   HYDRODATA_EXPORT ~HYDROData_PolylineXY();
342
343 private:
344   bool myIsInCustomFlag;
345 };
346
347 #endif