mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 18:50:44 +00:00
WIP on master: cc2a80e4
Start of PRS1 DFV3 Summary Parsing cleanup
This commit is contained in:
commit
4dcf1a75fb
@ -50,19 +50,12 @@ void MinutesAtPressure::SetDay(Day *day)
|
|||||||
Machine * cpap = nullptr;
|
Machine * cpap = nullptr;
|
||||||
if (day) cpap = day->machine(MT_CPAP);
|
if (day) cpap = day->machine(MT_CPAP);
|
||||||
if (cpap) {
|
if (cpap) {
|
||||||
QList<Session *>::iterator sit;
|
|
||||||
EventDataType minpressure = 20;
|
EventDataType minpressure = 20;
|
||||||
EventDataType maxpressure = 0;
|
EventDataType maxpressure = 0;
|
||||||
|
|
||||||
QMap<QDate, Day *>::iterator it;
|
|
||||||
QMap<QDate, Day *>::iterator day_end = cpap->day.end();
|
|
||||||
// look at overall pressure ranges and find the max
|
// look at overall pressure ranges and find the max
|
||||||
|
for (const auto d : cpap->day) {
|
||||||
for (it = cpap->day.begin(); it != day_end; ++it) {
|
for (const auto sess : d->sessions) {
|
||||||
Day * d = it.value();
|
|
||||||
QList<Session *>::iterator sess_end = d->end();
|
|
||||||
for (sit = d->begin(); sit != sess_end; ++sit) {
|
|
||||||
Session * sess = (*sit);
|
|
||||||
if (sess->channelExists(CPAP_Pressure)) {
|
if (sess->channelExists(CPAP_Pressure)) {
|
||||||
minpressure = qMin(sess->Min(CPAP_Pressure), minpressure);
|
minpressure = qMin(sess->Min(CPAP_Pressure), minpressure);
|
||||||
maxpressure = qMax(sess->Max(CPAP_Pressure), maxpressure);
|
maxpressure = qMax(sess->Max(CPAP_Pressure), maxpressure);
|
||||||
@ -157,7 +150,6 @@ void MinutesAtPressure::paint(QPainter &painter, gGraph &graph, const QRegion &r
|
|||||||
m_lastminx = m_minx;
|
m_lastminx = m_minx;
|
||||||
m_lastmaxx = m_maxx;
|
m_lastmaxx = m_maxx;
|
||||||
|
|
||||||
QMap<EventStoreType, int>::iterator it;
|
|
||||||
if (graph.printing()) {
|
if (graph.printing()) {
|
||||||
// Could just lock the mutex QMutex instead
|
// Could just lock the mutex QMutex instead
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
@ -245,8 +237,8 @@ void MinutesAtPressure::paint(QPainter &painter, gGraph &graph, const QRegion &r
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
double pstep = xstep * pressureMult;
|
double pstep = xstep * pressureMult;
|
||||||
|
|
||||||
xp = left;// /2.0;
|
xp = left;
|
||||||
for (int i = 0; i<=max-min; ++i) {
|
for (int i=0, end=max-min; i<=end; ++i) {
|
||||||
yp = bottom+1;
|
yp = bottom+1;
|
||||||
painter.drawLine(xp, yp, xp, yp+6);
|
painter.drawLine(xp, yp, xp, yp+6);
|
||||||
if (i>0) { // skip the first mid tick
|
if (i>0) { // skip the first mid tick
|
||||||
@ -335,11 +327,12 @@ void MinutesAtPressure::paint(QPainter &painter, gGraph &graph, const QRegion &r
|
|||||||
|
|
||||||
double lastyp = bottom - (s2 * ystep);
|
double lastyp = bottom - (s2 * ystep);
|
||||||
int tmax = qMin(ipap.times.size(), max);
|
int tmax = qMin(ipap.times.size(), max);
|
||||||
|
const auto & ipaptimes = ipap.times;
|
||||||
for (int i=qMax(min,1); i<tmax; ++i) {
|
for (int i=qMax(min,1); i<tmax; ++i) {
|
||||||
p0 = ipap.times[i-1] / 60.0;
|
p0 = ipaptimes[i-1] / 60.0;
|
||||||
p1 = ipap.times[i]/ 60.0;
|
p1 = ipaptimes[i]/ 60.0;
|
||||||
p2 = ipap.times[i+1]/ 60.0;
|
p2 = ipaptimes[i+1]/ 60.0;
|
||||||
p3 = ipap.times[i+2]/ 60.0;
|
p3 = ipaptimes[i+2]/ 60.0;
|
||||||
|
|
||||||
yp = bottom - qMax((double(p1) * ystep),0.0);
|
yp = bottom - qMax((double(p1) * ystep),0.0);
|
||||||
|
|
||||||
@ -376,13 +369,10 @@ void MinutesAtPressure::paint(QPainter &painter, gGraph &graph, const QRegion &r
|
|||||||
painter.drawLine(xp, lastyp, xp+xstep, yp);
|
painter.drawLine(xp, lastyp, xp+xstep, yp);
|
||||||
xp+=xstep;
|
xp+=xstep;
|
||||||
lastyp = yp;
|
lastyp = yp;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double estep;
|
double estep;
|
||||||
|
|
||||||
|
|
||||||
if (ipap.peakevents>0) {
|
if (ipap.peakevents>0) {
|
||||||
double evpeak = ipap.peakevents;
|
double evpeak = ipap.peakevents;
|
||||||
double bot = bottom+1;
|
double bot = bottom+1;
|
||||||
@ -403,7 +393,6 @@ void MinutesAtPressure::paint(QPainter &painter, gGraph &graph, const QRegion &r
|
|||||||
evpeak = ceil(evpeak/g)*g;
|
evpeak = ceil(evpeak/g)*g;
|
||||||
r = double(height+3) / (evpeak / g);
|
r = double(height+3) / (evpeak / g);
|
||||||
|
|
||||||
|
|
||||||
yp = bot;
|
yp = bot;
|
||||||
widest_YAxis+=2;
|
widest_YAxis+=2;
|
||||||
for (double f=0.0; f<=evpeak; f+=g) {
|
for (double f=0.0; f<=evpeak; f+=g) {
|
||||||
@ -421,8 +410,7 @@ void MinutesAtPressure::paint(QPainter &painter, gGraph &graph, const QRegion &r
|
|||||||
}
|
}
|
||||||
|
|
||||||
estep = double(height) / ipap.peakevents;
|
estep = double(height) / ipap.peakevents;
|
||||||
for (int k=0; k<ipap.chans.size(); ++k) {
|
for (const auto ch : ipap.chans) {
|
||||||
ChannelID ch = ipap.chans.at(k);
|
|
||||||
//(ch != CPAP_AHI) &&
|
//(ch != CPAP_AHI) &&
|
||||||
//if ((ch != CPAP_Hypopnea) && (ch != CPAP_Obstructive) && (ch != CPAP_ClearAirway) && (ch != CPAP_Apnea)) continue;
|
//if ((ch != CPAP_Hypopnea) && (ch != CPAP_Obstructive) && (ch != CPAP_ClearAirway) && (ch != CPAP_Apnea)) continue;
|
||||||
schema::Channel & chan = schema::channel[ch];
|
schema::Channel & chan = schema::channel[ch];
|
||||||
@ -437,11 +425,13 @@ void MinutesAtPressure::paint(QPainter &painter, gGraph &graph, const QRegion &r
|
|||||||
} else s2 = 0;
|
} else s2 = 0;
|
||||||
lastyp = bottom - (s2 * estep);
|
lastyp = bottom - (s2 * estep);
|
||||||
int tmax = qMin(ipap.events.size(), max);
|
int tmax = qMin(ipap.events.size(), max);
|
||||||
|
|
||||||
|
const auto & ipapev = ipap.events[ch];
|
||||||
for (int i=qMax(min,1); i<tmax; ++i) {
|
for (int i=qMax(min,1); i<tmax; ++i) {
|
||||||
p0 = ipap.events[ch][i-1];
|
p0 = ipapev[i-1];
|
||||||
p1 = ipap.events[ch][i];
|
p1 = ipapev[i];
|
||||||
p2 = ipap.events[ch][i+1];
|
p2 = ipapev[i+1];
|
||||||
p3 = ipap.events[ch][i+1];
|
p3 = ipapev[i+1];
|
||||||
yp = bottom - qMax((double(p1) * estep),0.0);
|
yp = bottom - qMax((double(p1) * estep),0.0);
|
||||||
painter.drawLine(xp, lastyp, xp+xstep, yp);
|
painter.drawLine(xp, lastyp, xp+xstep, yp);
|
||||||
lastyp = yp;
|
lastyp = yp;
|
||||||
@ -534,18 +524,19 @@ void MinutesAtPressure::paint(QPainter &painter, gGraph &graph, const QRegion &r
|
|||||||
if (epap.min_pressure) {
|
if (epap.min_pressure) {
|
||||||
painter.setPen(QPen(echan.defaultColor(), lineThickness));
|
painter.setPen(QPen(echan.defaultColor(), lineThickness));
|
||||||
|
|
||||||
if ( epap.times.size() > qMax(min,0)) {
|
const auto & epaptimes = epap.times;
|
||||||
s2 = double(epap.times[qMax(min,0)]/60.0);
|
if ( epaptimes.size() > qMax(min,0)) {
|
||||||
|
s2 = double(epaptimes[qMax(min,0)]/60.0);
|
||||||
} else {
|
} else {
|
||||||
s2 = 0;
|
s2 = 0;
|
||||||
}
|
}
|
||||||
xp=left, lastyp = bottom - (s2 * ystep);
|
xp=left, lastyp = bottom - (s2 * ystep);
|
||||||
int tmax = qMin(epap.times.size(), max);
|
int tmax = qMin(epaptimes.size(), max);
|
||||||
for (int i=qMax(min,1); i<tmax; ++i) {
|
for (int i=qMax(min,1); i<tmax; ++i) {
|
||||||
p0 = epap.times[i-1]/60.0;
|
p0 = epaptimes[i-1]/60.0;
|
||||||
p1 = epap.times[i]/60.0;
|
p1 = epaptimes[i]/60.0;
|
||||||
p2 = epap.times[i+1]/60.0;
|
p2 = epaptimes[i+1]/60.0;
|
||||||
p3 = epap.times[i+2]/60.0;
|
p3 = epaptimes[i+2]/60.0;
|
||||||
|
|
||||||
if (i == mouseOverKey) {
|
if (i == mouseOverKey) {
|
||||||
painter.setPen(QPen(Qt::black));
|
painter.setPen(QPen(Qt::black));
|
||||||
@ -586,7 +577,7 @@ void MinutesAtPressure::paint(QPainter &painter, gGraph &graph, const QRegion &r
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*QMap<EventStoreType, int>::iterator times_end = times.end();
|
/*auto times_end = times.end();
|
||||||
QPoint mouse = graph.graphView()->currentMousePos();
|
QPoint mouse = graph.graphView()->currentMousePos();
|
||||||
|
|
||||||
float ypos = top;
|
float ypos = top;
|
||||||
@ -637,9 +628,9 @@ void MinutesAtPressure::paint(QPainter &painter, gGraph &graph, const QRegion &r
|
|||||||
ypos += hix * 2;
|
ypos += hix * 2;
|
||||||
// left = rect.left();
|
// left = rect.left();
|
||||||
|
|
||||||
QHash<ChannelID, QMap<EventStoreType, EventDataType> >::iterator eit;
|
auto eit;
|
||||||
//QHash<ChannelID, QMap<EventStoreType, EventDataType> >::iterator ev_end = events.end();
|
//auto ev_end = events.end();
|
||||||
QMap<EventStoreType, EventDataType>::iterator vit;
|
auto vit;
|
||||||
|
|
||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
@ -654,7 +645,7 @@ void MinutesAtPressure::paint(QPainter &painter, gGraph &graph, const QRegion &r
|
|||||||
|
|
||||||
xpos = left;
|
xpos = left;
|
||||||
|
|
||||||
QMap<EventStoreType, EventDataType>::iterator eit_end = eit.value().end();
|
auto eit_end = eit.value().end();
|
||||||
|
|
||||||
QString text = chan.label();
|
QString text = chan.label();
|
||||||
rec = QRectF(titleWidth, ypos, marginWidth, hix);
|
rec = QRectF(titleWidth, ypos, marginWidth, hix);
|
||||||
@ -796,7 +787,7 @@ void MinutesAtPressure::paint(QPainter &painter, gGraph &graph, const QRegion &r
|
|||||||
if (type == schema::SPAN)
|
if (type == schema::SPAN)
|
||||||
continue;
|
continue;
|
||||||
eit = events.find(code);
|
eit = events.find(code);
|
||||||
QMap<EventStoreType, EventDataType>::iterator eit_end = eit.value().end();
|
auto eit_end = eit.value().end();
|
||||||
for (it = times.begin(), vit = eit.value().begin(); vit != eit_end; ++vit, ++it) {
|
for (it = times.begin(), vit = eit.value().begin(); vit != eit_end; ++vit, ++it) {
|
||||||
//float minutes = float(it.value()) / 60.0;
|
//float minutes = float(it.value()) / 60.0;
|
||||||
float value = vit.value();
|
float value = vit.value();
|
||||||
@ -823,7 +814,7 @@ void MinutesAtPressure::paint(QPainter &painter, gGraph &graph, const QRegion &r
|
|||||||
xpos = left;//+pix/2;
|
xpos = left;//+pix/2;
|
||||||
|
|
||||||
y1 = 0;
|
y1 = 0;
|
||||||
QMap<EventStoreType, EventDataType>::iterator eit_end = eit.value().end();
|
auto eit_end = eit.value().end();
|
||||||
for (it = times.begin(), vit = eit.value().begin(); vit != eit_end; ++vit, ++it) {
|
for (it = times.begin(), vit = eit.value().begin(); vit != eit_end; ++vit, ++it) {
|
||||||
//float minutes = float(it.value()) / 60.0;
|
//float minutes = float(it.value()) / 60.0;
|
||||||
float value = vit.value();
|
float value = vit.value();
|
||||||
@ -879,19 +870,16 @@ void RecalcMAP::updateTimes(PressureInfo & info, Session * sess)
|
|||||||
if (code == 0) return;
|
if (code == 0) return;
|
||||||
|
|
||||||
// Find pressure channel
|
// Find pressure channel
|
||||||
QHash<ChannelID, QVector<EventList *> >::iterator ei = sess->eventlist.find(code);
|
auto ei = sess->eventlist.find(code);
|
||||||
|
|
||||||
// Done already if no channel
|
// Done already if no channel
|
||||||
if (ei == sess->eventlist.end())
|
if (ei == sess->eventlist.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const QVector<EventList *> & evec = ei.value();
|
|
||||||
int esize = evec.size();
|
|
||||||
|
|
||||||
pressureMult = (sess->machine()->loaderName() == "PRS1") ? 2 : 5;
|
pressureMult = (sess->machine()->loaderName() == "PRS1") ? 2 : 5;
|
||||||
// Loop through event lists
|
// Loop through event lists
|
||||||
for (int ei = 0; ei < esize; ++ei) {
|
|
||||||
const EventList *EL = evec.at(ei);
|
for (const auto & EL : ei.value()) {
|
||||||
gain = EL->gain();
|
gain = EL->gain();
|
||||||
|
|
||||||
// Don't bother with short sessions
|
// Don't bother with short sessions
|
||||||
@ -939,10 +927,8 @@ void RecalcMAP::updateTimes(PressureInfo & info, Session * sess)
|
|||||||
key = lastdata;
|
key = lastdata;
|
||||||
info.times[key] += duration;
|
info.times[key] += duration;
|
||||||
|
|
||||||
int cs = info.chans.size();
|
|
||||||
|
|
||||||
for (int c = 0; c < cs; ++c) {
|
for (const auto & cod : info.chans) {
|
||||||
ChannelID cod = info.chans.at(c);
|
|
||||||
schema::Channel & chan = schema::channel[cod];
|
schema::Channel & chan = schema::channel[cod];
|
||||||
if (chan.type() == schema::SPAN) {
|
if (chan.type() == schema::SPAN) {
|
||||||
info.events[cod][key] += val = sess->rangeSum(cod, d1, d2);
|
info.events[cod][key] += val = sess->rangeSum(cod, d1, d2);
|
||||||
@ -966,10 +952,8 @@ void RecalcMAP::updateTimes(PressureInfo & info, Session * sess)
|
|||||||
duration = (d2 - d1) / 1000L;
|
duration = (d2 - d1) / 1000L;
|
||||||
key = lastdata;
|
key = lastdata;
|
||||||
info.times[key] += duration;
|
info.times[key] += duration;
|
||||||
int cs = info.chans.size();
|
|
||||||
|
|
||||||
for (int c = 0; c < cs; ++c) {
|
for (const auto & cod : info.chans) {
|
||||||
ChannelID cod = info.chans.at(c);
|
|
||||||
schema::Channel & chan = schema::channel[cod];
|
schema::Channel & chan = schema::channel[cod];
|
||||||
if (chan.type() == schema::SPAN) {
|
if (chan.type() == schema::SPAN) {
|
||||||
info.events[cod][key] += sess->rangeSum(cod, d1, d2);
|
info.events[cod][key] += sess->rangeSum(cod, d1, d2);
|
||||||
@ -977,9 +961,7 @@ void RecalcMAP::updateTimes(PressureInfo & info, Session * sess)
|
|||||||
info.events[cod][key] += sess->rangeCount(cod, d1, d2);
|
info.events[cod][key] += sess->rangeCount(cod, d1, d2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -991,7 +973,7 @@ void PressureInfo::finishCalcs()
|
|||||||
|
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
for (int i=0; i<times.size(); ++i) {
|
for (int i=0, end=times.size(); i<end; ++i) {
|
||||||
val = times.at(i);
|
val = times.at(i);
|
||||||
peaktime = qMax(peaktime, times.at(i));
|
peaktime = qMax(peaktime, times.at(i));
|
||||||
|
|
||||||
@ -1003,7 +985,6 @@ void PressureInfo::finishCalcs()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelID cod;
|
|
||||||
//chans.push_front(CPAP_AHI);
|
//chans.push_front(CPAP_AHI);
|
||||||
|
|
||||||
int size = events[CPAP_Obstructive].size();
|
int size = events[CPAP_Obstructive].size();
|
||||||
@ -1011,11 +992,10 @@ void PressureInfo::finishCalcs()
|
|||||||
/* events[CPAP_AHI].resize(size);
|
/* events[CPAP_AHI].resize(size);
|
||||||
|
|
||||||
|
|
||||||
QHash<unsigned int, QVector<int> >::iterator OB = events.find(CPAP_Obstructive);
|
auto OB = events.find(CPAP_Obstructive);
|
||||||
QHash<unsigned int, QVector<int> >::iterator HY = events.find(CPAP_Hypopnea);
|
auto HY = events.find(CPAP_Hypopnea);
|
||||||
QHash<unsigned int, QVector<int> >::iterator A = events.find(CPAP_Apnea);
|
auto A = events.find(CPAP_Apnea);
|
||||||
QHash<unsigned int, QVector<int> >::iterator CA = events.find(CPAP_ClearAirway);
|
auto CA = events.find(CPAP_ClearAirway);
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
|
|
||||||
@ -1034,9 +1014,7 @@ void PressureInfo::finishCalcs()
|
|||||||
} */
|
} */
|
||||||
|
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
|
for (const auto & cod : chans) {
|
||||||
for (int j=0 ; j < chans.size(); ++j) {
|
|
||||||
cod = chans.at(j);
|
|
||||||
if ((cod == CPAP_AHI) || (schema::channel[cod].type() == schema::SPAN)) continue;
|
if ((cod == CPAP_AHI) || (schema::channel[cod].type() == schema::SPAN)) continue;
|
||||||
val = events[cod][i];
|
val = events[cod][i];
|
||||||
peakevents = qMax(val, peakevents);
|
peakevents = qMax(val, peakevents);
|
||||||
@ -1052,14 +1030,6 @@ void RecalcMAP::run()
|
|||||||
Day * day = map->m_day;
|
Day * day = map->m_day;
|
||||||
if (!day) return;
|
if (!day) return;
|
||||||
|
|
||||||
QList<Session *>::iterator sit;
|
|
||||||
QList<Session *>::iterator sess_end = day->end();
|
|
||||||
|
|
||||||
|
|
||||||
QMap<EventStoreType, int> times;
|
|
||||||
|
|
||||||
QHash<ChannelID, QMap<EventStoreType, EventDataType> > events;
|
|
||||||
|
|
||||||
// Get the channels for specified Channel types
|
// Get the channels for specified Channel types
|
||||||
QList<ChannelID> chans = day->getSortedMachineChannels(schema::FLAG);
|
QList<ChannelID> chans = day->getSortedMachineChannels(schema::FLAG);
|
||||||
|
|
||||||
@ -1109,8 +1079,7 @@ void RecalcMAP::run()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (sit = day->begin(); sit != sess_end; ++sit) {
|
for (const auto & sess : day->sessions) {
|
||||||
Session * sess = (*sit);
|
|
||||||
|
|
||||||
updateTimes(EPAP, sess);
|
updateTimes(EPAP, sess);
|
||||||
updateTimes(IPAP, sess);
|
updateTimes(IPAP, sess);
|
||||||
@ -1121,11 +1090,11 @@ void RecalcMAP::run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* QHash<ChannelID, QVector<EventList *> >::iterator ei = sess->eventlist.find(ipapcode);
|
/* auto ei = sess->eventlist.find(ipapcode);
|
||||||
if (ei == sess->eventlist.end())
|
if (ei == sess->eventlist.end())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const QVector<EventList *> & evec = ei.value();
|
const auto & evec = ei.value();
|
||||||
int esize = evec.size();
|
int esize = evec.size();
|
||||||
for (int ei = 0; ei < esize; ++ei) {
|
for (int ei = 0; ei < esize; ++ei) {
|
||||||
const EventList *EL = evec.at(ei);
|
const EventList *EL = evec.at(ei);
|
||||||
@ -1218,12 +1187,11 @@ skip:
|
|||||||
EPAP.finishCalcs();
|
EPAP.finishCalcs();
|
||||||
IPAP.finishCalcs();
|
IPAP.finishCalcs();
|
||||||
|
|
||||||
/* QMap<EventStoreType, int>::iterator it;
|
/*
|
||||||
QMap<EventStoreType, int>::iterator times_end = times.end();
|
|
||||||
int maxtime = 0;
|
int maxtime = 0;
|
||||||
|
|
||||||
QList<EventStoreType> trash;
|
QList<EventStoreType> trash;
|
||||||
for (it = times.begin(); it != times_end; ++it) {
|
for (auto it=times.begin(), end=times.end(); it != end; ++it) {
|
||||||
//EventStoreType key = it.key();
|
//EventStoreType key = it.key();
|
||||||
int value = it.value();
|
int value = it.value();
|
||||||
// if (value == 0) {
|
// if (value == 0) {
|
||||||
@ -1254,13 +1222,12 @@ skip:
|
|||||||
maxevents = qMax(val, maxevents);
|
maxevents = qMax(val, maxevents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QHash<ChannelID, QMap<EventStoreType, EventDataType> >::iterator eit;
|
|
||||||
|
|
||||||
// for (int i=0; i< trash.size(); ++i) {
|
// for (int i=0; i< trash.size(); ++i) {
|
||||||
// EventStoreType key = trash.at(i);
|
// EventStoreType key = trash.at(i);
|
||||||
|
|
||||||
// times.remove(key);
|
// times.remove(key);
|
||||||
// for (eit = events.begin(); eit != events.end(); ++eit) {
|
// for (auto eit=events.begin(), end=events.end(); eit != end; ++eit) {
|
||||||
// eit.value().remove(key);
|
// eit.value().remove(key);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* gFlagsLine Implementation
|
/* gFlagsLine Implementation
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011-2018 Mark Watkins <mark@jedimark.net>
|
* Copyright (c) 2011-2018 Mark Watkins <mark@jedimark.net>
|
||||||
*
|
*
|
||||||
@ -79,10 +79,8 @@ void gFlagsGroup::SetDay(Day *d)
|
|||||||
if (m_rebuild_cpap) {
|
if (m_rebuild_cpap) {
|
||||||
QHash<ChannelID, schema::Channel *> chans;
|
QHash<ChannelID, schema::Channel *> chans;
|
||||||
|
|
||||||
for (int i=0; i< m_day->size(); ++i) {
|
for (const auto & sess : m_day->sessions) {
|
||||||
Session * sess = m_day->sessions.at(i);
|
for (auto it=sess->eventlist.begin(), end=sess->eventlist.end(); it != end; ++it) {
|
||||||
QHash<ChannelID, QVector<EventList *> >::iterator it;
|
|
||||||
for (it = sess->eventlist.begin(); it != sess->eventlist.end(); ++it) {
|
|
||||||
ChannelID code = it.key();
|
ChannelID code = it.key();
|
||||||
if (chans.contains(code)) continue;
|
if (chans.contains(code)) continue;
|
||||||
|
|
||||||
@ -103,10 +101,8 @@ void gFlagsGroup::SetDay(Day *d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
lvisible.clear();
|
lvisible.clear();
|
||||||
for (int i=0; i < availableChans.size(); ++i) {
|
for (const auto code : availableChans) {
|
||||||
ChannelID code = availableChans.at(i);
|
|
||||||
// const schema::Channel & chan = schema::channel[code];
|
// const schema::Channel & chan = schema::channel[code];
|
||||||
|
|
||||||
gFlagsLine * fl = new gFlagsLine(code);
|
gFlagsLine * fl = new gFlagsLine(code);
|
||||||
fl->SetDay(d);
|
fl->SetDay(d);
|
||||||
lvisible.push_back(fl);
|
lvisible.push_back(fl);
|
||||||
@ -164,9 +160,9 @@ void gFlagsGroup::paint(QPainter &painter, gGraph &g, const QRegion ®ion)
|
|||||||
|
|
||||||
QVector<gFlagsLine *> visflags;
|
QVector<gFlagsLine *> visflags;
|
||||||
|
|
||||||
for (int i = 0; i < lvisible.size(); i++) {
|
for (const auto & flagsline : lvisible) {
|
||||||
if (schema::channel[lvisible.at(i)->code()].enabled())
|
if (schema::channel[flagsline->code()].enabled())
|
||||||
visflags.push_back(lvisible.at(i));
|
visflags.push_back(flagsline);
|
||||||
}
|
}
|
||||||
|
|
||||||
int vis = visflags.size();
|
int vis = visflags.size();
|
||||||
@ -175,7 +171,7 @@ void gFlagsGroup::paint(QPainter &painter, gGraph &g, const QRegion ®ion)
|
|||||||
|
|
||||||
QColor barcol;
|
QColor barcol;
|
||||||
|
|
||||||
for (int i = 0; i < visflags.size(); i++) {
|
for (int i=0, end=visflags.size(); i < end; i++) {
|
||||||
//schema::Channel & chan = schema::channel[visflags.at(i)->code()];
|
//schema::Channel & chan = schema::channel[visflags.at(i)->code()];
|
||||||
|
|
||||||
// Alternating box color
|
// Alternating box color
|
||||||
@ -221,15 +217,15 @@ bool gFlagsGroup::mouseMoveEvent(QMouseEvent *event, gGraph *graph)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < lvisible.size(); i++) {
|
for (int i=0, end=lvisible.size(); i < end; i++) {
|
||||||
gFlagsLine *fl = lvisible[i];
|
gFlagsLine *fl = lvisible.at(i);
|
||||||
|
|
||||||
if (fl->m_rect.contains(event->x(), event->y())) {
|
if (fl->m_rect.contains(event->x(), event->y())) {
|
||||||
if (fl->mouseMoveEvent(event, graph)) { return true; }
|
if (fl->mouseMoveEvent(event, graph)) { return true; }
|
||||||
} else {
|
} else {
|
||||||
// Inside main graph area?
|
// Inside main graph area?
|
||||||
if ((event->y() > fl->m_rect.y()) && (event->y()) < (fl->m_rect.y() + fl->m_rect.height())) {
|
if ((event->y() > fl->m_rect.y()) && (event->y()) < (fl->m_rect.y() + fl->m_rect.height())) {
|
||||||
if (event->x() < lvisible[i]->m_rect.x()) {
|
if (event->x() < fl->m_rect.x()) {
|
||||||
// Display tooltip
|
// Display tooltip
|
||||||
QString ttip = schema::channel[fl->code()].fullname() + "\n" +
|
QString ttip = schema::channel[fl->code()].fullname() + "\n" +
|
||||||
schema::channel[fl->code()].description();
|
schema::channel[fl->code()].description();
|
||||||
@ -309,27 +305,26 @@ void gFlagsLine::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
int tooltipTimeout = AppSetting->tooltipTimeout();
|
int tooltipTimeout = AppSetting->tooltipTimeout();
|
||||||
|
|
||||||
bool hover = false;
|
bool hover = false;
|
||||||
for (QList<Session *>::iterator s = m_day->begin(); s != m_day->end(); s++) {
|
for (const auto & sess : m_day->sessions) {
|
||||||
if (!(*s)->enabled()) {
|
if (!sess->enabled()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
drift = ((*s)->type() == MT_CPAP) ? clockdrift : 0;
|
drift = (sess->type() == MT_CPAP) ? clockdrift : 0;
|
||||||
|
|
||||||
cei = (*s)->eventlist.find(m_code);
|
cei = sess->eventlist.find(m_code);
|
||||||
|
|
||||||
if (cei == (*s)->eventlist.end()) {
|
if (cei == sess->eventlist.end()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<EventList *> &evlist = cei.value();
|
|
||||||
|
|
||||||
for (int k = 0; k < evlist.size(); k++) {
|
for (const auto & el : cei.value()) {
|
||||||
EventList &el = *(evlist[k]);
|
|
||||||
start = el.first() + drift;
|
start = el->first() + drift;
|
||||||
tptr = el.rawTime();
|
tptr = el->rawTime();
|
||||||
dptr = el.rawData();
|
dptr = el->rawData();
|
||||||
int np = el.count();
|
int np = el->count();
|
||||||
eptr = dptr + np;
|
eptr = dptr + np;
|
||||||
|
|
||||||
for (idx = 0; dptr < eptr; dptr++, tptr++, idx++) {
|
for (idx = 0; dptr < eptr; dptr++, tptr++, idx++) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* gGraph Implemntation
|
/* gGraph Implemntation
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011-2018 Mark Watkins <mark@jedimark.net>
|
* Copyright (c) 2011-2018 Mark Watkins <mark@jedimark.net>
|
||||||
*
|
*
|
||||||
@ -116,8 +116,8 @@ void DestroyGraphGlobals()
|
|||||||
delete bigfont;
|
delete bigfont;
|
||||||
delete mediumfont;
|
delete mediumfont;
|
||||||
|
|
||||||
for (QHash<QString, QImage *>::iterator i = images.begin(); i != images.end(); i++) {
|
for (auto & image : images) {
|
||||||
delete i.value();
|
delete image;
|
||||||
}
|
}
|
||||||
|
|
||||||
globalsInitialized = false;
|
globalsInitialized = false;
|
||||||
@ -187,9 +187,9 @@ gGraph::gGraph(QString name, gGraphView *graphview, QString title, QString units
|
|||||||
}
|
}
|
||||||
gGraph::~gGraph()
|
gGraph::~gGraph()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_layers.size(); i++) {
|
for (auto & layer : m_layers) {
|
||||||
if (m_layers[i]->unref()) {
|
if (layer->unref()) {
|
||||||
delete m_layers[i];
|
delete layer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,16 +216,16 @@ void gGraph::Timeout()
|
|||||||
|
|
||||||
void gGraph::deselect()
|
void gGraph::deselect()
|
||||||
{
|
{
|
||||||
for (QVector<Layer *>::iterator l = m_layers.begin(); l != m_layers.end(); l++) {
|
for (auto & layer : m_layers) {
|
||||||
(*l)->deselect();
|
layer->deselect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool gGraph::isSelected()
|
bool gGraph::isSelected()
|
||||||
{
|
{
|
||||||
bool res = false;
|
bool res = false;
|
||||||
|
|
||||||
for (QVector<Layer *>::iterator l = m_layers.begin(); l != m_layers.end(); l++) {
|
for (const auto & layer : m_layers) {
|
||||||
res = (*l)->isSelected();
|
res = layer->isSelected();
|
||||||
|
|
||||||
if (res) { break; }
|
if (res) { break; }
|
||||||
}
|
}
|
||||||
@ -237,14 +237,13 @@ bool gGraph::isEmpty()
|
|||||||
{
|
{
|
||||||
bool empty = true;
|
bool empty = true;
|
||||||
|
|
||||||
for (QVector<Layer *>::iterator l = m_layers.begin(); l != m_layers.end(); l++) {
|
for (const auto & layer : m_layers) {
|
||||||
if (!(*l)->isEmpty()) {
|
if (!layer->isEmpty()) {
|
||||||
empty = false;
|
empty = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return empty;
|
return empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,8 +271,8 @@ void gGraph::setDay(Day *day)
|
|||||||
|
|
||||||
m_day = day;
|
m_day = day;
|
||||||
|
|
||||||
for (int i = 0; i < m_layers.size(); i++) {
|
for (auto & layer : m_layers) {
|
||||||
m_layers[i]->SetDay(day);
|
layer->SetDay(day);
|
||||||
}
|
}
|
||||||
|
|
||||||
rmin_y = rmax_y = 0;
|
rmin_y = rmax_y = 0;
|
||||||
@ -369,31 +368,27 @@ void gGraph::paint(QPainter &painter, const QRegion ®ion)
|
|||||||
|
|
||||||
// left = 0;
|
// left = 0;
|
||||||
|
|
||||||
for (int i = 0; i < m_layers.size(); i++) {
|
for (const auto & layer : m_layers) {
|
||||||
Layer *ll = m_layers[i];
|
if (!layer->visible()) { continue; }
|
||||||
|
|
||||||
if (!ll->visible()) { continue; }
|
tmp = layer->minimumHeight();// * m_graphview->printScaleY();
|
||||||
|
|
||||||
tmp = ll->minimumHeight();// * m_graphview->printScaleY();
|
if (layer->position() == LayerTop) { top += tmp; }
|
||||||
|
if (layer->position() == LayerBottom) { bottom += tmp * printScaleY(); }
|
||||||
if (ll->position() == LayerTop) { top += tmp; }
|
|
||||||
if (ll->position() == LayerBottom) { bottom += tmp * printScaleY(); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < m_layers.size(); i++) {
|
for (const auto & layer : m_layers) {
|
||||||
Layer *ll = m_layers[i];
|
if (!layer->visible()) { continue; }
|
||||||
|
|
||||||
if (!ll->visible()) { continue; }
|
tmp = layer->minimumWidth();
|
||||||
|
|
||||||
tmp = ll->minimumWidth();
|
|
||||||
tmp *= m_graphview->printScaleX();
|
tmp *= m_graphview->printScaleX();
|
||||||
tmp *= m_graphview->devicePixelRatio();
|
tmp *= m_graphview->devicePixelRatio();
|
||||||
|
|
||||||
if (ll->position() == LayerLeft) {
|
if (layer->position() == LayerLeft) {
|
||||||
QRect rect(originX + left, originY + top, tmp, height - top - bottom);
|
QRect rect(originX + left, originY + top, tmp, height - top - bottom);
|
||||||
ll->m_rect = rect;
|
layer->m_rect = rect;
|
||||||
// ll->paint(painter, *this, QRegion(rect));
|
// layer->paint(painter, *this, QRegion(rect));
|
||||||
left += tmp;
|
left += tmp;
|
||||||
#ifdef DEBUG_LAYOUT
|
#ifdef DEBUG_LAYOUT
|
||||||
QColor col = Qt::red;
|
QColor col = Qt::red;
|
||||||
@ -402,11 +397,11 @@ void gGraph::paint(QPainter &painter, const QRegion ®ion)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ll->position() == LayerRight) {
|
if (layer->position() == LayerRight) {
|
||||||
right += tmp;
|
right += tmp;
|
||||||
QRect rect(originX + width - right, originY + top, tmp, height - top - bottom);
|
QRect rect(originX + width - right, originY + top, tmp, height - top - bottom);
|
||||||
ll->m_rect = rect;
|
layer->m_rect = rect;
|
||||||
//ll->paint(painter, *this, QRegion(rect));
|
//layer->paint(painter, *this, QRegion(rect));
|
||||||
#ifdef DEBUG_LAYOUT
|
#ifdef DEBUG_LAYOUT
|
||||||
QColor col = Qt::red;
|
QColor col = Qt::red;
|
||||||
painter.setPen(col);
|
painter.setPen(col);
|
||||||
@ -418,25 +413,23 @@ void gGraph::paint(QPainter &painter, const QRegion ®ion)
|
|||||||
bottom = marginBottom() * printScaleY();
|
bottom = marginBottom() * printScaleY();
|
||||||
top = marginTop();
|
top = marginTop();
|
||||||
|
|
||||||
for (int i = 0; i < m_layers.size(); i++) {
|
for (const auto & layer : m_layers) {
|
||||||
Layer *ll = m_layers[i];
|
if (!layer->visible()) { continue; }
|
||||||
|
|
||||||
if (!ll->visible()) { continue; }
|
tmp = layer->minimumHeight();
|
||||||
|
|
||||||
tmp = ll->minimumHeight();
|
if (layer->position() == LayerTop) {
|
||||||
|
|
||||||
if (ll->position() == LayerTop) {
|
|
||||||
QRect rect(originX + left, originY + top, width - left - right, tmp);
|
QRect rect(originX + left, originY + top, width - left - right, tmp);
|
||||||
ll->m_rect = rect;
|
layer->m_rect = rect;
|
||||||
ll->paint(painter, *this, QRegion(rect));
|
layer->paint(painter, *this, QRegion(rect));
|
||||||
top += tmp;
|
top += tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ll->position() == LayerBottom) {
|
if (layer->position() == LayerBottom) {
|
||||||
bottom += tmp * printScaleY();
|
bottom += tmp * printScaleY();
|
||||||
QRect rect(originX + left, originY + height - bottom, width - left - right, tmp);
|
QRect rect(originX + left, originY + height - bottom, width - left - right, tmp);
|
||||||
ll->m_rect = rect;
|
layer->m_rect = rect;
|
||||||
ll->paint(painter, *this, QRegion(rect));
|
layer->paint(painter, *this, QRegion(rect));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,25 +438,21 @@ void gGraph::paint(QPainter &painter, const QRegion ®ion)
|
|||||||
painter.fillRect(originX + left, originY + top, width - right, height - bottom - top, QBrush(QColor(Qt::white)));
|
painter.fillRect(originX + left, originY + top, width - right, height - bottom - top, QBrush(QColor(Qt::white)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < m_layers.size(); i++) {
|
for (const auto & layer : m_layers) {
|
||||||
Layer *ll = m_layers[i];
|
if (!layer->visible()) { continue; }
|
||||||
|
|
||||||
if (!ll->visible()) { continue; }
|
if (layer->position() == LayerCenter) {
|
||||||
|
|
||||||
if (ll->position() == LayerCenter) {
|
|
||||||
QRect rect(originX + left, originY + top, width - left - right, height - top - bottom);
|
QRect rect(originX + left, originY + top, width - left - right, height - top - bottom);
|
||||||
ll->m_rect = rect;
|
layer->m_rect = rect;
|
||||||
ll->paint(painter, *this, QRegion(rect));
|
layer->paint(painter, *this, QRegion(rect));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw anything like the YAxis labels afterwards, in case the graph scale was updated during draw
|
// Draw anything like the YAxis labels afterwards, in case the graph scale was updated during draw
|
||||||
for (int i = 0; i < m_layers.size(); i++) {
|
for (const auto & layer : m_layers) {
|
||||||
Layer *ll = m_layers[i];
|
if (!layer->visible()) { continue; }
|
||||||
|
if ((layer->position() == LayerLeft) || (layer->position() == LayerRight)) {
|
||||||
if (!ll->visible()) { continue; }
|
layer->paint(painter, *this, QRegion(layer->m_rect));
|
||||||
if ((ll->position() == LayerLeft) || (ll->position() == LayerRight)) {
|
|
||||||
ll->paint(painter, *this, QRegion(ll->m_rect));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -697,9 +686,8 @@ void gGraph::AddLayer(Layer *l, LayerPosition position, short width, short heigh
|
|||||||
|
|
||||||
void gGraph::dataChanged()
|
void gGraph::dataChanged()
|
||||||
{
|
{
|
||||||
int size = m_layers.size();
|
for (auto & layer : m_layers) {
|
||||||
for (int i=0; i < size; i++) {
|
layer->dataChanged();
|
||||||
m_layers[i]->dataChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -739,11 +727,10 @@ void gGraph::mouseMoveEvent(QMouseEvent *event)
|
|||||||
timedRedraw(0);
|
timedRedraw(0);
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < m_layers.size(); i++) {
|
for (const auto & layer : m_layers) {
|
||||||
if (m_layers[i]->m_rect.contains(x, y))
|
if (layer->m_rect.contains(x, y))
|
||||||
if (m_layers[i]->mouseMoveEvent(event, this)) {
|
if (layer->mouseMoveEvent(event, this)) {
|
||||||
return;
|
return;
|
||||||
// doredraw = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -754,7 +741,6 @@ void gGraph::mouseMoveEvent(QMouseEvent *event)
|
|||||||
|
|
||||||
int w = m_rect.width() - left - right;
|
int w = m_rect.width() - left - right;
|
||||||
|
|
||||||
|
|
||||||
double xx; //= max_x - min_x;
|
double xx; //= max_x - min_x;
|
||||||
double xmult;// = xx / double(w);
|
double xmult;// = xx / double(w);
|
||||||
|
|
||||||
@ -888,9 +874,9 @@ void gGraph::mousePressEvent(QMouseEvent *event)
|
|||||||
int y = event->pos().y();
|
int y = event->pos().y();
|
||||||
int x = event->pos().x();
|
int x = event->pos().x();
|
||||||
|
|
||||||
for (int i = 0; i < m_layers.size(); i++) {
|
for (const auto & layer : m_layers) {
|
||||||
if (m_layers[i]->m_rect.contains(x, y))
|
if (layer->m_rect.contains(x, y))
|
||||||
if (m_layers[i]->mousePressEvent(event, this)) {
|
if (layer->mousePressEvent(event, this)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -914,9 +900,9 @@ void gGraph::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
int y = event->pos().y();
|
int y = event->pos().y();
|
||||||
int x = event->pos().x();
|
int x = event->pos().x();
|
||||||
|
|
||||||
for (int i = 0; i < m_layers.size(); i++) {
|
for (const auto & layer : m_layers) {
|
||||||
if (m_layers[i]->m_rect.contains(x, y))
|
if (layer->m_rect.contains(x, y))
|
||||||
if (m_layers[i]->mouseReleaseEvent(event, this)) {
|
if (layer->mouseReleaseEvent(event, this)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -924,14 +910,12 @@ void gGraph::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
x -= m_rect.left();
|
x -= m_rect.left();
|
||||||
y -= m_rect.top();
|
y -= m_rect.top();
|
||||||
|
|
||||||
|
|
||||||
int w = m_rect.width() - left - right; //(m_marginleft+left+right+m_marginright);
|
int w = m_rect.width() - left - right; //(m_marginleft+left+right+m_marginright);
|
||||||
int h = m_rect.height() - bottom; //+m_marginbottom);
|
int h = m_rect.height() - bottom; //+m_marginbottom);
|
||||||
|
|
||||||
int x2 = m_graphview->pointClicked().x() - m_rect.left();
|
int x2 = m_graphview->pointClicked().x() - m_rect.left();
|
||||||
//int y2 = m_graphview->pointClicked().y() - m_rect.top();
|
//int y2 = m_graphview->pointClicked().y() - m_rect.top();
|
||||||
|
|
||||||
|
|
||||||
m_selDurString = QString();
|
m_selDurString = QString();
|
||||||
|
|
||||||
//qDebug() << m_title << "Released" << min_x << max_x << x << y << x2 << y2 << left << right << top << bottom << m_width << m_height;
|
//qDebug() << m_title << "Released" << min_x << max_x << x << y << x2 << y2 << left << right << top << bottom << m_width << m_height;
|
||||||
@ -1091,9 +1075,9 @@ void gGraph::wheelEvent(QWheelEvent *event)
|
|||||||
int y = event->pos().y();
|
int y = event->pos().y();
|
||||||
x = event->pos().x();
|
x = event->pos().x();
|
||||||
|
|
||||||
for (int i = 0; i < m_layers.size(); i++) {
|
for (const auto & layer : m_layers) {
|
||||||
if (m_layers[i]->m_rect.contains(x, y)) {
|
if (layer->m_rect.contains(x, y)) {
|
||||||
m_layers[i]->wheelEvent(event, this);
|
layer->wheelEvent(event, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1105,9 +1089,9 @@ void gGraph::mouseDoubleClickEvent(QMouseEvent *event)
|
|||||||
int y = event->pos().y();
|
int y = event->pos().y();
|
||||||
int x = event->pos().x();
|
int x = event->pos().x();
|
||||||
|
|
||||||
for (int i = 0; i < m_layers.size(); i++) {
|
for (const auto & layer : m_layers) {
|
||||||
if (m_layers[i]->m_rect.contains(x, y)) {
|
if (layer->m_rect.contains(x, y)) {
|
||||||
m_layers[i]->mouseDoubleClickEvent(event, this);
|
layer->mouseDoubleClickEvent(event, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1131,8 +1115,8 @@ void gGraph::mouseDoubleClickEvent(QMouseEvent *event)
|
|||||||
}
|
}
|
||||||
void gGraph::keyPressEvent(QKeyEvent *event)
|
void gGraph::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
for (QVector<Layer *>::iterator i = m_layers.begin(); i != m_layers.end(); i++) {
|
for (const auto & layer : m_layers) {
|
||||||
(*i)->keyPressEvent(event, this);
|
layer->keyPressEvent(event, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//qDebug() << m_title << "Key Pressed.. implement me" << event->key();
|
//qDebug() << m_title << "Key Pressed.. implement me" << event->key();
|
||||||
@ -1225,12 +1209,12 @@ qint64 gGraph::MinX()
|
|||||||
{
|
{
|
||||||
qint64 val = 0, tmp;
|
qint64 val = 0, tmp;
|
||||||
|
|
||||||
for (QVector<Layer *>::iterator l = m_layers.begin(); l != m_layers.end(); l++) {
|
for (const auto & layer : m_layers) {
|
||||||
if ((*l)->isEmpty()) {
|
if (layer->isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = (*l)->Minx();
|
tmp = layer->Minx();
|
||||||
|
|
||||||
if (!tmp) {
|
if (!tmp) {
|
||||||
continue;
|
continue;
|
||||||
@ -1250,15 +1234,15 @@ qint64 gGraph::MaxX()
|
|||||||
//bool first=true;
|
//bool first=true;
|
||||||
qint64 val = 0, tmp;
|
qint64 val = 0, tmp;
|
||||||
|
|
||||||
for (QVector<Layer *>::iterator l = m_layers.begin(); l != m_layers.end(); l++) {
|
for (const auto & layer : m_layers) {
|
||||||
if ((*l)->isEmpty()) {
|
if (layer->isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = (*l)->Maxx();
|
tmp = layer->Maxx();
|
||||||
|
|
||||||
//if (!tmp) continue;
|
//if (!tmp) continue;
|
||||||
if (!val || tmp > val) {
|
if (!val || (tmp > val)) {
|
||||||
val = tmp;
|
val = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1277,12 +1261,12 @@ EventDataType gGraph::MinY()
|
|||||||
return rmin_y = f_miny;
|
return rmin_y = f_miny;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (QVector<Layer *>::iterator l = m_layers.begin(); l != m_layers.end(); l++) {
|
for (const auto & layer : m_layers) {
|
||||||
if ((*l)->isEmpty() || ((*l)->layerType() == LT_Other)) {
|
if (layer->isEmpty() || (layer->layerType() == LT_Other)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = (*l)->Miny();
|
tmp = layer->Miny();
|
||||||
|
|
||||||
// if (tmp == 0 && tmp == (*l)->Maxy()) {
|
// if (tmp == 0 && tmp == (*l)->Maxy()) {
|
||||||
// continue;
|
// continue;
|
||||||
@ -1309,9 +1293,7 @@ EventDataType gGraph::MaxY()
|
|||||||
return rmax_y = f_maxy;
|
return rmax_y = f_maxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<Layer *>::const_iterator iterEnd = m_layers.constEnd();
|
for (const auto & layer : m_layers) {
|
||||||
for (QVector<Layer *>::const_iterator iter = m_layers.constBegin(); iter != iterEnd; ++iter) {
|
|
||||||
Layer *layer = *iter;
|
|
||||||
if (layer->isEmpty() || (layer->layerType() == LT_Other)) {
|
if (layer->isEmpty() || (layer->layerType() == LT_Other)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1341,9 +1323,7 @@ EventDataType gGraph::physMinY()
|
|||||||
|
|
||||||
//if (m_enforceMinY) return rmin_y=f_miny;
|
//if (m_enforceMinY) return rmin_y=f_miny;
|
||||||
|
|
||||||
QVector<Layer *>::const_iterator iterEnd = m_layers.constEnd();
|
for (const auto & layer : m_layers) {
|
||||||
for (QVector<Layer *>::const_iterator iter = m_layers.constBegin(); iter != iterEnd; ++iter) {
|
|
||||||
Layer *layer = *iter;
|
|
||||||
if (layer->isEmpty()) {
|
if (layer->isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1372,9 +1352,7 @@ EventDataType gGraph::physMaxY()
|
|||||||
|
|
||||||
// if (m_enforceMaxY) return rmax_y=f_maxy;
|
// if (m_enforceMaxY) return rmax_y=f_maxy;
|
||||||
|
|
||||||
QVector<Layer *>::const_iterator iterEnd = m_layers.constEnd();
|
for (const auto & layer : m_layers) {
|
||||||
for (QVector<Layer *>::const_iterator iter = m_layers.constBegin(); iter != iterEnd; ++iter) {
|
|
||||||
Layer *layer = *iter;
|
|
||||||
if (layer->isEmpty()) {
|
if (layer->isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1421,8 +1399,8 @@ Layer *gGraph::getLineChart()
|
|||||||
{
|
{
|
||||||
gLineChart *lc;
|
gLineChart *lc;
|
||||||
|
|
||||||
for (int i = 0; i < m_layers.size(); i++) {
|
for (auto & layer : m_layers) {
|
||||||
lc = dynamic_cast<gLineChart *>(m_layers[i]);
|
lc = dynamic_cast<gLineChart *>(layer);
|
||||||
|
|
||||||
if (lc) { return lc; }
|
if (lc) { return lc; }
|
||||||
}
|
}
|
||||||
@ -1436,8 +1414,8 @@ int gGraph::minHeight()
|
|||||||
// int top = 0;
|
// int top = 0;
|
||||||
// int center = 0;
|
// int center = 0;
|
||||||
// int bottom = 0;
|
// int bottom = 0;
|
||||||
for (int i=0; i<m_layers.size(); ++i) {
|
for (const auto & layer : m_layers) {
|
||||||
int mh = m_layers[i]->minimumHeight();
|
int mh = layer->minimumHeight();
|
||||||
mh += m_margintop + m_marginbottom;
|
mh += m_margintop + m_marginbottom;
|
||||||
if (mh > minheight) minheight = mh;
|
if (mh > minheight) minheight = mh;
|
||||||
}
|
}
|
||||||
@ -1452,13 +1430,11 @@ int GetXHeight(QFont *font)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void gGraph::dumpInfo() {
|
void gGraph::dumpInfo() {
|
||||||
for (int i = 0; i < m_layers.size(); i++) {
|
for (const auto & layer : m_layers) {
|
||||||
Layer *ll = m_layers[i];
|
if (!layer->visible()) { continue; }
|
||||||
|
|
||||||
if (!ll->visible()) { continue; }
|
if (layer->position() == LayerCenter) {
|
||||||
|
gLineChart *lc = dynamic_cast<gLineChart *>(layer);
|
||||||
if (ll->position() == LayerCenter) {
|
|
||||||
gLineChart *lc = dynamic_cast<gLineChart *>(ll);
|
|
||||||
if (lc != nullptr) {
|
if (lc != nullptr) {
|
||||||
QString text = lc->getMetaString(currentTime());
|
QString text = lc->getMetaString(currentTime());
|
||||||
if (!text.isEmpty()) {
|
if (!text.isEmpty()) {
|
||||||
|
@ -266,8 +266,8 @@ void gGraphView::queGraph(gGraph *g, int left, int top, int width, int height)
|
|||||||
void gGraphView::trashGraphs(bool destroy)
|
void gGraphView::trashGraphs(bool destroy)
|
||||||
{
|
{
|
||||||
if (destroy) {
|
if (destroy) {
|
||||||
for (int i=0; i< m_graphs.size(); ++i) {
|
for (auto & graph : m_graphs) {
|
||||||
delete m_graphs[i];
|
delete graph;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Don't actually want to delete them here.. we are just borrowing the graphs
|
// Don't actually want to delete them here.. we are just borrowing the graphs
|
||||||
@ -505,15 +505,14 @@ void gGraphView::popoutGraph()
|
|||||||
gv->m_graphsbyname[newname] = newgraph;
|
gv->m_graphsbyname[newname] = newgraph;
|
||||||
newgraph->m_graphview = gv;
|
newgraph->m_graphview = gv;
|
||||||
|
|
||||||
for (int i=0; i < graph->m_layers.size(); ++i) {
|
for (auto & l : graph->m_layers) {
|
||||||
Layer * layer = graph->m_layers.at(i)->Clone();
|
Layer * layer = l->Clone();
|
||||||
if (layer) {
|
if (layer) {
|
||||||
newgraph->m_layers.append(layer);
|
newgraph->m_layers.append(layer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0;i<m_graphs.size();i++) {
|
for (auto & g : m_graphs) {
|
||||||
gGraph *g = m_graphs.at(i);
|
|
||||||
group = qMax(g->group(), group);
|
group = qMax(g->group(), group);
|
||||||
}
|
}
|
||||||
newgraph->setGroup(group+1);
|
newgraph->setGroup(group+1);
|
||||||
@ -578,7 +577,7 @@ gGraphView::~gGraphView()
|
|||||||
|
|
||||||
#ifdef ENABLE_THREADED_DRAWING
|
#ifdef ENABLE_THREADED_DRAWING
|
||||||
|
|
||||||
for (int i = 0; i < m_threads.size(); i++) {
|
for (int i=0; i < m_threads.size(); i++) {
|
||||||
delete m_threads[i];
|
delete m_threads[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,8 +585,7 @@ gGraphView::~gGraphView()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Note: This will cause a crash if two graphs accidentally have the same name
|
// Note: This will cause a crash if two graphs accidentally have the same name
|
||||||
for (QList<gGraph *>::iterator g = m_graphs.begin(); g!= m_graphs.end(); ++g) {
|
for (auto & graph : m_graphs) {
|
||||||
gGraph * graph = *g;
|
|
||||||
delete graph;
|
delete graph;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -616,17 +614,17 @@ bool gGraphView::pinchTriggered(QPinchGesture * gesture)
|
|||||||
{
|
{
|
||||||
gGraph * graph = nullptr;
|
gGraph * graph = nullptr;
|
||||||
int group =0;
|
int group =0;
|
||||||
if (!graph) {
|
// if (!graph) {
|
||||||
// just pick any graph then
|
// just pick any graph then
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (const auto & g : m_graphs) {
|
||||||
if (!m_graphs[i]) continue;
|
if (!g) continue;
|
||||||
if (!m_graphs[i]->isEmpty()) {
|
if (!g->isEmpty()) {
|
||||||
graph = m_graphs[i];
|
graph = g;
|
||||||
group = graph->group();
|
group = graph->group();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else group=graph->group();
|
// } else group=graph->group();
|
||||||
|
|
||||||
if (!graph) { return true; }
|
if (!graph) { return true; }
|
||||||
|
|
||||||
@ -694,10 +692,8 @@ void gGraphView::dumpInfo()
|
|||||||
mainwin->log(QString("Available Channels for %1").arg(dt.toString("MMM dd yyyy")));
|
mainwin->log(QString("Available Channels for %1").arg(dt.toString("MMM dd yyyy")));
|
||||||
QHash<schema::ChanType, QList<schema::Channel *> > list;
|
QHash<schema::ChanType, QList<schema::Channel *> > list;
|
||||||
|
|
||||||
for (int i=0; i< day->size(); ++i) {
|
for (const auto & sess : day->sessions) {
|
||||||
Session * sess = day->sessions.at(i);
|
for (auto it=sess->eventlist.begin(), end=sess->eventlist.end(); it != end; ++it) {
|
||||||
QHash<ChannelID, QVector<EventList *> >::iterator it;
|
|
||||||
for (it = sess->eventlist.begin(); it != sess->eventlist.end(); ++it) {
|
|
||||||
ChannelID code = it.key();
|
ChannelID code = it.key();
|
||||||
schema::Channel * chan = &schema::channel[code];
|
schema::Channel * chan = &schema::channel[code];
|
||||||
list[chan->type()].append(chan);
|
list[chan->type()].append(chan);
|
||||||
@ -705,7 +701,7 @@ void gGraphView::dumpInfo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QHash<schema::ChanType, QList<schema::Channel *> >::iterator lit;
|
QHash<schema::ChanType, QList<schema::Channel *> >::iterator lit;
|
||||||
for (lit = list.begin(); lit != list.end(); ++lit) {
|
for (auto lit = list.begin(), end=list.end(); lit != end; ++lit) {
|
||||||
switch (lit.key()) {
|
switch (lit.key()) {
|
||||||
case schema::DATA:
|
case schema::DATA:
|
||||||
text = "DATA: ";
|
text = "DATA: ";
|
||||||
@ -732,8 +728,8 @@ void gGraphView::dumpInfo()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
QStringList str;
|
QStringList str;
|
||||||
for (int i=0; i< lit.value().size(); ++i) {
|
for (const auto & chan : lit.value()) {
|
||||||
str.append(lit.value().at(i)->code());
|
str.append(chan->code());
|
||||||
}
|
}
|
||||||
str.sort();
|
str.sort();
|
||||||
text.append(str.join(", "));
|
text.append(str.join(", "));
|
||||||
@ -825,13 +821,9 @@ void gGraphView::DrawTextQue(QPainter &painter)
|
|||||||
{
|
{
|
||||||
{
|
{
|
||||||
// process the text drawing queue
|
// process the text drawing queue
|
||||||
int m_textque_items = m_textque.size();
|
|
||||||
|
|
||||||
int h,w;
|
int h,w;
|
||||||
|
|
||||||
for (int i = 0; i < m_textque_items; ++i) {
|
for (const auto & q : m_textque) {
|
||||||
const TextQue &q = m_textque.at(i);
|
|
||||||
|
|
||||||
// can do antialiased text via texture cache fine on mac
|
// can do antialiased text via texture cache fine on mac
|
||||||
if (usePixmapCache()) {
|
if (usePixmapCache()) {
|
||||||
// Generate the pixmap cache "key"
|
// Generate the pixmap cache "key"
|
||||||
@ -919,12 +911,9 @@ void gGraphView::DrawTextQue(QPainter &painter)
|
|||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Text Rectangle Queues..
|
// Text Rectangle Queues..
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
int items = m_textqueRect.size();
|
|
||||||
|
|
||||||
float ww, hh;
|
float ww, hh;
|
||||||
for (int i = 0; i < items; ++i) {
|
for (const auto & q : m_textqueRect) {
|
||||||
const TextQueRect &q = m_textqueRect.at(i);
|
|
||||||
|
|
||||||
// can do antialiased text via texture cache fine on mac
|
// can do antialiased text via texture cache fine on mac
|
||||||
if (usePixmapCache()) {
|
if (usePixmapCache()) {
|
||||||
// Generate the pixmap cache "key"
|
// Generate the pixmap cache "key"
|
||||||
@ -1065,8 +1054,7 @@ float gGraphView::totalHeight()
|
|||||||
{
|
{
|
||||||
float th = 0;
|
float th = 0;
|
||||||
|
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (const auto & g : m_graphs) {
|
||||||
gGraph * g = m_graphs[i];
|
|
||||||
if (g->isEmpty() || (!g->visible())) { continue; }
|
if (g->isEmpty() || (!g->visible())) { continue; }
|
||||||
|
|
||||||
th += g->height() + graphSpacer;
|
th += g->height() + graphSpacer;
|
||||||
@ -1079,12 +1067,12 @@ float gGraphView::findTop(gGraph *graph)
|
|||||||
{
|
{
|
||||||
float th = -m_offsetY;
|
float th = -m_offsetY;
|
||||||
|
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (const auto & g : m_graphs) {
|
||||||
if (m_graphs[i] == graph) { break; }
|
if (g == graph) { break; }
|
||||||
|
|
||||||
if (m_graphs[i]->isEmpty() || (!m_graphs[i]->visible())) { continue; }
|
if (g->isEmpty() || (!g->visible())) { continue; }
|
||||||
|
|
||||||
th += m_graphs[i]->height() * m_scaleY + graphSpacer;
|
th += g->height() * m_scaleY + graphSpacer;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ceil(th);
|
return ceil(th);
|
||||||
@ -1094,10 +1082,10 @@ float gGraphView::scaleHeight()
|
|||||||
{
|
{
|
||||||
float th = 0;
|
float th = 0;
|
||||||
|
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (const auto & graph : m_graphs) {
|
||||||
if (m_graphs[i]->isEmpty() || (!m_graphs[i]->visible())) { continue; }
|
if (graph->isEmpty() || (!graph->visible())) { continue; }
|
||||||
|
|
||||||
th += m_graphs[i]->height() * m_scaleY + graphSpacer;
|
th += graph->height() * m_scaleY + graphSpacer;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ceil(th);
|
return ceil(th);
|
||||||
@ -1136,8 +1124,8 @@ void gGraphView::resizeEvent(QResizeEvent *e)
|
|||||||
updateScale();
|
updateScale();
|
||||||
|
|
||||||
if (m_scaleY > 0.0001) {
|
if (m_scaleY > 0.0001) {
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (auto & graph : m_graphs) {
|
||||||
m_graphs[i]->resize(e->size().width(), m_graphs[i]->height() * m_scaleY);
|
graph->resize(e->size().width(), graph->height() * m_scaleY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
e->accept();
|
e->accept();
|
||||||
@ -1158,20 +1146,13 @@ void gGraphView::scrollbarValueChanged(int val)
|
|||||||
|
|
||||||
void gGraphView::GetRXBounds(qint64 &st, qint64 &et)
|
void gGraphView::GetRXBounds(qint64 &st, qint64 &et)
|
||||||
{
|
{
|
||||||
//qint64 m1=0,m2=0;
|
for (const auto & graph : m_graphs) {
|
||||||
gGraph *g = nullptr;
|
if (graph->group() == 0) {
|
||||||
|
st = graph->rmin_x;
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
et = graph->rmax_x;
|
||||||
g = m_graphs[i];
|
|
||||||
|
|
||||||
if (g->group() == 0) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (g) {
|
|
||||||
st = g->rmin_x;
|
|
||||||
et = g->rmax_x;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gGraphView::ResetBounds(bool refresh) //short group)
|
void gGraphView::ResetBounds(bool refresh) //short group)
|
||||||
@ -1179,18 +1160,18 @@ void gGraphView::ResetBounds(bool refresh) //short group)
|
|||||||
if (m_graphs.size() == 0) return;
|
if (m_graphs.size() == 0) return;
|
||||||
Q_UNUSED(refresh)
|
Q_UNUSED(refresh)
|
||||||
qint64 m1 = 0, m2 = 0;
|
qint64 m1 = 0, m2 = 0;
|
||||||
gGraph *g = nullptr;
|
gGraph *graph = nullptr;
|
||||||
|
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (auto & g : m_graphs) {
|
||||||
m_graphs[i]->ResetBounds();
|
g->ResetBounds();
|
||||||
|
|
||||||
if (!m_graphs[i]->min_x) { continue; }
|
if (!g->min_x) { continue; }
|
||||||
|
|
||||||
g = m_graphs[i];
|
graph = g;
|
||||||
|
|
||||||
if (!m1 || m_graphs[i]->min_x < m1) { m1 = m_graphs[i]->min_x; }
|
if (!m1 || g->min_x < m1) { m1 = g->min_x; }
|
||||||
|
|
||||||
if (!m2 || m_graphs[i]->max_x > m2) { m2 = m_graphs[i]->max_x; }
|
if (!m2 || g->max_x > m2) { m2 = g->max_x; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (p_profile->general->linkGroups()) {
|
// if (p_profile->general->linkGroups()) {
|
||||||
@ -1200,12 +1181,12 @@ void gGraphView::ResetBounds(bool refresh) //short group)
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (!g) {
|
if (!graph) {
|
||||||
g = m_graphs[0];
|
graph = m_graphs[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
m_minx = g->min_x;
|
m_minx = graph->min_x;
|
||||||
m_maxx = g->max_x;
|
m_maxx = graph->max_x;
|
||||||
|
|
||||||
updateScale();
|
updateScale();
|
||||||
}
|
}
|
||||||
@ -1218,9 +1199,9 @@ void gGraphView::GetXBounds(qint64 &st, qint64 &et)
|
|||||||
|
|
||||||
void gGraphView::SetXBounds(qint64 minx, qint64 maxx, short group, bool refresh)
|
void gGraphView::SetXBounds(qint64 minx, qint64 maxx, short group, bool refresh)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (auto & graph : m_graphs) {
|
||||||
if ((m_graphs[i]->group() == group)) {
|
if ((graph->group() == group)) {
|
||||||
m_graphs[i]->SetXBounds(minx, maxx);
|
graph->SetXBounds(minx, maxx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1241,8 +1222,8 @@ void gGraphView::updateScrollBar()
|
|||||||
|
|
||||||
float vis = 0;
|
float vis = 0;
|
||||||
|
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (const auto & graph : m_graphs) {
|
||||||
vis += (m_graphs[i]->isEmpty() || !m_graphs[i]->visible()) ? 0 : 1;
|
vis += (graph->isEmpty() || !graph->visible()) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (th < h) { // less graphs than fits on screen
|
if (th < h) { // less graphs than fits on screen
|
||||||
@ -1304,10 +1285,8 @@ bool gGraphView::renderGraphs(QPainter &painter)
|
|||||||
|
|
||||||
float pinned_height = 0; // pixel height total
|
float pinned_height = 0; // pixel height total
|
||||||
int pinned_graphs = 0; // count
|
int pinned_graphs = 0; // count
|
||||||
gGraph * g = nullptr;
|
|
||||||
|
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (auto & g : m_graphs) {
|
||||||
g = m_graphs[i];
|
|
||||||
int minh = g->minHeight();
|
int minh = g->minHeight();
|
||||||
if (g->height() < minh) {
|
if (g->height() < minh) {
|
||||||
g->setHeight(minh);
|
g->setHeight(minh);
|
||||||
@ -1326,8 +1305,7 @@ bool gGraphView::renderGraphs(QPainter &painter)
|
|||||||
py += pinned_height; // start drawing at the end of pinned space
|
py += pinned_height; // start drawing at the end of pinned space
|
||||||
|
|
||||||
// Draw non pinned graphs
|
// Draw non pinned graphs
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (auto & g : m_graphs) {
|
||||||
g = m_graphs[i];
|
|
||||||
if (g->isEmpty()) { continue; }
|
if (g->isEmpty()) { continue; }
|
||||||
|
|
||||||
if (!g->visible()) { continue; }
|
if (!g->visible()) { continue; }
|
||||||
@ -1367,13 +1345,10 @@ bool gGraphView::renderGraphs(QPainter &painter)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Physically draw the unpinned graphs
|
// Physically draw the unpinned graphs
|
||||||
int s = m_drawlist.size();
|
for (const auto & g : m_drawlist) {
|
||||||
|
|
||||||
for (int i = 0; i < s; i++) {
|
|
||||||
g = m_drawlist.at(0);
|
|
||||||
m_drawlist.pop_front();
|
|
||||||
g->paint(painter, QRegion(g->m_rect));
|
g->paint(painter, QRegion(g->m_rect));
|
||||||
}
|
}
|
||||||
|
m_drawlist.clear();
|
||||||
|
|
||||||
if (m_graphs.size() > 1) {
|
if (m_graphs.size() > 1) {
|
||||||
DrawTextQue(painter);
|
DrawTextQue(painter);
|
||||||
@ -1389,8 +1364,7 @@ bool gGraphView::renderGraphs(QPainter &painter)
|
|||||||
py = 0; // start drawing at top...
|
py = 0; // start drawing at top...
|
||||||
|
|
||||||
// Draw Pinned graphs
|
// Draw Pinned graphs
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (const auto & g : m_graphs) {
|
||||||
g = m_graphs[i];
|
|
||||||
if (g->isEmpty()) { continue; }
|
if (g->isEmpty()) { continue; }
|
||||||
|
|
||||||
if (!g->visible()) { continue; }
|
if (!g->visible()) { continue; }
|
||||||
@ -1439,13 +1413,10 @@ bool gGraphView::renderGraphs(QPainter &painter)
|
|||||||
masterlock->release(m_idealthreads);
|
masterlock->release(m_idealthreads);
|
||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
s = m_drawlist.size();
|
for (const auto & g : m_drawlist) {
|
||||||
|
|
||||||
for (int i = 0; i < s; i++) {
|
|
||||||
g = m_drawlist.at(0);
|
|
||||||
m_drawlist.pop_front();
|
|
||||||
g->paint(painter, QRegion(g->m_rect));
|
g->paint(painter, QRegion(g->m_rect));
|
||||||
}
|
}
|
||||||
|
m_drawlist.clear();
|
||||||
|
|
||||||
#ifdef ENABLED_THREADED_DRAWING
|
#ifdef ENABLED_THREADED_DRAWING
|
||||||
}
|
}
|
||||||
@ -1776,22 +1747,22 @@ void gGraphView::mouseMoveEvent(QMouseEvent *event)
|
|||||||
bool done = false;
|
bool done = false;
|
||||||
|
|
||||||
// Do pinned graphs first
|
// Do pinned graphs first
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (const auto & graph : m_graphs) {
|
||||||
|
|
||||||
if (m_graphs[i]->isEmpty() || !m_graphs[i]->visible() || !m_graphs[i]->isPinned()) {
|
if (graph->isEmpty() || !graph->visible() || !graph->isPinned()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
h = m_graphs[i]->height() * m_scaleY;
|
h = graph->height() * m_scaleY;
|
||||||
pinned_height += h + graphSpacer;
|
pinned_height += h + graphSpacer;
|
||||||
|
|
||||||
if (py > height()) {
|
if (py > height()) {
|
||||||
break; // we are done.. can't draw anymore
|
break; // we are done.. can't draw anymore
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!((y >= py + m_graphs[i]->top) && (y < py + h - m_graphs[i]->bottom))) {
|
if (!((y >= py + graph->top) && (y < py + h - graph->bottom))) {
|
||||||
if (m_graphs[i]->isSelected()) {
|
if (graph->isSelected()) {
|
||||||
m_graphs[i]->deselect();
|
graph->deselect();
|
||||||
timedRedraw(150);
|
timedRedraw(150);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1817,7 +1788,7 @@ void gGraphView::mouseMoveEvent(QMouseEvent *event)
|
|||||||
// QPoint p(x,y);
|
// QPoint p(x,y);
|
||||||
// QMouseEvent e(event->type(),p,event->button(),event->buttons(),event->modifiers());
|
// QMouseEvent e(event->type(),p,event->button(),event->buttons(),event->modifiers());
|
||||||
|
|
||||||
m_graphs[i]->mouseMoveEvent(event);
|
graph->mouseMoveEvent(event);
|
||||||
|
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
@ -1831,21 +1802,21 @@ void gGraphView::mouseMoveEvent(QMouseEvent *event)
|
|||||||
|
|
||||||
// Propagate mouseMove events to relevant graphs
|
// Propagate mouseMove events to relevant graphs
|
||||||
if (!done)
|
if (!done)
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (const auto & graph : m_graphs) {
|
||||||
|
|
||||||
if (m_graphs[i]->isEmpty() || !m_graphs[i]->visible() || m_graphs[i]->isPinned()) {
|
if (graph->isEmpty() || !graph->visible() || graph->isPinned()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
h = m_graphs[i]->height() * m_scaleY;
|
h = graph->height() * m_scaleY;
|
||||||
|
|
||||||
if (py > height()) {
|
if (py > height()) {
|
||||||
break; // we are done.. can't draw anymore
|
break; // we are done.. can't draw anymore
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!((y >= py + m_graphs[i]->top) && (y < py + h - m_graphs[i]->bottom))) {
|
if (!((y >= py + graph->top) && (y < py + h - graph->bottom))) {
|
||||||
if (m_graphs[i]->isSelected()) {
|
if (graph->isSelected()) {
|
||||||
m_graphs[i]->deselect();
|
graph->deselect();
|
||||||
timedRedraw(150);
|
timedRedraw(150);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1867,11 +1838,9 @@ void gGraphView::mouseMoveEvent(QMouseEvent *event)
|
|||||||
m_horiz_travel += qAbs(x - m_lastxpos) + qAbs(y - m_lastypos);
|
m_horiz_travel += qAbs(x - m_lastxpos) + qAbs(y - m_lastypos);
|
||||||
m_lastxpos = x;
|
m_lastxpos = x;
|
||||||
m_lastypos = y;
|
m_lastypos = y;
|
||||||
gGraph *g = m_graphs[i];
|
if (graph) {
|
||||||
if (g) {
|
graph->mouseMoveEvent(event);
|
||||||
g->mouseMoveEvent(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else if (!m_button_down && (y >= py) && (y < py+m_graphs[i]->top)) {
|
/* else if (!m_button_down && (y >= py) && (y < py+m_graphs[i]->top)) {
|
||||||
@ -1936,10 +1905,9 @@ void gGraphView::mouseMoveEvent(QMouseEvent *event)
|
|||||||
|
|
||||||
Layer * gGraphView::findLayer(gGraph * graph, LayerType type)
|
Layer * gGraphView::findLayer(gGraph * graph, LayerType type)
|
||||||
{
|
{
|
||||||
for (int i=0; i< graph->layers().size(); i++) {
|
for (auto & layer : graph->m_layers) {
|
||||||
Layer * l = graph->layers()[i];
|
if (layer->layerType() == type) {
|
||||||
if (l->layerType() == type) {
|
return layer;
|
||||||
return l;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -2020,8 +1988,6 @@ void MinMaxWidget::onComboChanged(int idx)
|
|||||||
|
|
||||||
void MinMaxWidget::createLayout()
|
void MinMaxWidget::createLayout()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
QGridLayout * layout = new QGridLayout;
|
QGridLayout * layout = new QGridLayout;
|
||||||
layout->setMargin(4);
|
layout->setMargin(4);
|
||||||
layout->setSpacing(4);
|
layout->setSpacing(4);
|
||||||
@ -2106,7 +2072,6 @@ void gGraphView::populateMenu(gGraph * graph)
|
|||||||
{
|
{
|
||||||
QAction * action;
|
QAction * action;
|
||||||
|
|
||||||
|
|
||||||
if (graph->isSnapshot()) {
|
if (graph->isSnapshot()) {
|
||||||
snap_action->setText(tr("Remove Clone"));
|
snap_action->setText(tr("Remove Clone"));
|
||||||
snap_action->setData(graph->name()+"|remove");
|
snap_action->setData(graph->name()+"|remove");
|
||||||
@ -2117,7 +2082,6 @@ void gGraphView::populateMenu(gGraph * graph)
|
|||||||
// zoom100_action->setVisible(true);
|
// zoom100_action->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Menu title fonts
|
// Menu title fonts
|
||||||
QFont font = QApplication::font();
|
QFont font = QApplication::font();
|
||||||
font.setBold(true);
|
font.setBold(true);
|
||||||
@ -2127,7 +2091,6 @@ void gGraphView::populateMenu(gGraph * graph)
|
|||||||
SummaryChart * sc = dynamic_cast<SummaryChart *>(findLayer(graph,LT_SummaryChart));
|
SummaryChart * sc = dynamic_cast<SummaryChart *>(findLayer(graph,LT_SummaryChart));
|
||||||
gSummaryChart * stg = dynamic_cast<gSummaryChart *>(findLayer(graph,LT_Overview));
|
gSummaryChart * stg = dynamic_cast<gSummaryChart *>(findLayer(graph,LT_Overview));
|
||||||
|
|
||||||
|
|
||||||
limits_menu->clear();
|
limits_menu->clear();
|
||||||
if (lc || sc || stg) {
|
if (lc || sc || stg) {
|
||||||
QWidgetAction * widget = new QWidgetAction(this);
|
QWidgetAction * widget = new QWidgetAction(this);
|
||||||
@ -2141,12 +2104,11 @@ void gGraphView::populateMenu(gGraph * graph)
|
|||||||
limits_menu->menuAction()->setVisible(false);
|
limits_menu->menuAction()->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// First check for any linechart for this graph..
|
// First check for any linechart for this graph..
|
||||||
if (lc) {
|
if (lc) {
|
||||||
lines_menu->clear();
|
lines_menu->clear();
|
||||||
for (int i=0; i < lc->m_dotlines.size(); i++) {
|
for (int i=0, end=lc->m_dotlines.size(); i < end; i++) {
|
||||||
DottedLine & dot = lc->m_dotlines[i];
|
const DottedLine & dot = lc->m_dotlines[i];
|
||||||
|
|
||||||
if (!lc->m_enabled[dot.code]) continue;
|
if (!lc->m_enabled[dot.code]) continue;
|
||||||
|
|
||||||
@ -2171,15 +2133,7 @@ void gGraphView::populateMenu(gGraph * graph)
|
|||||||
bool b = lc->m_dot_enabled[dot.code][dot.type]; //chan.calc[dot.type].enabled;
|
bool b = lc->m_dot_enabled[dot.code][dot.type]; //chan.calc[dot.type].enabled;
|
||||||
chbox->setChecked(b);
|
chbox->setChecked(b);
|
||||||
lines_menu->addAction(widget);
|
lines_menu->addAction(widget);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// QAction *action = lines_menu->addAction(chan.calc[dot.type].label());
|
|
||||||
// action->setData(graph->name());
|
|
||||||
// action->setCheckable(true);
|
|
||||||
// action->setChecked(chan.calc[dot.type].enabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lines_menu->menuAction()->setVisible(lines_menu->actions().size() > 0);
|
lines_menu->menuAction()->setVisible(lines_menu->actions().size() > 0);
|
||||||
@ -2194,45 +2148,35 @@ void gGraphView::populateMenu(gGraph * graph)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Populate Plots Menus
|
// Populate Plots Menus
|
||||||
//////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
plots_menu->clear();
|
plots_menu->clear();
|
||||||
|
|
||||||
if (lc->m_codes.size() > 1) {
|
for (const auto code : lc->m_codes) {
|
||||||
for (int i=0; i <lc->m_codes.size(); ++i) {
|
if (lc->m_day && !lc->m_day->channelHasData(code)) continue;
|
||||||
ChannelID code = lc->m_codes[i];
|
|
||||||
if (lc->m_day && !lc->m_day->channelHasData(code)) continue;
|
|
||||||
|
|
||||||
QWidgetAction * widget = new QWidgetAction(context_menu);
|
QWidgetAction * widget = new QWidgetAction(context_menu);
|
||||||
|
|
||||||
QCheckBox *chbox = new QCheckBox(schema::channel[code].label(), context_menu);
|
QCheckBox *chbox = new QCheckBox(schema::channel[code].label(), context_menu);
|
||||||
chbox->setMouseTracking(true);
|
chbox->setMouseTracking(true);
|
||||||
chbox->setToolTip(schema::channel[code].description());
|
chbox->setToolTip(schema::channel[code].description());
|
||||||
chbox->setStyleSheet(QString("QCheckBox:hover { background: %1; }").arg(QApplication::palette().highlight().color().name()));
|
chbox->setStyleSheet(QString("QCheckBox:hover { background: %1; }").arg(QApplication::palette().highlight().color().name()));
|
||||||
|
|
||||||
|
|
||||||
widget->setDefaultWidget(chbox);
|
widget->setDefaultWidget(chbox);
|
||||||
|
|
||||||
widget->setCheckable(true);
|
widget->setCheckable(true);
|
||||||
widget->setData(QString("%1|%2").arg(graph->name()).arg(code));
|
widget->setData(QString("%1|%2").arg(graph->name()).arg(code));
|
||||||
|
|
||||||
connect(chbox, SIGNAL(toggled(bool)), widget, SLOT(setChecked(bool)));
|
connect(chbox, SIGNAL(toggled(bool)), widget, SLOT(setChecked(bool)));
|
||||||
connect(chbox, SIGNAL(clicked()), widget, SLOT(trigger()));
|
connect(chbox, SIGNAL(clicked()), widget, SLOT(trigger()));
|
||||||
|
|
||||||
bool b = lc->m_enabled[code];
|
bool b = lc->m_enabled[code];
|
||||||
chbox->setChecked(b);
|
chbox->setChecked(b);
|
||||||
|
|
||||||
plots_menu->addAction(widget);
|
plots_menu->addAction(widget);
|
||||||
|
|
||||||
// QAction * action = plots_menu->addAction(schema::channel[code].label());
|
|
||||||
// action->setData(QString("%1|%2").arg(graph->name()).arg(code));
|
|
||||||
// action->setCheckable(true);
|
|
||||||
// action->setChecked(lc->m_enabled[code]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
plots_menu->menuAction()->setVisible((plots_menu->actions().size() > 1));
|
plots_menu->menuAction()->setVisible((plots_menu->actions().size() > 1));
|
||||||
@ -2258,10 +2202,9 @@ void gGraphView::populateMenu(gGraph * graph)
|
|||||||
if (p_profile->general->showUnknownFlags()) showflags |= schema::UNKNOWN;
|
if (p_profile->general->showUnknownFlags()) showflags |= schema::UNKNOWN;
|
||||||
QList<ChannelID> chans = lc->m_day->getSortedMachineChannels(showflags);
|
QList<ChannelID> chans = lc->m_day->getSortedMachineChannels(showflags);
|
||||||
|
|
||||||
|
|
||||||
QHash<MachineType, int> Vis;
|
QHash<MachineType, int> Vis;
|
||||||
for (int i=0; i < chans.size() ; ++i) {
|
|
||||||
ChannelID code = chans.at(i);
|
for (const auto code : chans) {
|
||||||
schema::Channel & chan = schema::channel[code];
|
schema::Channel & chan = schema::channel[code];
|
||||||
|
|
||||||
QWidgetAction * widget = new QWidgetAction(context_menu);
|
QWidgetAction * widget = new QWidgetAction(context_menu);
|
||||||
@ -2272,7 +2215,6 @@ void gGraphView::populateMenu(gGraph * graph)
|
|||||||
chbox->setToolTip(schema::channel[code].description());
|
chbox->setToolTip(schema::channel[code].description());
|
||||||
chbox->setStyleSheet(QString("QCheckBox:hover { background: %1; }").arg(QApplication::palette().highlight().color().name()));
|
chbox->setStyleSheet(QString("QCheckBox:hover { background: %1; }").arg(QApplication::palette().highlight().color().name()));
|
||||||
|
|
||||||
|
|
||||||
widget->setDefaultWidget(chbox);
|
widget->setDefaultWidget(chbox);
|
||||||
|
|
||||||
widget->setCheckable(true);
|
widget->setCheckable(true);
|
||||||
@ -2285,7 +2227,6 @@ void gGraphView::populateMenu(gGraph * graph)
|
|||||||
chbox->setChecked(b);
|
chbox->setChecked(b);
|
||||||
Vis[chan.machtype()] += b ? 1 : 0;
|
Vis[chan.machtype()] += b ? 1 : 0;
|
||||||
|
|
||||||
|
|
||||||
action = nullptr;
|
action = nullptr;
|
||||||
if (chan.machtype() == MT_OXIMETER) {
|
if (chan.machtype() == MT_OXIMETER) {
|
||||||
oximeter_menu->insertAction(nullptr, widget);
|
oximeter_menu->insertAction(nullptr, widget);
|
||||||
@ -2311,7 +2252,6 @@ void gGraphView::populateMenu(gGraph * graph)
|
|||||||
action->setData(QString("%1|ShowAll:CPAP").arg(graph->name()));
|
action->setData(QString("%1|ShowAll:CPAP").arg(graph->name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Show CPAP Events menu Header...
|
// Show CPAP Events menu Header...
|
||||||
cpap_menu->insertSeparator(cpap_menu->actions()[0]);
|
cpap_menu->insertSeparator(cpap_menu->actions()[0]);
|
||||||
action = new QAction(QObject::tr("%1").arg(graph->title()), cpap_menu);
|
action = new QAction(QObject::tr("%1").arg(graph->title()), cpap_menu);
|
||||||
@ -2354,7 +2294,7 @@ void gGraphView::onSnapshotGraphToggle()
|
|||||||
{
|
{
|
||||||
QString name = snap_action->data().toString().section("|",0,0);
|
QString name = snap_action->data().toString().section("|",0,0);
|
||||||
QString cmd = snap_action->data().toString().section("|",-1).toLower();
|
QString cmd = snap_action->data().toString().section("|",-1).toLower();
|
||||||
QHash<QString, gGraph *>::iterator it = m_graphsbyname.find(name);
|
auto it = m_graphsbyname.find(name);
|
||||||
if (it == m_graphsbyname.end()) return;
|
if (it == m_graphsbyname.end()) return;
|
||||||
|
|
||||||
gGraph * graph = it.value();
|
gGraph * graph = it.value();
|
||||||
@ -2387,8 +2327,8 @@ void gGraphView::onSnapshotGraphToggle()
|
|||||||
for (int i=1; i < 100; i++) {
|
for (int i=1; i < 100; i++) {
|
||||||
newtitle = graph->title()+"-"+QString::number(i);
|
newtitle = graph->title()+"-"+QString::number(i);
|
||||||
fnd = false;
|
fnd = false;
|
||||||
for (int j=0; j<m_graphs.size(); ++j) {
|
for (const auto & graph : m_graphs) {
|
||||||
if (m_graphs[j]->title() == newtitle) {
|
if (graph->title() == newtitle) {
|
||||||
fnd = true;
|
fnd = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2400,7 +2340,6 @@ void gGraphView::onSnapshotGraphToggle()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gGraph * newgraph = new gGraph(newname, nullptr, newtitle, graph->units(), graph->height(), graph->group());
|
gGraph * newgraph = new gGraph(newname, nullptr, newtitle, graph->units(), graph->height(), graph->group());
|
||||||
// newgraph->setBlockSelect(true);
|
// newgraph->setBlockSelect(true);
|
||||||
newgraph->setHeight(graph->height());
|
newgraph->setHeight(graph->height());
|
||||||
@ -2410,15 +2349,14 @@ void gGraphView::onSnapshotGraphToggle()
|
|||||||
m_graphsbyname[newname] = newgraph;
|
m_graphsbyname[newname] = newgraph;
|
||||||
newgraph->m_graphview = this;
|
newgraph->m_graphview = this;
|
||||||
|
|
||||||
for (int i=0; i < graph->m_layers.size(); ++i) {
|
for (const auto & l : graph->m_layers) {
|
||||||
Layer * layer = graph->m_layers.at(i)->Clone();
|
Layer * layer = l->Clone();
|
||||||
if (layer) {
|
if (layer) {
|
||||||
newgraph->m_layers.append(layer);
|
newgraph->m_layers.append(layer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0;i<m_graphs.size();i++) {
|
for (const auto & g : m_graphs) {
|
||||||
gGraph *g = m_graphs.at(i);
|
|
||||||
group = qMax(g->group(), group);
|
group = qMax(g->group(), group);
|
||||||
}
|
}
|
||||||
newgraph->setGroup(group+1);
|
newgraph->setGroup(group+1);
|
||||||
@ -2456,7 +2394,6 @@ void gGraphView::onSnapshotGraphToggle()
|
|||||||
m_graphs.removeAll(it.value());
|
m_graphs.removeAll(it.value());
|
||||||
delete graph;
|
delete graph;
|
||||||
|
|
||||||
|
|
||||||
updateScale();
|
updateScale();
|
||||||
timedRedraw(0);
|
timedRedraw(0);
|
||||||
|
|
||||||
@ -2467,10 +2404,8 @@ void gGraphView::onSnapshotGraphToggle()
|
|||||||
|
|
||||||
bool gGraphView::hasSnapshots()
|
bool gGraphView::hasSnapshots()
|
||||||
{
|
{
|
||||||
int size = m_graphs.size();
|
|
||||||
bool snap = false;
|
bool snap = false;
|
||||||
for (int i=0; i< size; ++i) {
|
for (const auto & graph : m_graphs) {
|
||||||
gGraph * graph = m_graphs.at(i);
|
|
||||||
if (graph->isSnapshot()) {
|
if (graph->isSnapshot()) {
|
||||||
snap = true;
|
snap = true;
|
||||||
break;
|
break;
|
||||||
@ -2485,7 +2420,7 @@ void gGraphView::onPlotsClicked(QAction *action)
|
|||||||
QString name = action->data().toString().section("|",0,0);
|
QString name = action->data().toString().section("|",0,0);
|
||||||
ChannelID code = action->data().toString().section("|",-1).toInt();
|
ChannelID code = action->data().toString().section("|",-1).toInt();
|
||||||
|
|
||||||
QHash<QString, gGraph *>::iterator it = m_graphsbyname.find(name);
|
auto it = m_graphsbyname.find(name);
|
||||||
if (it == m_graphsbyname.end()) return;
|
if (it == m_graphsbyname.end()) return;
|
||||||
|
|
||||||
gGraph * graph = it.value();
|
gGraph * graph = it.value();
|
||||||
@ -2506,7 +2441,7 @@ void gGraphView::onOverlaysClicked(QAction *action)
|
|||||||
{
|
{
|
||||||
QString name = action->data().toString().section("|",0,0);
|
QString name = action->data().toString().section("|",0,0);
|
||||||
QString data = action->data().toString().section("|",-1);
|
QString data = action->data().toString().section("|",-1);
|
||||||
QHash<QString, gGraph *>::iterator it = m_graphsbyname.find(name);
|
auto it = m_graphsbyname.find(name);
|
||||||
if (it == m_graphsbyname.end()) return;
|
if (it == m_graphsbyname.end()) return;
|
||||||
gGraph * graph = it.value();
|
gGraph * graph = it.value();
|
||||||
|
|
||||||
@ -2539,11 +2474,8 @@ void gGraphView::onOverlaysClicked(QAction *action)
|
|||||||
else if (group == "OXI") mtype = MT_OXIMETER;
|
else if (group == "OXI") mtype = MT_OXIMETER;
|
||||||
else mtype = MT_UNKNOWN;
|
else mtype = MT_UNKNOWN;
|
||||||
|
|
||||||
QHash<ChannelID, bool>::iterator it;
|
|
||||||
QHash<ChannelID, bool>::iterator mfe = lc->m_flags_enabled.end();
|
|
||||||
|
|
||||||
// First toggle the actual flag bits
|
// First toggle the actual flag bits
|
||||||
for (it = lc->m_flags_enabled.begin(); it != mfe; ++it) {
|
for (auto it=lc->m_flags_enabled.begin(), end=lc->m_flags_enabled.end(); it != end; ++it) {
|
||||||
if (schema::channel[it.key()].machtype() == mtype) {
|
if (schema::channel[it.key()].machtype() == mtype) {
|
||||||
lc->m_flags_enabled[it.key()] = value;
|
lc->m_flags_enabled[it.key()] = value;
|
||||||
}
|
}
|
||||||
@ -2551,15 +2483,15 @@ void gGraphView::onOverlaysClicked(QAction *action)
|
|||||||
|
|
||||||
// Now toggle the menu actions.. bleh
|
// Now toggle the menu actions.. bleh
|
||||||
if (mtype == MT_CPAP) {
|
if (mtype == MT_CPAP) {
|
||||||
for (int i=0; i< cpap_menu->actions().size(); i++) {
|
for (auto & action : cpap_menu->actions()) {
|
||||||
if (cpap_menu->actions().at(i)->isCheckable()) {
|
if (action->isCheckable()) {
|
||||||
cpap_menu->actions().at(i)->setChecked(value);
|
action->setChecked(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (mtype == MT_OXIMETER) {
|
} else if (mtype == MT_OXIMETER) {
|
||||||
for (int i=0; i< oximeter_menu->actions().size(); i++) {
|
for (auto & action : oximeter_menu->actions()) {
|
||||||
if (oximeter_menu->actions().at(i)->isCheckable()) {
|
if (action->isCheckable()) {
|
||||||
oximeter_menu->actions().at(i)->setChecked(value);
|
action->setChecked(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2573,7 +2505,7 @@ void gGraphView::onLinesClicked(QAction *action)
|
|||||||
QString name = action->data().toString().section("|",0,0);
|
QString name = action->data().toString().section("|",0,0);
|
||||||
QString data = action->data().toString().section("|",-1);
|
QString data = action->data().toString().section("|",-1);
|
||||||
|
|
||||||
QHash<QString, gGraph *>::iterator it = m_graphsbyname.find(name);
|
auto it = m_graphsbyname.find(name);
|
||||||
if (it == m_graphsbyname.end()) return;
|
if (it == m_graphsbyname.end()) return;
|
||||||
|
|
||||||
gGraph * graph = it.value();
|
gGraph * graph = it.value();
|
||||||
@ -2607,8 +2539,8 @@ void gGraphView::mousePressEvent(QMouseEvent *event)
|
|||||||
|
|
||||||
// first handle pinned graphs.
|
// first handle pinned graphs.
|
||||||
// Calculate total height of all pinned graphs
|
// Calculate total height of all pinned graphs
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (int i=0, end=m_graphs.size(); i<end; ++i) {
|
||||||
gGraph *g = m_graphs[i];
|
gGraph * g = m_graphs[i];
|
||||||
|
|
||||||
if (!g || g->isEmpty() || !g->visible() || !g->isPinned()) {
|
if (!g || g->isEmpty() || !g->visible() || !g->isPinned()) {
|
||||||
continue;
|
continue;
|
||||||
@ -2684,10 +2616,9 @@ void gGraphView::mousePressEvent(QMouseEvent *event)
|
|||||||
py = -m_offsetY;
|
py = -m_offsetY;
|
||||||
py += pinned_height;
|
py += pinned_height;
|
||||||
|
|
||||||
if (!done)
|
if (!done) {
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (int i=0, end=m_graphs.size(); i<end; ++i) {
|
||||||
gGraph * g = m_graphs[i];
|
gGraph * g = m_graphs[i];
|
||||||
if (!g) continue;
|
|
||||||
|
|
||||||
if (!g || g->isEmpty() || !g->visible() || g->isPinned()) { continue; }
|
if (!g || g->isEmpty() || !g->visible() || g->isPinned()) { continue; }
|
||||||
|
|
||||||
@ -2753,7 +2684,7 @@ void gGraphView::mousePressEvent(QMouseEvent *event)
|
|||||||
py += h + graphSpacer;
|
py += h + graphSpacer;
|
||||||
done=true;
|
done=true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!done) {
|
if (!done) {
|
||||||
// if (event->button() == Qt::RightButton) {
|
// if (event->button() == Qt::RightButton) {
|
||||||
// this->setCursor(Qt::ArrowCursor);
|
// this->setCursor(Qt::ArrowCursor);
|
||||||
@ -2778,8 +2709,7 @@ void gGraphView::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
m_button_down = false;
|
m_button_down = false;
|
||||||
|
|
||||||
// Handle pinned graphs first
|
// Handle pinned graphs first
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (const auto & g : m_graphs) {
|
||||||
gGraph *g = m_graphs[i];
|
|
||||||
|
|
||||||
if (!g || g->isEmpty() || !g->visible() || !g->isPinned()) {
|
if (!g || g->isEmpty() || !g->visible() || !g->isPinned()) {
|
||||||
continue;
|
continue;
|
||||||
@ -2818,8 +2748,7 @@ void gGraphView::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
py += pinned_height;
|
py += pinned_height;
|
||||||
|
|
||||||
if (done)
|
if (done)
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (const auto & g : m_graphs) {
|
||||||
gGraph *g = m_graphs[i];
|
|
||||||
|
|
||||||
if (!g || g->isEmpty() || !g->visible() || g->isPinned()) {
|
if (!g || g->isEmpty() || !g->visible() || g->isPinned()) {
|
||||||
continue;
|
continue;
|
||||||
@ -2893,7 +2822,6 @@ void gGraphView::keyReleaseEvent(QKeyEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_metaselect = false;
|
m_metaselect = false;
|
||||||
|
|
||||||
timedRedraw(50);
|
timedRedraw(50);
|
||||||
}
|
}
|
||||||
if (event->key() == Qt::Key_Escape) {
|
if (event->key() == Qt::Key_Escape) {
|
||||||
@ -2929,8 +2857,7 @@ void gGraphView::mouseDoubleClickEvent(QMouseEvent *event)
|
|||||||
bool done = false;
|
bool done = false;
|
||||||
|
|
||||||
// Handle pinned graphs first
|
// Handle pinned graphs first
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (const auto & g : m_graphs) {
|
||||||
gGraph *g = m_graphs[i];
|
|
||||||
if (!g || g->isEmpty() || !g->visible() || !g->isPinned()) {
|
if (!g || g->isEmpty() || !g->visible() || !g->isPinned()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -2972,8 +2899,7 @@ void gGraphView::mouseDoubleClickEvent(QMouseEvent *event)
|
|||||||
py += pinned_height;
|
py += pinned_height;
|
||||||
|
|
||||||
if (!done) // then handle unpinned graphs
|
if (!done) // then handle unpinned graphs
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (const auto & g : m_graphs) {
|
||||||
gGraph *g = m_graphs[i];
|
|
||||||
if (!g || g->isEmpty() || !g->visible() || g->isPinned()) {
|
if (!g || g->isEmpty() || !g->visible() || g->isPinned()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -3046,8 +2972,8 @@ void gGraphView::wheelEvent(QWheelEvent *event)
|
|||||||
|
|
||||||
|
|
||||||
// Find graph hovered over
|
// Find graph hovered over
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (const auto & g : m_graphs) {
|
||||||
gGraph *g = m_graphs[i];
|
|
||||||
if (!g || g->isEmpty() || !g->visible() || !g->isPinned()) {
|
if (!g || g->isEmpty() || !g->visible() || !g->isPinned()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -3077,8 +3003,7 @@ void gGraphView::wheelEvent(QWheelEvent *event)
|
|||||||
py = -m_offsetY;
|
py = -m_offsetY;
|
||||||
py += pinned_height;
|
py += pinned_height;
|
||||||
|
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (const auto & g : m_graphs) {
|
||||||
gGraph *g = m_graphs[i];
|
|
||||||
if (!g || g->isEmpty() || !g->visible() || g->isPinned()) {
|
if (!g || g->isEmpty() || !g->visible() || g->isPinned()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -3110,10 +3035,10 @@ void gGraphView::wheelEvent(QWheelEvent *event)
|
|||||||
if (event->modifiers() == Qt::NoModifier) {
|
if (event->modifiers() == Qt::NoModifier) {
|
||||||
if (!graph) {
|
if (!graph) {
|
||||||
// just pick any graph then
|
// just pick any graph then
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (const auto & g : m_graphs) {
|
||||||
if (!m_graphs[i]) continue;
|
if (!g) continue;
|
||||||
if (!m_graphs[i]->isEmpty()) {
|
if (!g->isEmpty()) {
|
||||||
graph = m_graphs[i];
|
graph = g;
|
||||||
group = graph->group();
|
group = graph->group();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3272,19 +3197,19 @@ void gGraphView::keyPressEvent(QKeyEvent *event)
|
|||||||
int group = 0;
|
int group = 0;
|
||||||
|
|
||||||
// Pick the first valid graph in the primary group
|
// Pick the first valid graph in the primary group
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (const auto & gr : m_graphs) {
|
||||||
if (m_graphs[i]->group() == group) {
|
if (gr->group() == group) {
|
||||||
if (!m_graphs[i]->isEmpty() && m_graphs[i]->visible()) {
|
if (!gr->isEmpty() && gr->visible()) {
|
||||||
g = m_graphs[i];
|
g = gr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g) {
|
if (!g) {
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (const auto & gr : m_graphs) {
|
||||||
if (!m_graphs[i]->isEmpty()) {
|
if (!gr->isEmpty()) {
|
||||||
g = m_graphs[i];
|
g = gr;
|
||||||
group = g->group();
|
group = g->group();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3350,8 +3275,8 @@ void gGraphView::setDay(Day *day)
|
|||||||
|
|
||||||
m_day = day;
|
m_day = day;
|
||||||
|
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (const auto & g : m_graphs) {
|
||||||
if (m_graphs[i]) m_graphs[i]->setDay(day);
|
if (g) g->setDay(day);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResetBounds(false);
|
ResetBounds(false);
|
||||||
@ -3360,8 +3285,7 @@ bool gGraphView::isEmpty()
|
|||||||
{
|
{
|
||||||
bool res = true;
|
bool res = true;
|
||||||
|
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (const auto & graph : m_graphs) {
|
||||||
gGraph * graph = m_graphs.at(i);
|
|
||||||
if (!graph->isSnapshot() && !graph->isEmpty()) {
|
if (!graph->isSnapshot() && !graph->isEmpty()) {
|
||||||
res = false;
|
res = false;
|
||||||
break;
|
break;
|
||||||
@ -3397,8 +3321,8 @@ void gGraphView::resetLayout()
|
|||||||
{
|
{
|
||||||
int default_height = AppSetting->graphHeight();
|
int default_height = AppSetting->graphHeight();
|
||||||
|
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (auto & graph : m_graphs) {
|
||||||
if (m_graphs[i]) m_graphs[i]->setHeight(default_height);
|
if (graph) graph->setHeight(default_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateScale();
|
updateScale();
|
||||||
@ -3406,8 +3330,8 @@ void gGraphView::resetLayout()
|
|||||||
}
|
}
|
||||||
void gGraphView::deselect()
|
void gGraphView::deselect()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (auto & graph : m_graphs) {
|
||||||
if (m_graphs[i]) m_graphs[i]->deselect();
|
if (graph) graph->deselect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3429,8 +3353,7 @@ void gGraphView::SaveSettings(QString title)
|
|||||||
|
|
||||||
out << (qint16)size();
|
out << (qint16)size();
|
||||||
|
|
||||||
for (qint16 i = 0; i < size(); i++) {
|
for (auto & graph : m_graphs) {
|
||||||
gGraph * graph = m_graphs[i];
|
|
||||||
if (!graph) continue;
|
if (!graph) continue;
|
||||||
if (graph->isSnapshot()) continue;
|
if (graph->isSnapshot()) continue;
|
||||||
|
|
||||||
@ -3586,17 +3509,17 @@ bool gGraphView::LoadSettings(QString title)
|
|||||||
|
|
||||||
gGraph *gGraphView::findGraph(QString name)
|
gGraph *gGraphView::findGraph(QString name)
|
||||||
{
|
{
|
||||||
QHash<QString, gGraph *>::iterator i = m_graphsbyname.find(name);
|
auto it = m_graphsbyname.find(name);
|
||||||
|
|
||||||
if (i == m_graphsbyname.end()) { return nullptr; }
|
if (it == m_graphsbyname.end()) { return nullptr; }
|
||||||
|
|
||||||
return i.value();
|
return it.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
gGraph *gGraphView::findGraphTitle(QString title)
|
gGraph *gGraphView::findGraphTitle(QString title)
|
||||||
{
|
{
|
||||||
for (int i=0; i< m_graphs.size(); ++i) {
|
for (auto & graph : m_graphs) {
|
||||||
if (m_graphs[i]->title() == title) return m_graphs[i];
|
if (graph->title() == title) return graph;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -3605,8 +3528,8 @@ int gGraphView::visibleGraphs()
|
|||||||
{
|
{
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
|
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (auto & graph : m_graphs) {
|
||||||
if (m_graphs[i]->visible() && !m_graphs[i]->isEmpty()) { cnt++; }
|
if (graph->visible() && !graph->isEmpty()) { cnt++; }
|
||||||
}
|
}
|
||||||
|
|
||||||
return cnt;
|
return cnt;
|
||||||
@ -3614,8 +3537,8 @@ int gGraphView::visibleGraphs()
|
|||||||
|
|
||||||
void gGraphView::dataChanged()
|
void gGraphView::dataChanged()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_graphs.size(); i++) {
|
for (auto & graph : m_graphs) {
|
||||||
m_graphs[i]->dataChanged();
|
graph->dataChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* gLineChart Implementation
|
/* gLineChart Implementation
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011-2018 Mark Watkins <mark@jedimark.net>
|
* Copyright (c) 2011-2018 Mark Watkins <mark@jedimark.net>
|
||||||
*
|
*
|
||||||
@ -64,8 +64,7 @@ gLineChart::gLineChart(ChannelID code, bool square_plot, bool disable_accel)
|
|||||||
}
|
}
|
||||||
gLineChart::~gLineChart()
|
gLineChart::~gLineChart()
|
||||||
{
|
{
|
||||||
QHash<ChannelID, gLineOverlayBar *>::iterator fit;
|
for (auto fit = flags.begin(), end=flags.end(); fit != end; ++fit) {
|
||||||
for (fit = flags.begin(); fit != flags.end(); ++fit) {
|
|
||||||
// destroy any overlay bar from previous day
|
// destroy any overlay bar from previous day
|
||||||
delete fit.value();
|
delete fit.value();
|
||||||
}
|
}
|
||||||
@ -78,10 +77,8 @@ bool gLineChart::isEmpty()
|
|||||||
{
|
{
|
||||||
if (!m_day) { return true; }
|
if (!m_day) { return true; }
|
||||||
|
|
||||||
for (int j = 0; j < m_codes.size(); j++) {
|
for (const auto code : m_codes) {
|
||||||
ChannelID code = m_codes[j];
|
for (int i=0, end=m_day->size(); i < end; i++) {
|
||||||
|
|
||||||
for (int i = 0; i < m_day->size(); i++) {
|
|
||||||
Session *sess = m_day->sessions[i];
|
Session *sess = m_day->sessions[i];
|
||||||
|
|
||||||
if (sess->channelExists(code)) {
|
if (sess->channelExists(code)) {
|
||||||
@ -112,10 +109,9 @@ void gLineChart::SetDay(Day *d)
|
|||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
||||||
for (int j = 0; j < m_codes.size(); j++) {
|
for (auto & code : m_codes) {
|
||||||
ChannelID code = m_codes[j];
|
|
||||||
|
|
||||||
for (int i = 0; i < d->size(); i++) {
|
for (int i=0, end=d->size(); i < end; i++) {
|
||||||
Session *sess = d->sessions[i];
|
Session *sess = d->sessions[i];
|
||||||
if (!sess->enabled()) continue;
|
if (!sess->enabled()) continue;
|
||||||
|
|
||||||
@ -129,7 +125,7 @@ void gLineChart::SetDay(Day *d)
|
|||||||
|
|
||||||
if (code == CPAP_MaskPressure) {
|
if (code == CPAP_MaskPressure) {
|
||||||
if (sess->channelExists(CPAP_MaskPressureHi)) {
|
if (sess->channelExists(CPAP_MaskPressureHi)) {
|
||||||
code = m_codes[j] = CPAP_MaskPressureHi;
|
code = CPAP_MaskPressureHi; // verify setting m_codes[]
|
||||||
m_enabled[code] = schema::channel[CPAP_MaskPressureHi].enabled();
|
m_enabled[code] = schema::channel[CPAP_MaskPressureHi].enabled();
|
||||||
|
|
||||||
goto skipcheck; // why not :P
|
goto skipcheck; // why not :P
|
||||||
@ -192,8 +188,7 @@ skipcheck:
|
|||||||
|
|
||||||
subtract_offset = 0;
|
subtract_offset = 0;
|
||||||
|
|
||||||
QHash<ChannelID, gLineOverlayBar *>::iterator fit;
|
for (auto fit = flags.begin(), end=flags.end(); fit != end; ++fit) {
|
||||||
for (fit = flags.begin(); fit != flags.end(); ++fit) {
|
|
||||||
// destroy any overlay bar from previous day
|
// destroy any overlay bar from previous day
|
||||||
delete fit.value();
|
delete fit.value();
|
||||||
}
|
}
|
||||||
@ -204,8 +199,7 @@ skipcheck:
|
|||||||
if (p_profile->general->showUnknownFlags()) z |= schema::UNKNOWN;
|
if (p_profile->general->showUnknownFlags()) z |= schema::UNKNOWN;
|
||||||
QList<ChannelID> available = m_day->getSortedMachineChannels(z);
|
QList<ChannelID> available = m_day->getSortedMachineChannels(z);
|
||||||
|
|
||||||
for (int i=0; i < available.size(); ++i) {
|
for (const auto & code : available) {
|
||||||
ChannelID code = available.at(i);
|
|
||||||
if (!m_flags_enabled.contains(code)) {
|
if (!m_flags_enabled.contains(code)) {
|
||||||
bool b = false;
|
bool b = false;
|
||||||
|
|
||||||
@ -215,7 +209,6 @@ skipcheck:
|
|||||||
}
|
}
|
||||||
if (!m_day->channelExists(code)) continue;
|
if (!m_day->channelExists(code)) continue;
|
||||||
|
|
||||||
|
|
||||||
schema::Channel * chan = &schema::channel[code];
|
schema::Channel * chan = &schema::channel[code];
|
||||||
gLineOverlayBar * lob = nullptr;
|
gLineOverlayBar * lob = nullptr;
|
||||||
|
|
||||||
@ -235,9 +228,8 @@ skipcheck:
|
|||||||
|
|
||||||
m_dotlines.clear();
|
m_dotlines.clear();
|
||||||
|
|
||||||
for (int i=0; i< m_codes.size(); i++) {
|
for (const auto & code : m_codes) {
|
||||||
ChannelID code = m_codes[i];
|
const schema::Channel & chan = schema::channel[code];
|
||||||
schema::Channel & chan = schema::channel[code];
|
|
||||||
addDotLine(DottedLine(code, Calc_Max,chan.calc[Calc_Max].enabled));
|
addDotLine(DottedLine(code, Calc_Max,chan.calc[Calc_Max].enabled));
|
||||||
if ((code != CPAP_FlowRate) && (code != CPAP_MaskPressure) && (code != CPAP_MaskPressureHi)) {
|
if ((code != CPAP_FlowRate) && (code != CPAP_MaskPressure) && (code != CPAP_MaskPressureHi)) {
|
||||||
addDotLine(DottedLine(code, Calc_Perc,chan.calc[Calc_Perc].enabled));
|
addDotLine(DottedLine(code, Calc_Perc,chan.calc[Calc_Perc].enabled));
|
||||||
@ -260,20 +252,19 @@ skipcheck:
|
|||||||
|
|
||||||
|
|
||||||
if (m_day) {
|
if (m_day) {
|
||||||
for (int i=0; i < m_dotlines.size(); i++) {
|
for (auto & dot : m_dotlines) {
|
||||||
m_dotlines[i].calc(m_day);
|
dot.calc(m_day);
|
||||||
|
|
||||||
ChannelID code = m_dotlines[i].code;
|
ChannelID code = dot.code;
|
||||||
ChannelCalcType type = m_dotlines[i].type;
|
ChannelCalcType type = dot.type;
|
||||||
|
|
||||||
bool b = false; // default value
|
bool b = false; // default value
|
||||||
|
|
||||||
QHash<ChannelID, QHash<quint32, bool> >::iterator cit = m_dot_enabled.find(code);
|
const auto & cit = m_dot_enabled.find(code);
|
||||||
|
|
||||||
if (cit == m_dot_enabled.end()) {
|
if (cit == m_dot_enabled.end()) {
|
||||||
m_dot_enabled[code].insert(type, b);
|
m_dot_enabled[code].insert(type, b);
|
||||||
} else {
|
} else {
|
||||||
QHash<quint32, bool>::iterator it = cit.value().find(type);
|
const auto & it = cit.value().find(type);
|
||||||
if (it == cit.value().end()) {
|
if (it == cit.value().end()) {
|
||||||
cit.value().insert(type, b);
|
cit.value().insert(type, b);
|
||||||
}
|
}
|
||||||
@ -283,15 +274,13 @@ skipcheck:
|
|||||||
}
|
}
|
||||||
EventDataType gLineChart::Miny()
|
EventDataType gLineChart::Miny()
|
||||||
{
|
{
|
||||||
int size = m_codes.size();
|
if (m_codes.size() == 0) return 0;
|
||||||
if (size == 0) return 0;
|
|
||||||
if (!m_day) return 0;
|
if (!m_day) return 0;
|
||||||
|
|
||||||
bool first = false;
|
bool first = false;
|
||||||
EventDataType min = 0, tmp;
|
EventDataType min = 0, tmp;
|
||||||
|
|
||||||
for (int i=0; i< size; ++i) {
|
for (const auto code : m_codes) {
|
||||||
ChannelID code = m_codes[i];
|
|
||||||
if (!m_enabled[code] || !m_day->channelExists(code)) continue;
|
if (!m_enabled[code] || !m_day->channelExists(code)) continue;
|
||||||
|
|
||||||
tmp = m_day->Min(code);
|
tmp = m_day->Min(code);
|
||||||
@ -308,27 +297,16 @@ EventDataType gLineChart::Miny()
|
|||||||
m_miny = min;
|
m_miny = min;
|
||||||
|
|
||||||
return min;
|
return min;
|
||||||
// int m = Layer::Miny();
|
|
||||||
|
|
||||||
// if (subtract_offset > 0) {
|
|
||||||
// m -= subtract_offset;
|
|
||||||
|
|
||||||
// if (m < 0) { m = 0; }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return m;
|
|
||||||
}
|
}
|
||||||
EventDataType gLineChart::Maxy()
|
EventDataType gLineChart::Maxy()
|
||||||
{
|
{
|
||||||
int size = m_codes.size();
|
if (m_codes.size() == 0) return 0;
|
||||||
if (size == 0) return 0;
|
|
||||||
if (!m_day) return 0;
|
if (!m_day) return 0;
|
||||||
|
|
||||||
bool first = false;
|
bool first = false;
|
||||||
EventDataType max = 0, tmp;
|
EventDataType max = 0, tmp;
|
||||||
|
|
||||||
for (int i=0; i< size; ++i) {
|
for (const auto code : m_codes) {
|
||||||
ChannelID code = m_codes[i];
|
|
||||||
if (!m_enabled[code] || !m_day->channelExists(code)) continue;
|
if (!m_enabled[code] || !m_day->channelExists(code)) continue;
|
||||||
|
|
||||||
tmp = m_day->Max(code);
|
tmp = m_day->Max(code);
|
||||||
@ -357,18 +335,15 @@ bool gLineChart::mouseMoveEvent(QMouseEvent *event, gGraph *graph)
|
|||||||
|
|
||||||
QString gLineChart::getMetaString(qint64 time)
|
QString gLineChart::getMetaString(qint64 time)
|
||||||
{
|
{
|
||||||
lasttext = QString();
|
|
||||||
if (!m_day) return lasttext;
|
if (!m_day) return lasttext;
|
||||||
|
lasttext = QString();
|
||||||
|
|
||||||
EventDataType val;
|
EventDataType val;
|
||||||
|
|
||||||
EventDataType ipap = 0, epap = 0;
|
EventDataType ipap = 0, epap = 0;
|
||||||
bool addPS = false;
|
bool addPS = false;
|
||||||
|
|
||||||
for (int i=0; i<m_codes.size(); ++i) {
|
for (const auto code : m_codes) {
|
||||||
ChannelID code = m_codes[i];
|
|
||||||
|
|
||||||
if (m_day->channelHasData(code)) {
|
if (m_day->channelHasData(code)) {
|
||||||
val = m_day->lookupValue(code, time, m_square_plot);
|
val = m_day->lookupValue(code, time, m_square_plot);
|
||||||
lasttext += " "+QString("%1: %2").arg(schema::channel[code].label()).arg(val,0,'f',2); //.arg(schema::channel[code].units());
|
lasttext += " "+QString("%1: %2").arg(schema::channel[code].label()).arg(val,0,'f',2); //.arg(schema::channel[code].units());
|
||||||
@ -543,33 +518,27 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
painter.setFont(*defaultfont);
|
painter.setFont(*defaultfont);
|
||||||
bool showDottedLines = true;
|
bool showDottedLines = true;
|
||||||
|
|
||||||
int dotlinesize = m_dotlines.size();
|
|
||||||
|
|
||||||
// Unset Dotted lines visible status, so we only draw necessary labels later
|
// Unset Dotted lines visible status, so we only draw necessary labels later
|
||||||
for (int i=0; i < dotlinesize; i++) {
|
for (auto & dot : m_dotlines) {
|
||||||
DottedLine & dot = m_dotlines[i];
|
|
||||||
dot.visible = false;
|
dot.visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Session * sess = nullptr;
|
|
||||||
ChannelID code;
|
ChannelID code;
|
||||||
|
|
||||||
float lineThickness = AppSetting->lineThickness()+0.001F;
|
float lineThickness = AppSetting->lineThickness()+0.001F;
|
||||||
|
|
||||||
for (int gi = 0; gi < m_codes.size(); gi++) {
|
for (const auto & code : m_codes) {
|
||||||
code = m_codes[gi];
|
const schema::Channel &chan = schema::channel[code];
|
||||||
schema::Channel &chan = schema::channel[code];
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Draw the Channel Threshold dotted lines, and flow waveform centreline
|
// Draw the Channel Threshold dotted lines, and flow waveform centreline
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
if (showDottedLines) {
|
if (showDottedLines) {
|
||||||
for (int i=0; i < dotlinesize; i++) {
|
for (auto & dot : m_dotlines) {
|
||||||
DottedLine & dot = m_dotlines[i];
|
|
||||||
if ((dot.code != code) || (!m_dot_enabled[dot.code][dot.type]) || (!dot.available) || (!m_enabled[dot.code])) {
|
if ((dot.code != code) || (!m_dot_enabled[dot.code][dot.type]) || (!dot.available) || (!m_enabled[dot.code])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
schema::Channel & chan = schema::channel[code];
|
//schema::Channel & chan = schema::channel[code];
|
||||||
|
|
||||||
dot.visible = true;
|
dot.visible = true;
|
||||||
QColor color = chan.calc[dot.type].color;
|
QColor color = chan.calc[dot.type].color;
|
||||||
@ -588,10 +557,7 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
codepoints = 0;
|
codepoints = 0;
|
||||||
|
|
||||||
// For each session...
|
// For each session...
|
||||||
int daysize = m_day->size();
|
for (const auto & sess : m_day->sessions) {
|
||||||
for (int svi = 0; svi < daysize; svi++) {
|
|
||||||
sess = (*m_day)[svi];
|
|
||||||
|
|
||||||
if (!sess) {
|
if (!sess) {
|
||||||
qWarning() << "gLineChart::Plot() nullptr Session Record.. This should not happen";
|
qWarning() << "gLineChart::Plot() nullptr Session Record.. This should not happen";
|
||||||
continue;
|
continue;
|
||||||
@ -604,12 +570,10 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
schema::Channel ch = schema::channel[code];
|
schema::Channel ch = schema::channel[code];
|
||||||
bool fndbetter = false;
|
bool fndbetter = false;
|
||||||
|
|
||||||
QList<schema::Channel *>::iterator mlend=ch.m_links.end();
|
for (const auto & c : ch.m_links) {
|
||||||
for (QList<schema::Channel *>::iterator l = ch.m_links.begin(); l != mlend; l++) {
|
ci = sess->eventlist.find(c->id());
|
||||||
schema::Channel &c = *(*l);
|
|
||||||
ci = (*m_day)[svi]->eventlist.find(c.id());
|
|
||||||
|
|
||||||
if (ci != (*m_day)[svi]->eventlist.end()) {
|
if (ci != sess->eventlist.end()) {
|
||||||
fndbetter = true;
|
fndbetter = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -617,20 +581,15 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!fndbetter) {
|
if (!fndbetter) {
|
||||||
ci = (*m_day)[svi]->eventlist.find(code);
|
ci = sess->eventlist.find(code);
|
||||||
|
|
||||||
if (ci == (*m_day)[svi]->eventlist.end()) { continue; }
|
if (ci == sess->eventlist.end()) { continue; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVector<EventList *> &evec = ci.value();
|
|
||||||
num_points = 0;
|
num_points = 0;
|
||||||
|
|
||||||
QVector<EventList *>::iterator evec_end = evec.end();
|
for (const auto & ni : ci.value()) {
|
||||||
QVector<EventList *>::iterator ni;
|
num_points += ni->count();
|
||||||
|
|
||||||
for (ni = evec.begin(); ni != evec_end; ++ni) {
|
|
||||||
num_points += (*ni)->count();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
total_points += num_points;
|
total_points += num_points;
|
||||||
@ -639,9 +598,8 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
// Max number of samples taken from samples per pixel for better min/max values
|
// Max number of samples taken from samples per pixel for better min/max values
|
||||||
const int num_averages = 20;
|
const int num_averages = 20;
|
||||||
|
|
||||||
int n=0;
|
for (auto & ni : ci.value()) {
|
||||||
for (ni = evec.begin(); ni != evec_end; ++ni, ++n) {
|
EventList & el = (*ni);
|
||||||
EventList & el = *(EventList*) (*ni);
|
|
||||||
|
|
||||||
accel = (el.type() == EVL_Waveform); // Turn on acceleration if this is a waveform.
|
accel = (el.type() == EVL_Waveform); // Turn on acceleration if this is a waveform.
|
||||||
|
|
||||||
@ -656,7 +614,6 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
|
|
||||||
if (m_disable_accel) { accel = false; }
|
if (m_disable_accel) { accel = false; }
|
||||||
|
|
||||||
|
|
||||||
square_plot = m_square_plot;
|
square_plot = m_square_plot;
|
||||||
|
|
||||||
if (accel || num_points > 20000) { // Don't square plot if too many points or waveform
|
if (accel || num_points > 20000) { // Don't square plot if too many points or waveform
|
||||||
@ -882,7 +839,6 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
w.graphView()->lines_drawn_this_frame += lines.count();
|
w.graphView()->lines_drawn_this_frame += lines.count();
|
||||||
lines.clear();
|
lines.clear();
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
// Standard events/zoomed in Plot
|
// Standard events/zoomed in Plot
|
||||||
@ -1050,8 +1006,7 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Draw Channel Threshold legend markers
|
// Draw Channel Threshold legend markers
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
for (int i=0; i < dotlinesize; i++) {
|
for (const auto & dot : m_dotlines) {
|
||||||
DottedLine & dot = m_dotlines[i];
|
|
||||||
if (!dot.visible) continue;
|
if (!dot.visible) continue;
|
||||||
code = dot.code;
|
code = dot.code;
|
||||||
schema::Channel &chan = schema::channel[code];
|
schema::Channel &chan = schema::channel[code];
|
||||||
@ -1074,8 +1029,6 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
int yp = rec.top()+(rec.height()/2);
|
int yp = rec.top()+(rec.height()/2);
|
||||||
painter.drawLine(rec.left()-linewidth, yp , rec.left()-(2 * ratioX), yp);
|
painter.drawLine(rec.left()-linewidth, yp , rec.left()-(2 * ratioX), yp);
|
||||||
legendx -= linewidth + (2*ratioX);
|
legendx -= linewidth + (2*ratioX);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
painter.setClipping(true);
|
painter.setClipping(true);
|
||||||
@ -1094,8 +1047,7 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
double time = 0;
|
double time = 0;
|
||||||
|
|
||||||
// Calculate the CPAP session time.
|
// Calculate the CPAP session time.
|
||||||
for (QList<Session *>::iterator s = m_day->begin(); s != m_day->end(); s++) {
|
for (auto & sess : m_day->sessions) {
|
||||||
sess = *s;
|
|
||||||
if (!sess->enabled() || (sess->type() != MT_CPAP)) continue;
|
if (!sess->enabled() || (sess->type() != MT_CPAP)) continue;
|
||||||
|
|
||||||
first = sess->first();
|
first = sess->first();
|
||||||
@ -1134,10 +1086,8 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
|
|
||||||
// Draw the linechart overlays
|
// Draw the linechart overlays
|
||||||
if (m_day && (AppSetting->lineCursorMode() || (m_codes[0]==CPAP_FlowRate))) {
|
if (m_day && (AppSetting->lineCursorMode() || (m_codes[0]==CPAP_FlowRate))) {
|
||||||
QHash<ChannelID, gLineOverlayBar *>::iterator fit;
|
|
||||||
bool blockhover = false;
|
bool blockhover = false;
|
||||||
|
for (auto fit=flags.begin(), end=flags.end(); fit != end; ++fit) {
|
||||||
for (fit = flags.begin(); fit != flags.end(); ++fit) {
|
|
||||||
code = fit.key();
|
code = fit.key();
|
||||||
if ((!m_flags_enabled[code]) || (!m_day->channelExists(code))) continue;
|
if ((!m_flags_enabled[code]) || (!m_day->channelExists(code))) continue;
|
||||||
gLineOverlayBar * lob = fit.value();
|
gLineOverlayBar * lob = fit.value();
|
||||||
@ -1151,8 +1101,6 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if (m_codes[0] == OXI_SPO2Drop) {
|
|
||||||
// }
|
|
||||||
if (m_codes[0] == CPAP_FlowRate) {
|
if (m_codes[0] == CPAP_FlowRate) {
|
||||||
float hours = time / 3600.0;
|
float hours = time / 3600.0;
|
||||||
int h = time / 3600;
|
int h = time / 3600;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* gLineOverlayBar Implementation
|
/* gLineOverlayBar Implementation
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011-2018 Mark Watkins <mark@jedimark.net>
|
* Copyright (c) 2011-2018 Mark Watkins <mark@jedimark.net>
|
||||||
*
|
*
|
||||||
@ -86,28 +86,24 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
int tooltipTimeout = AppSetting->tooltipTimeout();
|
int tooltipTimeout = AppSetting->tooltipTimeout();
|
||||||
|
|
||||||
// For each session, process it's eventlist
|
// For each session, process it's eventlist
|
||||||
for (QList<Session *>::iterator s = m_day->begin(); s != m_day->end(); s++) {
|
for (const auto sess : m_day->sessions) {
|
||||||
|
if (!sess->enabled()) { continue; }
|
||||||
|
|
||||||
if (!(*s)->enabled()) { continue; }
|
cei = sess->eventlist.find(m_code);
|
||||||
|
|
||||||
cei = (*s)->eventlist.find(m_code);
|
if (cei == sess->eventlist.end()) { continue; }
|
||||||
|
|
||||||
if (cei == (*s)->eventlist.end()) { continue; }
|
if (cei.value().size() == 0) { continue; }
|
||||||
|
|
||||||
QVector<EventList *> &evlist = cei.value();
|
drift = (sess->type() == MT_CPAP) ? clockdrift : 0;
|
||||||
|
|
||||||
if (evlist.size() == 0) { continue; }
|
|
||||||
|
|
||||||
drift = ((*s)->type() == MT_CPAP) ? clockdrift : 0;
|
|
||||||
|
|
||||||
// Could loop through here, but nowhere uses more than one yet..
|
// Could loop through here, but nowhere uses more than one yet..
|
||||||
for (int k = 0; k < evlist.size(); k++) {
|
for (const auto & el : cei.value()) {
|
||||||
EventList &el = *(evlist[k]);
|
count = el->count();
|
||||||
count = el.count();
|
stime = el->first() + drift;
|
||||||
stime = el.first() + drift;
|
dptr = el->rawData();
|
||||||
dptr = el.rawData();
|
|
||||||
eptr = dptr + count;
|
eptr = dptr + count;
|
||||||
tptr = el.rawTime();
|
tptr = el->rawTime();
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// Skip data previous to minx bounds
|
// Skip data previous to minx bounds
|
||||||
@ -352,22 +348,22 @@ void gLineOverlaySummary::paint(QPainter &painter, gGraph &w, const QRegion ®
|
|||||||
double sum = 0;
|
double sum = 0;
|
||||||
bool isSpan = false;
|
bool isSpan = false;
|
||||||
|
|
||||||
for (int i = 0; i < m_overlays.size(); i++) {
|
for (const auto & lobar : m_overlays) {
|
||||||
cnt += m_overlays[i]->count();
|
cnt += lobar->count();
|
||||||
sum += m_overlays[i]->sum();
|
sum += lobar->sum();
|
||||||
|
|
||||||
if (m_overlays[i]->flagtype() == FT_Span) { isSpan = true; }
|
if (lobar->flagtype() == FT_Span) { isSpan = true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
double val, first, last;
|
double val, first, last;
|
||||||
double time = 0;
|
double time = 0;
|
||||||
|
|
||||||
// Calculate the session time.
|
// Calculate the session time.
|
||||||
for (QList<Session *>::iterator s = m_day->begin(); s != m_day->end(); s++) {
|
for (const auto & sess : m_day->sessions) {
|
||||||
if (!(*s)->enabled()) { continue; }
|
if (!sess->enabled()) { continue; }
|
||||||
|
|
||||||
first = (*s)->first();
|
first = sess->first();
|
||||||
last = (*s)->last();
|
last = sess->last();
|
||||||
|
|
||||||
if (last < w.min_x) { continue; }
|
if (last < w.min_x) { continue; }
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* gSegmentChart Implementation
|
/* gSegmentChart Implementation
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011-2018 Mark Watkins <mark@jedimark.net>
|
* Copyright (c) 2011-2018 Mark Watkins <mark@jedimark.net>
|
||||||
*
|
*
|
||||||
@ -33,13 +33,17 @@ void gSegmentChart::SetDay(Day *d)
|
|||||||
|
|
||||||
if (!m_day) { return; }
|
if (!m_day) { return; }
|
||||||
|
|
||||||
for (int c = 0; c < m_codes.size(); c++) {
|
|
||||||
m_values[c] = 0;
|
|
||||||
|
|
||||||
for (QList<Session *>::iterator s = m_day->begin(); s != m_day->end(); ++s) {
|
for (int c = 0; c < m_codes.size(); c++) {
|
||||||
if ((*s)->enabled() && (*s)->m_cnt.contains(m_codes[c])) {
|
auto & mval = m_values[c];
|
||||||
EventDataType cnt = (*s)->count(m_codes[c]);
|
auto & mcode = m_codes[c];
|
||||||
m_values[c] += cnt;
|
|
||||||
|
mval = 0;
|
||||||
|
|
||||||
|
for (const auto & sess : m_day->sessions) {
|
||||||
|
if (sess->enabled() && sess->m_cnt.contains(mcode)) {
|
||||||
|
EventDataType cnt = sess->count(mcode);
|
||||||
|
mval += cnt;
|
||||||
m_total += cnt;
|
m_total += cnt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,8 +51,8 @@ void gSegmentChart::SetDay(Day *d)
|
|||||||
|
|
||||||
m_empty = true;
|
m_empty = true;
|
||||||
|
|
||||||
for (int i = 0; i < m_codes.size(); i++) {
|
for (const auto & mc : m_codes) {
|
||||||
if (m_day->count(m_codes[i]) > 0) {
|
if (m_day->count(mc) > 0) {
|
||||||
m_empty = false;
|
m_empty = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -249,27 +253,25 @@ void gTAPGraph::SetDay(Day *d)
|
|||||||
EventDataType gain = 1, offset = 0;
|
EventDataType gain = 1, offset = 0;
|
||||||
QHash<ChannelID, QVector<EventList *> >::iterator ei;
|
QHash<ChannelID, QVector<EventList *> >::iterator ei;
|
||||||
|
|
||||||
for (QList<Session *>::iterator s = m_day->begin(); s != m_day->end(); ++s) {
|
for (const auto & sess : m_day->sessions) {
|
||||||
if (!(*s)->enabled()) { continue; }
|
if (!sess->enabled()) { continue; }
|
||||||
|
|
||||||
if ((ei = (*s)->eventlist.find(m_code)) == (*s)->eventlist.end()) { continue; }
|
ei = sess->eventlist.find(m_code);
|
||||||
|
if (ei == sess->eventlist.end()) { continue; }
|
||||||
|
|
||||||
for (int q = 0; q < ei.value().size(); q++) {
|
for (const auto & el : ei.value()) {
|
||||||
EventList &el = *(ei.value()[q]);
|
lasttime = el->time(0);
|
||||||
lasttime = el.time(0);
|
lastval = el->raw(0);
|
||||||
lastval = el.raw(0);
|
|
||||||
|
|
||||||
if (rfirst) {
|
if (rfirst) {
|
||||||
gain = el.gain();
|
gain = el->gain();
|
||||||
offset = el.offset();
|
offset = el->offset();
|
||||||
rfirst = false;
|
rfirst = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//first=true;
|
for (quint32 i=1, end=el->count(); i < end; i++) {
|
||||||
//changed=false;
|
data = el->raw(i);
|
||||||
for (quint32 i = 1; i < el.count(); i++) {
|
time = el->time(i);
|
||||||
data = el.raw(i);
|
|
||||||
time = el.time(i);
|
|
||||||
|
|
||||||
if (lastval != data) {
|
if (lastval != data) {
|
||||||
qint64 v = (time - lasttime);
|
qint64 v = (time - lasttime);
|
||||||
@ -303,7 +305,7 @@ void gTAPGraph::SetDay(Day *d)
|
|||||||
m_total = 0;
|
m_total = 0;
|
||||||
EventDataType val;
|
EventDataType val;
|
||||||
|
|
||||||
for (QMap<EventStoreType, qint64>::iterator i = tap.begin(); i != tap.end(); i++) {
|
for (auto i=tap.begin(), end=tap.end(); i != end; i++) {
|
||||||
val = float(i.key()) * gain + offset;
|
val = float(i.key()) * gain + offset;
|
||||||
|
|
||||||
m_values.push_back(i.value() / 1000L);
|
m_values.push_back(i.value() / 1000L);
|
||||||
|
@ -77,7 +77,7 @@ void gSummaryChart::SetDay(Day *unused_day)
|
|||||||
QDate date = firstday;
|
QDate date = firstday;
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
do {
|
do {
|
||||||
QMap<QDate, Day *>::iterator di = p_profile->daylist.find(date);
|
auto di = p_profile->daylist.find(date);
|
||||||
Day * day = nullptr;
|
Day * day = nullptr;
|
||||||
if (di != p_profile->daylist.end()) {
|
if (di != p_profile->daylist.end()) {
|
||||||
day = di.value();
|
day = di.value();
|
||||||
@ -146,7 +146,7 @@ bool gSummaryChart::mouseReleaseEvent(QMouseEvent *event, gGraph *graph)
|
|||||||
|
|
||||||
date = date.addDays(idx);
|
date = date.addDays(idx);
|
||||||
|
|
||||||
QMap<QDate, int>::iterator it = dayindex.find(date);
|
auto it = dayindex.find(date);
|
||||||
if (it != dayindex.end()) {
|
if (it != dayindex.end()) {
|
||||||
Day * day = daylist.at(it.value());
|
Day * day = daylist.at(it.value());
|
||||||
if (day) {
|
if (day) {
|
||||||
@ -162,8 +162,7 @@ void gSummaryChart::preCalc()
|
|||||||
{
|
{
|
||||||
midcalc = p_profile->general->prefCalcMiddle();
|
midcalc = p_profile->general->prefCalcMiddle();
|
||||||
|
|
||||||
for (int i=0; i<calcitems.size(); ++i) {
|
for (auto & calc : calcitems) {
|
||||||
SummaryCalcItem & calc = calcitems[i];
|
|
||||||
calc.reset(idx_end - idx_start, midcalc);
|
calc.reset(idx_end - idx_start, midcalc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,6 +174,7 @@ void gSummaryChart::customCalc(Day *day, QVector<SummaryChartSlice> & slices)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float hour = day->hours(m_machtype);
|
float hour = day->hours(m_machtype);
|
||||||
|
|
||||||
for (int i=0; i < size; ++i) {
|
for (int i=0; i < size; ++i) {
|
||||||
const SummaryChartSlice & slice = slices.at(i);
|
const SummaryChartSlice & slice = slices.at(i);
|
||||||
SummaryCalcItem & calc = calcitems[i];
|
SummaryCalcItem & calc = calcitems[i];
|
||||||
@ -208,8 +208,8 @@ void gSummaryChart::afterDraw(QPainter &painter, gGraph &graph, QRect rect)
|
|||||||
|
|
||||||
schema::Channel & chan = schema::channel[calcitems.at(0).code];
|
schema::Channel & chan = schema::channel[calcitems.at(0).code];
|
||||||
|
|
||||||
for (int i=0; i<calcitems.size(); ++i) {
|
for (auto & calc : calcitems) {
|
||||||
SummaryCalcItem & calc = calcitems[i];
|
|
||||||
if (calcitems.size() == 1) {
|
if (calcitems.size() == 1) {
|
||||||
float val = calc.min;
|
float val = calc.min;
|
||||||
if (val < 99998)
|
if (val < 99998)
|
||||||
@ -303,10 +303,9 @@ void gSummaryChart::afterDraw(QPainter &painter, gGraph &graph, QRect rect)
|
|||||||
|
|
||||||
QString gSummaryChart::tooltipData(Day *, int idx)
|
QString gSummaryChart::tooltipData(Day *, int idx)
|
||||||
{
|
{
|
||||||
QVector<SummaryChartSlice> & slices = cache[idx];
|
|
||||||
QString txt;
|
QString txt;
|
||||||
for (int i=0; i< slices.size(); ++i) {
|
const auto & slices = cache[idx];
|
||||||
SummaryChartSlice & slice = slices[i];
|
for (const auto & slice : slices) {
|
||||||
txt += QString("\n%1: %2").arg(slice.name).arg(float(slice.value), 0, 'f', 2);
|
txt += QString("\n%1: %2").arg(slice.name).arg(float(slice.value), 0, 'f', 2);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -316,10 +315,8 @@ QString gSummaryChart::tooltipData(Day *, int idx)
|
|||||||
void gSummaryChart::populate(Day * day, int idx)
|
void gSummaryChart::populate(Day * day, int idx)
|
||||||
{
|
{
|
||||||
|
|
||||||
int size = calcitems.size();
|
|
||||||
bool good = false;
|
bool good = false;
|
||||||
for (int i=0; i < size; ++i) {
|
for (const auto & item : calcitems) {
|
||||||
const SummaryCalcItem & item = calcitems.at(i);
|
|
||||||
if (day->hasData(item.code, item.type)) {
|
if (day->hasData(item.code, item.type)) {
|
||||||
good = true;
|
good = true;
|
||||||
break;
|
break;
|
||||||
@ -327,12 +324,12 @@ void gSummaryChart::populate(Day * day, int idx)
|
|||||||
}
|
}
|
||||||
if (!good) return;
|
if (!good) return;
|
||||||
|
|
||||||
QVector<SummaryChartSlice> & slices = cache[idx];
|
auto & slices = cache[idx];
|
||||||
|
|
||||||
float hours = day->hours(m_machtype);
|
float hours = day->hours(m_machtype);
|
||||||
float base = 0;
|
float base = 0;
|
||||||
for (int i=0; i < size; ++i) {
|
|
||||||
SummaryCalcItem & item = calcitems[i];
|
for (auto & item : calcitems) {
|
||||||
ChannelID code = item.code;
|
ChannelID code = item.code;
|
||||||
schema::Channel & chan = schema::channel[code];
|
schema::Channel & chan = schema::channel[code];
|
||||||
float value = 0;
|
float value = 0;
|
||||||
@ -413,7 +410,7 @@ void gSummaryChart::paint(QPainter &painter, gGraph &graph, const QRegion ®io
|
|||||||
|
|
||||||
//float lasty1 = rect.bottom();
|
//float lasty1 = rect.bottom();
|
||||||
|
|
||||||
QMap<QDate, int>::iterator it = dayindex.find(date);
|
auto it = dayindex.find(date);
|
||||||
idx_start = 0;
|
idx_start = 0;
|
||||||
if (it == dayindex.end()) {
|
if (it == dayindex.end()) {
|
||||||
it = dayindex.begin();
|
it = dayindex.begin();
|
||||||
@ -423,7 +420,7 @@ void gSummaryChart::paint(QPainter &painter, gGraph &graph, const QRegion ®io
|
|||||||
|
|
||||||
int idx = idx_start;
|
int idx = idx_start;
|
||||||
|
|
||||||
QMap<QDate, int>::iterator ite = dayindex.find(enddate);
|
auto ite = dayindex.find(enddate);
|
||||||
idx_end = daylist.size()-1;
|
idx_end = daylist.size()-1;
|
||||||
if (ite != dayindex.end()) {
|
if (ite != dayindex.end()) {
|
||||||
idx_end = ite.value();
|
idx_end = ite.value();
|
||||||
@ -486,7 +483,7 @@ void gSummaryChart::paint(QPainter &painter, gGraph &graph, const QRegion ®io
|
|||||||
|
|
||||||
day->OpenSummary();
|
day->OpenSummary();
|
||||||
|
|
||||||
QHash<int, QVector<SummaryChartSlice> >::iterator cit = cache.find(i);
|
auto cit = cache.find(i);
|
||||||
|
|
||||||
if (cit == cache.end()) {
|
if (cit == cache.end()) {
|
||||||
populate(day, i);
|
populate(day, i);
|
||||||
@ -494,11 +491,8 @@ void gSummaryChart::paint(QPainter &painter, gGraph &graph, const QRegion ®io
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cit != cache.end()) {
|
if (cit != cache.end()) {
|
||||||
QVector<SummaryChartSlice> & list = cit.value();
|
|
||||||
float base = 0, val;
|
float base = 0, val;
|
||||||
int listsize = list.size();
|
for (const auto & slice : cit.value()) {
|
||||||
for (int j=0; j < listsize; ++j) {
|
|
||||||
SummaryChartSlice & slice = list[j];
|
|
||||||
val = slice.height;
|
val = slice.height;
|
||||||
base += val;
|
base += val;
|
||||||
}
|
}
|
||||||
@ -559,7 +553,7 @@ void gSummaryChart::paint(QPainter &painter, gGraph &graph, const QRegion ®io
|
|||||||
hlday = true;
|
hlday = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, QVector<SummaryChartSlice> >::iterator cit = cache.find(idx);
|
auto cit = cache.find(idx);
|
||||||
|
|
||||||
if (cit == cache.end()) {
|
if (cit == cache.end()) {
|
||||||
populate(day, idx);
|
populate(day, idx);
|
||||||
@ -574,12 +568,9 @@ void gSummaryChart::paint(QPainter &painter, gGraph &graph, const QRegion ®io
|
|||||||
QVector<SummaryChartSlice> & list = cit.value();
|
QVector<SummaryChartSlice> & list = cit.value();
|
||||||
customCalc(day, list);
|
customCalc(day, list);
|
||||||
|
|
||||||
int listsize = list.size();
|
|
||||||
QLinearGradient gradient(lastx1, 0, lastx1 + barw, 0); //rect.bottom(), barw, rect.bottom());
|
QLinearGradient gradient(lastx1, 0, lastx1 + barw, 0); //rect.bottom(), barw, rect.bottom());
|
||||||
|
|
||||||
for (int i=0; i < listsize; ++i) {
|
for (const auto & slice : list) {
|
||||||
SummaryChartSlice & slice = list[i];
|
|
||||||
|
|
||||||
val = slice.height;
|
val = slice.height;
|
||||||
y1 = ((lastval-miny) * ymult);
|
y1 = ((lastval-miny) * ymult);
|
||||||
y2 = (val * ymult);
|
y2 = (val * ymult);
|
||||||
@ -608,14 +599,11 @@ void gSummaryChart::paint(QPainter &painter, gGraph &graph, const QRegion ®io
|
|||||||
}
|
}
|
||||||
|
|
||||||
lastval += val;
|
lastval += val;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lastx1 = x1;
|
lastx1 = x1;
|
||||||
it++;
|
it++;
|
||||||
|
|
||||||
} while (++idx <= idx_end);
|
} while (++idx <= idx_end);
|
||||||
painter.setPen(QPen(Qt::black,1));
|
painter.setPen(QPen(Qt::black,1));
|
||||||
painter.drawRects(outlines);
|
painter.drawRects(outlines);
|
||||||
@ -756,11 +744,9 @@ void gSessionTimesChart::customCalc(Day *, QVector<SummaryChartSlice> & slices)
|
|||||||
calc1.update(slices.size(), 1);
|
calc1.update(slices.size(), 1);
|
||||||
|
|
||||||
EventDataType max = 0;
|
EventDataType max = 0;
|
||||||
for (int i=0; i<size; ++i) {
|
|
||||||
SummaryChartSlice & slice = slices[i];
|
|
||||||
SummaryCalcItem & calc = *slice.calc;
|
|
||||||
|
|
||||||
calc.update(slice.height, slice.height);
|
for (auto & slice : slices) {
|
||||||
|
slice.calc->update(slice.height, slice.height);
|
||||||
|
|
||||||
max = qMax(slice.height, max);
|
max = qMax(slice.height, max);
|
||||||
}
|
}
|
||||||
@ -837,7 +823,7 @@ void gSessionTimesChart::paint(QPainter &painter, gGraph &graph, const QRegion &
|
|||||||
// float lasty1 = rect.bottom();
|
// float lasty1 = rect.bottom();
|
||||||
float lastx1 = rect.left();
|
float lastx1 = rect.left();
|
||||||
|
|
||||||
QMap<QDate, int>::iterator it = dayindex.find(date);
|
auto it = dayindex.find(date);
|
||||||
int idx=0;
|
int idx=0;
|
||||||
|
|
||||||
if (it == dayindex.end()) {
|
if (it == dayindex.end()) {
|
||||||
@ -846,7 +832,7 @@ void gSessionTimesChart::paint(QPainter &painter, gGraph &graph, const QRegion &
|
|||||||
idx = it.value();
|
idx = it.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QDate, int>::iterator ite = dayindex.find(enddate);
|
auto ite = dayindex.find(enddate);
|
||||||
int idx_end = daylist.size()-1;
|
int idx_end = daylist.size()-1;
|
||||||
if (ite != dayindex.end()) {
|
if (ite != dayindex.end()) {
|
||||||
idx_end = ite.value();
|
idx_end = ite.value();
|
||||||
@ -860,14 +846,14 @@ void gSessionTimesChart::paint(QPainter &painter, gGraph &graph, const QRegion &
|
|||||||
int size = idx_end - idx;
|
int size = idx_end - idx;
|
||||||
outlines.reserve(size * 5);
|
outlines.reserve(size * 5);
|
||||||
|
|
||||||
QMap<QDate, int>::iterator it2 = it;
|
auto it2 = it;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
/// Calculate Graph Peaks
|
/// Calculate Graph Peaks
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
peak_value = 0;
|
peak_value = 0;
|
||||||
min_value = 999;
|
min_value = 999;
|
||||||
QMap<QDate, int>::iterator it_end = dayindex.end();
|
auto it_end = dayindex.end();
|
||||||
|
|
||||||
float right_edge = (rect.left()+rect.width()+1);
|
float right_edge = (rect.left()+rect.width()+1);
|
||||||
for (int i=idx; (i <= idx_end) && (it2 != it_end); ++i, ++it2, lastx1 += barw) {
|
for (int i=idx; (i <= idx_end) && (it2 != it_end); ++i, ++it2, lastx1 += barw) {
|
||||||
@ -880,13 +866,12 @@ void gSessionTimesChart::paint(QPainter &painter, gGraph &graph, const QRegion &
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, QVector<SummaryChartSlice> >::iterator cit = cache.find(i);
|
auto cit = cache.find(i);
|
||||||
|
|
||||||
if (cit == cache.end()) {
|
if (cit == cache.end()) {
|
||||||
day->OpenSummary();
|
day->OpenSummary();
|
||||||
date = it2.key();
|
date = it2.key();
|
||||||
splittime = QDateTime(date, split);
|
splittime = QDateTime(date, split);
|
||||||
QList<Session *>::iterator si;
|
|
||||||
|
|
||||||
QVector<SummaryChartSlice> & slices = cache[i];
|
QVector<SummaryChartSlice> & slices = cache[i];
|
||||||
|
|
||||||
@ -896,16 +881,13 @@ void gSessionTimesChart::paint(QPainter &painter, gGraph &graph, const QRegion &
|
|||||||
|
|
||||||
QString datestr = date.toString(Qt::SystemLocaleShortDate);
|
QString datestr = date.toString(Qt::SystemLocaleShortDate);
|
||||||
|
|
||||||
for (si = day->begin(); si != day->end(); ++si) {
|
for (const auto & sess : day->sessions) {
|
||||||
Session *sess = (*si);
|
|
||||||
if (!sess->enabled() || (sess->type() != m_machtype)) continue;
|
if (!sess->enabled() || (sess->type() != m_machtype)) continue;
|
||||||
|
|
||||||
// Look at mask on/off slices...
|
// Look at mask on/off slices...
|
||||||
int slize = sess->m_slices.size();
|
if (sess->m_slices.size() > 0) {
|
||||||
if (slize > 0) {
|
|
||||||
// segments
|
// segments
|
||||||
for (int j=0; j<slize; ++j) {
|
for (const auto & slice : sess->m_slices) {
|
||||||
const SessionSlice & slice = sess->m_slices.at(j);
|
|
||||||
QDateTime st = QDateTime::fromMSecsSinceEpoch(slice.start, Qt::LocalTime);
|
QDateTime st = QDateTime::fromMSecsSinceEpoch(slice.start, Qt::LocalTime);
|
||||||
|
|
||||||
float s1 = float(splittime.secsTo(st)) / 3600.0;
|
float s1 = float(splittime.secsTo(st)) / 3600.0;
|
||||||
@ -936,13 +918,9 @@ void gSessionTimesChart::paint(QPainter &painter, gGraph &graph, const QRegion &
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cit != cache.end()) {
|
if (cit != cache.end()) {
|
||||||
QVector<SummaryChartSlice> & list = cit.value();
|
|
||||||
int listsize = list.size();
|
|
||||||
|
|
||||||
float peak = 0, base = 999;
|
float peak = 0, base = 999;
|
||||||
|
|
||||||
for (int j=0; j < listsize; ++j) {
|
for (const auto & slice : cit.value()) {
|
||||||
SummaryChartSlice & slice = list[j];
|
|
||||||
float s1 = slice.value;
|
float s1 = slice.value;
|
||||||
float s2 = slice.height;
|
float s2 = slice.height;
|
||||||
|
|
||||||
@ -994,7 +972,7 @@ void gSessionTimesChart::paint(QPainter &painter, gGraph &graph, const QRegion &
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, QVector<SummaryChartSlice> >::iterator cit = cache.find(idx);
|
auto cit = cache.find(idx);
|
||||||
|
|
||||||
float x1 = lastx1 + barw;
|
float x1 = lastx1 + barw;
|
||||||
|
|
||||||
@ -1011,12 +989,10 @@ void gSessionTimesChart::paint(QPainter &painter, gGraph &graph, const QRegion &
|
|||||||
QVector<SummaryChartSlice> & slices = cit.value();
|
QVector<SummaryChartSlice> & slices = cit.value();
|
||||||
|
|
||||||
customCalc(day, slices);
|
customCalc(day, slices);
|
||||||
int size = slices.size();
|
|
||||||
|
|
||||||
QLinearGradient gradient(lastx1, rect.bottom(), lastx1+barw, rect.bottom());
|
QLinearGradient gradient(lastx1, rect.bottom(), lastx1+barw, rect.bottom());
|
||||||
|
|
||||||
for (int i=0; i < size; ++i) {
|
for (const auto & slice : slices) {
|
||||||
const SummaryChartSlice & slice = slices.at(i);
|
|
||||||
float s1 = slice.value - miny;
|
float s1 = slice.value - miny;
|
||||||
float s2 = slice.height;
|
float s2 = slice.height;
|
||||||
|
|
||||||
@ -1028,7 +1004,6 @@ void gSessionTimesChart::paint(QPainter &painter, gGraph &graph, const QRegion &
|
|||||||
QRect rec(lastx1, rect.bottom() - y1 - y2, barw, y2);
|
QRect rec(lastx1, rect.bottom() - y1 - y2, barw, y2);
|
||||||
rec = rec.intersected(rect);
|
rec = rec.intersected(rect);
|
||||||
|
|
||||||
// QBrush brush = slice.brush;
|
|
||||||
if (rec.contains(mouse)) {
|
if (rec.contains(mouse)) {
|
||||||
col = Qt::yellow;
|
col = Qt::yellow;
|
||||||
graph.ToolTip(slice.name, mouse.x() - 15,mouse.y() + 15, TT_AlignRight);
|
graph.ToolTip(slice.name, mouse.x() - 15,mouse.y() + 15, TT_AlignRight);
|
||||||
@ -1068,6 +1043,7 @@ void gTTIAChart::preCalc()
|
|||||||
{
|
{
|
||||||
gSummaryChart::preCalc();
|
gSummaryChart::preCalc();
|
||||||
}
|
}
|
||||||
|
|
||||||
void gTTIAChart::customCalc(Day *, QVector<SummaryChartSlice> & slices)
|
void gTTIAChart::customCalc(Day *, QVector<SummaryChartSlice> & slices)
|
||||||
{
|
{
|
||||||
if (slices.size() == 0) return;
|
if (slices.size() == 0) return;
|
||||||
@ -1075,13 +1051,12 @@ void gTTIAChart::customCalc(Day *, QVector<SummaryChartSlice> & slices)
|
|||||||
|
|
||||||
calcitems[0].update(slice.value, slice.value);
|
calcitems[0].update(slice.value, slice.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gTTIAChart::afterDraw(QPainter &, gGraph &graph, QRect rect)
|
void gTTIAChart::afterDraw(QPainter &, gGraph &graph, QRect rect)
|
||||||
{
|
{
|
||||||
QStringList txtlist;
|
QStringList txtlist;
|
||||||
int num_channels = calcitems.size();
|
|
||||||
|
|
||||||
for (int i=0; i < num_channels; ++i) {
|
for (auto & calc : calcitems) {
|
||||||
SummaryCalcItem & calc = calcitems[i];
|
|
||||||
//ChannelID code = calc.code;
|
//ChannelID code = calc.code;
|
||||||
//schema::Channel & chan = schema::channel[code];
|
//schema::Channel & chan = schema::channel[code];
|
||||||
float mid = 0;
|
float mid = 0;
|
||||||
@ -1108,6 +1083,7 @@ void gTTIAChart::afterDraw(QPainter &, gGraph &graph, QRect rect)
|
|||||||
QString txt = txtlist.join(", ");
|
QString txt = txtlist.join(", ");
|
||||||
graph.renderText(txt, rect.left(), rect.top()-5*graph.printScaleY(), 0);
|
graph.renderText(txt, rect.left(), rect.top()-5*graph.printScaleY(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gTTIAChart::populate(Day *day, int idx)
|
void gTTIAChart::populate(Day *day, int idx)
|
||||||
{
|
{
|
||||||
QVector<SummaryChartSlice> & slices = cache[idx];
|
QVector<SummaryChartSlice> & slices = cache[idx];
|
||||||
@ -1116,9 +1092,8 @@ void gTTIAChart::populate(Day *day, int idx)
|
|||||||
int m = int(ttia) / 60 % 60;
|
int m = int(ttia) / 60 % 60;
|
||||||
int s = int(ttia) % 60;
|
int s = int(ttia) % 60;
|
||||||
slices.append(SummaryChartSlice(&calcitems[0], ttia / 60.0, ttia / 60.0, QObject::tr("\nTTIA: %1").arg(QString().sprintf("%02i:%02i:%02i",h,m,s)), QColor(255,147,150)));
|
slices.append(SummaryChartSlice(&calcitems[0], ttia / 60.0, ttia / 60.0, QObject::tr("\nTTIA: %1").arg(QString().sprintf("%02i:%02i:%02i",h,m,s)), QColor(255,147,150)));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString gTTIAChart::tooltipData(Day *, int idx)
|
QString gTTIAChart::tooltipData(Day *, int idx)
|
||||||
{
|
{
|
||||||
QVector<SummaryChartSlice> & slices = cache[idx];
|
QVector<SummaryChartSlice> & slices = cache[idx];
|
||||||
@ -1151,8 +1126,8 @@ void gAHIChart::customCalc(Day *day, QVector<SummaryChartSlice> &list)
|
|||||||
if (size == 0) return;
|
if (size == 0) return;
|
||||||
EventDataType hours = day->hours(m_machtype);
|
EventDataType hours = day->hours(m_machtype);
|
||||||
EventDataType ahi_cnt = 0;
|
EventDataType ahi_cnt = 0;
|
||||||
for (int i=0; i < size; ++i) {
|
|
||||||
SummaryChartSlice & slice = list[i];
|
for (auto & slice : list) {
|
||||||
SummaryCalcItem * calc = slice.calc;
|
SummaryCalcItem * calc = slice.calc;
|
||||||
|
|
||||||
EventDataType value = slice.value;
|
EventDataType value = slice.value;
|
||||||
@ -1171,8 +1146,6 @@ void gAHIChart::customCalc(Day *day, QVector<SummaryChartSlice> &list)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
calc->min = qMin(valh, calc->min);
|
calc->min = qMin(valh, calc->min);
|
||||||
calc->max = qMax(valh, calc->max);
|
calc->max = qMax(valh, calc->max);
|
||||||
|
|
||||||
@ -1220,10 +1193,7 @@ void gAHIChart::afterDraw(QPainter & /*painter */, gGraph &graph, QRect rect)
|
|||||||
QStringList txtlist;
|
QStringList txtlist;
|
||||||
if (!skip) txtlist.append(QObject::tr("%1 %2 / %3 / %4").arg(STR_TR_AHI).arg(min_ahi, 0, 'f', 2).arg(med, 0, 'f', 2).arg(max_ahi, 0, 'f', 2));
|
if (!skip) txtlist.append(QObject::tr("%1 %2 / %3 / %4").arg(STR_TR_AHI).arg(min_ahi, 0, 'f', 2).arg(med, 0, 'f', 2).arg(max_ahi, 0, 'f', 2));
|
||||||
|
|
||||||
int num_channels = calcitems.size();
|
for (auto & calc : calcitems) {
|
||||||
|
|
||||||
for (int i=0; i < num_channels; ++i) {
|
|
||||||
SummaryCalcItem & calc = calcitems[i];
|
|
||||||
ChannelID code = calc.code;
|
ChannelID code = calc.code;
|
||||||
schema::Channel & chan = schema::channel[code];
|
schema::Channel & chan = schema::channel[code];
|
||||||
float mid = 0;
|
float mid = 0;
|
||||||
@ -1260,10 +1230,8 @@ void gAHIChart::populate(Day *day, int idx)
|
|||||||
QVector<SummaryChartSlice> & slices = cache[idx];
|
QVector<SummaryChartSlice> & slices = cache[idx];
|
||||||
|
|
||||||
float hours = day->hours();
|
float hours = day->hours();
|
||||||
int num_channels = calcitems.size();
|
|
||||||
|
|
||||||
for (int i=0; i < num_channels; ++i) {
|
for (auto & calc : calcitems) {
|
||||||
SummaryCalcItem & calc = calcitems[i];
|
|
||||||
ChannelID code = calc.code;
|
ChannelID code = calc.code;
|
||||||
if (!day->hasData(code, ST_CNT)) continue;
|
if (!day->hasData(code, ST_CNT)) continue;
|
||||||
|
|
||||||
@ -1279,11 +1247,9 @@ QString gAHIChart::tooltipData(Day *day, int idx)
|
|||||||
float total = 0;
|
float total = 0;
|
||||||
float hour = day->hours(m_machtype);
|
float hour = day->hours(m_machtype);
|
||||||
QString txt;
|
QString txt;
|
||||||
for (int i=0; i< slices.size(); ++i) {
|
for (const auto & slice : slices) {
|
||||||
SummaryChartSlice & slice = slices[i];
|
|
||||||
total += slice.value;
|
total += slice.value;
|
||||||
txt += QString("\n%1: %2").arg(slice.name).arg(float(slice.value) / hour, 0, 'f', 2);
|
txt += QString("\n%1: %2").arg(slice.name).arg(float(slice.value) / hour, 0, 'f', 2);
|
||||||
|
|
||||||
}
|
}
|
||||||
return QString("\n%1: %2").arg(STR_TR_AHI).arg(float(total) / hour,0,'f',2)+txt;
|
return QString("\n%1: %2").arg(STR_TR_AHI).arg(float(total) / hour,0,'f',2)+txt;
|
||||||
}
|
}
|
||||||
|
@ -125,9 +125,9 @@ void SummaryChart::SetDay(Day * nullday)
|
|||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
||||||
// For each day in the main profile daylist
|
// For each day in the main profile daylist
|
||||||
QMap<QDate, Day *>::iterator d;
|
|
||||||
|
|
||||||
for (d = p_profile->daylist.begin(); d != p_profile->daylist.end(); d++) {
|
for (auto d=p_profile->daylist.begin(), dend=p_profile->daylist.end(); d!=dend; ++d) {
|
||||||
|
Day * day = d.value();
|
||||||
|
|
||||||
// get the timestamp of this day.
|
// get the timestamp of this day.
|
||||||
tt = QDateTime(d.key(), QTime(0, 0, 0), Qt::UTC).toTime_t();
|
tt = QDateTime(d.key(), QTime(0, 0, 0), Qt::UTC).toTime_t();
|
||||||
@ -155,7 +155,6 @@ void SummaryChart::SetDay(Day * nullday)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// for each day object on record for this date
|
// for each day object on record for this date
|
||||||
day = d.value();
|
|
||||||
|
|
||||||
// skip any empty or irrelevant day records
|
// skip any empty or irrelevant day records
|
||||||
if (!day || (day->machine(m_machinetype) == nullptr)) { continue; }
|
if (!day || (day->machine(m_machinetype) == nullptr)) { continue; }
|
||||||
@ -168,7 +167,7 @@ void SummaryChart::SetDay(Day * nullday)
|
|||||||
// ft = first sessions time, rounded back to midnight..
|
// ft = first sessions time, rounded back to midnight..
|
||||||
|
|
||||||
// For each session in this day record
|
// For each session in this day record
|
||||||
for (int s = 0; s < day->size(); s++) {
|
for (int s=0, size=day->size(); s < size; s++) {
|
||||||
Session *sess = (*day)[s];
|
Session *sess = (*day)[s];
|
||||||
|
|
||||||
if (!sess->enabled()) { continue; }
|
if (!sess->enabled()) { continue; }
|
||||||
@ -366,8 +365,8 @@ void SummaryChart::SetDay(Day * nullday)
|
|||||||
|
|
||||||
m_empty = true;
|
m_empty = true;
|
||||||
|
|
||||||
for (int i = 0; i < m_goodcodes.size(); i++) {
|
for (const auto & goodcode : m_goodcodes) {
|
||||||
if (m_goodcodes[i]) {
|
if (goodcode) {
|
||||||
m_empty = false;
|
m_empty = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -486,7 +485,7 @@ void SummaryChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
lastY.resize(numcodes);
|
lastY.resize(numcodes);
|
||||||
int zd = minx / 86400000L;
|
int zd = minx / 86400000L;
|
||||||
zd--;
|
zd--;
|
||||||
QHash<int, QMap<short, EventDataType> >::iterator d = m_values.find(zd);
|
auto d = m_values.find(zd);
|
||||||
|
|
||||||
QVector<bool> goodcodes;
|
QVector<bool> goodcodes;
|
||||||
goodcodes.resize(m_goodcodes.size());
|
goodcodes.resize(m_goodcodes.size());
|
||||||
@ -619,7 +618,7 @@ void SummaryChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
|
|
||||||
if (graphtype == GT_SESSIONS) {
|
if (graphtype == GT_SESSIONS) {
|
||||||
int j;
|
int j;
|
||||||
QHash<int, QMap<short, EventDataType> >::iterator times = m_times.find(zd);
|
auto times = m_times.find(zd);
|
||||||
QColor col = m_colors[0];
|
QColor col = m_colors[0];
|
||||||
//if (hours<compliance_hours) col=QColor("#f03030");
|
//if (hours<compliance_hours) col=QColor("#f03030");
|
||||||
|
|
||||||
@ -637,8 +636,8 @@ void SummaryChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
int np = d.value().size();
|
int np = d.value().size();
|
||||||
|
|
||||||
if (np > 0) {
|
if (np > 0) {
|
||||||
for (int i = 0; i < goodcodes.size(); i++) {
|
for (auto & goodcode : goodcodes) {
|
||||||
goodcodes[i] = true;
|
goodcode = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -695,7 +694,7 @@ void SummaryChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
|||||||
bool good;
|
bool good;
|
||||||
SummaryType type;
|
SummaryType type;
|
||||||
|
|
||||||
for (QMap<short, EventDataType>::iterator g = d.value().begin(); g != d.value().end(); g++) {
|
for (auto g=d.value().begin(), dend=d.value().end(); g != dend; g++) {
|
||||||
short j = g.key();
|
short j = g.key();
|
||||||
|
|
||||||
if (!j) { continue; }
|
if (!j) { continue; }
|
||||||
@ -1077,7 +1076,7 @@ bool SummaryChart::mouseMoveEvent(QMouseEvent *event, gGraph *graph)
|
|||||||
hl_day = zd;
|
hl_day = zd;
|
||||||
graph->Trigger(2000);
|
graph->Trigger(2000);
|
||||||
|
|
||||||
QHash<int, QMap<short, EventDataType> >::iterator d = m_values.find(hl_day);
|
auto d = m_values.find(hl_day);
|
||||||
|
|
||||||
QMap<short, EventDataType> &valhash = d.value();
|
QMap<short, EventDataType> &valhash = d.value();
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Custom CPAP/Oximetry Calculations Header
|
/* Custom CPAP/Oximetry Calculations Header
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011-2018 Mark Watkins <mark@jedimark.net>
|
* Copyright (c) 2011-2018 Mark Watkins <mark@jedimark.net>
|
||||||
*
|
*
|
||||||
@ -19,8 +19,7 @@
|
|||||||
bool SearchEvent(Session * session, ChannelID code, qint64 time, int dur, bool update=true)
|
bool SearchEvent(Session * session, ChannelID code, qint64 time, int dur, bool update=true)
|
||||||
{
|
{
|
||||||
qint64 t, start;
|
qint64 t, start;
|
||||||
QHash<ChannelID, QVector<EventList *> >::iterator it;
|
auto it = session->eventlist.find(code);
|
||||||
it = session->eventlist.find(code);
|
|
||||||
quint32 *tptr;
|
quint32 *tptr;
|
||||||
|
|
||||||
EventStoreType *dptr;
|
EventStoreType *dptr;
|
||||||
@ -34,12 +33,10 @@ bool SearchEvent(Session * session, ChannelID code, qint64 time, int dur, bool u
|
|||||||
update=false;
|
update=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<ChannelID, QVector<EventList *> >::iterator evend = session->eventlist.end();
|
auto evend = session->eventlist.end();
|
||||||
if (it != evend) {
|
if (it != evend) {
|
||||||
int el_size=it.value().size();
|
for (const auto & el : it.value()) {
|
||||||
for (int i = 0; i < el_size; i++) {
|
//rate=el->rate();
|
||||||
EventList *el = it.value()[i];
|
|
||||||
// rate=el->rate();
|
|
||||||
cnt = el->count();
|
cnt = el->count();
|
||||||
|
|
||||||
// why would this be necessary???
|
// why would this be necessary???
|
||||||
@ -901,30 +898,22 @@ void calcRespRate(Session *session, FlowParser *flowparser)
|
|||||||
calcTv = calcMv = calcResp = true;
|
calcTv = calcMv = calcResp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<EventList *> &list = session->eventlist[CPAP_RespRate];
|
auto & list = session->eventlist[CPAP_RespRate];
|
||||||
int size = list.size();
|
for (auto & l : list) {
|
||||||
for (int i = 0; i < size; ++i) {
|
delete l;
|
||||||
delete list[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
session->eventlist[CPAP_RespRate].clear();
|
session->eventlist[CPAP_RespRate].clear();
|
||||||
|
|
||||||
QVector<EventList *> &list2 = session->eventlist[CPAP_TidalVolume];
|
auto & list2 = session->eventlist[CPAP_TidalVolume];
|
||||||
|
for (auto & l2 : list2) {
|
||||||
size = list2.size();
|
delete l2;
|
||||||
for (int i = 0; i < size; ++i) {
|
|
||||||
delete list2[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
session->eventlist[CPAP_TidalVolume].clear();
|
session->eventlist[CPAP_TidalVolume].clear();
|
||||||
|
|
||||||
QVector<EventList *> &list3 = session->eventlist[CPAP_MinuteVent];
|
auto & list3 = session->eventlist[CPAP_MinuteVent];
|
||||||
|
for (auto & l3 : list3) {
|
||||||
size = list3.size();
|
delete l3;
|
||||||
for (int i = 0; i < size; ++i) {
|
|
||||||
delete list3[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
session->eventlist[CPAP_MinuteVent].clear();
|
session->eventlist[CPAP_MinuteVent].clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -936,14 +925,9 @@ void calcRespRate(Session *session, FlowParser *flowparser)
|
|||||||
//flowparser->addFilter(FilterPercentile,7,0.5);
|
//flowparser->addFilter(FilterPercentile,7,0.5);
|
||||||
//flowparser->addFilter(FilterPercentile,5,0.5);
|
//flowparser->addFilter(FilterPercentile,5,0.5);
|
||||||
//flowparser->addFilter(FilterXPass,0.5);
|
//flowparser->addFilter(FilterXPass,0.5);
|
||||||
EventList *flow;
|
|
||||||
|
|
||||||
QVector<EventList *> &EVL = session->eventlist[CPAP_FlowRate];
|
|
||||||
int size = EVL.size();
|
|
||||||
|
|
||||||
for (int ws = 0; ws < size; ++ws) {
|
|
||||||
flow = EVL[ws];
|
|
||||||
|
|
||||||
|
auto & EVL = session->eventlist[CPAP_FlowRate];
|
||||||
|
for (auto & flow : EVL) {
|
||||||
if (flow->count() > 20) {
|
if (flow->count() > 20) {
|
||||||
flowparser->openFlow(session, flow);
|
flowparser->openFlow(session, flow);
|
||||||
flowparser->calc(calcResp, calcTv, calcTi , calcTe, calcMv);
|
flowparser->calc(calcResp, calcTv, calcTi , calcTe, calcMv);
|
||||||
@ -1258,19 +1242,15 @@ void zMaskProfile::save()
|
|||||||
|
|
||||||
void zMaskProfile::scanPressureList(Session *session, ChannelID code)
|
void zMaskProfile::scanPressureList(Session *session, ChannelID code)
|
||||||
{
|
{
|
||||||
QHash<ChannelID, QVector<EventList *> >::iterator it = session->eventlist.find(code);
|
auto it = session->eventlist.find(code);
|
||||||
|
|
||||||
if (it == session->eventlist.end()) return;
|
if (it == session->eventlist.end()) return;
|
||||||
|
|
||||||
int prescnt = session->count(code);
|
int prescnt = session->count(code);
|
||||||
Pressure.reserve(Pressure.size() + prescnt);
|
Pressure.reserve(Pressure.size() + prescnt);
|
||||||
|
|
||||||
QVector<EventList *> &EVL = it.value();
|
auto & EVL = it.value();
|
||||||
int size = EVL.size();
|
|
||||||
|
|
||||||
for (int j = 0; j < size; ++j) {
|
|
||||||
EventList * el = EVL[j];
|
|
||||||
|
|
||||||
|
for (const auto & el : EVL) {
|
||||||
qint64 start = el->first();
|
qint64 start = el->first();
|
||||||
int count = el->count();
|
int count = el->count();
|
||||||
EventStoreType *dptr = el->rawData();
|
EventStoreType *dptr = el->rawData();
|
||||||
@ -1310,7 +1290,6 @@ void zMaskProfile::scanLeakList(EventList *el)
|
|||||||
EventStoreType pressure, leak;
|
EventStoreType pressure, leak;
|
||||||
|
|
||||||
//EventDataType fleak;
|
//EventDataType fleak;
|
||||||
// QMap<EventStoreType, EventDataType>::iterator pmin;
|
|
||||||
qint64 ti;
|
qint64 ti;
|
||||||
bool found;
|
bool found;
|
||||||
|
|
||||||
@ -1386,25 +1365,17 @@ void zMaskProfile::scanLeakList(EventList *el)
|
|||||||
}
|
}
|
||||||
void zMaskProfile::scanLeaks(Session *session)
|
void zMaskProfile::scanLeaks(Session *session)
|
||||||
{
|
{
|
||||||
QHash<ChannelID, QVector<EventList *> >::iterator ELV = session->eventlist.find(CPAP_LeakTotal);
|
auto ELV = session->eventlist.find(CPAP_LeakTotal);
|
||||||
|
|
||||||
if (ELV == session->eventlist.end()) return;
|
if (ELV == session->eventlist.end()) return;
|
||||||
QVector<EventList *> &elv = ELV.value();
|
|
||||||
|
|
||||||
int size=elv.size();
|
auto & elv = ELV.value();
|
||||||
if (!size)
|
|
||||||
return;
|
|
||||||
|
|
||||||
QVector<EventList *>::iterator end = elv.end();
|
for (auto & it : elv) {
|
||||||
QVector<EventList *>::iterator it;
|
scanLeakList(it);
|
||||||
for (it = elv.begin(); it != end; ++it) {
|
|
||||||
scanLeakList(*it);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void zMaskProfile::updatePressureMin()
|
void zMaskProfile::updatePressureMin()
|
||||||
{
|
{
|
||||||
QMap<EventStoreType, QMap<EventStoreType, quint32> >::iterator it;
|
|
||||||
|
|
||||||
EventStoreType pressure;
|
EventStoreType pressure;
|
||||||
//EventDataType perc=0.1;
|
//EventDataType perc=0.1;
|
||||||
//EventDataType tmp,l1,l2;
|
//EventDataType tmp,l1,l2;
|
||||||
@ -1418,22 +1389,16 @@ void zMaskProfile::updatePressureMin()
|
|||||||
|
|
||||||
int sum1, sum2, w1, w2, N, k;
|
int sum1, sum2, w1, w2, N, k;
|
||||||
|
|
||||||
|
|
||||||
QMap<EventStoreType, QMap<EventStoreType, quint32> >::iterator plend = pressureleaks.end();
|
|
||||||
|
|
||||||
QMap<EventStoreType, quint32>::iterator lmend;
|
|
||||||
|
|
||||||
// Calculate a weighted percentile of all leak values contained within each pressure, using pressureleaks histogram
|
// Calculate a weighted percentile of all leak values contained within each pressure, using pressureleaks histogram
|
||||||
|
for (auto it = pressureleaks.begin(), plend=pressureleaks.end(); it != plend; it++) {
|
||||||
for (it = pressureleaks.begin(); it != plend; it++) {
|
|
||||||
pressure = it.key();
|
pressure = it.key();
|
||||||
QMap<EventStoreType, quint32> &leakmap = it.value();
|
QMap<EventStoreType, quint32> &leakmap = it.value();
|
||||||
//lks = leakmap.size();
|
//lks = leakmap.size();
|
||||||
SN = 0;
|
SN = 0;
|
||||||
|
|
||||||
|
auto lmend = leakmap.end();
|
||||||
// First sum total counts of all leaks
|
// First sum total counts of all leaks
|
||||||
lmend = leakmap.end();
|
for (auto lit = leakmap.begin(); lit != lmend; ++lit) {
|
||||||
for (QMap<EventStoreType, quint32>::iterator lit = leakmap.begin(); lit != lmend; ++lit) {
|
|
||||||
SN += lit.value();
|
SN += lit.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1453,14 +1418,14 @@ void zMaskProfile::updatePressureMin()
|
|||||||
double total = 0;
|
double total = 0;
|
||||||
|
|
||||||
// why do this effectively twice? and k = size
|
// why do this effectively twice? and k = size
|
||||||
for (QMap<EventStoreType, quint32>::iterator lit = leakmap.begin(); lit != lmend; ++lit, ++k) {
|
for (auto lit = leakmap.begin(); lit != lmend; ++lit, ++k) {
|
||||||
total += lit.value();
|
total += lit.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
pressuretotal[pressure] = total;
|
pressuretotal[pressure] = total;
|
||||||
|
|
||||||
k = 0;
|
k = 0;
|
||||||
for (QMap<EventStoreType, quint32>::iterator lit = leakmap.begin(); lit != lmend; ++lit, ++k) {
|
for (auto lit=leakmap.begin(); lit != lmend; ++lit, ++k) {
|
||||||
//for (k=0;k < N;k++) {
|
//for (k=0;k < N;k++) {
|
||||||
v1 = lit.key();
|
v1 = lit.key();
|
||||||
w1 = lit.value();
|
w1 = lit.value();
|
||||||
@ -1573,8 +1538,8 @@ void zMaskProfile::updateProfile(Session *session)
|
|||||||
EventDataType maxcnt, maxval, lastval; //, lastcnt;
|
EventDataType maxcnt, maxval, lastval; //, lastcnt;
|
||||||
|
|
||||||
|
|
||||||
QMap<EventStoreType, QMap<EventStoreType, quint32> >::iterator plend = pressureleaks.end();
|
auto plend = pressureleaks.end();
|
||||||
QMap<EventStoreType, QMap<EventStoreType, quint32> >::iterator it = pressureleaks.begin();
|
auto it = pressureleaks.begin();
|
||||||
|
|
||||||
QMap<EventStoreType, quint32>::iterator lit;
|
QMap<EventStoreType, quint32>::iterator lit;
|
||||||
QMap<EventStoreType, quint32>::iterator lvend;
|
QMap<EventStoreType, quint32>::iterator lvend;
|
||||||
@ -1634,13 +1599,12 @@ void zMaskProfile::updateProfile(Session *session)
|
|||||||
QMap<EventStoreType, EventDataType> pressureval2;
|
QMap<EventStoreType, EventDataType> pressureval2;
|
||||||
EventDataType max = 0, tmp2, tmp3;
|
EventDataType max = 0, tmp2, tmp3;
|
||||||
|
|
||||||
QMap<EventStoreType, EventDataType>::iterator ptit;
|
auto ptend = pressuretotal.end();
|
||||||
QMap<EventStoreType, EventDataType>::iterator ptend = pressuretotal.end();
|
for (auto ptit = pressuretotal.begin(); ptit != ptend; ++ptit) {
|
||||||
for (ptit = pressuretotal.begin(); ptit != ptend; ++ptit) {
|
|
||||||
if (max < ptit.value()) { max = ptit.value(); }
|
if (max < ptit.value()) { max = ptit.value(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ptit = pressuretotal.begin(); ptit != pressuretotal.end(); ptit++) {
|
for (auto ptit = pressuretotal.begin(); ptit != ptend; ptit++) {
|
||||||
p = ptit.key();
|
p = ptit.key();
|
||||||
tmp = pressurecount[p];
|
tmp = pressurecount[p];
|
||||||
tmp2 = ptit.value();
|
tmp2 = ptit.value();
|
||||||
@ -1674,7 +1638,7 @@ void zMaskProfile::updateProfile(Session *session)
|
|||||||
|
|
||||||
m_factor = (maxL - minL) / (maxP - minP);
|
m_factor = (maxL - minL) / (maxP - minP);
|
||||||
|
|
||||||
// for (QMap<EventStoreType, EventDataType>::iterator it=pressuremin.begin();it!=pressuremin.end()-1;it++) {
|
// for (auto it=pressuremin.begin();it!=pressuremin.end()-1;it++) {
|
||||||
// p1=it.key();
|
// p1=it.key();
|
||||||
// p2=(it+1).key();
|
// p2=(it+1).key();
|
||||||
// l1=it.value();
|
// l1=it.value();
|
||||||
@ -1695,7 +1659,7 @@ void zMaskProfile::updateProfile(Session *session)
|
|||||||
// QTextStream out(&f);
|
// QTextStream out(&f);
|
||||||
// EventDataType p,l,c;
|
// EventDataType p,l,c;
|
||||||
// QString fmt;
|
// QString fmt;
|
||||||
// for (QMap<EventStoreType, EventDataType>::iterator it=pressuremin.begin();it!=pressuremin.end();it++) {
|
// for (auto it=pressuremin.begin();it!=pressuremin.end();it++) {
|
||||||
// p=EventDataType(it.key()/10.0);
|
// p=EventDataType(it.key()/10.0);
|
||||||
// l=it.value();
|
// l=it.value();
|
||||||
// fmt=QString("%1,%2\n").arg(p,0,'f',1).arg(l);
|
// fmt=QString("%1,%2\n").arg(p,0,'f',1).arg(l);
|
||||||
@ -1703,9 +1667,9 @@ void zMaskProfile::updateProfile(Session *session)
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// cruft
|
// cruft
|
||||||
// for (QMap<EventStoreType, QMap<EventStoreType,quint32> >::iterator it=pressureleaks.begin();it!=pressureleaks.end();it++) {
|
// for (auto it=pressureleaks.begin();it!=pressureleaks.end();it++) {
|
||||||
// QMap<EventStoreType,quint32> & leakval=it.value();
|
// auto & leakval=it.value();
|
||||||
// for (QMap<EventStoreType,quint32>::iterator lit=leakval.begin();lit!=leakval.end();lit++) {
|
// for (auto lit=leakval.begin();lit!=leakval.end();lit++) {
|
||||||
// l=lit.key();
|
// l=lit.key();
|
||||||
// c=lit.value();
|
// c=lit.value();
|
||||||
// fmt=QString("%1,%2,%3\n").arg(p,0,'f',2).arg(l).arg(c);
|
// fmt=QString("%1,%2,%3\n").arg(p,0,'f',2).arg(l).arg(c);
|
||||||
@ -1746,8 +1710,7 @@ int calcLeaks(Session *session)
|
|||||||
|
|
||||||
EventList *leak = session->AddEventList(CPAP_Leak, EVL_Event, 1);
|
EventList *leak = session->AddEventList(CPAP_Leak, EVL_Event, 1);
|
||||||
|
|
||||||
QVector<EventList *> & EVL = session->eventlist[CPAP_LeakTotal];
|
auto & EVL = session->eventlist[CPAP_LeakTotal];
|
||||||
int evlsize = EVL.size();
|
|
||||||
|
|
||||||
TimeValue *p2, *pstr, *pend;
|
TimeValue *p2, *pstr, *pend;
|
||||||
|
|
||||||
@ -1757,17 +1720,20 @@ int calcLeaks(Session *session)
|
|||||||
pend = maskProfile->Pressure.data()+(mppressize-1);
|
pend = maskProfile->Pressure.data()+(mppressize-1);
|
||||||
|
|
||||||
// For each sessions Total Leaks list
|
// For each sessions Total Leaks list
|
||||||
for (int i = 0; i < evlsize; ++i) {
|
EventDataType gain, tmp, val;
|
||||||
EventList &el = *EVL[i];
|
int count;
|
||||||
EventDataType gain = el.gain(), tmp, val;
|
EventStoreType *dptr, *eptr, pressure;
|
||||||
int count = el.count();
|
quint32 * tptr;
|
||||||
EventStoreType *dptr = el.rawData();
|
qint64 start, ti;
|
||||||
EventStoreType *eptr = dptr + count;
|
bool found;
|
||||||
quint32 *tptr = el.rawTime();
|
|
||||||
qint64 start = el.first(), ti;
|
|
||||||
EventStoreType pressure;
|
|
||||||
|
|
||||||
bool found;
|
for (auto & el : EVL) {
|
||||||
|
gain = el->gain();
|
||||||
|
count = el->count();
|
||||||
|
dptr = el->rawData();
|
||||||
|
eptr = dptr + count;
|
||||||
|
tptr = el->rawTime();
|
||||||
|
start = el->first();
|
||||||
|
|
||||||
// Scan through this Total Leak list's data
|
// Scan through this Total Leak list's data
|
||||||
for (; dptr < eptr; ++dptr) {
|
for (; dptr < eptr; ++dptr) {
|
||||||
@ -1834,21 +1800,21 @@ void flagLargeLeaks(Session *session)
|
|||||||
|
|
||||||
EventList * LL = nullptr;
|
EventList * LL = nullptr;
|
||||||
qint64 time = 0;
|
qint64 time = 0;
|
||||||
EventDataType lastvalue=-1;
|
EventDataType value, lastvalue=-1;
|
||||||
qint64 leaktime=0;
|
qint64 leaktime=0;
|
||||||
for (int ec = 0; ec < evlsize; ++ec) {
|
int count;
|
||||||
EventList &el = *EVL[ec];
|
|
||||||
int count = el.count();
|
for (auto & el : EVL) {
|
||||||
|
count = el->count();
|
||||||
if (!count) continue;
|
if (!count) continue;
|
||||||
|
|
||||||
leaktime = 0;
|
leaktime = 0;
|
||||||
//EventDataType leakvalue = 0;
|
//EventDataType leakvalue = 0;
|
||||||
lastvalue = -1;
|
lastvalue = -1;
|
||||||
|
|
||||||
|
|
||||||
for (int i=0; i < count; ++i) {
|
for (int i=0; i < count; ++i) {
|
||||||
time = el.time(i);
|
time = el->time(i);
|
||||||
EventDataType value = el.data(i);
|
value = el->data(i);
|
||||||
if (value >= threshold) {
|
if (value >= threshold) {
|
||||||
if (lastvalue < threshold) {
|
if (lastvalue < threshold) {
|
||||||
leaktime = time;
|
leaktime = time;
|
||||||
@ -1879,7 +1845,7 @@ int calcPulseChange(Session *session)
|
|||||||
{
|
{
|
||||||
if (session->eventlist.contains(OXI_PulseChange)) { return 0; }
|
if (session->eventlist.contains(OXI_PulseChange)) { return 0; }
|
||||||
|
|
||||||
QHash<ChannelID, QVector<EventList *> >::iterator it = session->eventlist.find(OXI_Pulse);
|
auto it = session->eventlist.find(OXI_Pulse);
|
||||||
|
|
||||||
if (it == session->eventlist.end()) { return 0; }
|
if (it == session->eventlist.end()) { return 0; }
|
||||||
|
|
||||||
@ -1898,26 +1864,23 @@ int calcPulseChange(Session *session)
|
|||||||
|
|
||||||
int max;
|
int max;
|
||||||
|
|
||||||
int size = it.value().size();
|
int elcount;
|
||||||
for (int e = 0; e < size; ++e) {
|
for (auto & el : it.value()) {
|
||||||
EventList &el = *(it.value()[e]);
|
elcount = el->count();
|
||||||
|
|
||||||
int elcount=el.count();
|
|
||||||
for (int i = 0; i < elcount; ++i) {
|
for (int i = 0; i < elcount; ++i) {
|
||||||
val = el.data(i);
|
val = el->data(i);
|
||||||
time = el.time(i);
|
time = el->time(i);
|
||||||
|
|
||||||
|
|
||||||
lastt = 0;
|
lastt = 0;
|
||||||
lv = change;
|
lv = change;
|
||||||
max = 0;
|
max = 0;
|
||||||
|
|
||||||
for (int j = i + 1; j < elcount; ++j) { // scan ahead in the window
|
for (int j = i + 1; j < elcount; ++j) { // scan ahead in the window
|
||||||
time2 = el.time(j);
|
time2 = el->time(j);
|
||||||
|
|
||||||
if (time2 > time + window) { break; }
|
if (time2 > time + window) { break; }
|
||||||
|
|
||||||
val2 = el.data(j);
|
val2 = el->data(j);
|
||||||
tmp = qAbs(val2 - val);
|
tmp = qAbs(val2 - val);
|
||||||
|
|
||||||
if (tmp > lv) {
|
if (tmp > lv) {
|
||||||
@ -1958,8 +1921,7 @@ int calcSPO2Drop(Session *session)
|
|||||||
{
|
{
|
||||||
if (session->eventlist.contains(OXI_SPO2Drop)) { return 0; }
|
if (session->eventlist.contains(OXI_SPO2Drop)) { return 0; }
|
||||||
|
|
||||||
QHash<ChannelID, QVector<EventList *> >::iterator it = session->eventlist.find(OXI_SPO2);
|
auto it = session->eventlist.find(OXI_SPO2);
|
||||||
|
|
||||||
if (it == session->eventlist.end()) { return 0; }
|
if (it == session->eventlist.end()) { return 0; }
|
||||||
|
|
||||||
EventDataType val, val2, change, tmp;
|
EventDataType val, val2, change, tmp;
|
||||||
@ -1987,14 +1949,12 @@ int calcSPO2Drop(Session *session)
|
|||||||
// Calculate median baseline
|
// Calculate median baseline
|
||||||
QList<EventDataType> med;
|
QList<EventDataType> med;
|
||||||
|
|
||||||
int evsize = it.value().size();
|
int elcount;
|
||||||
for (int e = 0; e < evsize; ++e) {
|
for (auto & el : it.value()) {
|
||||||
EventList &el = *(it.value()[e]);
|
elcount = el->count();
|
||||||
|
|
||||||
int elcount = el.count();
|
|
||||||
for (int i = 0; i < elcount; i++) {
|
for (int i = 0; i < elcount; i++) {
|
||||||
val = el.data(i);
|
val = el->data(i);
|
||||||
time = el.time(i);
|
time = el->time(i);
|
||||||
|
|
||||||
if (val > 0) { med.push_back(val); }
|
if (val > 0) { med.push_back(val); }
|
||||||
|
|
||||||
@ -2026,16 +1986,14 @@ int calcSPO2Drop(Session *session)
|
|||||||
EventDataType current;
|
EventDataType current;
|
||||||
qDebug() << "Calculated baseline" << baseline;
|
qDebug() << "Calculated baseline" << baseline;
|
||||||
|
|
||||||
for (int e = 0; e < evsize; ++e) {
|
for (auto & el : it.value()) {
|
||||||
EventList &el = *(it.value()[e]);
|
elcount = el->count();
|
||||||
|
|
||||||
int elcount = el.count();
|
|
||||||
for (int i = 0; i < elcount; ++i) {
|
for (int i = 0; i < elcount; ++i) {
|
||||||
current = el.data(i);
|
current = el->data(i);
|
||||||
|
|
||||||
if (!current) { continue; }
|
if (!current) { continue; }
|
||||||
|
|
||||||
time = el.time(i);
|
time = el->time(i);
|
||||||
/*ring[rp]=val;
|
/*ring[rp]=val;
|
||||||
rtime[rp]=time;
|
rtime[rp]=time;
|
||||||
rp++;
|
rp++;
|
||||||
@ -2067,9 +2025,9 @@ int calcSPO2Drop(Session *session)
|
|||||||
min = val;
|
min = val;
|
||||||
|
|
||||||
for (int j = i; j < elcount; ++j) { // scan ahead in the window
|
for (int j = i; j < elcount; ++j) { // scan ahead in the window
|
||||||
time2 = el.time(j);
|
time2 = el->time(j);
|
||||||
//if (time2 > time+window) break;
|
//if (time2 > time+window) break;
|
||||||
val2 = el.data(j);
|
val2 = el->data(j);
|
||||||
|
|
||||||
if (val2 > baseline - change) { break; }
|
if (val2 > baseline - change) { break; }
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -172,7 +172,7 @@ class Day
|
|||||||
return d_hours = double(total_time()) / 3600000.0;
|
return d_hours = double(total_time()) / 3600000.0;
|
||||||
}
|
}
|
||||||
EventDataType hours(MachineType type) {
|
EventDataType hours(MachineType type) {
|
||||||
QHash<MachineType, EventDataType>::iterator it = d_machhours.find(type);
|
auto it = d_machhours.find(type);
|
||||||
if (it == d_machhours.end()) {
|
if (it == d_machhours.end()) {
|
||||||
return d_machhours[type] = double(total_time(type)) / 3600000.0;
|
return d_machhours[type] = double(total_time(type)) / 3600000.0;
|
||||||
}
|
}
|
||||||
|
@ -742,8 +742,7 @@ int PRS1Loader::OpenMachine(const QString & path)
|
|||||||
finishAddingSessions();
|
finishAddingSessions();
|
||||||
|
|
||||||
if (unknownCodes.size() > 0) {
|
if (unknownCodes.size() > 0) {
|
||||||
QMap<unsigned char, QStringList>::iterator it;
|
for (auto it = unknownCodes.begin(), end=unknownCodes.end(); it != end; ++it) {
|
||||||
for (it = unknownCodes.begin(); it != unknownCodes.end(); ++it) {
|
|
||||||
qDebug() << QString("Unknown CPAP Codes '0x%1' was detected during import").arg((short)it.key(), 2, 16, QChar(0));
|
qDebug() << QString("Unknown CPAP Codes '0x%1' was detected during import").arg((short)it.key(), 2, 16, QChar(0));
|
||||||
QStringList & strlist = it.value();
|
QStringList & strlist = it.value();
|
||||||
for (int i=0;i<it.value().size(); ++i) {
|
for (int i=0;i<it.value().size(); ++i) {
|
||||||
@ -2352,7 +2351,6 @@ bool PRS1Import::ParseSummaryF3()
|
|||||||
{
|
{
|
||||||
CPAPMode mode = MODE_UNKNOWN;
|
CPAPMode mode = MODE_UNKNOWN;
|
||||||
EventDataType epap, ipap;
|
EventDataType epap, ipap;
|
||||||
int duration;
|
|
||||||
|
|
||||||
QMap<unsigned char, QByteArray>::iterator it;
|
QMap<unsigned char, QByteArray>::iterator it;
|
||||||
|
|
||||||
@ -2383,11 +2381,36 @@ bool PRS1Import::ParseSummaryF3()
|
|||||||
session->settings[CPAP_Mode] = (int)mode;
|
session->settings[CPAP_Mode] = (int)mode;
|
||||||
|
|
||||||
if ((it=hbdata.find(5)) != hbdata.end()) {
|
if ((it=hbdata.find(5)) != hbdata.end()) {
|
||||||
duration = (it.value()[1] << 8 ) + it.value()[0];
|
summary_duration = (it.value()[1] << 8 ) + it.value()[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* QDateTime date = QDateTime::fromMSecsSinceEpoch(session->first());
|
||||||
|
if (date.date() == QDate(2018,5,1)) {
|
||||||
|
|
||||||
|
qDebug() << "Dumping session" << (int)session->session() << "summary file";
|
||||||
|
QString hexstr = QString("%1@0000: ").arg(session->session(),8,16,QChar('0'));
|
||||||
|
const unsigned char * data = (const unsigned char *)summary->m_data.constData();
|
||||||
|
int size = summary->m_data.size();
|
||||||
|
for (int i=0; i<size; ++i) {
|
||||||
|
unsigned char val = data[i];
|
||||||
|
hexstr += QString(" %1").arg((short)val, 2, 16, QChar('0'));
|
||||||
|
if ((i % 0x10) == 0x0f) {
|
||||||
|
qDebug() << hexstr;
|
||||||
|
hexstr = QString("%1@%2: ").arg(session->session(),8,16,QChar('0')).arg(i+1, 4, 16, QChar('0'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qDebug() << "Dumping mainblock";
|
||||||
|
for (auto it=mainblock.cbegin(), end=mainblock.cend(); it!=end; ++it) {
|
||||||
|
qDebug() << it.key() << it.value().toHex();
|
||||||
|
}
|
||||||
|
qDebug() << "Dumping hbdata";
|
||||||
|
for (auto it=hbdata.cbegin(), end=hbdata.cend(); it!=end; ++it) {
|
||||||
|
qDebug() << it.key() << it.value().toHex();
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "In date";
|
||||||
|
} */
|
||||||
|
|
||||||
summary_duration = duration;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -44,11 +44,10 @@ const QString STR_UnknownModel = "Resmed S9 ???";
|
|||||||
const QString & lookupModel(quint16 model)
|
const QString & lookupModel(quint16 model)
|
||||||
{
|
{
|
||||||
|
|
||||||
QHash<QString, QList<quint16> >::iterator end = Resmed_Model_Map.end();
|
for (auto it=Resmed_Model_Map.begin(),end = Resmed_Model_Map.end(); it != end; ++it) {
|
||||||
for (QHash<QString, QList<quint16> >::iterator it = Resmed_Model_Map.begin(); it != end; ++it) {
|
|
||||||
QList<quint16> & list = it.value();
|
QList<quint16> & list = it.value();
|
||||||
for (int i=0; i < list.size(); ++i) {
|
for (auto val : list) {
|
||||||
if (list.at(i) == model) {
|
if (val == model) {
|
||||||
return it.key();
|
return it.key();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,8 +73,7 @@ ResMedEDFParser::~ResMedEDFParser()
|
|||||||
EDFSignal *ResMedEDFParser::lookupSignal(ChannelID ch)
|
EDFSignal *ResMedEDFParser::lookupSignal(ChannelID ch)
|
||||||
{
|
{
|
||||||
// Get list of all known foreign language names for this channel
|
// Get list of all known foreign language names for this channel
|
||||||
QHash<ChannelID, QStringList>::iterator channames = resmed_codes.find(ch);
|
auto channames = resmed_codes.find(ch);
|
||||||
|
|
||||||
if (channames == resmed_codes.end()) {
|
if (channames == resmed_codes.end()) {
|
||||||
// no alternatives strings found for this channel
|
// no alternatives strings found for this channel
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -84,8 +82,8 @@ EDFSignal *ResMedEDFParser::lookupSignal(ChannelID ch)
|
|||||||
// This is bad, because ResMed thinks it was a cool idea to use two channels with the same name.
|
// This is bad, because ResMed thinks it was a cool idea to use two channels with the same name.
|
||||||
|
|
||||||
// Scan through EDF's list of signals to see if any match
|
// Scan through EDF's list of signals to see if any match
|
||||||
for (int i = 0; i < channames.value().size(); i++) {
|
for (auto & name : channames.value()) {
|
||||||
EDFSignal *sig = lookupLabel(channames.value()[i]);
|
EDFSignal *sig = lookupLabel(name);
|
||||||
if (sig) return sig;
|
if (sig) return sig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,18 +94,14 @@ EDFSignal *ResMedEDFParser::lookupSignal(ChannelID ch)
|
|||||||
// Check if given string matches any alternative signal names for this channel
|
// Check if given string matches any alternative signal names for this channel
|
||||||
bool matchSignal(ChannelID ch, const QString & name)
|
bool matchSignal(ChannelID ch, const QString & name)
|
||||||
{
|
{
|
||||||
QHash<ChannelID, QStringList>::iterator channames = resmed_codes.find(ch);
|
auto channames = resmed_codes.find(ch);
|
||||||
|
|
||||||
if (channames == resmed_codes.end()) {
|
if (channames == resmed_codes.end()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList & strings = channames.value();
|
for (auto & string : channames.value()) {
|
||||||
int size = strings.size();
|
|
||||||
|
|
||||||
for (int i=0; i < size; ++i) {
|
|
||||||
// Using starts with, because ResMed is very lazy about consistency
|
// Using starts with, because ResMed is very lazy about consistency
|
||||||
if (name.startsWith(strings.at(i), Qt::CaseInsensitive)) {
|
if (name.startsWith(string, Qt::CaseInsensitive)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,14 +111,14 @@ bool matchSignal(ChannelID ch, const QString & name)
|
|||||||
// This function parses a list of STR files and creates a date ordered map of individual records
|
// This function parses a list of STR files and creates a date ordered map of individual records
|
||||||
void ResmedLoader::ParseSTR(Machine *mach, QMap<QDate, STRFile> & STRmap)
|
void ResmedLoader::ParseSTR(Machine *mach, QMap<QDate, STRFile> & STRmap)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(mach)
|
||||||
|
|
||||||
if (!qprogress) {
|
if (!qprogress) {
|
||||||
qWarning() << "What happened to qprogress object in ResmedLoader::ParseSTR()";
|
qWarning() << "What happened to qprogress object in ResmedLoader::ParseSTR()";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QDate, STRFile>::iterator it;
|
for (auto it=STRmap.begin(), end=STRmap.end(); it != end; ++it) {
|
||||||
|
|
||||||
for (it = STRmap.begin(); it!= STRmap.end(); ++it) {
|
|
||||||
STRFile & file = it.value();
|
STRFile & file = it.value();
|
||||||
QString & strfile = file.filename;
|
QString & strfile = file.filename;
|
||||||
ResMedEDFParser & str = *file.edf;
|
ResMedEDFParser & str = *file.edf;
|
||||||
@ -151,7 +145,7 @@ void ResmedLoader::ParseSTR(Machine *mach, QMap<QDate, STRFile> & STRmap)
|
|||||||
// For each data record, representing 1 day each
|
// For each data record, representing 1 day each
|
||||||
for (int rec = 0; rec < size; ++rec, date = date.addDays(1)) {
|
for (int rec = 0; rec < size; ++rec, date = date.addDays(1)) {
|
||||||
|
|
||||||
QMap<QDate, ResMedDay>::iterator rit = resdayList.find(date);
|
auto rit = resdayList.find(date);
|
||||||
if (rit != resdayList.end()) {
|
if (rit != resdayList.end()) {
|
||||||
// Already seen this record.. should check if the data is the same, but meh.
|
// Already seen this record.. should check if the data is the same, but meh.
|
||||||
continue;
|
continue;
|
||||||
@ -1488,7 +1482,7 @@ int ResmedLoader::scanFiles(Machine * mach, const QString & datalog_path)
|
|||||||
// EDFType type = lookupEDFType(ext);
|
// EDFType type = lookupEDFType(ext);
|
||||||
|
|
||||||
// Find or create ResMedDay object for this date
|
// Find or create ResMedDay object for this date
|
||||||
QMap<QDate, ResMedDay>::iterator rd = resdayList.find(date);
|
auto rd = resdayList.find(date);
|
||||||
if (rd == resdayList.end()) {
|
if (rd == resdayList.end()) {
|
||||||
rd = resdayList.insert(date, ResMedDay());
|
rd = resdayList.insert(date, ResMedDay());
|
||||||
rd.value().date = date;
|
rd.value().date = date;
|
||||||
@ -1967,7 +1961,9 @@ struct OverlappingEDF {
|
|||||||
|
|
||||||
void ResDayTask::run()
|
void ResDayTask::run()
|
||||||
{
|
{
|
||||||
|
if (this->resday->date == QDate(2016,1,20)) {
|
||||||
|
qDebug() << "in resday" << this->resday->date;
|
||||||
|
}
|
||||||
/*loader->sessionMutex.lock();
|
/*loader->sessionMutex.lock();
|
||||||
Day *day = p_profile->FindDay(resday->date, MT_CPAP);
|
Day *day = p_profile->FindDay(resday->date, MT_CPAP);
|
||||||
if (day) {
|
if (day) {
|
||||||
@ -2054,8 +2050,7 @@ void ResDayTask::run()
|
|||||||
|
|
||||||
QMap<quint32, QString> EVElist, CSLlist;
|
QMap<quint32, QString> EVElist, CSLlist;
|
||||||
|
|
||||||
QHash<QString, QString>::iterator fit;
|
for (auto fit=resday->files.begin(), fend=resday->files.end(); fit!=fend; ++fit) {
|
||||||
for (fit=resday->files.begin(); fit!=resday->files.end(); ++fit) {
|
|
||||||
const QString & key = fit.key();
|
const QString & key = fit.key();
|
||||||
const QString & fullpath = fit.value();
|
const QString & fullpath = fit.value();
|
||||||
QString ext = key.section("_", -1).section(".",0,0).toUpper();
|
QString ext = key.section("_", -1).section(".",0,0).toUpper();
|
||||||
@ -2074,8 +2069,7 @@ void ResDayTask::run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool added = false;
|
bool added = false;
|
||||||
for (int i=0; i< overlaps.size(); i++) {
|
for (auto & ovr : overlaps) {
|
||||||
OverlappingEDF & ovr = overlaps[i];
|
|
||||||
if ((tt >= (ovr.start)) && (tt < ovr.end)) {
|
if ((tt >= (ovr.start)) && (tt < ovr.end)) {
|
||||||
ovr.filemap.insert(tt, key);
|
ovr.filemap.insert(tt, key);
|
||||||
|
|
||||||
@ -2111,16 +2105,14 @@ void ResDayTask::run()
|
|||||||
|
|
||||||
// Create an ordered map and see how far apart the sessions really are.
|
// Create an ordered map and see how far apart the sessions really are.
|
||||||
QMap<quint32, OverlappingEDF> mapov;
|
QMap<quint32, OverlappingEDF> mapov;
|
||||||
for (int i=0;i<overlaps.size();++i) {
|
for (auto & ovr : overlaps) {
|
||||||
OverlappingEDF & ovr = overlaps[i];
|
|
||||||
mapov[ovr.start] = ovr;
|
mapov[ovr.start] = ovr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Examine the gaps in between to see if we should merge sessions
|
// Examine the gaps in between to see if we should merge sessions
|
||||||
QMap<quint32, OverlappingEDF>::iterator oit;
|
for (auto oit=mapov.begin(), oend=mapov.end(); oit != oend; ++oit) {
|
||||||
for (oit=mapov.begin(); oit != mapov.end(); ++oit) {
|
|
||||||
// Get next in line
|
// Get next in line
|
||||||
QMap<quint32, OverlappingEDF>::iterator next_oit = oit+1;
|
auto next_oit = oit+1;
|
||||||
if (next_oit != mapov.end()) {
|
if (next_oit != mapov.end()) {
|
||||||
OverlappingEDF & A = oit.value();
|
OverlappingEDF & A = oit.value();
|
||||||
OverlappingEDF & B = next_oit.value();
|
OverlappingEDF & B = next_oit.value();
|
||||||
@ -2134,16 +2126,13 @@ void ResDayTask::run()
|
|||||||
|
|
||||||
if (overlaps.size()==0) return;
|
if (overlaps.size()==0) return;
|
||||||
|
|
||||||
|
|
||||||
// Now overlaps is populated with zero or more individual session groups of EDF files (zero because of sucky summary only days)
|
// Now overlaps is populated with zero or more individual session groups of EDF files (zero because of sucky summary only days)
|
||||||
for (int s=0; s<overlaps.size(); ++s) {
|
for (auto & ovr : overlaps) {
|
||||||
OverlappingEDF & ovr = overlaps[s];
|
|
||||||
if (ovr.filemap.size() == 0) continue;
|
if (ovr.filemap.size() == 0) continue;
|
||||||
Session * sess = new Session(mach, ovr.start);
|
Session * sess = new Session(mach, ovr.start);
|
||||||
ovr.sess = sess;
|
ovr.sess = sess;
|
||||||
|
|
||||||
QMultiMap<quint32,QString>::iterator mit;
|
for (auto mit=ovr.filemap.begin(), mend=ovr.filemap.end(); mit != mend; ++mit) {
|
||||||
for (mit = ovr.filemap.begin(); mit != ovr.filemap.end(); ++mit) {
|
|
||||||
const QString & filename = mit.value();
|
const QString & filename = mit.value();
|
||||||
const QString & fullpath = resday->files[filename];
|
const QString & fullpath = resday->files[filename];
|
||||||
QString ext = filename.section("_", -1).section(".",0,0).toUpper();
|
QString ext = filename.section("_", -1).section(".",0,0).toUpper();
|
||||||
@ -2172,13 +2161,11 @@ void ResDayTask::run()
|
|||||||
|
|
||||||
// Turns out there is only one or sometimes two EVE's per day, and they store data for the whole day
|
// Turns out there is only one or sometimes two EVE's per day, and they store data for the whole day
|
||||||
// So we have to extract Annotations data and apply it for all sessions
|
// So we have to extract Annotations data and apply it for all sessions
|
||||||
QMap<quint32, QString>::iterator eit;
|
for (auto eit=EVElist.begin(), eveend=EVElist.end(); eit != eveend; ++eit) {
|
||||||
for (eit = EVElist.begin(); eit != EVElist.end(); ++eit) {
|
|
||||||
const QString & fullpath = resday->files[eit.value()];
|
const QString & fullpath = resday->files[eit.value()];
|
||||||
|
|
||||||
loader->LoadEVE(ovr.sess, fullpath);
|
loader->LoadEVE(ovr.sess, fullpath);
|
||||||
}
|
}
|
||||||
for (eit = CSLlist.begin(); eit != CSLlist.end(); ++eit) {
|
for (auto eit=CSLlist.begin(), cslend=CSLlist.end(); eit != cslend; ++eit) {
|
||||||
const QString & fullpath = resday->files[eit.value()];
|
const QString & fullpath = resday->files[eit.value()];
|
||||||
loader->LoadCSL(ovr.sess, fullpath);
|
loader->LoadCSL(ovr.sess, fullpath);
|
||||||
}
|
}
|
||||||
@ -2397,7 +2384,7 @@ int ResmedLoader::Open(const QString & dirpath)
|
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
// Parse the idmap into machine objects properties, (overwriting any old values)
|
// Parse the idmap into machine objects properties, (overwriting any old values)
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
for (QHash<QString, QString>::iterator i = idmap.begin(); i != idmap.end(); i++) {
|
for (auto i=idmap.begin(), idend=idmap.end(); i != idend; i++) {
|
||||||
mach->properties[i.key()] = i.value();
|
mach->properties[i.key()] = i.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2426,10 +2413,8 @@ int ResmedLoader::Open(const QString & dirpath)
|
|||||||
dir.setFilter(QDir::Files | QDir::Hidden | QDir::Readable);
|
dir.setFilter(QDir::Files | QDir::Hidden | QDir::Readable);
|
||||||
QFileInfoList flist = dir.entryInfoList();
|
QFileInfoList flist = dir.entryInfoList();
|
||||||
|
|
||||||
int size = flist.size();
|
|
||||||
// Add any STR_Backup versions to the file list
|
// Add any STR_Backup versions to the file list
|
||||||
for (int i = 0; i < size; i++) {
|
for (auto & fi : flist) {
|
||||||
QFileInfo fi = flist.at(i);
|
|
||||||
filename = fi.fileName();
|
filename = fi.fileName();
|
||||||
if (!filename.startsWith("STR", Qt::CaseInsensitive))
|
if (!filename.startsWith("STR", Qt::CaseInsensitive))
|
||||||
continue;
|
continue;
|
||||||
@ -2439,8 +2424,7 @@ int ResmedLoader::Open(const QString & dirpath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now place any of these files in the Backup folder sorted by the file date
|
// Now place any of these files in the Backup folder sorted by the file date
|
||||||
for (int i=0;i<strfiles.size();i++) {
|
for (auto & filename : strfiles) {
|
||||||
QString filename = strfiles.at(i);
|
|
||||||
ResMedEDFParser * stredf = new ResMedEDFParser(filename);
|
ResMedEDFParser * stredf = new ResMedEDFParser(filename);
|
||||||
if (!stredf->Parse()) {
|
if (!stredf->Parse()) {
|
||||||
qDebug() << "Faulty STR file" << filename;
|
qDebug() << "Faulty STR file" << filename;
|
||||||
@ -2506,8 +2490,7 @@ int ResmedLoader::Open(const QString & dirpath)
|
|||||||
|
|
||||||
int size = flist.size();
|
int size = flist.size();
|
||||||
// Add any STR_Backup versions to the file list
|
// Add any STR_Backup versions to the file list
|
||||||
for (int i = 0; i < size; i++) {
|
for (auto & fi : flist) {
|
||||||
QFileInfo fi = flist.at(i);
|
|
||||||
filename = fi.fileName();
|
filename = fi.fileName();
|
||||||
if (!filename.startsWith("STR", Qt::CaseInsensitive))
|
if (!filename.startsWith("STR", Qt::CaseInsensitive))
|
||||||
continue;
|
continue;
|
||||||
@ -2546,8 +2529,7 @@ int ResmedLoader::Open(const QString & dirpath)
|
|||||||
ParseSTR(mach, STRmap);
|
ParseSTR(mach, STRmap);
|
||||||
|
|
||||||
// We are done with the Parsed STR EDF objects, so delete them
|
// We are done with the Parsed STR EDF objects, so delete them
|
||||||
QMap<QDate, STRFile>::iterator it;
|
for (auto it=STRmap.begin(), end=STRmap.end(); it != end; ++it) {
|
||||||
for (it=STRmap.begin(); it!= STRmap.end(); ++it) {
|
|
||||||
delete it.value().edf;
|
delete it.value().edf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2588,9 +2570,7 @@ int ResmedLoader::Open(const QString & dirpath)
|
|||||||
// Now at this point we have resdayList populated with processable summary and EDF files data
|
// Now at this point we have resdayList populated with processable summary and EDF files data
|
||||||
// that can be processed in threads..
|
// that can be processed in threads..
|
||||||
|
|
||||||
QMap<QDate, ResMedDay>::iterator rdi;
|
for (auto rdi=resdayList.begin(), rend=resdayList.end(); rdi != rend; rdi++) {
|
||||||
|
|
||||||
for (rdi = resdayList.begin(); rdi != resdayList.end(); rdi++) {
|
|
||||||
QDate date = rdi.key();
|
QDate date = rdi.key();
|
||||||
|
|
||||||
ResMedDay & resday = rdi.value();
|
ResMedDay & resday = rdi.value();
|
||||||
@ -2606,13 +2586,11 @@ int ResmedLoader::Open(const QString & dirpath)
|
|||||||
// but the worst case scenario is this session is deleted and reimported.. this just slows things down a bit in that case
|
// but the worst case scenario is this session is deleted and reimported.. this just slows things down a bit in that case
|
||||||
|
|
||||||
// This day was first imported as a summary from STR.edf, so we now totally want to redo this day
|
// This day was first imported as a summary from STR.edf, so we now totally want to redo this day
|
||||||
QList<Session *> sessions = day->getSessions(MT_CPAP);
|
for (auto & sess : day->sessions) {
|
||||||
|
if (sess->type() == MT_CPAP) {
|
||||||
// Delete sessions for this day so they recreate with a clean slate.
|
day->removeSession(sess);
|
||||||
for (int i=0;i<sessions.size();++i) {
|
delete sess;
|
||||||
Session * sess = sessions[i];
|
}
|
||||||
day->removeSession(sess);
|
|
||||||
delete sess;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reimporting = true;
|
reimporting = true;
|
||||||
@ -2747,8 +2725,7 @@ int ResmedLoader::Open(const QString & dirpath)
|
|||||||
qint64 totalns = 0;
|
qint64 totalns = 0;
|
||||||
qDebug() << "Time Delta Efficiency Information";
|
qDebug() << "Time Delta Efficiency Information";
|
||||||
|
|
||||||
for (QHash<ChannelID, qint64>::iterator it = channel_efficiency.begin();
|
for (auto it = channel_efficiency.begin(), end=channel_efficiency.end(); it != end; it++) {
|
||||||
it != channel_efficiency.end(); it++) {
|
|
||||||
ChannelID code = it.key();
|
ChannelID code = it.key();
|
||||||
qint64 value = it.value();
|
qint64 value = it.value();
|
||||||
qint64 ns = channel_time[code];
|
qint64 ns = channel_time[code];
|
||||||
@ -3154,9 +3131,7 @@ bool ResmedLoader::LoadBRP(Session *sess, const QString & path)
|
|||||||
qint64 duration = edf.GetNumDataRecords() * edf.GetDuration();
|
qint64 duration = edf.GetNumDataRecords() * edf.GetDuration();
|
||||||
sess->updateLast(edf.startdate + duration);
|
sess->updateLast(edf.startdate + duration);
|
||||||
|
|
||||||
for (int s = 0; s < edf.GetNumSignals(); s++) {
|
for (auto & es : edf.edfsignals) {
|
||||||
EDFSignal &es = edf.edfsignals[s];
|
|
||||||
|
|
||||||
long recs = es.nr * edf.GetNumDataRecords();
|
long recs = es.nr * edf.GetNumDataRecords();
|
||||||
if (recs < 0)
|
if (recs < 0)
|
||||||
continue;
|
continue;
|
||||||
@ -3338,7 +3313,7 @@ void ResmedLoader::ToTimeDelta(Session *sess, ResMedEDFParser &edf, EDFSignal &e
|
|||||||
int cnt = el->count();
|
int cnt = el->count();
|
||||||
int bytes = cnt * (sizeof(EventStoreType) + sizeof(quint32));
|
int bytes = cnt * (sizeof(EventStoreType) + sizeof(quint32));
|
||||||
int wvbytes = recs * (sizeof(EventStoreType));
|
int wvbytes = recs * (sizeof(EventStoreType));
|
||||||
QHash<ChannelID, qint64>::iterator it = channel_efficiency.find(code);
|
auto it = channel_efficiency.find(code);
|
||||||
|
|
||||||
if (it == channel_efficiency.end()) {
|
if (it == channel_efficiency.end()) {
|
||||||
channel_efficiency[code] = wvbytes - bytes;
|
channel_efficiency[code] = wvbytes - bytes;
|
||||||
@ -3362,8 +3337,7 @@ bool ResmedLoader::LoadSAD(Session *sess, const QString & path)
|
|||||||
qint64 duration = edf.GetNumDataRecords() * edf.GetDuration();
|
qint64 duration = edf.GetNumDataRecords() * edf.GetDuration();
|
||||||
sess->updateLast(edf.startdate + duration);
|
sess->updateLast(edf.startdate + duration);
|
||||||
|
|
||||||
for (int s = 0; s < edf.GetNumSignals(); s++) {
|
for (auto & es : edf.edfsignals) {
|
||||||
EDFSignal &es = edf.edfsignals[s];
|
|
||||||
//qDebug() << "SAD:" << es.label << es.digital_maximum << es.digital_minimum << es.physical_maximum << es.physical_minimum;
|
//qDebug() << "SAD:" << es.label << es.digital_maximum << es.digital_minimum << es.physical_maximum << es.physical_minimum;
|
||||||
long recs = es.nr * edf.GetNumDataRecords();
|
long recs = es.nr * edf.GetNumDataRecords();
|
||||||
ChannelID code;
|
ChannelID code;
|
||||||
@ -3419,9 +3393,8 @@ bool ResmedLoader::LoadPLD(Session *sess, const QString & path)
|
|||||||
long recs;
|
long recs;
|
||||||
ChannelID code;
|
ChannelID code;
|
||||||
|
|
||||||
for (int s = 0; s < edf.GetNumSignals(); s++) {
|
for (auto & es : edf.edfsignals) {
|
||||||
a = nullptr;
|
a = nullptr;
|
||||||
EDFSignal &es = edf.edfsignals[s];
|
|
||||||
recs = es.nr * edf.GetNumDataRecords();
|
recs = es.nr * edf.GetNumDataRecords();
|
||||||
|
|
||||||
if (recs <= 0) { continue; }
|
if (recs <= 0) { continue; }
|
||||||
|
@ -69,8 +69,8 @@ void RegisterLoader(MachineLoader *loader)
|
|||||||
}
|
}
|
||||||
void DestroyLoaders()
|
void DestroyLoaders()
|
||||||
{
|
{
|
||||||
for (QList<MachineLoader *>::iterator i = m_loaders.begin(); i != m_loaders.end(); i++) {
|
for (auto & loader : m_loaders) {
|
||||||
delete(*i);
|
delete(loader);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_loaders.clear();
|
m_loaders.clear();
|
||||||
@ -89,33 +89,17 @@ MachineLoader::MachineLoader() :QObject(nullptr)
|
|||||||
|
|
||||||
MachineLoader::~MachineLoader()
|
MachineLoader::~MachineLoader()
|
||||||
{
|
{
|
||||||
// for (QList<Machine *>::iterator m = m_machlist.begin(); m != m_machlist.end(); m++) {
|
|
||||||
// delete *m;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MachineLoader::finishAddingSessions()
|
void MachineLoader::finishAddingSessions()
|
||||||
{
|
{
|
||||||
QMap<SessionID, Session *>::iterator it;
|
|
||||||
QMap<SessionID, Session *>::iterator it_end = new_sessions.end();
|
|
||||||
|
|
||||||
// Using a map specifically so they are inserted in order.
|
// Using a map specifically so they are inserted in order.
|
||||||
for (it = new_sessions.begin(); it != it_end; ++it) {
|
for (auto it=new_sessions.begin(), end=new_sessions.end(); it != end; ++it) {
|
||||||
Session * sess = it.value();
|
Session * sess = it.value();
|
||||||
Machine * mach = sess->machine();
|
Machine * mach = sess->machine();
|
||||||
mach->AddSession(sess);
|
mach->AddSession(sess);
|
||||||
}
|
}
|
||||||
|
|
||||||
new_sessions.clear();
|
new_sessions.clear();
|
||||||
|
|
||||||
/* QHash<QString, QHash<QString, Machine *> >::iterator mlit = MachineList.find(loaderName());
|
|
||||||
|
|
||||||
if (mlit != MachineList.end()) {
|
|
||||||
for(QHash<QString, Machine *>::iterator mit = mlit.value().begin(); mit!=mlit.value().end(); ++mit) {
|
|
||||||
mit.value()->SaveSummary();
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool uncompressFile(QString infile, QString outfile)
|
bool uncompressFile(QString infile, QString outfile)
|
||||||
|
@ -86,12 +86,12 @@ Profile::~Profile()
|
|||||||
delete general;
|
delete general;
|
||||||
|
|
||||||
// delete machine objects...
|
// delete machine objects...
|
||||||
for (int i=0; i<m_machlist.size(); ++i) {
|
for (auto & mach : m_machlist) {
|
||||||
delete m_machlist[i];
|
delete mach;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (QMap<QDate, Day *>::iterator d = daylist.begin(); d != daylist.end(); d++) {
|
for (auto & day : daylist) {
|
||||||
delete d.value();
|
delete day;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -340,7 +340,7 @@ QString Environment::searchInDirectory(const QStringList & execs, QString direct
|
|||||||
if (!directory.endsWith(slash))
|
if (!directory.endsWith(slash))
|
||||||
directory += slash;
|
directory += slash;
|
||||||
|
|
||||||
foreach (const QString & exec, execs) {
|
for (auto & exec : execs) {
|
||||||
QFileInfo fi(directory + exec);
|
QFileInfo fi(directory + exec);
|
||||||
if (fi.exists() && fi.isFile() && fi.isExecutable())
|
if (fi.exists() && fi.isFile() && fi.isExecutable())
|
||||||
return fi.absoluteFilePath();
|
return fi.absoluteFilePath();
|
||||||
@ -387,7 +387,7 @@ QString Environment::searchInPath(const QString &executable, const QStringList &
|
|||||||
if (executable.indexOf(QLatin1Char('/')) != -1)
|
if (executable.indexOf(QLatin1Char('/')) != -1)
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
foreach (const QString &p, path()) {
|
for (auto & p : path()) {
|
||||||
if (alreadyChecked.contains(p))
|
if (alreadyChecked.contains(p))
|
||||||
continue;
|
continue;
|
||||||
alreadyChecked.insert(p);
|
alreadyChecked.insert(p);
|
||||||
@ -550,16 +550,14 @@ void Profile::UnloadMachineData()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QDate, Day *>::iterator it;
|
for (auto & day : daylist) {
|
||||||
for (it = daylist.begin(); it != daylist.end(); ++it) {
|
delete day;
|
||||||
delete it.value();
|
|
||||||
}
|
}
|
||||||
daylist.clear();
|
daylist.clear();
|
||||||
|
|
||||||
for (int i=0; i<m_machlist.size(); ++i) {
|
for (auto & mach : m_machlist) {
|
||||||
Machine *m = m_machlist[i];
|
mach->sessionlist.clear();
|
||||||
m->sessionlist.clear();
|
mach->day.clear();
|
||||||
m->day.clear();
|
|
||||||
}
|
}
|
||||||
removeLock();
|
removeLock();
|
||||||
}
|
}
|
||||||
@ -567,36 +565,34 @@ void Profile::LoadMachineData()
|
|||||||
{
|
{
|
||||||
addLock();
|
addLock();
|
||||||
|
|
||||||
for (int i=0; i<m_machlist.size();++i) {
|
for (auto & mach : m_machlist) {
|
||||||
Machine *m = m_machlist[i];
|
MachineLoader *loader = lookupLoader(mach);
|
||||||
|
|
||||||
MachineLoader *loader = lookupLoader(m);
|
|
||||||
|
|
||||||
if (loader) {
|
if (loader) {
|
||||||
if (m->version() < loader->Version()) {
|
if (mach->version() < loader->Version()) {
|
||||||
DataFormatError(m);
|
DataFormatError(mach);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
m->Load();
|
mach->Load();
|
||||||
} catch (OldDBVersion& e) {
|
} catch (OldDBVersion& e) {
|
||||||
Q_UNUSED(e)
|
Q_UNUSED(e)
|
||||||
DataFormatError(m);
|
DataFormatError(mach);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m->Load();
|
mach->Load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadChannels();
|
loadChannels();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Profile::removeMachine(Machine * m)
|
void Profile::removeMachine(Machine * mach)
|
||||||
{
|
{
|
||||||
m_machlist.removeAll(m);
|
m_machlist.removeAll(mach);
|
||||||
QHash<QString, QHash<QString, Machine *> >::iterator mlit = MachineList.find(m->loaderName());
|
auto mlit = MachineList.find(mach->loaderName());
|
||||||
|
|
||||||
if (mlit != MachineList.end()) {
|
if (mlit != MachineList.end()) {
|
||||||
QHash<QString, Machine *>::iterator mit = mlit.value().find(m->serial());
|
auto mit = mlit.value().find(mach->serial());
|
||||||
if (mit != mlit.value().end()) {
|
if (mit != mlit.value().end()) {
|
||||||
mlit.value().erase(mit);
|
mlit.value().erase(mit);
|
||||||
}
|
}
|
||||||
@ -606,9 +602,9 @@ void Profile::removeMachine(Machine * m)
|
|||||||
|
|
||||||
Machine * Profile::lookupMachine(QString serial, QString loadername)
|
Machine * Profile::lookupMachine(QString serial, QString loadername)
|
||||||
{
|
{
|
||||||
QHash<QString, QHash<QString, Machine *> >::iterator mlit = MachineList.find(loadername);
|
auto mlit = MachineList.find(loadername);
|
||||||
if (mlit != MachineList.end()) {
|
if (mlit != MachineList.end()) {
|
||||||
QHash<QString, Machine *>::iterator mit = mlit.value().find(serial);
|
auto mit = mlit.value().find(serial);
|
||||||
if (mit != mlit.value().end()) {
|
if (mit != mlit.value().end()) {
|
||||||
return mit.value();
|
return mit.value();
|
||||||
}
|
}
|
||||||
@ -619,13 +615,12 @@ Machine * Profile::lookupMachine(QString serial, QString loadername)
|
|||||||
|
|
||||||
Machine * Profile::CreateMachine(MachineInfo info, MachineID id)
|
Machine * Profile::CreateMachine(MachineInfo info, MachineID id)
|
||||||
{
|
{
|
||||||
|
|
||||||
Machine *m = nullptr;
|
Machine *m = nullptr;
|
||||||
|
|
||||||
QHash<QString, QHash<QString, Machine *> >::iterator mlit = MachineList.find(info.loadername);
|
auto mlit = MachineList.find(info.loadername);
|
||||||
|
|
||||||
if (mlit != MachineList.end()) {
|
if (mlit != MachineList.end()) {
|
||||||
QHash<QString, Machine *>::iterator mit = mlit.value().find(info.serial);
|
auto mit = mlit.value().find(info.serial);
|
||||||
if (mit != mlit.value().end()) {
|
if (mit != mlit.value().end()) {
|
||||||
mit.value()->setInfo(info); // update info
|
mit.value()->setInfo(info); // update info
|
||||||
return mit.value();
|
return mit.value();
|
||||||
@ -701,7 +696,7 @@ void Profile::DelMachine(Machine *m)
|
|||||||
|
|
||||||
Day *Profile::addDay(QDate date)
|
Day *Profile::addDay(QDate date)
|
||||||
{
|
{
|
||||||
QMap<QDate, Day *>::iterator dit = daylist.find(date);
|
auto dit = daylist.find(date);
|
||||||
if (dit == daylist.end()) {
|
if (dit == daylist.end()) {
|
||||||
dit = daylist.insert(date, new Day());
|
dit = daylist.insert(date, new Day());
|
||||||
}
|
}
|
||||||
@ -732,11 +727,10 @@ Day *Profile::GetGoodDay(QDate date, MachineType type)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// For a machine match, find at least one enabled Session.
|
// For a machine match, find at least one enabled Session.
|
||||||
for (int i = 0; i < day->size(); ++i) {
|
|
||||||
Session * sess = (*day)[i];
|
for (auto & sess : day->sessions) {
|
||||||
if (((type == MT_UNKNOWN) || (sess->type() == type)) && sess->enabled()) {
|
if (((type == MT_UNKNOWN) || (sess->type() == type)) && sess->enabled()) {
|
||||||
day->OpenSummary();
|
day->OpenSummary();
|
||||||
|
|
||||||
return day;
|
return day;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -752,8 +746,7 @@ Day *Profile::FindGoodDay(QDate date, MachineType type)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// For a machine match, find at least one enabled Session.
|
// For a machine match, find at least one enabled Session.
|
||||||
for (int i = 0; i < day->size(); ++i) {
|
for (auto & sess : day->sessions) {
|
||||||
Session * sess = (*day)[i];
|
|
||||||
if (((type == MT_UNKNOWN) || (sess->type() == type)) && sess->enabled()) {
|
if (((type == MT_UNKNOWN) || (sess->type() == type)) && sess->enabled()) {
|
||||||
return day;
|
return day;
|
||||||
}
|
}
|
||||||
@ -766,7 +759,7 @@ Day *Profile::FindGoodDay(QDate date, MachineType type)
|
|||||||
|
|
||||||
Day *Profile::GetDay(QDate date, MachineType type)
|
Day *Profile::GetDay(QDate date, MachineType type)
|
||||||
{
|
{
|
||||||
QMap<QDate, Day *>::iterator di = daylist.find(date);
|
auto di = daylist.find(date);
|
||||||
if (di == daylist.end()) return nullptr;
|
if (di == daylist.end()) return nullptr;
|
||||||
|
|
||||||
Day * day = di.value();
|
Day * day = di.value();
|
||||||
@ -786,7 +779,7 @@ Day *Profile::GetDay(QDate date, MachineType type)
|
|||||||
|
|
||||||
Day *Profile::FindDay(QDate date, MachineType type)
|
Day *Profile::FindDay(QDate date, MachineType type)
|
||||||
{
|
{
|
||||||
QMap<QDate, Day *>::iterator di = daylist.find(date);
|
auto di = daylist.find(date);
|
||||||
if (di == daylist.end()) return nullptr;
|
if (di == daylist.end()) return nullptr;
|
||||||
|
|
||||||
Day * day = di.value();
|
Day * day = di.value();
|
||||||
@ -815,7 +808,7 @@ int Profile::Import(QString path)
|
|||||||
|
|
||||||
QList<MachineLoader *>loaders = GetLoaders(MT_CPAP);
|
QList<MachineLoader *>loaders = GetLoaders(MT_CPAP);
|
||||||
|
|
||||||
Q_FOREACH(MachineLoader * loader, loaders) {
|
for(auto & loader : loaders) {
|
||||||
if (c += loader->Open(path)) {
|
if (c += loader->Open(path)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -826,9 +819,9 @@ int Profile::Import(QString path)
|
|||||||
|
|
||||||
MachineLoader *GetLoader(QString name)
|
MachineLoader *GetLoader(QString name)
|
||||||
{
|
{
|
||||||
QList<MachineLoader *>loaders = GetLoaders();
|
QList<MachineLoader *> loaders = GetLoaders();
|
||||||
|
|
||||||
Q_FOREACH(MachineLoader * loader, loaders) {
|
for (auto & loader : loaders) {
|
||||||
if (loader->loaderName() == name) {
|
if (loader->loaderName() == name) {
|
||||||
return loader;
|
return loader;
|
||||||
}
|
}
|
||||||
@ -843,17 +836,16 @@ QList<Machine *> Profile::GetMachines(MachineType t)
|
|||||||
{
|
{
|
||||||
QList<Machine *> vec;
|
QList<Machine *> vec;
|
||||||
|
|
||||||
for (int i=0; i<m_machlist.size(); ++i) {
|
for (auto & mach : m_machlist) {
|
||||||
Machine * m = m_machlist[i];
|
if (!mach) {
|
||||||
if (!m) {
|
|
||||||
qWarning() << "Profile::GetMachines() m == nullptr";
|
qWarning() << "Profile::GetMachines() m == nullptr";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
MachineType mt = m->type();
|
MachineType mt = mach->type();
|
||||||
|
|
||||||
if ((t == MT_UNKNOWN) || (mt == t)) {
|
if ((t == MT_UNKNOWN) || (mt == t)) {
|
||||||
vec.push_back(m);
|
vec.push_back(mach);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -905,11 +897,8 @@ Machine *Profile::GetMachine(MachineType t)
|
|||||||
|
|
||||||
bool Profile::unlinkDay(Day * day)
|
bool Profile::unlinkDay(Day * day)
|
||||||
{
|
{
|
||||||
QMap<QDate, Day *>::iterator it;
|
|
||||||
QMap<QDate, Day *>::iterator it_end = daylist.end();
|
|
||||||
|
|
||||||
// Find the key...
|
// Find the key...
|
||||||
for (it = daylist.begin(); it != it_end; ++it) {
|
for (auto it = daylist.begin(), it_end = daylist.end(); it != it_end; ++it) {
|
||||||
if (it.value() == day) {
|
if (it.value() == day) {
|
||||||
daylist.erase(it);
|
daylist.erase(it);
|
||||||
return true;
|
return true;
|
||||||
@ -995,9 +984,7 @@ void saveProfileList()
|
|||||||
|
|
||||||
root.appendChild(doc.createComment("This file is created during Profile Scan for cloud access convenience, it's not used by Desktop version of SleepyHead."));
|
root.appendChild(doc.createComment("This file is created during Profile Scan for cloud access convenience, it's not used by Desktop version of SleepyHead."));
|
||||||
|
|
||||||
QMap<QString, Profile *>::iterator it;
|
for (auto it = profiles.begin(); it != profiles.end(); ++it) {
|
||||||
|
|
||||||
for (it = profiles.begin(); it != profiles.end(); ++it) {
|
|
||||||
QDomElement elem = doc.createElement("profile");
|
QDomElement elem = doc.createElement("profile");
|
||||||
elem.setAttribute("name", it.key());
|
elem.setAttribute("name", it.key());
|
||||||
// Not technically nessesary..
|
// Not technically nessesary..
|
||||||
@ -1027,8 +1014,7 @@ int CleanupProfile(Profile *prof)
|
|||||||
<< STR_CS_UserEventPieChart << STR_AS_OverlayType << STR_AS_OverviewLinechartMode;
|
<< STR_CS_UserEventPieChart << STR_AS_OverlayType << STR_AS_OverviewLinechartMode;
|
||||||
|
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
for (int i=0; i<migrateList.length(); ++i) {
|
for (auto & prf :migrateList) {
|
||||||
const QString &prf = migrateList.at(i);
|
|
||||||
if (prof->contains(prf)) {
|
if (prof->contains(prf)) {
|
||||||
qDebug() << "Migrating profile preference" << prf;
|
qDebug() << "Migrating profile preference" << prf;
|
||||||
PREF[prf] = (*prof)[prf];
|
PREF[prf] = (*prof)[prf];
|
||||||
@ -1068,8 +1054,7 @@ void Scan()
|
|||||||
int cleanup = 0;
|
int cleanup = 0;
|
||||||
|
|
||||||
// Iterate through subdirectories and load profiles..
|
// Iterate through subdirectories and load profiles..
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (auto & fi : list) {
|
||||||
QFileInfo fi = list.at(i);
|
|
||||||
QString npath = fi.canonicalFilePath();
|
QString npath = fi.canonicalFilePath();
|
||||||
Profile *prof = new Profile(npath);
|
Profile *prof = new Profile(npath);
|
||||||
//prof->Open();
|
//prof->Open();
|
||||||
@ -1354,15 +1339,10 @@ EventDataType Profile::calcBelowThreshold(ChannelID code, EventDataType threshol
|
|||||||
|
|
||||||
Day * Profile::findSessionDay(Session * session)
|
Day * Profile::findSessionDay(Session * session)
|
||||||
{
|
{
|
||||||
// MachineType mt = session->type();
|
for (auto it=p_profile->daylist.begin(),it_end = p_profile->daylist.end(); it != it_end; ++it) {
|
||||||
|
|
||||||
QMap<QDate, Day *>::iterator it;
|
|
||||||
QMap<QDate, Day *>::iterator it_end = p_profile->daylist.end();
|
|
||||||
for (it = p_profile->daylist.begin(); it != it_end; ++it) {
|
|
||||||
Day *day = it.value();
|
Day *day = it.value();
|
||||||
for (int i=0; i<day->size(); i++) {
|
for (auto & sess : day->sessions) {
|
||||||
Session * s = day->sessions.at(i);
|
if (sess == session) {
|
||||||
if (s == session) {
|
|
||||||
return day;
|
return day;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1661,13 +1641,14 @@ EventDataType Profile::calcPercentile(ChannelID code, EventDataType percent, Mac
|
|||||||
summaryOnly = true;
|
summaryOnly = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < day->size(); i++) {
|
|
||||||
for (QList<Session *>::iterator s = day->begin(); s != day->end(); s++) {
|
// why was this nested like this???
|
||||||
if (!(*s)->enabled()) {
|
//for (int i = 0; i < day->size(); i++) {
|
||||||
|
for (auto & sess : day->sessions) {
|
||||||
|
if (!sess->enabled()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Session *sess = *s;
|
|
||||||
gain = sess->m_gain[code];
|
gain = sess->m_gain[code];
|
||||||
|
|
||||||
if (!gain) { gain = 1; }
|
if (!gain) { gain = 1; }
|
||||||
@ -1683,7 +1664,7 @@ EventDataType Profile::calcPercentile(ChannelID code, EventDataType percent, Mac
|
|||||||
QHash<EventStoreType, quint32> &tsum = tsi.value();
|
QHash<EventStoreType, quint32> &tsum = tsi.value();
|
||||||
|
|
||||||
if (timeweight) {
|
if (timeweight) {
|
||||||
for (QHash<EventStoreType, quint32>::iterator k = tsum.begin(); k != tsum.end(); k++) {
|
for (auto k=tsum.begin(), tsumend=tsum.end(); k != tsumend; k++) {
|
||||||
weight = k.value();
|
weight = k.value();
|
||||||
value = EventDataType(k.key()) * gain;
|
value = EventDataType(k.key()) * gain;
|
||||||
|
|
||||||
@ -1697,7 +1678,7 @@ EventDataType Profile::calcPercentile(ChannelID code, EventDataType percent, Mac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (QHash<EventStoreType, EventStoreType>::iterator k = vsum.begin(); k != vsum.end(); k++) {
|
for (auto k=vsum.begin(), vsumend=vsum.end(); k!=vsumend; k++) {
|
||||||
weight = k.value();
|
weight = k.value();
|
||||||
value = EventDataType(k.key()) * gain;
|
value = EventDataType(k.key()) * gain;
|
||||||
|
|
||||||
@ -1712,7 +1693,7 @@ EventDataType Profile::calcPercentile(ChannelID code, EventDataType percent, Mac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
date = date.addDays(1);
|
date = date.addDays(1);
|
||||||
@ -1879,8 +1860,7 @@ QDate Profile::LastGoodDay(MachineType mt)
|
|||||||
|
|
||||||
bool Profile::channelAvailable(ChannelID code)
|
bool Profile::channelAvailable(ChannelID code)
|
||||||
{
|
{
|
||||||
for (int i=0; i<m_machlist.size(); ++i) {
|
for (auto & mach : m_machlist) {
|
||||||
Machine * mach = m_machlist[i];
|
|
||||||
if (mach->hasChannel(code))
|
if (mach->hasChannel(code))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1942,10 +1922,7 @@ void Profile::saveChannels()
|
|||||||
quint16 size = schema::channel.channels.size();
|
quint16 size = schema::channel.channels.size();
|
||||||
out << size;
|
out << size;
|
||||||
|
|
||||||
QHash<ChannelID, schema::Channel *>::iterator it;
|
for (auto it = schema::channel.channels.begin(),it_end = schema::channel.channels.end(); it != it_end; ++it) {
|
||||||
QHash<ChannelID, schema::Channel *>::iterator it_end = schema::channel.channels.end();
|
|
||||||
|
|
||||||
for (it = schema::channel.channels.begin(); it != it_end; ++it) {
|
|
||||||
schema::Channel * chan = it.value();
|
schema::Channel * chan = it.value();
|
||||||
out << it.key();
|
out << it.key();
|
||||||
out << chan->code();
|
out << chan->code();
|
||||||
|
@ -787,8 +787,8 @@ ChannelList::ChannelList()
|
|||||||
}
|
}
|
||||||
ChannelList::~ChannelList()
|
ChannelList::~ChannelList()
|
||||||
{
|
{
|
||||||
for (QHash<ChannelID, Channel *>::iterator i = channels.begin(); i != channels.end(); i++) {
|
for (auto & chan : channels) {
|
||||||
delete i.value();
|
delete chan;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool ChannelList::Load(QString filename)
|
bool ChannelList::Load(QString filename)
|
||||||
@ -835,8 +835,7 @@ bool ChannelList::Load(QString filename)
|
|||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
int id, linkid;
|
int id, linkid;
|
||||||
QString chantype, scopestr, typestr, name, group, idtxt, details, label, unit, datatypestr,
|
QString chantype, scopestr, typestr, name, group, idtxt, details, label, unit, datatypestr, defcolor, link;
|
||||||
defcolor, link;
|
|
||||||
ChanType type;
|
ChanType type;
|
||||||
DataType datatype;
|
DataType datatype;
|
||||||
Channel *chan;
|
Channel *chan;
|
||||||
@ -1031,19 +1030,14 @@ bool ChannelList::Save(QString filename)
|
|||||||
QDomElement root = doc.createElement("channels");
|
QDomElement root = doc.createElement("channels");
|
||||||
droot.appendChild(root);
|
droot.appendChild(root);
|
||||||
|
|
||||||
QHash<QString, QHash<QString, Channel *> >::iterator git;
|
|
||||||
QHash<QString, QHash<QString, Channel *> >::iterator groups_end = groups.end();
|
|
||||||
|
|
||||||
for (git = groups.begin(); git != groups_end; ++git) {
|
for (auto git=groups.begin(), end=groups.end(); git != end; ++git) {
|
||||||
QHash<QString, Channel *> & chanlist = git.value();
|
auto & chanlist = git.value();
|
||||||
QHash<QString, Channel *>::iterator it;
|
|
||||||
QHash<QString, Channel *>::iterator chend = chanlist.end();
|
|
||||||
|
|
||||||
QDomElement grp = doc.createElement("group");
|
QDomElement grp = doc.createElement("group");
|
||||||
grp.setAttribute("name", git.key());
|
grp.setAttribute("name", git.key());
|
||||||
root.appendChild(grp);
|
root.appendChild(grp);
|
||||||
|
for (auto it = chanlist.begin(), cend=chanlist.end(); it!=cend; ++it) {
|
||||||
for (it =chanlist.begin(); it!= chend; ++it) {
|
|
||||||
Channel * chan = it.value();
|
Channel * chan = it.value();
|
||||||
QDomElement cn = doc.createElement("channel");
|
QDomElement cn = doc.createElement("channel");
|
||||||
cn.setAttribute("id", chan->id());
|
cn.setAttribute("id", chan->id());
|
||||||
@ -1058,8 +1052,7 @@ bool ChannelList::Save(QString filename)
|
|||||||
cn.setAttribute("type", chan->type());
|
cn.setAttribute("type", chan->type());
|
||||||
cn.setAttribute("datatype", chan->datatype());
|
cn.setAttribute("datatype", chan->datatype());
|
||||||
cn.setAttribute("overview", chan->showInOverview());
|
cn.setAttribute("overview", chan->showInOverview());
|
||||||
QHash<int, QString>::iterator op;
|
for (auto op=chan->m_options.begin(), opend=chan->m_options.end(); op!=opend; ++op) {
|
||||||
for (op = chan->m_options.begin(); op!=chan->m_options.end(); ++op) {
|
|
||||||
QDomElement c2 = doc.createElement("option");
|
QDomElement c2 = doc.createElement("option");
|
||||||
c2.setAttribute("key", op.key());
|
c2.setAttribute("key", op.key());
|
||||||
c2.setAttribute("value", op.value());
|
c2.setAttribute("value", op.value());
|
||||||
@ -1069,10 +1062,8 @@ bool ChannelList::Save(QString filename)
|
|||||||
//cn.appendChild(doc.createTextNode(i.value().toDateTime().toString("yyyy-MM-dd HH:mm:ss")));
|
//cn.appendChild(doc.createTextNode(i.value().toDateTime().toString("yyyy-MM-dd HH:mm:ss")));
|
||||||
grp.appendChild(cn);
|
grp.appendChild(cn);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
|
|
||||||
if (!file.open(QIODevice::WriteOnly)) {
|
if (!file.open(QIODevice::WriteOnly)) {
|
||||||
@ -1083,11 +1074,10 @@ bool ChannelList::Save(QString filename)
|
|||||||
ts << doc.toString();
|
ts << doc.toString();
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
QString ChannelCalc::label()
|
QString ChannelCalc::label()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user