From: adv Date: Mon, 20 Jan 2014 06:04:03 +0000 (+0000) Subject: Dump obstacle object to python script. X-Git-Tag: BR_hydro_v_1_0~63 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=97e331dedb6c4a834944e0c47e44e8d7e258edd4;p=modules%2Fhydro.git Dump obstacle object to python script. --- diff --git a/src/HYDROData/HYDROData_Obstacle.cxx b/src/HYDROData/HYDROData_Obstacle.cxx index 22fcb0f5..6a4cb635 100644 --- a/src/HYDROData/HYDROData_Obstacle.cxx +++ b/src/HYDROData/HYDROData_Obstacle.cxx @@ -4,12 +4,15 @@ #include "HYDROData_Document.h" #include "HYDROData_ShapesGroup.h" #include "HYDROData_ShapesTool.h" +#include "HYDROData_Tool.h" #include #include #include +#include + #include #include @@ -53,12 +56,30 @@ HYDROData_Obstacle::~HYDROData_Obstacle() QStringList HYDROData_Obstacle::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const { QStringList aResList = dumpObjectCreation( theTreatedObjects ); - QString aName = GetObjPyName(); + + QString anObstacleName = GetObjPyName(); + + QString aGeomObjectEntry = GetGeomObjectEntry(); + QString aFilePath = GetFilePath(); + + if ( !aGeomObjectEntry.isEmpty() ) + { + QString aSalomeObjName = HYDROData_Tool::GenerateNameForPython( theTreatedObjects, "obstacle_sobj" ); + aResList << QString( "%1 = salome.sg.IDToObject( \"%2\" );" ) + .arg( aSalomeObjName ).arg( aGeomObjectEntry ); - // TODO + aResList << QString( "%1.ImportFromGeomIOR( %2.GetIOR() );" ) + .arg( anObstacleName ).arg( aSalomeObjName ); + } + else if ( !aFilePath.isEmpty() ) + { + aResList << QString( "%1.ImportFromFile( \"%2\" );" ) + .arg( anObstacleName ).arg( aFilePath ); + } aResList << QString( "" ); - aResList << QString( "%1.Update();" ).arg( aName ); + + aResList << QString( "%1.Update();" ).arg( anObstacleName ); aResList << QString( "" ); return aResList; @@ -133,6 +154,18 @@ bool HYDROData_Obstacle::ImportFromFile( const QString& theFilePath ) return aRes; } +bool HYDROData_Obstacle::ImportFromGeomIOR( const QString& theIOR ) +{ + TopoDS_Shape aShape = GEOMBase::GetShapeFromIOR( theIOR ); + if ( aShape.IsNull() ) + return false; + + SetShape3D( aShape ); + SetGeomObjectEntry( theIOR ); + + return true; +} + void HYDROData_Obstacle::SetFilePath( const QString& theFilePath ) { TCollection_AsciiString anAsciiStr( theFilePath.toStdString().c_str() ); diff --git a/src/HYDROData/HYDROData_Obstacle.h b/src/HYDROData/HYDROData_Obstacle.h index dc78d9f1..194dae8b 100644 --- a/src/HYDROData/HYDROData_Obstacle.h +++ b/src/HYDROData/HYDROData_Obstacle.h @@ -83,6 +83,13 @@ public: */ HYDRODATA_EXPORT virtual bool ImportFromFile( const QString& theFilePath ); + /** + * Imports shape from IOR. + * \param theIOR the IOR of Geom object + * \return \c true if shape has been successfully imported + */ + HYDRODATA_EXPORT virtual bool ImportFromGeomIOR( const QString& theIOR ); + /** * Stores the file path of the imported file. * \param theFilePath file path @@ -98,7 +105,7 @@ public: * Stores the study entry of the imported GEOM object. * \param theEntry GEOM object entry */ - HYDRODATA_EXPORT void SetGeomObjectEntry(const QString& theEntry); + HYDRODATA_EXPORT void SetGeomObjectEntry( const QString& theEntry ); /** * Returns the imported GEOM object entry. diff --git a/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx b/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx index a454cd98..60b0384b 100644 --- a/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx @@ -215,6 +215,7 @@ bool HYDROGUI_ImportGeomObjectOp::processApply( int& theUpdateFlags, Handle(HYDROData_Obstacle) anObstacle = Handle(HYDROData_Obstacle)::DownCast( anObject ); anObstacle->SetFillingColor( HYDROData_Obstacle::DefaultFillingColor() ); anObstacle->SetBorderColor( HYDROData_Obstacle::DefaultBorderColor() ); + anObstacle->SetGeomObjectEntry( anEntry ); } else if ( myOpType == ImportSelectedAsPolyline ) { anObject = doc()->CreateObject( KIND_POLYLINEXY ); Handle(HYDROData_PolylineXY) aPolylineObj = Handle(HYDROData_PolylineXY)::DownCast( anObject ); diff --git a/src/HYDROPy/HYDROData_Obstacle.sip b/src/HYDROPy/HYDROData_Obstacle.sip index 06063fd1..ca3e321c 100644 --- a/src/HYDROPy/HYDROData_Obstacle.sip +++ b/src/HYDROPy/HYDROData_Obstacle.sip @@ -56,6 +56,14 @@ public: */ bool ImportFromFile( const QString& theFilePath ); + + /** + * Imports shape from IOR. + * \param theIOR the IOR of Geom object + * \return \c true if shape has been successfully imported + */ + bool ImportFromGeomIOR( const QString& theIOR ); + /** * Stores the file path of the imported file. * \param theFilePath file path