diff --git a/Graphs/graphwindow.cpp b/Graphs/graphwindow.cpp index 9d1d0eb2..226f3375 100644 --- a/Graphs/graphwindow.cpp +++ b/Graphs/graphwindow.cpp @@ -6,10 +6,14 @@ #include #include +#include #include #include "SleepLib/profiles.h" #include "graphwindow.h" #include "Graphs/gTitle.h" + +extern QStatusBar *qstatusbar; + gGraphWindow::gGraphWindow(QWidget *parent, const QString & title, QGLWidget * shared,Qt::WindowFlags f) : QGLWidget(parent,shared, f ) { @@ -357,6 +361,28 @@ void gGraphWindow::mouseMoveEvent(QMouseEvent * event) QRect r(t1-1, m_marginBottom, t2-t1, m_scrY-m_marginBottom-m_marginTop); + double z; + if (m_block_zoom) { + z=rmax_x-rmin_x; + } else { + z=max_x-min_x; + } + double q=double(t2-t1)/width(); + double f=(q*z)*24.0; + int hours,minutes,seconds; + hours=int(f); + minutes=int(f*60.0) % 60; + seconds=int(f*3600.0) % 60; + QString s; + if (z>1) { + s.sprintf("%.1f days",q*z); + } else if (z>(1.0/(24.0*12.0))) { + s.sprintf("%02i:%02i:%02i",hours,minutes,seconds); + } else { + int milli=int(f*3600000.0) % 1000; + s.sprintf("%02i:%02i:%02i:%04i",hours,minutes,seconds,milli); + } + qstatusbar->showMessage(s,3000); m_mouseRBlast=m_mouseRBrect; m_mouseRBrect=r; diff --git a/mainwindow.cpp b/mainwindow.cpp index a3c9e59b..0e651b91 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -19,6 +19,7 @@ QProgressBar *qprogress; QLabel *qstatus; +QStatusBar *qstatusbar; void MainWindow::Log(QString s) { @@ -49,6 +50,7 @@ MainWindow::MainWindow(QWidget *parent) : shared_context=new QGLContext(fmt); //ui->tabWidget->setCurrentWidget(daily); + qstatusbar=ui->statusbar; qprogress=new QProgressBar(this); qprogress->setMaximum(100); qstatus=new QLabel("",this); diff --git a/mainwindow.h b/mainwindow.h index 736e4304..0e1398da 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -18,6 +18,8 @@ namespace Ui { class MainWindow; } +extern QStatusBar *qstatusbar; + class MainWindow : public QMainWindow { Q_OBJECT diff --git a/overview.cpp b/overview.cpp index 20cbc98f..5ab50829 100644 --- a/overview.cpp +++ b/overview.cpp @@ -145,17 +145,8 @@ void Overview::ReloadGraphs() // session_times->Reload(NULL); on_rbLastWeek_clicked(); } - -void Overview::UpdateGraphs() +void Overview::UpdateHTML() { - QDate first=ui->drStart->date(); - QDate last=ui->drEnd->date(); - for (list::iterator h=Data.begin();h!=Data.end();h++) { - //(*h)->Update(dummyday); - (*h)->SetDateRange(first,last); - } - session_times->SetDateRange(first,last); - RedrawGraphs(); QString html="
"; html+=""; html+=""; @@ -180,7 +171,18 @@ void Overview::UpdateGraphs() html+="
Statistics
" "
"; ui->webView->setHtml(html); - +} +void Overview::UpdateGraphs() +{ + QDate first=ui->drStart->date(); + QDate last=ui->drEnd->date(); + for (list::iterator h=Data.begin();h!=Data.end();h++) { + //(*h)->Update(dummyday); + (*h)->SetDateRange(first,last); + } + session_times->SetDateRange(first,last); + RedrawGraphs(); + UpdateHTML(); } diff --git a/overview.h b/overview.h index 8dd6574b..44cef1c5 100644 --- a/overview.h +++ b/overview.h @@ -48,6 +48,7 @@ private: void AddData(HistoryData *d) { Data.push_back(d); }; void AddGraph(gGraphWindow *w) { Graphs.push_back(w); }; void RedrawGraphs(); + void UpdateHTML(); HistoryData *ahidata,*pressure,*leak,*usage,*bedtime,*waketime,*pressure_iap,*pressure_eap; HistoryData *pressure_min,*pressure_max; diff --git a/oximetry.cpp b/oximetry.cpp index afca7d09..49dbbb73 100644 --- a/oximetry.cpp +++ b/oximetry.cpp @@ -91,7 +91,7 @@ void Oximetry::on_RefreshPortsButton_clicked() int z=0; QString firstport; bool current_found=false; -#if (Q_WS_WINDOWS) +#if (Q_WS_WIN32) #define qesPORTNAME portName #else #define qesPORTNAME physName @@ -244,6 +244,12 @@ void Oximetry::UpdatePlethy(qint8 d) PLETHY->MinX(); PLETHY->MaxX(); PLETHY->RealMaxX(); + pulse->SetRealMaxX(PLETHY->RealMaxX()); + spo2->SetRealMaxX(PLETHY->RealMaxX()); + PULSE->SetMinX(PLETHY->MinX()); + SPO2->SetMinX(PLETHY->MinX()); + PULSE->SetMaxX(PLETHY->MaxX()); + SPO2->SetMaxX(PLETHY->MaxX()); if (plethy->np[0]>max_data_points) { //TODO: Stop Serial recording.. @@ -253,16 +259,36 @@ void Oximetry::UpdatePlethy(qint8 d) } //PLETHY->updateGL(); // Move this to a timer. } -bool Oximetry::UpdatePulseSPO2(qint8 pul,qint8 sp) +bool Oximetry::UpdatePulse(qint8 pul) { bool ret=false; // Don't block zeros.. If the data is used, it's needed // Can make the graph can skip them. - if (lastpulse!=pul) { + if (lastpulse!=pul) + { pulse->point[0][pulse->np[0]].setX(double(lasttime)/86400000.0); pulse->point[0][pulse->np[0]++].setY(pul); - PULSE->updateGL(); + if (pul!=0) { + if (pulse->MinY()==0) { + pulse->SetMinY((pul/10) * 10); + pulse->SetMaxY((pul/10+1) * 10); + PULSE->MinY(); + PULSE->MaxY(); + } else { + if (pulMinY()) { + pulse->SetMinY((pul/10) * 10); + PULSE->MinY(); + } + if (pul>pulse->MaxY()) { + pulse->SetMaxY((pul/10+1) * 10); + PULSE->MaxY(); + } + + } + } + + // PULSE->updateGL(); if (pulse->np[0]>max_data_points) { //TODO: Stop Serial recording.. @@ -273,10 +299,38 @@ bool Oximetry::UpdatePulseSPO2(qint8 pul,qint8 sp) ret=true; //qDebug() << "Pulse=" << int(bytes[0]); } - if (lastspo2!=sp) { + lastpulse=pul; + return ret; +} +bool Oximetry::UpdateSPO2(qint8 sp) +{ + bool ret=false; + + if (lastspo2!=sp) + { spo2->point[0][spo2->np[0]].setX(double(lasttime)/86400000.0); spo2->point[0][spo2->np[0]++].setY(sp); - SPO2->updateGL(); + + if (sp!=0) { + if (spo2->MinY()==0) { + spo2->SetMinY((sp/10) * 10); + spo2->SetMaxY((sp/10+1) * 10); + SPO2->MinY(); + SPO2->MaxY(); + } else { + if (spMinY()) { + spo2->SetMinY((sp/10) * 10); + SPO2->MinY(); + } + if (sp>spo2->MaxY()) { + spo2->SetMaxY((sp/10+1) * 10); + SPO2->MaxY(); + } + + } + } + + //SPO2->updateGL(); if (spo2->np[0]>max_data_points) { //TODO: Stop Serial recording.. @@ -288,7 +342,6 @@ bool Oximetry::UpdatePulseSPO2(qint8 pul,qint8 sp) //qDebug() << "SpO2=" << int(bytes[1]); } - lastpulse=pul; lastspo2=sp; return ret; } @@ -301,22 +354,25 @@ void Oximetry::onReadyRead() port->read(bytes.data(), bytes.size()); int i=0; - bool redraw_ps=false; + bool redraw_pulse,redraw_spo2; + redraw_pulse=redraw_spo2=false; while (iupdateGL(); - if (redraw_ps) { + if (redraw_pulse) PULSE->updateGL(); + if (redraw_spo2) SPO2->updateGL(); - } + /*if (bytes.size()==3) { } else if (bytes.size()==2) { // Data bytes in live mode // Plethy data diff --git a/oximetry.h b/oximetry.h index 5b9eda4d..fdd0907f 100644 --- a/oximetry.h +++ b/oximetry.h @@ -40,7 +40,8 @@ private slots: void on_ImportButton_clicked(); private: - bool UpdatePulseSPO2(qint8 pulse,qint8 spo2); + bool UpdatePulse(qint8 pulse); + bool UpdateSPO2(qint8 spo2); void UpdatePlethy(qint8 plethy);