mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4341 Make docked plots follow font size preferences (but subtract 1 in point size)
* The docked plots have much less space available than most plots
This commit is contained in:
78
ApplicationCode/UserInterface/RiuDockedQwtPlot.cpp
Normal file
78
ApplicationCode/UserInterface/RiuDockedQwtPlot.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RiuDockedQwtPlot.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "qwt_abstract_legend.h"
|
||||
#include "qwt_text.h"
|
||||
|
||||
#include <QFont>
|
||||
#include <set>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuDockedQwtPlot::RiuDockedQwtPlot(QWidget* parent /*= nullptr*/)
|
||||
: QwtPlot(parent)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuDockedQwtPlot::applyFontSizes(bool replot /*= false*/)
|
||||
{
|
||||
std::set<QwtPlot::Axis> allAxes = {QwtPlot::xBottom, QwtPlot::yLeft, QwtPlot::xTop, QwtPlot::yRight};
|
||||
|
||||
RiaFontCache::FontSize fontSizeEnum = RiaApplication::instance()->preferences()->defaultPlotFontSize();
|
||||
int fontPointSize = RiaFontCache::pointSizeFromFontSizeEnum(fontSizeEnum) - 1;
|
||||
|
||||
for (QwtPlot::Axis axis : allAxes)
|
||||
{
|
||||
QwtText text = this->axisTitle(axis);
|
||||
QFont font = text.font();
|
||||
font.setPointSize(fontPointSize);
|
||||
text.setFont(font);
|
||||
this->setAxisTitle(axis, text);
|
||||
|
||||
QFont valuesFont = this->axisFont(axis);
|
||||
valuesFont.setPointSize(fontPointSize);
|
||||
this->setAxisFont(axis, valuesFont);
|
||||
}
|
||||
|
||||
if (legend())
|
||||
{
|
||||
auto font = legend()->font();
|
||||
font.setPointSize(fontPointSize);
|
||||
legend()->setFont(font);
|
||||
}
|
||||
|
||||
QwtText titleText = this->title();
|
||||
QFont font = titleText.font();
|
||||
|
||||
font.setPointSize(fontPointSize + 3);
|
||||
titleText.setFont(font);
|
||||
this->setTitle(titleText);
|
||||
|
||||
if (replot)
|
||||
{
|
||||
this->replot();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user