Roy Stone's F&P time patch, plus some Right click yaxis scaling work of Marks

This commit is contained in:
Mark Watkins 2014-08-27 19:00:55 +10:00
parent da9c160ec2
commit 1fd3703b32
7 changed files with 65 additions and 66 deletions

View File

@ -249,6 +249,7 @@ void gGraph::setDay(Day *day)
m_layers[i]->SetDay(day); m_layers[i]->SetDay(day);
} }
rmin_y = rmax_y = 0;
ResetBounds(); ResetBounds();
} }
@ -509,20 +510,17 @@ void gGraph::ToolTip(QString text, int x, int y, ToolTipAlignment align, int tim
void gGraph::roundY(EventDataType &miny, EventDataType &maxy) void gGraph::roundY(EventDataType &miny, EventDataType &maxy)
{ {
if (zoomY() == 0) { if (zoomY() == 2) {
// AutoScale mode
miny = rmin_y; // MinY();
maxy = rmax_y; //MaxY();
// fall through.
} else if (zoomY() == 1) {
miny = rphysmin_y; //physMinY()
maxy = rphysmax_y; //physMaxY();
return;
} else {
miny = rec_miny; miny = rec_miny;
maxy = rec_maxy; maxy = rec_maxy;
return; if (maxy > miny) return;
} else if (zoomY() ==1) {
miny = physMinY();
maxy = physMaxY();
if (maxy > miny) return;
} }
miny = MinY();
maxy = MaxY();
int m, t; int m, t;
bool ymin_good = false, ymax_good = false; bool ymin_good = false, ymax_good = false;
@ -578,7 +576,7 @@ void gGraph::roundY(EventDataType &miny, EventDataType &maxy)
if (!ymin_good) { if (!ymin_good) {
miny = m * 50; miny = m * 50;
} }
} else if (maxy >= 5) { } else if (maxy >= 30) {
m = ceil(maxy / 5.0); m = ceil(maxy / 5.0);
t = m * 5; t = m * 5;
@ -1207,9 +1205,9 @@ EventDataType gGraph::MinY()
tmp = (*l)->Miny(); tmp = (*l)->Miny();
if (tmp == 0 && tmp == (*l)->Maxy()) { // if (tmp == 0 && tmp == (*l)->Maxy()) {
continue; // continue;
} // }
if (first) { if (first) {
val = tmp; val = tmp;
@ -1240,9 +1238,9 @@ EventDataType gGraph::MaxY()
} }
tmp = layer->Maxy(); tmp = layer->Maxy();
if (tmp == 0 && layer->Miny() == 0) { // if (tmp == 0 && layer->Miny() == 0) {
continue; // continue;
} // }
if (first) { if (first) {
val = tmp; val = tmp;

View File

@ -39,39 +39,40 @@ extern MainWindow *mainwin;
#include <QApplication> #include <QApplication>
MyLabel::MyLabel(QWidget * parent): MyLabel::MyLabel(QWidget * parent)
QWidget(parent) : QWidget(parent) {
{
m_font = QApplication::font(); m_font = QApplication::font();
time.start();
} }
MyLabel::~MyLabel() MyLabel::~MyLabel()
{ {
} }
void MyLabel::setText(QString text) { void MyLabel::setText(QString text) {
m_text = text; m_text = text;
repaint(); update();
} }
void MyLabel::setFont(QFont & font) void MyLabel::setFont(QFont & font)
{ {
m_font=font; m_font=font;
} }
void MyLabel::doRedraw()
{
update();
}
void MyLabel::setAlignment(Qt::Alignment alignment) { void MyLabel::setAlignment(Qt::Alignment alignment) {
m_alignment = alignment; m_alignment = alignment;
repaint(); doRedraw();
} }
void MyLabel::paintEvent(QPaintEvent * event) void MyLabel::paintEvent(QPaintEvent * /*event*/)
{ {
QRectF rect(event->rect());
QPainter painter(this); QPainter painter(this);
painter.setFont(m_font); painter.setFont(m_font);
painter.drawText(rect, m_alignment, m_text); painter.drawText(rect(), m_alignment, m_text);
} }
gToolTip::gToolTip(gGraphView *graphview) gToolTip::gToolTip(gGraphView *graphview)
: m_graphview(graphview) : m_graphview(graphview)
{ {

View File

@ -23,6 +23,7 @@
#include <QComboBox> #include <QComboBox>
#include <QDoubleSpinBox> #include <QDoubleSpinBox>
#include <QToolButton> #include <QToolButton>
#include <QTimer>
#ifndef BROKEN_OPENGL_BUILD #ifndef BROKEN_OPENGL_BUILD
#include <QGLWidget> #include <QGLWidget>
@ -77,6 +78,7 @@ void setEmptyImage(QString text, QPixmap pixmap);
class MyLabel:public QWidget class MyLabel:public QWidget
{ {
Q_OBJECT
public: public:
MyLabel(QWidget * parent); MyLabel(QWidget * parent);
virtual ~MyLabel(); virtual ~MyLabel();
@ -86,11 +88,16 @@ public:
void setFont(QFont & font); void setFont(QFont & font);
QFont & font() { return m_font; } QFont & font() { return m_font; }
virtual void paintEvent(QPaintEvent * event);
virtual void paintEvent(QPaintEvent *);
QFont m_font; QFont m_font;
QString m_text; QString m_text;
Qt::Alignment m_alignment; Qt::Alignment m_alignment;
QTime time;
protected slots:
void doRedraw();
}; };
class gGraphView; class gGraphView;
@ -620,7 +627,7 @@ class gGraphView
bool m_blockUpdates; bool m_blockUpdates;
QPoint m_mouse; QPoint m_mouse;
qint64 m_currenttime; double m_currenttime;
QTime m_animationStarted; QTime m_animationStarted;

View File

@ -219,7 +219,7 @@ skipcheck:
lob = new gLineOverlayBar(code, chan->defaultColor(), chan->label(), FT_Span); lob = new gLineOverlayBar(code, chan->defaultColor(), chan->label(), FT_Span);
} }
if (lob != nullptr) { if (lob != nullptr) {
lob->setOverlayDisplayType(((m_codes[0] == CPAP_FlowRate) || (m_codes[0] == CPAP_MaskPressureHi))? (OverlayDisplayType)p_profile->appearance->overlayType() : ODT_TopAndBottom); lob->setOverlayDisplayType(((m_codes[0] == CPAP_FlowRate))? (OverlayDisplayType)p_profile->appearance->overlayType() : ODT_TopAndBottom);
lob->SetDay(m_day); lob->SetDay(m_day);
flags[code] = lob; flags[code] = lob;
} }
@ -272,7 +272,6 @@ skipcheck:
} }
} }
} }
} }
EventDataType gLineChart::Miny() EventDataType gLineChart::Miny()
{ {
@ -285,7 +284,7 @@ EventDataType gLineChart::Miny()
for (int i=0; i< size; ++i) { for (int i=0; i< size; ++i) {
ChannelID code = m_codes[i]; ChannelID code = m_codes[i];
if (!m_enabled[code]) continue; if (!m_enabled[code] || !m_day->channelExists(code)) continue;
tmp = m_day->Min(code); tmp = m_day->Min(code);
@ -322,7 +321,7 @@ EventDataType gLineChart::Maxy()
for (int i=0; i< size; ++i) { for (int i=0; i< size; ++i) {
ChannelID code = m_codes[i]; ChannelID code = m_codes[i];
if (!m_enabled[code]) continue; if (!m_enabled[code] || !m_day->channelExists(code)) continue;
tmp = m_day->Max(code); tmp = m_day->Max(code);
if (!first) { if (!first) {
@ -426,6 +425,9 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion &region)
EventDataType miny = m_physminy; EventDataType miny = m_physminy;
EventDataType maxy = m_physmaxy; EventDataType maxy = m_physmaxy;
if (m_codes[0] == CPAP_Pressure) {
int i=5; Q_UNUSED(i);
}
w.roundY(miny, maxy); w.roundY(miny, maxy);

View File

@ -306,18 +306,13 @@ quint32 convertDate(quint32 timestamp)
month = (timestamp >> 5) & 0x0f; month = (timestamp >> 5) & 0x0f;
year = 2000 + ((timestamp >> 9) & 0x3f); year = 2000 + ((timestamp >> 9) & 0x3f);
timestamp >>= 15; timestamp >>= 15;
// second = timestamp & 0x3f;
// hour = (timestamp >> 6) & 0x1f;
// minute = (timestamp >> 12) & 0x3f;
second = timestamp & 0x3f; second = timestamp & 0x3f;
minute = (timestamp >> 6) & 0x3f; minute = (timestamp >> 6) & 0x3f;
hour = (timestamp >> 12)+1; hour = (timestamp >> 12);
QDateTime dt = QDateTime(QDate(year, month, day), QTime(hour, minute, second),Qt::UTC); QDateTime dt = QDateTime(QDate(year, month, day), QTime(hour, minute, second),Qt::UTC);
Q_ASSERT(dt.isValid()); // Q_ASSERT(dt.isValid());
// if ((year == 2013) && (month == 9) && (day == 18)) { // if ((year == 2013) && (month == 9) && (day == 18)) {
// // this is for testing.. set a breakpoint on here and // // this is for testing.. set a breakpoint on here and
// int i=5; // int i=5;
@ -330,10 +325,10 @@ quint32 convertDate(quint32 timestamp)
// 91596 = 00:23:12 WET // 91596 = 00:23:12 WET
// 19790 = 23:23:50 WET // 19790 = 23:23:50 WET
return dt.toTime_t(); return dt.addSecs(-54).toTime_t();
} }
quint32 convertFLWDate(quint32 timestamp) quint32 convertFLWDate(quint32 timestamp) // Bit format: hhhhhmmmmmmssssssYYYYYYMMMMDDDDD
{ {
quint16 day, month, hour, minute, second; quint16 day, month, hour, minute, second;
quint16 year; quint16 year;
@ -342,24 +337,21 @@ quint32 convertFLWDate(quint32 timestamp)
month = (timestamp >> 5) & 0x0f; month = (timestamp >> 5) & 0x0f;
year = 2000 + ((timestamp >> 9) & 0x3f); year = 2000 + ((timestamp >> 9) & 0x3f);
timestamp >>= 15; timestamp >>= 15;
// Okay, why did I swap the first and last bits of the time field?
// What am I forgetting?? This seems to work properly like this
// Was I looking at older data that worked like this?
second = timestamp & 0x3f; second = timestamp & 0x3f;
minute = (timestamp >> 6) & 0x3f; minute = (timestamp >> 6) & 0x3f;
hour = (timestamp >> 12)+1; hour = (timestamp >> 12);
// second = timestamp & 0x3f;
// minute = (timestamp >> 6) & 0x3f;
// hour = (timestamp >> 12) & 0x1f;
QDateTime dt = QDateTime(QDate(year, month, day), QTime(hour, minute, second), Qt::UTC); QDateTime dt = QDateTime(QDate(year, month, day), QTime(hour, minute, second), Qt::UTC);
Q_ASSERT(dt.isValid());
if(!dt.isValid()){
dt = QDateTime(QDate(2015,1,1), QTime(0,0,1));
}
// Q_ASSERT(dt.isValid());
// if ((year == 2013) && (month == 9) && (day == 18)) { // if ((year == 2013) && (month == 9) && (day == 18)) {
// int i=5; // int i=5;
// } // }
// 87922 23:23:50 WET // 87922 23:23:50 WET
return dt.addSecs(-360).toTime_t(); return dt.addSecs(-54).toTime_t();
} }
//QDateTime FPIconLoader::readFPDateTime(quint8 *data) //QDateTime FPIconLoader::readFPDateTime(quint8 *data)
@ -481,7 +473,6 @@ bool FPIconLoader::OpenFLW(Machine *mach, QString filename)
ts = convertFLWDate(t2); ts = convertFLWDate(t2);
if (ts > QDateTime(QDate(2015,1,1), QTime(0,0,0)).toTime_t()) { if (ts > QDateTime(QDate(2015,1,1), QTime(0,0,0)).toTime_t()) {
ts = convertFLWDate(t2);
return false; return false;
} }
@ -864,7 +855,7 @@ bool FPIconLoader::OpenDetail(Machine *mach, QString filename)
sess = Sessions[sessid]; sess = Sessions[sessid];
ti = qint64(sessid) * 1000L; ti = qint64(sessid) * 1000L;
sess->really_set_first(ti); sess->really_set_first(ti);
ti -= 360000;
EventList *LK = sess->AddEventList(CPAP_LeakTotal, EVL_Event, 1); EventList *LK = sess->AddEventList(CPAP_LeakTotal, EVL_Event, 1);
EventList *PR = sess->AddEventList(CPAP_Pressure, EVL_Event, 0.1F); EventList *PR = sess->AddEventList(CPAP_Pressure, EVL_Event, 0.1F);
EventList *OA = sess->AddEventList(CPAP_Obstructive, EVL_Event); EventList *OA = sess->AddEventList(CPAP_Obstructive, EVL_Event);
@ -881,10 +872,10 @@ bool FPIconLoader::OpenDetail(Machine *mach, QString filename)
for (int i = 0; i < rec; ++i) { for (int i = 0; i < rec; ++i) {
for (int j = 0; j < 3; ++j) { for (int j = 0; j < 3; ++j) {
pressure = data[idx]; pressure = data[idx];
PR->AddEvent(ti+360000/2, pressure); PR->AddEvent(ti+120000, pressure);
leak = data[idx + 1]; leak = data[idx + 1];
LK->AddEvent(ti+360000/2, leak); LK->AddEvent(ti+120000, leak);
a1 = data[idx + 2]; // [0..5] Obstructive flag, [6..7] Unknown a1 = data[idx + 2]; // [0..5] Obstructive flag, [6..7] Unknown
a2 = data[idx + 3]; // [0..5] Hypopnea, [6..7] Unknown a2 = data[idx + 3]; // [0..5] Hypopnea, [6..7] Unknown

View File

@ -925,8 +925,8 @@ QString Daily::getSessionInformation(Day * day)
.arg(QString("%1h %2m %3s").arg(h,2,10,QChar('0')).arg(m,2,10,QChar('0')).arg(s1,2,10,QChar('0'))) .arg(QString("%1h %2m %3s").arg(h,2,10,QChar('0')).arg(m,2,10,QChar('0')).arg(s1,2,10,QChar('0')))
.arg((b ? "on" : "off")) .arg((b ? "on" : "off"))
.arg(fd.date().toString(Qt::SystemLocaleShortDate)) .arg(fd.date().toString(Qt::SystemLocaleShortDate))
.arg(fd.toString("HH:mm")) .arg(fd.toString("HH:mm:ss"))
.arg(ld.toString("HH:mm")); .arg(ld.toString("HH:mm:ss"));
} }
} }
@ -1285,8 +1285,8 @@ QString Daily::getSleepTime(Day * day)
int s=tt % 60; int s=tt % 60;
html+=QString("<tr><td align='center'>%1</td><td align='center'>%2</td><td align='center'>%3</td><td align='center'>%4</td></tr>\n") html+=QString("<tr><td align='center'>%1</td><td align='center'>%2</td><td align='center'>%3</td><td align='center'>%4</td></tr>\n")
.arg(date.date().toString(Qt::SystemLocaleShortDate)) .arg(date.date().toString(Qt::SystemLocaleShortDate))
.arg(date.toString("HH:mm")) .arg(date.toString("HH:mm:ss"))
.arg(date2.toString("HH:mm")) .arg(date2.toString("HH:mm:ss"))
.arg(QString().sprintf("%02i:%02i:%02i",h,m,s)); .arg(QString().sprintf("%02i:%02i:%02i",h,m,s));
html+="</table>\n"; html+="</table>\n";
// html+="<hr/>"; // html+="<hr/>";

View File

@ -51,7 +51,7 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>2</number> <number>7</number>
</property> </property>
<widget class="QWidget" name="importTab"> <widget class="QWidget" name="importTab">
<attribute name="title"> <attribute name="title">
@ -2408,7 +2408,7 @@ p, li { white-space: pre-wrap; }
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>Top &amp; Bottom Markers</string> <string>Top Markers</string>
</property> </property>
</item> </item>
</widget> </widget>