Skip to content

Commit

Permalink
#2062 Prefix the Saturation title on the x-axis with "Water", "Gas" o…
Browse files Browse the repository at this point in the history
…r "Water/Gas" depending on the curves present in the plot.
  • Loading branch information
sigurdp committed Nov 24, 2017
1 parent 65fe3ba commit e83b3a8
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 15 deletions.
70 changes: 55 additions & 15 deletions ApplicationCode/UserInterface/RiuRelativePermeabilityPlotPanel.cpp
Expand Up @@ -240,20 +240,8 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(const std::vector<RigFlow

qwtCurve->setStyle(QwtPlotCurve::Lines);

bool plotCurveOnRightAxis = false;
QColor curveClr = Qt::magenta;
switch (curve.ident)
{
case RigFlowDiagSolverInterface::RelPermCurve::KRW: curveClr = Qt::blue; break;
case RigFlowDiagSolverInterface::RelPermCurve::KRG: curveClr = Qt::red; break;
case RigFlowDiagSolverInterface::RelPermCurve::KROW: curveClr = QColor(0, 130, 175); break;
case RigFlowDiagSolverInterface::RelPermCurve::KROG: curveClr = QColor(225, 110, 0); break;
case RigFlowDiagSolverInterface::RelPermCurve::PCOW: curveClr = QColor(0, 130, 175); plotCurveOnRightAxis = true; break;
case RigFlowDiagSolverInterface::RelPermCurve::PCOG: curveClr = QColor(225, 110, 0); plotCurveOnRightAxis = true; break;
}

QPen curvePen;
curvePen.setColor(curveClr);
const QColor curveClr = curveColorFromIdent(curve.ident);
const QPen curvePen(curveClr);
qwtCurve->setPen(curvePen);

qwtCurve->setLegendAttribute(QwtPlotCurve::LegendShowLine, true);
Expand All @@ -262,6 +250,7 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(const std::vector<RigFlow

qwtCurve->setRenderHint(QwtPlotItem::RenderAntialiased, true);

const bool plotCurveOnRightAxis = (curve.ident == RigFlowDiagSolverInterface::RelPermCurve::PCOW) || (curve.ident == RigFlowDiagSolverInterface::RelPermCurve::PCOG);
if (plotCurveOnRightAxis)
{
QwtSymbol* curveSymbol = new QwtSymbol(QwtSymbol::Ellipse);
Expand Down Expand Up @@ -304,7 +293,7 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(const std::vector<RigFlow
}
plot->setTitle(titleStr);

plot->setAxisTitle(QwtPlot::xBottom, "Saturation");
plot->setAxisTitle(QwtPlot::xBottom, determineXAxisTitleFromCurveCollection(curveArr));
plot->setAxisTitle(QwtPlot::yLeft, "Kr");
plot->setAxisTitle(QwtPlot::yRight, "Pc");

Expand All @@ -316,6 +305,57 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(const std::vector<RigFlow
//plot->setAxisScale(QwtPlot::yLeft, 0, 1);
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiuRelativePermeabilityPlotPanel::determineXAxisTitleFromCurveCollection(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr)
{
bool sawWater = false;
bool sawGas = false;

for (RigFlowDiagSolverInterface::RelPermCurve curve : curveArr)
{
switch (curve.ident)
{
case RigFlowDiagSolverInterface::RelPermCurve::KRW: sawWater = true; break;
case RigFlowDiagSolverInterface::RelPermCurve::KROW: sawWater = true; break;
case RigFlowDiagSolverInterface::RelPermCurve::PCOW: sawWater = true; break;

case RigFlowDiagSolverInterface::RelPermCurve::KRG: sawGas = true; break;
case RigFlowDiagSolverInterface::RelPermCurve::KROG: sawGas = true; break;
case RigFlowDiagSolverInterface::RelPermCurve::PCOG: sawGas = true; break;
}
}

QString title = "";
if (sawWater && sawGas) title = "Water/Gas ";
else if (sawWater) title = "Water ";
else if (sawGas) title = "Gas ";

title += "Saturation";

return title;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QColor RiuRelativePermeabilityPlotPanel::curveColorFromIdent(RigFlowDiagSolverInterface::RelPermCurve::Ident ident)
{
QColor clr = Qt::magenta;
switch (ident)
{
case RigFlowDiagSolverInterface::RelPermCurve::KRW: clr = Qt::blue; break;
case RigFlowDiagSolverInterface::RelPermCurve::KRG: clr = Qt::red; break;
case RigFlowDiagSolverInterface::RelPermCurve::KROW: clr = QColor(0, 130, 175); break;
case RigFlowDiagSolverInterface::RelPermCurve::KROG: clr = QColor(225, 110, 0); break;
case RigFlowDiagSolverInterface::RelPermCurve::PCOW: clr = QColor(0, 130, 175); break;
case RigFlowDiagSolverInterface::RelPermCurve::PCOG: clr = QColor(225, 110, 0); break;
}

return clr;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
Expand Up @@ -48,6 +48,8 @@ class RiuRelativePermeabilityPlotPanel : public QWidget
void plotUiSelectedCurves();
static void setPlotDefaults(QwtPlot* plot);
static void plotCurvesInQwt(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr, double swat, double sgas, QString cellReferenceText, QwtPlot* plot);
static QColor curveColorFromIdent(RigFlowDiagSolverInterface::RelPermCurve::Ident ident);
static QString determineXAxisTitleFromCurveCollection(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr);

private slots:
void slotButtonInButtonGroupClicked(int);
Expand Down

0 comments on commit e83b3a8

Please sign in to comment.