#2256 PVT Plot: Added text label showing the values for the cell value marker

This commit is contained in:
sigurdp 2017-12-14 12:56:35 +01:00
parent fc2b6694ae
commit 8fdb5cd7ba
3 changed files with 70 additions and 33 deletions

View File

@ -64,10 +64,10 @@ public:
//
//
//==================================================================================================
class PvtQwtPicker : public QwtPicker
class RiuPvtQwtPicker : public QwtPicker
{
public:
PvtQwtPicker(QwtPlot* plot, RiuPvtTrackerTextProvider* trackerTextProvider)
RiuPvtQwtPicker(QwtPlot* plot, RiuPvtTrackerTextProvider* trackerTextProvider)
: QwtPicker(QwtPicker::NoRubberBand, QwtPicker::AlwaysOn, plot->canvas()),
m_trackerTextProvider(trackerTextProvider)
{
@ -112,7 +112,7 @@ RiuPvtPlotWidget::RiuPvtPlotWidget(RiuPvtPlotPanel* parent)
setLayout(layout);
m_qwtPicker = new PvtQwtPicker(m_qwtPlot, this);
m_qwtPicker = new RiuPvtQwtPicker(m_qwtPlot, this);
connect(m_qwtPicker, SIGNAL(activated(bool)), this, SLOT(slotPickerActivated(bool)));
connect(m_qwtPicker, SIGNAL(moved(const QPoint&)), this, SLOT(slotPickerPointChanged(const QPoint&)));
}
@ -184,7 +184,7 @@ void RiuPvtPlotWidget::setPlotDefaults(QwtPlot* plot)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPvtPlotWidget::plotCurves(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& curveArr, double pressure, double pointMarkerYValue, QString plotTitle, QString yAxisTitle)
void RiuPvtPlotWidget::plotCurves(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& curveArr, double pressure, double pointMarkerYValue, QString pointMarkerLabel, QString plotTitle, QString yAxisTitle)
{
m_qwtPlot->detachItems(QwtPlotItem::Rtti_PlotCurve);
m_qwtPlot->detachItems(QwtPlotItem::Rtti_PlotMarker);
@ -266,7 +266,7 @@ void RiuPvtPlotWidget::plotCurves(RiaEclipseUnitTools::UnitSystem unitSystem, co
QwtPlotMarker* lineMarker = new QwtPlotMarker;
lineMarker->setXValue(pressure);
lineMarker->setLineStyle(QwtPlotMarker::VLine);
lineMarker->setLinePen(QPen(QColor(128, 0, 255), 1, Qt::DashLine));
lineMarker->setLinePen(QPen(QColor(128, 128, 255), 1, Qt::DashLine));
lineMarker->setLabel(QString("PRESSURE"));
lineMarker->setLabelAlignment(Qt::AlignTop | Qt::AlignRight);
lineMarker->setLabelOrientation(Qt::Vertical);
@ -279,11 +279,22 @@ void RiuPvtPlotWidget::plotCurves(RiaEclipseUnitTools::UnitSystem unitSystem, co
QwtPlotMarker* pointMarker = new QwtPlotMarker;
pointMarker->setValue(pressure, pointMarkerYValue);
QColor markerClr(128, 0, 255);
QwtSymbol* symbol = new QwtSymbol(QwtSymbol::Ellipse);
symbol->setSize(13, 13);
symbol->setPen(QPen(QColor(128, 128, 255), 2));
symbol->setPen(QPen(markerClr, 2));
symbol->setBrush(Qt::NoBrush);
pointMarker->setSymbol(symbol);
if (!pointMarkerLabel.isEmpty())
{
QwtText text(pointMarkerLabel);
text.setRenderFlags(Qt::AlignLeft);
text.setColor(markerClr);
pointMarker->setLabel(text);
pointMarker->setLabelAlignment(Qt::AlignTop | Qt::AlignRight);
}
pointMarker->attach(m_qwtPlot);
}
@ -486,7 +497,6 @@ void RiuPvtPlotWidget::slotPickerActivated(bool on)
RiuPvtPlotPanel::RiuPvtPlotPanel(QDockWidget* parent)
: QWidget(parent),
m_unitSystem(RiaEclipseUnitTools::UNITS_UNKNOWN),
m_pressure(HUGE_VAL),
m_plotUpdater(new RiuPvtPlotUpdater(this))
{
m_phaseComboBox = new QComboBox(this);
@ -531,7 +541,7 @@ RiuPvtPlotPanel::~RiuPvtPlotPanel()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPvtPlotPanel::setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& fvfCurveArr, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& viscosityCurveArr, FvfDynProps fvfDynProps, ViscosityDynProps viscosityDynProps, double pressure)
void RiuPvtPlotPanel::setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& fvfCurveArr, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& viscosityCurveArr, FvfDynProps fvfDynProps, ViscosityDynProps viscosityDynProps, CellValues cellValues)
{
//cvf::Trace::show("RiuPvtPlotPanel::setPlotData()");
@ -540,7 +550,7 @@ void RiuPvtPlotPanel::setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem, co
m_allViscosityCurvesArr = viscosityCurveArr;
m_fvfDynProps = fvfDynProps;
m_viscosityDynProps = viscosityDynProps;
m_pressure = pressure;
m_cellValues = cellValues;
plotUiSelectedCurves();
}
@ -562,7 +572,7 @@ void RiuPvtPlotPanel::clearPlot()
m_allViscosityCurvesArr.clear();
m_fvfDynProps = FvfDynProps();
m_viscosityDynProps = ViscosityDynProps();
m_pressure = HUGE_VAL;
m_cellValues = CellValues();
plotUiSelectedCurves();
}
@ -597,17 +607,28 @@ void RiuPvtPlotPanel::plotUiSelectedCurves()
// FVF plot
{
RigFlowDiagSolverInterface::PvtCurve::Ident curveIdentToPlot = RigFlowDiagSolverInterface::PvtCurve::Unknown;
double fvfPointMarkerYValue = HUGE_VAL;
double pointMarkerFvfValue = HUGE_VAL;
QString pointMarkerLabel = "";
if (phaseToPlot == RigFlowDiagSolverInterface::PvtCurve::GAS)
{
curveIdentToPlot = RigFlowDiagSolverInterface::PvtCurve::Bg;
fvfPointMarkerYValue = m_fvfDynProps.bg;
pointMarkerFvfValue = m_fvfDynProps.bg;
pointMarkerLabel = QString("%1 (%2)").arg(pointMarkerFvfValue).arg(m_cellValues.pressure);
if (m_cellValues.rv != HUGE_VAL)
{
pointMarkerLabel += QString("\nRv = %1").arg(m_cellValues.rv);
}
}
else if (phaseToPlot == RigFlowDiagSolverInterface::PvtCurve::OIL)
{
curveIdentToPlot = RigFlowDiagSolverInterface::PvtCurve::Bo;
fvfPointMarkerYValue = m_fvfDynProps.bo;
pointMarkerFvfValue = m_fvfDynProps.bo;
pointMarkerLabel = QString("%1 (%2)").arg(pointMarkerFvfValue).arg(m_cellValues.pressure);
if (m_cellValues.rv != HUGE_VAL)
{
pointMarkerLabel += QString("\nRs = %1").arg(m_cellValues.rs);
}
}
std::vector<RigFlowDiagSolverInterface::PvtCurve> selectedFvfCurves;
@ -621,23 +642,34 @@ void RiuPvtPlotPanel::plotUiSelectedCurves()
const QString plotTitle = QString("%1 Formation Volume Factor").arg(phaseString);
const QString yAxisTitle = QString("%1 Formation Volume Factor [%2]").arg(phaseString).arg(unitLabelFromCurveIdent(m_unitSystem, curveIdentToPlot));
m_fvfPlot->plotCurves(m_unitSystem, selectedFvfCurves, m_pressure, fvfPointMarkerYValue, plotTitle, yAxisTitle);
m_fvfPlot->plotCurves(m_unitSystem, selectedFvfCurves, m_cellValues.pressure, pointMarkerFvfValue, pointMarkerLabel, plotTitle, yAxisTitle);
}
// Viscosity plot
{
RigFlowDiagSolverInterface::PvtCurve::Ident curveIdentToPlot = RigFlowDiagSolverInterface::PvtCurve::Unknown;
double viscosityPointMarkerYValue = HUGE_VAL;
double pointMarkerViscosityValue = HUGE_VAL;
QString pointMarkerLabel = "";
if (phaseToPlot == RigFlowDiagSolverInterface::PvtCurve::GAS)
{
curveIdentToPlot = RigFlowDiagSolverInterface::PvtCurve::Visc_g;
viscosityPointMarkerYValue = m_viscosityDynProps.mu_g;
pointMarkerViscosityValue = m_viscosityDynProps.mu_g;
pointMarkerLabel = QString("%1 (%2)").arg(pointMarkerViscosityValue).arg(m_cellValues.pressure);
if (m_cellValues.rv != HUGE_VAL)
{
pointMarkerLabel += QString("\nRv = %1").arg(m_cellValues.rv);
}
}
else if (phaseToPlot == RigFlowDiagSolverInterface::PvtCurve::OIL)
{
curveIdentToPlot = RigFlowDiagSolverInterface::PvtCurve::Visc_o;
viscosityPointMarkerYValue = m_viscosityDynProps.mu_o;
pointMarkerViscosityValue = m_viscosityDynProps.mu_o;
pointMarkerLabel = QString("%1 (%2)").arg(pointMarkerViscosityValue).arg(m_cellValues.pressure);
if (m_cellValues.rs != HUGE_VAL)
{
pointMarkerLabel += QString("\nRs = %1").arg(m_cellValues.rs);
}
}
std::vector<RigFlowDiagSolverInterface::PvtCurve> selectedViscosityCurves;
@ -651,7 +683,7 @@ void RiuPvtPlotPanel::plotUiSelectedCurves()
const QString plotTitle = QString("%1 Viscosity").arg(phaseString);
const QString yAxisTitle = QString("%1 Viscosity [%2]").arg(phaseString).arg(unitLabelFromCurveIdent(m_unitSystem, curveIdentToPlot));
m_viscosityPlot->plotCurves(m_unitSystem, selectedViscosityCurves, m_pressure, viscosityPointMarkerYValue, plotTitle, yAxisTitle);
m_viscosityPlot->plotCurves(m_unitSystem, selectedViscosityCurves, m_cellValues.pressure, pointMarkerViscosityValue, pointMarkerLabel, plotTitle, yAxisTitle);
}
}

View File

@ -34,7 +34,7 @@ class QComboBox;
class QwtPlotMarker;
class QwtPlotCurve;
class PvtQwtPicker;
class RiuPvtQwtPicker;
class RiuPvtPlotPanel;
@ -59,7 +59,7 @@ class RiuPvtPlotWidget : public QWidget, public RiuPvtTrackerTextProvider
public:
RiuPvtPlotWidget(RiuPvtPlotPanel* parent);
void plotCurves(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& curveArr, double pressure, double pointMarkerYValue, QString plotTitle, QString yAxisTitle);
void plotCurves(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& curveArr, double pressure, double pointMarkerYValue, QString pointMarkerLabel, QString plotTitle, QString yAxisTitle);
private:
static void setPlotDefaults(QwtPlot* plot);
@ -68,7 +68,7 @@ private:
void updateTrackerPlotMarkerAndLabelFromPicker();
virtual QString trackerText() const override;
private slots:
private slots:
void slotPickerActivated(bool);
void slotPickerPointChanged(const QPoint& pt);
@ -78,10 +78,9 @@ private:
std::vector<RigFlowDiagSolverInterface::PvtCurve> m_pvtCurveArr; // Array of source Pvt curves currently being plotted
std::vector<const QwtPlotCurve*> m_qwtCurveArr; // Array of corresponding qwt curves used for mapping to Pvt curve when doing tracking
QPointer<PvtQwtPicker> m_qwtPicker;
QPointer<RiuPvtQwtPicker> m_qwtPicker;
QString m_trackerLabel;
QwtPlotMarker* m_trackerPlotMarker;
};
@ -96,6 +95,13 @@ class RiuPvtPlotPanel : public QWidget
Q_OBJECT
public:
struct CellValues
{
double pressure = HUGE_VAL;
double rs = HUGE_VAL;
double rv = HUGE_VAL;
};
struct FvfDynProps
{
double bo = HUGE_VAL;
@ -112,7 +118,7 @@ public:
RiuPvtPlotPanel(QDockWidget* parent);
virtual ~RiuPvtPlotPanel();
void setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& fvfCurveArr, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& viscosityCurveArr, FvfDynProps fvfDynProps, ViscosityDynProps viscosityDynProps, double pressure);
void setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& fvfCurveArr, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& viscosityCurveArr, FvfDynProps fvfDynProps, ViscosityDynProps viscosityDynProps, CellValues cellValues);
void clearPlot();
RiuPvtPlotUpdater* plotUpdater();
@ -129,7 +135,7 @@ private:
std::vector<RigFlowDiagSolverInterface::PvtCurve> m_allViscosityCurvesArr;
FvfDynProps m_fvfDynProps;
ViscosityDynProps m_viscosityDynProps;
double m_pressure;
CellValues m_cellValues;
QComboBox* m_phaseComboBox;
@ -140,4 +146,3 @@ private:
};

View File

@ -148,18 +148,18 @@ bool RiuPvtPlotUpdater::queryDataAndUpdatePlot(const RimEclipseView& eclipseView
cvf::ref<RigResultAccessor> rsAccessor = RigResultAccessorFactory::createFromNameAndType(eclipseCaseData, gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, "RS", RiaDefines::DYNAMIC_NATIVE);
cvf::ref<RigResultAccessor> rvAccessor = RigResultAccessorFactory::createFromNameAndType(eclipseCaseData, gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, "RV", RiaDefines::DYNAMIC_NATIVE);
cvf::ref<RigResultAccessor> pressureAccessor = RigResultAccessorFactory::createFromNameAndType(eclipseCaseData, gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, "PRESSURE", RiaDefines::DYNAMIC_NATIVE);
const double cellRS = rsAccessor.notNull() ? rsAccessor->cellScalar(gridLocalCellIndex) : HUGE_VAL;
const double cellRV = rvAccessor.notNull() ? rvAccessor->cellScalar(gridLocalCellIndex) : HUGE_VAL;
const double cellPressure = pressureAccessor.notNull() ? pressureAccessor->cellScalar(gridLocalCellIndex) : HUGE_VAL;
//cvf::Trace::show("cellRS = %f cellRV = %f cellPressure = %f", cellRS, cellRV, cellPressure);
RiuPvtPlotPanel::CellValues cellValues;
cellValues.rs = rsAccessor.notNull() ? rsAccessor->cellScalar(gridLocalCellIndex) : HUGE_VAL;
cellValues.rv = rvAccessor.notNull() ? rvAccessor->cellScalar(gridLocalCellIndex) : HUGE_VAL;
cellValues.pressure = pressureAccessor.notNull() ? pressureAccessor->cellScalar(gridLocalCellIndex) : HUGE_VAL;
RiuPvtPlotPanel::FvfDynProps fvfDynProps;
eclipseResultCase->flowDiagSolverInterface()->calculatePvtDynamicPropertiesFvf(activeCellIndex, cellPressure, cellRS, cellRV, &fvfDynProps.bo, &fvfDynProps.bg);
eclipseResultCase->flowDiagSolverInterface()->calculatePvtDynamicPropertiesFvf(activeCellIndex, cellValues.pressure, cellValues.rs, cellValues.rv, &fvfDynProps.bo, &fvfDynProps.bg);
RiuPvtPlotPanel::ViscosityDynProps viscosityDynProps;
eclipseResultCase->flowDiagSolverInterface()->calculatePvtDynamicPropertiesViscosity(activeCellIndex, cellPressure, cellRS, cellRV, &viscosityDynProps.mu_o, &viscosityDynProps.mu_g);
eclipseResultCase->flowDiagSolverInterface()->calculatePvtDynamicPropertiesViscosity(activeCellIndex, cellValues.pressure, cellValues.rs, cellValues.rv, &viscosityDynProps.mu_o, &viscosityDynProps.mu_g);
plotPanel->setPlotData(eclipseCaseData->unitsType(), fvfCurveArr, viscosityCurveArr, fvfDynProps, viscosityDynProps, cellPressure);
plotPanel->setPlotData(eclipseCaseData->unitsType(), fvfCurveArr, viscosityCurveArr, fvfDynProps, viscosityDynProps, cellValues);
return true;
}