Salome HOME
#18963 Minimize compiler warnings
[modules/med.git] / src / MEDCalc / gui / DatasourceController.cxx
index 0cde0a66b6f261aa4a9e5ef4df62b805eaa6fe5d..f0f18b997dff9e65e6e5b982a941d69d7dc5bbcd 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2020  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
 // Author : Guillaume Boulant (EDF)
 
 #include "DatasourceController.hxx"
-#include "DatasourceConstants.hxx"
+#include <MEDCalcConstants.hxx>
+
+#include <SalomeApp_Application.h>
+#include <SalomeApp_Study.h>
+#include <SalomeApp_DataObject.h>
+
+#include <SALOME_ListIO.hxx>
+#include <LightApp_SelectionMgr.h>
+
+#include <SALOME_LifeCycleCORBA.hxx>
+#include <SALOMEDS_SObject.hxx>
+#include <SALOMEDS_Study.hxx>
 
 #include "MEDFactoryClient.hxx"
+#include "MEDModule.hxx"
 #include "QtHelper.hxx"
 
 #include CORBA_CLIENT_HEADER(SALOMEDS)
+#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
 #include <SUIT_FileDlg.h>
 #include <SUIT_Desktop.h>
 
 #include <QStringList>
 #include <QString>
 #include <QMessageBox>
+#include <QFileDialog>
 
 #include "DlgAlias.hxx"
 
 // Datasource controller
 // ==============================================================
 //
-DatasourceController::DatasourceController(StandardApp_Module * salomeModule) {
+DatasourceController::DatasourceController(MEDModule* salomeModule)
+{
   STDLOG("Creating a DatasourceController");
   _salomeModule = salomeModule;
-  _studyEditor = new SALOME_AppStudyEditor(_salomeModule->getApp());
-
-  _dlgChangeUnderlyingMesh = new DlgChangeUnderlyingMesh(_studyEditor);
-  connect(_dlgChangeUnderlyingMesh,SIGNAL(inputValidated()),
-          this, SLOT(OnChangeUnderlyingMeshInputValidated()));
-
-  _dlgInterpolateField = new DlgInterpolateField(_studyEditor);
-  connect(_dlgInterpolateField,SIGNAL(inputValidated()),
-          this, SLOT(OnInterpolateFieldInputValidated()));
-
+  _studyEditor = _salomeModule->getStudyEditor();
 }
 
 DatasourceController::~DatasourceController() {
   STDLOG("Deleting the DatasourceController");
-  delete _studyEditor;
 }
 
 void DatasourceController::createActions() {
+  int toolbarId = _salomeModule->createTool("Datasource", "DatasourceToolbar");
+
   //
   // Main actions (toolbar and menubar)
   //
@@ -69,17 +76,20 @@ void DatasourceController::createActions() {
   QString icon    = tr("ICO_DATASOURCE_ADD");
   int actionId;
   actionId = _salomeModule->createStandardAction(label,this, SLOT(OnAddDatasource()),icon,tooltip);
-  _salomeModule->addActionInToolbar(actionId);
+  _salomeModule->createTool(actionId, toolbarId);
 
   // This action has to be placed in the general file menu with the label "Import MED file"
   int menuId = _salomeModule->createMenu( tr( "MEN_FILE" ), -1,  1 );
-  _salomeModule->addActionInMenubar(actionId, menuId);
+  _salomeModule->action(actionId)->setIconVisibleInMenu(true);
+  _salomeModule->createMenu(actionId, menuId, 10);
 
   label   = tr("LAB_ADD_IMAGE_SOURCE");
   tooltip = tr("TIP_ADD_IMAGE_SOURCE");
   icon    = tr("ICO_IMAGE_ADD");
   actionId = _salomeModule->createStandardAction(label,this, SLOT(OnAddImagesource()),icon,tooltip);
-  _salomeModule->addActionInToolbar(actionId);
+  _salomeModule->createTool(actionId, toolbarId);
+  _salomeModule->action(actionId)->setIconVisibleInMenu(true);
+  _salomeModule->createMenu(actionId, menuId, 20);
 
   //
   // Actions for popup menu only
@@ -90,37 +100,19 @@ void DatasourceController::createActions() {
   actionId = _salomeModule->createStandardAction(label,this,SLOT(OnExpandField()),icon);
   _salomeModule->addActionInPopupMenu(actionId);
 
-  // Create a view submenu with usual visualization functions
-  label = tr("LAB_VISUALIZE_SCALARMAP");
-  icon  = tr("ICO_DATASOURCE_VIEW");
-  actionId = _salomeModule->createStandardAction(label,this,SLOT(OnVisualizeScalarMap()),icon);
-  _salomeModule->addActionInPopupMenu(actionId, tr("LAB_VISUALIZE"));
-
   // Use in workspace
   label = tr("LAB_USE_IN_WORKSPACE");
   icon  = tr("ICO_DATASOURCE_USE");
   actionId = _salomeModule->createStandardAction(label,this,SLOT(OnUseInWorkspace()),icon);
   _salomeModule->addActionInPopupMenu(actionId);
 
-  // Change underlying mesh (note that this action creates a new field in
-  // the workspace that corresponds to a copy of the selected field
-  // modified by the change of the underlying mesh.
-  label = tr("LAB_CHANGE_MESH");
-  icon  = tr("ICO_DATASOURCE_CHANGE_MESH");
-  actionId = _salomeModule->createStandardAction(label,this,SLOT(OnChangeUnderlyingMesh()),icon);
-  _salomeModule->addActionInPopupMenu(actionId);
-
-  label = tr("LAB_INTERPOLATE_FIELD");
-  icon  = tr("ICO_DATASOURCE_INTERPOLATE_FIELD");
-  actionId = _salomeModule->createStandardAction(label,this,SLOT(OnInterpolateField()),icon);
-  _salomeModule->addActionInPopupMenu(actionId);
 }
 
 /**
  * This function adds the specified MED file as a datasource in the
  * dataspace. Technically speaking, the engine loads the
  * meta-information concerning med data from the file, gives this
- * informations to the GUI, and the GUI creates a tree view of these
+ * information to the GUI, and the GUI creates a tree view of these
  * data in the study object browser.
  */
 // This function emits a signal that will be caught by workspace to delegate command (datasource creation) to python console.
@@ -130,8 +122,14 @@ DatasourceController::addDatasource(const char* filename)
   DatasourceEvent* event = new DatasourceEvent();
   event->eventtype = DatasourceEvent::EVENT_ADD_DATASOURCE;
   event->objectalias = filename;
-  emit datasourceSignal(event);
+  emit datasourceSignal(event);  // --> WorkspaceController::processDatasourceEvent()
+//#ifdef MED_WITH_QTTESTING
+//  _dirtyAddDataSource = true;
+//  while(_dirtyAddDataSource)
+//    QApplication::processEvents();
+//#endif
 }
+
 // After above data source creation, python console emits a signal, forwarded by workspace, to update the GUI
 void
 DatasourceController::updateTreeViewWithNewDatasource(const MEDCALC::DatasourceHandler* datasourceHandler)
@@ -140,47 +138,14 @@ DatasourceController::updateTreeViewWithNewDatasource(const MEDCALC::DatasourceH
     return;
   }
 
-  // We need a studyEditor updated on the active study
-  _studyEditor->updateActiveStudy();
-
-  // Create a datasource SObject as a father of the module root
-  SALOMEDS::SComponent_var root = _studyEditor->findRoot(QCHARSTAR(_salomeModule->moduleName()));
-  SALOMEDS::SObject_var soDatasource = _studyEditor->newObject(root);
-  _studyEditor->setName(soDatasource,datasourceHandler->name);
-  _studyEditor->setIcon(soDatasource,tr("ICO_DATASOURCE").toStdString().c_str());
-  _studyEditor->setParameterInt(soDatasource,OBJECT_ID,datasourceHandler->id);
-
-
-  // We can add the meshes as children of the datasource
-  MEDCALC::MeshHandlerList * meshHandlerList =
-    MEDFactoryClient::getDataManager()->getMeshList(datasourceHandler->id);
-
-  for(CORBA::ULong iMesh=0; iMesh<meshHandlerList->length(); iMesh++) {
-    MEDCALC::MeshHandler meshHandler = (*meshHandlerList)[iMesh];
-    SALOMEDS::SObject_var soMesh = _studyEditor->newObject(soDatasource);
-    _studyEditor->setName(soMesh,meshHandler.name);
-    _studyEditor->setIcon(soMesh,tr("ICO_DATASOURCE_MESH").toStdString().c_str());
-    _studyEditor->setParameterInt(soMesh,OBJECT_ID,meshHandler.id);
-    _studyEditor->setParameterBool(soMesh,OBJECT_IS_IN_WORKSPACE,false);
-
-    // We add the field timeseries defined on this mesh, as children
-    // of the mesh SObject
-    MEDCALC::FieldseriesHandlerList * fieldseriesHandlerList =
-      MEDFactoryClient::getDataManager()->getFieldseriesListOnMesh(meshHandler.id);
-
-    for(CORBA::ULong iFieldseries=0; iFieldseries<fieldseriesHandlerList->length(); iFieldseries++) {
-      MEDCALC::FieldseriesHandler fieldseriesHandler = (*fieldseriesHandlerList)[iFieldseries];
-      SALOMEDS::SObject_var soFieldseries = _studyEditor->newObject(soMesh);
-
-      std::string label(fieldseriesHandler.name);
-      label +=" ("+std::string(XmedDataObject::mapTypeOfFieldLabel[fieldseriesHandler.type])+")";
-      _studyEditor->setName(soFieldseries,label.c_str());
-
-      _studyEditor->setIcon(soFieldseries,tr("ICO_DATASOURCE_FIELD").toStdString().c_str());
-      _studyEditor->setParameterInt(soFieldseries,OBJECT_ID,fieldseriesHandler.id);
-      _studyEditor->setParameterBool(soFieldseries,OBJECT_IS_IN_WORKSPACE,false);
-    }
-  }
+  _salomeModule->engine()->addDatasourceToStudy(*datasourceHandler);
+
+  // update Object browser
+  _salomeModule->getApp()->updateObjectBrowser(true);
+
+//#ifdef MED_WITH_QTTESTING
+//  _dirtyAddDataSource = false;
+//#endif
 }
 
 void DatasourceController::OnAddDatasource()
@@ -193,10 +158,15 @@ void DatasourceController::OnAddDatasource()
   if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
     anInitialPath = QDir::currentPath();
 
-  QStringList filenames = SUIT_FileDlg::getOpenFileNames( _salomeModule->getApp()->desktop(),
+//  QStringList filenames = SUIT_FileDlg::getOpenFileNames( _salomeModule->getApp()->desktop(),
+//                                                          anInitialPath,
+//                                                          filter,
+//                                                          tr("IMPORT_MED_FIELDS") );
+  // [ABN] the below to be compatible with QtTesting:
+  QStringList filenames = QFileDialog::getOpenFileNames( _salomeModule->getApp()->desktop(),
+                                                          tr("IMPORT_MED_FIELDS"),
                                                           anInitialPath,
-                                                          filter,
-                                                          tr("IMPORT_MED_FIELDS") );
+                                                          tr("FILE_FILTER_MED") );
 
   if ( filenames.count() <= 0 ) return;
   for ( QStringList::ConstIterator itFile = filenames.begin();
@@ -208,8 +178,6 @@ void DatasourceController::OnAddDatasource()
 }
 
 #include "DlgImageToMed.hxx"
-//#include <stdio.h>
-//#include <stdlib.h>
 void DatasourceController::OnAddImagesource()
 {
 
@@ -226,8 +194,8 @@ void DatasourceController::OnAddImagesource()
   QString medFilename   = dialog.getMedFilepath();
   bool autoLoad         = dialog.isAutoLoaded();
 
-  std::string ROOT_DIR(getenv("MED_ROOT_DIR"));
-  std::string command(ROOT_DIR+"/bin/salome/med/image2med.py");
+  std::string ROOT_DIR(getenv("FIELDS_ROOT_DIR"));
+  std::string command(ROOT_DIR+"/bin/salome/fields/image2med.py");
   command += " -i "+QS2S(imageFilename);
   command += " -m "+QS2S(medFilename);
   int error = system(command.c_str());
@@ -247,21 +215,39 @@ void DatasourceController::OnAddImagesource()
   DatasourceEvent* event = new DatasourceEvent();
   event->eventtype = DatasourceEvent::EVENT_ADD_IMAGE_AS_DATASOURCE;
   event->objectalias = imageFilename;
-  emit datasourceSignal(event);
+  emit datasourceSignal(event); // --> WorkspaceController::processDatasourceEvent()
 }
 
 void DatasourceController::OnExpandField()
 {
-  // We need a studyEditor updated on the active study
-  _studyEditor->updateActiveStudy();
+  SALOMEDS::Study_var aStudy = KERNEL::getStudyServant();
+  // check if reference to study is valid
+  if (CORBA::is_nil(aStudy)) 
+    return;
+
+  // check if reference to use case builder is valid
+  SALOMEDS::UseCaseBuilder_var useCaseBuilder = aStudy->GetUseCaseBuilder();
+  if (CORBA::is_nil(useCaseBuilder)) 
+    return;
+
 
   // Get the selected objects in the study (SObject)
-  SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects();
-  for (int i=0; i<listOfSObject->size(); i++) {
+  SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects();
+  for (int i=0; i<(int)listOfSObject->size(); i++) {
     SALOMEDS::SObject_var soFieldseries = listOfSObject->at(i);
+    std::string name(_studyEditor->getName(soFieldseries));
+    if (soFieldseries->_is_nil() || name == "MEDCalc")
+      return;
 
     // First retrieve the fieldseries id associated to this study object
-    long fieldseriesId = _studyEditor->getParameterInt(soFieldseries,OBJECT_ID);
+    SALOMEDS::GenericAttribute_var anAttr;
+    SALOMEDS::AttributeParameter_var aParam;
+    if ( soFieldseries->FindAttribute(anAttr,"AttributeParameter") ) {
+      aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
+      if (! aParam->IsSet(FIELD_SERIES_ID, PT_INTEGER))
+        return;
+    }
+    long fieldseriesId = aParam->GetInt(FIELD_SERIES_ID);
     STDLOG("Expand the field timeseries "<<fieldseriesId);
 
     // If fieldseriesId equals -1, then it means that it is not a
@@ -273,7 +259,7 @@ void DatasourceController::OnExpandField()
     // contextual menu if the selected object is not conform
 
     // Then retrieve the list of fields in this timeseries
-    MEDCALC::FieldHandlerList * fieldHandlerList =
+    MEDCALC::FieldHandlerList* fieldHandlerList =
       MEDFactoryClient::getDataManager()->getFieldListInFieldseries(fieldseriesId);
 
     // Finally, create an entry for each of the field
@@ -282,58 +268,17 @@ void DatasourceController::OnExpandField()
       SALOMEDS::SObject_var soField = _studyEditor->newObject(soFieldseries);
       std::string label("it="); label += ToString(fieldHandler.iteration);
       _studyEditor->setName(soField,label.c_str());
-      _studyEditor->setParameterInt(soField, OBJECT_ID, fieldHandler.id);
-      _studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,false);
+      _studyEditor->setParameterInt(soField, FIELD_ID, fieldHandler.id);
+      _studyEditor->setParameterBool(soField,IS_IN_WORKSPACE,false);
+      useCaseBuilder->AppendTo(soField->GetFather(), soField);
     }
   }
   _salomeModule->updateObjBrowser(true);
 }
 
-void DatasourceController::visualize(DatasourceEvent::EventType eventType) {
-  // We need a _studyEditor updated on the active study
-  _studyEditor->updateActiveStudy();
-
-  // Get the selected objects in the study (SObject)
-  SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects();
-
-  // For each object, emit a signal to the workspace to request a
-  // visualisation using the tui command (so that the user can see how
-  // to make a view of an object from the tui console).
-  for (int i=0; i<listOfSObject->size(); i++) {
-    SALOMEDS::SObject_var soField = listOfSObject->at(i);
-    int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
-    // If fieldId equals -1, then it means that it is not a field
-    // managed by the MED module, and we stop this function process.
-    if ( fieldId < 0 )
-      continue;
-
-    MEDCALC::FieldHandler * fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
-    if (! fieldHandler) {
-      QMessageBox::warning(_salomeModule->getApp()->desktop(),
-         tr("Operation not allowed"),
-         tr("No field is defined"));
-      return;
-    }
-
-    DatasourceEvent * event = new DatasourceEvent();
-    event->eventtype = eventType;
-    XmedDataObject * dataObject = new XmedDataObject();
-    dataObject->setFieldHandler(*fieldHandler);
-    event->objectdata  = dataObject;
-    emit datasourceSignal(event);
-  }
-}
-
-void DatasourceController::OnVisualizeScalarMap() {
-  this->visualize(DatasourceEvent::EVENT_VIEW_OBJECT_SCALAR_MAP);
-}
-
 void DatasourceController::OnUseInWorkspace() {
-  // We need a studyEditor updated on the active study
-  _studyEditor->updateActiveStudy();
-
   // Get the selected objects in the study (SObject)
-  SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects();
+  SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects();
   if ( listOfSObject->size() == 1 ) {
     // In this case we ask the name of the variable for the python
     // console
@@ -346,8 +291,17 @@ void DatasourceController::OnUseInWorkspace() {
     // <<<
 
     SALOMEDS::SObject_var soField = listOfSObject->at(0);
-
-    bool isInWorkspace = _studyEditor->getParameterBool(soField,OBJECT_IS_IN_WORKSPACE);
+    std::string name(_studyEditor->getName(soField));
+    if (soField->_is_nil() || name == "MEDCalc")
+      return;
+    SALOMEDS::GenericAttribute_var anAttr;
+    SALOMEDS::AttributeParameter_var aParam;
+    if ( soField->FindAttribute(anAttr,"AttributeParameter") ) {
+      aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
+      if (! aParam->IsSet(IS_IN_WORKSPACE, PT_BOOLEAN))
+        return;
+    }
+    bool isInWorkspace = aParam->GetBool(IS_IN_WORKSPACE);
     if ( isInWorkspace ) {
       QMessageBox::warning(_salomeModule->getApp()->desktop(),
          tr("Operation not allowed"),
@@ -355,7 +309,9 @@ void DatasourceController::OnUseInWorkspace() {
       return;
     }
 
-    int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
+    if (! aParam->IsSet(FIELD_ID, PT_INTEGER))
+      return;
+    int fieldId = aParam->GetInt(FIELD_ID);
 
     // If fieldId equals -1, then it means that it is not a field
     // managed by the MED module, and we stop this function process.
@@ -366,7 +322,7 @@ void DatasourceController::OnUseInWorkspace() {
       return;
     }
 
-    MEDCALC::FieldHandler * fieldHandler =
+    MEDCALC::FieldHandler* fieldHandler =
       MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
 
     if (! fieldHandler) {
@@ -386,15 +342,15 @@ void DatasourceController::OnUseInWorkspace() {
     }
     alias = dialog.getAlias();
 
-    DatasourceEvent * event = new DatasourceEvent();
+    DatasourceEvent* event = new DatasourceEvent();
     event->eventtype = DatasourceEvent::EVENT_USE_OBJECT;
-    XmedDataObject * dataObject = new XmedDataObject();
+    XmedDataObject* dataObject = new XmedDataObject();
     dataObject->setFieldHandler(*fieldHandler);
     event->objectdata  = dataObject;
     event->objectalias = alias;
-    emit datasourceSignal(event);
+    emit datasourceSignal(event);  // --> WorkspaceController::processDatasourceEvent()
     // Tag the item to prevent double import
-    //    _studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true);
+    //    _studyEditor->setParameterBool(soField,IS_IN_WORKSPACE,true);
     // Tag the field as persistent on the server. It means that a
     // saving of the workspace will save at least this field (maybe it
     // should be an option?)
@@ -403,24 +359,34 @@ void DatasourceController::OnUseInWorkspace() {
   else {
     // In this case, we don't ask the user to specify an alias for
     // each item, we just import the whole set of items.
-    for (int i=0; i<listOfSObject->size(); i++) {
+    for (int i=0; i<(int)listOfSObject->size(); i++) {
       SALOMEDS::SObject_var soField = listOfSObject->at(i);
-
-      bool isInWorkspace = _studyEditor->getParameterBool(soField,OBJECT_IS_IN_WORKSPACE);
+      if (soField->_is_nil())
+        continue;
+      SALOMEDS::GenericAttribute_var anAttr;
+      SALOMEDS::AttributeParameter_var aParam;
+      if ( soField->FindAttribute(anAttr,"AttributeParameter") ) {
+        aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
+        if (! aParam->IsSet(IS_IN_WORKSPACE, PT_BOOLEAN))
+          return;
+      }
+      bool isInWorkspace = aParam->GetBool(IS_IN_WORKSPACE);
       if ( !isInWorkspace ) {
-        int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
-        MEDCALC::FieldHandler * fieldHandler =
+        if (! aParam->IsSet(FIELD_ID, PT_INTEGER))
+          continue;
+        int fieldId = aParam->GetInt(FIELD_ID);
+        MEDCALC::FieldHandler* fieldHandler =
           MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
-        DatasourceEvent * event = new DatasourceEvent();
+        DatasourceEvent* event = new DatasourceEvent();
         event->eventtype = DatasourceEvent::EVENT_IMPORT_OBJECT;
-        XmedDataObject * dataObject = new XmedDataObject();
+        XmedDataObject* dataObject = new XmedDataObject();
         dataObject->setFieldHandler(*fieldHandler);
         event->objectdata  = dataObject;
-        emit datasourceSignal(event);
+        emit datasourceSignal(event); // --> WorkspaceController::processDatasourceEvent()
         // Note that this signal is processed by the WorkspaceController
 
         // Tag the item to prevent double import
-        //        _studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true);
+        //        _studyEditor->setParameterBool(soField,IS_IN_WORKSPACE,true);
         // Tag the field as persistent on the server. It means that a
         // saving of the workspace will save at least this field (maybe it
         // should be an option?)
@@ -434,138 +400,11 @@ void DatasourceController::OnUseInWorkspace() {
   }
 }
 
-void DatasourceController::OnChangeUnderlyingMesh() {
-  // We need a studyEditor updated on the active study
-  _studyEditor->updateActiveStudy();
-
-  // Get the selected objects in the study (SObject). In cas of a
-  // multiple selection, we consider only the first item. At least one
-  // item must be selected.
-  SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects();
-  if ( listOfSObject->size() > 0 ) {
-    SALOMEDS::SObject_var soField = listOfSObject->at(0);
-    int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
-    // _GBO_ : the dialog should not be modal, so that we can choose a
-    // mesh in the browser. Then we have to emit a signal from the
-    // dialog.accept, connected to a slot of the DatasourceControler
-    _dlgChangeUnderlyingMesh->setFieldId(fieldId);
-    Qt::WindowFlags flags = _dlgChangeUnderlyingMesh->windowFlags();
-    _dlgChangeUnderlyingMesh->setWindowFlags(flags | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
-    _dlgChangeUnderlyingMesh->open();
-  }
-}
-
-void DatasourceController::OnChangeUnderlyingMeshInputValidated() {
-  int meshId = _dlgChangeUnderlyingMesh->getMeshId();
-  STDLOG("meshId = " << ToString(meshId));
-  int fieldId = _dlgChangeUnderlyingMesh->getFieldId();
-  MEDCALC::FieldHandler * fieldHandler =
-    MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
-
-  // We don't modify the original field but create first a duplicate
-  MEDCALC::FieldHandler * duplicate = MEDFactoryClient::getCalculator()->dup(*fieldHandler);
-  MEDFactoryClient::getDataManager()->changeUnderlyingMesh(duplicate->id, meshId);
-
-  // Request once more the duplicate to update the meta-data on this
-  // client side
-  duplicate = MEDFactoryClient::getDataManager()->getFieldHandler(duplicate->id);
-
-  // >>>
-  // WARN: the following is a temporary code for test purpose
-  // Automatically add in ws
-  DatasourceEvent * event = new DatasourceEvent();
-  event->eventtype = DatasourceEvent::EVENT_IMPORT_OBJECT;
-  XmedDataObject * dataObject = new XmedDataObject();
-  dataObject->setFieldHandler(*duplicate);
-  event->objectdata = dataObject;
-  emit datasourceSignal(event);
-  // Note that this signal is processed by the WorkspaceController
-
-  // Tag the item to prevent double import
-  //_studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true);
-}
-
-void DatasourceController::OnInterpolateField() {
-  // We need a studyEditor updated on the active study
-  _studyEditor->updateActiveStudy();
-
-  // Get the selected objects in the study (SObject). In case of a
-  // multiple selection, we consider only the first item. At least one
-  // item must be selected.
-  SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects();
-  if ( listOfSObject->size() > 0 ) {
-    SALOMEDS::SObject_var soField = listOfSObject->at(0);
-    int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
-    // _GBO_ : the dialog should not be modal, so that we can choose a
-    // mesh in the browser. Then we have to emit a signal from the
-    // dialog.accept, connected to a slot of the DatasourceControler
-    _dlgInterpolateField->setFieldId(fieldId);
-    Qt::WindowFlags flags = _dlgInterpolateField->windowFlags();
-    _dlgInterpolateField->setWindowFlags(flags | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
-    _dlgInterpolateField->open();
-  }
-}
-
-void DatasourceController::OnInterpolateFieldInputValidated() {
-  MEDCALC::InterpolationParameters params;
-  params.precision = _dlgInterpolateField->getPrecision();
-  STDLOG("precision = " << params.precision);
-  params.defaultValue = _dlgInterpolateField->getDefaultValue();
-  STDLOG("defaultValue = " << params.defaultValue);
-  params.reverse = _dlgInterpolateField->getReverse();
-  STDLOG("reverse = " << params.reverse);
-  params.intersectionType = _dlgInterpolateField->getIntersectionType().c_str();
-  STDLOG("intersectionType = " << params.intersectionType);
-  params.method = _dlgInterpolateField->getMethod().c_str();
-  STDLOG("method = " << params.method);
-  params.nature = _dlgInterpolateField->getFieldNature().c_str();
-  STDLOG("nature = " << params.nature);
-
-  int meshId = _dlgInterpolateField->getMeshId();
-  STDLOG("meshId = " << ToString(meshId));
-  int fieldId = _dlgInterpolateField->getFieldId();
-  MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
-
-  // We don't modify the original field but create first a duplicate
-  // MEDCALC::FieldHandler* duplicate = MEDFactoryClient::getCalculator()->dup(*fieldHandler);
-  //MEDFactoryClient::getDataManager()->changeUnderlyingMesh(duplicate->id, meshId);
-  MEDCALC::FieldHandler* result = NULL;
-  try {
-    result = MEDFactoryClient::getDataManager()->interpolateField(fieldId, meshId, params);
-  }
-  catch(...) {
-    STDLOG("Unable to process field interpolation; please check interpolation parameters");
-    QMessageBox::critical(_salomeModule->getApp()->desktop(),
-                          tr("Operation failed"),
-                          tr("Unable to process field interpolation; please check interpolation parameters"));
-    return;
-  }
-
-  // Request once more the duplicate to update the meta-data on this
-  // client side
-  // duplicate = MEDFactoryClient::getDataManager()->getFieldHandler(duplicate->id);
-
-  // >>>
-  // WARN: the following is a temporary code for test purpose
-  // Automatically add in ws
-  DatasourceEvent * event = new DatasourceEvent();
-  event->eventtype = DatasourceEvent::EVENT_IMPORT_OBJECT;
-  XmedDataObject * dataObject = new XmedDataObject();
-  dataObject->setFieldHandler(*result);
-  event->objectdata = dataObject;
-  emit datasourceSignal(event);
-  // Note that this signal is processed by the WorkspaceController
-
-  // // Tag the item to prevent double import
-  // //_studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true);
-}
-
 void
 DatasourceController::processWorkspaceEvent(const MEDCALC::MedEvent* event)
 {
   if ( event->type == MEDCALC::EVENT_ADD_DATASOURCE ) {
     MEDCALC::DatasourceHandler* datasourceHandler = MEDFactoryClient::getDataManager()->getDatasourceHandler(event->filename);
     this->updateTreeViewWithNewDatasource(datasourceHandler);
-    _salomeModule->updateObjBrowser(true);
   }
 }