-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);
-}
-