ResInsight/ApplicationCode/UserInterface/RiuWellLogTracePlot.cpp
Pål Hagen f186e07742 (#396) Added simple zoom functionality for the depth axis
Ctrl + scroll wheel = zoom around center. Consider making a more
specialized zoom functionality for zooming around mouse cursor, and with
synchronization with other trace plots.
2015-08-31 14:47:34 +02:00

84 lines
2.8 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// 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"
#include "qwt_plot_grid.h"
#include "qwt_scale_engine.h"
#include "qwt_plot_magnifier.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuWellLogTracePlot::RiuWellLogTracePlot(QWidget* parent)
: QwtPlot(parent)
{
m_grid = new QwtPlotGrid();
m_grid->attach(this);
QwtPlotMagnifier* magnifierDepth = new QwtPlotMagnifier(canvas());
magnifierDepth->setWheelModifiers(Qt::ControlModifier);
magnifierDepth->setAxisEnabled(QwtPlot::yLeft, true);
magnifierDepth->setAxisEnabled(QwtPlot::yRight, false);
magnifierDepth->setAxisEnabled(QwtPlot::xTop, false);
magnifierDepth->setAxisEnabled(QwtPlot::xBottom, false);
setDefaults();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuWellLogTracePlot::~RiuWellLogTracePlot()
{
m_grid->detach();
delete m_grid;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogTracePlot::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);
}
QPen gridPen(Qt::SolidLine);
gridPen.setColor(Qt::lightGray);
m_grid->setPen(gridPen);
enableAxis(QwtPlot::xTop, true);
enableAxis(QwtPlot::yLeft, true);
enableAxis(QwtPlot::xBottom, false);
enableAxis(QwtPlot::yRight, false);
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Inverted, true);
}