From 1452be8c2842890c0309ed5bbfce86af6555d439 Mon Sep 17 00:00:00 2001 From: mpa Date: Tue, 13 Jan 2015 13:03:20 +0300 Subject: [PATCH] Some corrections of import/export operations --- idl/{ACISPlugin_Gen.idl => ACISPlugin.idl} | 12 +- idl/CMakeLists.txt | 2 +- src/ACISPluginBuilder.py | 4 +- src/ACISPluginGUI.cxx | 127 -------- ...PluginEngine.cxx => ACISPlugin_Engine.cxx} | 7 +- src/ACISPlugin_Engine.hxx | 2 +- src/ACISPlugin_ExportDlg.cxx | 132 -------- src/ACISPlugin_ExportDlg.h | 52 ---- src/ACISPlugin_ExportDriver.cxx | 1 - src/ACISPlugin_ExportDriver.hxx | 19 +- src/ACISPlugin_GUI.cxx | 284 ++++++++++++++++++ src/{ACISPluginGUI.h => ACISPlugin_GUI.h} | 17 +- src/ACISPlugin_IECallBack.cxx | 24 +- src/ACISPlugin_IECallBack.hxx | 24 +- src/ACISPlugin_IOperations.cxx | 8 +- src/ACISPlugin_IOperations.hxx | 15 +- ...tions_i.cc => ACISPlugin_IOperations_i.cc} | 51 +--- ...tions_i.hh => ACISPlugin_IOperations_i.hh} | 30 +- src/ACISPlugin_ImportDlg.cxx | 173 ----------- src/ACISPlugin_ImportDlg.h | 49 --- src/ACISPlugin_ImportDriver.cxx | 1 - src/ACISPlugin_ImportDriver.hxx | 17 +- ...or.cc => ACISPlugin_OperationsCreator.cxx} | 52 ++-- ...or.hh => ACISPlugin_OperationsCreator.hxx} | 24 +- src/CMakeLists.txt | 32 +- src/resources/ACISPlugin_msg_en.ts | 15 +- src/resources/ACISPlugin_msg_fr.ts | 15 +- src/resources/ACISPlugin_msg_ja.ts | 15 +- 28 files changed, 464 insertions(+), 740 deletions(-) rename idl/{ACISPlugin_Gen.idl => ACISPlugin.idl} (91%) delete mode 100644 src/ACISPluginGUI.cxx rename src/{ACISPluginEngine.cxx => ACISPlugin_Engine.cxx} (85%) delete mode 100644 src/ACISPlugin_ExportDlg.cxx delete mode 100644 src/ACISPlugin_ExportDlg.h create mode 100644 src/ACISPlugin_GUI.cxx rename src/{ACISPluginGUI.h => ACISPlugin_GUI.h} (78%) rename src/{ACISPlugin_Operations_i.cc => ACISPlugin_IOperations_i.cc} (66%) rename src/{ACISPlugin_Operations_i.hh => ACISPlugin_IOperations_i.hh} (63%) delete mode 100644 src/ACISPlugin_ImportDlg.cxx delete mode 100644 src/ACISPlugin_ImportDlg.h rename src/{ACISPlugin_OperationsCreator.cc => ACISPlugin_OperationsCreator.cxx} (59%) rename src/{ACISPlugin_OperationsCreator.hh => ACISPlugin_OperationsCreator.hxx} (69%) mode change 100755 => 100644 diff --git a/idl/ACISPlugin_Gen.idl b/idl/ACISPlugin.idl similarity index 91% rename from idl/ACISPlugin_Gen.idl rename to idl/ACISPlugin.idl index 0fd7d0d..be59e1c 100644 --- a/idl/ACISPlugin_Gen.idl +++ b/idl/ACISPlugin.idl @@ -17,17 +17,17 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef __ACISPlugin_GEN__ -#define __ACISPlugin_GEN__ +#ifndef __ACISPlugin_IDL__ +#define __ACISPlugin_IDL__ #include "GEOM_Gen.idl" -module ACISPlugin { - +module ACISPlugin +{ /*! * \brief Interface for ACISPlugin modeling functions. */ - interface GEOM_IACISPluginOperations : GEOM::GEOM_IOperations + interface IACISOperations : GEOM::GEOM_IOperations { /*! * \brief Export the given shape into a file with given name in ACIS format. @@ -48,4 +48,4 @@ module ACISPlugin { }; }; -#endif +#endif // __ACISPlugin_IDL__ diff --git a/idl/CMakeLists.txt b/idl/CMakeLists.txt index e462ebb..f3d62b4 100755 --- a/idl/CMakeLists.txt +++ b/idl/CMakeLists.txt @@ -31,7 +31,7 @@ IF(WIN32) ENDIF(WIN32) SET(SalomeIDLACISPlugin_IDLSOURCES - ACISPlugin_Gen.idl + ACISPlugin.idl ) SET(IDL_INCLUDE_DIRS diff --git a/src/ACISPluginBuilder.py b/src/ACISPluginBuilder.py index cf4e037..1fcd6f3 100644 --- a/src/ACISPluginBuilder.py +++ b/src/ACISPluginBuilder.py @@ -18,14 +18,14 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -from ACISPlugin import GEOM_IACISPluginOperations +from ACISPlugin import IACISOperations # Engine Library Name __libraryName__ = "ACISPluginEngine" def GetACISPluginOperations(self): anOp = self.GetPluginOperations(self.myStudyId, __libraryName__) - return anOp._narrow(GEOM_IACISPluginOperations) + return anOp._narrow(IACISOperations) ## Export the given shape into a file with given name in ACIS format. # @param theObject Shape to be stored in the file. diff --git a/src/ACISPluginGUI.cxx b/src/ACISPluginGUI.cxx deleted file mode 100644 index 08fb2b6..0000000 --- a/src/ACISPluginGUI.cxx +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (C) 2014 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 -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// internal includes -#include "ACISPluginGUI.h" -#include "ACISPlugin_ExportDlg.h" -#include "ACISPlugin_ImportDlg.h" - -// GUI includes -#include -#include -#include -#include -#include - -// GEOM includes -#include - -//======================================================================= -// function : ACISPluginGUI() -// purpose : Constructor -//======================================================================= -ACISPluginGUI::ACISPluginGUI( GeometryGUI* parent ) : GEOMPluginGUI( parent ) -{ -} - -//======================================================================= -// function : ~ACISPluginGUI -// purpose : Destructor -//======================================================================= -ACISPluginGUI::~ACISPluginGUI() -{ -} - -//======================================================================= -// function : OnGUIEvent() -// purpose : -//======================================================================= -bool ACISPluginGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) -{ - switch ( theCommandID ) { - case 1: - return OnGUIEvent("Export_ACIS", parent); - case 2: - return OnGUIEvent("Import_ACIS", parent); - default: - return OnGUIEvent("", parent); - } - return false; -} - -//======================================================================= -// function : OnGUIEvent() -// purpose : -//======================================================================= -bool ACISPluginGUI::OnGUIEvent( const QString& theCommandID, SUIT_Desktop* parent ) -{ - SalomeApp_Application* app = getGeometryGUI()->getApp(); - if (!app) return false; - - getGeometryGUI()->EmitSignalDeactivateDialog(); - - SUIT_FileDlg* dialog = NULL; - if( theCommandID == "Export_ACIS" ) { - // Get selected objects - LightApp_SelectionMgr* sm = app->selectionMgr(); - if( !sm ) return false; - SALOME_ListIO selectedObjects; - sm->selectedObjects( selectedObjects ); - if( selectedObjects.Extent() == 0 ) { - SUIT_MessageBox::warning( app->desktop(), - QObject::tr("WRN_WARNING"), - QObject::tr("GEOM_WRN_NO_APPROPRIATE_SELECTION") ); - } - else { - SALOME_ListIteratorOfListIO It( selectedObjects ); - for( ; It.More(); It.Next() ) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - dialog = new ACISPlugin_ExportDlg( IObject, parent ); - if( dialog->exec() == QDialog::Accepted ) - delete dialog; - } - } - } - else if (theCommandID == "Import_ACIS") { - dialog = new ACISPlugin_ImportDlg( parent ); - if (dialog != NULL) - dialog->show(); - if( dialog->exec() == QDialog::Accepted ) - delete dialog; - } - else { - app->putInfo( tr("GEOM_PRP_COMMAND").arg( theCommandID ) ); - } - - return true; -} - -//===================================================================================== -// EXPORTED METHODS -//===================================================================================== -extern "C" -{ -#ifdef WIN32 - __declspec( dllexport ) -#endif - GEOMGUI* GetLibGUI( GeometryGUI* parent ) - { - return new ACISPluginGUI( parent ); - } -} diff --git a/src/ACISPluginEngine.cxx b/src/ACISPlugin_Engine.cxx similarity index 85% rename from src/ACISPluginEngine.cxx rename to src/ACISPlugin_Engine.cxx index 63da1ac..74c3999 100644 --- a/src/ACISPluginEngine.cxx +++ b/src/ACISPlugin_Engine.cxx @@ -19,14 +19,13 @@ // internal includes #include "ACISPlugin_Engine.hxx" -#include "ACISPlugin_OperationsCreator.hh" +#include "ACISPlugin_OperationsCreator.hxx" extern "C" { -ACISPLUGINENGINE_EXPORT + ACISPLUGINENGINE_EXPORT GEOM_GenericOperationsCreator* GetOperationsCreator() { - ACISPlugin_OperationsCreator* aCreator = new ACISPlugin_OperationsCreator(); - return aCreator; + return new ACISPlugin_OperationsCreator(); } } diff --git a/src/ACISPlugin_Engine.hxx b/src/ACISPlugin_Engine.hxx index d7dbb92..b91f47c 100755 --- a/src/ACISPlugin_Engine.hxx +++ b/src/ACISPlugin_Engine.hxx @@ -21,7 +21,7 @@ #define _ACISPLUGIN_ENGINE_HXX_ #ifdef WIN32 - #if defined ACISPLUGINENGINE_EXPORTS || defined ACISPLUGINENGINE_EXPORTS + #if defined ACISPLUGINENGINE_EXPORTS || defined ACISPluginEngine_EXPORTS #define ACISPLUGINENGINE_EXPORT __declspec( dllexport ) #else #define ACISPLUGINENGINE_EXPORT __declspec( dllimport ) diff --git a/src/ACISPlugin_ExportDlg.cxx b/src/ACISPlugin_ExportDlg.cxx deleted file mode 100644 index ae96e9d..0000000 --- a/src/ACISPlugin_ExportDlg.cxx +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (C) 2014 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 -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// internal includes -#include "ACISPlugin_ExportDlg.h" -#include "ACISPlugin_Operations_i.hh" - -// GUI includes -#include -#include -#include -#include -#include - -#include - -// GEOM includes -#include -#include -#include - -//================================================================================= -// Constructor -//================================================================================= -ACISPlugin_ExportDlg::ACISPlugin_ExportDlg( Handle(SALOME_InteractiveObject)& object, QWidget* parent ) -: SUIT_FileDlg( parent, false, true, true ), - GEOMBase_Helper( dynamic_cast( parent ) ) -{ - setWindowTitle( tr( "ACISPLUGIN_EXPORT_TITLE" ) ); - setNameFilter( tr( "ACISPLUGIN_ACIS_FILES" ) ); - - myObject = object; - const char* objectName = myObject->getName(); - selectFile( QString( objectName ) ); -} - -//================================================================================= -// Destructor -//================================================================================= -ACISPlugin_ExportDlg::~ACISPlugin_ExportDlg() -{ - // no need to delete child widgets, Qt does it all for us -} - -//================================================================================= -// function : createOperation -// purpose : -//================================================================================= -GEOM::GEOM_IOperations_ptr ACISPlugin_ExportDlg::createOperation() -{ - return getGeomEngine()->GetPluginOperations( getStudyId(), "ACISPluginEngine" ); -} - -//================================================================================= -// function : isValid -// purpose : -//================================================================================= -bool ACISPlugin_ExportDlg::isValid( QString& msg ) -{ - bool ok = true; - //@@ add custom validation actions here @@// - return ok; -} - -//================================================================================= -// function : execute -// purpose : -//================================================================================= -bool ACISPlugin_ExportDlg::execute( ObjectList& objects ) -{ - SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); - if (!app) return false; - - ACISPlugin::GEOM_IACISPluginOperations_var aACISOp = ACISPlugin::GEOM_IACISPluginOperations::_narrow( getOperation() ); - if ( aACISOp->_is_nil() ) return false; - - GEOM::GEOM_Object_var anObj = GEOMBase::ConvertIOinGEOMObject( myObject ); - if ( anObj->_is_nil() ) return false; - - QString aFile = selectedFile(); - - // User has pressed "Cancel" --> stop the operation - if ( aFile.isEmpty() ) - return false; - - GEOM_Operation* anOp = new GEOM_Operation( app, aACISOp.in() ); - try { - SUIT_OverrideCursor wc; - app->putInfo( tr("GEOM_PRP_EXPORT").arg(SUIT_Tools::file( aFile, /*withExten=*/true )) ); - anOp->start(); - aACISOp->ExportACIS( anObj, aFile.toUtf8().constData() ); - if( aACISOp->IsDone() ) - anOp->commit(); - else { - anOp->abort(); - wc.suspend(); - SUIT_MessageBox::critical( app->desktop(), - QObject::tr("GEOM_ERROR"), - QObject::tr("GEOM_PRP_ABORT") + "\n" + QObject::tr( aACISOp->GetErrorCode() ) ); - return false; - } - } - catch( const SALOME::SALOME_Exception& S_ex ) { - anOp->abort(); - return false; - } - - objects.push_back( anObj._retn() ); - return true; -} - -void ACISPlugin_ExportDlg::accept() -{ - SUIT_FileDlg::accept(); - onAccept(false); -} diff --git a/src/ACISPlugin_ExportDlg.h b/src/ACISPlugin_ExportDlg.h deleted file mode 100644 index 5c346a9..0000000 --- a/src/ACISPlugin_ExportDlg.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2014 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 -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef ACISPlugin_ExportDlg_H -#define ACISPlugin_ExportDlg_H - -// GUI includes -#include - -// GEOM includes -#include -#include - - -class ACISPlugin_ExportDlg: public SUIT_FileDlg, public GEOMBase_Helper -{ - Q_OBJECT - -public: - ACISPlugin_ExportDlg( Handle(SALOME_InteractiveObject)&, QWidget* = 0 ); - ~ACISPlugin_ExportDlg(); - -protected: - // redefined from GEOMBase_Helper - virtual GEOM::GEOM_IOperations_ptr createOperation(); - virtual bool isValid( QString& ); - virtual bool execute( ObjectList& ); - -protected slots: - void accept(); - -private: - Handle(SALOME_InteractiveObject) myObject; -}; - -#endif // ACISPlugin_ExportDlg_H diff --git a/src/ACISPlugin_ExportDriver.cxx b/src/ACISPlugin_ExportDriver.cxx index 455033b..3a66932 100644 --- a/src/ACISPlugin_ExportDriver.cxx +++ b/src/ACISPlugin_ExportDriver.cxx @@ -20,7 +20,6 @@ // internal includes #include "ACISPlugin_ExportDriver.hxx" #include "ACISPlugin_IExport.hxx" -#include "ACISPlugin_Engine.hxx" // KERNEL includes #include diff --git a/src/ACISPlugin_ExportDriver.hxx b/src/ACISPlugin_ExportDriver.hxx index f4a79fa..8a6aefa 100644 --- a/src/ACISPlugin_ExportDriver.hxx +++ b/src/ACISPlugin_ExportDriver.hxx @@ -24,26 +24,23 @@ #include // OCCT includes -#ifndef _TFunction_Logbook_HeaderFile #include -#endif DEFINE_STANDARD_HANDLE( ACISPlugin_ExportDriver, GEOM_BaseDriver ); class ACISPlugin_ExportDriver : public GEOM_BaseDriver { public: - Standard_EXPORT ACISPlugin_ExportDriver(); - Standard_EXPORT ~ACISPlugin_ExportDriver() {}; + ACISPlugin_ExportDriver(); + ~ACISPlugin_ExportDriver() {}; - Standard_EXPORT static const Standard_GUID& GetID(); - Standard_EXPORT virtual Standard_Integer Execute( TFunction_Logbook& log ) const; - Standard_EXPORT Standard_Boolean MustExecute( const TFunction_Logbook& ) const; - Standard_EXPORT virtual void Validate( TFunction_Logbook& ) const {} + static const Standard_GUID& GetID(); + virtual Standard_Integer Execute( TFunction_Logbook& log ) const; + Standard_Boolean MustExecute( const TFunction_Logbook& ) const; + virtual void Validate( TFunction_Logbook& ) const {} - Standard_EXPORT virtual - bool GetCreationInformation( std::string& theOperationName, - std::vector& params ); + virtual bool GetCreationInformation( std::string& heOperationName, + std::vector& params ); DEFINE_STANDARD_RTTI( ACISPlugin_ExportDriver ) }; diff --git a/src/ACISPlugin_GUI.cxx b/src/ACISPlugin_GUI.cxx new file mode 100644 index 0000000..3faed45 --- /dev/null +++ b/src/ACISPlugin_GUI.cxx @@ -0,0 +1,284 @@ +// Copyright (C) 2014 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 +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// internal includes +#include "ACISPlugin_GUI.h" +#include "ACISPlugin_IOperations_i.hh" + +// GUI includes +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// GEOM includes +#include "GeometryGUI.h" +#include "GEOM_Operation.h" +#include "GEOMBase.h" +#include "GEOM_Displayer.h" + +#include +#include CORBA_SERVER_HEADER(ACISPlugin) + +//======================================================================= +// function : ACISPlugin_GUI() +// purpose : Constructor +//======================================================================= +ACISPlugin_GUI::ACISPlugin_GUI( GeometryGUI* parent ) : GEOMPluginGUI( parent ) +{ +} + +//======================================================================= +// function : ~ACISPlugin_GUI +// purpose : Destructor +//======================================================================= +ACISPlugin_GUI::~ACISPlugin_GUI() +{ +} + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool ACISPlugin_GUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) +{ + QString cmd; + switch ( theCommandID ) { + case 1: + cmd = "Export_ACIS"; + case 2: + cmd = "Import_ACIS"; + default: + break; + } + return OnGUIEvent( cmd, parent ); +} + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool ACISPlugin_GUI::OnGUIEvent( const QString& theCommandID, SUIT_Desktop* parent ) +{ + bool result = false; + + if ( theCommandID == "Export_ACIS" ) + { + result = exportACIS( parent ); + } + else if ( theCommandID == "Import_ACIS" ) + { + result = importACIS( parent ); + } + else + { + getGeometryGUI()->getApp()->putInfo( tr("GEOM_PRP_COMMAND").arg( theCommandID ) ); + } + return result; +} + +//======================================================================= +// function : importACIS +// purpose : +//======================================================================= +bool ACISPlugin_GUI::importACIS( 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(), "ACISPluginEngine" ); + ACISPlugin::IACISOperations_var acisOp = ACISPlugin::IACISOperations::_narrow( op ); + if ( CORBA::is_nil( acisOp ) ) return false; + + QStringList fileNames = app->getOpenFileNames( SUIT_FileDlg::getLastVisitedPath().isEmpty() ? QDir::currentPath() : QString(""), + tr( "ACIS_FILES" ), + tr( "IMPORT_TITLE" ), + parent ); + if ( fileNames.count() > 0 ) + { + QStringList entryList; + QStringList errors; + + SUIT_MessageBox::StandardButton acisAnswer = SUIT_MessageBox::NoButton; + + foreach( QString fileName, fileNames ) + { + SUIT_OverrideCursor wc; + GEOM_Operation transaction( app, acisOp.in() ); + + try + { + app->putInfo( tr( "GEOM_PRP_LOADING" ).arg( fileName ) ); + transaction.start(); + + if ( acisAnswer != SUIT_MessageBox::YesToAll && acisAnswer != SUIT_MessageBox::NoToAll ) { + SUIT_MessageBox::StandardButtons btns = SUIT_MessageBox::Yes | SUIT_MessageBox::No; + btns = btns | SUIT_MessageBox::YesToAll | SUIT_MessageBox::NoToAll; + acisAnswer = SUIT_MessageBox::question( app->desktop(), + "Question", + tr("GEOM_PUBLISH_NAMED_SHAPES"), + btns | SUIT_MessageBox::Cancel, + SUIT_MessageBox::No ); + if ( acisAnswer == SUIT_MessageBox::Cancel ) { + acisOp->SetErrorCode(OK); + return true; // cancel (break) import operation + } + } + GEOM::ListOfGO_var result = acisOp->ImportACIS( fileName.toUtf8().constData() ); + + if ( result->length() > 0 && acisOp->IsDone() ) { + GEOM::GEOM_Object_var main = result[0]; + QString publishName = GEOMBase::GetDefaultName( SUIT_Tools::file( fileName, true ) ); + main.in()->SetName( publishName.toStdString().c_str() ); + SALOMEDS::SObject_var so = GeometryGUI::GetGeomGen()->PublishInStudy( dsStudy, + SALOMEDS::SObject::_nil(), + main.in(), + publishName.toUtf8().constData() ); + if ( acisAnswer == SUIT_MessageBox::Yes || acisAnswer == SUIT_MessageBox::YesToAll ) + GeometryGUI::GetGeomGen()->PublishNamedShapesInStudy( dsStudy, main.in() ); + + entryList.append( so->GetID() ); + transaction.commit(); + } + else + { + transaction.abort(); + errors.append( QString( "%1 : %2" ).arg( fileName ).arg( acisOp->GetErrorCode() ) ); + } + } + catch( const SALOME::SALOME_Exception& e ) + { + transaction.abort(); + } + } + getGeometryGUI()->updateObjBrowser( true ); + app->browseObjects( entryList ); + + if ( errors.count() > 0 ) + { + SUIT_MessageBox::critical( parent, + tr( "GEOM_ERROR" ), + tr( "GEOM_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) ); + } + } + return fileNames.count() > 0; +} + +//======================================================================= +// function : exportACIS +// purpose : +//======================================================================= +bool ACISPlugin_GUI::exportACIS( 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(), "ACISPluginEngine" ); + ACISPlugin::IACISOperations_var acisOp = ACISPlugin::IACISOperations::_narrow( op ); + if ( CORBA::is_nil( acisOp ) ) return false; + + LightApp_SelectionMgr* sm = app->selectionMgr(); + if ( !sm ) return false; + + SALOME_ListIO selectedObjects; + sm->selectedObjects( selectedObjects ); + bool ok = false; + + SALOME_ListIteratorOfListIO it( selectedObjects ); + for ( ; it.More(); it.Next() ) + { + Handle(SALOME_InteractiveObject) io = it.Value(); + GEOM::GEOM_Object_var obj = GEOMBase::ConvertIOinGEOMObject( io ); + + if ( CORBA::is_nil( obj ) ) continue; + + QString fileName = app->getFileName( false, + QString( io->getName() ), + tr( "ACIS_FILES" ), + tr( "EXPORT_TITLE" ), + parent ); + + if ( fileName.isEmpty() ) + return false; + + SUIT_OverrideCursor wc; + + GEOM_Operation transaction( app, acisOp.in() ); + + try + { + app->putInfo( tr( "GEOM_PRP_EXPORT" ).arg( fileName ) ); + transaction.start(); + + acisOp->ExportACIS( obj, fileName.toUtf8().constData() ); + + if ( acisOp->IsDone() ) + { + transaction.commit(); + } + else + { + transaction.abort(); + SUIT_MessageBox::critical( parent, + tr( "GEOM_ERROR" ), + tr( "GEOM_PRP_ABORT" ) + "\n" + tr( acisOp->GetErrorCode() ) ); + return false; + } + } + catch ( const SALOME::SALOME_Exception& e ) + { + transaction.abort(); + return false; + } + ok = true; + } + + if ( !ok ) + { + SUIT_MessageBox::warning( parent, + tr( "WRN_WARNING" ), + tr( "GEOM_WRN_NO_APPROPRIATE_SELECTION" ) ); + } + return ok; +} + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ +#ifdef WIN32 + __declspec( dllexport ) +#endif + GEOMGUI* GetLibGUI( GeometryGUI* parent ) + { + return new ACISPlugin_GUI( parent ); + } +} diff --git a/src/ACISPluginGUI.h b/src/ACISPlugin_GUI.h similarity index 78% rename from src/ACISPluginGUI.h rename to src/ACISPlugin_GUI.h index f61093c..15a6609 100644 --- a/src/ACISPluginGUI.h +++ b/src/ACISPlugin_GUI.h @@ -17,19 +17,24 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef ACISPluginGUI_H -#define ACISPluginGUI_H +#ifndef ACISPlugin_GUI_H +#define ACISPlugin_GUI_H #include -class ACISPluginGUI: public GEOMPluginGUI +class ACISPlugin_GUI: public GEOMPluginGUI { + Q_OBJECT public: - ACISPluginGUI( GeometryGUI* parent ); - ~ACISPluginGUI(); + ACISPlugin_GUI( GeometryGUI* parent ); + ~ACISPlugin_GUI(); bool OnGUIEvent( int commandId, SUIT_Desktop* ); bool OnGUIEvent( const QString&, SUIT_Desktop* ); + +private: + bool importACIS( SUIT_Desktop* ); + bool exportACIS( SUIT_Desktop* ); }; -#endif // ACISPluginGUI_H +#endif // ACISPlugin_GUI_H diff --git a/src/ACISPlugin_IECallBack.cxx b/src/ACISPlugin_IECallBack.cxx index 5d21b00..d6793fb 100755 --- a/src/ACISPlugin_IECallBack.cxx +++ b/src/ACISPlugin_IECallBack.cxx @@ -19,16 +19,16 @@ // internal includes #include "ACISPlugin_IECallBack.hxx" +#include "ACISPlugin_IOperations.hxx" +#include "ACISPlugin_OperationsCreator.hxx" //============================================================================= /*! * constructor */ //============================================================================= -ACISPlugin_IECallBack::ACISPlugin_IECallBack( ACISPlugin_IOperations* theOperations ) -: GEOMImpl_IECallBack() +ACISPlugin_IECallBack::ACISPlugin_IECallBack() { - myPluginOperations = theOperations; } //============================================================================= @@ -45,11 +45,13 @@ ACISPlugin_IECallBack::~ACISPlugin_IECallBack() * Export */ //============================================================================= -bool ACISPlugin_IECallBack::Export( const Handle(GEOM_Object) theOriginal, - const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& theFormatName ) +bool ACISPlugin_IECallBack::Export( int theDocId, + const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName ) { - myPluginOperations->ExportACIS( theOriginal, theFileName ); + ACISPlugin_IOperations* aPluginOperations = ACISPlugin_OperationsCreator::get( GetEngine(), theDocId ); + aPluginOperations->ExportACIS( theOriginal, theFileName ); return true; } @@ -59,9 +61,11 @@ bool ACISPlugin_IECallBack::Export( const Handle(GEOM_Object) theOriginal, */ //============================================================================= Handle(TColStd_HSequenceOfTransient) -ACISPlugin_IECallBack::Import( const TCollection_AsciiString& theFormatName, - const TCollection_AsciiString& theFileName ) +ACISPlugin_IECallBack::Import( int theDocId, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theFileName ) { - return myPluginOperations->ImportACIS( theFileName ); + ACISPlugin_IOperations* aPluginOperations = ACISPlugin_OperationsCreator::get( GetEngine(), theDocId ); + return aPluginOperations->ImportACIS( theFileName ); } diff --git a/src/ACISPlugin_IECallBack.hxx b/src/ACISPlugin_IECallBack.hxx index cc6b08f..3edb110 100644 --- a/src/ACISPlugin_IECallBack.hxx +++ b/src/ACISPlugin_IECallBack.hxx @@ -30,22 +30,20 @@ // OCC includes #include -class ACISPlugin_IECallBack : public GEOMImpl_IECallBack +class ACISPLUGINENGINE_EXPORT ACISPlugin_IECallBack : public GEOMImpl_IECallBack { public: - Standard_EXPORT ACISPlugin_IECallBack( ACISPlugin_IOperations* theOperations ); - Standard_EXPORT ~ACISPlugin_IECallBack(); + ACISPlugin_IECallBack(); + ~ACISPlugin_IECallBack(); - Standard_EXPORT virtual bool Export( const Handle(GEOM_Object) theOriginal, - const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& theFormatName ); - - Standard_EXPORT virtual - Handle(TColStd_HSequenceOfTransient) Import( const TCollection_AsciiString& theFormatName, - const TCollection_AsciiString& theFileName ); - -private: - ACISPlugin_IOperations* myPluginOperations; + bool Export( int theDocId, + const Handle(GEOM_Object) theOriginal, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName ); + + Handle(TColStd_HSequenceOfTransient) Import( int theDocId, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theFileName ); }; #endif diff --git a/src/ACISPlugin_IOperations.cxx b/src/ACISPlugin_IOperations.cxx index 051b085..d107a03 100644 --- a/src/ACISPlugin_IOperations.cxx +++ b/src/ACISPlugin_IOperations.cxx @@ -60,12 +60,10 @@ ACISPlugin_IOperations::~ACISPlugin_IOperations() * Export a shape to ACIS format * \param theOriginal The shape to export * \param theFileName The name of the file to exported - * \param theIsASCII The format of the exported file (ASCII or Binary) - * \param theDeflection The deflection of the shape to exported */ //============================================================================= void ACISPlugin_IOperations::ExportACIS( const Handle(GEOM_Object) theOriginal, - const TCollection_AsciiString& theFileName ) + const TCollection_AsciiString& theFileName ) { SetErrorCode(KO); if( theOriginal.IsNull() ) return; @@ -90,9 +88,7 @@ void ACISPlugin_IOperations::ExportACIS( const Handle(GEOM_Object) theOrigi //Perform the Export try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if( !GetSolver()->ComputeFunction( aFunction ) ) { SetErrorCode( "Not enough space on disk, or you haven't permissions to write this directory" ); return; @@ -144,9 +140,7 @@ ACISPlugin_IOperations::ImportACIS( const TCollection_AsciiString& theFileName ) Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if( !GetSolver()->ComputeFunction( aFunction ) ) { SetErrorCode( "Import driver failed" ); return NULL; diff --git a/src/ACISPlugin_IOperations.hxx b/src/ACISPlugin_IOperations.hxx index 9a6c367..6e17f9d 100644 --- a/src/ACISPlugin_IOperations.hxx +++ b/src/ACISPlugin_IOperations.hxx @@ -21,19 +21,22 @@ #ifndef _ACISPlugin_IOperations_HXX_ #define _ACISPlugin_IOperations_HXX_ +// internal includes +#include "ACISPlugin_Engine.hxx" + // GEOM includes #include -class ACISPlugin_IOperations: public GEOMImpl_IBaseIEOperations +class ACISPLUGINENGINE_EXPORT ACISPlugin_IOperations: public GEOMImpl_IBaseIEOperations { public: - Standard_EXPORT ACISPlugin_IOperations( GEOM_Engine*, int ); - Standard_EXPORT ~ACISPlugin_IOperations(); + ACISPlugin_IOperations( GEOM_Engine*, int ); + ~ACISPlugin_IOperations(); - Standard_EXPORT void ExportACIS( const Handle(GEOM_Object), - const TCollection_AsciiString& ); + void ExportACIS( const Handle(GEOM_Object), + const TCollection_AsciiString& ); - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) ImportACIS( const TCollection_AsciiString& ); + Handle(TColStd_HSequenceOfTransient) ImportACIS( const TCollection_AsciiString& ); }; #endif diff --git a/src/ACISPlugin_Operations_i.cc b/src/ACISPlugin_IOperations_i.cc similarity index 66% rename from src/ACISPlugin_Operations_i.cc rename to src/ACISPlugin_IOperations_i.cc index 34d14cc..80ac137 100644 --- a/src/ACISPlugin_Operations_i.cc +++ b/src/ACISPlugin_IOperations_i.cc @@ -18,7 +18,8 @@ // // internal includes -#include "ACISPlugin_Operations_i.hh" +#include "ACISPlugin_IOperations_i.hh" +#include "ACISPlugin_IOperations.hxx" #include // KERNEL includes @@ -29,9 +30,9 @@ * constructor: */ //============================================================================= -ACISPlugin_Operations_i::ACISPlugin_Operations_i( PortableServer::POA_ptr thePOA, - GEOM::GEOM_Gen_ptr theEngine, - ::ACISPlugin_IOperations* theImpl ) +ACISPlugin_IOperations_i::ACISPlugin_IOperations_i( PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + ::ACISPlugin_IOperations* theImpl ) :GEOM_IOperations_i( thePOA, theEngine, theImpl ) { MESSAGE( "ACISPlugin_Operations_i::ACISPlugin_Operations_i" ); @@ -42,7 +43,7 @@ ACISPlugin_Operations_i::ACISPlugin_Operations_i( PortableServer::POA_ptr thePOA * destructor */ //============================================================================= -ACISPlugin_Operations_i::~ACISPlugin_Operations_i() +ACISPlugin_IOperations_i::~ACISPlugin_IOperations_i() { MESSAGE( "ACISPlugin_Operations_i::~ACISPlugin_Operations_i" ); } @@ -55,8 +56,8 @@ ACISPlugin_Operations_i::~ACISPlugin_Operations_i() * \param theFileName The name of the exported file */ //============================================================================= -void ACISPlugin_Operations_i::ExportACIS( GEOM::GEOM_Object_ptr theOriginal, - const char* theFileName ) +void ACISPlugin_IOperations_i::ExportACIS( GEOM::GEOM_Object_ptr theOriginal, + const char* theFileName ) { // duplicate the original shape GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate( theOriginal ); @@ -69,10 +70,7 @@ void ACISPlugin_Operations_i::ExportACIS( GEOM::GEOM_Object_ptr theOriginal, if (anOriginal.IsNull()) return; //Export the shape to the file - char* aFileName = strdup( theFileName ); - - GetOperations()->ExportACIS( anOriginal, aFileName ); - free( aFileName ); + GetOperations()->ExportACIS( anOriginal, theFileName ); } //============================================================================= @@ -83,7 +81,7 @@ void ACISPlugin_Operations_i::ExportACIS( GEOM::GEOM_Object_ptr theOriginal, * \return List of GEOM_Objects, containing the created shape and propagation groups. */ //============================================================================= -GEOM::ListOfGO* ACISPlugin_Operations_i::ImportACIS( const char* theFileName ) +GEOM::ListOfGO* ACISPlugin_IOperations_i::ImportACIS( const char* theFileName ) { GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; @@ -91,13 +89,8 @@ GEOM::ListOfGO* ACISPlugin_Operations_i::ImportACIS( const char* theFileName ) GetOperations()->SetNotDone(); //Import the shape from the file - char* aFileName = strdup( theFileName ); - TCollection_AsciiString fileName( aFileName ); - - //Import the shape from the file - Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->ImportACIS( fileName ); + Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->ImportACIS( theFileName ); - free( aFileName ); if( !GetOperations()->IsDone() || aHSeq.IsNull() ) return aSeq._retn(); @@ -110,25 +103,7 @@ GEOM::ListOfGO* ACISPlugin_Operations_i::ImportACIS( const char* theFileName ) return aSeq._retn(); } -//============================================================================= -/*! - * \brief Get version of the plugin. - * \return the version of the plugin -*/ -//============================================================================= - -int ACISPlugin_Operations_i::GetVersion() -{ - return ACISPLUGIN_VERSION; -} -//============================================================================= -/*! - * \brief Get version of the plugin. - * \return the string representation of the plugin's version -*/ -//============================================================================= - -char* ACISPlugin_Operations_i::GetVersionStr() +ACISPlugin_IOperations* ACISPlugin_IOperations_i::GetOperations() { - return (char*)ACISPLUGIN_VERSION_STR; + return (ACISPlugin_IOperations*)GetImpl(); } diff --git a/src/ACISPlugin_Operations_i.hh b/src/ACISPlugin_IOperations_i.hh similarity index 63% rename from src/ACISPlugin_Operations_i.hh rename to src/ACISPlugin_IOperations_i.hh index bb378ea..717eace 100644 --- a/src/ACISPlugin_Operations_i.hh +++ b/src/ACISPlugin_IOperations_i.hh @@ -17,40 +17,36 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef _ACISPlugin_Operations_i_HeaderFile -#define _ACISPlugin_Operations_i_HeaderFile +#ifndef _ACISPlugin_IOperations_i_HeaderFile +#define _ACISPlugin_IOperations_i_HeaderFile // idl includes #include #include CORBA_SERVER_HEADER( GEOM_Gen ) -#include CORBA_SERVER_HEADER( ACISPlugin_Gen ) +#include CORBA_SERVER_HEADER( ACISPlugin ) // internal includes #include "ACISPlugin_Engine.hxx" -#include "ACISPlugin_IOperations.hxx" // GEOM includes #include -class ACISPLUGINENGINE_EXPORT ACISPlugin_Operations_i : - public virtual POA_ACISPlugin::GEOM_IACISPluginOperations, +class ACISPlugin_IOperations; + +class ACISPLUGINENGINE_EXPORT ACISPlugin_IOperations_i : + public virtual POA_ACISPlugin::IACISOperations, public virtual GEOM_IOperations_i { public: - ACISPlugin_Operations_i( PortableServer::POA_ptr thePOA, - GEOM::GEOM_Gen_ptr theEngine, - ::ACISPlugin_IOperations* theImpl ); - ~ACISPlugin_Operations_i(); + ACISPlugin_IOperations_i( PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + ACISPlugin_IOperations* theImpl ); + ~ACISPlugin_IOperations_i(); void ExportACIS( GEOM::GEOM_Object_ptr, const char* ); GEOM::ListOfGO* ImportACIS( const char* ); - // Version information - virtual int GetVersion(); - virtual char* GetVersionStr(); - - ::ACISPlugin_IOperations* GetOperations() - { return (::ACISPlugin_IOperations*)GetImpl(); } + ACISPlugin_IOperations* GetOperations(); }; -#endif +#endif // _ACISPlugin_IOperations_i_HeaderFile diff --git a/src/ACISPlugin_ImportDlg.cxx b/src/ACISPlugin_ImportDlg.cxx deleted file mode 100644 index 79e5000..0000000 --- a/src/ACISPlugin_ImportDlg.cxx +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright (C) 2014 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 -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// internal includes -#include "ACISPlugin_ImportDlg.h" -#include "ACISPlugin_Operations_i.hh" - -// GUI includes -#include -#include -#include -#include -#include -#include - -// GEOM includes -#include -#include -#include - -//================================================================================= -// Constructor -//================================================================================= -ACISPlugin_ImportDlg::ACISPlugin_ImportDlg( QWidget* parent ) -: SUIT_FileDlg( parent, true, true, true ), - GEOMBase_Helper( dynamic_cast( parent ) ) -{ - setWindowTitle( tr( "ACISPLUGIN_IMPORT_TITLE" ) ); - setAcceptMode( AcceptOpen ); - setNameFilter( tr( "ACISPLUGIN_ACIS_FILES" ) ); - setFileMode( QFileDialog::ExistingFiles ); -} - -//================================================================================= -// Destructor -//================================================================================= -ACISPlugin_ImportDlg::~ACISPlugin_ImportDlg() -{ - // no need to delete child widgets, Qt does it all for us -} - -//================================================================================= -// function : createOperation -// purpose : -//================================================================================= -GEOM::GEOM_IOperations_ptr ACISPlugin_ImportDlg::createOperation() -{ - return getGeomEngine()->GetPluginOperations(getStudyId(), "ACISPluginEngine"); -} - -//================================================================================= -// function : isValid -// purpose : -//================================================================================= -bool ACISPlugin_ImportDlg::isValid (QString& msg) -{ - bool ok = true; - //@@ add custom validation actions here @@// - return ok; -} - -//================================================================================= -// function : execute -// purpose : -//================================================================================= -bool ACISPlugin_ImportDlg::execute( ObjectList& objects ) -{ - bool res = false; - GEOM::GEOM_Object_var anObj; - ACISPlugin::GEOM_IACISPluginOperations_var anOper = ACISPlugin::GEOM_IACISPluginOperations::_narrow( getOperation() ); - - SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); - _PTR(Study) aStudy = dynamic_cast ( app->activeStudy() )->studyDS(); - SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy ); - - QStringList fileNames = selectedFiles(); - if ( fileNames.count() == 0 ) - return false; // nothing selected, return - - SUIT_MessageBox::StandardButton acisAnswer = SUIT_MessageBox::NoButton; - - for( int i = 0; i < fileNames.size(); i++ ) { - QString aFileName = fileNames.at( i ); - if ( aFileName.isEmpty() ) - continue; - GEOM_Operation* anOp = new GEOM_Operation( app, anOper.in() ); - try { - app->putInfo( tr( "GEOM_PRP_LOADING" ).arg( SUIT_Tools::file( aFileName.toUtf8().constData(), /*withExten=*/true ) ) ); - anOp->start(); - - if ( acisAnswer != SUIT_MessageBox::YesToAll && acisAnswer != SUIT_MessageBox::NoToAll ) { - SUIT_MessageBox::StandardButtons btns = SUIT_MessageBox::Yes | SUIT_MessageBox::No; - if ( i < fileNames.count()-1 ) btns = btns | SUIT_MessageBox::YesToAll | SUIT_MessageBox::NoToAll; - acisAnswer = SUIT_MessageBox::question( app->desktop(), - "Question",//tr("WRN_WARNING"), - tr("GEOM_PUBLISH_NAMED_SHAPES"), - btns | SUIT_MessageBox::Cancel, - SUIT_MessageBox::No ); - if ( acisAnswer == SUIT_MessageBox::Cancel ) { - anOper->SetErrorCode(OK); - return true; // cancel (break) import operation - } - } - - GEOM::ListOfGO_var anObj = anOper->ImportACIS( aFileName.toUtf8().constData() ); - - if ( anObj->length() > 0 && anOper->IsDone() ) { - GEOM::GEOM_Object_ptr anObjPtr = anObj[0]._retn(); - objects.push_back( anObjPtr ); - QString aPublishObjName = - GEOMBase::GetDefaultName( SUIT_Tools::file( aFileName, /*withExten=*/true ) ); - anObjPtr->SetName( aPublishObjName.toStdString().c_str() ); - - SALOMEDS::SObject_var aSO = - GeometryGUI::GetGeomGen()->PublishInStudy( aDSStudy, - SALOMEDS::SObject::_nil(), - anObjPtr, - aPublishObjName.toLatin1().constData() ); - if ( acisAnswer == SUIT_MessageBox::Yes || acisAnswer == SUIT_MessageBox::YesToAll ) - GeometryGUI::GetGeomGen()->PublishNamedShapesInStudy( aDSStudy, anObjPtr ); - - anOp->commit(); - } - else { - anOp->abort(); - SUIT_MessageBox::critical( app->desktop(), - QObject::tr("GEOM_ERROR"), - QObject::tr("GEOM_PRP_ABORT") + "\n" + QObject::tr( anOper->GetErrorCode() ) ); - } - } - catch( const SALOME::SALOME_Exception& S_ex ) { - anOp->abort(); - } - } - return true; -} - -//================================================================================= -// function : accept -// purpose : -//================================================================================= -void ACISPlugin_ImportDlg::accept() -{ - SUIT_FileDlg::accept(); - onAccept( false ); -} - -//================================================================================= -// function : getObjectName -// purpose : -//================================================================================= -QString ACISPlugin_ImportDlg::getObjectName( GEOM::GEOM_Object_ptr object ) const -{ - if( object->_is_nil() ) - return QString::null; - return object->GetName(); -} diff --git a/src/ACISPlugin_ImportDlg.h b/src/ACISPlugin_ImportDlg.h deleted file mode 100644 index c1583ac..0000000 --- a/src/ACISPlugin_ImportDlg.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2014 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 -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef ACISPlugin_IMPORTDLG_H -#define ACISPlugin_IMPORTDLG_H - -// GUI includes -#include - -// GEOM includes -#include -#include - -class ACISPlugin_ImportDlg: public SUIT_FileDlg, public GEOMBase_Helper -{ - Q_OBJECT - -public: - ACISPlugin_ImportDlg( QWidget* = 0 ); - ~ACISPlugin_ImportDlg(); - -protected: - // redefined from GEOMBase_Helper - virtual GEOM::GEOM_IOperations_ptr createOperation(); - virtual bool isValid( QString& ); - virtual bool execute( ObjectList& ); - virtual QString getObjectName( GEOM::GEOM_Object_ptr object ) const; - -protected slots: - void accept(); -}; - -#endif // ACISPlugin_IMPORTDLG_H diff --git a/src/ACISPlugin_ImportDriver.cxx b/src/ACISPlugin_ImportDriver.cxx index c7cd2ec..efa8ee9 100644 --- a/src/ACISPlugin_ImportDriver.cxx +++ b/src/ACISPlugin_ImportDriver.cxx @@ -20,7 +20,6 @@ // internal includes #include "ACISPlugin_ImportDriver.hxx" #include "ACISPlugin_IImport.hxx" -#include "ACISPlugin_Engine.hxx" // KERNEL includes #include diff --git a/src/ACISPlugin_ImportDriver.hxx b/src/ACISPlugin_ImportDriver.hxx index 120db15..c244140 100644 --- a/src/ACISPlugin_ImportDriver.hxx +++ b/src/ACISPlugin_ImportDriver.hxx @@ -33,17 +33,16 @@ DEFINE_STANDARD_HANDLE( ACISPlugin_ImportDriver, GEOM_BaseDriver ); class ACISPlugin_ImportDriver : public GEOM_BaseDriver { public: - Standard_EXPORT ACISPlugin_ImportDriver(); - Standard_EXPORT ~ACISPlugin_ImportDriver() {}; + ACISPlugin_ImportDriver(); + ~ACISPlugin_ImportDriver() {}; - Standard_EXPORT static const Standard_GUID& GetID(); - Standard_EXPORT virtual Standard_Integer Execute( TFunction_Logbook& log ) const; - Standard_EXPORT Standard_Boolean MustExecute( const TFunction_Logbook& ) const; - Standard_EXPORT virtual void Validate( TFunction_Logbook& ) const {} + static const Standard_GUID& GetID(); + virtual Standard_Integer Execute( TFunction_Logbook& log ) const; + Standard_Boolean MustExecute( const TFunction_Logbook& ) const; + virtual void Validate( TFunction_Logbook& ) const {} - Standard_EXPORT virtual - bool GetCreationInformation( std::string& theOperationName, - std::vector& params ); + virtual bool GetCreationInformation( std::string& theOperationName, + std::vector& params ); DEFINE_STANDARD_RTTI( ACISPlugin_ImportDriver ) }; diff --git a/src/ACISPlugin_OperationsCreator.cc b/src/ACISPlugin_OperationsCreator.cxx similarity index 59% rename from src/ACISPlugin_OperationsCreator.cc rename to src/ACISPlugin_OperationsCreator.cxx index 95d01fe..faab5d7 100644 --- a/src/ACISPlugin_OperationsCreator.cc +++ b/src/ACISPlugin_OperationsCreator.cxx @@ -18,8 +18,8 @@ // // internal includes -#include "ACISPlugin_OperationsCreator.hh" -#include "ACISPlugin_Operations_i.hh" +#include "ACISPlugin_OperationsCreator.hxx" +#include "ACISPlugin_IOperations_i.hh" #include "ACISPlugin_ExportDriver.hxx" #include "ACISPlugin_ImportDriver.hxx" #include "ACISPlugin_IECallBack.hxx" @@ -34,10 +34,24 @@ // OCCT includes #include -//============================================================================ -// function : Create -// purpose : -//============================================================================ +std::map ACISPlugin_OperationsCreator::_mapOfOperations; + +ACISPlugin_OperationsCreator::ACISPlugin_OperationsCreator() +{ + // Register drivers + TFunction_DriverTable::Get()->AddDriver( ACISPlugin_ExportDriver::GetID(), + new ACISPlugin_ExportDriver() ); + TFunction_DriverTable::Get()->AddDriver( ACISPlugin_ImportDriver::GetID(), + new ACISPlugin_ImportDriver() ); + // Register callback + ACISPlugin_IECallBack* callback = new ACISPlugin_IECallBack(); + GEOMImpl_IECallBack::Register( "ACIS", callback ); +} + +ACISPlugin_OperationsCreator::~ACISPlugin_OperationsCreator() +{ +} + GEOM_IOperations_i* ACISPlugin_OperationsCreator::Create( PortableServer::POA_ptr thePOA, int theStudyId, GEOM::GEOM_Gen_ptr theEngine, @@ -45,23 +59,13 @@ GEOM_IOperations_i* ACISPlugin_OperationsCreator::Create( PortableServer::POA_pt { Unexpect aCatch( SALOME_SalomeException ); MESSAGE( "ACISPlugin_OperationsCreator::Create" ); + return new ACISPlugin_IOperations_i( thePOA, theEngine, get( theGenImpl, theStudyId ) ); +} - if (_mapOfOperations.find( theStudyId ) == _mapOfOperations.end() ) { - ACISPlugin_IOperations* anOper = new ACISPlugin_IOperations( theGenImpl, theStudyId ); - _mapOfOperations[theStudyId] = anOper; - - // Import/Export ACIS - TFunction_DriverTable::Get()->AddDriver( ACISPlugin_ExportDriver::GetID(), - new ACISPlugin_ExportDriver() ); - TFunction_DriverTable::Get()->AddDriver( ACISPlugin_ImportDriver::GetID(), - new ACISPlugin_ImportDriver() ); - - ACISPlugin_IECallBack* ACISCallBack = new ACISPlugin_IECallBack( anOper ); - GEOMImpl_IECallBack::Register( "ACIS", ACISCallBack ); - } - - ACISPlugin_Operations_i* aServant = - new ACISPlugin_Operations_i( thePOA, theEngine, _mapOfOperations[theStudyId] ); - - return aServant; +ACISPlugin_IOperations* ACISPlugin_OperationsCreator::get( ::GEOMImpl_Gen* theGenImpl, + int theStudyId ) +{ + if (_mapOfOperations.find( theStudyId ) == _mapOfOperations.end() ) + _mapOfOperations[theStudyId] = new ACISPlugin_IOperations( theGenImpl, theStudyId ); + return _mapOfOperations[theStudyId]; } diff --git a/src/ACISPlugin_OperationsCreator.hh b/src/ACISPlugin_OperationsCreator.hxx old mode 100755 new mode 100644 similarity index 69% rename from src/ACISPlugin_OperationsCreator.hh rename to src/ACISPlugin_OperationsCreator.hxx index 1d803d8..7440cf6 --- a/src/ACISPlugin_OperationsCreator.hh +++ b/src/ACISPlugin_OperationsCreator.hxx @@ -22,7 +22,6 @@ // internal includes #include "ACISPlugin_Engine.hxx" -#include "ACISPlugin_IOperations.hxx" // GEOM includes #include "GEOM_Gen_i.hh" @@ -30,18 +29,29 @@ // C++ includes #include +class ACISPlugin_IOperations; + //===================================================================== // Operations creator //===================================================================== class ACISPLUGINENGINE_EXPORT ACISPlugin_OperationsCreator : public GEOM_GenericOperationsCreator { public: - virtual GEOM_IOperations_i* Create( PortableServer::POA_ptr thePOA, - int theStudyId, - GEOM::GEOM_Gen_ptr theEngine, - ::GEOMImpl_Gen* theGenImpl ); - private: - std::map _mapOfOperations; + ACISPlugin_OperationsCreator(); + ~ACISPlugin_OperationsCreator(); + + GEOM_IOperations_i* Create( PortableServer::POA_ptr thePOA, + int theStudyId, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_Gen* theGenImpl ); + +private: + static ACISPlugin_IOperations* get( ::GEOMImpl_Gen* theGenImpl, + int theStudyId ); + + static std::map _mapOfOperations; + + friend class ACISPlugin_IECallBack; }; #endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e737dd5..0f73a25 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -29,7 +29,6 @@ INCLUDE_DIRECTORIES( ${CAS_INCLUDE_DIRS} ${ACIS_INCLUDE_DIRS} ${KERNEL_INCLUDE_DIRS} - ${GUI_INCLUDE_DIRS} ${PROJECT_BINARY_DIR} ${PROJECT_BINARY_DIR}/idl ) @@ -37,6 +36,8 @@ INCLUDE_DIRECTORIES( IF(SALOME_BUILD_GUI) INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIRS} + ${GUI_INCLUDE_DIRS} + ${GEOM_INCLUDE_DIRS} ) ENDIF() @@ -52,7 +53,7 @@ ADD_DEFINITIONS( ENDIF() # libraries to link to -SET(_link_LIBRARIES +SET(_link_engine_LIBRARIES ${CAS_TKXSBase} ${ACIS_LIBRARIES} ${KERNEL_SALOMEBasics} @@ -66,8 +67,10 @@ SET(_link_LIBRARIES ) IF(SALOME_BUILD_GUI) - SET(_link_LIBRARIES - ${_link_LIBRARIES} + SET(_link_gui_LIBRARIES + SalomeIDLACISPlugin + ${GEOM_GEOMObject} + ${GEOM_GEOMBase} ${GEOM_GEOMBase} ) ENDIF() @@ -76,9 +79,9 @@ ENDIF() # --- headers --- SET(ACISPluginEngine_HEADERS - ACISPlugin_Operations_i.hh + ACISPlugin_IOperations_i.hh ACISPlugin_Engine.hxx - ACISPlugin_OperationsCreator.hh + ACISPlugin_OperationsCreator.hxx ACISPlugin_IOperations.hxx ACISPlugin_IExport.hxx ACISPlugin_IImport.hxx @@ -90,8 +93,7 @@ SET(ACISPluginEngine_HEADERS IF(SALOME_BUILD_GUI) # header files / to be processed by moc SET(_moc_HEADERS - ACISPlugin_ExportDlg.h - ACISPlugin_ImportDlg.h + ACISPlugin_GUI.h ) ENDIF() @@ -102,17 +104,15 @@ IF(SALOME_BUILD_GUI) QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS}) SET(ACISPluginGUI_SOURCES - ACISPluginGUI.cxx - ACISPlugin_ExportDlg.cxx - ACISPlugin_ImportDlg.cxx + ACISPlugin_GUI.cxx ${_moc_SOURCES} ) ENDIF() SET(ACISPluginEngine_SOURCES - ACISPluginEngine.cxx - ACISPlugin_OperationsCreator.cc - ACISPlugin_Operations_i.cc + ACISPlugin_Engine.cxx + ACISPlugin_OperationsCreator.cxx + ACISPlugin_IOperations_i.cc ACISPlugin_IOperations.cxx ACISPlugin_ExportDriver.cxx ACISPlugin_ImportDriver.cxx @@ -136,13 +136,13 @@ SET(_python_ACIS_SCRIPTS # install Engine library ADD_LIBRARY(ACISPluginEngine ${ACISPluginEngine_SOURCES}) -TARGET_LINK_LIBRARIES(ACISPluginEngine ${_link_LIBRARIES}) +TARGET_LINK_LIBRARIES(ACISPluginEngine ${_link_engine_LIBRARIES}) INSTALL(TARGETS ACISPluginEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) # install GUI library IF(SALOME_BUILD_GUI) ADD_LIBRARY(ACISPluginGUI ${ACISPluginGUI_SOURCES}) - TARGET_LINK_LIBRARIES(ACISPluginGUI ${_link_LIBRARIES}) + TARGET_LINK_LIBRARIES(ACISPluginGUI ${_link_gui_LIBRARIES}) INSTALL(TARGETS ACISPluginGUI EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) # install resources QT4_INSTALL_TS_RESOURCES("${ACISPlugin_RESOURCES}" "${SALOME_ACISPLUGIN_INSTALL_RES_DATA}") diff --git a/src/resources/ACISPlugin_msg_en.ts b/src/resources/ACISPlugin_msg_en.ts index 523c0db..dd438a0 100644 --- a/src/resources/ACISPlugin_msg_en.ts +++ b/src/resources/ACISPlugin_msg_en.ts @@ -27,22 +27,19 @@ STB_IMPORTACIS Import ACIS + + + ACISPlugin_GUI - ACISPLUGIN_ACIS_FILES + ACIS_FILES ACIS files( *.sat ) - - - ACISPlugin_ExportDlg - ACISPLUGIN_EXPORT_TITLE + EXPORT_TITLE Export ACIS - - - ACISPlugin_ImportDlg - ACISPLUGIN_IMPORT_TITLE + IMPORT_TITLE Import ACIS diff --git a/src/resources/ACISPlugin_msg_fr.ts b/src/resources/ACISPlugin_msg_fr.ts index d6f7345..49a9413 100644 --- a/src/resources/ACISPlugin_msg_fr.ts +++ b/src/resources/ACISPlugin_msg_fr.ts @@ -27,22 +27,19 @@ STB_IMPORTACIS Importer ACIS + + + ACISPlugin_GUI - ACISPLUGIN_ACIS_FILES + ACIS_FILES ACIS Fichiers( *.sat ) - - - ACISPlugin_ExportDlg - ACISPLUGIN_EXPORT_TITLE + EXPORT_TITLE Exporter ACIS - - - ACISPlugin_ImportDlg - ACISPLUGIN_IMPORT_TITLE + IMPORT_TITLE Importer ACIS diff --git a/src/resources/ACISPlugin_msg_ja.ts b/src/resources/ACISPlugin_msg_ja.ts index 8b1b675..e796fe9 100644 --- a/src/resources/ACISPlugin_msg_ja.ts +++ b/src/resources/ACISPlugin_msg_ja.ts @@ -27,22 +27,19 @@ STB_IMPORTACIS Import ACIS + + + ACISPlugin_GUI - ACISPLUGIN_ACIS_FILES + ACIS_FILES ACIS files( *.sat ) - - - ACISPlugin_ExportDlg - ACISPLUGIN_EXPORT_TITLE + EXPORT_TITLE Export ACIS - - - ACISPlugin_ImportDlg - ACISPLUGIN_IMPORT_TITLE + IMPORT_TITLE Import ACIS -- 2.39.2