1034 Summary plot legend. Support for setting legend font size

This commit is contained in:
Bjørn Erik Jensen 2017-12-11 13:09:51 +01:00
parent 07b1bbca4b
commit b181d59ba9
3 changed files with 50 additions and 0 deletions

View File

@ -107,9 +107,13 @@ QList<caf::PdmOptionItemInfo> RimSummaryAxisProperties::calculateValueOptions(co
{
std::vector<int> 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)

View File

@ -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<caf::PdmOptionItemInfo> RimSummaryPlot::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly)
{
QList<caf::PdmOptionItemInfo> options;
if (fieldNeedingOptions == &m_legendFontSize)
{
std::vector<int> 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

View File

@ -115,6 +115,7 @@ private:
protected:
// Overridden PDM methods
virtual caf::PdmFieldHandle* userDescriptionField();
virtual QList<caf::PdmOptionItemInfo> 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<bool> m_showPlotTitle;
caf::PdmField<bool> m_showLegend;
caf::PdmField<int> m_legendFontSize;
caf::PdmField<bool> m_isUsingAutoName;
caf::PdmField<QString> m_userDefinedPlotTitle;