From 26eddd444472f3cc37016382e52215fc82e48a6f Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Tue, 3 Jan 2012 17:15:02 +1000 Subject: [PATCH] Fix gold highlights in overview not disappearing when leaving graph --- Graphs/gGraphView.cpp | 37 +++++- Graphs/gGraphView.h | 9 ++ Graphs/gSummaryChart.cpp | 25 ++-- Graphs/gSummaryChart.h | 4 + SleepLib/day.cpp | 6 +- SleepLib/loader_plugins/prs1_loader.cpp | 34 +++-- SleepLib/loader_plugins/resmed_loader.cpp | 148 +++++++--------------- SleepLib/loader_plugins/resmed_loader.h | 1 + SleepLib/session.cpp | 33 +++-- SleepLib/session.h | 12 +- mainwindow.cpp | 2 +- overview.cpp | 2 +- 12 files changed, 166 insertions(+), 147 deletions(-) diff --git a/Graphs/gGraphView.cpp b/Graphs/gGraphView.cpp index dcaa1e10..1f005694 100644 --- a/Graphs/gGraphView.cpp +++ b/Graphs/gGraphView.cpp @@ -1037,6 +1037,16 @@ void gGraph::deselect() (*l)->deselect(); } } +bool gGraph::isSelected() +{ + bool res=false; + for (QVector::iterator l=m_layers.begin();l!=m_layers.end();l++) { + res=(*l)->isSelected(); + if (res) break; + } + return res; +} + bool gGraph::isEmpty() { bool empty=true; @@ -2803,10 +2813,35 @@ void gGraphView::mouseMoveEvent(QMouseEvent * event) if (py > height()) break; // we are done.. can't draw anymore + if (!((y >= py+m_graphs[i]->top) && (y < py + h-m_graphs[i]->bottom))) { + if (m_graphs[i]->isSelected()) { + m_graphs[i]->deselect(); + timedRedraw(150); + //redraw(); + } + } if (m_button_down || ((py + h + graphSpacer) >= 0)) { if ((y >= py + h) && (y <= py + h + graphSpacer + 1)) { this->setCursor(Qt::SplitVCursor); - } else if (m_button_down || ((y >= py) && (y < py + h))) { + } else if (!m_button_down && (y >= py) && (y < py+m_graphs[i]->top)) { + // Mouse cursor is in top graph margin. +// if (m_graphs[i]->isSelected()) { +// m_graphs[i]->deselect(); +// if (m_tooltip->visible()) +// m_tooltip->cancel(); +// redraw(); +// } + //qDebug() << "upper bounds"; + } else if (!m_button_down && (y >= py+h-m_graphs[i]->bottom) && (y <= py+h)) { + // Mouse cursor is in bottom grpah margin. +// if (m_graphs[i]->isSelected()) { +// if (m_tooltip->visible()) +// m_tooltip->cancel(); +// m_graphs[i]->deselect(); +// redraw(); +// } + //qDebug() << "lower bounds"; + } else if (m_button_down || ((y >= py+m_graphs[i]->top) && (y < py + h-m_graphs[i]->bottom))) { if (m_button_down || (x >= titleWidth+10)) { //(gYAxis::Margin-5) this->setCursor(Qt::ArrowCursor); m_horiz_travel+=qAbs(x-m_lastxpos)+qAbs(y-m_lastypos); diff --git a/Graphs/gGraphView.h b/Graphs/gGraphView.h index df66e727..b1717daa 100644 --- a/Graphs/gGraphView.h +++ b/Graphs/gGraphView.h @@ -280,6 +280,9 @@ public: //! \brief returns true if this layer contains no data. virtual bool isEmpty(); + //! \brief Override and returns true if there are any highlighted components + virtual bool isSelected() { return false; } + //! \brief Deselect any highlighted components virtual void deselect() { } @@ -476,6 +479,9 @@ public: //! \brief Close the tooltip early. void cancel(); + + //! \brief Returns true if the tooltip is currently visible + bool visible() { return m_visible; } protected: gGraphView * m_graphview; QTimer * timer; @@ -511,6 +517,9 @@ public: //! \brief Tells all Layers to deselect any highlighting void deselect(); + //! \brief Returns true if any Layers have anything highlighted + bool isSelected(); + //! \brief Starts the singleshot Timer running, for ms milliseconds void Trigger(int ms); diff --git a/Graphs/gSummaryChart.cpp b/Graphs/gSummaryChart.cpp index 84f52c9b..119981b4 100644 --- a/Graphs/gSummaryChart.cpp +++ b/Graphs/gSummaryChart.cpp @@ -74,13 +74,12 @@ void SummaryChart::SetDay(Day * nullday) } else if (mode>=MODE_BIPAP) { addSlice(CPAP_EPAP,QColor("green"),ST_SETMIN); addSlice(CPAP_EPAP,QColor("light green"),ST_PERC,0.95); - - addSlice(CPAP_IPAP,QColor("light cyan"),ST_WAVG); + addSlice(CPAP_IPAP,QColor("light cyan"),ST_PERC,0.5); addSlice(CPAP_IPAP,QColor("light blue"),ST_PERC,0.95); addSlice(CPAP_IPAP,QColor("blue"),ST_SETMAX); } else if (mode>=MODE_APAP) { addSlice(CPAP_PressureMin,QColor("orange"),ST_SETMIN); - addSlice(CPAP_Pressure,QColor("dark green"),ST_WAVG); + addSlice(CPAP_Pressure,QColor("dark green"),ST_PERC,0.5); addSlice(CPAP_Pressure,QColor("grey"),ST_PERC,0.95); addSlice(CPAP_PressureMax,QColor("red"),ST_SETMAX); } else { @@ -182,11 +181,10 @@ void SummaryChart::SetDay(Day * nullday) if (code==CPAP_Pressure) { if (mode==MODE_CPAP) { - if (type==ST_PERC) - hascode=false; - else if (type==ST_WAVG) { - //hascode=false; + hascode=false; + if ((type==ST_PERC) && (m_typeval[j]==0.5)) { type=ST_SETWAVG; + hascode=true; } } else { @@ -612,7 +610,12 @@ jumpnext: case ST_WAVG: b="Avg"; break; case ST_AVG: b="Avg"; break; case ST_90P: b="90%"; break; - case ST_PERC: b=QString("%1%").arg(tval*100.0,0,'f',0); break; + case ST_PERC: + if (tval>=0.99) b="Max"; + else if (tval==0.5) b="Med"; + else b=QString("%1%").arg(tval*100.0,0,'f',0); + break; + //b=QString("%1%").arg(tval*100.0,0,'f',0); break; case ST_MIN: b="Min"; break; case ST_MAX: b="Max"; break; case ST_SETMIN: b="Min"; break; @@ -827,7 +830,11 @@ bool SummaryChart::mouseMoveEvent(QMouseEvent *event) case ST_WAVG: a="W-avg"; break; case ST_AVG: a="Avg"; break; case ST_90P: a="90%"; break; - case ST_PERC: a=QString("%1%").arg(tval*100.0,0,'f',0); break; + case ST_PERC: + if (tval>=0.99) a="Max"; + else if (tval==0.5) a="Med"; + else a=QString("%1%").arg(tval*100.0,0,'f',0); + break; case ST_MIN: a="Min"; break; case ST_MAX: a="Max"; break; case ST_CPH: a=""; break; diff --git a/Graphs/gSummaryChart.h b/Graphs/gSummaryChart.h index 2d7fa879..3e4baf48 100644 --- a/Graphs/gSummaryChart.h +++ b/Graphs/gSummaryChart.h @@ -52,6 +52,10 @@ class SummaryChart:public Layer hl_day=-1; } + //! \brief Returns true if currently selected.. + virtual bool isSelected() { return hl_day>=0; } + + //! \brief Sets the MachineType this SummaryChart is interested in void setMachineType(MachineType type) { m_machinetype=type; } diff --git a/SleepLib/day.cpp b/SleepLib/day.cpp index 1cb83b4d..034593bf 100644 --- a/SleepLib/day.cpp +++ b/SleepLib/day.cpp @@ -375,9 +375,9 @@ bool Day::hasData(ChannelID code, SummaryType type) if (!(*s)->enabled()) continue; Session *sess=*s; switch(type) { - case ST_90P: - has=sess->m_90p.contains(code); - break; +// case ST_90P: +// has=sess->m_90p.contains(code); +// break; case ST_PERC: has=sess->m_valuesummary.contains(code); break; diff --git a/SleepLib/loader_plugins/prs1_loader.cpp b/SleepLib/loader_plugins/prs1_loader.cpp index dfccb3d4..a77cf1d9 100644 --- a/SleepLib/loader_plugins/prs1_loader.cpp +++ b/SleepLib/loader_plugins/prs1_loader.cpp @@ -519,19 +519,31 @@ bool PRS1Loader::ParseSummary(Machine *mach, qint32 sequence, quint32 timestamp, float hours=float(duration)/3600.0; // Not using these because sometimes this summary is broken. - EventDataType minp,maxp,avgp,p90p; + //EventDataType minp,maxp,avgp,p90p; - minp=float(data[offset+0x16])/10.0; - maxp=float(data[offset+0x17])/10.0; - p90p=float(data[offset+0x18])/10.0; - avgp=float(data[offset+0x19])/10.0; + //minp=float(data[offset+0x16])/10.0; + //maxp=float(data[offset+0x17])/10.0; + //p90p=float(data[offset+0x18])/10.0; + //avgp=float(data[offset+0x19])/10.0; - if (minp>0) session->setMin(CPAP_Pressure,minp); - if (maxp>0) session->setMax(CPAP_Pressure,maxp); - if (avgp>0) session->setWavg(CPAP_Pressure,avgp); - if (p90p>0) { - session->set90p(CPAP_Pressure,p90p); - } + short minp=data[offset+0x16]; + short maxp=data[offset+0x17]; + short medp=data[offset+0x19]; + short p90p=data[offset+0x18]; + + if (minp>0) session->setMin(CPAP_Pressure,EventDataType(minp)*0.10); + if (maxp>0) session->setMax(CPAP_Pressure,EventDataType(maxp)*0.10); + if (medp>0) session->setWavg(CPAP_Pressure,EventDataType(medp)*0.10); // ?? + + session->m_gain[CPAP_Pressure]=0.1; + session->m_valuesummary[CPAP_Pressure][minp]=5; + session->m_valuesummary[CPAP_Pressure][medp]=46; + session->m_valuesummary[CPAP_Pressure][p90p]=44; + session->m_valuesummary[CPAP_Pressure][maxp]=5; + +// if (p90p>0) { +// session->set90p(CPAP_Pressure,p90p); +// } int oc, cc, hc, rc, fc; session->setCount(CPAP_Obstructive,oc=(int)data[offset+0x1C] | (data[offset+0x1D] << 8)); diff --git a/SleepLib/loader_plugins/resmed_loader.cpp b/SleepLib/loader_plugins/resmed_loader.cpp index ffe93bab..1ea738bc 100644 --- a/SleepLib/loader_plugins/resmed_loader.cpp +++ b/SleepLib/loader_plugins/resmed_loader.cpp @@ -39,6 +39,14 @@ EDFSignal * EDFParser::lookupSignal(ChannelID ch) } return NULL; } +EDFSignal * EDFParser::lookupName(QString name) +{ + QHash::iterator i=lookup.find(name); + if (i!=lookup.end()) return i.value(); + return NULL; +} + + EDFParser::EDFParser(QString name) { @@ -630,20 +638,16 @@ int ResmedLoader::Open(QString & path,Profile *profile) sess->settings[CPAP_Mode]=MODE_BIPAP; EventDataType tmp,epap=0,ipap=0; - if (stredf.lookup.contains("EPAP")) { - sig=stredf.lookup["EPAP"]; - //div=50; //1.0/sig->gain; + if ((sig=stredf.lookupName("EPAP"))) { epap=sig->data[dn]*sig->gain; sess->settings[CPAP_EPAP]=epap; sess->setMin(CPAP_EPAP,epap); } - if (stredf.lookup.contains("IPAP")) { - sig=stredf.lookup["IPAP"]; + if ((sig=stredf.lookupName("IPAP"))) { ipap=sig->data[dn]*sig->gain; sess->settings[CPAP_IPAP]=ipap; } - if (stredf.lookup.contains("PS")) { - sig=stredf.lookup["PS"]; + if ((sig=stredf.lookupName("PS"))) { tmp=sig->data[dn]*sig->gain; sess->settings[CPAP_PS]=tmp; // technically this is IPAP-EPAP if (!ipap) { @@ -651,27 +655,23 @@ int ResmedLoader::Open(QString & path,Profile *profile) sess->settings[CPAP_IPAP]=epap+tmp; } } - if (stredf.lookup.contains("Min PS")) { - sig=stredf.lookup["Min PS"]; + if ((sig=stredf.lookupName("Min PS"))) { tmp=sig->data[dn]*sig->gain; sess->settings[CPAP_PSMin]=tmp; sess->settings[CPAP_IPAPLo]=epap+tmp; sess->setMin(CPAP_IPAP,epap+tmp); } - if (stredf.lookup.contains("Max PS")) { - sig=stredf.lookup["Max PS"]; + if ((sig=stredf.lookupName("Max PS"))) { tmp=sig->data[dn]*sig->gain; sess->settings[CPAP_PSMax]=tmp; sess->settings[CPAP_IPAPHi]=epap+tmp; } - if (stredf.lookup.contains("RR")) { // Is this a setting to force respiratory rate on S/T machines? - sig=stredf.lookup["RR"]; + if ((sig=stredf.lookupName("RR"))) { // Is this a setting to force respiratory rate on S/T machines? tmp=sig->data[dn]; sess->settings[CPAP_RespRate]=tmp*sig->gain; } - if (stredf.lookup.contains("Easy-Breathe")) { - sig=stredf.lookup["Easy-Breathe"]; + if ((sig=stredf.lookupName("Easy-Breathe"))) { tmp=sig->data[dn]*sig->gain; sess->settings[CPAP_PresReliefSet]=tmp; @@ -699,218 +699,164 @@ int ResmedLoader::Open(QString & path,Profile *profile) EventDataType valmed=0,valmax=0,val95=0; - if (stredf.lookup.contains("Leak Med")) { - sig=stredf.lookup["Leak Med"]; + if ((sig=stredf.lookupName("Leak Med"))) { valmed=sig->data[dn]; - sess->setMedian(CPAP_Leak,valmed*sig->gain*60.0); sess->m_gain[CPAP_Leak]=sig->gain*60.0; sess->m_valuesummary[CPAP_Leak][valmed]=51; } - if (stredf.lookup.contains("Leak 95")) { - sig=stredf.lookup["Leak 95"]; + if ((sig=stredf.lookupName("Leak 95"))) { val95=sig->data[dn]; - sess->set95p(CPAP_Leak,val95*sig->gain*60.0); sess->m_valuesummary[CPAP_Leak][val95]=45; } - if (stredf.lookup.contains("Leak Max")) { - sig=stredf.lookup["Leak Max"]; + if ((sig=stredf.lookupName("Leak Max"))) { valmax=sig->data[dn]; sess->setMax(CPAP_Leak,valmax*sig->gain*60.0); sess->m_valuesummary[CPAP_Leak][valmax]=4; } - if (stredf.lookup.contains("Min Vent Med")) { - sig=stredf.lookup["Min Vent Med"]; + if ((sig=stredf.lookupName("Min Vent Med"))) { valmed=sig->data[dn]; - sess->setMedian(CPAP_MinuteVent,valmed*sig->gain); sess->m_gain[CPAP_MinuteVent]=sig->gain; sess->m_valuesummary[CPAP_MinuteVent][valmed]=51; } - if (stredf.lookup.contains("Min Vent 95")) { - sig=stredf.lookup["Min Vent 95"]; + if ((sig=stredf.lookupName("Min Vent 95"))) { val95=sig->data[dn]; - sess->set95p(CPAP_MinuteVent,val95*sig->gain); sess->m_valuesummary[CPAP_MinuteVent][val95]=45; } - if (stredf.lookup.contains("Min Vent Max")) { - sig=stredf.lookup["Min Vent Max"]; + if ((sig=stredf.lookupName("Min Vent Max"))) { valmax=sig->data[dn]; sess->setMax(CPAP_MinuteVent,valmax*sig->gain); sess->m_valuesummary[CPAP_MinuteVent][valmax]=4; } - if (stredf.lookup.contains("RR Med")) { - sig=stredf.lookup["RR Med"]; + if ((sig=stredf.lookupName("RR Med"))) { valmed=sig->data[dn]; - sess->setMedian(CPAP_RespRate,valmed*sig->gain); sess->m_gain[CPAP_RespRate]=sig->gain; sess->m_valuesummary[CPAP_RespRate][valmed]=51; } - if (stredf.lookup.contains("RR 95")) { - sig=stredf.lookup["RR 95"]; + if ((sig=stredf.lookupName("RR 95"))) { val95=sig->data[dn]; - sess->set95p(CPAP_RespRate,val95*sig->gain); sess->m_valuesummary[CPAP_RespRate][val95]=45; } - if (stredf.lookup.contains("RR Max")) { - sig=stredf.lookup["RR Max"]; + if ((sig=stredf.lookupName("RR Max"))) { valmax=sig->data[dn]; sess->setMax(CPAP_RespRate,valmax*sig->gain); sess->m_valuesummary[CPAP_RespRate][valmax]=4; } - if (stredf.lookup.contains("Tid Vol Med")) { - sig=stredf.lookup["Tid Vol Med"]; + if ((sig=stredf.lookupName("Tid Vol Med"))) { valmed=sig->data[dn]; - sess->setMedian(CPAP_TidalVolume,valmed*sig->gain*1000.0); sess->m_gain[CPAP_TidalVolume]=sig->gain*1000.0; sess->m_valuesummary[CPAP_TidalVolume][valmed]=51; } - if (stredf.lookup.contains("Tid Vol 95")) { - sig=stredf.lookup["Tid Vol 95"]; + if ((sig=stredf.lookupName("Tid Vol 95"))) { val95=sig->data[dn]; - sess->set95p(CPAP_TidalVolume,val95*sig->gain*1000.0); sess->m_valuesummary[CPAP_TidalVolume][val95]=45; } - if (stredf.lookup.contains("Tid Vol Max")) { - sig=stredf.lookup["Tid Vol Max"]; + if ((sig=stredf.lookupName("Tid Vol Max"))) { valmax=sig->data[dn]; sess->setMax(CPAP_TidalVolume,valmax*sig->gain*1000.0); sess->m_valuesummary[CPAP_TidalVolume][valmax]=4; } - if (stredf.lookup.contains("Targ Vent Med")) { - sig=stredf.lookup["Targ Vent Med"]; + if ((sig=stredf.lookupName("Targ Vent Med"))) { valmed=sig->data[dn]; - sess->setMedian(CPAP_TgMV,valmed*sig->gain); sess->m_gain[CPAP_TgMV]=sig->gain; sess->m_valuesummary[CPAP_TgMV][valmed]=51; } - if (stredf.lookup.contains("Targ Vent 95")) { - sig=stredf.lookup["Targ Vent 95"]; + if ((sig=stredf.lookupName("Targ Vent 95"))) { val95=sig->data[dn]; - sess->set95p(CPAP_TgMV,val95*sig->gain); sess->m_valuesummary[CPAP_TgMV][val95]=45; } - if (stredf.lookup.contains("Targ Vent Max")) { - sig=stredf.lookup["Targ Vent Max"]; + if ((sig=stredf.lookupName("Targ Vent Max"))) { valmax=sig->data[dn]; sess->setMax(CPAP_TgMV,valmax*sig->gain); sess->m_valuesummary[CPAP_TgMV][valmax]=4; } - if (stredf.lookup.contains("I:E Med")) { - sig=stredf.lookup["I:E Med"]; + if ((sig=stredf.lookupName("I:E Med"))) { valmed=sig->data[dn]; - sess->setMedian(CPAP_IE,valmed*sig->gain); sess->m_gain[CPAP_IE]=sig->gain; sess->m_valuesummary[CPAP_IE][valmed]=51; } - if (stredf.lookup.contains("I:E 95")) { - sig=stredf.lookup["I:E 95"]; + if ((sig=stredf.lookupName("I:E 95"))) { val95=sig->data[dn]; - sess->set95p(CPAP_IE,val95*sig->gain); sess->m_valuesummary[CPAP_IE][val95]=45; } - if (stredf.lookup.contains("I:E Max")) { - sig=stredf.lookup["I:E Max"]; + if ((sig=stredf.lookupName("I:E Max"))) { valmax=sig->data[dn]; sess->setMax(CPAP_IE,valmax*sig->gain); sess->m_valuesummary[CPAP_IE][valmax]=4; } - - - if (stredf.lookup.contains("Mask Pres Med")) { - sig=stredf.lookup["Mask Pres Med"]; + if ((sig=stredf.lookupName("Mask Pres Med"))) { valmed=sig->data[dn]; - sess->setMedian(CPAP_Pressure,valmed*sig->gain); sess->m_gain[CPAP_Pressure]=sig->gain; sess->m_valuesummary[CPAP_Pressure][valmed]=51; } - if (stredf.lookup.contains("Mask Pres 95")) { - sig=stredf.lookup["Mask Pres 95"]; + if ((sig=stredf.lookupName("Mask Pres 95"))) { val95=sig->data[dn]; - sess->set95p(CPAP_Pressure,val95*sig->gain); sess->m_valuesummary[CPAP_Pressure][val95]=45; } - if (stredf.lookup.contains("Mask Pres Max")) { - sig=stredf.lookup["Mask Pres Max"]; + if ((sig=stredf.lookupName("Mask Pres Max"))) { valmax=sig->data[dn]; sess->setMax(CPAP_Pressure,valmax*sig->gain); sess->m_valuesummary[CPAP_Pressure][valmax]=4; } - if (stredf.lookup.contains("Insp Pres Med")) { - sig=stredf.lookup["Insp Pres Med"]; + if ((sig=stredf.lookupName("Insp Pres Med"))) { valmed=sig->data[dn]; - sess->setMedian(CPAP_IPAP,valmed*sig->gain); sess->m_gain[CPAP_IPAP]=sig->gain; sess->m_valuesummary[CPAP_IPAP][valmed]=51; } - if (stredf.lookup.contains("Insp Pres 95")) { - sig=stredf.lookup["Insp Pres 95"]; + if ((sig=stredf.lookupName("Insp Pres 95"))) { val95=sig->data[dn]; - sess->set95p(CPAP_IPAP,val95*sig->gain); sess->m_valuesummary[CPAP_IPAP][val95]=45; } - if (stredf.lookup.contains("Insp Pres Max")) { - sig=stredf.lookup["Insp Pres Max"]; + if ((sig=stredf.lookupName("Insp Pres Max"))) { valmax=sig->data[dn]; sess->setMax(CPAP_IPAP,valmax*sig->gain); sess->m_valuesummary[CPAP_IPAP][valmax]=4; } - if (stredf.lookup.contains("Exp Pres Med")) { - sig=stredf.lookup["Exp Pres Med"]; + if ((sig=stredf.lookupName("Exp Pres Med"))) { valmed=sig->data[dn]; - sess->setMedian(CPAP_EPAP,valmed*sig->gain); sess->m_gain[CPAP_EPAP]=sig->gain; sess->m_valuesummary[CPAP_EPAP][valmed]=51; } - if (stredf.lookup.contains("Exp Pres 95")) { - sig=stredf.lookup["Exp Pres 95"]; + if ((sig=stredf.lookupName("Exp Pres 95"))) { val95=sig->data[dn]; - sess->set95p(CPAP_EPAP,val95*sig->gain); sess->m_valuesummary[CPAP_EPAP][val95]=45; } - if (stredf.lookup.contains("Exp Pres Max")) { - sig=stredf.lookup["Exp Pres Max"]; + if ((sig=stredf.lookupName("Exp Pres Max"))) { valmax=sig->data[dn]; sess->setMax(CPAP_EPAP,valmax*sig->gain); sess->m_valuesummary[CPAP_EPAP][valmax]=4; } - if (stredf.lookup.contains("Mask Dur")) { - sig=stredf.lookup["Mask Dur"]; + if ((sig=stredf.lookupName("Mask Dur"))) { dur=sig->data[dn]*sig->gain; } - if (stredf.lookup.contains("OAI")) { - sig=stredf.lookup["OAI"]; + if ((sig=stredf.lookupName("OAI"))) { tmp=sig->data[dn]*sig->gain; sess->setCph(CPAP_Obstructive,tmp); sess->setCount(CPAP_Obstructive,tmp*(dur/60.0)); } - if (stredf.lookup.contains("HI")) { - sig=stredf.lookup["HI"]; + if ((sig=stredf.lookupName("HI"))) { tmp=sig->data[dn]*sig->gain; sess->setCph(CPAP_Hypopnea,tmp); sess->setCount(CPAP_Hypopnea,tmp*(dur/60.0)); } - if (stredf.lookup.contains("UAI")) { - sig=stredf.lookup["UAI"]; + if ((sig=stredf.lookupName("UAI"))) { tmp=sig->data[dn]*sig->gain; sess->setCph(CPAP_Apnea,tmp); sess->setCount(CPAP_Apnea,tmp*(dur/60.0)); } - if (stredf.lookup.contains("CAI")) { - sig=stredf.lookup["CAI"]; + if ((sig=stredf.lookupName("CAI"))) { tmp=sig->data[dn]*sig->gain; sess->setCph(CPAP_ClearAirway,tmp); sess->setCount(CPAP_ClearAirway,tmp*(dur/60.0)); } - - } } diff --git a/SleepLib/loader_plugins/resmed_loader.h b/SleepLib/loader_plugins/resmed_loader.h index 6093da6e..ca1f26ac 100644 --- a/SleepLib/loader_plugins/resmed_loader.h +++ b/SleepLib/loader_plugins/resmed_loader.h @@ -127,6 +127,7 @@ public: //! \brief Look up signal names by SleepLib ChannelID.. A little "ResMed"ified.. :/ EDFSignal * lookupSignal(ChannelID); + EDFSignal * lookupName(QString name); //! \brief Returns the number of signals contained in this EDF file long GetNumSignals() { return num_signals; } diff --git a/SleepLib/session.cpp b/SleepLib/session.cpp index 1fbb1e40..fd25edfa 100644 --- a/SleepLib/session.cpp +++ b/SleepLib/session.cpp @@ -22,7 +22,7 @@ const quint16 filetype_data=1; // This is the uber important database version for SleepyHeads internal storage // Increment this after stuffing with Session's save & load code. -const quint16 summary_version=10; +const quint16 summary_version=11; const quint16 events_version=8; Session::Session(Machine * m,SessionID session) @@ -138,9 +138,6 @@ bool Session::StoreSummary(QString filename) out << m_sum; out << m_avg; out << m_wavg; - out << m_90p; - out << m_95p; - out << m_med; out << m_min; out << m_max; out << m_cph; @@ -218,6 +215,8 @@ bool Session::LoadSummary(QString filename) in >> s_last; // Duration // (16bit==Limited to 18 hours) + QHash cruft; + if (version<7) { QHash v1; in >> v1; @@ -253,10 +252,11 @@ bool Session::LoadSummary(QString filename) } ztmp.clear(); in >> ztmp; // 90p - for (QHash::iterator i=ztmp.begin();i!=ztmp.end();i++) { - code=schema::channel[i.key()].id(); - m_90p[code]=i.value(); - } + // Ignore this +// for (QHash::iterator i=ztmp.begin();i!=ztmp.end();i++) { +// code=schema::channel[i.key()].id(); +// m_90p[code]=i.value(); +// } ztmp.clear(); in >> ztmp; // min for (QHash::iterator i=ztmp.begin();i!=ztmp.end();i++) { @@ -300,10 +300,15 @@ bool Session::LoadSummary(QString filename) in >> m_sum; in >> m_avg; in >> m_wavg; - in >> m_90p; - if (version >= 10) { - in >> m_95p; - in >> m_med; + if (version < 11) { + cruft.clear(); + in >> cruft; // 90% + if (version >= 10) { + cruft.clear(); + in >> cruft;// med + cruft.clear(); + in >> cruft; //p95 + } } in >> m_min; in >> m_max; @@ -988,7 +993,7 @@ EventDataType Session::sph(ChannelID id) // sum per hour return val; } -EventDataType Session::p90(ChannelID id) // 90th Percentile +/*EventDataType Session::p90(ChannelID id) // 90th Percentile { QHash::iterator i=m_90p.find(id); if (i!=m_90p.end()) @@ -1037,7 +1042,7 @@ EventDataType Session::median(ChannelID id) return val; } - +*/ bool sortfunction (EventStoreType i,EventStoreType j) { return (i m_sum; QHash m_avg; QHash m_wavg; - QHash m_90p; - QHash m_95p; - QHash m_med; + //QHash m_90p; + //QHash m_95p; + //QHash m_med; QHash m_min; QHash m_max; QHash m_cph; // Counts per hour (eg AHI) @@ -163,9 +163,9 @@ public: void setMax(ChannelID id,EventDataType val) { m_max[id]=val; } void setAvg(ChannelID id,EventDataType val) { m_avg[id]=val; } void setWavg(ChannelID id,EventDataType val) { m_wavg[id]=val; } - void setMedian(ChannelID id,EventDataType val) { m_med[id]=val; } - void set90p(ChannelID id,EventDataType val) { m_90p[id]=val; } - void set95p(ChannelID id,EventDataType val) { m_95p[id]=val; } +// void setMedian(ChannelID id,EventDataType val) { m_med[id]=val; } +// void set90p(ChannelID id,EventDataType val) { m_90p[id]=val; } +// void set95p(ChannelID id,EventDataType val) { m_95p[id]=val; } void setCph(ChannelID id,EventDataType val) { m_cph[id]=val; } void setSph(ChannelID id,EventDataType val) { m_sph[id]=val; } void setFirst(ChannelID id,qint64 val) { m_firstchan[id]=val; } diff --git a/mainwindow.cpp b/mainwindow.cpp index 5d35f581..87021976 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -2077,7 +2077,7 @@ void MainWindow::on_action_Rebuild_Oximetry_Index_triggered() sess->m_sph.clear(); sess->m_avg.clear(); sess->m_wavg.clear(); - sess->m_90p.clear(); + //sess->m_90p.clear(); sess->m_firstchan.clear(); sess->m_lastchan.clear(); sess->SetChanged(true); diff --git a/overview.cpp b/overview.cpp index c6fd2a5c..e14d47bd 100644 --- a/overview.cpp +++ b/overview.cpp @@ -247,7 +247,7 @@ Overview::Overview(QWidget *parent,gGraphView * shared) : // //} PR->AddLayer(pr); - lk=new SummaryChart(tr("Avg Leak"),GT_LINE); + lk=new SummaryChart(tr("Leaks"),GT_LINE); lk->addSlice(CPAP_Leak,QColor("light blue"),ST_PERC,0.5); lk->addSlice(CPAP_Leak,QColor("dark grey"),ST_PERC,0.95); //lk->addSlice(CPAP_Leak,QColor("dark blue"),ST_WAVG);