#2301 Rel.perm Plot: Add tooltip for cell value

This commit is contained in:
Rebecca Cox 2018-01-25 17:04:20 +01:00
parent 3a1c6406ff
commit 5273ace5e6
2 changed files with 145 additions and 48 deletions

View File

@ -169,7 +169,12 @@ void RiuRelativePermeabilityPlotPanel::setPlotDefaults(QwtPlot* plot)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuRelativePermeabilityPlotPanel::setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& relPermCurves, double swat, double sgas, QString caseName, QString cellReferenceText)
void RiuRelativePermeabilityPlotPanel::setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem,
const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& relPermCurves,
double swat,
double sgas,
QString caseName,
QString cellReferenceText)
{
//cvf::Trace::show("Set RelPerm plot data");
@ -224,10 +229,59 @@ void RiuRelativePermeabilityPlotPanel::plotUiSelectedCurves()
plotCurvesInQwt(m_unitSystem, selectedCurves, m_swat, m_sgas, m_cellReferenceText, useLogScale, m_qwtPlot, &m_myPlotMarkers);
}
//--------------------------------------------------------------------------------------------------
/// Add a transparent curve to make tooltip available on given points.
//--------------------------------------------------------------------------------------------------
void RiuRelativePermeabilityPlotPanel::addTransparentCurve(QwtPlot* plot, const std::vector<QPointF>& points, const std::vector<WhichYAxis>& axes)
{
QwtPlotCurve* curveLeftAxis = new QwtPlotCurve();
QwtPlotCurve* curveRightAxis = new QwtPlotCurve();
QVector<QPointF> pointsOnLeftAxis;
QVector<QPointF> pointsOnRightAxis;
// Each point is defined by either left or right axis
CVF_ASSERT(points.size() == axes.size());
for (size_t i = 0; i < points.size(); i++)
{
if (axes[i] == LEFT_YAXIS)
{
pointsOnLeftAxis.push_back(points[i]);
}
else
{
pointsOnRightAxis.push_back(points[i]);
}
}
curveLeftAxis->setSamples(pointsOnLeftAxis);
curveRightAxis->setSamples(pointsOnRightAxis);
curveLeftAxis->setYAxis(QwtPlot::yLeft);
curveRightAxis->setYAxis(QwtPlot::yRight);
curveLeftAxis->setStyle(QwtPlotCurve::NoCurve);
curveRightAxis->setStyle(QwtPlotCurve::NoCurve);
curveLeftAxis->setLegendAttribute(QwtPlotCurve::LegendNoAttribute);
curveRightAxis->setLegendAttribute(QwtPlotCurve::LegendNoAttribute);
curveLeftAxis->attach(plot);
curveRightAxis->attach(plot);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr, double swat, double sgas, QString cellReferenceText, bool logScaleLeftAxis, QwtPlot* plot, std::vector<QwtPlotMarker*>* myPlotMarkers)
void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(RiaEclipseUnitTools::UnitSystem unitSystem,
const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr,
double swat,
double sgas,
QString cellReferenceText,
bool logScaleLeftAxis,
QwtPlot* plot,
std::vector<QwtPlotMarker*>* myPlotMarkers)
{
plot->detachItems(QwtPlotItem::Rtti_PlotCurve);
@ -240,7 +294,9 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(RiaEclipseUnitTools::Unit
delete marker;
}
myPlotMarkers->clear();
std::vector<QPointF> points;
std::vector<WhichYAxis> axes;
bool shouldEnableRightYAxis = false;
@ -255,7 +311,6 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(RiaEclipseUnitTools::Unit
plotOnWhichYAxis = RIGHT_YAXIS;
}
//QwtPlotCurve* qwtCurve = new QwtPlotCurve(curve.name.c_str());
RiuLineSegmentQwtPlotCurve* qwtCurve = new RiuLineSegmentQwtPlotCurve(curve.name.c_str());
@ -303,7 +358,6 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(RiaEclipseUnitTools::Unit
qwtCurve->attach(plot);
// Add markers to indicate where SWAT and/or SGAS saturation intersects the respective curves
// Note that if we're using log scale we must guard against non-positive values
if (swat != HUGE_VAL)
@ -312,7 +366,7 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(RiaEclipseUnitTools::Unit
curve.ident == RigFlowDiagSolverInterface::RelPermCurve::KROW ||
curve.ident == RigFlowDiagSolverInterface::RelPermCurve::PCOW)
{
addCurveConstSaturationIntersectionMarker(curve, swat, Qt::blue, plotOnWhichYAxis, plot, myPlotMarkers);
addCurveConstSaturationIntersectionMarker(curve, swat, Qt::blue, plotOnWhichYAxis, plot, myPlotMarkers, &points, &axes);
}
}
if (sgas != HUGE_VAL)
@ -321,11 +375,14 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(RiaEclipseUnitTools::Unit
curve.ident == RigFlowDiagSolverInterface::RelPermCurve::KROG ||
curve.ident == RigFlowDiagSolverInterface::RelPermCurve::PCOG)
{
addCurveConstSaturationIntersectionMarker(curve, sgas, Qt::red, plotOnWhichYAxis, plot, myPlotMarkers);
addCurveConstSaturationIntersectionMarker(curve, sgas, Qt::red, plotOnWhichYAxis, plot, myPlotMarkers, &points, &axes);
}
}
}
plot->enableAxis(QwtPlot::yRight, shouldEnableRightYAxis);
addTransparentCurve(plot, points, axes);
// Add vertical marker lines to indicate cell SWAT and/or SGAS saturations
if (swat != HUGE_VAL)
@ -367,8 +424,6 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(RiaEclipseUnitTools::Unit
plot->setAxisTitle(QwtPlot::yLeft, "Kr");
plot->setAxisTitle(QwtPlot::yRight, QString("Pc [%1]").arg(RiaEclipseUnitTools::unitStringPressure(unitSystem)));
plot->enableAxis(QwtPlot::yRight, shouldEnableRightYAxis);
plot->replot();
}
@ -408,7 +463,11 @@ QString RiuRelativePermeabilityPlotPanel::determineXAxisTitleFromCurveCollection
//--------------------------------------------------------------------------------------------------
/// Add a vertical labeled marker line at the specified saturation value
//--------------------------------------------------------------------------------------------------
void RiuRelativePermeabilityPlotPanel::addVerticalSaturationMarkerLine(double saturationValue, QString label, QColor color, QwtPlot* plot, std::vector<QwtPlotMarker*>* myPlotMarkers)
void RiuRelativePermeabilityPlotPanel::addVerticalSaturationMarkerLine(double saturationValue,
QString label,
QColor color,
QwtPlot* plot,
std::vector<QwtPlotMarker*>* myPlotMarkers)
{
QwtPlotMarker* lineMarker = new QwtPlotMarker;
lineMarker->setXValue(saturationValue);
@ -425,7 +484,14 @@ void RiuRelativePermeabilityPlotPanel::addVerticalSaturationMarkerLine(double sa
//--------------------------------------------------------------------------------------------------
/// Add a marker at the intersection of the passed curve and the constant saturation value
//--------------------------------------------------------------------------------------------------
void RiuRelativePermeabilityPlotPanel::addCurveConstSaturationIntersectionMarker(const RigFlowDiagSolverInterface::RelPermCurve& curve, double saturationValue, QColor markerColor, WhichYAxis whichYAxis, QwtPlot* plot, std::vector<QwtPlotMarker*>* myPlotMarkers)
void RiuRelativePermeabilityPlotPanel::addCurveConstSaturationIntersectionMarker(const RigFlowDiagSolverInterface::RelPermCurve& curve,
double saturationValue,
QColor markerColor,
WhichYAxis whichYAxis,
QwtPlot* plot,
std::vector<QwtPlotMarker*>* myPlotMarkers,
std::vector<QPointF>* points,
std::vector<WhichYAxis>* axes)
{
const double yVal = interpolatedCurveYValue(curve.saturationVals, curve.yVals, saturationValue);
if (yVal != HUGE_VAL)
@ -446,6 +512,8 @@ void RiuRelativePermeabilityPlotPanel::addCurveConstSaturationIntersectionMarker
}
myPlotMarkers->push_back(pointMarker);
axes->push_back(whichYAxis);
points->push_back(QPointF(saturationValue, yVal));
}
}
@ -497,7 +565,9 @@ std::vector<RigFlowDiagSolverInterface::RelPermCurve> RiuRelativePermeabilityPlo
std::vector<RigFlowDiagSolverInterface::RelPermCurve> selectedCurves;
// Determine which curves to actually plot based on selection in GUI
const RigFlowDiagSolverInterface::RelPermCurve::EpsMode epsModeToShow = m_showUnscaledCheckBox->isChecked() ? RigFlowDiagSolverInterface::RelPermCurve::EPS_OFF : RigFlowDiagSolverInterface::RelPermCurve::EPS_ON;
const RigFlowDiagSolverInterface::RelPermCurve::EpsMode epsModeToShow = m_showUnscaledCheckBox->isChecked() ?
RigFlowDiagSolverInterface::RelPermCurve::EPS_OFF :
RigFlowDiagSolverInterface::RelPermCurve::EPS_ON;
for (size_t i = 0; i < m_allCurvesArr.size(); i++)
{

View File

@ -1,25 +1,25 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RigFlowDiagSolverInterface.h"
#include "RiaEclipseUnitTools.h"
#include "RigFlowDiagSolverInterface.h"
#include <QWidget>
@ -31,8 +31,7 @@ class QButtonGroup;
class QCheckBox;
class QwtPlot;
class QwtPlotMarker;
class QPointF;
//==================================================================================================
//
@ -46,8 +45,13 @@ class RiuRelativePermeabilityPlotPanel : public QWidget
public:
RiuRelativePermeabilityPlotPanel(QDockWidget* parent);
virtual ~RiuRelativePermeabilityPlotPanel();
void setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& relPermCurves, double swat, double sgas, QString caseName, QString cellReferenceText);
void setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem,
const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& relPermCurves,
double swat,
double sgas,
QString caseName,
QString cellReferenceText);
void clearPlot();
RiuRelativePermeabilityPlotUpdater* plotUpdater();
@ -69,38 +73,61 @@ private:
double max;
};
void plotUiSelectedCurves();
static void setPlotDefaults(QwtPlot* plot);
static void plotCurvesInQwt(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr, double swat, double sgas, QString cellReferenceText, bool logScaleLeftAxis, QwtPlot* plot, std::vector<QwtPlotMarker*>* myPlotMarkers);
static QString determineXAxisTitleFromCurveCollection(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr);
static void addVerticalSaturationMarkerLine(double saturationValue, QString label, QColor color, QwtPlot* plot, std::vector<QwtPlotMarker*>* myPlotMarkers);
static void addCurveConstSaturationIntersectionMarker(const RigFlowDiagSolverInterface::RelPermCurve& curve, double saturationValue, QColor markerColor, WhichYAxis whichYAxis, QwtPlot* plot, std::vector<QwtPlotMarker*>* myPlotMarkers);
static double interpolatedCurveYValue(const std::vector<double>& xVals, const std::vector<double>& yVals, double x);
std::vector<RigFlowDiagSolverInterface::RelPermCurve> gatherUiSelectedCurves() const;
QString asciiDataForUiSelectedCurves() const;
void plotUiSelectedCurves();
static void setPlotDefaults(QwtPlot* plot);
static void plotCurvesInQwt(RiaEclipseUnitTools::UnitSystem unitSystem,
const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr,
double swat,
double sgas,
QString cellReferenceText,
bool logScaleLeftAxis,
QwtPlot* plot,
std::vector<QwtPlotMarker*>* myPlotMarkers);
virtual void contextMenuEvent(QContextMenuEvent* event) override;
static QString determineXAxisTitleFromCurveCollection(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr);
static void addVerticalSaturationMarkerLine(double saturationValue,
QString label,
QColor color,
QwtPlot* plot,
std::vector<QwtPlotMarker*>* myPlotMarkers);
static void addCurveConstSaturationIntersectionMarker(const RigFlowDiagSolverInterface::RelPermCurve& curve,
double saturationValue,
QColor markerColor,
WhichYAxis whichYAxis,
QwtPlot* plot,
std::vector<QwtPlotMarker*>* myPlotMarkers,
std::vector<QPointF>* points,
std::vector<WhichYAxis>* axes);
static double interpolatedCurveYValue(const std::vector<double>& xVals, const std::vector<double>& yVals, double x);
static void addTransparentCurve(QwtPlot* plot, const std::vector<QPointF>& points, const std::vector<WhichYAxis>& axes);
std::vector<RigFlowDiagSolverInterface::RelPermCurve> gatherUiSelectedCurves() const;
QString asciiDataForUiSelectedCurves() const;
virtual void contextMenuEvent(QContextMenuEvent* event) override;
private slots:
void slotButtonInButtonGroupClicked(int);
void slotSomeCheckBoxStateChanged(int);
void slotCurrentPlotDataInTextDialog();
void slotButtonInButtonGroupClicked(int);
void slotSomeCheckBoxStateChanged(int);
void slotCurrentPlotDataInTextDialog();
private:
RiaEclipseUnitTools::UnitSystem m_unitSystem;
std::vector<RigFlowDiagSolverInterface::RelPermCurve> m_allCurvesArr;
double m_swat;
double m_sgas;
QString m_caseName;
QString m_cellReferenceText;
QwtPlot* m_qwtPlot;
std::vector<QwtPlotMarker*> m_myPlotMarkers;
RiaEclipseUnitTools::UnitSystem m_unitSystem;
std::vector<RigFlowDiagSolverInterface::RelPermCurve> m_allCurvesArr;
double m_swat;
double m_sgas;
QString m_caseName;
QString m_cellReferenceText;
QwtPlot* m_qwtPlot;
std::vector<QwtPlotMarker*> m_myPlotMarkers;
QButtonGroup* m_selectedCurvesButtonGroup;
QCheckBox* m_showUnscaledCheckBox;
QCheckBox* m_logarithmicScaleKrAxisCheckBox;
QButtonGroup* m_selectedCurvesButtonGroup;
QCheckBox* m_showUnscaledCheckBox;
QCheckBox* m_logarithmicScaleKrAxisCheckBox;
std::unique_ptr<RiuRelativePermeabilityPlotUpdater> m_plotUpdater;
std::unique_ptr<RiuRelativePermeabilityPlotUpdater> m_plotUpdater;
};