#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>
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;
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() );
*/
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
* 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.
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 );
*/
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