Moved Box shape creator to QwtPlotTools for use in correlation matrix

This commit is contained in:
Gaute Lindkvist
2020-04-20 09:35:59 +02:00
parent 48c4d81505
commit 85851d0794
4 changed files with 61 additions and 50 deletions

View File

@@ -25,6 +25,7 @@
#include "qwt_plot.h"
#include "qwt_plot_grid.h"
#include "qwt_plot_layout.h"
#include "qwt_plot_shapeitem.h"
#include "qwt_scale_widget.h"
#include <QRegExp>
@@ -66,7 +67,7 @@ void RiuQwtPlotTools::setCommonPlotBehaviour( QwtPlot* plot )
plot->setAxisFont( QwtPlot::yRight, axisFont );
// Axis title font
std::vector<QwtPlot::Axis> axes = {QwtPlot::xBottom, QwtPlot::xTop, QwtPlot::yLeft, QwtPlot::yRight};
std::vector<QwtPlot::Axis> axes = { QwtPlot::xBottom, QwtPlot::xTop, QwtPlot::yLeft, QwtPlot::yRight };
for ( QwtPlot::Axis axis : axes )
{
@@ -130,14 +131,14 @@ void RiuQwtPlotTools::enableDateBasedBottomXAxis( QwtPlot*
{
QwtDateScaleDraw* scaleDraw = new QwtDateScaleDraw( Qt::UTC );
std::set<QwtDate::IntervalType> intervals = {QwtDate::Year,
QwtDate::Month,
QwtDate::Week,
QwtDate::Day,
QwtDate::Hour,
QwtDate::Minute,
QwtDate::Second,
QwtDate::Millisecond};
std::set<QwtDate::IntervalType> intervals = { QwtDate::Year,
QwtDate::Month,
QwtDate::Week,
QwtDate::Day,
QwtDate::Hour,
QwtDate::Minute,
QwtDate::Second,
QwtDate::Millisecond };
for ( QwtDate::IntervalType interval : intervals )
{
@@ -208,3 +209,30 @@ QString RiuQwtPlotTools::dateTimeFormatForInterval( QwtDate::IntervalType
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QwtPlotItem* RiuQwtPlotTools::createBoxShape( const QString& label,
double startX,
double endX,
double startY,
double endY,
QColor color,
Qt::BrushStyle brushStyle )
{
QwtPlotShapeItem* columnShape = new QwtPlotShapeItem( label );
QPolygonF polygon;
polygon.push_back( QPointF( startX, startY ) );
polygon.push_back( QPointF( endX, startY ) );
polygon.push_back( QPointF( endX, endY ) );
polygon.push_back( QPointF( startX, endY ) );
polygon.push_back( QPointF( startX, startY ) );
columnShape->setPolygon( polygon );
columnShape->setXAxis( QwtPlot::xBottom );
columnShape->setBrush( QBrush( color, brushStyle ) );
columnShape->setLegendMode( QwtPlotShapeItem::LegendShape );
columnShape->setLegendIconSize( QSize( 16, 16 ) );
return columnShape;
}