From 4d7f753d3c178c78d4b065dc144230dcfd520291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 8 Mar 2018 16:15:45 +0100 Subject: [PATCH] #51 Add preference option to control legend background --- ApplicationCode/Application/RiaPreferences.cpp | 3 +++ ApplicationCode/Application/RiaPreferences.h | 1 + ApplicationCode/ProjectDataModel/RimLegendConfig.cpp | 5 +++++ ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp | 5 +++++ 4 files changed, 14 insertions(+) diff --git a/ApplicationCode/Application/RiaPreferences.cpp b/ApplicationCode/Application/RiaPreferences.cpp index b7ed3af14c..623ef531b3 100644 --- a/ApplicationCode/Application/RiaPreferences.cpp +++ b/ApplicationCode/Application/RiaPreferences.cpp @@ -77,6 +77,8 @@ RiaPreferences::RiaPreferences(void) CAF_PDM_InitField(&includeFractureDebugInfoFile, "includeFractureDebugInfoFile", false, "Include Fracture Debug Info for Completion Export", "", "", ""); includeFractureDebugInfoFile.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + CAF_PDM_InitField(&showLegendBackground, "showLegendBackground", true, "Enable Legend Background", "", "", ""); + CAF_PDM_InitFieldNoDefault(&lastUsedProjectFileName,"lastUsedProjectFileName", "Last Used Project File", "", "", ""); lastUsedProjectFileName.uiCapability()->setUiHidden(true); @@ -153,6 +155,7 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& defaultSettingsGroup->add(&defaultWellLabelColor); defaultSettingsGroup->add(&fontSizeInScene); defaultSettingsGroup->add(&defaultScaleFactorZ); + defaultSettingsGroup->add(&showLegendBackground); caf::PdmUiGroup* viewsGroup = uiOrdering.addNewGroup("3D Views"); viewsGroup->add(&navigationPolicy); diff --git a/ApplicationCode/Application/RiaPreferences.h b/ApplicationCode/Application/RiaPreferences.h index 3fcd582ec6..dbc02b5953 100644 --- a/ApplicationCode/Application/RiaPreferences.h +++ b/ApplicationCode/Application/RiaPreferences.h @@ -63,6 +63,7 @@ public: // Pdm Fields caf::PdmField defaultWellLabelColor; caf::PdmField showLasCurveWithoutTvdWarning; caf::PdmField fontSizeInScene; + caf::PdmField showLegendBackground; caf::PdmField useShaders; caf::PdmField showHud; diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 971d48e037..fdd5364cb8 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -48,6 +48,7 @@ #include #include "RimIntersectionCollection.h" +#include "RiaPreferences.h" CAF_PDM_SOURCE_INIT(RimLegendConfig, "Legend"); @@ -369,6 +370,10 @@ void RimLegendConfig::updateLegend() } m_scalarMapperLegend->setTickPrecision(cvf::Math::clamp(numDecimalDigits, 0, 20)); + RiaApplication* app = RiaApplication::instance(); + RiaPreferences* preferences = app->preferences(); + m_scalarMapperLegend->enableBackground(preferences->showLegendBackground()); + m_categoryLegend->enableBackground(preferences->showLegendBackground()); if (m_globalAutoMax != cvf::UNDEFINED_DOUBLE ) { diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp index b507afc267..f79dab9d00 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp @@ -35,6 +35,7 @@ #include "cvfqtUtils.h" #include +#include "RiaPreferences.h" CAF_PDM_SOURCE_INIT(RimTernaryLegendConfig, "RimTernaryLegendConfig"); @@ -201,6 +202,10 @@ void RimTernaryLegendConfig::updateLegend() if (!m_legend.isNull()) { m_legend->setRangeText(soilRange, sgasRange, swatRange); + + RiaApplication* app = RiaApplication::instance(); + RiaPreferences* preferences = app->preferences(); + m_legend->enableBackground(preferences->showLegendBackground()); } }