00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include <KDChartParams.h>
00030 #include <KDChartAxisParams.h>
00031 #include <KDChartEnums.h>
00032 #include <KDFrame.h>
00033 #include <KDChartCustomBox.h>
00034 #include <KDChartTextPiece.h>
00035 #include <KDXMLTools.h>
00036 #ifndef KDCHART_MASTER_CVS
00037 #include "KDChartParams.moc"
00038 #endif
00039
00040 class KDChartData;
00041
00042
00043
00055
00056
00057 KDChartAutoColor* KDChartAutoColor::mInstance = NULL;
00058
00059 KDChartAutoColor::KDChartAutoColor()
00060 {
00061 }
00062
00063 KDChartAutoColor::KDChartAutoColor( KDChartAutoColor const& )
00064 {
00065 }
00066
00067 KDChartAutoColor::~KDChartAutoColor()
00068 {
00069 }
00070
00071 const KDChartAutoColor* KDChartAutoColor::instance()
00072 {
00073 if( mInstance == 0 )
00074 mInstance = new KDChartAutoColor();
00075 return mInstance;
00076 }
00077
00078 void KDChartAutoColor::freeInstance()
00079 {
00080 if( mInstance )
00081 delete mInstance;
00082 mInstance = 0;
00083 }
00084
00085
00086
00087
00088
00089
00090
00094 KDChartParams::KDChartParams()
00095 {
00096 tempPropSetA = new KDChartPropertySet();
00097 tempPropSetB = new KDChartPropertySet();
00098
00099
00100
00101
00102 _maxDatasetColor = 1;
00103 _maxDatasetSourceMode = 0;
00104 _setChartSourceModeWasUsed = false;
00105
00106 _customBoxDictMayContainHoles = false;
00107
00108
00109
00110
00111 setPrintDataValuesWithDefaultFontParams( KDCHART_ALL_CHARTS, false );
00112 _printDataValuesSettings._dataValuesShowInfinite = true;
00113 _printDataValuesSettings2._dataValuesShowInfinite = true;
00114
00115 setAllowOverlappingDataValueTexts( false );
00116
00117 #if COMPAT_QT_VERSION >= 0x030100
00118 setOptimizeOutputForScreen( false );
00119 #else
00120 setOptimizeOutputForScreen( true );
00121 #endif
00122
00123 setGlobalLeading( 0,0,0,0 );
00124
00125
00126
00127 setChartType( Bar );
00128
00129
00130 setAdditionalChartType( NoType );
00131
00132
00133 setNumValues( static_cast<unsigned int>( -1 ) );
00134
00135 _defaultFont = QFont( "helvetica", 8, QFont::Normal, false );
00136
00137
00138 _noFrame.clearAll();
00139
00140
00141
00142
00143
00144
00145 setShadowBrightnessFactor( 1.0 );
00146
00147
00148 setShadowPattern( Qt::SolidPattern );
00149
00150
00151 setDataDefaultColors();
00152
00153
00154 setOutlineDataColor( black );
00155
00156
00157 setOutlineDataLineWidth( 1 );
00158
00159
00160 setOutlineDataLineStyle( Qt::SolidLine );
00161
00162
00163
00164
00165 setDataArea( QRect( QPoint(0,0), QSize(0,0)) );
00166 setLegendArea(QRect( QPoint(0,0), QSize(0,0)) );
00167
00168
00169
00170
00171
00172 setBarChartSubType( BarNormal );
00173
00174
00175 setThreeDBars( false );
00176
00177
00178 setThreeDBarsShadowColors( true );
00179
00180
00181 setThreeDBarAngle( 45 );
00182
00183
00184 setThreeDBarDepth( 1.0 );
00185
00186
00187 setDatasetGap( 6 );
00188 setDatasetGapIsRelative( true );
00189
00190
00191 setValueBlockGap( 24 );
00192 setValueBlockGapIsRelative( true );
00193
00194
00195 setBarWidth( KDCHART_AUTO_SIZE );
00196
00197
00198
00199 setBarsDisplayed( 0 );
00200 setBarsLeft( 0 );
00201
00202
00203 setDrawSolidExcessArrows( false );
00204
00205
00206
00207
00208
00209
00210 setLineChartSubType( LineNormal );
00211
00212
00213 setLineMarker( false );
00214
00215
00216 setLineWidth( 1 );
00217
00218
00219 setLineStyle( Qt::SolidLine );
00220
00221
00222
00223 setLineColor();
00224
00225
00226
00227 _maxDatasetLineMarkerStyle = 0;
00228 setLineMarkerStyle( 0, LineMarkerCircle );
00229 setLineMarkerStyle( 1, LineMarkerSquare );
00230 setLineMarkerStyle( 2, LineMarkerDiamond );
00231 setLineMarkerSize( QSize( 6, 6 ) );
00232
00233
00234 setThreeDLines( false );
00235 setThreeDLineDepth( 10 );
00236
00237
00238
00239
00240 setThreeDLineXRotation( 15 );
00241 setThreeDLineYRotation( 15 );
00242
00243
00244 setAreaChartSubType( AreaNormal );
00245
00246
00247 setAreaLocation( AreaBelow );
00248
00249
00250
00251
00252
00253 setPolarChartSubType( PolarNormal );
00254
00255
00256 setPolarMarker( true );
00257
00258
00259 setPolarZeroDegreePos( 0 );
00260
00261
00262
00263 setPolarLineWidth( -3 );
00264
00265
00266 _maxDatasetPolarMarkerStyle = 0;
00267 setPolarMarkerStyle( 0, PolarMarkerCircle );
00268 setPolarMarkerStyle( 1, PolarMarkerSquare );
00269 setPolarMarkerStyle( 2, PolarMarkerDiamond );
00270 setPolarMarkerSize( QSize( -40,-40 ) );
00271
00272
00273 setPolarRotateCircularLabels( false );
00274 setPolarDelimsAndLabelsAtPos( KDChartEnums::PosTopLeft, false, false );
00275 setPolarDelimsAndLabelsAtPos( KDChartEnums::PosTopCenter, true, true );
00276 setPolarDelimsAndLabelsAtPos( KDChartEnums::PosTopRight, false, false );
00277
00278 setPolarDelimsAndLabelsAtPos( KDChartEnums::PosCenterLeft, false, false );
00279 setPolarDelimsAndLabelsAtPos( KDChartEnums::PosCenterRight, false, false );
00280
00281 setPolarDelimsAndLabelsAtPos( KDChartEnums::PosBottomLeft, false, false );
00282 setPolarDelimsAndLabelsAtPos( KDChartEnums::PosBottomCenter, true, true );
00283 setPolarDelimsAndLabelsAtPos( KDChartEnums::PosBottomRight, false, false );
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302 setExplode( false );
00303
00304 setExplodeFactor( 0.1 );
00305
00306
00307
00308 setThreeDPies( false );
00309
00310 setThreeDPieHeight( 20 );
00311
00312 setPieStart( 0 );
00313
00314 setRingStart( 0 );
00315
00316 setRelativeRingThickness( false );
00317
00318
00319
00320
00321
00322 setHiLoChartSubType( KDChartParams::HiLoSimple );
00323 setHiLoChartPrintLowValues( false );
00324 setHiLoChartPrintHighValues( false );
00325 setHiLoChartPrintOpenValues( false );
00326 setHiLoChartPrintCloseValues( false );
00327
00328
00329
00330
00331 setBWChartSubType( KDChartParams::BWSimple );
00332 setBWChartFences(1.5, 1.5, 3.0, 3.0);
00333 setBWChartOutValMarkerSize( -25 );
00334 setBWChartPrintStatistics( BWStatValALL, false );
00335 setBWChartBrush( Qt::white );
00336
00337
00338
00339 setLegendSpacing( 20 );
00340
00341 setLegendPosition( LegendRight );
00342
00343 setLegendOrientation( Qt::Vertical );
00344
00345
00346 setLegendShowLines( false );
00347
00348 setLegendSource( LegendAutomatic );
00349
00350 setLegendTextColor( Qt::black );
00351
00352 setLegendFont( QFont( "helvetica", 10, QFont::Normal, false ), false );
00353
00354
00355
00356 setLegendFontRelSize( 40 );
00357
00358 setLegendTitleText( tr( "Legend" ) );
00359
00360 setLegendTitleTextColor( Qt::black );
00361
00362
00363 setLegendTitleFont( QFont( "helvetica", 12, QFont::Normal, false ), false );
00364
00365
00366
00367 setLegendTitleFontRelSize( 50 );
00368
00369
00370
00371
00372
00373 setDefaultAxesTypes();
00374
00375 activateDefaultAxes();
00376
00377
00378
00379
00380
00381
00382
00383
00384 QFont defaultHdFtFont( "helvetica", 14, QFont::Normal, false );
00385 int relHd0Size = 15;
00386 int relHdSize = 22;
00387 int relHd2Size = 19;
00388
00389 int relFt0Size = 15;
00390 int relFtSize = 19;
00391 int relFt2Size = 12;
00392 setHeaderFooterFont( KDChartParams::HdFtPosHeader0,
00393 defaultHdFtFont, true, relHd0Size );
00394 setHeaderFooterFont( KDChartParams::HdFtPosHeader0L,
00395 defaultHdFtFont, true, relHd0Size );
00396 setHeaderFooterFont( KDChartParams::HdFtPosHeader0R,
00397 defaultHdFtFont, true, relHd0Size );
00398 setHeaderFooterFont( KDChartParams::HdFtPosHeader,
00399 defaultHdFtFont, true, relHdSize );
00400 setHeaderFooterFont( KDChartParams::HdFtPosHeaderL,
00401 defaultHdFtFont, true, relHdSize );
00402 setHeaderFooterFont( KDChartParams::HdFtPosHeaderR,
00403 defaultHdFtFont, true, relHdSize );
00404 setHeaderFooterFont( KDChartParams::HdFtPosHeader2,
00405 defaultHdFtFont, true, relHd2Size );
00406 setHeaderFooterFont( KDChartParams::HdFtPosHeader2L,
00407 defaultHdFtFont, true, relHd2Size );
00408 setHeaderFooterFont( KDChartParams::HdFtPosHeader2R,
00409 defaultHdFtFont, true, relHd2Size );
00410
00411 setHeaderFooterFont( KDChartParams::HdFtPosFooter0,
00412 defaultHdFtFont, true, relFt0Size );
00413 setHeaderFooterFont( KDChartParams::HdFtPosFooter0L,
00414 defaultHdFtFont, true, relFt0Size );
00415 setHeaderFooterFont( KDChartParams::HdFtPosFooter0R,
00416 defaultHdFtFont, true, relFt0Size );
00417 setHeaderFooterFont( KDChartParams::HdFtPosFooter,
00418 defaultHdFtFont, true, relFtSize );
00419 setHeaderFooterFont( KDChartParams::HdFtPosFooterL,
00420 defaultHdFtFont, true, relFtSize );
00421 setHeaderFooterFont( KDChartParams::HdFtPosFooterR,
00422 defaultHdFtFont, true, relFtSize );
00423 setHeaderFooterFont( KDChartParams::HdFtPosFooter2,
00424 defaultHdFtFont, true, relFt2Size );
00425 setHeaderFooterFont( KDChartParams::HdFtPosFooter2L,
00426 defaultHdFtFont, true, relFt2Size );
00427 setHeaderFooterFont( KDChartParams::HdFtPosFooter2R,
00428 defaultHdFtFont, true, relFt2Size );
00429
00430
00431
00432 tempPropSetA->fullReset("normal data");
00433 setProperties(KDCHART_PROPSET_NORMAL_DATA, *tempPropSetA);
00434
00435 tempPropSetA->setName("transparent data");
00436 tempPropSetA->setLineStyle( KDChartPropertySet::OwnID, Qt::NoPen );
00437 tempPropSetA->setShowMarker( KDChartPropertySet::OwnID, false );
00438 setProperties(KDCHART_PROPSET_TRANSPARENT_DATA, *tempPropSetA);
00439
00440 tempPropSetA->setName("horizontal line");
00441 tempPropSetA->setExtraLinesAlign( KDChartPropertySet::OwnID, Qt::AlignLeft | Qt::AlignRight );
00442 setProperties(KDCHART_PROPSET_HORI_LINE, *tempPropSetA);
00443
00444 tempPropSetA->setName("vertical line");
00445 tempPropSetA->setExtraLinesAlign( KDChartPropertySet::OwnID, Qt::AlignTop | Qt::AlignBottom );
00446 setProperties(KDCHART_PROPSET_VERT_LINE, *tempPropSetA);
00447
00448 }
00449
00450
00454 KDChartParams::~KDChartParams()
00455 {
00456 KDChartAutoColor::freeInstance();
00457 delete tempPropSetA;
00458 delete tempPropSetB;
00459 }
00460
00461
00462
00468
00469
00491 int KDChartParams::registerProperties( KDChartPropertySet& rSet )
00492 {
00493 _propertySetList.setAutoDelete( true );
00494 rSet.mOwnID = _propertySetList.count();
00495 _propertySetList.insert( rSet.mOwnID, rSet.clone() );
00496 return rSet.mOwnID;
00497 }
00498
00517 void KDChartParams::setProperties( int id, KDChartPropertySet& rSet )
00518 {
00519 _propertySetList.setAutoDelete( true );
00520 rSet.mOwnID = id;
00521 _propertySetList.replace( rSet.mOwnID, rSet.clone() );
00522 }
00523
00538 bool KDChartParams::removeProperties( int id )
00539 {
00540 _propertySetList.setAutoDelete( true );
00541
00542 if( KDCHART_PROPSET_NORMAL_DATA == id )
00543 return false;
00544 return _propertySetList.remove( id );
00545 }
00546
00547
00569 bool KDChartParams::properties( int id, KDChartPropertySet& rSet ) const
00570 {
00571 const KDChartPropertySet* R = _propertySetList.find( id );
00572 const bool bFound = (0 != R);
00573 if( bFound )
00574 rSet.deepCopy( R );
00575 return bFound;
00576 }
00577
00578
00601 KDChartPropertySet* KDChartParams::properties( int id )
00602 {
00603 return _propertySetList.find( id );
00604 }
00605
00606
00624 bool KDChartParams::calculateProperties( int startId, KDChartPropertySet& rSet ) const
00625 {
00626 KDChartPropertySet& startSet = *tempPropSetA;
00627 startSet.quickReset("");
00628
00629 rSet.deepCopy( &startSet );
00630
00631
00632
00633
00634
00635 bool bOk = properties(startId, startSet);
00636 if( bOk ){
00637 int lineWidth;
00638 QColor lineColor;
00639 Qt::PenStyle lineStyle;
00640 bool showMarker;
00641 uint markerAlign;
00642 QSize markerSize;
00643 QColor markerColor;
00644 int markerStyle;
00645 uint extraLinesAlign;
00646 bool extraLinesInFront;
00647 int extraLinesLength;
00648 int extraLinesWidth;
00649 QColor extraLinesColor;
00650 Qt::PenStyle extraLinesStyle;
00651 uint extraMarkersAlign;
00652 QSize extraMarkersSize;
00653 QColor extraMarkersColor;
00654 int extraMarkersStyle;
00655 bool showBar;
00656 QColor barColor;
00657 QBrush areaBrush;
00658
00659 KDChartPropertySet& propSet = *tempPropSetB;
00660 propSet.quickReset("");
00661
00662
00663
00664 const int maxDepth = 1000;
00665 int i;
00666 int id;
00667
00668 propSet.deepCopy( &startSet ); i=0;
00669 do{
00670 if( propSet.hasOwnLineWidth( id, lineWidth ) ){
00671 rSet.setLineWidth( KDChartPropertySet::OwnID, lineWidth );
00672 break;
00673 }else if( KDChartPropertySet::UndefinedID == id || maxDepth < i )
00674 break;
00675 ++i;
00676 }while( properties(id, propSet) );
00677
00678 propSet.deepCopy( &startSet ); i=0;
00679 do{
00680 if( propSet.hasOwnLineColor( id, lineColor ) ){
00681 rSet.setLineColor( KDChartPropertySet::OwnID, lineColor );
00682 break;
00683 }else if( KDChartPropertySet::UndefinedID == id || maxDepth < i )
00684 break;
00685 ++i;
00686 }while( properties(id, propSet) );
00687
00688 propSet.deepCopy( &startSet ); i=0;
00689 do{
00690 if( propSet.hasOwnLineStyle( id, lineStyle ) ){
00691 rSet.setLineStyle( KDChartPropertySet::OwnID, lineStyle );
00692 break;
00693 }else if( KDChartPropertySet::UndefinedID == id || maxDepth < i )
00694 break;
00695 ++i;
00696 }while( properties(id, propSet) );
00697
00698
00699
00700
00701 propSet.deepCopy( &startSet ); i=0;
00702 do{
00703 if( propSet.hasOwnShowMarker( id, showMarker ) ){
00704 rSet.setShowMarker( KDChartPropertySet::OwnID, showMarker );
00705 break;
00706 }else if( KDChartPropertySet::UndefinedID == id || maxDepth < i )
00707 break;
00708 ++i;
00709 }while( properties(id, propSet) );
00710
00711 propSet.deepCopy( &startSet ); i=0;
00712 do{
00713 if( propSet.hasOwnMarkerAlign( id, markerAlign ) ){
00714 rSet.setMarkerAlign( KDChartPropertySet::OwnID, markerAlign );
00715 break;
00716 }else if( KDChartPropertySet::UndefinedID == id || maxDepth < i )
00717 break;
00718 ++i;
00719 }while( properties(id, propSet) );
00720
00721 propSet.deepCopy( &startSet ); i=0;
00722 do{
00723 if( propSet.hasOwnMarkerSize( id, markerSize ) ){
00724 rSet.setMarkerSize( KDChartPropertySet::OwnID, markerSize );
00725 break;
00726 }else if( KDChartPropertySet::UndefinedID == id || maxDepth < i )
00727 break;
00728 ++i;
00729 }while( properties(id, propSet) );
00730
00731 propSet.deepCopy( &startSet ); i=0;
00732 do{
00733 if( propSet.hasOwnMarkerColor( id, markerColor ) ){
00734 rSet.setMarkerColor( KDChartPropertySet::OwnID, markerColor );
00735 break;
00736 }else if( KDChartPropertySet::UndefinedID == id || maxDepth < i )
00737 break;
00738 ++i;
00739 }while( properties(id, propSet) );
00740
00741 propSet.deepCopy( &startSet ); i=0;
00742 do{
00743 if( propSet.hasOwnMarkerStyle( id, markerStyle ) ){
00744 rSet.setMarkerStyle( KDChartPropertySet::OwnID, markerStyle );
00745 break;
00746 }else if( KDChartPropertySet::UndefinedID == id || maxDepth < i )
00747 break;
00748 ++i;
00749 }while( properties(id, propSet) );
00750
00751
00752
00753
00754 propSet.deepCopy( &startSet ); i=0;
00755 do{
00756 if( propSet.hasOwnExtraLinesAlign( id, extraLinesAlign ) ){
00757 rSet.setExtraLinesAlign( KDChartPropertySet::OwnID, extraLinesAlign );
00758 break;
00759 }else if( KDChartPropertySet::UndefinedID == id || maxDepth < i )
00760 break;
00761 ++i;
00762 }while( properties(id, propSet) );
00763
00764 propSet.deepCopy( &startSet ); i=0;
00765 do{
00766 if( propSet.hasOwnExtraLinesInFront( id, extraLinesInFront ) ){
00767 rSet.setExtraLinesInFront( KDChartPropertySet::OwnID, extraLinesInFront );
00768 break;
00769 }else if( KDChartPropertySet::UndefinedID == id || maxDepth < i )
00770 break;
00771 ++i;
00772 }while( properties(id, propSet) );
00773
00774 propSet.deepCopy( &startSet ); i=0;
00775 do{
00776 if( propSet.hasOwnExtraLinesLength( id, extraLinesLength ) ){
00777 rSet.setExtraLinesLength( KDChartPropertySet::OwnID, extraLinesLength );
00778 break;
00779 }else if( KDChartPropertySet::UndefinedID == id || maxDepth < i )
00780 break;
00781 ++i;
00782 }while( properties(id, propSet) );
00783
00784 propSet.deepCopy( &startSet ); i=0;
00785 do{
00786 if( propSet.hasOwnExtraLinesWidth( id, extraLinesWidth ) ){
00787 rSet.setExtraLinesWidth( KDChartPropertySet::OwnID, extraLinesWidth );
00788 break;
00789 }else if( KDChartPropertySet::UndefinedID == id || maxDepth < i )
00790 break;
00791 ++i;
00792 }while( properties(id, propSet) );
00793
00794 propSet.deepCopy( &startSet ); i=0;
00795 do{
00796 if( propSet.hasOwnExtraLinesColor( id, extraLinesColor ) ){
00797 rSet.setExtraLinesColor( KDChartPropertySet::OwnID, extraLinesColor );
00798 break;
00799 }else if( KDChartPropertySet::UndefinedID == id || maxDepth < i )
00800 break;
00801 ++i;
00802 }while( properties(id, propSet) );
00803
00804 propSet.deepCopy( &startSet ); i=0;
00805 do{
00806 if( propSet.hasOwnExtraLinesStyle( id, extraLinesStyle ) ){
00807 rSet.setExtraLinesStyle( KDChartPropertySet::OwnID, extraLinesStyle );
00808 break;
00809 }else if( KDChartPropertySet::UndefinedID == id || maxDepth < i )
00810 break;
00811 ++i;
00812 }while( properties(id, propSet) );
00813
00814
00815
00816
00817 propSet.deepCopy( &startSet ); i=0;
00818 do{
00819 if( propSet.hasOwnExtraMarkersAlign( id, extraMarkersAlign ) ){
00820 rSet.setExtraMarkersAlign( KDChartPropertySet::OwnID, extraMarkersAlign );
00821 break;
00822 }else if( KDChartPropertySet::UndefinedID == id || maxDepth < i )
00823 break;
00824 ++i;
00825 }while( properties(id, propSet) );
00826
00827 propSet.deepCopy( &startSet ); i=0;
00828 do{
00829 if( propSet.hasOwnExtraMarkersSize( id, extraMarkersSize ) ){
00830 rSet.setExtraMarkersSize( KDChartPropertySet::OwnID, extraMarkersSize );
00831 break;
00832 }else if( KDChartPropertySet::UndefinedID == id || maxDepth < i )
00833 break;
00834 ++i;
00835 }while( properties(id, propSet) );
00836
00837 propSet.deepCopy( &startSet ); i=0;
00838 do{
00839 if( propSet.hasOwnExtraMarkersColor( id, extraMarkersColor ) ){
00840 rSet.setExtraMarkersColor( KDChartPropertySet::OwnID, extraMarkersColor );
00841 break;
00842 }else if( KDChartPropertySet::UndefinedID == id || maxDepth < i )
00843 break;
00844 ++i;
00845 }while( properties(id, propSet) );
00846
00847 propSet.deepCopy( &startSet ); i=0;
00848 do{
00849 if( propSet.hasOwnExtraMarkersStyle( id, extraMarkersStyle ) ){
00850 rSet.setExtraMarkersStyle( KDChartPropertySet::OwnID, extraMarkersStyle );
00851 break;
00852 }else if( KDChartPropertySet::UndefinedID == id || maxDepth < i )
00853 break;
00854 ++i;
00855 }while( properties(id, propSet) );
00856
00857
00858 propSet.deepCopy( &startSet ); i=0;
00859 do{
00860 if( propSet.hasOwnShowBar( id, showBar ) ){
00861 rSet.setShowBar( KDChartPropertySet::OwnID, showBar );
00862 break;
00863 }else if( KDChartPropertySet::UndefinedID == id || maxDepth < i )
00864 break;
00865 ++i;
00866 }while( properties(id, propSet) );
00867
00868 propSet.deepCopy( &startSet ); i=0;
00869 do{
00870 if( propSet.hasOwnBarColor( id, barColor ) ){
00871 rSet.setBarColor( KDChartPropertySet::OwnID, barColor );
00872 break;
00873 }else if( KDChartPropertySet::UndefinedID == id || maxDepth < i )
00874 break;
00875 ++i;
00876 }while( properties(id, propSet) );
00877
00878
00879 propSet.deepCopy( &startSet ); i=0;
00880 do{
00881 if( propSet.hasOwnAreaBrush( id, areaBrush ) ){
00882 rSet.setAreaBrush( KDChartPropertySet::OwnID, areaBrush );
00883 break;
00884 }else if( KDChartPropertySet::UndefinedID == id || maxDepth < i )
00885 break;
00886 ++i;
00887 }while( properties(id, propSet) );
00888
00889 }
00890 return bOk;
00891 }
00892
00893
01063 void KDChartParams::setPrintDataValues( bool active,
01064 uint chart,
01065 int divPow10,
01066 int digitsBehindComma,
01067 QFont* font,
01068 uint size,
01069 const QColor* color,
01070 KDChartEnums::PositionFlag negativePosition,
01071 uint negativeAlign,
01072 int negativeDeltaX,
01073 int negativeDeltaY,
01074 int negativeRotation,
01075 KDChartEnums::PositionFlag positivePosition,
01076 uint positiveAlign,
01077 int positiveDeltaX,
01078 int positiveDeltaY,
01079 int positiveRotation,
01080 KDChartEnums::TextLayoutPolicy policy )
01081 {
01082 uint count = (KDCHART_ALL_CHARTS == chart) ? 2 : 1;
01083 PrintDataValuesSettings * settings = (( 1 < count ) || ( 0 == chart ))
01084 ? &_printDataValuesSettings
01085 : &_printDataValuesSettings2;
01086 for ( uint i = 0; i < count; ++i ) {
01087 settings->_printDataValues = active;
01088 settings->_divPow10 = divPow10;
01089 settings->_digitsBehindComma = digitsBehindComma;
01090
01091 const ChartType cType
01092 = ( ( 1 < count && i )
01093 || ( 1 == count && 0 < chart && chart < 1000 ) )
01094 ? additionalChartType()
01095 : chartType();
01096
01097 bool finished( false );
01098 if ( UINT_MAX == size ) {
01099 finished = true;
01100 switch ( cType ) {
01101 case NoType:
01102 case Bar: {
01103 if ( font )
01104 settings->_dataValuesFont = *font;
01105 else
01106 settings->_dataValuesFont = QFont( "times", 1, QFont::Bold );
01107 settings->_dataValuesUseFontRelSize = true;
01108 settings->_dataValuesFontRelSize = 16;
01109 settings->_dataValuesAutoColor = false;
01110 settings->_dataValuesColor = QColor( Qt::darkBlue );
01111 settings->_dataValuesBrush = QBrush( Qt::NoBrush );
01112
01113 settings->_dataValuesAnchorNegativePosition = KDChartEnums::PosBottomRight;
01114 settings->_dataValuesAnchorNegativeAlign = Qt::AlignBottom + Qt::AlignRight;
01115 settings->_dataValuesAnchorNegativeDeltaX = 20;
01116 settings->_dataValuesAnchorNegativeDeltaY = 55;
01117 settings->_dataValuesNegativeRotation = 300;
01118
01119 settings->_dataValuesAnchorPositivePosition = KDChartEnums::PosTopLeft;
01120 settings->_dataValuesAnchorPositiveAlign = Qt::AlignTop + Qt::AlignLeft;
01121 settings->_dataValuesAnchorPositiveDeltaX = - 20;
01122 settings->_dataValuesAnchorPositiveDeltaY = - 65;
01123 settings->_dataValuesPositiveRotation = 300;
01124
01125 settings->_dataValuesLayoutPolicy = KDChartEnums::LayoutPolicyRotate;
01126 }
01127 break;
01128 case Line: {
01129 if ( font )
01130 settings->_dataValuesFont = *font;
01131 else
01132 settings->_dataValuesFont = QFont( "times", 1, QFont::Normal );
01133 settings->_dataValuesUseFontRelSize = true;
01134 settings->_dataValuesFontRelSize = 16;
01135 settings->_dataValuesAutoColor = false;
01136 settings->_dataValuesColor = QColor( Qt::darkBlue );
01137 settings->_dataValuesBrush = QBrush( Qt::NoBrush );
01138
01139 settings->_dataValuesAnchorNegativePosition = KDChartEnums::PosBottomCenter;
01140 settings->_dataValuesAnchorNegativeAlign = Qt::AlignTop + Qt::AlignHCenter;
01141 settings->_dataValuesAnchorNegativeDeltaX = 0;
01142 settings->_dataValuesAnchorNegativeDeltaY = 0;
01143 settings->_dataValuesNegativeRotation = 0;
01144
01145 settings->_dataValuesAnchorPositivePosition = KDChartEnums::PosTopCenter;
01146 settings->_dataValuesAnchorPositiveAlign = Qt::AlignBottom + Qt::AlignHCenter;
01147 settings->_dataValuesAnchorPositiveDeltaX = 0;
01148 settings->_dataValuesAnchorPositiveDeltaY = 0;
01149 settings->_dataValuesPositiveRotation = 0;
01150
01151 settings->_dataValuesLayoutPolicy = KDChartEnums::LayoutPolicyRotate;
01152 }
01153 break;
01154 case Area: {
01155 if ( font )
01156 settings->_dataValuesFont = *font;
01157 else
01158 settings->_dataValuesFont = QFont( "times", 1, QFont::Bold );
01159 settings->_dataValuesUseFontRelSize = true;
01160 settings->_dataValuesFontRelSize = 21;
01161 settings->_dataValuesAutoColor = true;
01162 settings->_dataValuesColor = QColor( Qt::black );
01163 settings->_dataValuesBrush = QBrush( Qt::white );
01164
01165 bool bShowOutside = areaChartSubType() == AreaNormal;
01166
01167 settings->_dataValuesAnchorNegativePosition = KDChartEnums::PosBottomCenter;
01168 settings->_dataValuesAnchorNegativeAlign = Qt::AlignHCenter
01169 + (bShowOutside ? Qt::AlignTop : Qt::AlignBottom);
01170 settings->_dataValuesAnchorNegativeDeltaX = 0;
01171 settings->_dataValuesAnchorNegativeDeltaY = bShowOutside ? 20 : -35;
01172 settings->_dataValuesNegativeRotation = 0;
01173
01174 settings->_dataValuesAnchorPositivePosition = KDChartEnums::PosTopCenter;
01175 settings->_dataValuesAnchorPositiveAlign = Qt::AlignHCenter
01176 + (bShowOutside ? Qt::AlignBottom : Qt::AlignTop);
01177 settings->_dataValuesAnchorPositiveDeltaX = 0;
01178 settings->_dataValuesAnchorPositiveDeltaY = bShowOutside ? -20 : 35;
01179 settings->_dataValuesPositiveRotation = 0;
01180
01181 settings->_dataValuesLayoutPolicy = KDChartEnums::LayoutPolicyRotate;
01182 }
01183 break;
01184 case HiLo:
01185 case BoxWhisker:
01186
01187
01188
01189 break;
01190 case Pie: {
01191 if ( font )
01192 settings->_dataValuesFont = *font;
01193 else
01194 settings->_dataValuesFont = QFont( "times", 1, QFont::Bold );
01195 settings->_dataValuesUseFontRelSize = true;
01196 settings->_dataValuesFontRelSize = 25;
01197 settings->_dataValuesAutoColor = true;
01198 settings->_dataValuesColor = QColor( Qt::black );
01199 settings->_dataValuesBrush = QBrush( Qt::NoBrush );
01200
01201 settings->_dataValuesAnchorNegativePosition = KDChartEnums::PosTopCenter;
01202 settings->_dataValuesAnchorNegativeAlign = Qt::AlignTop + Qt::AlignHCenter;
01203 settings->_dataValuesAnchorNegativeDeltaX = 0;
01204 settings->_dataValuesAnchorNegativeDeltaY = 50;
01205 settings->_dataValuesNegativeRotation = KDCHART_TANGENTIAL_ROTATION;
01206
01207 settings->_dataValuesAnchorPositivePosition = KDChartEnums::PosTopCenter;
01208 settings->_dataValuesAnchorPositiveAlign = Qt::AlignTop + Qt::AlignHCenter;
01209 settings->_dataValuesAnchorPositiveDeltaX = 0;
01210 settings->_dataValuesAnchorPositiveDeltaY = 50;
01211 settings->_dataValuesPositiveRotation = KDCHART_TANGENTIAL_ROTATION;
01212
01213 settings->_dataValuesLayoutPolicy = KDChartEnums::LayoutPolicyRotate;
01214 }
01215 break;
01216 case Ring: {
01217 if ( font )
01218 settings->_dataValuesFont = *font;
01219 else
01220 settings->_dataValuesFont = QFont( "times", 1, QFont::Bold );
01221 settings->_dataValuesUseFontRelSize = true;
01222 settings->_dataValuesFontRelSize = 25;
01223 settings->_dataValuesAutoColor = true;
01224 settings->_dataValuesColor = QColor( Qt::black );
01225 settings->_dataValuesBrush = QBrush( Qt::NoBrush );
01226
01227 settings->_dataValuesAnchorNegativePosition = KDChartEnums::PosCenter;
01228 settings->_dataValuesAnchorNegativeAlign = Qt::AlignCenter;
01229 settings->_dataValuesAnchorNegativeDeltaX = 0;
01230 settings->_dataValuesAnchorNegativeDeltaY = 10;
01231 settings->_dataValuesNegativeRotation = KDCHART_TANGENTIAL_ROTATION;
01232
01233 settings->_dataValuesAnchorPositivePosition = KDChartEnums::PosCenter;
01234 settings->_dataValuesAnchorPositiveAlign = Qt::AlignCenter;
01235 settings->_dataValuesAnchorPositiveDeltaX = 0;
01236 settings->_dataValuesAnchorPositiveDeltaY = 10;
01237 settings->_dataValuesPositiveRotation = KDCHART_TANGENTIAL_ROTATION;
01238
01239 settings->_dataValuesLayoutPolicy = KDChartEnums::LayoutPolicyRotate;
01240 }
01241 break;
01242
01243 case Polar: {
01244 settings->_dataValuesFontRelSize = 18;
01245 if ( font )
01246 settings->_dataValuesFont = *font;
01247 else
01248 settings->_dataValuesFont = QFont( "times", 1, QFont::Bold );
01249 settings->_dataValuesUseFontRelSize = true;
01250 settings->_dataValuesFontRelSize = 26;
01251 settings->_dataValuesAutoColor = polarMarker();
01252 settings->_dataValuesColor = QColor( Qt::black );
01253 settings->_dataValuesBrush = QBrush( Qt::NoBrush );
01254
01255
01256 settings->_dataValuesAnchorNegativePosition = KDChartEnums::PosCenter;
01257 settings->_dataValuesAnchorNegativeAlign = Qt::AlignCenter;
01258 settings->_dataValuesAnchorNegativeDeltaX = 0;
01259 settings->_dataValuesAnchorNegativeDeltaY = 0;
01260 settings->_dataValuesNegativeRotation = 0;
01261
01262 settings->_dataValuesAnchorNegativePosition = KDChartEnums::PosCenter;
01263 settings->_dataValuesAnchorNegativeAlign = Qt::AlignCenter;
01264 settings->_dataValuesAnchorNegativeDeltaX = 0;
01265 settings->_dataValuesAnchorNegativeDeltaY = 0;
01266 settings->_dataValuesNegativeRotation = 0;
01267
01268
01269
01270
01271
01272 }
01273 break;
01274
01275 default: {
01276 qDebug( "IMPLEMENTATION ERROR: Unknown chartType in setPrintDataValues()" );
01277 finished = false;
01278 }
01279 }
01280 }
01281 if ( !finished ) {
01282 settings->_useDefaultFontParams = false;
01283
01284 if ( font )
01285 settings->_dataValuesFont = *font;
01286 else
01287 settings->_dataValuesFont = QFont( "times", 1, QFont::Bold );
01288
01289 uint theSize( UINT_MAX == size ? 14 : size );
01290 settings->_dataValuesUseFontRelSize = ( 0 < theSize );
01291 settings->_dataValuesFontRelSize = theSize;
01292 if ( KDCHART_DATA_VALUE_AUTO_COLOR == color
01293 && ( Polar != cType || polarMarker() ) ) {
01294 settings->_dataValuesAutoColor = true;
01295 settings->_dataValuesColor = QColor( Qt::black );
01296 }
01297 else {
01298 settings->_dataValuesAutoColor = false;
01299 if ( 0 == color )
01300 settings->_dataValuesColor
01301 = QColor( i ? Qt::darkBlue : Qt::black );
01302 else
01303 settings->_dataValuesColor = *color;
01304 }
01305 settings->_dataValuesBrush = Qt::NoBrush;
01306
01307 settings->_dataValuesAnchorNegativePosition = negativePosition;
01308 settings->_dataValuesAnchorNegativeAlign = negativeAlign;
01309 settings->_dataValuesAnchorNegativeDeltaX = negativeDeltaX;
01310 settings->_dataValuesAnchorNegativeDeltaY = negativeDeltaY;
01311 settings->_dataValuesNegativeRotation = negativeRotation;
01312
01313 settings->_dataValuesAnchorPositivePosition = positivePosition;
01314 settings->_dataValuesAnchorPositiveAlign = positiveAlign;
01315 settings->_dataValuesAnchorPositiveDeltaX = positiveDeltaX;
01316 settings->_dataValuesAnchorPositiveDeltaY = positiveDeltaY;
01317 settings->_dataValuesPositiveRotation = positiveRotation;
01318
01319 settings->_dataValuesLayoutPolicy = policy;
01320 }
01321 if ( 0 < chart )
01322 settings = &_printDataValuesSettings2;
01323 }
01324 emit changed();
01325 }
01326
01327
01440 void KDChartParams::setChartSourceMode( SourceMode mode,
01441 uint dataset,
01442 uint dataset2,
01443 uint chart )
01444 {
01445 if ( KDCHART_NO_DATASET != dataset
01446 && KDCHART_ALL_DATASETS != dataset
01447 && KDCHART_ALL_DATASETS != dataset2 ) {
01448 uint i;
01449 uint last = ( KDCHART_NO_DATASET == dataset2 ) ? dataset : dataset2;
01450 for ( i = dataset; i <= last; ++i )
01451 _dataSourceModeAndChart[ i ] = ModeAndChart( mode, chart );
01452 _maxDatasetSourceMode = QMAX( _maxDatasetSourceMode, --i );
01453 _setChartSourceModeWasUsed = true;
01454 } else if ( UnknownMode == mode && dataset == KDCHART_ALL_DATASETS ) {
01455 _dataSourceModeAndChart.clear();
01456 _setChartSourceModeWasUsed = false;
01457 }
01458
01459 emit changed();
01460 }
01461
01462
01494 KDChartParams::SourceMode KDChartParams::chartSourceMode( uint dataset,
01495 uint dataset2,
01496 uint* pChart ) const
01497 {
01498 uint chart = KDCHART_UNKNOWN_CHART;
01499 SourceMode mode = UnknownMode;
01500
01501 if ( _setChartSourceModeWasUsed ) {
01502 if ( dataset <= _maxDatasetSourceMode
01503 && ( KDCHART_NO_DATASET == dataset2
01504 || dataset2 <= _maxDatasetSourceMode ) ) {
01505
01506 uint a, b;
01507 if ( KDCHART_ALL_DATASETS == dataset ) {
01508 a = 0;
01509 b = UINT_MAX;
01510 } else {
01511 a = dataset;
01512 b = KDCHART_NO_DATASET == dataset2 ? a : dataset2;
01513 }
01514
01515 bool bStart = true;
01516 ModeAndChartMap::ConstIterator it;
01517 for( it = _dataSourceModeAndChart.find( a );
01518 ( it != _dataSourceModeAndChart.end() ) && ( it.key() <= b );
01519 ++it ){
01520 if ( bStart ) {
01521 mode = it.data().mode();
01522 chart = it.data().chart();
01523 bStart = false;
01524 } else {
01525 if ( mode != it.data().mode() )
01526 mode = UnknownMode;
01527 if ( chart != it.data().chart() )
01528 chart = KDCHART_UNKNOWN_CHART;
01529 }
01530 }
01531 }
01532 } else {
01533 mode = DataEntry;
01534 chart = 0;
01535 }
01536 if ( pChart )
01537 * pChart = chart;
01538 return mode;
01539 }
01540
01541
01570 bool KDChartParams::findDataset( SourceMode mode,
01571 uint& dataset,
01572 uint& dataset2,
01573 uint chart ) const
01574 {
01575 bool res = false;
01576 dataset = KDCHART_NO_DATASET;
01577 dataset2 = KDCHART_NO_DATASET;
01578 if ( _setChartSourceModeWasUsed ) {
01579 bool bStart = true;
01580 ModeAndChartMap::ConstIterator it;
01581 for ( it = _dataSourceModeAndChart.begin();
01582 it != _dataSourceModeAndChart.end(); ++it ) {
01583 if ( ( it.data().mode() == mode )
01584 && ( ( KDCHART_ALL_CHARTS == chart )
01585 || ( it.data().chart() == chart ) ) ) {
01586 if ( bStart ) {
01587 dataset = it.key();
01588 bStart = false;
01589 }
01590 dataset2 = it.key();
01591 res = true;
01592 } else if ( !bStart )
01593 return res;
01594 }
01595 } else if ( DataEntry == mode ) {
01596 dataset = KDCHART_ALL_DATASETS;
01597 dataset2 = KDCHART_ALL_DATASETS;
01598 res = true;
01599 }
01600 return res;
01601 }
01602
01603
01640 bool KDChartParams::findDatasets( SourceMode modeA,
01641 SourceMode modeB,
01642 uint& dataset,
01643 uint& dataset2,
01644 uint chart ) const
01645 {
01646 bool res = false;
01647 dataset = KDCHART_NO_DATASET;
01648 dataset2 = KDCHART_NO_DATASET;
01649 uint dsA1, dsA2, dsB1, dsB2;
01650 bool foundA = findDataset( modeA, dsA1, dsA2, chart );
01651 bool foundB = findDataset( modeB, dsB1, dsB2, chart );
01652 if( foundA || foundB ){
01653 if( dsA1 == KDCHART_ALL_DATASETS || dsB1 == KDCHART_ALL_DATASETS ){
01654 dataset = KDCHART_ALL_DATASETS;
01655 dataset2 = KDCHART_ALL_DATASETS;
01656 res = true;
01657 }else{
01658 if( foundA && foundB ){
01659 if( QMIN(dsA2, dsB2) + 1 == QMAX(dsA1, dsB1) ){
01660 dataset = QMIN(dsA1, dsB1);
01661 dataset2 = QMAX(dsA2, dsB2);
01662 res = true;
01663 }else{
01664 qDebug("ERROR in KDChartParams::findDatasets(): Datasets found are *not* a contiguous series.");
01665 }
01666 }else{
01667 dataset = foundA ? dsA1 : dsB1;
01668 dataset2 = foundA ? dsA2 : dsB2;
01669 res = true;
01670 }
01671 }
01672 }
01673 return res;
01674 }
01675
01676
01694 void KDChartParams::setDataColor( uint dataset, QColor color )
01695 {
01696 QColor shadow1;
01697 QColor shadow2;
01698 calculateShadowColors( color, shadow1, shadow2 );
01699 _dataColors[ dataset ] = color;
01700 _dataColorsShadow1[ dataset ] = shadow1;
01701 _dataColorsShadow2[ dataset ] = shadow2;
01702 _maxDatasetColor = QMAX( _maxDatasetColor, dataset );
01703
01704 emit changed();
01705 }
01706
01716 void KDChartParams::setDataDefaultColors()
01717 {
01718 setDataColor( 0, red );
01719 setDataColor( 1, green );
01720 setDataColor( 2, blue );
01721 setDataColor( 3, cyan );
01722 setDataColor( 4, magenta );
01723 setDataColor( 5, yellow );
01724 setDataColor( 6, darkRed );
01725 setDataColor( 7, darkGreen );
01726 setDataColor( 8, darkBlue );
01727 setDataColor( 9, darkCyan );
01728 setDataColor( 10, darkMagenta );
01729 setDataColor( 11, darkYellow );
01730 }
01731
01742 void KDChartParams::setDataRainbowColors()
01743 {
01744 setDataColor( 0, QColor(255, 0,196) );
01745 setDataColor( 1, QColor(255, 0, 96) );
01746 setDataColor( 2, QColor(255, 128,64) );
01747 setDataColor( 3, Qt::yellow );
01748 setDataColor( 4, Qt::green );
01749 setDataColor( 5, Qt::cyan );
01750 setDataColor( 6, QColor( 96, 96,255) );
01751 setDataColor( 7, QColor(160, 0,255) );
01752 for( int i=8; i<16; ++i )
01753 setDataColor( i, dataColor(i-8).light() );
01754 }
01755
01772 void KDChartParams::setDataSubduedColors( bool ordered )
01773 {
01774 static const int NUM_SUBDUEDCOLORS = 18;
01775 static const QColor SUBDUEDCOLORS[ NUM_SUBDUEDCOLORS ] = {
01776 QColor( 0xe0,0x7f,0x70 ),
01777 QColor( 0xe2,0xa5,0x6f ),
01778 QColor( 0xe0,0xc9,0x70 ),
01779 QColor( 0xd1,0xe0,0x70 ),
01780 QColor( 0xac,0xe0,0x70 ),
01781 QColor( 0x86,0xe0,0x70 ),
01782 QColor( 0x70,0xe0,0x7f ),
01783 QColor( 0x70,0xe0,0xa4 ),
01784 QColor( 0x70,0xe0,0xc9 ),
01785 QColor( 0x70,0xd1,0xe0 ),
01786 QColor( 0x70,0xac,0xe0 ),
01787 QColor( 0x70,0x86,0xe0 ),
01788 QColor( 0x7f,0x70,0xe0 ),
01789 QColor( 0xa4,0x70,0xe0 ),
01790 QColor( 0xc9,0x70,0xe0 ),
01791 QColor( 0xe0,0x70,0xd1 ),
01792 QColor( 0xe0,0x70,0xac ),
01793 QColor( 0xe0,0x70,0x86 ),
01794 };
01795 if( ordered )
01796 for(int i=0; i<NUM_SUBDUEDCOLORS; ++i)
01797 setDataColor( i, SUBDUEDCOLORS[i] );
01798 else{
01799 setDataColor( 0, SUBDUEDCOLORS[ 0] );
01800 setDataColor( 1, SUBDUEDCOLORS[ 5] );
01801 setDataColor( 2, SUBDUEDCOLORS[10] );
01802 setDataColor( 3, SUBDUEDCOLORS[15] );
01803 setDataColor( 4, SUBDUEDCOLORS[ 2] );
01804 setDataColor( 5, SUBDUEDCOLORS[ 7] );
01805 setDataColor( 6, SUBDUEDCOLORS[12] );
01806 setDataColor( 7, SUBDUEDCOLORS[17] );
01807 setDataColor( 8, SUBDUEDCOLORS[ 4] );
01808 setDataColor( 9, SUBDUEDCOLORS[ 9] );
01809 setDataColor(10, SUBDUEDCOLORS[14] );
01810 setDataColor(11, SUBDUEDCOLORS[ 1] );
01811 setDataColor(12, SUBDUEDCOLORS[ 6] );
01812 setDataColor(13, SUBDUEDCOLORS[11] );
01813 setDataColor(14, SUBDUEDCOLORS[16] );
01814 setDataColor(15, SUBDUEDCOLORS[ 3] );
01815 setDataColor(16, SUBDUEDCOLORS[ 8] );
01816 setDataColor(17, SUBDUEDCOLORS[13] );
01817 }
01818 }
01819
01820
01821 void KDChartParams::calculateShadowColors( QColor color,
01822 QColor& shadow1,
01823 QColor& shadow2 ) const
01824 {
01825 if ( !color.isValid() ) {
01826 shadow1 = QColor();
01827 shadow2 = QColor();
01828 } else {
01829 int hue, saturation, value;
01830 color.hsv( &hue, &saturation, &value );
01831 double v = value;
01832 v = v * 2.0 / 3.0 * shadowBrightnessFactor();
01833 if ( 255.0 < v )
01834 v = 255.0;
01835 else if ( 1.0 > v )
01836 v = 0.0;
01837 shadow1.setHsv( hue, saturation, static_cast < int > ( v ) );
01838 v = value;
01839 v = v / 3.0 * shadowBrightnessFactor();
01840 if ( 255.0 < v )
01841 v = 255.0;
01842 else if ( 1.0 > v )
01843 v = 0.0;
01844 shadow2.setHsv( hue, saturation, static_cast < int > ( v ) );
01845 }
01846 }
01847
01848
01860 QColor KDChartParams::dataColor( uint dataset ) const
01861 {
01862 uint index = dataset % (_maxDatasetColor+1);
01863 if( _dataColors.find( index ) != _dataColors.end() )
01864 return _dataColors[ index ];
01865 else
01866 return QColor();
01867 }
01868
01869
01870 QString KDChartParams::dataRegionFrameAreaName( uint dataRow,
01871 uint dataCol,
01872 uint data3rd )
01873 {
01874 return QString( "%1/%2/%3/%4" )
01875 .arg( KDChartEnums::AreaChartDataRegion, 5 )
01876 .arg( dataRow, 5 )
01877 .arg( dataCol, 5 )
01878 .arg( data3rd, 5 );
01879 }
01880
01881
01889 void KDChartParams::recomputeShadowColors()
01890 {
01891
01892
01893 for( QMap<uint,QColor>::Iterator it = _dataColors.begin();
01894 it != _dataColors.end(); ++it ) {
01895 setDataColor( it.key(), it.data() );
01896 }
01897 }
01898
01899
01900
01901
01915 QColor KDChartParams::dataShadow1Color( uint dataset ) const
01916 {
01917 uint index = dataset % _maxDatasetColor;
01918 if ( _threeDShadowColors )
01919 if( _dataColorsShadow1.find( index ) != _dataColorsShadow1.end() )
01920 return _dataColorsShadow1[ index ];
01921 else
01922 return QColor();
01923 else
01924 if( _dataColors.find( index ) != _dataColors.end() )
01925 return _dataColors[ index ];
01926 else
01927 return QColor();
01928 }
01929
01930
01944 QColor KDChartParams::dataShadow2Color( uint dataset ) const
01945 {
01946 uint index = dataset % _maxDatasetColor;
01947 if ( _threeDShadowColors )
01948 if( _dataColorsShadow2.find( index ) != _dataColorsShadow2.end() )
01949 return _dataColorsShadow2[ index ];
01950 else
01951 return QColor();
01952 else
01953 if( _dataColors.find( index ) != _dataColors.end() )
01954 return _dataColors[ index ];
01955 else
01956 return QColor();
01957 }
01958
01959
01971 void KDChartParams::setDefaultAxesTypes()
01972 {
01973
01974 uint i = 0;
01975 for ( i = 0; i < KDCHART_MAX_AXES; ++i )
01976 setAxisType( i, KDChartAxisParams::AxisTypeUnknown );
01977
01978
01979
01980
01981
01982
01983 for ( i = KDChartAxisParams::AxisPosSTART;
01984 i <= KDChartAxisParams::AxisPosEND; ++i )
01985 switch ( i ) {
01986
01987 case KDChartAxisParams::AxisPosBottom:
01988 case KDChartAxisParams::AxisPosTop:
01989 case KDChartAxisParams::AxisPosBottom2:
01990 case KDChartAxisParams::AxisPosTop2:
01991 setAxisLabelsTouchEdges( i, Area == chartType() );
01992 break;
01993
01994 case KDChartAxisParams::AxisPosLeft:
01995 case KDChartAxisParams::AxisPosRight:
01996 case KDChartAxisParams::AxisPosLeft2:
01997 case KDChartAxisParams::AxisPosRight2:
01998 setAxisLabelsTouchEdges( i, true );
01999 break;
02000
02001 case KDChartAxisParams::AxisPosLowerRightEdge:
02002 case KDChartAxisParams::AxisPosLowerLeftEdge:
02003 case KDChartAxisParams::AxisPosLowerRightEdge2:
02004 case KDChartAxisParams::AxisPosLowerLeftEdge2:
02005 setAxisLabelsTouchEdges( i, false );
02006 break;
02007 default: {
02008 qDebug( "IMPLEMENTATION ERROR: axis type missing in KDChartParams::setDefaultAxesTypes()" );
02009 Q_ASSERT( !this );
02010 }
02011 }
02012
02013
02014 switch ( chartType() ) {
02015 case NoType:
02016 break;
02017 case Bar:
02018 case Line:
02019 case Area:
02020
02021 setAxisType( KDChartAxisParams::AxisPosBottom,
02022 KDChartAxisParams::AxisTypeEAST );
02023 setAxisShowGrid( KDChartAxisParams::AxisPosBottom,
02024 true );
02025 setAxisType( KDChartAxisParams::AxisPosLeft,
02026 KDChartAxisParams::AxisTypeNORTH );
02027 setAxisShowGrid( KDChartAxisParams::AxisPosLeft,
02028 true );
02029
02030 setAxisType( KDChartAxisParams::AxisPosTop,
02031 KDChartAxisParams::AxisTypeEAST );
02032 setAxisType( KDChartAxisParams::AxisPosRight,
02033 KDChartAxisParams::AxisTypeNORTH );
02034
02035 setAxisType( KDChartAxisParams::AxisPosBottom2,
02036 KDChartAxisParams::AxisTypeEAST );
02037 setAxisType( KDChartAxisParams::AxisPosLeft2,
02038 KDChartAxisParams::AxisTypeNORTH );
02039
02040 setAxisType( KDChartAxisParams::AxisPosTop2,
02041 KDChartAxisParams::AxisTypeEAST );
02042 setAxisType( KDChartAxisParams::AxisPosRight2,
02043 KDChartAxisParams::AxisTypeNORTH );
02044
02045
02046
02047
02048
02049
02050
02051
02052
02053
02054 setAxisLabelTextParams( KDChartAxisParams::AxisPosBottom, false,
02055 1.0,
02056 KDCHART_AXIS_LABELS_AUTO_LIMIT,
02057 1.0, 0 );
02058 setAxisLabelTextParams( KDChartAxisParams::AxisPosTop, false,
02059 1.0,
02060 KDCHART_AXIS_LABELS_AUTO_LIMIT,
02061 1.0, 0 );
02062 setAxisLabelTextParams( KDChartAxisParams::AxisPosBottom2, false,
02063 1.0,
02064 KDCHART_AXIS_LABELS_AUTO_LIMIT,
02065 1.0, 0 );
02066 setAxisLabelTextParams( KDChartAxisParams::AxisPosTop2, false,
02067 1.0,
02068 KDCHART_AXIS_LABELS_AUTO_LIMIT,
02069 1.0, 0 );
02070
02071
02072
02073
02074
02075 break;
02076
02077
02078
02079
02080
02081
02082
02083
02084
02085
02086
02087
02088
02089
02090
02091
02092
02093
02094
02095
02096
02097
02098
02099
02100
02101
02102
02103
02104
02105
02106
02107
02108
02109
02110
02111
02112
02113
02114
02115
02116
02117
02118
02119
02120
02121
02122
02123
02124
02125
02126
02127
02128
02129
02130
02131
02132
02133
02134
02135
02136
02137
02138
02139
02140
02141
02142
02143
02144
02145
02146
02147
02148
02149
02150
02151 case KDChartParams::Pie:
02152 case KDChartParams::Ring:
02153
02154 break;
02155 case KDChartParams::Polar:
02156 setAxisType( KDChartAxisParams::AxisPosSaggital,
02157 KDChartAxisParams::AxisTypeEAST );
02158 setAxisType( KDChartAxisParams::AxisPosCircular,
02159 KDChartAxisParams::AxisTypeNORTH );
02160 setAxisLabelsVisible( KDChartAxisParams::AxisPosSaggital, true );
02161 setAxisLabelsFont( KDChartAxisParams::AxisPosSaggital,
02162 QFont( "helvetica", 1, QFont::Bold ),
02163 -30,
02164 Qt::darkBlue );
02165 setAxisLabelsVisible( KDChartAxisParams::AxisPosCircular, true );
02166 setAxisLabelsFont( KDChartAxisParams::AxisPosCircular,
02167 QFont( "helvetica", 1, QFont::Bold ),
02168 -22,
02169 Qt::darkBlue );
02170 setPolarRotateCircularLabels( false );
02171 break;
02172 default: {
02173 qDebug( "IMPLEMENTATION ERROR: type missing in KDChartParams::setDefaultAxesTypes()" );
02174 Q_ASSERT( !this );
02175 }
02176 }
02177
02178 emit changed();
02179 }
02180
02181
02188 void KDChartParams::activateDefaultAxes()
02189 {
02190
02191
02192 for ( uint i = 0; i < KDCHART_MAX_AXES; ++i )
02193 setAxisDatasets( i, KDCHART_NO_DATASET );
02194
02195 switch ( chartType() ) {
02196 case NoType:
02197 break;
02198 case Bar:
02199 case Line:
02200 case Area:
02201 setAxisVisible( KDChartAxisParams::AxisPosBottom, true );
02202 setAxisDatasets( KDChartAxisParams::AxisPosBottom, KDCHART_ALL_DATASETS );
02203 setAxisVisible( KDChartAxisParams::AxisPosLeft, true );
02204 setAxisDatasets( KDChartAxisParams::AxisPosLeft, KDCHART_ALL_DATASETS );
02205
02206
02207
02208
02209
02210
02211
02212
02213
02214
02215
02216
02217
02218
02219
02220
02221 break;
02222
02223
02224
02225
02226
02227
02228
02229
02230
02231
02232
02233
02234
02235
02236
02237
02238 case KDChartParams::Pie:
02239 case KDChartParams::Ring:
02240 case KDChartParams::Polar:
02241
02242 break;
02243 default: {
02244 qDebug( "IMPLEMENTATION ERROR: type missing in KDChartParams::activateDefaultAxes()" );
02245 Q_ASSERT( !this );
02246 }
02247 }
02248 }
02249
02250
02251
02252
02253
02254
02255
02256
02296 void KDChartParams::setGlobalLeading( int left, int top, int right, int bottom )
02297 {
02298 _globalLeadingLeft = left;
02299 _globalLeadingTop = top;
02300 _globalLeadingRight = right;
02301 _globalLeadingBottom = bottom;
02302 emit changed();
02303 }
02304
02305
02566 bool KDChartParams::moveDataRegionFrame( uint oldDataRow,
02567 uint oldDataCol,
02568 uint,
02569 uint newDataRow,
02570 uint newDataCol,
02571 uint
02572 )
02573 {
02574 const QString oldKey( dataRegionFrameAreaName( oldDataRow, oldDataCol, 0 ) );
02575 KDChartFrameSettings* it = _areaDict.find( oldKey );
02576 bool bFound = ( it != 0 );
02577 if( bFound ){
02578 if( KDCHART_NO_DATASET != newDataRow ){
02579 KDChartFrameSettings* frame = new KDChartFrameSettings;
02580 KDChartFrameSettings::deepCopy( *frame, *it );
02581 frame->setDataRow( newDataRow );
02582 frame->setDataCol( newDataCol );
02583 frame->setData3rd( 0 );
02584 _areaDict.setAutoDelete( TRUE );
02585 _areaDict.replace(
02586 dataRegionFrameAreaName( newDataRow, newDataCol, 0 ),
02587 frame );
02588 }
02589 _areaDict.remove( oldKey );
02590 emit changed();
02591 }
02592 return bFound;
02593 }
02594
02606 const KDChartParams::KDChartFrameSettings* KDChartParams::frameSettings( uint area,
02607 bool& bFound,
02608 int* pIterIdx ) const
02609 {
02610 if( pIterIdx )
02611 *pIterIdx = 0;
02612 const QString key( QString( "%1/-----/-----/-----" ).arg( area, 5 ) );
02613 KDChartFrameSettings* it = _areaDict.find( key );
02614 bFound = ( it != 0 );
02615 if( bFound )
02616 return it;
02617 else if( pIterIdx ){
02618 QString keyStart( key.left(6) );
02619 QDictIterator<KDChartFrameSettings> it2( _areaDict );
02620 for( ; it2.current(); ++it2 ){
02621 if( it2.currentKey().startsWith( keyStart ) ){
02622 bFound = true;
02623 return it2.current();
02624 }
02625 ++*pIterIdx;
02626 }
02627 }
02628 return &_noFrameSettings;
02629 }
02630
02631
02644 bool KDChartParams::removeFrame( uint area )
02645 {
02646 return _areaDict.remove( QString( "%1/-----/-----/-----" ).arg( area, 5 ) );
02647 }
02648
02649
02657 const KDChartParams::KDChartFrameSettings* KDChartParams::nextFrameSettings( bool& bFound,
02658 int* pIterIdx ) const
02659 {
02660 bFound = false;
02661 if( pIterIdx ){
02662 int i=0;
02663 QDictIterator<KDChartFrameSettings> it( _areaDict );
02664 for( ; it.current(); ++it ){
02665 if( *pIterIdx == i )
02666 break;
02667 ++i;
02668 }
02669 if( *pIterIdx == i ){
02670 QString keyStart( it.currentKey().left(6) );
02671 ++it;
02672 for( ; it.current(); ++it ){
02673 ++*pIterIdx;
02674 if( it.currentKey().startsWith( keyStart ) ){
02675 bFound = true;
02676 return it.current();
02677 }
02678 }
02679 }
02680 }
02681 return &_noFrameSettings;
02682 }
02683
02684
02692 uint KDChartParams::insertCustomBox( const KDChartCustomBox & box )
02693 {
02694 _customBoxDict.setAutoDelete( true );
02695 uint newIdx;
02696 if( _customBoxDictMayContainHoles ){
02697 _customBoxDictMayContainHoles = false;
02698 const uint maxIndex = maxCustomBoxIdx();
02699 newIdx = 1 + maxIndex;
02700 for( uint idx = 0; idx <= maxIndex; ++idx ) {
02701 if( ! _customBoxDict.find( idx ) ) {
02702 newIdx = idx;
02703 _customBoxDictMayContainHoles = true;
02704 break;
02705 }
02706 }
02707 }else{
02708 newIdx = _customBoxDict.count();
02709 }
02710 _customBoxDict.insert( newIdx, box.clone() );
02711 emit changed();
02712 return newIdx;
02713 }
02714
02715
02728 bool KDChartParams::removeCustomBox( const uint & idx )
02729 {
02730 const bool bFound = _customBoxDict.remove( idx );
02731 if( bFound ){
02732
02733 removeFrame( KDChartEnums::AreaCustomBoxesBASE + idx );
02734 }
02735 _customBoxDictMayContainHoles = true;
02736 emit changed();
02737 return bFound;
02738 }
02739
02740
02759 const KDChartCustomBox* KDChartParams::customBox( uint box ) const
02760 {
02761 return _customBoxDict.find( box );
02762 }
02763
02777 KDChartCustomBox* KDChartParams::customBoxRef( uint box )
02778 {
02779 return _customBoxDict.find( box );
02780 }
02781
02787 uint KDChartParams::maxCustomBoxIdx() const
02788 {
02789 uint cnt( _customBoxDict.count() );
02790 if( cnt ) {
02791 int maxIndex = cnt-1;
02792 QIntDictIterator<KDChartCustomBox> it( _customBoxDict );
02793 for( ; it.current(); ++it )
02794 if( it.currentKey() > maxIndex )
02795 maxIndex = it.currentKey();
02796 return maxIndex;
02797 }
02798 return 0;
02799 }
02800
02847 void KDChartParams::setChartType( ChartType chartType )
02848 {
02849 _chartType = chartType;
02850
02851
02852
02853 setAxisVisible( KDChartAxisParams::AxisPosRight, false );
02854
02855
02856
02857
02858
02859
02860 bool bAbscissaAxisLabelsTouchEdges = ( Area == chartType );
02861 setAxisLabelsTouchEdges( KDChartAxisParams::AxisPosBottom,
02862 bAbscissaAxisLabelsTouchEdges );
02863 setAxisLabelsTouchEdges( KDChartAxisParams::AxisPosTop,
02864 bAbscissaAxisLabelsTouchEdges );
02865 setAxisLabelsTouchEdges( KDChartAxisParams::AxisPosBottom2,
02866 bAbscissaAxisLabelsTouchEdges );
02867 setAxisLabelsTouchEdges( KDChartAxisParams::AxisPosTop2,
02868 bAbscissaAxisLabelsTouchEdges );
02869
02870 if ( printDataValues( 0 )
02871 && printDataValuesWithDefaultFontParams( 0 ) )
02872 setPrintDataValues( true, 0 );
02873 emit changed();
02874 }
02875
02876
02990 void KDChartParams::setAdditionalChartType( ChartType chartType )
02991 {
02992 _additionalChartType = chartType;
02993 if ( KDChartParams::NoType == chartType ) {
02994 setAxisDatasets( KDChartAxisParams::AxisPosRight,
02995 KDCHART_NO_DATASET );
02996 } else {
02997 setAxisDatasets( KDChartAxisParams::AxisPosRight,
02998 KDCHART_ALL_DATASETS,
02999 KDCHART_ALL_DATASETS,
03000 1 );
03001 if( printDataValues( 1 )
03002 && printDataValuesWithDefaultFontParams( 1 ) )
03003 setPrintDataValues( true, 1 );
03004 }
03005 emit changed();
03006 }
03007
03008
03263 void KDChartParams::setDataValuesCalc( int divPow10,
03264 int digitsBehindComma,
03265 uint chart )
03266 {
03267 uint count = (KDCHART_ALL_CHARTS == chart) ? 2 : 1;
03268 PrintDataValuesSettings * settings = (( 1 < count ) || ( 0 == chart ))
03269 ? &_printDataValuesSettings
03270 : &_printDataValuesSettings2;
03271 for ( uint i = 0; i < count; ++i ) {
03272 settings->_divPow10 = divPow10;
03273 settings->_digitsBehindComma = digitsBehindComma;
03274 if ( 0 < chart )
03275 settings = &_printDataValuesSettings2;
03276 }
03277 emit changed();
03278 }
03279
03290 void KDChartParams::setDataValuesFont( QFont* font,
03291 uint size,
03292 uint chart )
03293 {
03294 uint count = (KDCHART_ALL_CHARTS == chart) ? 2 : 1;
03295 PrintDataValuesSettings * settings = (( 1 < count ) || ( 0 == chart ))
03296 ? &_printDataValuesSettings
03297 : &_printDataValuesSettings2;
03298 for ( uint i = 0; i < count; ++i ) {
03299 settings->_useDefaultFontParams = false;
03300 if( font )
03301 settings->_dataValuesFont = *font;
03302 if( UINT_MAX != size ){
03303 settings->_dataValuesUseFontRelSize = ( 0 < size );
03304 settings->_dataValuesFontRelSize = size;
03305 }
03306 if ( 0 < chart )
03307 settings = &_printDataValuesSettings2;
03308 }
03309 emit changed();
03310 }
03311
03322 void KDChartParams::setDataValuesPlacing( KDChartEnums::PositionFlag position,
03323 uint align,
03324 int deltaX,
03325 int deltaY,
03326 int rotation,
03327 bool specifyingPositiveValues,
03328 uint chart )
03329 {
03330 uint count = (KDCHART_ALL_CHARTS == chart) ? 2 : 1;
03331 PrintDataValuesSettings * settings = (( 1 < count ) || ( 0 == chart ))
03332 ? &_printDataValuesSettings
03333 : &_printDataValuesSettings2;
03334 for ( uint i = 0; i < count; ++i ) {
03335 if( specifyingPositiveValues ){
03336
03337 settings->_dataValuesAnchorPositivePosition = position;
03338 settings->_dataValuesAnchorPositiveAlign = align;
03339 settings->_dataValuesAnchorPositiveDeltaX = deltaX;
03340 settings->_dataValuesAnchorPositiveDeltaY = deltaY;
03341 settings->_dataValuesPositiveRotation = rotation;
03342 }else{
03343
03344 settings->_dataValuesAnchorNegativePosition = position;
03345 settings->_dataValuesAnchorNegativeAlign = align;
03346 settings->_dataValuesAnchorNegativeDeltaX = deltaX;
03347 settings->_dataValuesAnchorNegativeDeltaY = deltaY;
03348 settings->_dataValuesNegativeRotation = rotation;
03349 }
03350 if ( 0 < chart )
03351 settings = &_printDataValuesSettings2;
03352 }
03353 emit changed();
03354 }
03355
03379 void KDChartParams::setDataValuesColors( const QColor* color,
03380 const QBrush& background,
03381 uint chart )
03382 {
03383
03384 if( color )
03385 setPrintDataValuesColor( chart, color );
03386
03387 uint count = (KDCHART_ALL_CHARTS == chart) ? 2 : 1;
03388 PrintDataValuesSettings * settings = (( 1 < count ) || ( 0 == chart ))
03389 ? &_printDataValuesSettings
03390 : &_printDataValuesSettings2;
03391 for ( uint i = 0; i < count; ++i ) {
03392 settings->_dataValuesBrush = background;
03393 if ( 0 < chart )
03394 settings = &_printDataValuesSettings2;
03395 }
03396 emit changed();
03397 }
03398
03399
03400
03401 void KDChartParams::setDataValuesPolicy(
03402 KDChartEnums::TextLayoutPolicy policy,
03403 uint chart )
03404 {
03405 uint count = (KDCHART_ALL_CHARTS == chart) ? 2 : 1;
03406 PrintDataValuesSettings * settings = (( 1 < count ) || ( 0 == chart ))
03407 ? &_printDataValuesSettings
03408 : &_printDataValuesSettings2;
03409 for ( uint i = 0; i < count; ++i ) {
03410 settings->_dataValuesLayoutPolicy = policy;
03411 if ( 0 < chart )
03412 settings = &_printDataValuesSettings2;
03413 }
03414 emit changed();
03415 }
03416
03417
03430 void KDChartParams::setDataValuesShowInfinite( bool dataValuesShowInfinite,
03431 uint chart)
03432 {
03433 uint count = (KDCHART_ALL_CHARTS == chart) ? 2 : 1;
03434 PrintDataValuesSettings * settings = (( 1 < count ) || ( 0 == chart ))
03435 ? &_printDataValuesSettings
03436 : &_printDataValuesSettings2;
03437 for ( uint i = 0; i < count; ++i ) {
03438 settings->_dataValuesShowInfinite = dataValuesShowInfinite;
03439 if ( 0 < chart )
03440 settings = &_printDataValuesSettings2;
03441 }
03442 emit changed();
03443 }
03444
03445
03446
03447 void KDChartParams::setPrintDataValuesColor( uint chart, const QColor* color )
03448 {
03449 uint count = (KDCHART_ALL_CHARTS == chart) ? 2 : 1;
03450 PrintDataValuesSettings * settings = (( 1 < count ) || ( 0 == chart ))
03451 ? &_printDataValuesSettings
03452 : &_printDataValuesSettings2;
03453 for ( uint i = 0; i < count; ++i ) {
03454 if ( KDCHART_DATA_VALUE_AUTO_COLOR == color ) {
03455 settings->_dataValuesAutoColor = true;
03456 settings->_dataValuesColor = QColor( Qt::black );
03457 }
03458 else {
03459 settings->_dataValuesAutoColor = false;
03460 if ( 0 == color )
03461 settings->_dataValuesColor
03462 = QColor( i ? Qt::darkBlue : Qt::black );
03463 else
03464 settings->_dataValuesColor = *color;
03465 }
03466 if ( 0 < chart )
03467 settings = &_printDataValuesSettings2;
03468 }
03469 emit changed();
03470 }
03471
03472
03484 void KDChartParams::setPrintDataValuesFontRelSize( uint chart, uint size )
03485 {
03486 uint count = (KDCHART_ALL_CHARTS == chart) ? 2 : 1;
03487 PrintDataValuesSettings * settings = (( 1 < count ) || ( 0 == chart ))
03488 ? &_printDataValuesSettings
03489 : &_printDataValuesSettings2;
03490 uint theSize( UINT_MAX == size ? 16 : size );
03491 for ( uint i = 0; i < count; ++i ) {
03492 settings->_dataValuesUseFontRelSize = ( 0 < theSize );
03493 settings->_dataValuesFontRelSize = theSize;
03494 if ( 0 < chart )
03495 settings = &_printDataValuesSettings2;
03496 }
03497 emit changed();
03498 }
03499
03500
03519 void KDChartParams::setPrintDataValuesWithDefaultFontParams( uint chart,
03520 bool callSetPrintDataValues )
03521 {
03522 uint count = (KDCHART_ALL_CHARTS == chart) ? 2 : 1;
03523 PrintDataValuesSettings * settings = (( 1 < count ) || ( 0 == chart ))
03524 ? &_printDataValuesSettings
03525 : &_printDataValuesSettings2;
03526 for ( uint i = 0; i < count; ++i ) {
03527 settings->_printDataValues = true;
03528 settings->_useDefaultFontParams = true;
03529 if ( 0 < chart )
03530 settings = &_printDataValuesSettings2;
03531 }
03532 if ( callSetPrintDataValues )
03533 setPrintDataValues( true, chart );
03534 }
03535
03536
03671 KDChartEnums::PositionFlag KDChartParams::dataValuesAnchorPosition( uint chart, bool negative ) const
03672 {
03673 if ( negative )
03674 return chart ? _printDataValuesSettings2._dataValuesAnchorNegativePosition
03675 : _printDataValuesSettings._dataValuesAnchorNegativePosition;
03676 else
03677 return chart ? _printDataValuesSettings2._dataValuesAnchorPositivePosition
03678 : _printDataValuesSettings._dataValuesAnchorPositivePosition;
03679 }
03680
03681
03700 uint KDChartParams::dataValuesAnchorAlign( uint chart, bool negative ) const
03701 {
03702 if ( negative )
03703 return chart ? _printDataValuesSettings2._dataValuesAnchorNegativeAlign
03704 : _printDataValuesSettings._dataValuesAnchorNegativeAlign;
03705 else
03706 return chart ? _printDataValuesSettings2._dataValuesAnchorPositiveAlign
03707 : _printDataValuesSettings._dataValuesAnchorPositiveAlign;
03708 }
03709
03710
03732 int KDChartParams::dataValuesAnchorDeltaX( uint chart, bool negative ) const
03733 {
03734 if ( negative )
03735 return chart ? _printDataValuesSettings2._dataValuesAnchorNegativeDeltaX
03736 : _printDataValuesSettings._dataValuesAnchorNegativeDeltaX;
03737 else
03738 return chart ? _printDataValuesSettings2._dataValuesAnchorPositiveDeltaX
03739 : _printDataValuesSettings._dataValuesAnchorPositiveDeltaX;
03740 }
03741
03742
03764 int KDChartParams::dataValuesAnchorDeltaY( uint chart, bool negative ) const
03765 {
03766 if ( negative )
03767 return chart ? _printDataValuesSettings2._dataValuesAnchorNegativeDeltaY
03768 : _printDataValuesSettings._dataValuesAnchorNegativeDeltaY;
03769 else
03770 return chart ? _printDataValuesSettings2._dataValuesAnchorPositiveDeltaY
03771 : _printDataValuesSettings._dataValuesAnchorPositiveDeltaY;
03772 }
03773
03774
03792 int KDChartParams::dataValuesRotation( uint chart, bool negative ) const
03793 {
03794 if ( negative )
03795 return chart ? _printDataValuesSettings2._dataValuesNegativeRotation
03796 : _printDataValuesSettings._dataValuesNegativeRotation;
03797 else
03798 return chart ? _printDataValuesSettings2._dataValuesPositiveRotation
03799 : _printDataValuesSettings._dataValuesPositiveRotation;
03800 }
03801
03802
04089
04090
04091
04097
04200 void KDChartParams::setThreeDBarAngle( uint angle )
04201 {
04202 if ( angle > 90 )
04203
04204 return ;
04205 _threeDBarAngle = angle;
04206
04207
04208 _cosThreeDBarAngle = cos( static_cast < double > ( _threeDBarAngle ) * M_PI / 180.0 );
04209 emit changed();
04210 }
04211
04212
04572
04573
04574
04580
04670 void KDChartParams::setLineMarkerStyle( uint dataset, LineMarkerStyle style )
04671 {
04672 _lineMarkerStyles[ dataset ] = style;
04673 _maxDatasetLineMarkerStyle = QMAX( dataset,
04674 _maxDatasetLineMarkerStyle );
04675 emit changed();
04676 }
04677
04686 KDChartParams::LineMarkerStyle KDChartParams::lineMarkerStyle( uint dataset ) const
04687 {
04688 if( _lineMarkerStyles.find( dataset ) != _lineMarkerStyles.end() )
04689 return _lineMarkerStyles[ dataset ];
04690 else
04691 return LineMarkerCircle;
04692 }
04693
04694
04695
04696
04715 void KDChartParams::setLineMarkerStyles( LineMarkerStyleMap map ) {
04716 _lineMarkerStyles = map;
04717
04718 uint maxDataset = 0;
04719 for( LineMarkerStyleMap::ConstIterator it = _lineMarkerStyles.begin();
04720 it != _lineMarkerStyles.end(); ++it )
04721 maxDataset = QMAX( maxDataset, it.key() );
04722 _maxDatasetLineMarkerStyle = maxDataset;
04723 }
04724
04725
04866 void KDChartParams::setLineStyle( Qt::PenStyle style, uint dataset )
04867 {
04868 if( KDCHART_GLOBAL_LINE_STYLE == dataset )
04869 _lineStyle = style;
04870 else
04871 _datasetLineStyles[ dataset ] = style;
04872 emit changed();
04873 }
04874
04889 Qt::PenStyle KDChartParams::lineStyle( uint dataset ) const
04890 {
04891 if( KDCHART_GLOBAL_LINE_STYLE == dataset )
04892
04893 return _lineStyle;
04894 else if( _datasetLineStyles.find( dataset ) == _datasetLineStyles.end() )
04895 return lineStyle();
04896 else
04897 return _datasetLineStyles[ dataset ];
04898 }
04899
04900
04960
04961
04962
04963
04964
04965
04966
04967
04968
04969
04970
04971
04972
04973
04974
04975
04981
04982
04983
04984
04985
04986
04987
04988
04989
04990
04991
04997
04998
04999
05000
05001
05002
05003
05004
05005
05006
05007
05008
05009
05010
05016
05017
05018
05019
05020
05021
05022
05023
05024
05025
05026
05099
05100
05101
05107
05108
05182 void KDChartParams::setPolarMarkerStyle( uint dataset, PolarMarkerStyle style )
05183 {
05184 _polarMarkerStyles[ dataset ] = style;
05185 _maxDatasetPolarMarkerStyle = QMAX( dataset,
05186 _maxDatasetPolarMarkerStyle );
05187 emit changed();
05188 }
05189
05198 KDChartParams::PolarMarkerStyle KDChartParams::polarMarkerStyle( uint dataset ) const
05199 {
05200 if( _polarMarkerStyles.find( dataset ) != _polarMarkerStyles.end() )
05201 return _polarMarkerStyles[ dataset ];
05202 else
05203 return PolarMarkerCircle;
05204 }
05205
05206
05225 void KDChartParams::setPolarMarkerStyles( PolarMarkerStyleMap map ) {
05226 _polarMarkerStyles = map;
05227
05228 uint maxDataset = 0;
05229 for( PolarMarkerStyleMap::ConstIterator it = _polarMarkerStyles.begin();
05230 it != _polarMarkerStyles.end(); ++it )
05231 maxDataset = QMAX( maxDataset, it.key() );
05232 _maxDatasetPolarMarkerStyle = maxDataset;
05233 }
05234
05235
05353 void KDChartParams::setPolarDelimsAndLabelsAtPos( KDChartEnums::PositionFlag pos,
05354 bool showDelimiters,
05355 bool showLabels )
05356 {
05357 if( KDCHART_MAX_POLAR_DELIMS_AND_LABELS_POS >= pos ) {
05358 _polarDelimsAndLabels[ pos ].showDelimiters = showDelimiters;
05359 _polarDelimsAndLabels[ pos ].showLabels = showLabels;
05360 }
05361 }
05362
05369 bool KDChartParams::polarDelimAtPos( KDChartEnums::PositionFlag pos ) const
05370 {
05371 if( KDCHART_MAX_POLAR_DELIMS_AND_LABELS_POS >= pos )
05372 return _polarDelimsAndLabels[ pos ].showDelimiters;
05373 else
05374 return false;
05375 }
05376
05383 bool KDChartParams::polarLabelsAtPos( KDChartEnums::PositionFlag pos ) const
05384 {
05385 if( KDCHART_MAX_POLAR_DELIMS_AND_LABELS_POS >= pos )
05386 return _polarDelimsAndLabels[ pos ].showLabels;
05387 else
05388 return false;
05389 }
05390
05391
05392
05394
05395
05396
05402
05691
05692
05693
05699
05755 void KDChartParams::setHiLoChartPrintLowValues( bool active, QFont* font,
05756 int size, QColor* color )
05757 {
05758 _hiLoChartPrintLowValues = active;
05759 if ( font )
05760 _hiLoChartLowValuesFont = *font;
05761 else
05762 _hiLoChartLowValuesFont = _defaultFont;
05763 _hiLoChartLowValuesUseFontRelSize = ( 0 < size );
05764 _hiLoChartLowValuesFontRelSize = size;
05765 if ( 0 == color )
05766 _hiLoChartLowValuesColor = QColor( 0, 0, 0 );
05767 else
05768 _hiLoChartLowValuesColor = *color;
05769 emit changed();
05770 }
05771
05772
05878 void KDChartParams::setHiLoChartPrintHighValues( bool active, QFont* font,
05879 int size, QColor* color )
05880 {
05881 _hiLoChartPrintHighValues = active;
05882 if ( font )
05883 _hiLoChartHighValuesFont = *font;
05884 else
05885 _hiLoChartHighValuesFont = _defaultFont;
05886 _hiLoChartHighValuesUseFontRelSize = ( 0 < size );
05887 _hiLoChartHighValuesFontRelSize = size;
05888 if ( 0 == color )
05889 _hiLoChartHighValuesColor = QColor( 0, 0, 0 );
05890 else
05891 _hiLoChartHighValuesColor = *color;
05892 emit changed();
05893 }
05894
05895
06000 void KDChartParams::setHiLoChartPrintOpenValues( bool active, QFont* font,
06001 uint size, QColor* color )
06002 {
06003 _hiLoChartPrintOpenValues = active;
06004 if ( font )
06005 _hiLoChartOpenValuesFont = *font;
06006 else
06007 _hiLoChartOpenValuesFont = _defaultFont;
06008 _hiLoChartOpenValuesUseFontRelSize = ( 0 < size );
06009 _hiLoChartOpenValuesFontRelSize = size;
06010 if ( 0 == color )
06011 _hiLoChartOpenValuesColor = QColor( 0, 0, 0 );
06012 else
06013 _hiLoChartOpenValuesColor = *color;
06014 emit changed();
06015 }
06016
06017
06120 void KDChartParams::setHiLoChartPrintCloseValues( bool active, QFont* font,
06121 int size, QColor* color )
06122 {
06123 _hiLoChartPrintCloseValues = active;
06124 if ( font )
06125 _hiLoChartCloseValuesFont = *font;
06126 else
06127 _hiLoChartCloseValuesFont = _defaultFont;
06128 _hiLoChartCloseValuesUseFontRelSize = ( 0 < size );
06129 _hiLoChartCloseValuesFontRelSize = size;
06130 if ( 0 == color )
06131 _hiLoChartCloseValuesColor = QColor( 0, 0, 0 );
06132 else
06133 _hiLoChartCloseValuesColor = *color;
06134 emit changed();
06135 }
06136
06330
06331
06332
06338
06356
06357
06394 void KDChartParams::setBWChartFences( double upperInner, double lowerInner,
06395 double upperOuter, double lowerOuter )
06396 {
06397 _BWChartFenceUpperInner = upperInner;
06398 _BWChartFenceLowerInner = lowerInner;
06399 _BWChartFenceUpperOuter = upperOuter;
06400 _BWChartFenceLowerOuter = lowerOuter;
06401 }
06411 void KDChartParams::bWChartFences( double& upperInner, double& lowerInner,
06412 double& upperOuter, double& lowerOuter ) const
06413 {
06414 upperInner = _BWChartFenceUpperInner;
06415 lowerInner = _BWChartFenceLowerInner;
06416 upperOuter = _BWChartFenceUpperOuter;
06417 lowerOuter = _BWChartFenceLowerOuter;
06418 }
06419
06420
06511 void KDChartParams::setBWChartPrintStatistics( BWStatVal statValue,
06512 bool active,
06513 QFont* font,
06514 int size,
06515 QColor* color,
06516 QBrush* brush )
06517 {
06518 BWStatVal statValA = (BWStatValALL == statValue) ? BWStatValSTART : statValue;
06519 BWStatVal statValZ = (BWStatValALL == statValue) ? BWStatValEND : statValue;
06520 for( int i = statValA; i <= statValZ; ++i ){
06521 _BWChartStatistics[ i ].active = active;
06522 if ( font )
06523 _BWChartStatistics[ i ].font = *font;
06524 else
06525 _BWChartStatistics[ i ].font = _defaultFont;
06526 _BWChartStatistics[ i ].useRelSize = ( 0 < size );
06527 _BWChartStatistics[ i ].relSize = size;
06528 if ( 0 == color )
06529 _BWChartStatistics[ i ].color = QColor( 0, 0, 0 );
06530 else
06531 _BWChartStatistics[ i ].color = *color;
06532 if ( 0 == brush )
06533 _BWChartStatistics[ i ].brush = QBrush( Qt::white );
06534 else
06535 _BWChartStatistics[ i ].brush = *brush;
06536 }
06537 emit changed();
06538 }
06539
06540
06630
06631
06632
06638
07041
07042
07043
07049
07096 void KDChartParams::setAxisShowGrid( uint n, bool axisShowGrid )
07097 {
07098 if ( n < KDCHART_MAX_AXES ) {
07099 _axisSettings[ n ].params.setAxisShowGrid( axisShowGrid );
07100 emit changed();
07101 }
07102 }
07103
07110 bool KDChartParams::showGrid() const
07111 {
07112 for ( uint i = 0; i < KDCHART_MAX_AXES; ++i ) {
07113 if ( _axisSettings[ i ].params.axisVisible()
07114 && _axisSettings[ i ].params.axisShowGrid() )
07115 return true;
07116 }
07117 return false;
07118 }
07119
07147 void KDChartParams::setAxisDatasets( uint n, uint dataset,
07148 uint dataset2,
07149 uint chart )
07150 {
07151 uint a1 = ( KDCHART_ALL_AXES == n )
07152 ? 0
07153 : QMIN( n, KDCHART_MAX_AXES-1 );
07154 uint a2 = ( KDCHART_ALL_AXES == n )
07155 ? KDCHART_MAX_AXES-1
07156 : QMIN( n, KDCHART_MAX_AXES-1 );
07157 for( uint i = a1; i <= a2; ++i ) {
07158 _axisSettings[ i ].params.setAxisVisible( KDCHART_NO_DATASET != dataset );
07159 _axisSettings[ i ].dataset = dataset;
07160 _axisSettings[ i ].dataset2 =
07161 ( KDCHART_ALL_DATASETS == dataset
07162 || KDCHART_NO_DATASET == dataset
07163 || KDCHART_ALL_DATASETS == dataset2
07164 || KDCHART_NO_DATASET == dataset2 )
07165 ? dataset
07166 : dataset2;
07167 _axisSettings[ i ].chart = chart;
07168 }
07169 emit changed();
07170 }
07171
07183 bool KDChartParams::axisDatasets( uint n, uint& dataset,
07184 uint& dataset2, uint& chart ) const
07185 {
07186 bool bOk = ( n < KDCHART_MAX_AXES );
07187 if ( bOk ) {
07188 dataset = _axisSettings[ n ].dataset;
07189 dataset2 = _axisSettings[ n ].dataset2;
07190 chart = _axisSettings[ n ].chart;
07191 }
07192 return bOk;
07193 }
07194
07195
07212 bool KDChartParams::chartAxes( uint chart, uint& cnt, AxesArray& axes ) const
07213 {
07214 cnt = 0;
07215 axes.resize( KDCHART_CNT_ORDINATES );
07216 for ( int i2 = 0; i2 < KDCHART_CNT_ORDINATES; ++i2 ) {
07217 axes[ i2 ] = KDCHART_NO_AXIS;
07218 }
07219 for ( uint i = 0; i < KDCHART_MAX_AXES; ++i ) {
07220 if ( chart == _axisSettings[ i ].chart
07221 && ( KDChartAxisParams::AxisPosLeft == i
07222 || KDChartAxisParams::AxisPosRight == i
07223 || KDChartAxisParams::AxisPosLeft2 == i
07224 || KDChartAxisParams::AxisPosRight2 == i ) ) {
07225 for( int j = 0; j < KDCHART_CNT_ORDINATES; ++j ) {
07226 if( KDCHART_NO_AXIS == axes[ j ] || axes[ j ] == i ) {
07227 if( KDCHART_NO_AXIS == axes[ j ] ) {
07228 ++cnt;
07229 axes[ j ] = i;
07230 }
07231 break;
07232 }
07233 }
07234 }
07235 }
07236 return (0 < cnt);
07237 }
07238
07239
07240
07241
07355 void KDChartParams::setAxisLabelsFont( uint n,
07356 QFont axisLabelsFont,
07357 int axisLabelsFontSize,
07358 QColor axisLabelsColor )
07359 {
07360 if ( n < KDCHART_MAX_AXES ) {
07361 bool extraSize = (0 != axisLabelsFontSize);
07362 QFont theFont( axisLabelsFont );
07363 bool useFontFixedSize = true;
07364 if ( extraSize ){
07365 if( 0 > axisLabelsFontSize ){
07366 useFontFixedSize = false;
07367 _axisSettings[ n ].params.setAxisLabelsFontRelSize( -axisLabelsFontSize );
07368 }else{
07369 theFont.setPointSize( axisLabelsFontSize );
07370 }
07371 }
07372 _axisSettings[ n ].params.setAxisLabelsFont( theFont, useFontFixedSize );
07373 _axisSettings[ n ].params.setAxisLabelsColor( axisLabelsColor );
07374 }
07375 }
07376
07377
07428 void KDChartParams::setAxisLabelStringParams( uint n,
07429 QStringList* axisLabelStringList,
07430 QStringList* axisShortLabelStringList,
07431 const QString& valueStart,
07432 const QString& valueEnd )
07433 {
07434 if ( n < KDCHART_MAX_AXES ) {
07435 _axisSettings[ n ].params.setAxisLabelStringLists( axisLabelStringList,
07436 axisShortLabelStringList,
07437 valueStart,
07438 valueEnd );
07439 emit changed();
07440 }
07441 }
07442
07443
07450 void KDChartParams::setAxisParams( uint n,
07451 const KDChartAxisParams& axisParams )
07452 {
07453 if ( n < KDCHART_MAX_AXES ) {
07454 _axisSettings[ n ].params = axisParams;
07455 emit changed();
07456 }
07457 }
07458
07459
07472
07473
07474
07475
07559
07560
07734 void KDChartParams::setHeaderFooterText( uint pos, const QString& text )
07735 {
07736 if ( HdFtPosEND >= pos ) {
07737 _hdFtParams[ pos ]._text = text;
07738 emit changed();
07739 }
07740 }
07741
07742
07760 QString KDChartParams::headerFooterText( uint pos ) const
07761 {
07762 if ( HdFtPosEND >= pos )
07763 return _hdFtParams[ pos ]._text;
07764 else
07765 return QString::null;
07766 }
07767
07768
07769
07775 const QRect& KDChartParams::headerFooterRect( uint pos ) const
07776 {
07777 if ( HdFtPosEND >= pos )
07778 return _hdFtParams[ pos ].rect();
07779 else
07780 return _noRect;
07781 }
07782
07783
07802 void KDChartParams::setHeaderFooterColor( uint pos, const QColor color )
07803 {
07804 if ( HdFtPosEND >= pos ) {
07805 _hdFtParams[ pos ]._color = color;
07806 emit changed();
07807 }
07808 }
07809
07810
07828 QColor KDChartParams::headerFooterColor( uint pos ) const
07829 {
07830 if ( HdFtPosEND >= pos )
07831 return _hdFtParams[ pos ]._color;
07832 else
07833 return QColor( Qt::black );
07834 }
07835
07836
07858 void KDChartParams::setHeaderFooterFont( uint pos, const QFont& font,
07859 bool fontUseRelSize,
07860 int fontRelSize )
07861 {
07862 if ( HdFtPosEND >= pos ) {
07863 _hdFtParams[ pos ]._font = font;
07864 _hdFtParams[ pos ]._fontUseRelSize = fontUseRelSize;
07865 _hdFtParams[ pos ]._fontRelSize = fontRelSize;
07866 emit changed();
07867 }
07868 }
07869
07870
07891 QFont KDChartParams::headerFooterFont( uint pos ) const
07892 {
07893 if ( HdFtPosEND >= pos )
07894 return _hdFtParams[ pos ]._font;
07895 else
07896 return QApplication::font();
07897 }
07898
07899
07920 bool KDChartParams::headerFooterFontUseRelSize( uint pos ) const
07921 {
07922 if ( HdFtPosEND >= pos )
07923 return _hdFtParams[ pos ]._fontUseRelSize;
07924 else
07925 return false;
07926 }
07927
07928
07950 int KDChartParams::headerFooterFontRelSize( uint pos ) const
07951 {
07952 if ( HdFtPosEND >= pos )
07953 return _hdFtParams[ pos ]._fontRelSize;
07954 else
07955 return 10;
07956 }
07957
07958
08280
08281
08282
08283
08284
08587
08588
08609
08610
08611
08612
08613
08614
08615
08616
08617
08618
08619
08620
08621
08622
08623
08624
08625
08626
08627
08628
08693
08694
08765
08822
08823
09167 bool KDChartParams::findFirstAxisCustomBoxID( uint n, uint& boxID ) const
09168 {
09169 QIntDictIterator<KDChartCustomBox> it( _customBoxDict );
09170 for( ; it.current(); ++it ){
09171 if( (*it).anchorArea() == KDChartEnums::AreaAxisBASE + n ){
09172 boxID = it.currentKey();
09173 return true;
09174 }
09175 }
09176 return false;
09177 }
09178
09179 void KDChartParams::insertDefaultAxisTitleBox( uint n,
09180 bool setTitle, const QString& axisTitle,
09181 bool setColor, const QColor& axisTitleColor,
09182 bool setFont, const QFont& axisTitleFont,
09183 bool setFontUseRelSize, bool axisTitleFontUseRelSize,
09184 bool setFontRelSize, int axisTitleFontRelSize )
09185 {
09186 bool bVert = false;
09187 bool bHorz = false;
09188 bool b3rd = false;
09189 switch( KDChartAxisParams::basicAxisPos( n ) ){
09190 case KDChartAxisParams::AxisPosLeft:
09191 case KDChartAxisParams::AxisPosRight:
09192 case KDChartAxisParams::AxisPosLeft2:
09193 case KDChartAxisParams::AxisPosRight2:
09194 bVert = true;
09195 break;
09196 case KDChartAxisParams::AxisPosTop:
09197 case KDChartAxisParams::AxisPosBottom:
09198 case KDChartAxisParams::AxisPosTop2:
09199 case KDChartAxisParams::AxisPosBottom2:
09200 bHorz = true;
09201 break;
09202 default:
09203 b3rd = true;
09204 break;
09205 }
09206 const QFont defaultFont( "helvetica", 6, QFont::Normal, false );
09207
09208
09209
09210 QString titleString;
09211 if( setTitle )
09212 titleString = axisTitle;
09213 else
09214 titleString = "<qt><center> </center></qt>";
09215
09216
09217 const QString stripTitleString( titleString.simplifyWhiteSpace().upper() );
09218 if( setTitle ){
09219 if( !stripTitleString.startsWith("<QT>" ) )
09220 titleString.prepend("<qt><center>");
09221 if( !stripTitleString.endsWith("</QT>" ) )
09222 titleString.append("</center></qt>");
09223 }
09224
09225 KDChartTextPiece textPiece( titleString, setFont ? axisTitleFont : defaultFont );
09226 int fixedFontSize = textPiece.font().pointSize();
09227 if( -1 == fixedFontSize )
09228 fixedFontSize = textPiece.font().pixelSize();
09229 if( -1 == fixedFontSize )
09230 fixedFontSize = 15;
09231 int relFontSize = setFontRelSize ? -axisTitleFontRelSize : -18;
09232
09233 KDChartCustomBox customBox( bVert ? -90 : 0,
09234 textPiece,
09235 setFontUseRelSize
09236 ? ( axisTitleFontUseRelSize ? relFontSize : fixedFontSize )
09237 : relFontSize,
09238 true,
09239 0, 0,
09240 0, 0,
09241 setColor ? axisTitleColor : Qt::darkBlue,
09242 Qt::NoBrush,
09243 KDChartEnums::AreaAxisBASE + n,
09244 bVert ? KDChartEnums::PosCenterLeft : KDChartEnums::PosBottomCenter, bVert ? (Qt::AlignTop + Qt::AlignHCenter) : (Qt::AlignBottom + Qt::AlignHCenter),
09245 0,0,0,
09246 bVert ? (Qt::AlignBottom + Qt::AlignRight) : (Qt::AlignTop + Qt::AlignHCenter),
09247 false, n );
09248
09249 customBox.setParentAxisArea( n );
09250 const uint id = insertCustomBox( customBox );
09251
09252
09253
09254
09255
09256
09257
09258
09259
09260
09261
09262
09263
09264
09265 }
09266
09276 void KDChartParams::setAxisTitle( uint n, const QString& axisTitle )
09277 {
09278 bool bDone = false;
09279 uint boxID;
09280 if( findFirstAxisCustomBoxID( n, boxID ) ){
09281 KDChartCustomBox* box = (KDChartCustomBox*)customBox( boxID );
09282 if( box ){
09283 QString title = axisTitle;
09284 const QString stripTitleString( title.simplifyWhiteSpace().upper() );
09285 if( !stripTitleString.startsWith("<QT>" ) )
09286 title.prepend("<qt><center>");
09287 if( !stripTitleString.endsWith("</QT>" ) )
09288 title.append("</center></qt>");
09289
09290 KDChartTextPiece textPiece( 0, title,
09291 box->content().font() );
09292
09293 box->setContent( textPiece );
09294
09295 bDone = true;
09296 }
09297 }
09298 if( !bDone ){
09299 insertDefaultAxisTitleBox( n,
09300 true, axisTitle,
09301 false, QColor(),
09302 false, QFont(),
09303 false, false,
09304 false, 0 );
09305
09306 }
09307 emit changed();
09308 }
09315 QString KDChartParams::axisTitle( uint n ) const
09316 {
09317 uint boxID;
09318 if( findFirstAxisCustomBoxID( n, boxID ) ){
09319 const KDChartCustomBox* box = customBox( boxID );
09320 if( box )
09321 return box->content().text();
09322 }
09323 return QString();
09324 }
09325
09333 void KDChartParams::setAxisTitleColor( uint n, QColor axisTitleColor )
09334 {
09335 bool bDone = false;
09336 uint boxID;
09337 if( findFirstAxisCustomBoxID( n, boxID ) ){
09338 KDChartCustomBox* box = (KDChartCustomBox*)customBox( boxID );
09339 if( box ){
09340 box->setColor( axisTitleColor );
09341 bDone = true;
09342 }
09343 }
09344 if( !bDone )
09345 insertDefaultAxisTitleBox( n,
09346 false, QString(),
09347 true, axisTitleColor,
09348 false, QFont(),
09349 false, false,
09350 false, 0 );
09351 emit changed();
09352 }
09359 QColor KDChartParams::axisTitleColor( uint n ) const
09360 {
09361 uint boxID;
09362 if( findFirstAxisCustomBoxID( n, boxID ) ){
09363 const KDChartCustomBox* box = customBox( boxID );
09364 if( box )
09365 return box->color();
09366 }
09367 return Qt::darkBlue;
09368 }
09369
09379 void KDChartParams::setAxisTitleFont( uint n,
09380 QFont axisTitleFont )
09381 {
09382 bool bDone = false;
09383 uint boxID;
09384 if( findFirstAxisCustomBoxID( n, boxID ) ){
09385 KDChartCustomBox* box = (KDChartCustomBox*)customBox( boxID );
09386 if( box ){
09387 KDChartTextPiece textPiece( 0, box->content().text(),
09388 axisTitleFont );
09389 box->setContent( textPiece );
09390 bDone = true;
09391 }
09392 }
09393 if( !bDone )
09394 insertDefaultAxisTitleBox( n,
09395 false, QString(),
09396 false, QColor(),
09397 true, axisTitleFont,
09398 false, false,
09399 false, 0 );
09400 emit changed();
09401 }
09402
09412 void KDChartParams::setAxisTitleFont( uint n,
09413 QFont axisTitleFont,
09414 bool useFixedFontSize )
09415 {
09416
09417 bool bDone = false;
09418 uint boxID;
09419 if( findFirstAxisCustomBoxID( n, boxID ) ){
09420 KDChartCustomBox* box = (KDChartCustomBox*)customBox( boxID );
09421 if( box ){
09422 KDChartTextPiece textPiece( 0, box->content().text(),
09423 axisTitleFont );
09424 int fixedFontSize = textPiece.font().pointSize();
09425 setAxisTitleFontRelSize( n, fixedFontSize );
09426 box->setContent( textPiece );
09427 bDone = true;
09428 }
09429 }
09430 if( !bDone )
09431 insertDefaultAxisTitleBox( n,
09432 false, QString(),
09433 false, QColor(),
09434 true, axisTitleFont,
09435 false, false,
09436 false, 0 );
09437
09438 emit changed();
09439
09440 if ( useFixedFontSize )
09441 setAxisTitleFontUseRelSize( n, false);
09442
09443 }
09444
09445
09452 QFont KDChartParams::axisTitleFont( uint n ) const
09453 {
09454 uint boxID;
09455 if( findFirstAxisCustomBoxID( n, boxID ) ){
09456 const KDChartCustomBox* box = customBox( boxID );
09457 if( box )
09458 return box->content().font();
09459 }
09460 return QFont( "helvetica", 6, QFont::Normal, false );
09461 }
09462
09470 void KDChartParams::setAxisTitleFontUseRelSize( uint n,
09471 bool axisTitleFontUseRelSize )
09472 {
09473 bool bDone = false;
09474 uint boxID;
09475 if( findFirstAxisCustomBoxID( n, boxID ) ){
09476 KDChartCustomBox* box = (KDChartCustomBox*)customBox( boxID );
09477 if( box ){
09478 if ( !axisTitleFontUseRelSize ) {
09479 if ( box->fontSize() < 0 )
09480 box->setFontSize( -(box->fontSize()), true );
09481 } else {
09482 if( 0 <= box->fontSize() ) {
09483 box->setFontSize( -(box->fontSize()), true );
09484 } else
09485 box->setFontSize( box->fontSize(), true);
09486 }
09487 bDone = true;
09488 }
09489 }
09490 if( !bDone )
09491 insertDefaultAxisTitleBox( n,
09492 false, QString(),
09493 false, QColor(),
09494 false, QFont(),
09495 true, axisTitleFontUseRelSize,
09496 false, 0 );
09497 emit changed();
09498 }
09505 bool KDChartParams::axisTitleFontUseRelSize( uint n ) const
09506 {
09507 uint boxID;
09508 if( findFirstAxisCustomBoxID( n, boxID ) ){
09509 const KDChartCustomBox* box = customBox( boxID );
09510 if( box )
09511 return ( 0 > box->fontSize() );
09512 }
09513 return true;
09514 }
09515
09525 void KDChartParams::setAxisTitleFontRelSize( uint n,
09526 int axisTitleFontRelSize )
09527 {
09528 bool bDone = false;
09529 uint boxID;
09530 if( findFirstAxisCustomBoxID( n, boxID ) ){
09531 KDChartCustomBox* box = (KDChartCustomBox*)customBox( boxID );
09532 if( box ){
09533 box->setFontSize( -axisTitleFontRelSize, true );
09534 bDone = true;
09535 }
09536 }
09537 if( !bDone )
09538 insertDefaultAxisTitleBox( n,
09539 false, QString(),
09540 false, QColor(),
09541 false, QFont(),
09542 true, true,
09543 true, axisTitleFontRelSize );
09544 emit changed();
09545 }
09553 int KDChartParams::axisTitleFontRelSize( uint n ) const
09554 {
09555 uint boxID;
09556 if( findFirstAxisCustomBoxID( n, boxID ) ){
09557 const KDChartCustomBox* box = customBox( boxID );
09558 if( box ){
09559 int i = box->fontSize();
09560 return (0 > i) ? -i : i;
09561 }
09562 }
09563 return 18;
09564 }