Real YAxis Ticker fix.. removed the ugly hacks

This commit is contained in:
Mark Watkins 2011-09-04 22:25:11 +10:00
parent 6d71d7f353
commit 9922efc61a
6 changed files with 34 additions and 91 deletions

View File

@ -283,7 +283,7 @@ void UsageChart::SetDay(Day * day)
if (total>m_maxy) m_maxy=total;
}
}
m_maxy=ceil(m_maxy);
//m_maxy=ceil(m_maxy);
//m_miny=floor(m_miny);
m_miny=0;
@ -354,7 +354,7 @@ void AHIChart::SetDay(Day * day)
if (total>m_maxy) m_maxy=total;
}
}
m_maxy=ceil(m_maxy);
//m_maxy=ceil(m_maxy);
//m_miny=floor(m_miny);
m_miny=0;

View File

@ -977,19 +977,19 @@ EventDataType gGraph::MaxY()
void gGraph::SetMinX(qint64 v)
{
min_x=v;
rmax_x=min_x=v;
}
void gGraph::SetMaxX(qint64 v)
{
max_x=v;
rmin_x=max_x=v;
}
void gGraph::SetMinY(EventDataType v)
{
min_y=v;
rmin_y=min_y=v;
}
void gGraph::SetMaxY(EventDataType v)
{
max_y=v;
rmax_y=max_y=v;
}
GLBuffer * gGraph::lines()
{
@ -1050,14 +1050,22 @@ void gGraph::roundY(EventDataType &miny, EventDataType &maxy)
maxy=m*10;
m=floor(miny/10.0);
miny=m*10;
} else if (maxy>1) {
} else if (maxy>=4) {
m=ceil(maxy/5.0);
maxy=m*5;
m=floor(miny/5.0);
miny=m*5;
} else {
maxy=ceil(maxy);
miny=floor(miny);
if (maxy==miny && maxy==0) {
maxy=0.5;
} else {
maxy*=4.0;
miny*=4.0;
maxy=ceil(maxy);
miny=floor(miny);
maxy/=4.0;
miny/=4.0;
}
}
}

View File

@ -242,8 +242,8 @@ public:
void resize(int width, int height); // margin recalcs..
qint64 max_x,min_x,max_y,min_y;
qint64 rmax_x,rmin_x,rmax_y,rmin_y;
qint64 max_x,min_x,rmax_x,rmin_x;
EventDataType max_y,min_y,rmax_y,rmin_y;
bool blockZoom() { return m_blockzoom; }
void setBlockZoom(bool b) { m_blockzoom=b; }

View File

@ -30,19 +30,12 @@ void gXGrid::paint(gGraph & w,int left,int top, int width, int height)
EventDataType miny=w.min_y;
EventDataType maxy=w.max_y;
if (miny<0) {
if (miny<0) { // even it up if it's starts negative
miny=-MAX(fabs(miny),fabs(maxy));
}
EventDataType dy=maxy-miny;
if (dy<=0) {
if ((maxy==0) && (miny==0))
return;
//miny=miny;
maxy++;
dy=1;
}
w.roundY(miny,maxy);
EventDataType dy=maxy-miny;
if (height<0) return;
@ -121,55 +114,15 @@ void gYAxis::paint(gGraph & w,int left,int top, int width, int height)
int x,y;
int labelW=0;
double miny=w.min_y;
double maxy=w.max_y;
EventDataType miny=w.min_y;
EventDataType maxy=w.max_y;
if (miny<0) {
if (miny<0) { // even it up if it's starts negative
miny=-MAX(fabs(miny),fabs(maxy));
}
double dy=maxy-miny;
if (dy<=0) {
if ((maxy==0) && (miny==0))
return;
//miny=miny;
maxy++;
dy=1;
}
int m;
if (maxy>500) {
m=ceil(maxy/100.0);
maxy=m*100;
m=floor(miny/100.0);
miny=m*100;
} else if (maxy>150) {
m=ceil(maxy/50.0);
maxy=m*50;
m=floor(miny/50.0);
miny=m*50;
} else if (maxy>80) {
m=ceil(maxy/20.0);
maxy=m*20;
m=floor(miny/20.0);
miny=m*20;
} else if (maxy>30) {
m=ceil(maxy/10.0);
maxy=m*10;
m=floor(miny/10.0);
miny=m*10;
} else if (maxy>5) {
m=ceil(maxy/5.0);
maxy=m*5;
m=floor(miny/5.0);
miny=m*5;
} else {
//maxy=ceil(maxy);
//if (maxy<1) maxy=1;
//miny=floor(miny);
//if (miny<1) miny=0;
}
w.roundY(miny,maxy);
EventDataType dy=maxy-miny;
//if ((w.max_x-w.min_x)==0)
// return;
@ -217,7 +170,12 @@ void gYAxis::paint(gGraph & w,int left,int top, int width, int height)
for (double i=miny; i<=maxy+min_ytick-0.00001; i+=min_ytick) {
ty=(i - miny) * ymult;
fd=Format(i*m_yaxis_scale); // Override this as a function.
if (dy<5) {
fd=QString().sprintf("%.2f",i*m_yaxis_scale);
} else {
fd=QString().sprintf("%.1f",i*m_yaxis_scale);
}
//fd=Format(i*m_yaxis_scale); // Override this as a function.
GetTextExtent(fd,x,y);
if (x>labelW) labelW=x;
h=top+height-ty;

View File

@ -1032,16 +1032,6 @@ bool PRS1Loader::Parse002ASV(Session *session,unsigned char *buffer,int size,qin
return false;
}
}
/*EventList *a;
for (int i=0;i<24;i++){
a=Code[i];
if (a) {
int v=ceil(a->max()/5);
a->setMax(v*5);
v=floor(a->min()/5);
a->setMin(v*5);
}
}*/
session->updateLast(t);
return true;
}
@ -1292,10 +1282,6 @@ bool PRS1Loader::OpenWaveforms(Session *session,QString filename)
a->setMax(120);
a->setMin(-120);
} else if (wc[i]==CPAP_MaskPressure) {
/*int v=ceil(a->max()/5);
a->setMax(v*5);
v=floor(a->min()/5);
a->setMin(v*5); */
}
session->eventlist[wc[i]].push_back(a);
session->updateLast(start+qint64(wdur[i])*1000L);

View File

@ -585,13 +585,7 @@ bool ResmedLoader::LoadBRP(Session *sess,EDFParser &edf)
a->AddWaveform(edf.startdate,es.data,recs,duration);
if (code==CPAP_MaskPressure) {
/*int v=ceil(a->max()/1);
a->setMax(v*1);
v=floor(a->min()/1);
a->setMin(v*1); */
} else if (code==CPAP_FlowRate) {
//a->setMax(1);
//a->setMin(-1);
}
sess->setMin(code,a->min());
sess->setMax(code,a->max());
@ -788,11 +782,8 @@ bool ResmedLoader::LoadPLD(Session *sess,EDFParser &edf)
a=NULL;
}
if (a) {
double min=floor(a->min()), max=ceil(a->max());
if (min==max) max+=1;
sess->setMin(code,min);
sess->setMax(code,max);
sess->setMin(code,a->min());
sess->setMax(code,a->max());
a->setDimension(es.physical_dimension);
}
}