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);
}
rmin_y = rmax_y = 0;
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)
{
if (zoomY() == 0) {
// 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 {
if (zoomY() == 2) {
miny = rec_miny;
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;
bool ymin_good = false, ymax_good = false;
@ -578,7 +576,7 @@ void gGraph::roundY(EventDataType &miny, EventDataType &maxy)
if (!ymin_good) {
miny = m * 50;
}
} else if (maxy >= 5) {
} else if (maxy >= 30) {
m = ceil(maxy / 5.0);
t = m * 5;
@ -1207,9 +1205,9 @@ EventDataType gGraph::MinY()
tmp = (*l)->Miny();
if (tmp == 0 && tmp == (*l)->Maxy()) {
continue;
}
// if (tmp == 0 && tmp == (*l)->Maxy()) {
// continue;
// }
if (first) {
val = tmp;
@ -1240,9 +1238,9 @@ EventDataType gGraph::MaxY()
}
tmp = layer->Maxy();
if (tmp == 0 && layer->Miny() == 0) {
continue;
}
// if (tmp == 0 && layer->Miny() == 0) {
// continue;
// }
if (first) {
val = tmp;

View File

@ -39,39 +39,40 @@ extern MainWindow *mainwin;
#include <QApplication>
MyLabel::MyLabel(QWidget * parent):
QWidget(parent)
{
MyLabel::MyLabel(QWidget * parent)
: QWidget(parent) {
m_font = QApplication::font();
time.start();
}
MyLabel::~MyLabel()
{
}
void MyLabel::setText(QString text) {
m_text = text;
repaint();
update();
}
void MyLabel::setFont(QFont & font)
{
m_font=font;
}
void MyLabel::doRedraw()
{
update();
}
void MyLabel::setAlignment(Qt::Alignment alignment) {
m_alignment = alignment;
repaint();
doRedraw();
}
void MyLabel::paintEvent(QPaintEvent * event)
void MyLabel::paintEvent(QPaintEvent * /*event*/)
{
QRectF rect(event->rect());
QPainter painter(this);
painter.setFont(m_font);
painter.drawText(rect, m_alignment, m_text);
painter.drawText(rect(), m_alignment, m_text);
}
gToolTip::gToolTip(gGraphView *graphview)
: m_graphview(graphview)
{
@ -1288,9 +1289,9 @@ void gGraphView::paintGL()
painter.drawText(rec, Qt::AlignHCenter | Qt::AlignBottom, txt);
}
if (p_profile->appearance->lineCursorMode()) {
emit updateCurrentTime(graphs_drawn ? m_currenttime : 0.0F);
emit updateCurrentTime(graphs_drawn ? m_currenttime : 0.0F);
} else {
emit updateRange(graphs_drawn ? m_minx : 0.0F, m_maxx);
emit updateRange(graphs_drawn ? m_minx : 0.0F, m_maxx);
}
DrawTextQue(painter);

View File

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

View File

@ -219,7 +219,7 @@ skipcheck:
lob = new gLineOverlayBar(code, chan->defaultColor(), chan->label(), FT_Span);
}
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);
flags[code] = lob;
}
@ -272,7 +272,6 @@ skipcheck:
}
}
}
}
EventDataType gLineChart::Miny()
{
@ -285,7 +284,7 @@ EventDataType gLineChart::Miny()
for (int i=0; i< size; ++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);
@ -322,7 +321,7 @@ EventDataType gLineChart::Maxy()
for (int i=0; i< size; ++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);
if (!first) {
@ -426,6 +425,9 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion &region)
EventDataType miny = m_physminy;
EventDataType maxy = m_physmaxy;
if (m_codes[0] == CPAP_Pressure) {
int i=5; Q_UNUSED(i);
}
w.roundY(miny, maxy);

View File

@ -306,18 +306,13 @@ quint32 convertDate(quint32 timestamp)
month = (timestamp >> 5) & 0x0f;
year = 2000 + ((timestamp >> 9) & 0x3f);
timestamp >>= 15;
// second = timestamp & 0x3f;
// hour = (timestamp >> 6) & 0x1f;
// minute = (timestamp >> 12) & 0x3f;
second = timestamp & 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);
Q_ASSERT(dt.isValid());
// Q_ASSERT(dt.isValid());
// if ((year == 2013) && (month == 9) && (day == 18)) {
// // this is for testing.. set a breakpoint on here and
// int i=5;
@ -330,10 +325,10 @@ quint32 convertDate(quint32 timestamp)
// 91596 = 00:23:12 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 year;
@ -342,24 +337,21 @@ quint32 convertFLWDate(quint32 timestamp)
month = (timestamp >> 5) & 0x0f;
year = 2000 + ((timestamp >> 9) & 0x3f);
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;
minute = (timestamp >> 6) & 0x3f;
hour = (timestamp >> 12)+1;
// second = timestamp & 0x3f;
// minute = (timestamp >> 6) & 0x3f;
// hour = (timestamp >> 12) & 0x1f;
hour = (timestamp >> 12);
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)) {
// int i=5;
// }
// 87922 23:23:50 WET
return dt.addSecs(-360).toTime_t();
return dt.addSecs(-54).toTime_t();
}
//QDateTime FPIconLoader::readFPDateTime(quint8 *data)
@ -481,7 +473,6 @@ bool FPIconLoader::OpenFLW(Machine *mach, QString filename)
ts = convertFLWDate(t2);
if (ts > QDateTime(QDate(2015,1,1), QTime(0,0,0)).toTime_t()) {
ts = convertFLWDate(t2);
return false;
}
@ -864,7 +855,7 @@ bool FPIconLoader::OpenDetail(Machine *mach, QString filename)
sess = Sessions[sessid];
ti = qint64(sessid) * 1000L;
sess->really_set_first(ti);
ti -= 360000;
EventList *LK = sess->AddEventList(CPAP_LeakTotal, EVL_Event, 1);
EventList *PR = sess->AddEventList(CPAP_Pressure, EVL_Event, 0.1F);
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 j = 0; j < 3; ++j) {
pressure = data[idx];
PR->AddEvent(ti+360000/2, pressure);
PR->AddEvent(ti+120000, pressure);
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
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((b ? "on" : "off"))
.arg(fd.date().toString(Qt::SystemLocaleShortDate))
.arg(fd.toString("HH:mm"))
.arg(ld.toString("HH:mm"));
.arg(fd.toString("HH:mm:ss"))
.arg(ld.toString("HH:mm:ss"));
}
}
@ -1285,8 +1285,8 @@ QString Daily::getSleepTime(Day * day)
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")
.arg(date.date().toString(Qt::SystemLocaleShortDate))
.arg(date.toString("HH:mm"))
.arg(date2.toString("HH:mm"))
.arg(date.toString("HH:mm:ss"))
.arg(date2.toString("HH:mm:ss"))
.arg(QString().sprintf("%02i:%02i:%02i",h,m,s));
html+="</table>\n";
// html+="<hr/>";

View File

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