mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Move legend control methods to RiuQwtPlotWidget
This commit is contained in:
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user