From e0d562a6e55220fe3fbaf3883a7feda1e28d123c Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Tue, 21 Jul 2015 18:02:36 +0200 Subject: [PATCH] can create datasource from tui --- idl/MEDEventListener.idl | 2 ++ src/MEDOP/gui/DatasourceController.cxx | 9 +++++++++ src/MEDOP/gui/DatasourceController.hxx | 2 ++ src/MEDOP/gui/MEDEventListener_i.cxx | 2 -- src/MEDOP/gui/MEDOPModule.cxx | 3 +++ src/MEDOP/gui/WorkspaceController.cxx | 3 +++ src/MEDOP/gui/WorkspaceController.hxx | 3 +++ src/MEDOP/tui/medpresentation/medpresentation.py | 5 ++--- src/MEDOP/tui/xmedpy/fieldproxy.py | 7 +++++-- 9 files changed, 29 insertions(+), 7 deletions(-) diff --git a/idl/MEDEventListener.idl b/idl/MEDEventListener.idl index 30ea6b085..1fbf557b8 100644 --- a/idl/MEDEventListener.idl +++ b/idl/MEDEventListener.idl @@ -32,12 +32,14 @@ module MEDOP EVENT_DELETE_FIELD, EVENT_UPDATE_FIELD, EVENT_CLEAN_WORKSPACE, + EVENT_ADD_DATASOURCE, EVENT_UNKNOWN }; struct MedEvent { MedEventType type; long fieldid; + string filename; }; interface MEDEventListener: SALOME::GenericObj { diff --git a/src/MEDOP/gui/DatasourceController.cxx b/src/MEDOP/gui/DatasourceController.cxx index f46e9b5e0..740677333 100644 --- a/src/MEDOP/gui/DatasourceController.cxx +++ b/src/MEDOP/gui/DatasourceController.cxx @@ -552,3 +552,12 @@ void DatasourceController::OnInterpolateFieldInputValidated() { // // Tag the item to prevent double import // //_studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true); } + +void +DatasourceController::processWorkspaceEvent(const MEDOP::MedEvent * event) +{ + if ( event->type == MEDOP::EVENT_ADD_DATASOURCE ) { + this->addDatasource(event->filename); + _salomeModule->updateObjBrowser(true); + } +} diff --git a/src/MEDOP/gui/DatasourceController.hxx b/src/MEDOP/gui/DatasourceController.hxx index 435aebec9..9ed1ee0da 100644 --- a/src/MEDOP/gui/DatasourceController.hxx +++ b/src/MEDOP/gui/DatasourceController.hxx @@ -22,6 +22,7 @@ #ifndef DATASOURCE_CONTROLLER_H #define DATASOURCE_CONTROLLER_H +#include "MEDEventListener_i.hxx" #include #include CORBA_CLIENT_HEADER(MEDDataManager) #include @@ -79,6 +80,7 @@ public slots: // Callback connected to dialog box validation signals void OnChangeUnderlyingMeshInputValidated(); void OnInterpolateFieldInputValidated(); + void processWorkspaceEvent(const MEDOP::MedEvent * event); signals: void datasourceSignal(const DatasourceEvent * event); diff --git a/src/MEDOP/gui/MEDEventListener_i.cxx b/src/MEDOP/gui/MEDEventListener_i.cxx index ea129021b..5acb73efe 100644 --- a/src/MEDOP/gui/MEDEventListener_i.cxx +++ b/src/MEDOP/gui/MEDEventListener_i.cxx @@ -55,6 +55,4 @@ void MEDEventListener_i::processMedEvent(const MEDOP::MedEvent & event) { // WorkspaceController (connect to a slot of WorkspaceController). emit medEventSignal(new MEDOP::MedEvent(event)); - - } diff --git a/src/MEDOP/gui/MEDOPModule.cxx b/src/MEDOP/gui/MEDOPModule.cxx index 88139f752..e3fb1716e 100644 --- a/src/MEDOP/gui/MEDOPModule.cxx +++ b/src/MEDOP/gui/MEDOPModule.cxx @@ -83,6 +83,9 @@ void MEDOPModule::createModuleWidgets() { connect(_datasourceController, SIGNAL(datasourceSignal(const DatasourceEvent *)), _workspaceController, SLOT(processDatasourceEvent(const DatasourceEvent *))); + + connect(_workspaceController, SIGNAL(workspaceSignal(const MEDOP::MedEvent *)), + _datasourceController, SLOT(processWorkspaceEvent(const MEDOP::MedEvent *))); } bool MEDOPModule::activateModule( SUIT_Study* theStudy ) diff --git a/src/MEDOP/gui/WorkspaceController.cxx b/src/MEDOP/gui/WorkspaceController.cxx index e9930e846..6b2e5cc3f 100644 --- a/src/MEDOP/gui/WorkspaceController.cxx +++ b/src/MEDOP/gui/WorkspaceController.cxx @@ -293,6 +293,9 @@ void WorkspaceController::processMedEvent(const MEDOP::MedEvent * event) { dataModel->removeDataObject(itemNameId); } } + else if ( event->type == MEDOP::EVENT_ADD_DATASOURCE ) { + emit workspaceSignal(event); // forward to DatasourceController + } } diff --git a/src/MEDOP/gui/WorkspaceController.hxx b/src/MEDOP/gui/WorkspaceController.hxx index 229973360..410e52809 100644 --- a/src/MEDOP/gui/WorkspaceController.hxx +++ b/src/MEDOP/gui/WorkspaceController.hxx @@ -59,6 +59,9 @@ public slots: void OnSaveWorkspace(); void OnCleanWorkspace(); +signals: + void workspaceSignal(const MEDOP::MedEvent * event); + private: XmedConsoleDriver * _consoleDriver; StandardApp_Module * _salomeModule; diff --git a/src/MEDOP/tui/medpresentation/medpresentation.py b/src/MEDOP/tui/medpresentation/medpresentation.py index 11b029ad5..dfc977ef5 100644 --- a/src/MEDOP/tui/medpresentation/medpresentation.py +++ b/src/MEDOP/tui/medpresentation/medpresentation.py @@ -24,9 +24,8 @@ import SALOME __manager = xmed.factory.getPresentationManager() def LoadDataSource(filename): - dataHandler = xmed.dataManager.addDatasource(filename) - print data - #return data + from xmed.fieldproxy import notifyGui_addsource + notifyGui_addsource(filename) # def MakeScalarMap(proxy, viewMode): diff --git a/src/MEDOP/tui/xmedpy/fieldproxy.py b/src/MEDOP/tui/xmedpy/fieldproxy.py index a2f7d23ea..687f11e21 100644 --- a/src/MEDOP/tui/xmedpy/fieldproxy.py +++ b/src/MEDOP/tui/xmedpy/fieldproxy.py @@ -385,8 +385,8 @@ class FieldProxy: # that they could be used in another context than the FieldProxy instances import MEDOP -def __notifyGui(type, fieldId=-1): - medEvent = MEDOP.MedEvent(type, fieldId) +def __notifyGui(type, fieldId=-1, filename=""): + medEvent = MEDOP.MedEvent(type, fieldId, filename) if not xmed.eventListenerIsRunning(): return @@ -411,6 +411,9 @@ def notifyGui_remove(fieldId): def notifyGui_clean(): __notifyGui(MEDOP.EVENT_CLEAN_WORKSPACE) +def notifyGui_addsource(filename): + __notifyGui(MEDOP.EVENT_ADD_DATASOURCE,-1,filename) + # # =================================================================== # use case functions -- 2.39.2