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 );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -84,6 +84,9 @@ public:
|
||||
void setPlotTitleEnabled( bool enabled );
|
||||
bool plotTitleEnabled() const;
|
||||
|
||||
void setLegendFontSize( int fontSize );
|
||||
void setLegendVisible( bool visible );
|
||||
|
||||
QwtInterval axisRange( QwtPlot::Axis axis );
|
||||
void setAxisRange( QwtPlot::Axis axis, double min, double max );
|
||||
|
||||
|
||||
@@ -155,41 +155,6 @@ void RiuSummaryQwtPlot::useTimeBasedTimeAxis()
|
||||
setAxisScaleDraw( QwtPlot::xBottom, new QwtScaleDraw() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::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 RiuSummaryQwtPlot::setLegendVisible( bool visible )
|
||||
{
|
||||
if ( visible )
|
||||
{
|
||||
QwtLegend* legend = new QwtLegend( this );
|
||||
this->insertLegend( legend, BottomLegend );
|
||||
}
|
||||
else
|
||||
{
|
||||
this->insertLegend( nullptr );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -52,10 +52,6 @@ public:
|
||||
RiaQDateTimeTools::TimeFormatComponents timeComponents = RiaQDateTimeTools::TIME_FORMAT_UNSPECIFIED );
|
||||
|
||||
void useTimeBasedTimeAxis();
|
||||
|
||||
void setLegendFontSize( int fontSize );
|
||||
void setLegendVisible( bool visible );
|
||||
|
||||
void setAxisIsLogarithmic( QwtPlot::Axis axis, bool logarithmic );
|
||||
|
||||
signals:
|
||||
|
||||
Reference in New Issue
Block a user