mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Preparations for #1321: Aligned default stuff between the plot types.
This commit is contained in:
parent
a82677c743
commit
c0ff734cc7
@ -23,12 +23,14 @@
|
|||||||
|
|
||||||
#include "qwt_plot_curve.h"
|
#include "qwt_plot_curve.h"
|
||||||
#include "qwt_date_scale_draw.h"
|
#include "qwt_date_scale_draw.h"
|
||||||
|
#include <QEvent>
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RiuQwtCurvePointTracker::RiuQwtCurvePointTracker(QwtPlot* plot, bool isMainAxisHorizontal): QwtPlotPicker(plot->canvas()), m_plot(plot), m_isMainAxisHorizontal(isMainAxisHorizontal)
|
RiuQwtCurvePointTracker::RiuQwtCurvePointTracker(QwtPlot* plot, bool isMainAxisHorizontal)
|
||||||
|
: QwtPlotPicker(plot->canvas()), m_plot(plot), m_isMainAxisHorizontal(isMainAxisHorizontal)
|
||||||
{
|
{
|
||||||
this->setTrackerMode(QwtPicker::AlwaysOn);
|
this->setTrackerMode(QwtPicker::AlwaysOn);
|
||||||
m_plotMarker = new QwtPlotMarker;
|
m_plotMarker = new QwtPlotMarker;
|
||||||
@ -60,6 +62,20 @@ void RiuQwtCurvePointTracker::removeMarkerOnFocusLeave()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RiuQwtCurvePointTracker::eventFilter(QObject *watched, QEvent *event)
|
||||||
|
{
|
||||||
|
if ( event->type() == QEvent::Leave )
|
||||||
|
{
|
||||||
|
this->removeMarkerOnFocusLeave();
|
||||||
|
}
|
||||||
|
|
||||||
|
// pass the event on to the parent class
|
||||||
|
return QwtPlotPicker::eventFilter(watched, event);
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -33,12 +33,20 @@ public:
|
|||||||
explicit RiuQwtCurvePointTracker(QwtPlot* plot, bool isMainAxisHorizontal);
|
explicit RiuQwtCurvePointTracker(QwtPlot* plot, bool isMainAxisHorizontal);
|
||||||
~RiuQwtCurvePointTracker();
|
~RiuQwtCurvePointTracker();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual bool eventFilter(QObject *, QEvent *) override;
|
||||||
void removeMarkerOnFocusLeave();
|
void removeMarkerOnFocusLeave();
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual QwtText trackerText(const QPoint& pos) const override;
|
virtual QwtText trackerText(const QPoint& pos) const override;
|
||||||
QPointF closestCurvePoint(const QPoint& cursorPosition, QString* valueAxisValueString, QString* mainAxisValueString, QwtPlot::Axis* relatedXAxis, QwtPlot::Axis* relatedYAxis) const;
|
QPointF closestCurvePoint(const QPoint& cursorPosition,
|
||||||
void updateClosestCurvePointMarker(const QPointF& closestPoint, QwtPlot::Axis relatedXAxis, QwtPlot::Axis relatedYAxis) const;
|
QString* valueAxisValueString,
|
||||||
|
QString* mainAxisValueString,
|
||||||
|
QwtPlot::Axis* relatedXAxis,
|
||||||
|
QwtPlot::Axis* relatedYAxis) const;
|
||||||
|
void updateClosestCurvePointMarker(const QPointF& closestPoint,
|
||||||
|
QwtPlot::Axis relatedXAxis,
|
||||||
|
QwtPlot::Axis relatedYAxis) const;
|
||||||
|
|
||||||
QPointer<QwtPlot> m_plot;
|
QPointer<QwtPlot> m_plot;
|
||||||
QwtPlotMarker* m_plotMarker;
|
QwtPlotMarker* m_plotMarker;
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
|
#include "RiuSummaryQwtPlot.h"
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -47,9 +48,6 @@
|
|||||||
RiuResultQwtPlot::RiuResultQwtPlot(QWidget* parent)
|
RiuResultQwtPlot::RiuResultQwtPlot(QWidget* parent)
|
||||||
: QwtPlot(parent)
|
: QwtPlot(parent)
|
||||||
{
|
{
|
||||||
m_grid = new QwtPlotGrid;
|
|
||||||
m_grid->attach(this);
|
|
||||||
|
|
||||||
setDefaults();
|
setDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,9 +57,6 @@ RiuResultQwtPlot::RiuResultQwtPlot(QWidget* parent)
|
|||||||
RiuResultQwtPlot::~RiuResultQwtPlot()
|
RiuResultQwtPlot::~RiuResultQwtPlot()
|
||||||
{
|
{
|
||||||
deleteAllCurves();
|
deleteAllCurves();
|
||||||
|
|
||||||
m_grid->detach();
|
|
||||||
delete m_grid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -152,59 +147,20 @@ void RiuResultQwtPlot::contextMenuEvent(QContextMenuEvent* event)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuResultQwtPlot::setDefaults()
|
void RiuResultQwtPlot::setDefaults()
|
||||||
{
|
{
|
||||||
QPalette newPalette(palette());
|
RiuSummaryQwtPlot::setCommonPlotBehaviour(this);
|
||||||
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);
|
|
||||||
|
|
||||||
enableAxis(QwtPlot::xBottom, true);
|
enableAxis(QwtPlot::xBottom, true);
|
||||||
enableAxis(QwtPlot::yLeft, true);
|
enableAxis(QwtPlot::yLeft, true);
|
||||||
enableAxis(QwtPlot::xTop, false);
|
enableAxis(QwtPlot::xTop, false);
|
||||||
enableAxis(QwtPlot::yRight, false);
|
enableAxis(QwtPlot::yRight, false);
|
||||||
|
|
||||||
plotLayout()->setAlignCanvasToScales(true);
|
RiuSummaryQwtPlot::enableDateBasedBottomXAxis(this);
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
|
|
||||||
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
|
// The legend will be deleted in the destructor of the plot or when
|
||||||
// another legend is inserted.
|
// another legend is inserted.
|
||||||
|
QwtLegend* legend = new QwtLegend(this);
|
||||||
this->insertLegend(legend, BottomLegend);
|
this->insertLegend(legend, BottomLegend);
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,5 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<QwtPlotCurve*> m_plotCurves;
|
std::vector<QwtPlotCurve*> m_plotCurves;
|
||||||
QwtPlotGrid* m_grid;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,6 +45,8 @@
|
|||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
|
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
#include "qwt_plot_magnifier.h"
|
||||||
|
#include "RiuQwtPlotWheelZoomer.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
@ -54,9 +56,6 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot(RimSummaryPlot* plotDefinition, QWidget* pa
|
|||||||
Q_ASSERT(plotDefinition);
|
Q_ASSERT(plotDefinition);
|
||||||
m_plotDefinition = plotDefinition;
|
m_plotDefinition = plotDefinition;
|
||||||
|
|
||||||
m_grid = new QwtPlotGrid;
|
|
||||||
m_grid->attach(this);
|
|
||||||
|
|
||||||
setDefaults();
|
setDefaults();
|
||||||
|
|
||||||
// LeftButton for the zooming
|
// LeftButton for the zooming
|
||||||
@ -85,9 +84,6 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot(RimSummaryPlot* plotDefinition, QWidget* pa
|
|||||||
RiuQwtScalePicker* scalePicker = new RiuQwtScalePicker(this);
|
RiuQwtScalePicker* scalePicker = new RiuQwtScalePicker(this);
|
||||||
connect(scalePicker, SIGNAL(clicked(int, double)), this, SLOT(onAxisClicked(int, double)));
|
connect(scalePicker, SIGNAL(clicked(int, double)), this, SLOT(onAxisClicked(int, double)));
|
||||||
|
|
||||||
// Create a plot picker to display values next to mouse cursor
|
|
||||||
m_curvePointTracker = new RiuQwtCurvePointTracker(this, true);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -95,15 +91,11 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot(RimSummaryPlot* plotDefinition, QWidget* pa
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RiuSummaryQwtPlot::~RiuSummaryQwtPlot()
|
RiuSummaryQwtPlot::~RiuSummaryQwtPlot()
|
||||||
{
|
{
|
||||||
m_grid->detach();
|
|
||||||
delete m_grid;
|
|
||||||
|
|
||||||
if (m_plotDefinition)
|
if (m_plotDefinition)
|
||||||
{
|
{
|
||||||
m_plotDefinition->detachAllCurves();
|
m_plotDefinition->detachAllCurves();
|
||||||
m_plotDefinition->handleMdiWindowClosed();
|
m_plotDefinition->handleMdiWindowClosed();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -191,71 +183,99 @@ QSize RiuSummaryQwtPlot::sizeHint() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuSummaryQwtPlot::setDefaults()
|
void RiuSummaryQwtPlot::setDefaults()
|
||||||
{
|
{
|
||||||
QPalette newPalette(palette());
|
setCommonPlotBehaviour(this);
|
||||||
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);
|
|
||||||
|
|
||||||
enableAxis(QwtPlot::xBottom, true);
|
enableAxis(QwtPlot::xBottom, true);
|
||||||
enableAxis(QwtPlot::yLeft, true);
|
enableAxis(QwtPlot::yLeft, true);
|
||||||
enableAxis(QwtPlot::xTop, false);
|
enableAxis(QwtPlot::xTop, false);
|
||||||
enableAxis(QwtPlot::yRight, false);
|
enableAxis(QwtPlot::yRight, false);
|
||||||
|
|
||||||
plotLayout()->setAlignCanvasToScales(true);
|
|
||||||
|
|
||||||
useDateBasedTimeAxis();
|
useDateBasedTimeAxis();
|
||||||
|
|
||||||
QFont xAxisFont = axisFont(QwtPlot::xBottom);
|
|
||||||
xAxisFont.setPixelSize(11);
|
|
||||||
setAxisFont(QwtPlot::xBottom, xAxisFont);
|
|
||||||
setAxisMaxMinor(QwtPlot::xBottom, 2);
|
setAxisMaxMinor(QwtPlot::xBottom, 2);
|
||||||
|
|
||||||
QFont yAxisFont = axisFont(QwtPlot::yLeft);
|
|
||||||
yAxisFont.setPixelSize(11);
|
|
||||||
setAxisFont(QwtPlot::yLeft, yAxisFont);
|
|
||||||
|
|
||||||
setAxisMaxMinor(QwtPlot::yLeft, 3);
|
setAxisMaxMinor(QwtPlot::yLeft, 3);
|
||||||
|
|
||||||
QwtText axisTitleY = axisTitle(QwtPlot::yLeft);
|
|
||||||
QFont yAxisTitleFont = axisTitleY.font();
|
|
||||||
yAxisTitleFont.setPixelSize(11);
|
|
||||||
yAxisTitleFont.setBold(false);
|
|
||||||
axisTitleY.setFont(yAxisTitleFont);
|
|
||||||
axisTitleY.setRenderFlags(Qt::AlignRight);
|
|
||||||
setAxisTitle(QwtPlot::yLeft, axisTitleY);
|
|
||||||
|
|
||||||
QwtLegend* legend = new QwtLegend(this);
|
|
||||||
// The legend will be deleted in the destructor of the plot or when
|
// The legend will be deleted in the destructor of the plot or when
|
||||||
// another legend is inserted.
|
// another legend is inserted.
|
||||||
|
QwtLegend* legend = new QwtLegend(this);
|
||||||
this->insertLegend(legend, BottomLegend);
|
this->insertLegend(legend, BottomLegend);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RiuSummaryQwtPlot::setCommonPlotBehaviour(QwtPlot* plot)
|
||||||
|
{
|
||||||
|
// Plot background and frame look
|
||||||
|
|
||||||
|
QPalette newPalette(plot->palette());
|
||||||
|
newPalette.setColor(QPalette::Background, Qt::white);
|
||||||
|
plot->setPalette(newPalette);
|
||||||
|
|
||||||
|
plot->setAutoFillBackground(true);
|
||||||
|
plot->setCanvasBackground(Qt::white);
|
||||||
|
|
||||||
|
QFrame* canvasFrame = dynamic_cast<QFrame*>(plot->canvas());
|
||||||
|
if (canvasFrame)
|
||||||
|
{
|
||||||
|
canvasFrame->setFrameShape(QFrame::NoFrame);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Grid
|
||||||
|
|
||||||
|
QwtPlotGrid* grid = new QwtPlotGrid;
|
||||||
|
grid->attach(plot);
|
||||||
|
QPen gridPen(Qt::SolidLine);
|
||||||
|
gridPen.setColor(Qt::lightGray);
|
||||||
|
grid->setPen(gridPen);
|
||||||
|
|
||||||
|
// Axis number font
|
||||||
|
QFont axisFont = plot->axisFont(QwtPlot::xBottom);
|
||||||
|
axisFont.setPixelSize(11);
|
||||||
|
|
||||||
|
plot->setAxisFont(QwtPlot::xBottom, axisFont);
|
||||||
|
plot->setAxisFont(QwtPlot::xTop, axisFont);
|
||||||
|
plot->setAxisFont(QwtPlot::yLeft, axisFont);
|
||||||
|
plot->setAxisFont(QwtPlot::yRight, axisFont);
|
||||||
|
|
||||||
|
// Axis title font
|
||||||
|
QwtText axisTitle = plot->axisTitle(QwtPlot::xBottom);
|
||||||
|
QFont axisTitleFont = axisTitle.font();
|
||||||
|
axisTitleFont.setPixelSize(11);
|
||||||
|
axisTitleFont.setBold(false);
|
||||||
|
axisTitle.setFont(axisTitleFont);
|
||||||
|
axisTitle.setRenderFlags(Qt::AlignRight);
|
||||||
|
|
||||||
|
plot->setAxisTitle(QwtPlot::xBottom, axisTitle);
|
||||||
|
plot->setAxisTitle(QwtPlot::xTop, axisTitle);
|
||||||
|
plot->setAxisTitle(QwtPlot::yLeft, axisTitle);
|
||||||
|
plot->setAxisTitle(QwtPlot::yRight, axisTitle);
|
||||||
|
|
||||||
|
// Enable mousetracking and event filter
|
||||||
|
|
||||||
|
plot->canvas()->setMouseTracking(true);
|
||||||
|
plot->canvas()->installEventFilter(plot);
|
||||||
|
plot->plotLayout()->setAlignCanvasToScales(true);
|
||||||
|
|
||||||
|
new RiuQwtCurvePointTracker(plot, true);
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuSummaryQwtPlot::useDateBasedTimeAxis()
|
void RiuSummaryQwtPlot::useDateBasedTimeAxis()
|
||||||
|
{
|
||||||
|
enableDateBasedBottomXAxis(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuSummaryQwtPlot::enableDateBasedBottomXAxis(QwtPlot* plot)
|
||||||
{
|
{
|
||||||
QwtDateScaleDraw* scaleDraw = new QwtDateScaleDraw(Qt::UTC);
|
QwtDateScaleDraw* scaleDraw = new QwtDateScaleDraw(Qt::UTC);
|
||||||
scaleDraw->setDateFormat(QwtDate::Year, QString("dd-MM-yyyy"));
|
scaleDraw->setDateFormat(QwtDate::Year, QString("dd-MM-yyyy"));
|
||||||
|
|
||||||
QwtDateScaleEngine* scaleEngine = new QwtDateScaleEngine(Qt::UTC);
|
QwtDateScaleEngine* scaleEngine = new QwtDateScaleEngine(Qt::UTC);
|
||||||
setAxisScaleEngine(QwtPlot::xBottom, scaleEngine);
|
plot->setAxisScaleEngine(QwtPlot::xBottom, scaleEngine);
|
||||||
setAxisScaleDraw(QwtPlot::xBottom, scaleDraw);
|
plot->setAxisScaleDraw(QwtPlot::xBottom, scaleDraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -288,13 +308,6 @@ bool RiuSummaryQwtPlot::eventFilter(QObject* watched, QEvent* event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RiuSummaryQwtPlot::leaveEvent(QEvent *)
|
|
||||||
{
|
|
||||||
m_curvePointTracker->removeMarkerOnFocusLeave();
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
@ -335,11 +348,6 @@ void RiuSummaryQwtPlot::selectClosestCurve(const QPoint& pos)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuSummaryQwtPlot::onZoomedSlot()
|
void RiuSummaryQwtPlot::onZoomedSlot()
|
||||||
{
|
{
|
||||||
QwtInterval left, right, time;
|
|
||||||
currentVisibleWindow(&left, &right, &time);
|
|
||||||
|
|
||||||
this->setZoomWindow(left, right, time);
|
|
||||||
|
|
||||||
m_plotDefinition->updateZoomWindowFromQwt();
|
m_plotDefinition->updateZoomWindowFromQwt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,9 +58,11 @@ public:
|
|||||||
const QwtInterval& rightAxis,
|
const QwtInterval& rightAxis,
|
||||||
const QwtInterval& timeAxis);
|
const QwtInterval& timeAxis);
|
||||||
|
|
||||||
|
static void setCommonPlotBehaviour(QwtPlot* plot);
|
||||||
|
static void enableDateBasedBottomXAxis(QwtPlot* plot);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool eventFilter(QObject* watched, QEvent* event) override;
|
virtual bool eventFilter(QObject* watched, QEvent* event) override;
|
||||||
virtual void leaveEvent(QEvent *) override;
|
|
||||||
|
|
||||||
virtual QSize sizeHint() const override;
|
virtual QSize sizeHint() const override;
|
||||||
virtual QSize minimumSizeHint() const override;
|
virtual QSize minimumSizeHint() const override;
|
||||||
@ -76,7 +78,6 @@ private slots:
|
|||||||
void onAxisClicked(int axis, double value);
|
void onAxisClicked(int axis, double value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QwtPlotGrid* m_grid;
|
|
||||||
RiuQwtCurvePointTracker* m_curvePointTracker;
|
RiuQwtCurvePointTracker* m_curvePointTracker;
|
||||||
|
|
||||||
caf::PdmPointer<RimSummaryPlot> m_plotDefinition;
|
caf::PdmPointer<RimSummaryPlot> m_plotDefinition;
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
|
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
#include "RiuSummaryQwtPlot.h"
|
||||||
|
|
||||||
#define RIU_SCROLLWHEEL_ZOOMFACTOR 1.1
|
#define RIU_SCROLLWHEEL_ZOOMFACTOR 1.1
|
||||||
#define RIU_SCROLLWHEEL_PANFACTOR 0.1
|
#define RIU_SCROLLWHEEL_PANFACTOR 0.1
|
||||||
@ -57,16 +58,9 @@ RiuWellLogTrack::RiuWellLogTrack(RimWellLogTrack* plotTrackDefinition, QWidget*
|
|||||||
{
|
{
|
||||||
Q_ASSERT(plotTrackDefinition);
|
Q_ASSERT(plotTrackDefinition);
|
||||||
m_plotTrackDefinition = plotTrackDefinition;
|
m_plotTrackDefinition = plotTrackDefinition;
|
||||||
|
|
||||||
m_grid = new QwtPlotGrid();
|
|
||||||
m_grid->attach(this);
|
|
||||||
|
|
||||||
setFocusPolicy(Qt::ClickFocus);
|
setFocusPolicy(Qt::ClickFocus);
|
||||||
setDefaults();
|
setDefaults();
|
||||||
|
|
||||||
// Create a plot picker to display values next to mouse cursor
|
|
||||||
|
|
||||||
m_curvePointTracker = new RiuQwtCurvePointTracker(this, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -74,8 +68,7 @@ RiuWellLogTrack::RiuWellLogTrack(RimWellLogTrack* plotTrackDefinition, QWidget*
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RiuWellLogTrack::~RiuWellLogTrack()
|
RiuWellLogTrack::~RiuWellLogTrack()
|
||||||
{
|
{
|
||||||
m_grid->detach();
|
|
||||||
delete m_grid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -84,33 +77,13 @@ RiuWellLogTrack::~RiuWellLogTrack()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuWellLogTrack::setDefaults()
|
void RiuWellLogTrack::setDefaults()
|
||||||
{
|
{
|
||||||
QPalette newPalette(palette());
|
RiuSummaryQwtPlot::setCommonPlotBehaviour(this);
|
||||||
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);
|
|
||||||
|
|
||||||
enableAxis(QwtPlot::xTop, true);
|
enableAxis(QwtPlot::xTop, true);
|
||||||
enableAxis(QwtPlot::yLeft, true);
|
enableAxis(QwtPlot::yLeft, true);
|
||||||
enableAxis(QwtPlot::xBottom, false);
|
enableAxis(QwtPlot::xBottom, false);
|
||||||
enableAxis(QwtPlot::yRight, false);
|
enableAxis(QwtPlot::yRight, false);
|
||||||
|
|
||||||
plotLayout()->setAlignCanvasToScales(true);
|
|
||||||
|
|
||||||
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Inverted, true);
|
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Inverted, true);
|
||||||
|
|
||||||
// Align the canvas with the actual min and max values of the curves
|
// Align the canvas with the actual min and max values of the curves
|
||||||
@ -119,28 +92,6 @@ void RiuWellLogTrack::setDefaults()
|
|||||||
setAxisScale(QwtPlot::yLeft, 1000, 0);
|
setAxisScale(QwtPlot::yLeft, 1000, 0);
|
||||||
setAxisScale(QwtPlot::xTop, -10, 100);
|
setAxisScale(QwtPlot::xTop, -10, 100);
|
||||||
|
|
||||||
QFont xAxisFont = axisFont(QwtPlot::xTop);
|
|
||||||
xAxisFont.setPixelSize(9);
|
|
||||||
setAxisFont(QwtPlot::xTop, xAxisFont);
|
|
||||||
QwtText axisTitleX = axisTitle(QwtPlot::yLeft);
|
|
||||||
QFont xAxisTitleFont = axisTitleX.font();
|
|
||||||
xAxisTitleFont.setPixelSize(9);
|
|
||||||
xAxisTitleFont.setBold(false);
|
|
||||||
axisTitleX.setFont(xAxisTitleFont);
|
|
||||||
axisTitleX.setRenderFlags(Qt::AlignRight);
|
|
||||||
setAxisTitle(QwtPlot::xTop, axisTitleX);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -303,13 +254,6 @@ QSize RiuWellLogTrack::minimumSizeHint() const
|
|||||||
return QSize(0, 0);
|
return QSize(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RiuWellLogTrack::leaveEvent(QEvent *)
|
|
||||||
{
|
|
||||||
m_curvePointTracker->removeMarkerOnFocusLeave();
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
|
@ -60,7 +60,6 @@ protected:
|
|||||||
virtual void focusInEvent(QFocusEvent* event);
|
virtual void focusInEvent(QFocusEvent* event);
|
||||||
virtual QSize sizeHint() const;
|
virtual QSize sizeHint() const;
|
||||||
virtual QSize minimumSizeHint() const;
|
virtual QSize minimumSizeHint() const;
|
||||||
virtual void leaveEvent(QEvent *) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setDefaults();
|
void setDefaults();
|
||||||
@ -68,7 +67,6 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
caf::PdmPointer<RimWellLogTrack> m_plotTrackDefinition;
|
caf::PdmPointer<RimWellLogTrack> m_plotTrackDefinition;
|
||||||
QwtPlotGrid* m_grid;
|
|
||||||
RiuQwtCurvePointTracker* m_curvePointTracker;
|
RiuQwtCurvePointTracker* m_curvePointTracker;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user