Logo Search packages:      
Sourcecode: kcpuload version File versions  Download package

void StatDock::addPercentReading ( int  upper,
int  lower 
) [slot]

Add the given pair of readings as the most recent in our list. The diagram will be updated accordingly.

Each argument should be a percentage between 0 and 100. The sum of both arguments must not exceed 100.

If diagram splitting is switched off, the given lower reading will be ignored completely and 0 will be used instead.

Parameters:
upper the upper reading in this pair.
lower the lower reading in this pair.

Definition at line 104 of file statdock.cpp.

References bufLower, bufUpper, oldLower, pos, soft, and split.

Referenced by StatPopup::takeReading().

                                                     {
    // Rescale the readings to a measure in pixels.
    upper = (int) (((float) upper) / DOCK_SCALE);
    lower = (split ? (int) (((float) lower) / DOCK_SCALE) : 0);

    if (soft) {
        // Do a bit of juggling to obtain a soft reading.
        oldUpper = bufUpper[pos];
        oldLower = bufLower[pos];
        if(++pos >= DOCK_SIZE)
            pos = 0;

        // Modify the upper reading.
        if (upper > oldUpper + SOFT_STEP)
            upper = oldUpper + SOFT_STEP;
        else if (upper < oldUpper - SOFT_STEP)
            upper = oldUpper - SOFT_STEP;
        bufUpper[pos] = upper;

        // Modify the lower reading.
        if (split) {
            if (lower > oldLower + SOFT_STEP)
                lower = oldLower + SOFT_STEP;
            else if (lower < oldLower - SOFT_STEP)
                lower = oldLower - SOFT_STEP;
        }
        bufLower[pos] = lower;
    } else {
        // Just a straight update.
        if(++pos >= DOCK_SIZE)
            pos = 0;
        bufUpper[pos] = upper;
        bufLower[pos] = lower;
    }

    // Refresh the diagram.
    repaint();
}


Generated by  Doxygen 1.6.0   Back to index