mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 02:30:44 +00:00
Added current pressure settings to alt-key graph hover
This commit is contained in:
parent
86eed559ad
commit
cd87d10736
@ -165,6 +165,7 @@ bool gLineChart::mouseMoveEvent(QMouseEvent *event, gGraph *graph)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Time Domain Line Chart
|
||||
void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
{
|
||||
@ -238,15 +239,30 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
QPoint mouse = w.graphView()->currentMousePos();
|
||||
double pos = mouse.x() - left;
|
||||
if (pos > 0) {
|
||||
double xval = minx + (pos * (xx / double(width)));
|
||||
qint64 xpos = minx + (pos * (xx / double(width)));
|
||||
|
||||
EventDataType val = 0, val2 = 0, val3 = 0;
|
||||
QString pressure;
|
||||
if (m_day) {
|
||||
CPAPMode mode = (CPAPMode)round(m_day->settings_wavg(CPAP_Mode));
|
||||
if (mode >= MODE_BIPAP) {
|
||||
val = m_day->lookupValue(CPAP_EPAP, xpos);
|
||||
val2 = m_day->lookupValue(CPAP_IPAP, xpos);
|
||||
val3 = val2 - val;
|
||||
pressure=QString("%1: %2%3 %4:%5%3 %6:%7%3").arg(STR_TR_EPAP).arg(val,0,'f',1).arg(STR_UNIT_CMH2O).arg(STR_TR_IPAP).arg(val2,0,'f',1).arg(STR_TR_PS).arg(val3,0,'f',1);
|
||||
|
||||
} else {
|
||||
val = m_day->lookupValue(CPAP_Pressure, xpos);
|
||||
pressure=QString("%1: %2%3").arg(STR_TR_Pressure).arg(val).arg(STR_UNIT_CMH2O);
|
||||
}
|
||||
}
|
||||
|
||||
painter.setPen(QPen(QBrush(QColor(Qt::gray)),1));
|
||||
painter.drawLine(mouse.x(), top-w.marginTop()-3, mouse.x(), top+height+w.bottom-1);
|
||||
|
||||
QDateTime dt=QDateTime::fromMSecsSinceEpoch(xval);
|
||||
QDateTime dt=QDateTime::fromMSecsSinceEpoch(xpos);
|
||||
|
||||
QString text = dt.toString("MMM dd - HH:mm:ss:zzz");
|
||||
QString text = dt.toString("MMM dd - HH:mm:ss:zzz")+" "+pressure;
|
||||
|
||||
int wid, h;
|
||||
GetTextExtent(text, wid, h);
|
||||
|
@ -241,18 +241,19 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
painter.drawLine(x1, z, x1, z - 12);
|
||||
}
|
||||
|
||||
QColor txcol = hover ? Qt::red: Qt::black;
|
||||
if (xx < 300000) {
|
||||
QString lab = schema::channel[m_code].fullname();
|
||||
QString lab = QString("%1 (%2)").arg(schema::channel[m_code].fullname()).arg(raw);
|
||||
GetTextExtent(lab, x, y);
|
||||
w.renderText(lab, x1 - (x / 2)+2, top - y + (3 * w.printScaleY()));
|
||||
w.renderText(lab, x1 - (x / 2)+2, top - y + (3 * w.printScaleY()),0,txcol);
|
||||
} else if (xx < (3600000)) {
|
||||
if (!hover) {
|
||||
GetTextExtent(m_label, x, y);
|
||||
w.renderText(m_label, x1 - (x / 2)+2, top - y + (3 * w.printScaleY()));
|
||||
w.renderText(m_label, x1 - (x / 2)+2, top - y + (3 * w.printScaleY()),0,txcol);
|
||||
} else {
|
||||
QString lab = QString("%1 (%2)").arg(m_label).arg(raw);
|
||||
GetTextExtent(lab, x, y);
|
||||
w.renderText(lab, x1 - (x / 2)+2, top - y + (3 * w.printScaleY()),0,Qt::red);
|
||||
w.renderText(lab, x1 - (x / 2)+2, top - y + (3 * w.printScaleY()),0,txcol);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -265,6 +266,7 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
bool gLineOverlayBar::mouseMoveEvent(QMouseEvent *event, gGraph *graph)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
Q_UNUSED(graph)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,22 @@ void Day::AddSession(Session *s)
|
||||
sessions.push_back(s);
|
||||
}
|
||||
|
||||
EventDataType Day::lookupValue(ChannelID code, qint64 time)
|
||||
{
|
||||
QList<Session *>::iterator end = sessions.end();
|
||||
for (QList<Session *>::iterator it = sessions.begin(); it != end; ++it) {
|
||||
Session &sess = *(*it);
|
||||
|
||||
if (sess.enabled()) {
|
||||
if ((time > sess.first()) && (time < sess.last())) {
|
||||
return sess.SearchValue(code,time);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
EventDataType Day::timeAboveThreshold(ChannelID code, EventDataType threshold)
|
||||
{
|
||||
EventDataType val = 0;
|
||||
|
@ -98,11 +98,13 @@ class Day
|
||||
EventDataType settings_max(ChannelID code);
|
||||
|
||||
//! \brief Returns the amount of time (in decimal minutes) the Channel spent above the threshold
|
||||
EventDataType timeAboveThreshold(ChannelID id, EventDataType threshold);
|
||||
EventDataType timeAboveThreshold(ChannelID code, EventDataType threshold);
|
||||
|
||||
//! \brief Returns the amount of time (in decimal minutes) the Channel spent below the threshold
|
||||
EventDataType timeBelowThreshold(ChannelID id, EventDataType threshold);
|
||||
EventDataType timeBelowThreshold(ChannelID code, EventDataType threshold);
|
||||
|
||||
//! \brief Returns the value for Channel code at a given time
|
||||
EventDataType lookupValue(ChannelID code, qint64 time);
|
||||
|
||||
//! \brief Returns the first session time of this day
|
||||
qint64 first();
|
||||
|
@ -937,8 +937,10 @@ void Session::UpdateSummaries()
|
||||
last(id);
|
||||
first(id);
|
||||
|
||||
if (((id == CPAP_FlowRate) || (id == CPAP_MaskPressureHi) || (id == CPAP_RespEvent)
|
||||
|| (id == CPAP_MaskPressure))) {
|
||||
if (((id == CPAP_FlowRate)
|
||||
|| (id == CPAP_MaskPressureHi)
|
||||
|| (id == CPAP_RespEvent)
|
||||
|| (id == CPAP_MaskPressure))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -950,42 +952,41 @@ void Session::UpdateSummaries()
|
||||
}
|
||||
}
|
||||
|
||||
bool Session::SearchEvent(ChannelID code, qint64 time, qint64 dist)
|
||||
EventDataType Session::SearchValue(ChannelID code, qint64 time)
|
||||
{
|
||||
qint64 t, start;
|
||||
qint64 tt, start;
|
||||
QHash<ChannelID, QVector<EventList *> >::iterator it;
|
||||
it = eventlist.find(code);
|
||||
quint32 *tptr;
|
||||
int cnt;
|
||||
|
||||
//qint64 rate;
|
||||
if (it != eventlist.end()) {
|
||||
int el_size=it.value().size();
|
||||
for (int i = 0; i < el_size; i++) {
|
||||
EventList *el = it.value()[i];
|
||||
// rate=el->rate();
|
||||
if ((time < el->first()) || (time > el->last())) continue;
|
||||
|
||||
cnt = el->count();
|
||||
|
||||
// why would this be necessary???
|
||||
if (el->type() == EVL_Waveform) {
|
||||
qDebug() << "Called SearchEvent on a waveform object!";
|
||||
return false;
|
||||
return 0;
|
||||
} else {
|
||||
start = el->first();
|
||||
tptr = el->rawTime();
|
||||
|
||||
for (int j = 0; j < cnt; j++) {
|
||||
t = start + *tptr++;
|
||||
|
||||
if (qAbs(time - t) < dist) {
|
||||
return true;
|
||||
for (int j = 0; j < cnt-1; j++) {
|
||||
tptr++;
|
||||
tt = start + *tptr;
|
||||
if (tt > time) {
|
||||
return el->data(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Session::enabled()
|
||||
|
@ -64,8 +64,8 @@ class Session
|
||||
//! \brief Returns true if session contains an empty duration
|
||||
inline bool isEmpty() { return (s_first == s_last); }
|
||||
|
||||
//! \brief Search for Event code happening within dist milliseconds of supplied time (ms since epoch)
|
||||
bool SearchEvent(ChannelID code, qint64 time, qint64 dist = 15000);
|
||||
//! \brief Search for Event code happening at supplied time (ms since epoch)
|
||||
EventDataType SearchValue(ChannelID code, qint64 time);
|
||||
|
||||
//! \brief Return the sessionID
|
||||
inline const SessionID &session() {
|
||||
|
Loading…
Reference in New Issue
Block a user