#4255 Read default plot font sizes from preferences and apply

This commit is contained in:
Gaute Lindkvist
2019-04-10 16:13:40 +02:00
parent 798e3ff19e
commit 9d06b59357
35 changed files with 679 additions and 202 deletions

View File

@@ -539,6 +539,61 @@ size_t RimSummaryPlot::singleColorCurveCount() const
return colorIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSummaryPlot::hasCustomFontSizes(RiaDefines::FontSettingType fontSettingType, int defaultFontSize) const
{
if (fontSettingType != RiaDefines::PLOT_FONT) return false;
for (auto plotAxis : allPlotAxes())
{
if (plotAxis->titleFontSize() != defaultFontSize || plotAxis->valuesFontSize() != defaultFontSize)
{
return true;
}
}
if (m_legendFontSize() != defaultFontSize)
{
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSummaryPlot::applyFontSize(RiaDefines::FontSettingType fontSettingType, int oldFontSize, int fontSize, bool forceChange /*= false*/)
{
if (fontSettingType != RiaDefines::PLOT_FONT) return false;
bool anyChange = false;
for (auto plotAxis : allPlotAxes())
{
if (forceChange || plotAxis->titleFontSize() == oldFontSize)
{
plotAxis->setTitleFontSize(fontSize);
anyChange = true;
}
if (forceChange || plotAxis->valuesFontSize() == oldFontSize)
{
plotAxis->setValuesFontSize(fontSize);
anyChange = true;
}
}
if (forceChange || m_legendFontSize() == oldFontSize)
{
m_legendFontSize = fontSize;
anyChange = true;
}
if (anyChange) loadDataAndUpdate();
return anyChange;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -847,12 +902,12 @@ void RimSummaryPlot::updateTimeAxis()
QFont font = timeAxisTitle.font();
font.setBold(true);
font.setPixelSize(m_timeAxisProperties->titleFontSize);
font.setPointSize(m_timeAxisProperties->titleFontSize());
timeAxisTitle.setFont(font);
timeAxisTitle.setText(axisTitle);
switch ( m_timeAxisProperties->titlePositionEnum() )
switch ( m_timeAxisProperties->titlePosition() )
{
case RimSummaryTimeAxisProperties::AXIS_TITLE_CENTER:
timeAxisTitle.setRenderFlags(Qt::AlignCenter);
@@ -868,7 +923,7 @@ void RimSummaryPlot::updateTimeAxis()
{
QFont timeAxisFont = m_qwtPlot->axisFont(QwtPlot::xBottom);
timeAxisFont.setBold(false);
timeAxisFont.setPixelSize(m_timeAxisProperties->valuesFontSize);
timeAxisFont.setPointSize(m_timeAxisProperties->valuesFontSize());
m_qwtPlot->setAxisFont(QwtPlot::xBottom, timeAxisFont);
}
}
@@ -1337,6 +1392,14 @@ void RimSummaryPlot::updateAxisRangesFromQwt()
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<RimPlotAxisPropertiesInterface*> RimSummaryPlot::allPlotAxes() const
{
return { m_timeAxisProperties, m_bottomAxisProperties, m_leftYAxisProperties, m_rightYAxisProperties };
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -1518,7 +1581,7 @@ void RimSummaryPlot::updateMdiWindowTitle()
QwtLegend* legend = new QwtLegend(m_qwtPlot);
auto font = legend->font();
font.setPixelSize(m_legendFontSize());
font.setPointSize(m_legendFontSize());
legend->setFont(font);
m_qwtPlot->insertLegend(legend, QwtPlot::BottomLegend);
}