mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-01 03:37:15 -06:00
82 lines
2.9 KiB
C++
82 lines
2.9 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// 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<QwtAxis::Position> allAxes = { QwtAxis::XBottom, QwtAxis::YLeft, QwtAxis::XTop, QwtAxis::YRight };
|
|
|
|
caf::FontTools::FontSize fontSize = RiaPreferences::current()->defaultPlotFontSize();
|
|
|
|
int titleFontSize = caf::FontTools::absolutePointSize( fontSize, caf::FontTools::RelativeSize::Large );
|
|
int axisFontSize = caf::FontTools::absolutePointSize( fontSize, caf::FontTools::RelativeSize::Medium );
|
|
int legendFontSize = caf::FontTools::absolutePointSize( fontSize, caf::FontTools::RelativeSize::Small );
|
|
|
|
QwtText titleText = title();
|
|
QFont font = titleText.font();
|
|
|
|
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( titleFontSize ) );
|
|
titleText.setFont( font );
|
|
setTitle( titleText );
|
|
|
|
for ( QwtAxis::Position axis : allAxes )
|
|
{
|
|
QwtText text = axisTitle( axis );
|
|
QFont axisTitleFont = text.font();
|
|
axisTitleFont.setPixelSize( caf::FontTools::pointSizeToPixelSize( axisFontSize ) );
|
|
text.setFont( axisTitleFont );
|
|
setAxisTitle( axis, text );
|
|
|
|
QFont valuesFont = axisFont( axis );
|
|
valuesFont.setPixelSize( axisTitleFont.pixelSize() );
|
|
setAxisFont( axis, valuesFont );
|
|
}
|
|
|
|
if ( legend() )
|
|
{
|
|
auto font = legend()->font();
|
|
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( legendFontSize ) );
|
|
legend()->setFont( font );
|
|
}
|
|
|
|
if ( replot )
|
|
{
|
|
this->replot();
|
|
}
|
|
}
|