diff --git a/sleepyhead/Graphs/gFlagsLine.cpp b/sleepyhead/Graphs/gFlagsLine.cpp index e009483f..fd22df1a 100644 --- a/sleepyhead/Graphs/gFlagsLine.cpp +++ b/sleepyhead/Graphs/gFlagsLine.cpp @@ -129,7 +129,7 @@ void gFlagsGroup::SetDay(Day *d) if (m_empty) { if (d) { - m_empty = !(d->channelExists(CPAP_Pressure) || d->channelExists(CPAP_IPAP) || d->channelExists(CPAP_EPAP)); + m_empty = !d->hasEvents(); } } @@ -138,9 +138,10 @@ void gFlagsGroup::SetDay(Day *d) bool gFlagsGroup::isEmpty() { if (m_day) { - return !(m_day->hasEnabledSessions()) || m_empty; + if (m_day->hasEnabledSessions() && m_day->hasEvents()) + return false; } - return m_empty; + return true; } void gFlagsGroup::paint(QPainter &painter, gGraph &g, const QRegion ®ion) diff --git a/sleepyhead/Graphs/gGraphView.cpp b/sleepyhead/Graphs/gGraphView.cpp index 472db704..316347f7 100644 --- a/sleepyhead/Graphs/gGraphView.cpp +++ b/sleepyhead/Graphs/gGraphView.cpp @@ -1695,6 +1695,9 @@ void gGraphView::populateMenu(gGraph * graph) lines_menu->clear(); for (int i=0; i < lc->m_dotlines.size(); i++) { DottedLine & dot = lc->m_dotlines[i]; + + if (!lc->m_enabled[dot.code]) continue; + schema::Channel &chan = schema::channel[dot.code]; if (dot.available) { diff --git a/sleepyhead/Graphs/gLineChart.cpp b/sleepyhead/Graphs/gLineChart.cpp index 8056bb3e..1cf38b0b 100644 --- a/sleepyhead/Graphs/gLineChart.cpp +++ b/sleepyhead/Graphs/gLineChart.cpp @@ -31,11 +31,10 @@ QColor darken(QColor color, float p) return QColor(r,g,b, color.alpha()); } -gLineChart::gLineChart(ChannelID code, QColor col, bool square_plot, bool disable_accel) +gLineChart::gLineChart(ChannelID code, bool square_plot, bool disable_accel) : Layer(code), m_square_plot(square_plot), m_disable_accel(disable_accel) { - addPlot(code, col, square_plot); - m_line_color = col; + addPlot(code, square_plot); m_report_empty = false; lines.reserve(50000); lasttime = 0; @@ -100,6 +99,7 @@ void gLineChart::SetDay(Day *d) if (code == CPAP_MaskPressure) { if (sess->channelExists(CPAP_MaskPressureHi)) { code = m_codes[j] = CPAP_MaskPressureHi; + m_enabled[code] = schema::channel[CPAP_MaskPressureHi].enabled(); goto skipcheck; // why not :P } } @@ -322,6 +322,7 @@ EventDataType gLineChart::Miny() if (!first) { min = tmp; + first = true; } else { min = qMin(tmp, min); } @@ -583,7 +584,7 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion) if (showDottedLines) { for (int i=0; i < dotlinesize; i++) { DottedLine & dot = m_dotlines[i]; - if ((dot.code != code) || (!dot.enabled) || (!dot.available)) { + if ((dot.code != code) || (!dot.enabled) || (!dot.available) || (!m_enabled[dot.code])) { continue; } schema::Channel & chan = schema::channel[code]; diff --git a/sleepyhead/Graphs/gLineChart.h b/sleepyhead/Graphs/gLineChart.h index 93840236..fcbd5f65 100644 --- a/sleepyhead/Graphs/gLineChart.h +++ b/sleepyhead/Graphs/gLineChart.h @@ -69,12 +69,10 @@ class gLineChart: public Layer public: /*! \brief Creates a new 2D gLineChart Layer \param code The Channel that gets drawn by this layer - \param col Color of the Plot \param square_plot Whether or not to use square plots (only effective for EVL_Event typed EventList data) \param disable_accel Whether or not to disable acceleration for EVL_Waveform typed EventList data */ - gLineChart(ChannelID code, const QColor col = QColor("black"), bool square_plot = false, - bool disable_accel = false); + gLineChart(ChannelID code, bool square_plot = false, bool disable_accel = false); virtual ~gLineChart(); //! \brief The drawing code that fills the vertex buffers @@ -112,7 +110,7 @@ class gLineChart: public Layer virtual bool isEmpty(); //! \brief Add Subplot 'code'. Note the first one is added in the constructor. - void addPlot(ChannelID code, QColor color, bool square) { m_codes.push_back(code); m_colors.push_back(color); m_enabled[code] = true; m_square.push_back(square); } + void addPlot(ChannelID code, bool square) { m_codes.push_back(code); m_enabled[code] = true; m_square.push_back(square); } //! \brief Returns true of the subplot 'code' is enabled. bool plotEnabled(ChannelID code) { if ((m_enabled.contains(code)) && m_enabled[code]) { return true; } else { return false; } } @@ -133,7 +131,6 @@ class gLineChart: public Layer bool m_report_empty; bool m_square_plot; bool m_disable_accel; - QColor m_line_color; //! \brief Used by accelerated waveform plots. Must be >= Screen Resolution (or at least graph width) static const int max_drawlist_size = 10000; @@ -145,7 +142,6 @@ class gLineChart: public Layer QVector m_codes; QStringList m_threshold; - QVector m_colors; QVector m_square; QHash m_enabled; QHash flags; diff --git a/sleepyhead/SleepLib/day.cpp b/sleepyhead/SleepLib/day.cpp index 46ad8ebe..bfd48163 100644 --- a/sleepyhead/SleepLib/day.cpp +++ b/sleepyhead/SleepLib/day.cpp @@ -898,6 +898,13 @@ bool Day::channelExists(ChannelID id) return false; } +bool Day::hasEvents() { + int s=sessions.size(); + for (int i=0; ieventlist.size() > 0) return true; + } + return false; +} bool Day::channelHasData(ChannelID id) { diff --git a/sleepyhead/SleepLib/day.h b/sleepyhead/SleepLib/day.h index 1e78f9b4..e858aa1a 100644 --- a/sleepyhead/SleepLib/day.h +++ b/sleepyhead/SleepLib/day.h @@ -227,6 +227,7 @@ class Day EventDataType c = sum(CPAP_Hypopnea) + sum(CPAP_Obstructive) + sum(CPAP_Apnea) + sum(CPAP_ClearAirway); return c; } + bool hasEvents(); // According to preferences.. EventDataType calcMiddle(ChannelID code); diff --git a/sleepyhead/daily.cpp b/sleepyhead/daily.cpp index e6caf2a2..96537125 100644 --- a/sleepyhead/daily.cpp +++ b/sleepyhead/daily.cpp @@ -285,7 +285,7 @@ Daily::Daily(QWidget *parent,gGraphView * shared) gLineChart *l; - l=new gLineChart(CPAP_FlowRate,COLOR_Black,false,false); + l=new gLineChart(CPAP_FlowRate,false,false); //gLineOverlaySummary *los=new gLineOverlaySummary(tr("Selection AHI"),5,-4); AddCPAP(l); @@ -331,15 +331,15 @@ Daily::Daily(QWidget *parent,gGraphView * shared) // FRW->AddLayer(AddCPAP(los)); bool square=p_profile->appearance->squareWavePlots(); - gLineChart *pc=new gLineChart(CPAP_Pressure, COLOR_Pressure, square); + gLineChart *pc=new gLineChart(CPAP_Pressure, square); graphlist[schema::channel[CPAP_Pressure].code()]->AddLayer(AddCPAP(pc)); graphlist[schema::channel[CPAP_Pressure].code()]->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_Ramp, COLOR_Ramp, schema::channel[CPAP_Ramp].label(), FT_Span))); - pc->addPlot(CPAP_EPAP, COLOR_EPAP, square); - pc->addPlot(CPAP_IPAPLo, COLOR_IPAPLo, square); - pc->addPlot(CPAP_IPAP, COLOR_IPAP, square); - pc->addPlot(CPAP_IPAPHi, COLOR_IPAPHi, square); + pc->addPlot(CPAP_EPAP, square); + pc->addPlot(CPAP_IPAPLo, square); + pc->addPlot(CPAP_IPAP, square); + pc->addPlot(CPAP_IPAPHi, square); gGraph * TAP2; graphlist[STR_GRAPH_TAP] = TAP2 = new gGraph(STR_GRAPH_TAP, GraphView, QObject::tr("By Pressure"), QObject::tr("Statistics at Pressure"), default_height); @@ -349,53 +349,53 @@ Daily::Daily(QWidget *parent,gGraphView * shared) TAP2->setBlockSelect(true); if (p_profile->general->calculateRDI()) { - AHI->AddLayer(AddCPAP(new gLineChart(CPAP_RDI, COLOR_RDI, square))); + AHI->AddLayer(AddCPAP(new gLineChart(CPAP_RDI, square))); // AHI->AddLayer(AddCPAP(new AHIChart(QColor("#37a24b")))); } else { - AHI->AddLayer(AddCPAP(new gLineChart(CPAP_AHI, COLOR_AHI, square))); + AHI->AddLayer(AddCPAP(new gLineChart(CPAP_AHI, square))); } // this is class wide because the leak redline can be reset in preferences.. // Better way would be having a search for linechart layers in graphlist[...] - gLineChart *leakchart=new gLineChart(CPAP_Leak, COLOR_LeakTotal, square); + gLineChart *leakchart=new gLineChart(CPAP_Leak, square); graphlist[schema::channel[CPAP_Leak].code()]->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_LargeLeak, COLOR_LargeLeak, STR_TR_LL, FT_Span))); - leakchart->addPlot(CPAP_LeakTotal, COLOR_Leak, square); - leakchart->addPlot(CPAP_MaxLeak, COLOR_MaxLeak, square); + leakchart->addPlot(CPAP_LeakTotal, square); + leakchart->addPlot(CPAP_MaxLeak, square); schema::channel[CPAP_Leak].setUpperThresholdColor(Qt::red); schema::channel[CPAP_Leak].setLowerThresholdColor(Qt::green); graphlist[schema::channel[CPAP_Leak].code()]->AddLayer(AddCPAP(leakchart)); //LEAK->AddLayer(AddCPAP(new gLineChart(CPAP_Leak, COLOR_Leak,square))); //LEAK->AddLayer(AddCPAP(new gLineChart(CPAP_MaxLeak, COLOR_MaxLeak,square))); - graphlist[schema::channel[CPAP_Snore].code()]->AddLayer(AddCPAP(new gLineChart(CPAP_Snore, COLOR_Snore, true))); + graphlist[schema::channel[CPAP_Snore].code()]->AddLayer(AddCPAP(new gLineChart(CPAP_Snore, true))); - graphlist[schema::channel[CPAP_PTB].code()]->AddLayer(AddCPAP(new gLineChart(CPAP_PTB, COLOR_PTB, square))); - graphlist[schema::channel[CPAP_Test1].code()]->AddLayer(AddCPAP(new gLineChart(CPAP_Test1, COLOR_PTB, false))); + graphlist[schema::channel[CPAP_PTB].code()]->AddLayer(AddCPAP(new gLineChart(CPAP_PTB, square))); + graphlist[schema::channel[CPAP_Test1].code()]->AddLayer(AddCPAP(new gLineChart(CPAP_Test1, false))); gLineChart *lc = nullptr; - graphlist[schema::channel[CPAP_MaskPressure].code()]->AddLayer(AddCPAP(new gLineChart(CPAP_MaskPressure, COLOR_MaskPressure, false))); - graphlist[schema::channel[CPAP_RespRate].code()]->AddLayer(AddCPAP(lc=new gLineChart(CPAP_RespRate, COLOR_RespRate, square))); + 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[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, COLOR_MinuteVent, square))); - lc->addPlot(CPAP_TgMV,COLOR_TgMV,square); + graphlist[schema::channel[CPAP_MinuteVent].code()]->AddLayer(AddCPAP(lc=new gLineChart(CPAP_MinuteVent, square))); + lc->addPlot(CPAP_TgMV, square); - graphlist[schema::channel[CPAP_TidalVolume].code()]->AddLayer(AddCPAP(lc=new gLineChart(CPAP_TidalVolume,COLOR_TidalVolume,square))); + graphlist[schema::channel[CPAP_TidalVolume].code()]->AddLayer(AddCPAP(lc=new gLineChart(CPAP_TidalVolume, square))); //lc->addPlot(CPAP_Test2,COLOR_DarkYellow,square); - //graphlist[schema::channel[CPAP_TidalVolume].code()]->AddLayer(AddCPAP(new gLineChart("TidalVolume2",COLOR_Magenta,square))); - graphlist[schema::channel[CPAP_FLG].code()]->AddLayer(AddCPAP(new gLineChart(CPAP_FLG, COLOR_FLG, true))); - //graphlist[schema::channel[CPAP_RespiratoryEvent].code()]->AddLayer(AddCPAP(new gLineChart(CPAP_RespiratoryEvent,COLOR_Magenta,true))); - graphlist[schema::channel[CPAP_IE].code()]->AddLayer(AddCPAP(lc=new gLineChart(CPAP_IE, COLOR_IE, square))); - graphlist[schema::channel[CPAP_Te].code()]->AddLayer(AddCPAP(lc=new gLineChart(CPAP_Te, COLOR_Te, square))); - graphlist[schema::channel[CPAP_Ti].code()]->AddLayer(AddCPAP(lc=new gLineChart(CPAP_Ti, COLOR_Ti, 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))); //lc->addPlot(CPAP_Test2,COLOR:DarkYellow,square); - graphlist[schema::channel[ZEO_SleepStage].code()]->AddLayer(AddSTAGE(new gLineChart(ZEO_SleepStage, COLOR_SleepStage, true))); + graphlist[schema::channel[ZEO_SleepStage].code()]->AddLayer(AddSTAGE(new gLineChart(ZEO_SleepStage, true))); gLineOverlaySummary *los1=new gLineOverlaySummary(STR_UNIT_EventsPerHour,5,-4); gLineOverlaySummary *los2=new gLineOverlaySummary(STR_UNIT_EventsPerHour,5,-4); @@ -404,20 +404,20 @@ Daily::Daily(QWidget *parent,gGraphView * shared) graphlist[schema::channel[OXI_SPO2].code()]->AddLayer(AddOXI(los2->add(new gLineOverlayBar(OXI_SPO2Drop, COLOR_SPO2Drop, STR_TR_O2,FT_Span)))); graphlist[schema::channel[OXI_SPO2].code()]->AddLayer(AddOXI(los2)); - graphlist[schema::channel[OXI_Pulse].code()]->AddLayer(AddOXI(new gLineChart(OXI_Pulse, COLOR_Pulse, square))); - graphlist[schema::channel[OXI_SPO2].code()]->AddLayer(AddOXI(new gLineChart(OXI_SPO2, COLOR_SPO2, true))); - graphlist[schema::channel[OXI_Plethy].code()]->AddLayer(AddOXI(new gLineChart(OXI_Plethy, COLOR_Plethy,false))); + graphlist[schema::channel[OXI_Pulse].code()]->AddLayer(AddOXI(new gLineChart(OXI_Pulse, square))); + graphlist[schema::channel[OXI_SPO2].code()]->AddLayer(AddOXI(new gLineChart(OXI_SPO2, true))); + graphlist[schema::channel[OXI_Plethy].code()]->AddLayer(AddOXI(new gLineChart(OXI_Plethy, false))); // Fix me 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, COLOR_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, COLOR_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);