From 7c69ae434e6003ea06628ecd201ece6d398f0004 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 21 Oct 2016 13:57:15 +0200 Subject: [PATCH] #760 Input Property rename does not update dependent fields --- .../RimEclipseInputProperty.cpp | 59 +++++++ .../RimEclipseInputProperty.h | 4 +- .../RimEclipseResultDefinition.cpp | 151 +++++++++++------- .../RimEclipseResultDefinition.h | 6 + .../RigCaseCellResultsData.cpp | 19 +++ .../RigCaseCellResultsData.h | 2 + 6 files changed, 178 insertions(+), 63 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseInputProperty.cpp b/ApplicationCode/ProjectDataModel/RimEclipseInputProperty.cpp index 14c0c07807..d10b4c95d5 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseInputProperty.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseInputProperty.cpp @@ -20,6 +20,11 @@ #include "RimEclipseInputProperty.h" +#include "RigCaseCellResultsData.h" +#include "RigCaseData.h" +#include "RimEclipseInputCase.h" +#include "RimEclipseResultDefinition.h" + #include "cafPdmUiLineEditor.h" #include "cvfAssert.h" @@ -69,3 +74,57 @@ RimEclipseInputProperty::~RimEclipseInputProperty() } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseInputProperty::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if (changedField == &resultName) + { + RimEclipseInputCase* rimCase = nullptr; + this->firstAncestorOrThisOfType(rimCase); + if (rimCase) + { + bool anyNameUpdated = false; + + QString oldName = oldValue.toString(); + QString newName = newValue.toString(); + + RigCaseCellResultsData* matrixResults = rimCase->reservoirData()->results(RifReaderInterface::MATRIX_RESULTS); + if (matrixResults) + { + if (matrixResults->updateResultName(RimDefines::INPUT_PROPERTY, oldName, newName)) + { + anyNameUpdated = true; + } + } + + RigCaseCellResultsData* fracResults = rimCase->reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS); + if (fracResults) + { + if (fracResults->updateResultName(RimDefines::INPUT_PROPERTY, oldName, newName)) + { + anyNameUpdated = true; + } + } + + if (anyNameUpdated) + { + std::vector resDefs; + rimCase->descendantsIncludingThisOfType(resDefs); + + for (auto it : resDefs) + { + if (it->resultVariable() == oldName) + { + it->setResultVariable(newName); + } + + it->updateResultNameHasChanged(); + it->updateAnyFieldHasChanged(); + } + } + } + } +} + diff --git a/ApplicationCode/ProjectDataModel/RimEclipseInputProperty.h b/ApplicationCode/ProjectDataModel/RimEclipseInputProperty.h index 4a21500647..d0016bf92e 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseInputProperty.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseInputProperty.h @@ -57,8 +57,6 @@ public: // PdmObject Overrides virtual caf::PdmFieldHandle* userDescriptionField() { return &resultName;} - -private: - // Possibly the resultIndex, but it should be superfluous + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; }; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp index 1d5116e131..91082aa2f4 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -102,7 +102,7 @@ QStringList RimEclipseResultDefinition::getResultVariableListForCurrentUIFieldSe //-------------------------------------------------------------------------------------------------- RimReservoirCellResultsStorage* RimEclipseResultDefinition::currentGridCellResults() const { - if (!m_eclipseCase ) return NULL; + if (!m_eclipseCase ) return nullptr; RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(m_porosityModel()); @@ -133,87 +133,118 @@ void RimEclipseResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha } - RimEclipsePropertyFilter* propFilter = dynamic_cast(this->parentField()->ownerObject()); - RimView* view = NULL; - this->firstAncestorOrThisOfType(view); - RimWellLogCurve* curve = NULL; - this->firstAncestorOrThisOfType(curve); - - RimCellEdgeColors* cellEdgeColors = NULL; - this->firstAncestorOrThisOfType(cellEdgeColors); - if (&m_resultVariableUiField == changedField) { m_porosityModel = m_porosityModelUiField; m_resultType = m_resultTypeUiField; m_resultVariable = m_resultVariableUiField; - loadResult(); - - if (propFilter) - { - propFilter->setToDefaultValues(); - propFilter->updateFilterName(); - - if (view) - { - view->scheduleGeometryRegen(PROPERTY_FILTERED); - view->scheduleCreateDisplayModelAndRedraw(); - } - } - - if (dynamic_cast(this)) - { - this->updateLegendCategorySettings(); - - if (view) - { - RimViewLinker* viewLinker = view->assosiatedViewLinker(); - if (viewLinker) - { - viewLinker->updateCellResult(); - } - } - } - - if (cellEdgeColors) - { - cellEdgeColors->singleVarEdgeResultColors()->updateLegendCategorySettings(); - cellEdgeColors->loadResult(); - - if (view) - { - view->scheduleCreateDisplayModelAndRedraw(); - } - } - - if (curve) - { - curve->loadDataAndUpdate(); - } + updateResultNameHasChanged(); } + updateAnyFieldHasChanged(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseResultDefinition::updateAnyFieldHasChanged() +{ + RimEclipsePropertyFilter* propFilter = nullptr; + this->firstAncestorOrThisOfType(propFilter); if (propFilter) { propFilter->updateConnectedEditors(); } - - RimEclipseFaultColors* faultColors = dynamic_cast(this->parentField()->ownerObject()); + + RimEclipseFaultColors* faultColors = nullptr; + this->firstAncestorOrThisOfType(faultColors); if (faultColors) { faultColors->updateConnectedEditors(); } + RimCellEdgeColors* cellEdgeColors = nullptr; + this->firstAncestorOrThisOfType(cellEdgeColors); if (cellEdgeColors) { cellEdgeColors->updateConnectedEditors(); } + RimEclipseCellColors* cellColors = nullptr; + this->firstAncestorOrThisOfType(cellColors); + if (cellColors) + { + cellColors->updateConnectedEditors(); + } + + RimWellLogCurve* curve = nullptr; + this->firstAncestorOrThisOfType(curve); if (curve) { curve->updateConnectedEditors(); } - +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseResultDefinition::updateResultNameHasChanged() +{ + RimView* view = nullptr; + this->firstAncestorOrThisOfType(view); + + loadResult(); + + RimEclipsePropertyFilter* propFilter = nullptr; + this->firstAncestorOrThisOfType(propFilter); + if (propFilter) + { + propFilter->setToDefaultValues(); + propFilter->updateFilterName(); + + if (view) + { + view->scheduleGeometryRegen(PROPERTY_FILTERED); + view->scheduleCreateDisplayModelAndRedraw(); + } + } + + RimEclipseCellColors* cellColors = nullptr; + this->firstAncestorOrThisOfType(cellColors); + if (cellColors) + { + this->updateLegendCategorySettings(); + + if (view) + { + RimViewLinker* viewLinker = view->assosiatedViewLinker(); + if (viewLinker) + { + viewLinker->updateCellResult(); + } + } + } + + RimCellEdgeColors* cellEdgeColors = nullptr; + this->firstAncestorOrThisOfType(cellEdgeColors); + if (cellEdgeColors) + { + cellEdgeColors->singleVarEdgeResultColors()->updateLegendCategorySettings(); + cellEdgeColors->loadResult(); + + if (view) + { + view->scheduleCreateDisplayModelAndRedraw(); + } + } + + RimWellLogCurve* curve = nullptr; + this->firstAncestorOrThisOfType(curve); + if (curve) + { + curve->loadDataAndUpdate(); + } } //-------------------------------------------------------------------------------------------------- @@ -223,19 +254,19 @@ QList RimEclipseResultDefinition::calculateValueOptions( { bool showPerFaceResultsFirst = false; - RimEclipseFaultColors* rimEclipseFaultColors = NULL; + RimEclipseFaultColors* rimEclipseFaultColors = nullptr; this->firstAncestorOrThisOfType(rimEclipseFaultColors); if (rimEclipseFaultColors) showPerFaceResultsFirst = true; QList optionItems = calculateValueOptionsForSpecifiedDerivedListPosition(showPerFaceResultsFirst, fieldNeedingOptions, useOptionsOnly); - RimWellLogCurve* curve = NULL; + RimWellLogCurve* curve = nullptr; this->firstAncestorOrThisOfType(curve); - RimEclipsePropertyFilter* propFilter = NULL; + RimEclipsePropertyFilter* propFilter = nullptr; this->firstAncestorOrThisOfType(propFilter); - RimCellEdgeColors* cellEdge = NULL; + RimCellEdgeColors* cellEdge = nullptr; this->firstAncestorOrThisOfType(cellEdge); if (propFilter || curve || cellEdge) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h index 94f083e34d..bb1f2caf29 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h @@ -64,10 +64,16 @@ public: virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly); virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); + + + virtual void initAfterRead(); virtual void updateLegendCategorySettings() {}; + void updateResultNameHasChanged(); + void updateAnyFieldHasChanged(); + protected: void updateFieldVisibility(); diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index e3555362ae..b2ef4e3cec 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -519,6 +519,25 @@ RifReaderInterface::PorosityModelResultType RigCaseCellResultsData::convertFromP return RifReaderInterface::FRACTURE_RESULTS; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigCaseCellResultsData::updateResultName(RimDefines::ResultCatType resultType, QString& oldName, const QString& newName) +{ + bool anyNameUpdated = false; + + for (auto& it : m_resultInfos) + { + if (it.m_resultType == resultType && it.m_resultName == oldName) + { + anyNameUpdated = true; + it.m_resultName = newName; + } + } + + return anyNameUpdated; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h index 3d421c59b3..73038a9089 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h @@ -96,6 +96,8 @@ public: static RifReaderInterface::PorosityModelResultType convertFromProjectModelPorosityModel(RimDefines::PorosityModelType porosityModel); + bool updateResultName(RimDefines::ResultCatType resultType, QString& oldName, const QString& newName); + public: class ResultInfo {