00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef __KDCHARTAXESPAINTER_H__
00030 #define __KDCHARTAXESPAINTER_H__
00031
00032 #include <qpen.h>
00033 #include <qpainter.h>
00034
00035 #include <KDChartPainter.h>
00036 #include <KDChartTable.h>
00037 #include <KDChartAxisParams.h>
00038
00039 class QDateTime;
00040 class KDChartParams;
00041
00042 class KDChartAxesPainter : public KDChartPainter
00043 {
00044 protected:
00045 KDChartAxesPainter( KDChartParams* params );
00046 virtual ~KDChartAxesPainter();
00047
00048 virtual void paintAxes( QPainter* painter,
00049 KDChartTableDataBase* data );
00050
00051 virtual void paintData( QPainter* painter,
00052 KDChartTableDataBase* data,
00053 bool paint2nd,
00054 KDChartDataRegionList* regions );
00055
00056
00057
00058
00059
00060
00061 virtual bool isNormalMode() const = 0;
00062
00063
00064
00065
00066 virtual int clipShiftUp( bool normalMode, double areaWidthP1000 ) const = 0;
00067
00068
00069 virtual void specificPaintData( QPainter* painter,
00070 const QRect& ourClipRect,
00071 KDChartTableDataBase* data,
00072 KDChartDataRegionList* regions,
00073 const KDChartAxisParams* axisPara,
00074 bool bNormalMode,
00075 uint chart,
00076 double logWidth,
00077 double areaWidthP1000,
00078 double logHeight,
00079 double axisYOffset,
00080 double minColumnValue,
00081 double maxColumnValue,
00082 double columnValueDistance,
00083 uint chartDatasetStart,
00084 uint chartDatasetEnd,
00085 uint datasetStart,
00086 uint datasetEnd ) = 0;
00087
00088 virtual bool calculateAllAxesLabelTextsAndCalcValues(
00089 QPainter* painter,
00090 KDChartTableDataBase* data,
00091 double areaWidthP1000,
00092 double areaHeightP1000,
00093 double& delimLen );
00094
00095 private:
00096 public:
00097
00098
00099 struct abscissaInfos{
00100 const KDChartAxisParams* abscissaPara;
00101 bool bCenterThePoints;
00102 bool bAbscissaDecreasing;
00103 bool bAbscissaIsLogarithmic;
00104 bool bCellsHaveSeveralCoordinates;
00105 int numValues;
00106 int numLabels;
00107 bool bAbscissaHasTrueAxisValues;
00108 double abscissaStart;
00109 double abscissaEnd;
00110 double abscissaSpan;
00111 double abscissaDelta;
00112 bool bAbscissaHasTrueAxisDtValues;
00113 double dtLowPos;
00114 double dtHighPos;
00115 QDateTime abscissaDtStart;
00116 QDateTime abscissaDtEnd;
00117 bool bScaleLessThanDay;
00118 double abscissaDtSpan;
00119 double abscissaDtPixelsPerScaleUnit;
00120 double pointDist;
00121 double abscissaPixelsPerUnit;
00122 double abscissaZeroPos;
00123 };
00124 static void calculateAbscissaInfos(
00125 const KDChartParams& params,
00126 const KDChartTableDataBase& data,
00127 uint datasetStart,
00128 uint datasetEnd,
00129 double logWidth,
00130 const QRect& dataRect,
00131 abscissaInfos& infos );
00132 static bool calculateAbscissaAxisValue( const QVariant& value,
00133 abscissaInfos& ai,
00134 int colNumber,
00135 double& xValue );
00136
00137 static void saveDrawLine( QPainter& painter,
00138 QPoint pA,
00139 QPoint pZ,
00140 QPen pen );
00141 static void calculateLabelTexts(
00142 QPainter* painter,
00143 const KDChartTableDataBase& data,
00144 const KDChartParams& params,
00145 uint axisNumber,
00146 double averageValueP1000,
00147 double delimLen,
00148
00149 KDChartAxisParams::AxisPos& basicPos,
00150 QPoint& orig,
00151 QPoint& dest,
00152 double& pXDeltaFactor,
00153 double& pYDeltaFactor,
00154 double& pXDelimDeltaFaktor,
00155 double& pYDelimDeltaFaktor,
00156 double& nSubDelimFactor,
00157 double& pDelimDelta,
00158 double& nTxtHeight,
00159 double& pTextsX,
00160 double& pTextsY,
00161 double& pTextsW,
00162 double& pTextsH,
00163 int& textAlign,
00164 bool& isLogarithmic,
00165 bool& isDateTime,
00166 bool& autoDtLabels,
00167 QDateTime& dtLow,
00168 QDateTime& dtHigh,
00169 KDChartAxisParams::ValueScale& dtDeltaScale,
00170 bool adjustTheValues = false,
00171 double trueDelta = 0.0,
00172 double trueDeltaPix = 0.0 );
00173 static void calculateBasicTextFactors( double nTxtHeight,
00174 const KDChartAxisParams& para,
00175 double averageValueP1000,
00176 KDChartAxisParams::AxisPos basicPos,
00177 const QPoint& orig,
00178 double delimLen,
00179 uint nLabels,
00180
00181 double& pDelimDelta,
00182 double& pTextsX,
00183 double& pTextsY,
00184 double& pTextsW,
00185 double& pTextsH,
00186 int& textAlign );
00187 static QString truncateBehindComma( const double nVal,
00188 const int behindComma,
00189 const double nDelta,
00190 int& trueBehindComma );
00191 static QString applyLabelsFormat( const double nVal,
00192 int divPow10,
00193 int behindComma,
00194 double nDelta,
00195 int& trueBehindComma,
00196 const QString& decimalPoint,
00197 const QString& thousandsPoint,
00198 const QString& prefix,
00199 const QString& postfix,
00200 int totalLen,
00201 const QChar& padFill,
00202 bool blockAlign );
00203 static void calculateOrdinateFactors( const KDChartAxisParams& para,
00204 bool bLogarithmic,
00205 double& nDist,
00206 double& nDivisor,
00207 double& nRound,
00208 double& nDelta,
00209 double& nSubDelimFactor,
00210 double& nLow,
00211 double& nHigh,
00212 bool findNextRound = false );
00213 static void dtAddSecs( const QDateTime& org, const int secs, QDateTime& dest );
00214 static void dtAddDays( const QDateTime& org, const int days, QDateTime& dest );
00215 static void dtAddMonths( const QDateTime& org, const int months, QDateTime& dest );
00216 static void dtAddYears( const QDateTime& org, const int years, QDateTime& dest );
00217 };
00218
00219 #endif