Fixed PB/CSR Waveform Overlay

This commit is contained in:
Mark Watkins 2011-08-26 01:58:52 +10:00
parent 529acbe16e
commit 2cbe6f49c2
6 changed files with 30 additions and 40 deletions

View File

@ -62,8 +62,8 @@ void gFlagsGroup::paint(gGraph &w, int left, int top, int width, int height)
//if (evil_intel_graphics_card) qo=1;
// Draw the bars with filled quads
w.qglColor(*barcol);
glBegin(GL_QUADS);
w.qglColor(*barcol);
glVertex2f(left, linetop);
glVertex2f(left, linetop+barh);
glVertex2f(left+width-1, linetop+barh);
@ -76,9 +76,9 @@ void gFlagsGroup::paint(gGraph &w, int left, int top, int width, int height)
}
// Draw the outer rectangle outline
glColor3f (0.0F, 0.0F, 0.0F);
glLineWidth(1);
glBegin(GL_LINE_LOOP);
w.qglColor(Qt::black);
glVertex2f(left-1, top);
glVertex2f(left-1, top+height);
glVertex2f(left+width, top+height);
@ -128,7 +128,7 @@ void gFlagsLine::paint(gGraph & w,int left, int top, int width, int height)
// Draw text label
float x,y;
GetTextExtent(m_label,x,y);
w.qglColor(Qt::black);
//w.qglColor(Qt::black);
//w.renderText(start_px-x-10,(scry-line_top)-(line_h/2)+(y/2),m_label);
//DrawText(w,m_label);
w.renderText(m_label,left-x-10,top+(height/2)+(y/2));

View File

@ -31,10 +31,10 @@ void gShadowArea::paint(gGraph & w,int left, int top, int width, int height)
double px=((1/rmx)*(w.min_x-w.rmin_x))*width;
double py=((1/rmx)*(w.max_x-w.rmin_x))*width;
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glBegin(GL_QUADS);
glEnable(GL_BLEND);
w.qglColor(m_shadow_color);
glVertex2f(start_px, top);
@ -46,8 +46,10 @@ void gShadowArea::paint(gGraph & w,int left, int top, int width, int height)
glVertex2f(start_px+py, top+height);
glVertex2f(end_px, top+height);
glVertex2f(end_px, top);
glEnd();
glDisable(GL_BLEND);
glEnd();
//glFlush();
}
gFooBar::gFooBar(int offset,QColor handle_color,QColor line_color)

View File

@ -238,6 +238,8 @@ void gGraph::renderText(QString text, int x,int y, float angle, QColor color, QF
painter->translate(-x,-y);
}
painter->beginNativePainting();
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_BUFFER);
}
@ -307,17 +309,17 @@ void gGraph::paint(int originX, int originY, int width, int height)
}
if (m_selection.width()>0 && m_selecting_area) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBegin(GL_QUADS);
glEnable(GL_BLEND);
glColor4ub(128,128,128,128);
glVertex2i(originX+m_selection.x(),originY+top);
glVertex2i(originX+m_selection.x()+m_selection.width(),originY+top);
glColor4ub(128,128,255,128);
glVertex2i(originX+m_selection.x()+m_selection.width(),originY+height-top-bottom);
glVertex2i(originX+m_selection.x(),originY+height-top-bottom);
glEnd();
glDisable(GL_BLEND);
glEnd();
}
}

View File

@ -57,6 +57,7 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh
bool verts_exceeded=false;
QHash<ChannelID,QVector<EventList *> >::iterator cei;
for (QVector<Session *>::iterator s=m_day->begin();s!=m_day->end(); s++) {
cei=(*s)->eventlist.find(m_code);
if (cei==(*s)->eventlist.end()) continue;
@ -80,16 +81,19 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh
x1=double(width)/double(xx)*double(X-w.min_x)+left;
if (m_flt==FT_Span) {
//x2=w.x2p(Y);
x2=double(width)/double(xx)*double(X-w.min_x)+left;
x2=double(width)/double(xx)*double(Y-w.min_x)+left;
if (x2<left) x2=left;
if (x1>width+left) x1=width+left;
//double w1=x2-x1;
quadarray[quadcnt++]=x1;
quadarray[quadcnt++]=start_py;
quadarray[quadcnt++]=x1;
quadarray[quadcnt++]=start_py+height;
quadarray[quadcnt++]=x2;
quadarray[quadcnt++]=start_py+height;
quadarray[quadcnt++]=x2;
quadarray[quadcnt++]=start_py;
quadarray[quadcnt++]=x2;
quadarray[quadcnt++]=start_py+height;
quadarray[quadcnt++]=x1;
quadarray[quadcnt++]=start_py+height;
qDebug()<< x1 << x2 << start_py << height;
if (quadcnt>=maxverts) { verts_exceeded=true; break; }
} else if (m_flt==FT_Dot) {
//if (pref["AlwaysShowOverlayBars"].toBool()) {
@ -143,6 +147,7 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh
}
bool antialias=pref["UseAntiAliasing"].toBool();
glEnableClientState(GL_VERTEX_ARRAY);
if (antialias) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //_MINUS_SRC_ALPHA);
@ -151,7 +156,6 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh
glLineWidth (1.5);
} else glLineWidth (1);
glEnableClientState(GL_VERTEX_ARRAY);
w.qglColor(m_flag_color);
if (quadcnt>0) {
glVertexPointer(2, GL_SHORT, 0, quadarray);
@ -166,12 +170,12 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh
glVertexPointer(2, GL_SHORT, 0, pointarray);
glDrawArrays(GL_POINTS, 0, pointcnt>>1);
}
glDisableClientState(GL_VERTEX_ARRAY);
if (antialias) {
glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
}
glDisableClientState(GL_VERTEX_ARRAY);
//glDisable(GL_SCISSOR_TEST);
}

View File

@ -302,12 +302,6 @@ void gYAxis::paint(gGraph & w,int left,int top, int width, int height)
vertarray[vertcnt++]=left+width;
vertarray[vertcnt++]=h;
/*if (m_show_major_lines && (i > miny)) {
majorvertarray[majorvertcnt++]=start_px;
majorvertarray[majorvertcnt++]=h;
majorvertarray[majorvertcnt++]=start_px+width;
majorvertarray[majorvertcnt++]=h;
} */
double z=(min_ytick/4)*ymult;
double g=h;
for (int i=0;i<3;i++) {
@ -321,12 +315,6 @@ void gYAxis::paint(gGraph & w,int left,int top, int width, int height)
qWarning() << "vertarray bounds exceeded in gYAxis for " << w.title() << "graph" << "MinY =" <<miny << "MaxY =" << maxy << "min_ytick=" <<min_ytick;
break;
}
/*if (m_show_minor_lines) {// && (i > miny)) {
minorvertarray[minorvertcnt++]=start_px;
minorvertarray[minorvertcnt++]=g;
minorvertarray[minorvertcnt++]=start_px+width;
minorvertarray[minorvertcnt++]=g;
} */
}
if (vertcnt>=maxverts) {
qWarning() << "vertarray bounds exceeded in gYAxis for " << w.title() << "graph" << "MinY =" <<miny << "MaxY =" << maxy << "min_ytick=" <<min_ytick;
@ -343,16 +331,10 @@ void gYAxis::paint(gGraph & w,int left,int top, int width, int height)
// Draw the lines & ticks
// Turn on blending??
glLineWidth(1);
w.qglColor(m_line_color);
glEnableClientState(GL_VERTEX_ARRAY);
w.qglColor(m_line_color);
glVertexPointer(2, GL_SHORT, 0, vertarray);
glDrawArrays(GL_LINES, 0, vertcnt>>1);
/*w.qglColor(m_minor_color);
glVertexPointer(2, GL_SHORT, 0, minorvertarray);
glDrawArrays(GL_LINES, 0, minorvertcnt>>1);
w.qglColor(m_major_color);
glVertexPointer(2, GL_SHORT, 0, majorvertarray);
glDrawArrays(GL_LINES, 0, majorvertcnt>>1); */
glDisableClientState(GL_VERTEX_ARRAY); // deactivate vertex arrays after drawing
}

View File

@ -104,11 +104,11 @@ Daily::Daily(QWidget *parent,QGLWidget * shared, MainWindow *mw)
gLineChart *l;
l=new gLineChart(CPAP_FlowRate,Qt::black,false,false);
AddCPAP(l);
FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_CSR,QColor("light green"),"CSR",FT_Span)));
FRW->AddLayer(new gXGrid());
FRW->AddLayer(l);
FRW->AddLayer(new gYAxis(),LayerLeft,gYAxis::Margin);
FRW->AddLayer(new gXAxis(),LayerBottom,0,20);
FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_CSR,QColor("light green"),"CSR",FT_Span)));
FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_Hypopnea,QColor("blue"),"H")));
FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_PressurePulse,QColor("red"),"PR",FT_Dot)));
//FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_Pressure,QColor("white"),"P",FT_Dot)));