Salome HOME
Copyright update 2022
[modules/geom.git] / src / STEPPlugin / STEPPlugin_GUI.cxx
index 5543266d7845b41240aee421f25afd0948132210..5da9339867dba4becf435c09f68f629c7e1f020f 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2015  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
@@ -38,6 +38,7 @@
 #include "GEOM_Displayer.h"
 #include "GEOM_GenericObjPtr.h"
 #include "STEPPlugin_ExportDlg.h"
+#include "STEPPlugin_ImportDlg.h"
 
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(STEPPlugin)
@@ -110,18 +111,16 @@ bool STEPPlugin_GUI::importSTEP( SUIT_Desktop* parent )
 {
   SalomeApp_Application* app = getGeometryGUI()->getApp();
   if ( !app ) return false;
-  SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*> ( 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::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( "STEPPluginEngine" );
   STEPOpPtr stepOp = GEOM::ISTEPOperations::_narrow( op );
   if ( stepOp.isNull() ) return false;
 
-  QStringList fileNames = app->getOpenFileNames( SUIT_FileDlg::getLastVisitedPath().isEmpty() ? QDir::currentPath() : QString(""),
-                                                tr( "STEP_FILES" ),
-                                                tr( "IMPORT_TITLE" ),
-                                                parent );
+  bool        isCreateAssemblies = true;
+  QStringList fileNames          = STEPPlugin_ImportDlg::getOpenFileNames
+        (SUIT_FileDlg::getLastVisitedPath().isEmpty() ? QDir::currentPath() : QString(""),
+         tr("STEP_FILES"), tr("IMPORT_TITLE"), parent, isCreateAssemblies);
+
   if ( fileNames.count() > 0 )
   {
     QStringList entryList;
@@ -175,24 +174,24 @@ 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
@@ -207,7 +206,7 @@ bool STEPPlugin_GUI::importSTEP( SUIT_Desktop* parent )
       }
     }
 
-    getGeometryGUI()->updateObjBrowser( true );
+    getGeometryGUI()->updateObjBrowser();
     app->browseObjects( entryList );
           
     if ( errors.count() > 0 )
@@ -231,8 +230,7 @@ bool STEPPlugin_GUI::exportSTEP( SUIT_Desktop* parent )
   SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*> ( 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::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( "STEPPluginEngine" );
   STEPOpPtr stepOp = GEOM::ISTEPOperations::_narrow( op );
   if ( stepOp.isNull() ) return false;