Added Session count overview chart

This commit is contained in:
Mark Watkins 2011-10-31 01:25:53 +10:00
parent b0fec0c74a
commit df7c1817a0
5 changed files with 31 additions and 8 deletions

View File

@ -65,7 +65,7 @@ void SummaryChart::SetDay(Day * nullday)
for (int i=0;i<d.value().size();i++) { for (int i=0;i<d.value().size();i++) {
day=d.value()[i]; day=d.value()[i];
if (day->machine_type()!=m_machinetype) continue; if (day->machine_type()!=m_machinetype) continue;
if (type==ST_HOURS || day->channelExists(code) || day->settingExists(code)) { // too many lookups happening here.. stop the crap.. if (type==ST_HOURS || type==ST_SESSIONS || day->channelHasData(code) || day->settingExists(code)) { // too many lookups happening here.. stop the crap..
m_days[dn]=day; m_days[dn]=day;
switch(m_type[j]) { switch(m_type[j]) {
case ST_AVG: tmp=day->avg(code); break; case ST_AVG: tmp=day->avg(code); break;
@ -78,6 +78,7 @@ void SummaryChart::SetDay(Day * nullday)
case ST_CPH: tmp=day->cph(code); break; case ST_CPH: tmp=day->cph(code); break;
case ST_SPH: tmp=day->sph(code); break; case ST_SPH: tmp=day->sph(code); break;
case ST_HOURS: tmp=day->hours(); break; case ST_HOURS: tmp=day->hours(); break;
case ST_SESSIONS: tmp=day->size(); break;
case ST_SETMIN: tmp=day->settings_min(code); break; case ST_SETMIN: tmp=day->settings_min(code); break;
case ST_SETMAX: tmp=day->settings_max(code); break; case ST_SETMAX: tmp=day->settings_max(code); break;
case ST_SETAVG: tmp=day->settings_avg(code); break; case ST_SETAVG: tmp=day->settings_avg(code); break;
@ -352,6 +353,8 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height)
case ST_CPH: a+=""; break; case ST_CPH: a+=""; break;
case ST_SPH: a+="%"; break; case ST_SPH: a+="%"; break;
case ST_HOURS: a+="Hours"; break; case ST_HOURS: a+="Hours"; break;
case ST_SESSIONS: a+="Sessions"; break;
default: default:
break; break;
} }
@ -403,6 +406,7 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height)
w.renderText(a,left,top-3); w.renderText(a,left,top-3);
} }
bool SummaryChart::mouseMoveEvent(QMouseEvent *event) bool SummaryChart::mouseMoveEvent(QMouseEvent *event)
{ {
int x=event->x()-l_left; int x=event->x()-l_left;
@ -472,13 +476,19 @@ bool SummaryChart::mouseMoveEvent(QMouseEvent *event)
case ST_CPH: a=""; break; case ST_CPH: a=""; break;
case ST_SPH: a="%"; break; case ST_SPH: a="%"; break;
case ST_HOURS: a="Hours"; break; case ST_HOURS: a="Hours"; break;
case ST_SESSIONS: a="Sessions"; break;
default: default:
break; break;
} }
if (day && (day->channelExists(m_codes[i]) || day->settingExists(m_codes[i]))) { if (m_type[i]==ST_SESSIONS) {
schema::Channel & chan=schema::channel[m_codes[i]]; val=QString::number(d.value()[i+1],'f',0);
val=QString::number(d.value()[i+1],'f',2); z+="\r\n"+a+"="+val;
z+="\r\n"+chan.label()+" "+a+"="+val; } else {
if (day && (day->channelExists(m_codes[i]) || day->settingExists(m_codes[i]))) {
schema::Channel & chan=schema::channel[m_codes[i]];
val=QString::number(d.value()[i+1],'f',2);
z+="\r\n"+chan.label()+" "+a+"="+val;
}
} }
} }

View File

@ -549,6 +549,7 @@ bool Session::channelExists(ChannelID id)
QHash<ChannelID,int>::iterator q=m_cnt.find(id); QHash<ChannelID,int>::iterator q=m_cnt.find(id);
if (q==m_cnt.end()) if (q==m_cnt.end())
return false; return false;
if (q.value()==0) return false;
} }
return true; return true;
} }

View File

@ -19,7 +19,7 @@
class Machine; class Machine;
const quint32 magic=0xC73216AB; const quint32 magic=0xC73216AB;
enum SummaryType { ST_CNT, ST_SUM, ST_AVG, ST_WAVG, ST_90P, ST_MIN, ST_MAX, ST_CPH, ST_SPH, ST_FIRST, ST_LAST, ST_HOURS, ST_SETMIN, ST_SETAVG, ST_SETMAX, ST_SETWAVG, ST_SETSUM }; enum SummaryType { ST_CNT, ST_SUM, ST_AVG, ST_WAVG, ST_90P, ST_MIN, ST_MAX, ST_CPH, ST_SPH, ST_FIRST, ST_LAST, ST_HOURS, ST_SESSIONS, ST_SETMIN, ST_SETAVG, ST_SETMAX, ST_SETWAVG, ST_SETSUM };
class Session class Session
{ {

View File

@ -54,6 +54,7 @@ Overview::Overview(QWidget *parent,gGraphView * shared) :
PR=new gGraph(GraphView,"Pressure",default_height,0); PR=new gGraph(GraphView,"Pressure",default_height,0);
SET=new gGraph(GraphView,"Settings",default_height,0); SET=new gGraph(GraphView,"Settings",default_height,0);
LK=new gGraph(GraphView,"Leaks",default_height,0); LK=new gGraph(GraphView,"Leaks",default_height,0);
SES=new gGraph(GraphView,"Sessions",default_height,0);
uc=new SummaryChart("Hours",GT_BAR); uc=new SummaryChart("Hours",GT_BAR);
uc->addSlice("",QColor("green"),ST_HOURS); uc->addSlice("",QColor("green"),ST_HOURS);
@ -64,6 +65,16 @@ Overview::Overview(QWidget *parent,gGraphView * shared) :
UC->AddLayer(uc); UC->AddLayer(uc);
UC->AddLayer(new gXGrid()); UC->AddLayer(new gXGrid());
ses=new SummaryChart("Sessions",GT_LINE);
ses->addSlice("",QColor("blue"),ST_SESSIONS);
SES->AddLayer(new gYAxis(),LayerLeft,gYAxis::Margin);
gx=new gXAxis();
gx->setUtcFix(true);
SES->AddLayer(gx,LayerBottom,0,gXAxis::Margin);
SES->AddLayer(ses);
SES->AddLayer(new gXGrid());
bc=new SummaryChart("AHI",GT_BAR); bc=new SummaryChart("AHI",GT_BAR);
bc->addSlice(CPAP_Hypopnea,QColor("blue"),ST_CPH); bc->addSlice(CPAP_Hypopnea,QColor("blue"),ST_CPH);
@ -260,6 +271,7 @@ QString Overview::GetHTML()
pr->deselect(); pr->deselect();
lk->deselect(); lk->deselect();
npb->deselect(); npb->deselect();
ses->deselect();
report->ReloadGraphs(); report->ReloadGraphs();
QString reportname="overview"; QString reportname="overview";

View File

@ -34,8 +34,8 @@ public:
void RedrawGraphs(); void RedrawGraphs();
gGraph *AHI,*UC,*PR,*LK,*NPB,*SET; gGraph *AHI,*UC,*PR,*LK,*NPB,*SET,*SES;
SummaryChart *bc,*uc,*pr,*lk,*npb,*set; SummaryChart *bc,*uc,*pr,*lk,*npb,*set,*ses;
public slots: public slots:
void on_printButton_clicked(); void on_printButton_clicked();