mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-07 03:30:44 +00:00
A little more tinkering on TAP chart, fake yAxis labels for now
This commit is contained in:
parent
0eccfb6d21
commit
c1082d8b5f
@ -20,18 +20,6 @@
|
|||||||
#include "Graphs/gYAxis.h"
|
#include "Graphs/gYAxis.h"
|
||||||
|
|
||||||
|
|
||||||
// Calculate Catmull-Rom Spline of given 4 samples, with t between 0-1;
|
|
||||||
float CatmullRomSpline(float p0, float p1, float p2, float p3, float t = 0.5)
|
|
||||||
{
|
|
||||||
float t2 = t*t;
|
|
||||||
float t3 = t2 * t;
|
|
||||||
|
|
||||||
return (float)0.5 * ((2 * p1) +
|
|
||||||
(-p0 + p2) * t +
|
|
||||||
(2*p0 - 5*p1 + 4*p2 - p3) * t2 +
|
|
||||||
(-p0 + 3*p1- 3*p2 + p3) * t3);
|
|
||||||
}
|
|
||||||
|
|
||||||
MinutesAtPressure::MinutesAtPressure() :Layer(NoChannel)
|
MinutesAtPressure::MinutesAtPressure() :Layer(NoChannel)
|
||||||
{
|
{
|
||||||
m_remap = nullptr;
|
m_remap = nullptr;
|
||||||
@ -145,7 +133,7 @@ void MinutesAtPressure::paint(QPainter &painter, gGraph &graph, const QRegion &r
|
|||||||
float height = rect.height();
|
float height = rect.height();
|
||||||
float left = rect.left();
|
float left = rect.left();
|
||||||
float pix = width / float(cells);
|
float pix = width / float(cells);
|
||||||
float bottom = rect.bottom();
|
float bottom = rect.bottom()+1;
|
||||||
|
|
||||||
|
|
||||||
int numchans = chans.size();
|
int numchans = chans.size();
|
||||||
@ -182,16 +170,19 @@ void MinutesAtPressure::paint(QPainter &painter, gGraph &graph, const QRegion &r
|
|||||||
|
|
||||||
painter.setFont(*defaultfont);
|
painter.setFont(*defaultfont);
|
||||||
painter.setPen(Qt::black);
|
painter.setPen(Qt::black);
|
||||||
painter.drawRect(rect.left(),rect.top(), rect.width(), height);
|
painter.drawRect(rect.left(),rect.top(), rect.width(), height+1);
|
||||||
|
|
||||||
|
|
||||||
|
int min = 4*5;
|
||||||
int min = 40;
|
int max = 24*5;
|
||||||
int max = 240;
|
|
||||||
int tot = max - min;
|
int tot = max - min;
|
||||||
float xstep = float(width) / float(tot);
|
float xstep = float(width) / float(tot);
|
||||||
height -= 2;
|
height -= 2;
|
||||||
float peak = float(qMax(ipap.peaktime, epap.peaktime));
|
float peak = float(qMax(ipap.peaktime, epap.peaktime));
|
||||||
|
|
||||||
|
m_miny = m_physminy = 0;
|
||||||
|
m_maxy = m_physmaxy = peak;
|
||||||
|
|
||||||
float ystep = float(height) / peak;
|
float ystep = float(height) / peak;
|
||||||
|
|
||||||
int p0, p1, p2, p3;
|
int p0, p1, p2, p3;
|
||||||
@ -199,9 +190,9 @@ void MinutesAtPressure::paint(QPainter &painter, gGraph &graph, const QRegion &r
|
|||||||
if (ipap.min_pressure > 0) {
|
if (ipap.min_pressure > 0) {
|
||||||
float xp,yp;
|
float xp,yp;
|
||||||
|
|
||||||
float pstep = xstep*10.0;
|
float pstep = xstep * 5;
|
||||||
|
|
||||||
xp = left + pstep/2.0;
|
xp = left;// /2.0;
|
||||||
int w, h;
|
int w, h;
|
||||||
for (int i = 0; i<=20; ++i) {
|
for (int i = 0; i<=20; ++i) {
|
||||||
yp = bottom;
|
yp = bottom;
|
||||||
@ -213,7 +204,7 @@ void MinutesAtPressure::paint(QPainter &painter, gGraph &graph, const QRegion &r
|
|||||||
xp+= pstep;
|
xp+= pstep;
|
||||||
}
|
}
|
||||||
|
|
||||||
xstep /= 4.0;
|
xstep /= 5.0;
|
||||||
painter.setPen(Qt::red);
|
painter.setPen(Qt::red);
|
||||||
|
|
||||||
xp=left;
|
xp=left;
|
||||||
@ -229,24 +220,30 @@ void MinutesAtPressure::paint(QPainter &painter, gGraph &graph, const QRegion &r
|
|||||||
|
|
||||||
lastyp = yp;
|
lastyp = yp;
|
||||||
xp += xstep;
|
xp += xstep;
|
||||||
float s2 = qMax(CatmullRomSpline(p0, p1, p2, p3, 0.25),0.0f);
|
float s2 = qMax(CatmullRomSpline(p0, p1, p2, p3, 0.2),0.0f);
|
||||||
yp = qMax(bottom-height, (bottom - (s2 * ystep)));
|
yp = qMax(bottom-height, (bottom - (s2 * ystep)));
|
||||||
painter.drawLine(xp, lastyp, xp+xstep, yp);
|
painter.drawLine(xp, lastyp, xp+xstep, yp);
|
||||||
|
|
||||||
lastyp = yp;
|
lastyp = yp;
|
||||||
xp += xstep;
|
xp += xstep;
|
||||||
s2 = qMax(CatmullRomSpline(p0, p1, p2, p3, 0.5),0.0f);
|
s2 = qMax(CatmullRomSpline(p0, p1, p2, p3, 0.4),0.0f);
|
||||||
yp = qMax(bottom-height, (bottom - (s2 * ystep)));
|
yp = qMax(bottom-height, (bottom - (s2 * ystep)));
|
||||||
painter.drawLine(xp, lastyp, xp+xstep, yp);
|
painter.drawLine(xp, lastyp, xp+xstep, yp);
|
||||||
lastyp = yp;
|
lastyp = yp;
|
||||||
xp += xstep;
|
xp += xstep;
|
||||||
|
|
||||||
s2 = qMax(CatmullRomSpline(p0, p1, p2, p3, 0.75),0.0f);
|
s2 = qMax(CatmullRomSpline(p0, p1, p2, p3, 0.6),0.0f);
|
||||||
yp = qMax(bottom-height, (bottom - (s2 * ystep)));
|
yp = qMax(bottom-height, (bottom - (s2 * ystep)));
|
||||||
painter.drawLine(xp, lastyp, xp+xstep, yp);
|
painter.drawLine(xp, lastyp, xp+xstep, yp);
|
||||||
|
|
||||||
xp+=xstep;
|
xp+=xstep;
|
||||||
lastyp = yp;
|
lastyp = yp;
|
||||||
|
|
||||||
|
s2 = qMax(CatmullRomSpline(p0, p1, p2, p3, 0.8),0.0f);
|
||||||
|
yp = qMax(bottom-height, (bottom - (s2 * ystep)));
|
||||||
|
painter.drawLine(xp, lastyp, xp+xstep, yp);
|
||||||
|
xp+=xstep;
|
||||||
|
lastyp = yp;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (epap.min_pressure) {
|
if (epap.min_pressure) {
|
||||||
@ -579,7 +576,6 @@ 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);
|
QHash<ChannelID, QVector<EventList *> >::iterator ei = sess->eventlist.find(code);
|
||||||
|
|
||||||
@ -617,7 +613,7 @@ void RecalcMAP::updateTimes(PressureInfo & info, Session * sess)
|
|||||||
}
|
}
|
||||||
|
|
||||||
time = EL->time(e);
|
time = EL->time(e);
|
||||||
data = floor(float(EL->raw(e)) * gain * 10.0); // pressure times ten, so can look at .1 intervals in an integer
|
data = floor(float(EL->raw(e)) * gain * 5.0); // pressure times ten, so can look at .1 intervals in an integer
|
||||||
|
|
||||||
Q_ASSERT(data < 300);
|
Q_ASSERT(data < 300);
|
||||||
|
|
||||||
@ -634,11 +630,11 @@ void RecalcMAP::updateTimes(PressureInfo & info, Session * sess)
|
|||||||
d2 = qMin(maxx, time);
|
d2 = qMin(maxx, time);
|
||||||
|
|
||||||
duration = (d2 - d1) / 1000L;
|
duration = (d2 - d1) / 1000L;
|
||||||
info.times[lastdata] += duration;
|
|
||||||
|
|
||||||
key = lastdata;
|
key = lastdata;
|
||||||
|
info.times[key] += duration;
|
||||||
|
|
||||||
int cs = info.chans.size();
|
int cs = info.chans.size();
|
||||||
|
|
||||||
for (int c = 0; c < cs; ++c) {
|
for (int c = 0; c < cs; ++c) {
|
||||||
ChannelID cod = info.chans.at(c);
|
ChannelID cod = info.chans.at(c);
|
||||||
schema::Channel & chan = schema::channel[cod];
|
schema::Channel & chan = schema::channel[cod];
|
||||||
@ -662,9 +658,10 @@ void RecalcMAP::updateTimes(PressureInfo & info, Session * sess)
|
|||||||
d2 = qMin(maxx, EL->last());
|
d2 = qMin(maxx, EL->last());
|
||||||
|
|
||||||
duration = (d2 - d1) / 1000L;
|
duration = (d2 - d1) / 1000L;
|
||||||
info.times[lastdata] += duration;
|
|
||||||
key = lastdata;
|
key = lastdata;
|
||||||
|
info.times[key] += duration;
|
||||||
int cs = info.chans.size();
|
int cs = info.chans.size();
|
||||||
|
|
||||||
for (int c = 0; c < cs; ++c) {
|
for (int c = 0; c < cs; ++c) {
|
||||||
ChannelID cod = info.chans.at(c);
|
ChannelID cod = info.chans.at(c);
|
||||||
schema::Channel & chan = schema::channel[cod];
|
schema::Channel & chan = schema::channel[cod];
|
||||||
|
@ -95,7 +95,6 @@ public:
|
|||||||
//! Draw filled rectangles behind Event Flag's, and an outlines around them all, Calls the individual paint for each gFlagLine
|
//! Draw filled rectangles behind Event Flag's, and an outlines around them all, Calls the individual paint for each gFlagLine
|
||||||
virtual void paint(QPainter &painter, gGraph &w, const QRegion ®ion);
|
virtual void paint(QPainter &painter, gGraph &w, const QRegion ®ion);
|
||||||
|
|
||||||
|
|
||||||
bool mouseMoveEvent(QMouseEvent *event, gGraph *graph);
|
bool mouseMoveEvent(QMouseEvent *event, gGraph *graph);
|
||||||
bool mousePressEvent(QMouseEvent *event, gGraph *graph);
|
bool mousePressEvent(QMouseEvent *event, gGraph *graph);
|
||||||
bool mouseReleaseEvent(QMouseEvent *event, gGraph *graph);
|
bool mouseReleaseEvent(QMouseEvent *event, gGraph *graph);
|
||||||
|
@ -31,6 +31,19 @@ static bool globalsInitialized = false;
|
|||||||
// Graph constants.
|
// Graph constants.
|
||||||
static const double zoom_hard_limit = 500.0;
|
static const double zoom_hard_limit = 500.0;
|
||||||
|
|
||||||
|
|
||||||
|
// Calculate Catmull-Rom Spline of given 4 samples, with t between 0-1;
|
||||||
|
float CatmullRomSpline(float p0, float p1, float p2, float p3, float t)
|
||||||
|
{
|
||||||
|
float t2 = t*t;
|
||||||
|
float t3 = t2 * t;
|
||||||
|
|
||||||
|
return (float)0.5 * ((2 * p1) +
|
||||||
|
(-p0 + p2) * t +
|
||||||
|
(2*p0 - 5*p1 + 4*p2 - p3) * t2 +
|
||||||
|
(-p0 + 3*p1- 3*p2 + p3) * t3);
|
||||||
|
}
|
||||||
|
|
||||||
// Must be called from a thread inside the application.
|
// Must be called from a thread inside the application.
|
||||||
bool InitGraphGlobals()
|
bool InitGraphGlobals()
|
||||||
{
|
{
|
||||||
|
@ -34,6 +34,8 @@ void DestroyGraphGlobals();
|
|||||||
|
|
||||||
const int mouse_movement_threshold = 6;
|
const int mouse_movement_threshold = 6;
|
||||||
|
|
||||||
|
float CatmullRomSpline(float p0, float p1, float p2, float p3, float t = 0.5);
|
||||||
|
|
||||||
inline void GetTextExtent(QString text, int &width, int &height, QFont *font)
|
inline void GetTextExtent(QString text, int &width, int &height, QFont *font)
|
||||||
{
|
{
|
||||||
QFontMetrics fm(*font);
|
QFontMetrics fm(*font);
|
||||||
|
@ -1177,6 +1177,71 @@ bool PRS1Import::ParseF3Events()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern float CatmullRomSpline(float p0, float p1, float p2, float p3, float t = 0.5);
|
||||||
|
|
||||||
|
void SmoothEventList(Session * session, EventList * ev, ChannelID code)
|
||||||
|
{
|
||||||
|
if (!ev) return;
|
||||||
|
int cnt = ev->count();
|
||||||
|
if (cnt > 4) {
|
||||||
|
EventList * smooth = new EventList(EVL_Event, ev->gain());
|
||||||
|
|
||||||
|
smooth->setFirst(ev->first());
|
||||||
|
smooth->AddEvent(ev->time(0), ev->raw(0));
|
||||||
|
|
||||||
|
float p0, p1, p2, p3, v;
|
||||||
|
for (int i=1; i<cnt-2; ++i) {
|
||||||
|
qint64 time = ev->time(i);
|
||||||
|
qint64 time2 = ev->time(i+1);
|
||||||
|
qint64 diff = time2 - time;
|
||||||
|
|
||||||
|
// these aren't evenly spaced... spline won't work here.
|
||||||
|
p0 = ev->raw(i-1);
|
||||||
|
p1 = ev->raw(i);
|
||||||
|
p2 = ev->raw(i+1);
|
||||||
|
p3 = ev->raw(i+2);
|
||||||
|
|
||||||
|
smooth->AddEvent(time, p1);
|
||||||
|
|
||||||
|
// int df = p2-p1;
|
||||||
|
// if (df > 0) {
|
||||||
|
// qint64 inter = diff/(df+1);
|
||||||
|
// qint64 t = time+inter;
|
||||||
|
// for (int j=0; j<df; ++j) {
|
||||||
|
// smooth->AddEvent(t, p1+j);
|
||||||
|
// t+=inter;
|
||||||
|
// }
|
||||||
|
// } else if (df<0) {
|
||||||
|
// df = abs(df);
|
||||||
|
// qint64 inter = diff/(df+1);
|
||||||
|
// qint64 t = time+inter;
|
||||||
|
// for (int j=0; j<df; ++j) {
|
||||||
|
// smooth->AddEvent(t, p1-j);
|
||||||
|
// t+=inter;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// don't want to use Catmull here...
|
||||||
|
|
||||||
|
|
||||||
|
v = CatmullRomSpline(p0, p1, p2, p3, 0.25);
|
||||||
|
smooth->AddEvent(time+diff*0.25, v);
|
||||||
|
v = CatmullRomSpline(p0, p1, p2, p3, 0.5);
|
||||||
|
smooth->AddEvent(time+diff*0.5, v);
|
||||||
|
v = CatmullRomSpline(p0, p1, p2, p3, 0.75);
|
||||||
|
smooth->AddEvent(time+diff*0.75, v);
|
||||||
|
|
||||||
|
}
|
||||||
|
smooth->AddEvent(ev->time(cnt-2), ev->raw(cnt-2));
|
||||||
|
smooth->AddEvent(ev->time(cnt-1), ev->raw(cnt-1));
|
||||||
|
|
||||||
|
|
||||||
|
session->eventlist[code].removeAll(ev);
|
||||||
|
delete ev;
|
||||||
|
session->eventlist[code].append(smooth);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool PRS1Import::ParseF0Events()
|
bool PRS1Import::ParseF0Events()
|
||||||
{
|
{
|
||||||
unsigned char code=0;
|
unsigned char code=0;
|
||||||
@ -1230,7 +1295,7 @@ bool PRS1Import::ParseF0Events()
|
|||||||
float lpm = lpm20 - lpm4;
|
float lpm = lpm20 - lpm4;
|
||||||
float ppm = lpm / 16.0;
|
float ppm = lpm / 16.0;
|
||||||
|
|
||||||
//CPAPMode mode = (CPAPMode) session->settings[CPAP_Mode].toInt();
|
CPAPMode mode = (CPAPMode) session->settings[CPAP_Mode].toInt();
|
||||||
|
|
||||||
for (pos = 0; pos < size;) {
|
for (pos = 0; pos < size;) {
|
||||||
lastcode3 = lastcode2;
|
lastcode3 = lastcode2;
|
||||||
@ -1472,10 +1537,12 @@ bool PRS1Import::ParseF0Events()
|
|||||||
|
|
||||||
// Perhaps this check is not necessary, as it will theoretically add extra resolution to pressure chart
|
// Perhaps this check is not necessary, as it will theoretically add extra resolution to pressure chart
|
||||||
// for bipap models and above???
|
// for bipap models and above???
|
||||||
// if (mode <= MODE_BILEVEL_FIXED) {
|
if (mode <= MODE_BILEVEL_FIXED) {
|
||||||
// if (!(EPAP = session->AddEventList(CPAP_EPAP, EVL_Event, 0.1F))) { return false; }
|
if (!EPAP) {
|
||||||
// EPAP->AddEvent(t, data0);
|
if (!(EPAP = session->AddEventList(CPAP_EPAP, EVL_Event, 0.1F))) { return false; }
|
||||||
// }
|
}
|
||||||
|
EPAP->AddEvent(t, data0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1510,6 +1577,11 @@ bool PRS1Import::ParseF0Events()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SmoothEventList(session, PRESSURE, CPAP_Pressure);
|
||||||
|
// SmoothEventList(session, IPAP, CPAP_IPAP);
|
||||||
|
// SmoothEventList(session, EPAP, CPAP_EPAP);
|
||||||
|
|
||||||
|
|
||||||
session->updateLast(t);
|
session->updateLast(t);
|
||||||
session->m_cnt.clear();
|
session->m_cnt.clear();
|
||||||
session->m_cph.clear();
|
session->m_cph.clear();
|
||||||
|
@ -272,7 +272,7 @@ Daily::Daily(QWidget *parent,gGraphView * shared)
|
|||||||
graphlist[STR_GRAPH_TAP] = TAP2 = new gGraph(STR_GRAPH_TAP, GraphView, QObject::tr("Time at Pressure"), QObject::tr("Time at Pressure"), default_height);
|
graphlist[STR_GRAPH_TAP] = TAP2 = new gGraph(STR_GRAPH_TAP, GraphView, QObject::tr("Time at Pressure"), QObject::tr("Time at Pressure"), default_height);
|
||||||
MinutesAtPressure * map;
|
MinutesAtPressure * map;
|
||||||
TAP2->AddLayer(map = new MinutesAtPressure());
|
TAP2->AddLayer(map = new MinutesAtPressure());
|
||||||
TAP2->AddLayer(new gLabelArea(map),LayerLeft,gYAxis::Margin);
|
TAP2->AddLayer(new gYAxis(),LayerLeft,gYAxis::Margin);
|
||||||
TAP2->AddLayer(new gXAxisPressure(),LayerBottom,gXAxisPressure::Margin);
|
TAP2->AddLayer(new gXAxisPressure(),LayerBottom,gXAxisPressure::Margin);
|
||||||
TAP2->setBlockSelect(true);
|
TAP2->setBlockSelect(true);
|
||||||
|
|
||||||
|
@ -1167,7 +1167,7 @@ void PreferencesDialog::on_maskLeaks20Slider_valueChanged(int value)
|
|||||||
ui->maskLeaks20Label->setText(tr("%1 %2").arg(value/10.0f, 5,'f',1).arg(STR_UNIT_LPM));
|
ui->maskLeaks20Label->setText(tr("%1 %2").arg(value/10.0f, 5,'f',1).arg(STR_UNIT_LPM));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesDialog::on_calculateUnintentionalLeaks_toggled(bool arg1)
|
void PreferencesDialog::on_calculateUnintentionalLeaks_toggled(bool)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user