diff options
Diffstat (limited to 'libkdchart/KDChartPolarPainter.cpp')
-rw-r--r-- | libkdchart/KDChartPolarPainter.cpp | 178 |
1 files changed, 89 insertions, 89 deletions
diff --git a/libkdchart/KDChartPolarPainter.cpp b/libkdchart/KDChartPolarPainter.cpp index 41009a1..23430db 100644 --- a/libkdchart/KDChartPolarPainter.cpp +++ b/libkdchart/KDChartPolarPainter.cpp @@ -32,7 +32,7 @@ #include "KDChartAxesPainter.h" #include "KDDrawText.h" -#include <qpainter.h> +#include <tqpainter.h> /** \class KDChartPolarPainter KDChartPolarPainter.h @@ -50,7 +50,7 @@ KDChartPolarPainter::KDChartPolarPainter( KDChartParams* params ) : KDChartPainter( params ) { // This constructor intentionally left blank so far; we cannot setup the - // geometry yet since we do not know the size of the painter. + // tqgeometry yet since we do not know the size of the painter. } @@ -68,20 +68,20 @@ KDChartPolarPainter::~KDChartPolarPainter() regions is not 0 and the chart is configured to be drawn with markers. - \param painter the QPainter onto which the chart should be painted + \param painter the TQPainter onto which the chart should be painted \param data the data that will be displayed as a chart \param paint2nd specifies whether the main chart or the additional chart is to be drawn now \param regions a pointer to a list of regions that will be filled with regions representing the data segments, if not null */ -void KDChartPolarPainter::paintData( QPainter* painter, +void KDChartPolarPainter::paintData( TQPainter* painter, KDChartTableDataBase* data, bool paint2nd, KDChartDataRegionList* regions ) { uint chart = paint2nd ? 1 : 0; - QRect ourClipRect( _dataRect ); + TQRect ourClipRect( _dataRect ); ourClipRect.setBottom( ourClipRect.bottom() - 1 ); // protect axes ourClipRect.setLeft( ourClipRect.left() + 1 ); ourClipRect.setRight( ourClipRect.right() - 1 ); @@ -89,9 +89,9 @@ void KDChartPolarPainter::paintData( QPainter* painter, // PENDING(khz) adjust the clip rect if neccessary... // - const QWMatrix & world = painter->worldMatrix(); + const TQWMatrix & world = painter->tqworldMatrix(); ourClipRect = -#if COMPAT_QT_VERSION >= 0x030000 +#if COMPAT_TQT_VERSION >= 0x030000 world.mapRect( ourClipRect ); #else world.map( ourClipRect ); @@ -116,15 +116,15 @@ void KDChartPolarPainter::paintData( QPainter* painter, numValues = data->usedCols(); // compute position - int size = QMIN( _dataRect.width(), _dataRect.height() ); // initial size + int size = TQMIN( _dataRect.width(), _dataRect.height() ); // initial size const double minSizeP1000 = size / 1000.0; int x = ( _dataRect.width() == size ) ? 0 : ( ( _dataRect.width() - size ) / 2 ); int y = ( _dataRect.height() == size ) ? 0 : ( ( _dataRect.height() - size ) / 2 ); - QRect position( x, y, size, size ); + TQRect position( x, y, size, size ); - QPoint center( position.width() / 2 + position.x(), + TQPoint center( position.width() / 2 + position.x(), position.height() / 2 + position.y() ); @@ -137,7 +137,7 @@ void KDChartPolarPainter::paintData( QPainter* painter, maxValue = 100.0; break; default: - maxValue = QMAX( data->maxColSum(), 0.0 ); + maxValue = TQMAX( data->maxColSum(), 0.0 ); } double pixelsPerUnit = 0.0; @@ -145,7 +145,7 @@ void KDChartPolarPainter::paintData( QPainter* painter, // both directions pixelsPerUnit = (position.height() / maxValue / 2) * 1000 / 1250; - QMap < int, double > currentValueSums; + TQMap < int, double > currentValueSums; if ( params()->polarChartSubType() == KDChartParams::PolarStacked || params()->polarChartSubType() == KDChartParams::PolarPercent ) // this array is only used for stacked and percent polar @@ -153,7 +153,7 @@ void KDChartPolarPainter::paintData( QPainter* painter, // ones for ( int value = 0; value < numValues; value++ ) currentValueSums[ value ] = 0.0; - QMap < int, double > totalValueSums; + TQMap < int, double > totalValueSums; /* @@ -191,7 +191,7 @@ void KDChartPolarPainter::paintData( QPainter* painter, : -1 * static_cast < int > ( paraCircular.axisGridLineWidth() * minSizeP1000 ) ); - QFont actFont; + TQFont actFont; int labels = 0; double currentRadiusPPU = position.height() / 2.0; @@ -204,16 +204,16 @@ void KDChartPolarPainter::paintData( QPainter* painter, double pDelimDelta = 0.0; // calculate label texts - QStringList* labelTexts = 0; + TQStringList* labelTexts = 0; ((KDChartParams*)params())->setAxisArea( KDChartAxisParams::AxisPosCircular, - QRect( 0, + TQRect( 0, 0, static_cast<int>( radiusPPU ), static_cast<int>( radiusPPU ) ) ); double delimLen = 20.0 * minSizeP1000; // per mille of area KDChartAxisParams::AxisPos basicPos; - QPoint orig, dest; + TQPoint orig, dest; double dDummy; double nSubDelimFactor = 0.0; double nTxtHeight = 0.0; @@ -221,12 +221,12 @@ void KDChartPolarPainter::paintData( QPainter* painter, double pTextsY = 0.0; double pTextsW = 0.0; double pTextsH = 0.0; - int textAlign = Qt::AlignHCenter | Qt::AlignVCenter; + int textAlign = TQt::AlignHCenter | TQt::AlignVCenter; bool isLogarithmic = false; bool isDateTime = false; bool autoDtLabels = false; - QDateTime dtLow; - QDateTime dtHigh; + TQDateTime dtLow; + TQDateTime dtHigh; KDChartAxisParams::ValueScale dtDeltaScale; KDChartAxesPainter::calculateLabelTexts( painter, @@ -254,19 +254,19 @@ void KDChartPolarPainter::paintData( QPainter* painter, dtLow, dtHigh, dtDeltaScale ); - labelTexts = ( QStringList* ) paraCircular.axisLabelTexts(); + labelTexts = ( TQStringList* ) paraCircular.axisLabelTexts(); if( paraCircular.axisLabelsVisible() ) { -//qDebug("\nnTxtHeight: "+QString::number(nTxtHeight)); +//qDebug("\nnTxtHeight: "+TQString::number(nTxtHeight)); // calculate font size actFont = paraCircular.axisLabelsFont(); if ( paraCircular.axisLabelsFontUseRelSize() ) { //qDebug("paraCircular.axisLabelsFontUseRelSize() is TRUE"); actFont.setPointSizeFloat( nTxtHeight ); } - QFontMetrics fm( actFont ); - QString strMax; + TQFontMetrics fm( actFont ); + TQString strMax; int maxLabelsWidth = 0; - for ( QStringList::Iterator it = labelTexts->begin(); + for ( TQStringList::Iterator it = labelTexts->begin(); it != labelTexts->end(); ++it ) { if ( fm.width( *it ) > maxLabelsWidth ) { @@ -278,7 +278,7 @@ void KDChartPolarPainter::paintData( QPainter* painter, && 6.0 < nTxtHeight ) { nTxtHeight -= 0.5; actFont.setPointSizeFloat( nTxtHeight ); - fm = QFontMetrics( actFont ); + fm = TQFontMetrics( actFont ); } painter->setFont( actFont ); } @@ -297,14 +297,14 @@ void KDChartPolarPainter::paintData( QPainter* painter, double currentRadiusPPU2 = currentRadiusPPU * 2; int circularAxisAngle = ( currentRadiusPPU != 0.0 ) ? ( static_cast < int > (4.0 * radiusPPU / currentRadiusPPU) ) : 0; if( paraCircular.axisShowGrid() ) { - painter->setPen( QPen( paraCircular.axisGridColor(), + painter->setPen( TQPen( paraCircular.axisGridColor(), circularGridLineWidth ) ); painter->drawEllipse( static_cast<int>( center.x() - currentRadiusPPU ), static_cast<int>( center.y() - currentRadiusPPU ), static_cast<int>( currentRadiusPPU2 ), static_cast<int>( currentRadiusPPU2 ) ); } if( paraCircular.axisVisible() ) { - painter->setPen( QPen( paraCircular.axisLineColor(), + painter->setPen( TQPen( paraCircular.axisLineColor(), circularLineWidth ) ); if( params()->polarDelimAtPos( KDChartEnums::PosTopCenter ) ) painter->drawArc( static_cast<int>( center.x() - currentRadiusPPU ), @@ -360,40 +360,40 @@ void KDChartPolarPainter::paintData( QPainter* painter, } if( paraCircular.axisLabelsVisible() ) { const bool rotate = params()->polarRotateCircularLabels(); - painter->setPen( QPen( paraCircular.axisLabelsColor(), + painter->setPen( TQPen( paraCircular.axisLabelsColor(), circularLineWidth ) ); - const QString& txt = (*labelTexts)[ iLabel ]; + const TQString& txt = (*labelTexts)[ iLabel ]; if( params()->polarLabelsAtPos( KDChartEnums::PosTopCenter ) ) paintCircularAxisLabel( painter, rotate, 90, center, currentRadiusPPU, txt, - Qt::AlignBottom | Qt::AlignHCenter, iLabel ); + TQt::AlignBottom | TQt::AlignHCenter, iLabel ); if( params()->polarLabelsAtPos( KDChartEnums::PosBottomCenter ) ) paintCircularAxisLabel( painter, rotate, 270, center, currentRadiusPPU, txt, - Qt::AlignTop | Qt::AlignHCenter, iLabel ); + TQt::AlignTop | TQt::AlignHCenter, iLabel ); if( params()->polarLabelsAtPos( KDChartEnums::PosCenterRight ) ) paintCircularAxisLabel( painter, rotate, 0, center, currentRadiusPPU, txt, - Qt::AlignVCenter | Qt::AlignRight, iLabel ); + TQt::AlignVCenter | TQt::AlignRight, iLabel ); if( params()->polarLabelsAtPos( KDChartEnums::PosCenterLeft ) ) paintCircularAxisLabel( painter, rotate, 180, center, currentRadiusPPU, txt, - Qt::AlignVCenter | Qt::AlignLeft, iLabel ); + TQt::AlignVCenter | TQt::AlignLeft, iLabel ); if( params()->polarLabelsAtPos( KDChartEnums::PosTopRight ) ) paintCircularAxisLabel( painter, rotate, 45, center, currentRadiusPPU, txt, - Qt::AlignBottom | Qt::AlignRight, iLabel ); + TQt::AlignBottom | TQt::AlignRight, iLabel ); if( params()->polarLabelsAtPos( KDChartEnums::PosBottomLeft ) ) paintCircularAxisLabel( painter, rotate, 225, center, currentRadiusPPU, txt, - Qt::AlignTop | Qt::AlignLeft, iLabel ); + TQt::AlignTop | TQt::AlignLeft, iLabel ); if( params()->polarLabelsAtPos( KDChartEnums::PosBottomRight ) ) paintCircularAxisLabel( painter, rotate, 315, center, currentRadiusPPU, txt, - Qt::AlignTop | Qt::AlignRight, iLabel ); + TQt::AlignTop | TQt::AlignRight, iLabel ); if( params()->polarLabelsAtPos( KDChartEnums::PosTopLeft ) ) paintCircularAxisLabel( painter, rotate, 135, center, currentRadiusPPU, txt, - Qt::AlignBottom | Qt::AlignLeft, iLabel ); + TQt::AlignBottom | TQt::AlignLeft, iLabel ); } } } @@ -419,17 +419,17 @@ void KDChartPolarPainter::paintData( QPainter* painter, || paraSagittal.axisLabelsVisible() ) { // calculate label texts - QStringList* labelTexts = 0; + TQStringList* labelTexts = 0; bool onlyDefaultLabels = true; if( paraSagittal.axisLabelsVisible() ) { ((KDChartParams*)params())->setAxisArea( KDChartAxisParams::AxisPosSagittal, - QRect( 0, + TQRect( 0, 0, static_cast < int > ( 2.0 * M_PI * radius ), static_cast < int > ( 0.5 * radius ) ) ); double delimLen = 20.0 * minSizeP1000; // per mille of area KDChartAxisParams::AxisPos basicPos; - QPoint orig, dest; + TQPoint orig, dest; double dDummy; double nSubDelimFactor = 0.0; double pDelimDelta = 0.0; @@ -438,12 +438,12 @@ void KDChartPolarPainter::paintData( QPainter* painter, double pTextsY = 0.0; double pTextsW = 0.0; double pTextsH = 0.0; - int textAlign = Qt::AlignCenter; + int textAlign = TQt::AlignCenter; bool isLogarithmic = false; bool isDateTime = false; bool autoDtLabels = false; - QDateTime dtLow; - QDateTime dtHigh; + TQDateTime dtLow; + TQDateTime dtHigh; KDChartAxisParams::ValueScale dtDeltaScale; KDChartAxesPainter::calculateLabelTexts( painter, @@ -471,16 +471,16 @@ void KDChartPolarPainter::paintData( QPainter* painter, dtLow, dtHigh, dtDeltaScale ); - labelTexts = ( QStringList* ) paraSagittal.axisLabelTexts(); + labelTexts = ( TQStringList* ) paraSagittal.axisLabelTexts(); // calculate font size actFont = paraSagittal.axisLabelsFont(); if ( paraSagittal.axisLabelsFontUseRelSize() ) { actFont.setPointSizeFloat( nTxtHeight ); } - QFontMetrics fm( actFont ); - QString strMax; + TQFontMetrics fm( actFont ); + TQString strMax; int maxLabelsWidth = 0; - for ( QStringList::Iterator it = labelTexts->begin(); + for ( TQStringList::Iterator it = labelTexts->begin(); it != labelTexts->end(); ++it ) { if ( fm.width( *it ) > maxLabelsWidth ) { @@ -493,7 +493,7 @@ void KDChartPolarPainter::paintData( QPainter* painter, while ( fm.width( strMax ) > pTextsW && 6.0 < nTxtHeight ) { nTxtHeight -= 0.5; actFont.setPointSizeFloat( nTxtHeight ); - fm = QFontMetrics( actFont ); + fm = TQFontMetrics( actFont ); } painter->setFont( actFont ); } @@ -507,7 +507,7 @@ void KDChartPolarPainter::paintData( QPainter* painter, int r1 = static_cast < int > ( radius * 1050 / 1000 ); int r2 = static_cast < int > ( radius * 1100 / 1000 ); int r3 = static_cast < int > ( radius * 1175 / 1000 ); - QPoint pt1, pt2, pt3; + TQPoint pt1, pt2, pt3; uint nLabels = labelTexts->count(); int angleBetweenRays = 360 / nLabels; for( uint value = 0; value < nLabels; ++value ) { @@ -515,33 +515,33 @@ void KDChartPolarPainter::paintData( QPainter* painter, pt2 = center + polarToXY( r2, currentAngle ); pt3 = center + polarToXY( r3, currentAngle ); - //pt3 = painter->worldMatrix().map( pt3 ); + //pt3 = painter->tqworldMatrix().map( pt3 ); if( paraSagittal.axisShowGrid() ) { - painter->setPen( QPen( paraSagittal.axisGridColor(), + painter->setPen( TQPen( paraSagittal.axisGridColor(), sagittalGridLineWidth ) ); painter->drawLine( center, pt1 ); } if( paraSagittal.axisVisible() ) { - painter->setPen( QPen( paraSagittal.axisLineColor(), + painter->setPen( TQPen( paraSagittal.axisLineColor(), sagittalLineWidth ) ); painter->drawLine( pt1, pt2 ); } if( paraSagittal.axisLabelsVisible() && labelTexts && labelTexts->count() > value ) { - painter->setPen( QPen( paraSagittal.axisLabelsColor(), + painter->setPen( TQPen( paraSagittal.axisLabelsColor(), sagittalLineWidth ) ); - QString label( onlyDefaultLabels - ? QString::number( currentAngle ) + TQString label( onlyDefaultLabels + ? TQString::number( currentAngle ) : (*labelTexts)[ value ] ); KDDrawText::drawRotatedText( painter, currentAngle+90, - painter->worldMatrix().map(pt3), + painter->tqworldMatrix().map(pt3), label, 0, - Qt::AlignCenter ); + TQt::AlignCenter ); } currentAngle += angleBetweenRays; } @@ -553,21 +553,21 @@ void KDChartPolarPainter::paintData( QPainter* painter, ? params()->polarLineWidth() : -1 * static_cast < int > ( params()->polarLineWidth() * minSizeP1000 ); - painter->setBrush( Qt::NoBrush ); + painter->setBrush( TQt::NoBrush ); for ( unsigned int dataset = datasetStart; dataset <= datasetEnd; dataset++ ) { - painter->setPen( QPen( params()->dataColor( dataset ), + painter->setPen( TQPen( params()->dataColor( dataset ), dataLinesWidth ) ); - QPointArray points( numValues ); + TQPointArray points( numValues ); int totalPoints = 0; double valueTotal = 0.0; // Will only be used for Percent int angleBetweenRays = 360 / numValues; - QVariant vValY; + TQVariant vValY; for ( int value = 0; value < numValues; value++ ) { if( params()->polarChartSubType() == KDChartParams::PolarPercent ) valueTotal = data->colAbsSum( value ); // the value determines the angle, the dataset only the color if( data->cellCoord( dataset, value, vValY, 1 ) && - QVariant::Double == vValY.type() ){ + TQVariant::Double == vValY.type() ){ const double cellValue = vValY.toDouble(); double drawValue; if ( params()->polarChartSubType() == KDChartParams::PolarStacked ) @@ -580,7 +580,7 @@ void KDChartPolarPainter::paintData( QPainter* painter, // record the point for drawing the polygon later int drawAngle = value * angleBetweenRays; - QPoint drawPoint( center + polarToXY( static_cast<int>( drawValue ), + TQPoint drawPoint( center + polarToXY( static_cast<int>( drawValue ), drawAngle ) ); points.setPoint( totalPoints, drawPoint ); totalPoints++; @@ -600,15 +600,15 @@ void KDChartPolarPainter::paintData( QPainter* painter, regions, xsize ? &xsize : 0, ysize ? &ysize : 0 ); - painter->setPen( QPen( params()->dataColor( dataset ), + painter->setPen( TQPen( params()->dataColor( dataset ), dataLinesWidth ) ); } if ( regions ) { bool bMustAppendDatReg = 0 == datReg; if( bMustAppendDatReg ){ - QRect rect( QPoint( drawPoint.x() - 1, + TQRect rect( TQPoint( drawPoint.x() - 1, drawPoint.y() - 1 ), - QSize( 3, 3 ) ); + TQSize( 3, 3 ) ); datReg = new KDChartDataRegion( dataset, value, chart, @@ -659,26 +659,26 @@ void KDChartPolarPainter::paintData( QPainter* painter, /* Helper methode being called by KDChartPolarPainter::paintData() */ -void KDChartPolarPainter::paintCircularAxisLabel( QPainter* painter, +void KDChartPolarPainter::paintCircularAxisLabel( TQPainter* painter, bool rotate, int txtAngle, - QPoint center, + TQPoint center, double currentRadiusPPU, - const QString& txt, + const TQString& txt, int align, int step ) { - if( !rotate && (0 != (align & (Qt::AlignLeft | Qt::AlignRight) ) ) ) + if( !rotate && (0 != (align & (TQt::AlignLeft | TQt::AlignRight) ) ) ) currentRadiusPPU += center.x()*0.01; KDDrawText::drawRotatedText( painter, rotate ? txtAngle - 90 : 0, - painter->worldMatrix().map(center - polarToXY( static_cast<int>( currentRadiusPPU ), txtAngle )), + painter->tqworldMatrix().map(center - polarToXY( static_cast<int>( currentRadiusPPU ), txtAngle )), txt, 0, step - ? (rotate ? Qt::AlignBottom | Qt::AlignHCenter : align) - : Qt::AlignCenter, + ? (rotate ? TQt::AlignBottom | TQt::AlignHCenter : align) + : TQt::AlignCenter, false,0,false, false ); } @@ -696,15 +696,15 @@ void KDChartPolarPainter::paintCircularAxisLabel( QPainter* painter, \param regions a list of regions for data points, a new region for the new marker will be appended to this list if it is not 0 *//* -void KDChartPolarPainter::drawMarker( QPainter* painter, +void KDChartPolarPainter::drawMarker( TQPainter* painter, KDChartParams::PolarMarkerStyle style, - const QColor& color, - const QPoint& p, + const TQColor& color, + const TQPoint& p, uint, //dataset, uint, //value, uint, //chart, double minSizeP1000, - QRegion& region ) + TQRegion& region ) { int xsize = params()->polarMarkerSize().width(); if ( 0 > xsize ) @@ -719,18 +719,18 @@ void KDChartPolarPainter::drawMarker( QPainter* painter, case KDChartParams::PolarMarkerSquare: { painter->save(); painter->setBrush( color ); - QRect rect( QPoint( p.x() - xsize2, p.y() - ysize2 ), QPoint( p.x() + xsize2, p.y() + ysize2 ) ); + TQRect rect( TQPoint( p.x() - xsize2, p.y() - ysize2 ), TQPoint( p.x() + xsize2, p.y() + ysize2 ) ); painter->drawRect( rect ); // Don't use rect for drawing after this! rect.moveBy( _dataRect.x(), _dataRect.y() ); - region = QRegion( rect ); + region = TQRegion( rect ); painter->restore(); break; } case KDChartParams::PolarMarkerDiamond: { painter->save(); painter->setBrush( color ); - QPointArray points( 4 ); + TQPointArray points( 4 ); points.setPoint( 0, p.x() - xsize2, p.y() ); points.setPoint( 1, p.x(), p.y() - ysize2 ); points.setPoint( 2, p.x() + xsize2, p.y() ); @@ -738,7 +738,7 @@ void KDChartPolarPainter::drawMarker( QPainter* painter, painter->drawPolygon( points ); // Don't use points for drawing after this! points.translate( _dataRect.x(), _dataRect.y() ); - region = QRegion( points ); + region = TQRegion( points ); painter->restore(); break; } @@ -747,14 +747,14 @@ void KDChartPolarPainter::drawMarker( QPainter* painter, painter->save(); painter->setBrush( color ); painter->drawEllipse( p.x() - xsize2, p.y() - ysize2, xsize, ysize ); - QPointArray points; + TQPointArray points; points.makeEllipse( p.x() - xsize2, p.y() - ysize2, xsize, ysize ); // Don't use points for drawing after this! points.translate( _dataRect.x(), _dataRect.y() ); if( points.size() > 0 ) - region = QRegion( points ); + region = TQRegion( points ); else - region = QRegion(); + region = TQRegion(); painter->restore(); } }; @@ -762,10 +762,10 @@ void KDChartPolarPainter::drawMarker( QPainter* painter, #define DEGTORAD(d) (d)*M_PI/180 -QPoint KDChartPolarPainter::polarToXY( int radius, int angle ) +TQPoint KDChartPolarPainter::polarToXY( int radius, int angle ) { double anglerad = DEGTORAD( static_cast<double>( angle ) ); - QPoint ret( static_cast<int>( cos( anglerad ) * radius ), + TQPoint ret( static_cast<int>( cos( anglerad ) * radius ), static_cast<int>( sin( anglerad ) * radius ) ); return ret; } @@ -784,9 +784,9 @@ QPoint KDChartPolarPainter::polarToXY( int radius, int angle ) \return the fallback text to use for describing the specified dataset in the legend */ -QString KDChartPolarPainter::fallbackLegendText( uint dataset ) const +TQString KDChartPolarPainter::fallbackLegendText( uint dataset ) const { - return QObject::tr( "Series " ) + QString::number( dataset + 1 ); + return TQObject::tr( "Series " ) + TQString::number( dataset + 1 ); } |