diff --git a/Graphs/gLineChart.cpp b/Graphs/gLineChart.cpp index f3f86177..79bde685 100644 --- a/Graphs/gLineChart.cpp +++ b/Graphs/gLineChart.cpp @@ -217,17 +217,16 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry) } bool firstpx=true; + int done2=0; for (int i=idx;i=sam) i-=sam; // Start with the previous sample (which will be in clipping area) } - if (point[i].x() > maxx) done=true; // Let this iteration finish.. (This point will be in far clipping) - px=1+((point[i].x() - minx) * xmult); // Scale the time scale X to pixel scale X @@ -256,6 +255,7 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry) } lastpx=start_px+px; lastpy=start_py+py; + //if (lastpx>start_px+width) done=true; } else { // In accel mode, each pixel has a min/max Y value. // m_drawlist's index is the pixel index for the X pixel axis. @@ -271,8 +271,10 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry) // Update the Y pixel bounds. if (y1m_drawlist[z].y()) m_drawlist[z].setY(y1); + //if (z>width) done=true; } + if (point[i].x() > maxx) done=true; // Let this iteration finish.. (This point will be in far clipping) if (done) break; } @@ -295,13 +297,13 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry) - QString b; + /*QString b; long j=vertcnt/2; if (accel) j/=2; - //b.sprintf("%i %i %i %i",visible_points,sam,num_points,j); - //float x,y; - //GetTextExtent(b,x,y); - //DrawText(w,b,scrx-w.GetRightMargin()-x-15,scry-w.GetTopMargin()-10); + b.sprintf("%i %i %i %li",visible_points,sam,num_points,j); + float x,y; + GetTextExtent(b,x,y); + DrawText(b,scrx-w.GetRightMargin()-x-15,scry-w.GetBottomMargin()-10); */ glColor4ub(col.red(),col.green(),col.blue(),255); diff --git a/Graphs/gLineOverlay.cpp b/Graphs/gLineOverlay.cpp index eac5aec1..d0d9d19c 100644 --- a/Graphs/gLineOverlay.cpp +++ b/Graphs/gLineOverlay.cpp @@ -95,19 +95,23 @@ void gLineOverlayBar::Plot(gGraphWindow & w,float scrx,float scry) } else { if (lo_type==LOT_Dot) { pointarray[pointcnt++]=x1; - pointarray[pointcnt++]=w.y2p(20); + pointarray[pointcnt++]=start_py+3; // } else if (lo_type==LOT_Bar) { - pointarray[pointcnt++]=x1; - pointarray[pointcnt++]=top; - vertarray[vertcnt++]=x1; - vertarray[vertcnt++]=top; - vertarray[vertcnt++]=x1; - vertarray[vertcnt++]=bottom; + int z=start_py+height-2; if (xx<(1800.0/86400.0)) { + z=top; + + vertarray[vertcnt++]=x1; + vertarray[vertcnt++]=top; + vertarray[vertcnt++]=x1; + vertarray[vertcnt++]=bottom; GetTextExtent(label,x,y); DrawText(label,x1-(x/2),scry-(start_py+height-30+y)); //w.renderText(x1-(x/2),scry-(start_py+height-30+y),label); } + pointarray[pointcnt++]=x1; + pointarray[pointcnt++]=z; + } } } diff --git a/Graphs/gYAxis.cpp b/Graphs/gYAxis.cpp index a6edc8ae..8a90cc89 100644 --- a/Graphs/gYAxis.cpp +++ b/Graphs/gYAxis.cpp @@ -31,8 +31,8 @@ void gYAxis::Plot(gGraphWindow &w,float scrx,float scry) double maxy=w.max_y; if (maxy==miny) return; - if ((w.max_x-w.min_x)==0) - return; + //if ((w.max_x-w.min_x)==0) + // return; int start_px=w.GetLeftMargin(); int start_py=w.GetBottomMargin(); diff --git a/SleepLib/loader_plugins/prs1_loader.cpp b/SleepLib/loader_plugins/prs1_loader.cpp index 0f806393..06e529ec 100644 --- a/SleepLib/loader_plugins/prs1_loader.cpp +++ b/SleepLib/loader_plugins/prs1_loader.cpp @@ -391,7 +391,7 @@ int PRS1Loader::OpenMachine(Machine *m,QString path,Profile *profile) bool PRS1Loader::OpenSummary(Session *session,QString filename) { - int size,sequence,seconds,br,htype,version; + int size,seconds,br,htype,version,sequence; qint64 timestamp; unsigned char header[24]; unsigned char ext,sum; @@ -420,6 +420,11 @@ bool PRS1Loader::OpenSummary(Session *session,QString filename) htype=header[3]; // 00 = normal // 01=waveform // could be a bool? version=header[4]; + sequence=sequence; + version=version; // don't need it here? + + htype=htype; // shut the warning up.. this is useless. + if (ext!=PRS1_SUMMARY_FILE) return false; @@ -519,7 +524,7 @@ bool PRS1Loader::OpenSummary(Session *session,QString filename) } // v2 event parser. -bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64 timestamp,int version) +bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64 timestamp) { MachineCode Codes[]={ PRS1_Unknown00, PRS1_Unknown01, CPAP_Pressure, CPAP_EAP, PRS1_PressurePulse, CPAP_RERA, CPAP_Obstructive, CPAP_ClearAirway, @@ -530,12 +535,12 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64 EventDataType data[10]; - qint64 start=timestamp; + //qint64 start=timestamp; qint64 t=timestamp; qint64 tt; int pos=0; int cnt=0; - short delta,duration; + short delta;//,duration; while (pos=ncodes) { @@ -547,7 +552,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64 // qDebug()<< d.toString("yyyy-MM-dd HH:mm:ss") << ": " << hex << pos+15 << " " << hex << int(code) ; if (code!=0x12) { delta=buffer[pos]; - duration=buffer[pos+1]; + //duration=buffer[pos+1]; //delta=buffer[pos+1] << 8 | buffer[pos]; pos+=2; t+=delta*1000; @@ -555,7 +560,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64 MachineCode cpapcode=Codes[(int)code]; tt=t; cnt++; - int fc=0; + //int fc=0; switch (code) { case 0x01: // Unknown session->AddEvent(new Event(t,cpapcode, data,0)); @@ -648,7 +653,7 @@ bool PRS1Loader::Parse002(Session *session,unsigned char *buffer,int size,qint64 return true; } -bool PRS1Loader::Parse002ASV(Session *session,unsigned char *buffer,int size,qint64 timestamp,int version) +bool PRS1Loader::Parse002ASV(Session *session,unsigned char *buffer,int size,qint64 timestamp) { MachineCode Codes[]={ PRS1_Unknown00, PRS1_Unknown01, CPAP_Pressure, CPAP_EAP, PRS1_PressurePulse, CPAP_Obstructive, CPAP_ClearAirway, CPAP_Hypopnea, @@ -660,12 +665,12 @@ bool PRS1Loader::Parse002ASV(Session *session,unsigned char *buffer,int size,qin EventDataType data[10]; - qint64 start=timestamp; + //qint64 start=timestamp; qint64 t=timestamp; qint64 tt; int pos=0; int cnt=0; - short delta,duration; + short delta;//,duration; QDateTime d; while (posfirst()); QDate date=d2.date(); - QTime time=d2.time(); + //QTime time=d2.time(); // pref["NoonDateSplit"]=true; if (pref["NoonDateSplit"].toBool()) { int hour=d2.time().hour(); - if (s->session()==0x114) { - int q=0; - } if (hour<12) date=date.addDays(-1); //date=date.addDays(1); diff --git a/main.cpp b/main.cpp index 1168560c..0e72f9dd 100644 --- a/main.cpp +++ b/main.cpp @@ -53,13 +53,13 @@ int main(int argc, char *argv[]) } a.setFont(QFont("FreeSans",10)); - MainWindow w; - mainwin=&w; PRS1Loader::Register(); CMS50Loader::Register(); ZEOLoader::Register(); ResmedLoader::Register(); + MainWindow w; + mainwin=&w; w.show(); diff --git a/mainwindow.ui b/mainwindow.ui index 6c8b0d8f..daa93af8 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -49,6 +49,12 @@ + + 0 + + + 0 + diff --git a/oximetry.cpp b/oximetry.cpp index 1d432c36..67a1bebf 100644 --- a/oximetry.cpp +++ b/oximetry.cpp @@ -17,6 +17,7 @@ Oximetry::Oximetry(QWidget *parent) : { ui->setupUi(this); port=NULL; + portname=""; QString prof=pref["Profile"].toString(); profile=Profiles::Get(prof); if (!profile) { @@ -29,55 +30,46 @@ Oximetry::Oximetry(QWidget *parent) : gSplitter->setHandleWidth(2); ui->graphLayout->addWidget(gSplitter); + AddData(plethy=new WaveData(OXI_Plethy)); + AddGraph(PLETHY=new gGraphWindow(gSplitter,tr("Plethysomogram"),(QGLWidget *)NULL)); + PLETHY->AddLayer(new gLineChart(plethy,Qt::black,65536,true,false,false)); + AddData(pulse=new EventData(OXI_Pulse)); - PULSE=new gGraphWindow(gSplitter,tr("Pulse Rate"),(QGLWidget *)NULL); - PULSE->AddLayer(new gXAxis()); - PULSE->AddLayer(new gYAxis()); - PULSE->AddLayer(new gFooBar()); + AddGraph(PULSE=new gGraphWindow(gSplitter,tr("Pulse Rate"),PLETHY)); PULSE->AddLayer(new gLineChart(pulse,Qt::red,65536,false,false,false)); - PULSE->setMinimumHeight(150); AddData(spo2=new EventData(OXI_SPO2)); - SPO2=new gGraphWindow(gSplitter,tr("SPO2"),PULSE); - SPO2->AddLayer(new gXAxis()); - SPO2->AddLayer(new gYAxis()); - SPO2->AddLayer(new gFooBar()); + AddGraph(SPO2=new gGraphWindow(gSplitter,tr("SPO2"),PLETHY)); SPO2->AddLayer(new gLineChart(spo2,Qt::blue,65536,false,false,false)); - SPO2->setMinimumHeight(150); - pulse->AddSegment(1000000); - pulse->np.push_back(0); - spo2->AddSegment(1000000); - spo2->np.push_back(0); + plethy->SetRealMaxY(128); + pulse->SetRealMaxY(130); + spo2->SetRealMaxY(100); + for (unsigned i=0;iAddSegment(1000000); + Data[i]->np.push_back(0); + Data[i]->SetRealMinY(0); + Data[i]->SetMinY(0); + Data[i]->SetMaxY(Data[i]->RealMaxY()); + } - AddData(plethy=new WaveData(OXI_Plethy)); - plethy->AddSegment(1000000); - plethy->np.push_back(0); - plethy->SetMaxY(100); - plethy->SetMinY(0); - PLETHY=new gGraphWindow(gSplitter,tr("Plethysomogram"),PULSE); - //PLETHY->AddLayer(new gXAxis()); - PLETHY->AddLayer(new gYAxis()); - PLETHY->AddLayer(new gFooBar()); - PLETHY->AddLayer(new gLineChart(plethy,Qt::black,65536,true,false,false)); - PLETHY->setMinimumHeight(150); - //PLETHY->SetBlockZoom(true); - - portname=""; - - - gGraphWindow * graphs[]={PLETHY,PULSE,SPO2}; - int ss=sizeof(graphs)/sizeof(gGraphWindow *); - - for (int i=0;iLinkZoom(graphs[j]); + for (unsigned i=0;iLinkZoom(Graphs[j]); } - gSplitter->addWidget(graphs[i]); - graphs[i]->SetSplitter(gSplitter); + Graphs[i]->AddLayer(new gYAxis()); + Graphs[i]->AddLayer(new gXAxis()); + Graphs[i]->AddLayer(new gFooBar()); + + Graphs[i]->setMinimumHeight(150); + Graphs[i]->SetSplitter(gSplitter); + Graphs[i]->RealMinY(); + Graphs[i]->RealMaxY(); + Graphs[i]->MinY(); + Graphs[i]->MaxY(); + gSplitter->addWidget(Graphs[i]); } on_RefreshPortsButton_clicked(); @@ -120,7 +112,7 @@ void Oximetry::on_RefreshPortsButton_clicked() } void Oximetry::RedrawGraphs() { - for (list::iterator g=Graphs.begin();g!=Graphs.end();g++) { + for (vector::iterator g=Graphs.begin();g!=Graphs.end();g++) { (*g)->updateGL(); } } @@ -139,16 +131,10 @@ void Oximetry::on_RunButton_toggled(bool checked) plethy->SetRealMaxX(double(lasttime+60000)/86400000.0); plethy->SetMinX(double(lasttime)/86400000.0); plethy->SetMaxX(double(lasttime+30000)/86400000.0); - plethy->SetRealMinY(0); - plethy->SetRealMaxY(130); - plethy->SetMaxY(130); - plethy->SetMinY(0); - PLETHY->MinX(); - PLETHY->MaxX(); PLETHY->RealMinX(); PLETHY->RealMaxX(); - PLETHY->MinY(); - PLETHY->MaxY(); + PLETHY->MinX(); + PLETHY->MaxX(); plethy->SetReady(true); plethy->SetVC(1); plethy->np[0]=0; @@ -158,37 +144,25 @@ void Oximetry::on_RunButton_toggled(bool checked) pulse->SetRealMaxX(double(lasttime)/86400000.0+(1.0/24.0)); pulse->SetMinX(double(lasttime)/86400000.0); pulse->SetMaxX(double(lasttime)/86400000.0+(1.0/24.0)); - pulse->SetRealMinY(40); - pulse->SetRealMaxY(120); - pulse->SetMaxY(120); - pulse->SetMinY(40); pulse->np[0]=0; pulse->SetReady(true); pulse->SetVC(1); - PULSE->MinX(); - PULSE->MaxX(); PULSE->RealMinX(); PULSE->RealMaxX(); - PULSE->MinY(); - PULSE->MaxY(); + PULSE->MinX(); + PULSE->MaxX(); spo2->SetRealMinX(double(lasttime)/86400000.0); spo2->SetRealMaxX(double(lasttime)/86400000.0+(1.0/24.0)); spo2->SetMinX(double(lasttime)/86400000.0); spo2->SetMaxX(double(lasttime)/86400000.0+(1.0/24.0)); - spo2->SetRealMinY(40); - spo2->SetRealMaxY(100); - spo2->SetMaxY(100); - spo2->SetMinY(40); spo2->np[0]=0; spo2->SetReady(true); spo2->SetVC(1); - SPO2->MinX(); - SPO2->MaxX(); SPO2->RealMinX(); SPO2->RealMaxX(); - SPO2->MinY(); - SPO2->MaxY(); + SPO2->MinX(); + SPO2->MaxX(); ui->RunButton->setText("&Stop"); ui->SerialPortsCombo->setEnabled(false); diff --git a/oximetry.h b/oximetry.h index cc2d9063..5b9eda4d 100644 --- a/oximetry.h +++ b/oximetry.h @@ -49,8 +49,8 @@ private: QSplitter *gSplitter; gPointData *pulse,*spo2,*plethy; gGraphWindow *PULSE,*SPO2,*PLETHY; - list Graphs; - list Data; + vector Graphs; + vector Data; QextSerialPort *port; QString portname; PORTMODE portmode;