From e92eaf98a3075f4abca3784d899a78f01c7a2735 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Tue, 12 Jul 2011 18:53:16 +1000 Subject: [PATCH] XAxis improvements to Usage Graph --- Graphs/gSessionTime.cpp | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/Graphs/gSessionTime.cpp b/Graphs/gSessionTime.cpp index 94108123..6eb3bf9f 100644 --- a/Graphs/gSessionTime.cpp +++ b/Graphs/gSessionTime.cpp @@ -63,14 +63,22 @@ void gSessionTime::Plot(gGraphWindow & w,float scrx,float scry) double px1,px2,py1,py2; QColor & col1=color[0]; QColor col2("light grey"); + QString str; + bool draw_xticks_instead=false; + bool antialias=pref["UseAntiAliasing"].toBool(); QDateTime d; QTime t; double start,end,total; + float textX,textY; + map datedrawn; + + int idx=-1; for (int i=0;inp[0];i++) { QPointD & rp=data->point[0][i]; if (int(rp.x()) < int(minx)) continue; if (int(rp.x()) > int(maxx+.5)) break; + if (idx<0) idx=i; d=QDateTime::fromTime_t(rp.x()*86400.0); t=d.time(); start=t.hour()+(t.minute()/60.0)+(t.second()/3600.0); @@ -119,7 +127,29 @@ void gSessionTime::Plot(gGraphWindow & w,float scrx,float scry) glVertex2f(rect.x()+rect.width(),rect.y()); glVertex2f(rect.x()+rect.width(), rect.y()+rect.height()); glEnd(); + if (!draw_xticks_instead) { + if (datedrawn.find(dy)==datedrawn.end()) { + datedrawn[dy]=true; + str=FormatX(rp.y()); + + GetTextExtent(str, textX, textY); + if (!draw_xticks_instead && (textY+6SetShowMinorTicks(false); + Xaxis->Plot(w,scrx,scry); + } + glColor3f (0.0F, 0.0F, 0.0F); glLineWidth(1); glBegin (GL_LINES); @@ -128,6 +158,4 @@ void gSessionTime::Plot(gGraphWindow & w,float scrx,float scry) glVertex2f (start_px,start_py); glVertex2f (start_px+width, start_py); glEnd (); - - Xaxis->Plot(w,scrx,scry); }