kchart

KDChartParams.cpp

00001 /* -*- Mode: C++ -*-
00002    KDChart - a multi-platform charting engine
00003    */
00004 
00005 /****************************************************************************
00006  ** Copyright (C) 2001-2003 Klarälvdalens Datakonsult AB.  All rights reserved.
00007  **
00008  ** This file is part of the KDChart library.
00009  **
00010  ** This file may be distributed and/or modified under the terms of the
00011  ** GNU General Public License version 2 as published by the Free Software
00012  ** Foundation and appearing in the file LICENSE.GPL included in the
00013  ** packaging of this file.
00014  **
00015  ** Licensees holding valid commercial KDChart licenses may use this file in
00016  ** accordance with the KDChart Commercial License Agreement provided with
00017  ** the Software.
00018  **
00019  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021  **
00022  ** See http://www.klaralvdalens-datakonsult.se/?page=products for
00023  **   information about KDChart Commercial License Agreements.
00024  **
00025  ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
00026  ** licensing are not clear to you.
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 //#include <qdom.h>
00043 
00055 //QColor  KDChartParams::_internalPointer_DataValueAutoColor = QColor( 0,1,0 );
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 static QColor defaultColor;
00088 QT_STATIC_CONST_IMPL QColor & KDChartParams_AutoColor = defaultColor;
00089 */
00090 
00094 KDChartParams::KDChartParams()
00095 {
00096     tempPropSetA = new KDChartPropertySet();
00097     tempPropSetB = new KDChartPropertySet();
00098 
00099     // GENERAL
00100 
00101     // Avoid Purify UMR
00102     _maxDatasetColor = 1;
00103     _maxDatasetSourceMode = 0;
00104     _setChartSourceModeWasUsed = false;
00105 
00106     _customBoxDictMayContainHoles = false;
00107 
00108     // Set the default font params flag for data value texts
00109     // but do *not* call setPrintDataValues() there since
00110     // this will be called internally by setChartType() below.
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     // Default type is bar charts
00127     setChartType( Bar );
00128 
00129     // By default, there is no additional chart type
00130     setAdditionalChartType( NoType );
00131 
00132     // Default is to show all values.
00133     setNumValues( static_cast<unsigned int>( -1 ) );
00134 
00135     _defaultFont = QFont( "helvetica", 8, QFont::Normal, false );
00136 
00137     // The default frame settings: no border, no corners, no background
00138     _noFrame.clearAll();
00139 
00140     // The default frame settings: no inner gap, no outer gap and use the _noFrame
00141     // *** no need to initialize _noFrameSettings: it is initialized by a default c'tor!
00142 
00143     // The default brightness of shadow colors (needs to be set
00144     // before the data colors to avoid an UMR).
00145     setShadowBrightnessFactor( 1.0 );
00146 
00147     // The default shadow fill style.
00148     setShadowPattern( Qt::SolidPattern );
00149 
00150     // Some default colors for the data.
00151     setDataDefaultColors();
00152 
00153     // Default color for data display outlines.
00154     setOutlineDataColor( black );
00155 
00156     // Default line width for data display outlines.
00157     setOutlineDataLineWidth( 1 );
00158 
00159     // Default line style for data display outlines.
00160     setOutlineDataLineStyle( Qt::SolidLine );
00161 
00162     // END GENERAL
00163 
00164 
00165     setDataArea(  QRect( QPoint(0,0), QSize(0,0)) );
00166     setLegendArea(QRect( QPoint(0,0), QSize(0,0)) );
00167 
00168 
00169     // BAR CHART-SPECIFIC
00170 
00171     // Default bar subtype is normal
00172     setBarChartSubType( BarNormal );
00173 
00174     // Default is not to draw 3D bars
00175     setThreeDBars( false );
00176 
00177     // Default is to used shadowed colors for 3D bar effects
00178     setThreeDBarsShadowColors( true );
00179 
00180     // Default angle for 3D bars is 45 degrees.
00181     setThreeDBarAngle( 45 );
00182 
00183     // Default depth of 3D bars is 1.0
00184     setThreeDBarDepth( 1.0 );
00185 
00186     // Default gap between datasets is 6 per mille of chart data area.
00187     setDatasetGap( 6 );
00188     setDatasetGapIsRelative( true );
00189 
00190     // Default gap between value blocks is 24 per mille of chart data area.
00191     setValueBlockGap( 24 );
00192     setValueBlockGapIsRelative( true );
00193 
00194     // Default is to have the bar width's calculated indiidually
00195     setBarWidth( KDCHART_AUTO_SIZE );
00196     // reset the special indicator members storing the number
00197     // of bars that were drawn last time / could not be drawn
00198     // due to too less horizontal space
00199     setBarsDisplayed( 0 );
00200     setBarsLeft( 0 );
00201 
00202     // By default, excess arrows are drawn in a split fashion
00203     setDrawSolidExcessArrows( false );
00204 
00205     // END BAR CHART-SPECIFIC
00206 
00207 
00208     // LINE/AREA CHART-SPECIFIC
00209     // Normal lines by default
00210     setLineChartSubType( LineNormal );
00211 
00212     // No markers by default
00213     setLineMarker( false );
00214 
00215     // Lines have a width of 1 pixel by default
00216     setLineWidth( 1 );
00217 
00218     // Lines are solid by default
00219     setLineStyle( Qt::SolidLine );
00220 
00221     // Lines have the same color as their
00222     // respective data points by default
00223     setLineColor();
00224 
00225 
00226     // Default line marker styles and size
00227     _maxDatasetLineMarkerStyle = 0; // avoid UMR
00228     setLineMarkerStyle( 0, LineMarkerCircle );
00229     setLineMarkerStyle( 1, LineMarkerSquare );
00230     setLineMarkerStyle( 2, LineMarkerDiamond );
00231     setLineMarkerSize( QSize( 6, 6 ) );
00232 
00233     // 3D line settings
00234     setThreeDLines( false );
00235     setThreeDLineDepth( 10 );
00236     /* temporary disabled:
00237        setThreeDLineXRotation( 30 );
00238        setThreeDLineYRotation( 30 );
00239        */
00240     setThreeDLineXRotation( 15 );
00241     setThreeDLineYRotation( 15 );
00242 
00243     // Normal areas by default
00244     setAreaChartSubType( AreaNormal );
00245 
00246     // Areas are filled below the value points by default.
00247     setAreaLocation( AreaBelow );
00248 
00249     // END LINE/AREA CHART-SPECIFIC
00250 
00251     // POLAR CHART-SPECIFIC
00252     // Normal polar charts by default
00253     setPolarChartSubType( PolarNormal );
00254 
00255     // Have markers by default
00256     setPolarMarker( true );
00257 
00258     // Polar charts show the zero point at the right side of the circle
00259     setPolarZeroDegreePos( 0 );
00260 
00261     // Lines have a width of 3/1000 of the chart's min size
00262     // (either width or height) by default
00263     setPolarLineWidth( -3 );
00264 
00265     // Default polar marker styles and size
00266     _maxDatasetPolarMarkerStyle = 0; // avoid UMR
00267     setPolarMarkerStyle( 0, PolarMarkerCircle );
00268     setPolarMarkerStyle( 1, PolarMarkerSquare );
00269     setPolarMarkerStyle( 2, PolarMarkerDiamond );
00270     setPolarMarkerSize( QSize( -40,-40 ) );
00271 
00272     // default circular axes delimiters
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     /* for test:
00287        setPolarDelimsAndLabelsAtPos( KDChartEnums::PosTopLeft,      true, true );
00288        setPolarDelimsAndLabelsAtPos( KDChartEnums::PosTopCenter,    true, true  );
00289        setPolarDelimsAndLabelsAtPos( KDChartEnums::PosTopRight,     true, true );
00290        setPolarDelimsAndLabelsAtPos( KDChartEnums::PosCenterRight,  true, true );
00291        setPolarDelimsAndLabelsAtPos( KDChartEnums::PosBottomRight,  true, true );
00292        setPolarDelimsAndLabelsAtPos( KDChartEnums::PosBottomCenter, true, true  );
00293        setPolarDelimsAndLabelsAtPos( KDChartEnums::PosBottomLeft,   true, true );
00294        setPolarDelimsAndLabelsAtPos( KDChartEnums::PosCenterLeft,   true, true );
00295        */
00296 
00297 
00298     // END POLAR CHART-SPECIFIC
00299 
00300     // PIE/RING CHART-SPECIFIC
00301     // Pie/ring charts do not explode by default.
00302     setExplode( false );
00303     // But if they do, the explode factor is 10%
00304     setExplodeFactor( 0.1 );
00305     // setExplodeValues() is not called for initialization, the default
00306     // empty list is the default.
00307     // Flat pies by default
00308     setThreeDPies( false );
00309     // Height of 3D effect
00310     setThreeDPieHeight( 20 );
00311     // Start of pie circle
00312     setPieStart( 0 );
00313     // Start of ring circle
00314     setRingStart( 0 );
00315     // Ring thickness is constant by default
00316     setRelativeRingThickness( false );
00317     // END PIE/RING CHART-SPECIFIC
00318 
00319 
00320     // HILO CHART-SPECIFIC
00321     // Simple HiLo charts by default
00322     setHiLoChartSubType( KDChartParams::HiLoSimple );
00323     setHiLoChartPrintLowValues( false );
00324     setHiLoChartPrintHighValues( false );
00325     setHiLoChartPrintOpenValues( false );
00326     setHiLoChartPrintCloseValues( false );
00327 
00328 
00329     // BOX+WHISKER CHART-SPECIFIC
00330     // Simple Box-and-Whisker charts by default
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     // LEGEND
00338     // Distance between legend and data.
00339     setLegendSpacing( 20 );
00340     // Position of the legend
00341     setLegendPosition( LegendRight );
00342     // Orientation of the legend
00343     setLegendOrientation( Qt::Vertical );
00344     // Whether the legend shall show lines or just
00345     // show the markers (or squares, resp.)
00346     setLegendShowLines( false );
00347     // Where the legend labels come from
00348     setLegendSource( LegendAutomatic );
00349     // legend texts are drawn in black by default
00350     setLegendTextColor( Qt::black );
00351     // legend font size is calculated dynamically, but ignore the font size
00352     setLegendFont( QFont( "helvetica", 10, QFont::Normal, false ), false );
00353     // legend font size is calculated dynamically:
00354     //                    20 / 1000 of the average value of
00355     //                                 the printable area height and width
00356     setLegendFontRelSize( 16 );
00357     // the default legend title is "Legend"
00358     setLegendTitleText( tr( "Legend" ) );
00359     // legend title is drawn in black by default
00360     setLegendTitleTextColor( Qt::black );
00361     // legend title font size is calculated dynamically, but ignore
00362     // the font size
00363     setLegendTitleFont( QFont( "helvetica", 12, QFont::Normal, false ), false );
00364     // legend title font size is calculated dynamically:
00365     //                    25 / 1000 of the average value of
00366     //                                 the printable area height and width
00367     setLegendTitleFontRelSize( 20 );
00368     // END LEGEND
00369 
00370 
00371     // AXES
00372 
00373     setDefaultAxesTypes();
00374     // activate bottom (ordinate) and left (abcissa) axis
00375     activateDefaultAxes();
00376 
00377     // END AXES
00378 
00379 
00380     // HEADERS/FOOTERS
00381 
00382     // Set a default font for all sections not taking the build-in
00383     // defaults from c'tor KDChartParams::HdFtParams::HdFtParams()
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     // END HEADERS/FOOTERS
00430 
00431     // PROPERTY SETS
00432     tempPropSetA->fullReset("normal data");
00433     setProperties(KDCHART_PROPSET_NORMAL_DATA, *tempPropSetA);
00434     // don't show the line, don't show the marker
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     // don't show line nor marker, but do show the horizontal line
00440     tempPropSetA->setName("horizontal line");
00441     tempPropSetA->setExtraLinesAlign(  KDChartPropertySet::OwnID, Qt::AlignLeft | Qt::AlignRight );
00442     setProperties(KDCHART_PROPSET_HORI_LINE, *tempPropSetA);
00443     // don't show line nor marker, but do show the vertical line
00444     tempPropSetA->setName("vertical line");
00445     tempPropSetA->setExtraLinesAlign(  KDChartPropertySet::OwnID, Qt::AlignTop | Qt::AlignBottom );
00446     setProperties(KDCHART_PROPSET_VERT_LINE, *tempPropSetA);
00447     // END PROPERTY SETS
00448 }
00449 
00450 
00454 KDChartParams::~KDChartParams()
00455 {
00456     KDChartAutoColor::freeInstance();
00457     delete tempPropSetA;
00458     delete tempPropSetB;
00459 }
00460 
00461 
00462 // GENERAL
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     // Removing the default property set is not allowed!
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 ); // reset all properties of rSet to the default !!
00630 
00631 //qDebug("in KDChartParams::calculateProperties():");
00632 //qDebug("   startId: %i",startId);
00633 //qDebug("   startSet: %s",startSet.name().latin1());
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         // c'tor sets all IDs to unknown by default
00659         KDChartPropertySet& propSet = *tempPropSetB;
00660         propSet.quickReset("");
00661         // PENDING(khz) replace the rustic depth counter i by a smart way
00662         // to quickly and safely recognize forbidden circular ID dependencies
00663         // *without* using this artificial maximal tree depth limitation.
00664         const int maxDepth = 1000;
00665         int i;
00666         int id;
00667         // retrieve lineWidth
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         // retrieve lineColor
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         // retrieve lineStyle
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         // markers at cell value position:
00699 
00700         // retrieve showMarker
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         // retrieve marker alignment
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         // retrieve marker size
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         // retrieve marker color
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         // retrieve marker style
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         // extra lines:
00752 
00753         // retrieve alignment of extra lines
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         // retrieve whether the extra lines shall be printed in front of the normal lines
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         // retrieve lineLength
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         // retrieve lineWidth
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         // retrieve lineColor
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         // retrieve lineStyle
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         // markers at the ends of the extra lines:
00815 
00816         // retrieve marker alignment
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         // retrieve marker size
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         // retrieve marker color
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         // retrieve marker style
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         // retrieve showBar
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         // retrieve barColor
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         // retrieve areaBrush
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                               // for values below zero:
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                               // for values greater/equal zero:
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                                // for values below zero:
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                                // for values greater/equal zero:
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                                // for values below zero:
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                                // for values greater/equal zero:
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                            // settings are not defined here because HiLo and BW charts
01187                            // are *not* set up using setPrintDataValues()
01188                            // but by using their own methods
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                               // for values below zero:
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                               // for values greater/equal zero:
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                                // for values below zero:
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                                // for values greater/equal zero:
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                                 // for values below zero:
01256                                 settings->_dataValuesAnchorNegativePosition = KDChartEnums::PosCenter;
01257                                 settings->_dataValuesAnchorNegativeAlign    = Qt::AlignCenter;
01258                                 settings->_dataValuesAnchorNegativeDeltaX   = 0;
01259                                 settings->_dataValuesAnchorNegativeDeltaY   = 0;
01260                                 settings->_dataValuesNegativeRotation       = 0;
01261                                 // for values greater/equal zero:
01262                                 settings->_dataValuesAnchorNegativePosition = KDChartEnums::PosCenter;
01263                                 settings->_dataValuesAnchorNegativeAlign    = Qt::AlignCenter;
01264                                 settings->_dataValuesAnchorNegativeDeltaX   = 0;
01265                                 settings->_dataValuesAnchorNegativeDeltaY   = 0;
01266                                 settings->_dataValuesNegativeRotation       = 0;
01267 
01268                                 //settings->_dataValuesLayoutPolicy = KDChartEnums::LayoutPolicyShrinkFontSize;
01269                                 //settings->_dataValuesFontRelSize = 26;
01270                                 //setDefaultAxesTypes();
01271                                 //finished = false;  // use build-in default params, see KDChartParams.h::setPrintDataValues()
01272                             }
01273                             break;
01274 
01275                 default: {
01276                              qDebug( "IMPLEMENTATION ERROR: Unknown chartType in setPrintDataValues()" );
01277                              finished = false;  // use build-in default params, see KDChartParams.h::setPrintDataValues()
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             // for values below zero:
01307             settings->_dataValuesAnchorNegativePosition = negativePosition;
01308             settings->_dataValuesAnchorNegativeAlign    = negativeAlign;
01309             settings->_dataValuesAnchorNegativeDeltaX   = negativeDeltaX;
01310             settings->_dataValuesAnchorNegativeDeltaY   = negativeDeltaY;
01311             settings->_dataValuesNegativeRotation       = negativeRotation;
01312             // for values greater/equal zero:
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() ) { // no fill color
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(); // documentation says undefined
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     // Simply reassign the available colors; this will trigger
01892     // recomputation of the shadow colors.
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(); // documentation says undefined
01923     else
01924         if( _dataColors.find( index ) != _dataColors.end() )
01925             return _dataColors[ index ];
01926         else
01927             return QColor(); // documentation says undefined
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(); // documentation says undefined
01952     else
01953         if( _dataColors.find( index ) != _dataColors.end() )
01954             return _dataColors[ index ];
01955         else
01956             return QColor(); // documentation says undefined
01957 }
01958 
01959 
01971 void KDChartParams::setDefaultAxesTypes()
01972 {
01973     // reset types of all axes
01974     uint i = 0;
01975     for ( i = 0; i < KDCHART_MAX_AXES; ++i )
01976         setAxisType( i, KDChartAxisParams::AxisTypeUnknown );
01977 
01978     // Note that abscissa axes should start labeling at the very
01979     // first position and end at the last position when drawing
01980     // area charts.
01981     // Bar charts and line charts look better with their abscissa labels
01982     // in the respective middle positions below each bar (or point, resp.)
01983     for ( i = KDChartAxisParams::AxisPosSTART;
01984             i <= KDChartAxisParams::AxisPosEND; ++i )
01985         switch ( i ) {
01986             // abscissa axes:
01987             case KDChartAxisParams::AxisPosBottom:
01988             case KDChartAxisParams::AxisPosTop:
01989             case KDChartAxisParams::AxisPosBottom2:
01990             case KDChartAxisParams::AxisPosTop2:
01991                 setAxisLabelsTouchEdges( i, Area == chartType() );
01992                 break;
01993                 // ordinate axes:
01994             case KDChartAxisParams::AxisPosLeft:
01995             case KDChartAxisParams::AxisPosRight:
01996             case KDChartAxisParams::AxisPosLeft2:
01997             case KDChartAxisParams::AxisPosRight2:
01998                 setAxisLabelsTouchEdges( i, true ); //Polar != chartType() );
01999                 break;
02000                 // additional axes for charts representing 3-dimensional data:
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     // set default axis types according to chart type
02014     switch ( chartType() ) {
02015         case NoType:
02016             break;
02017         case Bar:
02018         case Line:
02019         case Area:
02020             // default axes
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             // 'other side' axes
02030             setAxisType( KDChartAxisParams::AxisPosTop,
02031                     KDChartAxisParams::AxisTypeEAST );
02032             setAxisType( KDChartAxisParams::AxisPosRight,
02033                     KDChartAxisParams::AxisTypeNORTH );
02034             // additional, 2nd axes
02035             setAxisType( KDChartAxisParams::AxisPosBottom2,
02036                     KDChartAxisParams::AxisTypeEAST );
02037             setAxisType( KDChartAxisParams::AxisPosLeft2,
02038                     KDChartAxisParams::AxisTypeNORTH );
02039             // additional, 2nd axes for 'other' sides
02040             setAxisType( KDChartAxisParams::AxisPosTop2,
02041                     KDChartAxisParams::AxisTypeEAST );
02042             setAxisType( KDChartAxisParams::AxisPosRight2,
02043                     KDChartAxisParams::AxisTypeNORTH );
02044 
02045             // Specify default numbering information
02046             // for all 'non-ordinate' axes (this are the X axes):
02047             //
02048             // axisSteadyValueCalc flag is set to false
02049             // Start value 1
02050             // End value   following the number of entries
02051             //             in the associated dataset(s)
02052             // Delta value 1.0
02053             // and dont show any Digits behind the comma.
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             // no need to specify numbering information for
02072             // the ordinate-axes since the default auto-calc
02073             // feature is fine for here.
02074 
02075             break;
02076 
02077             // Code for charts representing 3-dimensional data.
02078 
02079             /*
02080 
02081             //   ( not active since there are no such charts yet )
02082 
02083             case KDChartParams::BarMatrix:
02084             // default axes
02085             setAxisType( KDChartAxisParams::AxisPosBottom,
02086             KDChartAxisParams::AxisTypeEAST );
02087             setAxisType( KDChartAxisParams::AxisPosLowerRightEdge,
02088             KDChartAxisParams::AxisTypeNORTH );
02089             setAxisType( KDChartAxisParams::AxisPosLeft,
02090             KDChartAxisParams::AxisTypeUP );
02091             // 'other side' axes
02092             setAxisType( KDChartAxisParams::AxisPosTop,
02093             KDChartAxisParams::AxisTypeEAST );
02094             setAxisType( KDChartAxisParams::AxisPosLowerLeftEdge,
02095             KDChartAxisParams::AxisTypeNORTH );
02096             setAxisType( KDChartAxisParams::AxisPosRight,
02097             KDChartAxisParams::AxisTypeUP );
02098             // additional, 2nd axes
02099             setAxisType( KDChartAxisParams::AxisPosBottom2,
02100             KDChartAxisParams::AxisTypeEAST );
02101             setAxisType( KDChartAxisParams::AxisPosLowerRightEdge2,
02102             KDChartAxisParams::AxisTypeNORTH );
02103             setAxisType( KDChartAxisParams::AxisPosLeft2,
02104             KDChartAxisParams::AxisTypeUP );
02105             // additional, 2nd axes for 'other' sides
02106             setAxisType( KDChartAxisParams::AxisPosTop2,
02107             KDChartAxisParams::AxisTypeEAST );
02108             setAxisType( KDChartAxisParams::AxisPosLowerLeftEdge2,
02109             KDChartAxisParams::AxisTypeNORTH );
02110             setAxisType( KDChartAxisParams::AxisPosRight2,
02111             KDChartAxisParams::AxisTypeUP );
02112 
02113             // Specify default numbering information
02114             // for all 'non-ordinate' axes (this are the X and the Y axes):
02115             // Start vaule 1
02116             // End value   following the number of entries
02117             //             in the associated dataset(s)
02118             // Delta value 1.0
02119             // and don't show any Digits behind the comma.
02120             setAxisLabelTextParams( KDChartAxisParams::AxisPosBottom,  false,
02121             1.0, KDCHART_AXIS_LABELS_AUTO_LIMIT, 1.0, 0 );
02122             setAxisLabelTextParams( KDChartAxisParams::AxisPosTop,     false,
02123             1.0, KDCHART_AXIS_LABELS_AUTO_LIMIT, 1.0, 0 );
02124             setAxisLabelTextParams( KDChartAxisParams::AxisPosLowerRightEdge,
02125             false,
02126             1.0, KDCHART_AXIS_LABELS_AUTO_LIMIT, 1.0, 0 );
02127             setAxisLabelTextParams( KDChartAxisParams::AxisPosLowerLeftEdge,
02128             false,
02129             1.0, KDCHART_AXIS_LABELS_AUTO_LIMIT, 1.0, 0 );
02130             setAxisLabelTextParams( KDChartAxisParams::AxisPosBottom2, false,
02131             1.0, KDCHART_AXIS_LABELS_AUTO_LIMIT, 1.0, 0 );
02132             setAxisLabelTextParams( KDChartAxisParams::AxisPosTop2,    false,
02133             1.0, KDCHART_AXIS_LABELS_AUTO_LIMIT, 1.0, 0 );
02134             setAxisLabelTextParams(KDChartAxisParams::AxisPosLowerRightEdge2,
02135             false,
02136             1.0, KDCHART_AXIS_LABELS_AUTO_LIMIT, 1.0, 0 );
02137             setAxisLabelTextParams( KDChartAxisParams::AxisPosLowerLeftEdge2,
02138             false,
02139             1.0, KDCHART_AXIS_LABELS_AUTO_LIMIT, 1.0, 0 );
02140 
02141             false,
02142             1.0, KDCHART_AXIS_LABELS_AUTO_LIMIT, 1.0, 0 );
02143 
02144             // no need to specify numbering information for
02145             // the ordinate-axes since the default auto-calc
02146             // feature is fine for here.
02147 
02148             break;
02149             */
02150 
02151         case KDChartParams::Pie:
02152         case KDChartParams::Ring:
02153             // by default there are no axes defined for pie and ring charts
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     // deactivate all axes: specifying KDCHART_NO_DATASET will
02191     //                      also remove their visability flag
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             /* test:
02206                setAxisVisible( KDChartAxisParams::AxisPosTop,    true );
02207                setAxisDatasets(KDChartAxisParams::AxisPosTop,    KDCHART_ALL_DATASETS );
02208                setAxisVisible( KDChartAxisParams::AxisPosRight,  true );
02209                setAxisDatasets(KDChartAxisParams::AxisPosRight,  KDCHART_ALL_DATASETS );
02210 
02211                setAxisVisible( KDChartAxisParams::AxisPosBottom2, true );
02212                setAxisDatasets(KDChartAxisParams::AxisPosBottom2, KDCHART_ALL_DATASETS );
02213                setAxisVisible( KDChartAxisParams::AxisPosLeft2,   true );
02214                setAxisDatasets(KDChartAxisParams::AxisPosLeft2,   KDCHART_ALL_DATASETS );
02215 
02216                setAxisVisible( KDChartAxisParams::AxisPosTop2,    true );
02217                setAxisDatasets(KDChartAxisParams::AxisPosTop2,    KDCHART_ALL_DATASETS );
02218                setAxisVisible( KDChartAxisParams::AxisPosRight2,  true );
02219                setAxisDatasets(KDChartAxisParams::AxisPosRight2,  KDCHART_ALL_DATASETS );
02220                */
02221             break;
02222             // Code for charts representing 3-dimensional data.
02223 
02224             /*
02225 
02226             //   ( not active since there are no such charts yet )
02227 
02228             case KDChartParams::BarMatrix:
02229             setAxisVisible( KDChartAxisParams::AxisPosBottom,         true );
02230             setAxisDatasets(KDChartAxisParams::AxisPosBottom, KDCHART_ALL_DATASETS );
02231             setAxisVisible( KDChartAxisParams::AxisPosLeft,           true );
02232             setAxisDatasets(KDChartAxisParams::AxisPosLeft,   KDCHART_ALL_DATASETS );
02233             setAxisVisible( KDChartAxisParams::AxisPosLowerRightEdge, true );
02234             setAxisDatasets(KDChartAxisParams::AxisPosLowerRightEdge,
02235             KDCHART_ALL_DATASETS);
02236             break;
02237             */
02238         case KDChartParams::Pie:
02239         case KDChartParams::Ring:
02240         case KDChartParams::Polar:
02241             // by default there are no axes defined for pie, ring, and polar charts
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, // important: we ignore the data3rd parameter for now!
02567                              uint newDataRow,
02568                              uint newDataCol,
02569                              uint// important: we ignore the data3rd parameter for now!
02570                              )
02571 {
02572     const QString oldKey( dataRegionFrameAreaName( oldDataRow, oldDataCol, 0 ) ); // oldData3rd ) );
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 ); // newData3rd );
02582             _areaDict.setAutoDelete( TRUE );
02583             _areaDict.insert(
02584                 dataRegionFrameAreaName( newDataRow, newDataCol, 0 ), //data3rd 5 ),
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; // we found a hole, so there might be more of them
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     // de-activate 2nd axis that might have been set automatically
02823     // by a previous call of \c setAdditionalChartType()
02824     setAxisVisible( KDChartAxisParams::AxisPosRight, false );
02825 
02826     // Make sure abscissa axes start their labeling at the very
02827     // first position and end at the last position when drawing
02828     // area charts.
02829     // Bar charts and line charts look better with their abscissa labels
02830     // in the respective middle positions below each bar (or point, resp.)
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     // activate default data value text settings for this chart type
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             // for values greater/equal zero:
03308             settings->_dataValuesAnchorPositivePosition = position;
03309             settings->_dataValuesAnchorPositiveAlign    = align;
03310             settings->_dataValuesAnchorPositiveDeltaX   = deltaX;
03311             settings->_dataValuesAnchorPositiveDeltaY   = deltaY;
03312             settings->_dataValuesPositiveRotation       = rotation;
03313         }else{
03314             // for values below zero:
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     // first store the color
03355     if( color )
03356         setPrintDataValuesColor( chart, color );
03357     // now store the background
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 /* sorry, but policy handling is not implemnted yet: */
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 /* function only there for backward compatibility */
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 // END GENERAL
04061 
04062 // START BARCHART
04068 
04171 void KDChartParams::setThreeDBarAngle( uint angle )
04172 {
04173     if ( angle > 90 )  /* since angle is an uint, we do not need to
04174                           test for < 0 */
04175         return ;
04176     _threeDBarAngle = angle;
04177 
04178     // cache the cosine of this value
04179     _cosThreeDBarAngle = cos( static_cast < double > ( _threeDBarAngle ) * M_PI / 180.0 );
04180     emit changed();
04181 }
04182 
04183 
04543 // END BARCHART
04544 
04545 // START LINECHART
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; // default
04663 }
04664 
04665 
04666 
04667 
04686 void KDChartParams::setLineMarkerStyles( LineMarkerStyleMap map ) {
04687     _lineMarkerStyles = map;
04688     // update _maxDatasetLineMarkerStyle
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         // global line style
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    \fn void KDChartParams::setThreeDLineXRotation( int degrees )
04933 
04934    Specifies the rotation around the X axis in degrees. The value
04935    may be between 0 and 90. Only used if chartType() == Line and
04936    threeDLines() == true. The default is 30 degrees. If 0 degrees is
04937    specified for both the X and the Y rotation, the lines will look
04938    like 2D lines.
04939 
04940    \param rotation the rotation in degrees. Must be between 0 and
04941    90.
04942    \sa setThreeDLines(), threeDLines(), threeDLineXRotation()
04943    */
04944 
04945 
04946 
04952 /*
04953    \fn int KDChartParams::threeDLineXRotation() const
04954 
04955    Returns the rotation around the X axis in degrees. The value may
04956    be between 0 and 90. Only used if chartType() == Line and
04957    threeDLines() == true. The default is 30 degrees.
04958 
04959    \return the rotation in degrees. Is always between 0 and 90.
04960    */
04961 
04962 
04968 /*
04969    \fn void KDChartParams::setThreeDLineYRotation( int degrees )
04970 
04971    Specifies the rotation around the Y axis in degrees. The value
04972    may be between 0 and 90. Only used if chartType() == Line and
04973    threeDLines() == true. The default is 30 degrees. If 0 degrees is
04974    specified for both the X and the Y rotation, the lines will look
04975    like 2D lines.
04976 
04977    \param rotation the rotation in degrees. Must be between 0 and
04978    90.
04979    \sa setThreeDLines(), threeDLines(), threeDLineYRotation()
04980    */
04981 
04987 /*
04988    \fn int KDChartParams::threeDLineYRotation() const
04989 
04990    Returns the rotation around the X axis in degrees. The value may
04991    be between 0 and 90. Only used if chartType() == Line and
04992    threeDLines() == true. The default is 30 degrees.
04993 
04994    \return the rotation in degrees. Is always between 0 and 90.
04995    */
04996 
04997 
05070 // END LINECHART
05071 
05072 // START POLARCHART
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; // default
05175 }
05176 
05177 
05196 void KDChartParams::setPolarMarkerStyles( PolarMarkerStyleMap map ) {
05197     _polarMarkerStyles = map;
05198     // update _maxDatasetPolarMarkerStyle
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 // END LINECHART
05366 
05367 // START RING/PIECHART
05373 
05662 // END RING/PIECHART
05663 
05664 // START HILO CHART
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 // END HILO CHART
06302 
06303 // START BOX/WHISKER CHART
06309                // use the following syntax to avoid warnings:
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 // END BOX/WHISKER CHART
06602 
06603 // START LEGENDS
06609 
07012 // END LEGENDS
07013 
07014 // START AXES
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 // END AXES
07444 
07445 // START HEADERFOOTER
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 // END HEADERFOOTER
08252 
08253 
08254 
08255 // PRIVATE VARIABLES
08558 
08559 
08580 // documentation of this member variable temporary disabled:
08581 // Feature is currently not supported, will be implemented
08582 // by future versions of KDChart
08583 /*
08584    \var int KDChartParams::_threeDLineXRotation;
08585 
08586    Stores the X rotation of 3D lines.
08587    */
08588 
08589 
08590 // documentation of this member variable temporary disabled:
08591 // Feature is currently not supported, will be implemented
08592 // by future versions of KDChart
08593 /*
08594    \var int KDChartParams::_threeDLineYRotation;
08595 
08596    Stores the Y rotation of 3D lines.
08597    */
08598 
08599 
08664 
08665 
08736 // PIES/RINGS
08793 // HI-LO CHARTS
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     // SGI IRIX: Compiling error.
09180     // QString titleString( setTitle ? axisTitle : "<qt><center> </center></qt>" );
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           //qDebug ("old Axis Title updated");
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         //qDebug("new Axis Title Box inserted");
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 }
KDE Home | KDE Accessibility Home | Description of Access Keys