From cb21585678f9597abd93b55844723138ba52a645 Mon Sep 17 00:00:00 2001 From: abn Date: Mon, 25 Jul 2016 14:06:26 +0200 Subject: [PATCH] [MEDCalc]: bug fix: field series ID and field ID mix up in presentation. --- src/MEDCalc/MEDCalcConstants.hxx | 2 +- src/MEDCalc/cmp/MED.cxx | 14 ++++++------ src/MEDCalc/gui/DatasourceController.cxx | 4 ++-- src/MEDCalc/gui/PresentationController.cxx | 26 +++++++++++++++++----- 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/MEDCalc/MEDCalcConstants.hxx b/src/MEDCalc/MEDCalcConstants.hxx index e9c72abbf..2023db6d7 100644 --- a/src/MEDCalc/MEDCalcConstants.hxx +++ b/src/MEDCalc/MEDCalcConstants.hxx @@ -22,7 +22,7 @@ #define IS_IN_WORKSPACE "isInWorkspace" #define SOURCE_ID "sourceId" #define MESH_ID "meshId" -//#define FIELD_SERIES_ID "fieldSeriesId" +#define FIELD_SERIES_ID "fieldSeriesId" #define FIELD_ID "fieldId" #define PRESENTATION_ID "presentationId" #define IS_PRESENTATION "isPresentation" diff --git a/src/MEDCalc/cmp/MED.cxx b/src/MEDCalc/cmp/MED.cxx index a780f5ae1..cb92d8e48 100644 --- a/src/MEDCalc/cmp/MED.cxx +++ b/src/MEDCalc/cmp/MED.cxx @@ -136,8 +136,8 @@ MED::addDatasourceToStudy(SALOMEDS::Study_ptr study, soFieldseries->SetAttrString("AttributePixMap", "ICO_DATASOURCE_FIELD"); anAttr = studyBuilder->FindOrCreateAttribute(soFieldseries, "AttributeParameter"); aParam = SALOMEDS::AttributeParameter::_narrow(anAttr); - //aParam->SetInt(FIELD_SERIES_ID, fieldseriesHandler.id); - aParam->SetInt(FIELD_ID, fieldseriesHandler.id); + aParam->SetInt(FIELD_SERIES_ID, fieldseriesHandler.id); + //aParam->SetInt(FIELD_ID, fieldseriesHandler.id); aParam->SetBool(IS_IN_WORKSPACE, false); useCaseBuilder->AppendTo(soFieldseries->GetFather(), soFieldseries); @@ -302,7 +302,7 @@ MED::getObjectInfo(CORBA::Long studyId, const char* entry) //bool isPresentation = false; int sourceId = -1; int meshId = -1; - //int fieldSeriesId = -1; + int fieldSeriesId = -1; int fieldId = -1; int presentationId = -1; if (aSObj->FindAttribute(anAttribute, "AttributeParameter")) { @@ -315,8 +315,8 @@ MED::getObjectInfo(CORBA::Long studyId, const char* entry) sourceId = attrParam->GetInt(SOURCE_ID); if (attrParam->IsSet(MESH_ID, PT_INTEGER)) meshId = attrParam->GetInt(MESH_ID); - //if (attrParam->IsSet(FIELD_SERIES_ID, PT_INTEGER)) - // fieldSeriesId = attrParam->GetInt(FIELD_SERIES_ID); + if (attrParam->IsSet(FIELD_SERIES_ID, PT_INTEGER)) + fieldSeriesId = attrParam->GetInt(FIELD_SERIES_ID); if (attrParam->IsSet(FIELD_ID, PT_INTEGER)) fieldId = attrParam->GetInt(FIELD_ID); if (attrParam->IsSet(PRESENTATION_ID, PT_INTEGER)) @@ -331,8 +331,8 @@ MED::getObjectInfo(CORBA::Long studyId, const char* entry) oss << "Source id: " << sourceId << std::endl; if (meshId > -1) oss << "Mesh id: " << meshId << std::endl; - //if (fieldSeriesId > -1) - // oss << "Field series id: " << fieldSeriesId << std::endl; + if (fieldSeriesId > -1) + oss << "Field series id: " << fieldSeriesId << std::endl; if (fieldId > -1) oss << "Field id: " << fieldId << std::endl; //oss << "Is presentation: " << isPresentation << std::endl; diff --git a/src/MEDCalc/gui/DatasourceController.cxx b/src/MEDCalc/gui/DatasourceController.cxx index c6cfe636e..3cd5c7381 100644 --- a/src/MEDCalc/gui/DatasourceController.cxx +++ b/src/MEDCalc/gui/DatasourceController.cxx @@ -215,8 +215,8 @@ void DatasourceController::OnExpandField() SALOMEDS::SObject_var soFieldseries = listOfSObject->at(i); // First retrieve the fieldseries id associated to this study object - //long fieldseriesId = _studyEditor->getParameterInt(soFieldseries,FIELD_SERIES_ID); - long fieldseriesId = _studyEditor->getParameterInt(soFieldseries,FIELD_ID); + long fieldseriesId = _studyEditor->getParameterInt(soFieldseries,FIELD_SERIES_ID); + //long fieldseriesId = _studyEditor->getParameterInt(soFieldseries,FIELD_ID); STDLOG("Expand the field timeseries "<size(); i++) { SALOMEDS::SObject_var soField = listOfSObject->at(i); - int fieldId = _studyEditor->getParameterInt(soField,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. - if ( fieldId < 0 ) - continue; + int fieldId = -1; + try { + fieldId = _studyEditor->getParameterInt(soField,FIELD_ID); } + catch(...) { } + if (fieldId < 0) // is it a field serie ? + { + int fieldSeriesId = -1; + try { + fieldSeriesId = _studyEditor->getParameterInt(soField,FIELD_SERIES_ID); } + catch(...) { } + // 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) + continue; + MEDCALC::FieldHandlerList* fieldHandlerList = MEDFactoryClient::getDataManager()->getFieldListInFieldseries(fieldSeriesId); + if (fieldHandlerList->length() < 0) + continue; + // For a field series, get the first real field entry: + MEDCALC::FieldHandler fieldHandler = (*fieldHandlerList)[0]; + fieldId = fieldHandler.id; + } MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId); if (! fieldHandler) { -- 2.39.2