From 6c35df1de6d1bfe288eeaa60d2588324156fced2 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Sat, 3 Sep 2011 12:51:55 +1000 Subject: [PATCH] AHI miny set to 0 --- Graphs/gBarChart.cpp | 32 +++----------------------------- Graphs/gGraphView.cpp | 33 +++++++++++++++++++++++++++++++++ Graphs/gGraphView.h | 1 + Graphs/gLineChart.cpp | 34 +--------------------------------- Graphs/gYAxis.cpp | 34 ++++------------------------------ 5 files changed, 42 insertions(+), 92 deletions(-) diff --git a/Graphs/gBarChart.cpp b/Graphs/gBarChart.cpp index 6cf4a99d..6946770d 100644 --- a/Graphs/gBarChart.cpp +++ b/Graphs/gBarChart.cpp @@ -89,7 +89,8 @@ void gBarChart::SetDay(Day * day) } } m_maxy=ceil(m_maxy); - m_miny=floor(m_miny); + //m_miny=floor(m_miny); + m_miny=0; //m_minx-=86400000L; // 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 miny=m_miny; - // make this a reusable function in gGraph - 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; - } + w.roundY(miny,maxy); EventDataType yy=maxy-miny; EventDataType ymult=float(height-2)/yy; diff --git a/Graphs/gGraphView.cpp b/Graphs/gGraphView.cpp index 3d82559c..70211e14 100644 --- a/Graphs/gGraphView.cpp +++ b/Graphs/gGraphView.cpp @@ -1010,6 +1010,39 @@ void gGraph::ResetBounds() 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) : QGLWidget(parent,shared), diff --git a/Graphs/gGraphView.h b/Graphs/gGraphView.h index dd038143..090f22b3 100644 --- a/Graphs/gGraphView.h +++ b/Graphs/gGraphView.h @@ -210,6 +210,7 @@ public: void qglColor(QColor col); 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(); QString title() { return m_title; } diff --git a/Graphs/gLineChart.cpp b/Graphs/gLineChart.cpp index 8c16bcae..29f35d62 100644 --- a/Graphs/gLineChart.cpp +++ b/Graphs/gLineChart.cpp @@ -55,39 +55,7 @@ void gLineChart::paint(gGraph & w,int left, int top, int width, int height) miny=-MAX(fabs(miny),fabs(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; - } else { - maxy=ceil(maxy); - if (maxy<1) maxy=1; - - miny=floor(miny); - //if (miny<1) miny=0; - } + w.roundY(miny,maxy); double xx=maxx-minx; double xmult=double(width)/xx; diff --git a/Graphs/gYAxis.cpp b/Graphs/gYAxis.cpp index 8e823e64..ecd0f946 100644 --- a/Graphs/gYAxis.cpp +++ b/Graphs/gYAxis.cpp @@ -27,13 +27,13 @@ void gXGrid::paint(gGraph & w,int left,int top, int width, int height) { int x,y; - double miny=w.min_y; - double maxy=w.max_y; + EventDataType miny=w.min_y; + EventDataType maxy=w.max_y; if (miny<0) { miny=-MAX(fabs(miny),fabs(maxy)); } - double dy=maxy-miny; + EventDataType dy=maxy-miny; if (dy<=0) { if ((maxy==0) && (miny==0)) return; @@ -42,34 +42,8 @@ void gXGrid::paint(gGraph & w,int left,int top, int width, int height) 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; QString fd="0";