From 726a151f28dc899349039692d32d6227a5ef1d4f Mon Sep 17 00:00:00 2001 From: adv Date: Fri, 6 Sep 2013 07:27:20 +0000 Subject: [PATCH] Python API for HYDROData_Polyline. Plus some minor changes. --- src/HYDROPy/HYDROData.sip | 4 +- src/HYDROPy/HYDROData_Document.sip | 13 ++- src/HYDROPy/HYDROData_Object.sip | 35 +------- src/HYDROPy/HYDROData_Polyline.sip | 127 +++++++++++++++++++++++++++++ src/HYDROPy/HYDROPy.vcproj | 4 + 5 files changed, 146 insertions(+), 37 deletions(-) create mode 100644 src/HYDROPy/HYDROData_Polyline.sip diff --git a/src/HYDROPy/HYDROData.sip b/src/HYDROPy/HYDROData.sip index 9bb7e82f..16016f2a 100644 --- a/src/HYDROPy/HYDROData.sip +++ b/src/HYDROPy/HYDROData.sip @@ -53,9 +53,9 @@ See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com %Import QtGui/QtGuimod.sip %Include HYDROData_Object.sip -%Include HYDROData_Bathymetry.sip %Include HYDROData_Image.sip - +%Include HYDROData_Polyline.sip +%Include HYDROData_Bathymetry.sip %Include HYDROData_Document.sip diff --git a/src/HYDROPy/HYDROData_Document.sip b/src/HYDROPy/HYDROData_Document.sip index 9c4779ff..4c2bfae1 100644 --- a/src/HYDROPy/HYDROData_Document.sip +++ b/src/HYDROPy/HYDROData_Document.sip @@ -62,14 +62,19 @@ class HYDROData_Document switch( theObject->GetKind() ) { - case KIND_BATHYMETRY: + case KIND_IMAGE: { - aRes = new HYDROData_Bathymetry( *dynamic_cast( theObject ) ); + aRes = new HYDROData_Image( *dynamic_cast( theObject ) ); break; } - case KIND_IMAGE: + case KIND_POLYLINE: { - aRes = new HYDROData_Image( *dynamic_cast( theObject ) ); + aRes = new HYDROData_Polyline( *dynamic_cast( theObject ) ); + break; + } + case KIND_BATHYMETRY: + { + aRes = new HYDROData_Bathymetry( *dynamic_cast( theObject ) ); break; } } diff --git a/src/HYDROPy/HYDROData_Object.sip b/src/HYDROPy/HYDROData_Object.sip index feb7aca2..ba45f00f 100644 --- a/src/HYDROPy/HYDROData_Object.sip +++ b/src/HYDROPy/HYDROData_Object.sip @@ -41,6 +41,10 @@ class HYDROData_Object sipClass = sipClass_HYDROData_Image; break; + case KIND_POLYLINE: + sipClass = sipClass_HYDROData_Polyline; + break; + case KIND_BATHYMETRY: sipClass = sipClass_HYDROData_Bathymetry; break; @@ -55,22 +59,6 @@ class HYDROData_Object } %End -public: - /** - * Visual state data. - */ - struct VisualState - { - bool Visibility; - double Transparency; - double ZValue; - - VisualState(); - }; - - typedef QMap < int, HYDROData_Object::VisualState > ViewId2VisualStateMap; - typedef QMapIterator< int, HYDROData_Object::VisualState > ViewId2VisualStateMapIterator; - public: /** @@ -88,21 +76,6 @@ public: */ void SetName(const QString& theName); - /** - * Returns the object visibility state for the view with specified id. - * \param theViewId view id - * \returns visibility state - */ - bool IsVisible( const int theViewId ) const; - - /** - * Sets the object visibility state for the view with specified id. - * \param theViewId view id - * \param theVal visibility state - */ - void SetVisible( const int theViewId, - const bool theVal ); - /** * Checks is object exists in the data structure. * \returns true is object is not exists in the data model diff --git a/src/HYDROPy/HYDROData_Polyline.sip b/src/HYDROPy/HYDROData_Polyline.sip new file mode 100644 index 00000000..f3b5c582 --- /dev/null +++ b/src/HYDROPy/HYDROData_Polyline.sip @@ -0,0 +1,127 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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. +// +// 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 +// + +%ExportedHeaderCode +#include +%End + +struct PolylineSection +{ +%TypeHeaderCode +#include +%End + + enum SectionType{ SECTION_POLYLINE = 0, SECTION_SPLINE = 1 }; + + PolylineSection(); + + SectionType myType; + bool myIsClosed; + QList myCoords; + + QString mySectionName + { + %GetCode + sipPy = PyString_FromString( TCollection_AsciiString( sipCpp->mySectionName ).ToCString() ); + %End + + %SetCode + char* ptr; + + if ( ( ptr = PyString_AsString( sipPy ) ) == NULL ) + { + sipErr = 1; + } + else + { + sipCpp->mySectionName = TCollection_ExtendedString( ptr ); + } + %End + }; +}; + +class HYDROData_Polyline : HYDROData_Object +{ + +%ConvertToSubClassCode + if ( !Handle(HYDROData_Polyline)::DownCast( sipCpp ).IsNull() ) + sipClass = sipClass_HYDROData_Polyline; + else + sipClass = NULL; +%End + +public: + + const ObjectKind GetKind() const; + +public: + + /** + * Replace current polyline data by new sections list + * \param theSections the sections list + */ + void setPolylineData( const QList& theSections ); + + /** + * Return polyline data + * \return polyline section list + */ + QList getPolylineData(); + + /** + * Return polyline dimension + * \return polyline dimension (2 or 3) + */ + int getDimension() const; + + /** + * Set polyline dimension (2 or 3) + * \param theDimension the polyline dimension + */ + void setDimension( int theDimension ); + + /** + * Remove all sections from polyline + */ + void removeAll(); + + + /** + * Returns the painter path. The painter path is construct by lines + */ + QPainterPath painterPath(); + +protected: + + /** + * Creates new object in the internal data structure. Use higher level objects + * to create objects with real content. + */ + HYDROData_Polyline(); + + /** + * Destructs properties of the object and object itself, removes it from the document. + */ + ~HYDROData_Polyline(); +}; + + diff --git a/src/HYDROPy/HYDROPy.vcproj b/src/HYDROPy/HYDROPy.vcproj index 71b1051d..1b1f8559 100644 --- a/src/HYDROPy/HYDROPy.vcproj +++ b/src/HYDROPy/HYDROPy.vcproj @@ -182,6 +182,10 @@ RelativePath=".\HYDROData_Object.sip" > + +