From: Cédric Aguerre Date: Wed, 2 Mar 2016 15:16:38 +0000 (+0100) Subject: [MEDCalc] Introduce ProcessingController X-Git-Tag: V8_1_0a1~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cbed3da64522b5be004aee4e771ca1f75d4af172;hp=6149e4228ca17b6cf365076867a332b933d39a25;p=modules%2Fmed.git [MEDCalc] Introduce ProcessingController --- diff --git a/src/MEDCalc/gui/CMakeLists.txt b/src/MEDCalc/gui/CMakeLists.txt index 62cb36a16..125b60995 100644 --- a/src/MEDCalc/gui/CMakeLists.txt +++ b/src/MEDCalc/gui/CMakeLists.txt @@ -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}) diff --git a/src/MEDCalc/gui/DatasourceController.cxx b/src/MEDCalc/gui/DatasourceController.cxx index 5a1444719..bd9395524 100644 --- a/src/MEDCalc/gui/DatasourceController.cxx +++ b/src/MEDCalc/gui/DatasourceController.cxx @@ -53,20 +53,11 @@ // 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 -//#include 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) { diff --git a/src/MEDCalc/gui/DatasourceController.hxx b/src/MEDCalc/gui/DatasourceController.hxx index b2097e38c..7d9e5bef2 100644 --- a/src/MEDCalc/gui/DatasourceController.hxx +++ b/src/MEDCalc/gui/DatasourceController.hxx @@ -31,8 +31,6 @@ #include #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 diff --git a/src/MEDCalc/gui/MEDModule.cxx b/src/MEDCalc/gui/MEDModule.cxx index f5f091420..d5835444a 100644 --- a/src/MEDCalc/gui/MEDModule.cxx +++ b/src/MEDCalc/gui/MEDModule.cxx @@ -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 diff --git a/src/MEDCalc/gui/MEDModule.hxx b/src/MEDCalc/gui/MEDModule.hxx index 97cf19888..cec0dbf4a 100644 --- a/src/MEDCalc/gui/MEDModule.hxx +++ b/src/MEDCalc/gui/MEDModule.hxx @@ -31,6 +31,7 @@ #include "XmedDataModel.hxx" #include "DatasourceController.hxx" #include "PresentationController.hxx" +#include "ProcessingController.hxx" #include #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; }; diff --git a/src/MEDCalc/gui/MED_images.ts b/src/MEDCalc/gui/MED_images.ts index bcc3b14e5..7484fc4c1 100644 --- a/src/MEDCalc/gui/MED_images.ts +++ b/src/MEDCalc/gui/MED_images.ts @@ -16,12 +16,12 @@ datasource_add.png - ICO_DATASOURCE_CHANGE_MESH - datasource_changeUnderlyingMesh.png + ICO_PROCESSING_CHANGE_MESH + processing_changeUnderlyingMesh.png - ICO_DATASOURCE_INTERPOLATE_FIELD - datasource_interpolateField.png + ICO_PROCESSING_INTERPOLATE_FIELD + processing_interpolateField.png ICO_DATASOURCE_EXPAND_FIELD diff --git a/src/MEDCalc/gui/MED_msg_en.ts b/src/MEDCalc/gui/MED_msg_en.ts index ba14c9e84..8754beb6b 100644 --- a/src/MEDCalc/gui/MED_msg_en.ts +++ b/src/MEDCalc/gui/MED_msg_en.ts @@ -84,6 +84,21 @@ Point sprite + + ProcessingController + + MENU_PROCESSING + Processing + + + LAB_PROCESSING_CHANGE_MESH + Change underlying mesh + + + LAB_PROCESSING_INTERPOLATE_FIELD + Interpolate field + + DatasourceController @@ -116,16 +131,6 @@ LAB_USE_IN_WORKSPACE Use in workspace - - - LAB_CHANGE_MESH - Change underlying mesh - - - - LAB_INTERPOLATE_FIELD - Interpolate field - IMPORT_MED_FIELDS diff --git a/src/MEDCalc/gui/MED_msg_fr.ts b/src/MEDCalc/gui/MED_msg_fr.ts index d339c08b9..f09dc6717 100644 --- a/src/MEDCalc/gui/MED_msg_fr.ts +++ b/src/MEDCalc/gui/MED_msg_fr.ts @@ -84,6 +84,21 @@ Point sprite + + ProcessingController + + MENU_PROCESSING + Traitement + + + LAB_PROCESSING_CHANGE_MESH + Changer le maillage sous-jacent + + + LAB_PROCESSING_INTERPOLATE_FIELD + Interpoler le champ + + DatasourceController @@ -116,16 +131,6 @@ LAB_USE_IN_WORKSPACE Utiliser dans l'espace de travail - - - LAB_CHANGE_MESH - Changer le maillage sous-jacent - - - - LAB_INTERPOLATE_FIELD - Interpoler le champ - IMPORT_MED_FIELDS diff --git a/src/MEDCalc/gui/PresentationController.cxx b/src/MEDCalc/gui/PresentationController.cxx index b6cbe19c1..c53281a49 100644 --- a/src/MEDCalc/gui/PresentationController.cxx +++ b/src/MEDCalc/gui/PresentationController.cxx @@ -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 diff --git a/src/MEDCalc/gui/PresentationController.hxx b/src/MEDCalc/gui/PresentationController.hxx index 19384c52f..57f7e46df 100644 --- a/src/MEDCalc/gui/PresentationController.hxx +++ b/src/MEDCalc/gui/PresentationController.hxx @@ -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 index 000000000..e2a257224 --- /dev/null +++ b/src/MEDCalc/gui/ProcessingController.cxx @@ -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 + +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 index 000000000..f3bffe195 --- /dev/null +++ b/src/MEDCalc/gui/ProcessingController.hxx @@ -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 +#include CORBA_CLIENT_HEADER(MEDDataManager) + +#include +#include +#include + +#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 */ diff --git a/src/MEDCalc/gui/WorkspaceController.cxx b/src/MEDCalc/gui/WorkspaceController.cxx index ec6f3e2b2..e98cbe532 100644 --- a/src/MEDCalc/gui/WorkspaceController.cxx +++ b/src/MEDCalc/gui/WorkspaceController.cxx @@ -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"<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 diff --git a/src/MEDCalc/gui/WorkspaceController.hxx b/src/MEDCalc/gui/WorkspaceController.hxx index b53c73db5..5c6960767 100644 --- a/src/MEDCalc/gui/WorkspaceController.hxx +++ b/src/MEDCalc/gui/WorkspaceController.hxx @@ -27,6 +27,7 @@ #include "XmedConsoleDriver.hxx" #include "DatasourceController.hxx" #include "PresentationController.hxx" +#include "ProcessingController.hxx" #include "MEDCALCGUI.hxx" #include @@ -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(); diff --git a/src/MEDCalc/res/MEDCalc.png b/src/MEDCalc/res/MEDCalc.png index 85079c10f..a32e67b2a 100644 Binary files a/src/MEDCalc/res/MEDCalc.png and b/src/MEDCalc/res/MEDCalc.png differ diff --git a/src/MEDCalc/res/MEDCalc_small.png b/src/MEDCalc/res/MEDCalc_small.png index 1c367d6c4..1d91b3fb8 100644 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 index fe6c8b6d3..000000000 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 index 97b7c97d3..000000000 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 index 000000000..57980dbf1 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 index 000000000..62750404f Binary files /dev/null and b/src/MEDCalc/res/processing_interpolateField.png differ