diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index d726b519e4..6db35dbec7 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -26,6 +26,7 @@ #include "RimEclipseCellColors.h" #include "RimEclipseView.h" #include "RimGeoMechResultDefinition.h" +#include "RimViewLinker.h" #include "cafCategoryLegend.h" #include "cafCategoryMapper.h" @@ -182,6 +183,18 @@ void RimLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changedField, updateLegend(); + RimView* view = nullptr; + this->firstAncestorOrThisOfType(view); + + if (view) + { + RimViewLinker* viewLinker = view->assosiatedViewLinker(); + if (viewLinker) + { + viewLinker->updateCellResult(); + } + } + if (m_reservoirView) m_reservoirView->updateCurrentTimeStepAndRedraw(); } @@ -758,6 +771,24 @@ cvf::OverlayItem* RimLegendConfig::legend() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimLegendConfig::setUiValuesFromLegendConfig(const RimLegendConfig* otherLegendConfig) +{ + this->m_numLevels = otherLegendConfig->m_numLevels; + this->m_precision = otherLegendConfig->m_precision; + this->m_tickNumberFormat = otherLegendConfig->m_tickNumberFormat; + this->m_rangeMode = otherLegendConfig->m_rangeMode; + this->m_userDefinedMaxValue = otherLegendConfig->m_userDefinedMaxValue; + this->m_userDefinedMinValue = otherLegendConfig->m_userDefinedMinValue; + this->m_colorRangeMode = otherLegendConfig->m_colorRangeMode; + this->m_mappingMode = otherLegendConfig->m_mappingMode; + + this->m_userDefinedMinValue = otherLegendConfig->m_userDefinedMinValue; + this->m_userDefinedMaxValue = otherLegendConfig->m_userDefinedMaxValue; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.h b/ApplicationCode/ProjectDataModel/RimLegendConfig.h index c71276467e..c151dfe2c1 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.h @@ -126,6 +126,8 @@ private: cvf::ref interpolateColorArray(const cvf::Color3ubArray& colorArray, cvf::uint targetColorCount); double roundToNumSignificantDigits(double value, double precision); + friend class RimViewLinker; + void setUiValuesFromLegendConfig(const RimLegendConfig* otherLegendConfig); private: caf::PdmPointer m_reservoirView; diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp index 0c107d4f2c..207163eec3 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp @@ -19,15 +19,17 @@ #include "RimTernaryLegendConfig.h" -#include "cafPdmUiPushButtonEditor.h" -#include "cafPdmUiTextEditor.h" - #include "RiaApplication.h" + #include "RimEclipseView.h" +#include "RimViewLinker.h" #include "RivTernarySaturationOverlayItem.h" #include "RivTernaryScalarMapper.h" +#include "cafPdmUiPushButtonEditor.h" +#include "cafPdmUiTextEditor.h" + #include "cvfqtUtils.h" #include @@ -152,6 +154,18 @@ void RimTernaryLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changed updateLabelText(); updateLegend(); + RimView* view = nullptr; + this->firstAncestorOrThisOfType(view); + + if (view) + { + RimViewLinker* viewLinker = view->assosiatedViewLinker(); + if (viewLinker) + { + viewLinker->updateCellResult(); + } + } + if (m_reservoirView) m_reservoirView->updateCurrentTimeStepAndRedraw(); } @@ -231,6 +245,24 @@ void RimTernaryLegendConfig::recreateLegend() updateLegend(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTernaryLegendConfig::setUiValuesFromLegendConfig(const RimTernaryLegendConfig* otherLegendConfig) +{ + this->precision = otherLegendConfig->precision; + this->rangeMode = otherLegendConfig->rangeMode; + this->userDefinedMaxValueSoil = otherLegendConfig->userDefinedMaxValueSoil; + this->userDefinedMinValueSoil = otherLegendConfig->userDefinedMinValueSoil; + this->userDefinedMaxValueSgas = otherLegendConfig->userDefinedMaxValueSgas; + this->userDefinedMinValueSgas = otherLegendConfig->userDefinedMinValueSgas; + this->userDefinedMaxValueSwat = otherLegendConfig->userDefinedMaxValueSwat; + this->userDefinedMinValueSwat = otherLegendConfig->userDefinedMinValueSwat; + this->applyLocalMinMax = otherLegendConfig->applyLocalMinMax; + this->applyGlobalMinMax = otherLegendConfig->applyGlobalMinMax; + this->applyFullRangeMinMax = otherLegendConfig->applyFullRangeMinMax; +} + //-------------------------------------------------------------------------------------------------- /// Rounding the double value to given number of significant digits //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h index 321629cdec..3a3e5e7163 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h @@ -73,7 +73,7 @@ public: void recreateLegend(); RivTernarySaturationOverlayItem* legend(); - RivTernaryScalarMapper* scalarMapper(); + RivTernaryScalarMapper* scalarMapper(); protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); @@ -84,7 +84,9 @@ private: void updateLegend(); void updateLabelText(); double roundToNumSignificantDigits(double value, double precision); - + + friend class RimViewLinker; + void setUiValuesFromLegendConfig(const RimTernaryLegendConfig* otherLegendConfig); private: caf::PdmField precision; diff --git a/ApplicationCode/ProjectDataModel/RimViewController.cpp b/ApplicationCode/ProjectDataModel/RimViewController.cpp index e016374774..da28fa0a79 100644 --- a/ApplicationCode/ProjectDataModel/RimViewController.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewController.cpp @@ -66,9 +66,10 @@ RimViewController::RimViewController(void) CAF_PDM_InitFieldNoDefault(&m_managedView, "ManagedView", "Linked View", "", "", ""); m_managedView.uiCapability()->setUiTreeChildrenHidden(true); - CAF_PDM_InitField(&m_syncCamera, "SyncCamera", true, "Camera", "", "", ""); - CAF_PDM_InitField(&m_syncTimeStep, "SyncTimeStep", true, "Time Step", "", "", ""); - CAF_PDM_InitField(&m_syncCellResult, "SyncCellResult", false, "Cell Color Result", "", "", ""); + CAF_PDM_InitField(&m_syncCamera, "SyncCamera", true, "Camera", "", "", ""); + CAF_PDM_InitField(&m_syncTimeStep, "SyncTimeStep", true, "Time Step", "", "", ""); + CAF_PDM_InitField(&m_syncCellResult, "SyncCellResult", false, "Cell Result", "", "", ""); + CAF_PDM_InitField(&m_syncLegendDefinitions, "SyncLegendDefinitions", true, " Legend Definition", "", "", ""); CAF_PDM_InitField(&m_syncVisibleCells, "SyncVisibleCells", false, "Visible Cells", "", "", ""); /// We do not support this. Consider to remove sometime @@ -185,6 +186,10 @@ void RimViewController::fieldChangedByUi(const caf::PdmFieldHandle* changedField managedGeoView()->cellResult()->updateIconState(); } } + else if (changedField == &m_syncLegendDefinitions) + { + updateLegendDefinitions(); + } else if (changedField == &m_syncRangeFilters) { if (!m_syncRangeFilters) @@ -365,6 +370,7 @@ void RimViewController::updateOptionSensitivity() { isMasterAndDependentViewDifferentType = true; } + if (geoMasterView && !managedGeoView()) { isMasterAndDependentViewDifferentType = true; @@ -374,10 +380,22 @@ void RimViewController::updateOptionSensitivity() { this->m_syncCellResult.uiCapability()->setUiReadOnly(true); this->m_syncCellResult = false; + + this->m_syncLegendDefinitions.uiCapability()->setUiReadOnly(true); + this->m_syncLegendDefinitions = false; } else { this->m_syncCellResult.uiCapability()->setUiReadOnly(false); + + if (this->m_syncCellResult) + { + this->m_syncLegendDefinitions.uiCapability()->setUiReadOnly(false); + } + else + { + this->m_syncLegendDefinitions.uiCapability()->setUiReadOnly(true); + } } if (isPropertyFilterControlPossible()) @@ -390,7 +408,6 @@ void RimViewController::updateOptionSensitivity() this->m_syncPropertyFilters = false; } - if (isRangeFilterControlPossible()) { this->m_syncRangeFilters.uiCapability()->setUiReadOnly(false); @@ -440,6 +457,7 @@ void RimViewController::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin scriptGroup->add(&m_syncCamera); scriptGroup->add(&m_syncTimeStep); scriptGroup->add(&m_syncCellResult); + scriptGroup->add(&m_syncLegendDefinitions); caf::PdmUiGroup* visibleCells = uiOrdering.addNewGroup("Link Cell Filters"); visibleCells->add(&m_syncVisibleCells); @@ -498,6 +516,17 @@ void RimViewController::updateResultColorsControl() viewLinker->updateCellResult(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimViewController::updateLegendDefinitions() +{ + if (!this->isLegendDefinitionsControlled()) return; + + RimViewLinker* viewLinker = ownerViewLinker(); + viewLinker->updateCellResult(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -714,6 +743,21 @@ bool RimViewController::isResultColorControlled() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimViewController::isLegendDefinitionsControlled() +{ + if (ownerViewLinker()->isActive() && this->m_isActive()) + { + return m_syncLegendDefinitions; + } + else + { + return false; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimViewController.h b/ApplicationCode/ProjectDataModel/RimViewController.h index 1f30e228f0..b3eb903dae 100644 --- a/ApplicationCode/ProjectDataModel/RimViewController.h +++ b/ApplicationCode/ProjectDataModel/RimViewController.h @@ -61,6 +61,7 @@ public: bool isTimeStepLinked(); bool isResultColorControlled(); + bool isLegendDefinitionsControlled(); bool isRangeFiltersControlled(); bool isVisibleCellsOveridden(); @@ -90,6 +91,7 @@ private: void updateCameraLink(); void updateTimeStepLink(); void updateResultColorsControl(); + void updateLegendDefinitions(); bool isMasterAndDepViewDifferentType(); bool isRangeFilterControlPossible(); @@ -111,6 +113,7 @@ private: // Overridden properties caf::PdmField m_syncCellResult; + caf::PdmField m_syncLegendDefinitions; caf::PdmField m_syncRangeFilters; caf::PdmField m_syncVisibleCells; diff --git a/ApplicationCode/ProjectDataModel/RimViewLinker.cpp b/ApplicationCode/ProjectDataModel/RimViewLinker.cpp index 8d1e71c6a8..c6e41d2df4 100644 --- a/ApplicationCode/ProjectDataModel/RimViewLinker.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewLinker.cpp @@ -24,7 +24,6 @@ #include "RigCaseData.h" #include "RimCase.h" - #include "RimEclipseCellColors.h" #include "RimEclipseInputCase.h" #include "RimEclipseResultCase.h" @@ -34,9 +33,11 @@ #include "RimGeoMechCellColors.h" #include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" -#include "RimViewController.h" +#include "RimLegendConfig.h" #include "RimProject.h" +#include "RimTernaryLegendConfig.h" #include "RimView.h" +#include "RimViewController.h" #include "RimViewLinkerCollection.h" #include "RiuViewer.h" @@ -147,6 +148,16 @@ void RimViewLinker::updateCellResult() eclipeView->cellResult()->setPorosityModel(eclipseCellResultDefinition->porosityModel()); eclipeView->cellResult()->setResultType(eclipseCellResultDefinition->resultType()); eclipeView->cellResult()->setResultVariable(eclipseCellResultDefinition->resultVariable()); + + if (viewLink->isLegendDefinitionsControlled()) + { + eclipeView->cellResult()->legendConfig()->setUiValuesFromLegendConfig(masterEclipseView->cellResult()->legendConfig()); + eclipeView->cellResult()->legendConfig()->updateLegend(); + + eclipeView->cellResult()->ternaryLegendConfig()->setUiValuesFromLegendConfig(masterEclipseView->cellResult()->ternaryLegendConfig()); + eclipeView->cellResult()->ternaryLegendConfig()->updateLegend(); + } + eclipeView->scheduleCreateDisplayModelAndRedraw(); } @@ -174,6 +185,13 @@ void RimViewLinker::updateCellResult() if (viewLink->isResultColorControlled()) { geoView->cellResult()->setResultAddress(geoMechResultDefinition->resultAddress()); + + if (viewLink->isLegendDefinitionsControlled()) + { + geoView->cellResult()->legendConfig()->setUiValuesFromLegendConfig(masterGeoView->cellResult()->legendConfig()); + geoView->cellResult()->legendConfig()->updateLegend(); + } + geoView->scheduleCreateDisplayModelAndRedraw(); } diff --git a/ApplicationCode/ProjectDataModel/RimViewLinker.h b/ApplicationCode/ProjectDataModel/RimViewLinker.h index 5ea734651d..b453b2a74d 100644 --- a/ApplicationCode/ProjectDataModel/RimViewLinker.h +++ b/ApplicationCode/ProjectDataModel/RimViewLinker.h @@ -66,6 +66,7 @@ public: void updateScaleZ(RimView* sourceView, double scaleZ); void updateCellResult(); + void updateRangeFilters(RimCellRangeFilter* changedRangeFilter); void applyRangeFilterCollectionByUserChoice();