From: mpa Date: Tue, 13 Jan 2015 13:54:18 +0000 (+0300) Subject: Some corrections of import operation X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=276becdc5d2eeccd63e805587021dc5a9f757956;p=plugins%2Fxtplugin.git Some corrections of import operation --- diff --git a/idl/CMakeLists.txt b/idl/CMakeLists.txt index 72cd17f..121bda3 100755 --- a/idl/CMakeLists.txt +++ b/idl/CMakeLists.txt @@ -31,7 +31,7 @@ IF(WIN32) ENDIF(WIN32) SET(SalomeIDLXTPlugin_IDLSOURCES - XTPlugin_Gen.idl + XTPlugin.idl ) SET(IDL_INCLUDE_DIRS diff --git a/idl/XTPlugin.idl b/idl/XTPlugin.idl new file mode 100644 index 0000000..05e8e97 --- /dev/null +++ b/idl/XTPlugin.idl @@ -0,0 +1,42 @@ +// 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 __XTPlugin_IDL__ +#define __XTPlugin_IDL__ + +#include "GEOM_Gen.idl" + +module XTPlugin +{ + /*! + * \brief Interface for XTPlugin modeling functions. + */ + interface IXTOperations : GEOM::GEOM_IOperations + { + /*! + * \brief Import a shape from the XT file. + * + * \param theFileName The file, containing the shape. + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ + GEOM::ListOfGO ImportXT( in string theFileName ); + }; +}; + +#endif // __XTPlugin_IDL__ diff --git a/idl/XTPlugin_Gen.idl b/idl/XTPlugin_Gen.idl deleted file mode 100644 index 3e36727..0000000 --- a/idl/XTPlugin_Gen.idl +++ /dev/null @@ -1,42 +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 __XTPlugin_GEN__ -#define __XTPlugin_GEN__ - -#include "GEOM_Gen.idl" - -module XTPlugin { - - /*! - * \brief Interface for XTPlugin modeling functions. - */ - interface GEOM_IXTPluginOperations : GEOM::GEOM_IOperations - { - /*! - * \brief Import a shape from the XT file. - * - * \param theFileName The file, containing the shape. - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ - GEOM::ListOfGO ImportXT( in string theFileName ); - }; -}; - -#endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c6c5768..e50527e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -29,7 +29,6 @@ INCLUDE_DIRECTORIES( ${CAS_INCLUDE_DIRS} ${XT_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} ${XT_LIBRARIES} ${KERNEL_SALOMEBasics} @@ -66,8 +67,10 @@ SET(_link_LIBRARIES ) IF(SALOME_BUILD_GUI) - SET(_link_LIBRARIES - ${_link_LIBRARIES} + SET(_link_gui_LIBRARIES + SalomeIDLXTPlugin + ${GEOM_GEOMObject} + ${GEOM_GEOMBase} ${GEOM_GEOMBase} ) ENDIF() @@ -76,9 +79,9 @@ ENDIF() # --- headers --- SET(XTPluginEngine_HEADERS - XTPlugin_Operations_i.hh + XTPlugin_IOperations_i.hh XTPlugin_Engine.hxx - XTPlugin_OperationsCreator.hh + XTPlugin_OperationsCreator.hxx XTPlugin_IOperations.hxx XTPlugin_IImport.hxx XTPlugin_ImportDriver.hxx @@ -88,7 +91,7 @@ SET(XTPluginEngine_HEADERS IF(SALOME_BUILD_GUI) # header files / to be processed by moc SET(_moc_HEADERS - XTPlugin_ImportDlg.h + XTPlugin_GUI.h ) ENDIF() @@ -99,16 +102,15 @@ IF(SALOME_BUILD_GUI) QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS}) SET(XTPluginGUI_SOURCES - XTPluginGUI.cxx - XTPlugin_ImportDlg.cxx + XTPlugin_GUI.cxx ${_moc_SOURCES} ) ENDIF() SET(XTPluginEngine_SOURCES - XTPluginEngine.cxx - XTPlugin_OperationsCreator.cc - XTPlugin_Operations_i.cc + XTPlugin_Engine.cxx + XTPlugin_OperationsCreator.cxx + XTPlugin_IOperations_i.cc XTPlugin_IOperations.cxx XTPlugin_ImportDriver.cxx XTPlugin_IECallBack.cxx @@ -131,13 +133,13 @@ SET(_python_XT_SCRIPTS # install Engine library ADD_LIBRARY(XTPluginEngine ${XTPluginEngine_SOURCES}) -TARGET_LINK_LIBRARIES(XTPluginEngine ${_link_LIBRARIES}) +TARGET_LINK_LIBRARIES(XTPluginEngine ${_link_engine_LIBRARIES}) INSTALL(TARGETS XTPluginEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) # install GUI library IF(SALOME_BUILD_GUI) ADD_LIBRARY(XTPluginGUI ${XTPluginGUI_SOURCES}) - TARGET_LINK_LIBRARIES(XTPluginGUI ${_link_LIBRARIES}) + TARGET_LINK_LIBRARIES(XTPluginGUI ${_link_gui_LIBRARIES}) INSTALL(TARGETS XTPluginGUI EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) # install resources QT4_INSTALL_TS_RESOURCES("${XTPlugin_RESOURCES}" "${SALOME_XTPLUGIN_INSTALL_RES_DATA}") diff --git a/src/XTPluginBuilder.py b/src/XTPluginBuilder.py index 20611c2..7c4ae02 100644 --- a/src/XTPluginBuilder.py +++ b/src/XTPluginBuilder.py @@ -18,14 +18,14 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -from XTPlugin import GEOM_IXTPluginOperations +from XTPlugin import IXTOperations # Engine Library Name __libraryName__ = "XTPluginEngine" def GetXTPluginOperations(self): anOp = self.GetPluginOperations(self.myStudyId, __libraryName__) - return anOp._narrow(GEOM_IXTPluginOperations) + return anOp._narrow(IXTOperations) ## Import a shape from the XT file # @param theFileName The file, containing the shape. diff --git a/src/XTPluginEngine.cxx b/src/XTPluginEngine.cxx deleted file mode 100644 index b0dd35a..0000000 --- a/src/XTPluginEngine.cxx +++ /dev/null @@ -1,32 +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 "XTPlugin_Engine.hxx" -#include "XTPlugin_OperationsCreator.hh" - -extern "C" -{ -XTPLUGINENGINE_EXPORT - GEOM_GenericOperationsCreator* GetOperationsCreator() - { - XTPlugin_OperationsCreator* aCreator = new XTPlugin_OperationsCreator(); - return aCreator; - } -} diff --git a/src/XTPluginGUI.cxx b/src/XTPluginGUI.cxx deleted file mode 100644 index ceb94bc..0000000 --- a/src/XTPluginGUI.cxx +++ /dev/null @@ -1,103 +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 "XTPluginGUI.h" -#include "XTPlugin_ImportDlg.h" - -// GUI includes -#include -#include -#include -#include -#include - -// GEOM includes -#include - -//======================================================================= -// function : XTPluginGUI() -// purpose : Constructor -//======================================================================= -XTPluginGUI::XTPluginGUI( GeometryGUI* parent ) : GEOMPluginGUI( parent ) -{ -} - -//======================================================================= -// function : ~XTPluginGUI -// purpose : Destructor -//======================================================================= -XTPluginGUI::~XTPluginGUI() -{ -} - -//======================================================================= -// function : OnGUIEvent() -// purpose : -//======================================================================= -bool XTPluginGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) -{ - switch ( theCommandID ) { - case 1: - return OnGUIEvent("Import_XT", parent); - default: - return OnGUIEvent("", parent); - } - return false; -} - -//======================================================================= -// function : OnGUIEvent() -// purpose : -//======================================================================= -bool XTPluginGUI::OnGUIEvent( const QString& theCommandID, SUIT_Desktop* parent ) -{ - SalomeApp_Application* app = getGeometryGUI()->getApp(); - if (!app) return false; - - getGeometryGUI()->EmitSignalDeactivateDialog(); - - SUIT_FileDlg* dialog = NULL; - if (theCommandID == "Import_XT") { - dialog = new XTPlugin_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 XTPluginGUI( parent ); - } -} diff --git a/src/XTPluginGUI.h b/src/XTPluginGUI.h deleted file mode 100644 index b40daec..0000000 --- a/src/XTPluginGUI.h +++ /dev/null @@ -1,35 +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 XTPluginGUI_H -#define XTPluginGUI_H - -#include - -class XTPluginGUI: public GEOMPluginGUI -{ -public: - XTPluginGUI( GeometryGUI* parent ); - ~XTPluginGUI(); - - bool OnGUIEvent( int commandId, SUIT_Desktop* ); - bool OnGUIEvent( const QString&, SUIT_Desktop* ); -}; - -#endif // XTPluginGUI_H diff --git a/src/XTPlugin_Engine.cxx b/src/XTPlugin_Engine.cxx new file mode 100644 index 0000000..3fac07c --- /dev/null +++ b/src/XTPlugin_Engine.cxx @@ -0,0 +1,31 @@ +// 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 "XTPlugin_Engine.hxx" +#include "XTPlugin_OperationsCreator.hxx" + +extern "C" +{ + XTPLUGINENGINE_EXPORT + GEOM_GenericOperationsCreator* GetOperationsCreator() + { + return new XTPlugin_OperationsCreator(); + } +} diff --git a/src/XTPlugin_Engine.hxx b/src/XTPlugin_Engine.hxx index de7aaf3..005bdeb 100755 --- a/src/XTPlugin_Engine.hxx +++ b/src/XTPlugin_Engine.hxx @@ -21,7 +21,7 @@ #define _XTPLUGIN_ENGINE_HXX_ #ifdef WIN32 - #if defined XTPLUGINENGINE_EXPORTS || defined XTPLUGINENGINE_EXPORTS + #if defined XTPLUGINENGINE_EXPORTS || defined XTPluginEngine_EXPORTS #define XTPLUGINENGINE_EXPORT __declspec( dllexport ) #else #define XTPLUGINENGINE_EXPORT __declspec( dllimport ) diff --git a/src/XTPlugin_GUI.cxx b/src/XTPlugin_GUI.cxx new file mode 100644 index 0000000..2e9d98f --- /dev/null +++ b/src/XTPlugin_GUI.cxx @@ -0,0 +1,181 @@ +// 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 "XTPlugin_GUI.h" +#include "XTPlugin_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(XTPlugin) + +//======================================================================= +// function : XTPlugin_GUI() +// purpose : Constructor +//======================================================================= +XTPlugin_GUI::XTPlugin_GUI( GeometryGUI* parent ) : GEOMPluginGUI( parent ) +{ +} + +//======================================================================= +// function : ~XTPlugin_GUI +// purpose : Destructor +//======================================================================= +XTPlugin_GUI::~XTPlugin_GUI() +{ +} + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool XTPlugin_GUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) +{ + QString cmd; + switch ( theCommandID ) { + case 1: + cmd = "Import_XT"; + default: + break; + } + return OnGUIEvent( cmd, parent ); +} + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool XTPlugin_GUI::OnGUIEvent( const QString& theCommandID, SUIT_Desktop* parent ) +{ + bool result = false; + + if ( theCommandID == "Import_XT" ) + { + result = importXT( parent ); + } + else + { + getGeometryGUI()->getApp()->putInfo( tr("GEOM_PRP_COMMAND").arg( theCommandID ) ); + } + + return result; + +} + +//======================================================================= +// function : importXT +// purpose : +//======================================================================= +bool XTPlugin_GUI::importXT( 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(), "XTPluginEngine" ); + XTPlugin::IXTOperations_var xtOp = XTPlugin::IXTOperations::_narrow( op ); + if ( CORBA::is_nil( xtOp ) ) return false; + + QStringList fileNames = app->getOpenFileNames( SUIT_FileDlg::getLastVisitedPath().isEmpty() ? QDir::currentPath() : QString(""), + tr( "XT_FILES" ), + tr( "IMPORT_TITLE" ), + parent ); + if ( fileNames.count() > 0 ) + { + QStringList entryList; + QStringList errors; + + foreach( QString fileName, fileNames ) + { + SUIT_OverrideCursor wc; + GEOM_Operation transaction( app, xtOp.in() ); + + try + { + app->putInfo( tr( "GEOM_PRP_LOADING" ).arg( fileName ) ); + transaction.start(); + GEOM::ListOfGO_var result = xtOp->ImportXT( fileName.toUtf8().constData() ); + if ( result->length() > 0 && xtOp->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( xtOp->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; +} + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ +#ifdef WIN32 + __declspec( dllexport ) +#endif + GEOMGUI* GetLibGUI( GeometryGUI* parent ) + { + return new XTPlugin_GUI( parent ); + } +} diff --git a/src/XTPlugin_GUI.h b/src/XTPlugin_GUI.h new file mode 100644 index 0000000..1231345 --- /dev/null +++ b/src/XTPlugin_GUI.h @@ -0,0 +1,39 @@ +// 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 XTPlugin_GUI_H +#define XTPlugin_GUI_H + +#include + +class XTPlugin_GUI: public GEOMPluginGUI +{ + Q_OBJECT +public: + XTPlugin_GUI( GeometryGUI* parent ); + ~XTPlugin_GUI(); + + bool OnGUIEvent( int commandId, SUIT_Desktop* ); + bool OnGUIEvent( const QString&, SUIT_Desktop* ); + +private: + bool importXT( SUIT_Desktop* ); +}; + +#endif // XTPlugin_GUI_H diff --git a/src/XTPlugin_IECallBack.cxx b/src/XTPlugin_IECallBack.cxx index dd2d643..c782013 100755 --- a/src/XTPlugin_IECallBack.cxx +++ b/src/XTPlugin_IECallBack.cxx @@ -19,16 +19,16 @@ // internal includes #include "XTPlugin_IECallBack.hxx" +#include "XTPlugin_IOperations.hxx" +#include "XTPlugin_OperationsCreator.hxx" //============================================================================= /*! * constructor */ //============================================================================= -XTPlugin_IECallBack::XTPlugin_IECallBack( XTPlugin_IOperations* theOperations ) -: GEOMImpl_IECallBack() +XTPlugin_IECallBack::XTPlugin_IECallBack() { - myPluginOperations = theOperations; } //============================================================================= @@ -46,9 +46,11 @@ XTPlugin_IECallBack::~XTPlugin_IECallBack() */ //============================================================================= Handle(TColStd_HSequenceOfTransient) -XTPlugin_IECallBack::Import( const TCollection_AsciiString& theFormatName, - const TCollection_AsciiString& theFileName ) +XTPlugin_IECallBack::Import( int theDocId, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theFileName ) { - return myPluginOperations->ImportXT( theFileName ); + XTPlugin_IOperations* aPluginOperations = XTPlugin_OperationsCreator::get( GetEngine(), theDocId ); + return aPluginOperations->ImportXT( theFileName ); } diff --git a/src/XTPlugin_IECallBack.hxx b/src/XTPlugin_IECallBack.hxx index 5537b93..975e7e1 100644 --- a/src/XTPlugin_IECallBack.hxx +++ b/src/XTPlugin_IECallBack.hxx @@ -30,18 +30,15 @@ // OCC includes #include -class XTPlugin_IECallBack : public GEOMImpl_IECallBack +class XTPLUGINENGINE_EXPORT XTPlugin_IECallBack : public GEOMImpl_IECallBack { public: - Standard_EXPORT XTPlugin_IECallBack( XTPlugin_IOperations* theOperations ); - Standard_EXPORT ~XTPlugin_IECallBack(); + XTPlugin_IECallBack(); + ~XTPlugin_IECallBack(); - Standard_EXPORT virtual - Handle(TColStd_HSequenceOfTransient) Import( const TCollection_AsciiString& theFormatName, - const TCollection_AsciiString& theFileName ); - -private: - XTPlugin_IOperations* myPluginOperations; + Handle(TColStd_HSequenceOfTransient) Import( int theDocId, + const TCollection_AsciiString& theFormatName, + const TCollection_AsciiString& theFileName ); }; #endif diff --git a/src/XTPlugin_IOperations.cxx b/src/XTPlugin_IOperations.cxx index f2268c3..411be1f 100644 --- a/src/XTPlugin_IOperations.cxx +++ b/src/XTPlugin_IOperations.cxx @@ -85,9 +85,7 @@ XTPlugin_IOperations::ImportXT( 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/XTPlugin_IOperations.hxx b/src/XTPlugin_IOperations.hxx index cdd8f37..d259c99 100644 --- a/src/XTPlugin_IOperations.hxx +++ b/src/XTPlugin_IOperations.hxx @@ -21,16 +21,19 @@ #ifndef _XTPlugin_IOperations_HXX_ #define _XTPlugin_IOperations_HXX_ +// internal includes +#include "XTPlugin_Engine.hxx" + // GEOM includes #include -class XTPlugin_IOperations: public GEOMImpl_IBaseIEOperations +class XTPLUGINENGINE_EXPORT XTPlugin_IOperations: public GEOMImpl_IBaseIEOperations { public: - Standard_EXPORT XTPlugin_IOperations( GEOM_Engine*, int ); - Standard_EXPORT ~XTPlugin_IOperations(); + XTPlugin_IOperations( GEOM_Engine*, int ); + ~XTPlugin_IOperations(); - Standard_EXPORT Handle(TColStd_HSequenceOfTransient) ImportXT( const TCollection_AsciiString& ); + Handle(TColStd_HSequenceOfTransient) ImportXT( const TCollection_AsciiString& ); }; #endif diff --git a/src/XTPlugin_IOperations_i.cc b/src/XTPlugin_IOperations_i.cc new file mode 100644 index 0000000..47dcac8 --- /dev/null +++ b/src/XTPlugin_IOperations_i.cc @@ -0,0 +1,84 @@ +// 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 "XTPlugin_IOperations_i.hh" +#include "XTPlugin_IOperations.hxx" +#include + +// KERNEL includes +#include + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +XTPlugin_IOperations_i::XTPlugin_IOperations_i( PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + ::XTPlugin_IOperations* theImpl ) +:GEOM_IOperations_i( thePOA, theEngine, theImpl ) +{ + MESSAGE( "XTPlugin_Operations_i::XTPlugin_Operations_i" ); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +XTPlugin_IOperations_i::~XTPlugin_IOperations_i() +{ + MESSAGE( "XTPlugin_Operations_i::~XTPlugin_Operations_i" ); +} + +//============================================================================= +/*! + * ImportXT + * Import a shape from XT format + * \param theFileName The name of the file to import + * \return List of GEOM_Objects, containing the created shape and propagation groups. + */ +//============================================================================= +GEOM::ListOfGO* XTPlugin_IOperations_i::ImportXT( const char* theFileName ) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Import the shape from the file + Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->ImportXT( theFileName ); + + if( !GetOperations()->IsDone() || aHSeq.IsNull() ) + return aSeq._retn(); + + // Copy created objects. + Standard_Integer aLength = aHSeq->Length(); + aSeq->length( aLength ); + for( Standard_Integer i = 1; i <= aLength; i++ ) + aSeq[i-1] = GetObject( Handle(GEOM_Object)::DownCast( aHSeq->Value(i) ) ); + + return aSeq._retn(); +} + +XTPlugin_IOperations* XTPlugin_IOperations_i::GetOperations() +{ + return (XTPlugin_IOperations*)GetImpl(); +} diff --git a/src/XTPlugin_IOperations_i.hh b/src/XTPlugin_IOperations_i.hh new file mode 100644 index 0000000..5fea3b9 --- /dev/null +++ b/src/XTPlugin_IOperations_i.hh @@ -0,0 +1,51 @@ +// 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 _XTPlugin_IOperations_i_HeaderFile +#define _XTPlugin_IOperations_i_HeaderFile + +// idl includes +#include +#include CORBA_SERVER_HEADER( GEOM_Gen ) +#include CORBA_SERVER_HEADER( XTPlugin ) + +// internal includes +#include "XTPlugin_Engine.hxx" + +// GEOM includes +#include + +class XTPlugin_IOperations; + +class XTPLUGINENGINE_EXPORT XTPlugin_IOperations_i : + public virtual POA_XTPlugin::IXTOperations, + public virtual GEOM_IOperations_i +{ +public: + XTPlugin_IOperations_i( PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + XTPlugin_IOperations* theImpl ); + ~XTPlugin_IOperations_i(); + + GEOM::ListOfGO* ImportXT( const char* ); + + XTPlugin_IOperations* GetOperations(); +}; + +#endif // _XTPlugin_IOperations_i_HeaderFile diff --git a/src/XTPlugin_ImportDlg.cxx b/src/XTPlugin_ImportDlg.cxx deleted file mode 100644 index d5f962d..0000000 --- a/src/XTPlugin_ImportDlg.cxx +++ /dev/null @@ -1,142 +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 "XTPlugin_ImportDlg.h" -#include "XTPlugin_Operations_i.hh" - -// GUI includes -#include -#include -#include -#include -#include - -// GEOM includes -#include -#include - -//================================================================================= -// Constructor -//================================================================================= -XTPlugin_ImportDlg::XTPlugin_ImportDlg( QWidget* parent ) -: SUIT_FileDlg( parent, true, true, true ), - GEOMBase_Helper( dynamic_cast( parent ) ) -{ - setWindowTitle( tr( "XTPLUGIN_IMPORT_TITLE" ) ); - setAcceptMode( AcceptOpen ); - setNameFilter( tr( "XTPLUGIN_XT_FILES" ) ); - setFileMode( QFileDialog::ExistingFiles ); -} - -//================================================================================= -// Destructor -//================================================================================= -XTPlugin_ImportDlg::~XTPlugin_ImportDlg() -{ - // no need to delete child widgets, Qt does it all for us -} - -//================================================================================= -// function : createOperation -// purpose : -//================================================================================= -GEOM::GEOM_IOperations_ptr XTPlugin_ImportDlg::createOperation() -{ - return getGeomEngine()->GetPluginOperations(getStudyId(), "XTPluginEngine"); -} - -//================================================================================= -// function : isValid -// purpose : -//================================================================================= -bool XTPlugin_ImportDlg::isValid (QString& msg) -{ - bool ok = true; - //@@ add custom validation actions here @@// - return ok; -} - -//================================================================================= -// function : execute -// purpose : -//================================================================================= -bool XTPlugin_ImportDlg::execute( ObjectList& objects ) -{ - bool res = false; - GEOM::GEOM_Object_var anObj; - XTPlugin::GEOM_IXTPluginOperations_var anOper = XTPlugin::GEOM_IXTPluginOperations::_narrow( getOperation() ); - - SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); - - QStringList fileNames = selectedFiles(); - if ( fileNames.count() == 0 ) - return false; // nothing selected, return - - 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(); - GEOM::ListOfGO_var anObj = anOper->ImportXT( 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( fileNames.at( i ), - /*withExten=*/true ) ); - anObjPtr->SetName( aPublishObjName.toStdString().c_str() ); - 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 XTPlugin_ImportDlg::accept() -{ - SUIT_FileDlg::accept(); - onAccept(); -} - -//================================================================================= -// function : getObjectName -// purpose : -//================================================================================= -QString XTPlugin_ImportDlg::getObjectName( GEOM::GEOM_Object_ptr object ) const -{ - if( object->_is_nil() ) - return QString::null; - return object->GetName(); -} diff --git a/src/XTPlugin_ImportDlg.h b/src/XTPlugin_ImportDlg.h deleted file mode 100644 index 0eeb222..0000000 --- a/src/XTPlugin_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 XTPlugin_IMPORTDLG_H -#define XTPlugin_IMPORTDLG_H - -// GUI includes -#include - -// GEOM includes -#include -#include - -class XTPlugin_ImportDlg: public SUIT_FileDlg, public GEOMBase_Helper -{ - Q_OBJECT - -public: - XTPlugin_ImportDlg( QWidget* = 0 ); - ~XTPlugin_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 // XTPlugin_IMPORTDLG_H diff --git a/src/XTPlugin_ImportDriver.hxx b/src/XTPlugin_ImportDriver.hxx index 50f0ed2..6ec1dd2 100644 --- a/src/XTPlugin_ImportDriver.hxx +++ b/src/XTPlugin_ImportDriver.hxx @@ -33,17 +33,16 @@ DEFINE_STANDARD_HANDLE( XTPlugin_ImportDriver, GEOM_BaseDriver ); class XTPlugin_ImportDriver : public GEOM_BaseDriver { public: - Standard_EXPORT XTPlugin_ImportDriver(); - Standard_EXPORT ~XTPlugin_ImportDriver() {}; + XTPlugin_ImportDriver(); + ~XTPlugin_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( XTPlugin_ImportDriver ) }; diff --git a/src/XTPlugin_OperationsCreator.cc b/src/XTPlugin_OperationsCreator.cc deleted file mode 100644 index 30b712d..0000000 --- a/src/XTPlugin_OperationsCreator.cc +++ /dev/null @@ -1,64 +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 "XTPlugin_OperationsCreator.hh" -#include "XTPlugin_Operations_i.hh" -#include "XTPlugin_ImportDriver.hxx" -#include "XTPlugin_IECallBack.hxx" - -// KERNEL includes -#include -#include - -// GEOM includes -#include - -// OCCT includes -#include - -//============================================================================ -// function : Create -// purpose : -//============================================================================ -GEOM_IOperations_i* XTPlugin_OperationsCreator::Create( PortableServer::POA_ptr thePOA, - int theStudyId, - GEOM::GEOM_Gen_ptr theEngine, - ::GEOMImpl_Gen* theGenImpl ) -{ - Unexpect aCatch( SALOME_SalomeException ); - MESSAGE( "XTPlugin_OperationsCreator::Create" ); - - if (_mapOfOperations.find( theStudyId ) == _mapOfOperations.end() ) { - XTPlugin_IOperations* anOper = new XTPlugin_IOperations( theGenImpl, theStudyId ); - _mapOfOperations[theStudyId] = anOper; - - // Import XT - TFunction_DriverTable::Get()->AddDriver( XTPlugin_ImportDriver::GetID(), - new XTPlugin_ImportDriver() ); - - XTPlugin_IECallBack* XTCallBack = new XTPlugin_IECallBack( anOper ); - GEOMImpl_IECallBack::Register( "XT", XTCallBack ); - } - - XTPlugin_Operations_i* aServant = - new XTPlugin_Operations_i( thePOA, theEngine, _mapOfOperations[theStudyId] ); - - return aServant; -} diff --git a/src/XTPlugin_OperationsCreator.cxx b/src/XTPlugin_OperationsCreator.cxx new file mode 100644 index 0000000..a419d73 --- /dev/null +++ b/src/XTPlugin_OperationsCreator.cxx @@ -0,0 +1,68 @@ +// 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 "XTPlugin_OperationsCreator.hxx" +#include "XTPlugin_IOperations_i.hh" +#include "XTPlugin_ImportDriver.hxx" +#include "XTPlugin_IECallBack.hxx" + +// KERNEL includes +#include +#include + +// GEOM includes +#include + +// OCCT includes +#include + +std::map XTPlugin_OperationsCreator::_mapOfOperations; + +XTPlugin_OperationsCreator::XTPlugin_OperationsCreator() +{ + // Register drivers + TFunction_DriverTable::Get()->AddDriver( XTPlugin_ImportDriver::GetID(), + new XTPlugin_ImportDriver() ); + // Register callback + XTPlugin_IECallBack* callback = new XTPlugin_IECallBack(); + GEOMImpl_IECallBack::Register( "XT", callback ); +} + +XTPlugin_OperationsCreator::~XTPlugin_OperationsCreator() +{ +} + +GEOM_IOperations_i* XTPlugin_OperationsCreator::Create( PortableServer::POA_ptr thePOA, + int theStudyId, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_Gen* theGenImpl ) +{ + Unexpect aCatch( SALOME_SalomeException ); + MESSAGE( "XTPlugin_OperationsCreator::Create" ); + return new XTPlugin_IOperations_i( thePOA, theEngine, get( theGenImpl, theStudyId ) ); +} + +XTPlugin_IOperations* XTPlugin_OperationsCreator::get( ::GEOMImpl_Gen* theGenImpl, + int theStudyId ) +{ + if (_mapOfOperations.find( theStudyId ) == _mapOfOperations.end() ) + _mapOfOperations[theStudyId] = new XTPlugin_IOperations( theGenImpl, theStudyId ); + return _mapOfOperations[theStudyId]; +} diff --git a/src/XTPlugin_OperationsCreator.hh b/src/XTPlugin_OperationsCreator.hh deleted file mode 100755 index d1ae32d..0000000 --- a/src/XTPlugin_OperationsCreator.hh +++ /dev/null @@ -1,47 +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 _GEOM_XTPlugin_OperationsCreator_HXX_ -#define _GEOM_XTPlugin_OperationsCreator_HXX_ - -// internal includes -#include "XTPlugin_Engine.hxx" -#include "XTPlugin_IOperations.hxx" - -// GEOM includes -#include "GEOM_Gen_i.hh" - -// C++ includes -#include - -//===================================================================== -// Operations creator -//===================================================================== -class XTPLUGINENGINE_EXPORT XTPlugin_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; -}; - -#endif diff --git a/src/XTPlugin_OperationsCreator.hxx b/src/XTPlugin_OperationsCreator.hxx new file mode 100755 index 0000000..f89be10 --- /dev/null +++ b/src/XTPlugin_OperationsCreator.hxx @@ -0,0 +1,57 @@ +// 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 _GEOM_XTPlugin_OperationsCreator_HXX_ +#define _GEOM_XTPlugin_OperationsCreator_HXX_ + +// internal includes +#include "XTPlugin_Engine.hxx" + +// GEOM includes +#include "GEOM_Gen_i.hh" + +// C++ includes +#include + +class XTPlugin_IOperations; + +//===================================================================== +// Operations creator +//===================================================================== +class XTPLUGINENGINE_EXPORT XTPlugin_OperationsCreator : public GEOM_GenericOperationsCreator +{ +public: + XTPlugin_OperationsCreator(); + ~XTPlugin_OperationsCreator(); + + GEOM_IOperations_i* Create( PortableServer::POA_ptr thePOA, + int theStudyId, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_Gen* theGenImpl ); + +private: + static XTPlugin_IOperations* get( ::GEOMImpl_Gen* theGenImpl, + int theStudyId ); + + static std::map _mapOfOperations; + + friend class XTPlugin_IECallBack; +}; + +#endif diff --git a/src/XTPlugin_Operations_i.cc b/src/XTPlugin_Operations_i.cc deleted file mode 100644 index bb22e83..0000000 --- a/src/XTPlugin_Operations_i.cc +++ /dev/null @@ -1,106 +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 "XTPlugin_Operations_i.hh" -#include - -// KERNEL includes -#include - -//============================================================================= -/*! - * constructor: - */ -//============================================================================= -XTPlugin_Operations_i::XTPlugin_Operations_i( PortableServer::POA_ptr thePOA, - GEOM::GEOM_Gen_ptr theEngine, - ::XTPlugin_IOperations* theImpl ) -:GEOM_IOperations_i( thePOA, theEngine, theImpl ) -{ - MESSAGE( "XTPlugin_Operations_i::XTPlugin_Operations_i" ); -} - -//============================================================================= -/*! - * destructor - */ -//============================================================================= -XTPlugin_Operations_i::~XTPlugin_Operations_i() -{ - MESSAGE( "XTPlugin_Operations_i::~XTPlugin_Operations_i" ); -} - -//============================================================================= -/*! - * ImportXT - * Import a shape from XT format - * \param theFileName The name of the file to import - * \return List of GEOM_Objects, containing the created shape and propagation groups. - */ -//============================================================================= -GEOM::ListOfGO* XTPlugin_Operations_i::ImportXT( const char* theFileName ) -{ - GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; - - //Set a not done flag - 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()->ImportXT( fileName ); - - free( aFileName ); - if( !GetOperations()->IsDone() || aHSeq.IsNull() ) - return aSeq._retn(); - - // Copy created objects. - Standard_Integer aLength = aHSeq->Length(); - aSeq->length( aLength ); - for( Standard_Integer i = 1; i <= aLength; i++ ) - aSeq[i-1] = GetObject( Handle(GEOM_Object)::DownCast( aHSeq->Value(i) ) ); - - return aSeq._retn(); -} - -//============================================================================= -/*! - * \brief Get version of the plugin. - * \return the version of the plugin -*/ -//============================================================================= - -int XTPlugin_Operations_i::GetVersion() -{ - return XTPLUGIN_VERSION; -} -//============================================================================= -/*! - * \brief Get version of the plugin. - * \return the string representation of the plugin's version -*/ -//============================================================================= - -char* XTPlugin_Operations_i::GetVersionStr() -{ - return (char*)XTPLUGIN_VERSION_STR; -} diff --git a/src/XTPlugin_Operations_i.hh b/src/XTPlugin_Operations_i.hh deleted file mode 100644 index c717b09..0000000 --- a/src/XTPlugin_Operations_i.hh +++ /dev/null @@ -1,55 +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 _XTPlugin_Operations_i_HeaderFile -#define _XTPlugin_Operations_i_HeaderFile - -// idl includes -#include -#include CORBA_SERVER_HEADER( GEOM_Gen ) -#include CORBA_SERVER_HEADER( XTPlugin_Gen ) - -// internal includes -#include "XTPlugin_Engine.hxx" -#include "XTPlugin_IOperations.hxx" - -// GEOM includes -#include - -class XTPLUGINENGINE_EXPORT XTPlugin_Operations_i : - public virtual POA_XTPlugin::GEOM_IXTPluginOperations, - public virtual GEOM_IOperations_i -{ -public: - XTPlugin_Operations_i( PortableServer::POA_ptr thePOA, - GEOM::GEOM_Gen_ptr theEngine, - ::XTPlugin_IOperations* theImpl ); - ~XTPlugin_Operations_i(); - - GEOM::ListOfGO* ImportXT( const char* ); - - // Version information - virtual int GetVersion(); - virtual char* GetVersionStr(); - - ::XTPlugin_IOperations* GetOperations() - { return (::XTPlugin_IOperations*)GetImpl(); } -}; - -#endif diff --git a/src/resources/XTPlugin_msg_en.ts b/src/resources/XTPlugin_msg_en.ts index 8be5f3b..8a17946 100644 --- a/src/resources/XTPlugin_msg_en.ts +++ b/src/resources/XTPlugin_msg_en.ts @@ -15,15 +15,15 @@ STB_IMPORTXT Import XT + + + XTPlugin_GUI - XTPLUGIN_XT_FILES + XT_FILES Parasolid Files ( *.x_t *.xt ) - - - XTPlugin_ImportDlg - XTPLUGIN_IMPORT_TITLE + IMPORT_TITLE Import XT diff --git a/src/resources/XTPlugin_msg_fr.ts b/src/resources/XTPlugin_msg_fr.ts index ca1628d..7f26c29 100644 --- a/src/resources/XTPlugin_msg_fr.ts +++ b/src/resources/XTPlugin_msg_fr.ts @@ -15,15 +15,15 @@ STB_IMPORTXT Importer XT + + + XTPlugin_GUI - XTPLUGIN_XT_FILES + XT_FILES Parasolid Fichiers ( *.x_t *.xt ) - - - XTPlugin_ImportDlg - XTPLUGIN_IMPORT_TITLE + IMPORT_TITLE Importer XT diff --git a/src/resources/XTPlugin_msg_ja.ts b/src/resources/XTPlugin_msg_ja.ts index bbee63d..7ce1a44 100644 --- a/src/resources/XTPlugin_msg_ja.ts +++ b/src/resources/XTPlugin_msg_ja.ts @@ -15,15 +15,15 @@ STB_IMPORTXT Import XT + + + XTPlugin_GUI - XTPLUGIN_XT_FILES + XT_FILES Parasolid Files ( *.x_t *.xt ) - - - XTPlugin_ImportDlg - XTPLUGIN_IMPORT_TITLE + IMPORT_TITLE Import XT