diff --git a/Graphs/gFlagsLine.cpp b/Graphs/gFlagsLine.cpp index adaa71a8..4827f310 100644 --- a/Graphs/gFlagsLine.cpp +++ b/Graphs/gFlagsLine.cpp @@ -55,6 +55,11 @@ void gFlagsGroup::SetDay(Day * d) } } m_empty=(cnt==0); + if (m_empty) { + if (d) { + m_empty=!d->channelExists(CPAP_Pressure); + } + } m_barh=0; } @@ -142,87 +147,96 @@ void gFlagsLine::paint(gGraph & w,int left, int top, int width, int height) qint64 start; quint32 * tptr; - EventStoreType *dptr; + EventStoreType *dptr, * eptr; int idx; + QHash >::iterator cei; + for (QVector::iterator s=m_day->begin();s!=m_day->end(); s++) { - if (!(*s)->enabled()) continue; + if (!(*s)->enabled()) + continue; - if ((*s)->eventlist.find(m_code)==(*s)->eventlist.end()) continue; + cei=(*s)->eventlist.find(m_code); + if (cei==(*s)->eventlist.end()) + continue; - EventList & el=*((*s)->eventlist[m_code][0]); - start=el.first(); - tptr=el.rawTime(); - dptr=el.rawData(); - int np=el.count(); + QVector & evlist=cei.value(); + for (int k=0;k= minx) - break; - X2=X-L; - if (X2 >= minx) - break; - dptr++; - tptr++; - } - np-=idx; - - if (m_flt==FT_Bar) { - /////////////////////////////////////////////////////////////////////////// - // Draw Event Flag Bars - /////////////////////////////////////////////////////////////////////////// - - // Check bounds outside of loop is faster.. - // This will have to be reverted if multithreaded drawing is ever brought back - - int rem=lines->Max() - lines->cnt(); - if ((np<<1) > rem) { - qDebug() << "gFlagsLine would overfill lines for" << schema::channel[m_code].label(); - np=rem >> 1; - verts_exceeded=true; - } - - for (int i=0;i maxx) + for (idx=0;dptr < eptr; dptr++, tptr++, idx++) { + X=start + *tptr; + L=*dptr * 1000; + if (X >= minx) break; - - x1=(X - minx) * xmult + left; - lines->add(x1,bartop,x1,bottom); - - //if (lines->full()) { verts_exceeded=true; break; } - } - } else if (m_flt==FT_Span) { - /////////////////////////////////////////////////////////////////////////// - // Draw Event Flag Spans - /////////////////////////////////////////////////////////////////////////// - quads->setColor(m_flag_color); - int rem=quads->Max() - quads->cnt(); - - if ((np<<2) > rem) { - qDebug() << "gFlagsLine would overfill quads for" << schema::channel[m_code].label(); - np=rem >> 2; - verts_exceeded=true; - } - - for (int i=0;i < np; i++) { - X=start + * tptr++; - - if (X > maxx) - break; - - L=*dptr++ * 1000L; X2=X-L; - - x1=double(X - minx) * xmult + left; - x2=double(X2 - minx) * xmult + left; - - quads->add(x2,bartop,x1,bartop, x1,bottom,x2,bottom); - //if (quads->full()) { verts_exceeded=true; break; } + if (X2 >= minx) + break; } + np-=idx; + + if (m_flt==FT_Bar) { + /////////////////////////////////////////////////////////////////////////// + // Draw Event Flag Bars + /////////////////////////////////////////////////////////////////////////// + + // Check bounds outside of loop is faster.. + // This will have to be reverted if multithreaded drawing is ever brought back + + int rem=lines->Max() - lines->cnt(); + if ((np<<1) > rem) { + qDebug() << "gFlagsLine would overfill lines for" << schema::channel[m_code].label(); + np=rem >> 1; + verts_exceeded=true; + } + + for (int i=0;i maxx) + break; + + x1=(X - minx) * xmult + left; + lines->add(x1,bartop,x1,bottom); + + //if (lines->full()) { verts_exceeded=true; break; } + } + } else if (m_flt==FT_Span) { + /////////////////////////////////////////////////////////////////////////// + // Draw Event Flag Spans + /////////////////////////////////////////////////////////////////////////// + quads->setColor(m_flag_color); + int rem=quads->Max() - quads->cnt(); + + if ((np<<2) > rem) { + qDebug() << "gFlagsLine would overfill quads for" << schema::channel[m_code].label(); + np=rem >> 2; + verts_exceeded=true; + } + + for (; dptr < eptr; dptr++) { + X=start + * tptr++; + + if (X > maxx) + break; + + L=*dptr * 1000L; + X2=X-L; + + x1=double(X - minx) * xmult + left; + x2=double(X2 - minx) * xmult + left; + + quads->add(x2,bartop,x1,bartop, x1,bottom,x2,bottom); + //if (quads->full()) { verts_exceeded=true; break; } + + } + } + if (verts_exceeded) break; } if (verts_exceeded) break; } diff --git a/Graphs/gLineOverlay.cpp b/Graphs/gLineOverlay.cpp index 800bc1b7..892e2bbe 100644 --- a/Graphs/gLineOverlay.cpp +++ b/Graphs/gLineOverlay.cpp @@ -50,7 +50,6 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh double Y; bool verts_exceeded=false; - QHash >::iterator cei; m_count=0; m_sum=0; @@ -64,108 +63,139 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh EventStoreType raw; quint32 * tptr; - EventStoreType * ptr; + EventStoreType * dptr, *eptr; qint64 stime; OverlayDisplayType odt=PROFILE.appearance->overlayType(); - + QHash >::iterator cei; + int count; // For each session, process it's eventlist for (QVector::iterator s=m_day->begin();s!=m_day->end(); s++) { + if (!(*s)->enabled()) continue; cei=(*s)->eventlist.find(m_code); if (cei==(*s)->eventlist.end()) continue; - if (cei.value().size()==0) continue; + QVector & evlist=cei.value(); + if (evlist.size()==0) continue; // Could loop through here, but nowhere uses more than one yet.. - EventList & el=*cei.value()[0]; - stime=el.first(); - ptr=el.rawData(); - tptr=el.rawTime(); + for (int k=0;k= w.min_x) + //////////////////////////////////////////////////////////////////////////// + // Skip data previous to minx bounds + //////////////////////////////////////////////////////////////////////////// + quint32 idx; + for (; dptr < eptr; dptr++) { + X=stime + *tptr; + if (X >= w.min_x) + break; + tptr++; + } + + if (m_flt==FT_Span) { + //////////////////////////////////////////////////////////////////////////// + // FT_Span + //////////////////////////////////////////////////////////////////////////// + for (;dptr < eptr; dptr++) { + X=stime + *tptr++; + raw=*dptr; + Y=X-(qint64(raw)*1000.0L); // duration + if (Y > w.max_x) + break; + x1=double(width)/double(xx)*double(X-w.min_x)+left; + m_count++; + m_sum+=raw; + x2=double(width)/double(xx)*double(Y-w.min_x)+left; + + if (int(x1)==int(x2)) + x2+=1; + if (x2width+left) + x1=width+left; + + quads->add(x2,start_py, x1,start_py, x1,start_py+height, x2,start_py+height,m_flag_color.rgba()); + if (quads->full()) { + verts_exceeded=true; + break; + } + } + } else if (m_flt==FT_Dot) { + //////////////////////////////////////////////////////////////////////////// + // FT_Dot + //////////////////////////////////////////////////////////////////////////// + for (; dptr < eptr; dptr++) { + X=stime + *tptr++; //el.time(i); + raw=*dptr; //el.data(i); + if (X > w.max_x) + break; + x1=double(width)/double(xx)*double(X-w.min_x)+left; + m_count++; + m_sum+=raw; + if ((odt==ODT_Bars) || (xx<3600000)) { + // show the fat dots in the middle + points->add(x1,double(height)/double(yy)*double(-20-w.min_y)+topp); + if (points->full()) { + verts_exceeded=true; + break; + } + } else { + // thin lines down the bottom + lines->add(x1,start_py+1,x1,start_py+1+12); + if (lines->full()) { + verts_exceeded=true; + break; + } + } + + } + } else if (m_flt==FT_Bar) { + //////////////////////////////////////////////////////////////////////////// + // FT_Bar + //////////////////////////////////////////////////////////////////////////// + for (; dptr < eptr; dptr++) { + X=stime + *tptr++; + raw=*dptr; + if (X > w.max_x) + break; + x1=double(width)/double(xx)*double(X-w.min_x)+left; + m_count++; + m_sum+=raw; + int z=start_py+height; + if ((odt==ODT_Bars) || (xx<3600000)) { + z=top; + + points->add(x1,top); + lines->add(x1,top,x1,bottom); + if (points->full()) { + verts_exceeded=true; + break; + } + } else { + lines->add(x1,z,x1,z-12); + } + if (lines->full()) { + verts_exceeded=true; + break; + } + if (xx<(1800000)) { + GetTextExtent(m_label,x,y); + w.renderText(m_label,x1-(x/2),top-y+(3*w.printScaleY())); + } + } + } + + if (verts_exceeded) break; - tptr++; - ptr++; } - - if (m_flt==FT_Span) { - //////////////////////////////////////////////////////////////////////////// - // FT_Span - //////////////////////////////////////////////////////////////////////////// - for (quint32 i=idx;i w.max_x) break; - x1=double(width)/double(xx)*double(X-w.min_x)+left; - m_count++; - m_sum+=raw; - x2=double(width)/double(xx)*double(Y-w.min_x)+left; - if (int(x1)==int(x2)) x2+=1; - if (x2width+left) x1=width+left; - //double w1=x2-x1; - quads->add(x2,start_py, x1,start_py, x1,start_py+height, x2,start_py+height,m_flag_color.rgba()); - if (quads->full()) { verts_exceeded=true; break; } - } - } else if (m_flt==FT_Dot) { - //////////////////////////////////////////////////////////////////////////// - // FT_Dot - //////////////////////////////////////////////////////////////////////////// - for (quint32 i=idx;i w.max_x) break; - x1=double(width)/double(xx)*double(X-w.min_x)+left; - m_count++; - m_sum+=raw; - if ((odt==ODT_Bars) || (xx<3600000)) { - // show the fat dots in the middle - points->add(x1,double(height)/double(yy)*double(-20-w.min_y)+topp); - if (points->full()) { verts_exceeded=true; break; } - } else { - // thin lines down the bottom - lines->add(x1,start_py+1,x1,start_py+1+12); - if (lines->full()) { verts_exceeded=true; break; } - } - - } - } else if (m_flt==FT_Bar) { - //////////////////////////////////////////////////////////////////////////// - // FT_Bar - //////////////////////////////////////////////////////////////////////////// - for (quint32 i=idx;i w.max_x) break; - x1=double(width)/double(xx)*double(X-w.min_x)+left; - m_count++; - m_sum+=raw; - int z=start_py+height; - if ((odt==ODT_Bars) || (xx<3600000)) { - z=top; - - points->add(x1,top); - lines->add(x1,top,x1,bottom); - if (points->full()) { verts_exceeded=true; break; } - } else { - lines->add(x1,z,x1,z-12); - } - if (lines->full()) { verts_exceeded=true; break; } - if (xx<(1800000)) { - GetTextExtent(m_label,x,y); - w.renderText(m_label,x1-(x/2),top-y+(3*w.printScaleY())); - } - } - } - - if (verts_exceeded) break; + if (verts_exceeded) + break; } if (verts_exceeded) { qWarning() << "exceeded maxverts in gLineOverlay::Plot()";