mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-06 19:20:45 +00:00
Added Selection AHI back, selection duration tooltip
This commit is contained in:
parent
af19d82b71
commit
faf341ce43
@ -366,7 +366,7 @@ void gFlagsLine::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
|
|
||||||
brush = QBrush(color);
|
brush = QBrush(color);
|
||||||
painter.fillRect(x2, bartop, x1-x2, bottom-bartop, brush);
|
painter.fillRect(x2, bartop, x1-x2, bottom-bartop, brush);
|
||||||
if (!hover && QRect(x2, bartop, x1-x2, bottom-bartop).contains(w.graphView()->currentMousePos())) {
|
if (!w.selectingArea() && !hover && QRect(x2, bartop, x1-x2, bottom-bartop).contains(w.graphView()->currentMousePos())) {
|
||||||
hover = true;
|
hover = true;
|
||||||
painter.setPen(QPen(Qt::red,1));
|
painter.setPen(QPen(Qt::red,1));
|
||||||
|
|
||||||
@ -394,7 +394,7 @@ void gFlagsLine::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
|
|
||||||
x1 = (X - minx) * xmult + left;
|
x1 = (X - minx) * xmult + left;
|
||||||
|
|
||||||
if (!hover && QRect(x1-3, bartop-2, 6, bottom-bartop+4).contains(w.graphView()->currentMousePos())) {
|
if (!w.selectingArea() && !hover && QRect(x1-3, bartop-2, 6, bottom-bartop+4).contains(w.graphView()->currentMousePos())) {
|
||||||
hover = true;
|
hover = true;
|
||||||
painter.setPen(QPen(Qt::red,1));
|
painter.setPen(QPen(Qt::red,1));
|
||||||
|
|
||||||
|
@ -766,6 +766,10 @@ void gGraph::mouseMoveEvent(QMouseEvent *event)
|
|||||||
m_selDurString.sprintf("%02i:%02i:%02i:%03i", h, m, s, ms);
|
m_selDurString.sprintf("%02i:%02i:%02i:%03i", h, m, s, ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ToolTipAlignment align = x >= x2 ? TT_AlignLeft : TT_AlignRight;
|
||||||
|
int offset = (x >= x2) ? 20 : - 20;
|
||||||
|
ToolTip(m_selDurString, m_rect.left() + x + offset, m_rect.top() + y + 20, align);
|
||||||
|
|
||||||
if (qstatus2) {
|
if (qstatus2) {
|
||||||
qstatus2->setText(m_selDurString);
|
qstatus2->setText(m_selDurString);
|
||||||
}
|
}
|
||||||
@ -836,6 +840,9 @@ void gGraph::mouseMoveEvent(QMouseEvent *event)
|
|||||||
// //qDebug() << m_title << "Moved" << x << y << left << right << top << bottom << m_width << m_height;
|
// //qDebug() << m_title << "Moved" << x << y << left << right << top << bottom << m_width << m_height;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool gGraph::selectingArea() { return m_selecting_area || m_graphview->metaSelect(); }
|
||||||
|
|
||||||
void gGraph::mousePressEvent(QMouseEvent *event)
|
void gGraph::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
int y = event->pos().y();
|
int y = event->pos().y();
|
||||||
|
@ -106,9 +106,13 @@ class gGraph : public QObject
|
|||||||
//! \brief Returns true if none of the included layers have data attached
|
//! \brief Returns true if none of the included layers have data attached
|
||||||
bool isEmpty();
|
bool isEmpty();
|
||||||
|
|
||||||
|
//! \brief Returns true if the user is currently dragging the mouse to select an area
|
||||||
|
bool selectingArea();
|
||||||
|
|
||||||
double currentTime() const;
|
double currentTime() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! \brief Add Layer l to graph object, allowing you to specify position,
|
//! \brief Add Layer l to graph object, allowing you to specify position,
|
||||||
// margin sizes, order, movability status and offsets
|
// margin sizes, order, movability status and offsets
|
||||||
void AddLayer(Layer *l, LayerPosition position = LayerCenter,
|
void AddLayer(Layer *l, LayerPosition position = LayerCenter,
|
||||||
|
@ -936,16 +936,80 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
painter.setClipping(false);
|
painter.setClipping(false);
|
||||||
|
|
||||||
|
|
||||||
|
// Calculate combined session times within selected area...
|
||||||
|
double first, last;
|
||||||
|
double time = 0;
|
||||||
|
|
||||||
|
// Calculate the session time.
|
||||||
|
for (QList<Session *>::iterator s = m_day->begin(); s != m_day->end(); s++) {
|
||||||
|
if (!(*s)->enabled()) { continue; }
|
||||||
|
|
||||||
|
first = (*s)->first();
|
||||||
|
last = (*s)->last();
|
||||||
|
|
||||||
|
if (last < w.min_x) { continue; }
|
||||||
|
if (first > w.max_x) { continue; }
|
||||||
|
|
||||||
|
if (first < w.min_x) {
|
||||||
|
first = w.min_x;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (last > w.max_x) {
|
||||||
|
last = w.max_x;
|
||||||
|
}
|
||||||
|
|
||||||
|
time += last - first;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
time /= 1000;
|
||||||
|
|
||||||
|
QList<ChannelID> ahilist;
|
||||||
|
ahilist.push_back(CPAP_Hypopnea);
|
||||||
|
ahilist.push_back(CPAP_Obstructive);
|
||||||
|
ahilist.push_back(CPAP_Apnea);
|
||||||
|
ahilist.push_back(CPAP_ClearAirway);
|
||||||
|
|
||||||
|
QList<ChannelID> extras;
|
||||||
|
ahilist.push_back(CPAP_NRI);
|
||||||
|
ahilist.push_back(CPAP_UserFlag1);
|
||||||
|
ahilist.push_back(CPAP_UserFlag2);
|
||||||
|
|
||||||
|
double sum = 0;
|
||||||
|
int cnt = 0;
|
||||||
|
|
||||||
|
// Draw the linechart overlays
|
||||||
if (m_day && (p_profile->appearance->lineCursorMode() || (m_codes[0]==CPAP_FlowRate))) {
|
if (m_day && (p_profile->appearance->lineCursorMode() || (m_codes[0]==CPAP_FlowRate))) {
|
||||||
QHash<ChannelID, gLineOverlayBar *>::iterator fit;
|
QHash<ChannelID, gLineOverlayBar *>::iterator fit;
|
||||||
bool blockhover = false;
|
bool blockhover = false;
|
||||||
|
|
||||||
for (fit = flags.begin(); fit != flags.end(); ++fit) {
|
for (fit = flags.begin(); fit != flags.end(); ++fit) {
|
||||||
|
ChannelID code = fit.key();
|
||||||
gLineOverlayBar * lob = fit.value();
|
gLineOverlayBar * lob = fit.value();
|
||||||
lob->setBlockHover(blockhover);
|
lob->setBlockHover(blockhover);
|
||||||
lob->paint(painter, w, region);
|
lob->paint(painter, w, region);
|
||||||
if (lob->hover()) blockhover = true; // did it render a hover over?
|
if (lob->hover()) blockhover = true; // did it render a hover over?
|
||||||
|
|
||||||
|
if (ahilist.contains(code)) {
|
||||||
|
sum += lob->sum();
|
||||||
|
cnt += lob->count();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (m_codes[0] == CPAP_FlowRate) {
|
||||||
|
float hours = float(time) / 3600.0;
|
||||||
|
int h = time / 3600;
|
||||||
|
int m = int(time / 60) % 60;
|
||||||
|
int s = int(time) % 60;
|
||||||
|
|
||||||
|
float f = float(cnt) / hours; // / (sum / 3600.0);
|
||||||
|
QString txt = QObject::tr("Duration %1:%2:%3").arg(h,2,10,QChar('0')).arg(m,2,10,QChar('0')).arg(s,2,10,QChar('0')) + " "+
|
||||||
|
QObject::tr("AHI: %1").arg(f,0,'f',2);
|
||||||
|
painter.setPen(Qt::black);
|
||||||
|
painter.drawText(left,top-4,txt);
|
||||||
|
}
|
||||||
|
|
||||||
painter.setRenderHint(QPainter::Antialiasing, false);
|
painter.setRenderHint(QPainter::Antialiasing, false);
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
painter.setPen(QPen(col,4));
|
painter.setPen(QPen(col,4));
|
||||||
painter.drawPoint(x1, top);
|
painter.drawPoint(x1, top);
|
||||||
|
|
||||||
if (!m_blockhover && rect.contains(mouse) && !m_hover) {
|
if (!w.selectingArea() && !m_blockhover && rect.contains(mouse) && !m_hover) {
|
||||||
m_hover = true;
|
m_hover = true;
|
||||||
|
|
||||||
|
|
||||||
@ -270,7 +270,7 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
// Top and bottom markers
|
// Top and bottom markers
|
||||||
//////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool b = false;
|
bool b = false;
|
||||||
if (!m_blockhover && QRect(x1-2, topp, 6, height).contains(mouse) && !m_hover) {
|
if (!w.selectingArea() && !m_blockhover && QRect(x1-2, topp, 6, height).contains(mouse) && !m_hover) {
|
||||||
// only want to draw the highlight/label once per frame
|
// only want to draw the highlight/label once per frame
|
||||||
m_hover = true;
|
m_hover = true;
|
||||||
b = true;
|
b = true;
|
||||||
@ -401,11 +401,12 @@ void gLineOverlaySummary::paint(QPainter &painter, gGraph &w, const QRegion ®
|
|||||||
|
|
||||||
QString a;
|
QString a;
|
||||||
|
|
||||||
if ((w.graphView()->selectionInProgress() || w.graphView()->metaSelect()) && (!w.selDurString().isEmpty())) {
|
if (0) { //(w.graphView()->selectionInProgress())) { // || w.graphView()->metaSelect()) && (!w.selDurString().isEmpty())) {
|
||||||
a = QObject::tr("Duration")+": "+w.selDurString();
|
a = QObject::tr("Duration")+": "+w.selDurString();
|
||||||
} else {
|
} else {
|
||||||
a = QObject::tr("Events") + ": " + QString::number(cnt) + ", " +
|
a = QObject::tr("Events") + ": " + QString::number(cnt) + ", " +
|
||||||
QObject::tr("Duration") + " " + QString().sprintf("%02i:%02i:%02i", h, m, s) + ", " + m_text + ": " + QString::number(val, 'f', 2);
|
QObject::tr("Duration") + " " + QString().sprintf("%02i:%02i:%02i", h, m, s) + ", " +
|
||||||
|
m_text + ": " + QString::number(val, 'f', 2);
|
||||||
}
|
}
|
||||||
if (isSpan) {
|
if (isSpan) {
|
||||||
float sph;
|
float sph;
|
||||||
|
Loading…
Reference in New Issue
Block a user