Move legend control methods to RiuQwtPlotWidget

This commit is contained in:
Jacob Støren
2020-02-25 15:59:07 +01:00
parent 66d98b3d23
commit ba1a538bb9
4 changed files with 39 additions and 39 deletions

View File

@@ -35,6 +35,7 @@
#include "cafAssert.h"
#include "qwt_legend.h"
#include "qwt_legend_label.h"
#include "qwt_plot_canvas.h"
#include "qwt_plot_curve.h"
#include "qwt_plot_grid.h"
@@ -237,6 +238,41 @@ bool RiuQwtPlotWidget::plotTitleEnabled() const
return m_plotTitleEnabled;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::setLegendFontSize( int fontSize )
{
if ( legend() )
{
QFont font = legend()->font();
font.setPixelSize( RiaFontCache::pointSizeToPixelSize( fontSize ) );
legend()->setFont( font );
// Set font size for all existing labels
QList<QwtLegendLabel*> labels = legend()->findChildren<QwtLegendLabel*>();
for ( QwtLegendLabel* label : labels )
{
label->setFont( font );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::setLegendVisible( bool visible )
{
if ( visible )
{
QwtLegend* legend = new QwtLegend( this );
this->insertLegend( legend, BottomLegend );
}
else
{
this->insertLegend( nullptr );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------