From 40bb6f32af972feb0d7583acdc61a54fa0560085 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Sat, 2 Jul 2011 18:37:24 +1000 Subject: [PATCH] ResMed Start & End time calculations fix --- Graphs/graphwindow.cpp | 14 ++------------ SleepLib/loader_plugins/resmed_loader.cpp | 16 +++++++++++----- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/Graphs/graphwindow.cpp b/Graphs/graphwindow.cpp index fe770b04..8cbcb76b 100644 --- a/Graphs/graphwindow.cpp +++ b/Graphs/graphwindow.cpp @@ -673,14 +673,6 @@ void gGraphWindow::resizeGL(int w, int h) void gGraphWindow::Render(float w, float h) { - /*glViewport(0, 0, width, height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - glOrtho(0, width, 0, height, -1, 1); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity();*/ - if (m_gradient_background) { glBegin(GL_QUADS); glColor4f(1.0,1.0,1.0,.5); // Gradient start @@ -692,10 +684,8 @@ void gGraphWindow::Render(float w, float h) glVertex2f(w, h); glEnd(); } else { - glClearColor(255,255,255,0); glClear(GL_COLOR_BUFFER_BIT ); //| GL_DEPTH_BUFFER_BIT - // glClear(GL_COLOR_BUFFER_BIT); } @@ -718,9 +708,9 @@ void gGraphWindow::paintGL() if (m_mouseLDown) { if (m_mouseRBrect.width()>0) - glDisable(GL_DEPTH_TEST); + //glDisable(GL_DEPTH_TEST); RoundedRectangle(m_mouseRBrect.x(),m_mouseRBrect.y(),m_mouseRBrect.width(),m_mouseRBrect.height(),5,QColor(50,50,50,128)); - glEnable(GL_DEPTH_TEST); + //glEnable(GL_DEPTH_TEST); } glEnable(GL_DEPTH_TEST); diff --git a/SleepLib/loader_plugins/resmed_loader.cpp b/SleepLib/loader_plugins/resmed_loader.cpp index 427608a6..da11ecdb 100644 --- a/SleepLib/loader_plugins/resmed_loader.cpp +++ b/SleepLib/loader_plugins/resmed_loader.cpp @@ -359,6 +359,12 @@ bool ResmedLoader::LoadEVE(Session *sess,EDFParser &edf) recs=edf.edfsignals[s]->nr*edf.GetNumDataRecords()*2; totaldur=edf.GetNumDataRecords()*edf.GetDuration(); totaldur/=3600.0; + if (!sess->first().isValid()) { + sess->set_first(edf.startdate); + sess->set_last(edf.startdate.addMSecs(totaldur*1000.0)); + sess->set_hours(totaldur/3600.0); + } + //t.sprintf("EVE: %li %.2f",recs,totaldur); //qDebug() << edf.edfsignals[s]->label << " " << t; data=(char *)edf.edfsignals[s]->data; @@ -456,11 +462,11 @@ bool ResmedLoader::LoadBRP(Session *sess,EDFParser &edf) qDebug() << "Unknown Signal " << edf.edfsignals[s]->label; continue; } - sess->set_first(edf.startdate); - QDateTime e=edf.startdate.addSecs(duration); - sess->set_last(e); - //duration/=3600.0; - sess->set_hours(duration/3600.0); + if (!sess->first().isValid()) { + sess->set_first(edf.startdate); + sess->set_last(edf.startdate.addMSecs(duration*1000.0)); + sess->set_hours(duration/3600.0); + } Waveform *w=new Waveform(edf.startdate,code,edf.edfsignals[s]->data,recs,duration,edf.edfsignals[s]->digital_minimum,edf.edfsignals[s]->digital_maximum); edf.edfsignals[s]->data=NULL; // so it doesn't get deleted when edf gets trashed. sess->AddWaveform(w);