#2102 Statistics dialog. Refactoring

This commit is contained in:
Bjørn Erik Jensen
2017-11-16 12:51:08 +01:00
parent cdfb839c06
commit 3bb1933f4d
3 changed files with 159 additions and 149 deletions

View File

@@ -62,6 +62,7 @@ RicGridStatisticsDialog::RicGridStatisticsDialog(QWidget* parent)
// Define layout
QVBoxLayout* layout = new QVBoxLayout();
layout->setSpacing(0);
layout->addWidget(m_label);
layout->addWidget(m_textEdit);
layout->addWidget(m_historgramPlot);
@@ -94,8 +95,8 @@ void RicGridStatisticsDialog::setInfoText(RimEclipseView* eclipseView)
if (eclipseView && overlayInfo)
{
QString text;
text = overlayInfo->caseInfoText(eclipseView);
text += overlayInfo->resultInfoText(overlayInfo->histogramData(eclipseView), eclipseView);
text = overlayInfo->caseInfoText();
text += overlayInfo->resultInfoText(overlayInfo->histogramData());
m_textEdit->setText(text);
}
}
@@ -119,7 +120,7 @@ void RicGridStatisticsDialog::setHistogramData(RimEclipseView* eclipseView)
aggr->setStyle(QwtPlotCurve::Steps);
aggr->setCurveAttribute(QwtPlotCurve::Inverted);
Rim3dOverlayInfoConfig::HistogramData histogramData = overlayInfo->histogramData(eclipseView);
Rim3dOverlayInfoConfig::HistogramData histogramData = overlayInfo->histogramData();
QVector<QwtIntervalSample> histSamples;
QVector<QPointF> aggrSamples;

View File

@@ -163,108 +163,112 @@ void Rim3dOverlayInfoConfig::setPosition(cvf::Vec2ui position)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Rim3dOverlayInfoConfig::HistogramData Rim3dOverlayInfoConfig::histogramData(RimEclipseView* eclipseView)
Rim3dOverlayInfoConfig::HistogramData Rim3dOverlayInfoConfig::histogramData()
{
HistogramData histData;
bool isResultsInfoRelevant = eclipseView->hasUserRequestedAnimation() && eclipseView->cellResult()->hasResult();
if (isResultsInfoRelevant)
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_viewDef.p());
if (eclipseView)
{
size_t scalarIndex = eclipseView->cellResult()->scalarResultIndex();
bool isResultsInfoRelevant = eclipseView->hasUserRequestedAnimation() && eclipseView->cellResult()->hasResult();
if (scalarIndex != cvf::UNDEFINED_SIZE_T)
if (isResultsInfoRelevant)
{
size_t scalarIndex = eclipseView->cellResult()->scalarResultIndex();
if (m_statisticsCellRange == ALL_CELLS)
if (scalarIndex != cvf::UNDEFINED_SIZE_T)
{
if (m_statisticsTimeRange == ALL_TIMESTEPS)
{
eclipseView->currentGridCellResults()->minMaxCellScalarValues(scalarIndex, histData.min, histData.max);
eclipseView->currentGridCellResults()->p10p90CellScalarValues(scalarIndex, histData.p10, histData.p90);
eclipseView->currentGridCellResults()->meanCellScalarValues(scalarIndex, histData.mean);
eclipseView->currentGridCellResults()->sumCellScalarValues(scalarIndex, histData.sum);
histData.histogram = &(eclipseView->currentGridCellResults()->cellScalarValuesHistogram(scalarIndex));
}
else if (m_statisticsTimeRange == CURRENT_TIMESTEP)
{
int currentTimeStep = eclipseView->currentTimeStep();
if (eclipseView->cellResult()->hasStaticResult())
{
currentTimeStep = 0;
}
eclipseView->currentGridCellResults()->minMaxCellScalarValues(scalarIndex, currentTimeStep, histData.min, histData.max);
eclipseView->currentGridCellResults()->p10p90CellScalarValues(scalarIndex, currentTimeStep, histData.p10, histData.p90);
eclipseView->currentGridCellResults()->meanCellScalarValues(scalarIndex, currentTimeStep, histData.mean);
eclipseView->currentGridCellResults()->sumCellScalarValues(scalarIndex, currentTimeStep, histData.sum);
histData.histogram = &(eclipseView->currentGridCellResults()->cellScalarValuesHistogram(scalarIndex, currentTimeStep));
}
else
{
CVF_ASSERT(false);
}
}
else if (m_statisticsCellRange == VISIBLE_CELLS)
{
updateVisCellStatsIfNeeded();
if (m_statisticsTimeRange == ALL_TIMESTEPS)
{
// TODO: Only valid if we have no dynamic property filter
m_visibleCellStatistics->meanCellScalarValues(histData.mean);
m_visibleCellStatistics->minMaxCellScalarValues(histData.min, histData.max);
m_visibleCellStatistics->p10p90CellScalarValues(histData.p10, histData.p90);
m_visibleCellStatistics->sumCellScalarValues(histData.sum);
histData.histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram());
}
else if (m_statisticsTimeRange == CURRENT_TIMESTEP)
{
int currentTimeStep = eclipseView->currentTimeStep();
if (eclipseView->cellResult()->hasStaticResult())
{
currentTimeStep = 0;
}
m_visibleCellStatistics->meanCellScalarValues(currentTimeStep, histData.mean);
m_visibleCellStatistics->minMaxCellScalarValues(currentTimeStep, histData.min, histData.max);
m_visibleCellStatistics->p10p90CellScalarValues(currentTimeStep, histData.p10, histData.p90);
m_visibleCellStatistics->sumCellScalarValues(currentTimeStep, histData.sum);
m_visibleCellStatistics->mobileVolumeWeightedMean(currentTimeStep, histData.weightedMean);
histData.histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram(currentTimeStep));
}
}
}
else if (eclipseView->cellResult()->isFlowDiagOrInjectionFlooding())
{
if (m_statisticsTimeRange == CURRENT_TIMESTEP || m_statisticsTimeRange == ALL_TIMESTEPS) // All timesteps is ignored
{
int currentTimeStep = eclipseView->currentTimeStep();
if (m_statisticsCellRange == ALL_CELLS)
{
RigFlowDiagResults* fldResults = eclipseView->cellResult()->flowDiagSolution()->flowDiagResults();
RigFlowDiagResultAddress resAddr = eclipseView->cellResult()->flowDiagResAddress();
if (m_statisticsTimeRange == ALL_TIMESTEPS)
{
eclipseView->currentGridCellResults()->minMaxCellScalarValues(scalarIndex, histData.min, histData.max);
eclipseView->currentGridCellResults()->p10p90CellScalarValues(scalarIndex, histData.p10, histData.p90);
eclipseView->currentGridCellResults()->meanCellScalarValues(scalarIndex, histData.mean);
eclipseView->currentGridCellResults()->sumCellScalarValues(scalarIndex, histData.sum);
histData.histogram = &(eclipseView->currentGridCellResults()->cellScalarValuesHistogram(scalarIndex));
}
else if (m_statisticsTimeRange == CURRENT_TIMESTEP)
{
int currentTimeStep = eclipseView->currentTimeStep();
if (eclipseView->cellResult()->hasStaticResult())
{
currentTimeStep = 0;
}
fldResults->minMaxScalarValues(resAddr, currentTimeStep, &histData.min, &histData.max);
fldResults->p10p90ScalarValues(resAddr, currentTimeStep, &histData.p10, &histData.p90);
fldResults->meanScalarValue(resAddr, currentTimeStep, &histData.mean);
fldResults->sumScalarValue(resAddr, currentTimeStep, &histData.sum);
histData.histogram = &(fldResults->scalarValuesHistogram(resAddr, currentTimeStep));
eclipseView->currentGridCellResults()->minMaxCellScalarValues(scalarIndex, currentTimeStep, histData.min, histData.max);
eclipseView->currentGridCellResults()->p10p90CellScalarValues(scalarIndex, currentTimeStep, histData.p10, histData.p90);
eclipseView->currentGridCellResults()->meanCellScalarValues(scalarIndex, currentTimeStep, histData.mean);
eclipseView->currentGridCellResults()->sumCellScalarValues(scalarIndex, currentTimeStep, histData.sum);
histData.histogram = &(eclipseView->currentGridCellResults()->cellScalarValuesHistogram(scalarIndex, currentTimeStep));
}
else
{
CVF_ASSERT(false);
}
}
else if (m_statisticsCellRange == VISIBLE_CELLS)
{
updateVisCellStatsIfNeeded();
if (m_statisticsTimeRange == ALL_TIMESTEPS)
{
// TODO: Only valid if we have no dynamic property filter
m_visibleCellStatistics->meanCellScalarValues(histData.mean);
m_visibleCellStatistics->minMaxCellScalarValues(histData.min, histData.max);
m_visibleCellStatistics->p10p90CellScalarValues(histData.p10, histData.p90);
m_visibleCellStatistics->sumCellScalarValues(histData.sum);
m_visibleCellStatistics->meanCellScalarValues(currentTimeStep, histData.mean);
m_visibleCellStatistics->minMaxCellScalarValues(currentTimeStep, histData.min, histData.max);
m_visibleCellStatistics->p10p90CellScalarValues(currentTimeStep, histData.p10, histData.p90);
m_visibleCellStatistics->sumCellScalarValues(currentTimeStep, histData.sum);
m_visibleCellStatistics->mobileVolumeWeightedMean(currentTimeStep, histData.weightedMean);
histData.histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram());
}
else if (m_statisticsTimeRange == CURRENT_TIMESTEP)
{
int currentTimeStep = eclipseView->currentTimeStep();
if (eclipseView->cellResult()->hasStaticResult())
{
currentTimeStep = 0;
}
histData.histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram(currentTimeStep));
m_visibleCellStatistics->meanCellScalarValues(currentTimeStep, histData.mean);
m_visibleCellStatistics->minMaxCellScalarValues(currentTimeStep, histData.min, histData.max);
m_visibleCellStatistics->p10p90CellScalarValues(currentTimeStep, histData.p10, histData.p90);
m_visibleCellStatistics->sumCellScalarValues(currentTimeStep, histData.sum);
m_visibleCellStatistics->mobileVolumeWeightedMean(currentTimeStep, histData.weightedMean);
histData.histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram(currentTimeStep));
}
}
}
else if (eclipseView->cellResult()->isFlowDiagOrInjectionFlooding())
{
if (m_statisticsTimeRange == CURRENT_TIMESTEP || m_statisticsTimeRange == ALL_TIMESTEPS) // All timesteps is ignored
{
int currentTimeStep = eclipseView->currentTimeStep();
if (m_statisticsCellRange == ALL_CELLS)
{
RigFlowDiagResults* fldResults = eclipseView->cellResult()->flowDiagSolution()->flowDiagResults();
RigFlowDiagResultAddress resAddr = eclipseView->cellResult()->flowDiagResAddress();
fldResults->minMaxScalarValues(resAddr, currentTimeStep, &histData.min, &histData.max);
fldResults->p10p90ScalarValues(resAddr, currentTimeStep, &histData.p10, &histData.p90);
fldResults->meanScalarValue(resAddr, currentTimeStep, &histData.mean);
fldResults->sumScalarValue(resAddr, currentTimeStep, &histData.sum);
histData.histogram = &(fldResults->scalarValuesHistogram(resAddr, currentTimeStep));
}
else if (m_statisticsCellRange == VISIBLE_CELLS)
{
updateVisCellStatsIfNeeded();
m_visibleCellStatistics->meanCellScalarValues(currentTimeStep, histData.mean);
m_visibleCellStatistics->minMaxCellScalarValues(currentTimeStep, histData.min, histData.max);
m_visibleCellStatistics->p10p90CellScalarValues(currentTimeStep, histData.p10, histData.p90);
m_visibleCellStatistics->sumCellScalarValues(currentTimeStep, histData.sum);
m_visibleCellStatistics->mobileVolumeWeightedMean(currentTimeStep, histData.weightedMean);
histData.histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram(currentTimeStep));
}
}
}
}
@@ -275,11 +279,12 @@ Rim3dOverlayInfoConfig::HistogramData Rim3dOverlayInfoConfig::histogramData(RimE
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString Rim3dOverlayInfoConfig::caseInfoText(RimEclipseView* eclipseView)
QString Rim3dOverlayInfoConfig::caseInfoText()
{
QString infoText;
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_viewDef.p());
if (showCaseInfo())
if (eclipseView && showCaseInfo())
{
QString caseName;
QString totCellCount;
@@ -318,79 +323,83 @@ QString Rim3dOverlayInfoConfig::caseInfoText(RimEclipseView* eclipseView)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString Rim3dOverlayInfoConfig::resultInfoText(const HistogramData& histData, RimEclipseView* eclipseView)
QString Rim3dOverlayInfoConfig::resultInfoText(const HistogramData& histData)
{
QString infoText;
bool isResultsInfoRelevant = eclipseView->hasUserRequestedAnimation() && eclipseView->cellResult()->hasResult();
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_viewDef.p());
if (eclipseView->cellResult()->isTernarySaturationSelected())
if (eclipseView)
{
QString propName = eclipseView->cellResult()->resultVariableUiShortName();
infoText += QString("<b>Cell Property:</b> %1 ").arg(propName);
}
bool isResultsInfoRelevant = eclipseView->hasUserRequestedAnimation() && eclipseView->cellResult()->hasResult();
if (isResultsInfoRelevant)
{
QString propName = eclipseView->cellResult()->resultVariableUiShortName();
QString timeRangeText = m_statisticsTimeRange().uiText();
if (eclipseView->cellResult()->isFlowDiagOrInjectionFlooding())
if (eclipseView->cellResult()->isTernarySaturationSelected())
{
timeRangeText = caf::AppEnum<StatisticsTimeRangeType>::uiText(CURRENT_TIMESTEP);
QString propName = eclipseView->cellResult()->resultVariableUiShortName();
infoText += QString("<b>Cell Property:</b> %1 ").arg(propName);
}
infoText += QString("<b>Cell Property:</b> %1 ").arg(propName);
infoText += QString("<br><b>Statistics:</b> ") + timeRangeText + " and " + m_statisticsCellRange().uiText();
infoText += QString("<table border=0 cellspacing=5 >"
"<tr> <td>Min</td> <td>P10</td> <td>Mean</td> <td>P90</td> <td>Max</td> <td>Sum</td> </tr>"
"<tr> <td>%1</td> <td> %2</td> <td> %3</td> <td> %4</td> <td> %5</td> <td> %6</td> </tr>"
"</table>").arg(histData.min).arg(histData.p10).arg(histData.mean).arg(histData.p90).arg(histData.max).arg(histData.sum);
if (eclipseView->faultResultSettings()->hasValidCustomResult())
if (isResultsInfoRelevant)
{
QString faultMapping;
bool isShowingGrid = eclipseView->faultCollection()->isGridVisualizationMode();
if (!isShowingGrid)
QString propName = eclipseView->cellResult()->resultVariableUiShortName();
QString timeRangeText = m_statisticsTimeRange().uiText();
if (eclipseView->cellResult()->isFlowDiagOrInjectionFlooding())
{
if (eclipseView->faultCollection()->faultResult() == RimFaultInViewCollection::FAULT_BACK_FACE_CULLING)
timeRangeText = caf::AppEnum<StatisticsTimeRangeType>::uiText(CURRENT_TIMESTEP);
}
infoText += QString("<b>Cell Property:</b> %1 ").arg(propName);
infoText += QString("<br><b>Statistics:</b> ") + timeRangeText + " and " + m_statisticsCellRange().uiText();
infoText += QString("<table border=0 cellspacing=5 >"
"<tr> <td>Min</td> <td>P10</td> <td>Mean</td> <td>P90</td> <td>Max</td> <td>Sum</td> </tr>"
"<tr> <td>%1</td> <td> %2</td> <td> %3</td> <td> %4</td> <td> %5</td> <td> %6</td> </tr>"
"</table>").arg(histData.min).arg(histData.p10).arg(histData.mean).arg(histData.p90).arg(histData.max).arg(histData.sum);
if (eclipseView->faultResultSettings()->hasValidCustomResult())
{
QString faultMapping;
bool isShowingGrid = eclipseView->faultCollection()->isGridVisualizationMode();
if (!isShowingGrid)
{
faultMapping = "Cells behind fault";
}
else if (eclipseView->faultCollection()->faultResult() == RimFaultInViewCollection::FAULT_FRONT_FACE_CULLING)
{
faultMapping = "Cells in front of fault";
if (eclipseView->faultCollection()->faultResult() == RimFaultInViewCollection::FAULT_BACK_FACE_CULLING)
{
faultMapping = "Cells behind fault";
}
else if (eclipseView->faultCollection()->faultResult() == RimFaultInViewCollection::FAULT_FRONT_FACE_CULLING)
{
faultMapping = "Cells in front of fault";
}
else
{
faultMapping = "Cells in front and behind fault";
}
}
else
{
faultMapping = "Cells in front and behind fault";
}
}
else
{
faultMapping = "Cells in front and behind fault";
}
infoText += QString("<b>Fault results: </b> %1<br>").arg(faultMapping);
infoText += QString("<b>Fault Property:</b> %1 <br>").arg(eclipseView->faultResultSettings()->customFaultResult()->resultVariableUiShortName());
infoText += QString("<b>Fault results: </b> %1<br>").arg(faultMapping);
infoText += QString("<b>Fault Property:</b> %1 <br>").arg(eclipseView->faultResultSettings()->customFaultResult()->resultVariableUiShortName());
}
}
if (eclipseView->hasUserRequestedAnimation() && eclipseView->cellEdgeResult()->hasResult())
{
double min, max;
QString cellEdgeName = eclipseView->cellEdgeResult()->resultVariableUiShortName();
eclipseView->cellEdgeResult()->minMaxCellEdgeValues(min, max);
infoText += QString("<b>Cell Edge Property:</b> %1 ").arg(cellEdgeName);
infoText += QString("<table border=0 cellspacing=5 >"
"<tr> <td>Min</td> <td></td> <td></td> <td></td> <td>Max</td> </tr>"
"<tr> <td>%1</td> <td></td> <td></td> <td></td> <td> %2</td></tr>"
"</table>").arg(min).arg(max);
}
if (showVolumeWeightedMean() && histData.weightedMean != HUGE_VAL)
{
infoText += QString("<b>Mobile Volume Weighted Mean:</b> %1").arg(histData.weightedMean);
}
}
if (eclipseView->hasUserRequestedAnimation() && eclipseView->cellEdgeResult()->hasResult())
{
double min, max;
QString cellEdgeName = eclipseView->cellEdgeResult()->resultVariableUiShortName();
eclipseView->cellEdgeResult()->minMaxCellEdgeValues(min, max);
infoText += QString("<b>Cell Edge Property:</b> %1 ").arg(cellEdgeName);
infoText += QString("<table border=0 cellspacing=5 >"
"<tr> <td>Min</td> <td></td> <td></td> <td></td> <td>Max</td> </tr>"
"<tr> <td>%1</td> <td></td> <td></td> <td></td> <td> %2</td></tr>"
"</table>").arg(min).arg(max);
}
if (showVolumeWeightedMean() && histData.weightedMean != HUGE_VAL)
{
infoText += QString("<b>Mobile Volume Weighted Mean:</b> %1").arg(histData.weightedMean);
}
return infoText;
}
@@ -508,19 +517,19 @@ void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * eclipseView)
if (showHistogram() || showResultInfo())
{
histData = histogramData(eclipseView);
histData = histogramData();
}
QString infoText;
if (showCaseInfo())
{
infoText = caseInfoText(eclipseView);
infoText = caseInfoText();
}
if (showResultInfo())
{
infoText += resultInfoText(histData, eclipseView);
infoText += resultInfoText(histData);
}
if (!infoText.isEmpty())

View File

@@ -69,9 +69,9 @@ public:
void setPosition(cvf::Vec2ui position);
HistogramData histogramData(RimEclipseView* eclipseView);
QString caseInfoText(RimEclipseView* eclipseView);
QString resultInfoText(const HistogramData& histData, RimEclipseView* eclipseView);
HistogramData histogramData();
QString caseInfoText();
QString resultInfoText(const HistogramData& histData);
void showStatisticsInfoDialog();