3
$Id: KDChartAxesPainter.h,v 1.3.2.1 2001/12/08 12:15:40 khz Exp $
5
KDChart - a multi-platform charting engine
7
Copyright (C) 2001 by Klarļæ½lvdalens Datakonsult AB
2
KDChart - a multi-platform charting engine
5
/****************************************************************************
6
** Copyright (C) 2001-2003 Klarļæ½lvdalens Datakonsult AB. All rights reserved.
8
** This file is part of the KDChart library.
10
** This file may be distributed and/or modified under the terms of the
11
** GNU General Public License version 2 as published by the Free Software
12
** Foundation and appearing in the file LICENSE.GPL included in the
13
** packaging of this file.
15
** Licensees holding valid commercial KDChart licenses may use this file in
16
** accordance with the KDChart Commercial License Agreement provided with
19
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22
** See http://www.klaralvdalens-datakonsult.se/?page=products for
23
** information about KDChart Commercial License Agreements.
25
** Contact info@klaralvdalens-datakonsult.se if any conditions of this
26
** licensing are not clear to you.
28
**********************************************************************/
10
29
#ifndef __KDCHARTAXESPAINTER_H__
11
30
#define __KDCHARTAXESPAINTER_H__
17
36
#include <KDChartTable.h>
18
37
#include <KDChartAxisParams.h>
20
40
class KDChartParams;
22
42
class KDChartAxesPainter : public KDChartPainter
25
KDChartAxesPainter( KDChartParams* params );
26
virtual ~KDChartAxesPainter();
28
virtual void paintAxes( QPainter* painter, KDChartTableData* data );
31
static void saveDrawLine( QPainter& painter,
35
static void calculateLabelTexts( QPainter& painter,
36
const KDChartTableData& data,
37
const KDChartParams& params,
39
double averageValueP1000,
40
KDChartAxisParams::AxisPos basicPos,
43
// start of return parameters
44
double& nSubDelimFactor,
52
static void calculateBasicTextFactors( double nTxtHeight,
53
const KDChartAxisParams& para,
54
double averageValueP1000,
55
KDChartAxisParams::AxisPos basicPos,
59
// start of return parameters
66
static QString trunctateBehindComma( const double nVal,
67
const int behindComma,
69
int& trueBehindComma );
70
static void calculateOrdinateFactors( const KDChartAxisParams& para,
75
double& nSubDelimFactor,
78
bool findNextRound = false );
79
static void findInfos( double averageValueP1000,
80
const KDChartAxisParams& para,
82
KDChartAxisParams::AxisPos& basicPos,
45
KDChartAxesPainter( KDChartParams* params );
46
virtual ~KDChartAxesPainter();
48
virtual void paintAxes( QPainter* painter,
49
KDChartTableDataBase* data );
51
virtual void paintData( QPainter* painter,
52
KDChartTableDataBase* data,
54
KDChartDataRegionList* regions );
56
// note: Classes inheriting from KDChartAxesPainter
57
// MUST implement the following abstract functions:
59
// Returns whether a normal chart is to be drawn
60
// or a stacked or percentage (or ... ) chart .
61
virtual bool isNormalMode() const = 0;
63
// Returns the number of pixels to be added to the clipping area's height
64
// to make room for special arrows indicating oversized, cut data entries.
65
// Chart classes not drawing such indicators must return 0.
66
virtual int clipShiftUp( bool normalMode, double areaWidthP1000 ) const = 0;
68
// The actual, chart type specific drawing of the data.
69
virtual void specificPaintData( QPainter* painter,
70
const QRect& ourClipRect,
71
KDChartTableDataBase* data,
72
KDChartDataRegionList* regions,
73
const KDChartAxisParams* axisPara,
77
double areaWidthP1000,
80
double minColumnValue,
81
double maxColumnValue,
82
double columnValueDistance,
83
uint chartDatasetStart,
86
uint datasetEnd ) = 0;
88
virtual bool calculateAllAxesLabelTextsAndCalcValues(
89
KDChartTableDataBase* data,
90
double areaWidthP1000,
91
double areaHeightP1000,
95
int axisGapX( int axis );
96
int axisGapY( int axis );
98
// special infos needed by the different painters' implementations
99
// of the specificPaintData() function
100
struct abscissaInfos{
101
const KDChartAxisParams* abscissaPara;
102
bool bCenterThePoints;
103
bool bAbscissaIsLogarithmic;
104
bool bCellsHaveSeveralCoordinates;
107
bool bAbscissaHasTrueAxisValues;
108
double abscissaStart;
111
double abscissaDelta;
112
bool bAbscissaHasTrueAxisDtValues;
115
QDateTime abscissaDtStart;
116
QDateTime abscissaDtEnd;
117
bool bScaleLessThanDay;
118
double abscissaDtSpan;
119
double abscissaDtPixelsPerScaleUnit;
121
double abscissaPixelsPerUnit;
122
double abscissaZeroPos;
124
static void calculateAbscissaInfos(
125
const KDChartParams& params,
126
const KDChartTableDataBase& data,
130
const QRect& dataRect,
131
abscissaInfos& infos );
132
static bool calculateAbscissaAxisValue( const KDChartData& cell,
137
static void saveDrawLine( QPainter& painter,
141
static void calculateLabelTexts( const KDChartTableDataBase& data,
142
const KDChartParams& params,
144
double averageValueP1000,
146
// start of return parameters
147
KDChartAxisParams::AxisPos& basicPos,
150
double& pXDeltaFactor,
151
double& pYDeltaFactor,
152
double& pXDelimDeltaFaktor,
153
double& pYDelimDeltaFaktor,
154
double& nSubDelimFactor,
167
KDChartAxisParams::ValueScale& dtDeltaScale,
168
bool adjustTheValues = false,
169
double trueDelta = 0.0,
170
double trueDeltaPix = 0.0 );
171
static void calculateBasicTextFactors( double nTxtHeight,
172
const KDChartAxisParams& para,
173
double averageValueP1000,
174
KDChartAxisParams::AxisPos basicPos,
178
// start of return parameters
185
static QString truncateBehindComma( const double nVal,
186
const int behindComma,
188
int& trueBehindComma );
189
static QString applyLabelsFormat( const double nVal,
193
int& trueBehindComma,
194
const QString& decimalPoint,
195
const QString& thousandsPoint,
196
const QString& prefix,
197
const QString& postfix,
199
const QChar& padFill,
201
static void calculateOrdinateFactors( const KDChartAxisParams& para,
207
double& nSubDelimFactor,
210
bool findNextRound = false );
211
static void dtAddSecs( const QDateTime& org, const int secs, QDateTime& dest );
212
static void dtAddDays( const QDateTime& org, const int days, QDateTime& dest );
213
static void dtAddMonths( const QDateTime& org, const int months, QDateTime& dest );
214
static void dtAddYears( const QDateTime& org, const int years, QDateTime& dest );