Salome HOME
[MEDCalc] Introduce ProcessingController
authorCédric Aguerre <cedric.aguerre@edf.fr>
Wed, 2 Mar 2016 15:16:38 +0000 (16:16 +0100)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Wed, 2 Mar 2016 15:16:38 +0000 (16:16 +0100)
20 files changed:
src/MEDCalc/gui/CMakeLists.txt
src/MEDCalc/gui/DatasourceController.cxx
src/MEDCalc/gui/DatasourceController.hxx
src/MEDCalc/gui/MEDModule.cxx
src/MEDCalc/gui/MEDModule.hxx
src/MEDCalc/gui/MED_images.ts
src/MEDCalc/gui/MED_msg_en.ts
src/MEDCalc/gui/MED_msg_fr.ts
src/MEDCalc/gui/PresentationController.cxx
src/MEDCalc/gui/PresentationController.hxx
src/MEDCalc/gui/ProcessingController.cxx [new file with mode: 0644]
src/MEDCalc/gui/ProcessingController.hxx [new file with mode: 0644]
src/MEDCalc/gui/WorkspaceController.cxx
src/MEDCalc/gui/WorkspaceController.hxx
src/MEDCalc/res/MEDCalc.png
src/MEDCalc/res/MEDCalc_small.png
src/MEDCalc/res/datasource_changeUnderlyingMesh.png [deleted file]
src/MEDCalc/res/datasource_interpolateField.png [deleted file]
src/MEDCalc/res/processing_changeUnderlyingMesh.png [new file with mode: 0644]
src/MEDCalc/res/processing_interpolateField.png [new file with mode: 0644]

index 62cb36a167e0ea8fe6ed6d3805f30bd081c3334e..125b6099530f4981ca16ce236ee03faa6092ae68 100644 (file)
@@ -31,7 +31,9 @@ SET(MEDCALCGUI_HEADERS
   MEDEventListener_i.hxx
   WorkspaceController.hxx
   DatasourceController.hxx
-  PresentationController.hxx)
+  PresentationController.hxx
+  ProcessingController.hxx
+  )
 QT_WRAP_MOC(MEDCALCGUI_HEADERS_MOC ${MEDCALCGUI_HEADERS})
 
 
index 5a14447196786ab0daacc2fe2fd20815eb6d6b0a..bd939552487b53f11e7c8a946717e1ad6234df1d 100644 (file)
 // Datasource controller
 // ==============================================================
 //
-//DatasourceController::DatasourceController(StandardApp_Module* salomeModule)
 DatasourceController::DatasourceController(MEDModule* salomeModule)
 {
   STDLOG("Creating a DatasourceController");
   _salomeModule = salomeModule;
   _studyEditor = _salomeModule->getStudyEditor();
-
-  _dlgChangeUnderlyingMesh = new DlgChangeUnderlyingMesh(_studyEditor);
-  connect(_dlgChangeUnderlyingMesh,SIGNAL(inputValidated()),
-          this, SLOT(OnChangeUnderlyingMeshInputValidated()));
-
-  _dlgInterpolateField = new DlgInterpolateField(_studyEditor);
-  connect(_dlgInterpolateField,SIGNAL(inputValidated()),
-          this, SLOT(OnInterpolateFieldInputValidated()));
 }
 
 DatasourceController::~DatasourceController() {
@@ -74,8 +65,6 @@ DatasourceController::~DatasourceController() {
 }
 
 void DatasourceController::createActions() {
-  //QWidget* dsk = _salomeModule->getApp()->desktop();
-  //SUIT_ResourceMgr* resMgr = _salomeModule->getApp()->resourceMgr();
   int toolbarId = _salomeModule->createTool("Datasource", "DatasourceToolbar");
 
   //
@@ -86,12 +75,10 @@ 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);
 
@@ -99,7 +86,6 @@ void DatasourceController::createActions() {
   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);
@@ -118,19 +104,6 @@ void DatasourceController::createActions() {
   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);
 }
 
 /**
@@ -191,8 +164,6 @@ void DatasourceController::OnAddDatasource()
 }
 
 #include "DlgImageToMed.hxx"
-//#include <stdio.h>
-//#include <stdlib.h>
 void DatasourceController::OnAddImagesource()
 {
 
@@ -378,132 +349,6 @@ 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)
 {
index b2097e38c1f135be45a87504b733f198a1f7d054..7d9e5bef233059a94ad8ea8e71a71895c0eb39f3 100644 (file)
@@ -31,8 +31,6 @@
 #include <MEDPresentation.hxx>
 
 #include "XmedDataModel.hxx"
-#include "DlgChangeUnderlyingMesh.hxx"
-#include "DlgInterpolateField.hxx"
 #include "MEDCALCGUI.hxx"
 //
 // The DatasourceController defines data structures and classes to
@@ -88,9 +86,6 @@ public:
   void createActions();
 
 public slots:
-  // Callback connected to dialog box validation signals
-  void OnChangeUnderlyingMeshInputValidated();
-  void OnInterpolateFieldInputValidated();
   void processWorkspaceEvent(const MEDCALC::MedEvent* event);
 
 signals:
@@ -101,8 +96,6 @@ protected slots:
   void OnAddImagesource();
   void OnExpandField();
   void OnUseInWorkspace();
-  void OnChangeUnderlyingMesh();
-  void OnInterpolateField();
 
 private:
   void addDatasource(const char* filename);
@@ -111,10 +104,6 @@ private:
 private:
   MEDModule* _salomeModule;
   SALOME_AppStudyEditor* _studyEditor; // borrowed to MEDModule
-
-  DlgChangeUnderlyingMesh* _dlgChangeUnderlyingMesh;
-  DlgInterpolateField* _dlgInterpolateField;
-
 };
 
 #endif
index f5f091420b6fecf4bc6c22a566b280089ec6ee49..d5835444a3e5cf674f7a4312e36752e10585b5e3 100644 (file)
@@ -39,7 +39,7 @@
 MED_ORB::MED_Gen_var MEDModule::myEngine;
 
 MEDModule::MEDModule() :
-  SalomeApp_Module("MED"), _studyEditor(0), _datasourceController(0), _workspaceController(0), _presentationController(0)
+  SalomeApp_Module("MED"), _studyEditor(0), _datasourceController(0), _workspaceController(0), _presentationController(0), _processingController(0)
 {
   // Note also that we can't use the getApp() function here because
   // the initialize(...) function has not been called yet.
@@ -57,6 +57,8 @@ MEDModule::~MEDModule()
   //  delete _workspaceController;
   if (_presentationController)
     delete _presentationController;
+  if (_processingController)
+    delete _processingController;
 }
 
 MED_ORB::MED_Gen_var
@@ -201,6 +203,7 @@ MEDModule::createModuleWidgets() {
   _xmedDataModel  = new XmedDataModel();
   _workspaceController->setDataModel(_xmedDataModel);
   _presentationController = new PresentationController(this);
+  _processingController = new ProcessingController(this);
 
   connect(_datasourceController, SIGNAL(datasourceSignal(const DatasourceEvent*)),
     _workspaceController, SLOT(processDatasourceEvent(const DatasourceEvent*)));
@@ -208,6 +211,9 @@ MEDModule::createModuleWidgets() {
   connect(_presentationController, SIGNAL(presentationSignal(const PresentationEvent*)),
     _workspaceController, SLOT(processPresentationEvent(const PresentationEvent*)));
 
+  connect(_processingController, SIGNAL(processingSignal(const ProcessingEvent*)),
+    _workspaceController, SLOT(processProcessingEvent(const ProcessingEvent*)));
+
   connect(_workspaceController, SIGNAL(workspaceSignal(const MEDCALC::MedEvent*)),
     _datasourceController, SLOT(processWorkspaceEvent(const MEDCALC::MedEvent*)));
 
@@ -220,6 +226,7 @@ MEDModule::createModuleActions() {
   _datasourceController->createActions();
   _workspaceController->createActions();
   _presentationController->createActions();
+  _processingController->createActions();
 }
 
 int
index 97cf198888537d13565a975a5dc2c1d53ca5ca18..cec0dbf4afe131518b94192a04aa2e18f0799ffa 100644 (file)
@@ -31,6 +31,7 @@
 #include "XmedDataModel.hxx"
 #include "DatasourceController.hxx"
 #include "PresentationController.hxx"
+#include "ProcessingController.hxx"
 
 #include <SALOMEconfig.h>
 #include CORBA_CLIENT_HEADER(MED_Gen)
@@ -94,6 +95,7 @@ private:
   WorkspaceController* _workspaceController;
   XmedDataModel* _xmedDataModel;
   PresentationController* _presentationController;
+  ProcessingController* _processingController;
   static MED_ORB::MED_Gen_var myEngine;
 };
 
index bcc3b14e51f948a07aff328d42cc61bf1beb107f..7484fc4c111b09db7227ddef25907df34442fbca 100644 (file)
       <translation>datasource_add.png</translation>
     </message>
     <message>
-      <source>ICO_DATASOURCE_CHANGE_MESH</source>
-      <translation>datasource_changeUnderlyingMesh.png</translation>
+      <source>ICO_PROCESSING_CHANGE_MESH</source>
+      <translation>processing_changeUnderlyingMesh.png</translation>
     </message>
     <message>
-      <source>ICO_DATASOURCE_INTERPOLATE_FIELD</source>
-      <translation>datasource_interpolateField.png</translation>
+      <source>ICO_PROCESSING_INTERPOLATE_FIELD</source>
+      <translation>processing_interpolateField.png</translation>
     </message>
     <message>
       <source>ICO_DATASOURCE_EXPAND_FIELD</source>
index ba14c9e84e0614681c6dc7ae0a91d1a1aefa087c..8754beb6b09bc21c26409d280839844815041856 100644 (file)
       <translation>Point sprite</translation>
     </message>
   </context>
+  <context>
+    <name>ProcessingController</name>
+    <message>
+      <source>MENU_PROCESSING</source>
+      <translation>Processing</translation>
+    </message>
+    <message>
+      <source>LAB_PROCESSING_CHANGE_MESH</source>
+      <translation>Change underlying mesh</translation>
+    </message>
+    <message>
+      <source>LAB_PROCESSING_INTERPOLATE_FIELD</source>
+      <translation>Interpolate field</translation>
+    </message>
+  </context>
   <context>
     <name>DatasourceController</name>
     <message>
       <source>LAB_USE_IN_WORKSPACE</source>
       <translation>Use in workspace</translation>
     </message>
-    <message>
-      <location filename="MEDCALC/gui/DatasourceController.cxx" line="83"/>
-      <source>LAB_CHANGE_MESH</source>
-      <translation>Change underlying mesh</translation>
-    </message>
-    <message>
-      <location filename="MEDCALC/gui/DatasourceController.cxx" line="113"/>
-      <source>LAB_INTERPOLATE_FIELD</source>
-      <translation>Interpolate field</translation>
-    </message>
     <message>
       <location filename="MEDCALC/gui/DatasourceController.cxx" line="157"/>
       <source>IMPORT_MED_FIELDS</source>
index d339c08b96b34df07b19a31628e8a37533eab070..f09dc6717584ab52ebe985a92deae7bf1c61b8f5 100644 (file)
       <translation>Point sprite</translation>
     </message>
   </context>
+  <context>
+    <name>ProcessingController</name>
+    <message>
+      <source>MENU_PROCESSING</source>
+      <translation>Traitement</translation>
+    </message>
+    <message>
+      <source>LAB_PROCESSING_CHANGE_MESH</source>
+      <translation>Changer le maillage sous-jacent</translation>
+    </message>
+    <message>
+      <source>LAB_PROCESSING_INTERPOLATE_FIELD</source>
+      <translation>Interpoler le champ</translation>
+    </message>
+  </context>
   <context>
     <name>DatasourceController</name>
     <message>
       <source>LAB_USE_IN_WORKSPACE</source>
       <translation>Utiliser dans l'espace de travail</translation>
     </message>
-    <message>
-      <location filename="MEDCALC/gui/DatasourceController.cxx" line="83"/>
-      <source>LAB_CHANGE_MESH</source>
-      <translation>Changer le maillage sous-jacent</translation>
-    </message>
-    <message>
-      <location filename="MEDCALC/gui/DatasourceController.cxx" line="113"/>
-      <source>LAB_INTERPOLATE_FIELD</source>
-      <translation>Interpoler le champ</translation>
-    </message>
     <message>
       <location filename="MEDCALC/gui/DatasourceController.cxx" line="157"/>
       <source>IMPORT_MED_FIELDS</source>
index b6cbe19c191845f3d93b35d4c651b6ddc1d75ff9..c53281a49b2c21cc82bb0fe9330a7951d24795c5 100644 (file)
@@ -85,7 +85,7 @@ PresentationController::createActions()
 {
   STDLOG("Creating PresentationController actions");
 
-  int presentationToolbarId = _salomeModule->createTool("View Mode", "PresentationToolbar");
+  int presentationToolbarId = _salomeModule->createTool("Presentations", "PresentationToolbar");
   int presentationMenuId = _salomeModule->createMenu(tr("MENU_PRESENTATIONS"), -1, 1);
 
   // Presentations
index 19384c52f96104c10852da7310325b2f32f07fba..57f7e46dff65c9422950f81bc4128247d6ba8e04 100644 (file)
@@ -43,7 +43,6 @@ typedef struct {
   };
   int eventtype;
   XmedDataObject* objectdata;
-  QString objectalias;
 } PresentationEvent;
 
 class MEDModule;
diff --git a/src/MEDCalc/gui/ProcessingController.cxx b/src/MEDCalc/gui/ProcessingController.cxx
new file mode 100644 (file)
index 0000000..e2a2572
--- /dev/null
@@ -0,0 +1,208 @@
+// Copyright (C) 2016  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 "ProcessingController.hxx"
+#include "DatasourceConstants.hxx"
+
+#include "MEDFactoryClient.hxx"
+#include "MEDModule.hxx"
+#include "Basics_Utils.hxx"
+
+#include <SUIT_Desktop.h>
+
+ProcessingController::ProcessingController(MEDModule* salomeModule)
+{
+  STDLOG("Creating a ProcessingController");
+  _salomeModule = salomeModule;
+  _studyEditor = _salomeModule->getStudyEditor();
+
+  _dlgChangeUnderlyingMesh = new DlgChangeUnderlyingMesh(_studyEditor);
+  connect(_dlgChangeUnderlyingMesh,SIGNAL(inputValidated()),
+          this, SLOT(OnChangeUnderlyingMeshInputValidated()));
+
+  _dlgInterpolateField = new DlgInterpolateField(_studyEditor);
+  connect(_dlgInterpolateField,SIGNAL(inputValidated()),
+          this, SLOT(OnInterpolateFieldInputValidated()));
+}
+
+ProcessingController::~ProcessingController()
+{
+  STDLOG("Deleting the ProcessingController");
+}
+
+void
+ProcessingController::createActions()
+{
+  STDLOG("Creating ProcessingController actions");
+
+  int processingToolbarId = _salomeModule->createTool("Processing", "ProcessingToolbar");
+  int processingMenuId = _salomeModule->createMenu(tr("MENU_PROCESSING"), -1, 1);
+
+  // 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.
+  QString label   = tr("LAB_PROCESSING_CHANGE_MESH");
+  QString icon = tr("ICO_PROCESSING_CHANGE_MESH");
+  int actionId;
+  actionId = _salomeModule->createStandardAction(label,this, SLOT(OnChangeUnderlyingMesh()),icon,label);
+  _salomeModule->createTool(actionId, processingToolbarId);
+  _salomeModule->action(actionId)->setIconVisibleInMenu(true);
+  _salomeModule->createMenu(actionId, processingMenuId);
+
+  label   = tr("LAB_PROCESSING_INTERPOLATE_FIELD");
+  icon = tr("ICO_PROCESSING_INTERPOLATE_FIELD");
+  actionId = _salomeModule->createStandardAction(label,this, SLOT(OnInterpolateField()),icon,label);
+  _salomeModule->createTool(actionId, processingToolbarId);
+  _salomeModule->action(actionId)->setIconVisibleInMenu(true);
+  _salomeModule->createMenu(actionId, processingMenuId);
+}
+
+void
+ProcessingController::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
+ProcessingController::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
+  ProcessingEvent* event = new ProcessingEvent();
+  event->eventtype = ProcessingEvent::EVENT_IMPORT_OBJECT;
+  XmedDataObject* dataObject = new XmedDataObject();
+  dataObject->setFieldHandler(*duplicate);
+  event->objectdata = dataObject;
+  emit processingSignal(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
+ProcessingController::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
+ProcessingController::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
+  ProcessingEvent* event = new ProcessingEvent();
+  event->eventtype = ProcessingEvent::EVENT_IMPORT_OBJECT;
+  XmedDataObject* dataObject = new XmedDataObject();
+  dataObject->setFieldHandler(*result);
+  event->objectdata = dataObject;
+  emit processingSignal(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);
+}
diff --git a/src/MEDCalc/gui/ProcessingController.hxx b/src/MEDCalc/gui/ProcessingController.hxx
new file mode 100644 (file)
index 0000000..f3bffe1
--- /dev/null
@@ -0,0 +1,77 @@
+// Copyright (C) 2016  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 PROCESSING_CONTROLLER_HXX
+#define PROCESSING_CONTROLLER_HXX
+
+#include "MEDCALCGUI.hxx"
+
+#include "MEDEventListener_i.hxx"
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(MEDDataManager)
+
+#include <QtGui>
+#include <SalomeApp_Module.h>
+#include <SALOME_AppStudyEditor.hxx>
+
+#include "XmedDataModel.hxx"
+#include "DlgChangeUnderlyingMesh.hxx"
+#include "DlgInterpolateField.hxx"
+
+typedef struct {
+  enum EventType {
+    EVENT_IMPORT_OBJECT,
+    EVENT_PROCESS_INTERPOLATE_FIELD,
+    EVENT_PROCESS_CHANGE_UNDERLYING_MESH
+  };
+  int eventtype;
+  XmedDataObject* objectdata;
+} ProcessingEvent;
+
+class MEDModule;
+
+class MEDCALCGUI_EXPORT ProcessingController : public QObject {
+  Q_OBJECT
+
+public:
+  ProcessingController(MEDModule* salomeModule);
+  ~ProcessingController();
+
+  void createActions();
+
+public slots:
+  // Callback connected to dialog box validation signals
+  void OnChangeUnderlyingMeshInputValidated();
+  void OnInterpolateFieldInputValidated();
+
+protected slots:
+  void OnChangeUnderlyingMesh();
+  void OnInterpolateField();
+
+signals:
+  void processingSignal(const ProcessingEvent*);
+
+private:
+  MEDModule* _salomeModule;
+  SALOME_AppStudyEditor* _studyEditor; // borrowed to MEDModule
+  DlgChangeUnderlyingMesh* _dlgChangeUnderlyingMesh;
+  DlgInterpolateField* _dlgInterpolateField;
+};
+
+#endif /* PROCESSING_CONTROLLER_HXX */
index ec6f3e2b29da43915b5f2a076c54f4460b1d1e51..e98cbe532fb7a56ab2ed3dae3f9063e47abd5d27 100644 (file)
@@ -611,6 +611,35 @@ void WorkspaceController::processPresentationEvent(const PresentationEvent* even
   }
 }
 
+void
+WorkspaceController::processProcessingEvent(const ProcessingEvent* event)
+{
+  XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel();
+  if ( dataModel == NULL ) {
+    STDLOG("No data model associated to this tree view");
+    return;
+  }
+
+  // >>>
+  // __GBO__ To know what to do we should test the type, because the
+  // object could be a mesh, a timeseries or a single field. We test
+  // here the case of a single field. Moreover, there could have
+  // options such that "change the underlying mesh".
+  // <<<
+
+  XmedDataObject* dataObject = event->objectdata;
+
+  if ( event->eventtype == ProcessingEvent::EVENT_IMPORT_OBJECT ) {
+    std::cout << "IMPORT object in workspace: " << dataObject->toString() << std::endl;
+    STDLOG("IMPORT object in workspace:\n"<<dataObject->toString());
+    // _GBO_ QUESTION: tag automatically the object as a peristant object ??
+    // We first add the data object to the internal data model
+    dataModel->addDataObject(dataObject);
+    // Then we request the tree view to consider this new object
+    this->getDataTreeModel()->addData(dataObject);
+  }
+}
+
 void WorkspaceController::OnSaveWorkspace() {
 
   // Dialog to get the filename where the workspace must be saved into
index b53c73db5fe2003deaf70e95f425e807c81b0a02..5c69607673f702dcbb5a80bcbdbf7ddf97c57871 100644 (file)
@@ -27,6 +27,7 @@
 #include "XmedConsoleDriver.hxx"
 #include "DatasourceController.hxx"
 #include "PresentationController.hxx"
+#include "ProcessingController.hxx"
 #include "MEDCALCGUI.hxx"
 
 #include <SALOMEconfig.h>
@@ -60,6 +61,7 @@ public slots:
   void processMedEvent(const MEDCALC::MedEvent* event);
   void processDatasourceEvent(const DatasourceEvent* event);
   void processPresentationEvent(const PresentationEvent* event);
+  void processProcessingEvent(const ProcessingEvent* event);
   void OnSaveWorkspace();
   void OnCleanWorkspace();
 
index 85079c10f8afe9c8a5d7fa89dac7cfac52dc64dd..a32e67b2a7c892f7cfee96071ed4bd849e8b0cf1 100644 (file)
Binary files a/src/MEDCalc/res/MEDCalc.png and b/src/MEDCalc/res/MEDCalc.png differ
index 1c367d6c4a6d1123df5d616589baf8d269a784a3..1d91b3fb80d793d39c2f05431fcdf43098bd3a21 100644 (file)
Binary files a/src/MEDCalc/res/MEDCalc_small.png and b/src/MEDCalc/res/MEDCalc_small.png differ
diff --git a/src/MEDCalc/res/datasource_changeUnderlyingMesh.png b/src/MEDCalc/res/datasource_changeUnderlyingMesh.png
deleted file mode 100644 (file)
index fe6c8b6..0000000
Binary files a/src/MEDCalc/res/datasource_changeUnderlyingMesh.png and /dev/null differ
diff --git a/src/MEDCalc/res/datasource_interpolateField.png b/src/MEDCalc/res/datasource_interpolateField.png
deleted file mode 100644 (file)
index 97b7c97..0000000
Binary files a/src/MEDCalc/res/datasource_interpolateField.png and /dev/null differ
diff --git a/src/MEDCalc/res/processing_changeUnderlyingMesh.png b/src/MEDCalc/res/processing_changeUnderlyingMesh.png
new file mode 100644 (file)
index 0000000..57980db
Binary files /dev/null and b/src/MEDCalc/res/processing_changeUnderlyingMesh.png differ
diff --git a/src/MEDCalc/res/processing_interpolateField.png b/src/MEDCalc/res/processing_interpolateField.png
new file mode 100644 (file)
index 0000000..6275040
Binary files /dev/null and b/src/MEDCalc/res/processing_interpolateField.png differ