mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#612) Time history result accessor and display of curve from selection
This commit is contained in:
parent
30adb2661e
commit
0011f090de
@ -37,6 +37,7 @@ ${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.h
|
||||
${CEE_CURRENT_LIST_DIR}RigEclipseNativeStatCalc.h
|
||||
${CEE_CURRENT_LIST_DIR}RigEclipseMultiPropertyStatCalc.h
|
||||
${CEE_CURRENT_LIST_DIR}RigWellLogCurveData.h
|
||||
${CEE_CURRENT_LIST_DIR}RigTimeHistoryResultAccessor.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@ -68,6 +69,7 @@ ${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigEclipseNativeStatCalc.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigEclipseMultiPropertyStatCalc.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigWellLogCurveData.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigTimeHistoryResultAccessor.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -0,0 +1,118 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA
|
||||
// Copyright (C) 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 "RigTimeHistoryResultAccessor.h"
|
||||
|
||||
#include <cmath> // Needed for HUGE_VAL on Linux
|
||||
|
||||
#include "RigCaseData.h"
|
||||
#include "RigResultAccessor.h"
|
||||
#include "RigResultAccessorFactory.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigTimeHistoryResultAccessor::RigTimeHistoryResultAccessor(RigCaseData* eclipseCaseData, size_t gridIndex, size_t cellIndex, size_t scalarResultIndex, RifReaderInterface::PorosityModelResultType porosityModel)
|
||||
: m_eclipseCaseData(eclipseCaseData),
|
||||
m_gridIndex(gridIndex),
|
||||
m_cellIndex(cellIndex),
|
||||
m_scalarResultIndex(scalarResultIndex),
|
||||
m_porosityModel(porosityModel)
|
||||
{
|
||||
m_face = cvf::StructGridInterface::NO_FACE;
|
||||
m_nncIndex = cvf::UNDEFINED_SIZE_T;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigTimeHistoryResultAccessor::setFace(cvf::StructGridInterface::FaceType face)
|
||||
{
|
||||
m_face = face;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigTimeHistoryResultAccessor::setNncIndex(size_t nncIndex)
|
||||
{
|
||||
m_nncIndex = nncIndex;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RigTimeHistoryResultAccessor::yValues() const
|
||||
{
|
||||
return m_yValues;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RigTimeHistoryResultAccessor::topologyText()
|
||||
{
|
||||
QString text;
|
||||
|
||||
if (m_eclipseCaseData)
|
||||
{
|
||||
if (m_cellIndex != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
size_t i = 0;
|
||||
size_t j = 0;
|
||||
size_t k = 0;
|
||||
if (m_eclipseCaseData->grid(m_gridIndex)->ijkFromCellIndex(m_cellIndex, &i, &j, &k))
|
||||
{
|
||||
// Adjust to 1-based Eclipse indexing
|
||||
i++;
|
||||
j++;
|
||||
k++;
|
||||
|
||||
cvf::StructGridInterface::FaceEnum faceEnum(m_face);
|
||||
|
||||
text += QString("Cell : [%1, %2, %3]").arg(i).arg(j).arg(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigTimeHistoryResultAccessor::computeCurveData()
|
||||
{
|
||||
if (m_yValues.size() != 0) return;
|
||||
|
||||
if (m_eclipseCaseData)
|
||||
{
|
||||
size_t timeStepCount = m_eclipseCaseData->results(m_porosityModel)->timeStepCount(m_scalarResultIndex);
|
||||
|
||||
for (size_t i = 0; i < timeStepCount; i++)
|
||||
{
|
||||
cvf::ref<RigResultAccessor> resultAccessor = RigResultAccessorFactory::createResultAccessor(m_eclipseCaseData, m_gridIndex, m_porosityModel, i, m_scalarResultIndex);
|
||||
|
||||
m_yValues.push_back(resultAccessor->cellScalar(m_cellIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,58 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA
|
||||
// Copyright (C) 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 "cvfStructGrid.h"
|
||||
#include "RifReaderInterface.h"
|
||||
|
||||
class RigCaseData;
|
||||
|
||||
|
||||
class RigTimeHistoryResultAccessor
|
||||
{
|
||||
public:
|
||||
RigTimeHistoryResultAccessor(RigCaseData* eclipseCaseData, size_t gridIndex, size_t cellIndex, size_t scalarResultIndex, RifReaderInterface::PorosityModelResultType porosityModel);
|
||||
|
||||
void setFace(cvf::StructGridInterface::FaceType face);
|
||||
void setNncIndex(size_t nncIndex);
|
||||
|
||||
void computeCurveData();
|
||||
QString topologyText();
|
||||
|
||||
QString curveName() const;
|
||||
std::vector<double> yValues() const;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
private:
|
||||
RigCaseData* m_eclipseCaseData;
|
||||
|
||||
size_t m_gridIndex;
|
||||
size_t m_cellIndex;
|
||||
size_t m_nncIndex;
|
||||
size_t m_scalarResultIndex;
|
||||
|
||||
cvf::StructGridInterface::FaceType m_face;
|
||||
RifReaderInterface::PorosityModelResultType m_porosityModel;
|
||||
|
||||
std::vector<double> m_yValues;
|
||||
};
|
||||
|
@ -1165,6 +1165,14 @@ QMdiSubWindow* RiuMainWindow::findMdiSubWindow(QWidget* viewer)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuTimeHistoryQwtPlot* RiuMainWindow::timeHistoryPlot()
|
||||
{
|
||||
return m_timeHistoryQwtPlot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -113,6 +113,8 @@ public:
|
||||
bool isAnyMdiSubWindowVisible();
|
||||
QMdiSubWindow* findMdiSubWindow(QWidget* viewer);
|
||||
|
||||
RiuTimeHistoryQwtPlot* timeHistoryPlot();
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent* event);
|
||||
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "qwt_plot_curve.h"
|
||||
#include "qwt_plot_layout.h"
|
||||
#include "qwt_scale_engine.h"
|
||||
#include "qwt_date_scale_draw.h"
|
||||
#include "qwt_date_scale_engine.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -32,25 +34,7 @@
|
||||
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);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -64,16 +48,28 @@ RiuTimeHistoryQwtPlot::~RiuTimeHistoryQwtPlot()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuTimeHistoryQwtPlot::addCurve(const QString& curveName, const std::vector<double>& xValues, const std::vector<double>& yValues)
|
||||
void RiuTimeHistoryQwtPlot::addCurve(const QString& curveName, const std::vector<QDateTime>& dateTimes, const std::vector<double>& yValues)
|
||||
{
|
||||
CVF_ASSERT(xValues.size() == yValues.size());
|
||||
CVF_ASSERT(dateTimes.size() == yValues.size());
|
||||
|
||||
QwtPlotCurve* plotCurve = new QwtPlotCurve("Curve 1");
|
||||
plotCurve->setSamples(xValues.data(), yValues.data(), (int) xValues.size());
|
||||
|
||||
QPolygonF points;
|
||||
for (int i = 0; i < dateTimes.size(); i++)
|
||||
{
|
||||
double milliSecSinceEpoch = QwtDate::toDouble(dateTimes[i]);
|
||||
points << QPointF(milliSecSinceEpoch, yValues[i]);
|
||||
}
|
||||
|
||||
plotCurve->setSamples(points);
|
||||
plotCurve->setTitle(curveName);
|
||||
|
||||
plotCurve->attach(this);
|
||||
m_plotCurves.push_back(plotCurve);
|
||||
|
||||
this->setAxisScale( QwtPlot::xTop, QwtDate::toDouble(dateTimes.front()), QwtDate::toDouble(dateTimes.back()));
|
||||
|
||||
this->replot();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -111,30 +107,23 @@ void RiuTimeHistoryQwtPlot::setDefaults()
|
||||
canvas()->setMouseTracking(true);
|
||||
canvas()->installEventFilter(this);
|
||||
|
||||
/*
|
||||
QPen gridPen(Qt::SolidLine);
|
||||
gridPen.setColor(Qt::lightGray);
|
||||
m_grid->setPen(gridPen);
|
||||
*/
|
||||
|
||||
enableAxis(QwtPlot::xTop, true);
|
||||
enableAxis(QwtPlot::xBottom, true);
|
||||
enableAxis(QwtPlot::yLeft, true);
|
||||
enableAxis(QwtPlot::xBottom, false);
|
||||
enableAxis(QwtPlot::xTop, false);
|
||||
enableAxis(QwtPlot::yRight, false);
|
||||
|
||||
plotLayout()->setAlignCanvasToScales(true);
|
||||
|
||||
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Inverted, 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);
|
||||
|
||||
// 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);
|
||||
QFont xAxisFont = axisFont(QwtPlot::xBottom);
|
||||
xAxisFont.setPixelSize(9);
|
||||
setAxisFont(QwtPlot::xTop, xAxisFont);
|
||||
setAxisFont(QwtPlot::xBottom, xAxisFont);
|
||||
|
||||
QFont yAxisFont = axisFont(QwtPlot::yLeft);
|
||||
yAxisFont.setPixelSize(9);
|
||||
@ -149,9 +138,7 @@ void RiuTimeHistoryQwtPlot::setDefaults()
|
||||
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);
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
RiuTimeHistoryQwtPlot(QWidget* parent = NULL);
|
||||
virtual ~RiuTimeHistoryQwtPlot();
|
||||
|
||||
void addCurve(const QString& curveName, const std::vector<double>& xValues, const std::vector<double>& yValues);
|
||||
void addCurve(const QString& curveName, const std::vector<QDateTime>& dateTimes, const std::vector<double>& yValues);
|
||||
void deleteAllCurves();
|
||||
|
||||
private:
|
||||
|
@ -26,9 +26,11 @@
|
||||
#include "Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.h"
|
||||
|
||||
#include "RigCaseData.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigFemPartCollection.h"
|
||||
#include "RigFemPartGrid.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
#include "RigTimeHistoryResultAccessor.h"
|
||||
|
||||
#include "RimCellRangeFilter.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
@ -55,6 +57,7 @@
|
||||
#include "RiuFemResultTextBuilder.h"
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuResultTextBuilder.h"
|
||||
#include "RiuTimeHistoryQwtPlot.h"
|
||||
#include "RiuViewer.h"
|
||||
|
||||
#include "RivFemPartGeometryGenerator.h"
|
||||
@ -489,6 +492,13 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY)
|
||||
resultInfo = textBuilder.mainResultText();
|
||||
|
||||
pickInfo = textBuilder.topologyText(", ");
|
||||
|
||||
if (eclipseView->cellResult()->hasDynamicResult() &&
|
||||
eclipseView->eclipseCase() &&
|
||||
eclipseView->eclipseCase()->reservoirData())
|
||||
{
|
||||
addTimeHistoryCurve(eclipseView, gridIndex, cellIndex);
|
||||
}
|
||||
}
|
||||
else if (geomView)
|
||||
{
|
||||
@ -517,6 +527,34 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY)
|
||||
mainWnd->setResultInfo(resultInfo);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewerCommands::addTimeHistoryCurve(RimEclipseView* eclipseView, size_t gridIndex, size_t cellIndex)
|
||||
{
|
||||
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(eclipseView->cellResult()->porosityModel());
|
||||
|
||||
std::vector<QDateTime> timeStepDates = eclipseView->eclipseCase()->reservoirData()->results(porosityModel)->timeStepDates(eclipseView->cellResult()->scalarResultIndex());
|
||||
|
||||
RigTimeHistoryResultAccessor timeHistResultAccessor(eclipseView->eclipseCase()->reservoirData(), gridIndex, cellIndex, eclipseView->cellResult()->scalarResultIndex(), porosityModel);
|
||||
timeHistResultAccessor.computeCurveData();
|
||||
|
||||
QString curveName = eclipseView->eclipseCase()->caseUserDescription();
|
||||
curveName += " - Result : ";
|
||||
curveName += eclipseView->cellResult()->resultVariable();
|
||||
curveName += " - ";
|
||||
curveName += timeHistResultAccessor.topologyText();
|
||||
|
||||
std::vector<double> yValues = timeHistResultAccessor.yValues();
|
||||
|
||||
CVF_ASSERT(timeStepDates.size() == yValues.size());
|
||||
|
||||
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
||||
|
||||
mainWnd->timeHistoryPlot()->deleteAllCurves();
|
||||
mainWnd->timeHistoryPlot()->addCurve(curveName, timeStepDates, yValues);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Perform picking and return the index of the face that was hit, if a drawable geo was hit
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -49,6 +49,7 @@ public:
|
||||
void displayContextMenu(QMouseEvent* event);
|
||||
void handlePickAction(int winPosX, int winPosY);
|
||||
|
||||
|
||||
private slots:
|
||||
void slotRangeFilterI();
|
||||
void slotRangeFilterJ();
|
||||
@ -62,6 +63,7 @@ private:
|
||||
void createSliceRangeFilter(int ijOrk);
|
||||
void extractIntersectionData(const cvf::HitItemCollection& hitItems, cvf::Vec3d* localIntersectionPoint, cvf::Part** firstPart, uint* firstPartFaceHit, cvf::Part** nncPart, uint* nncPartFaceHit);
|
||||
void updateSelectionFromPickedPart(cvf::Part* part);
|
||||
void addTimeHistoryCurve(RimEclipseView* eclipseView, size_t gridIndex, size_t cellIndex);
|
||||
|
||||
size_t m_currentGridIdx;
|
||||
size_t m_currentCellIndex;
|
||||
|
Loading…
Reference in New Issue
Block a user