(#612) Added time history plot as a dockwidget

This commit is contained in:
Magne Sjaastad 2015-11-04 09:39:55 +01:00
parent 4388f39175
commit 30adb2661e
5 changed files with 218 additions and 12 deletions

View File

@ -90,6 +90,8 @@ set( USER_INTERFACE_FILES
UserInterface/RiuWellLogTrack.h
UserInterface/RiuProjectPropertyView.h
UserInterface/RiuProjectPropertyView.cpp
UserInterface/RiuTimeHistoryQwtPlot.h
UserInterface/RiuTimeHistoryQwtPlot.cpp
)
set( SOCKET_INTERFACE_FILES

View File

@ -58,6 +58,7 @@
#include "RiuProcessMonitor.h"
#include "RiuProjectPropertyView.h"
#include "RiuResultInfoPanel.h"
#include "RiuTimeHistoryQwtPlot.h"
#include "RiuTreeViewEventFilter.h"
#include "RiuViewer.h"
#include "RiuWellImportWizard.h"
@ -661,19 +662,15 @@ void RiuMainWindow::createDockPanels()
addDockWidget(Qt::BottomDockWidgetArea, dockPanel);
}
// Test - create well log viewer in a dock widget
// TODO: remove after making MDI widgets for well log viewers
// {
// QDockWidget* dockPanel = new QDockWidget("TEST - Well Log Viewer", this);
// dockPanel->setObjectName("dockWellLogViewer");
// dockPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);
//
// RiuWellLogViewer* wellLogViewer = new RiuWellLogViewer(dockPanel);
// dockPanel->setWidget(wellLogViewer);
//
// addDockWidget(Qt::BottomDockWidgetArea, dockPanel);
// }
{
QDockWidget* dockPanel = new QDockWidget("Time History Plot", this);
dockPanel->setObjectName("dockTimeHistoryPanel");
dockPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);
m_timeHistoryQwtPlot = new RiuTimeHistoryQwtPlot(dockPanel);
dockPanel->setWidget(m_timeHistoryQwtPlot);
addDockWidget(Qt::RightDockWidgetArea, dockPanel);
}
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea);

View File

@ -42,6 +42,7 @@ class RiuProcessMonitor;
class RiuResultInfoPanel;
class RiuViewer;
class RiuWellLogPlot;
class RiuTimeHistoryQwtPlot;
namespace caf
{
@ -198,6 +199,8 @@ private:
RiuResultInfoPanel* m_resultInfoPanel;
RiuProcessMonitor* m_processMonitor;
RiuTimeHistoryQwtPlot* m_timeHistoryQwtPlot;
QMenu* m_windowMenu;

View File

@ -0,0 +1,158 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiuTimeHistoryQwtPlot.h"
#include "cvfAssert.h"
#include "qwt_legend.h"
#include "qwt_plot_curve.h"
#include "qwt_plot_layout.h"
#include "qwt_scale_engine.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuTimeHistoryQwtPlot::RiuTimeHistoryQwtPlot(QWidget* parent)
: QwtPlot(parent)
{
/*
setFocusPolicy(Qt::ClickFocus);
*/
setDefaults();
std::vector<double> xValues;
std::vector<double> yValues;
xValues.push_back(1);
xValues.push_back(2);
xValues.push_back(3);
xValues.push_back(4);
yValues.push_back(10);
yValues.push_back(12);
yValues.push_back(15);
yValues.push_back(11);
addCurve("Test", xValues, yValues);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuTimeHistoryQwtPlot::~RiuTimeHistoryQwtPlot()
{
deleteAllCurves();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuTimeHistoryQwtPlot::addCurve(const QString& curveName, const std::vector<double>& xValues, const std::vector<double>& yValues)
{
CVF_ASSERT(xValues.size() == yValues.size());
QwtPlotCurve* plotCurve = new QwtPlotCurve("Curve 1");
plotCurve->setSamples(xValues.data(), yValues.data(), (int) xValues.size());
plotCurve->setTitle(curveName);
plotCurve->attach(this);
m_plotCurves.push_back(plotCurve);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuTimeHistoryQwtPlot::deleteAllCurves()
{
for (size_t i = 0; i < m_plotCurves.size(); i++)
{
m_plotCurves[i]->detach();
delete m_plotCurves[i];
}
m_plotCurves.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuTimeHistoryQwtPlot::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);
*/
enableAxis(QwtPlot::xTop, true);
enableAxis(QwtPlot::yLeft, true);
enableAxis(QwtPlot::xBottom, false);
enableAxis(QwtPlot::yRight, false);
plotLayout()->setAlignCanvasToScales(true);
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Inverted, true);
// 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);
setAxisScale(QwtPlot::yLeft, 1000, 0);
setAxisScale(QwtPlot::xTop, -10, 100);
QFont xAxisFont = axisFont(QwtPlot::xTop);
xAxisFont.setPixelSize(9);
setAxisFont(QwtPlot::xTop, 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);
// The legend will be deleted in the destructor of the plot or when
// another legend is inserted.
this->insertLegend(legend, BottomLegend);
}

View File

@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "qwt_plot.h"
class QwtPlotCurve;
//==================================================================================================
//
//
//
//==================================================================================================
class RiuTimeHistoryQwtPlot : public QwtPlot
{
public:
RiuTimeHistoryQwtPlot(QWidget* parent = NULL);
virtual ~RiuTimeHistoryQwtPlot();
void addCurve(const QString& curveName, const std::vector<double>& xValues, const std::vector<double>& yValues);
void deleteAllCurves();
private:
void setDefaults();
private:
std::vector<QwtPlotCurve*> m_plotCurves;
};