From ab2a72fdcb546cd74591d4cf6c9dc4f91526e1bc Mon Sep 17 00:00:00 2001 From: Rivo Laks Date: Thu, 6 Sep 2007 15:30:57 +0000 Subject: [PATCH] Tune the range of the pixels drawn graph - displayed range is now 10^2 to 10^7.2 which should be good enough. The y-axis lines are for each 10^k, 2 <= k <= 7 svn path=/trunk/KDE/kdebase/workspace/; revision=709113 --- effects/showfps.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/effects/showfps.cpp b/effects/showfps.cpp index 1dc74f2c1c..68981b44c9 100644 --- a/effects/showfps.cpp +++ b/effects/showfps.cpp @@ -236,12 +236,16 @@ void ShowFpsEffect::paintDrawSizeGraph(int x, int y) for( int i = 0; i < NUM_PAINTS; i++) max_drawsize = qMax(max_drawsize, paint_size[ i ] ); - const int max_pixels_log = 8; - float drawscale = MAX_TIME / max_pixels_log; + // Log of min/max values shown on graph + const float max_pixels_log = 7.2f; + const float min_pixels_log = 2.0f; + const int minh = 5; // Minimum height of the bar when value > 0 + + float drawscale = (MAX_TIME - minh) / (max_pixels_log - min_pixels_log); QList drawlines; - for( int logh = 2; logh <= max_pixels_log; logh++ ) - drawlines.append( (int)(logh*drawscale) ); + for( int logh = (int)min_pixels_log; logh <= max_pixels_log; logh++ ) + drawlines.append( (int)(( logh - min_pixels_log ) * drawscale ) + minh ); QList drawvalues; for( int i = 0; @@ -249,7 +253,12 @@ void ShowFpsEffect::paintDrawSizeGraph(int x, int y) ++i ) { int value = paint_size[ ( i + paints_pos ) % NUM_PAINTS ]; - int h = ( !value ) ? 0 : qMin( (int)( log10( value ) * drawscale ), MAX_TIME ); + int h = 0; + if( value > 0) + { + h = (int)(( log10( value ) - min_pixels_log ) * drawscale ); + h = qMin( qMax( 0, h ) + minh, MAX_TIME ); + } drawvalues.append( h ); } paintGraph( x, y, drawvalues, drawlines, false );