From 127f5b40b4f263af0c360f57e570f46b598259d7 Mon Sep 17 00:00:00 2001 From: sigurdp Date: Thu, 14 Dec 2017 13:55:47 +0100 Subject: [PATCH] PVT Plot: Added header in PVT plot panel containing cell info --- .../UserInterface/RiuPvtPlotPanel.cpp | 36 +++++++++++---- .../UserInterface/RiuPvtPlotPanel.h | 13 ++++-- .../UserInterface/RiuPvtPlotUpdater.cpp | 44 ++++++++++++++++++- .../UserInterface/RiuPvtPlotUpdater.h | 4 +- 4 files changed, 82 insertions(+), 15 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuPvtPlotPanel.cpp b/ApplicationCode/UserInterface/RiuPvtPlotPanel.cpp index 94d6edc2ad..cc787e7038 100644 --- a/ApplicationCode/UserInterface/RiuPvtPlotPanel.cpp +++ b/ApplicationCode/UserInterface/RiuPvtPlotPanel.cpp @@ -504,11 +504,18 @@ RiuPvtPlotPanel::RiuPvtPlotPanel(QDockWidget* parent) m_phaseComboBox->addItem("Oil", QVariant(RigFlowDiagSolverInterface::PvtCurve::OIL)); m_phaseComboBox->addItem("Gas", QVariant(RigFlowDiagSolverInterface::PvtCurve::GAS)); - QHBoxLayout* comboLayout = new QHBoxLayout(); - comboLayout->addWidget(new QLabel("Phase:")); - comboLayout->addWidget(m_phaseComboBox); - comboLayout->addStretch(1); - comboLayout->setContentsMargins(5, 5, 0, 0); + m_titleLabel = new QLabel("", this); + m_titleLabel->setAlignment(Qt::AlignHCenter); + QFont font = m_titleLabel->font(); + font.setPixelSize(14); + font.setBold(true); + m_titleLabel->setFont(font); + + QHBoxLayout* topLayout = new QHBoxLayout(); + topLayout->addWidget(new QLabel("Phase:")); + topLayout->addWidget(m_phaseComboBox); + topLayout->addWidget(m_titleLabel, 1); + topLayout->setContentsMargins(5, 5, 0, 0); m_fvfPlot = new RiuPvtPlotWidget(this); m_viscosityPlot = new RiuPvtPlotWidget(this); @@ -520,7 +527,7 @@ RiuPvtPlotPanel::RiuPvtPlotPanel(QDockWidget* parent) plotLayout->setContentsMargins(0, 0, 0, 0); QVBoxLayout* mainLayout = new QVBoxLayout(); - mainLayout->addLayout(comboLayout); + mainLayout->addLayout(topLayout); mainLayout->addLayout(plotLayout); mainLayout->setContentsMargins(0, 0, 0, 0); @@ -541,7 +548,7 @@ RiuPvtPlotPanel::~RiuPvtPlotPanel() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuPvtPlotPanel::setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector& fvfCurveArr, const std::vector& viscosityCurveArr, FvfDynProps fvfDynProps, ViscosityDynProps viscosityDynProps, CellValues cellValues) +void RiuPvtPlotPanel::setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector& fvfCurveArr, const std::vector& viscosityCurveArr, FvfDynProps fvfDynProps, ViscosityDynProps viscosityDynProps, CellValues cellValues, QString cellReferenceText) { //cvf::Trace::show("RiuPvtPlotPanel::setPlotData()"); @@ -551,6 +558,7 @@ void RiuPvtPlotPanel::setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem, co m_fvfDynProps = fvfDynProps; m_viscosityDynProps = viscosityDynProps; m_cellValues = cellValues; + m_cellReferenceText = cellReferenceText; plotUiSelectedCurves(); } @@ -562,7 +570,7 @@ void RiuPvtPlotPanel::clearPlot() { //cvf::Trace::show("RiuPvtPlotPanel::clearPlot()"); - if (m_allFvfCurvesArr.empty() && m_allViscosityCurvesArr.empty()) + if (m_allFvfCurvesArr.empty() && m_allViscosityCurvesArr.empty() && m_cellReferenceText.isEmpty()) { return; } @@ -573,6 +581,7 @@ void RiuPvtPlotPanel::clearPlot() m_fvfDynProps = FvfDynProps(); m_viscosityDynProps = ViscosityDynProps(); m_cellValues = CellValues(); + m_cellReferenceText.clear(); plotUiSelectedCurves(); } @@ -625,7 +634,7 @@ void RiuPvtPlotPanel::plotUiSelectedCurves() curveIdentToPlot = RigFlowDiagSolverInterface::PvtCurve::Bo; pointMarkerFvfValue = m_fvfDynProps.bo; pointMarkerLabel = QString("%1 (%2)").arg(pointMarkerFvfValue).arg(m_cellValues.pressure); - if (m_cellValues.rv != HUGE_VAL) + if (m_cellValues.rs != HUGE_VAL) { pointMarkerLabel += QString("\nRs = %1").arg(m_cellValues.rs); } @@ -685,6 +694,15 @@ void RiuPvtPlotPanel::plotUiSelectedCurves() const QString yAxisTitle = QString("%1 Viscosity [%2]").arg(phaseString).arg(unitLabelFromCurveIdent(m_unitSystem, curveIdentToPlot)); m_viscosityPlot->plotCurves(m_unitSystem, selectedViscosityCurves, m_cellValues.pressure, pointMarkerViscosityValue, pointMarkerLabel, plotTitle, yAxisTitle); } + + // Update the label on top in our panel + QString titleStr = "PVT"; + if (!m_cellReferenceText.isEmpty()) + { + titleStr += ", " + m_cellReferenceText; + } + + m_titleLabel->setText(titleStr); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuPvtPlotPanel.h b/ApplicationCode/UserInterface/RiuPvtPlotPanel.h index ebe315eb9d..88b09eb5e8 100644 --- a/ApplicationCode/UserInterface/RiuPvtPlotPanel.h +++ b/ApplicationCode/UserInterface/RiuPvtPlotPanel.h @@ -28,14 +28,17 @@ #include class RiuPvtPlotUpdater; +class RiuPvtQwtPicker; +class RiuPvtPlotPanel; + class QDockWidget; -class QwtPlot; class QComboBox; +class QLabel; + +class QwtPlot; class QwtPlotMarker; class QwtPlotCurve; -class RiuPvtQwtPicker; -class RiuPvtPlotPanel; @@ -118,7 +121,7 @@ public: RiuPvtPlotPanel(QDockWidget* parent); virtual ~RiuPvtPlotPanel(); - void setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector& fvfCurveArr, const std::vector& viscosityCurveArr, FvfDynProps fvfDynProps, ViscosityDynProps viscosityDynProps, CellValues cellValues); + void setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector& fvfCurveArr, const std::vector& viscosityCurveArr, FvfDynProps fvfDynProps, ViscosityDynProps viscosityDynProps, CellValues cellValues, QString cellReferenceText); void clearPlot(); RiuPvtPlotUpdater* plotUpdater(); @@ -136,8 +139,10 @@ private: FvfDynProps m_fvfDynProps; ViscosityDynProps m_viscosityDynProps; CellValues m_cellValues; + QString m_cellReferenceText; QComboBox* m_phaseComboBox; + QLabel* m_titleLabel; RiuPvtPlotWidget* m_fvfPlot; RiuPvtPlotWidget* m_viscosityPlot; diff --git a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp index 55049dc02c..3aede8270b 100644 --- a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp +++ b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp @@ -144,22 +144,30 @@ bool RiuPvtPlotUpdater::queryDataAndUpdatePlot(const RimEclipseView& eclipseView cellResultsData->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "RS"); cellResultsData->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "RV"); cellResultsData->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "PRESSURE"); + cellResultsData->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PVTNUM"); cvf::ref rsAccessor = RigResultAccessorFactory::createFromNameAndType(eclipseCaseData, gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, "RS", RiaDefines::DYNAMIC_NATIVE); cvf::ref rvAccessor = RigResultAccessorFactory::createFromNameAndType(eclipseCaseData, gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, "RV", RiaDefines::DYNAMIC_NATIVE); cvf::ref pressureAccessor = RigResultAccessorFactory::createFromNameAndType(eclipseCaseData, gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, "PRESSURE", RiaDefines::DYNAMIC_NATIVE); + cvf::ref pvtnumAccessor = RigResultAccessorFactory::createFromNameAndType(eclipseCaseData, gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, "PVTNUM", RiaDefines::STATIC_NATIVE); + 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; + const double cellPVTNUM = pvtnumAccessor.notNull() ? pvtnumAccessor->cellScalar(gridLocalCellIndex) : HUGE_VAL; + + RiuPvtPlotPanel::FvfDynProps fvfDynProps; eclipseResultCase->flowDiagSolverInterface()->calculatePvtDynamicPropertiesFvf(activeCellIndex, cellValues.pressure, cellValues.rs, cellValues.rv, &fvfDynProps.bo, &fvfDynProps.bg); RiuPvtPlotPanel::ViscosityDynProps viscosityDynProps; eclipseResultCase->flowDiagSolverInterface()->calculatePvtDynamicPropertiesViscosity(activeCellIndex, cellValues.pressure, cellValues.rs, cellValues.rv, &viscosityDynProps.mu_o, &viscosityDynProps.mu_g); - plotPanel->setPlotData(eclipseCaseData->unitsType(), fvfCurveArr, viscosityCurveArr, fvfDynProps, viscosityDynProps, cellValues); + QString cellRefText = constructCellReferenceText(eclipseCaseData, gridIndex, gridLocalCellIndex, cellPVTNUM); + + plotPanel->setPlotData(eclipseCaseData->unitsType(), fvfCurveArr, viscosityCurveArr, fvfDynProps, viscosityDynProps, cellValues, cellRefText); return true; } @@ -169,3 +177,37 @@ bool RiuPvtPlotUpdater::queryDataAndUpdatePlot(const RimEclipseView& eclipseView } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuPvtPlotUpdater::constructCellReferenceText(const RigEclipseCaseData* eclipseCaseData, size_t gridIndex, size_t gridLocalCellIndex, double pvtnum) +{ + const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0; + const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid(gridIndex) : NULL; + if (grid && gridLocalCellIndex < grid->cellCount()) + { + size_t i = 0; + size_t j = 0; + size_t k = 0; + if (grid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k)) + { + // Adjust to 1-based Eclipse indexing + i++; + j++; + k++; + + QString retText = QString("Grid index %1, Cell: [%2, %3, %4]").arg(gridIndex).arg(i).arg(j).arg(k); + + if (pvtnum != HUGE_VAL) + { + retText += QString(" (PVTNUM=%1)").arg(pvtnum); + } + + return retText; + } + } + + return QString(); +} + + diff --git a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.h b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.h index 6c0db15b2a..5bcf60517d 100644 --- a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.h +++ b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.h @@ -25,6 +25,7 @@ class RiuSelectionItem; class RiuPvtPlotPanel; class RimView; class RimEclipseView; +class RigEclipseCaseData; //================================================================================================== @@ -41,7 +42,8 @@ public: void updateOnTimeStepChanged(RimView* changedView); private: - static bool queryDataAndUpdatePlot(const RimEclipseView& eclipseView, size_t gridIndex, size_t gridLocalCellIndex, RiuPvtPlotPanel* plotPanel); + static bool queryDataAndUpdatePlot(const RimEclipseView& eclipseView, size_t gridIndex, size_t gridLocalCellIndex, RiuPvtPlotPanel* plotPanel); + static QString constructCellReferenceText(const RigEclipseCaseData* eclipseCaseData, size_t gridIndex, size_t gridLocalCellIndex, double pvtnum); private: QPointer m_targetPlotPanel;