2015-08-28 07:25:14 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
|
|
|
//
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RiuWellLogTracePlot.h"
|
|
|
|
|
2015-09-04 08:57:34 -05:00
|
|
|
#include "RimWellLogPlot.h"
|
|
|
|
#include "RimWellLogPlotTrace.h"
|
|
|
|
|
2015-08-31 04:39:59 -05:00
|
|
|
#include "qwt_plot_grid.h"
|
2015-08-31 08:23:20 -05:00
|
|
|
#include "qwt_legend.h"
|
2015-08-31 05:45:28 -05:00
|
|
|
#include "qwt_scale_engine.h"
|
2015-09-01 08:48:53 -05:00
|
|
|
#include "qwt_plot_layout.h"
|
2015-08-31 04:39:59 -05:00
|
|
|
|
2015-09-04 08:57:34 -05:00
|
|
|
#include <QWheelEvent>
|
2015-09-04 10:11:16 -05:00
|
|
|
#include <QFont>
|
2015-09-04 08:57:34 -05:00
|
|
|
|
|
|
|
#define RIU_SCROLLWHEEL_ZOOMFACTOR 1.1
|
|
|
|
#define RIU_SCROLLWHEEL_PANFACTOR 0.1
|
|
|
|
|
2015-08-28 07:25:14 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-09-04 08:57:34 -05:00
|
|
|
RiuWellLogTracePlot::RiuWellLogTracePlot(RimWellLogPlotTrace* plotTraceDefinition, QWidget* parent)
|
2015-08-28 07:25:14 -05:00
|
|
|
: QwtPlot(parent)
|
|
|
|
{
|
2015-09-04 08:57:34 -05:00
|
|
|
Q_ASSERT(plotTraceDefinition);
|
|
|
|
m_plotTraceDefinition = plotTraceDefinition;
|
|
|
|
|
2015-08-31 04:39:59 -05:00
|
|
|
m_grid = new QwtPlotGrid();
|
|
|
|
m_grid->attach(this);
|
|
|
|
|
2015-08-31 08:23:20 -05:00
|
|
|
m_legend = new QwtLegend(this);
|
|
|
|
insertLegend(m_legend, QwtPlot::TopLegend);
|
2015-08-31 07:54:48 -05:00
|
|
|
|
2015-08-31 02:34:41 -05:00
|
|
|
setDefaults();
|
2015-08-28 07:25:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RiuWellLogTracePlot::~RiuWellLogTracePlot()
|
|
|
|
{
|
2015-08-31 04:39:59 -05:00
|
|
|
m_grid->detach();
|
|
|
|
delete m_grid;
|
2015-08-28 07:25:14 -05:00
|
|
|
}
|
2015-08-31 02:34:41 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuWellLogTracePlot::setDefaults()
|
|
|
|
{
|
|
|
|
QPalette newPalette(palette());
|
|
|
|
newPalette.setColor(QPalette::Background, Qt::white);
|
|
|
|
setPalette(newPalette);
|
|
|
|
|
|
|
|
setAutoFillBackground(true);
|
|
|
|
setCanvasBackground(Qt::white);
|
2015-08-31 02:42:29 -05:00
|
|
|
|
|
|
|
QFrame* canvasFrame = dynamic_cast<QFrame*>(canvas());
|
|
|
|
if (canvasFrame)
|
|
|
|
{
|
|
|
|
canvasFrame->setFrameShape(QFrame::NoFrame);
|
|
|
|
}
|
2015-08-31 04:39:59 -05:00
|
|
|
|
2015-09-04 08:57:34 -05:00
|
|
|
canvas()->setMouseTracking(true);
|
|
|
|
canvas()->installEventFilter(this);
|
|
|
|
|
2015-08-31 04:39:59 -05:00
|
|
|
QPen gridPen(Qt::SolidLine);
|
|
|
|
gridPen.setColor(Qt::lightGray);
|
|
|
|
m_grid->setPen(gridPen);
|
2015-08-31 05:34:08 -05:00
|
|
|
|
|
|
|
enableAxis(QwtPlot::xTop, true);
|
|
|
|
enableAxis(QwtPlot::yLeft, true);
|
|
|
|
enableAxis(QwtPlot::xBottom, false);
|
|
|
|
enableAxis(QwtPlot::yRight, false);
|
2015-08-31 05:45:28 -05:00
|
|
|
|
2015-09-01 08:48:53 -05:00
|
|
|
plotLayout()->setAlignCanvasToScales(true);
|
|
|
|
|
2015-08-31 05:45:28 -05:00
|
|
|
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Inverted, true);
|
2015-09-02 09:41:12 -05:00
|
|
|
|
|
|
|
// Align the canvas with the actual min and max values of the curves
|
|
|
|
axisScaleEngine(QwtPlot::xTop)->setAttribute(QwtScaleEngine::Floating, true);
|
|
|
|
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating, true);
|
2015-09-03 04:55:24 -05:00
|
|
|
setAxisScale(QwtPlot::yLeft, 1000, 0);
|
|
|
|
setAxisScale(QwtPlot::xTop, -10, 100);
|
2015-09-03 07:21:08 -05:00
|
|
|
|
|
|
|
setAxisAutoScale(QwtPlot::xTop, true);
|
2015-09-04 10:11:16 -05:00
|
|
|
|
|
|
|
QFont xAxisFont = axisFont(QwtPlot::xTop);
|
|
|
|
xAxisFont.setPixelSize(9);
|
|
|
|
setAxisFont(QwtPlot::xTop, xAxisFont);
|
|
|
|
|
|
|
|
QFont yAxisFont = axisFont(QwtPlot::yLeft);
|
|
|
|
yAxisFont.setPixelSize(9);
|
|
|
|
setAxisFont(QwtPlot::yLeft, yAxisFont);
|
2015-08-31 02:34:41 -05:00
|
|
|
}
|
2015-08-31 10:21:21 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RiuWellLogTracePlot::setDepthRange(double minDepth, double maxDepth)
|
|
|
|
{
|
|
|
|
// Note: Y-axis is inverted
|
|
|
|
setAxisScale(QwtPlot::yLeft, maxDepth, minDepth);
|
2015-09-07 11:00:04 -05:00
|
|
|
//replot();
|
2015-08-31 10:21:21 -05:00
|
|
|
}
|
2015-09-04 08:57:34 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RiuWellLogTracePlot::eventFilter(QObject* watched, QEvent* event)
|
|
|
|
{
|
|
|
|
if (watched == canvas())
|
|
|
|
{
|
|
|
|
QWheelEvent* wheelEvent = dynamic_cast<QWheelEvent*>(event);
|
|
|
|
if (wheelEvent)
|
|
|
|
{
|
|
|
|
if (!m_plotTraceDefinition)
|
|
|
|
{
|
|
|
|
return QwtPlot::eventFilter(watched, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
RimWellLogPlot* plotDefinition;
|
|
|
|
m_plotTraceDefinition->firstAnchestorOrThisOfType(plotDefinition);
|
|
|
|
if (!plotDefinition)
|
|
|
|
{
|
|
|
|
return QwtPlot::eventFilter(watched, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wheelEvent->modifiers() & Qt::ControlModifier)
|
|
|
|
{
|
|
|
|
QwtScaleMap scaleMap = canvasMap(QwtPlot::yLeft);
|
|
|
|
double zoomCenter = scaleMap.invTransform(wheelEvent->pos().y());
|
|
|
|
|
|
|
|
if (wheelEvent->delta() > 0)
|
|
|
|
{
|
|
|
|
plotDefinition->zoomDepth(RIU_SCROLLWHEEL_ZOOMFACTOR, zoomCenter);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
plotDefinition->zoomDepth(1.0/RIU_SCROLLWHEEL_ZOOMFACTOR, zoomCenter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
plotDefinition->panDepth(wheelEvent->delta() < 0 ? RIU_SCROLLWHEEL_PANFACTOR : -RIU_SCROLLWHEEL_PANFACTOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
event->accept();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return QwtPlot::eventFilter(watched, event);
|
|
|
|
}
|