QPainter does not work in offscreen graphs

This commit is contained in:
Mark Watkins 2011-07-22 23:46:17 +10:00
parent 5b18435f3f
commit ea18dc5890
16 changed files with 183 additions and 160 deletions

View File

@ -24,14 +24,6 @@ void gFlagsGroup::Plot(gGraphWindow &w, float scrx, float scry)
int width=scrx-(w.GetLeftMargin()+w.GetRightMargin())-1; int width=scrx-(w.GetLeftMargin()+w.GetRightMargin())-1;
int height=scry-(w.GetTopMargin()+w.GetBottomMargin()); int height=scry-(w.GetTopMargin()+w.GetBottomMargin());
glColor3f (0.1F, 0.1F, 0.1F);
glLineWidth (1);
glBegin (GL_LINE_LOOP);
glVertex2f (start_px-1, start_py);
glVertex2f (start_px-1, start_py+height);
glVertex2f (start_px+width,start_py+height);
glVertex2f (start_px+width, start_py);
glEnd ();
vector<gFlagsLine *> visible; vector<gFlagsLine *> visible;
for (unsigned i=0;i<layers.size();i++) { for (unsigned i=0;i<layers.size();i++) {
@ -48,6 +40,15 @@ void gFlagsGroup::Plot(gGraphWindow &w, float scrx, float scry)
visible[i]->total_lines=vis; visible[i]->total_lines=vis;
visible[i]->Plot(w,scrx,scry); visible[i]->Plot(w,scrx,scry);
} }
glColor3f (0.0F, 0.0F, 0.0F);
glLineWidth (1);
glBegin (GL_LINE_LOOP);
glVertex2f (start_px-1, start_py);
glVertex2f (start_px-1, start_py+height);
glVertex2f (start_px+width,start_py+height);
glVertex2f (start_px+width, start_py);
glEnd ();
} }

View File

@ -104,22 +104,28 @@ vector<TextBuffer *> TextQueRot;
void DrawTextQueue(gGraphWindow & wid) void DrawTextQueue(gGraphWindow & wid)
{ {
glFlush(); //glFlush();
QPainter painter(&wid);
for (unsigned i=0;i<TextQue.size();i++) { for (unsigned i=0;i<TextQue.size();i++) {
TextBuffer & t=*TextQue[i]; TextBuffer & t=*TextQue[i];
RDrawText(painter,t.text,t.x,t.y,t.angle,t.color,t.font); wid.qglColor(t.color);
wid.renderText(t.x,wid.GetScrY()-t.y,0,t.text,*t.font);
//RDrawText(painter,t.text,t.x,t.y,t.angle,t.color,t.font);
delete TextQue[i]; delete TextQue[i];
} }
if (wid.parentWidget()!=0) {
QPainter painter(&wid);
// TODO.. Prerotate the 90degree stuff here and keep the matrix for all of these.. // TODO.. Prerotate the 90degree stuff here and keep the matrix for all of these..
TextQue.clear();
for (unsigned i=0;i<TextQueRot.size();i++) { for (unsigned i=0;i<TextQueRot.size();i++) {
TextBuffer & t=*TextQueRot[i]; TextBuffer & t=*TextQueRot[i];
RDrawText(painter,t.text,t.x,t.y,t.angle,t.color,t.font); RDrawText(painter,t.text,t.x,t.y,t.angle,t.color,t.font);
delete TextQueRot[i]; delete TextQueRot[i];
} }
TextQueRot.clear();
painter.end(); painter.end();
}
TextQueRot.clear();
TextQue.clear();
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);

View File

@ -110,7 +110,7 @@ int PRS1Loader::Open(QString & path,Profile *profile)
if ((!dir.exists() || !dir.isReadable())) if ((!dir.exists() || !dir.isReadable()))
return 0; return 0;
qDebug() << "PRS1Loader::Open newpath=" << newpath; //qDebug() << "PRS1Loader::Open newpath=" << newpath;
dir.setFilter(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoSymLinks); dir.setFilter(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoSymLinks);
dir.setSorting(QDir::Name); dir.setSorting(QDir::Name);
QFileInfoList flist=dir.entryInfoList(); QFileInfoList flist=dir.entryInfoList();
@ -157,7 +157,6 @@ int PRS1Loader::Open(QString & path,Profile *profile)
delete m; delete m;
} }
} }
qDebug() << "Open() Done";
return PRS1List.size(); return PRS1List.size();
} }
@ -287,8 +286,8 @@ int PRS1Loader::OpenMachine(Machine *m,QString path,Profile *profile)
if (!OpenSummary(sess,s->second[0])) { if (!OpenSummary(sess,s->second[0])) {
//qWarning() << "PRS1Loader: Dodgy summary file " << s->second[0]; //qWarning() << "PRS1Loader: Dodgy summary file " << s->second[0];
// delete sess; delete sess;
// continue; continue;
} }
//sess->SetSessionID(sess->start().GetTicks()); //sess->SetSessionID(sess->start().GetTicks());
if (!s->second[1].isEmpty()) { if (!s->second[1].isEmpty()) {
@ -303,20 +302,16 @@ int PRS1Loader::OpenMachine(Machine *m,QString path,Profile *profile)
} }
const double ignore_thresh=300.0/3600.0;// Ignore useless sessions under 5 minute const double ignore_thresh=300.0/3600.0;// Ignore useless sessions under 5 minute
if (sess->hours()<=ignore_thresh) { if (sess->hours()<=ignore_thresh) {
qDebug() << "Igoring short session" << session << "which is only" << (sess->hours()*60.0) << "minute(s) long"; //qDebug() << "Ignoring short session" << session << "which is only" << (sess->hours()*60.0) << "minute(s) long";
delete sess; delete sess;
continue; continue;
} }
m->AddSession(sess,profile);
//if (sess->summary.find(CPAP_Obstructive)==sess->summary.end()) {
sess->summary[CPAP_Obstructive]=sess->count_events(CPAP_Obstructive); sess->summary[CPAP_Obstructive]=sess->count_events(CPAP_Obstructive);
sess->summary[CPAP_Hypopnea]=sess->count_events(CPAP_Hypopnea); sess->summary[CPAP_Hypopnea]=sess->count_events(CPAP_Hypopnea);
sess->summary[CPAP_ClearAirway]=sess->count_events(CPAP_ClearAirway); sess->summary[CPAP_ClearAirway]=sess->count_events(CPAP_ClearAirway);
sess->summary[CPAP_RERA]=sess->count_events(CPAP_RERA); sess->summary[CPAP_RERA]=sess->count_events(CPAP_RERA);
sess->summary[CPAP_FlowLimit]=sess->count_events(CPAP_FlowLimit); sess->summary[CPAP_FlowLimit]=sess->count_events(CPAP_FlowLimit);
sess->summary[CPAP_VSnore]=sess->count_events(CPAP_VSnore); sess->summary[CPAP_VSnore]=sess->count_events(CPAP_VSnore);
//}
sess->summary[CPAP_CSR]=sess->sum_event_field(CPAP_CSR,0); sess->summary[CPAP_CSR]=sess->sum_event_field(CPAP_CSR,0);
sess->summary[CPAP_Snore]=sess->sum_event_field(CPAP_Snore,0); sess->summary[CPAP_Snore]=sess->sum_event_field(CPAP_Snore,0);
@ -382,13 +377,15 @@ int PRS1Loader::OpenMachine(Machine *m,QString path,Profile *profile)
//Printf(sess->start().Format()+wxT(" avgsummary=%.3f avgmine=%.3f\n"),sess->summary[CPAP_PressureAverage].GetDouble(),sess->weighted_avg_event_field(CPAP_Pressure,0)); //Printf(sess->start().Format()+wxT(" avgsummary=%.3f avgmine=%.3f\n"),sess->summary[CPAP_PressureAverage].GetDouble(),sess->weighted_avg_event_field(CPAP_Pressure,0));
sess->SetChanged(true); sess->SetChanged(true);
m->AddSession(sess,profile);
} }
QString s; QString s;
s.sprintf("%i",prs1_data_version); s.sprintf("%i",prs1_data_version);
m->properties["DataVersion"]=s; m->properties["DataVersion"]=s;
m->Save(); // Save any new sessions to disk in our format m->Save(); // Save any new sessions to disk in our format */
if (qprogress) qprogress->setValue(100); if (qprogress) qprogress->setValue(100);
qDebug() << "OpenMachine Done"; //qDebug() << "OpenMachine Done";
return true; return true;
} }
@ -976,11 +973,27 @@ bool PRS1Loader::OpenWaveforms(Session *session,QString filename)
pos+=length; pos+=length;
continue; continue;
} else { } else {
int diff=(lasttimestamp+duration)-timestamp; int diff=timestamp-(lasttimestamp+duration);
if (block==1) {
if (diff>0)
start-=diff;
}
length=m_buffer[pos+0x1] | m_buffer[pos+0x2] << 8; // block length in bytes length=m_buffer[pos+0x1] | m_buffer[pos+0x2] << 8; // block length in bytes
duration=m_buffer[pos+0xf] | m_buffer[pos+0x10] << 8; // block duration in seconds duration=m_buffer[pos+0xf] | m_buffer[pos+0x10] << 8; // block duration in seconds
if (diff || corrupt) { /* if (diff<0) {
qDebug() << "Timestamp restarts" << diff << corrupt << duration; //diff=abs(diff);
for (int i=0;i<num_signals;i++) {
for (int j=0;j<diff;j++) {
for (int k=0;k<whl[i].interleave;k++)
waveform[i][wlength[i]++]=0;
}
wdur[i]+=diff;
}
} else
if (diff>0 && wlength[0]>0) {
qDebug() << "Timestamp restarts" << block << diff << corrupt << duration << timestamp-lasttimestamp << filename;
for (int i=0;i<num_signals;i++) { for (int i=0;i<num_signals;i++) {
wf[i]=new SampleFormat [wlength[i]]; wf[i]=new SampleFormat [wlength[i]];
@ -997,11 +1010,11 @@ bool PRS1Loader::OpenWaveforms(Session *session,QString filename)
} }
start=timestamp; start=timestamp;
corrupt=0; corrupt=0;
} } */
} }
pos+=hl+1; pos+=hl+1;
//qDebug() << (duration*num_signals*whl[0].interleave) << length-(hl+3); //qDebug() << (duration*num_signals*whl[0].interleave) << duration;
if (num_signals==1) { // no interleave.. this is much quicker. if (num_signals==1) { // no interleave.. this is much quicker.
int bs=duration*whl[0].interleave; int bs=duration*whl[0].interleave;
memcpy((char *)&(waveform[0])[wlength[0]],(char *)&m_buffer[pos],bs); memcpy((char *)&(waveform[0])[wlength[0]],(char *)&m_buffer[pos],bs);
@ -1037,7 +1050,7 @@ bool PRS1Loader::OpenWaveforms(Session *session,QString filename)
} }
return true; return true;
} }
/*bool PRS1Loader::OldOpenWaveforms(Session *session,QString filename) /*bool PRS1Loader::OpenWaveforms(Session *session,QString filename)
{ {
int size,sequence,seconds,br,htype,version,numsignals; int size,sequence,seconds,br,htype,version,numsignals;
unsigned cnt=0; unsigned cnt=0;
@ -1277,8 +1290,8 @@ bool PRS1Loader::OpenWaveforms(Session *session,QString filename)
session->AddWaveform(w); session->AddWaveform(w);
} }
return true; return true;
} } */
*/
void InitModelMap() void InitModelMap()
{ {
ModelMap[34]="RemStar Pro with C-Flex+"; ModelMap[34]="RemStar Pro with C-Flex+";

View File

@ -223,6 +223,7 @@ Session *Machine::SessionExists(SessionID session)
return NULL; return NULL;
} }
} }
Day *Machine::AddSession(Session *s,Profile *p) Day *Machine::AddSession(Session *s,Profile *p)
{ {
double span=0; double span=0;
@ -238,8 +239,7 @@ Day *Machine::AddSession(Session *s,Profile *p)
//QTime time=d2.time(); //QTime time=d2.time();
// pref["NoonDateSplit"]=true; // pref["NoonDateSplit"]=true;
if (pref.Exists("NoonDataSplit") && pref["NoonDateSplit"].toBool()) {
if (pref["NoonDateSplit"].toBool()) {
int hour=d2.time().hour(); int hour=d2.time().hour();
if (hour<12) if (hour<12)
date=date.addDays(-1); date=date.addDays(-1);
@ -302,7 +302,6 @@ Day *Machine::AddSession(Session *s,Profile *p)
//qDebug() << "New day: " << d.toString("yyyy-MM-dd HH:mm:ss"); //qDebug() << "New day: " << d.toString("yyyy-MM-dd HH:mm:ss");
p->AddDay(date,day[date],m_type); p->AddDay(date,day[date],m_type);
} }
day[date]->AddSession(s); day[date]->AddSession(s);
return day[date]; return day[date];
@ -432,13 +431,13 @@ bool Machine::Save()
for (d=day.begin();d!=day.end();d++) { for (d=day.begin();d!=day.end();d++) {
qDebug() << "Day Save Commenced"; //qDebug() << "Day Save Commenced";
for (s=d->second->begin(); s!=d->second->end(); s++) { for (s=d->second->begin(); s!=d->second->end(); s++) {
cnt++; cnt++;
if (qprogress) qprogress->setValue(66.0+(float(cnt)/float(size)*33.0)); if (qprogress) qprogress->setValue(66.0+(float(cnt)/float(size)*33.0));
if ((*s)->IsChanged()) (*s)->Store(path); if ((*s)->IsChanged()) (*s)->Store(path);
} }
qDebug() << "Day Save Completed"; //qDebug() << "Day Save Completed";
} }
return true; return true;

View File

@ -160,6 +160,7 @@ TiXmlElement * Profile::ExtraSave()
} }
#include <QMessageBox>
void Profile::AddDay(QDate date,Day *day,MachineType mt) { void Profile::AddDay(QDate date,Day *day,MachineType mt) {
//date+=wxTimeSpan::Day(); //date+=wxTimeSpan::Day();
if (is_first_day) { if (is_first_day) {
@ -170,14 +171,12 @@ void Profile::AddDay(QDate date,Day *day,MachineType mt) {
if (m_last<date) m_last=date; if (m_last<date) m_last=date;
// Check for any other machines of same type.. Throw an exception if one already exists. // Check for any other machines of same type.. Throw an exception if one already exists.
vector<Day *> & dl=daylist[date]; vector<Day *> & dl=daylist[date];
for (vector<Day *>::iterator a=dl.begin();a!=dl.end();a++) { for (vector<Day *>::iterator a=dl.begin();a!=dl.end();a++) {
if ((*a)->machine->GetType()==mt) { if ((*a)->machine->GetType()==mt) {
throw OneTypePerDay(); throw OneTypePerDay();
} }
} }
daylist[date].push_back(day); daylist[date].push_back(day);
} }
@ -213,7 +212,7 @@ int Profile::Import(QString path)
for (list<MachineLoader *>::iterator i=loaders.begin(); i!=loaders.end(); i++) { for (list<MachineLoader *>::iterator i=loaders.begin(); i!=loaders.end(); i++) {
if (c+=(*i)->Open(path,this)) break; if (c+=(*i)->Open(path,this)) break;
} }
qDebug() << "Import Done"; //qDebug() << "Import Done";
return c; return c;
} }

View File

@ -247,9 +247,7 @@ bool Session::OpenEvents() {
if(s_events_loaded) if(s_events_loaded)
return true; return true;
bool b; bool b;
qDebug() << "Open Events() Start";
b=LoadEvents(s_eventfile); b=LoadEvents(s_eventfile);
qDebug() << "Open Events() Done";
if (!b) { if (!b) {
qWarning() << "Error Unkpacking Events" << s_eventfile; qWarning() << "Error Unkpacking Events" << s_eventfile;
} }
@ -261,9 +259,7 @@ bool Session::OpenWaveforms() {
if (s_waves_loaded) if (s_waves_loaded)
return true; return true;
bool b; bool b;
qDebug() << "OpenWaveforms() Start";
b=LoadWaveforms(s_wavefile); b=LoadWaveforms(s_wavefile);
qDebug() << "OpenWaveforms() Done";
if (!b) { if (!b) {
qWarning() << "Error Unkpacking Wavefile" << s_wavefile; qWarning() << "Error Unkpacking Wavefile" << s_wavefile;
} }
@ -271,9 +267,6 @@ bool Session::OpenWaveforms() {
return b; return b;
}; };
bool Session::Store(QString path) bool Session::Store(QString path)
// Storing Session Data in our format // Storing Session Data in our format
// {DataDir}/{MachineID}/{SessionID}.{ext} // {DataDir}/{MachineID}/{SessionID}.{ext}
@ -285,14 +278,14 @@ bool Session::Store(QString path)
QString base; QString base;
base.sprintf("%08lx",s_session); base.sprintf("%08lx",s_session);
base=path+"/"+base; base=path+"/"+base;
qDebug() << "Storing Session: " << base; //qDebug() << "Storing Session: " << base;
bool a,b,c; bool a,b,c;
a=StoreSummary(base+".000"); // if actually has events a=StoreSummary(base+".000"); // if actually has events
qDebug() << " Summary done"; //qDebug() << " Summary done";
if (events.size()>0) b=StoreEvents(base+".001"); if (events.size()>0) b=StoreEvents(base+".001");
qDebug() << " Events done"; //qDebug() << " Events done";
if (waveforms.size()>0) c=StoreWaveforms(base+".002"); if (waveforms.size()>0) c=StoreWaveforms(base+".002");
qDebug() << " Waveform done"; //qDebug() << " Waveform done";
if (a) { if (a) {
s_changed=false; s_changed=false;
} }
@ -642,13 +635,13 @@ bool Session::StoreWaveforms(QString filename)
vector<Waveform *>::iterator j; vector<Waveform *>::iterator j;
int zz=0; int zz=0;
for (i=waveforms.begin(); i!=waveforms.end(); i++) { for (i=waveforms.begin(); i!=waveforms.end(); i++) {
qDebug() << "Storing Waveform" << zz++ << filename; //qDebug() << "Storing Waveform" << zz++ << filename;
out << (quint16)i->first; // Machine Code out << (quint16)i->first; // Machine Code
t16=i->second.size(); t16=i->second.size();
out << t16; // Number of (hopefully non-linear) waveform chunks out << t16; // Number of (hopefully non-linear) waveform chunks
int chnk=0; int chnk=0;
for (j=i->second.begin(); j!=i->second.end(); j++) { for (j=i->second.begin(); j!=i->second.end(); j++) {
qDebug() << "Storing Waveform Chunk" << chnk++; //qDebug() << "Storing Waveform Chunk" << chnk++;
Waveform &w=*(*j); Waveform &w=*(*j);
// 64bit number.. // 64bit number..
@ -666,7 +659,7 @@ bool Session::StoreWaveforms(QString filename)
//t8=0; // 0=signed, 1=unsigned, 2=float //t8=0; // 0=signed, 1=unsigned, 2=float
// followed by sample data. // followed by sample data.
qDebug() << "Writing " << (*j)->samples() << "samples"; //qDebug() << "Writing " << (*j)->samples() << "samples";
for (int k=0; k<(*j)->samples(); k++) out << w[k]; for (int k=0; k<(*j)->samples(); k++) out << w[k];
} }
} }

View File

@ -25,14 +25,13 @@
#include "Graphs/gBarChart.h" #include "Graphs/gBarChart.h"
#include "Graphs/gpiechart.h" #include "Graphs/gpiechart.h"
Daily::Daily(QWidget *parent,QGLContext *context) :
Daily::Daily(QWidget *parent,QGLWidget * shared) :
QWidget(parent), QWidget(parent),
ui(new Ui::Daily) ui(new Ui::Daily)
{ {
ui->setupUi(this); ui->setupUi(this);
shared_context=context;
QString prof=pref["Profile"].toString(); QString prof=pref["Profile"].toString();
profile=Profiles::Get(prof); profile=Profiles::Get(prof);
if (!profile) { if (!profile) {
@ -43,18 +42,8 @@ Daily::Daily(QWidget *parent,QGLContext *context) :
gSplitter=new QSplitter(Qt::Vertical,ui->scrollArea); gSplitter=new QSplitter(Qt::Vertical,ui->scrollArea);
gSplitter->setStyleSheet("QSplitter::handle { background-color: 'dark grey'; }"); gSplitter->setStyleSheet("QSplitter::handle { background-color: 'dark grey'; }");
gSplitter->setHandleWidth(2); gSplitter->setHandleWidth(2);
//gSplitter->handle
ui->graphSizer->addWidget(gSplitter); ui->graphSizer->addWidget(gSplitter);
//QPalette pal;
//QColor col("blue");
//pal.setColor(QPalette::Button, col);
//gSplitter->setPaletteForegroundColor(QColor("blue"));
//gSplitter->setBackgroundRole(QPalette::Button);
//ui->scrollArea->setWidgetResizable(true);
//gSplitter->setMinimumSize(500,500);
//gSplitter->setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum);
AddCPAPData(flags[3]=new FlagData(CPAP_Hypopnea,4)); AddCPAPData(flags[3]=new FlagData(CPAP_Hypopnea,4));
AddCPAPData(flags[0]=new FlagData(CPAP_CSR,7,1,0)); AddCPAPData(flags[0]=new FlagData(CPAP_CSR,7,1,0));
AddCPAPData(flags[1]=new FlagData(CPAP_ClearAirway,6)); AddCPAPData(flags[1]=new FlagData(CPAP_ClearAirway,6));
@ -66,15 +55,42 @@ Daily::Daily(QWidget *parent,QGLContext *context) :
AddCPAPData(flags[8]=new FlagData(PRS1_Unknown0E,1)); AddCPAPData(flags[8]=new FlagData(PRS1_Unknown0E,1));
AddCPAPData(flags[9]=new FlagData(CPAP_Snore,1)); // Snore Index AddCPAPData(flags[9]=new FlagData(CPAP_Snore,1)); // Snore Index
SF=new gGraphWindow(gSplitter,tr("Event Flags"),(QGLWidget *)NULL); SF=new gGraphWindow(gSplitter,tr("Event Flags"),shared);
fg=new gFlagsGroup(); FRW=new gGraphWindow(gSplitter,tr("Flow Rate"),SF);
PRD=new gGraphWindow(gSplitter,tr("Pressure"),SF);
LEAK=new gGraphWindow(gSplitter,tr("Leaks"),SF);
MP=new gGraphWindow(gSplitter,tr("Mask Pressure"),SF);
SNORE=new gGraphWindow(gSplitter,tr("Snore"),SF);
FLG=new gGraphWindow(gSplitter,tr("Flow Limitation"),SF);
MV=new gGraphWindow(gSplitter,tr("Minute Ventilation"),SF);
TV=new gGraphWindow(gSplitter,tr("Tidal Volume"),SF);
RR=new gGraphWindow(gSplitter,tr("Respiratory Rate"),SF);
PTB=new gGraphWindow(gSplitter,tr("Patient Trig Breaths"),SF);
PULSE=new gGraphWindow(gSplitter,tr("Pulse & SpO2"),SF);
/*QGLFormat fmt;
fmt.setDepth(false);
fmt.setDirectRendering(false);
fmt.setAlpha(true);
fmt.setDoubleBuffer(false);
fmt.setRgba(true);
//fmt.setDefaultFormat(fmt);
offscreen_context=new QGLContext(fmt); */
TAP=new gGraphWindow(NULL,"",(QGLWidget* )NULL);
TAP_EAP=new gGraphWindow(NULL,"",(QGLWidget* )NULL);
TAP_IAP=new gGraphWindow(NULL,"",(QGLWidget* )NULL);
G_AHI=new gGraphWindow(NULL,"",(QGLWidget* )NULL);
SF->SetLeftMargin(SF->GetLeftMargin()+gYAxis::Margin); SF->SetLeftMargin(SF->GetLeftMargin()+gYAxis::Margin);
SF->SetBlockZoom(true); SF->SetBlockZoom(true);
SF->AddLayer(new gXAxis()); SF->AddLayer(new gXAxis());
SF->setMinimumHeight(160);
int sfc=7; int sfc=7;
bool extras=false; //true; bool extras=false; //true;
fg=new gFlagsGroup();
fg->AddLayer(new gFlagsLine(flags[0],QColor("light green"),"CSR",false,0,sfc)); fg->AddLayer(new gFlagsLine(flags[0],QColor("light green"),"CSR",false,0,sfc));
fg->AddLayer(new gFlagsLine(flags[1],QColor("purple"),"CA",true,1,sfc)); fg->AddLayer(new gFlagsLine(flags[1],QColor("purple"),"CA",true,1,sfc));
fg->AddLayer(new gFlagsLine(flags[2],QColor("#40c0ff"),"OA",true,2,sfc)); fg->AddLayer(new gFlagsLine(flags[2],QColor("#40c0ff"),"OA",true,2,sfc));
@ -82,15 +98,11 @@ Daily::Daily(QWidget *parent,QGLContext *context) :
fg->AddLayer(new gFlagsLine(flags[4],QColor("black"),"FL",false,4,sfc)); fg->AddLayer(new gFlagsLine(flags[4],QColor("black"),"FL",false,4,sfc));
fg->AddLayer(new gFlagsLine(flags[6],QColor("gold"),"RE",false,6,sfc)); fg->AddLayer(new gFlagsLine(flags[6],QColor("gold"),"RE",false,6,sfc));
fg->AddLayer(new gFlagsLine(flags[5],QColor("red"),"VS",false,5,sfc)); fg->AddLayer(new gFlagsLine(flags[5],QColor("red"),"VS",false,5,sfc));
if (extras) {
fg->AddLayer(new gFlagsLine(flags[8],QColor("dark green"),"U0E",7,sfc)); fg->AddLayer(new gFlagsLine(flags[8],QColor("dark green"),"U0E",7,sfc));
fg->AddLayer(new gFlagsLine(flags[9],QColor("red"),"VS2",8,sfc)); //fg->AddLayer(new gFlagsLine(flags[9],QColor("red"),"VS2",8,sfc));
sfc++;
}
SF->AddLayer(fg); SF->AddLayer(fg);
// SF Foobar must go last
SF->AddLayer(new gFooBar(10,QColor("orange"),QColor("dark grey"),true)); SF->AddLayer(new gFooBar(10,QColor("orange"),QColor("dark grey"),true));
SF->setMinimumHeight(150+(extras ? 20 : 0));
// SF->setMaximumHeight(350);
AddCPAPData(pressure_iap=new EventData(CPAP_IAP)); AddCPAPData(pressure_iap=new EventData(CPAP_IAP));
AddCPAPData(pressure_eap=new EventData(CPAP_EAP)); AddCPAPData(pressure_eap=new EventData(CPAP_EAP));
@ -98,7 +110,6 @@ Daily::Daily(QWidget *parent,QGLContext *context) :
pressure_eap->ForceMinY(0); pressure_eap->ForceMinY(0);
pressure_eap->ForceMaxY(30); pressure_eap->ForceMaxY(30);
PRD=new gGraphWindow(gSplitter,tr("Pressure"),SF);
PRD->AddLayer(new gXAxis()); PRD->AddLayer(new gXAxis());
PRD->AddLayer(new gYAxis()); PRD->AddLayer(new gYAxis());
//PRD->AddLayer(new gFooBar()); //PRD->AddLayer(new gFooBar());
@ -109,7 +120,6 @@ Daily::Daily(QWidget *parent,QGLContext *context) :
PRD->setMinimumHeight(150); PRD->setMinimumHeight(150);
AddCPAPData(leak=new EventData(CPAP_Leak,0)); AddCPAPData(leak=new EventData(CPAP_Leak,0));
LEAK=new gGraphWindow(gSplitter,tr("Leaks"),SF);
LEAK->AddLayer(new gXAxis()); LEAK->AddLayer(new gXAxis());
LEAK->AddLayer(new gYAxis()); LEAK->AddLayer(new gYAxis());
//LEAK->AddLayer(new gFooBar()); //LEAK->AddLayer(new gFooBar());
@ -119,7 +129,6 @@ Daily::Daily(QWidget *parent,QGLContext *context) :
AddCPAPData(mp=new WaveData(CPAP_MaskPressure,1000000)); //FlowRate AddCPAPData(mp=new WaveData(CPAP_MaskPressure,1000000)); //FlowRate
MP=new gGraphWindow(gSplitter,tr("Mask Pressure"),SF);
gYAxis *y=new gYAxis(); gYAxis *y=new gYAxis();
y->SetScale(.1); y->SetScale(.1);
MP->AddLayer(y); MP->AddLayer(y);
@ -129,10 +138,8 @@ Daily::Daily(QWidget *parent,QGLContext *context) :
MP->AddLayer(g); MP->AddLayer(g);
MP->setMinimumHeight(120); MP->setMinimumHeight(120);
AddCPAPData(frw=new WaveData(CPAP_FlowRate,1000000)); //FlowRate AddCPAPData(frw=new WaveData(CPAP_FlowRate,1000000)); //FlowRate
// Holy crap resmed stuff is huge.. // Holy crap resmed stuff is huge..
FRW=new gGraphWindow(gSplitter,tr("Flow Rate"),SF);
//FRW->AddLayer(new gFooBar()); //FRW->AddLayer(new gFooBar());
FRW->AddLayer(new gYAxis()); FRW->AddLayer(new gYAxis());
FRW->AddLayer(new gXAxis()); FRW->AddLayer(new gXAxis());
@ -153,14 +160,12 @@ Daily::Daily(QWidget *parent,QGLContext *context) :
FRW->setMinimumHeight(150); FRW->setMinimumHeight(150);
AddCPAPData(snore=new EventData(CPAP_Snore,0)); AddCPAPData(snore=new EventData(CPAP_Snore,0));
SNORE=new gGraphWindow(gSplitter,tr("Snore"),SF);
SNORE->AddLayer(new gXAxis()); SNORE->AddLayer(new gXAxis());
SNORE->AddLayer(new gYAxis()); SNORE->AddLayer(new gYAxis());
SNORE->AddLayer(new gLineChart(snore,Qt::black,4096,false,false,true)); SNORE->AddLayer(new gLineChart(snore,Qt::black,4096,false,false,true));
SNORE->setMinimumHeight(150); SNORE->setMinimumHeight(150);
AddCPAPData(flg=new EventData(CPAP_FlowLimitGraph,0)); AddCPAPData(flg=new EventData(CPAP_FlowLimitGraph,0));
FLG=new gGraphWindow(gSplitter,tr("Flow Limitation"),SF);
FLG->AddLayer(new gXAxis()); FLG->AddLayer(new gXAxis());
FLG->AddLayer(new gYAxis()); FLG->AddLayer(new gYAxis());
FLG->AddLayer(new gLineChart(flg,Qt::black,4096,false,false,true)); FLG->AddLayer(new gLineChart(flg,Qt::black,4096,false,false,true));
@ -168,28 +173,24 @@ Daily::Daily(QWidget *parent,QGLContext *context) :
AddCPAPData(mv=new EventData(CPAP_MinuteVentilation)); AddCPAPData(mv=new EventData(CPAP_MinuteVentilation));
MV=new gGraphWindow(gSplitter,tr("Minute Ventilation"),SF);
MV->AddLayer(new gXAxis()); MV->AddLayer(new gXAxis());
MV->AddLayer(new gYAxis()); MV->AddLayer(new gYAxis());
MV->AddLayer(new gLineChart(mv,QColor(0x20,0x20,0x7f),65536,false,false,true)); MV->AddLayer(new gLineChart(mv,QColor(0x20,0x20,0x7f),65536,false,false,true));
MV->setMinimumHeight(150); MV->setMinimumHeight(150);
AddCPAPData(tv=new EventData(CPAP_TidalVolume)); AddCPAPData(tv=new EventData(CPAP_TidalVolume));
TV=new gGraphWindow(gSplitter,tr("Tidal Volume"),SF);
TV->AddLayer(new gXAxis()); TV->AddLayer(new gXAxis());
TV->AddLayer(new gYAxis()); TV->AddLayer(new gYAxis());
TV->AddLayer(new gLineChart(tv,QColor(0x7f,0x20,0x20),65536,false,false,true)); TV->AddLayer(new gLineChart(tv,QColor(0x7f,0x20,0x20),65536,false,false,true));
TV->setMinimumHeight(150); TV->setMinimumHeight(150);
AddCPAPData(rr=new EventData(CPAP_RespiratoryRate)); AddCPAPData(rr=new EventData(CPAP_RespiratoryRate));
RR=new gGraphWindow(gSplitter,tr("Respiratory Rate"),SF);
RR->AddLayer(new gXAxis()); RR->AddLayer(new gXAxis());
RR->AddLayer(new gYAxis()); RR->AddLayer(new gYAxis());
RR->AddLayer(new gLineChart(rr,Qt::gray,65536,false,false,true)); RR->AddLayer(new gLineChart(rr,Qt::gray,65536,false,false,true));
RR->setMinimumHeight(150); RR->setMinimumHeight(150);
AddCPAPData(ptb=new EventData(CPAP_PatientTriggeredBreaths )); AddCPAPData(ptb=new EventData(CPAP_PatientTriggeredBreaths ));
PTB=new gGraphWindow(gSplitter,tr("Patient Trig Breaths"),SF);
PTB->AddLayer(new gXAxis()); PTB->AddLayer(new gXAxis());
PTB->AddLayer(new gYAxis()); PTB->AddLayer(new gYAxis());
PTB->AddLayer(new gLineChart(ptb,Qt::gray,65536,false,false,true)); PTB->AddLayer(new gLineChart(ptb,Qt::gray,65536,false,false,true));
@ -199,7 +200,6 @@ Daily::Daily(QWidget *parent,QGLContext *context) :
AddOXIData(pulse=new EventData(OXI_Pulse,0,65536,true)); AddOXIData(pulse=new EventData(OXI_Pulse,0,65536,true));
//pulse->ForceMinY(40); //pulse->ForceMinY(40);
//pulse->ForceMaxY(120); //pulse->ForceMaxY(120);
PULSE=new gGraphWindow(gSplitter,tr("Pulse & SpO2"),SF);
PULSE->AddLayer(new gXAxis()); PULSE->AddLayer(new gXAxis());
PULSE->AddLayer(new gYAxis()); PULSE->AddLayer(new gYAxis());
// PULSE->AddLayer(new gFooBar()); // PULSE->AddLayer(new gFooBar());
@ -226,21 +226,18 @@ Daily::Daily(QWidget *parent,QGLContext *context) :
AddCPAPData(tap=new TAPData(CPAP_Pressure)); AddCPAPData(tap=new TAPData(CPAP_Pressure));
TAP=new gGraphWindow(gSplitter,"",SF);
//TAP->SetMargins(20,15,5,50); //TAP->SetMargins(20,15,5,50);
TAP->SetMargins(0,0,0,0); TAP->SetMargins(0,0,0,0);
TAP->AddLayer(new gCandleStick(tap)); TAP->AddLayer(new gCandleStick(tap));
//TAP->AddLayer(new gPieChart(tap)); //TAP->AddLayer(new gPieChart(tap));
TAP_EAP=new gGraphWindow(gSplitter,"",SF);
TAP_EAP->SetMargins(0,0,0,0); TAP_EAP->SetMargins(0,0,0,0);
TAP_EAP->AddLayer(new gCandleStick(tap_eap)); TAP_EAP->AddLayer(new gCandleStick(tap_eap));
TAP_IAP=new gGraphWindow(gSplitter,"",SF);
TAP_IAP->SetMargins(0,0,0,0); TAP_IAP->SetMargins(0,0,0,0);
TAP_IAP->AddLayer(new gCandleStick(tap_iap)); TAP_IAP->AddLayer(new gCandleStick(tap_iap));
G_AHI=new gGraphWindow(gSplitter,"",SF);
G_AHI->SetMargins(0,0,0,0); G_AHI->SetMargins(0,0,0,0);
AddCPAPData(g_ahi=new AHIData()); AddCPAPData(g_ahi=new AHIData());
//gCandleStick *l=new gCandleStick(g_ahi); //gCandleStick *l=new gCandleStick(g_ahi);
@ -260,6 +257,7 @@ Daily::Daily(QWidget *parent,QGLContext *context) :
l->color.push_back(QColor(0x60,0xff,0x60,0xff)); // green l->color.push_back(QColor(0x60,0xff,0x60,0xff)); // green
G_AHI->AddLayer(l); G_AHI->AddLayer(l);
G_AHI->SetGradientBackground(false); G_AHI->SetGradientBackground(false);
//G_AHI->setMaximumSize(2000,30); //G_AHI->setMaximumSize(2000,30);
//TAP->setMaximumSize(2000,30); //TAP->setMaximumSize(2000,30);
NoData=new QLabel(tr("No data"),gSplitter); NoData=new QLabel(tr("No data"),gSplitter);
@ -329,7 +327,6 @@ void Daily::ReloadGraphs()
if (!d.isValid()) { if (!d.isValid()) {
d=ui->calendar->selectedDate(); d=ui->calendar->selectedDate();
} }
on_calendar_currentPageChanged(d.year(),d.month()); on_calendar_currentPageChanged(d.year(),d.month());
ui->calendar->setSelectedDate(d); ui->calendar->setSelectedDate(d);
Load(d); Load(d);
@ -469,8 +466,8 @@ void Daily::Load(QDate date)
const int gwwidth=240; const int gwwidth=240;
const int gwheight=25; const int gwheight=25;
UpdateCPAPGraphs(cpap);
UpdateOXIGraphs(oxi); UpdateOXIGraphs(oxi);
UpdateCPAPGraphs(cpap);
UpdateEventsTree(ui->treeWidget,cpap); UpdateEventsTree(ui->treeWidget,cpap);
QString epr,modestr; QString epr,modestr;
@ -496,6 +493,7 @@ void Daily::Load(QDate date)
float rei=cpap->count(CPAP_RERA)/cpap->hours(); float rei=cpap->count(CPAP_RERA)/cpap->hours();
float vsi=cpap->count(CPAP_VSnore)/cpap->hours(); float vsi=cpap->count(CPAP_VSnore)/cpap->hours();
float fli=cpap->count(CPAP_FlowLimit)/cpap->hours(); float fli=cpap->count(CPAP_FlowLimit)/cpap->hours();
// float p90=cpap->percentile(CPAP_Pressure,0,0.9); // float p90=cpap->percentile(CPAP_Pressure,0,0.9);
eap90=cpap->percentile(CPAP_EAP,0,0.9); eap90=cpap->percentile(CPAP_EAP,0,0.9);
iap90=cpap->percentile(CPAP_IAP,0,0.9); iap90=cpap->percentile(CPAP_IAP,0,0.9);
@ -541,7 +539,8 @@ void Daily::Load(QDate date)
"</table></td>"; "</table></td>";
} }
html+="</tr>\n<tr><td colspan=4 align=center><i>"+tr("Event Breakdown")+"</i></td></tr>\n"; html+="</tr>\n<tr><td colspan=4 align=center><i>"+tr("Event Breakdown")+"</i></td></tr>\n";
{ if (1) {
G_AHI->setFixedSize(gwwidth,gwheight); G_AHI->setFixedSize(gwwidth,gwheight);
QPixmap pixmap=G_AHI->renderPixmap(120,120,false); //gwwidth,gwheight,false); QPixmap pixmap=G_AHI->renderPixmap(120,120,false); //gwwidth,gwheight,false);
QByteArray byteArray; QByteArray byteArray;
@ -620,11 +619,6 @@ void Daily::Load(QDate date)
// Instead of doing this, check whether any data exists.. // Instead of doing this, check whether any data exists..
// and show based on this factor. // and show based on this factor.
//cpap && cpap->count(CPAP_MinuteVentilation)>0 ? MV->show() : MV->hide();
//cpap && cpap->count(CPAP_MinuteVentilation)>0 ? MV->show() : MV->hide();
//cpap && cpap->count(CPAP_TidalVolume)>0 ? TV->show() : TV->hide();
//cpap && cpap->count(CPAP_RespiratoryRate)>0 ? RR->show() : RR->hide();
//cpap && cpap->count(CPAP_FlowLimitGraph)>0 ? FLG->show() : FLG->hide();
mv->isEmpty() ? MV->hide() : MV->show(); mv->isEmpty() ? MV->hide() : MV->show();
tv->isEmpty() ? TV->hide() : TV->show(); tv->isEmpty() ? TV->hide() : TV->show();
rr->isEmpty() ? RR->hide() : RR->show(); rr->isEmpty() ? RR->hide() : RR->show();
@ -882,8 +876,9 @@ void Daily::RedrawGraphs()
// could recall Min & Max stuff here to reset cache // could recall Min & Max stuff here to reset cache
// instead of using the dodgy notify calls. // instead of using the dodgy notify calls.
for (list<gGraphWindow *>::iterator g=Graphs.begin();g!=Graphs.end();g++) {
(*g)->updateGL(); for (int i=0;i<Graphs.size();i++) {
Graphs[i]->updateGL();
} }
} }

10
daily.h
View File

@ -28,11 +28,11 @@ class Daily : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit Daily(QWidget *parent,QGLContext *context); explicit Daily(QWidget *parent,QGLWidget *shared=NULL);
~Daily(); ~Daily();
void SetGLContext(QGLContext *context) { shared_context=context; }
void ReloadGraphs(); void ReloadGraphs();
void RedrawGraphs(); void RedrawGraphs();
QGLWidget *SharedWidget() { return SF; };
private slots: private slots:
@ -65,8 +65,8 @@ private:
list<gPointData *> OXIData; list<gPointData *> OXIData;
list<gPointData *> CPAPData; list<gPointData *> CPAPData;
list<gGraphWindow *> Graphs; vector<gGraphWindow *> Graphs;
QGLContext *offscreen_context;
void AddCPAPData(gPointData *d) { CPAPData.push_back(d); } void AddCPAPData(gPointData *d) { CPAPData.push_back(d); }
void AddOXIData(gPointData *d) { OXIData.push_back(d); } void AddOXIData(gPointData *d) { OXIData.push_back(d); }
@ -79,10 +79,10 @@ private:
Ui::Daily *ui; Ui::Daily *ui;
Profile *profile; Profile *profile;
QDate previous_date; QDate previous_date;
QGLContext *shared_context;
QScrollArea *scrollArea; QScrollArea *scrollArea;
QSplitter *gSplitter; QSplitter *gSplitter;
QLabel *NoData; QLabel *NoData;
}; };
/*class AHIGraph:public QWebPluginFactory /*class AHIGraph:public QWebPluginFactory

View File

@ -12,15 +12,14 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "SleepLib/profiles.h" #include "SleepLib/profiles.h"
#include "SleepLib/loader_plugins/prs1_loader.h"
#include "SleepLib/loader_plugins/cms50_loader.h"
#include "SleepLib/loader_plugins/zeo_loader.h"
#include "SleepLib/loader_plugins/resmed_loader.h"
MainWindow *mainwin; MainWindow *mainwin=NULL;
void MyOutputHandler(QtMsgType type, const char *msg) { void MyOutputHandler(QtMsgType type, const char *msg) {
if (!mainwin) return; if (!mainwin) {
return;
}
switch (type) { switch (type) {
case QtDebugMsg: case QtDebugMsg:
mainwin->Log(msg); mainwin->Log(msg);
@ -42,7 +41,6 @@ void MyOutputHandler(QtMsgType type, const char *msg) {
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
qInstallMsgHandler(MyOutputHandler);
a.setApplicationName("SleepyHead"); a.setApplicationName("SleepyHead");
@ -54,12 +52,10 @@ int main(int argc, char *argv[])
a.setFont(QFont("FreeSans",10)); a.setFont(QFont("FreeSans",10));
PRS1Loader::Register();
CMS50Loader::Register();
ZEOLoader::Register();
ResmedLoader::Register();
MainWindow w; MainWindow w;
mainwin=&w; mainwin=&w;
qInstallMsgHandler(MyOutputHandler);
w.show(); w.show();
return a.exec(); return a.exec();

View File

@ -13,6 +13,12 @@
#include <QTimer> #include <QTimer>
#include "mainwindow.h" #include "mainwindow.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "SleepLib/loader_plugins/prs1_loader.h"
#include "SleepLib/loader_plugins/cms50_loader.h"
#include "SleepLib/loader_plugins/zeo_loader.h"
#include "SleepLib/loader_plugins/resmed_loader.h"
#include "daily.h" #include "daily.h"
#include "overview.h" #include "overview.h"
#include "Graphs/glcommon.h" #include "Graphs/glcommon.h"
@ -25,6 +31,9 @@ QStatusBar *qstatusbar;
void MainWindow::Log(QString s) void MainWindow::Log(QString s)
{ {
ui->logText->appendPlainText(s); ui->logText->appendPlainText(s);
if (s.startsWith("Warning")) {
int i=5;
}
} }
@ -34,21 +43,32 @@ MainWindow::MainWindow(QWidget *parent) :
ui(new Ui::MainWindow) ui(new Ui::MainWindow)
{ {
#ifndef Q_WS_MAC //#ifndef Q_WS_MAC
this->showMaximized(); // this->showMaximized();
#endif //#endif
ui->setupUi(this); ui->setupUi(this);
this->setWindowTitle(tr("SleepyHead")+QString(" v0.8.")+subversion); this->setWindowTitle(tr("SleepyHead")+QString(" v0.8.")+subversion);
ui->tabWidget->setCurrentIndex(0); ui->tabWidget->setCurrentIndex(0);
QGLFormat fmt; PRS1Loader::Register();
CMS50Loader::Register();
ZEOLoader::Register();
ResmedLoader::Register();
/* QGLFormat fmt;
fmt.setDepth(false); fmt.setDepth(false);
fmt.setDirectRendering(true); fmt.setDirectRendering(true);
fmt.setAlpha(true); fmt.setAlpha(true);
fmt.setDoubleBuffer(true); fmt.setDoubleBuffer(true);
fmt.setRgba(true); fmt.setRgba(true);
fmt.setDefaultFormat(fmt); fmt.setDefaultFormat(fmt);
shared_context=new QGLContext(fmt); QGLContext smeg(fmt); */
//new QGLContext(fmt);
//shared_context->create(shared_context);
daily=NULL;
overview=NULL;
oximetry=NULL;
//ui->tabWidget->setCurrentWidget(daily); //ui->tabWidget->setCurrentWidget(daily);
qstatusbar=ui->statusbar; qstatusbar=ui->statusbar;
@ -67,8 +87,6 @@ MainWindow::MainWindow(QWidget *parent) :
ui->statusbar->addPermanentWidget(qstatus2,0); ui->statusbar->addPermanentWidget(qstatus2,0);
ui->statusbar->addPermanentWidget(qstatus,0); ui->statusbar->addPermanentWidget(qstatus,0);
ui->statusbar->addPermanentWidget(qprogress,10); ui->statusbar->addPermanentWidget(qprogress,10);
daily=NULL;
overview=NULL;
Profiles::Scan(); Profiles::Scan();
//loader_progress->Show(); //loader_progress->Show();
@ -76,6 +94,7 @@ MainWindow::MainWindow(QWidget *parent) :
//pref["Version"]=wxString(AutoVersion::_FULLVERSION_STRING,wxConvUTF8); //pref["Version"]=wxString(AutoVersion::_FULLVERSION_STRING,wxConvUTF8);
if (!pref.Exists("AppName")) pref["AppName"]="SleepyHead"; if (!pref.Exists("AppName")) pref["AppName"]="SleepyHead";
if (!pref.Exists("Profile")) pref["Profile"]=getUserName(); if (!pref.Exists("Profile")) pref["Profile"]=getUserName();
if (!pref.Exists("LinkGraphMovement")) pref["LinkGraphMovement"]=true; if (!pref.Exists("LinkGraphMovement")) pref["LinkGraphMovement"]=true;
else ui->action_Link_Graphs->setChecked(pref["LinkGraphMovement"].toBool()); else ui->action_Link_Graphs->setChecked(pref["LinkGraphMovement"].toBool());
@ -129,13 +148,13 @@ void MainWindow::Startup()
profile=Profiles::Get(pref["Profile"].toString()); profile=Profiles::Get(pref["Profile"].toString());
profile->LoadMachineData(); profile->LoadMachineData();
daily=new Daily(ui->tabWidget,shared_context); daily=new Daily(ui->tabWidget);
ui->tabWidget->insertTab(1,daily,tr("Daily")); ui->tabWidget->insertTab(1,daily,tr("Daily"));
overview=new Overview(ui->tabWidget,shared_context); overview=new Overview(ui->tabWidget,daily->SharedWidget());
ui->tabWidget->insertTab(2,overview,tr("Overview")); ui->tabWidget->insertTab(2,overview,tr("Overview"));
oximetry=new Oximetry(ui->tabWidget); oximetry=new Oximetry(ui->tabWidget,daily->SharedWidget());
ui->tabWidget->insertTab(3,oximetry,tr("Oximetry")); ui->tabWidget->insertTab(3,oximetry,tr("Oximetry"));
qprogress->hide(); qprogress->hide();
@ -152,7 +171,7 @@ void MainWindow::on_action_Import_Data_triggered()
if (qfd.exec()) { if (qfd.exec()) {
qprogress->setValue(0); qprogress->setValue(0);
qprogress->show(); qprogress->show();
qstatus->setText(tr("Importing Data")); //qstatus->setText(tr("Importing Data"));
dirNames=qfd.selectedFiles(); dirNames=qfd.selectedFiles();
int c=0,d; int c=0,d;
for (int i=0;i<dirNames.size();i++) { for (int i=0;i<dirNames.size();i++) {
@ -165,14 +184,16 @@ void MainWindow::on_action_Import_Data_triggered()
qDebug() << "Finished Importing data" << c; qDebug() << "Finished Importing data" << c;
if (c) { if (c) {
profile->Save(); profile->Save();
qDebug() << " profile->Save();"; //qDebug() << " profile->Save();";
if (daily) daily->ReloadGraphs(); if (daily) daily->ReloadGraphs();
qDebug() << " daily->ReloadGraphs();";
//qDebug() << " daily->ReloadGraphs();";
if (overview) { if (overview) {
overview->ReloadGraphs(); overview->ReloadGraphs();
overview->UpdateGraphs(); overview->UpdateGraphs();
} }
qDebug() << "overview->ReloadGraphs();"; //qDebug() << "overview->ReloadGraphs();";
} }
qstatus->setText(tr("Ready")); qstatus->setText(tr("Ready"));
qprogress->hide(); qprogress->hide();
@ -285,7 +306,8 @@ void MainWindow::on_action_Link_Graphs_triggered(bool checked)
void MainWindow::on_actionUse_AntiAliasing_triggered(bool checked) void MainWindow::on_actionUse_AntiAliasing_triggered(bool checked)
{ {
pref["UseAntiAliasing"]=checked; pref["UseAntiAliasing"]=checked;
if (daily) daily->RedrawGraphs(); if (daily)
daily->RedrawGraphs();
} }
@ -307,5 +329,6 @@ void MainWindow::on_actionDebug_toggled(bool checked)
void MainWindow::on_actionOverlay_Bars_toggled(bool checked) void MainWindow::on_actionOverlay_Bars_toggled(bool checked)
{ {
pref["AlwaysShowOverlayBars"]=checked; pref["AlwaysShowOverlayBars"]=checked;
if (daily) daily->RedrawGraphs(); if (daily)
daily->RedrawGraphs();
} }

View File

@ -75,7 +75,6 @@ private:
Daily * daily; Daily * daily;
Overview * overview; Overview * overview;
Oximetry * oximetry; Oximetry * oximetry;
QGLContext *shared_context;
bool first_load; bool first_load;
Profile *profile; Profile *profile;
}; };

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>822</width> <width>930</width>
<height>468</height> <height>540</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -562,7 +562,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>822</width> <width>930</width>
<height>25</height> <height>25</height>
</rect> </rect>
</property> </property>

View File

@ -18,12 +18,11 @@
#include "Graphs/gFooBar.h" #include "Graphs/gFooBar.h"
#include "Graphs/gSessionTime.h" #include "Graphs/gSessionTime.h"
Overview::Overview(QWidget *parent,QGLContext *context) : Overview::Overview(QWidget *parent,QGLWidget * shared) :
QWidget(parent), QWidget(parent),
ui(new Ui::Overview) ui(new Ui::Overview)
{ {
ui->setupUi(this); ui->setupUi(this);
shared_context=context;
profile=Profiles::Get(pref["Profile"].toString()); profile=Profiles::Get(pref["Profile"].toString());
AddData(ahidata=new HistoryData(profile)); AddData(ahidata=new HistoryData(profile));
AddData(pressure=new HistoryCodeData(profile,CPAP_PressureAverage)); AddData(pressure=new HistoryCodeData(profile,CPAP_PressureAverage));
@ -46,7 +45,7 @@ Overview::Overview(QWidget *parent,QGLContext *context) :
gSplitter->setHandleWidth(3); gSplitter->setHandleWidth(3);
ui->graphLayout->addWidget(gSplitter); ui->graphLayout->addWidget(gSplitter);
AddGraph(AHI=new gGraphWindow(ui->SummaryGraphWindow,tr("AHI"),(QGLWidget *)NULL)); AddGraph(AHI=new gGraphWindow(ui->SummaryGraphWindow,tr("AHI"),shared)); //(QGLContext *)NULL));
AHI->SetTopMargin(10); AHI->SetTopMargin(10);
AHI->SetBottomMargin(AHI->GetBottomMargin()+gXAxis::Margin+25); AHI->SetBottomMargin(AHI->GetBottomMargin()+gXAxis::Margin+25);
//AHI->AddLayer(new gFooBar(7)); //AHI->AddLayer(new gFooBar(7));
@ -130,7 +129,7 @@ void Overview::RedrawGraphs()
for (list<gGraphWindow *>::iterator g=Graphs.begin();g!=Graphs.end();g++) { for (list<gGraphWindow *>::iterator g=Graphs.begin();g!=Graphs.end();g++) {
(*g)->updateGL(); (*g)->updateGL();
} }
SESSTIMES->updateGL(); //SESSTIMES->updateGL();
} }
void Overview::ReloadGraphs() void Overview::ReloadGraphs()
{ {

View File

@ -23,10 +23,9 @@ class Overview : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit Overview(QWidget *parent,QGLContext *context); explicit Overview(QWidget *parent,QGLWidget *shared=NULL);
~Overview(); ~Overview();
void SetGLContext(QGLContext *context) { shared_context=context; };
void ReloadGraphs(); void ReloadGraphs();
void UpdateGraphs(); void UpdateGraphs();
@ -43,7 +42,6 @@ private slots:
private: private:
Ui::Overview *ui; Ui::Overview *ui;
Profile *profile; Profile *profile;
QGLContext *shared_context;
void AddData(HistoryData *d) { Data.push_back(d); }; void AddData(HistoryData *d) { Data.push_back(d); };
void AddGraph(gGraphWindow *w) { Graphs.push_back(w); }; void AddGraph(gGraphWindow *w) { Graphs.push_back(w); };

View File

@ -12,7 +12,7 @@
#include "Graphs/gYAxis.h" #include "Graphs/gYAxis.h"
#include "Graphs/gFooBar.h" #include "Graphs/gFooBar.h"
Oximetry::Oximetry(QWidget *parent) : Oximetry::Oximetry(QWidget *parent,QGLWidget * shared) :
QWidget(parent), QWidget(parent),
ui(new Ui::Oximetry) ui(new Ui::Oximetry)
{ {
@ -32,7 +32,7 @@ Oximetry::Oximetry(QWidget *parent) :
ui->graphLayout->addWidget(gSplitter); ui->graphLayout->addWidget(gSplitter);
AddData(plethy=new WaveData(OXI_Plethy)); AddData(plethy=new WaveData(OXI_Plethy));
AddGraph(PLETHY=new gGraphWindow(gSplitter,tr("Plethysomogram"),(QGLWidget *)NULL)); AddGraph(PLETHY=new gGraphWindow(gSplitter,tr("Plethysomogram"),shared));
AddData(pulse=new EventData(OXI_Pulse)); AddData(pulse=new EventData(OXI_Pulse));
AddGraph(PULSE=new gGraphWindow(gSplitter,tr("Pulse Rate"),PLETHY)); AddGraph(PULSE=new gGraphWindow(gSplitter,tr("Pulse Rate"),PLETHY));
@ -103,9 +103,9 @@ void Oximetry::on_RefreshPortsButton_clicked()
if (!portname.isEmpty() && ports.at(i).qesPORTNAME==portname) current_found=true; if (!portname.isEmpty() && ports.at(i).qesPORTNAME==portname) current_found=true;
ui->SerialPortsCombo->addItem(ports.at(i).qesPORTNAME); ui->SerialPortsCombo->addItem(ports.at(i).qesPORTNAME);
z++; z++;
qDebug() << "Serial Port:" << ports.at(i).qesPORTNAME << ports.at(i).friendName;
} }
//qDebug() << "port name:" << ports.at(i).portName; //qDebug() << "port name:" << ports.at(i).portName;
qDebug() << "Serial Port:" << ports.at(i).qesPORTNAME << ports.at(i).friendName;
//qDebug() << "enumerator name:" << ports.at(i).enumName; //qDebug() << "enumerator name:" << ports.at(i).enumName;
} }
if (z>0) { if (z>0) {

View File

@ -2,6 +2,8 @@
#define OXIMETRY_H #define OXIMETRY_H
#include <QWidget> #include <QWidget>
#include <QGLContext>
#include <QSplitter> #include <QSplitter>
#include <qextserialport/qextserialport.h> #include <qextserialport/qextserialport.h>
@ -21,7 +23,7 @@ class Oximetry : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit Oximetry(QWidget *parent = 0); explicit Oximetry(QWidget *parent,QGLWidget * shared=NULL);
~Oximetry(); ~Oximetry();
void AddData(gPointData *d) { Data.push_back(d); } void AddData(gPointData *d) { Data.push_back(d); }