Salome HOME
Merge remote-tracking branch 'origin/BR_SHP_FORMAT' into BR_v14_rc
[modules/hydro.git] / src / HYDROData / HYDROData_Polyline.h
index 641ade902f5a3b6085e374b88a35c1b19d7e1ff3..ca7475c37c7cc1bb7dd0f379753e239a0af7ee6a 100755 (executable)
@@ -1,14 +1,48 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
 #ifndef HYDROData_Polyline_HeaderFile
 #define HYDROData_Polyline_HeaderFile
 
 #include <HYDROData_Object.h>
 
+#include <TCollection_ExtendedString.hxx>
+
 #include <QPointF>
 #include <QPainterPath>
 #include <QList>
 
+class TopoDS_Wire;
+
 DEFINE_STANDARD_HANDLE(HYDROData_Polyline, HYDROData_Object)
 
+struct HYDRODATA_EXPORT PolylineSection
+{
+public:
+  enum SectionType{ SECTION_POLYLINE=0, SECTION_SPLINE=1 };
+
+  PolylineSection(){ myIsClosed=true; myType=SECTION_POLYLINE; mySectionName="Section";}
+  TCollection_ExtendedString  mySectionName;
+  SectionType                 myType;
+  bool                        myIsClosed;
+  QList<double>               myCoords;
+};
+
 /**\class HYDROData_Polyline
  * \brief Class that stores/retreives information about the painter path.
  *
@@ -17,6 +51,24 @@ DEFINE_STANDARD_HANDLE(HYDROData_Polyline, HYDROData_Object)
  */
 class HYDROData_Polyline : public HYDROData_Object
 {
+public:
+
+  typedef QList<PolylineSection> PolylineData;
+
+protected:
+  /**
+   * Enumeration of tags corresponding to the persistent object parameters.
+   */
+  enum DataTag
+  {
+    DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
+    DataTag_SectionsName,
+    DataTag_SectionsClosed,
+    DataTag_SectionsSize,
+    DataTag_SectionsType,
+    DataTag_ZValue
+  };
+
 public:
   DEFINE_STANDARD_RTTI(HYDROData_Polyline);
 
@@ -26,53 +78,75 @@ public:
   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_POLYLINE;}
 
   /**
-   * Replace current array by points list
-   * \param thePoint the point to add
+   * Returns the top shape of the object.
    */
-  HYDRODATA_EXPORT void setPoints( QList<QPointF> thePointsList );
+  HYDRODATA_EXPORT virtual TopoDS_Shape GetTopShape() const;
 
   /**
-   * Add point to the end of point list
-   * \param thePoint the point to add
+   * Returns the 3d shape of the object.
    */
-  HYDRODATA_EXPORT void addPoint( const QPointF& thePoint );
-   
+  HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
+
   /**
-   * Add point to the point list at the specified position
-   * \param theIndex the index of the list the point will insert after
+   * Dump object to Python script representation.
    */
-  HYDRODATA_EXPORT void insertPoint( int theIndex, const QPointF& thePoint);
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
 
   /**
-   * Remove point from polyline
-   * \param theIndex the point index
+   * Returns data of object wrapped to QVariant.
+   * Reimplemented to wrap and return saved path.
    */
-  HYDRODATA_EXPORT void removePoint( int theIndex );
+  HYDRODATA_EXPORT virtual QVariant GetDataVariant();
 
   /**
-   * Remove all points from polyline
-   * \param theIndex the point index
+   * Replace current polyline data by new sections list
+   * \param theSections the sections list
    */
-  HYDRODATA_EXPORT void removeAllPoints();
+  HYDRODATA_EXPORT void SetPolylineData( const PolylineData& theSections );
 
   /**
-   * Return list point count
-   * \return list point count
+   * Return polyline data
+   * \return polyline section list
+   */
+  HYDRODATA_EXPORT PolylineData GetPolylineData() const;
+   
+  /**
+   * Returns true if polyline is closed
    */
-  HYDRODATA_EXPORT int pointsCount();
+  HYDRODATA_EXPORT bool IsClosed() const;
 
   /**
-   * Returns list of points
-   * \return list of points
+   * Return polyline dimension
+   * \return polyline dimension (2 or 3)
    */
-  HYDRODATA_EXPORT QList<QPointF> points();
+  HYDRODATA_EXPORT int GetDimension() const;
 
+  /**
+   * Set polyline dimension (2 or 3)
+   * \param theDimension the polyline dimension
+   */
+  HYDRODATA_EXPORT void SetDimension( int theDimension );
 
   /**
-   * Returns the painter path. The painter path is construct by lines
+   * Remove all sections from polyline
    */
-  HYDRODATA_EXPORT QPainterPath painterPathLinear();
+  HYDRODATA_EXPORT void RemoveAll();
 
+  /**
+   * Returns the painter path.
+   * Note: currently only the first section of the polyline data is taken into account.
+   */
+  HYDRODATA_EXPORT QPainterPath GetPainterPath() const;
+
+  HYDRODATA_EXPORT void   SetZValue( const double theZValue );
+  HYDRODATA_EXPORT double ZValue() const;
+
+protected:
+
+  /**
+   * Update the wire contour on the basis of the polyline data.
+   */
+  void UpdateWire( const PolylineData& theSections );
 
 protected:
 
@@ -82,13 +156,12 @@ protected:
    * Creates new object in the internal data structure. Use higher level objects 
    * to create objects with real content.
    */
-  HYDROData_Polyline();
+  HYDRODATA_EXPORT HYDROData_Polyline();
 
   /**
    * Destructs properties of the object and object itself, removes it from the document.
    */
-  ~HYDROData_Polyline();
-
+  HYDRODATA_EXPORT ~HYDROData_Polyline();
 };
 
 #endif