X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSTEPPlugin%2FSTEPPlugin_GUI.cxx;h=5da9339867dba4becf435c09f68f629c7e1f020f;hb=b6f0965afb72083a5234f9b4fb0b233adaaf8d9d;hp=66ebd4cc3c6a3b1c68e081d931ae4c8e0da4a1d9;hpb=3c1414974ed3d3b939640fa7c8dd87178e74e8c8;p=modules%2Fgeom.git diff --git a/src/STEPPlugin/STEPPlugin_GUI.cxx b/src/STEPPlugin/STEPPlugin_GUI.cxx index 66ebd4cc3..5da933986 100644 --- a/src/STEPPlugin/STEPPlugin_GUI.cxx +++ b/src/STEPPlugin/STEPPlugin_GUI.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2014-2022 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -36,10 +36,15 @@ #include "GEOM_Operation.h" #include "GEOMBase.h" #include "GEOM_Displayer.h" +#include "GEOM_GenericObjPtr.h" +#include "STEPPlugin_ExportDlg.h" +#include "STEPPlugin_ImportDlg.h" #include #include CORBA_SERVER_HEADER(STEPPlugin) +typedef GEOM::GenericObjPtr STEPOpPtr; + //======================================================================= // function : STEPPlugin_GUI() // purpose : Constructor @@ -106,18 +111,16 @@ bool STEPPlugin_GUI::importSTEP( SUIT_Desktop* parent ) { SalomeApp_Application* app = getGeometryGUI()->getApp(); if ( !app ) return false; - SalomeApp_Study* study = dynamic_cast ( app->activeStudy() ); - if ( !study ) return false; - SALOMEDS::Study_var dsStudy = GeometryGUI::ClientStudyToStudy( study->studyDS() ); - GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "STEPPluginEngine" ); - GEOM::ISTEPOperations_var stepOp = GEOM::ISTEPOperations::_narrow( op ); - if ( CORBA::is_nil( stepOp ) ) return false; + GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( "STEPPluginEngine" ); + STEPOpPtr stepOp = GEOM::ISTEPOperations::_narrow( op ); + if ( stepOp.isNull() ) return false; + + bool isCreateAssemblies = true; + QStringList fileNames = STEPPlugin_ImportDlg::getOpenFileNames + (SUIT_FileDlg::getLastVisitedPath().isEmpty() ? QDir::currentPath() : QString(""), + tr("STEP_FILES"), tr("IMPORT_TITLE"), parent, isCreateAssemblies); - QStringList fileNames = app->getOpenFileNames( SUIT_FileDlg::getLastVisitedPath().isEmpty() ? QDir::currentPath() : QString(""), - tr( "STEP_FILES" ), - tr( "IMPORT_TITLE" ), - parent ); if ( fileNames.count() > 0 ) { QStringList entryList; @@ -128,7 +131,7 @@ bool STEPPlugin_GUI::importSTEP( SUIT_Desktop* parent ) { QString fileName = fileNames.at( i ); SUIT_OverrideCursor wc; - GEOM_Operation transaction( app, stepOp.in() ); + GEOM_Operation transaction( app, stepOp.get() ); bool ignoreUnits = false; try @@ -171,24 +174,25 @@ bool STEPPlugin_GUI::importSTEP( SUIT_Desktop* parent ) } } - GEOM::ListOfGO_var result = stepOp->ImportSTEP( fileName.toUtf8().constData(), ignoreUnits ); + GEOM::ListOfGO_var result = stepOp->ImportSTEP + (fileName.toUtf8().constData(), ignoreUnits, isCreateAssemblies); if ( result->length() > 0 && stepOp->IsDone() ) { GEOM::GEOM_Object_var main = result[0]; QString publishName = GEOMBase::GetDefaultName( SUIT_Tools::file( fileName, true ) ); - SALOMEDS::SObject_var so = GeometryGUI::GetGeomGen()->PublishInStudy( dsStudy, - SALOMEDS::SObject::_nil(), - main.in(), - publishName.toUtf8().constData() ); + SALOMEDS::SObject_var so = GeometryGUI::GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(), + main.in(), + publishName.toUtf8().constData() ); entryList.append( so->GetID() ); for ( int i = 1, n = result->length(); i < n; i++ ) { GEOM::GEOM_Object_ptr group = result[i]; CORBA::String_var grpName = group->GetName(); - GeometryGUI::GetGeomGen()->AddInStudy( dsStudy, group, grpName.in(), main ); + GeometryGUI::GetGeomGen()->AddInStudy( group, grpName.in(), main ); } transaction.commit(); - GEOM_Displayer( study ).Display( main.in() ); + GEOM_Displayer().Display( main.in() ); + main->UnRegister(); } else { @@ -202,7 +206,7 @@ bool STEPPlugin_GUI::importSTEP( SUIT_Desktop* parent ) } } - getGeometryGUI()->updateObjBrowser( true ); + getGeometryGUI()->updateObjBrowser(); app->browseObjects( entryList ); if ( errors.count() > 0 ) @@ -226,10 +230,9 @@ bool STEPPlugin_GUI::exportSTEP( SUIT_Desktop* parent ) SalomeApp_Study* study = dynamic_cast ( app->activeStudy() ); if ( !study ) return false; - SALOMEDS::Study_var dsStudy = GeometryGUI::ClientStudyToStudy( study->studyDS() ); - GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "STEPPluginEngine" ); - GEOM::ISTEPOperations_var stepOp = GEOM::ISTEPOperations::_narrow( op ); - if ( CORBA::is_nil( stepOp ) ) return false; + GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( "STEPPluginEngine" ); + STEPOpPtr stepOp = GEOM::ISTEPOperations::_narrow( op ); + if ( stepOp.isNull() ) return false; LightApp_SelectionMgr* sm = app->selectionMgr(); if ( !sm ) return false; @@ -246,25 +249,26 @@ bool STEPPlugin_GUI::exportSTEP( SUIT_Desktop* parent ) if ( CORBA::is_nil( obj ) ) continue; - QString fileName = app->getFileName( false, - QString( io->getName() ), + GEOM::length_unit anUnit; + QString fileName = STEPPlugin_ExportDlg::getFileName + (QString( io->getName() ), tr( "STEP_FILES" ), tr( "EXPORT_TITLE" ), - parent ); + parent, anUnit); if ( fileName.isEmpty() ) return false; SUIT_OverrideCursor wc; - GEOM_Operation transaction( app, stepOp.in() ); + GEOM_Operation transaction( app, stepOp.get() ); try { app->putInfo( tr( "GEOM_PRP_EXPORT" ).arg( fileName ) ); transaction.start(); - stepOp->ExportSTEP( obj, fileName.toUtf8().constData() ); + stepOp->ExportSTEP( obj, fileName.toUtf8().constData(), anUnit); if ( stepOp->IsDone() ) {