]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Dump obstacle object to python script.
authoradv <adv@opencascade.com>
Mon, 20 Jan 2014 06:04:03 +0000 (06:04 +0000)
committeradv <adv@opencascade.com>
Mon, 20 Jan 2014 06:04:03 +0000 (06:04 +0000)
src/HYDROData/HYDROData_Obstacle.cxx
src/HYDROData/HYDROData_Obstacle.h
src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx
src/HYDROPy/HYDROData_Obstacle.sip

index 22fcb0f58a6fe263cfe36fbb799a82cf30898685..6a4cb6357e132c7ac79a5a61736174daeaa2b7fb 100644 (file)
@@ -4,12 +4,15 @@
 #include "HYDROData_Document.h"
 #include "HYDROData_ShapesGroup.h"
 #include "HYDROData_ShapesTool.h"
+#include "HYDROData_Tool.h"
 
 #include <Basics_Utils.hxx>
 
 #include <BRepTools.hxx>
 #include <BRep_Builder.hxx>
 
+#include <GEOMBase.h>
+
 #include <IGESControl_Reader.hxx>
 #include <IGESData_IGESModel.hxx>
 
@@ -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() );
index dc78d9f1647a9c4f11cd17caa2b17d8547e2a7df..194dae8bc9d000bdebc80ef115d73b2570958d88 100644 (file)
@@ -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.
index a454cd985c7b5d30393d8eaf06fa7ac81aa6b2d0..60b0384b00a233f824e00ef3eeebc3781e3cf04d 100644 (file)
@@ -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 );
index 06063fd1d4610786a90479d47d9b40922a596fda..ca3e321ce797718f9b9bd5acd3780fd761a87e35 100644 (file)
@@ -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