Event Flags tooltips over labels

This commit is contained in:
Mark Watkins 2011-12-05 20:50:58 +10:00
parent e340809ca8
commit f77847b6a1
6 changed files with 69 additions and 21 deletions

View File

@ -18,6 +18,7 @@ gFlagsGroup::gFlagsGroup()
addGLBuf(lines=new GLShortBuffer(20,GL_LINE_LOOP));
quads->setAntiAlias(true);
lines->setAntiAlias(false);
m_barh=0;
}
gFlagsGroup::~gFlagsGroup()
{
@ -48,7 +49,7 @@ void gFlagsGroup::SetDay(Day * d)
lvisible.push_back(f);
}
}
m_barh=0;
}
void gFlagsGroup::paint(gGraph &w, int left, int top, int width, int height)
@ -57,7 +58,7 @@ void gFlagsGroup::paint(gGraph &w, int left, int top, int width, int height)
if (!m_day) return;
int vis=lvisible.size();
float barh=float(height)/float(vis);
m_barh=float(height)/float(vis);
float linetop=top;
static QColor col1=QColor(0xd0,0xff,0xd0,0xff);
@ -66,19 +67,17 @@ void gFlagsGroup::paint(gGraph &w, int left, int top, int width, int height)
for (int i=0;i<lvisible.size();i++) {
// Alternating box color
if (i & 1) barcol=&col1; else barcol=&col2;
quads->add(left,linetop,left,linetop+barh,left+width-1,linetop+barh,left+width-1,linetop,*barcol);
quads->add(left,linetop,left,linetop+m_barh,left+width-1,linetop+m_barh,left+width-1,linetop,*barcol);
// Paint the actual flags
lvisible[i]->paint(w,left,linetop,width,barh);
linetop+=barh;
lvisible[i]->paint(w,left,linetop,width,m_barh);
linetop+=m_barh;
}
GLShortBuffer *outlines=w.lines();
QColor blk=Qt::black;
outlines->add(left-1, top, left-1, top+height, blk);
outlines->add(left-1, top+height, left+width,top+height, blk);
outlines->add(left+width,top+height, left+width, top, blk);
outlines->add(left+width, top, left-1, top, blk);
outlines->add(left-1, top, left-1, top+height,left-1, top+height, left+width,top+height, blk);
outlines->add(left+width,top+height, left+width, top, left+width, top, left-1, top, blk);
//lines->add(left-1, top, left-1, top+height);
//lines->add(left+width, top+height, left+width, top);

View File

@ -45,9 +45,14 @@ public:
virtual qint64 Minx();
virtual qint64 Maxx();
virtual void SetDay(Day *);
int count() { return lvisible.size(); }
int barHeight() { return m_barh; }
QVector<gFlagsLine *> & visibleLayers() { return lvisible; }
protected:
GLShortBuffer *quads, *lines;
QVector<gFlagsLine *> lvisible;
float m_barh;
};
#endif // GFLAGSLINE_H

View File

@ -14,6 +14,7 @@
#include "mainwindow.h"
#include "Graphs/gYAxis.h"
#include "Graphs/gFlagsLine.h"
extern MainWindow *mainwin;
@ -1319,9 +1320,13 @@ void gGraph::mouseReleaseEvent(QMouseEvent * event)
qint64 a1=MIN(j1,j2)
qint64 a2=MAX(j1,j2)
//if (a1<rmin_x) a1=rmin_x;
if (a2-a1<zoom_hard_limit) a2=a1+zoom_hard_limit;
if (a2>rmax_x) a2=rmax_x;
if (a1<=rmin_x && a2<=rmin_x) {
//qDebug() << "Foo??";
} else {
if (a2-a1<zoom_hard_limit) a2=a1+zoom_hard_limit;
m_graphview->SetXBounds(a1,a2,m_group);
}
} else {
xx=rmax_x-rmin_x;
xmult=xx/double(w);
@ -1329,11 +1334,16 @@ void gGraph::mouseReleaseEvent(QMouseEvent * event)
qint64 j2=rmin_x+xmult*x2;
qint64 a1=MIN(j1,j2)
qint64 a2=MAX(j1,j2)
if (a2-a1<zoom_hard_limit) a2=a1+zoom_hard_limit;
//if (a1<rmin_x) a1=rmin_x;
if (a2>rmax_x) a2=rmax_x;
if (a1<=rmin_x && a2<=rmin_x) {
qDebug() << "Foo2??";
} else {
if (a2-a1<zoom_hard_limit) a2=a1+zoom_hard_limit;
m_graphview->SetXBounds(a1,a2,m_group);
}
}
return;
} else m_graphview->updateGL();
@ -2287,7 +2297,7 @@ void gGraphView::mouseMoveEvent(QMouseEvent * event)
if (m_button_down || ((py + h + graphSpacer) >= 0)) {
if (m_button_down || ((y >= py) && (y < py + h))) {
if (m_button_down || (x >= titleWidth+(gYAxis::Margin-20))) {
if (m_button_down || (x >= titleWidth+(gYAxis::Margin-5))) {
this->setCursor(Qt::ArrowCursor);
m_horiz_travel+=qAbs(x-m_lastxpos)+qAbs(y-m_lastypos);
m_lastxpos=x;
@ -2298,10 +2308,36 @@ void gGraphView::mouseMoveEvent(QMouseEvent * event)
m_graphs[i]->mouseMoveEvent(&e);
} else {
//qDebug() << "Hovering over" << m_graphs[i]->title();
if (m_graphsbytitle["Event Flags"]==m_graphs[i]) {
QVector<Layer *> & layers=m_graphs[i]->layers();
gFlagsGroup *fg;
for (int i=0;i<layers.size();i++) {
if ((fg=dynamic_cast<gFlagsGroup *>(layers[i]))!=NULL) {
float bh=fg->barHeight();
int count=fg->count();
float yp=py+m_graphs[i]->marginTop();
yp=y-yp;
float th=(float(count)*bh);
if (yp>=0 && yp<th) {
int i=yp/bh;
if (i<count) {
ChannelID code=fg->visibleLayers()[i]->code();
QString ttip=schema::channel[code].description();
m_tooltip->display(ttip,x,y-20,800);
updateGL();
//qDebug() << code << ttip;
}
}
break;
}
}
} else {
if (!m_graphs[i]->units().isEmpty()) {
m_tooltip->display(m_graphs[i]->units(),x,y-20,800);
updateGL();
}
}
this->setCursor(Qt::OpenHandCursor);
}

View File

@ -215,6 +215,7 @@ public:
virtual bool isEmpty();
virtual void SetDay(Day * d);
virtual void drawGLBuf();
QVector<Layer *> & getLayers() { return layers; }
protected:
QVector<Layer *> layers;
@ -358,6 +359,7 @@ public:
QRect m_lastbounds;
QTimer * timer;
QVector<Layer *> & layers() { return m_layers; }
protected:
//void invalidate();
@ -377,7 +379,6 @@ protected:
QVector<Layer *> m_layers;
float m_height,m_width;
int m_min_height;
int m_max_height;
bool m_visible;

View File

@ -131,7 +131,7 @@ Daily::Daily(QWidget *parent,gGraphView * shared, MainWindow *mw)
gFlagsGroup *fg=new gFlagsGroup();
SF->AddLayer(AddCPAP(fg));
fg->AddLayer((new gFlagsLine(CPAP_CSR,QColor("light green"),"CSR",false,FT_Span)));
fg->AddLayer((new gFlagsLine(CPAP_CSR,QColor("light green"),"PB",false,FT_Span)));
fg->AddLayer((new gFlagsLine(CPAP_ClearAirway,QColor("purple"),"CA",false)));
fg->AddLayer((new gFlagsLine(CPAP_Obstructive,QColor("#40c0ff"),"OA",true)));
fg->AddLayer((new gFlagsLine(CPAP_Apnea,QColor("dark green"),"A")));

View File

@ -174,9 +174,13 @@ void SerialOximeter::addPulse(qint64 time, EventDataType pr)
//EventDataType min=0,max=0;
if (pr>0) {
if (lastpr==0) {
if (pulse->count()==0)
if (pulse->count()==0) {
pulse->setFirst(time);
else {
if (session->eventlist[OXI_Pulse].size()==1) {
session->setFirst(OXI_Pulse,time);
}
} else {
qDebug() << "Shouldn't happen in addPulse()";
}
}
@ -204,9 +208,12 @@ void SerialOximeter::addSpO2(qint64 time, EventDataType o2)
//EventDataType min=0,max=0;
if (o2>0) {
if (lasto2==0) {
if (spo2->count()==0)
if (spo2->count()==0) {
spo2->setFirst(time);
else {
if (session->eventlist[OXI_SPO2].size()==1) {
session->setFirst(OXI_SPO2,time);
}
} else {
qDebug() << "Shouldn't happen in addSpO2()";
}
}