diff --git a/sleepyhead/Graphs/gGraphView.cpp b/sleepyhead/Graphs/gGraphView.cpp index 47c1c6f9..d3c5e772 100644 --- a/sleepyhead/Graphs/gGraphView.cpp +++ b/sleepyhead/Graphs/gGraphView.cpp @@ -1238,23 +1238,23 @@ void gGraphView::paintGL() if (!graphs_drawn) { // No graphs drawn? show something useful :) QString txt = QObject::tr("SleepyHead is proudly brought to you by JediMark.").arg(VersionString); - int x2, y2; - GetTextExtent(m_emptytext, x2, y2, bigfont); - int tp2, tp1; +// int x2, y2; +// GetTextExtent(m_emptytext, x2, y2, bigfont); +// int tp2, tp1; if (!m_emptyimage.isNull()) { painter.drawPixmap(width() /2 - m_emptyimage.width() /2, height() /2 - m_emptyimage.height() /2 , m_emptyimage); - tp2 = height() /2 + m_emptyimage.height()/2 + y2; +// tp2 = height() /2 + m_emptyimage.height()/2 + y2; - } else { + } /*else { tp2 = height() / 2 + y2; - } + }*/ QColor col = Qt::black; painter.setPen(col); - painter.setFont(*bigfont); - painter.drawText((width() / 2) - x2 / 2, tp2, m_emptytext); +// painter.setFont(*bigfont); +// painter.drawText((width() / 2) - x2 / 2, tp2, m_emptytext); QRectF rec(0,0,width(),0); painter.setFont(*defaultfont); @@ -1262,7 +1262,11 @@ void gGraphView::paintGL() rec.moveBottom(height()-5); painter.drawText(rec, Qt::AlignHCenter | Qt::AlignBottom, txt); - + } + if (p_profile->appearance->lineCursorMode()) { + emit updateCurrentTime(graphs_drawn ? m_currenttime : 0.0F); + } else { + emit updateRange(graphs_drawn ? m_minx : 0.0F, m_maxx); } DrawTextQue(painter); @@ -1326,11 +1330,6 @@ void gGraphView::paintGL() redrawtimer->start(); } - if (p_profile->appearance->lineCursorMode()) { - emit updateCurrentTime(m_currenttime); - } else { - emit updateRange(m_minx, m_maxx); - } } QString gGraphView::getRangeString() diff --git a/sleepyhead/Graphs/gGraphView.h b/sleepyhead/Graphs/gGraphView.h index 247b5ae5..82bb2b2d 100644 --- a/sleepyhead/Graphs/gGraphView.h +++ b/sleepyhead/Graphs/gGraphView.h @@ -386,6 +386,9 @@ class gGraphView //! \brief Sets the message displayed when there are no graphs to draw void setEmptyText(QString s) { m_emptytext = s; } + //! \brief Returns the message displayed when there are no graphs to draw + QString emptyText() { return m_emptytext; } + //! \brief Sets the message displayed when there are no graphs to draw void setEmptyImage(QPixmap pm) { m_emptyimage = pm; } diff --git a/sleepyhead/Graphs/gLineChart.cpp b/sleepyhead/Graphs/gLineChart.cpp index 1772ab3b..3af368bd 100644 --- a/sleepyhead/Graphs/gLineChart.cpp +++ b/sleepyhead/Graphs/gLineChart.cpp @@ -222,92 +222,6 @@ skipcheck: } } -// for (int i=0; i< m_day->size(); ++i) { -// Session * sess = m_day->sessions.at(i); -// QHash >::iterator it; -// for (it = sess->eventlist.begin(); it != sess->eventlist.end(); ++it) { -// ChannelID code = it.key(); - -// if (flags.contains(code)) continue; - -// schema::Channel * chan = &schema::channel[code]; -// gLineOverlayBar * lob = nullptr; - -// if (chan->type() == schema::FLAG) { -// lob = new gLineOverlayBar(code, chan->defaultColor(), chan->label(), FT_Bar); -// } else if (chan->type() == schema::MINOR_FLAG) { -// lob = new gLineOverlayBar(code, chan->defaultColor(), chan->label(), FT_Dot); -// } else if (chan->type() == schema::SPAN) { -// lob = new gLineOverlayBar(code, chan->defaultColor(), chan->label(), FT_Span); -// } -// if (lob != nullptr) { -// lob->setOverlayDisplayType((m_codes[0] == CPAP_FlowRate) ? (OverlayDisplayType)p_profile->appearance->overlayType() : ODT_TopAndBottom); -// lob->SetDay(m_day); -// flags[code] = lob; -// } -// } -// } - -/* QList middles; - - middles.push_back(CPAP_RespRate); - middles.push_back(CPAP_TidalVolume); - middles.push_back(CPAP_MinuteVent); - middles.push_back(CPAP_Ti); - middles.push_back(CPAP_Te); - - - - CPAPMode mode = (CPAPMode)m_day->settings_wavg(CPAP_Mode); - float perc = p_profile->general->prefCalcPercentile(); - for (int i=0; ipercentile(code, perc / 100.0); - chan.setUpperThreshold(f); - chan.setUpperThresholdColor(darken(schema::channel[CPAP_Pressure].defaultColor())); - m_threshold.push_back(QString("%1% %2 %3").arg(perc, 0, 'f', 0).arg(chan.label()).arg(f,0,'f',2)); - } else { - chan.setUpperThreshold(0); - m_threshold.push_back(QString()); - } - } else if (code == CPAP_IPAP) { - if (mode >= MODE_BILEVEL_AUTO_FIXED_PS) { - float f = m_day->percentile(code,perc / 100.0); - chan.setUpperThreshold(f); - QColor color = darken(schema::channel[CPAP_IPAP].defaultColor()); - chan.setUpperThresholdColor(color); - m_threshold.push_back(QString("%1% %2").arg(perc, 0, 'f', 0).arg(chan.label()));//.arg(f,0,'f',2)); - } else { - chan.setUpperThreshold(0); - m_threshold.push_back(QString()); - } - } else if (code == CPAP_EPAP) { - if ((mode >= MODE_BILEVEL_AUTO_FIXED_PS) && (mode != MODE_ASV)) { - float f = m_day->percentile(code,perc / 100.0); - chan.setUpperThreshold(f); - QColor color = darken(schema::channel[CPAP_EPAP].defaultColor()); - chan.setUpperThresholdColor(color); - m_threshold.push_back(QString("%1% %2").arg(perc, 0, 'f', 0).arg(chan.label()));//.arg(f,0,'f',2)); - } else { - chan.setUpperThreshold(0); - m_threshold.push_back(QString()); - } - } else if (code == CPAP_Leak) { - m_threshold.push_back(QObject::tr("%1 threshold").arg(chan.label())); - } else if (middles.contains(code)) { - float f = m_day->calcMiddle(code); - - chan.setUpperThreshold(f); - chan.setUpperThresholdColor(darken(schema::channel[code].defaultColor())); - m_threshold.push_back(m_day->calcMiddleLabel(code)); - } else { - chan.setUpperThreshold(0); - m_threshold.push_back(QString()); - } - }*/ } EventDataType gLineChart::Miny() { @@ -602,30 +516,6 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion) painter.drawLine(left + 1, y, left + 1 + width, y); } -// if (chan.upperThreshold() > 0) { -// QColor color = chan.upperThresholdColor(); -// color.setAlpha(200); -// painter.setPen(QPen(QBrush(color),1.5,Qt::DotLine)); - -// EventDataType y=top + height + 1 - ((chan.upperThreshold() - miny) * ymult); -// painter.drawLine(left + 1, y, left + 1 + width, y); -// } -// if (chan.lowerThreshold() > 0) { -// QColor color = chan.lowerThresholdColor(); -// color.setAlpha(200); -// painter.setPen(QPen(QBrush(color),1.5 ,Qt::DotLine)); - -// EventDataType y=top + height + 1 - ((chan.lowerThreshold() - miny) * ymult); -// painter.drawLine(left+1, y, left + 1 + width, y); -// } -// if (chan.id() == CPAP_FlowRate) { -// QColor color(Qt::red); -// color.setAlpha(200); -// painter.setPen(QPen(QBrush(color),1.5 ,Qt::DotLine)); - -// EventDataType y=top + height + 1 - ((0 - miny) * ymult); -// painter.drawLine(left+1, y, left + 1 + width, y); -// } } if (!m_enabled[code]) continue; @@ -634,6 +524,7 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion) codepoints = 0; + // For each session... int daysize = m_day->size(); for (int svi = 0; svi < daysize; svi++) { Session *sess = (*m_day)[svi]; @@ -811,13 +702,15 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion) time = el.time(idx) + drift; double rate = double(sr) * double(sam); EventStoreType *ptr = el.rawData() + idx; + if (siz > el.count()) + siz = el.count(); if (accel) { ////////////////////////////////////////////////////////////////// // Accelerated Waveform Plot ////////////////////////////////////////////////////////////////// - for (int i = idx; i < siz; i += sam, ptr += sam) { + for (int i = idx; i <= siz; i += sam, ptr += sam) { time += rate; // This is much faster than QVector access. data = *ptr + el.offset(); @@ -896,10 +789,12 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion) data = (*ptr + el.offset()) * gain; lastpx = xst + ((time - minx) * xmult); lastpy = yst - ((data - miny) * ymult); + EventStoreType *eptr = ptr + el.count()-1; siz--; for (int i = idx; i < siz; i += sam) { ptr += sam; + if (ptr > eptr) break; time += rate; data = (*ptr + el.offset()) * gain; @@ -913,7 +808,7 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion) lastpx = px; lastpy = py; - if (time > maxx) { + if (time >= maxx) { done = true; break; } @@ -938,7 +833,7 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion) int idx = 0; if (siz > 15) { - + // Prime a bit... for (; idx < siz; ++idx) { time = start + *tptr++; diff --git a/sleepyhead/SleepLib/common.cpp b/sleepyhead/SleepLib/common.cpp index f2daa4fd..1b3f1bbb 100644 --- a/sleepyhead/SleepLib/common.cpp +++ b/sleepyhead/SleepLib/common.cpp @@ -348,11 +348,11 @@ void initializeStrings() STR_MessageBox_Busy = QObject::tr("Busy"); STR_MessageBox_PleaseNote = QObject::tr("Please Note"); - STR_Empty_NoData = QObject::tr(""); + STR_Empty_NoData = QObject::tr("No Data Available"); STR_Empty_Brick = QObject::tr("Compliance Only :("); - STR_Empty_NoGraphs = QObject::tr("Graphs Switched Off!"); + STR_Empty_NoGraphs = QObject::tr("Graphs Switched Off"); STR_Empty_SummaryOnly = QObject::tr("Summary Only :("); - STR_Empty_NoSessions = QObject::tr("Sessions Switched Off!"); + STR_Empty_NoSessions = QObject::tr("Sessions Switched Off"); // Dialog box options diff --git a/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp b/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp index 44b8f946..373fa63a 100644 --- a/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/cms50f37_loader.cpp @@ -460,7 +460,9 @@ void CMS50F37Loader::processBytes(QByteArray bytes) buf[i] = (buf[i] & 0x7f) | (msb & 0x01 ? 0x80 : 0); } - qint16 pi = buffer.data()[idx+4] | buffer.data()[idx+5] << 8; + //qint16 pi = buffer.data()[idx+4] | buffer.data()[idx+5] << 8; + qint16 pi = ((char *)buf)[idx+5] << 8 | buf[idx+4]; + pulse = buf[3]; quint8 spo2 = buf[2]; @@ -498,6 +500,8 @@ void CMS50F37Loader::processBytes(QByteArray bytes) idx += len; } while (idx < size); + emit updateProgress(oxirec->size(), duration); + if (!started_import) { imp_callbacks = 0; } else { diff --git a/sleepyhead/daily.cpp b/sleepyhead/daily.cpp index df129b0a..c77e64e4 100644 --- a/sleepyhead/daily.cpp +++ b/sleepyhead/daily.cpp @@ -196,8 +196,8 @@ Daily::Daily(QWidget *parent,gGraphView * shared) graphlist["AHI"] = AHI; - graphlist["INTPULSE"] = new gGraph("INTPULSE", GraphView,tr("Int. Pulse"), channelInfo(OXI_Pulse), default_height, oxigrp); - graphlist["INTSPO2"] = new gGraph("INTSPO2", GraphView,tr("Int. SpO2"), channelInfo(OXI_SPO2), default_height, oxigrp); +// graphlist["INTPULSE"] = new gGraph("INTPULSE", GraphView,tr("Int. Pulse"), channelInfo(OXI_Pulse), default_height, oxigrp); +// graphlist["INTSPO2"] = new gGraph("INTSPO2", GraphView,tr("Int. SpO2"), channelInfo(OXI_SPO2), default_height, oxigrp); // Event Pie Chart (for snapshot purposes) // TODO: Convert snapGV to generic for snapshotting multiple graphs (like reports does) @@ -376,23 +376,23 @@ Daily::Daily(QWidget *parent,gGraphView * shared) gLineChart *lc = nullptr; graphlist[schema::channel[CPAP_MaskPressure].code()]->AddLayer(AddCPAP(new gLineChart(CPAP_MaskPressure, false))); - graphlist[schema::channel[CPAP_RespRate].code()]->AddLayer(AddCPAP(lc=new gLineChart(CPAP_RespRate, square))); + graphlist[schema::channel[CPAP_RespRate].code()]->AddLayer(AddCPAP(lc=new gLineChart(CPAP_RespRate, false))); graphlist[schema::channel[POS_Inclination].code()]->AddLayer(AddPOS(new gLineChart(POS_Inclination))); graphlist[schema::channel[POS_Orientation].code()]->AddLayer(AddPOS(new gLineChart(POS_Orientation))); - graphlist[schema::channel[CPAP_MinuteVent].code()]->AddLayer(AddCPAP(lc=new gLineChart(CPAP_MinuteVent, square))); + graphlist[schema::channel[CPAP_MinuteVent].code()]->AddLayer(AddCPAP(lc=new gLineChart(CPAP_MinuteVent, false))); lc->addPlot(CPAP_TgMV, square); - graphlist[schema::channel[CPAP_TidalVolume].code()]->AddLayer(AddCPAP(lc=new gLineChart(CPAP_TidalVolume, square))); + graphlist[schema::channel[CPAP_TidalVolume].code()]->AddLayer(AddCPAP(lc=new gLineChart(CPAP_TidalVolume, false))); //lc->addPlot(CPAP_Test2,COLOR_DarkYellow,square); //graphlist[schema::channel[CPAP_TidalVolume].code()]->AddLayer(AddCPAP(new gLineChart("TidalVolume2", square))); graphlist[schema::channel[CPAP_FLG].code()]->AddLayer(AddCPAP(new gLineChart(CPAP_FLG, true))); //graphlist[schema::channel[CPAP_RespiratoryEvent].code()]->AddLayer(AddCPAP(new gLineChart(CPAP_RespiratoryEvent, true))); - graphlist[schema::channel[CPAP_IE].code()]->AddLayer(AddCPAP(lc=new gLineChart(CPAP_IE, square))); - graphlist[schema::channel[CPAP_Te].code()]->AddLayer(AddCPAP(lc=new gLineChart(CPAP_Te, square))); - graphlist[schema::channel[CPAP_Ti].code()]->AddLayer(AddCPAP(lc=new gLineChart(CPAP_Ti, square))); + graphlist[schema::channel[CPAP_IE].code()]->AddLayer(AddCPAP(lc=new gLineChart(CPAP_IE, false))); + graphlist[schema::channel[CPAP_Te].code()]->AddLayer(AddCPAP(lc=new gLineChart(CPAP_Te, false))); + graphlist[schema::channel[CPAP_Ti].code()]->AddLayer(AddCPAP(lc=new gLineChart(CPAP_Ti, false))); //lc->addPlot(CPAP_Test2,COLOR:DarkYellow,square); graphlist[schema::channel[ZEO_SleepStage].code()]->AddLayer(AddSTAGE(new gLineChart(ZEO_SleepStage, true))); @@ -414,11 +414,11 @@ Daily::Daily(QWidget *parent,gGraphView * shared) // gLineOverlaySummary *los3=new gLineOverlaySummary(STR_UNIT_EventsPerHour,5,-4); // graphlist["INTPULSE"]->AddLayer(AddCPAP(los3->add(new gLineOverlayBar(OXI_PulseChange, COLOR_PulseChange, STR_TR_PC,FT_Span)))); // graphlist["INTPULSE"]->AddLayer(AddCPAP(los3)); - graphlist["INTPULSE"]->AddLayer(AddCPAP(new gLineChart(OXI_Pulse, square))); +// graphlist["INTPULSE"]->AddLayer(AddCPAP(new gLineChart(OXI_Pulse, square))); // gLineOverlaySummary *los4=new gLineOverlaySummary(STR_UNIT_EventsPerHour,5,-4); // graphlist["INTSPO2"]->AddLayer(AddCPAP(los4->add(new gLineOverlayBar(OXI_SPO2Drop, COLOR_SPO2Drop, STR_TR_O2,FT_Span)))); // graphlist["INTSPO2"]->AddLayer(AddCPAP(los4)); - graphlist["INTSPO2"]->AddLayer(AddCPAP(new gLineChart(OXI_SPO2, true))); +// graphlist["INTSPO2"]->AddLayer(AddCPAP(new gLineChart(OXI_SPO2, true))); graphlist[schema::channel[CPAP_PTB].code()]->setForceMaxY(100); graphlist[schema::channel[OXI_SPO2].code()]->setForceMaxY(100); @@ -1467,11 +1467,11 @@ void Daily::Load(QDate date) // GraphView->ResetBounds(false); // wtf is hiding the scrollbars for??? - if (!cpap && !oxi) { - scrollbar->hide(); - } else { - scrollbar->show(); - } +// if (!cpap && !oxi) { +// scrollbar->hide(); +// } else { +// scrollbar->show(); +// } QString modestr; CPAPMode mode=MODE_UNKNOWN; @@ -2050,9 +2050,11 @@ void Daily::RedrawGraphs() void Daily::on_LineCursorUpdate(double time) { - QDateTime dt = QDateTime::fromMSecsSinceEpoch(time); - QString txt = dt.toString("MMM dd HH:mm:ss:zzz"); - dateDisplay->setText(txt); + if (time > 1) { + QDateTime dt = QDateTime::fromMSecsSinceEpoch(time); + QString txt = dt.toString("MMM dd HH:mm:ss:zzz"); + dateDisplay->setText(txt); + } else dateDisplay->setText(QString(GraphView->emptyText())); } void Daily::on_RangeUpdate(double minx, double maxx) @@ -2061,7 +2063,11 @@ void Daily::on_RangeUpdate(double minx, double maxx) // static qint64 last_maxx = 0; //if ((last_minx != minx) || (last_maxx != maxx)) { + if (minx > 1) { dateDisplay->setText(GraphView->getRangeString()); + } else { + dateDisplay->setText(QString(GraphView->emptyText())); + } //} // last_minx=minx; // last_maxx=maxx; diff --git a/sleepyhead/icons/trophy.png b/sleepyhead/icons/trophy.png index 40ea2e63..3def81dd 100644 Binary files a/sleepyhead/icons/trophy.png and b/sleepyhead/icons/trophy.png differ diff --git a/sleepyhead/mainwindow.ui b/sleepyhead/mainwindow.ui index 173a6ae3..26e301c8 100644 --- a/sleepyhead/mainwindow.ui +++ b/sleepyhead/mainwindow.ui @@ -1442,7 +1442,7 @@ color: yellow; QToolBox { -icon-size: 24px; +icon-size: 32px; border-radius: 15px; background: rgb(163, 190, 255) } @@ -1498,7 +1498,7 @@ QToolBox::tab:selected { 0 0 180 - 724 + 700 @@ -1911,8 +1911,8 @@ border: 2px solid #56789a; border-radius: 30px; 0 0 - 180 - 724 + 100 + 30 @@ -3059,8 +3059,8 @@ border-radius: 10px; 0 0 - 180 - 724 + 100 + 30 diff --git a/sleepyhead/oximeterimport.cpp b/sleepyhead/oximeterimport.cpp index 8282fd1d..67adadc8 100644 --- a/sleepyhead/oximeterimport.cpp +++ b/sleepyhead/oximeterimport.cpp @@ -886,18 +886,18 @@ void OximeterImport::on_saveButton_clicked() ti += step; } ti -= step; - if (lastpulse > 0) { + if (ELpulse && (lastpulse > 0)) { ELpulse->AddEvent(ti, lastpulse); session->setLast(OXI_Pulse, ti); } - if (lastspo2 > 0) { + if (ELspo2 && (lastspo2 > 0)) { ELspo2->AddEvent(ti, lastspo2); session->setLast(OXI_SPO2, ti); } - if (haveperf && lastperf > 0) { + if (haveperf && ELperf && lastperf > 0) { ELperf->AddEvent(ti, lastperf); session->setLast(OXI_Perf, ti); }