From 670693dd5f12f9c077fc15fddb6e94ad47e72ebd Mon Sep 17 00:00:00 2001 From: sawinglogz <3787776-sawinglogz@users.noreply.gitlab.com> Date: Mon, 27 Apr 2020 16:55:56 -0400 Subject: [PATCH] Move gPressureChart value calculation into addSlice. --- oscar/Graphs/gPressureChart.cpp | 97 ++++++++++++--------------------- oscar/Graphs/gPressureChart.h | 2 +- 2 files changed, 35 insertions(+), 64 deletions(-) diff --git a/oscar/Graphs/gPressureChart.cpp b/oscar/Graphs/gPressureChart.cpp index 85da32be..55d3e2ea 100644 --- a/oscar/Graphs/gPressureChart.cpp +++ b/oscar/Graphs/gPressureChart.cpp @@ -98,21 +98,26 @@ QString gPressureChart::channelRange(ChannelID code, const QString & label) } -void gPressureChart::addSlice(float value, ChannelID code, SummaryType type) +void gPressureChart::addSlice(ChannelID code, SummaryType type) { - SummaryCalcItem* calc = getCalc(code, type); - float height = value - m_height; + float value = 0; QString label; switch (type) { case ST_SETMIN: + value = m_day->settings_min(code); + label = schema::channel[code].label(); + break; case ST_SETMAX: + value = m_day->settings_max(code); label = schema::channel[code].label(); break; case ST_MID: + value = m_day->calcMiddle(code); label = m_day->calcMiddleLabel(code); break; case ST_90P: + value = m_day->calcPercentile(code); label = m_day->calcPercentileLabel(code); break; default: @@ -120,6 +125,9 @@ void gPressureChart::addSlice(float value, ChannelID code, SummaryType type) break; } + SummaryCalcItem* calc = getCalc(code, type); + float height = value - m_height; + m_slices->append(SummaryChartSlice(calc, value, height, label, calc->color)); m_height += height; } @@ -133,80 +141,43 @@ void gPressureChart::populate(Day * day, int idx) m_height = 0; if (mode == MODE_CPAP) { - float pr = day->settings_max(CPAP_Pressure); - addSlice(pr, CPAP_Pressure); + addSlice(CPAP_Pressure); } else if (mode == MODE_APAP) { - float min = day->settings_min(CPAP_PressureMin); - float max = day->settings_max(CPAP_PressureMax); - - addSlice(min, CPAP_PressureMin, ST_SETMIN); + addSlice(CPAP_PressureMin, ST_SETMIN); if (!day->summaryOnly()) { - float med = day->calcMiddle(CPAP_Pressure); - addSlice(med, CPAP_Pressure, ST_MID); - - float p90 = day->calcPercentile(CPAP_Pressure); - addSlice(p90, CPAP_Pressure, ST_90P); + addSlice(CPAP_Pressure, ST_MID); + addSlice(CPAP_Pressure, ST_90P); } - addSlice(max, CPAP_PressureMax, ST_SETMAX); + addSlice(CPAP_PressureMax, ST_SETMAX); } else if (mode == MODE_BILEVEL_FIXED) { - float epap = day->settings_max(CPAP_EPAP); - float ipap = day->settings_max(CPAP_IPAP); - - addSlice(epap, CPAP_EPAP); - addSlice(ipap, CPAP_IPAP); + addSlice(CPAP_EPAP); + addSlice(CPAP_IPAP); } else if (mode == MODE_BILEVEL_AUTO_FIXED_PS) { - float epap = day->settings_max(CPAP_EPAPLo); - float ipap = day->settings_max(CPAP_IPAPHi); - - addSlice(epap, CPAP_EPAPLo); + addSlice(CPAP_EPAPLo); if (!day->summaryOnly()) { - - float e50 = day->calcMiddle(CPAP_EPAP); - addSlice(e50, CPAP_EPAP, ST_MID); - - float e90 = day->calcPercentile(CPAP_EPAP); - addSlice(e90, CPAP_EPAP, ST_90P); - - float i50 = day->calcMiddle(CPAP_IPAP); - addSlice(i50, CPAP_IPAP, ST_MID); - - float i90 = day->calcPercentile(CPAP_IPAP); - addSlice(i90, CPAP_IPAP, ST_90P); + addSlice(CPAP_EPAP, ST_MID); + addSlice(CPAP_EPAP, ST_90P); + addSlice(CPAP_IPAP, ST_MID); + addSlice(CPAP_IPAP, ST_90P); } - addSlice(ipap, CPAP_IPAPHi); + addSlice(CPAP_IPAPHi); } else if ((mode == MODE_BILEVEL_AUTO_VARIABLE_PS) || (mode == MODE_ASV_VARIABLE_EPAP)) { - float epap = day->settings_max(CPAP_EPAPLo); - - addSlice(epap, CPAP_EPAPLo); + addSlice(CPAP_EPAPLo); if (!day->summaryOnly()) { - float e50 = day->calcMiddle(CPAP_EPAP); - addSlice(e50, CPAP_EPAP, ST_MID); - - float e90 = day->calcPercentile(CPAP_EPAP); - addSlice(e90, CPAP_EPAP, ST_90P); - - float i50 = day->calcMiddle(CPAP_IPAP); - addSlice(i50, CPAP_IPAP, ST_MID); - - float i90 = day->calcPercentile(CPAP_IPAP); - addSlice(i90, CPAP_IPAP, ST_90P); + addSlice(CPAP_EPAP, ST_MID); + addSlice(CPAP_EPAP, ST_90P); + addSlice(CPAP_IPAP, ST_MID); + addSlice(CPAP_IPAP, ST_90P); } - float ipap = day->settings_max(CPAP_IPAPHi); - addSlice(ipap, CPAP_IPAPHi); + addSlice(CPAP_IPAPHi); } else if (mode == MODE_ASV) { - float epap = day->settings_max(CPAP_EPAP); - - addSlice(epap, CPAP_EPAP); + addSlice(CPAP_EPAP); if (!day->summaryOnly()) { - float i50 = day->calcMiddle(CPAP_IPAP); - addSlice(i50, CPAP_IPAP, ST_MID); - - float i90 = day->calcPercentile(CPAP_IPAP); - addSlice(i90, CPAP_IPAP, ST_90P); + addSlice(CPAP_IPAP, ST_MID); + addSlice(CPAP_IPAP, ST_90P); } - float ipap = day->settings_max(CPAP_IPAPHi); - addSlice(ipap, CPAP_IPAPHi); + addSlice(CPAP_IPAPHi); } } diff --git a/oscar/Graphs/gPressureChart.h b/oscar/Graphs/gPressureChart.h index 692b11ad..842d1c94 100644 --- a/oscar/Graphs/gPressureChart.h +++ b/oscar/Graphs/gPressureChart.h @@ -48,7 +48,7 @@ public: protected: SummaryCalcItem* getCalc(ChannelID code, SummaryType type = ST_SETMAX); QString channelRange(ChannelID code, const QString & label); - void addSlice(float value, ChannelID code, SummaryType type = ST_SETMAX); + void addSlice(ChannelID code, SummaryType type = ST_SETMAX); QHash> m_calcs;