#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"); //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); 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); plot->detachItems(QwtPlotItem::Rtti_PlotCurve);
@ -241,6 +295,8 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(RiaEclipseUnitTools::Unit
} }
myPlotMarkers->clear(); myPlotMarkers->clear();
std::vector<QPointF> points;
std::vector<WhichYAxis> axes;
bool shouldEnableRightYAxis = false; bool shouldEnableRightYAxis = false;
@ -255,7 +311,6 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(RiaEclipseUnitTools::Unit
plotOnWhichYAxis = RIGHT_YAXIS; plotOnWhichYAxis = RIGHT_YAXIS;
} }
//QwtPlotCurve* qwtCurve = new QwtPlotCurve(curve.name.c_str()); //QwtPlotCurve* qwtCurve = new QwtPlotCurve(curve.name.c_str());
RiuLineSegmentQwtPlotCurve* qwtCurve = new RiuLineSegmentQwtPlotCurve(curve.name.c_str()); RiuLineSegmentQwtPlotCurve* qwtCurve = new RiuLineSegmentQwtPlotCurve(curve.name.c_str());
@ -303,7 +358,6 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(RiaEclipseUnitTools::Unit
qwtCurve->attach(plot); qwtCurve->attach(plot);
// Add markers to indicate where SWAT and/or SGAS saturation intersects the respective curves // 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 // Note that if we're using log scale we must guard against non-positive values
if (swat != HUGE_VAL) if (swat != HUGE_VAL)
@ -312,7 +366,7 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(RiaEclipseUnitTools::Unit
curve.ident == RigFlowDiagSolverInterface::RelPermCurve::KROW || curve.ident == RigFlowDiagSolverInterface::RelPermCurve::KROW ||
curve.ident == RigFlowDiagSolverInterface::RelPermCurve::PCOW) 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) if (sgas != HUGE_VAL)
@ -321,11 +375,14 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(RiaEclipseUnitTools::Unit
curve.ident == RigFlowDiagSolverInterface::RelPermCurve::KROG || curve.ident == RigFlowDiagSolverInterface::RelPermCurve::KROG ||
curve.ident == RigFlowDiagSolverInterface::RelPermCurve::PCOG) 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 // Add vertical marker lines to indicate cell SWAT and/or SGAS saturations
if (swat != HUGE_VAL) if (swat != HUGE_VAL)
@ -367,8 +424,6 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(RiaEclipseUnitTools::Unit
plot->setAxisTitle(QwtPlot::yLeft, "Kr"); plot->setAxisTitle(QwtPlot::yLeft, "Kr");
plot->setAxisTitle(QwtPlot::yRight, QString("Pc [%1]").arg(RiaEclipseUnitTools::unitStringPressure(unitSystem))); plot->setAxisTitle(QwtPlot::yRight, QString("Pc [%1]").arg(RiaEclipseUnitTools::unitStringPressure(unitSystem)));
plot->enableAxis(QwtPlot::yRight, shouldEnableRightYAxis);
plot->replot(); plot->replot();
} }
@ -408,7 +463,11 @@ QString RiuRelativePermeabilityPlotPanel::determineXAxisTitleFromCurveCollection
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Add a vertical labeled marker line at the specified saturation value /// 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; QwtPlotMarker* lineMarker = new QwtPlotMarker;
lineMarker->setXValue(saturationValue); 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 /// 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); const double yVal = interpolatedCurveYValue(curve.saturationVals, curve.yVals, saturationValue);
if (yVal != HUGE_VAL) if (yVal != HUGE_VAL)
@ -446,6 +512,8 @@ void RiuRelativePermeabilityPlotPanel::addCurveConstSaturationIntersectionMarker
} }
myPlotMarkers->push_back(pointMarker); 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; std::vector<RigFlowDiagSolverInterface::RelPermCurve> selectedCurves;
// Determine which curves to actually plot based on selection in GUI // 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++) for (size_t i = 0; i < m_allCurvesArr.size(); i++)
{ {

View File

@ -18,8 +18,8 @@
#pragma once #pragma once
#include "RigFlowDiagSolverInterface.h"
#include "RiaEclipseUnitTools.h" #include "RiaEclipseUnitTools.h"
#include "RigFlowDiagSolverInterface.h"
#include <QWidget> #include <QWidget>
@ -31,8 +31,7 @@ class QButtonGroup;
class QCheckBox; class QCheckBox;
class QwtPlot; class QwtPlot;
class QwtPlotMarker; class QwtPlotMarker;
class QPointF;
//================================================================================================== //==================================================================================================
// //
@ -47,7 +46,12 @@ public:
RiuRelativePermeabilityPlotPanel(QDockWidget* parent); RiuRelativePermeabilityPlotPanel(QDockWidget* parent);
virtual ~RiuRelativePermeabilityPlotPanel(); 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(); void clearPlot();
RiuRelativePermeabilityPlotUpdater* plotUpdater(); RiuRelativePermeabilityPlotUpdater* plotUpdater();
@ -69,38 +73,61 @@ private:
double max; double max;
}; };
void plotUiSelectedCurves(); void plotUiSelectedCurves();
static void setPlotDefaults(QwtPlot* plot); 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 void plotCurvesInQwt(RiaEclipseUnitTools::UnitSystem unitSystem,
static QString determineXAxisTitleFromCurveCollection(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr); const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr,
static void addVerticalSaturationMarkerLine(double saturationValue, QString label, QColor color, QwtPlot* plot, std::vector<QwtPlotMarker*>* myPlotMarkers); double swat,
static void addCurveConstSaturationIntersectionMarker(const RigFlowDiagSolverInterface::RelPermCurve& curve, double saturationValue, QColor markerColor, WhichYAxis whichYAxis, QwtPlot* plot, std::vector<QwtPlotMarker*>* myPlotMarkers); double sgas,
static double interpolatedCurveYValue(const std::vector<double>& xVals, const std::vector<double>& yVals, double x); QString cellReferenceText,
bool logScaleLeftAxis,
QwtPlot* plot,
std::vector<QwtPlotMarker*>* myPlotMarkers);
std::vector<RigFlowDiagSolverInterface::RelPermCurve> gatherUiSelectedCurves() const; static QString determineXAxisTitleFromCurveCollection(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr);
QString asciiDataForUiSelectedCurves() const;
virtual void contextMenuEvent(QContextMenuEvent* event) override; 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: private slots:
void slotButtonInButtonGroupClicked(int); void slotButtonInButtonGroupClicked(int);
void slotSomeCheckBoxStateChanged(int); void slotSomeCheckBoxStateChanged(int);
void slotCurrentPlotDataInTextDialog(); void slotCurrentPlotDataInTextDialog();
private: private:
RiaEclipseUnitTools::UnitSystem m_unitSystem; RiaEclipseUnitTools::UnitSystem m_unitSystem;
std::vector<RigFlowDiagSolverInterface::RelPermCurve> m_allCurvesArr; std::vector<RigFlowDiagSolverInterface::RelPermCurve> m_allCurvesArr;
double m_swat; double m_swat;
double m_sgas; double m_sgas;
QString m_caseName; QString m_caseName;
QString m_cellReferenceText; QString m_cellReferenceText;
QwtPlot* m_qwtPlot; QwtPlot* m_qwtPlot;
std::vector<QwtPlotMarker*> m_myPlotMarkers; std::vector<QwtPlotMarker*> m_myPlotMarkers;
QButtonGroup* m_selectedCurvesButtonGroup; QButtonGroup* m_selectedCurvesButtonGroup;
QCheckBox* m_showUnscaledCheckBox; QCheckBox* m_showUnscaledCheckBox;
QCheckBox* m_logarithmicScaleKrAxisCheckBox; QCheckBox* m_logarithmicScaleKrAxisCheckBox;
std::unique_ptr<RiuRelativePermeabilityPlotUpdater> m_plotUpdater; std::unique_ptr<RiuRelativePermeabilityPlotUpdater> m_plotUpdater;
}; };