#4929 Fix legend fonts in Summary plot

This commit is contained in:
Gaute Lindkvist
2019-10-25 15:24:53 +02:00
parent 4bce02c375
commit 625feaf36c
6 changed files with 110 additions and 39 deletions

View File

@@ -42,6 +42,8 @@
#include "RimPlotAxisProperties.h"
#include "RiuPlotAnnotationTool.h"
#include "qwt_legend.h"
#include "qwt_legend_label.h"
#include "qwt_plot_panner.h"
#include "qwt_scale_draw.h"
#include "qwt_scale_widget.h"
@@ -104,6 +106,8 @@ RiuGridCrossQwtPlot::RiuGridCrossQwtPlot( RimPlotInterface* plotDefinition, QWid
this->installEventFilter( this );
this->canvas()->installEventFilter( this );
setLegendVisible( true );
}
//--------------------------------------------------------------------------------------------------
@@ -243,6 +247,42 @@ RimViewWindow* RiuGridCrossQwtPlot::ownerViewWindow() const
return dynamic_cast<RimViewWindow*>( plotDefinition() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGridCrossQwtPlot::setLegendFontSize( int fontSize )
{
if ( legend() )
{
QFont font = legend()->font();
font.setPointSize( fontSize );
legend()->setFont( font );
// Set font size for all existing labels
QList<QwtLegendLabel*> labels = legend()->findChildren<QwtLegendLabel*>();
for ( QwtLegendLabel* label : labels )
{
label->setFont( font );
}
}
updateInfoBoxLayout();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGridCrossQwtPlot::setLegendVisible( bool visible )
{
if ( visible )
{
QwtLegend* legend = new QwtLegend( this );
this->insertLegend( legend, BottomLegend );
}
else
{
this->insertLegend( nullptr );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -291,9 +331,9 @@ void RiuGridCrossQwtPlot::updateInfoBoxLayout()
if ( !infoText.empty() )
{
m_infoBox->label()->setText( infoText.join( "\n" ) );
QFont font = m_infoBox->font();
QFont font = m_infoBox->label()->font();
font.setPointSize( crossPlot->legendFontSize() );
m_infoBox->setFont( font );
m_infoBox->label()->setFont( font );
m_infoBox->adjustSize();
QRect infoRect = m_infoBox->frameGeometry();
QRect canvasRect = canvas()->frameGeometry();