-// 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
#include "GEOM_Operation.h"
#include "GEOMBase.h"
#include "GEOM_Displayer.h"
+#include "GEOM_GenericObjPtr.h"
+#include "STEPPlugin_ExportDlg.h"
+#include "STEPPlugin_ImportDlg.h"
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(STEPPlugin)
+typedef GEOM::GenericObjPtr<GEOM::ISTEPOperations> STEPOpPtr;
+
//=======================================================================
// function : STEPPlugin_GUI()
// purpose : Constructor
{
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::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;
{
QString fileName = fileNames.at( i );
SUIT_OverrideCursor wc;
- GEOM_Operation transaction( app, stepOp.in() );
+ GEOM_Operation transaction( app, stepOp.get() );
bool ignoreUnits = false;
try
}
}
- 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
{
}
}
- getGeometryGUI()->updateObjBrowser( true );
+ getGeometryGUI()->updateObjBrowser();
app->browseObjects( entryList );
if ( errors.count() > 0 )
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::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;
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() )
{