From 56dd1b3eb994f9fcd00d06a29569cbf02f5d4a27 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 17 Apr 2018 15:59:50 +0200 Subject: [PATCH] Legends (#2749): Clean up enable/showLegend option * Make public field private ... * Make the option invisible from within the property panel. --- ApplicationCode/ProjectDataModel/RimEclipseView.cpp | 10 +++++----- ApplicationCode/ProjectDataModel/RimGeoMechView.cpp | 4 ++-- ApplicationCode/ProjectDataModel/RimLegendConfig.cpp | 10 ++++++++-- ApplicationCode/ProjectDataModel/RimLegendConfig.h | 4 ++-- .../ProjectDataModel/RimTernaryLegendConfig.cpp | 10 ++++++++-- .../ProjectDataModel/RimTernaryLegendConfig.h | 4 +++- 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 9e5ff47280..b1b0e6b6ad 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -1055,7 +1055,7 @@ void RimEclipseView::updateLegends() updateMinMaxValuesAndAddLegendToView(QString("Fault Results: \n"), this->currentFaultResultColors(), results); } - if (this->cellEdgeResult()->legendConfig()->enableLegend()) + if (this->cellEdgeResult()->legendConfig()->showLegend()) { if (this->cellEdgeResult()->hasResult()) { @@ -1098,7 +1098,7 @@ void RimEclipseView::updateLegends() } RimLegendConfig* stimPlanLegend = fractureColors()->activeLegend(); - if (stimPlanLegend && stimPlanLegend->enableLegend()) + if (stimPlanLegend && stimPlanLegend->showLegend()) { fractureColors()->updateLegendData(); @@ -1108,7 +1108,7 @@ void RimEclipseView::updateLegends() } } - if (m_virtualPerforationResult->isActive() && m_virtualPerforationResult->legendConfig()->enableLegend()) + if (m_virtualPerforationResult->isActive() && m_virtualPerforationResult->legendConfig()->showLegend()) { updateVirtualConnectionLegendRanges(); @@ -1126,7 +1126,7 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, { resultColors->updateLegendData(m_currentTimeStep); - if (resultColors->hasResult() && resultColors->legendConfig()->enableLegend()) + if (resultColors->hasResult() && resultColors->legendConfig()->showLegend()) { m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->legend()); resultColors->legendConfig()->setTitle(legendLabel + resultColors->resultVariableUiShortName()); @@ -1135,7 +1135,7 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, size_t maxTimeStepCount = cellResultsData->maxTimeStepCount(); if (resultColors->isTernarySaturationSelected() && maxTimeStepCount > 1) { - if (resultColors->ternaryLegendConfig->enableLegend() && resultColors->ternaryLegendConfig->legend()) + if (resultColors->ternaryLegendConfig->showLegend() && resultColors->ternaryLegendConfig->legend()) { resultColors->ternaryLegendConfig->setTitle(legendLabel); m_viewer->addColorLegendToBottomLeftCorner(resultColors->ternaryLegendConfig->legend()); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index bfedd4a30d..771207fdc3 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -378,7 +378,7 @@ void RimGeoMechView::updateLegends() this->updateLegendTextAndRanges(cellResult()->legendConfig(), m_currentTimeStep()); - if (cellResult()->hasResult() && cellResult()->legendConfig()->enableLegend()) + if (cellResult()->hasResult() && cellResult()->legendConfig()->showLegend()) { m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend()); } @@ -387,7 +387,7 @@ void RimGeoMechView::updateLegends() if (tensorResults()->vectorColors() == RimTensorResults::RESULT_COLORS && tensorResults()->showTensors()) { - if (tensorResults()->arrowColorLegendConfig()->enableLegend()) + if (tensorResults()->arrowColorLegendConfig()->showLegend()) { m_viewer->addColorLegendToBottomLeftCorner(m_tensorResults->arrowColorLegendConfig->legend()); } diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 3aa7ebf901..d3693906c3 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -123,7 +123,8 @@ RimLegendConfig::RimLegendConfig() m_isAllTimeStepsRangeDisabled(false) { CAF_PDM_InitObject("Legend Definition", ":/Legend.png", "", ""); - CAF_PDM_InitField(&enableLegend, "EnableLegend", true, "Enable Legend", "", "", ""); + CAF_PDM_InitField(&m_showLegend, "ShowLegend", true, "Show Legend", "", "", ""); + m_showLegend.uiCapability()->setUiHidden(true); CAF_PDM_InitField(&m_numLevels, "NumberOfLevels", 8, "Number of Levels", "", "A hint on how many tick marks you whish.",""); CAF_PDM_InitField(&m_precision, "Precision", 4, "Significant Digits", "", "The number of significant digits displayed in the legend numbers",""); CAF_PDM_InitField(&m_tickNumberFormat, "TickNumberFormat", caf::AppEnum(FIXED), "Number format", "", "",""); @@ -442,7 +443,7 @@ void RimLegendConfig::initAfterRead() caf::PdmFieldHandle* RimLegendConfig::objectToggleField() { - return &enableLegend; + return &m_showLegend; } //-------------------------------------------------------------------------------------------------- @@ -669,6 +670,11 @@ caf::TitledOverlayFrame* RimLegendConfig::legend() } } +bool RimLegendConfig::showLegend() const +{ + return m_showLegend; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.h b/ApplicationCode/ProjectDataModel/RimLegendConfig.h index 2b9471e07e..5ae482d36d 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.h @@ -121,8 +121,7 @@ public: cvf::ScalarMapper* scalarMapper() { return m_currentScalarMapper.p(); } caf::TitledOverlayFrame* legend(); - - caf::PdmField enableLegend; + bool showLegend() const; protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); @@ -172,6 +171,7 @@ private: cvf::Color3ubArray m_categoryColors; // Fields + caf::PdmField m_showLegend; caf::PdmField m_numLevels; caf::PdmField m_precision; caf::PdmField > m_tickNumberFormat; diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp index b6311b960a..e9f71cdd87 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp @@ -57,7 +57,8 @@ namespace caf { RimTernaryLegendConfig::RimTernaryLegendConfig() { CAF_PDM_InitObject("Ternary Legend Definition", ":/Legend.png", "", ""); - CAF_PDM_InitField(&enableLegend, "EnableTernaryLegend", true, "Enable Ternary Legend", "", "", ""); + CAF_PDM_InitField(&m_showLegend, "ShowTernaryLegend", true, "Show Ternary Legend", "", "", ""); + m_showLegend.uiCapability()->setUiHidden(true); CAF_PDM_InitField(&precision, "Precision", 2, "Significant digits", "", "The number of significant digits displayed in the legend numbers",""); CAF_PDM_InitField(&rangeMode, "RangeType", RangeModeEnum(USER_DEFINED), "Range type", "", "Switches between automatic and user defined range on the legend", ""); @@ -340,6 +341,11 @@ RivTernarySaturationOverlayItem* RimTernaryLegendConfig::legend() return m_legend.p(); } +bool RimTernaryLegendConfig::showLegend() const +{ + return m_showLegend; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -493,5 +499,5 @@ const RivTernaryScalarMapper* RimTernaryLegendConfig::scalarMapper() const caf::PdmFieldHandle* RimTernaryLegendConfig::objectToggleField() { - return &enableLegend; + return &m_showLegend; } diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h index 804c61328e..7993753666 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h @@ -74,7 +74,7 @@ public: const RivTernarySaturationOverlayItem* legend() const; RivTernarySaturationOverlayItem* legend(); - caf::PdmField enableLegend; + bool showLegend() const; void setTitle(const QString& title); @@ -107,6 +107,8 @@ private: caf::PdmField applyFullRangeMinMax; caf::PdmField ternaryRangeSummary; + caf::PdmField m_showLegend; + std::vector m_globalAutoMax; std::vector m_globalAutoMin; std::vector m_localAutoMax;