X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCalc%2Fgui%2FProcessingController.cxx;h=3a55776052e1970676e2b1c9fed743c6e2098072;hb=12e72b16e927a491139cde26adf98395bf222ce1;hp=a554668d76d6d2cd0029eb91ab49ef3028e228fa;hpb=5a68b347e3e1538f91e78144c39efd763c909b3e;p=modules%2Fmed.git diff --git a/src/MEDCalc/gui/ProcessingController.cxx b/src/MEDCalc/gui/ProcessingController.cxx index a554668d7..3a5577605 100644 --- a/src/MEDCalc/gui/ProcessingController.cxx +++ b/src/MEDCalc/gui/ProcessingController.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2016 CEA/DEN, EDF R&D +// Copyright (C) 2016-2021 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 @@ -20,6 +20,11 @@ #include "ProcessingController.hxx" #include +#include +#include +#include CORBA_CLIENT_HEADER(SALOMEDS) +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) + #include "MEDFactoryClient.hxx" #include "MEDModule.hxx" #include "Basics_Utils.hxx" @@ -53,7 +58,7 @@ ProcessingController::createActions() STDLOG("Creating ProcessingController actions"); int processingToolbarId = _salomeModule->createTool("Processing", "ProcessingToolbar"); - int processingMenuId = _salomeModule->createMenu(tr("MENU_PROCESSING"), -1, 1); + int processingMenuId = _salomeModule->createMenu(tr("MENU_PROCESSING"), -1, -1, 12); // Change underlying mesh (note that this action creates a new field in // the workspace that corresponds to a copy of the selected field @@ -68,7 +73,8 @@ ProcessingController::createActions() label = tr("LAB_PROCESSING_INTERPOLATE_FIELD"); icon = tr("ICO_PROCESSING_INTERPOLATE_FIELD"); - actionId = _salomeModule->createStandardAction(label,this, SLOT(OnInterpolateField()),icon,label); + actionId = _salomeModule->createStandardAction(label, this, SLOT(OnInterpolateField()), + icon, label, FIELDSOp::OpProcessingInterpolation); _salomeModule->createTool(actionId, processingToolbarId); _salomeModule->action(actionId)->setIconVisibleInMenu(true); _salomeModule->createMenu(actionId, processingMenuId); @@ -77,17 +83,35 @@ ProcessingController::createActions() 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 + // 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,FIELD_SERIES_ID); - int fieldId = _studyEditor->getParameterInt(soField,FIELD_ID); + SALOMEDS::SObject_var soObj = listOfSObject->at(0); + std::string name(_studyEditor->getName(soObj)); + if (soObj->_is_nil() || name == "MEDCalc") + return; + + int fieldId = _salomeModule->getIntParamFromStudyEditor(soObj, FIELD_ID); + if (fieldId < 0) { // is it a field series? + int fieldSeriesId = _salomeModule->getIntParamFromStudyEditor(soObj, FIELD_SERIES_ID); + // If fieldId and fieldSeriesId equals -1, then it means that it is not a field + // managed by the MED module, and we stop this function process. + if ( fieldSeriesId < 0) + return; + MEDCALC::FieldHandlerList* fieldHandlerList = MEDFactoryClient::getDataManager()->getFieldListInFieldseries(fieldSeriesId); + /* todo: always false! + if (fieldHandlerList->length() < 0) + return; + */ + // For a field series, get the first real field entry: + MEDCALC::FieldHandler fieldHandler = (*fieldHandlerList)[0]; + fieldId = fieldHandler.id; + if (fieldId < 0) + return; + } + // _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 @@ -101,30 +125,16 @@ ProcessingController::OnChangeUnderlyingMesh() void ProcessingController::OnChangeUnderlyingMeshInputValidated() { + STDLOG("Change Underlying Mesh"); 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 + event->eventtype = ProcessingEvent::EVENT_CHANGE_UNDERLYING_MESH; + event->fieldId = fieldId; + event->meshId = meshId; + emit processingSignal(event); // --> WorkspaceController::processProcessingEvent() // Tag the item to prevent double import //_studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true); @@ -133,16 +143,35 @@ ProcessingController::OnChangeUnderlyingMeshInputValidated() 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,FIELD_ID); + SALOMEDS::SObject_var soObj = listOfSObject->at(0); + std::string name(_studyEditor->getName(soObj)); + if (soObj->_is_nil() || name == "MEDCalc") + return; + + int fieldId = _salomeModule->getIntParamFromStudyEditor(soObj, FIELD_ID); + if (fieldId < 0) { // is it a field series? + int fieldSeriesId = _salomeModule->getIntParamFromStudyEditor(soObj, FIELD_SERIES_ID); + // If fieldId and fieldSeriesId equals -1, then it means that it is not a field + // managed by the MED module, and we stop this function process. + if ( fieldSeriesId < 0) + return; + MEDCALC::FieldHandlerList* fieldHandlerList = MEDFactoryClient::getDataManager()->getFieldListInFieldseries(fieldSeriesId); + /* todo: always false! + if (fieldHandlerList->length() < 0) + return; + */ + // For a field series, get the first real field entry: + MEDCALC::FieldHandler fieldHandler = (*fieldHandlerList)[0]; + fieldId = fieldHandler.id; + if (fieldId < 0) + return; + } + // _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 @@ -156,6 +185,7 @@ ProcessingController::OnInterpolateField() void ProcessingController::OnInterpolateFieldInputValidated() { + STDLOG("Interpolate Field"); MEDCALC::InterpolationParameters params; params.precision = _dlgInterpolateField->getPrecision(); STDLOG("precision = " << params.precision); @@ -173,37 +203,13 @@ ProcessingController::OnInterpolateFieldInputValidated() 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 + event->eventtype = ProcessingEvent::EVENT_INTERPOLATE_FIELD; + event->fieldId = fieldId; + event->meshId = meshId; + event->interpParams = params; + emit processingSignal(event); // --> WorkspaceController::processProcessingEvent() // // Tag the item to prevent double import // //_studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true);