From 4f05c0d6b99bfdba60ea0986fd6c8d3a5a24deb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 6 Nov 2015 13:22:54 +0100 Subject: [PATCH] (#606) (#607) Added eclipse stats for visible cells --- .../RigFemNativeVisibleCellsStatCalc.cpp | 73 --------- .../Rim3dOverlayInfoConfig.cpp | 141 +++++++++--------- .../ReservoirDataModel/CMakeLists_files.cmake | 2 + .../RigEclipseNativeVisibleCellsStatCalc.cpp | 91 +++++++++++ .../RigEclipseNativeVisibleCellsStatCalc.h | 72 +++++++++ .../RigStatisticsDataCache.cpp | 2 +- .../ResultStatisticsCache/RigStatisticsMath.h | 75 ++++++++++ .../RiuSimpleHistogramWidget.cpp | 35 +++++ .../UserInterface/RiuSimpleHistogramWidget.h | 8 +- 9 files changed, 354 insertions(+), 145 deletions(-) create mode 100644 ApplicationCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.cpp create mode 100644 ApplicationCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.h diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeVisibleCellsStatCalc.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeVisibleCellsStatCalc.cpp index cc7ed6b31c..b60a5ba5a2 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeVisibleCellsStatCalc.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeVisibleCellsStatCalc.cpp @@ -37,33 +37,6 @@ RigFemNativeVisibleCellsStatCalc::RigFemNativeVisibleCellsStatCalc(RigGeoMechCas m_resultsData = femCase->femPartResults(); } -class MinMaxAccumulator -{ -public: - MinMaxAccumulator(double initMin, double initMax): max(initMax), min(initMin) {} - void addValue(double value) - { - if (value == HUGE_VAL) // TODO - { - return; - } - - if (value < min) - { - min = value; - } - - if (value > max) - { - max = value; - } - } - - double max; - double min; -}; - - //-------------------------------------------------------------------------------------------------- /// @@ -77,32 +50,6 @@ void RigFemNativeVisibleCellsStatCalc::minMaxCellScalarValues(size_t timeStepInd } -class PosNegAccumulator -{ -public: - PosNegAccumulator(double initPos, double initNeg): pos(initPos), neg(initNeg) {} - void addValue(double value) - { - if (value == HUGE_VAL) - { - return; - } - - if (value < pos && value > 0) - { - pos = value; - } - - if (value > neg && value < 0) - { - neg = value; - } - } - - double pos; - double neg; -}; - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -115,26 +62,6 @@ void RigFemNativeVisibleCellsStatCalc::posNegClosestToZero(size_t timeStepIndex, } -class SumCountAccumulator -{ -public: - SumCountAccumulator(double initSum, size_t initCount): valueSum(initSum), sampleCount(initCount) {} - - void addValue(double value) - { - if (value == HUGE_VAL || value != value) - { - return; - } - - valueSum += value; - ++sampleCount; - } - - double valueSum; - size_t sampleCount; -}; - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 95e21c2632..1ce6ef516f 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -43,6 +43,7 @@ #include "RigStatisticsDataCache.h" #include "RigFemNativeVisibleCellsStatCalc.h" +#include "RigEclipseNativeVisibleCellsStatCalc.h" CAF_PDM_SOURCE_INIT(Rim3dOverlayInfoConfig, "View3dOverlayInfoConfig"); //-------------------------------------------------------------------------------------------------- @@ -174,6 +175,65 @@ void Rim3dOverlayInfoConfig::setReservoirView(RimView* ownerReservoirView) //-------------------------------------------------------------------------------------------------- void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * reservoirView) { + double min = HUGE_VAL, max = HUGE_VAL; + double p10 = HUGE_VAL, p90 = HUGE_VAL; + double mean = HUGE_VAL; + const std::vector* histogram = NULL; + + bool isResultsInfoRelevant = reservoirView->hasUserRequestedAnimation() && reservoirView->cellResult()->hasResult(); + + if (showHistogram() || showInfoText()) + { + if (isResultsInfoRelevant) + { + size_t scalarIndex = reservoirView->cellResult()->scalarResultIndex(); + if (m_statisticsCellRange == ALL_CELLS) + { + if (m_statisticsTimeRange == ALL_TIMESTEPS) + { + reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max); + reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); + reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean); + histogram = &(reservoirView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex)); + } + else if (m_statisticsTimeRange == CURRENT_TIMESTEP ) + { + int timeStepIdx = reservoirView->currentTimeStep(); + reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, timeStepIdx, min, max); + reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, timeStepIdx, p10, p90); + reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, timeStepIdx, mean); + histogram = &(reservoirView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex, timeStepIdx)); + } + 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(mean); + m_visibleCellStatistics->minMaxCellScalarValues(min, max); + m_visibleCellStatistics->p10p90CellScalarValues(p10, p90); + + histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram()); + } + else if (m_statisticsTimeRange == CURRENT_TIMESTEP) + { + int currentTimeStep = reservoirView->currentTimeStep(); + m_visibleCellStatistics->meanCellScalarValues(currentTimeStep, mean); + m_visibleCellStatistics->minMaxCellScalarValues(currentTimeStep, min, max); + m_visibleCellStatistics->p10p90CellScalarValues(currentTimeStep, p10, p90); + + histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram(currentTimeStep)); + } + } + } + } + if (showInfoText()) { QString caseName; @@ -217,39 +277,17 @@ void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * reservoirView) infoText += QString("Cell Property: %1 ").arg(propName); } - if (reservoirView->hasUserRequestedAnimation() && reservoirView->cellResult()->hasResult()) + if (isResultsInfoRelevant) { infoText += QString("Cell Property: %1 ").arg(propName); // Wait until regression tests confirm new statisticks is ok : //infoText += QString("
Statistics for: ") + m_statisticsTimeRange().uiText() + " and " + m_statisticsCellRange().uiText(); - if (m_statisticsCellRange == ALL_CELLS) - { - double min = HUGE_VAL, max = HUGE_VAL; - double p10 = HUGE_VAL, p90 = HUGE_VAL; - double mean = HUGE_VAL; - - size_t scalarIndex = reservoirView->cellResult()->scalarResultIndex(); - if (m_statisticsTimeRange == ALL_TIMESTEPS) - { - reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max); - reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); - reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean); - } - else if (m_statisticsTimeRange == CURRENT_TIMESTEP) - { - int timeStepIdx = reservoirView->currentTimeStep(); - reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, timeStepIdx, min, max); - reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, timeStepIdx, p10, p90); - reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, timeStepIdx, mean); - } - - infoText += QString("" - "" - "" - "
Min P10 Mean P90 Max
%1 %2 %3 %4 %5
").arg(min).arg(p10).arg(mean).arg(p90).arg(max); - } + infoText += QString("" + "" + "" + "
Min P10 Mean P90 Max
%1 %2 %3 %4 %5
").arg(min).arg(p10).arg(mean).arg(p90).arg(max); if (reservoirView->faultResultSettings()->hasValidCustomResult()) { @@ -309,41 +347,11 @@ void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * reservoirView) if (showHistogram()) { - if (reservoirView->hasUserRequestedAnimation() && reservoirView->cellResult()->hasResult()) + if (isResultsInfoRelevant) { - if (m_statisticsCellRange == ALL_CELLS) - { - double min = HUGE_VAL, max = HUGE_VAL; - double p10 = HUGE_VAL, p90 = HUGE_VAL; - double mean = HUGE_VAL; - const std::vector* histogram = NULL; - - size_t scalarIndex = reservoirView->cellResult()->scalarResultIndex(); - - if (m_statisticsTimeRange == ALL_TIMESTEPS) - { - reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max); - reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); - reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean); - histogram = &(reservoirView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex)); - } - else if (m_statisticsTimeRange == CURRENT_TIMESTEP ) - { - int timeStepIdx = reservoirView->currentTimeStep(); - reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, timeStepIdx, min, max); - reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, timeStepIdx, p10, p90); - reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, timeStepIdx, mean); - histogram = &(reservoirView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex, timeStepIdx)); - } - else - { - CVF_ASSERT(false); - } - - reservoirView->viewer()->showHistogram(true); - reservoirView->viewer()->setHistogram(min, max, *histogram); - reservoirView->viewer()->setHistogramPercentiles(p10, p90, mean); - } + reservoirView->viewer()->showHistogram(true); + reservoirView->viewer()->setHistogram(min, max, *histogram); + reservoirView->viewer()->setHistogramPercentiles(p10, p90, mean); } } } @@ -511,15 +519,14 @@ void Rim3dOverlayInfoConfig::updateVisCellStatsIfNeeded() calc = new RigFemNativeVisibleCellsStatCalc(geoMechView->geoMechCase()->geoMechData(), resAddress, geoMechView->currentTotalCellVisibility().p()); - m_visibleCellStatistics = new RigStatisticsDataCache(calc.p()); - m_isVisCellStatUpToDate = true; + } else if (eclipseView) { - // RigFemResultAddress resAddress = geoMechView->cellResult()->resultAddress(); - // cvf::ref calc = new RigEclipseNativeVisibleCellsStatCalc(geoMechView->geoMechCase()->geoMechData(), - // resAddress, - // geoMechView->currentTotalCellVisibility().p()); + size_t scalarIndex = eclipseView->cellResult()->scalarResultIndex(); + calc = new RigEclipseNativeVisibleCellsStatCalc(eclipseView->currentGridCellResults()->cellResults(), + scalarIndex, + eclipseView->currentTotalCellVisibility().p()); } m_visibleCellStatistics = new RigStatisticsDataCache(calc.p()); diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 68d64de050..3afd3f2d9c 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -35,6 +35,7 @@ ${CEE_CURRENT_LIST_DIR}RigPipeInCellEvaluator.h ${CEE_CURRENT_LIST_DIR}RigResultAccessor2d.h ${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.h ${CEE_CURRENT_LIST_DIR}RigEclipseNativeStatCalc.h +${CEE_CURRENT_LIST_DIR}RigEclipseNativeVisibleCellsStatCalc.h ${CEE_CURRENT_LIST_DIR}RigEclipseMultiPropertyStatCalc.h ${CEE_CURRENT_LIST_DIR}RigWellLogCurveData.h ${CEE_CURRENT_LIST_DIR}RigTimeHistoryResultAccessor.h @@ -68,6 +69,7 @@ ${CEE_CURRENT_LIST_DIR}RigNNCData.cpp ${CEE_CURRENT_LIST_DIR}cvfGeometryTools.cpp ${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.cpp ${CEE_CURRENT_LIST_DIR}RigEclipseNativeStatCalc.cpp +${CEE_CURRENT_LIST_DIR}RigEclipseNativeVisibleCellsStatCalc.cpp ${CEE_CURRENT_LIST_DIR}RigEclipseMultiPropertyStatCalc.cpp ${CEE_CURRENT_LIST_DIR}RigWellLogCurveData.cpp ${CEE_CURRENT_LIST_DIR}RigTimeHistoryResultAccessor.cpp diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.cpp new file mode 100644 index 0000000000..0281f7b94d --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.cpp @@ -0,0 +1,91 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + + +#include "RigEclipseNativeVisibleCellsStatCalc.h" + +#include +#include "RigStatisticsMath.h" +#include "RigCaseCellResultsData.h" +#include "RigActiveCellInfo.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigEclipseNativeVisibleCellsStatCalc::RigEclipseNativeVisibleCellsStatCalc(RigCaseCellResultsData* cellResultsData, + size_t scalarResultIndex, + const cvf::UByteArray* cellVisibilities) +: m_caseData(cellResultsData), + m_scalarResultIndex(scalarResultIndex), + m_cellVisibilities(cellVisibilities) +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigEclipseNativeVisibleCellsStatCalc::minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max) +{ + MinMaxAccumulator acc(min, max); + traverseCells(acc, timeStepIndex); + min = acc.min; + max = acc.max; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigEclipseNativeVisibleCellsStatCalc::posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg) +{ + PosNegAccumulator acc(pos, neg); + traverseCells(acc, timeStepIndex); + pos = acc.pos; + neg = acc.neg; + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigEclipseNativeVisibleCellsStatCalc::valueSumAndSampleCount(size_t timeStepIndex, double& valueSum, size_t& sampleCount) +{ + SumCountAccumulator acc(valueSum, sampleCount); + traverseCells(acc, timeStepIndex); + valueSum = acc.valueSum; + sampleCount = acc.sampleCount; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigEclipseNativeVisibleCellsStatCalc::addDataToHistogramCalculator(size_t timeStepIndex, RigHistogramCalculator& histogramCalculator) +{ + traverseCells(histogramCalculator, timeStepIndex); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigEclipseNativeVisibleCellsStatCalc::timeStepCount() +{ + return m_caseData->timeStepCount(m_scalarResultIndex); +} + + diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.h b/ApplicationCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.h new file mode 100644 index 0000000000..1c58e067fc --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.h @@ -0,0 +1,72 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + + +//================================================================================================== +/// +//================================================================================================== +#include "RigStatisticsCalculator.h" +#include "cvfArray.h" + +class RigCaseCellResultsData; + + +class RigEclipseNativeVisibleCellsStatCalc : public RigStatisticsCalculator +{ +public: + RigEclipseNativeVisibleCellsStatCalc(RigCaseCellResultsData* cellResultsData, + size_t scalarResultIndex, + const cvf::UByteArray* cellVisibilities); + + virtual void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max); + virtual void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg); + virtual void valueSumAndSampleCount(size_t timeStepIndex, double& valueSum, size_t& sampleCount); + virtual void addDataToHistogramCalculator(size_t timeStepIndex, RigHistogramCalculator& histogramCalculator); + virtual size_t timeStepCount(); + +private: + RigCaseCellResultsData* m_caseData; + size_t m_scalarResultIndex; + cvf::cref m_cellVisibilities; + + template + void traverseCells(StatisticsAccumulator& accumulator, size_t timeStepIndex) + { + std::vector& values = m_caseData->cellScalarResults(m_scalarResultIndex, timeStepIndex); + const RigActiveCellInfo* actCellInfo = m_caseData->activeCellInfo(); + size_t cellCount = actCellInfo->reservoirCellCount(); + + CVF_TIGHT_ASSERT(cellCount == m_cellVisibilities->size()); + + for (size_t cIdx = 0; cIdx < cellCount; ++cIdx) + { + if (!(*m_cellVisibilities)[cIdx]) continue; + + size_t cellResultIndex = actCellInfo->cellResultIndex(cIdx); + + if (cellResultIndex != cvf::UNDEFINED_SIZE_T) accumulator.addValue(values[cellResultIndex]); + } + } + +}; + + + diff --git a/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.cpp b/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.cpp index 774278f324..acb1947449 100644 --- a/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.cpp +++ b/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.cpp @@ -263,7 +263,7 @@ void RigStatisticsDataCache::computeHistogramStatisticsIfNeeded(size_t timeStepI double min; double max; size_t nBins = 100; - this->minMaxCellScalarValues(min, max); + this->minMaxCellScalarValues(timeStepIndex, min, max); RigHistogramCalculator histCalc(min, max, nBins, &m_statsPrTs[timeStepIndex].m_histogram); diff --git a/ApplicationCode/ResultStatisticsCache/RigStatisticsMath.h b/ApplicationCode/ResultStatisticsCache/RigStatisticsMath.h index 741edf2eb2..5aac8c258a 100644 --- a/ApplicationCode/ResultStatisticsCache/RigStatisticsMath.h +++ b/ApplicationCode/ResultStatisticsCache/RigStatisticsMath.h @@ -56,3 +56,78 @@ private: size_t m_observationCount; std::vector* m_histogram; }; + + +class MinMaxAccumulator +{ +public: + MinMaxAccumulator(double initMin, double initMax): max(initMax), min(initMin) {} + void addValue(double value) + { + if (value == HUGE_VAL) // TODO + { + return; + } + + if (value < min) + { + min = value; + } + + if (value > max) + { + max = value; + } + } + + double max; + double min; +}; + + +class PosNegAccumulator +{ +public: + PosNegAccumulator(double initPos, double initNeg): pos(initPos), neg(initNeg) {} + void addValue(double value) + { + if (value == HUGE_VAL) + { + return; + } + + if (value < pos && value > 0) + { + pos = value; + } + + if (value > neg && value < 0) + { + neg = value; + } + } + + double pos; + double neg; +}; + + +class SumCountAccumulator +{ +public: + SumCountAccumulator(double initSum, size_t initCount): valueSum(initSum), sampleCount(initCount) {} + + void addValue(double value) + { + if (value == HUGE_VAL || value != value) + { + return; + } + + valueSum += value; + ++sampleCount; + } + + double valueSum; + size_t sampleCount; +}; diff --git a/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.cpp b/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.cpp index f5384166de..11eb954553 100644 --- a/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.cpp +++ b/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.cpp @@ -105,3 +105,38 @@ void RiuSimpleHistogramWidget::setHistogramData(double min, double max, const st if (m_maxHistogramCount < m_histogramData[colIdx]) m_maxHistogramCount = m_histogramData[colIdx] ; } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSimpleHistogramWidget::setPercentiles(double pmin, double pmax) +{ + m_minPercentile = pmin; + m_maxPercentile = pmax; +} + +#define xBorder 1 +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RiuSimpleHistogramWidget::xPosFromColIdx(size_t colIdx) +{ + return (int)(m_x + xBorder + (m_width - 2*xBorder) * colIdx/m_histogramData.size()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RiuSimpleHistogramWidget::xPosFromDomainValue(double value) +{ + double range = m_max - m_min; + return (range == 0.0) ? (int)(m_x + xBorder) : (int)(m_x + xBorder + (m_width - 2*xBorder) * (value - m_min)/(m_max - m_min)); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RiuSimpleHistogramWidget::yPosFromCount(size_t colHeight) +{ + return (int)(m_y + m_height - 1 - (m_height - 3) * colHeight/m_maxHistogramCount); +} diff --git a/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.h b/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.h index 5ced51fa8e..2dd2a409fa 100644 --- a/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.h +++ b/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.h @@ -10,7 +10,7 @@ public: RiuSimpleHistogramWidget( QWidget * parent = 0, Qt::WindowFlags f = 0); void setHistogramData(double min, double max, const std::vector& histogram); - void setPercentiles(double pmin, double pmax) {m_minPercentile = pmin; m_maxPercentile = pmax;} + void setPercentiles(double pmin, double pmax); void setMean(double mean) {m_mean = mean;} protected: @@ -19,10 +19,10 @@ protected: private: void draw(QPainter *painter,int x, int y, int width, int height ); - int xPosFromColIdx(size_t colIdx) { return (int)(m_x + 1 + (m_width - 2 ) * colIdx/m_histogramData.size());} - int yPosFromCount(size_t colHeight) { return (int)(m_y + m_height - 1 - (m_height - 3 ) * colHeight/m_maxHistogramCount);} + int xPosFromColIdx(size_t colIdx); + int yPosFromCount(size_t colHeight); - int xPosFromDomainValue(double value) { double range = m_max - m_min; return (range == 0.0) ? (int)(m_x + 1) : (int)(m_x + 1 + (m_width - 2 ) * (value - m_min)/(m_max - m_min));} + int xPosFromDomainValue(double value); std::vector m_histogramData; double m_max;