Salome HOME
[MEDCALC] Dump Python
authorCédric Aguerre <cedric.aguerre@edf.fr>
Tue, 15 Sep 2015 15:31:14 +0000 (17:31 +0200)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Tue, 15 Sep 2015 15:31:14 +0000 (17:31 +0200)
16 files changed:
idl/CMakeLists.txt
idl/MEDCommandsHistoryManager.idl [new file with mode: 0644]
idl/MEDFactory.idl
src/MEDCalc/cmp/CMakeLists.txt
src/MEDCalc/cmp/MED.cxx
src/MEDCalc/cmp/MEDCommandsHistoryManager_i.cxx [new file with mode: 0644]
src/MEDCalc/cmp/MEDCommandsHistoryManager_i.hxx [new file with mode: 0644]
src/MEDCalc/cmp/MEDFactoryClient.cxx
src/MEDCalc/cmp/MEDFactoryClient.hxx
src/MEDCalc/cmp/MEDFactory_i.cxx
src/MEDCalc/cmp/MEDFactory_i.hxx
src/MEDCalc/gui/DatasourceController.hxx
src/MEDCalc/gui/WorkspaceController.cxx
src/MEDCalc/gui/WorkspaceController.hxx
src/MEDCalc/gui/XmedConsoleDriver.cxx
src/MEDCalc/gui/XmedConsoleDriver.hxx

index 09229bd42ccb7001875b06ef5b4b59143f422058..98a700437a04dfc2f6e0d9198da9ddb70a182164 100644 (file)
@@ -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 (file)
index 0000000..494f1bf
--- /dev/null
@@ -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<string> CommandsList;
+
+  interface MEDCommandsHistoryManager : SALOME::GenericObj
+  {
+
+    void addCommand(in string command);
+    CommandsList getCommandsHistory();
+    void clearHistory();
+
+  };
+
+};
+
+#endif
index bd53af996ba66d689e5df6849e173a9245f8f037..89b962dee8c1a20b4829fbabc980c224673c5719 100644 (file)
@@ -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();
 
   };
 };
index 175ad0eda196676d3eac15cecdb53d2e289225ca..c4b2a8d4d62d7a82c9dec22e6d9865eb01f20155 100644 (file)
@@ -34,6 +34,7 @@ INCLUDE_DIRECTORIES(
 )
 
 SET(COMMON_SOURCES
+  MEDCommandsHistoryManager_i.cxx
   MEDFactoryClient.cxx
   MEDDataManager_i.cxx
   MEDCalculator_i.cxx
index ff3ab8651d00f478d7e314ad68bf1e07986b2459..9beb6774bd6306e1ec1295eb2a562018584f4039 100644 (file)
@@ -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 (file)
index 0000000..1d5a25e
--- /dev/null
@@ -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 (file)
index 0000000..fb7f722
--- /dev/null
@@ -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 <SALOMEconfig.h>
+#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
index 747286ac5a950d7ee7f0780ef96da31bad10e6d0..4a03f68500c729162bf93139df354698f02508c6 100644 (file)
@@ -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;
+  }
+
 }
index 84c97eef3f66ba7d0e66c0dc067312d0e5a7a804..c268e437921e0f7bc69a158c028a7fed7b4699ad 100644 (file)
@@ -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_
index 3e2982f3ed6238d0e000d9f04719aac4551386ac..b41ef3a673dc013f337881689aee27a3e77eb3cd 100644 (file)
 #include "MEDFactory_i.hxx"
 #include "utilities.h"
 
-#include <string>
-
 #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 charinstanceName,
+             const charinterfaceName)
   {
     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() ;
   }
 }
index 0fa3488ccaedb4eb534d388ce64afb6fb5a44af0..a881bf3d580afd4eba68c992d8e8ef5b83a075bd 100644 (file)
@@ -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"
index 09cf69a7ff27fc69544f06841fe8127b99d77044..a6b2cf68702b3321e0ffd75992de2d677aa923ef 100644 (file)
@@ -25,7 +25,7 @@
 #include "MEDEventListener_i.hxx"
 #include <SALOMEconfig.h>
 #include CORBA_CLIENT_HEADER(MEDDataManager)
-//#include <StandardApp_Module.hxx>
+
 #include <SalomeApp_Module.h>
 #include <SALOME_AppStudyEditor.hxx>
 #include <MEDPresentation.hxx>
@@ -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;
 
index c873c26c5fa388b24d5f7bcb36160b6d070b0e65..b4c6bd2db9f30861965d5f5c46da65e1beb09328 100644 (file)
@@ -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();
 }
 
index 28317ca8e5f7a70aeb9941523e2bbadd1a10df78..cfbcb8d21b36daa09d6ba9608d8f640e295d2584 100644 (file)
@@ -30,7 +30,6 @@
 
 #include <SALOMEconfig.h>
 #include CORBA_CLIENT_HEADER(MEDDataManager)
-//#include <StandardApp_Module.hxx>
 #include <SalomeApp_Module.h>
 
 #include <vector>
@@ -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
index bef4ef3751dbe93d14d71b4160533e8b832b9bfb..4a119de3cf868bf5a58fb7605a43e39987a2d945 100644 (file)
 
 #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);
 }
index 4aca66a1852d413ab7d297e68ea5bdf24f39a5ec..0a15f3706f6bb8f6410ec6e7e06733dee50172a0 100644 (file)
 #ifndef XMEDCONSOLEDRIVER_HXX
 #define XMEDCONSOLEDRIVER_HXX
 
-#include <SalomeApp_Application.h>
+#include "MEDCALCGUI.hxx"
+
 #include <PyConsole_Console.h>
 
 #include <QStringList>
 
-#include "MEDCALCGUI.hxx"
-
-typedef QList<QStringList> 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