From b181d59ba957e73cb93220334f889f9b22de51db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 11 Dec 2017 13:09:51 +0100 Subject: [PATCH] 1034 Summary plot legend. Support for setting legend font size --- .../Summary/RimSummaryAxisProperties.cpp | 4 ++ .../Summary/RimSummaryPlot.cpp | 44 +++++++++++++++++++ .../ProjectDataModel/Summary/RimSummaryPlot.h | 2 + 3 files changed, 50 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp index 89a18b3329..18d76e77af 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp @@ -107,9 +107,13 @@ QList RimSummaryAxisProperties::calculateValueOptions(co { std::vector fontSizes; fontSizes.push_back(8); + fontSizes.push_back(9); fontSizes.push_back(10); + fontSizes.push_back(11); fontSizes.push_back(12); + fontSizes.push_back(14); fontSizes.push_back(16); + fontSizes.push_back(18); fontSizes.push_back(24); for (int value : fontSizes) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index cf184ebe1a..3f0235ef79 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -68,6 +68,9 @@ RimSummaryPlot::RimSummaryPlot() CAF_PDM_InitField(&m_showLegend, "ShowLegend", true, "Legend", "", "", ""); m_showLegend.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + CAF_PDM_InitField(&m_legendFontSize, "LegendFontSize", 11, "Legend Font Size", "", "", ""); + m_showLegend.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + CAF_PDM_InitField(&m_isUsingAutoName, "IsUsingAutoName", false, "Auto Name", "", "", ""); m_isUsingAutoName.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); @@ -967,6 +970,35 @@ caf::PdmFieldHandle* RimSummaryPlot::userDescriptionField() return &m_userDefinedPlotTitle; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimSummaryPlot::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) +{ + QList options; + + if (fieldNeedingOptions == &m_legendFontSize) + { + std::vector fontSizes; + fontSizes.push_back(8); + fontSizes.push_back(9); + fontSizes.push_back(10); + fontSizes.push_back(11); + fontSizes.push_back(12); + fontSizes.push_back(14); + fontSizes.push_back(16); + fontSizes.push_back(18); + fontSizes.push_back(24); + + for (int value : fontSizes) + { + QString text = QString("%1").arg(value); + options.push_back(caf::PdmOptionItemInfo(text, value)); + } + } + return options; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -977,6 +1009,7 @@ void RimSummaryPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c if (changedField == &m_userDefinedPlotTitle || changedField == &m_showPlotTitle || changedField == &m_showLegend || + changedField == &m_legendFontSize || changedField == &m_isUsingAutoName) { updatePlotTitle(); @@ -1177,12 +1210,19 @@ void RimSummaryPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering.add(&m_showPlotTitle); uiOrdering.add(&m_showLegend); + if (m_showLegend()) + { + uiOrdering.add(&m_legendFontSize); + } + m_userDefinedPlotTitle.uiCapability()->setUiReadOnly(m_isUsingAutoName); if (m_isUsingAutoName) { m_userDefinedPlotTitle = m_summaryCurveCollection->compileAutoPlotTitle(); } + + uiOrdering.skipRemainingFields(true); } //-------------------------------------------------------------------------------------------------- @@ -1276,6 +1316,10 @@ void RimSummaryPlot::updateMdiWindowTitle() { // Will be released in plot destructor or when a new legend is set QwtLegend* legend = new QwtLegend(m_qwtPlot); + + auto font = legend->font(); + font.setPixelSize(m_legendFontSize()); + legend->setFont(font); m_qwtPlot->insertLegend(legend, QwtPlot::BottomLegend); } else diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h index 975c0bfcdf..6eb0338afe 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -115,6 +115,7 @@ private: protected: // Overridden PDM methods virtual caf::PdmFieldHandle* userDescriptionField(); + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); @@ -144,6 +145,7 @@ private: private: caf::PdmField m_showPlotTitle; caf::PdmField m_showLegend; + caf::PdmField m_legendFontSize; caf::PdmField m_isUsingAutoName; caf::PdmField m_userDefinedPlotTitle;