From 5aed8ea939201df01b3ad86e1517b5ea7b81a4ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 3 Jan 2017 14:58:34 +0100 Subject: [PATCH] #1053 Disabled the All Timesteps option in Legend range selection --- .../ProjectDataModel/RimEclipseView.cpp | 5 ++-- .../ProjectDataModel/RimLegendConfig.cpp | 26 ++++++++++++++++++- .../ProjectDataModel/RimLegendConfig.h | 3 +++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index bf4b6125bf..71e01a8b9e 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -1024,6 +1024,7 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, R CVF_ASSERT(resultColors->legendConfig()); + resultColors->legendConfig()->disableAllTimeStepsRange(true); resultColors->legendConfig()->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); resultColors->legendConfig()->setAutomaticRanges(globalMin, globalMax, localMin, localMax); @@ -1033,8 +1034,7 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, R } m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->legend()); - resultColors->legendConfig()->setTitle(cvfqt::Utils::toString(legendLabel + resultColors->resultVariable())); - + resultColors->legendConfig()->setTitle(cvfqt::Utils::toString(legendLabel + QString::fromStdString( resultColors->flowDiagResAddress().uiText()))); } else { @@ -1061,6 +1061,7 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, R CVF_ASSERT(resultColors->legendConfig()); + resultColors->legendConfig()->disableAllTimeStepsRange(false); resultColors->legendConfig()->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); resultColors->legendConfig()->setAutomaticRanges(globalMin, globalMax, localMin, localMax); diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 36dfc9e653..15649e4d53 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -113,7 +113,8 @@ RimLegendConfig::RimLegendConfig() m_globalAutoPosClosestToZero(0), m_globalAutoNegClosestToZero(0), m_localAutoPosClosestToZero(0), - m_localAutoNegClosestToZero(0) + m_localAutoNegClosestToZero(0), + m_isAllTimeStepsRangeDisabled(false) { CAF_PDM_InitObject("Legend Definition", ":/Legend.png", "", ""); CAF_PDM_InitField(&m_numLevels, "NumberOfLevels", 8, "Number of levels", "", "A hint on how many tick marks you whish.",""); @@ -488,6 +489,21 @@ void RimLegendConfig::updateLegend() } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimLegendConfig::disableAllTimeStepsRange(bool doDisable) +{ + // If we enable AllTimesteps, and we have used current timestep, then "restore" the default + if (m_isAllTimeStepsRangeDisabled && !doDisable && m_rangeMode == AUTOMATIC_CURRENT_TIMESTEP) m_rangeMode = AUTOMATIC_ALLTIMESTEPS; + + m_isAllTimeStepsRangeDisabled = doDisable; + + if (doDisable && m_rangeMode == AUTOMATIC_ALLTIMESTEPS) m_rangeMode = AUTOMATIC_CURRENT_TIMESTEP; + +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -890,6 +906,14 @@ QList RimLegendConfig::calculateValueOptions(const caf:: optionList.push_back(caf::PdmOptionItemInfo(ColorRangeEnum::uiText(colType), colType)); } } + else if (fieldNeedingOptions == &m_rangeMode) + { + if (!m_isAllTimeStepsRangeDisabled) { + optionList.push_back(caf::PdmOptionItemInfo(RangeModeEnum::uiText(RimLegendConfig::AUTOMATIC_ALLTIMESTEPS), RimLegendConfig::AUTOMATIC_ALLTIMESTEPS)); + } + optionList.push_back(caf::PdmOptionItemInfo(RangeModeEnum::uiText(RimLegendConfig::AUTOMATIC_CURRENT_TIMESTEP), RimLegendConfig::AUTOMATIC_CURRENT_TIMESTEP)); + optionList.push_back(caf::PdmOptionItemInfo(RangeModeEnum::uiText(RimLegendConfig::USER_DEFINED), RimLegendConfig::USER_DEFINED)); + } return optionList; } diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.h b/ApplicationCode/ProjectDataModel/RimLegendConfig.h index f679074eb8..de64b7e9a9 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.h @@ -101,6 +101,7 @@ public: ColorRangesType colorRangeMode() { return m_colorRangeMode();} void setMappingMode(MappingType mappingType); MappingType mappingMode() { return m_mappingMode();} + void disableAllTimeStepsRange(bool doDisable); void setAutomaticRanges(double globalMin, double globalMax, double localMin, double localMax); void setClosestToZeroValues(double globalPosClosestToZero, double globalNegClosestToZero, double localPosClosestToZero, double localNegClosestToZero); @@ -150,6 +151,8 @@ private: double m_localAutoPosClosestToZero; double m_localAutoNegClosestToZero; + bool m_isAllTimeStepsRangeDisabled; + std::vector m_categories; std::vector m_categoryNames;