diff --git a/Graphs/gBarChart.cpp b/Graphs/gBarChart.cpp index 19b29136..06a2dd44 100644 --- a/Graphs/gBarChart.cpp +++ b/Graphs/gBarChart.cpp @@ -1,8 +1,8 @@ -/******************************************************************** +/* gBarChart Implementation Copyright (c)2011 Mark Watkins License: GPL -*********************************************************************/ +*/ #include #include diff --git a/Graphs/gLineChart.cpp b/Graphs/gLineChart.cpp index 37101d02..2085ef37 100644 --- a/Graphs/gLineChart.cpp +++ b/Graphs/gLineChart.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include "gLineChart.h" @@ -78,7 +79,7 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry) } bool accel=m_accelerate; - double sfit,sr; + double sr; int dp,sam; QColor & col=color[0]; @@ -116,7 +117,7 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry) point[siz-1]=t; x0=point[0].x(); } else { - qDebug("Reversed order sample fed to gLineChart - ignored."); + qDebug() << "Reversed order sample fed to gLineChart - ignored."; continue; //assert(x10); - double qx=xL-x0; // Full time range of this segment - double gx=xx/qx; // ratio of how much of the whole data set this represents - double segwidth=width*gx; + // double qx=xL-x0; // Full time range of this segment + //double gx=xx/qx; // ratio of how much of the whole data set this represents + //double segwidth=width*gx; double XR=xx/sr; double Z1=MAX(x0,minx); double Z2=MIN(xL,maxx); @@ -248,7 +249,7 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry) // In accel mode, each pixel has a min/max Y value. // m_drawlist's index is the pixel index for the X pixel axis. - float zz=(maxy-miny)/2.0; // centreline + //float zz=(maxy-miny)/2.0; // centreline float jy=point[i].y(); int y1=1+(jy-miny)*ymult; diff --git a/Graphs/gLineOverlay.cpp b/Graphs/gLineOverlay.cpp index b078580e..f3b568d4 100644 --- a/Graphs/gLineOverlay.cpp +++ b/Graphs/gLineOverlay.cpp @@ -75,8 +75,8 @@ void gLineOverlayBar::Plot(gGraphWindow & w,float scrx,float scry) // bool done=false; for (int i=0;inp[n];i++) { QPointD & rp=data->point[n][i]; - float X=rp.x(); - float Y=rp.y(); + //float X=rp.x(); + //float Y=rp.y(); if (rp.y() < w.min_x) continue; if (rp.x() > w.max_x) break; diff --git a/Graphs/glcommon.cpp b/Graphs/glcommon.cpp index dccb5b60..5e6a09fc 100644 --- a/Graphs/glcommon.cpp +++ b/Graphs/glcommon.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include "glcommon.h" #include "SleepLib/profiles.h" @@ -62,7 +63,7 @@ void DrawText(gGraphWindow & wid, QString text, int x, int y, float angle, QCol //int a=fm.overlinePos(); //ascent(); //LinedRoundedRectangle(x,wid.GetScrY()-y,w,h,0,1,QColor("black")); if (!font) { - qDebug("Font Problem. Forgot to call GraphInit() ?"); + qDebug() << "Font Problem. Forgot to call GraphInit() ?"; abort(); return; } @@ -72,7 +73,7 @@ void DrawText(gGraphWindow & wid, QString text, int x, int y, float angle, QCol glFlush(); QPainter painter(&wid); painter.setFont(*font); - painter.setPen(Qt::black); + painter.setPen(color); painter.setOpacity(1); // painter.setCompositionMode(QPainter::CompositionMode_); if (angle==0) { diff --git a/Graphs/graphdata_custom.cpp b/Graphs/graphdata_custom.cpp index af4095fe..a1d0dbce 100644 --- a/Graphs/graphdata_custom.cpp +++ b/Graphs/graphdata_custom.cpp @@ -31,9 +31,9 @@ void WaveData::Reload(Day *day) } max_y=0; bool first=true; - int chunk=0; + // int chunk=0; for (vector::iterator s=day->begin();s!=day->end(); s++) { - //qDebug("Processing waveform chunk %i",chunk++); + //qDebug() << "Processing waveform chunk " << chunk++; if ((*s)->waveforms.find(code)==(*s)->waveforms.end()) continue; for (vector::iterator l=(*s)->waveforms[code].begin();l!=(*s)->waveforms[code].end();l++) { int ps=point.size(); @@ -45,7 +45,7 @@ void WaveData::Reload(Day *day) Waveform *w=(*l); double st=w->start().toMSecsSinceEpoch()/86400000.0; double rate=(w->duration()/w->samples())/86400.0; - //qDebug("Waveform Chunk contains %i samples",w->samples()); + //qDebug() << "Waveform Chunk contains " << w->samples() << " samples"; for (int i=0;isamples();i++) { QPointD r(st,(*w)[i]); st+=rate; @@ -117,8 +117,8 @@ void EventData::Reload(Day *day) min_x=day->first().toMSecsSinceEpoch()/86400000.0; max_x=day->last().toMSecsSinceEpoch()/86400000.0; if (min_x>max_x) { - int a=5; - //assert(min_xmax_slots) { - int i=0; - // throw BoundsError(); - } pTime[lastval]+=d; } cnt++; @@ -382,6 +378,7 @@ double HistoryData::Calc(Day *day) void HistoryData::Reload(Day *day) { + day=day; //shuttup warnings.. QDateTime date; vc=0; int i=0; diff --git a/Graphs/graphlayer.cpp b/Graphs/graphlayer.cpp index 5b008292..acd60ce0 100644 --- a/Graphs/graphlayer.cpp +++ b/Graphs/graphlayer.cpp @@ -23,9 +23,9 @@ gLayer::~gLayer() } -void gLayer::Plot(gGraphWindow & w,float scrx,float scry) -{ -} +//void gLayer::Plot(gGraphWindow & w,float scrx,float scry) +//{ +//} void gLayer::DataChanged(gGraphData *src) { diff --git a/Graphs/graphlayer.h b/Graphs/graphlayer.h index 2f9d0a47..5a415a8d 100644 --- a/Graphs/graphlayer.h +++ b/Graphs/graphlayer.h @@ -20,7 +20,7 @@ class gLayer public: gLayer(gPointData *g=NULL,QString title=""); virtual ~gLayer(); - virtual void Plot(gGraphWindow & w,float scrx,float scry); + virtual void Plot(gGraphWindow & w,float scrx,float scry)=0; vector color; virtual void SetData(gPointData * gd);; diff --git a/SleepLib/loader_plugins/cms50_loader.cpp b/SleepLib/loader_plugins/cms50_loader.cpp index 1d1bcfc7..8bfe9705 100644 --- a/SleepLib/loader_plugins/cms50_loader.cpp +++ b/SleepLib/loader_plugins/cms50_loader.cpp @@ -17,6 +17,7 @@ License: GPL #include #include #include +#include #include using namespace std; @@ -169,7 +170,7 @@ bool CMS50Loader::OpenSPORFile(QString path,Machine *mach,Profile *profile) date.setDate(d2); } if (!date.isValid()) { - qDebug("Invalid date time retreieved in CMS50::OpenSPORFile"); + qDebug() << "Invalid date time retreieved in CMS50::OpenSPORFile"; return false; } @@ -178,7 +179,7 @@ bool CMS50Loader::OpenSPORFile(QString path,Machine *mach,Profile *profile) buffer=new char [num_records]; br=f.read(buffer,num_records); if (br!=num_records) { - qDebug(("Short .spoR File: "+path).toLatin1()); + qDebug() << "Short .spoR File: " << path; delete [] buffer; return false; } @@ -280,7 +281,7 @@ Machine *CMS50Loader::CreateMachine(Profile *profile) } } - qDebug("Create CMS50 Machine Record"); + qDebug() << "Create CMS50 Machine Record"; Machine *m=new Oximeter(profile,0); m->SetClass(cms50_class_name); @@ -301,7 +302,7 @@ static bool cms50_initialized=false; void CMS50Loader::Register() { if (cms50_initialized) return; - qDebug("Registering CMS50Loader"); + qDebug() << "Registering CMS50Loader"; RegisterLoader(new CMS50Loader()); //InitModelMap(); cms50_initialized=true; diff --git a/SleepLib/loader_plugins/prs1_loader.cpp b/SleepLib/loader_plugins/prs1_loader.cpp index 951218fa..ffbfefda 100644 --- a/SleepLib/loader_plugins/prs1_loader.cpp +++ b/SleepLib/loader_plugins/prs1_loader.cpp @@ -12,6 +12,7 @@ License: GPL #include #include #include +#include #include "prs1_loader.h" #include "SleepLib/session.h" @@ -56,7 +57,7 @@ PRS1Loader::~PRS1Loader() } Machine *PRS1Loader::CreateMachine(QString serial,Profile *profile) { - qDebug(("Create Machine "+serial).toLatin1()); + qDebug() << "Create Machine " << serial; assert(profile!=NULL); vector ml=profile->GetMachines(MT_CPAP); @@ -102,7 +103,7 @@ bool PRS1Loader::Open(QString & path,Profile *profile) if ((!dir.exists() || !dir.isReadable())) return 0; - qDebug(("PRS1Loader::Open newpath="+newpath).toLatin1()); + qDebug() << "PRS1Loader::Open newpath=" << newpath; dir.setFilter(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoSymLinks); dir.setSorting(QDir::Name); QFileInfoList flist=dir.entryInfoList(); @@ -121,11 +122,11 @@ bool PRS1Loader::Open(QString & path,Profile *profile) QString file=fi.canonicalFilePath(); QFile f(file); if (!fi.isReadable()) { - qDebug("PRS1Loader: last.txt exists but I couldn't read it!"); + qDebug() << "PRS1Loader: last.txt exists but I couldn't read it!"; continue; } if (!f.open(QIODevice::ReadOnly)) { - qDebug("PRS1Loader: last.txt exists but I couldn't open it!"); + qDebug() << "PRS1Loader: last.txt exists but I couldn't open it!"; continue; } last=f.readLine(64); @@ -183,7 +184,7 @@ bool PRS1Loader::ParseProperties(Machine *m,QString filename) } } if (prop["SerialNumber"]!=m->properties["Serial"]) { - qDebug("Serial Number in PRS1 properties.txt doesn't match directory structure"); + qDebug() << "Serial Number in PRS1 properties.txt doesn't match directory structure"; } else prop.erase("SerialNumber"); // already got it stored. for (map::iterator i=prop.begin(); i!=prop.end(); i++) { @@ -197,7 +198,7 @@ bool PRS1Loader::ParseProperties(Machine *m,QString filename) int PRS1Loader::OpenMachine(Machine *m,QString path,Profile *profile) { - qDebug(("Opening PRS1 "+path).toLatin1()); + qDebug() << "Opening PRS1 " << path; QDir dir(path); if (!dir.exists() || (!dir.isReadable())) return false; @@ -277,22 +278,20 @@ int PRS1Loader::OpenMachine(Machine *m,QString path,Profile *profile) Session *sess=new Session(m,session); if (!OpenSummary(sess,s->second[0])) { - qWarning(("PRS1Loader: Could'nt open summary file "+s->second[0]).toLatin1()); + qWarning() << "PRS1Loader: Could'nt open summary file " << s->second[0]; delete sess; continue; } - //wxLogMessage(sess->first().Format(wxT("%Y-%m-%d %H:%M:%S"))+wxT(" ")+sess->last().Format(wxT("%Y-%m-%d %H:%M:%S"))); - //sess->SetSessionID(sess->start().GetTicks()); if (!s->second[1].isEmpty()) { if (!OpenEvents(sess,s->second[1])) { - qWarning(("PRS1Loader: Couldn't open event file "+s->second[1]).toLatin1()); + qWarning() << "PRS1Loader: Couldn't open event file " << s->second[1]; } } if (!s->second[2].isEmpty()) { if (!OpenWaveforms(sess,s->second[2])) { - qWarning(("PRS1Loader: Couldn't open event file "+s->second[2]).toLatin1()); + qWarning() << "PRS1Loader: Couldn't open event file " << s->second[2]; } } const double ignore_thresh=300.0/3600.0;// Ignore useless sessions under 5 minute @@ -383,7 +382,7 @@ bool PRS1Loader::OpenSummary(Session *session,QString filename) unsigned char header[24]; unsigned char ext,sum; - //qDebug("Opening PRS1 Summary %s",filename); + //qDebug() << "Opening PRS1 Summary " << filename; QFile f(filename); //,wxT("rb")); if (!f.open(QIODevice::ReadOnly)) @@ -417,13 +416,12 @@ bool PRS1Loader::OpenSummary(Session *session,QString filename) return false; if (size<=19) { - qDebug(("Ignoring short session file "+filename).toLatin1()); + qDebug() << "Ignoring short session file " << filename; return false; } QDateTime date=QDateTime::fromTime_t(timestamp); //QDateTime tmpdate=date; - //qDebug(date.Format()+wxT(" UTC=")+tmpdate.Format()); //int ticks=date.GetTicks(); if (!date.isValid()) @@ -473,7 +471,7 @@ bool PRS1Loader::OpenSummary(Session *session,QString filename) quint16 bb=*(quint16*)b; unsigned duration=bb;// | (buffer[0x15] << 8); session->summary[CPAP_Duration]=(int)duration; - //qDebug("ID: %i %i",session->session(),duration)); + //qDebug() << "ID: " << session->session() << " " << duration; float hours=float(duration)/3600.0; session->set_hours(hours); @@ -767,13 +765,10 @@ bool PRS1Loader::OpenWaveforms(Session *session,QString filename) if (min>c) min=c; if (maxAddWaveform(w); - //wxLogMessage(wxT("Done PRS1 Waveforms ")+filename); return true; } @@ -789,7 +784,7 @@ bool initialized=false; void PRS1Loader::Register() { if (initialized) return; - qDebug("Registering PRS1Loader"); + qDebug() << "Registering PRS1Loader"; RegisterLoader(new PRS1Loader()); InitModelMap(); initialized=true; diff --git a/SleepLib/loader_plugins/resmed_loader.cpp b/SleepLib/loader_plugins/resmed_loader.cpp index 3d9c5580..427608a6 100644 --- a/SleepLib/loader_plugins/resmed_loader.cpp +++ b/SleepLib/loader_plugins/resmed_loader.cpp @@ -12,6 +12,7 @@ License: GPL #include #include #include +#include #include #include "resmed_loader.h" @@ -77,11 +78,11 @@ bool EDFParser::Parse() startdate.setDate(d2); } if (!startdate.isValid()) { - qDebug(("Invalid date time retreieved parsing EDF File"+filename).toLatin1()); + qDebug() << "Invalid date time retreieved parsing EDF File " << filename; return false; } - //qDebug(startdate.toString("yyyy-MM-dd HH:mm:ss").toLatin1()); + //qDebug() << startdate.toString("yyyy-MM-dd HH:mm:ss"); num_header_bytes=Read(8).toLong(&ok); if (!ok) @@ -150,7 +151,7 @@ bool EDFParser::Open(QString name) if (!f.isReadable()) return false; filename=name; filesize=f.size(); - //qDebug(("Opening "+name).toLatin1()); + //qDebug() << "Opening " << name; buffer=new char [filesize]; f.read(buffer,filesize); f.close(); @@ -179,7 +180,7 @@ Machine *ResmedLoader::CreateMachine(QString serial,Profile *profile) } if (found) return ResmedList[serial]; - qDebug(("Create ResMed Machine"+serial).toLatin1()); + qDebug() << "Create ResMed Machine" << serial; Machine *m=new CPAP(profile,0); m->SetClass(resmed_class_name); @@ -228,7 +229,7 @@ bool ResmedLoader::Open(QString & path,Profile *profile) if ((!dir.exists() || !dir.isReadable())) return 0; - qDebug(("ResmedLoader::Open newpath="+newpath).toLatin1()); + qDebug() << "ResmedLoader::Open newpath=" << newpath; dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); dir.setSorting(QDir::Name); QFileInfoList flist=dir.entryInfoList(); @@ -267,13 +268,13 @@ bool ResmedLoader::Open(QString & path,Profile *profile) size=sessfiles.size(); for (map >::iterator si=sessfiles.begin();si!=sessfiles.end();si++) { sessionid=si->first; - //qDebug("Parsing Session %li",sessionid); + //qDebug() << "Parsing Session " << sessionid; bool done=false; bool first=true; - for (int i=0;isecond.size();i++) { + for (size_t i=0;isecond.size();i++) { fn=si->second[i].section("_",-1).toLower(); EDFParser edf(si->second[i]); - //qDebug("Parsing File %i %i",i,edf.filesize); + //qDebug() << "Parsing File " << i << " " << edf.filesize; if (!edf.Parse()) continue; @@ -283,7 +284,7 @@ bool ResmedLoader::Open(QString & path,Profile *profile) for (map::iterator i=idmap.begin();i!=idmap.end();i++) { if (i->first=="SRN") { if (edf.serialnumber!=i->second) { - qDebug("edf Serial number doesn't match Identification.tgt"); + qDebug() << "edf Serial number doesn't match Identification.tgt"; } } else if (i->first=="PNA") { m->properties["Model"]=i->second; @@ -298,10 +299,10 @@ bool ResmedLoader::Open(QString & path,Profile *profile) sess=new Session(m,sessionid); } if (!done) { - if (fn=="eve.edf") LoadEVE(m,sess,edf); - else if (fn=="pld.edf") LoadPLD(m,sess,edf); - else if (fn=="brp.edf") LoadBRP(m,sess,edf); - else if (fn=="sad.edf") LoadSAD(m,sess,edf); + if (fn=="eve.edf") LoadEVE(sess,edf); + else if (fn=="pld.edf") LoadPLD(sess,edf); + else if (fn=="brp.edf") LoadBRP(sess,edf); + else if (fn=="sad.edf") LoadSAD(sess,edf); } if (first) { sess->SetChanged(true); @@ -340,7 +341,7 @@ bool ResmedLoader::Open(QString & path,Profile *profile) return 0; } -bool ResmedLoader::LoadEVE(Machine *mach,Session *sess,EDFParser &edf) +bool ResmedLoader::LoadEVE(Session *sess,EDFParser &edf) { QString t; long recs; @@ -353,13 +354,13 @@ bool ResmedLoader::LoadEVE(Machine *mach,Session *sess,EDFParser &edf) QDateTime tt; EventDataType fields[3]; MachineCode code; - Event *e; + //Event *e; for (int s=0;snr*edf.GetNumDataRecords()*2; totaldur=edf.GetNumDataRecords()*edf.GetDuration(); totaldur/=3600.0; //t.sprintf("EVE: %li %.2f",recs,totaldur); - //qDebug((edf.edfsignals[s]->label+" "+t).toLatin1()); + //qDebug() << edf.edfsignals[s]->label << " " << t; data=(char *)edf.edfsignals[s]->data; pos=0; tt=edf.startdate; @@ -378,7 +379,7 @@ bool ResmedLoader::LoadEVE(Machine *mach,Session *sess,EDFParser &edf) } while ((c!=20) && (c!=21)); // start code d=t.toDouble(&ok); if (!ok) { - qDebug(("Faulty EDF EVE file"+edf.filename).toLatin1()); + qDebug() << "Faulty EDF EVE file " << edf.filename; break; } if (!sign) d=-d; @@ -397,7 +398,7 @@ bool ResmedLoader::LoadEVE(Machine *mach,Session *sess,EDFParser &edf) } while ((data[pos]!=20) && (posAddEvent(new Event(tt,code,fields,1)); } else { if (t!="recording starts") { - qDebug(("Unknown ResMed annotation field: "+t).toLatin1()); + qDebug() << "Unknown ResMed annotation field: " << t; } } // qDebug((tt.toString("yyyy-MM-dd HH:mm:ss")+t).toLatin1()); } if (pos>=recs) { - qDebug(("Short EDF EVE file"+edf.filename).toLatin1()); + qDebug() << "Short EDF EVE file" << edf.filename; break; } // pos++; @@ -440,8 +441,9 @@ bool ResmedLoader::LoadEVE(Machine *mach,Session *sess,EDFParser &edf) } // qDebug(data); } + return true; } -bool ResmedLoader::LoadBRP(Machine *mach,Session *sess,EDFParser &edf) +bool ResmedLoader::LoadBRP(Session *sess,EDFParser &edf) { QString t; for (int s=0;slabel=="Flow") code=CPAP_FlowRate; else if (edf.edfsignals[s]->label=="Mask Pres") code=CPAP_MaskPressure; else { - qDebug(("Unknown Signal "+edf.edfsignals[s]->label).toLatin1()); + qDebug() << "Unknown Signal " << edf.edfsignals[s]->label; continue; } sess->set_first(edf.startdate); @@ -465,8 +467,9 @@ bool ResmedLoader::LoadBRP(Machine *mach,Session *sess,EDFParser &edf) //t.sprintf("BRP: %li %.2f",recs,duration); //qDebug((edf.edfsignals[s]->label+" "+t).toLatin1()); } + return true; } -void ResmedLoader::ToTimeDelta(Machine *mach,Session *sess,EDFParser &edf, qint16 *data, MachineCode code, long recs, double duration,EventDataType divisor) +void ResmedLoader::ToTimeDelta(Session *sess,EDFParser &edf, qint16 *data, MachineCode code, long recs, double duration,EventDataType divisor) { bool first=true; double rate=(duration/recs)*1000.0; @@ -490,13 +493,15 @@ void ResmedLoader::ToTimeDelta(Machine *mach,Session *sess,EDFParser &edf, qint1 } sess->AddEvent(new Event(tt,code,&c,1)); // add one at the end.. } -bool ResmedLoader::LoadSAD(Machine *mach,Session *sess,EDFParser &edf) +bool ResmedLoader::LoadSAD(Session *sess,EDFParser &edf) { - // Oximeter bull crap.. + // Oximeter bull crap.. this oximeter is not reported of highly.. + // nonetheless, the data is easy to access. + return true; } -bool ResmedLoader::LoadPLD(Machine *mach,Session *sess,EDFParser &edf) +bool ResmedLoader::LoadPLD(Session *sess,EDFParser &edf) { // Is it save to assume the order does not change here? enum PLDType { MaskPres=0, TherapyPres, ExpPress, Leak, RR, Vt, Mv, SnoreIndex, FFLIndex, U1, U2 }; @@ -518,10 +523,10 @@ bool ResmedLoader::LoadPLD(Machine *mach,Session *sess,EDFParser &edf) // } else if (edf.edfsignals[s]->label=="Snore Index") { code=CPAP_Snore; - ToTimeDelta(mach,sess,edf,edf.edfsignals[s]->data, code,recs,duration); + ToTimeDelta(sess,edf,edf.edfsignals[s]->data, code,recs,duration); } else if (edf.edfsignals[s]->label=="Therapy Pres") { code=CPAP_Pressure; - ToTimeDelta(mach,sess,edf,edf.edfsignals[s]->data, code,recs,duration,50.0); //50.0 + ToTimeDelta(sess,edf,edf.edfsignals[s]->data, code,recs,duration,50.0); //50.0 } else if (edf.edfsignals[s]->label=="MV") { code=CPAP_MinuteVentilation; //ToTimeDelta(mach,sess,edf,edf.edfsignals[s]->data, code,recs,duration,1.0); @@ -542,15 +547,15 @@ bool ResmedLoader::LoadPLD(Machine *mach,Session *sess,EDFParser &edf) sess->AddWaveform(w); } else if (edf.edfsignals[s]->label=="Leak") { code=CPAP_Leak; - ToTimeDelta(mach,sess,edf,edf.edfsignals[s]->data, code,recs,duration,1.0); + ToTimeDelta(sess,edf,edf.edfsignals[s]->data, code,recs,duration,1.0); } else if (edf.edfsignals[s]->label=="FFL Index") { code=CPAP_FlowLimitGraph; - ToTimeDelta(mach,sess,edf,edf.edfsignals[s]->data, code,recs,duration,1.0); + ToTimeDelta(sess,edf,edf.edfsignals[s]->data, code,recs,duration,1.0); } else { - qDebug(("Unknown Signal "+edf.edfsignals[s]->label).toLatin1()); + qDebug() << "Unknown Signal " << edf.edfsignals[s]->label; } } - + return true; } void ResInitModelMap() @@ -563,7 +568,7 @@ bool resmed_initialized=false; void ResmedLoader::Register() { if (resmed_initialized) return; - qDebug("Registering ResmedLoader"); + qDebug() << "Registering ResmedLoader"; RegisterLoader(new ResmedLoader()); ResInitModelMap(); resmed_initialized=true; diff --git a/SleepLib/loader_plugins/resmed_loader.h b/SleepLib/loader_plugins/resmed_loader.h index 9701795c..aea9cfb4 100644 --- a/SleepLib/loader_plugins/resmed_loader.h +++ b/SleepLib/loader_plugins/resmed_loader.h @@ -86,17 +86,17 @@ public: virtual int Version() { return resmed_data_version; }; virtual const QString & ClassName() { return resmed_class_name; }; - void ToTimeDelta(Machine *mach,Session *sess,EDFParser &edf, qint16 *data, MachineCode code, long recs,double duration,EventDataType divisor=1); + void ToTimeDelta(Session *sess,EDFParser &edf, qint16 *data, MachineCode code, long recs,double duration,EventDataType divisor=1); Machine *CreateMachine(QString serial,Profile *profile); static void Register(); protected: map ResmedList; - bool LoadEVE(Machine *mach,Session *sess,EDFParser &edf); - bool LoadBRP(Machine *mach,Session *sess,EDFParser &edf); - bool LoadSAD(Machine *mach,Session *sess,EDFParser &edf); - bool LoadPLD(Machine *mach,Session *sess,EDFParser &edf); + bool LoadEVE(Session *sess,EDFParser &edf); + bool LoadBRP(Session *sess,EDFParser &edf); + bool LoadSAD(Session *sess,EDFParser &edf); + bool LoadPLD(Session *sess,EDFParser &edf); }; diff --git a/SleepLib/machine.cpp b/SleepLib/machine.cpp index 225d9f35..f0f780ed 100644 --- a/SleepLib/machine.cpp +++ b/SleepLib/machine.cpp @@ -1,17 +1,20 @@ -/******************************************************************** +/* SleepLib Machine Class Implementation Copyright (c)2011 Mark Watkins License: GPL -*********************************************************************/ +*/ +#include +#include +#include +#include +#include #include #include #include "binary_file.h" #include "machine.h" #include "profiles.h" #include -#include -#include extern QProgressBar * qprogress; @@ -98,58 +101,57 @@ map DefaultMCLongNames; {PRS1_VSnore2, wxT("Vibratory Snore")}, {PRS1_PressurePulse,wxT("Pressue Pulse")} }; */ -inline const QString & _(const QString q) { return q; }; void InitMapsWithoutAwesomeInitializerLists() { - CPAPModeNames[MODE_UNKNOWN]=_("Undetermined"); - CPAPModeNames[MODE_CPAP]=_("CPAP"); - CPAPModeNames[MODE_APAP]=_("Auto"); - CPAPModeNames[MODE_BIPAP]=_("BIPAP"); - CPAPModeNames[MODE_ASV]=_("ASV"); + CPAPModeNames[MODE_UNKNOWN]=QObject::tr("Undetermined"); + CPAPModeNames[MODE_CPAP]=QObject::tr("CPAP"); + CPAPModeNames[MODE_APAP]=QObject::tr("Auto"); + CPAPModeNames[MODE_BIPAP]=QObject::tr("BIPAP"); + CPAPModeNames[MODE_ASV]=QObject::tr("ASV"); - PressureReliefNames[PR_UNKNOWN]=_("Undetermined"); - PressureReliefNames[PR_NONE]=_("None"); - PressureReliefNames[PR_CFLEX]=_("C-Flex"); - PressureReliefNames[PR_CFLEXPLUS]=_("C-Flex+"); - PressureReliefNames[PR_AFLEX]=_("A-Flex"); - PressureReliefNames[PR_BIFLEX]=_("Bi-Flex"); - PressureReliefNames[PR_EPR]=_("Exhalation Pressure Relief (EPR)"); - PressureReliefNames[PR_SMARTFLEX]=_("SmartFlex"); + PressureReliefNames[PR_UNKNOWN]=QObject::tr("Undetermined"); + PressureReliefNames[PR_NONE]=QObject::tr("None"); + PressureReliefNames[PR_CFLEX]=QObject::tr("C-Flex"); + PressureReliefNames[PR_CFLEXPLUS]=QObject::tr("C-Flex+"); + PressureReliefNames[PR_AFLEX]=QObject::tr("A-Flex"); + PressureReliefNames[PR_BIFLEX]=QObject::tr("Bi-Flex"); + PressureReliefNames[PR_EPR]=QObject::tr("Exhalation Pressure Relief (EPR)"); + PressureReliefNames[PR_SMARTFLEX]=QObject::tr("SmartFlex"); - DefaultMCShortNames[CPAP_Obstructive]=_("OA"); - DefaultMCShortNames[CPAP_Hypopnea]=_("H"); - DefaultMCShortNames[CPAP_RERA]=_("RE"); - DefaultMCShortNames[CPAP_ClearAirway]=_("CA"); - DefaultMCShortNames[CPAP_CSR]=_("CSR/PB"); - DefaultMCShortNames[CPAP_VSnore]=_("VS"); - DefaultMCShortNames[PRS1_VSnore2]=_("VS2"); - DefaultMCShortNames[CPAP_FlowLimit]=_("FL"); - DefaultMCShortNames[CPAP_Pressure]=_("P"); - DefaultMCShortNames[CPAP_Leak]=_("LR"); - DefaultMCShortNames[CPAP_EAP]=_("EPAP"); - DefaultMCShortNames[CPAP_IAP]=_("IPAP"); - DefaultMCShortNames[PRS1_PressurePulse]=_("PP"); + DefaultMCShortNames[CPAP_Obstructive]=QObject::tr("OA"); + DefaultMCShortNames[CPAP_Hypopnea]=QObject::tr("H"); + DefaultMCShortNames[CPAP_RERA]=QObject::tr("RE"); + DefaultMCShortNames[CPAP_ClearAirway]=QObject::tr("CA"); + DefaultMCShortNames[CPAP_CSR]=QObject::tr("CSR/PB"); + DefaultMCShortNames[CPAP_VSnore]=QObject::tr("VS"); + DefaultMCShortNames[PRS1_VSnore2]=QObject::tr("VS2"); + DefaultMCShortNames[CPAP_FlowLimit]=QObject::tr("FL"); + DefaultMCShortNames[CPAP_Pressure]=QObject::tr("P"); + DefaultMCShortNames[CPAP_Leak]=QObject::tr("LR"); + DefaultMCShortNames[CPAP_EAP]=QObject::tr("EPAP"); + DefaultMCShortNames[CPAP_IAP]=QObject::tr("IPAP"); + DefaultMCShortNames[PRS1_PressurePulse]=QObject::tr("PP"); - DefaultMCLongNames[CPAP_Obstructive]=_("Obstructive Apnea"); - DefaultMCLongNames[CPAP_Hypopnea]=_("Hypopnea"); - DefaultMCLongNames[CPAP_RERA]=_("RERA"); - DefaultMCLongNames[CPAP_ClearAirway]=_("Clear Airway Apnea"); - DefaultMCLongNames[CPAP_CSR]=_("Periodic Breathing"); - DefaultMCLongNames[CPAP_VSnore]=_("Vibratory Snore"); // flags type - DefaultMCLongNames[CPAP_FlowLimit]=_("Flow Limitation"); - DefaultMCLongNames[CPAP_Pressure]=_("Pressure"); - DefaultMCLongNames[CPAP_Leak]=_("Leak Rate"); - DefaultMCLongNames[CPAP_EAP]=_("BIPAP EPAP"); - DefaultMCLongNames[CPAP_IAP]=_("BIPAP IPAP"); - DefaultMCLongNames[CPAP_Snore]=_("Vibratory Snore"); // Graph data - DefaultMCLongNames[PRS1_VSnore2]=_("Vibratory Snore (Graph)"); - DefaultMCLongNames[PRS1_PressurePulse]=_("Pressure Pulse"); - DefaultMCLongNames[PRS1_Unknown0E]=_("Unknown 0E"); - DefaultMCLongNames[PRS1_Unknown00]=_("Unknown 00"); - DefaultMCLongNames[PRS1_Unknown01]=_("Unknown 01"); - DefaultMCLongNames[PRS1_Unknown0B]=_("Unknown 0B"); - DefaultMCLongNames[PRS1_Unknown10]=_("Unknown 10"); + DefaultMCLongNames[CPAP_Obstructive]=QObject::tr("Obstructive Apnea"); + DefaultMCLongNames[CPAP_Hypopnea]=QObject::tr("Hypopnea"); + DefaultMCLongNames[CPAP_RERA]=QObject::tr("RERA"); + DefaultMCLongNames[CPAP_ClearAirway]=QObject::tr("Clear Airway Apnea"); + DefaultMCLongNames[CPAP_CSR]=QObject::tr("Periodic Breathing"); + DefaultMCLongNames[CPAP_VSnore]=QObject::tr("Vibratory Snore"); // flags type + DefaultMCLongNames[CPAP_FlowLimit]=QObject::tr("Flow Limitation"); + DefaultMCLongNames[CPAP_Pressure]=QObject::tr("Pressure"); + DefaultMCLongNames[CPAP_Leak]=QObject::tr("Leak Rate"); + DefaultMCLongNames[CPAP_EAP]=QObject::tr("BIPAP EPAP"); + DefaultMCLongNames[CPAP_IAP]=QObject::tr("BIPAP IPAP"); + DefaultMCLongNames[CPAP_Snore]=QObject::tr("Vibratory Snore"); // Graph data + DefaultMCLongNames[PRS1_VSnore2]=QObject::tr("Vibratory Snore (Graph)"); + DefaultMCLongNames[PRS1_PressurePulse]=QObject::tr("Pressure Pulse"); + DefaultMCLongNames[PRS1_Unknown0E]=QObject::tr("Unknown 0E"); + DefaultMCLongNames[PRS1_Unknown00]=QObject::tr("Unknown 00"); + DefaultMCLongNames[PRS1_Unknown01]=QObject::tr("Unknown 01"); + DefaultMCLongNames[PRS1_Unknown0B]=QObject::tr("Unknown 0B"); + DefaultMCLongNames[PRS1_Unknown10]=QObject::tr("Unknown 10"); } @@ -202,13 +204,13 @@ Machine::Machine(Profile *p,MachineID id) m_id=temp; } else m_id=id; - qDebug("Create Machine: %lx",m_id); + qDebug() << "Create Machine: " << hex << m_id; //%lx",m_id); m_type=MT_UNKNOWN; firstsession=true; } Machine::~Machine() { - qDebug("Destroy Machine"); + qDebug() << "Destroy Machine"; map::iterator d; for (d=day.begin();d!=day.end();d++) { delete d->second; @@ -308,8 +310,7 @@ bool Machine::Purge(int secret) return false; - QString native="Purging "+QDir::toNativeSeparators(path); - qDebug(native.toLatin1()); + qDebug() << "Purging " << QDir::toNativeSeparators(path); dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); dir.setSorting(QDir::Name); @@ -323,15 +324,15 @@ bool Machine::Purge(int secret) int j=fullpath.lastIndexOf("."); QString ext_s=*(fullpath.rightRef(j+1).string()); bool ok; - int ext=ext_s.toInt(&ok,10); + ext_s.toInt(&ok,10); if (ok) { - qDebug(("TestMe: Deleting "+fullpath).toLatin1()); + qDebug() << "TestMe: Deleting " << fullpath; dir.remove(fullpath); } else could_not_kill++; } if (could_not_kill>0) { - qWarning(("Could not purge path\n"+path+"\n\n%i file(s) remain.. Suggest manually deleting this path\n").toLatin1(),could_not_kill); + qWarning() << "Could not purge path\n" << path << "\n\n" << could_not_kill << " file(s) remain.. Suggest manually deleting this path\n"; return false; } @@ -341,7 +342,7 @@ bool Machine::Load() { QString path=profile->Get("DataFolder")+"/"+hexid(); QDir dir(path); - qDebug(("Loading "+path).toLatin1()); + qDebug() << "Loading " << path; if (!dir.exists() || !dir.isReadable()) return false; @@ -397,6 +398,7 @@ bool Machine::SaveSession(Session *sess) { QString path=profile->Get("DataFolder")+"/"+hexid(); if (sess->IsChanged()) sess->Store(path); + return true; } bool Machine::Save() { diff --git a/SleepLib/preferences.cpp b/SleepLib/preferences.cpp index 2b9d7000..66e0b588 100644 --- a/SleepLib/preferences.cpp +++ b/SleepLib/preferences.cpp @@ -16,6 +16,7 @@ License: GPL #include #include #include +#include #include "preferences.h" @@ -163,7 +164,7 @@ bool Preferences::Open(QString filename) { if (!filename.isEmpty()) p_filename=filename; - qDebug(("Opening "+p_filename).toLatin1()); + qDebug() << "Opening " << p_filename; TiXmlDocument xml(p_filename.toLatin1()); if (!xml.LoadFile()) { return false; @@ -194,13 +195,13 @@ bool Preferences::Open(QString filename) if (type=="double") { double d=pText.toDouble(&ok); if (!ok) - qDebug("String to number conversion error in Preferences::Open()"); + qDebug() << "String to number conversion error in Preferences::Open()"; else p_preferences[pKey]=d; } else if (type=="qlonglong") { qlonglong d=pText.toLongLong(&ok); if (!ok) - qDebug("String to number conversion error in Preferences::Open()"); + qDebug() << "String to number conversion error in Preferences::Open()"; else p_preferences[pKey]=d; } else if (type=="bool") { @@ -211,7 +212,7 @@ bool Preferences::Open(QString filename) else if (pText.toLower()=="false") p_preferences[pKey]=false; else - qDebug("String to number conversion error in Preferences::Open()"); + qDebug() << "String to number conversion error in Preferences::Open()"; } else p_preferences[pKey]=(bool)d; } else if (type=="qdatetime") { @@ -220,7 +221,7 @@ bool Preferences::Open(QString filename) if (d.isValid()) p_preferences[pKey]=d; else - qWarning(("Invalid DateTime record in "+filename).toLatin1()); + qWarning() << "Invalid DateTime record in " << filename; } else { // Assume string p_preferences[pKey]=pText; @@ -258,7 +259,7 @@ bool Preferences::Save(QString filename) if (type==QVariant::Invalid) continue; msg=new TiXmlElement(i->first.toLatin1()); - //qDebug(i->first.toLatin1()); + //qDebug() << i->first; msg->SetAttribute("type",i->second.typeName()); QString t; diff --git a/SleepLib/profiles.cpp b/SleepLib/profiles.cpp index fbd69934..1f49731e 100644 --- a/SleepLib/profiles.cpp +++ b/SleepLib/profiles.cpp @@ -6,17 +6,12 @@ Author: Mark Watkins License: GPL */ -//#include -//#include -//#include -//#include -//#include -//#include #include #include #include #include +#include #include "preferences.h" #include "profiles.h" @@ -211,7 +206,7 @@ Day * Profile::GetDay(QDate date,MachineType type) void Profile::Import(QString path) { int c=0; - qDebug(("Importing "+path).toLatin1()); + qDebug() << "Importing " << path; listloaders=GetLoaders(); for (list::iterator i=loaders.begin(); i!=loaders.end(); i++) { if (c+=(*i)->Open(path,this)) break; @@ -344,7 +339,7 @@ void Scan() return; } if (!dir.isReadable()) { - qWarning(("Can't open "+path).toLatin1()); + qWarning() << "Can't open " << path; return; } diff --git a/SleepLib/session.cpp b/SleepLib/session.cpp index 2f76aa00..0a9887be 100644 --- a/SleepLib/session.cpp +++ b/SleepLib/session.cpp @@ -8,6 +8,7 @@ #include "session.h" #include "math.h" #include +#include #include #include #include @@ -113,7 +114,7 @@ double Session::percentile(MachineCode mc,int field,double percent) for (e=events[mc].begin(); e!=events[mc].end(); e++) { Event & ev = *(*e); - array.push_back(ev[0]); + array.push_back(ev[field]); } std::sort(array.begin(),array.end(),sortfunction); int size=array.size(); @@ -327,7 +328,7 @@ bool Session::StoreSummary(QString filename) mctype[mc]=MC_datetime; } else { QString t=i->second.typeToName(type); - qWarning(("Error in Session->StoreSummary: Can't pack variant type "+t).toLatin1()); + qWarning() << "Error in Session->StoreSummary: Can't pack variant type " << t; exit(1); } f.Pack((qint16)mc); @@ -360,7 +361,7 @@ bool Session::LoadSummary(QString filename) //qDebug(("Loading Summary "+filename).toLatin1()); BinaryFile f; if (!f.Open(filename,BF_READ)) { - qDebug(("Couldn't open file"+filename).toLatin1()); + qDebug() << "Couldn't open file" << filename; return false; } @@ -496,14 +497,14 @@ bool Session::LoadEvents(QString filename) if (filename.isEmpty()) return false; BinaryFile f; if (!f.Open(filename,BF_READ)) { - qDebug(("Couldn't open events file"+filename).toLatin1()); + qDebug() << "Couldn't open events file" << filename; return false; } quint32 t32; quint16 t16; quint8 t8; - qint16 i16; + //qint16 i16; // qint16 sumsize; @@ -561,7 +562,7 @@ bool Session::LoadEvents(QString filename) } EventDataType ED[max_number_event_fields]; for (int c=0; c >::iterator m; - QTreeWidgetItem * ti,sroot; + //QTreeWidgetItem * sroot; for (m=(*s)->events.begin();m!=(*s)->events.end();m++) { MachineCode code=m->first; @@ -496,7 +496,7 @@ void Daily::Load(QDate date) previous_date=date; Day *cpap=profile->GetDay(date,MT_CPAP); Day *oxi=profile->GetDay(date,MT_OXIMETER); - Day *sleepstage=profile->GetDay(date,MT_SLEEPSTAGE); + // Day *sleepstage=profile->GetDay(date,MT_SLEEPSTAGE); QString html=""; html+=""; @@ -933,7 +933,7 @@ void Daily::on_JournalNotesUnderline_clicked() -AHIGraph::AHIGraph(QObject * parent) +/*AHIGraph::AHIGraph(QObject * parent) { } AHIGraph::~AHIGraph() @@ -977,3 +977,4 @@ QList AHIGraph::plugins() const return QList() << plugin; } + */ diff --git a/daily.h b/daily.h index efe5d332..06b76a7e 100644 --- a/daily.h +++ b/daily.h @@ -83,7 +83,7 @@ private: QLabel *NoData; }; -class AHIGraph:public QWebPluginFactory +/*class AHIGraph:public QWebPluginFactory { public: AHIGraph(QObject * parent = 0); @@ -91,6 +91,6 @@ public: virtual QObject * create ( const QString & mimeType, const QUrl & url, const QStringList & argumentNames, const QStringList & argumentValues) const; virtual QList plugins () const; //virtual void refreshPlugins (); -}; +}; */ #endif // DAILY_H diff --git a/main.cpp b/main.cpp index 24079952..e3a4236b 100644 --- a/main.cpp +++ b/main.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "mainwindow.h" #include "SleepLib/profiles.h" @@ -25,7 +26,7 @@ int main(int argc, char *argv[]) int id=QFontDatabase::addApplicationFont(":/fonts/FreeSans.ttf"); QStringList ffam=QFontDatabase::applicationFontFamilies(id); for (QStringList::iterator i=ffam.begin();i!=ffam.end();i++) { - qDebug(("Loaded Font: "+*i).toLatin1()); + qDebug() << "Loaded Font: " << (*i); } a.setFont(QFont("FreeSans",10)); diff --git a/mainwindow.cpp b/mainwindow.cpp index 79b3cf30..6b0a8799 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -77,11 +77,6 @@ MainWindow::~MainWindow() delete ui; Profiles::Done(); } -void MainWindow::showEvent(QShowEvent * event) -{ - if (daily) - daily->RedrawGraphs(); -} void MainWindow::Startup() { @@ -184,6 +179,7 @@ void MainWindow::on_overviewButton_clicked() void MainWindow::on_webView_loadFinished(bool arg1) { + arg1=arg1; qprogress->hide(); if (first_load) { QTimer::singleShot(0,this,SLOT(Startup())); diff --git a/mainwindow.h b/mainwindow.h index ce4248d1..94fd284d 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -59,7 +59,6 @@ private slots: void on_action_Link_Graphs_triggered(bool checked); void on_actionUse_AntiAliasing_triggered(bool checked); - void showEvent(QShowEvent * event); private: Ui::MainWindow *ui; diff --git a/overview.cpp b/overview.cpp index 24b76a76..60c9d6ba 100644 --- a/overview.cpp +++ b/overview.cpp @@ -122,7 +122,7 @@ void Overview::ReloadGraphs() (*h)->ResetDateRange(); (*h)->Reload(NULL); } - on_rbLastWeek_clicked(true); + on_rbLastWeek_clicked(); } void Overview::UpdateGraphs() { @@ -136,46 +136,6 @@ void Overview::UpdateGraphs() } -void Overview::on_rbLastWeek_clicked(bool checked) -{ - ui->drStart->setDateRange(profile->FirstDay(),profile->LastDay()); - ui->drEnd->setDateRange(profile->FirstDay(),profile->LastDay()); - - QDate d=profile->LastDay(); - ui->drEnd->setDate(d); - d=d.addDays(-7); - if (dFirstDay()) d=profile->FirstDay(); - ui->drStart->setDate(d); - UpdateGraphs(); -} - -void Overview::on_rbLastMonth_clicked(bool checked) -{ - ui->drStart->setDateRange(profile->FirstDay(),profile->LastDay()); - ui->drEnd->setDateRange(profile->FirstDay(),profile->LastDay()); - - QDate d=profile->LastDay(); - ui->drEnd->setDate(d); - d=d.addDays(-30); - if (dFirstDay()) d=profile->FirstDay(); - ui->drStart->setDate(d); - UpdateGraphs(); -} - -void Overview::on_rbEverything_clicked(bool checked) -{ - ui->drStart->setDateRange(profile->FirstDay(),profile->LastDay()); - ui->drEnd->setDateRange(profile->FirstDay(),profile->LastDay()); - - ui->drEnd->setDate(profile->LastDay()); - ui->drStart->setDate(profile->FirstDay()); - UpdateGraphs(); -} - -void Overview::on_rbDateRange_clicked(bool checked) -{ - UpdateGraphs(); -} void UpdateCal(QCalendarWidget *cal) { QDate d1=cal->minimumDate(); @@ -217,3 +177,44 @@ void Overview::on_rbDateRange_toggled(bool checked) ui->drStartLabel->setEnabled(checked); ui->drEndLabel->setEnabled(checked); } + +void Overview::on_rbLastWeek_clicked() +{ + ui->drStart->setDateRange(profile->FirstDay(),profile->LastDay()); + ui->drEnd->setDateRange(profile->FirstDay(),profile->LastDay()); + + QDate d=profile->LastDay(); + ui->drEnd->setDate(d); + d=d.addDays(-7); + if (dFirstDay()) d=profile->FirstDay(); + ui->drStart->setDate(d); + UpdateGraphs(); +} + +void Overview::on_rbLastMonth_clicked() +{ + ui->drStart->setDateRange(profile->FirstDay(),profile->LastDay()); + ui->drEnd->setDateRange(profile->FirstDay(),profile->LastDay()); + + QDate d=profile->LastDay(); + ui->drEnd->setDate(d); + d=d.addDays(-30); + if (dFirstDay()) d=profile->FirstDay(); + ui->drStart->setDate(d); + UpdateGraphs(); +} + +void Overview::on_rbEverything_clicked() +{ + ui->drStart->setDateRange(profile->FirstDay(),profile->LastDay()); + ui->drEnd->setDateRange(profile->FirstDay(),profile->LastDay()); + + ui->drEnd->setDate(profile->LastDay()); + ui->drStart->setDate(profile->FirstDay()); + UpdateGraphs(); +} + +void Overview::on_rbDateRange_clicked() +{ + UpdateGraphs(); +} diff --git a/overview.h b/overview.h index 6f76aeaf..8f57aece 100644 --- a/overview.h +++ b/overview.h @@ -31,20 +31,20 @@ public: private slots: - void on_rbLastWeek_clicked(bool checked); - - void on_rbLastMonth_clicked(bool checked); - - void on_rbEverything_clicked(bool checked); - - void on_rbDateRange_clicked(bool checked); - void on_drStart_dateChanged(const QDate &date); void on_drEnd_dateChanged(const QDate &date); void on_rbDateRange_toggled(bool checked); + void on_rbLastWeek_clicked(); + + void on_rbLastMonth_clicked(); + + void on_rbEverything_clicked(); + + void on_rbDateRange_clicked(); + private: Ui::Overview *ui; Profile *profile;