-// Copyright (C) 2014-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2014-2019 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 <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(STLPlugin)
+typedef GEOM::GenericObjPtr<GEOM::ISTLOperations> STLOpPtr;
+
//=======================================================================
// function : STLPlugin_GUI()
// purpose : Constructor
getGeometryGUI()->getApp()->putInfo( tr("GEOM_PRP_COMMAND").arg( theCommandID ) );
}
- return true;
+ return true; // ?????????
}
//=======================================================================
{
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(), "STLPluginEngine" );
- GEOM::ISTLOperations_var stlOp = GEOM::ISTLOperations::_narrow( op );
- if ( CORBA::is_nil( stlOp ) ) return false;
-
+ GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( "STLPluginEngine" );
+ STLOpPtr stlOp = GEOM::ISTLOperations::_narrow( op );
+ if ( stlOp.isNull() ) return false;
+
QStringList fileNames = app->getOpenFileNames( SUIT_FileDlg::getLastVisitedPath().isEmpty() ? QDir::currentPath() : QString(""),
- tr( "STL_FILES" ),
- tr( "IMPORT_TITLE" ),
- parent );
+ tr( "STL_FILES" ),
+ tr( "IMPORT_TITLE" ),
+ parent );
if ( fileNames.count() > 0 )
{
QStringList entryList;
QStringList errors;
-
+
foreach( QString fileName, fileNames )
{
SUIT_OverrideCursor wc;
- GEOM_Operation transaction( app, stlOp.in() );
-
+ GEOM_Operation transaction( app, stlOp.get() );
+
try
{
- app->putInfo( tr( "GEOM_PRP_LOADING" ).arg( fileName ) );
- transaction.start();
- GEOM::ListOfGO_var result = stlOp->ImportSTL( fileName.toUtf8().constData() );
- if ( result->length() > 0 && stlOp->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() );
-
- entryList.append( so->GetID() );
- transaction.commit();
- GEOM_Displayer( study ).Display( main.in() );
- }
- else
- {
- transaction.abort();
- errors.append( QString( "%1 : %2" ).arg( fileName ).arg( stlOp->GetErrorCode() ) );
- }
+ app->putInfo( tr( "GEOM_PRP_LOADING" ).arg( fileName ) );
+ transaction.start();
+ GEOM::ListOfGO_var result = stlOp->ImportSTL( fileName.toUtf8().constData() );
+ if ( result->length() > 0 && stlOp->IsDone() )
+ {
+ GEOM::GEOM_Object_var main = result[0];
+ QString publishName = GEOMBase::GetDefaultName( SUIT_Tools::file( fileName, true ) );
+ SALOMEDS::SObject_var so = GeometryGUI::GetGeomGen()->PublishInStudy( SALOMEDS::SObject::_nil(),
+ main.in(),
+ publishName.toUtf8().constData() );
+
+ entryList.append( so->GetID() );
+ transaction.commit();
+ GEOM_Displayer().Display( main.in() );
+ main->UnRegister();
+ }
+ else
+ {
+ transaction.abort();
+ errors.append( QString( "%1 : %2" ).arg( fileName ).arg( stlOp->GetErrorCode() ) );
+ }
}
catch( const SALOME::SALOME_Exception& e )
{
- transaction.abort();
+ transaction.abort();
}
}
- getGeometryGUI()->updateObjBrowser( true );
+ getGeometryGUI()->updateObjBrowser();
app->browseObjects( entryList );
-
+
if ( errors.count() > 0 )
{
SUIT_MessageBox::critical( parent,
- tr( "GEOM_ERROR" ),
- tr( "GEOM_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
+ tr( "GEOM_ERROR" ),
+ tr( "GEOM_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
}
}
return fileNames.count() > 0;
{
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(), "STLPluginEngine" );
- GEOM::ISTLOperations_var stlOp = GEOM::ISTLOperations::_narrow( op );
- if ( CORBA::is_nil( stlOp ) ) return false;
+ GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( "STLPluginEngine" );
+ STLOpPtr stlOp = GEOM::ISTLOperations::_narrow( op );
+ if ( stlOp.isNull() ) return false;
LightApp_SelectionMgr* sm = app->selectionMgr();
if ( !sm ) return false;
double deflection = 0.;
bool isRelative = false;
QString fileName = STLPlugin_ExportDlg::getFileName( io,
- tr( "STL_FILES" ),
- tr( "EXPORT_TITLE" ),
- parent,
- isASCII,
- deflection,
- isRelative );
+ tr( "STL_FILES" ),
+ tr( "EXPORT_TITLE" ),
+ parent,
+ isASCII,
+ deflection,
+ isRelative );
if ( fileName.isEmpty() )
return false;
SUIT_OverrideCursor wc;
- GEOM_Operation transaction( app, stlOp.in() );
+ GEOM_Operation transaction( app, stlOp.get() );
try
{
if ( stlOp->IsDone() )
{
- transaction.commit();
+ transaction.commit();
}
else
{
- transaction.abort();
- SUIT_MessageBox::critical( parent,
- tr( "GEOM_ERROR" ),
- tr( "GEOM_PRP_ABORT" ) + "\n" + tr( stlOp->GetErrorCode() ) );
- return false;
+ transaction.abort();
+ SUIT_MessageBox::critical( parent,
+ tr( "GEOM_ERROR" ),
+ tr( "GEOM_PRP_ABORT" ) + "\n" + tr( stlOp->GetErrorCode() ) );
+ return false;
}
}
catch ( const SALOME::SALOME_Exception& e )
if ( !ok )
{
SUIT_MessageBox::warning( parent,
- tr( "WRN_WARNING" ),
- tr( "GEOM_WRN_NO_APPROPRIATE_SELECTION" ) );
+ tr( "WRN_WARNING" ),
+ tr( "GEOM_WRN_NO_APPROPRIATE_SELECTION" ) );
}
return ok;
}