Salome HOME
can create datasource from tui
authorCédric Aguerre <cedric.aguerre@edf.fr>
Tue, 21 Jul 2015 16:02:36 +0000 (18:02 +0200)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Tue, 21 Jul 2015 16:02:36 +0000 (18:02 +0200)
idl/MEDEventListener.idl
src/MEDOP/gui/DatasourceController.cxx
src/MEDOP/gui/DatasourceController.hxx
src/MEDOP/gui/MEDEventListener_i.cxx
src/MEDOP/gui/MEDOPModule.cxx
src/MEDOP/gui/WorkspaceController.cxx
src/MEDOP/gui/WorkspaceController.hxx
src/MEDOP/tui/medpresentation/medpresentation.py
src/MEDOP/tui/xmedpy/fieldproxy.py

index 30ea6b0854e8fe11baaf57be518ed720a358d884..1fbf557b82386cd12060e60588e7c91f900bf00a 100644 (file)
@@ -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 {
index f46e9b5e0bbdab0b72555b958e57f5ef106171dd..740677333bfee29905c70b04e02563f22d83bede 100644 (file)
@@ -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);
+  }
+}
index 435aebec9ac755527f02944e7bd1a941817439c2..9ed1ee0daa4113ebfe409e8b0e0b1880f101c923 100644 (file)
@@ -22,6 +22,7 @@
 #ifndef DATASOURCE_CONTROLLER_H
 #define DATASOURCE_CONTROLLER_H
 
+#include "MEDEventListener_i.hxx"
 #include <SALOMEconfig.h>
 #include CORBA_CLIENT_HEADER(MEDDataManager)
 #include <StandardApp_Module.hxx>
@@ -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);
index ea129021b72d79b61eeab70378e70289029d238c..5acb73efead16973650721baf7b4b90e09c0da4f 100644 (file)
@@ -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));
-  
-
 }
index 88139f75251c711c0f63c9a8c83031abfeb168bd..e3fb1716efbf17f962b6aa70a9c94a133f6602ef 100644 (file)
@@ -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 )
index e9930e8467449095ddf2bc7cdaaffdca40593cdd..6b2e5cc3ff17589ab83c52ffd2b187889d8fb085 100644 (file)
@@ -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
+  }
 
 }
 
index 229973360fd1635427ae9b9d8174ed67eb2e4443..410e528090cc3dfabfee24ebc92a6671e1072752 100644 (file)
@@ -59,6 +59,9 @@ public slots:
   void OnSaveWorkspace();
   void OnCleanWorkspace();
 
+signals:
+  void workspaceSignal(const MEDOP::MedEvent * event);
+
 private:
   XmedConsoleDriver * _consoleDriver;
   StandardApp_Module * _salomeModule;
index 11b029ad5dc00b656c3c659a0b001e8963b6f6db..dfc977ef573d58238eade9884f2acbd794079089 100644 (file)
@@ -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):
index a2f7d23ea6ff42586643484a1a8dd0d30195c754..687f11e219f8635ede619cf6d5be7a4e959c163d 100644 (file)
@@ -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