YAxis tick cleanup, plus ResMed leaks to Litres per Minute instead of per second

This commit is contained in:
Mark Watkins 2011-08-07 18:52:12 +10:00
parent afc483dbf1
commit 67bfda3280
2 changed files with 58 additions and 32 deletions

View File

@ -33,13 +33,9 @@ void gYAxis::Plot(gGraphWindow &w,float scrx,float scry)
double dy=maxy-miny;
if (dy<=0) {
if (miny==0)
return;
else {
miny+=1;
maxy-=1;
dy=2;
}
//miny=miny;
maxy++;
dy=1;
}
int m;
@ -69,9 +65,9 @@ void gYAxis::Plot(gGraphWindow &w,float scrx,float scry)
m=floor(miny/5.0);
miny=m*5;
} else {
maxy=ceil(maxy);
if (maxy<1) maxy=1;
miny=floor(miny);
//maxy=ceil(maxy);
//if (maxy<1) maxy=1;
//miny=floor(miny);
//if (miny<1) miny=0;
}
@ -93,10 +89,13 @@ void gYAxis::Plot(gGraphWindow &w,float scrx,float scry)
double yt=1/max_yticks;
double mxy=MAX(maxy,fabs(miny));
double mny=MIN(maxy,fabs(miny));
double mxy=MAX(fabs(maxy),fabs(miny));
double mny=MIN(fabs(maxy),fabs(miny));
if (miny<0) mny=-mny;
if (maxy<0) mxy=-mxy;
//mny=miny;
//mxy=maxy;
double rxy=mxy-mny;
double ymult=height/rxy;
@ -131,24 +130,29 @@ void gYAxis::Plot(gGraphWindow &w,float scrx,float scry)
}
for (double i=miny+(min_ytick/2.0); i<maxy; i+=min_ytick) {
/*for (double i=miny+(min_ytick/2.0); i<maxy; i+=min_ytick) {
ty=(i - miny) * ymult;
h=(start_py+height)-ty;
vertarray[vertcnt++]=start_px-4;
vertarray[vertcnt++]=h;
vertarray[vertcnt++]=start_px;
vertarray[vertcnt++]=h;
if (m_show_minor_lines && (i > miny)) {
if (m_show_minor_lines) {// && (i > miny)) {
double z=(min_ytick/5)*ymult;
double g=h;
for (int i=0;i<4;i++) {
g+=z;
minorvertarray[minorvertcnt++]=start_px+1;
minorvertarray[minorvertcnt++]=h;
minorvertarray[minorvertcnt++]=g;
minorvertarray[minorvertcnt++]=start_px+width;
minorvertarray[minorvertcnt++]=h;
minorvertarray[minorvertcnt++]=g;
}
}
if (vertcnt>=maxverts) { // Should only need to check one.. The above check should be enough.
qWarning() << "vertarray bounds exceeded in gYAxis for " << w.Title() << "graph" << "MinY =" <<miny << "MaxY =" << maxy << "min_ytick=" <<min_ytick;
break;
}
}
} */
w.qglColor(m_text_color);
for (double i=miny; i<=maxy+min_ytick-0.00001; i+=min_ytick) {
@ -158,16 +162,12 @@ void gYAxis::Plot(gGraphWindow &w,float scrx,float scry)
if (x>labelW) labelW=x;
h=start_py+ty;
//w.renderText(start_px-12-x,scry-(h-(y/2.0)),fd);
DrawText(w,fd,start_px-12-x,scry-(h-(y/2.0)),0,m_text_color);
DrawText(w,fd,start_px-8-x,scry-(h-(y/2.0)),0,m_text_color);
vertarray[vertcnt++]=start_px-4;
vertarray[vertcnt++]=h;
vertarray[vertcnt++]=start_px;
vertarray[vertcnt++]=h;
if (vertcnt>=maxverts) {
qWarning() << "vertarray bounds exceeded in gYAxis for " << w.Title() << "graph" << "MinY =" <<miny << "MaxY =" << maxy << "min_ytick=" <<min_ytick;
break;
}
if (m_show_major_lines && (i > miny)) {
majorvertarray[majorvertcnt++]=start_px+1;
@ -175,6 +175,32 @@ void gYAxis::Plot(gGraphWindow &w,float scrx,float scry)
majorvertarray[majorvertcnt++]=start_px+width;
majorvertarray[majorvertcnt++]=h;
}
double z=(min_ytick/4)*ymult;
double g=h;
for (int i=0;i<3;i++) {
g+=z;
if (g>start_py+height) break;
vertarray[vertcnt++]=start_px-3;
vertarray[vertcnt++]=g;
vertarray[vertcnt++]=start_px;
vertarray[vertcnt++]=g;
if (vertcnt>=maxverts) {
qWarning() << "vertarray bounds exceeded in gYAxis for " << w.Title() << "graph" << "MinY =" <<miny << "MaxY =" << maxy << "min_ytick=" <<min_ytick;
break;
}
if (m_show_minor_lines) {// && (i > miny)) {
minorvertarray[minorvertcnt++]=start_px;
minorvertarray[minorvertcnt++]=g;
minorvertarray[minorvertcnt++]=start_px+width;
minorvertarray[minorvertcnt++]=g;
}
}
if (vertcnt>=maxverts) {
qWarning() << "vertarray bounds exceeded in gYAxis for " << w.Title() << "graph" << "MinY =" <<miny << "MaxY =" << maxy << "min_ytick=" <<min_ytick;
break;
}
}
if (vertcnt>=maxverts) {
qWarning() << "yAxis tickers and display should be corrupted, because something dumb is happening in " << w.Title() << "graph";

View File

@ -689,8 +689,8 @@ bool ResmedLoader::LoadPLD(Session *sess,EDFParser &edf)
//sess->eventlist[code].push_back(a);
//a->AddWaveform(edf.startdate,es.data,recs,duration);
a=ToTimeDelta(sess,edf,es, code,recs,duration,0,0);
a->setMax(1);
a->setMin(0);
//a->setMax(1);
//a->setMin(0);
} else if (es.label=="Therapy Pres") {
code=CPAP_IPAP; //TherapyPressure;
//EventList *a=new EventList(code,EVL_Waveform,es.gain,es.offset,es.physical_minimum,es.physical_maximum,rate);
@ -719,18 +719,18 @@ bool ResmedLoader::LoadPLD(Session *sess,EDFParser &edf)
a=ToTimeDelta(sess,edf,es, code,recs,duration,0,0);
} else if (es.label=="Leak") {
code=CPAP_Leak;
// es.gain*=100.0;
es.gain*=60;
//es.gain=1;//10.0;
es.offset=-0.5;
//es.offset=-0.5;
a=ToTimeDelta(sess,edf,es, code,recs,duration,0,0);
a->setMax(1);
a->setMin(0);
//a->setMax(1);
//a->setMin(0);
} else if (es.label=="FFL Index") {
code=CPAP_FlowLimitGraph;
//es.gain=1;//10.0;
a=ToTimeDelta(sess,edf,es, code,recs,duration,0,0);
a->setMax(1);
a->setMin(0);
//a->setMax(1);
//a->setMin(0);
} else if (es.label=="Mask Pres") {
code=CPAP_Pressure;
//es.gain=1;