AHI miny set to 0

This commit is contained in:
Mark Watkins 2011-09-03 12:51:55 +10:00
parent f9b58e5ac2
commit 6c35df1de6
5 changed files with 42 additions and 92 deletions

View File

@ -89,7 +89,8 @@ void gBarChart::SetDay(Day * day)
} }
} }
m_maxy=ceil(m_maxy); m_maxy=ceil(m_maxy);
m_miny=floor(m_miny); //m_miny=floor(m_miny);
m_miny=0;
//m_minx-=86400000L; //m_minx-=86400000L;
// m_minx=qint64(QDateTime(m_profile->FirstDay(),QTime(0,0,0),Qt::UTC).toTime_t())*1000L; // m_minx=qint64(QDateTime(m_profile->FirstDay(),QTime(0,0,0),Qt::UTC).toTime_t())*1000L;
@ -121,34 +122,7 @@ void gBarChart::paint(gGraph & w,int left, int top, int width, int height)
EventDataType maxy=m_maxy; EventDataType maxy=m_maxy;
EventDataType miny=m_miny; EventDataType miny=m_miny;
// make this a reusable function in gGraph w.roundY(miny,maxy);
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;
}
EventDataType yy=maxy-miny; EventDataType yy=maxy-miny;
EventDataType ymult=float(height-2)/yy; EventDataType ymult=float(height-2)/yy;

View File

@ -1010,6 +1010,39 @@ void gGraph::ResetBounds()
max_y=MaxY(); max_y=MaxY();
} }
void gGraph::roundY(EventDataType &miny, EventDataType &maxy)
{
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>1) {
m=ceil(maxy/5.0);
maxy=m*5;
m=floor(miny/5.0);
miny=m*5;
} else {
maxy=ceil(maxy);
miny=floor(miny);
}
}
gGraphView::gGraphView(QWidget *parent, gGraphView * shared) : gGraphView::gGraphView(QWidget *parent, gGraphView * shared) :
QGLWidget(parent,shared), QGLWidget(parent,shared),

View File

@ -210,6 +210,7 @@ public:
void qglColor(QColor col); void qglColor(QColor col);
void renderText(QString text, int x,int y, float angle=0.0, QColor color=Qt::black, QFont *font=defaultfont); void renderText(QString text, int x,int y, float angle=0.0, QColor color=Qt::black, QFont *font=defaultfont);
void roundY(EventDataType &miny, EventDataType &maxy);
void drawGLBuf(); void drawGLBuf();
QString title() { return m_title; } QString title() { return m_title; }

View File

@ -55,39 +55,7 @@ void gLineChart::paint(gGraph & w,int left, int top, int width, int height)
miny=-MAX(fabs(miny),fabs(maxy)); miny=-MAX(fabs(miny),fabs(maxy));
} }
int m; w.roundY(miny,maxy);
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;
}
double xx=maxx-minx; double xx=maxx-minx;
double xmult=double(width)/xx; double xmult=double(width)/xx;

View File

@ -27,13 +27,13 @@ void gXGrid::paint(gGraph & w,int left,int top, int width, int height)
{ {
int x,y; int x,y;
double miny=w.min_y; EventDataType miny=w.min_y;
double maxy=w.max_y; EventDataType maxy=w.max_y;
if (miny<0) { if (miny<0) {
miny=-MAX(fabs(miny),fabs(maxy)); miny=-MAX(fabs(miny),fabs(maxy));
} }
double dy=maxy-miny; EventDataType dy=maxy-miny;
if (dy<=0) { if (dy<=0) {
if ((maxy==0) && (miny==0)) if ((maxy==0) && (miny==0))
return; return;
@ -42,34 +42,8 @@ void gXGrid::paint(gGraph & w,int left,int top, int width, int height)
dy=1; dy=1;
} }
w.roundY(miny,maxy);
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;
}
if (height<0) return; if (height<0) return;
QString fd="0"; QString fd="0";