#559 : Linked Views: Linking legend definitions

This commit is contained in:
Magne Sjaastad 2016-12-09 20:36:31 +01:00
parent 2692abe7fe
commit 3fabe5f8b5
8 changed files with 144 additions and 11 deletions

View File

@ -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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -126,6 +126,8 @@ private:
cvf::ref<cvf::Color3ubArray> 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<RimView> m_reservoirView;

View File

@ -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 <cmath>
@ -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
//--------------------------------------------------------------------------------------------------

View File

@ -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<int> precision;

View File

@ -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;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -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<bool> m_syncCellResult;
caf::PdmField<bool> m_syncLegendDefinitions;
caf::PdmField<bool> m_syncRangeFilters;
caf::PdmField<bool> m_syncVisibleCells;

View File

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

View File

@ -66,6 +66,7 @@ public:
void updateScaleZ(RimView* sourceView, double scaleZ);
void updateCellResult();
void updateRangeFilters(RimCellRangeFilter* changedRangeFilter);
void applyRangeFilterCollectionByUserChoice();