KDChartCartesianAxis.cpp File Reference

#include "KDChartCartesianAxis.h"
#include "KDChartCartesianAxis_p.h"
#include <cmath>
#include <QtDebug>
#include <QPainter>
#include <QPen>
#include <QBrush>
#include <QApplication>
#include "KDChartPaintContext.h"
#include "KDChartChart.h"
#include "KDChartAbstractCartesianDiagram.h"
#include "KDChartAbstractGrid.h"
#include "KDChartPainterSaver_p.h"
#include "KDChartLayoutItems.h"
#include "KDChartBarDiagram.h"
#include "KDChartStockDiagram.h"
#include "KDChartLineDiagram.h"
#include "KDChartPrintingParameters.h"
#include <KDABLibFakes>
#include <limits>

Include dependency graph for KDChartCartesianAxis.cpp:

Go to the source code of this file.

Defines

#define d   (d_func())

Functions

static void calculateNextLabel (qreal &labelValue, qreal step, bool isLogarithmic, qreal min)
static void calculateOverlap (int i, int first, int last, int measure, bool centerAbscissaTicks, int &firstOverlap, int &lastOverlap)
static bool referenceDiagramIsBarDiagram (const AbstractDiagram *diagram)
static bool referenceDiagramNeedsCenteredAbscissaTicks (const AbstractDiagram *diagram)


Define Documentation

#define d   (d_func())

Definition at line 54 of file KDChartCartesianAxis.cpp.


Function Documentation

static void calculateNextLabel ( qreal &  labelValue,
qreal  step,
bool  isLogarithmic,
qreal  min 
) [static]

Definition at line 433 of file KDChartCartesianAxis.cpp.

Referenced by KDChart::CartesianAxis::paintCtx().

00434 {
00435     if ( isLogarithmic ){
00436         if( step > 0.0 )
00437             labelValue *= 10.0;
00438         else
00439             labelValue /= 10.0;
00440         if( labelValue == 0.0 )
00441             labelValue = pow( 10.0, floor( log10( min ) ) );
00442     }else{
00443         //qDebug() << "new axis label:" << labelValue << "+" << step << "=" << labelValue+step;
00444         labelValue += step;
00445         if( qAbs(labelValue) < 1.0e-15 )
00446             labelValue = 0.0;
00447     }
00448 }

static void calculateOverlap ( int  i,
int  first,
int  last,
int  measure,
bool  centerAbscissaTicks,
int &  firstOverlap,
int &  lastOverlap 
) [static]

Definition at line 1421 of file KDChartCartesianAxis.cpp.

01425 {
01426     if( i == first ){
01427         if( centerAbscissaTicks ){
01428             //TODO(khz): Calculate the amount of left overlap
01429             //           for bar diagrams.
01430         }else{
01431             firstOverlap = measure / 2;
01432         }
01433     }
01434     // we test both bounds in on go: first and last might be equal
01435     if( i == last ){
01436         if( centerAbscissaTicks ){
01437             //TODO(khz): Calculate the amount of right overlap
01438             //           for bar diagrams.
01439         }else{
01440             lastOverlap = measure / 2;
01441         }
01442     }
01443 }

static bool referenceDiagramIsBarDiagram ( const AbstractDiagram diagram  )  [static]

Definition at line 192 of file KDChartCartesianAxis.cpp.

References KDChart::AbstractCartesianDiagram::referenceDiagram().

Referenced by KDChart::CartesianAxis::isAbscissa(), and KDChart::CartesianAxis::isOrdinate().

00193 {
00194     const AbstractCartesianDiagram * dia =
00195             qobject_cast< const AbstractCartesianDiagram * >( diagram );
00196     if( dia && dia->referenceDiagram() )
00197         dia = dia->referenceDiagram();
00198     return qobject_cast< const BarDiagram* >( dia ) != 0;
00199 }

static bool referenceDiagramNeedsCenteredAbscissaTicks ( const AbstractDiagram diagram  )  [static]

Definition at line 201 of file KDChartCartesianAxis.cpp.

References KDChart::LineDiagram::centerDataPoints(), and KDChart::AbstractCartesianDiagram::referenceDiagram().

Referenced by KDChart::CartesianAxis::paintCtx().

00202 {
00203     const AbstractCartesianDiagram * dia =
00204             qobject_cast< const AbstractCartesianDiagram * >( diagram );
00205     if( dia && dia->referenceDiagram() )
00206         dia = dia->referenceDiagram();
00207     if ( qobject_cast< const BarDiagram* >( dia ) )
00208         return true;
00209     if ( qobject_cast< const StockDiagram* >( dia ) )
00210         return true;
00211 
00212     const LineDiagram * lineDiagram = qobject_cast< const LineDiagram* >( dia );
00213     return lineDiagram && lineDiagram->centerDataPoints();
00214 }


Generated on Thu Mar 4 23:20:26 2010 for KD Chart 2 by  doxygen 1.5.4