From 31fbd900a7aac66178658382470dc233dc8b12ff Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Thu, 23 Jul 2015 11:18:39 +0200 Subject: [PATCH] medcalc and commands history --- src/MEDOP/gui/DatasourceController.cxx | 2 +- src/MEDOP/gui/WorkspaceController.cxx | 6 +++--- src/MEDOP/gui/XmedConsoleDriver.cxx | 3 ++- src/MEDOP/gui/XmedConsoleDriver.hxx | 9 +++++++-- src/MEDOP/tui/CMakeLists.txt | 2 +- .../tui/{medpresentation => presentation}/CMakeLists.txt | 4 ++-- .../tui/{medpresentation => presentation}/__init__.py | 0 .../xmedimages.py => presentation/medimages.py} | 0 .../{medpresentation => presentation}/medpresentation.py | 2 +- 9 files changed, 17 insertions(+), 11 deletions(-) rename src/MEDOP/tui/{medpresentation => presentation}/CMakeLists.txt (95%) rename src/MEDOP/tui/{medpresentation => presentation}/__init__.py (100%) rename src/MEDOP/tui/{medpresentation/xmedimages.py => presentation/medimages.py} (100%) rename src/MEDOP/tui/{medpresentation => presentation}/medpresentation.py (97%) diff --git a/src/MEDOP/gui/DatasourceController.cxx b/src/MEDOP/gui/DatasourceController.cxx index 4b5b8cbf0..e4d2c57cc 100644 --- a/src/MEDOP/gui/DatasourceController.cxx +++ b/src/MEDOP/gui/DatasourceController.cxx @@ -477,7 +477,7 @@ void DatasourceController::OnChangeUnderlyingMeshInputValidated() { event->eventtype = DatasourceEvent::EVENT_IMPORT_OBJECT; XmedDataObject * dataObject = new XmedDataObject(); dataObject->setFieldHandler(*duplicate); - event->objectdata = dataObject; + event->objectdata = dataObject; emit datasourceSignal(event); // Note that this signal is processed by the WorkspaceController diff --git a/src/MEDOP/gui/WorkspaceController.cxx b/src/MEDOP/gui/WorkspaceController.cxx index 2f19a740a..36e620667 100644 --- a/src/MEDOP/gui/WorkspaceController.cxx +++ b/src/MEDOP/gui/WorkspaceController.cxx @@ -487,7 +487,7 @@ void WorkspaceController::processDatasourceEvent(const DatasourceEvent * event) } else if ( event->eventtype == DatasourceEvent::EVENT_VIEW_OBJECT_SCALAR_MAP ) { QStringList commands; - commands += QString("from medpresentation import MakeScalarMap"); + commands += QString("from medcalc import MakeScalarMap"); commands += QString("import MEDOP"); #define stringify( name ) # name @@ -500,13 +500,13 @@ void WorkspaceController::processDatasourceEvent(const DatasourceEvent * event) } else if ( event->eventtype == DatasourceEvent::EVENT_ADD_DATASOURCE ) { QStringList commands; - commands += QString("from medpresentation import LoadDataSource"); + commands += QString("from medcalc import LoadDataSource"); commands += QString("LoadDataSource('%1')").arg(event->objectalias); _consoleDriver->exec(commands); } else if ( event->eventtype == DatasourceEvent::EVENT_ADD_IMAGE_AS_DATASOURCE ) { QStringList commands; - commands += QString("from medpresentation import LoadImageAsDataSource"); + commands += QString("from medcalc import LoadImageAsDataSource"); commands += QString("LoadImageAsDataSource('%1')").arg(event->objectalias); _consoleDriver->exec(commands); } diff --git a/src/MEDOP/gui/XmedConsoleDriver.cxx b/src/MEDOP/gui/XmedConsoleDriver.cxx index 500879c1e..c98767915 100644 --- a/src/MEDOP/gui/XmedConsoleDriver.cxx +++ b/src/MEDOP/gui/XmedConsoleDriver.cxx @@ -67,9 +67,10 @@ void XmedConsoleDriver::setup() { /*! * This function sends the specified list of commands to the console. */ -void XmedConsoleDriver::exec(QStringList commands) { +void XmedConsoleDriver::exec(const QStringList& commands) { QStringListIterator it(commands); while (it.hasNext()) { _pyConsole->exec(it.next()); } + this->_history.append(commands); } diff --git a/src/MEDOP/gui/XmedConsoleDriver.hxx b/src/MEDOP/gui/XmedConsoleDriver.hxx index 11a18c953..365a8e224 100644 --- a/src/MEDOP/gui/XmedConsoleDriver.hxx +++ b/src/MEDOP/gui/XmedConsoleDriver.hxx @@ -16,7 +16,7 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// Author : Guillaume Boulant (EDF) +// Author : Guillaume Boulant (EDF) #ifndef XMEDCONSOLEDRIVER_HXX #define XMEDCONSOLEDRIVER_HXX @@ -28,17 +28,22 @@ #include "MEDOPGUI.hxx" +typedef QList CommandsHistory; + class MEDOPGUI_EXPORT XmedConsoleDriver { public: XmedConsoleDriver(SalomeApp_Application * application); void setup(); - void exec(QStringList commands); + void exec(const QStringList& commands); + + inline const CommandsHistory& getHistory() { return _history; } private: PyConsole_Console * _pyConsole; bool _importXmedDone; + CommandsHistory _history; }; #endif //XMEDCONSOLEDRIVER_HXX diff --git a/src/MEDOP/tui/CMakeLists.txt b/src/MEDOP/tui/CMakeLists.txt index 9e4b18ab7..734da38ad 100644 --- a/src/MEDOP/tui/CMakeLists.txt +++ b/src/MEDOP/tui/CMakeLists.txt @@ -18,4 +18,4 @@ # ADD_SUBDIRECTORY(xmedpy) -ADD_SUBDIRECTORY(medpresentation) +ADD_SUBDIRECTORY(presentation) diff --git a/src/MEDOP/tui/medpresentation/CMakeLists.txt b/src/MEDOP/tui/presentation/CMakeLists.txt similarity index 95% rename from src/MEDOP/tui/medpresentation/CMakeLists.txt rename to src/MEDOP/tui/presentation/CMakeLists.txt index 04121212d..6aba267cf 100644 --- a/src/MEDOP/tui/medpresentation/CMakeLists.txt +++ b/src/MEDOP/tui/presentation/CMakeLists.txt @@ -20,7 +20,7 @@ SET(PYFILES_TO_INSTALL __init__.py medpresentation.py - xmedimages.py + medimages.py ) -SALOME_INSTALL_SCRIPTS("${PYFILES_TO_INSTALL}" ${SALOME_INSTALL_PYTHON}/medpresentation) +SALOME_INSTALL_SCRIPTS("${PYFILES_TO_INSTALL}" ${SALOME_INSTALL_PYTHON}/medcalc) diff --git a/src/MEDOP/tui/medpresentation/__init__.py b/src/MEDOP/tui/presentation/__init__.py similarity index 100% rename from src/MEDOP/tui/medpresentation/__init__.py rename to src/MEDOP/tui/presentation/__init__.py diff --git a/src/MEDOP/tui/medpresentation/xmedimages.py b/src/MEDOP/tui/presentation/medimages.py similarity index 100% rename from src/MEDOP/tui/medpresentation/xmedimages.py rename to src/MEDOP/tui/presentation/medimages.py diff --git a/src/MEDOP/tui/medpresentation/medpresentation.py b/src/MEDOP/tui/presentation/medpresentation.py similarity index 97% rename from src/MEDOP/tui/medpresentation/medpresentation.py rename to src/MEDOP/tui/presentation/medpresentation.py index 086b4d7a0..6be27d541 100644 --- a/src/MEDOP/tui/medpresentation/medpresentation.py +++ b/src/MEDOP/tui/presentation/medpresentation.py @@ -36,7 +36,7 @@ def LoadImageAsDataSource(filename): medfilename = temp.name temp.close() - from xmedimages import FieldBuilder + from medimages import FieldBuilder builder = FieldBuilder() builder.image2med(filename, medfilename) LoadDataSource(medfilename) -- 2.39.2