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( 16 );
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( 20 );
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
02564 bool KDChartParams::moveDataRegionFrame( uint oldDataRow,
02565 uint oldDataCol,
02566 uint,
02567 uint newDataRow,
02568 uint newDataCol,
02569 uint
02570 )
02571 {
02572 const QString oldKey( dataRegionFrameAreaName( oldDataRow, oldDataCol, 0 ) );
02573 KDChartFrameSettings* it = _areaDict.find( oldKey );
02574 bool bFound = ( it != 0 );
02575 if( bFound ){
02576 if( KDCHART_NO_DATASET != newDataRow ){
02577 KDChartFrameSettings* frame = new KDChartFrameSettings;
02578 KDChartFrameSettings::deepCopy( *frame, *it );
02579 frame->setDataRow( newDataRow );
02580 frame->setDataCol( newDataCol );
02581 frame->setData3rd( 0 );
02582 _areaDict.setAutoDelete( TRUE );
02583 _areaDict.insert(
02584 dataRegionFrameAreaName( newDataRow, newDataCol, 0 ),
02585 frame );
02586 }
02587 _areaDict.remove( oldKey );
02588 emit changed();
02589 }
02590 return bFound;
02591 }
02592
02604 const KDChartParams::KDChartFrameSettings* KDChartParams::frameSettings( uint area,
02605 bool& bFound,
02606 int* pIterIdx ) const
02607 {
02608 if( pIterIdx )
02609 *pIterIdx = 0;
02610 const QString key( QString( "%1/-----/-----/-----" ).arg( area, 5 ) );
02611 KDChartFrameSettings* it = _areaDict.find( key );
02612 bFound = ( it != 0 );
02613 if( bFound )
02614 return it;
02615 else if( pIterIdx ){
02616 QString keyStart( key.left(6) );
02617 QDictIterator<KDChartFrameSettings> it2( _areaDict );
02618 for( ; it2.current(); ++it2 ){
02619 if( it2.currentKey().startsWith( keyStart ) ){
02620 bFound = true;
02621 return it2.current();
02622 }
02623 ++*pIterIdx;
02624 }
02625 }
02626 return &_noFrameSettings;
02627 }
02628
02629
02637 const KDChartParams::KDChartFrameSettings* KDChartParams::nextFrameSettings( bool& bFound,
02638 int* pIterIdx ) const
02639 {
02640 bFound = false;
02641 if( pIterIdx ){
02642 int i=0;
02643 QDictIterator<KDChartFrameSettings> it( _areaDict );
02644 for( ; it.current(); ++it ){
02645 if( *pIterIdx == i )
02646 break;
02647 ++i;
02648 }
02649 if( *pIterIdx == i ){
02650 QString keyStart( it.currentKey().left(6) );
02651 ++it;
02652 for( ; it.current(); ++it ){
02653 ++*pIterIdx;
02654 if( it.currentKey().startsWith( keyStart ) ){
02655 bFound = true;
02656 return it.current();
02657 }
02658 }
02659 }
02660 }
02661 return &_noFrameSettings;
02662 }
02663
02664
02672 uint KDChartParams::insertCustomBox( const KDChartCustomBox & box )
02673 {
02674 _customBoxDict.setAutoDelete( true );
02675 uint newIdx;
02676 if( _customBoxDictMayContainHoles ){
02677 _customBoxDictMayContainHoles = false;
02678 const uint maxIndex = maxCustomBoxIdx();
02679 newIdx = 1 + maxIndex;
02680 for( uint idx = 0; idx <= maxIndex; ++idx ) {
02681 if( ! _customBoxDict.find( idx ) ) {
02682 newIdx = idx;
02683 _customBoxDictMayContainHoles = true;
02684 break;
02685 }
02686 }
02687 }else{
02688 newIdx = _customBoxDict.count();
02689 }
02690 _customBoxDict.insert( newIdx, box.clone() );
02691 emit changed();
02692 return newIdx;
02693 }
02694
02695
02703 bool KDChartParams::removeCustomBox( const uint & idx )
02704 {
02705 const bool bFound = _customBoxDict.remove( idx );
02706 _customBoxDictMayContainHoles = true;
02707 emit changed();
02708 return bFound;
02709 }
02710
02711
02730 const KDChartCustomBox* KDChartParams::customBox( uint box ) const
02731 {
02732 return _customBoxDict.find( box );
02733 }
02734
02748 KDChartCustomBox* KDChartParams::customBoxRef( uint box )
02749 {
02750 return _customBoxDict.find( box );
02751 }
02752
02758 uint KDChartParams::maxCustomBoxIdx() const
02759 {
02760 uint cnt( _customBoxDict.count() );
02761 if( cnt ) {
02762 int maxIndex = cnt-1;
02763 QIntDictIterator<KDChartCustomBox> it( _customBoxDict );
02764 for( ; it.current(); ++it )
02765 if( it.currentKey() > maxIndex )
02766 maxIndex = it.currentKey();
02767 return maxIndex;
02768 }
02769 return 0;
02770 }
02771
02818 void KDChartParams::setChartType( ChartType chartType )
02819 {
02820 _chartType = chartType;
02821
02822
02823
02824 setAxisVisible( KDChartAxisParams::AxisPosRight, false );
02825
02826
02827
02828
02829
02830
02831 bool bAbscissaAxisLabelsTouchEdges = ( Area == chartType );
02832 setAxisLabelsTouchEdges( KDChartAxisParams::AxisPosBottom,
02833 bAbscissaAxisLabelsTouchEdges );
02834 setAxisLabelsTouchEdges( KDChartAxisParams::AxisPosTop,
02835 bAbscissaAxisLabelsTouchEdges );
02836 setAxisLabelsTouchEdges( KDChartAxisParams::AxisPosBottom2,
02837 bAbscissaAxisLabelsTouchEdges );
02838 setAxisLabelsTouchEdges( KDChartAxisParams::AxisPosTop2,
02839 bAbscissaAxisLabelsTouchEdges );
02840
02841 if ( printDataValues( 0 )
02842 && printDataValuesWithDefaultFontParams( 0 ) )
02843 setPrintDataValues( true, 0 );
02844 emit changed();
02845 }
02846
02847
02961 void KDChartParams::setAdditionalChartType( ChartType chartType )
02962 {
02963 _additionalChartType = chartType;
02964 if ( KDChartParams::NoType == chartType ) {
02965 setAxisDatasets( KDChartAxisParams::AxisPosRight,
02966 KDCHART_NO_DATASET );
02967 } else {
02968 setAxisDatasets( KDChartAxisParams::AxisPosRight,
02969 KDCHART_ALL_DATASETS,
02970 KDCHART_ALL_DATASETS,
02971 1 );
02972 if( printDataValues( 1 )
02973 && printDataValuesWithDefaultFontParams( 1 ) )
02974 setPrintDataValues( true, 1 );
02975 }
02976 emit changed();
02977 }
02978
02979
03234 void KDChartParams::setDataValuesCalc( int divPow10,
03235 int digitsBehindComma,
03236 uint chart )
03237 {
03238 uint count = (KDCHART_ALL_CHARTS == chart) ? 2 : 1;
03239 PrintDataValuesSettings * settings = (( 1 < count ) || ( 0 == chart ))
03240 ? &_printDataValuesSettings
03241 : &_printDataValuesSettings2;
03242 for ( uint i = 0; i < count; ++i ) {
03243 settings->_divPow10 = divPow10;
03244 settings->_digitsBehindComma = digitsBehindComma;
03245 if ( 0 < chart )
03246 settings = &_printDataValuesSettings2;
03247 }
03248 emit changed();
03249 }
03250
03261 void KDChartParams::setDataValuesFont( QFont* font,
03262 uint size,
03263 uint chart )
03264 {
03265 uint count = (KDCHART_ALL_CHARTS == chart) ? 2 : 1;
03266 PrintDataValuesSettings * settings = (( 1 < count ) || ( 0 == chart ))
03267 ? &_printDataValuesSettings
03268 : &_printDataValuesSettings2;
03269 for ( uint i = 0; i < count; ++i ) {
03270 settings->_useDefaultFontParams = false;
03271 if( font )
03272 settings->_dataValuesFont = *font;
03273 if( UINT_MAX != size ){
03274 settings->_dataValuesUseFontRelSize = ( 0 < size );
03275 settings->_dataValuesFontRelSize = size;
03276 }
03277 if ( 0 < chart )
03278 settings = &_printDataValuesSettings2;
03279 }
03280 emit changed();
03281 }
03282
03293 void KDChartParams::setDataValuesPlacing( KDChartEnums::PositionFlag position,
03294 uint align,
03295 int deltaX,
03296 int deltaY,
03297 int rotation,
03298 bool specifyingPositiveValues,
03299 uint chart )
03300 {
03301 uint count = (KDCHART_ALL_CHARTS == chart) ? 2 : 1;
03302 PrintDataValuesSettings * settings = (( 1 < count ) || ( 0 == chart ))
03303 ? &_printDataValuesSettings
03304 : &_printDataValuesSettings2;
03305 for ( uint i = 0; i < count; ++i ) {
03306 if( specifyingPositiveValues ){
03307
03308 settings->_dataValuesAnchorPositivePosition = position;
03309 settings->_dataValuesAnchorPositiveAlign = align;
03310 settings->_dataValuesAnchorPositiveDeltaX = deltaX;
03311 settings->_dataValuesAnchorPositiveDeltaY = deltaY;
03312 settings->_dataValuesPositiveRotation = rotation;
03313 }else{
03314
03315 settings->_dataValuesAnchorNegativePosition = position;
03316 settings->_dataValuesAnchorNegativeAlign = align;
03317 settings->_dataValuesAnchorNegativeDeltaX = deltaX;
03318 settings->_dataValuesAnchorNegativeDeltaY = deltaY;
03319 settings->_dataValuesNegativeRotation = rotation;
03320 }
03321 if ( 0 < chart )
03322 settings = &_printDataValuesSettings2;
03323 }
03324 emit changed();
03325 }
03326
03350 void KDChartParams::setDataValuesColors( const QColor* color,
03351 const QBrush& background,
03352 uint chart )
03353 {
03354
03355 if( color )
03356 setPrintDataValuesColor( chart, color );
03357
03358 uint count = (KDCHART_ALL_CHARTS == chart) ? 2 : 1;
03359 PrintDataValuesSettings * settings = (( 1 < count ) || ( 0 == chart ))
03360 ? &_printDataValuesSettings
03361 : &_printDataValuesSettings2;
03362 for ( uint i = 0; i < count; ++i ) {
03363 settings->_dataValuesBrush = background;
03364 if ( 0 < chart )
03365 settings = &_printDataValuesSettings2;
03366 }
03367 emit changed();
03368 }
03369
03370
03371
03372 void KDChartParams::setDataValuesPolicy(
03373 KDChartEnums::TextLayoutPolicy policy,
03374 uint chart )
03375 {
03376 uint count = (KDCHART_ALL_CHARTS == chart) ? 2 : 1;
03377 PrintDataValuesSettings * settings = (( 1 < count ) || ( 0 == chart ))
03378 ? &_printDataValuesSettings
03379 : &_printDataValuesSettings2;
03380 for ( uint i = 0; i < count; ++i ) {
03381 settings->_dataValuesLayoutPolicy = policy;
03382 if ( 0 < chart )
03383 settings = &_printDataValuesSettings2;
03384 }
03385 emit changed();
03386 }
03387
03388
03401 void KDChartParams::setDataValuesShowInfinite( bool dataValuesShowInfinite,
03402 uint chart)
03403 {
03404 uint count = (KDCHART_ALL_CHARTS == chart) ? 2 : 1;
03405 PrintDataValuesSettings * settings = (( 1 < count ) || ( 0 == chart ))
03406 ? &_printDataValuesSettings
03407 : &_printDataValuesSettings2;
03408 for ( uint i = 0; i < count; ++i ) {
03409 settings->_dataValuesShowInfinite = dataValuesShowInfinite;
03410 if ( 0 < chart )
03411 settings = &_printDataValuesSettings2;
03412 }
03413 emit changed();
03414 }
03415
03416
03417
03418 void KDChartParams::setPrintDataValuesColor( uint chart, const QColor* color )
03419 {
03420 uint count = (KDCHART_ALL_CHARTS == chart) ? 2 : 1;
03421 PrintDataValuesSettings * settings = (( 1 < count ) || ( 0 == chart ))
03422 ? &_printDataValuesSettings
03423 : &_printDataValuesSettings2;
03424 for ( uint i = 0; i < count; ++i ) {
03425 if ( KDCHART_DATA_VALUE_AUTO_COLOR == color ) {
03426 settings->_dataValuesAutoColor = true;
03427 settings->_dataValuesColor = QColor( Qt::black );
03428 }
03429 else {
03430 settings->_dataValuesAutoColor = false;
03431 if ( 0 == color )
03432 settings->_dataValuesColor
03433 = QColor( i ? Qt::darkBlue : Qt::black );
03434 else
03435 settings->_dataValuesColor = *color;
03436 }
03437 if ( 0 < chart )
03438 settings = &_printDataValuesSettings2;
03439 }
03440 emit changed();
03441 }
03442
03443
03455 void KDChartParams::setPrintDataValuesFontRelSize( uint chart, uint size )
03456 {
03457 uint count = (KDCHART_ALL_CHARTS == chart) ? 2 : 1;
03458 PrintDataValuesSettings * settings = (( 1 < count ) || ( 0 == chart ))
03459 ? &_printDataValuesSettings
03460 : &_printDataValuesSettings2;
03461 uint theSize( UINT_MAX == size ? 16 : size );
03462 for ( uint i = 0; i < count; ++i ) {
03463 settings->_dataValuesUseFontRelSize = ( 0 < theSize );
03464 settings->_dataValuesFontRelSize = theSize;
03465 if ( 0 < chart )
03466 settings = &_printDataValuesSettings2;
03467 }
03468 emit changed();
03469 }
03470
03471
03490 void KDChartParams::setPrintDataValuesWithDefaultFontParams( uint chart,
03491 bool callSetPrintDataValues )
03492 {
03493 uint count = (KDCHART_ALL_CHARTS == chart) ? 2 : 1;
03494 PrintDataValuesSettings * settings = (( 1 < count ) || ( 0 == chart ))
03495 ? &_printDataValuesSettings
03496 : &_printDataValuesSettings2;
03497 for ( uint i = 0; i < count; ++i ) {
03498 settings->_printDataValues = true;
03499 settings->_useDefaultFontParams = true;
03500 if ( 0 < chart )
03501 settings = &_printDataValuesSettings2;
03502 }
03503 if ( callSetPrintDataValues )
03504 setPrintDataValues( true, chart );
03505 }
03506
03507
03642 KDChartEnums::PositionFlag KDChartParams::dataValuesAnchorPosition( uint chart, bool negative ) const
03643 {
03644 if ( negative )
03645 return chart ? _printDataValuesSettings2._dataValuesAnchorNegativePosition
03646 : _printDataValuesSettings._dataValuesAnchorNegativePosition;
03647 else
03648 return chart ? _printDataValuesSettings2._dataValuesAnchorPositivePosition
03649 : _printDataValuesSettings._dataValuesAnchorPositivePosition;
03650 }
03651
03652
03671 uint KDChartParams::dataValuesAnchorAlign( uint chart, bool negative ) const
03672 {
03673 if ( negative )
03674 return chart ? _printDataValuesSettings2._dataValuesAnchorNegativeAlign
03675 : _printDataValuesSettings._dataValuesAnchorNegativeAlign;
03676 else
03677 return chart ? _printDataValuesSettings2._dataValuesAnchorPositiveAlign
03678 : _printDataValuesSettings._dataValuesAnchorPositiveAlign;
03679 }
03680
03681
03703 int KDChartParams::dataValuesAnchorDeltaX( uint chart, bool negative ) const
03704 {
03705 if ( negative )
03706 return chart ? _printDataValuesSettings2._dataValuesAnchorNegativeDeltaX
03707 : _printDataValuesSettings._dataValuesAnchorNegativeDeltaX;
03708 else
03709 return chart ? _printDataValuesSettings2._dataValuesAnchorPositiveDeltaX
03710 : _printDataValuesSettings._dataValuesAnchorPositiveDeltaX;
03711 }
03712
03713
03735 int KDChartParams::dataValuesAnchorDeltaY( uint chart, bool negative ) const
03736 {
03737 if ( negative )
03738 return chart ? _printDataValuesSettings2._dataValuesAnchorNegativeDeltaY
03739 : _printDataValuesSettings._dataValuesAnchorNegativeDeltaY;
03740 else
03741 return chart ? _printDataValuesSettings2._dataValuesAnchorPositiveDeltaY
03742 : _printDataValuesSettings._dataValuesAnchorPositiveDeltaY;
03743 }
03744
03745
03763 int KDChartParams::dataValuesRotation( uint chart, bool negative ) const
03764 {
03765 if ( negative )
03766 return chart ? _printDataValuesSettings2._dataValuesNegativeRotation
03767 : _printDataValuesSettings._dataValuesNegativeRotation;
03768 else
03769 return chart ? _printDataValuesSettings2._dataValuesPositiveRotation
03770 : _printDataValuesSettings._dataValuesPositiveRotation;
03771 }
03772
03773
04060
04061
04062
04068
04171 void KDChartParams::setThreeDBarAngle( uint angle )
04172 {
04173 if ( angle > 90 )
04174
04175 return ;
04176 _threeDBarAngle = angle;
04177
04178
04179 _cosThreeDBarAngle = cos( static_cast < double > ( _threeDBarAngle ) * M_PI / 180.0 );
04180 emit changed();
04181 }
04182
04183
04543
04544
04545
04551
04641 void KDChartParams::setLineMarkerStyle( uint dataset, LineMarkerStyle style )
04642 {
04643 _lineMarkerStyles[ dataset ] = style;
04644 _maxDatasetLineMarkerStyle = QMAX( dataset,
04645 _maxDatasetLineMarkerStyle );
04646 emit changed();
04647 }
04648
04657 KDChartParams::LineMarkerStyle KDChartParams::lineMarkerStyle( uint dataset ) const
04658 {
04659 if( _lineMarkerStyles.find( dataset ) != _lineMarkerStyles.end() )
04660 return _lineMarkerStyles[ dataset ];
04661 else
04662 return LineMarkerCircle;
04663 }
04664
04665
04666
04667
04686 void KDChartParams::setLineMarkerStyles( LineMarkerStyleMap map ) {
04687 _lineMarkerStyles = map;
04688
04689 uint maxDataset = 0;
04690 for( LineMarkerStyleMap::ConstIterator it = _lineMarkerStyles.begin();
04691 it != _lineMarkerStyles.end(); ++it )
04692 maxDataset = QMAX( maxDataset, it.key() );
04693 _maxDatasetLineMarkerStyle = maxDataset;
04694 }
04695
04696
04837 void KDChartParams::setLineStyle( Qt::PenStyle style, uint dataset )
04838 {
04839 if( KDCHART_GLOBAL_LINE_STYLE == dataset )
04840 _lineStyle = style;
04841 else
04842 _datasetLineStyles[ dataset ] = style;
04843 emit changed();
04844 }
04845
04860 Qt::PenStyle KDChartParams::lineStyle( uint dataset ) const
04861 {
04862 if( KDCHART_GLOBAL_LINE_STYLE == dataset )
04863
04864 return _lineStyle;
04865 else if( _datasetLineStyles.find( dataset ) == _datasetLineStyles.end() )
04866 return lineStyle();
04867 else
04868 return _datasetLineStyles[ dataset ];
04869 }
04870
04871
04931
04932
04933
04934
04935
04936
04937
04938
04939
04940
04941
04942
04943
04944
04945
04946
04952
04953
04954
04955
04956
04957
04958
04959
04960
04961
04962
04968
04969
04970
04971
04972
04973
04974
04975
04976
04977
04978
04979
04980
04981
04987
04988
04989
04990
04991
04992
04993
04994
04995
04996
04997
05070
05071
05072
05078
05079
05153 void KDChartParams::setPolarMarkerStyle( uint dataset, PolarMarkerStyle style )
05154 {
05155 _polarMarkerStyles[ dataset ] = style;
05156 _maxDatasetPolarMarkerStyle = QMAX( dataset,
05157 _maxDatasetPolarMarkerStyle );
05158 emit changed();
05159 }
05160
05169 KDChartParams::PolarMarkerStyle KDChartParams::polarMarkerStyle( uint dataset ) const
05170 {
05171 if( _polarMarkerStyles.find( dataset ) != _polarMarkerStyles.end() )
05172 return _polarMarkerStyles[ dataset ];
05173 else
05174 return PolarMarkerCircle;
05175 }
05176
05177
05196 void KDChartParams::setPolarMarkerStyles( PolarMarkerStyleMap map ) {
05197 _polarMarkerStyles = map;
05198
05199 uint maxDataset = 0;
05200 for( PolarMarkerStyleMap::ConstIterator it = _polarMarkerStyles.begin();
05201 it != _polarMarkerStyles.end(); ++it )
05202 maxDataset = QMAX( maxDataset, it.key() );
05203 _maxDatasetPolarMarkerStyle = maxDataset;
05204 }
05205
05206
05324 void KDChartParams::setPolarDelimsAndLabelsAtPos( KDChartEnums::PositionFlag pos,
05325 bool showDelimiters,
05326 bool showLabels )
05327 {
05328 if( KDCHART_MAX_POLAR_DELIMS_AND_LABELS_POS >= pos ) {
05329 _polarDelimsAndLabels[ pos ].showDelimiters = showDelimiters;
05330 _polarDelimsAndLabels[ pos ].showLabels = showLabels;
05331 }
05332 }
05333
05340 bool KDChartParams::polarDelimAtPos( KDChartEnums::PositionFlag pos ) const
05341 {
05342 if( KDCHART_MAX_POLAR_DELIMS_AND_LABELS_POS >= pos )
05343 return _polarDelimsAndLabels[ pos ].showDelimiters;
05344 else
05345 return false;
05346 }
05347
05354 bool KDChartParams::polarLabelsAtPos( KDChartEnums::PositionFlag pos ) const
05355 {
05356 if( KDCHART_MAX_POLAR_DELIMS_AND_LABELS_POS >= pos )
05357 return _polarDelimsAndLabels[ pos ].showLabels;
05358 else
05359 return false;
05360 }
05361
05362
05363
05365
05366
05367
05373
05662
05663
05664
05670
05726 void KDChartParams::setHiLoChartPrintLowValues( bool active, QFont* font,
05727 int size, QColor* color )
05728 {
05729 _hiLoChartPrintLowValues = active;
05730 if ( font )
05731 _hiLoChartLowValuesFont = *font;
05732 else
05733 _hiLoChartLowValuesFont = _defaultFont;
05734 _hiLoChartLowValuesUseFontRelSize = ( 0 < size );
05735 _hiLoChartLowValuesFontRelSize = size;
05736 if ( 0 == color )
05737 _hiLoChartLowValuesColor = QColor( 0, 0, 0 );
05738 else
05739 _hiLoChartLowValuesColor = *color;
05740 emit changed();
05741 }
05742
05743
05849 void KDChartParams::setHiLoChartPrintHighValues( bool active, QFont* font,
05850 int size, QColor* color )
05851 {
05852 _hiLoChartPrintHighValues = active;
05853 if ( font )
05854 _hiLoChartHighValuesFont = *font;
05855 else
05856 _hiLoChartHighValuesFont = _defaultFont;
05857 _hiLoChartHighValuesUseFontRelSize = ( 0 < size );
05858 _hiLoChartHighValuesFontRelSize = size;
05859 if ( 0 == color )
05860 _hiLoChartHighValuesColor = QColor( 0, 0, 0 );
05861 else
05862 _hiLoChartHighValuesColor = *color;
05863 emit changed();
05864 }
05865
05866
05971 void KDChartParams::setHiLoChartPrintOpenValues( bool active, QFont* font,
05972 uint size, QColor* color )
05973 {
05974 _hiLoChartPrintOpenValues = active;
05975 if ( font )
05976 _hiLoChartOpenValuesFont = *font;
05977 else
05978 _hiLoChartOpenValuesFont = _defaultFont;
05979 _hiLoChartOpenValuesUseFontRelSize = ( 0 < size );
05980 _hiLoChartOpenValuesFontRelSize = size;
05981 if ( 0 == color )
05982 _hiLoChartOpenValuesColor = QColor( 0, 0, 0 );
05983 else
05984 _hiLoChartOpenValuesColor = *color;
05985 emit changed();
05986 }
05987
05988
06091 void KDChartParams::setHiLoChartPrintCloseValues( bool active, QFont* font,
06092 int size, QColor* color )
06093 {
06094 _hiLoChartPrintCloseValues = active;
06095 if ( font )
06096 _hiLoChartCloseValuesFont = *font;
06097 else
06098 _hiLoChartCloseValuesFont = _defaultFont;
06099 _hiLoChartCloseValuesUseFontRelSize = ( 0 < size );
06100 _hiLoChartCloseValuesFontRelSize = size;
06101 if ( 0 == color )
06102 _hiLoChartCloseValuesColor = QColor( 0, 0, 0 );
06103 else
06104 _hiLoChartCloseValuesColor = *color;
06105 emit changed();
06106 }
06107
06301
06302
06303
06309
06327
06328
06365 void KDChartParams::setBWChartFences( double upperInner, double lowerInner,
06366 double upperOuter, double lowerOuter )
06367 {
06368 _BWChartFenceUpperInner = upperInner;
06369 _BWChartFenceLowerInner = lowerInner;
06370 _BWChartFenceUpperOuter = upperOuter;
06371 _BWChartFenceLowerOuter = lowerOuter;
06372 }
06382 void KDChartParams::bWChartFences( double& upperInner, double& lowerInner,
06383 double& upperOuter, double& lowerOuter ) const
06384 {
06385 upperInner = _BWChartFenceUpperInner;
06386 lowerInner = _BWChartFenceLowerInner;
06387 upperOuter = _BWChartFenceUpperOuter;
06388 lowerOuter = _BWChartFenceLowerOuter;
06389 }
06390
06391
06482 void KDChartParams::setBWChartPrintStatistics( BWStatVal statValue,
06483 bool active,
06484 QFont* font,
06485 int size,
06486 QColor* color,
06487 QBrush* brush )
06488 {
06489 BWStatVal statValA = (BWStatValALL == statValue) ? BWStatValSTART : statValue;
06490 BWStatVal statValZ = (BWStatValALL == statValue) ? BWStatValEND : statValue;
06491 for( int i = statValA; i <= statValZ; ++i ){
06492 _BWChartStatistics[ i ].active = active;
06493 if ( font )
06494 _BWChartStatistics[ i ].font = *font;
06495 else
06496 _BWChartStatistics[ i ].font = _defaultFont;
06497 _BWChartStatistics[ i ].useRelSize = ( 0 < size );
06498 _BWChartStatistics[ i ].relSize = size;
06499 if ( 0 == color )
06500 _BWChartStatistics[ i ].color = QColor( 0, 0, 0 );
06501 else
06502 _BWChartStatistics[ i ].color = *color;
06503 if ( 0 == brush )
06504 _BWChartStatistics[ i ].brush = QBrush( Qt::white );
06505 else
06506 _BWChartStatistics[ i ].brush = *brush;
06507 }
06508 emit changed();
06509 }
06510
06511
06601
06602
06603
06609
07012
07013
07014
07020
07067 void KDChartParams::setAxisShowGrid( uint n, bool axisShowGrid )
07068 {
07069 if ( n < KDCHART_MAX_AXES ) {
07070 _axisSettings[ n ].params.setAxisShowGrid( axisShowGrid );
07071 emit changed();
07072 }
07073 }
07074
07081 bool KDChartParams::showGrid() const
07082 {
07083 for ( uint i = 0; i < KDCHART_MAX_AXES; ++i ) {
07084 if ( _axisSettings[ i ].params.axisVisible()
07085 && _axisSettings[ i ].params.axisShowGrid() )
07086 return true;
07087 }
07088 return false;
07089 }
07090
07118 void KDChartParams::setAxisDatasets( uint n, uint dataset,
07119 uint dataset2,
07120 uint chart )
07121 {
07122 uint a1 = ( KDCHART_ALL_AXES == n )
07123 ? 0
07124 : QMIN( n, KDCHART_MAX_AXES-1 );
07125 uint a2 = ( KDCHART_ALL_AXES == n )
07126 ? KDCHART_MAX_AXES-1
07127 : QMIN( n, KDCHART_MAX_AXES-1 );
07128 for( uint i = a1; i <= a2; ++i ) {
07129 _axisSettings[ i ].params.setAxisVisible( KDCHART_NO_DATASET != dataset );
07130 _axisSettings[ i ].dataset = dataset;
07131 _axisSettings[ i ].dataset2 =
07132 ( KDCHART_ALL_DATASETS == dataset
07133 || KDCHART_NO_DATASET == dataset
07134 || KDCHART_ALL_DATASETS == dataset2
07135 || KDCHART_NO_DATASET == dataset2 )
07136 ? dataset
07137 : dataset2;
07138 _axisSettings[ i ].chart = chart;
07139 }
07140 emit changed();
07141 }
07142
07154 bool KDChartParams::axisDatasets( uint n, uint& dataset,
07155 uint& dataset2, uint& chart ) const
07156 {
07157 bool bOk = ( n < KDCHART_MAX_AXES );
07158 if ( bOk ) {
07159 dataset = _axisSettings[ n ].dataset;
07160 dataset2 = _axisSettings[ n ].dataset2;
07161 chart = _axisSettings[ n ].chart;
07162 }
07163 return bOk;
07164 }
07165
07166
07183 bool KDChartParams::chartAxes( uint chart, uint& cnt, AxesArray& axes ) const
07184 {
07185 cnt = 0;
07186 axes.resize( KDCHART_CNT_ORDINATES );
07187 for ( int i2 = 0; i2 < KDCHART_CNT_ORDINATES; ++i2 ) {
07188 axes[ i2 ] = KDCHART_NO_AXIS;
07189 }
07190 for ( uint i = 0; i < KDCHART_MAX_AXES; ++i ) {
07191 if ( chart == _axisSettings[ i ].chart
07192 && ( KDChartAxisParams::AxisPosLeft == i
07193 || KDChartAxisParams::AxisPosRight == i
07194 || KDChartAxisParams::AxisPosLeft2 == i
07195 || KDChartAxisParams::AxisPosRight2 == i ) ) {
07196 for( int j = 0; j < KDCHART_CNT_ORDINATES; ++j ) {
07197 if( KDCHART_NO_AXIS == axes[ j ] || axes[ j ] == i ) {
07198 if( KDCHART_NO_AXIS == axes[ j ] ) {
07199 ++cnt;
07200 axes[ j ] = i;
07201 }
07202 break;
07203 }
07204 }
07205 }
07206 }
07207 return (0 < cnt);
07208 }
07209
07210
07211
07212
07326 void KDChartParams::setAxisLabelsFont( uint n,
07327 QFont axisLabelsFont,
07328 int axisLabelsFontSize,
07329 QColor axisLabelsColor )
07330 {
07331 if ( n < KDCHART_MAX_AXES ) {
07332 bool extraSize = (0 != axisLabelsFontSize);
07333 QFont theFont( axisLabelsFont );
07334 bool useFontFixedSize = true;
07335 if ( extraSize ){
07336 if( 0 > axisLabelsFontSize ){
07337 useFontFixedSize = false;
07338 _axisSettings[ n ].params.setAxisLabelsFontRelSize( -axisLabelsFontSize );
07339 }else{
07340 theFont.setPointSize( axisLabelsFontSize );
07341 }
07342 }
07343 _axisSettings[ n ].params.setAxisLabelsFont( theFont, useFontFixedSize );
07344 _axisSettings[ n ].params.setAxisLabelsColor( axisLabelsColor );
07345 }
07346 }
07347
07348
07399 void KDChartParams::setAxisLabelStringParams( uint n,
07400 QStringList* axisLabelStringList,
07401 QStringList* axisShortLabelStringList,
07402 const QString& valueStart,
07403 const QString& valueEnd )
07404 {
07405 if ( n < KDCHART_MAX_AXES ) {
07406 _axisSettings[ n ].params.setAxisLabelStringLists( axisLabelStringList,
07407 axisShortLabelStringList,
07408 valueStart,
07409 valueEnd );
07410 emit changed();
07411 }
07412 }
07413
07414
07421 void KDChartParams::setAxisParams( uint n,
07422 const KDChartAxisParams& axisParams )
07423 {
07424 if ( n < KDCHART_MAX_AXES ) {
07425 _axisSettings[ n ].params = axisParams;
07426 emit changed();
07427 }
07428 }
07429
07430
07443
07444
07445
07446
07530
07531
07705 void KDChartParams::setHeaderFooterText( uint pos, const QString& text )
07706 {
07707 if ( HdFtPosEND >= pos ) {
07708 _hdFtParams[ pos ]._text = text;
07709 emit changed();
07710 }
07711 }
07712
07713
07731 QString KDChartParams::headerFooterText( uint pos ) const
07732 {
07733 if ( HdFtPosEND >= pos )
07734 return _hdFtParams[ pos ]._text;
07735 else
07736 return QString::null;
07737 }
07738
07739
07740
07746 const QRect& KDChartParams::headerFooterRect( uint pos ) const
07747 {
07748 if ( HdFtPosEND >= pos )
07749 return _hdFtParams[ pos ].rect();
07750 else
07751 return _noRect;
07752 }
07753
07754
07773 void KDChartParams::setHeaderFooterColor( uint pos, const QColor color )
07774 {
07775 if ( HdFtPosEND >= pos ) {
07776 _hdFtParams[ pos ]._color = color;
07777 emit changed();
07778 }
07779 }
07780
07781
07799 QColor KDChartParams::headerFooterColor( uint pos ) const
07800 {
07801 if ( HdFtPosEND >= pos )
07802 return _hdFtParams[ pos ]._color;
07803 else
07804 return QColor( Qt::black );
07805 }
07806
07807
07829 void KDChartParams::setHeaderFooterFont( uint pos, const QFont& font,
07830 bool fontUseRelSize,
07831 int fontRelSize )
07832 {
07833 if ( HdFtPosEND >= pos ) {
07834 _hdFtParams[ pos ]._font = font;
07835 _hdFtParams[ pos ]._fontUseRelSize = fontUseRelSize;
07836 _hdFtParams[ pos ]._fontRelSize = fontRelSize;
07837 emit changed();
07838 }
07839 }
07840
07841
07862 QFont KDChartParams::headerFooterFont( uint pos ) const
07863 {
07864 if ( HdFtPosEND >= pos )
07865 return _hdFtParams[ pos ]._font;
07866 else
07867 return QApplication::font();
07868 }
07869
07870
07891 bool KDChartParams::headerFooterFontUseRelSize( uint pos ) const
07892 {
07893 if ( HdFtPosEND >= pos )
07894 return _hdFtParams[ pos ]._fontUseRelSize;
07895 else
07896 return false;
07897 }
07898
07899
07921 int KDChartParams::headerFooterFontRelSize( uint pos ) const
07922 {
07923 if ( HdFtPosEND >= pos )
07924 return _hdFtParams[ pos ]._fontRelSize;
07925 else
07926 return 10;
07927 }
07928
07929
08251
08252
08253
08254
08255
08558
08559
08580
08581
08582
08583
08584
08585
08586
08587
08588
08589
08590
08591
08592
08593
08594
08595
08596
08597
08598
08599
08664
08665
08736
08793
08794
09138 bool KDChartParams::findFirstAxisCustomBoxID( uint n, uint& boxID ) const
09139 {
09140 QIntDictIterator<KDChartCustomBox> it( _customBoxDict );
09141 for( ; it.current(); ++it ){
09142 if( (*it).anchorArea() == KDChartEnums::AreaAxisBASE + n ){
09143 boxID = it.currentKey();
09144 return true;
09145 }
09146 }
09147 return false;
09148 }
09149
09150 void KDChartParams::insertDefaultAxisTitleBox( uint n,
09151 bool setTitle, const QString& axisTitle,
09152 bool setColor, const QColor& axisTitleColor,
09153 bool setFont, const QFont& axisTitleFont,
09154 bool setFontUseRelSize, bool axisTitleFontUseRelSize,
09155 bool setFontRelSize, int axisTitleFontRelSize )
09156 {
09157 bool bVert = false;
09158 bool bHorz = false;
09159 bool b3rd = false;
09160 switch( KDChartAxisParams::basicAxisPos( n ) ){
09161 case KDChartAxisParams::AxisPosLeft:
09162 case KDChartAxisParams::AxisPosRight:
09163 case KDChartAxisParams::AxisPosLeft2:
09164 case KDChartAxisParams::AxisPosRight2:
09165 bVert = true;
09166 break;
09167 case KDChartAxisParams::AxisPosTop:
09168 case KDChartAxisParams::AxisPosBottom:
09169 case KDChartAxisParams::AxisPosTop2:
09170 case KDChartAxisParams::AxisPosBottom2:
09171 bHorz = true;
09172 break;
09173 default:
09174 b3rd = true;
09175 break;
09176 }
09177 const QFont defaultFont( "helvetica", 6, QFont::Normal, false );
09178
09179
09180
09181 QString titleString;
09182 if( setTitle )
09183 titleString = axisTitle;
09184 else
09185 titleString = "<qt><center> </center></qt>";
09186
09187
09188 const QString stripTitleString( titleString.simplifyWhiteSpace().upper() );
09189 if( setTitle ){
09190 if( !stripTitleString.startsWith("<QT>" ) )
09191 titleString.prepend("<qt><center>");
09192 if( !stripTitleString.endsWith("</QT>" ) )
09193 titleString.append("</center></qt>");
09194 }
09195
09196 KDChartTextPiece textPiece( titleString, setFont ? axisTitleFont : defaultFont );
09197 int fixedFontSize = textPiece.font().pointSize();
09198 if( -1 == fixedFontSize )
09199 fixedFontSize = textPiece.font().pixelSize();
09200 if( -1 == fixedFontSize )
09201 fixedFontSize = 15;
09202 int relFontSize = setFontRelSize ? -axisTitleFontRelSize : -18;
09203
09204 KDChartCustomBox customBox( bVert ? -90 : 0,
09205 textPiece,
09206 setFontUseRelSize
09207 ? ( axisTitleFontUseRelSize ? relFontSize : fixedFontSize )
09208 : relFontSize,
09209 true,
09210 0, bVert ? -40 : (bHorz ? 0 : 0),
09211 -2000, bVert ? -200 : (bHorz ? -45 : 0),
09212 setColor ? axisTitleColor : Qt::darkBlue,
09213 Qt::NoBrush,
09214 KDChartEnums::AreaAxisBASE + n,
09215 bVert ? KDChartEnums::PosCenterLeft : KDChartEnums::PosBottomCenter,
09216 bVert ? (Qt::AlignTop + Qt::AlignHCenter) : (Qt::AlignBottom + Qt::AlignHCenter),
09217 0,0,0,
09218 bVert ? (Qt::AlignBottom + Qt::AlignRight) : (Qt::AlignTop + Qt::AlignHCenter),
09219 false );
09220 insertCustomBox( customBox );
09221 }
09222
09232 void KDChartParams::setAxisTitle( uint n, const QString& axisTitle )
09233 {
09234 bool bDone = false;
09235 uint boxID;
09236 if( findFirstAxisCustomBoxID( n, boxID ) ){
09237 KDChartCustomBox* box = (KDChartCustomBox*)customBox( boxID );
09238 if( box ){
09239 QString title = axisTitle;
09240 const QString stripTitleString( title.simplifyWhiteSpace().upper() );
09241 if( !stripTitleString.startsWith("<QT>" ) )
09242 title.prepend("<qt><center>");
09243 if( !stripTitleString.endsWith("</QT>" ) )
09244 title.append("</center></qt>");
09245
09246 KDChartTextPiece textPiece( 0, title,
09247 box->content().font() );
09248
09249 box->setContent( textPiece );
09250
09251 bDone = true;
09252 }
09253 }
09254 if( !bDone ){
09255 insertDefaultAxisTitleBox( n,
09256 true, axisTitle,
09257 false, QColor(),
09258 false, QFont(),
09259 false, false,
09260 false, 0 );
09261
09262 }
09263 emit changed();
09264 }
09271 QString KDChartParams::axisTitle( uint n ) const
09272 {
09273 uint boxID;
09274 if( findFirstAxisCustomBoxID( n, boxID ) ){
09275 const KDChartCustomBox* box = customBox( boxID );
09276 if( box )
09277 return box->content().text();
09278 }
09279 return QString();
09280 }
09281
09289 void KDChartParams::setAxisTitleColor( uint n, QColor axisTitleColor )
09290 {
09291 bool bDone = false;
09292 uint boxID;
09293 if( findFirstAxisCustomBoxID( n, boxID ) ){
09294 KDChartCustomBox* box = (KDChartCustomBox*)customBox( boxID );
09295 if( box ){
09296 box->setColor( axisTitleColor );
09297 bDone = true;
09298 }
09299 }
09300 if( !bDone )
09301 insertDefaultAxisTitleBox( n,
09302 false, QString(),
09303 true, axisTitleColor,
09304 false, QFont(),
09305 false, false,
09306 false, 0 );
09307 emit changed();
09308 }
09315 QColor KDChartParams::axisTitleColor( uint n ) const
09316 {
09317 uint boxID;
09318 if( findFirstAxisCustomBoxID( n, boxID ) ){
09319 const KDChartCustomBox* box = customBox( boxID );
09320 if( box )
09321 return box->color();
09322 }
09323 return Qt::darkBlue;
09324 }
09325
09335 void KDChartParams::setAxisTitleFont( uint n,
09336 QFont axisTitleFont )
09337 {
09338 bool bDone = false;
09339 uint boxID;
09340 if( findFirstAxisCustomBoxID( n, boxID ) ){
09341 KDChartCustomBox* box = (KDChartCustomBox*)customBox( boxID );
09342 if( box ){
09343 KDChartTextPiece textPiece( 0, box->content().text(),
09344 axisTitleFont );
09345 box->setContent( textPiece );
09346 bDone = true;
09347 }
09348 }
09349 if( !bDone )
09350 insertDefaultAxisTitleBox( n,
09351 false, QString(),
09352 false, QColor(),
09353 true, axisTitleFont,
09354 false, false,
09355 false, 0 );
09356 emit changed();
09357 }
09358
09368 void KDChartParams::setAxisTitleFont( uint n,
09369 QFont axisTitleFont,
09370 bool useFixedFontSize )
09371 {
09372
09373 bool bDone = false;
09374 uint boxID;
09375 if( findFirstAxisCustomBoxID( n, boxID ) ){
09376 KDChartCustomBox* box = (KDChartCustomBox*)customBox( boxID );
09377 if( box ){
09378 KDChartTextPiece textPiece( 0, box->content().text(),
09379 axisTitleFont );
09380 int fixedFontSize = textPiece.font().pointSize();
09381 setAxisTitleFontRelSize( n, fixedFontSize );
09382 box->setContent( textPiece );
09383 bDone = true;
09384 }
09385 }
09386 if( !bDone )
09387 insertDefaultAxisTitleBox( n,
09388 false, QString(),
09389 false, QColor(),
09390 true, axisTitleFont,
09391 false, false,
09392 false, 0 );
09393
09394 emit changed();
09395
09396 if ( useFixedFontSize )
09397 setAxisTitleFontUseRelSize( n, false);
09398
09399 }
09400
09401
09408 QFont KDChartParams::axisTitleFont( uint n ) const
09409 {
09410 uint boxID;
09411 if( findFirstAxisCustomBoxID( n, boxID ) ){
09412 const KDChartCustomBox* box = customBox( boxID );
09413 if( box )
09414 return box->content().font();
09415 }
09416 return QFont( "helvetica", 6, QFont::Normal, false );
09417 }
09418
09426 void KDChartParams::setAxisTitleFontUseRelSize( uint n,
09427 bool axisTitleFontUseRelSize )
09428 {
09429 bool bDone = false;
09430 uint boxID;
09431 if( findFirstAxisCustomBoxID( n, boxID ) ){
09432 KDChartCustomBox* box = (KDChartCustomBox*)customBox( boxID );
09433 if( box ){
09434 if ( !axisTitleFontUseRelSize ) {
09435 if ( box->fontSize() < 0 )
09436 box->setFontSize( -(box->fontSize()), true );
09437 } else {
09438 if( 0 <= box->fontSize() ) {
09439 box->setFontSize( -(box->fontSize()), true );
09440 } else
09441 box->setFontSize( box->fontSize(), true);
09442 }
09443 bDone = true;
09444 }
09445 }
09446 if( !bDone )
09447 insertDefaultAxisTitleBox( n,
09448 false, QString(),
09449 false, QColor(),
09450 false, QFont(),
09451 true, axisTitleFontUseRelSize,
09452 false, 0 );
09453 emit changed();
09454 }
09461 bool KDChartParams::axisTitleFontUseRelSize( uint n ) const
09462 {
09463 uint boxID;
09464 if( findFirstAxisCustomBoxID( n, boxID ) ){
09465 const KDChartCustomBox* box = customBox( boxID );
09466 if( box )
09467 return ( 0 > box->fontSize() );
09468 }
09469 return true;
09470 }
09471
09481 void KDChartParams::setAxisTitleFontRelSize( uint n,
09482 int axisTitleFontRelSize )
09483 {
09484 bool bDone = false;
09485 uint boxID;
09486 if( findFirstAxisCustomBoxID( n, boxID ) ){
09487 KDChartCustomBox* box = (KDChartCustomBox*)customBox( boxID );
09488 if( box ){
09489 box->setFontSize( -axisTitleFontRelSize, true );
09490 bDone = true;
09491 }
09492 }
09493 if( !bDone )
09494 insertDefaultAxisTitleBox( n,
09495 false, QString(),
09496 false, QColor(),
09497 false, QFont(),
09498 true, true,
09499 true, axisTitleFontRelSize );
09500 emit changed();
09501 }
09509 int KDChartParams::axisTitleFontRelSize( uint n ) const
09510 {
09511 uint boxID;
09512 if( findFirstAxisCustomBoxID( n, boxID ) ){
09513 const KDChartCustomBox* box = customBox( boxID );
09514 if( box ){
09515 int i = box->fontSize();
09516 return (0 > i) ? -i : i;
09517 }
09518 }
09519 return 18;
09520 }