Logo Search packages:      
Sourcecode: koffice version File versions

void KDChartAxesPainter::calculateLabelTexts ( const KDChartTableDataBase data,
const KDChartParams params,
uint  axisNumber,
double  averageValueP1000,
double  delimLen,
KDChartAxisParams::AxisPos &  basicPos,
QPoint &  orig,
QPoint &  dest,
double &  pXDeltaFactor,
double &  pYDeltaFactor,
double &  pXDelimDeltaFaktor,
double &  pYDelimDeltaFaktor,
double &  nSubDelimFactor,
double &  pDelimDelta,
double &  nTxtHeight,
double &  pTextsX,
double &  pTextsY,
double &  pTextsW,
double &  pTextsH,
int &  textAlign,
bool &  isLogarithmic,
bool &  isDateTime,
bool &  autoDtLabels,
QDateTime &  dtLow,
QDateTime &  dtHigh,
KDChartAxisParams::ValueScale &  dtDeltaScale,
bool  adjustTheValues = false,
double  trueDelta = 0.0,
double  trueDeltaPix = 0.0 
) [static, inherited]

Calculates the actual label texts for one axis.

Note:
When calling this function the actual area size for this axis must be set, this means you may only call it when KDChartPainter::setupGeometry() has been called before.
Parameters:
painter the QPainter onto which the chart should be painted
data the data that will be displayed as a chart
params the KDChartParams that were specified globally
axisNumber the number of this axis (used in some params structures)
averageValueP1000 (average height+width of the prtbl. area) / 1000
basicPos the basic axis position returned by KDChartAxisParams::basicAxisPos()
orig the axis start point
delimLen the length of one delimiter mark
(all others) the reference parameters to be returned by this function

Definition at line 1916 of file KDChartAxesPainter.cpp.

References KDChartParams::additionalChartType(), KDChartParams::areaChartSubType(), KDChartAxisParams::AXIS_IGNORE_EMPTY_INNER_SPAN, KDChartAxisParams::AXIS_LABELS_AUTO_DATETIME_FORMAT, KDChartAxisParams::AXIS_LABELS_AUTO_DELTA, KDChartAxisParams::AXIS_LABELS_AUTO_DIGITS, KDChartAxisParams::AXIS_LABELS_AUTO_LIMIT, KDChartAxisParams::axisCalcMode(), KDChartParams::axisDatasets(), KDChartAxisParams::axisDigitsBehindComma(), KDChartAxisParams::axisLabelsBlockAlign(), KDChartAxisParams::axisLabelsDateTimeFormat(), KDChartAxisParams::axisLabelsDecimalPoint(), KDChartAxisParams::axisLabelsDigitsBehindComma(), KDChartAxisParams::axisLabelsDivPow10(), KDChartAxisParams::axisLabelsFont(), KDChartAxisParams::axisLabelsFontRelSize(), KDChartAxisParams::axisLabelsFontUseRelSize(), KDChartAxisParams::axisLabelsPadFill(), KDChartAxisParams::axisLabelsPostfix(), KDChartAxisParams::axisLabelsPrefix(), KDChartAxisParams::axisLabelsThousandsPoint(), KDChartAxisParams::axisLabelsTotalLen(), KDChartAxisParams::axisLabelTextsFormDataRow(), KDChartParams::axisParams(), KDChartAxisParams::axisSteadyValueCalc(), KDChartAxisParams::axisTrueAreaRect(), KDChartAxisParams::axisValueDelta(), KDChartParams::barChartSubType(), KDChartAxisParams::basicAxisPos(), KDChartAxesPainter::calculateBasicTextFactors(), KDChartAxesPainter::calculateOrdinateFactors(), KDChartTableDataBase::cell(), KDChartTableDataBase::cellsHaveSeveralCoordinates(), KDChartTableDataBase::cellsValueType(), KDChartParams::chartType(), KDChartData::doubleValue(), KDChartParams::findDatasets(), KDChartData::isDouble(), KDChartData::isString(), KDChartAxisParams::labelTextsDataRow(), KDChartParams::lineChartSubType(), KDChartTableDataBase::maxColSum(), KDChartTableDataBase::maxDtInRows(), KDChartTableDataBase::maxDtValue(), KDChartTableDataBase::maxInRows(), KDChartTableDataBase::maxValue(), KDChartTableDataBase::minColSum(), KDChartTableDataBase::minDtInRows(), KDChartTableDataBase::minDtValue(), KDChartTableDataBase::minInRows(), KDChartTableDataBase::minValue(), KDChartParams::polarChartSubType(), KDChartParams::roundVal(), KDChartData::stringValue(), KDChartTableDataBase::usedCols(), and KDChartTableDataBase::usedRows().

Referenced by KDChartPolarPainter::paintData().

{
//qDebug("\nentering KDChartAxesPainter::calculateLabelTexts() :   nTxtHeight: "+QString::number(nTxtHeight));
    const KDChartAxisParams & para = params.axisParams( axisNumber );

    basicPos = KDChartAxisParams::basicAxisPos( axisNumber );

    pXDeltaFactor = 0.0;
    pYDeltaFactor = 0.0;
    pXDelimDeltaFaktor = 0.0;
    pYDelimDeltaFaktor = 0.0;
    int axisLength;
    switch ( basicPos ) {
        case KDChartAxisParams::AxisPosBottom: {
                                                   axisLength = para.axisTrueAreaRect().width();
                                                   orig = para.axisTrueAreaRect().topLeft();
                                                   dest = para.axisTrueAreaRect().topRight();
                                                   pYDelimDeltaFaktor = 1.0;
                                                   pXDeltaFactor      = 1.0;
                                                   //qDebug("\nsetting pXDeltaFactor for axis %x", axisNumber);
                                                   //qDebug("pXDeltaFactor = %f\n",pXDeltaFactor);
                                               }
                                               break;
        case KDChartAxisParams::AxisPosLeft: {
                                                 axisLength = para.axisTrueAreaRect().height();
                                                 orig = para.axisTrueAreaRect().bottomRight();
                                                 dest = para.axisTrueAreaRect().topRight();
                                                 pXDelimDeltaFaktor = -1.0;
                                                 pYDeltaFactor      = -1.0;
                                             }
                                             break;
        case KDChartAxisParams::AxisPosTop: {
                                                axisLength = para.axisTrueAreaRect().width();
                                                orig = para.axisTrueAreaRect().bottomLeft();
                                                dest = para.axisTrueAreaRect().bottomRight();
                                                pYDelimDeltaFaktor = -1.0;
                                                pXDeltaFactor      =  1.0;
                                            }
                                            break;
        case KDChartAxisParams::AxisPosRight: {
                                                  axisLength = para.axisTrueAreaRect().height();
                                                  orig = para.axisTrueAreaRect().bottomLeft();
                                                  dest = para.axisTrueAreaRect().topLeft();
                                                  pXDelimDeltaFaktor = 1.0;
                                                  pYDeltaFactor      = -1.0;
                                              }
                                              break;
        default: {
                     axisLength = 0;
                     qDebug( "IMPLEMENTATION ERROR: KDChartAxesPainter::paintAxes() unhandled enum value." );
                 }
                 break;
    }

    // which dataset(s) is/are represented by this axis?
    uint dataset, dataset2, chart;
    if ( !params.axisDatasets( axisNumber, dataset, dataset2, chart ) ) {
        dataset = KDChartParams::KDCHART_ALL_DATASETS;
        dataset2 = KDChartParams::KDCHART_ALL_DATASETS;
        chart = 0;
        //qDebug("\nautomatic set values:   chart: %u,\ndataset: %u,  dataset2: %u",
        //chart, dataset, dataset2);
    }
    // which dataset(s) with mode DataEntry (or mode ExtraLinesAnchor, resp.)
    // is/are represented by this axis?
    uint dataDataset, dataDataset2;
    if( params.findDatasets( KDChartParams::DataEntry,
                             KDChartParams::ExtraLinesAnchor,
                             dataDataset,
                             dataDataset2,
                             chart ) ) {
        // adjust dataDataset in case MORE THAN ONE AXIS
        //                    is representing THIS CHART
        if(    (    KDChartParams::KDCHART_ALL_DATASETS != dataset
                 && KDChartParams::KDCHART_NO_DATASET   != dataset )
            || (    KDChartParams::KDCHART_ALL_DATASETS != dataDataset
                 && KDChartParams::KDCHART_NO_DATASET   != dataDataset ) ){
            int ds = (KDChartParams::KDCHART_ALL_DATASETS != dataset)
                   ? dataset
                   : 0;
            int dds = (KDChartParams::KDCHART_ALL_DATASETS != dataDataset)
                    ? dataDataset
                    : 0;
            dataDataset  = QMAX( ds, dds );
        }
        if(    (    KDChartParams::KDCHART_ALL_DATASETS != dataset2
                 && KDChartParams::KDCHART_NO_DATASET   != dataset2 )
            || (    KDChartParams::KDCHART_ALL_DATASETS != dataDataset2
                 && KDChartParams::KDCHART_NO_DATASET   != dataDataset2 ) ){
            int ds2 = (KDChartParams::KDCHART_ALL_DATASETS != dataset2)
                    ? dataset2
                    : KDCHART_MAX_AXES-1;
            int dds2 = (KDChartParams::KDCHART_ALL_DATASETS != dataDataset2)
                     ? dataDataset2
                     : KDCHART_MAX_AXES-1;
            dataDataset2  = QMIN( ds2, dds2 );
        }
    }
    else {
        // Should not happen
        qDebug( "IMPLEMENTATION ERROR: findDatasets( DataEntry, ExtraLinesAnchor ) should *always* return true. (b)" );
        dataDataset = KDChartParams::KDCHART_ALL_DATASETS;
    }
    //qDebug("\naxisNumber: %x\nchart: %x\ndataset: %x,  dataset2: %x,\ndataDataset: %x,  dataDataset2: %x",
    //axisNumber, chart, dataset, dataset2, dataDataset, dataDataset2);

    if ( para.axisLabelsFontUseRelSize() ){
        nTxtHeight = para.axisLabelsFontRelSize()
            * averageValueP1000;
//qDebug("using rel. size in KDChartAxesPainter::calculateLabelTexts() :   nTxtHeight: "+QString::number(nTxtHeight));
    }else {
        QFontInfo info( para.axisLabelsFont() );
        nTxtHeight = info.pointSize();
//qDebug("using FIXED size in KDChartAxesPainter::calculateLabelTexts() :   nTxtHeight: "+QString::number(nTxtHeight));
    }

    const int     behindComma    = para.axisDigitsBehindComma();
    const int     divPow10       = para.axisLabelsDivPow10();
    const QString decimalPoint   = para.axisLabelsDecimalPoint();
    const QString thousandsPoint = para.axisLabelsThousandsPoint();
    const QString prefix         = para.axisLabelsPrefix();
    const QString postfix        = para.axisLabelsPostfix();
    const int     totalLen       = para.axisLabelsTotalLen();
    const QChar   padFill        = para.axisLabelsPadFill();
    const bool    blockAlign     = para.axisLabelsBlockAlign();

    QStringList labelTexts;
    int colNum = para.labelTextsDataRow();
    bool bDone = true;
    switch ( para.axisLabelTextsFormDataRow() ) {
        case KDChartAxisParams::LabelsFromDataRowYes: {
            // Take whatever is in the specified column (even if not a string)
            QString sVal;
            int trueBehindComma = -1;
            for ( uint iDataset = 0; iDataset < data.usedRows(); iDataset++ ) {
                const KDChartData& cell = data.cell( iDataset, colNum );
                if ( cell.isString() )
                    labelTexts.append( cell.stringValue() );
                else
                    labelTexts.append( applyLabelsFormat( cell.doubleValue(),
                                                          divPow10,
                                                          behindComma,
                                                          para.axisValueDelta(),
                                                          trueBehindComma,
                                                          decimalPoint,
                                                          thousandsPoint,
                                                          prefix,
                                                          postfix,
                                                          totalLen,
                                                          padFill,
                                                          blockAlign ) );
            }
            break;
        }
        case KDChartAxisParams::LabelsFromDataRowGuess: {
            for ( uint iDataset = 0; iDataset < data.usedRows(); iDataset++ ) {
                const KDChartData& cell = data.cell( iDataset, colNum );
                if ( cell.isString()
                        && !cell.stringValue().isEmpty()
                        && !cell.stringValue().isNull() )
                    labelTexts.append( cell.stringValue() );
                else {
                    labelTexts.clear();
                    bDone = false;
                    break;
                }
            }
            break;
        }
        case KDChartAxisParams::LabelsFromDataRowNo: {
            bDone = false;
            break;
        }
        default:
            // Should not happen
            qDebug( "KDChart: Unknown label texts source" );
    }

    // if necessary adjust text params *including* the steady value calc setting
    const bool dataCellsHaveSeveralCoordinates =
        (KDChartParams::KDCHART_ALL_DATASETS == dataDataset)
        ? data.cellsHaveSeveralCoordinates()
        : data.cellsHaveSeveralCoordinates( dataDataset, dataDataset2 );
    if( dataCellsHaveSeveralCoordinates && !para.axisSteadyValueCalc() )
        ((KDChartParams&)params).setAxisLabelTextParams(
            axisNumber,
            true,
            KDChartAxisParams::AXIS_LABELS_AUTO_LIMIT,
            KDChartAxisParams::AXIS_LABELS_AUTO_LIMIT,
            KDChartAxisParams::AXIS_LABELS_AUTO_DELTA,
            para.axisLabelsDigitsBehindComma() );// NOTE: This sets MANY other params to default values too!


    const KDChartParams::ChartType params_chartType
        = ( 0 == chart )
        ? params.chartType()
        : params.additionalChartType();


    // store whether we are calculating Ordinate-like axis values
    const bool bSteadyCalc = para.axisSteadyValueCalc();

    // store whether we logarithmic calculation is wanted
    isLogarithmic = bSteadyCalc &&
            (KDChartParams::Line == params_chartType) &&
            (KDChartAxisParams::AxisCalcLogarithmic == para.axisCalcMode());

    //qDebug(bSteadyCalc ? "bSteadyCalc":"NOT bSteadyCalc");
    //qDebug(isLogarithmic? "isLogarithmic":"NOT isLogarithmic");

    // store whether this is a vertical axis or a horizontal axis
    const bool bVertAxis = (KDChartAxisParams::AxisPosLeft  == basicPos) ||
                           (KDChartAxisParams::AxisPosRight == basicPos);

    // store the coordinate number to be used for this axis
    const int coordinate = bVertAxis ? 1 : 2;

    // store whether our coordinates are double or QDateTime values
    const KDChartData::ValueType valueType =
        (KDChartParams::KDCHART_ALL_DATASETS == dataDataset)
        ? data.cellsValueType(                            coordinate )
        : data.cellsValueType( dataDataset, dataDataset2, coordinate );
    isDateTime = valueType == KDChartData::DateTime;
    bool bIsDouble = valueType == KDChartData::Double;

    autoDtLabels = isDateTime && ( KDChartAxisParams::AXIS_LABELS_AUTO_DATETIME_FORMAT
            == para.axisLabelsDateTimeFormat() );

    if( autoDtLabels || bSteadyCalc )
        ( ( KDChartAxisParams& ) para ).setAxisLabelsTouchEdges( true );

    bool bStatistical = KDChartParams::HiLo       == params_chartType
        || KDChartParams::BoxWhisker == params_chartType;

    if ( !bVertAxis && KDChartParams::BoxWhisker == params_chartType
                    && ! para.axisLabelStringCount() ) {
        uint ds1 = (KDChartParams::KDCHART_ALL_DATASETS == dataDataset)
            ? 0
            : dataDataset;
        uint ds2 = (KDChartParams::KDCHART_ALL_DATASETS == dataDataset)
            ? data.usedRows() - 1
            : dataDataset2;
        for (uint i = ds1; i <= ds2; ++i)
            labelTexts.append(
                    QObject::tr( "Series " ) + QString::number( i + 1 ) );
        bDone = true;
    }

    double nLow   =  1.0;
    double nHigh  = 10.0;
    double nDelta =  1.0;
    if ( !bDone ) {
        bDone = true;

        // look if exact label specification was made via limits and delta
        if (       ! isLogarithmic
                && ! para.axisLabelStringCount()
                && ! ( KDChartAxisParams::AXIS_LABELS_AUTO_LIMIT == para.axisValueStart() )
                && para.axisValueStart().isDouble()
                && ! ( KDChartAxisParams::AXIS_LABELS_AUTO_LIMIT == para.axisValueEnd() )
                && para.axisValueEnd().isDouble()
                && ! ( para.axisValueStart() == para.axisValueEnd() )
                && ! ( KDChartAxisParams::AXIS_LABELS_AUTO_DELTA == para.axisValueDelta() )
                && ! ( 0.0 == para.axisValueDelta() ) ) {
            nLow   = para.axisValueStart().doubleValue();
            nHigh  = para.axisValueEnd().doubleValue();
            nDelta = para.axisValueDelta();
            int behindComma = para.axisDigitsBehindComma();
            int trueBehindComma = -1;
            bool upwards = (nLow < nHigh);
            if( upwards != (0.0 < nDelta) )
                nDelta *= -1.0;
            double nVal = nLow;
            bDone = false;
            while( upwards ? (nVal <= nHigh) : (nVal >= nHigh) ){
                labelTexts.append( applyLabelsFormat( nVal,
                                                      divPow10,
                                                      behindComma,
                                                      nDelta,
                                                      trueBehindComma,
                                                      decimalPoint,
                                                      thousandsPoint,
                                                      prefix,
                                                      postfix,
                                                      totalLen,
                                                      padFill,
                                                      blockAlign ) );
                nVal += nDelta;
                bDone = true;
            }
            ( ( KDChartAxisParams& ) para ).setTrueAxisLowHighDelta( nLow, nHigh, nDelta );
            //qDebug("\n[Z-0] nLow: %f,  nHigh: %f,  nDelta: %f", nLow, nHigh, nDelta );
        }         // look if a string list was specified
        else if ( para.axisLabelStringCount() ) {
            int nLabels = bSteadyCalc
                ? para.axisLabelStringCount()
                : bStatistical ? data.usedRows() : data.usedCols();
            calculateBasicTextFactors( nTxtHeight, para, averageValueP1000,
                    basicPos, orig, delimLen, nLabels,
                    // start of return parameters
                    pDelimDelta,
                    pTextsX, pTextsY, pTextsW, pTextsH,
                    textAlign );
            bool useShortLabels = false;
            QStringList tmpList( para.axisLabelStringList() );

            // find start- and/or end-entry
            int iStart = 0;
            int iEnd = para.axisLabelStringCount() - 1;
            if(    ! ( KDChartAxisParams::AXIS_LABELS_AUTO_LIMIT == para.axisValueStart() )
                || ! ( KDChartAxisParams::AXIS_LABELS_AUTO_LIMIT == para.axisValueEnd() ) ) {
                bool testStart = !( KDChartAxisParams::AXIS_LABELS_AUTO_LIMIT
                        == para.axisValueStart()
                        && para.axisValueStart().isString() );
                bool testEnd = !( KDChartAxisParams::AXIS_LABELS_AUTO_LIMIT
                        == para.axisValueEnd()
                        && para.axisValueEnd().isString() );
                QString sStart = testStart
                    ? para.axisValueStart().stringValue().upper()
                    : QString::null;
                QString sEnd = testEnd
                    ? para.axisValueEnd().stringValue().upper()
                    : QString::null;

                uint i = 0;
                for ( QStringList::Iterator it = tmpList.begin();
                        it != tmpList.end(); ++it, ++i ) {
                    if ( 0 == iStart &&
                         0 == QString::compare( sStart, ( *it ).upper() ) ) {
                        iStart = i;
                    }
                    if ( 0 == QString::compare( sEnd, ( *it ).upper() ) ) {
                        iEnd = i;
                    }
                }
            }

            // check text widths to ensure all the entries will fit
            // into the available space
            if (    para.axisLabelStringCount()
                 && para.axisShortLabelsStringCount()
                 && para.axisLabelStringList() != para.axisShortLabelsStringList() ) {
                QFont font( para.axisLabelsFont() );
                if ( para.axisLabelsFontUseRelSize() )
                    font.setPointSizeFloat( nTxtHeight );
                QFontMetrics fm( font );

                QStringList::Iterator it = tmpList.begin();
                for ( int i = 0; i < nLabels; ++i ) {
                    if ( it != tmpList.end() ) {
                        if ( fm.width( *it ) > pTextsW ) {
                            useShortLabels = true;
                            break;
                        }
                        ++it;
                    }
                }
            }
            if ( useShortLabels )
                tmpList = para.axisShortLabelsStringList();
            else
                tmpList = para.axisLabelStringList();

            // prepare transfering the strings into the labelTexts list
            double ddelta
                = ( KDChartAxisParams::AXIS_LABELS_AUTO_DELTA == para.axisValueDelta() )
                ? 1.0
                : para.axisValueDelta();
            modf( ddelta, &ddelta );
            bool positive = ( 0.0 <= ddelta );
            int delta = static_cast < int > ( fabs( ddelta ) );
            // find 1st significant entry
            QStringList::Iterator it = positive
                ? tmpList.begin()
                : tmpList.fromLast();
            if ( positive )
                for ( int i = 0; i < (int)tmpList.count(); ++i ) {
                    if ( i >= iStart )
                        break;
                    ++it;
                }
            else
                for ( int i = tmpList.count() - 1; i >= 0; --i ) {
                    if ( i <= iEnd )
                        break;
                    --it;
                }
            // transfer the strings
            int meter = delta;
            int i2 = positive ? iStart : iEnd;
            for ( int iLabel = 0; iLabel < nLabels; ) {
                if ( positive ) {
                    if ( it == tmpList.end() ) {
                        it = tmpList.begin();
                        i2 = 0;
                    }
                } else {
                    if ( it == tmpList.begin() ) {
                        it = tmpList.end();
                        i2 = tmpList.count();
                    }
                }
                if ( ( positive && i2 >= iStart )
                        || ( !positive && i2 <= iEnd ) ) {
                    if ( meter >= delta ) {
                        labelTexts << *it;
                        ++iLabel;
                        meter = 1;
                    } else {
                        meter += 1;
                    }
                }
                if ( positive ) {
                    if ( i2 == iEnd ) {
                        it = tmpList.begin();
                        i2 = 0;
                    } else {
                        ++it;
                        ++i2;
                    }
                } else {
                    if ( i2 == iStart ) {
                        it = tmpList.end();
                        i2 = tmpList.count();
                    } else {
                        --it;
                        --i2;
                    }
                }
            }
        } else {
            // find out if the associated dataset contains only strings
            // if yes, we will take these as label texts
            uint dset = ( dataset == KDChartParams::KDCHART_ALL_DATASETS ) ? 0 : dataset;
            //qDebug("\ndset: %u", dset);
            bDone = false;
            for ( uint col = 0; col < data.usedCols(); ++col ) {
                const KDChartData& cell = data.cell( dset, col );
                if ( cell.isString()
                        && !cell.stringValue().isEmpty()
                        && !cell.stringValue().isNull() ){
                    labelTexts.append( cell.stringValue() );
                    bDone = true;
                }else{
                    labelTexts.clear();
                    break;
                }
            }
        }
    }


    if ( bDone ) {
        // Some strings were found, now let us see which of them are
        // actually to be taken right now.
        //
        //
        //   F E A T U R E   P L A N N E D   F O R   F U T U R E . . .
        //
        //
    }
    else {
        // No strings were found, so let us either calculate the texts
        // based upon the numerical values of the associated dataset(s)
        // or just compose some default texts...
        if ( data.usedCols() && bSteadyCalc ) {
            // double values for numerical coordinates
            double nLow = 0.0;
            double nHigh = 0.0;
            double orgLow = 0.0;
            double orgHigh = 0.0;
            double nDelta = 0.0;
            double nDist = 0.0;

            //  VERTICAL axes support three modes:
            enum { Normal, Stacked, Percent } mode;

            if( bVertAxis ){
                switch ( params_chartType ) {
                    case KDChartParams::Bar:
                        if ( KDChartParams::BarStacked
                                == params.barChartSubType() )
                            mode = Stacked;
                        else if ( KDChartParams::BarPercent
                                == params.barChartSubType() )
                            mode = Percent;
                        else
                            mode = Normal;
                        break;
                    case KDChartParams::Line:
                        if ( KDChartParams::LineStacked
                                == params.lineChartSubType() )
                            mode = Stacked;
                        else if ( KDChartParams::LinePercent
                                == params.lineChartSubType() )
                            mode = Percent;
                        else
                            mode = Normal;
                        break;
                    case KDChartParams::Area:
                        if ( KDChartParams::AreaStacked
                                == params.areaChartSubType() )
                            mode = Stacked;
                        else if ( KDChartParams::AreaPercent
                                == params.areaChartSubType() )
                            mode = Percent;
                        else
                            mode = Normal;
                        break;
                    case KDChartParams::HiLo:
                    case KDChartParams::BoxWhisker:
                        mode = Normal;
                        break;
                    case KDChartParams::Polar:
                        if ( KDChartParams::PolarStacked
                                == params.polarChartSubType() )
                            mode = Stacked;
                        else if ( KDChartParams::PolarPercent
                                == params.polarChartSubType() )
                            mode = Percent;
                        else
                            mode = Normal;
                        break;
                    default: {
                                 // Should not happen
                                 qDebug( "IMPLEMENTATION ERROR: Unknown params_chartType in calculateLabelTexts()" );
                                 mode = Normal;
                             }
                }
            }else
                mode = Normal; // this axis is not a vertical axis


            uint nLabels = 200;

            // find highest and lowest value of associated dataset(s)
            bool bOrdFactorsOk = false;

            if( adjustTheValues ){
                nDelta = fabs( trueDelta );
                pDelimDelta = trueDeltaPix;
                nLow = QMIN( para.trueAxisLow(), para.trueAxisHigh() );
                //qDebug("\nsearching: para.trueAxisLow() %f    para.trueAxisHigh() %f",para.trueAxisLow(),para.trueAxisHigh());
                double orgLow( nLow );
                modf( nLow / nDelta, &nLow );
                nLow *= nDelta;
                if ( nLow > orgLow )
                    nLow -= nDelta;
                if ( 0.0 < nLow && 0.0 >= orgLow )
                    nLow = 0.0;
                nHigh = nLow;
                double dx = fabs( pXDeltaFactor * pDelimDelta );
                double dy = fabs( pYDeltaFactor * pDelimDelta );
                double x = 0.0;
                double y = 0.0;
                nLabels = 1;
                if( axisLength ){
                    do{
                        ++nLabels;
                        nHigh += nDelta;
                        x += dx;
                        y += dy;
                    }while( x < axisLength && y < axisLength );
                    nHigh -= nDelta;
                    --nLabels;
                }
                nDist = nHigh - nLow;
                bOrdFactorsOk = true;

            }

            if( !bOrdFactorsOk ){
                const bool bAutoCalcStart =
                       ( Percent != mode )
                    && ( KDChartAxisParams::AXIS_LABELS_AUTO_LIMIT == para.axisValueStart() );
                const bool bAutoCalcEnd =
                       ( Percent != mode )
                    && ( KDChartAxisParams::AXIS_LABELS_AUTO_LIMIT == para.axisValueEnd() );

                if( !bIsDouble && !isDateTime ){
                    // no data at all: let us use our default 0..10 range
                    nLow   = 0.0;
                    nHigh  = 10.0;
                    nDist  = 10.0;
                    nDelta = 1.0;
                    nSubDelimFactor = 0.5;
                    bIsDouble     = true;
                    bOrdFactorsOk = true;
                }else if( mode == Percent ){
                    // precentage mode: we use a 0..100 range
                    nLow   =   0.0;
                    nHigh  = 100.0;
                    nDist  = 100.0;
                    nDelta =  10.0;
                    nSubDelimFactor = 0.25;
                    bOrdFactorsOk = true;
                }else{
                    // get the raw start value
                    const bool bStackedMode = (mode == Stacked);
                    if( bAutoCalcStart ){
                        if ( dataDataset == KDChartParams::KDCHART_ALL_DATASETS ) {
                            if( bIsDouble ){
                                nLow = bStackedMode
                                     ? QMIN( data.minColSum(), 0.0 )
                                     : data.minValue( coordinate );
                            }else{
                                dtLow = data.minDtValue( coordinate );
                            }
                        } else {
                            if( bIsDouble ){
                                nLow = bStackedMode
                                     ? QMIN( data.minColSum( dataDataset, dataDataset2 ),
                                             0.0 )
                                     : data.minInRows( dataDataset,dataDataset2,
                                                       coordinate );
                            }else{
                                dtLow = data.minDtInRows( dataDataset,dataDataset2,
                                                          coordinate );
                            }
                        }
                    }else{
                        if( bIsDouble )
                            nLow  = para.axisValueStart().doubleValue();
                        else
                            dtLow = para.axisValueStart().dateTimeValue( coordinate );
                    }

                    // get the raw end value
                    if( bAutoCalcEnd ){
                        if ( dataDataset == KDChartParams::KDCHART_ALL_DATASETS ) {
                            if( bIsDouble )
                                nHigh = bStackedMode
                                      ? QMAX( data.maxColSum(), 0.0 )
                                      : data.maxValue( coordinate );
                            else
                                dtHigh = data.maxDtValue( coordinate );
                        } else {
                            if( bIsDouble )
                                nHigh = bStackedMode
                                      ? QMAX( data.maxColSum( dataDataset, dataDataset2 ),
                                              0.0 )
                                      : data.maxInRows( dataDataset,dataDataset2,
                                                        coordinate );
                            else
                                dtHigh = data.maxDtInRows( dataDataset,dataDataset2,
                                                          coordinate );
                        }
                    }else{
                        if( bIsDouble )
                            nHigh  = para.axisValueEnd().doubleValue();
                        else
                            dtHigh = para.axisValueEnd().dateTimeValue( coordinate );
                    }
                }

                if( bIsDouble ) {
                    if(    DBL_MAX == nLow
                        || (    ( 0.0 == nHigh || 0 == nHigh )
                             && ( 0.0 == nLow  || 0 == nLow  ) ) ) {
                        // qDebug("NO values or all values have ZERO value, showing 0.0 - 10.0 span");
                        nLow   = 0.0;
                        nHigh  = 10.0;
                        nDist  = 10.0;
                        nDelta = 1.0;
                        nSubDelimFactor = 0.5;
                        bOrdFactorsOk = true;
                        //qDebug("nLow: %f,  nHigh: %f", nLow, nHigh);
                    }else if( nLow == nHigh ){
                        // if both values are equal, but NOT Zero
                        // -> move the appropriate one to Zero
                        if( nLow < 0.0 )
                            nHigh = 0.0;
                        else
                            nLow = 0.0;
                        //qDebug("nLow: %f,  nHigh: %f", nLow, nHigh);
                    }else if( nHigh < nLow ){
                        // make sure nLow is <= nHigh
                        double nTmp = nLow;
                        nLow = nHigh;
                        nHigh = nTmp;
                    }
                } else if( isDateTime ){
                    bool toggleDts = dtLow > dtHigh;
                    if( toggleDts ) {
                        QDateTime dt( dtLow );
                        dtLow = dtHigh;
                        dtHigh = dt;
                    }
                    double secDist = dtLow.secsTo( dtHigh );
                    secDist += (dtHigh.time().msec() - dtLow.time().msec()) / 1000.0;
                    const double aDist = fabs( secDist );
                    const double secMin   = 60.0;
                    const double secHour  = 60.0 * secMin;
                    const double secDay   = 24.0 * secHour;
                    //
                    // we temporarily disable week alignment until bug
                    // is fixed (1st week of year must not start in the
                    // preceeding year but rather be shown incompletely)
                    //
                    //                                 (khz, 2003/10/10)
                    //
                    //const int secWeek  =  7 * secDay;
                    const double secMonth = 30 * secDay;   // approx.
                    const double secYear  = 12 * secMonth; // approx.
                    if(      2.0*secMin > aDist )
                        dtDeltaScale = KDChartAxisParams::ValueScaleSecond;
                    else if( 2.0*secHour > aDist )
                        dtDeltaScale = KDChartAxisParams::ValueScaleMinute;
                    else if( 2.0*secDay > aDist )
                        dtDeltaScale = KDChartAxisParams::ValueScaleHour;
                    // khz: else if( 2*secWeek > aDist )
                    // khz:    dtDeltaScale = KDChartAxisParams::ValueScaleDay;
                    else if( 2.0*secMonth > aDist )
                        dtDeltaScale = KDChartAxisParams::ValueScaleDay;
                    // khz: dtDeltaScale = KDChartAxisParams::ValueScaleWeek;

                    else if( 2.0*secYear > aDist )
                        dtDeltaScale = KDChartAxisParams::ValueScaleMonth;
                    else if( 10.0*secYear > aDist )
                        dtDeltaScale = KDChartAxisParams::ValueScaleQuarter;
                    else
                        dtDeltaScale = KDChartAxisParams::ValueScaleYear;


                    //const int yearLow   = dtLow.date().year();
                    const int monthLow  = dtLow.date().month();
                    // khz: currently unused: const int dowLow    = dtLow.date().dayOfWeek();
                    const int dayLow    = dtLow.date().day();
                    const int hourLow   = dtLow.time().hour();
                    const int minuteLow = dtLow.time().minute();
                    const int secondLow = dtLow.time().second();

                    //const int yearHigh   = dtHigh.date().year();
                    const int monthHigh  = dtHigh.date().month();
                    // khz: currently unused: const int dowHigh    = dtHigh.date().dayOfWeek();
                    const int hourHigh   = dtHigh.time().hour();
                    const int minuteHigh = dtHigh.time().minute();
                    const int secondHigh = dtHigh.time().second();
                    int yearLowD   = 0;
                    int monthLowD  = 0;
                    int dayLowD    = 0;
                    int hourLowD   = 0;
                    int minuteLowD = 0;
                    int secondLowD = 0;
                    int yearHighD   = 0;
                    int monthHighD  = 0;
                    int dayHighD    = 0;
                    int hourHighD   = 0;
                    int minuteHighD = 0;
                    int secondHighD = 0;
                    bool gotoEndOfMonth = false;
                    switch( dtDeltaScale ) {
                        case KDChartAxisParams::ValueScaleSecond:
                            //qDebug("\nKDChartAxisParams::ValueScaleSecond");
                            if( 5.0 < aDist ){
                                secondLowD = secondLow % 5;
                                if( secondHigh % 5 )
                                    secondHighD = 5 - secondHigh % 5;
                            }
                            break;
                        case KDChartAxisParams::ValueScaleMinute:
                            //qDebug("\nKDChartAxisParams::ValueScaleMinute");
                            secondLowD = secondLow;
                            secondHighD = 59-secondHigh;
                            break;
                        case KDChartAxisParams::ValueScaleHour:
                            //qDebug("\nKDChartAxisParams::ValueScaleHour");
                            minuteLowD = minuteLow;
                            secondLowD = secondLow;
                            minuteHighD = 59-minuteHigh;
                            secondHighD = 59-secondHigh;
                            break;
                        case KDChartAxisParams::ValueScaleDay:
                            //qDebug("\nKDChartAxisParams::ValueScaleDay");
                            hourLowD   = hourLow;
                            minuteLowD = minuteLow;
                            secondLowD = secondLow;
                            hourHighD   = 23-hourHigh;
                            minuteHighD = 59-minuteHigh;
                            secondHighD = 59-secondHigh;
                            break;
                        case KDChartAxisParams::ValueScaleWeek:
                            //qDebug("\nKDChartAxisParams::ValueScaleWeek");
                            // khz: week scaling is disabled at the moment
                            /*
                            dayLowD = dowLow - 1;
                            hourLowD   = hourLow;
                            minuteLowD = minuteLow;
                            secondLowD = secondLow;
                            if( 7 > dowHigh )
                            dayHighD = 7 - dowHigh + 1;
                            */
                            break;
                        case KDChartAxisParams::ValueScaleMonth:
                            //qDebug("\nKDChartAxisParams::ValueScaleMonth");
                            if( 1 < dayLow )
                                dayLowD = dayLow - 1;
                            hourLowD   = hourLow;
                            minuteLowD = minuteLow;
                            secondLowD = secondLow;
                            gotoEndOfMonth = true;
                            break;
                        case KDChartAxisParams::ValueScaleQuarter:
                            //qDebug("\nKDChartAxisParams::ValueScaleQuarter");
                            monthLowD = ( monthLow - 1 ) % 3;
                            dayLowD    = dayLow;
                            hourLowD   = hourLow;
                            minuteLowD = minuteLow;
                            secondLowD = secondLow;
                            if( ( monthHigh - 1 ) % 3 )
                                monthHighD = 3 - ( monthHigh - 1 ) % 3;
                            gotoEndOfMonth = true;
                            break;
                        case KDChartAxisParams::ValueScaleYear:
                            //qDebug("\nKDChartAxisParams::ValueScaleYear");
                            monthLowD  = monthLow;
                            dayLowD    = dayLow;
                            hourLowD   = hourLow;
                            minuteLowD = minuteLow;
                            secondLowD = secondLow;
                            if( 12 > monthHigh )
                                monthHighD = 12 - monthHigh;
                            gotoEndOfMonth = true;
                            break;
                        default:
                            /* NOOP */
                            break;
                    }
                    dtLow  = dtLow.addSecs(   -1 * (secondLowD + 60*minuteLowD + 3600*hourLowD) );
                    dtLow  = dtLow.addDays(   -1 * dayLowD   );
                    dtAddMonths( dtLow, -1 * monthLowD, dtLow );
                    dtAddYears(  dtLow, -1 * yearLowD,  dtLow );
                    dtHigh = dtHigh.addSecs(   secondHighD + 60*minuteHighD + 3600* hourHighD );
                    dtHigh = dtHigh.addDays(   dayHighD   );
                    dtAddMonths( dtHigh, monthHighD, dtHigh );
                    dtAddYears(  dtHigh, yearHighD,  dtHigh );
                    if( gotoEndOfMonth ){
                        dtHigh.setDate( QDate( dtHigh.date().year(),
                                    dtHigh.date().month(),
                                    dtHigh.date().daysInMonth() ) );
                        dtHigh.setTime( QTime( 23, 59, 59 ) );
                    }
                    if( toggleDts ) {
                        QDateTime dt( dtLow );
                        dtLow = dtHigh;
                        dtHigh = dt;
                    }
                    // secDist = dtLow.secsTo( dtHigh );

                    // NOTE: nSubDelimFactor is not set here since it
                    //        cannot be used for QDateTime values.
                    nSubDelimFactor = 0.0;
                    bOrdFactorsOk = true;
                }


                if( !bOrdFactorsOk ) {
                    // adjust one or both of our limit values
                    // according to first two digits of (nHigh - nLow) delta
                    nDist = nHigh - nLow;
                    // replace nLow (or nHigh, resp.) by zero if NOT ALL OF
                    // our values are located outside of the 'max. empty
                    //  inner space' (i.e. percentage of the y-axis range
                    // that may to contain NO data entries)
                    int maxEmpty = para.axisMaxEmptyInnerSpan();
                    if( bAutoCalcStart ) {
                        //qDebug("\nbAutoCalcStart:\n  nLow:  %f\n  nHigh: %f", nLow, nHigh );
                        if( 0.0 < nLow ) {
                            if(    maxEmpty == KDChartAxisParams::AXIS_IGNORE_EMPTY_INNER_SPAN
                                || maxEmpty > ( nLow / nHigh * 100.0 ) )
                                nLow = 0.0;
                            else if( nDist / 100.0 < nLow )
                                nLow -= nDist / 100.0; // shift lowest value

                        }
                        else if( nDist / 100.0 < fabs( nLow ) )
                            nLow -= nDist / 100.0; // shift lowest value
                        nDist = nHigh - nLow;
                        //qDebug("* nLow:  %f\n  nHigh: %f", nLow, nHigh );
                    }
                    if( bAutoCalcEnd ) {
                        //qDebug("\nbAutoCalcEnd:\n  nLow:  %f\n  nHigh: %f", nLow, nHigh );
                        if( 0.0 > nHigh ) {
                            if(    maxEmpty == KDChartAxisParams::AXIS_IGNORE_EMPTY_INNER_SPAN
                                    || maxEmpty > ( nHigh / nLow * 100.0 ) )
                                nHigh = 0.0;
                            else if( nDist / 100.0 > nHigh )
                                nHigh += nDist / 100.0; // shift highest value
                        }
                        else if( nDist / 100.0 < fabs( nHigh ) )
                            nHigh += nDist / 100.0; // shift highest value
                        nDist = nHigh - nLow;
                        //qDebug("* nLow:  %f\n  nHigh: %f\n\n", nLow, nHigh );
                    }
                }


                if( isLogarithmic ){
                    if( bIsDouble ) {
                        //qDebug("\n[L-0] nLow: %f,  nHigh: %f,  nDelta: %f", nLow, nHigh, nDelta );
                        nLow  = QMAX(log10( QMAX( nLow,  0.0 ) ), 0.0);
                        nHigh = QMAX(log10( QMAX( nHigh, 0.0 ) ), 0.0);
                        nDist = nHigh - nLow;
                        nDelta = 1.0;
                        nSubDelimFactor = 0.1;
                        //qDebug("\n[L-1] nLow: %f,  nHigh: %f,  nDelta: %f", nLow, nHigh, nDelta );
                        bOrdFactorsOk = true;
                    }
                }


                if ( !bOrdFactorsOk ) {
                    // adjust one or both of our limit values
                    // according to first two digits of (nHigh - nLow) delta
                    double nDivisor;
                    double nRound;
                    nDist = nHigh - nLow;
                    // find out factors and adjust nLow and nHigh
                    orgLow  = nLow;
                    orgHigh = nHigh;
                    calculateOrdinateFactors( para, isLogarithmic,
                                              nDist, nDivisor, nRound,
                                              nDelta, nSubDelimFactor,
                                              nLow, nHigh );
                    nLabels = params.roundVal( nDist / nDelta );

                    //qDebug("\n0.  nOrgHigh: %f\n    nOrgLow:  %f",
                    //       orgHigh, orgLow);
                    //qDebug("\n    nDist:    %f\n    nHigh:    %f\n    nLow:     %f",
                    //       nDist, nHigh, nLow);
                    //qDebug("    nDelta: %f", nDelta);
                    //qDebug("    nRound: %f", nRound);
                    //qDebug("    nLabels: %u", nLabels);

                    if( para.axisSteadyValueCalc() ) {
                        ++nLabels;
                        //qDebug("*   nLabels: %u", nLabels );
                    }
                }


                // calculate the amount of nLabels to be written we could take
                // based on the space we have for writing the label texts
                if( ! (    KDChartAxisParams::AXIS_LABELS_AUTO_DELTA
                        == para.axisValueDelta() ) ){
                    nDist = nHigh - nLow;
                    nDelta = para.axisValueDelta();
                    nLabels = params.roundVal( nDist / nDelta );

                    //qDebug("\nI nLow: %f\n  nHigh: %f\n  nDelta: %f\n  nLabels: %u",
                    //       nLow, nHigh, nDelta, nLabels );

                    if( para.axisSteadyValueCalc() ) {
                        ++nLabels;
                        /*
                           qDebug("* nLabels: %u", nLabels );
                           */
                    }
                }

                // make sure labels fit into available height, if vertical axis
                if( bVertAxis ) {
                    double areaHeight = para.axisTrueAreaRect().height();
                    double nDivisor;
                    double nRound;
                    orgLow = nLow;
                    orgHigh = nHigh;
                    //qDebug("\ncalc ordinate 0.  nDist: %f\n  nLow: %f\n  nHigh: %f\n  nDelta: %f\n  nLabels: %u",
                    //        nDist, nLow, nHigh, nDelta, nLabels );
                    bool bTryNext = false;
                    uint minLabels = para.axisSteadyValueCalc() ? 3 : 2;
                    while ( ( minLabels < nLabels )
                            && ( areaHeight < ( nTxtHeight * 1.5 ) * nLabels ) ) {
                        nDist = nHigh - nLow;
                        nLow = orgLow;
                        nHigh = orgHigh;
                        //qDebug("\n=============================================================================\ncalc ordinate 1.  nDist: %f\n  nLow: %f\n  nHigh: %f\n  nDelta: %f\n  nLabels: %u",
                        //        nDist, nLow, nHigh, nDelta, nLabels );
                        calculateOrdinateFactors( para, isLogarithmic,
                                nDist, nDivisor, nRound,
                                nDelta,
                                nSubDelimFactor, nLow, nHigh,
                                bTryNext );
                        nLabels = params.roundVal( nDist / nDelta );
                        //qDebug("\ncalc ordinate 2.  nDist: %f\n+ nLow: %f\n  nHigh: %f\n  nDelta: %f\n  nLabels: %u",
                        //        nDist, nLow, nHigh, nDelta, nLabels );
                        if( para.axisSteadyValueCalc() ) {
                            ++nLabels;
                        //    qDebug("\nnLabels: %u\n", nLabels );
                        }
                        //qDebug("calc ordinate n.  nDist = nHigh - nLow: %f = %f - %f",nDist, nHigh, nLow);
                        //qDebug("    nRound: %f\n", nRound);
                        bTryNext = true;
                    }
                }
            }

            // finally we can build the texts
            if( bIsDouble ) {
                int trueBehindComma = -1;
                double nVal = nLow;
                for ( uint i = 0; i < nLabels; ++i ) {
                    if( isLogarithmic )
                        labelTexts.append( applyLabelsFormat(
                            fastPow10( static_cast < int > ( nVal ) ),
                            divPow10,
                            behindComma,
                            nDelta,
                            trueBehindComma,
                            decimalPoint,
                            thousandsPoint,
                            prefix,
                            postfix,
                            totalLen,
                            padFill,
                            blockAlign ) );
                    else
                        labelTexts.append( applyLabelsFormat( nVal,
                                                              divPow10,
                                                              behindComma,
                                                              nDelta,
                                                              trueBehindComma,
                                                              decimalPoint,
                                                              thousandsPoint,
                                                              prefix,
                                                              postfix,
                                                              totalLen,
                                                              padFill,
                                                              blockAlign ) );
                    nVal += nDelta;
                }

                // save our true Low and High value
                //qDebug(para.axisSteadyValueCalc()?"\ntrue " : "\nfalse");
                //qDebug("nVal: %f,  nDelta: %f", nVal, nDelta );
                if ( para.axisSteadyValueCalc() ) {
                    nHigh = nVal - nDelta;
                }
                ( ( KDChartAxisParams& ) para ).setTrueAxisLowHighDelta( nLow, nHigh, nDelta );
                //qDebug("[Z] nLow: %f,  nHigh: %f,  nDelta: %f", nLow, nHigh, nDelta );

            } else {
                bool goDown = dtLow > dtHigh;
                int mult = goDown ? -1 : 1;
                QDateTime dt( dtLow );
                nLabels = 0;
                /*
                   qDebug("dtLow:  ");
                   qDebug(dtLow.toString(  Qt::ISODate ));
                   qDebug("dtHigh: ");
                   qDebug(dtHigh.toString( Qt::ISODate ));
                   */
                bool bDone=false;
                while( !bDone ) {
                    /*
                       qDebug("dtLow: %i %i %i    %i:%i:%i",
                       dtLow.date().year(),
                       dtLow.date().month(),
                       dtLow.date().day(),
                       dtLow.time().hour(),
                       dtLow.time().minute(),
                       dtLow.time().second());
                       qDebug("dtHigh: %i %i %i    %i:%i:%i",
                       dtHigh.date().year(),
                       dtHigh.date().month(),
                       dtHigh.date().day(),
                       dtHigh.time().hour(),
                       dtHigh.time().minute(),
                       dtHigh.time().second());
                       qDebug("dt: %i %i %i    %i:%i:%i",
                       dt.date().year(),
                       dt.date().month(),
                       dt.date().day(),
                       dt.time().hour(),
                       dt.time().minute(),
                       dt.time().second());
                       */
                    ++nLabels;
                    if( autoDtLabels )
                        labelTexts.append( "x" );
                    else
#if COMPAT_QT_VERSION >= 0x030000
                        labelTexts.append( dt.toString( Qt::ISODate ) );
#else
                    labelTexts.append( dateTimeToString( dt ) );
#endif
                    bDone = (goDown ? (dt < dtLow ) : (dt > dtHigh));
                    /*if( bDone ){
                      dtHigh = dt;
                      }else*/{
                          switch( dtDeltaScale ) {
                              case KDChartAxisParams::ValueScaleSecond:
                                  dtAddSecs( dt, 1 * mult, dt );
                                  break;
                              case KDChartAxisParams::ValueScaleMinute:
                                  dtAddSecs( dt, 60 * mult, dt );
                                  break;
                              case KDChartAxisParams::ValueScaleHour:
                                  dtAddSecs( dt, 3600 * mult, dt );
                                  break;
                              case KDChartAxisParams::ValueScaleDay:
                                  dtAddDays( dt, 1 * mult, dt );
                                  break;
                              case KDChartAxisParams::ValueScaleWeek:
                                  dtAddDays( dt, 7 * mult, dt );
                                  break;
                              case KDChartAxisParams::ValueScaleMonth:
                                  dtAddMonths( dt,1 * mult, dt );
                                  break;
                              case KDChartAxisParams::ValueScaleQuarter:
                                  dtAddMonths( dt,3 * mult, dt );
                                  break;
                              case KDChartAxisParams::ValueScaleYear:
                                  dtAddYears( dt, 1 * mult, dt );
                                  break;
                              default:
                                  dtAddDays( dt, 1 * mult, dt );
                                  break;
                          }
                      }
                }
                //if( autoDtLabels )
                //    labelTexts.append( "x" );
                ( ( KDChartAxisParams& ) para ).setTrueAxisDtLowHighDeltaScale(
                                                                               dtLow, dtHigh,
                                                                               dtDeltaScale );
                // note: pDelimDelta will be calculated below,
                //       look for "COMMOM CALC OF NLABELS, DELIM DELTA..."
            }
            bDone = true;
        }

        // let's generate some strings
        if ( !bDone ) {
            // default scenario for abscissa axes
            uint count = bStatistical
                ? (data.usedRows() ? data.usedRows() : 1)
                : (data.usedCols() ? data.usedCols() : 1);
            KDChartData start( 1.0 );
            double delta( 1.0 );
            KDChartData finis( start.doubleValue()
                    + delta * ( count - 1 ) );

            bool deltaIsAuto = true;
            if ( !( KDChartAxisParams::AXIS_LABELS_AUTO_DELTA == para.axisValueDelta() ) ) {
                delta = para.axisValueDelta();
                deltaIsAuto = false;
            }
            if ( KDChartAxisParams::AXIS_LABELS_AUTO_LIMIT == para.axisValueStart() ) {
                if ( ( KDChartAxisParams::AXIS_LABELS_AUTO_LIMIT == para.axisValueEnd() ) ) {
                    finis = start.doubleValue()
                        + delta * ( count - 1 );
                } else {
                    if ( para.axisValueEnd().isDouble() ) {
                        finis = para.axisValueEnd();
                        start = finis.doubleValue()
                            - delta * ( count - 1 );
                    } else {
                        //
                        //
                        //   F E A T U R E   P L A N N E D   F O R   F U T U R E . . .
                        //
                        //
                    }
                }
            }
            else {
                if ( para.axisValueStart().isDouble() ) {
                    start = para.axisValueStart();
                } else {
                    //
                    //
                    //   F E A T U R E   P L A N N E D   F O R   F U T U R E . . .
                    //
                    //
                }
                if ( !( KDChartAxisParams::AXIS_LABELS_AUTO_LIMIT == para.axisValueEnd() ) ) {
                    if ( para.axisValueEnd().isDouble() ) {
                        finis = para.axisValueEnd();
                        if ( deltaIsAuto ) {
                            delta = ( finis.doubleValue()
                                    - start.doubleValue() ) / count;
                        } else {
                            count = static_cast < uint > (
                                    ( finis.doubleValue()
                                      - start.doubleValue() ) / delta );
                        }
                    } else {
                        // auto-rows like
                        // sunday, monday, tuesday, ...
                        //
                        //
                        //   F E A T U R E   P L A N N E D   F O R   F U T U R E . . .
                        //
                        //
                    }
                }
                else {
                    finis = start.doubleValue()
                        + delta * ( count - 1 );
                }
            }
            QString prefix( QObject::tr( "Item " ) );
            QString postfix;


            if ( start.isDouble() && finis.isDouble() ) {
                int precis =
                    KDChartAxisParams::AXIS_LABELS_AUTO_DIGITS == para.axisDigitsBehindComma()
                    ? 0
                    : para.axisDigitsBehindComma();
                double s = start.doubleValue();
                double f = finis.doubleValue();
                bool up = ( 0.0 < delta );

                // check the text widths of one large(?) entry
                // and hope all the entries will
                // fit into the available space
                double value = up ? s : f;
                uint nLabels = 0;
                while ( up ? ( value <= f ) : ( value >= s ) ) {
                    ++nLabels;
                    value += delta * up ? 1.0 : -1.0;
                }
                calculateBasicTextFactors( nTxtHeight, para,
                        averageValueP1000,
                        basicPos, orig, delimLen, nLabels,
                        // start of return parameters
                        pDelimDelta,
                        pTextsX, pTextsY, pTextsW, pTextsH,
                        textAlign );
                QFont font( para.axisLabelsFont() );
                if ( para.axisLabelsFontUseRelSize() )
                    font.setPointSizeFloat( nTxtHeight );
                QFontMetrics fm( font );
                if ( fm.width( prefix +
                            QString::number( -fabs( ( s + f ) / 2.0 + delta ),
                                'f', precis ) )
                        > pTextsW ) {
                    prefix = "";
                    postfix = "";
                }

                // now transfer the strings into labelTexts
                value = up ? s : f;
                while ( up ? ( value <= f ) : ( value >= s ) ) {
                    labelTexts.append(
                            prefix + QString::number( value, 'f', precis )
                            + postfix );
                    value += delta * up ? 1.0 : -1.0;
                }
            } else {

                // check the text widths largest entry
                // to make sure it will fit into the available space
                calculateBasicTextFactors( nTxtHeight, para,
                        averageValueP1000,
                        basicPos, orig, delimLen,
                        count,
                        // start of return parameters
                        pDelimDelta,
                        pTextsX, pTextsY, pTextsW, pTextsH,
                        textAlign );
                QFont font( para.axisLabelsFont() );
                if ( para.axisLabelsFontUseRelSize() )
                    font.setPointSizeFloat( nTxtHeight );
                QFontMetrics fm( font );
                if ( fm.width( prefix + QString::number( count - 1 ) )
                        > pTextsW ) {
                    prefix = "";
                    postfix = "";
                }

                // now transfer the strings into labelTexts
                for ( uint i = 1; i <= count; ++i )
                    labelTexts.append(
                            prefix + QString::number( i ) + postfix );
            }
        }
    }

    /*
finishing: COMMOM CALC OF NLABELS, DELIM DELTA...
*/
    uint nLabels = labelTexts.count()
        ? labelTexts.count()
        : 0;
    ( ( KDChartAxisParams& ) para ).setAxisLabelTexts( &labelTexts );

    if( !adjustTheValues ){

        calculateBasicTextFactors( nTxtHeight, para, averageValueP1000,
                basicPos, orig, delimLen, nLabels,
                // start of return parameters
                pDelimDelta,
                pTextsX, pTextsY, pTextsW, pTextsH,
                textAlign );
    }

    ( ( KDChartAxisParams& ) para ).setTrueAxisDeltaPixels( pDelimDelta );
    //qDebug("\nsetting:   para.trueAxisLow() %f    para.trueAxisHigh() %f",para.trueAxisLow(),para.trueAxisHigh());
    //qDebug("\npDelimDelta: %f", pDelimDelta );

    /*
       qDebug( "Found label texts:" );
       for ( QStringList::Iterator it = labelTexts.begin();
       it != labelTexts.end(); ++it )
       qDebug( ">>>  %s", (*it).latin1() );
       qDebug( "\n" );
       */
//qDebug("\nleaving KDChartAxesPainter::calculateLabelTexts() :   nTxtHeight: "+QString::number(nTxtHeight));
}


Generated by  Doxygen 1.6.0   Back to index