Statistics dialog. Fix crash when no results exist

This commit is contained in:
Bjørn Erik Jensen 2017-11-16 13:22:05 +01:00
parent c59c167bbf
commit 985388e60f
2 changed files with 38 additions and 30 deletions

View File

@ -122,6 +122,8 @@ void RicGridStatisticsDialog::setHistogramData(RimEclipseView* eclipseView)
Rim3dOverlayInfoConfig::HistogramData histogramData = overlayInfo->histogramData();
if (histogramData.isValid())
{
QVector<QwtIntervalSample> histSamples;
QVector<QPointF> aggrSamples;
double xStep = (histogramData.max - histogramData.min) / (*histogramData.histogram).size();
@ -151,12 +153,13 @@ void RicGridStatisticsDialog::setHistogramData(RimEclipseView* eclipseView)
// Markers
setMarkers(histogramData, m_historgramPlot);
setMarkers(histogramData, m_aggregatedPlot);
}
}
// Refresh plot
m_historgramPlot->replot();
m_aggregatedPlot->replot();
}
}
//--------------------------------------------------------------------------------------------------
///

View File

@ -47,7 +47,7 @@ class Rim3dOverlayInfoConfig : public caf::PdmObject
class HistogramData
{
public:
HistogramData() : min(HUGE_VAL), max(HUGE_VAL), p10(HUGE_VAL), p90(HUGE_VAL), mean(HUGE_VAL), weightedMean(HUGE_VAL), sum(0.0) {}
HistogramData() : min(HUGE_VAL), max(HUGE_VAL), p10(HUGE_VAL), p90(HUGE_VAL), mean(HUGE_VAL), weightedMean(HUGE_VAL), sum(0.0), histogram(nullptr) {}
double min;
double max;
@ -57,6 +57,8 @@ class Rim3dOverlayInfoConfig : public caf::PdmObject
double sum;
double weightedMean;
const std::vector<size_t>* histogram;
bool isValid() { return histogram && histogram->size() > 0; }
};
public:
@ -97,6 +99,9 @@ private:
void updateEclipse3DInfo(RimEclipseView * reservoirView);
void updateGeoMech3DInfo(RimGeoMechView * geoMechView);
HistogramData histogramData(RimEclipseView* eclipseView);
HistogramData histogramData(RimGeoMechView* geoMechView);
caf::PdmField<bool> active;
caf::PdmField<bool> showAnimProgress;
caf::PdmField<bool> showCaseInfo;