From dad2dedbe9ae465e1e0f1009143f7451213f5846 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Tue, 12 Jul 2011 17:29:02 +1000 Subject: [PATCH] YAxis Tickers for Usage Graph --- Graphs/gSessionTime.cpp | 19 +++++++++++++++++++ Graphs/gSessionTime.h | 10 ++++++++++ overview.cpp | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Graphs/gSessionTime.cpp b/Graphs/gSessionTime.cpp index 037fdf7b..94108123 100644 --- a/Graphs/gSessionTime.cpp +++ b/Graphs/gSessionTime.cpp @@ -8,6 +8,25 @@ #include #include "gSessionTime.h" +gTimeYAxis::gTimeYAxis(QColor col) + :gYAxis(col) +{ +} +gTimeYAxis::~gTimeYAxis() +{ +} +const QString & gTimeYAxis::Format(double v) +{ + static QString t; + int i=v; + if (i<0) i=24+i; + + + t.sprintf("%02i:00",i); + return t; +}; + + gSessionTime::gSessionTime(gPointData *d,QColor col,Qt::Orientation o) :gLayer(d),m_orientation(o) { diff --git a/Graphs/gSessionTime.h b/Graphs/gSessionTime.h index 49f7a092..13d39320 100644 --- a/Graphs/gSessionTime.h +++ b/Graphs/gSessionTime.h @@ -9,6 +9,16 @@ #include "graphlayer.h" #include "gXAxis.h" +#include "gYAxis.h" + +class gTimeYAxis:public gYAxis +{ +public: + gTimeYAxis(QColor col=QColor("black")); + virtual ~gTimeYAxis(); + virtual const QString & Format(double v); +}; + class gSessionTime:public gLayer { diff --git a/overview.cpp b/overview.cpp index 05e8b2b9..98f480b2 100644 --- a/overview.cpp +++ b/overview.cpp @@ -92,7 +92,7 @@ Overview::Overview(QWidget *parent,QGLContext *context) : AddGraph(SESSTIMES=new gGraphWindow(ui->SummaryGraphWindow,tr("Session Times"),AHI)); //SESSTIMES->SetMargins(10,15,65,80); SESSTIMES->AddLayer(new gFooBar(7)); - SESSTIMES->AddLayer(new gYAxis()); + SESSTIMES->AddLayer(new gTimeYAxis()); SESSTIMES->AddLayer(new gSessionTime(session_times,QColor("green"))); SESSTIMES->SetBottomMargin(SESSTIMES->GetBottomMargin()+gXAxis::Margin+25); //SESSTIMES->AddLayer(new gXAxis());