mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
First round of caf::FontTools
This commit is contained in:
@@ -105,7 +105,7 @@ void RiuAbstractLegendFrame::renderTo( QPainter* painter, const QRect& targetRec
|
||||
{
|
||||
QFont font = this->font();
|
||||
font.setPixelSize(
|
||||
RiaFontCache::pointSizeToPixelSize( RiaApplication::instance()->preferences()->defaultPlotFontSize() ) );
|
||||
caf::FontTools::pointSizeToPixelSize( RiaApplication::instance()->preferences()->defaultPlotFontSize() ) );
|
||||
this->setFont( font );
|
||||
|
||||
LayoutInfo layout( QSize( targetRect.width(), targetRect.height() ) );
|
||||
|
||||
@@ -53,7 +53,7 @@ RiuTextOverlayContentFrame::RiuTextOverlayContentFrame( QWidget* parent /*= null
|
||||
layout->addWidget( m_textLabel );
|
||||
|
||||
QFont font = m_textLabel->font();
|
||||
RiaFontCache::pointSizeToPixelSize( RiaApplication::instance()->preferences()->defaultPlotFontSize() );
|
||||
caf::FontTools::pointSizeToPixelSize( RiaPreferences::current()->defaultPlotFontSize() );
|
||||
m_textLabel->setFont( font );
|
||||
}
|
||||
|
||||
|
||||
@@ -39,38 +39,41 @@ RiuDockedQwtPlot::RiuDockedQwtPlot( QWidget* parent /*= nullptr*/ )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuDockedQwtPlot::applyFontSizes( bool replot /*= false*/ )
|
||||
{
|
||||
std::set<QwtPlot::Axis> allAxes = {QwtPlot::xBottom, QwtPlot::yLeft, QwtPlot::xTop, QwtPlot::yRight};
|
||||
std::set<QwtPlot::Axis> allAxes = { QwtPlot::xBottom, QwtPlot::yLeft, QwtPlot::xTop, QwtPlot::yRight };
|
||||
|
||||
int fontPointSize = RiaApplication::instance()->preferences()->defaultPlotFontSize() - 1;
|
||||
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 = this->title();
|
||||
QFont font = titleText.font();
|
||||
|
||||
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( titleFontSize ) );
|
||||
titleText.setFont( font );
|
||||
this->setTitle( titleText );
|
||||
|
||||
for ( QwtPlot::Axis axis : allAxes )
|
||||
{
|
||||
QwtText text = this->axisTitle( axis );
|
||||
QFont font = text.font();
|
||||
font.setPixelSize(
|
||||
RiaFontCache::pointSizeToPixelSize( RiaApplication::instance()->preferences()->defaultPlotFontSize() ) );
|
||||
text.setFont( font );
|
||||
QwtText text = this->axisTitle( axis );
|
||||
QFont axisTitleFont = text.font();
|
||||
axisTitleFont.setPixelSize( caf::FontTools::pointSizeToPixelSize( axisFontSize ) );
|
||||
text.setFont( axisTitleFont );
|
||||
this->setAxisTitle( axis, text );
|
||||
|
||||
QFont valuesFont = this->axisFont( axis );
|
||||
valuesFont.setPixelSize( font.pixelSize() );
|
||||
valuesFont.setPixelSize( axisTitleFont.pixelSize() );
|
||||
this->setAxisFont( axis, valuesFont );
|
||||
}
|
||||
|
||||
if ( legend() )
|
||||
{
|
||||
auto font = legend()->font();
|
||||
font.setPointSize( fontPointSize );
|
||||
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( legendFontSize ) );
|
||||
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();
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#include "RiuFlowCharacteristicsPlot.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaColorTables.h"
|
||||
#include "RiaFeatureCommandContext.h"
|
||||
#include "RiaFontCache.h"
|
||||
@@ -81,8 +80,8 @@ RiuFlowCharacteristicsPlot::RiuFlowCharacteristicsPlot( RimFlowCharacteristicsPl
|
||||
new RiuQwtPlotWheelZoomer( m_lorenzPlot );
|
||||
addWindowZoom( m_lorenzPlot );
|
||||
|
||||
QString dateFormat = RiaApplication::instance()->preferences()->dateFormat();
|
||||
QString timeFormat = RiaApplication::instance()->preferences()->timeFormat();
|
||||
QString dateFormat = RiaPreferences::current()->dateFormat();
|
||||
QString timeFormat = RiaPreferences::current()->timeFormat();
|
||||
|
||||
RiuQwtPlotTools::enableDateBasedBottomXAxis( m_lorenzPlot, dateFormat, timeFormat );
|
||||
m_lorenzPlot->setTitle( "Lorenz Coefficient" );
|
||||
@@ -92,7 +91,8 @@ RiuFlowCharacteristicsPlot::RiuFlowCharacteristicsPlot( RimFlowCharacteristicsPl
|
||||
addWindowZoom( m_sweepEffPlot );
|
||||
m_sweepEffPlot->setTitle( "Sweep Efficiency" );
|
||||
|
||||
int legendFontSize = RiaApplication::instance()->preferences()->defaultPlotFontSize();
|
||||
int legendFontSize = caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(),
|
||||
caf::FontTools::RelativeSize::Small );
|
||||
|
||||
{
|
||||
QwtText axisTitle = m_sweepEffPlot->axisTitle( QwtPlot::xBottom );
|
||||
|
||||
@@ -141,7 +141,7 @@ void RiuGridCrossQwtPlot::setLegendFontSize( int fontSize )
|
||||
if ( legend() )
|
||||
{
|
||||
QFont font = legend()->font();
|
||||
font.setPixelSize( RiaFontCache::pointSizeToPixelSize( fontSize ) );
|
||||
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( fontSize ) );
|
||||
legend()->setFont( font );
|
||||
// Set font size for all existing labels
|
||||
QList<QwtLegendLabel*> labels = legend()->findChildren<QwtLegendLabel*>();
|
||||
|
||||
@@ -133,10 +133,6 @@ RiuMultiPlotBook::RiuMultiPlotBook( RimMultiPlot* plotDefinition, QWidget* paren
|
||||
|
||||
setFocusPolicy( Qt::StrongFocus );
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
int defaultFontSize = app->preferences()->defaultPlotFontSize();
|
||||
setFontSize( defaultFontSize );
|
||||
|
||||
QSize pageSize = m_plotDefinition->pageLayout().fullRectPixels( RiaGuiApplication::applicationResolution() ).size();
|
||||
setBookSize( pageSize.width() );
|
||||
this->setObjectName( QString( "%1" ).arg( reinterpret_cast<uint64_t>( this ) ) );
|
||||
@@ -229,26 +225,34 @@ void RiuMultiPlotBook::setSubTitlesVisible( bool visible )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotBook::setFontSize( int fontSize )
|
||||
void RiuMultiPlotBook::setTitleFontSizes( int titleFontSize, int subTitleFontSize )
|
||||
{
|
||||
QFont font = this->font();
|
||||
int pixelSize = RiaFontCache::pointSizeToPixelSize( fontSize );
|
||||
|
||||
font.setPixelSize( pixelSize );
|
||||
this->setFont( font );
|
||||
|
||||
for ( auto page : m_pages )
|
||||
{
|
||||
page->setFontSize( fontSize );
|
||||
page->setTitleFontSizes( titleFontSize, subTitleFontSize );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiuMultiPlotBook::fontSize() const
|
||||
void RiuMultiPlotBook::setLegendFontSize( int legendFontSize )
|
||||
{
|
||||
return RiaFontCache::pixelSizeToPointSize( this->font().pixelSize() );
|
||||
for ( auto page : m_pages )
|
||||
{
|
||||
page->setLegendFontSize( legendFontSize );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotBook::setAxisFontSizes( int axisTitleFontSize, int axisValueFontSize )
|
||||
{
|
||||
for ( auto page : m_pages )
|
||||
{
|
||||
page->setAxisFontSizes( axisTitleFontSize, axisValueFontSize );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -512,7 +516,9 @@ RiuMultiPlotPage* RiuMultiPlotBook::createPage()
|
||||
|
||||
// Reapply plot settings
|
||||
page->setPlotTitle( m_plotTitle );
|
||||
page->setFontSize( RiaApplication::instance()->preferences()->defaultPlotFontSize() );
|
||||
page->setTitleFontSizes( m_plotDefinition->titleFontSize(), m_plotDefinition->subTitleFontSize() );
|
||||
page->setLegendFontSize( m_plotDefinition->legendFontSize() );
|
||||
page->setAxisFontSizes( m_plotDefinition->axisTitleFontSize(), m_plotDefinition->axisValueFontSize() );
|
||||
page->setTitleVisible( m_titleVisible );
|
||||
page->setSubTitlesVisible( m_subTitlesVisible );
|
||||
page->setPreviewModeEnabled( m_previewMode );
|
||||
|
||||
@@ -73,8 +73,9 @@ public:
|
||||
void setTitleVisible( bool visible );
|
||||
void setSubTitlesVisible( bool visible );
|
||||
|
||||
void setFontSize( int fontSize );
|
||||
int fontSize() const;
|
||||
void setTitleFontSizes( int titleFontSize, int subTitleFontSize );
|
||||
void setLegendFontSize( int legendFontSize );
|
||||
void setAxisFontSizes( int axisTitleFontSize, int axisValueFontSize );
|
||||
|
||||
int indexOfPlotWidget( RiuQwtPlotWidget* plotWidget );
|
||||
|
||||
|
||||
@@ -68,6 +68,12 @@ RiuMultiPlotPage::RiuMultiPlotPage( RimPlotWindow* plotDefinition, QWidget* pare
|
||||
, m_plotDefinition( plotDefinition )
|
||||
, m_previewMode( false )
|
||||
, m_showSubTitles( false )
|
||||
, m_titleFontPixelSize( 12 )
|
||||
, m_subTitleFontPixelSize( 11 )
|
||||
, m_legendFontPixelSize( 8 )
|
||||
, m_axisTitleFontPixelSize( 10 )
|
||||
, m_axisValueFontPixelSize( 10 )
|
||||
|
||||
{
|
||||
CAF_ASSERT( m_plotDefinition );
|
||||
|
||||
@@ -109,10 +115,6 @@ RiuMultiPlotPage::RiuMultiPlotPage( RimPlotWindow* plotDefinition, QWidget* pare
|
||||
|
||||
setFocusPolicy( Qt::StrongFocus );
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
int defaultFontSize = app->preferences()->defaultPlotFontSize();
|
||||
setFontSize( defaultFontSize );
|
||||
|
||||
this->setObjectName( QString( "%1" ).arg( reinterpret_cast<uint64_t>( this ) ) );
|
||||
|
||||
this->setBackgroundRole( QPalette::Window );
|
||||
@@ -259,32 +261,33 @@ void RiuMultiPlotPage::setTitleVisible( bool visible )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotPage::setFontSize( int fontSize )
|
||||
void RiuMultiPlotPage::setTitleFontSizes( int titleFontSize, int subTitleFontSize )
|
||||
{
|
||||
int pixelSize = RiaFontCache::pointSizeToPixelSize( fontSize );
|
||||
{
|
||||
QFont font = m_plotTitle->font();
|
||||
m_titleFontPixelSize = caf::FontTools::pointSizeToPixelSize( titleFontSize );
|
||||
m_subTitleFontPixelSize = caf::FontTools::pointSizeToPixelSize( subTitleFontSize );
|
||||
|
||||
font.setPixelSize( pixelSize + 2 );
|
||||
font.setBold( true );
|
||||
m_plotTitle->setFont( font );
|
||||
}
|
||||
|
||||
for ( QLabel* subTitle : m_subTitles )
|
||||
{
|
||||
QFont font = subTitle->font();
|
||||
font.setPixelSize( pixelSize );
|
||||
font.setBold( true );
|
||||
subTitle->setFont( font );
|
||||
}
|
||||
scheduleUpdate();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiuMultiPlotPage::fontSize() const
|
||||
void RiuMultiPlotPage::setLegendFontSize( int legendFontSize )
|
||||
{
|
||||
return m_plotTitle->font().pointSize() - 2;
|
||||
m_legendFontPixelSize = caf::FontTools::pointSizeToPixelSize( legendFontSize );
|
||||
|
||||
scheduleUpdate();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotPage::setAxisFontSizes( int axisTitleFontSize, int axisValueFontSize )
|
||||
{
|
||||
m_axisTitleFontPixelSize = caf::FontTools::pointSizeToPixelSize( axisTitleFontSize );
|
||||
m_axisValueFontPixelSize = caf::FontTools::pointSizeToPixelSize( axisValueFontSize );
|
||||
|
||||
scheduleUpdate();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -579,6 +582,10 @@ void RiuMultiPlotPage::reinsertPlotWidgets()
|
||||
{
|
||||
clearGridLayout();
|
||||
|
||||
auto titleFont = m_plotTitle->font();
|
||||
titleFont.setPixelSize( m_titleFontPixelSize );
|
||||
m_plotTitle->setFont( titleFont );
|
||||
|
||||
for ( int tIdx = 0; tIdx < m_plotWidgets.size(); ++tIdx )
|
||||
{
|
||||
if ( m_plotWidgets[tIdx] )
|
||||
@@ -621,11 +628,17 @@ void RiuMultiPlotPage::reinsertPlotWidgets()
|
||||
m_gridLayout->addWidget( plotWidgets[visibleIndex], 3 * row + 2, column, 1 + ( rowSpan - 1 ) * 3, colSpan );
|
||||
|
||||
subTitles[visibleIndex]->setVisible( m_showSubTitles );
|
||||
QFont subTitleFont = subTitles[visibleIndex]->font();
|
||||
subTitleFont.setPixelSize( m_subTitleFontPixelSize );
|
||||
subTitles[visibleIndex]->setFont( subTitleFont );
|
||||
|
||||
plotWidgets[visibleIndex]->setAxisLabelsAndTicksEnabled( QwtPlot::yLeft,
|
||||
showYAxis( row, column ),
|
||||
showYAxis( row, column ) );
|
||||
plotWidgets[visibleIndex]->setAxisTitleEnabled( QwtPlot::yLeft, showYAxis( row, column ) );
|
||||
plotWidgets[visibleIndex]->setAxisFontsAndAlignment( QwtPlot::yLeft,
|
||||
m_axisTitleFontPixelSize,
|
||||
m_axisValueFontPixelSize );
|
||||
|
||||
plotWidgets[visibleIndex]->show();
|
||||
|
||||
@@ -640,7 +653,7 @@ void RiuMultiPlotPage::reinsertPlotWidgets()
|
||||
}
|
||||
legends[visibleIndex]->setMaxColumns( legendColumns );
|
||||
QFont legendFont = legends[visibleIndex]->font();
|
||||
legendFont.setPixelSize( RiaFontCache::pointSizeToPixelSize( m_plotDefinition->legendFontSize() ) );
|
||||
legendFont.setPixelSize( m_legendFontPixelSize );
|
||||
legends[visibleIndex]->setFont( legendFont );
|
||||
legends[visibleIndex]->show();
|
||||
}
|
||||
|
||||
@@ -79,8 +79,9 @@ public:
|
||||
|
||||
void setPlotTitle( const QString& plotTitle );
|
||||
void setTitleVisible( bool visible );
|
||||
void setFontSize( int fontSize );
|
||||
int fontSize() const;
|
||||
void setTitleFontSizes( int titleFontSize, int subTitleFontSize );
|
||||
void setLegendFontSize( int legendFontSize );
|
||||
void setAxisFontSizes( int axisTitleFontSize, int axisValueFontSize );
|
||||
void setSubTitlesVisible( bool visible );
|
||||
|
||||
bool previewModeEnabled() const;
|
||||
@@ -142,6 +143,12 @@ protected:
|
||||
QList<QPointer<RiuQwtPlotWidget>> m_plotWidgets;
|
||||
caf::PdmPointer<RimPlotWindow> m_plotDefinition;
|
||||
|
||||
int m_titleFontPixelSize;
|
||||
int m_subTitleFontPixelSize;
|
||||
int m_legendFontPixelSize;
|
||||
int m_axisTitleFontPixelSize;
|
||||
int m_axisValueFontPixelSize;
|
||||
|
||||
bool m_previewMode;
|
||||
bool m_showSubTitles;
|
||||
|
||||
|
||||
@@ -56,10 +56,11 @@ void RiuQwtPlotTools::setCommonPlotBehaviour( QwtPlot* plot )
|
||||
gridPen.setColor( Qt::lightGray );
|
||||
grid->setPen( gridPen );
|
||||
|
||||
int fontSize = RiaApplication::instance()->preferences()->defaultPlotFontSize();
|
||||
// Axis number font
|
||||
QFont axisFont = plot->axisFont( QwtPlot::xBottom );
|
||||
axisFont.setPixelSize( RiaFontCache::pointSizeToPixelSize( fontSize ) );
|
||||
int axisFontSize = caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(),
|
||||
caf::FontTools::RelativeSize::Medium );
|
||||
QFont axisFont = plot->axisFont( QwtPlot::xBottom );
|
||||
axisFont.setPixelSize( caf::FontTools::pointSizeToPixelSize( axisFontSize ) );
|
||||
|
||||
plot->setAxisFont( QwtPlot::xBottom, axisFont );
|
||||
plot->setAxisFont( QwtPlot::xTop, axisFont );
|
||||
@@ -73,7 +74,7 @@ void RiuQwtPlotTools::setCommonPlotBehaviour( QwtPlot* plot )
|
||||
{
|
||||
QwtText axisTitle = plot->axisTitle( axis );
|
||||
QFont axisTitleFont = axisTitle.font();
|
||||
axisTitleFont.setPixelSize( RiaFontCache::pointSizeToPixelSize( fontSize ) );
|
||||
axisTitleFont.setPixelSize( caf::FontTools::pointSizeToPixelSize( axisFontSize ) );
|
||||
axisTitleFont.setBold( false );
|
||||
axisTitle.setFont( axisTitleFont );
|
||||
axisTitle.setRenderFlags( Qt::AlignRight );
|
||||
|
||||
@@ -165,21 +165,21 @@ int RiuQwtPlotWidget::axisValueFontSize( QwtPlot::Axis axis ) const
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::setAxisFontsAndAlignment( QwtPlot::Axis axis,
|
||||
int titleFontSize,
|
||||
int valueFontSize,
|
||||
int titleFontPixelSize,
|
||||
int valueFontPixelSize,
|
||||
bool titleBold,
|
||||
int alignment )
|
||||
{
|
||||
// Axis number font
|
||||
QFont axisFont = this->axisFont( axis );
|
||||
axisFont.setPixelSize( RiaFontCache::pointSizeToPixelSize( valueFontSize ) );
|
||||
axisFont.setPixelSize( valueFontPixelSize );
|
||||
axisFont.setBold( false );
|
||||
this->setAxisFont( axis, axisFont );
|
||||
|
||||
// Axis title font
|
||||
QwtText axisTitle = this->axisTitle( axis );
|
||||
QFont axisTitleFont = axisTitle.font();
|
||||
axisTitleFont.setPixelSize( RiaFontCache::pointSizeToPixelSize( titleFontSize ) );
|
||||
axisTitleFont.setPixelSize( titleFontPixelSize );
|
||||
axisTitleFont.setBold( titleBold );
|
||||
axisTitle.setFont( axisTitleFont );
|
||||
axisTitle.setRenderFlags( alignment | Qt::TextWordWrap );
|
||||
@@ -247,7 +247,7 @@ void RiuQwtPlotWidget::setPlotTitleFontSize( int titleFontSize )
|
||||
{
|
||||
auto title = this->title();
|
||||
QFont font = title.font();
|
||||
font.setPixelSize( RiaFontCache::pointSizeToPixelSize( titleFontSize ) );
|
||||
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( titleFontSize ) );
|
||||
title.setFont( font );
|
||||
setTitle( title );
|
||||
}
|
||||
@@ -260,7 +260,7 @@ void RiuQwtPlotWidget::setLegendFontSize( int fontSize )
|
||||
if ( legend() )
|
||||
{
|
||||
QFont font = legend()->font();
|
||||
font.setPixelSize( RiaFontCache::pointSizeToPixelSize( fontSize ) );
|
||||
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( fontSize ) );
|
||||
legend()->setFont( font );
|
||||
// Set font size for all existing labels
|
||||
QList<QwtLegendLabel*> labels = legend()->findChildren<QwtLegendLabel*>();
|
||||
@@ -1074,7 +1074,7 @@ void RiuQwtPlotWidget::highlightPlotItem( const QwtPlotItem* closestItem )
|
||||
symbol->setPen( blendedSymbolLineColor, symbol->pen().width(), symbol->pen().style() );
|
||||
}
|
||||
}
|
||||
CurveColors curveColors = { curveColor, symbolColor, symbolLineColor };
|
||||
CurveColors curveColors = {curveColor, symbolColor, symbolLineColor};
|
||||
m_originalCurveColors.insert( std::make_pair( plotCurve, curveColors ) );
|
||||
m_originalCurveColors.insert( std::make_pair( plotCurve, curveColors ) );
|
||||
m_originalZValues.insert( std::make_pair( plotCurve, zValue ) );
|
||||
|
||||
@@ -72,8 +72,8 @@ public:
|
||||
int axisTitleFontSize( QwtPlot::Axis axis ) const;
|
||||
int axisValueFontSize( QwtPlot::Axis axis ) const;
|
||||
void setAxisFontsAndAlignment( QwtPlot::Axis,
|
||||
int titleFontSize,
|
||||
int valueFontSize,
|
||||
int titleFontPixelSize,
|
||||
int valueFontPixelSize,
|
||||
bool titleBold = false,
|
||||
int alignment = (int)Qt::AlignRight );
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ RiuQwtSymbol::RiuQwtSymbol( PointSymbolEnum riuStyle, const QString& label, Labe
|
||||
: QwtSymbol( QwtSymbol::NoSymbol )
|
||||
, m_globalLabel( label )
|
||||
, m_labelPosition( labelPosition )
|
||||
, m_labelFontSizePx( RiaFontCache::pointSizeToPixelSize( labelFontSizePt ) )
|
||||
, m_labelFontSizePx( caf::FontTools::pointSizeToPixelSize( labelFontSizePt ) )
|
||||
{
|
||||
QwtSymbol::Style style = QwtSymbol::NoSymbol;
|
||||
|
||||
|
||||
@@ -97,7 +97,9 @@ RiuViewer::RiuViewer( const QGLFormat& format, QWidget* parent )
|
||||
{
|
||||
cvf::Font* standardFont = RiaGuiApplication::instance()->defaultSceneFont();
|
||||
QFont font = RiaGuiApplication::instance()->font();
|
||||
font.setPointSize( RiaGuiApplication::instance()->preferences()->defaultSceneFontSize() );
|
||||
|
||||
auto viewFontSize = RiaPreferences::current()->defaultSceneFontSize();
|
||||
font.setPointSize( caf::FontTools::absolutePointSize( viewFontSize ) );
|
||||
|
||||
m_axisCross = new cvf::OverlayAxisCross( m_mainCamera.p(), standardFont );
|
||||
m_axisCross->setAxisLabels( "X", "Y", "Z" );
|
||||
@@ -206,6 +208,8 @@ RiuViewer::RiuViewer( const QGLFormat& format, QWidget* parent )
|
||||
|
||||
m_comparisonWindowMover = new RiuComparisonViewMover( this );
|
||||
this->setComparisonViewToFollowAnimation( false );
|
||||
|
||||
m_fontPointSize = caf::FontTools::absolutePointSize(RiaPreferences::current()->defaultSceneFontSize());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -715,7 +719,7 @@ void RiuViewer::addColorLegendToBottomLeftCorner( caf::TitledOverlayFrame* added
|
||||
addedLegend->enableBackground( preferences->showLegendBackground() );
|
||||
addedLegend->setBackgroundColor( backgroundColor );
|
||||
addedLegend->setBackgroundFrameColor( frameColor );
|
||||
addedLegend->setFont( app->defaultSceneFont() );
|
||||
addedLegend->setFont( app->sceneFont(m_fontPointSize) );
|
||||
|
||||
overlayRendering->addOverlayItem( addedLegend );
|
||||
|
||||
@@ -908,7 +912,7 @@ void RiuViewer::updateLegendLayout()
|
||||
const int xPos = width() - (int)scaleLegendSize.x() - margin - edgeAxisBorderWidth;
|
||||
const int yPos = margin + edgeAxisBorderHeight + margin + otherItemsHeight;
|
||||
|
||||
m_scaleLegend->setLayoutFixedPosition( {xPos, yPos} );
|
||||
m_scaleLegend->setLayoutFixedPosition( { xPos, yPos } );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1111,15 +1115,17 @@ void RiuViewer::leaveEvent( QEvent* )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::updateGridBoxData( double scaleZ,
|
||||
const cvf::Vec3d& displayModelOffset,
|
||||
const cvf::Color3f& backgroundColor,
|
||||
const cvf::BoundingBox& domainCoordBoundingBox )
|
||||
void RiuViewer::updateGridBoxData( double scaleZ,
|
||||
const cvf::Vec3d& displayModelOffset,
|
||||
const cvf::Color3f& backgroundColor,
|
||||
const cvf::BoundingBox& domainCoordBoundingBox,
|
||||
int fontPointSize )
|
||||
{
|
||||
m_gridBoxGenerator->setScaleZ( scaleZ );
|
||||
m_gridBoxGenerator->setDisplayModelOffset( displayModelOffset );
|
||||
m_gridBoxGenerator->updateFromBackgroundColor( backgroundColor );
|
||||
m_gridBoxGenerator->setGridBoxDomainCoordBoundingBox( domainCoordBoundingBox );
|
||||
m_gridBoxGenerator->setGridLabelFontSize(fontPointSize);
|
||||
|
||||
m_gridBoxGenerator->createGridBoxParts();
|
||||
|
||||
@@ -1285,9 +1291,9 @@ void RiuViewer::showScaleLegend( bool show )
|
||||
if ( show )
|
||||
{
|
||||
if ( m_scaleLegend->orientation() == caf::OverlayScaleLegend::HORIZONTAL )
|
||||
m_scaleLegend->setRenderSize( {280, 45} );
|
||||
m_scaleLegend->setRenderSize( { 280, 45 } );
|
||||
else
|
||||
m_scaleLegend->setRenderSize( {50, 280} );
|
||||
m_scaleLegend->setRenderSize( { 50, 280 } );
|
||||
|
||||
overlayItemsRendering()->addOverlayItem( m_scaleLegend.p() );
|
||||
}
|
||||
@@ -1316,20 +1322,28 @@ void RiuViewer::clearHoverCursor()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::updateFonts()
|
||||
void RiuViewer::updateFonts(int fontPointSize)
|
||||
{
|
||||
cvf::Font* standardFont = RiaGuiApplication::instance()->defaultSceneFont();
|
||||
overlayItemsRendering()->removeOverlayItem( m_axisCross.p() );
|
||||
m_fontPointSize = fontPointSize;
|
||||
|
||||
m_axisCross = new cvf::OverlayAxisCross( m_mainCamera.p(), standardFont );
|
||||
auto defaultFontSize = RiaApplication::instance()->preferences()->defaultSceneFontSize();
|
||||
cvf::Font* axisFont = RiaGuiApplication::instance()->defaultSceneFont();
|
||||
QFont font = QApplication::font();
|
||||
font.setPixelSize( caf::FontTools::pointSizeToPixelSize(m_fontPointSize ));
|
||||
|
||||
if ( caf::FontTools::absolutePointSize(defaultFontSize) != m_fontPointSize )
|
||||
{
|
||||
axisFont = RiaFontCache::getFont( m_fontPointSize ).p();
|
||||
}
|
||||
|
||||
overlayItemsRendering()->removeOverlayItem( m_axisCross.p() );
|
||||
|
||||
m_axisCross = new cvf::OverlayAxisCross( m_mainCamera.p(), axisFont );
|
||||
m_axisCross->setAxisLabels( "X", "Y", "Z" );
|
||||
m_axisCross->setLayout( cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_RIGHT );
|
||||
overlayItemsRendering()->addOverlayItem( m_axisCross.p() );
|
||||
m_showAxisCross = true;
|
||||
|
||||
QFont font = QApplication::font();
|
||||
font.setPointSize( RiaApplication::instance()->preferences()->defaultSceneFontSize() );
|
||||
|
||||
m_zScaleLabel->setFont( font );
|
||||
m_infoLabel->setFont( font );
|
||||
m_shortInfoLabel->setFont( font );
|
||||
@@ -1337,6 +1351,8 @@ void RiuViewer::updateFonts()
|
||||
m_animationProgress->setFont( font );
|
||||
m_animationProgressCompView->setFont( font );
|
||||
m_versionInfoLabel->setFont( font );
|
||||
|
||||
m_gridBoxGenerator->setGridLabelFontSize(m_fontPointSize);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "RiuInterfaceToViewWindow.h"
|
||||
#include "RiuViewerToViewInterface.h"
|
||||
|
||||
#include "cafFontTools.h"
|
||||
#include "cafMouseState.h"
|
||||
#include "cafPdmInterfacePointer.h"
|
||||
#include "cafPdmObject.h"
|
||||
@@ -98,10 +99,11 @@ public:
|
||||
void setHistogramPercentiles( double pmin, double pmax, double mean );
|
||||
|
||||
void showGridBox( bool enable );
|
||||
void updateGridBoxData( double scaleZ,
|
||||
const cvf::Vec3d& displayModelOffset,
|
||||
const cvf::Color3f& backgroundColor,
|
||||
const cvf::BoundingBox& domainCoordBoundingBox );
|
||||
void updateGridBoxData( double scaleZ,
|
||||
const cvf::Vec3d& displayModelOffset,
|
||||
const cvf::Color3f& backgroundColor,
|
||||
const cvf::BoundingBox& domainCoordBoundingBox,
|
||||
int fontPointSize );
|
||||
void showEdgeTickMarksXY( bool enable, bool showAxisLines = false );
|
||||
void showEdgeTickMarksXZ( bool enable, bool showAxisLines = false );
|
||||
|
||||
@@ -136,7 +138,7 @@ public:
|
||||
static void setHoverCursor( const QCursor& cursor );
|
||||
static void clearHoverCursor();
|
||||
|
||||
void updateFonts();
|
||||
void updateFonts(int fontPointSize);
|
||||
|
||||
public slots:
|
||||
void slotSetCurrentFrame( int frameIndex ) override;
|
||||
@@ -180,6 +182,7 @@ private:
|
||||
bool m_showZScaleLabel;
|
||||
bool m_hideZScaleCheckbox;
|
||||
double m_zScale;
|
||||
int m_fontPointSize;
|
||||
|
||||
caf::QStyledProgressBar* m_animationProgress;
|
||||
caf::QStyledProgressBar* m_animationProgressCompView;
|
||||
|
||||
Reference in New Issue
Block a user