(#612) Time history result accessor and display of curve from selection

This commit is contained in:
Magne Sjaastad
2015-11-04 14:18:52 +01:00
parent 30adb2661e
commit 0011f090de
9 changed files with 256 additions and 41 deletions

View File

@@ -1165,6 +1165,14 @@ QMdiSubWindow* RiuMainWindow::findMdiSubWindow(QWidget* viewer)
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuTimeHistoryQwtPlot* RiuMainWindow::timeHistoryPlot()
{
return m_timeHistoryQwtPlot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -113,6 +113,8 @@ public:
bool isAnyMdiSubWindowVisible();
QMdiSubWindow* findMdiSubWindow(QWidget* viewer);
RiuTimeHistoryQwtPlot* timeHistoryPlot();
protected:
virtual void closeEvent(QCloseEvent* event);

View File

@@ -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);

View File

@@ -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:

View File

@@ -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
//--------------------------------------------------------------------------------------------------

View File

@@ -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;