82 uint chart = paint2nd ? 1 : 0;
84 TQRect ourClipRect( _dataRect );
85 ourClipRect.setBottom( ourClipRect.bottom() - 1 );
86 ourClipRect.setLeft( ourClipRect.left() + 1 );
87 ourClipRect.setRight( ourClipRect.right() - 1 );
92 const TQWMatrix & world = painter->worldMatrix();
93 ourClipRect = world.mapRect( ourClipRect );
94 painter->setClipRect( ourClipRect );
97 uint datasetStart, datasetEnd;
98 findChartDatasets( data, paint2nd, chart, datasetStart, datasetEnd );
101 painter->translate( _dataRect.x(), _dataRect.y() );
107 if ( params()->numValues() != -1 )
108 numValues = params()->numValues();
113 int size = TQMIN( _dataRect.width(), _dataRect.height() );
115 const double minSizeP1000 = size / 1000.0;
117 int x = ( _dataRect.width() == size ) ? 0 : ( ( _dataRect.width() - size ) / 2 );
118 int y = ( _dataRect.height() == size ) ? 0 : ( ( _dataRect.height() - size ) / 2 );
119 TQRect position( x, y, size, size );
121 TQPoint center( position.width() / 2 + position.x(),
122 position.height() / 2 + position.y() );
126 switch ( params()->polarChartSubType() ) {
127 case KDChartParams::PolarNormal:
128 maxValue = data->maxValue();
130 case KDChartParams::PolarPercent:
134 maxValue = TQMAX( data->maxColSum(), 0.0 );
137 double pixelsPerUnit = 0.0;
140 pixelsPerUnit = (position.height() / maxValue / 2) * 1000 / 1250;
142 TQMap < int, double > currentValueSums;
143 if ( params()->polarChartSubType() == KDChartParams::PolarStacked
144 || params()->polarChartSubType() == KDChartParams::PolarPercent )
148 for (
int value = 0; value < numValues; value++ )
149 currentValueSums[ value ] = 0.0;
150 TQMap < int, double > totalValueSums;
157 const KDChartAxisParams & paraSagittal = params()->axisParams( KDChartAxisParams::AxisPosSagittal );
158 const KDChartAxisParams & paraCircular = params()->axisParams( KDChartAxisParams::AxisPosCircular );
164 ( (
KDChartAxisParams& ) paraSagittal ).setAxisTrueLineWidth( sagittalLineWidth );
165 int sagittalGridLineWidth
178 ( (
KDChartAxisParams& ) paraCircular ).setAxisTrueLineWidth( circularLineWidth );
179 int circularGridLineWidth
190 double currentRadiusPPU = position.height() / 2.0;
197 double radiusPPU = maxValue * pixelsPerUnit;
198 double pDelimDelta = 0.0;
201 TQStringList* labelTexts = 0;
202 ((
KDChartParams*)params())->setAxisArea( KDChartAxisParams::AxisPosCircular,
205 static_cast<int>( radiusPPU ),
206 static_cast<int>( radiusPPU ) ) );
208 double delimLen = 20.0 * minSizeP1000;
209 KDChartAxisParams::AxisPos basicPos;
212 double nSubDelimFactor = 0.0;
213 double nTxtHeight = 0.0;
214 double pTextsX = 0.0;
215 double pTextsY = 0.0;
216 double pTextsW = 0.0;
217 double pTextsH = 0.0;
218 int textAlign = TQt::AlignHCenter | TQt::AlignVCenter;
219 bool isLogarithmic =
false;
220 bool isDateTime =
false;
221 bool autoDtLabels =
false;
224 KDChartAxisParams::ValueScale dtDeltaScale;
229 KDChartAxisParams::AxisPosCircular,
236 dDummy,dDummy,dDummy,dDummy,
251 labelTexts = ( TQStringList* ) paraCircular.axisLabelTexts();
258 actFont.setPointSizeFloat( nTxtHeight );
260 TQFontMetrics fm( actFont );
262 int maxLabelsWidth = 0;
263 for ( TQStringList::Iterator it = labelTexts->begin();
264 it != labelTexts->end();
266 if ( fm.width( *it ) > maxLabelsWidth ) {
267 maxLabelsWidth = fm.width( *it );
271 while ( fm.width( strMax ) > pTextsW
272 && 6.0 < nTxtHeight ) {
274 actFont.setPointSizeFloat( nTxtHeight );
275 fm = TQFontMetrics( actFont );
277 painter->setFont( actFont );
280 double radiusDelta = pDelimDelta;
283 ? labelTexts->count()
286 currentRadiusPPU = -radiusDelta;
287 for(
int iLabel = 0; iLabel < labels; ++iLabel ) {
290 currentRadiusPPU += radiusDelta;
291 double currentRadiusPPU2 = currentRadiusPPU * 2;
292 int circularAxisAngle = ( currentRadiusPPU != 0.0 ) ? (
static_cast < int > (4.0 * radiusPPU / currentRadiusPPU) ) : 0;
295 circularGridLineWidth ) );
296 painter->drawEllipse(
static_cast<int>( center.x() - currentRadiusPPU ),
297 static_cast<int>( center.y() - currentRadiusPPU ),
298 static_cast<int>( currentRadiusPPU2 ),
static_cast<int>( currentRadiusPPU2 ) );
302 circularLineWidth ) );
303 if( params()->polarDelimAtPos( KDChartEnums::PosTopCenter ) )
304 painter->drawArc(
static_cast<int>( center.x() - currentRadiusPPU ),
305 static_cast<int>( center.y() - currentRadiusPPU ),
306 static_cast<int>( currentRadiusPPU2 ),
static_cast<int>( currentRadiusPPU2 ),
307 (90 - circularAxisAngle/2) * 16,
308 circularAxisAngle * 16 );
309 if( params()->polarDelimAtPos( KDChartEnums::PosBottomCenter ) )
310 painter->drawArc(
static_cast<int>( center.x() - currentRadiusPPU ),
311 static_cast<int>( center.y() - currentRadiusPPU ),
312 static_cast<int>( currentRadiusPPU2 ),
static_cast<int>( currentRadiusPPU2 ),
313 (270 - circularAxisAngle/2) * 16,
314 circularAxisAngle * 16 );
316 if( params()->polarDelimAtPos( KDChartEnums::PosCenterRight ) )
317 painter->drawArc(
static_cast<int>( center.x() - currentRadiusPPU ),
318 static_cast<int>( center.y() - currentRadiusPPU ),
319 static_cast<int>( currentRadiusPPU2 ),
static_cast<int>( currentRadiusPPU2 ),
320 (0 - circularAxisAngle/2) * 16,
321 circularAxisAngle * 16 );
322 if( params()->polarDelimAtPos( KDChartEnums::PosCenterLeft ) )
323 painter->drawArc(
static_cast<int>( center.x() - currentRadiusPPU ),
324 static_cast<int>( center.y() - currentRadiusPPU ),
325 static_cast<int>( currentRadiusPPU2 ),
static_cast<int>( currentRadiusPPU2 ),
326 (180 - circularAxisAngle/2) * 16,
327 circularAxisAngle * 16 );
329 if( params()->polarDelimAtPos( KDChartEnums::PosTopRight ) )
330 painter->drawArc(
static_cast<int>( center.x() - currentRadiusPPU ),
331 static_cast<int>( center.y() - currentRadiusPPU ),
332 static_cast<int>( currentRadiusPPU2 ),
static_cast<int>( currentRadiusPPU2 ),
333 (45 - circularAxisAngle/2) * 16,
334 circularAxisAngle * 16 );
335 if( params()->polarDelimAtPos( KDChartEnums::PosBottomLeft ) )
336 painter->drawArc(
static_cast<int>( center.x() - currentRadiusPPU ),
337 static_cast<int>( center.y() - currentRadiusPPU ),
338 static_cast<int>( currentRadiusPPU2 ),
static_cast<int>( currentRadiusPPU2 ),
339 (225 - circularAxisAngle/2) * 16,
340 circularAxisAngle * 16 );
342 if( params()->polarDelimAtPos( KDChartEnums::PosBottomRight ) )
343 painter->drawArc(
static_cast<int>( center.x() - currentRadiusPPU ),
344 static_cast<int>( center.y() - currentRadiusPPU ),
345 static_cast<int>( currentRadiusPPU2 ),
static_cast<int>( currentRadiusPPU2 ),
346 (315 - circularAxisAngle/2) * 16,
347 circularAxisAngle * 16 );
348 if( params()->polarDelimAtPos( KDChartEnums::PosTopLeft ) )
349 painter->drawArc(
static_cast<int>( center.x() - currentRadiusPPU ),
350 static_cast<int>( center.y() - currentRadiusPPU ),
351 static_cast<int>( currentRadiusPPU2 ),
static_cast<int>( currentRadiusPPU2 ),
352 (135 - circularAxisAngle/2) * 16,
353 circularAxisAngle * 16 );
356 const bool rotate = params()->polarRotateCircularLabels();
358 circularLineWidth ) );
359 const TQString& txt = (*labelTexts)[ iLabel ];
360 if( params()->polarLabelsAtPos( KDChartEnums::PosTopCenter ) )
361 paintCircularAxisLabel( painter, rotate, 90, center, currentRadiusPPU, txt,
362 TQt::AlignBottom | TQt::AlignHCenter, iLabel );
364 if( params()->polarLabelsAtPos( KDChartEnums::PosBottomCenter ) )
365 paintCircularAxisLabel( painter, rotate, 270, center, currentRadiusPPU, txt,
366 TQt::AlignTop | TQt::AlignHCenter, iLabel );
368 if( params()->polarLabelsAtPos( KDChartEnums::PosCenterRight ) )
369 paintCircularAxisLabel( painter, rotate, 0, center, currentRadiusPPU, txt,
370 TQt::AlignVCenter | TQt::AlignRight, iLabel );
372 if( params()->polarLabelsAtPos( KDChartEnums::PosCenterLeft ) )
373 paintCircularAxisLabel( painter, rotate, 180, center, currentRadiusPPU, txt,
374 TQt::AlignVCenter | TQt::AlignLeft, iLabel );
376 if( params()->polarLabelsAtPos( KDChartEnums::PosTopRight ) )
377 paintCircularAxisLabel( painter, rotate, 45, center, currentRadiusPPU, txt,
378 TQt::AlignBottom | TQt::AlignRight, iLabel );
380 if( params()->polarLabelsAtPos( KDChartEnums::PosBottomLeft ) )
381 paintCircularAxisLabel( painter, rotate, 225, center, currentRadiusPPU, txt,
382 TQt::AlignTop | TQt::AlignLeft, iLabel );
384 if( params()->polarLabelsAtPos( KDChartEnums::PosBottomRight ) )
385 paintCircularAxisLabel( painter, rotate, 315, center, currentRadiusPPU, txt,
386 TQt::AlignTop | TQt::AlignRight, iLabel );
388 if( params()->polarLabelsAtPos( KDChartEnums::PosTopLeft ) )
389 paintCircularAxisLabel( painter, rotate, 135, center, currentRadiusPPU, txt,
390 TQt::AlignBottom | TQt::AlignLeft, iLabel );
396 double circularSpan = params()->polarChartSubType() == KDChartParams::PolarPercent
399 double radius = currentRadiusPPU;
401 || params()->polarChartSubType() == KDChartParams::PolarPercent )
402 radius = (position.width() / 2.0) * 1000.0 / 1250.0;
404 if( params()->polarChartSubType() != KDChartParams::PolarPercent )
405 pixelsPerUnit = labels ? currentRadiusPPU / circularSpan
406 : (position.height() / maxValue / 2.0) * 1000.0 / 1250.0;
408 pixelsPerUnit = (position.height() / 100.0 / 2.0) * 1000.0 / 1250.0;
416 TQStringList* labelTexts = 0;
417 bool onlyDefaultLabels =
true;
419 ((
KDChartParams*)params())->setAxisArea( KDChartAxisParams::AxisPosSagittal,
422 static_cast < int > ( 2.0 * M_PI * radius ),
423 static_cast < int > ( 0.5 * radius ) ) );
424 double delimLen = 20.0 * minSizeP1000;
425 KDChartAxisParams::AxisPos basicPos;
428 double nSubDelimFactor = 0.0;
429 double pDelimDelta = 0.0;
430 double nTxtHeight = 0.0;
431 double pTextsX = 0.0;
432 double pTextsY = 0.0;
433 double pTextsW = 0.0;
434 double pTextsH = 0.0;
435 int textAlign = TQt::AlignCenter;
436 bool isLogarithmic =
false;
437 bool isDateTime =
false;
438 bool autoDtLabels =
false;
441 KDChartAxisParams::ValueScale dtDeltaScale;
446 KDChartAxisParams::AxisPosSagittal,
453 dDummy,dDummy,dDummy,dDummy,
468 labelTexts = ( TQStringList* ) paraSagittal.axisLabelTexts();
472 actFont.setPointSizeFloat( nTxtHeight );
474 TQFontMetrics fm( actFont );
476 int maxLabelsWidth = 0;
477 for ( TQStringList::Iterator it = labelTexts->begin();
478 it != labelTexts->end();
480 if ( fm.width( *it ) > maxLabelsWidth ) {
481 maxLabelsWidth = fm.width( *it );
484 if ( !(*it).startsWith(
"Item ") )
485 onlyDefaultLabels =
false;
487 while ( fm.width( strMax ) > pTextsW && 6.0 < nTxtHeight ) {
489 actFont.setPointSizeFloat( nTxtHeight );
490 fm = TQFontMetrics( actFont );
492 painter->setFont( actFont );
495 int currentAngle = params()->polarZeroDegreePos();
496 if( -360 > currentAngle
497 || 360 < currentAngle )
499 if( 0 > currentAngle )
501 int r1 =
static_cast < int > ( radius * 1050 / 1000 );
502 int r2 =
static_cast < int > ( radius * 1100 / 1000 );
503 int r3 =
static_cast < int > ( radius * 1175 / 1000 );
504 TQPoint pt1, pt2, pt3;
505 uint nLabels = labelTexts->count();
506 int angleBetweenRays = 360 / nLabels;
507 for( uint value = 0; value < nLabels; ++value ) {
508 pt1 = center + polarToXY( r1, currentAngle );
509 pt2 = center + polarToXY( r2, currentAngle );
510 pt3 = center + polarToXY( r3, currentAngle );
516 sagittalGridLineWidth ) );
517 painter->drawLine( center, pt1 );
521 sagittalLineWidth ) );
522 painter->drawLine( pt1, pt2 );
526 && labelTexts->count() > value ) {
528 sagittalLineWidth ) );
529 TQString label( onlyDefaultLabels
530 ? TQString::number( currentAngle )
531 : (*labelTexts)[ value ] );
533 KDDrawText::drawRotatedText( painter,
535 painter->worldMatrix().map(pt3),
540 currentAngle += angleBetweenRays;
546 int dataLinesWidth = 0 <= params()->polarLineWidth()
547 ? params()->polarLineWidth()
548 : -1 *
static_cast < int > ( params()->polarLineWidth()
550 painter->setBrush( TQt::NoBrush );
551 for (
unsigned int dataset = datasetStart; dataset <= datasetEnd; dataset++ ) {
552 painter->setPen( TQPen( params()->dataColor( dataset ),
554 TQPointArray points( numValues );
556 double valueTotal = 0.0;
557 int angleBetweenRays = 360 / numValues;
559 for (
int value = 0; value < numValues; value++ ) {
560 if( params()->polarChartSubType() == KDChartParams::PolarPercent )
561 valueTotal = data->colAbsSum( value );
563 if( data->
cellCoord( dataset, value, vValY, 1 ) &&
564 TQVariant::Double == vValY.type() ){
565 const double cellValue = vValY.toDouble();
567 if ( params()->polarChartSubType() == KDChartParams::PolarStacked )
568 drawValue = ( cellValue + currentValueSums[ value ] ) * pixelsPerUnit;
569 else if( params()->polarChartSubType() == KDChartParams::PolarPercent ) {
570 drawValue = ( ( cellValue + currentValueSums[ value ] )
571 / valueTotal *
static_cast<double>( radius ) );
573 drawValue = cellValue * pixelsPerUnit;
576 int drawAngle = value * angleBetweenRays;
577 TQPoint drawPoint( center + polarToXY(
static_cast<int>( drawValue ),
579 points.setPoint( totalPoints, drawPoint );
581 KDChartDataRegion* datReg = 0;
583 if( params()->polarMarker() ) {
584 int xsize = params()->polarMarkerSize().width();
585 int ysize = params()->polarMarkerSize().height();
588 _areaWidthP1000, _areaHeightP1000,
589 _dataRect.x(), _dataRect.y(),
590 params()->polarMarkerStyle( dataset ),
591 params()->dataColor( dataset ),
593 dataset, value, chart,
596 ysize ? &ysize : 0 );
597 painter->setPen( TQPen( params()->dataColor( dataset ),
601 bool bMustAppendDatReg = 0 == datReg;
602 if( bMustAppendDatReg ){
603 TQRect rect( TQPoint( drawPoint.x() - 1,
606 datReg =
new KDChartDataRegion( dataset,
611 datReg->points[ KDChartEnums::PosTopLeft ] =
612 drawPoint + _dataRect.topLeft();
614 datReg->points[ KDChartEnums::PosTopCenter ] =
615 datReg->points[ KDChartEnums::PosTopLeft ];
616 datReg->points[ KDChartEnums::PosTopRight ] =
617 datReg->points[ KDChartEnums::PosTopLeft ];
618 datReg->points[ KDChartEnums::PosBottomLeft ] =
619 datReg->points[ KDChartEnums::PosTopLeft ];
620 datReg->points[ KDChartEnums::PosBottomCenter ] =
621 datReg->points[ KDChartEnums::PosTopLeft ];
622 datReg->points[ KDChartEnums::PosBottomRight ] =
623 datReg->points[ KDChartEnums::PosTopLeft ];
624 datReg->points[ KDChartEnums::PosCenterLeft ] =
625 datReg->points[ KDChartEnums::PosTopLeft ];
626 datReg->points[ KDChartEnums::PosCenter ] =
627 datReg->points[ KDChartEnums::PosTopLeft ];
628 datReg->points[ KDChartEnums::PosCenterRight ] =
629 datReg->points[ KDChartEnums::PosTopLeft ];
635 datReg->startAngle = drawAngle;
636 datReg->angleLen = drawAngle;
637 if( bMustAppendDatReg )
638 regions->append( datReg );
641 if ( params()->polarChartSubType() == KDChartParams::PolarStacked ||
642 params()->polarChartSubType() == KDChartParams::PolarPercent )
643 currentValueSums[ value ] += cellValue;
646 painter->drawPolygon( points );
649 painter->translate( -_dataRect.x(), -_dataRect.y() );