#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

@@ -17,6 +17,8 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RiuGridCrossQwtPlot.h"
#include "RiaFontCache.h"
#include "RiuCvfOverlayItemWidget.h"
#include "RiuRimQwtPlotCurve.h"
#include "RiuQwtCurvePointTracker.h"
@@ -28,6 +30,7 @@
#include "RimRegularLegendConfig.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "cafFixedAtlasFont.h"
#include "cafSelectionManager.h"
#include "cafTitledOverlayFrame.h"
@@ -94,6 +97,7 @@ void RiuGridCrossQwtPlot::addOrUpdateDataSetLegend(RimGridCrossPlotDataSet* data
if (overlayWidget)
{
caf::TitledOverlayFrame* overlayItem = dataSet->legendConfig()->titledOverlayFrame();
applyFontSizeToOverlayItem(overlayItem);
resizeOverlayItemToFitPlot(overlayItem);
overlayWidget->updateFromOverlayItem(overlayItem);
}
@@ -135,6 +139,7 @@ void RiuGridCrossQwtPlot::updateLegendSizesToMatchPlot()
{
RiuCvfOverlayItemWidget* overlayWidget = pairIt->second;
caf::TitledOverlayFrame* overlayItem = dataSet->legendConfig()->titledOverlayFrame();
applyFontSizeToOverlayItem(overlayItem);
if (resizeOverlayItemToFitPlot(overlayItem))
{
anyLegendResized = true;
@@ -208,6 +213,9 @@ void RiuGridCrossQwtPlot::updateInfoBoxLayout()
if (!infoText.empty())
{
m_infoBox->label()->setText(infoText.join("\n"));
QFont font = m_infoBox->font();
font.setPointSize(crossPlot->legendFontSize());
m_infoBox->setFont(font);
m_infoBox->adjustSize();
QRect infoRect = m_infoBox->frameGeometry();
QRect canvasRect = canvas()->frameGeometry();
@@ -401,3 +409,14 @@ bool RiuGridCrossQwtPlot::curveText(const QwtPlotCurve* curve,
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGridCrossQwtPlot::applyFontSizeToOverlayItem(caf::TitledOverlayFrame* overlayItem)
{
RimGridCrossPlot* crossPlot = static_cast<RimGridCrossPlot*>(ownerViewWindow());
int fontSize = crossPlot->legendFontSize();
cvf::ref<cvf::Font> cafFont = RiaFontCache::getFont(RiaFontCache::fontSizeEnumFromPointSize(fontSize));
overlayItem->setFont(cafFont.p());
}

View File

@@ -66,13 +66,14 @@ protected:
void selectSample(QwtPlotCurve* curve, int sampleNumber) override;
void clearSampleSelection() override;
bool curveText(const QwtPlotCurve* curve, QString* curveTitle, QString* xParamName, QString* yParamName) const;
void applyFontSizeToOverlayItem(caf::TitledOverlayFrame* overlayItem);
private:
typedef caf::PdmPointer<RimGridCrossPlotDataSet> DataSetPtr;
typedef QPointer<RiuCvfOverlayItemWidget> LegendPtr;
typedef QPointer<RiuDraggableOverlayFrame> InfoBoxPtr;
InfoBoxPtr m_infoBox;
std::map<DataSetPtr, LegendPtr> m_legendWidgets;
std::map<DataSetPtr, LegendPtr> m_legendWidgets;
std::unique_ptr<RiuPlotAnnotationTool> m_annotationTool;
QwtPlotMarker* m_selectedPointMarker;

View File

@@ -147,7 +147,7 @@ void RiuPvtPlotWidget::setPlotDefaults(QwtPlot* plot)
// Axis number font
{
QFont axisFont = plot->axisFont(QwtPlot::xBottom);
axisFont.setPixelSize(11);
axisFont.setPointSize(10);
plot->setAxisFont(QwtPlot::xBottom, axisFont);
plot->setAxisFont(QwtPlot::yLeft, axisFont);
}
@@ -156,7 +156,7 @@ void RiuPvtPlotWidget::setPlotDefaults(QwtPlot* plot)
{
QwtText axisTitle = plot->axisTitle(QwtPlot::xBottom);
QFont axisTitleFont = axisTitle.font();
axisTitleFont.setPixelSize(11);
axisTitleFont.setPointSize(10);
axisTitleFont.setBold(false);
axisTitle.setFont(axisTitleFont);
axisTitle.setRenderFlags(Qt::AlignRight);
@@ -168,7 +168,7 @@ void RiuPvtPlotWidget::setPlotDefaults(QwtPlot* plot)
{
QwtText plotTitle = plot->title();
QFont titleFont = plotTitle.font();
titleFont.setPixelSize(14);
titleFont.setPointSize(14);
plotTitle.setFont(titleFont);
plot->setTitle(plotTitle);
}
@@ -506,7 +506,7 @@ RiuPvtPlotPanel::RiuPvtPlotPanel(QDockWidget* parent)
m_titleLabel = new QLabel("", this);
m_titleLabel->setAlignment(Qt::AlignHCenter);
QFont font = m_titleLabel->font();
font.setPixelSize(14);
font.setPointSize(14);
font.setBold(true);
m_titleLabel->setFont(font);

View File

@@ -55,7 +55,7 @@ void RiuQwtPlotTools::setCommonPlotBehaviour(QwtPlot* plot)
// Axis number font
QFont axisFont = plot->axisFont(QwtPlot::xBottom);
axisFont.setPixelSize(11);
axisFont.setPointSize(10);
plot->setAxisFont(QwtPlot::xBottom, axisFont);
plot->setAxisFont(QwtPlot::xTop, axisFont);
@@ -69,7 +69,7 @@ void RiuQwtPlotTools::setCommonPlotBehaviour(QwtPlot* plot)
{
QwtText axisTitle = plot->axisTitle(axis);
QFont axisTitleFont = axisTitle.font();
axisTitleFont.setPixelSize(11);
axisTitleFont.setPointSize(10);
axisTitleFont.setBold(false);
axisTitle.setFont(axisTitleFont);
axisTitle.setRenderFlags(Qt::AlignRight);

View File

@@ -159,7 +159,7 @@ void RiuRelativePermeabilityPlotPanel::setPlotDefaults(QwtPlot* plot)
{
QwtText plotTitle = plot->title();
QFont titleFont = plotTitle.font();
titleFont.setPixelSize(14);
titleFont.setPointSize(14);
plotTitle.setFont(titleFont);
plot->setTitle(plotTitle);
}

View File

@@ -57,7 +57,7 @@ RiuTofAccumulatedPhaseFractionsPlot::RiuTofAccumulatedPhaseFractionsPlot(RimTofA
setDefaults();
QwtText title("Cumulative Saturation by Time of Flight");
QFont titleFont = title.font();
titleFont.setPixelSize(12);
titleFont.setPointSize(12);
title.setFont(titleFont);
setTitle(title);
@@ -249,7 +249,7 @@ void RiuTofAccumulatedPhaseFractionsPlot::setCommonPlotBehaviour(QwtPlot* plot)
// Axis number font
QFont axisFont = plot->axisFont(QwtPlot::xBottom);
axisFont.setPixelSize(11);
axisFont.setPointSize(10);
plot->setAxisFont(QwtPlot::xBottom, axisFont);
plot->setAxisFont(QwtPlot::xTop, axisFont);
@@ -259,7 +259,7 @@ void RiuTofAccumulatedPhaseFractionsPlot::setCommonPlotBehaviour(QwtPlot* plot)
// Axis title font
QwtText axisTitle = plot->axisTitle(QwtPlot::xBottom);
QFont axisTitleFont = axisTitle.font();
axisTitleFont.setPixelSize(11);
axisTitleFont.setPointSize(10);
axisTitleFont.setBold(false);
axisTitle.setFont(axisTitleFont);
axisTitle.setRenderFlags(Qt::AlignRight);

View File

@@ -95,7 +95,7 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
{
cvf::Font* standardFont = RiaApplication::instance()->defaultSceneFont();
QFont font = QApplication::font();
font.setPointSize(RiaFontCache::getPointSize(RiaApplication::instance()->preferences()->defaultFontSizeInScene()));
font.setPointSize(RiaFontCache::pointSizeFromFontSizeEnum(RiaApplication::instance()->preferences()->defaultSceneFontSize()));
m_axisCross = new cvf::OverlayAxisCross(m_mainCamera.p(), standardFont);
m_axisCross->setAxisLabels("X", "Y", "Z");
@@ -1074,7 +1074,7 @@ void RiuViewer::updateFonts()
m_showAxisCross = true;
QFont font = QApplication::font();
font.setPointSize(RiaFontCache::getPointSize(RiaApplication::instance()->preferences()->defaultFontSizeInScene()));
font.setPointSize(RiaFontCache::pointSizeFromFontSizeEnum(RiaApplication::instance()->preferences()->defaultSceneFontSize()));
m_zScaleLabel->setFont(font);
m_infoLabel->setFont(font);