From 9b22259ac4215aa288b5b35790277d9717c042f4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Tue, 15 Sep 2015 17:31:14 +0200 Subject: [PATCH] [MEDCALC] Dump Python --- idl/CMakeLists.txt | 1 + idl/MEDCommandsHistoryManager.idl | 41 ++++++++++++ idl/MEDFactory.idl | 2 + src/MEDCalc/cmp/CMakeLists.txt | 1 + src/MEDCalc/cmp/MED.cxx | 25 ++++---- .../cmp/MEDCommandsHistoryManager_i.cxx | 64 +++++++++++++++++++ .../cmp/MEDCommandsHistoryManager_i.hxx | 49 ++++++++++++++ src/MEDCalc/cmp/MEDFactoryClient.cxx | 11 ++++ src/MEDCalc/cmp/MEDFactoryClient.hxx | 3 + src/MEDCalc/cmp/MEDFactory_i.cxx | 56 +++++++++------- src/MEDCalc/cmp/MEDFactory_i.hxx | 7 +- src/MEDCalc/gui/DatasourceController.hxx | 5 +- src/MEDCalc/gui/WorkspaceController.cxx | 2 +- src/MEDCalc/gui/WorkspaceController.hxx | 12 ++-- src/MEDCalc/gui/XmedConsoleDriver.cxx | 32 +++++----- src/MEDCalc/gui/XmedConsoleDriver.hxx | 13 ++-- 16 files changed, 253 insertions(+), 71 deletions(-) create mode 100644 idl/MEDCommandsHistoryManager.idl create mode 100644 src/MEDCalc/cmp/MEDCommandsHistoryManager_i.cxx create mode 100644 src/MEDCalc/cmp/MEDCommandsHistoryManager_i.hxx diff --git a/idl/CMakeLists.txt b/idl/CMakeLists.txt index 09229bd42..98a700437 100644 --- a/idl/CMakeLists.txt +++ b/idl/CMakeLists.txt @@ -27,6 +27,7 @@ INCLUDE_DIRECTORIES( SET(SalomeIDLMED_IDLSOURCES MED_Gen.idl + MEDCommandsHistoryManager.idl MEDCouplingCorbaServant.idl ParaMEDCouplingCorbaServant.idl MEDDataManager.idl diff --git a/idl/MEDCommandsHistoryManager.idl b/idl/MEDCommandsHistoryManager.idl new file mode 100644 index 000000000..494f1bfe3 --- /dev/null +++ b/idl/MEDCommandsHistoryManager.idl @@ -0,0 +1,41 @@ +// Copyright (C) 2015 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 __MED_COMMANDS_HISTORY_MANAGER_IDL_ +#define __MED_COMMANDS_HISTORY_MANAGER_IDL_ + +#include "SALOME_GenericObj.idl" + +module MEDCALC +{ + + typedef sequence CommandsList; + + interface MEDCommandsHistoryManager : SALOME::GenericObj + { + + void addCommand(in string command); + CommandsList getCommandsHistory(); + void clearHistory(); + + }; + +}; + +#endif diff --git a/idl/MEDFactory.idl b/idl/MEDFactory.idl index bd53af996..89b962dee 100644 --- a/idl/MEDFactory.idl +++ b/idl/MEDFactory.idl @@ -25,6 +25,7 @@ #include "MEDDataManager.idl" #include "MEDCalculator.idl" #include "MEDPresentationManager.idl" +#include "MEDCommandsHistoryManager.idl" /*! * This module contains the interface required for starting with MED @@ -42,6 +43,7 @@ module MEDCALC MEDCALC::MEDDataManager getDataManager(); MEDCALC::MEDCalculator getCalculator(); MEDCALC::MEDPresentationManager getPresentationManager(); + MEDCALC::MEDCommandsHistoryManager getCommandsHistoryManager(); }; }; diff --git a/src/MEDCalc/cmp/CMakeLists.txt b/src/MEDCalc/cmp/CMakeLists.txt index 175ad0eda..c4b2a8d4d 100644 --- a/src/MEDCalc/cmp/CMakeLists.txt +++ b/src/MEDCalc/cmp/CMakeLists.txt @@ -34,6 +34,7 @@ INCLUDE_DIRECTORIES( ) SET(COMMON_SOURCES + MEDCommandsHistoryManager_i.cxx MEDFactoryClient.cxx MEDDataManager_i.cxx MEDCalculator_i.cxx diff --git a/src/MEDCalc/cmp/MED.cxx b/src/MEDCalc/cmp/MED.cxx index ff3ab8651..9beb6774b 100644 --- a/src/MEDCalc/cmp/MED.cxx +++ b/src/MEDCalc/cmp/MED.cxx @@ -59,6 +59,10 @@ MED::~MED() // nothing to do } +// Duplicate gui/DatasourceConstants +#define OBJECT_ID "objectid" +#define OBJECT_IS_IN_WORKSPACE "isInWorkspace" + // Duplicate gui/XmedDataModel static const int NB_TYPE_OF_FIELDS = 4; static const char* mapTypeOfFieldLabel[NB_TYPE_OF_FIELDS] = @@ -110,7 +114,7 @@ MED::addDatasourceToStudy(SALOMEDS::Study_ptr study, soDatasource->SetAttrString("AttributePixMap", "ICO_DATASOURCE"); anAttr = studyBuilder->FindOrCreateAttribute(soDatasource, "AttributeParameter"); aParam = SALOMEDS::AttributeParameter::_narrow(anAttr); - aParam->SetInt("objectid", datasourceHandler.id); + aParam->SetInt(OBJECT_ID, datasourceHandler.id); useCaseBuilder->AppendTo(soDatasource->GetFather(), soDatasource); // We can add the meshes as children of the datasource @@ -124,10 +128,10 @@ MED::addDatasourceToStudy(SALOMEDS::Study_ptr study, soMesh->SetAttrString("AttributePixMap", "ICO_DATASOURCE_MESH"); anAttr = studyBuilder->FindOrCreateAttribute(soMesh, "AttributeParameter"); aParam = SALOMEDS::AttributeParameter::_narrow(anAttr); - aParam->SetInt("objectid", meshHandler.id); + aParam->SetInt(OBJECT_ID, meshHandler.id); anAttr = studyBuilder->FindOrCreateAttribute(soMesh, "AttributeParameter"); aParam = SALOMEDS::AttributeParameter::_narrow(anAttr); - aParam->SetBool("isInWorkspace", false); + aParam->SetBool(OBJECT_IS_IN_WORKSPACE, false); useCaseBuilder->AppendTo(soMesh->GetFather(), soMesh); // We add the field timeseries defined on this mesh, as children of the mesh SObject @@ -145,10 +149,10 @@ MED::addDatasourceToStudy(SALOMEDS::Study_ptr study, soFieldseries->SetAttrString("AttributePixMap", "ICO_DATASOURCE_FIELD"); anAttr = studyBuilder->FindOrCreateAttribute(soFieldseries, "AttributeParameter"); aParam = SALOMEDS::AttributeParameter::_narrow(anAttr); - aParam->SetInt("objectid", fieldseriesHandler.id); + aParam->SetInt(OBJECT_ID, fieldseriesHandler.id); anAttr = studyBuilder->FindOrCreateAttribute(soFieldseries, "AttributeParameter"); aParam = SALOMEDS::AttributeParameter::_narrow(anAttr); - aParam->SetBool("isInWorkspace", false); + aParam->SetBool(OBJECT_IS_IN_WORKSPACE, false); useCaseBuilder->AppendTo(soFieldseries->GetFather(), soFieldseries); soFieldseries->UnRegister(); @@ -183,7 +187,6 @@ MED::registerPresentation(SALOMEDS::Study_ptr study, return MED_ORB::OP_ERROR ; } std::string entry = _fieldSeriesEntries[fieldId]; - //SALOMEDS::SObject_ptr soFieldseries = _studyEditor->findObject(entry.c_str()); SALOMEDS::SObject_var sobject = study->FindObjectID(entry.c_str()); SALOMEDS::SObject_ptr soFieldseries = sobject._retn(); @@ -192,12 +195,9 @@ MED::registerPresentation(SALOMEDS::Study_ptr study, return MED_ORB::OP_ERROR; } - //SALOMEDS::SObject_var soPresentation = _studyEditor->newObject(soFieldseries); SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder(); SALOMEDS::SObject_var soPresentation = studyBuilder->NewObject(soFieldseries); - //_studyEditor->setName(soPresentation, tr(name.c_str()).toStdString().c_str()); - //_studyEditor->setIcon(soPresentation, tr("ICO_MED_PRESENTATION").toStdString().c_str()); soPresentation->SetAttrString("AttributeName", name); soPresentation->SetAttrString("AttributePixMap", label); @@ -228,7 +228,11 @@ MED::DumpPython(CORBA::Object_ptr theStudy, TCollection_AsciiString aScript; - aScript += "dumping MED"; + MEDCALC::CommandsList* history = MEDFactoryClient::getCommandsHistoryManager()->getCommandsHistory(); + for (CORBA::ULong i = 0; i < history->length(); ++i) { + aScript += (*history)[i]; + aScript += "\n"; + } int aLen = aScript.Length(); unsigned char* aBuffer = new unsigned char[aLen+1]; @@ -252,7 +256,6 @@ extern "C" \param interfaceName SALOME component interface name \return CORBA object identifier of the registered servant */ - //PortableServer::ObjectId* MEDEngine_factory( CORBA::ORB_ptr orb, PortableServer::ObjectId* MEDEngine_factory(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId* contId, diff --git a/src/MEDCalc/cmp/MEDCommandsHistoryManager_i.cxx b/src/MEDCalc/cmp/MEDCommandsHistoryManager_i.cxx new file mode 100644 index 000000000..1d5a25ece --- /dev/null +++ b/src/MEDCalc/cmp/MEDCommandsHistoryManager_i.cxx @@ -0,0 +1,64 @@ +// Copyright (C) 2015 CEA/DEN, EDF R&D +// +// 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 +// + +#include "MEDCommandsHistoryManager_i.hxx" + +MEDCommandsHistoryManager_i* MEDCommandsHistoryManager_i::_instance = NULL; + +MEDCommandsHistoryManager_i* +MEDCommandsHistoryManager_i::getInstance() +{ + if (_instance == NULL) + _instance = new MEDCommandsHistoryManager_i(); + return _instance; +} + +MEDCommandsHistoryManager_i::MEDCommandsHistoryManager_i() + : _history(0) +{ + _history = new MEDCALC::CommandsList; +} + +MEDCommandsHistoryManager_i::~MEDCommandsHistoryManager_i() +{ + for (CORBA::ULong i = 0; i < _history->length(); ++i) { + CORBA::string_free((*_history)[i]); + } + delete _history; +} + +void +MEDCommandsHistoryManager_i::addCommand(const char* command) +{ + CORBA::ULong size = _history->length(); + _history->length(size+1); + (*_history)[size] = CORBA::string_dup(command); +} + +MEDCALC::CommandsList* +MEDCommandsHistoryManager_i::getCommandsHistory() +{ + return _history; +} + +void +MEDCommandsHistoryManager_i::clearHistory() +{ + _history->length(0); +} diff --git a/src/MEDCalc/cmp/MEDCommandsHistoryManager_i.hxx b/src/MEDCalc/cmp/MEDCommandsHistoryManager_i.hxx new file mode 100644 index 000000000..fb7f72215 --- /dev/null +++ b/src/MEDCalc/cmp/MEDCommandsHistoryManager_i.hxx @@ -0,0 +1,49 @@ +// Copyright (C) 2015 CEA/DEN, EDF R&D +// +// 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 MED_COMMANDS_HISTORY_MANAGER_I_HXX +#define MED_COMMANDS_HISTORY_MANAGER_I_HXX + +#include +#include CORBA_SERVER_HEADER(MEDCommandsHistoryManager) +#include "SALOME_GenericObj_i.hh" + +#include "MEDCALC.hxx" + +class MEDCALC_EXPORT MEDCommandsHistoryManager_i + : public POA_MEDCALC::MEDCommandsHistoryManager, + public SALOME::GenericObj_i +{ + public: + static MEDCommandsHistoryManager_i* getInstance(); + + void addCommand(const char* command); + MEDCALC::CommandsList* getCommandsHistory(); + void clearHistory(); + + private: + MEDCommandsHistoryManager_i(); + virtual ~MEDCommandsHistoryManager_i(); + + private: + static MEDCommandsHistoryManager_i* _instance; + MEDCALC::CommandsList* _history; +}; + +#endif diff --git a/src/MEDCalc/cmp/MEDFactoryClient.cxx b/src/MEDCalc/cmp/MEDFactoryClient.cxx index 747286ac5..4a03f6850 100644 --- a/src/MEDCalc/cmp/MEDFactoryClient.cxx +++ b/src/MEDCalc/cmp/MEDFactoryClient.cxx @@ -70,4 +70,15 @@ namespace MEDFactoryClient { return presentationManager; } + /*! + * This returns a singleton (static) instance of the MED commands history. + */ + MEDCALC::MEDCommandsHistoryManager_ptr getCommandsHistoryManager() { + static MEDCALC::MEDCommandsHistoryManager_ptr commandsHistoryManager; + if(CORBA::is_nil(commandsHistoryManager)){ + commandsHistoryManager = getFactory()->getCommandsHistoryManager(); + } + return commandsHistoryManager; + } + } diff --git a/src/MEDCalc/cmp/MEDFactoryClient.hxx b/src/MEDCalc/cmp/MEDFactoryClient.hxx index 84c97eef3..c268e4379 100644 --- a/src/MEDCalc/cmp/MEDFactoryClient.hxx +++ b/src/MEDCalc/cmp/MEDFactoryClient.hxx @@ -27,6 +27,8 @@ #include CORBA_CLIENT_HEADER(MEDFactory) #include CORBA_CLIENT_HEADER(MEDDataManager) #include CORBA_CLIENT_HEADER(MEDCalculator) +#include CORBA_CLIENT_HEADER(MEDPresentationManager) +#include CORBA_CLIENT_HEADER(MEDCommandsHistoryManager) #include "MEDCALC.hxx" @@ -40,6 +42,7 @@ namespace MEDFactoryClient { MEDCALC_EXPORT MEDCALC::MEDDataManager_ptr getDataManager(); MEDCALC_EXPORT MEDCALC::MEDCalculator_ptr getCalculator(); MEDCALC_EXPORT MEDCALC::MEDPresentationManager_ptr getPresentationManager(); + MEDCALC_EXPORT MEDCALC::MEDCommandsHistoryManager_ptr getCommandsHistoryManager(); } #endif // _MEDFACTORY_CLIENT_HXX_ diff --git a/src/MEDCalc/cmp/MEDFactory_i.cxx b/src/MEDCalc/cmp/MEDFactory_i.cxx index 3e2982f3e..b41ef3a67 100644 --- a/src/MEDCalc/cmp/MEDFactory_i.cxx +++ b/src/MEDCalc/cmp/MEDFactory_i.cxx @@ -22,13 +22,10 @@ #include "MEDFactory_i.hxx" #include "utilities.h" -#include - #include "MEDDataManager_i.hxx" #include "MEDCalculator_i.hxx" #include "MEDPresentationManager_i.hxx" - -using namespace std; +#include "MEDCommandsHistoryManager_i.hxx" //============================================================================= /*! @@ -37,11 +34,11 @@ using namespace std; //============================================================================= MEDFactory_i::MEDFactory_i(CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - PortableServer::ObjectId * contId, - const char *instanceName, - const char *interfaceName) : - Engines_Component_i(orb, poa, contId, instanceName, interfaceName) + PortableServer::POA_ptr poa, + PortableServer::ObjectId* contId, + const char* instanceName, + const char* interfaceName) + : Engines_Component_i(orb, poa, contId, instanceName, interfaceName) { MESSAGE("activate object"); _thisObj = this ; @@ -50,40 +47,55 @@ MEDFactory_i::MEDFactory_i(CORBA::ORB_ptr orb, MEDFactory_i::~MEDFactory_i() { + // nothing to do } -MEDCALC::MEDDataManager_ptr MEDFactory_i::getDataManager() { - MEDDataManager_i * medDataManager = MEDDataManager_i::getInstance(); +MEDCALC::MEDDataManager_ptr +MEDFactory_i::getDataManager() +{ + MEDDataManager_i* medDataManager = MEDDataManager_i::getInstance(); MEDCALC::MEDDataManager_ptr medDataManagerPtr = medDataManager->_this(); return medDataManagerPtr; } -MEDCALC::MEDCalculator_ptr MEDFactory_i::getCalculator() { - MEDCalculator_i * medCalculator = MEDCalculator_i::getInstance(); +MEDCALC::MEDCalculator_ptr +MEDFactory_i::getCalculator() +{ + MEDCalculator_i* medCalculator = MEDCalculator_i::getInstance(); MEDCALC::MEDCalculator_ptr medCalculatorPtr = medCalculator->_this(); return medCalculatorPtr; } -MEDCALC::MEDPresentationManager_ptr MEDFactory_i::getPresentationManager() { - MEDPresentationManager_i * manager = MEDPresentationManager_i::getInstance(); +MEDCALC::MEDPresentationManager_ptr +MEDFactory_i::getPresentationManager() +{ + MEDPresentationManager_i* manager = MEDPresentationManager_i::getInstance(); MEDCALC::MEDPresentationManager_ptr managerPtr = manager->_this(); return managerPtr; } +MEDCALC::MEDCommandsHistoryManager_ptr +MEDFactory_i::getCommandsHistoryManager() +{ + MEDCommandsHistoryManager_i* manager = MEDCommandsHistoryManager_i::getInstance(); + MEDCALC::MEDCommandsHistoryManager_ptr managerPtr = manager->_this(); + return managerPtr; +} + extern "C" { - PortableServer::ObjectId * MEDFactoryEngine_factory( + PortableServer::ObjectId* MEDFactoryEngine_factory( CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, - PortableServer::ObjectId * contId, - const char *instanceName, - const char *interfaceName) + PortableServer::ObjectId* contId, + const char* instanceName, + const char* interfaceName) { MESSAGE("PortableServer::ObjectId * MEDEngine_factory()"); SCRUTE(interfaceName); - MEDFactory_i * factory = new MEDFactory_i(orb, poa, contId, - instanceName, - interfaceName); + MEDFactory_i* factory = new MEDFactory_i(orb, poa, contId, + instanceName, + interfaceName); return factory->getId() ; } } diff --git a/src/MEDCalc/cmp/MEDFactory_i.hxx b/src/MEDCalc/cmp/MEDFactory_i.hxx index 0fa3488cc..a881bf3d5 100644 --- a/src/MEDCalc/cmp/MEDFactory_i.hxx +++ b/src/MEDCalc/cmp/MEDFactory_i.hxx @@ -27,6 +27,7 @@ #include CORBA_SERVER_HEADER(MEDDataManager) #include CORBA_SERVER_HEADER(MEDCalculator) #include CORBA_SERVER_HEADER(MEDPresentationManager) +#include CORBA_SERVER_HEADER(MEDCommandsHistoryManager) #include "SALOME_Component_i.hxx" #include "MEDCALC.hxx" @@ -35,6 +36,7 @@ class MEDCALC_EXPORT MEDFactory_i: public POA_MEDCALC::MEDFactory, { public: + MEDFactory_i(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId, @@ -46,9 +48,10 @@ public: MEDCALC::MEDDataManager_ptr getDataManager(); /*! Returns the singleton instance of the calculator */ MEDCALC::MEDCalculator_ptr getCalculator(); - /*! Returns the singleton instance of the prsentation manager */ + /*! Returns the singleton instance of the presentation manager */ MEDCALC::MEDPresentationManager_ptr getPresentationManager(); - + /*! Returns the singleton instance of the commands history manager */ + MEDCALC::MEDCommandsHistoryManager_ptr getCommandsHistoryManager(); }; extern "C" diff --git a/src/MEDCalc/gui/DatasourceController.hxx b/src/MEDCalc/gui/DatasourceController.hxx index 09cf69a7f..a6b2cf687 100644 --- a/src/MEDCalc/gui/DatasourceController.hxx +++ b/src/MEDCalc/gui/DatasourceController.hxx @@ -25,7 +25,7 @@ #include "MEDEventListener_i.hxx" #include #include CORBA_CLIENT_HEADER(MEDDataManager) -//#include + #include #include #include @@ -76,8 +76,6 @@ class MEDCALCGUI_EXPORT DatasourceController: public QObject { Q_OBJECT public: - //DatasourceController(StandardApp_Module * salomeModule); - //DatasourceController(SalomeApp_Module * salomeModule); DatasourceController(MEDModule * salomeModule); ~DatasourceController(); @@ -108,7 +106,6 @@ private: void updateTreeViewWithNewPresentation(long fieldId, long presentationId); private: - //StandardApp_Module * _salomeModule; MEDModule* _salomeModule; SALOME_AppStudyEditor * _studyEditor; diff --git a/src/MEDCalc/gui/WorkspaceController.cxx b/src/MEDCalc/gui/WorkspaceController.cxx index c873c26c5..b4c6bd2db 100644 --- a/src/MEDCalc/gui/WorkspaceController.cxx +++ b/src/MEDCalc/gui/WorkspaceController.cxx @@ -95,7 +95,7 @@ WorkspaceController::WorkspaceController(MEDModule * salomeModule) // Initialize the python console. Note that this must be done at // last because the setup will try to initiate a connection to the // event listener. - _consoleDriver = new XmedConsoleDriver(salomeApp); + _consoleDriver = new XmedConsoleDriver(salomeModule); _consoleDriver->setup(); } diff --git a/src/MEDCalc/gui/WorkspaceController.hxx b/src/MEDCalc/gui/WorkspaceController.hxx index 28317ca8e..cfbcb8d21 100644 --- a/src/MEDCalc/gui/WorkspaceController.hxx +++ b/src/MEDCalc/gui/WorkspaceController.hxx @@ -30,7 +30,6 @@ #include #include CORBA_CLIENT_HEADER(MEDDataManager) -//#include #include #include @@ -47,7 +46,6 @@ class MEDCALCGUI_EXPORT WorkspaceController: public TreeGuiManager { Q_OBJECT public: - //WorkspaceController(StandardApp_Module * salomeModule); WorkspaceController(MEDModule * salomeModule); ~WorkspaceController(); @@ -67,20 +65,20 @@ signals: void workspaceSignal(const MEDCALC::MedEvent * event); private: - XmedConsoleDriver * _consoleDriver; - //StandardApp_Module * _salomeModule; - MEDModule * _salomeModule; void _importItem(QString itemNameId); void _importItemList(QStringList itemNameIdList); void _importFieldIntoConsole(MEDCALC::FieldHandler * fieldHandler, - bool askForOptions, - const char * alias=NULL); + bool askForOptions, + const char * alias=NULL); void _exportItemList(QStringList itemNameIdList); void _saveItemList(QStringList itemNameIdList); void _removeItemList(QStringList itemNameIdList); void _viewItemList(QStringList itemNameIdList); +private: + XmedConsoleDriver * _consoleDriver; + MEDModule * _salomeModule; MEDEventListener_i * _medEventListener; // This structure is intended to memorized in a bundle the whole set diff --git a/src/MEDCalc/gui/XmedConsoleDriver.cxx b/src/MEDCalc/gui/XmedConsoleDriver.cxx index bef4ef375..4a119de3c 100644 --- a/src/MEDCalc/gui/XmedConsoleDriver.cxx +++ b/src/MEDCalc/gui/XmedConsoleDriver.cxx @@ -20,11 +20,17 @@ #include "XmedConsoleDriver.hxx" #include "Utils_SALOME_Exception.hxx" +#include "MEDModule.hxx" +#include "MEDCommandsHistoryManager_i.hxx" +#include "MEDFactoryClient.hxx" +#include CORBA_CLIENT_HEADER(MED_Gen) +#include CORBA_CLIENT_HEADER(MEDCommandsHistoryManager) -XmedConsoleDriver::XmedConsoleDriver(SalomeApp_Application * application) { - +XmedConsoleDriver::XmedConsoleDriver(MEDModule* salomeModule) +{ + _salomeModule = salomeModule; bool forcePythonConsole = true; - _pyConsole = application->pythonConsole(forcePythonConsole); + _pyConsole = _salomeModule->getApp()->pythonConsole(forcePythonConsole); if ( !_pyConsole ) { const char * msg = "The python console can't be obtained from the SALOME application"; throw SALOME_Exception(msg); @@ -42,17 +48,6 @@ void XmedConsoleDriver::setup() { if ( !_importXmedDone ) { QStringList commands; - /* - // First import xmed to initialize the main objects, in particular - // the corba pointer to the event listener. - commands+="import xmed"; - // Set the globals dictionnary so that the fields tools work properly. - commands+="xmed.setConsoleGlobals(globals())"; - // Import the tools required for field operations - commands+="from xmed import load, get, put, dup, ls, la, save, view, doc, wipe, remove, clean"; - // A last one to clear the console screen - //commands+="wipe"; - */ #ifndef DISABLE_PVVIEWER // start PVServer and show render view commands+="import pvsimple as pvs"; @@ -77,9 +72,14 @@ void XmedConsoleDriver::setup() { * This function sends the specified list of commands to the console. */ void XmedConsoleDriver::exec(const QStringList& commands) { + MEDCALC::MEDCommandsHistoryManager_ptr history = MEDFactoryClient::getCommandsHistoryManager(); + QStringListIterator it(commands); + int i = 0; while (it.hasNext()) { - _pyConsole->exec(it.next()); + const QString& command = it.next(); + _pyConsole->exec(command); + // store command in history + history->addCommand(command.toStdString().c_str()); } - this->_history.append(commands); } diff --git a/src/MEDCalc/gui/XmedConsoleDriver.hxx b/src/MEDCalc/gui/XmedConsoleDriver.hxx index 4aca66a18..0a15f3706 100644 --- a/src/MEDCalc/gui/XmedConsoleDriver.hxx +++ b/src/MEDCalc/gui/XmedConsoleDriver.hxx @@ -21,29 +21,26 @@ #ifndef XMEDCONSOLEDRIVER_HXX #define XMEDCONSOLEDRIVER_HXX -#include +#include "MEDCALCGUI.hxx" + #include #include -#include "MEDCALCGUI.hxx" - -typedef QList CommandsHistory; +class MEDModule; class MEDCALCGUI_EXPORT XmedConsoleDriver { public: - XmedConsoleDriver(SalomeApp_Application * application); + XmedConsoleDriver(MEDModule* salomeModule); void setup(); void exec(const QStringList& commands); - inline const CommandsHistory& getHistory() { return _history; } - private: + MEDModule* _salomeModule; PyConsole_Console * _pyConsole; bool _importXmedDone; - CommandsHistory _history; }; #endif //XMEDCONSOLEDRIVER_HXX -- 2.39.2