From 86d0f1e1b87c3da9ba5450c31f8231b716893db9 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Fri, 5 Jun 2009 15:46:39 +0000 Subject: [PATCH] added some more graph code --- src/serverlogging.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/serverlogging.cpp b/src/serverlogging.cpp index 9f5660ee..43443ad6 100755 --- a/src/serverlogging.cpp +++ b/src/serverlogging.cpp @@ -50,7 +50,10 @@ CServerLogging::CServerLogging() : const QColor PlotFrameColor ( Qt::black ); // black frame const QColor PlotGridColor ( Qt::gray ); // gray grid const QColor PlotTextColor ( Qt::black ); // black text + const QColor PlotMarkerColor ( Qt::red ); // red marker + // get current date (this is the right edge of the x-axis) + const QDate curDate = QDate::currentDate(); // create base pixmap for plot QRect PlotCanvasRect ( QPoint ( 0, 0 ), QPoint ( iPlotWidth, iPlotHeight ) ); @@ -86,7 +89,7 @@ CServerLogging::CServerLogging() : PlotPainter.drawText ( QPoint ( iCurX - iTextOffsetX, PlotGridFrame.bottom() + iYAxisTextHeight + iTextOffsetToGrid ), - QDate::currentDate().addDays ( i - iNumTicksX + 1 ).toString ( "dd.MM." ) ); + curDate.addDays ( i - iNumTicksX + 1 ).toString ( "dd.MM." ) ); } // grid @@ -123,6 +126,24 @@ CServerLogging::CServerLogging() : + +// TEST add some points in the graph +const QDate testDate = QDate::currentDate().addDays ( -3 ); +const QTime testTime = QTime ( 18, 0, 0, 0 ); + +const int iXAxisOffs = curDate.daysTo ( testDate ); +const int iYAxisOffs = 24 - testTime.hour(); + +const QPoint curPoint ( + PlotGridFrame.x() + PlotGridFrame.width() / iNumTicksX * ( iNumTicksX + iXAxisOffs ), + PlotGridFrame.y() + PlotGridFrame.height() / ( iYAxisEnd - iYAxisStart ) * iYAxisOffs ); + +PlotPainter.setPen ( QPen ( QBrush ( PlotMarkerColor ), 9 ) ); +PlotPainter.drawPoint ( curPoint ); + + + + // save plot as a file PlotPixmap.save ( "test.jpg", "JPG", 90 );