Stop Event Flags dissappearing on zero days, Event Flags and Flow overlay checks and optimisations

This commit is contained in:
Mark Watkins 2012-01-10 12:34:44 +10:00
parent 21d9d7e32b
commit 194dc3d579
2 changed files with 206 additions and 162 deletions

View File

@ -55,6 +55,11 @@ void gFlagsGroup::SetDay(Day * d)
} }
} }
m_empty=(cnt==0); m_empty=(cnt==0);
if (m_empty) {
if (d) {
m_empty=!d->channelExists(CPAP_Pressure);
}
}
m_barh=0; m_barh=0;
} }
@ -142,87 +147,96 @@ void gFlagsLine::paint(gGraph & w,int left, int top, int width, int height)
qint64 start; qint64 start;
quint32 * tptr; quint32 * tptr;
EventStoreType *dptr; EventStoreType *dptr, * eptr;
int idx; int idx;
QHash<ChannelID,QVector<EventList *> >::iterator cei;
for (QVector<Session *>::iterator s=m_day->begin();s!=m_day->end(); s++) { for (QVector<Session *>::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]); QVector<EventList *> & evlist=cei.value();
start=el.first(); for (int k=0;k<evlist.size();k++) {
tptr=el.rawTime(); EventList & el=*(evlist[k]);
dptr=el.rawData(); start=el.first();
int np=el.count(); tptr=el.rawTime();
dptr=el.rawData();
int np=el.count();
eptr=dptr+np;
for (idx=0; idx < np; idx++) { for (idx=0;dptr < eptr; dptr++, tptr++, idx++) {
X=start + *tptr; X=start + *tptr;
L=*dptr * 1000; L=*dptr * 1000;
if (X >= minx) if (X >= 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<np;i++) {
X=start + * tptr++; //el.time(i);
if (X > maxx)
break; 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; X2=X-L;
if (X2 >= minx)
x1=double(X - minx) * xmult + left; break;
x2=double(X2 - minx) * xmult + left;
quads->add(x2,bartop,x1,bartop, x1,bottom,x2,bottom);
//if (quads->full()) { verts_exceeded=true; 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<np;i++) {
X=start + *tptr++;
if (X > 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; if (verts_exceeded) break;
} }

View File

@ -50,7 +50,6 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh
double Y; double Y;
bool verts_exceeded=false; bool verts_exceeded=false;
QHash<ChannelID,QVector<EventList *> >::iterator cei;
m_count=0; m_count=0;
m_sum=0; m_sum=0;
@ -64,108 +63,139 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh
EventStoreType raw; EventStoreType raw;
quint32 * tptr; quint32 * tptr;
EventStoreType * ptr; EventStoreType * dptr, *eptr;
qint64 stime; qint64 stime;
OverlayDisplayType odt=PROFILE.appearance->overlayType(); OverlayDisplayType odt=PROFILE.appearance->overlayType();
QHash<ChannelID,QVector<EventList *> >::iterator cei;
int count;
// For each session, process it's eventlist // For each session, process it's eventlist
for (QVector<Session *>::iterator s=m_day->begin();s!=m_day->end(); s++) { for (QVector<Session *>::iterator s=m_day->begin();s!=m_day->end(); s++) {
if (!(*s)->enabled()) continue; if (!(*s)->enabled()) continue;
cei=(*s)->eventlist.find(m_code); cei=(*s)->eventlist.find(m_code);
if (cei==(*s)->eventlist.end()) continue; if (cei==(*s)->eventlist.end()) continue;
if (cei.value().size()==0) continue; QVector<EventList *> & evlist=cei.value();
if (evlist.size()==0) continue;
// Could loop through here, but nowhere uses more than one yet.. // Could loop through here, but nowhere uses more than one yet..
EventList & el=*cei.value()[0]; for (int k=0;k<evlist.size();k++) {
stime=el.first(); EventList & el=*(evlist[k]);
ptr=el.rawData(); count=el.count();
tptr=el.rawTime(); stime=el.first();
dptr=el.rawData();
eptr=dptr+count;
tptr=el.rawTime();
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Skip data previous to minx bounds // Skip data previous to minx bounds
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
quint32 idx; quint32 idx;
for (idx=0;idx<el.count();idx++) { for (; dptr < eptr; dptr++) {
X=stime + *tptr; X=stime + *tptr;
if (X >= w.min_x) 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 (x2<left)
x2=left;
if (x1>width+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; break;
tptr++;
ptr++;
} }
if (verts_exceeded)
if (m_flt==FT_Span) { break;
////////////////////////////////////////////////////////////////////////////
// FT_Span
////////////////////////////////////////////////////////////////////////////
for (quint32 i=idx;i<el.count();i++) {
X=stime + *tptr++; //el.time(i);
raw=*ptr++; //el.data(i);
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 (x2<left) x2=left;
if (x1>width+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<el.count();i++) {
X=stime + *tptr++; //el.time(i);
raw=*ptr++; //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 (quint32 i=idx;i<el.count();i++) {
X=stime + *tptr++;
raw=*ptr++;
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;
} }
if (verts_exceeded) { if (verts_exceeded) {
qWarning() << "exceeded maxverts in gLineOverlay::Plot()"; qWarning() << "exceeded maxverts in gLineOverlay::Plot()";