30#if defined ( SUN7 ) || defined (_SGIAPI) || defined ( TQ_WS_WIN)
37#include <KDDrawText.h>
38#include <KDChartPainter.h>
43#include <KDChartDataRegion.h>
44#include <KDChartUnknownTypeException.h>
45#include <KDChartNotEnoughSpaceException.h>
46#include <KDChartBarPainter.h>
47#include <KDChartAreaPainter.h>
48#include <KDChartLinesPainter.h>
49#include <KDChartPiePainter.h>
50#include <KDChartPolarPainter.h>
51#include <KDChartRingPainter.h>
52#include <KDChartHiLoPainter.h>
53#include <KDChartBWPainter.h>
54#include <KDChartTextPiece.h>
59#include <tqpaintdevice.h>
60#include <tqpaintdevicemetrics.h>
62#define DEGTORAD(d) (d)*M_PI/180
97_outermostRect( TQRect(TQPoint(0,0), TQSize(0,0))),
100_legendNewLinesStartAtLeft( true ),
101_legendTitleHeight( 0 ),
102_legendTitleWidth( 0 ),
103_legendTitleMetricsHeight( 0 )
118bool KDChartPainter::calculateAllAxesLabelTextsAndCalcValues(
148 ? params->additionalChartType()
149 : params->chartType();
152 case KDChartParams::Bar:
154 case KDChartParams::Line:
156 case KDChartParams::Area:
158 case KDChartParams::Pie:
160 case KDChartParams::Ring:
162 case KDChartParams::HiLo:
164 case KDChartParams::BoxWhisker:
166 case KDChartParams::Polar:
168 case KDChartParams::NoType:
195 tqDebug( "Sorry, not implemented: KDChartPainter::registerPainter()" );
211 tqDebug( "Sorry, not implemented: KDChartPainter::unregisterPainter()" );
233 bool mustCalculateGeometry )
237 if( paintFirst && regions )
246 if( mustCalculateGeometry || _outermostRect.isNull() ){
250 tqDebug( "ERROR: KDChartPainter::paint() could not calculate the drawing area.");
256 drawRect = _outermostRect;
267 paintArea( painter, KDChartEnums::AreaOutermost );
268 paintArea( painter, KDChartEnums::AreaInnermost );
270 paintArea( painter, KDChartEnums::AreaDataAxesLegendHeadersFooters );
272 paintArea( painter, KDChartEnums::AreaHeaders );
273 paintArea( painter, KDChartEnums::AreaFooters );
278 paintArea( painter, KDChartEnums::AreaHdFtBASE + KDChartParams::HdFtPosHeader );
279 paintArea( painter, KDChartEnums::AreaHdFtBASE + KDChartParams::HdFtPosHeaderL );
280 paintArea( painter, KDChartEnums::AreaHdFtBASE + KDChartParams::HdFtPosHeaderR );
281 paintArea( painter, KDChartEnums::AreaHdFtBASE + KDChartParams::HdFtPosHeader0 );
282 paintArea( painter, KDChartEnums::AreaHdFtBASE + KDChartParams::HdFtPosHeader0L );
283 paintArea( painter, KDChartEnums::AreaHdFtBASE + KDChartParams::HdFtPosHeader0R );
284 paintArea( painter, KDChartEnums::AreaHdFtBASE + KDChartParams::HdFtPosHeader2 );
285 paintArea( painter, KDChartEnums::AreaHdFtBASE + KDChartParams::HdFtPosHeader2L );
286 paintArea( painter, KDChartEnums::AreaHdFtBASE + KDChartParams::HdFtPosHeader2R );
288 paintArea( painter, KDChartEnums::AreaHdFtBASE + KDChartParams::HdFtPosFooter );
289 paintArea( painter, KDChartEnums::AreaHdFtBASE + KDChartParams::HdFtPosFooterL );
290 paintArea( painter, KDChartEnums::AreaHdFtBASE + KDChartParams::HdFtPosFooterR );
291 paintArea( painter, KDChartEnums::AreaHdFtBASE + KDChartParams::HdFtPosFooter0 );
292 paintArea( painter, KDChartEnums::AreaHdFtBASE + KDChartParams::HdFtPosFooter0L );
293 paintArea( painter, KDChartEnums::AreaHdFtBASE + KDChartParams::HdFtPosFooter0R );
294 paintArea( painter, KDChartEnums::AreaHdFtBASE + KDChartParams::HdFtPosFooter2 );
295 paintArea( painter, KDChartEnums::AreaHdFtBASE + KDChartParams::HdFtPosFooter2L );
296 paintArea( painter, KDChartEnums::AreaHdFtBASE + KDChartParams::HdFtPosFooter2R );
300 paintArea( painter, KDChartEnums::AreaDataAxesLegend );
301 paintArea( painter, KDChartEnums::AreaDataAxes );
302 paintArea( painter, KDChartEnums::AreaAxes );
303 for( int axis = KDChartAxisParams::AxisPosSTART;
304 KDChartAxisParams::AxisPosEND >= axis; ++axis )
305 paintArea( painter, KDChartEnums::AreaAxisBASE + axis );
306 paintArea( painter, KDChartEnums::AreaData );
311 paintData( painter, data, !paintFirst, regions );
317 paintDataRegionAreas( painter, regions );
318 if( KDChartParams::Bar != params()->chartType() ||
319 KDChartParams::BarMultiRows != params()->barChartSubType() )
321 if (params()->legendPosition()!=KDChartParams::NoLegend)
322 paintArea( painter, KDChartEnums::AreaLegend );
339 if( KDChartEnums::AreaCustomBoxesBASE != (KDChartEnums::AreaBASEMask & area) ){
342 params()->frameSettings( area, bFound );
347 dataRow, dataCol, data3rd, regions ) );
349 if( !allCustomBoxes )
356void KDChartPainter::paintDataRegionAreas( TQPainter* painter,
363 params()-> frameSettings( KDChartEnums::AreaChartDataRegion, bFound, &iterIdx );
367 KDChartEnums::AreaChartDataRegion,
383 KDFrame::PaintBorder,
384 trueFrameRect( rect, settings ) );
391TQRect KDChartPainter::trueFrameRect( const TQRect& orgRect,
394 TQRect rect( orgRect );
397 rect.setWidth( rect.width() + 2*settings-> innerGapX() );
398 rect.setHeight( rect.height() + 2*settings-> innerGapY() );
414 if( painter && rect.isValid() )
417 trueFrameRect( rect, &settings ) );
428 KDChartDataRegion* region;
434 && ( params()->printDataValues( 0 )
435 || params()->printDataValues( 1 ) ) ) {
440 TQFont font0( params()->dataValuesFont( 0 ) );
442 if( params()->dataValuesUseFontRelSize( 0 ) ) {
443 float size = TQMIN(_areaWidthP1000, _areaHeightP1000) * abs(params()->dataValuesFontRelSize( 0 ));
446 font0.setPixelSize( static_cast < int > ( size ) );
448 painter->setFont( font0 );
449 TQFontMetrics fm0( painter->fontMetrics() );
450 double fm0HeightP100( fm0.height() / 100.0 );
451 TQFont font1( params()->dataValuesFont( 1 ) );
453 if( params()->dataValuesUseFontRelSize( 1 ) ) {
454 float size = TQMIN(_areaWidthP1000, _areaHeightP1000) * abs(params()->dataValuesFontRelSize( 1 ));
457 font1.setPixelSize( static_cast < int > ( size ) );
459 font1.setPixelSize( font0.pixelSize());
460 painter->setFont( font1 );
461 TQFontMetrics fm1( painter->fontMetrics() );
462 double fm1HeightP100( fm1.height() / 100.0 );
464 bool lastDigitIrrelevant0 = true;
465 bool lastDigitIrrelevant1 = true;
467 for ( region=regions->first();
469 region = regions->next() ) {
471 if( data-> cellCoord( region->row, region->col, vValY, 1 ) ){
472 if( TQVariant::String == vValY.type() ){
473 const TQString sVal( vValY.toString() );
474 if( !sVal.isEmpty() )
476 } else if( TQVariant::Double == vValY.type() ){
477 double value( vValY.toDouble() );
478 region->negative = 0.0 > value;
479 double divi( pow( 10.0, params()->dataValuesDivPow10( region->chart ) ) );
482 int digits( params()->dataValuesDigitsBehindComma( region->chart ) );
483 bool autoDigits( KDCHART_DATA_VALUE_AUTO_DIGITS == digits );
489 ? lastDigitIrrelevant1
490 : lastDigitIrrelevant0 ) = false;
492 region->text = "-LEMNISKATE";
494 region->text = "+LEMNISKATE";
496 region->text.setNum( value, 'f', digits );
497 if ( autoDigits && region->text.contains( '.' ) ) {
498 int len = region->text.length();
500 && '0' == region->text[ len-1 ]
501 && '.' != region->text[ len-2 ] ) {
503 region->text.truncate( len );
505 if( '0' != region->text[ len-1 ] )
507 ? lastDigitIrrelevant1
508 : lastDigitIrrelevant0 ) = false;
515 if ( lastDigitIrrelevant0 || lastDigitIrrelevant1 )
516 for ( region=regions->first();
518 region = regions->next() )
519 if ( ( ( lastDigitIrrelevant0 && !region->chart )
520 || ( lastDigitIrrelevant1 && region->chart ) )
521 && region->text.contains( '.' )
522 && ( 2 < region->text.length() ) )
523 region->text.truncate ( region->text.length() - 2 );
527 painter->setPen( TQt::black );
529 bool allowOverlapping = params()->allowOverlappingDataValueTexts();
531 TQRegion lastRegionDone;
533 TQFontMetrics actFM( painter->fontMetrics() );
537 uint oldChart = UINT_MAX;
538 uint oldDatacolorNo = UINT_MAX;
539 for ( region=regions->first();
541 region = regions->next() ) {
546 if ( region->text.length() ) {
550 data-> cellCoord( region->row, region->col, vValY, 1 ) &&
551 TQVariant::Double == vValY.type() &&
552 ( 0.0 == vValY.toDouble() || 0 == vValY.toDouble() );
553 uint align( params()->dataValuesAnchorAlign( region->chart,
554 region->negative ) );
556 ? params()->additionalChartType()
557 : params()->chartType();
561 bool bIsAreaChart = KDChartParams::Area == cType;
562 bool rectangular = ( KDChartParams::Bar == cType
563 || KDChartParams::Line == cType
565 || KDChartParams::HiLo == cType
566 || KDChartParams::BoxWhisker == cType );
569 bool circular = ( KDChartParams::Pie == cType
570 || KDChartParams::Ring == cType
571 || KDChartParams::Polar == cType );
575 params()->dataValuesAnchorPosition( region->chart, region->negative ) );
582 double & fmHeightP100 = region->chart ? fm1HeightP100 : fm0HeightP100;
584 int angle = region->startAngle;
585 switch ( anchorPos ) {
586 case KDChartEnums::PosTopLeft:
587 case KDChartEnums::PosCenterLeft:
588 case KDChartEnums::PosBottomLeft:
589 angle += region->angleLen;
591 case KDChartEnums::PosTopCenter:
592 case KDChartEnums::PosCenter:
593 case KDChartEnums::PosBottomCenter:
594 angle += region->angleLen / 2;
606 double anchorDX( params()->dataValuesAnchorDeltaX( region->chart, region->negative )
608 double anchorDY( params()->dataValuesAnchorDeltaY( region->chart, region->negative )
611 if ( 0.0 != anchorDY ) {
612 double normAngle = angle / 16;
613 double normAngleRad = DEGTORAD( normAngle );
614 double sinAngle = sin( normAngleRad );
615 TQPoint pM = TQPoint(region->points[ KDChartEnums::PosCenter ]);
616 double dX( pM.x() - anchor.x() );
617 double dY( pM.y() - anchor.y() );
618 double radialLen( sinAngle ? dY / sinAngle : dY );
619 double radialFactor( ( radialLen == 0.0 ) ? 0.0 : ( ( radialLen - anchorDY ) / radialLen ) );
620 anchor.setX( static_cast < int > ( pM.x() - dX * radialFactor ) );
621 anchor.setY( static_cast < int > ( pM.y() - dY * radialFactor ) );
624 anchor.setX( anchor.x() + static_cast < int > ( anchorDX ) );
625 anchor.setY( anchor.y() + static_cast < int > ( anchorDY ) );
629 if(anchor.x() < -250){
633 if(anchor.y() < -2500){
638 int rotation( params()->dataValuesRotation( region->chart,
639 region->negative ) );
640 bool incRotationBy90 = false;
641 if( region->text == "-LEMNISKATE" ||
642 region->text == "+LEMNISKATE" ){
643 if( params()->dataValuesShowInfinite( region->chart ) ){
645 if( region->text == "-LEMNISKATE" )
646 align = TQt::AlignRight + TQt::AlignVCenter;
648 align = TQt::AlignLeft + TQt::AlignVCenter;
652 incRotationBy90 = true;
653 region->text = " 8 ";
660 anchor = painter->worldMatrix().map( anchor );
667 if ( KDCHART_SAGGITAL_ROTATION == rotation
668 || KDCHART_TANGENTIAL_ROTATION == rotation ) {
669 rotation = ( KDCHART_TANGENTIAL_ROTATION == rotation
674 if( incRotationBy90 )
676 if ( 360 <= rotation )
678 else if ( 0 > rotation )
680 rotation = 360 - rotation;
681 } else if( incRotationBy90 )
682 rotation = (rotation + 90) % 360;
685 if( rotation != oldRotation ) {
686 painter->rotate( rotation - oldRotation );
691 TQFont* actFont = region->chart ? &font1 : &font0;
692 if( oldFont != actFont ) {
693 painter->setFont( *actFont );
694 actFM = TQFontMetrics( painter->fontMetrics() );
699 KDDrawTextRegionAndTrueRect infosKDD =
700 KDDrawText::measureRotatedText( painter,
712 if( allowOverlapping ) {
715 TQRegion sectReg( infosKDD.region.intersect( lastRegionDone ) );
716 drawThisOne = sectReg.isEmpty();
719 lastRegionDone = lastRegionDone.unite( infosKDD.region );
720 region->pTextRegion = new TQRegion( infosKDD.region );
722 if( params()->dataValuesAutoColor( region->chart ) ) {
724 TQColor color( params()->dataColor( region->row ) );
734 painter->setPen( color.dark() );
737 if( oldDatacolorNo != UINT_MAX ) {
738 painter->setPen( TQt::black );
739 oldDatacolorNo = UINT_MAX;
743 uint datacolorNo = ( KDChartParams::Pie == cType
744 || KDChartParams::Ring == cType )
747 if( oldDatacolorNo != datacolorNo ) {
748 oldDatacolorNo = datacolorNo;
749 TQColor color( params()->dataColor( datacolorNo ) );
750 painter->setPen( TQColor(
751 static_cast < int > (255-color.red() ),
752 static_cast < int > (255-color.green()),
753 static_cast < int > (255-color.blue() )));
758 else if( oldChart != region->chart ) {
759 oldChart = region->chart;
760 painter->setPen( params()->dataValuesColor( region->chart ) );
763 if( params()->optimizeOutputForScreen() ){
764 painter->rotate( -oldRotation );
766 if ( anchor.y() < 0 )
767 anchor.setY( -anchor.y() );
769 KDDrawText::drawRotatedText( painter,
773 region->chart ? &font1 : &font0,
782 painter->setPen( params()->dataValuesColor( region->chart ) );
784 painter->drawText( infosKDD.x , infosKDD.y ,
785 infosKDD.width, infosKDD.height,
786 TQt::AlignHCenter | TQt::AlignVCenter | TQt::SingleLine,
797 painter->rotate( -oldRotation );
799 TQFontMetrics & fm = region->chart ? fm1 : fm0;
800 int boundingRectWidth = fm.boundingRect( region->text ).width();
801 int leftBearing = fm.leftBearing( region->text[ 0 ] );
802 const TQChar c = region->text.at( region->text.length() - 1 );
803 int rightBearing = fm.rightBearing( c );
804 int w = boundingRectWidth + leftBearing + rightBearing + 1;
808 switch( align & ( TQt::AlignLeft | TQt::AlignRight | TQt::AlignHCenter ) ) {
809 case TQt::AlignRight:
812 case TQt::AlignHCenter:
815 dx = -( ( boundingRectWidth / 2 ) + leftBearing );
818 switch( align & ( TQt::AlignTop | TQt::AlignBottom | TQt::AlignVCenter ) ) {
819 case TQt::AlignBottom:
822 case TQt::AlignVCenter:
828 TQRect( anchor.x() + dx, anchor.y() + dy, w, h ) );
829 if( allowOverlapping )
832 TQRegion sectReg( thisRegion.intersect( lastRegionDone ) );
833 drawThisOne = sectReg.isEmpty();
836 lastRegionDone = lastRegionDone.unite( thisRegion );
837 region->pTextRegion = new TQRegion( thisRegion );
838#ifdef DEBUG_TEXT_PAINTING
840 TQRect rect( region->pTextRegion->boundingRect() );
841 painter->drawRect( rect );
842 painter->setPen( TQt::red );
843 rect.setLeft( rect.left() + leftBearing );
844 rect.setTop( rect.top() + ( fm.height()-fm.boundingRect( region->text ).height() ) /2 );
845 rect.setWidth( fm.boundingRect( region->text ).width() );
846 rect.setHeight( fm.boundingRect( region->text ).height() );
847 painter->drawRect( rect );
848 painter->setPen( TQt::black );
856 TQRect textRect( region->pTextRegion->boundingRect() );
858 TQBrush brush( params()->dataValuesBackground( region->chart ) );
859 painter->setBrush( brush );
860 painter->setPen( TQt::NoPen );
861 TQRect rect( textRect );
862 rect.moveBy( -2, 0 );
863 rect.setWidth( rect.width() + 4 );
864 painter->drawRect( rect );
866 painter->setFont( region->chart ? font1 : font0 );
867 if( params()->dataValuesAutoColor( region->chart ) ) {
869 TQColor color( params()->dataColor( region->row ) );
879 painter->setPen( color.dark() );
882 painter->setPen( TQt::black );
884 TQColor color( params()->dataColor(
885 ( KDChartParams::Pie == params()->chartType()
886 || KDChartParams::Ring == params()->chartType() )
889 painter->setPen( TQColor( static_cast < int > ( 255- color.red() ),
890 static_cast < int > ( 255- color.green() ),
891 static_cast < int > ( 255- color.blue() ) ) );
895 painter->setPen( params()->dataValuesColor( region->chart ) );
898 painter->drawText( textRect.left(), textRect.top(),
899 textRect.width()+1, textRect.height()+1,
900 TQt::AlignLeft | TQt::AlignTop, region->text );
926 = params()->frameSettings( KDChartEnums::AreasCustomBoxes, bGlobalFound );
929 for( idx = 0; idx <= params()->maxCustomBoxIdx(); ++idx ) {
934 KDChartEnums::AreaCustomBoxesBASE + idx,
940 bool bIndividualFound;
942 = params()->frameSettings( KDChartEnums::AreaCustomBoxesBASE + idx,
945 = bIndividualFound ? individualFrameSettings
946 : bGlobalFound ? globalFrameSettings : 0;
953 settings ? settings->framePtr() : 0,
954 trueFrameRect( box-> trueRect( anchor, _areaWidthP1000, _areaHeightP1000 ),
995 if( allCustomBoxes ) {
1032 TQRect rect(0,0, 0,0);
1033 allCustomBoxes = false;
1036 case KDChartEnums::AreaData:
1039 case KDChartEnums::AreaAxes:
1041 case KDChartEnums::AreaLegend:
1044 case KDChartEnums::AreaDataAxes:
1047 case KDChartEnums::AreaDataAxesLegend:
1049 if( _legendRect.isValid() ) {
1050 if( rect.isValid() )
1051 rect = rect.unite( _legendRect );
1056 case KDChartEnums::AreaHeaders: {
1058 for( pos = KDChartParams::HdFtPosHeadersSTART;
1059 KDChartParams::HdFtPosHeadersEND >= pos;
1061 const TQRect& r = params()->headerFooterRect( pos );
1066 rect = rect.unite( r );
1072 case KDChartEnums::AreaFooters: {
1074 for( pos = KDChartParams::HdFtPosFootersSTART;
1075 KDChartParams::HdFtPosFootersEND >= pos;
1077 const TQRect& r = params()->headerFooterRect( pos );
1082 rect = rect.unite( r );
1088 case KDChartEnums::AreaDataAxesLegendHeadersFooters: {
1090 bool bStart = !rect.isValid();
1091 if( _legendRect.isValid() ) {
1095 rect = rect.unite( _legendRect );
1098 for( pos = KDChartParams::HdFtPosSTART;
1099 KDChartParams::HdFtPosEND >= pos;
1101 const TQRect& r = params()->headerFooterRect( pos );
1106 rect = rect.unite( r );
1112 case KDChartEnums::AreaOutermost:
1113 rect = _outermostRect;
1115 case KDChartEnums::AreaInnermost:
1116 rect = _innermostRect;
1118 case KDChartEnums::AreasCustomBoxes:
1119 allCustomBoxes = true;
1121 case KDChartEnums::AreaChartDataRegion:
1123 KDChartDataRegion* current;
1124 for ( current = regions->first();
1126 current = regions->next() ) {
1127 if ( current->row == dataRow
1128 && current->col == dataCol
1133 rect = current->rect();
1139 case KDChartEnums::AreaUNKNOWN:
1143 uint maskBASE = KDChartEnums::AreaBASEMask & area;
1144 pos = area - maskBASE;
1145 if ( KDChartEnums::AreaAxisBASE == maskBASE ) {
1146 rect = params()->axisParams( pos ).axisTrueAreaRect();
1147 } else if ( KDChartEnums::AreaHdFtBASE == maskBASE ) {
1148 rect = params()->headerFooterRect( pos );
1149 } else if ( KDChartEnums::AreaCustomBoxesBASE == maskBASE ) {
1163TQPoint KDChartPainter::pointOnCircle( const TQRect& rect, double angle )
1172 double normAngle = angle / 16.0;
1173 double normAngleRad = DEGTORAD( normAngle );
1174 double cosAngle = cos( normAngleRad );
1175 double sinAngle = -sin( normAngleRad );
1176 double posX = floor( cosAngle * ( double ) rect.width() / 2.0 + 0.5 );
1177 double posY = floor( sinAngle * ( double ) rect.height() / 2.0 + 0.5 );
1178 return TQPoint( static_cast<int>(posX) + rect.center().x(),
1179 static_cast<int>(posY) + rect.center().y() );
1183void KDChartPainter::makeArc( TQPointArray& points,
1185 double startAngle, double angles )
1187 double endAngle = startAngle + angles;
1188 int rCX = rect.center().x();
1189 int rCY = rect.center().y();
1190 double rWid2 = ( double ) rect.width() / 2.0;
1191 double rHig2 = ( double ) rect.height() / 2.0;
1192 int numSteps = static_cast<int>(angles);
1193 if( floor( angles ) < angles )
1195 points.resize( numSteps );
1196 double angle = startAngle;
1199 else if( angle >= 5760.0 )
1201 for( int i = 0; i < numSteps; ++i){
1202 double normAngle = angle / 16.0;
1203 double normAngleRad = DEGTORAD( normAngle );
1204 double cosAngle = cos( normAngleRad );
1205 double sinAngle = -sin( normAngleRad );
1206 double posX = floor( cosAngle * rWid2 + 0.5 );
1207 double posY = floor( sinAngle * rHig2 + 0.5 );
1208 points[i] = TQPoint( ( int ) posX + rCX,
1209 ( int ) posY + rCY );
1210 if( i+1 >= numSteps-1 )
1214 if( angle >= 5760.0 )
1234int KDChartPainter::legendTitleVertGap() const
1236 return _legendTitleHeight
1237 + static_cast < int > ( _legendTitleMetricsHeight * 0.20 );
1241TQFont KDChartPainter::trueLegendFont() const
1243 TQFont trueFont = params()->legendFont();
1244 if ( params()->legendFontUseRelSize() ) {
1245 const double averageValueP1000 = TQMIN(_areaWidthP1000, _areaHeightP1000);
1246 trueFont.setPixelSize(
1247 static_cast < int > ( params()->legendFontRelSize() * averageValueP1000 ) );
1258void KDChartPainter::calculateHorizontalLegendSize( TQPainter* painter,
1260 bool& legendNewLinesStartAtLeft ) const
1263 legendNewLinesStartAtLeft = false;
1264 TQRect legendRect( _legendRect );
1272 legendRect.setLeft( _innermostRect.left() );
1274 const int em2 = 2 * _legendEMSpace;
1275 const int em4 = 4 * _legendEMSpace;
1276 const int emDiv2 = static_cast < int > ( _legendEMSpace / 2.0 );
1278 const int xposHori0 = legendRect.left() + _legendEMSpace;
1280 int xpos = xposHori0;
1282 int ypos = legendRect.top() + emDiv2;
1286 xpos += _legendTitleWidth + em4;
1288 int maxX = _legendTitleWidth + _legendEMSpace;
1291 int xposHori1 = xpos;
1294 int x2 = xpos + em2;
1299 const int rightEdge = _innermostRect.right()-_legendEMSpace;
1300 bool bFirstLFWithTitle = _legendTitle;
1301 painter->setFont( trueLegendFont() );
1302 TQFontMetrics txtMetrics( painter->fontMetrics() );
1304 for ( dataset = 0; dataset < _numLegendTexts; ++dataset ) {
1308 if( !_legendTexts[ dataset ].isEmpty() ){
1309 int txtWidth = txtMetrics.width( _legendTexts[ dataset ] ) + 1;
1310 if( x2 + txtWidth > rightEdge ){
1311 if( xposHori1 + em2 + txtWidth > rightEdge){
1312 xposHori1 = xposHori0;
1313 legendNewLinesStartAtLeft = true;
1317 ypos += bFirstLFWithTitle ? legendTitleVertGap() : _legendSpacing;
1318 bFirstLFWithTitle = false;
1320 maxX = TQMAX(maxX, x2+txtWidth+_legendEMSpace);
1322 xpos += txtWidth + em4;
1323 x2 += txtWidth + em4;
1326 if( bFirstLFWithTitle )
1327 ypos += _legendTitleHeight;
1329 ypos += txtMetrics.height();
1331 size.setWidth( maxX - legendRect.left() );
1332 size.setHeight( ypos + emDiv2 - _legendRect.top() );
1336bool KDChartPainter::mustDrawVerticalLegend() const
1339 params()->legendOrientation() == TQt::Vertical ||
1340 params()->legendPosition() == KDChartParams::LegendLeft ||
1341 params()->legendPosition() == KDChartParams::LegendRight ||
1342 params()->legendPosition() == KDChartParams::LegendTopLeft ||
1343 params()->legendPosition() == KDChartParams::LegendTopLeftLeft ||
1344 params()->legendPosition() == KDChartParams::LegendTopRight ||
1345 params()->legendPosition() == KDChartParams::LegendTopRightRight ||
1346 params()->legendPosition() == KDChartParams::LegendBottomLeft ||
1347 params()->legendPosition() == KDChartParams::LegendBottomLeftLeft ||
1348 params()->legendPosition() == KDChartParams::LegendBottomRight ||
1349 params()->legendPosition() == KDChartParams::LegendBottomRightRight;
1352TQFont KDChartPainter::trueLegendTitleFont() const
1354 const double averageValueP1000 = TQMIN(_areaWidthP1000, _areaHeightP1000);
1355 TQFont font( params()->legendTitleFont() );
1356 if ( params()->legendTitleFontUseRelSize() ) {
1358 static_cast < int > ( params()->legendTitleFontRelSize()
1359 * averageValueP1000 );
1360 font.setPixelSize( nTxtHeight );
1377 if ( params()->legendPosition() == KDChartParams::NoLegend )
1380 const bool bVertical = mustDrawVerticalLegend();
1385 params()->frameSettings( KDChartEnums::AreaLegend, bFrameFound );
1400 const int em2 = 2 * _legendEMSpace;
1401 const int em4 = 4 * _legendEMSpace;
1402 const int emDiv2 = static_cast < int > ( _legendEMSpace / 2.0 );
1404 const int xposHori0 = _legendRect.left() + _legendEMSpace;
1406 int xpos = xposHori0;
1408 int ypos = _legendRect.top() + emDiv2;
1414 if( _legendTitle ) {
1415 painter->setFont( trueLegendTitleFont() );
1416 _legendTitle->draw( painter,
1422 _legendTitleHeight ),
1423 params()->legendTitleTextColor() );
1425 ypos += legendTitleVertGap();
1428 xpos += _legendTitleWidth + em4;
1433 const int xposHori1 = _legendNewLinesStartAtLeft ? xposHori0 : xpos;
1436 int x2 = xpos + em2;
1441 const int rightEdge = _legendRect.right();
1442 bool bFirstLF = true;
1443 painter->setFont( trueLegendFont() );
1444 TQFontMetrics txtMetrics( painter->fontMetrics() );
1446 for ( dataset = 0; dataset < _numLegendTexts; ++dataset ) {
1450 if( !_legendTexts[ dataset ].isEmpty() ){
1451 int txtWidth = txtMetrics.width( _legendTexts[ dataset ] ) + 1;
1456 int legHeight = static_cast <int>((txtMetrics.height() - ( int)(txtMetrics.height() * 0.1))*0.85);
1460 if( !bVertical && x2 + txtWidth >= rightEdge ){
1461 _legendRect.setHeight( _legendRect.height() + _legendSpacing );
1464 ypos += bFirstLF ? legendTitleVertGap() : _legendSpacing;
1467 painter->setBrush( TQBrush( params()->dataColor( dataset ),
1468 TQBrush::SolidPattern ) );
1470 if( params()->legendShowLines() ){
1471 painter->setPen( TQPen( params()->dataColor( dataset ), 2,
1472 params()->lineStyle( dataset ) ) );
1476 xpos + static_cast < int > ( _legendEMSpace * 1.5 ),
1486 _areaWidthP1000, _areaHeightP1000,
1487 _dataRect.x(), _dataRect.y(),
1488 params()->lineMarker()
1489 ? params()->lineMarkerStyle( dataset )
1490 : KDChartParams::LineMarkerSquare,
1491 params()->dataColor(dataset),
1492 TQPoint(xpos + emDiv2,
1493 bVertical? ypos + emDiv2: !bFirstLF ?ypos + _legendSpacing:_legendRect.center().y() - (legHeight / 2 )) ,
1495 &legHeight , &legHeight ,
1496 bVertical ? TQt::AlignCenter : (TQt::AlignTop | TQt::AlignHCenter) );
1509 painter->setPen( params()->legendTextColor() );
1510 painter->drawText( x2,
1511 bVertical ? ypos : !bFirstLF ? ypos + _legendSpacing : _legendRect.center().y() - (legHeight / 2 ),
1514 TQt::AlignLeft | TQt::AlignVCenter,
1515 _legendTexts[ dataset ] );
1518 ypos += _legendSpacing;
1520 xpos += txtWidth + em4;
1521 x2 += txtWidth + em4;
1526 painter->setPen( TQPen( TQt::black, 1 ) );
1527 painter->setBrush( TQBrush::NoBrush );
1529 painter->drawRect( _legendRect );
1536void adjustFromTo( int& from, int& to)
1538 if( abs(from) > abs(to) ){
1546bool KDChartPainter::axesOverlapping( int axis1, int axis2 )
1553 if( KDChartAxisParams::AxisPosLeft != basicPos &&
1554 KDChartAxisParams::AxisPosRight != basicPos )
1558 int f1 = params()->axisParams( axis1 ).axisUseAvailableSpaceFrom();
1559 int t1 = params()->axisParams( axis1 ).axisUseAvailableSpaceTo();
1560 int f2 = params()->axisParams( axis2 ).axisUseAvailableSpaceFrom();
1561 int t2 = params()->axisParams( axis2 ).axisUseAvailableSpaceTo();
1562 adjustFromTo(f1,t1);
1563 adjustFromTo(f2,t2);
1566 const double guessedAxisHeightP1000 = _areaHeightP1000 * 80.0 / 100.0;
1567 if(f1 < 0) f1 = static_cast < int > ( f1 * -guessedAxisHeightP1000 );
1568 if(t1 < 0) t1 = static_cast < int > ( t1 * -guessedAxisHeightP1000 );
1569 if(f2 < 0) f2 = static_cast < int > ( f2 * -guessedAxisHeightP1000 );
1570 if(t2 < 0) t2 = static_cast < int > ( t2 * -guessedAxisHeightP1000 );
1571 const bool res = (f1 >= f2 && f1 < t2) || (f2 >= f1 && f2 < t1);
1577 int x0, int y0, int w0, int h0 )
1582 adjustFromTo(nFrom,nTo);
1586 if( KDChartAxisParams::AxisPosBottom == basicPos ||
1587 KDChartAxisParams::AxisPosTop == basicPos ){
1610 y = y0 + h0 - h0*nTo/-1000;
1615 h = y0 + h0 - h0*nFrom/-1000 - y;
1617 h = y0 + h0 - nFrom - y;
1639 const double averageValueP1000 = TQMIN(_areaWidthP1000, _areaHeightP1000);
1643 for( int iHdFt = KDChartParams::HdFtPosSTART;
1644 iHdFt <= KDChartParams::HdFtPosEND; ++iHdFt ){
1645 TQString txt( params()->headerFooterText( iHdFt ) );
1646 if ( !txt.isEmpty() ) {
1647 TQFont actFont( params()->headerFooterFont( iHdFt ) );
1648 if ( params()->headerFooterFontUseRelSize( iHdFt ) )
1649 actFont.setPixelSize( static_cast < int > (
1650 params()->headerFooterFontRelSize( iHdFt ) * averageValueP1000 ) );
1651 painter->setPen( params()->headerFooterColor( iHdFt ) );
1652 painter->setFont( actFont );
1658 TQRect rect( params()->headerFooterRect( iHdFt ) );
1659 int dXY = iHdFt < KDChartParams::HdFtPosFootersSTART
1662 rect.moveBy(dXY, dXY);
1663 rect.setWidth( rect.width() -2*dXY +1 );
1664 rect.setHeight( rect.height()-2*dXY +1 );
1665 painter->drawText( rect,
1666 TQt::AlignLeft | TQt::AlignTop | TQt::SingleLine,
1674int KDChartPainter::calculateHdFtRects(
1676 double averageValueP1000,
1683 int& leading = (bHeader ? _hdLeading : _ftLeading);
1687 const int rangesCnt = 3;
1688 const int ranges[ rangesCnt ]
1689 = { bHeader ? KDChartParams::HdFtPosHeaders0START : KDChartParams::HdFtPosFooters0START,
1690 bHeader ? KDChartParams::HdFtPosHeaders1START : KDChartParams::HdFtPosFooters1START,
1691 bHeader ? KDChartParams::HdFtPosHeaders2START : KDChartParams::HdFtPosFooters2START };
1692 const int rangeSize = 3;
1693 TQFontMetrics* metrics[rangesCnt * rangeSize];
1696 for( i = 0; i < rangesCnt*rangeSize; ++i )
1701 for( iRange = 0; iRange < rangesCnt; ++iRange ){
1702 for( i = 0; i < rangeSize; ++i ){
1703 iHdFt = ranges[iRange] + i;
1704 TQString txt( params()->headerFooterText( iHdFt ) );
1705 if ( !txt.isEmpty() ) {
1706 TQFont actFont( params()->headerFooterFont( iHdFt ) );
1707 if ( params()->headerFooterFontUseRelSize( iHdFt ) ) {
1708 actFont.setPixelSize( static_cast < int > (
1709 params()->headerFooterFontRelSize( iHdFt ) * averageValueP1000 ) );
1711 painter->setFont( actFont );
1712 metrics[ iRange*rangeSize + i ] = new TQFontMetrics( painter->fontMetrics() );
1713 leading = TQMAX( leading, metrics[ iRange*rangeSize + i ]->lineSpacing() / 2 );
1723 int leading23 = leading*2/3 +1;
1726 bHeader ? 0 : rangesCnt-1;
1727 bHeader ? iRange < rangesCnt : iRange >= 0;
1728 bHeader ? ++iRange : --iRange ){
1731 int ascents[rangeSize];
1732 int heights[rangeSize];
1733 int widths[ rangeSize];
1736 for( i = 0; i < rangeSize; ++i ){
1737 iHdFt = ranges[iRange] + i;
1738 if ( metrics[ iRange*rangeSize + i ] ) {
1739 TQFontMetrics& m = *metrics[ iRange*rangeSize + i ];
1740 ascents[i] = m.ascent();
1741 heights[i] = m.height() + leading23;
1745 widths[ i] = m.boundingRect( params()->headerFooterText( iHdFt )+ " " ).width() + leading23;
1747 maxAscent = TQMAX( maxAscent, ascents[i] );
1748 maxHeight = TQMAX( maxHeight, heights[i] );
1755 yposBottom -= maxHeight;
1757 for( i = 0; i < rangeSize; ++i ){
1759 iHdFt = ranges[iRange] + i;
1762 case 1: x1 = xposLeft+1;
1764 case 2: x1 = xposRight-widths[i]-1;
1766 default: x1 = xposLeft + (xposRight-xposLeft-widths[i]) / 2;
1768 ((KDChartParams*)params())->__internalStoreHdFtRect( iHdFt,
1771 ? yposTop + maxAscent - ascents[i]
1772 : yposBottom + maxAscent - ascents[i],
1778 yposTop += leading + maxHeight;
1780 yposBottom -= leading;
1782 for( i = 0; i < rangesCnt*rangeSize; ++i )
1784 delete metrics[ i ];
1793 uint& chartDatasetStart,
1794 uint& chartDatasetEnd )
1796 chartDatasetStart = 0;
1797 chartDatasetEnd = 0;
1798 if( params()->neverUsedSetChartSourceMode()
1799 || !params()->findDatasets( KDChartParams::DataEntry,
1800 KDChartParams::ExtraLinesAnchor,
1804 uint maxRow, maxRowMinus1;
1814 maxRowMinus1 = maxRow;
1816 chartDatasetStart = paint2nd ? maxRow : 0;
1817 chartDatasetEnd = paint2nd
1819 : ( ( KDChartParams::NoType == params()->additionalChartType() )
1827void KDChartPainter::calculateAllAxesRects(
1829 bool finalPrecision,
1833 const bool bIsAreaChart = KDChartParams::Area == params()->chartType();
1834 const bool bMultiRows = KDChartParams::Bar == params()->chartType() &&
1835 KDChartParams::BarMultiRows == params()->barChartSubType();
1837 const int trueWidth = _outermostRect.width();
1838 const int trueHeight = _outermostRect.height();
1839 const double averageValueP1000 = TQMIN(_areaWidthP1000, _areaHeightP1000);
1842 int nAxesLeft0 = _axesRect.left() - _outermostRect.left();
1843 int nAxesRight0 = _outermostRect.right() - _axesRect.right();
1844 int nAxesTop0 = _axesRect.top() - _outermostRect.top();
1845 int nAxesBottom0 = _outermostRect.bottom() - _axesRect.bottom();
1847 uint chartDatasetStart, chartDatasetEnd;
1848 findChartDatasets( data, false, 0, chartDatasetStart, chartDatasetEnd );
1849 const int datasets = chartDatasetEnd - chartDatasetStart + 1;
1851 if ( params()->numValues() != -1 )
1852 numValues = params()->numValues();
1856 const int additionalGapWidth = static_cast < int > ( 1.0 * _axesRect.width() / (9.75*numValues + 4.0*datasets) * 4.0*datasets );
1857 nAxesRight0 += additionalGapWidth;
1858 nAxesTop0 += static_cast < int > ( additionalGapWidth * 0.52 );
1864 int nAxesLeftADD =0;
1865 int nAxesRightADD =0;
1867 int nAxesBottomADD=0;
1871 bool bAddLeft = axesOverlapping( KDChartAxisParams::AxisPosLeft,
1872 KDChartAxisParams::AxisPosLeft2 );
1873 bool bAddRight = axesOverlapping( KDChartAxisParams::AxisPosRight,
1874 KDChartAxisParams::AxisPosRight2 );
1875 bool bAddTop = axesOverlapping( KDChartAxisParams::AxisPosTop,
1876 KDChartAxisParams::AxisPosTop2 );
1877 bool bAddBottom = axesOverlapping( KDChartAxisParams::AxisPosBottom,
1878 KDChartAxisParams::AxisPosBottom2 );
1883 const KDChartAxisParams& para = params()->axisParams( iAxis );
1887 && KDChartAxisParams::AxisTypeUnknown != para. axisType() ) {
1889 const KDChartAxisParams::AxisPos
1895 areaMin = static_cast < int > ( -1.0 * averageValueP1000 * areaMin );
1897 areaMax = static_cast < int > ( -1.0 * averageValueP1000 * areaMax );
1901 switch ( basicPos ) {
1902 case KDChartAxisParams::AxisPosBottom:
1903 case KDChartAxisParams::AxisPosTop:
1908 para.axisLabelsFontMinSize() );
1911 TQFontMetrics metrics( painter->fontMetrics() );
1912 fntHeight = metrics.height();
1915 uint dataDataset, dataDataset2;
1916 if( !params()->findDataset( KDChartParams::DataEntry,
1919 KDCHART_ALL_CHARTS ) ) {
1920 tqDebug( "IMPLEMENTATION ERROR: findDataset( DataEntry, ... ) should *always* return true. (a)" );
1921 dataDataset = KDCHART_ALL_DATASETS;
1923 TQVariant::Type valType = TQVariant::Invalid;
1924 const bool dataCellsHaveSeveralCoordinates =
1925 (KDCHART_ALL_DATASETS == dataDataset)
1926 ? data->cellsHaveSeveralCoordinates( &valType )
1927 : data->cellsHaveSeveralCoordinates( dataDataset, dataDataset2, &valType );
1929 if( dataCellsHaveSeveralCoordinates
1930 && TQVariant::DateTime == valType ){
1932 areaMin = TQMAX( areaMin, static_cast < int > ( fntHeight * 6.75 ) );
1934 areaMin = TQMAX( areaMin, fntHeight * ( 3 + format.contains( "\n") ) );
1937 areaMin = TQMAX( areaMin, fntHeight * 3 );
1940 case KDChartAxisParams::AxisPosLeft:
1941 case KDChartAxisParams::AxisPosRight:
1948 case KDChartAxisParams::AxisAreaModeAutoSize:
1951 switch ( basicPos ) {
1952 case KDChartAxisParams::AxisPosBottom:
1953 case KDChartAxisParams::AxisPosTop:
1955 case KDChartAxisParams::AxisPosLeft:
1956 case KDChartAxisParams::AxisPosRight:
1957 if( finalPrecision ){
1958 internal__KDChart__CalcValues& cv = calcVal[iAxis];
1959 const int nUsableAxisWidth = static_cast < int > (cv.pTextsW);
1960 const KDChartAxisParams & para = params()->axisParams( iAxis );
1963 axisLabelsFont.setPixelSize( static_cast < int > ( cv.nTxtHeight ) );
1966 TQFontMetrics axisLabelsFontMetrics( painter->fontMetrics() );
1967 const int lenEM( axisLabelsFontMetrics.boundingRect( "M").width() );
1968 const TQStringList* labelTexts = para.axisLabelTexts();
1969 uint nLabels = ( 0 != labelTexts )
1970 ? labelTexts->count()
1972 int maxLabelsWidth = 0;
1973 for ( uint i = 0; i < nLabels; ++i )
1975 TQMAX( maxLabelsWidth,
1976 axisLabelsFontMetrics.boundingRect(*labelTexts->at(i)).width() );
1977 if( nUsableAxisWidth < maxLabelsWidth )
1978 areaSize = maxLabelsWidth
1988 case KDChartAxisParams::AxisAreaModeMinMaxSize:
1990 tqDebug( "Sorry, not implemented: AxisAreaModeMinMaxSize" );
2001 case KDChartAxisParams::AxisAreaModeFixedSize:
2003 areaSize = areaMax ? TQMIN( areaMin, areaMax ) : areaMin;
2011 for( idx = 0; idx <= params()->maxCustomBoxIdx(); ++idx ) {
2012 const KDChartCustomBox * box = params()->customBox( idx );
2014 if ( box->parentAxisArea() == KDChartAxisParams::AxisPosBottom
2015 || box->parentAxisArea() == KDChartAxisParams::AxisPosLeft
2016 || box->parentAxisArea() == KDChartAxisParams::AxisPosTop
2017 || box->parentAxisArea() == KDChartAxisParams::AxisPosRight )
2018 boxSize = box-> trueRect(TQPoint( 0,0 ), _areaWidthP1000, _areaHeightP1000 ).height();
2021 areaSize += boxSize;
2023 switch ( basicPos ) {
2024 case KDChartAxisParams::AxisPosBottom:
2027 nAxesBottomADD += areaSize;
2031 nAxesBottomADD = TQMAX( nAxesBottomADD + boxSize, areaSize );
2034 case KDChartAxisParams::AxisPosLeft:
2036 nAxesLeftADD += areaSize;
2038 nAxesLeftADD = TQMAX( nAxesLeftADD + boxSize, areaSize );
2040 case KDChartAxisParams::AxisPosTop:
2042 nAxesTopADD += areaSize;
2044 nAxesTopADD = TQMAX( nAxesTopADD + boxSize, areaSize );
2046 case KDChartAxisParams::AxisPosRight:
2048 nAxesRightADD += areaSize;
2050 nAxesRightADD = TQMAX( nAxesRightADD + boxSize, areaSize );
2060 ( ( KDChartAxisParams& ) para ).setAxisTrueAreaSize( areaSize );
2062 int nMinDistance = static_cast < int > ( 30.0 * averageValueP1000 );
2064 int nAxesBottom = TQMAX( nAxesBottom0 + nAxesBottomADD, nMinDistance );
2068 int nAxesLeft = TQMAX( nAxesLeft0 + nAxesLeftADD, nMinDistance )
2069 - (bIsAreaChart ? 0 : 1);
2071 int nAxesTop = TQMAX( nAxesTop0 + nAxesTopADD, nMinDistance );
2073 int nAxesRight = TQMAX( nAxesRight0 + nAxesRightADD, nMinDistance );
2075 int nBottom = params()->axisParams( KDChartAxisParams::AxisPosBottom ).axisTrueAreaSize();
2076 int nLeft = params()->axisParams( KDChartAxisParams::AxisPosLeft ).axisTrueAreaSize();
2077 int nTop = params()->axisParams( KDChartAxisParams::AxisPosTop ).axisTrueAreaSize();
2078 int nRight = params()->axisParams( KDChartAxisParams::AxisPosRight ).axisTrueAreaSize();
2079 int nBottom2 = params()->axisParams( KDChartAxisParams::AxisPosBottom2 ).axisTrueAreaSize();
2080 int nLeft2 = params()->axisParams( KDChartAxisParams::AxisPosLeft2 ).axisTrueAreaSize();
2081 int nTop2 = params()->axisParams( KDChartAxisParams::AxisPosTop2 ).axisTrueAreaSize();
2082 int nRight2 = params()->axisParams( KDChartAxisParams::AxisPosRight2 ).axisTrueAreaSize();
2084 internSetAxisArea( _params,
2085 KDChartAxisParams::AxisPosBottom,
2086 _outermostRect.left() + nAxesLeft,
2087 _outermostRect.top() + trueHeight - nAxesBottom,
2088 trueWidth - nAxesLeft - nAxesRight + 1,
2090 internSetAxisArea( _params,
2091 KDChartAxisParams::AxisPosLeft,
2092 _outermostRect.left() + (bAddLeft ? nAxesLeft0 + nLeft2 : nAxesLeft0),
2093 _outermostRect.top() + nAxesTop,
2095 trueHeight - nAxesTop - nAxesBottom + 1 );
2097 internSetAxisArea( _params,
2098 KDChartAxisParams::AxisPosTop,
2099 _outermostRect.left() + nAxesLeft,
2100 _outermostRect.top() + (bAddTop ? nAxesTop0 + nTop2 : nAxesTop0),
2101 trueWidth - nAxesLeft - nAxesRight + 1,
2103 internSetAxisArea( _params,
2104 KDChartAxisParams::AxisPosRight,
2105 _outermostRect.left() + trueWidth - nAxesRight,
2106 _outermostRect.top() + nAxesTop,
2108 trueHeight - nAxesTop - nAxesBottom + 1 );
2110 internSetAxisArea( _params,
2111 KDChartAxisParams::AxisPosBottom2,
2112 _outermostRect.left() + nAxesLeft,
2113 _outermostRect.top() + trueHeight - nAxesBottom + (bAddBottom ? nBottom : 0),
2114 trueWidth - nAxesLeft - nAxesRight + 1,
2116 internSetAxisArea( _params,
2117 KDChartAxisParams::AxisPosLeft2,
2118 _outermostRect.left() + nAxesLeft0,
2119 _outermostRect.top() + nAxesTop,
2121 trueHeight - nAxesTop - nAxesBottom + 1 );
2123 internSetAxisArea( _params,
2124 KDChartAxisParams::AxisPosTop2,
2125 _outermostRect.left() + nAxesLeft,
2126 _outermostRect.top() + nAxesTop0,
2127 trueWidth - nAxesLeft - nAxesRight + 1,
2129 internSetAxisArea( _params,
2130 KDChartAxisParams::AxisPosRight2,
2131 _outermostRect.left() + trueWidth - nAxesRight + (bAddRight ? nRight : 0),
2132 _outermostRect.top() + nAxesTop,
2134 trueHeight - nAxesTop - nAxesBottom + 1 );
2136 _dataRect = TQRect( _outermostRect.left() + nAxesLeft,
2137 _outermostRect.top() + nAxesTop,
2138 trueWidth - nAxesLeft - nAxesRight + 1,
2139 trueHeight - nAxesTop - nAxesBottom + 1 );
2158 const TQRect& drawRect )
2162 const bool oldBlockSignalsState = params()->signalsBlocked();
2163 const_cast < KDChartParams* > ( params() )->blockSignals( true );
2165 _outermostRect = drawRect;
2167 int yposTop = _outermostRect.topLeft().y();
2168 int xposLeft = _outermostRect.topLeft().x();
2169 int yposBottom = _outermostRect.bottomRight().y();
2170 int xposRight = _outermostRect.bottomRight().x();
2172 const int trueWidth = _outermostRect.width();
2173 const int trueHeight = _outermostRect.height();
2177 _areaWidthP1000 = trueWidth / 1000.0;
2178 _areaHeightP1000 = trueHeight / 1000.0;
2181 xposLeft += 0 < params()->globalLeadingLeft()
2182 ? params()->globalLeadingLeft()
2183 : static_cast < int > ( params()->globalLeadingLeft() * -_areaWidthP1000 );
2184 yposTop += 0 < params()->globalLeadingTop()
2185 ? params()->globalLeadingTop()
2186 : static_cast < int > ( params()->globalLeadingTop() * -_areaHeightP1000 );
2187 xposRight -= 0 < params()->globalLeadingRight()
2188 ? params()->globalLeadingRight()
2189 : static_cast < int > ( params()->globalLeadingRight() * -_areaWidthP1000 );
2190 yposBottom -= 0 < params()->globalLeadingBottom()
2191 ? params()->globalLeadingBottom()
2192 : static_cast < int > ( params()->globalLeadingBottom()* -_areaHeightP1000 );
2194 _innermostRect = TQRect( TQPoint(xposLeft, yposTop),
2195 TQPoint(xposRight, yposBottom) );
2197 _logicalWidth = xposRight - xposLeft;
2198 _logicalHeight = yposBottom - yposTop;
2202 _areaWidthP1000 = _logicalWidth / 1000.0;
2203 _areaHeightP1000 = _logicalHeight / 1000.0;
2205 double averageValueP1000 = TQMIN(_areaWidthP1000, _areaHeightP1000);
2213 int headerLineLeading = calculateHdFtRects(
2216 xposLeft, xposRight,
2218 yposTop, yposBottom );
2222 xposLeft, xposRight,
2224 yposTop, yposBottom );
2228 if ( params()->legendPosition() != KDChartParams::NoLegend ) {
2230 findLegendTexts( data );
2232 bool hasLegendTitle = false;
2233 if ( !params()->legendTitleText().isEmpty() )
2234 hasLegendTitle = true;
2236 _legendTitleWidth = 0;
2238 delete _legendTitle;
2240 if ( hasLegendTitle ) {
2241 const TQFont font( trueLegendTitleFont() );
2242 painter->setFont( font );
2243 TQFontMetrics legendTitleMetrics( painter->fontMetrics() );
2244 _legendTitleMetricsHeight = legendTitleMetrics.height();
2246 _legendTitle = new KDChartTextPiece( painter,
2247 params()->legendTitleText(),
2249 _legendTitleWidth = _legendTitle->width();
2250 _legendTitleHeight = _legendTitle->height();
2254 painter->setFont( trueLegendFont() );
2255 TQFontMetrics legendMetrics( painter->fontMetrics() );
2256 _legendSpacing = legendMetrics.lineSpacing();
2257 _legendHeight = legendMetrics.height();
2258 _legendLeading = legendMetrics.leading();
2260 _legendEMSpace = legendMetrics.width( 'M' );
2265 for ( int dataset = 0; dataset < _numLegendTexts; dataset++ ) {
2266 sizeX = TQMAX( sizeX, legendMetrics.width( _legendTexts[ dataset ] ) );
2267 if( !_legendTexts[ dataset ].isEmpty() )
2268 sizeY += _legendSpacing;
2271 sizeY += _legendEMSpace - _legendLeading;
2273 if ( hasLegendTitle )
2274 sizeY += legendTitleVertGap();
2278 sizeX += ( _legendEMSpace * 4 );
2285 sizeX = TQMAX( sizeX, _legendTitleWidth + _legendEMSpace*2 );
2290 if( !mustDrawVerticalLegend() ){
2292 calculateHorizontalLegendSize( painter,
2294 _legendNewLinesStartAtLeft );
2295 sizeX = size.width();
2296 sizeY = size.height();
2299 switch ( params()->legendPosition() ) {
2300 case KDChartParams::LegendTop:
2301 if ( headerLineLeading )
2302 yposTop += TQMAX( ( int)params()->legendSpacing(), headerLineLeading );
2303 _legendRect = TQRect( xposLeft + ( (xposRight-xposLeft) - sizeX ) / 2,
2304 yposTop, sizeX, sizeY );
2305 yposTop = _legendRect.bottom() + params()->legendSpacing();
2308 case KDChartParams::LegendBottom:
2309 if ( params()->showGrid() )
2310 yposTop += headerLineLeading;
2311 _legendRect = TQRect( xposLeft + ( (xposRight-xposLeft) - sizeX ) / 2,
2314 yposBottom = _legendRect.top() - params()->legendSpacing();
2316 case KDChartParams::LegendLeft:
2317 if ( params()->showGrid() )
2318 yposTop += headerLineLeading;
2319 _legendRect = TQRect( xposLeft + 1, ( yposBottom - yposTop - sizeY ) / 2 +
2322 xposLeft = _legendRect.right() + params()->legendSpacing();
2324 case KDChartParams::LegendRight:
2325 if ( params()->showGrid() )
2326 yposTop += headerLineLeading;
2327 _legendRect = TQRect( xposRight - sizeX - 1,
2328 ( yposBottom - yposTop - sizeY ) / 2 + yposTop,
2330 xposRight = _legendRect.left() - params()->legendSpacing();
2332 case KDChartParams::LegendTopLeft:
2333 if ( headerLineLeading )
2334 yposTop += TQMAX( ( int)params()->legendSpacing(), headerLineLeading );
2335 _legendRect = TQRect( xposLeft + 1, yposTop, sizeX, sizeY );
2336 yposTop = _legendRect.bottom() + params()->legendSpacing();
2337 xposLeft = _legendRect.right() + params()->legendSpacing();
2339 case KDChartParams::LegendTopLeftTop:
2340 if ( headerLineLeading )
2341 yposTop += TQMAX( ( int)params()->legendSpacing(), headerLineLeading );
2342 _legendRect = TQRect( xposLeft + 1, yposTop, sizeX, sizeY );
2343 yposTop = _legendRect.bottom() + params()->legendSpacing();
2345 case KDChartParams::LegendTopLeftLeft:
2346 if ( headerLineLeading )
2347 yposTop += TQMAX( ( int)params()->legendSpacing(), headerLineLeading );
2348 _legendRect = TQRect( xposLeft + 1, yposTop, sizeX, sizeY );
2349 xposLeft = _legendRect.right() + params()->legendSpacing();
2351 case KDChartParams::LegendTopRight:
2352 if ( headerLineLeading )
2353 yposTop += TQMAX( ( int)params()->legendSpacing(), headerLineLeading );
2354 _legendRect = TQRect( xposRight - sizeX - 1,
2355 yposTop, sizeX, sizeY );
2356 yposTop = _legendRect.bottom() + params()->legendSpacing();
2357 xposRight = _legendRect.left() - params()->legendSpacing();
2359 case KDChartParams::LegendTopRightTop:
2360 if ( headerLineLeading )
2361 yposTop += TQMAX( ( int)params()->legendSpacing(), headerLineLeading );
2362 _legendRect = TQRect( xposRight - sizeX - 1,
2363 yposTop, sizeX, sizeY );
2364 yposTop = _legendRect.bottom() + params()->legendSpacing();
2366 case KDChartParams::LegendTopRightRight:
2367 if ( headerLineLeading )
2368 yposTop += TQMAX( ( int)params()->legendSpacing(), headerLineLeading );
2369 _legendRect = TQRect( xposRight - sizeX - 1,
2370 yposTop, sizeX, sizeY );
2371 xposRight = _legendRect.left() - params()->legendSpacing();
2373 case KDChartParams::LegendBottomLeft:
2374 if ( params()->showGrid() )
2375 yposTop += headerLineLeading;
2376 _legendRect = TQRect( xposLeft + 1, yposBottom - sizeY, sizeX, sizeY );
2377 yposBottom = _legendRect.top() - params()->legendSpacing();
2378 xposLeft = _legendRect.right() + params()->legendSpacing();
2380 case KDChartParams::LegendBottomLeftBottom:
2381 if ( params()->showGrid() )
2382 yposTop += headerLineLeading;
2383 _legendRect = TQRect( xposLeft + 1, yposBottom - sizeY, sizeX, sizeY );
2384 yposBottom = _legendRect.top() - params()->legendSpacing();
2386 case KDChartParams::LegendBottomLeftLeft:
2387 if ( params()->showGrid() )
2388 yposTop += headerLineLeading;
2389 _legendRect = TQRect( xposLeft + 1, yposBottom - sizeY, sizeX, sizeY );
2390 xposLeft = _legendRect.right() + params()->legendSpacing();
2392 case KDChartParams::LegendBottomRight:
2393 if ( params()->showGrid() )
2394 yposTop += headerLineLeading;
2395 _legendRect = TQRect( xposRight - sizeX - 1,
2396 yposBottom - sizeY, sizeX, sizeY );
2397 yposBottom = _legendRect.top() - params()->legendSpacing();
2398 xposRight = _legendRect.left() - params()->legendSpacing();
2400 case KDChartParams::LegendBottomRightBottom:
2401 if ( params()->showGrid() )
2402 yposTop += headerLineLeading;
2403 _legendRect = TQRect( xposRight - sizeX - 1,
2404 yposBottom - sizeY, sizeX, sizeY );
2405 yposBottom = _legendRect.top() - params()->legendSpacing();
2407 case KDChartParams::LegendBottomRightRight:
2408 if ( params()->showGrid() )
2409 yposTop += headerLineLeading;
2410 _legendRect = TQRect( xposRight - sizeX - 1,
2411 yposBottom - sizeY, sizeX, sizeY );
2412 xposRight = _legendRect.left() - params()->legendSpacing();
2416 tqDebug( "KDChart: Unknown legend position" );
2418 _params->setLegendArea( _legendRect );
2421 _params->setLegendArea( TQRect(TQPoint(0,0), TQSize(0,0)) );
2425 _axesRect = TQRect( TQPoint(xposLeft, yposTop), TQPoint(xposRight, yposBottom) );
2429 if( KDChartParams::Polar == params()->chartType() ) {
2430 _dataRect = _axesRect;
2434 calculateAllAxesRects( painter, false, data );
2439 if( calculateAllAxesLabelTextsAndCalcValues(
2447 calculateAllAxesRects( painter, true, data );
2449 _params->setDataArea( _dataRect );
2451 const_cast < KDChartParams* > ( params() )->blockSignals( oldBlockSignalsState );
2462 switch ( params()->legendSource() ) {
2463 case KDChartParams::LegendManual: {
2467 for ( dataset = 0; dataset < static_cast<uint>(_numLegendTexts); dataset++ )
2468 _legendTexts[ dataset ] = params()-> legendText( dataset );
2471 case KDChartParams::LegendFirstColumn: {
2473 for ( dataset = 0; dataset < data-> usedRows(); dataset++ ){
2474 if( data-> cellCoord( dataset, 0, vValY, 1 ) ){
2475 if( TQVariant::String == vValY.type() )
2476 _legendTexts[ dataset ] = vValY.toString();
2478 _legendTexts[ dataset ] = "";
2481 _numLegendTexts = data-> usedRows();
2484 case KDChartParams::LegendAutomatic: {
2486 bool notfound = false;
2489 for ( dataset = 0; dataset < data-> usedRows(); dataset++ ) {
2490 if( data-> cellCoord( dataset, 0, vValY, 1 ) ){
2491 if( TQVariant::String == vValY.type() )
2492 _legendTexts[ dataset ] = vValY.toString();
2494 _legendTexts[ dataset ] = "";
2495 if( _legendTexts[ dataset ].isEmpty() ){
2508 _legendTexts[ dataset ] = params()->legendText( dataset );
2509 if ( _legendTexts[ dataset ].isEmpty() || _legendTexts[ dataset ].isNull() ) {
2520 tqDebug( "KDChart: Unknown legend source" );
2542 return TQObject::tr( "Series " ) + TQString::number( dataset + 1 );
2575 const TQColor& color,
2580 int width = size.width();
2581 int height = size.height();
2614 double areaWidthP1000,
2615 double areaHeightP1000,
2619 const TQColor& color,
2621 uint dataset, uint value, uint chart,
2627 KDChartDataRegion* datReg = 0;
2628 const double areaSizeP1000 = TQMIN(areaWidthP1000, areaHeightP1000);
2629 int xsize = width ? *width : (params ? params->lineMarkerSize().width() : 12);
2631 xsize = static_cast < int > (xsize * -areaSizeP1000);
2632 int ysize = height ? *height : (params ? params->lineMarkerSize().height() : 12);
2634 ysize = static_cast < int > (ysize * -areaSizeP1000);
2635 if( KDChartParams::LineMarkerCross != style ){
2636 xsize = TQMAX( xsize, 4 );
2637 ysize = TQMAX( ysize, 4 );
2639 uint xsize2 = xsize / 2;
2640 uint ysize2 = ysize / 2;
2641 uint xsize4 = xsize / 4;
2642 uint ysize4 = ysize / 4;
2643 uint xsize6 = xsize / 6;
2644 uint ysize6 = ysize / 6;
2645 painter->setPen( color );
2646 const uint xysize2 = TQMIN( xsize2, ysize2 );
2650 if( align & TQt::AlignLeft )
2652 else if( align & TQt::AlignRight )
2654 if( align & TQt::AlignTop )
2656 else if( align & TQt::AlignBottom )
2658 const TQPoint p(x, y);
2661 case KDChartParams::LineMarkerSquare: {
2662 const TQPen oldPen( painter->pen() );
2663 const TQBrush oldBrush( painter->brush() );
2664 painter->setBrush( color );
2665 painter->setPen( color );
2666 TQRect rect( TQPoint( p.x() - xsize2, p.y() - ysize2 ), TQPoint( p.x() + xsize2, p.y() + ysize2 ) );
2667 painter->drawRect( rect );
2669 rect.moveBy( deltaX, deltaY );
2672 new KDChartDataRegion(
2675 regions->append( datReg );
2677 painter->setPen( oldPen );
2678 painter->setBrush( oldBrush );
2681 case KDChartParams::LineMarkerDiamond:{
2682 const TQBrush oldBrush( painter->brush() );
2683 painter->setBrush( color );
2684 TQPointArray points( 4 );
2685 points.setPoint( 0, p.x() - xsize2, p.y() );
2686 points.setPoint( 1, p.x(), p.y() - ysize2 );
2687 points.setPoint( 2, p.x() + xsize2, p.y() );
2688 points.setPoint( 3, p.x(), p.y() + ysize2 );
2689 painter->drawPolygon( points );
2691 points.translate( deltaX, deltaY );
2693 datReg = new KDChartDataRegion(
2696 regions->append( datReg );
2698 painter->setBrush( oldBrush );
2701 case KDChartParams::LineMarker1Pixel: {
2702 TQRect rect( p, p );
2703 painter->drawRect( rect );
2705 rect.moveBy( deltaX, deltaY );
2707 datReg = new KDChartDataRegion(
2710 regions->append( datReg );
2714 case KDChartParams::LineMarker4Pixels:{
2715 TQRect rect( p, TQPoint( p.x()+1, p.y()+1 ) );
2716 painter->drawRect( rect );
2718 rect.moveBy( deltaX, deltaY );
2720 datReg = new KDChartDataRegion(
2723 regions->append( datReg );
2727 case KDChartParams::LineMarkerRing: {
2728 const TQPen oldPen( painter->pen() );
2729 painter->setPen( TQPen( color, TQMIN(xsize4, ysize4) ) );
2730 const TQBrush oldBrush( painter->brush() );
2731 painter->setBrush( TQt::NoBrush );
2732 painter->drawEllipse( p.x() - xsize2, p.y() - ysize2, xsize, ysize );
2734 TQPointArray points;
2735 points.makeEllipse( p.x() - xsize2, p.y() - ysize2, xsize, ysize );
2737 points.translate( deltaX, deltaY );
2738 if( points.size() > 0 ){
2739 datReg = new KDChartDataRegion(
2742 regions->append( datReg );
2745 painter->setBrush( oldBrush );
2746 painter->setPen( oldPen );
2749 case KDChartParams::LineMarkerCross: {
2750 const TQPen oldPen( painter->pen() );
2751 painter->setPen( color );
2752 const TQBrush oldBrush( painter->brush() );
2753 painter->setBrush( color );
2754 int numPoints = (ysize && xsize) ? 12 : 4;
2755 TQPointArray points( numPoints );
2756 if( ysize && xsize ){
2757 points.setPoint( 0, p.x() - xsize6, p.y() - ysize6 );
2758 points.setPoint( 1, p.x() - xsize6, p.y() - ysize2 );
2759 points.setPoint( 2, p.x() + xsize6, p.y() - ysize2 );
2760 points.setPoint( 3, p.x() + xsize6, p.y() - ysize6 );
2761 points.setPoint( 4, p.x() + xsize2, p.y() - ysize6 );
2762 points.setPoint( 5, p.x() + xsize2, p.y() + ysize6 );
2763 points.setPoint( 6, p.x() + xsize6, p.y() + ysize6 );
2764 points.setPoint( 7, p.x() + xsize6, p.y() + ysize2 );
2765 points.setPoint( 8, p.x() - xsize6, p.y() + ysize2 );
2766 points.setPoint( 9, p.x() - xsize6, p.y() + ysize6 );
2767 points.setPoint(10, p.x() - xsize2, p.y() + ysize6 );
2768 points.setPoint(11, p.x() - xsize2, p.y() - ysize6 );
2770 points.setPoint( 0, p.x() - ysize6, p.y() - ysize2 );
2771 points.setPoint( 1, p.x() + ysize6, p.y() - ysize2 );
2772 points.setPoint( 2, p.x() + ysize6, p.y() + ysize2 );
2773 points.setPoint( 3, p.x() - ysize6, p.y() + ysize2 );
2775 points.setPoint( 0, p.x() - xsize2, p.y() - xsize6 );
2776 points.setPoint( 1, p.x() + xsize2, p.y() - xsize6 );
2777 points.setPoint( 2, p.x() + xsize2, p.y() + xsize6 );
2778 points.setPoint( 3, p.x() - xsize2, p.y() + xsize6 );
2780 painter->drawPolygon( points );
2782 points.translate( deltaX, deltaY );
2784 datReg = new KDChartDataRegion(
2787 regions->append( datReg );
2789 painter->setBrush( oldBrush );
2790 painter->setPen( oldPen );
2793 case KDChartParams::LineMarkerFastCross: {
2794 const TQPen oldPen( painter->pen() );
2795 painter->setPen( color );
2796 painter->drawLine( TQPoint(p.x() - xysize2, p.y()),
2797 TQPoint(p.x() + xysize2, p.y()) );
2798 painter->drawLine( TQPoint(p.x(), p.y() - xysize2),
2799 TQPoint(p.x(), p.y() + xysize2) );
2800 TQRect rect( TQPoint( p.x() - 2, p.y() - 2 ),
2801 TQPoint( p.x() + 2, p.y() + 2 ) );
2803 rect.moveBy( deltaX, deltaY );
2806 new KDChartDataRegion(
2809 regions->append( datReg );
2811 painter->setPen( oldPen );
2814 case KDChartParams::LineMarkerCircle:
2816 const TQBrush oldBrush( painter->brush() );
2817 painter->setBrush( color );
2818 painter->drawEllipse( p.x() - xsize2, p.y() - ysize2, xsize, ysize );
2820 TQPointArray points;
2821 points.makeEllipse( p.x() - xsize2, p.y() - ysize2, xsize, ysize );
2823 points.translate( deltaX, deltaY );
2824 if( points.size() > 0 ){
2825 datReg = new KDChartDataRegion(
2828 regions->append( datReg );
2831 painter->setBrush( oldBrush );
2838void KDChartPainter::drawExtraLinesAndMarkers(
2840 const TQPen& defaultPen,
2847 const double areaWidthP1000,
2848 const double areaHeightP1000,
2856 uint extraLinesAlign = 0;
2857 if( propSet.hasOwnExtraLinesAlign( iDummy, extraLinesAlign )
2858 && ( extraLinesAlign
2859 & ( TQt::AlignLeft | TQt::AlignRight | TQt::AlignHCenter |
2860 TQt::AlignTop | TQt::AlignBottom | TQt::AlignVCenter ) ) ){
2861 bool extraLinesInFront = false;
2862 propSet.hasOwnExtraLinesInFront( iDummy, extraLinesInFront );
2863 if( bDrawInFront == extraLinesInFront ){
2864 const double areaSizeP1000 = TQMIN(areaWidthP1000, areaHeightP1000);
2865 int extraLinesLength = -20;
2866 int extraLinesWidth = defaultPen.width();
2867 TQColor extraLinesColor = defaultPen.color();
2868 TQt::PenStyle extraLinesStyle = defaultPen.style();
2869 uint extraMarkersAlign = 0;
2870 propSet.hasOwnExtraLinesLength( iDummy, extraLinesLength );
2871 propSet.hasOwnExtraLinesWidth( iDummy, extraLinesWidth );
2872 propSet.hasOwnExtraLinesColor( iDummy, extraLinesColor );
2873 propSet.hasOwnExtraLinesStyle( iDummy, extraLinesStyle );
2874 const int horiLenP2 = (0 > extraLinesLength)
2875 ? static_cast<int>(areaWidthP1000 * extraLinesLength) / 2
2876 : extraLinesLength / 2;
2877 const int vertLenP2 = (0 > extraLinesLength)
2878 ? static_cast<int>(areaHeightP1000 * extraLinesLength) / 2
2879 : extraLinesLength / 2;
2881 TQPoint pL( (TQt::AlignLeft == (extraLinesAlign & TQt::AlignLeft))
2883 : (TQt::AlignHCenter == (extraLinesAlign & TQt::AlignHCenter))
2884 ? myPointX - horiLenP2
2887 TQPoint pR( (TQt::AlignRight == (extraLinesAlign & TQt::AlignRight))
2889 : (TQt::AlignHCenter == (extraLinesAlign & TQt::AlignHCenter))
2890 ? myPointX + horiLenP2
2893 TQPoint pT( myPointX,
2894 (TQt::AlignTop == (extraLinesAlign & TQt::AlignTop))
2896 : (TQt::AlignVCenter == (extraLinesAlign & TQt::AlignVCenter))
2897 ? myPointY - vertLenP2
2899 TQPoint pB( myPointX,
2900 (TQt::AlignBottom == (extraLinesAlign & TQt::AlignBottom))
2902 : (TQt::AlignVCenter == (extraLinesAlign & TQt::AlignVCenter))
2903 ? myPointY + vertLenP2
2905 const TQPen extraPen( extraLinesColor,
2907 ? static_cast < int > ( areaSizeP1000 * -extraLinesWidth )
2910 const TQPen oldPen( painter->pen() );
2911 painter->setPen( extraPen );
2912 if( extraLinesAlign & ( TQt::AlignLeft | TQt::AlignRight | TQt::AlignHCenter ) )
2913 painter->drawLine( pL, pR );
2914 if( extraLinesAlign & ( TQt::AlignTop | TQt::AlignBottom | TQt::AlignVCenter ) )
2915 painter->drawLine( pT, pB );
2916 painter->setPen( oldPen );
2918 propSet.hasOwnExtraMarkersAlign( iDummy, extraMarkersAlign );
2919 if( extraMarkersAlign
2920 & ( TQt::AlignLeft | TQt::AlignRight |
2921 TQt::AlignTop | TQt::AlignBottom ) ){
2923 TQColor extraMarkersColor = extraLinesColor;
2924 int extraMarkersStyle = defaultMarkerStyle;
2925 propSet.hasOwnExtraMarkersSize( iDummy, extraMarkersSize );
2926 propSet.hasOwnExtraMarkersColor( iDummy, extraMarkersColor );
2927 propSet.hasOwnExtraMarkersStyle( iDummy, extraMarkersStyle );
2929 int w = extraMarkersSize.width();
2930 int h = extraMarkersSize.height();
2932 w = static_cast < int > (w * -areaSizeP1000);
2934 h = static_cast < int > (h * -areaSizeP1000);
2935 if( extraMarkersAlign & TQt::AlignLeft )
2938 _areaWidthP1000, _areaHeightP1000,
2939 _dataRect.x(), _dataRect.y(),
2946 if( extraMarkersAlign & TQt::AlignRight )
2949 _areaWidthP1000, _areaHeightP1000,
2950 _dataRect.x(), _dataRect.y(),
2957 if( extraMarkersAlign & TQt::AlignTop )
2960 _areaWidthP1000, _areaHeightP1000,
2961 _dataRect.x(), _dataRect.y(),
2968 if( extraMarkersAlign & TQt::AlignBottom )
2971 _areaWidthP1000, _areaHeightP1000,
2972 _dataRect.x(), _dataRect.y(),
#define KDCHART_AXIS_LABELS_AUTO_DATETIME_FORMAT Use this to specify that date/time format to be used for displaying the axis labels is to be determin...
Definition of a class for specifying and drawing custom boxes.
Definition of global enums.
Header for all common chart parameters.
#define KDCHART_MAX_AXES Charts have up to 12 axes: up to two axes on both sides for X, Y and Z (if data is 3-dimensional).
Provides a table class holding all data values that are to be used in a chart.
#define KDCHART_NEG_INFINITE Use special value KDCHART_NEG_INFINITE to indicate negative infinite values.
#define KDCHART_POS_INFINITE Use special value KDCHART_POS_INFINITE to indicate positive infinite values.
Definition of a single entry-point to the charting engine for applications that wish to provide their...
Implements a chart painter that draws area charts.
access the chart axis parameters.
int axisAreaMax() const Returns the axis area maximum width (or height, resp.).
TQRect axisTrueAreaRect() const Returns the true axis area rectangle as calculated and drawn.
AxisAreaMode axisAreaMode() const Returns the axis size mode configured in this params object.
static AxisPos basicAxisPos(uint pos) enum KDChartAxisParams::AxisPos { AxisPosSTART = 0,
TQFont axisLabelsFont() const Returns the axis labels font.
int axisLabelsFontRelSize() const Returns the axis labels relative font size.
TQString axisLabelsDateTimeFormat() const Returns the format to be used for displaying abscissa axis TQDateTime item labels.
bool axisLabelsFontUseRelSize() const Returns whether the fix axis font size is used.
AxisType axisType() const
int axisUseAvailableSpaceFrom() const Returns the beginning offset of the space used by this axis in comparison to the available space that...
bool axisVisible() const Returns weither the axis will be drawn or not.
int axisUseAvailableSpaceTo() const Returns the ending offset of the space used by this axis in comparison to the available space that co...
int axisAreaMin() const Returns the axis area minimum width (or height, resp.).
bool axisLabelsVisible() const Returns whether the axis labels should be drawn.
A chart painter implementation that can paint Box&Whisker charts.
A chart painter implementation that can paint bar charts.
Class for specifying and drawing custom boxes.
KDChartEnums::PositionFlag anchorPosition() const Returns the anchor position.
uint dataCol() const Returns the column number of the KDChart data region that is to be used as anchor area.
virtual void paint(TQPainter *painter, TQPoint anchor, double areaWidthP1000, double areaHeightP1000, const KDFrame *frame=0, const TQRect &frameRect=TQRect(), const TQColor *color=0, const TQBrush *paper=0) const Paints the box.
void setInternalFlagAnchorBeingCalculated(bool flag) const Internal routine for recursion handling.
uint dataRow() const Returns the row number of the KDChart data region that is to be used as anchor area.
uint data3rd() const Returns the third dimensions number of the KDChart data region that is to be used as anchor area.
uint anchorArea() const Returns the area to which the box is to be aligned.
TQRect trueRect(TQPainter *painter, TQPoint anchor, double areaWidthP1000, double areaHeightP1000) const Return the actual rectangle which to draw box into.
bool anchorBeingCalculated() const Internal routine for recursion handling.
The collection class used by KD Chart to store data region information.
static TQPoint positionFlagToPoint(const TQRect &rect, PositionFlag pos) Returns the point representing a position of a rectangle.
PositionFlag The general position flag to specify a point of an area, for example this could be the anchor point w...
A chart painter implementation that can paint HiLo charts.
A chart painter implementation that can paint line charts.
virtual void paintAxes(TQPainter *painter, KDChartTableDataBase *data) Paints the axes for the chart.
virtual ~KDChartPainter() Destructor.
virtual void setupGeometry(TQPainter *painter, KDChartTableDataBase *data, const TQRect &rect) This method will be called whenever any parameters that affect geometry have been changed.
virtual void paintHeaderFooter(TQPainter *painter, KDChartTableDataBase *data) Paints the header and footers for the chart.
virtual void paintAreaWithGap(TQPainter *painter, TQRect rect, const KDChartParams::KDChartFrameSettings &settings) Paints an area frame.
static void drawMarker(TQPainter *painter, int style, const TQColor &color, const TQPoint &p, const TQSize &size, uint align=TQt::AlignCenter) Draws the marker for one data point according to the specified style, color, size.
virtual TQString fallbackLegendText(uint dataset) const This method provides a fallback legend text for the specified dataset, if there was no other way to d...
virtual TQRect calculateAreaRect(bool &allCustomBoxes, uint area, uint dataRow, uint dataCol, uint data3rd, KDChartDataRegionList *regions) const Calculated the rectangle covered by an area.
KDChartPainter(KDChartParams *) Constructor.
virtual void paintArea(TQPainter *painter, uint area, KDChartDataRegionList *regions=0, uint dataRow=0, uint dataCol=0, uint data3rd=0) Paints an area frame.
virtual void paintCustomBoxes(TQPainter *painter, KDChartDataRegionList *regions) Paints all custom boxes.
virtual void paintDataValues(TQPainter *painter, KDChartTableDataBase *data, KDChartDataRegionList *regions) Paints the data value texts near the data representations.
virtual TQPoint calculateAnchor(const KDChartCustomBox &box, KDChartDataRegionList *regions=0) const Calculated the top left corner of a custom box.
virtual void paintLegend(TQPainter *painter, KDChartTableDataBase *data) Paints the legend for the chart.
virtual uint numLegendFallbackTexts(KDChartTableDataBase *data) const This methods returns the number of elements to be shown in the legend in case fallback texts are used...
virtual void paint(TQPainter *painter, KDChartTableDataBase *data, bool paintFirst, bool paintLast, KDChartDataRegionList *regions=0, const TQRect *rect=0, bool mustCalculateGeometry=true) Paints the chart for which this chart painter is configured on a TQPainter.
static KDChartPainter * create(KDChartParams *params, bool make2nd=false) Creates an object of a concrete subclass of KDChartPainter that KDChart::paint() (and consequently,...
static void unregisterPainter(const TQString &painterName) Unregisters a user-defined painter implementation.
static void registerPainter(const TQString &painterName, KDChartPainter *painter) Registers a user-defined painter implementation which is identified by a string.
Stores the frame settings for one of the chart areas:
int innerGapX() const Return the X-distance between the frame and the inner area.
const KDFrame & frame() const Return the KDFrame object used for drawing this areas frame.
int innerGapY() const Return the Y-distance between the frame and the inner area.
Bundles the display parameters of a chart.
TQSize lineMarkerSize() const Returns the sizes of line markers.
void setAxisArea(const uint n, const TQRect &areaRect) Specifies the true axis area rectangle.
const KDChartFrameSettings * frameSettings(uint area, bool &bFound, int *pIterIdx=0) const Return the frame settings of one of the chart areas.
const KDChartFrameSettings * nextFrameSettings(bool &bFound, int *pIterIdx) const Return the next frame settings specified for the same area type as the frame that was retrieved by pr...
LineMarkerStyle The available line marker styles.
TQString legendText(uint dataset) const Returns the manually specified legend text for a given dataset.
const KDChartAxisParams & axisParams(uint n) const Returns the parameters that are currently defined for axis n.
A chart painter implementation that can paint pie charts.
A chart painter implementation that can paint polar charts.
Property settings of a single KDChart data cell.
A chart painter implementation that can paint pie charts.
KD Chart's build-in table data for an easy way of storing data values.
virtual uint usedCols() const Returns the number of cols in the table that actually contain data.
virtual bool cellCoord(uint _row, uint _col, TQVariant &_value, int coordinate=1) const =0 Returns one of the coordinate data value(s) stored in a cell.
virtual uint usedRows() const Returns the number of rows in the table that actually contain data.
static bool painterToDrawRect(TQPainter *painter, TQRect &drawRect) Calculates the drawing area from a given TQPainter.
virtual void paint(TQPainter *painter, KDFramePaintSteps steps=PaintAll, TQRect innerRect=TQRect(0, 0, 0, 0)) const Paint methode actually drawing the frame.
|