Preparations for #1321: Aligned default stuff between the plot types.

This commit is contained in:
Jacob Støren
2017-03-27 16:47:59 +02:00
parent a82677c743
commit c0ff734cc7
8 changed files with 111 additions and 181 deletions

View File

@@ -39,6 +39,7 @@
#include <QMenu>
#include <QContextMenuEvent>
#include "RiuSummaryQwtPlot.h"
//--------------------------------------------------------------------------------------------------
@@ -47,9 +48,6 @@
RiuResultQwtPlot::RiuResultQwtPlot(QWidget* parent)
: QwtPlot(parent)
{
m_grid = new QwtPlotGrid;
m_grid->attach(this);
setDefaults();
}
@@ -59,9 +57,6 @@ RiuResultQwtPlot::RiuResultQwtPlot(QWidget* parent)
RiuResultQwtPlot::~RiuResultQwtPlot()
{
deleteAllCurves();
m_grid->detach();
delete m_grid;
}
//--------------------------------------------------------------------------------------------------
@@ -152,59 +147,20 @@ void RiuResultQwtPlot::contextMenuEvent(QContextMenuEvent* event)
//--------------------------------------------------------------------------------------------------
void RiuResultQwtPlot::setDefaults()
{
QPalette newPalette(palette());
newPalette.setColor(QPalette::Background, Qt::white);
setPalette(newPalette);
setAutoFillBackground(true);
setCanvasBackground(Qt::white);
QFrame* canvasFrame = dynamic_cast<QFrame*>(canvas());
if (canvasFrame)
{
canvasFrame->setFrameShape(QFrame::NoFrame);
}
canvas()->setMouseTracking(true);
canvas()->installEventFilter(this);
QPen gridPen(Qt::SolidLine);
gridPen.setColor(Qt::lightGray);
m_grid->setPen(gridPen);
RiuSummaryQwtPlot::setCommonPlotBehaviour(this);
enableAxis(QwtPlot::xBottom, true);
enableAxis(QwtPlot::yLeft, true);
enableAxis(QwtPlot::xTop, false);
enableAxis(QwtPlot::yRight, false);
plotLayout()->setAlignCanvasToScales(true);
QwtDateScaleDraw* scaleDraw = new QwtDateScaleDraw(Qt::UTC);
scaleDraw->setDateFormat(QwtDate::Year, QString("dd-MM-yyyy"));
QwtDateScaleEngine* scaleEngine = new QwtDateScaleEngine(Qt::UTC);
setAxisScaleEngine(QwtPlot::xBottom, scaleEngine);
setAxisScaleDraw(QwtPlot::xBottom, scaleDraw);
QFont xAxisFont = axisFont(QwtPlot::xBottom);
xAxisFont.setPixelSize(9);
setAxisFont(QwtPlot::xBottom, xAxisFont);
QFont yAxisFont = axisFont(QwtPlot::yLeft);
yAxisFont.setPixelSize(9);
setAxisFont(QwtPlot::yLeft, yAxisFont);
QwtText axisTitleY = axisTitle(QwtPlot::yLeft);
QFont yAxisTitleFont = axisTitleY.font();
yAxisTitleFont.setPixelSize(9);
yAxisTitleFont.setBold(false);
axisTitleY.setFont(yAxisTitleFont);
axisTitleY.setRenderFlags(Qt::AlignRight);
setAxisTitle(QwtPlot::yLeft, axisTitleY);
RiuSummaryQwtPlot::enableDateBasedBottomXAxis(this);
QwtLegend* legend = new QwtLegend(this);
setAxisMaxMinor(QwtPlot::xBottom, 2);
setAxisMaxMinor(QwtPlot::yLeft, 3);
// The legend will be deleted in the destructor of the plot or when
// another legend is inserted.
QwtLegend* legend = new QwtLegend(this);
this->insertLegend(legend, BottomLegend);
}