From: adv Date: Mon, 23 Sep 2013 13:02:05 +0000 (+0000) Subject: Python scripting is done forcalculation Regions (Feature #13). X-Git-Tag: BR_hydro_v_0_1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8409849256ec79e1fe34fa460d46f0a91e646606;p=modules%2Fhydro.git Python scripting is done forcalculation Regions (Feature #13). --- diff --git a/src/HYDROData/HYDROData_Calculation.cxx b/src/HYDROData/HYDROData_Calculation.cxx index f11513cc..9514bcbd 100644 --- a/src/HYDROData/HYDROData_Calculation.cxx +++ b/src/HYDROData/HYDROData_Calculation.cxx @@ -60,10 +60,10 @@ QStringList HYDROData_Calculation::DumpToPython( MapOfTreatedObjects& theTreated anIter.Init( aZones ); for ( ; anIter.More(); anIter.Next() ) { - Handle(HYDROData_Zone) aSplittedZone = - Handle(HYDROData_Zone)::DownCast( anIter.Value() ); - if ( !aSplittedZone.IsNull() ) - setPythonReferenceObject( theTreatedObjects, aResList, aSplittedZone, "AddRegion" ); + Handle(HYDROData_Region) aRegion = + Handle(HYDROData_Region)::DownCast( anIter.Value() ); + if ( !aRegion.IsNull() ) + setPythonReferenceObject( theTreatedObjects, aResList, aRegion, "AddRegion" ); } return aResList; diff --git a/src/HYDROPy/HYDROData.sip b/src/HYDROPy/HYDROData.sip index 1ef50c1e..51f6775d 100644 --- a/src/HYDROPy/HYDROData.sip +++ b/src/HYDROPy/HYDROData.sip @@ -56,6 +56,7 @@ See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com %Include HYDROData_Image.sip %Include HYDROData_Polyline.sip %Include HYDROData_Bathymetry.sip +%Include HYDROData_Domain.sip %Include HYDROData_Zone.sip %Include HYDROData_Calculation.sip diff --git a/src/HYDROPy/HYDROData_Document.sip b/src/HYDROPy/HYDROData_Document.sip index a53cada0..e79e16d5 100644 --- a/src/HYDROPy/HYDROData_Document.sip +++ b/src/HYDROPy/HYDROData_Document.sip @@ -87,6 +87,11 @@ class HYDROData_Document aRes = new HYDROData_Zone( *dynamic_cast( theObject ) ); break; } + case KIND_REGION: + { + aRes = new HYDROData_Region( *dynamic_cast( theObject ) ); + break; + } } return aRes; diff --git a/src/HYDROPy/HYDROData_Domain.sip b/src/HYDROPy/HYDROData_Domain.sip new file mode 100644 index 00000000..79f70128 --- /dev/null +++ b/src/HYDROPy/HYDROData_Domain.sip @@ -0,0 +1,161 @@ +// 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 + +class HYDROData_Domain : HYDROData_Object +{ + +%TypeHeaderCode +#include +%End + +%ConvertToSubClassCode + // HYDROData_Object sub-classes provide a unique kind ID. + switch ( sipCpp->GetKind() ) + { + case KIND_REGION: + sipClass = sipClass_HYDROData_Region; + break; + + case KIND_ZONE: + sipClass = sipClass_HYDROData_Zone; + break; + + case KIND_UNKNOWN: + sipClass = sipClass_HYDROData_Object; + break; + + default: + // We don't recognise the type. + sipClass = NULL; + } +%End + +public: + + /** + * Sets filling color for zone. + */ + void SetFillingColor( const QColor& theColor ); + + /** + * Returns filling color of zone. + */ + QColor GetFillingColor() const; + + /** + * Sets border color for zone. + */ + void SetBorderColor( const QColor& theColor ); + + /** + * Returns border color of zone. + */ + QColor GetBorderColor() const; + + /** + * Returns number of bathymetry objects for zone. + */ + int NbBathymetries() const; + + /** + * Add reference bathymetry object for zone. + */ + void AddBathymetry( HYDROData_Bathymetry theBathymetry ) [void (const Handle_HYDROData_Bathymetry&)]; + %MethodCode + + Handle(HYDROData_Bathymetry) aRefBath = + Handle(HYDROData_Bathymetry)::DownCast( createHandle( a0 ) ); + if ( !aRefBath.IsNull() ) + { + Py_BEGIN_ALLOW_THREADS + sipSelfWasArg ? sipCpp->HYDROData_Domain::AddBathymetry( aRefBath ) : + sipCpp->AddBathymetry( aRefBath ); + Py_END_ALLOW_THREADS + } + + %End + + /** + * Change reference bathymetry object with given index for zone. + */ + void SetBathymetry( const int theIndex, + HYDROData_Bathymetry theBathymetry ) [void (const int, const Handle_HYDROData_Bathymetry&)]; + %MethodCode + + Handle(HYDROData_Bathymetry) aRefBath = + Handle(HYDROData_Bathymetry)::DownCast( createHandle( a1 ) ); + if ( !aRefBath.IsNull() ) + { + Py_BEGIN_ALLOW_THREADS + sipSelfWasArg ? sipCpp->HYDROData_Domain::SetBathymetry( a0, aRefBath ) : + sipCpp->SetBathymetry( a0, aRefBath ); + Py_END_ALLOW_THREADS + } + + %End + + /** + * Returns reference bathymetry object of zone by it index. + */ + HYDROData_Bathymetry GetBathymetry( const int theIndex ) const [Handle_HYDROData_Bathymetry (const int)]; + %MethodCode + + Handle(HYDROData_Bathymetry) aRefBath; + + Py_BEGIN_ALLOW_THREADS + aRefBath = sipSelfWasArg ? sipCpp->HYDROData_Domain::GetBathymetry( a0 ) : + sipCpp->GetBathymetry( a0 ); + Py_END_ALLOW_THREADS + + sipRes = (HYDROData_Bathymetry*)createPointer( aRefBath ); + + %End + + /** + * Returns list of all reference bathymetry objects of zone. + */ + //HYDROData_SequenceOfObjects GetBathymetries() const; + + /** + * Clear list of bathymetry objects of zone. + */ + void RemoveBathymetries(); + +protected: + + /** + * Creates new object in the internal data structure. Use higher level objects + * to create objects with real content. + */ + HYDROData_Domain(); + + /** + * Destructs properties of the object and object itself, removes it from the document. + */ + ~HYDROData_Domain(); +}; + + diff --git a/src/HYDROPy/HYDROData_Object.sip b/src/HYDROPy/HYDROData_Object.sip index 5cec249f..1d67675d 100644 --- a/src/HYDROPy/HYDROData_Object.sip +++ b/src/HYDROPy/HYDROData_Object.sip @@ -34,6 +34,7 @@ const ObjectKind KIND_VISUAL_STATE; const ObjectKind KIND_BATHYMETRY; const ObjectKind KIND_CALCULATION; const ObjectKind KIND_ZONE; +const ObjectKind KIND_REGION; class HYDROData_Object { @@ -65,6 +66,10 @@ class HYDROData_Object sipClass = sipClass_HYDROData_Zone; break; + case KIND_REGION: + sipClass = sipClass_HYDROData_Region; + break; + case KIND_UNKNOWN: sipClass = sipClass_HYDROData_Object; break; diff --git a/src/HYDROPy/HYDROData_Region.sip b/src/HYDROPy/HYDROData_Region.sip new file mode 100644 index 00000000..3199acc2 --- /dev/null +++ b/src/HYDROPy/HYDROData_Region.sip @@ -0,0 +1,59 @@ +// 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 + +class HYDROData_Region : HYDROData_Domain +{ + +%TypeHeaderCode +#include +%End + +%ConvertToSubClassCode + if ( !Handle(HYDROData_Region)::DownCast( sipCpp ).IsNull() ) + sipClass = sipClass_HYDROData_Region; + else + sipClass = NULL; +%End + +public: + + const ObjectKind GetKind() const; + +protected: + + /** + * Creates new object in the internal data structure. Use higher level objects + * to create objects with real content. + */ + HYDROData_Region(); + + /** + * Destructs properties of the object and object itself, removes it from the document. + */ + ~HYDROData_Region(); +}; + + diff --git a/src/HYDROPy/HYDROData_Zone.sip b/src/HYDROPy/HYDROData_Zone.sip index 892ef0aa..c7c4bb7e 100644 --- a/src/HYDROPy/HYDROData_Zone.sip +++ b/src/HYDROPy/HYDROData_Zone.sip @@ -24,7 +24,7 @@ #include %End -class HYDROData_Zone : HYDROData_Object +class HYDROData_Zone : HYDROData_Domain { %TypeHeaderCode @@ -44,26 +44,6 @@ public: public: - /** - * Sets filling color for zone. - */ - void SetFillingColor( const QColor& theColor ); - - /** - * Returns filling color of zone. - */ - QColor GetFillingColor() const; - - /** - * Sets border color for zone. - */ - void SetBorderColor( const QColor& theColor ); - - /** - * Returns border color of zone. - */ - QColor GetBorderColor() const; - /** * Sets reference polyline object for zone. */ @@ -104,75 +84,6 @@ public: */ void RemovePolyline(); - /** - * Returns number of bathymetry objects for zone. - */ - int NbBathymetries() const; - - /** - * Add reference bathymetry object for zone. - */ - void AddBathymetry( HYDROData_Bathymetry theBathymetry ) [void (const Handle_HYDROData_Bathymetry&)]; - %MethodCode - - Handle(HYDROData_Bathymetry) aRefBath = - Handle(HYDROData_Bathymetry)::DownCast( createHandle( a0 ) ); - if ( !aRefBath.IsNull() ) - { - Py_BEGIN_ALLOW_THREADS - sipSelfWasArg ? sipCpp->HYDROData_Zone::AddBathymetry( aRefBath ) : - sipCpp->AddBathymetry( aRefBath ); - Py_END_ALLOW_THREADS - } - - %End - - /** - * Change reference bathymetry object with given index for zone. - */ - void SetBathymetry( const int theIndex, - HYDROData_Bathymetry theBathymetry ) [void (const int, const Handle_HYDROData_Bathymetry&)]; - %MethodCode - - Handle(HYDROData_Bathymetry) aRefBath = - Handle(HYDROData_Bathymetry)::DownCast( createHandle( a1 ) ); - if ( !aRefBath.IsNull() ) - { - Py_BEGIN_ALLOW_THREADS - sipSelfWasArg ? sipCpp->HYDROData_Zone::SetBathymetry( a0, aRefBath ) : - sipCpp->SetBathymetry( a0, aRefBath ); - Py_END_ALLOW_THREADS - } - - %End - - /** - * Returns reference bathymetry object of zone by it index. - */ - HYDROData_Bathymetry GetBathymetry( const int theIndex ) const [Handle_HYDROData_Bathymetry (const int)]; - %MethodCode - - Handle(HYDROData_Bathymetry) aRefBath; - - Py_BEGIN_ALLOW_THREADS - aRefBath = sipSelfWasArg ? sipCpp->HYDROData_Zone::GetBathymetry( a0 ) : - sipCpp->GetBathymetry( a0 ); - Py_END_ALLOW_THREADS - - sipRes = (HYDROData_Bathymetry*)createPointer( aRefBath ); - - %End - - /** - * Returns list of all reference bathymetry objects of zone. - */ - //HYDROData_SequenceOfObjects GetBathymetries() const; - - /** - * Clear list of bathymetry objects of zone. - */ - void RemoveBathymetries(); - /** * Returns the painter path. The painter path is construct by polyline */ diff --git a/src/HYDROPy/HYDROPy.vcproj b/src/HYDROPy/HYDROPy.vcproj index ba703b69..bb69aa65 100644 --- a/src/HYDROPy/HYDROPy.vcproj +++ b/src/HYDROPy/HYDROPy.vcproj @@ -178,6 +178,10 @@ RelativePath=".\HYDROData_Document.sip" > + + @@ -190,6 +194,10 @@ RelativePath=".\HYDROData_Polyline.sip" > + +