Public Types | Public Member Functions

QwtScaleDiv Class Reference

A class representing a scale division. More...

#include <qwt_scale_div.h>

List of all members.

Public Types

enum  TickType {
  NoTick = -1, MinorTick, MediumTick, MajorTick,
  NTickTypes
}
 

Scale tick types.

More...

Public Member Functions

 QwtScaleDiv ()
 Construct an invalid QwtScaleDiv instance.
 QwtScaleDiv (const QwtDoubleInterval &, QwtValueList[NTickTypes])
 QwtScaleDiv (double lowerBound, double upperBound, QwtValueList[NTickTypes])
int operator== (const QwtScaleDiv &s) const
 Equality operator.
int operator!= (const QwtScaleDiv &s) const
 Inequality.
void setInterval (double lowerBound, double upperBound)
void setInterval (const QwtDoubleInterval &)
QwtDoubleInterval interval () const
double lowerBound () const
double upperBound () const
double range () const
bool contains (double v) const
void setTicks (int type, const QwtValueList &)
const QwtValueListticks (int type) const
void invalidate ()
 Invalidate the scale division.
bool isValid () const
 Check if the scale division is valid.
void invert ()
 Invert the scale divison.

Detailed Description

A class representing a scale division.

A scale division consists of its limits and 3 list of tick values qualified as major, medium and minor ticks.

In most cases scale divisions are calculated by a QwtScaleEngine.

See also:
subDivideInto(), subDivide()

Definition at line 30 of file qwt_scale_div.h.


Member Enumeration Documentation

Scale tick types.

Enumerator:
NoTick 
MinorTick 
MediumTick 
MajorTick 
NTickTypes 

Definition at line 34 of file qwt_scale_div.h.


Constructor & Destructor Documentation

QwtScaleDiv::QwtScaleDiv (  ) [explicit]

Construct an invalid QwtScaleDiv instance.

Definition at line 15 of file qwt_scale_div.cpp.

                        :
    d_lowerBound(0.0),
    d_upperBound(0.0),
    d_isValid(false)
{
}
QwtScaleDiv::QwtScaleDiv ( const QwtDoubleInterval interval,
QwtValueList  ticks[NTickTypes] 
) [explicit]

Construct QwtScaleDiv instance.

Parameters:
intervalInterval
ticksList of major, medium and minor ticks

Definition at line 28 of file qwt_scale_div.cpp.

References NTickTypes, and ticks().

                                       :
    d_lowerBound(interval.minValue()),
    d_upperBound(interval.maxValue()),
    d_isValid(true)
{
    for ( int i = 0; i < NTickTypes; i++ )
        d_ticks[i] = ticks[i];
}
QwtScaleDiv::QwtScaleDiv ( double  lowerBound,
double  upperBound,
QwtValueList  ticks[NTickTypes] 
) [explicit]

Construct QwtScaleDiv instance.

Parameters:
lowerBoundFirst interval limit
upperBoundSecond interval limit
ticksList of major, medium and minor ticks

Definition at line 46 of file qwt_scale_div.cpp.

References NTickTypes, and ticks().

                                       :
    d_lowerBound(lowerBound),
    d_upperBound(upperBound),
    d_isValid(true)
{
    for ( int i = 0; i < NTickTypes; i++ )
        d_ticks[i] = ticks[i];
}

Member Function Documentation

bool QwtScaleDiv::contains ( double  value ) const

Return if a value is between lowerBound() and upperBound()

Parameters:
valueValue
Returns:
true/false

Definition at line 121 of file qwt_scale_div.cpp.

References QuadProgPP::max(), min, qwtMax, and qwtMin.

Referenced by QwtRoundScaleDraw::extent(), QwtScaleDraw::maxLabelHeight(), and QwtScaleDraw::maxLabelWidth().

{
    if ( !d_isValid )
        return false;

    const double min = qwtMin(d_lowerBound, d_upperBound);
    const double max = qwtMax(d_lowerBound, d_upperBound);

    return value >= min && value <= max;
}
QwtDoubleInterval QwtScaleDiv::interval (  ) const [inline]
Returns:
lowerBound -> upperBound

Definition at line 94 of file qwt_scale_div.h.

{
    return QwtDoubleInterval(d_lowerBound, d_upperBound);
}
void QwtScaleDiv::invalidate (  )

Invalidate the scale division.

Definition at line 98 of file qwt_scale_div.cpp.

References NTickTypes.

Referenced by QwtPlot::setAxisMaxMajor(), QwtPlot::setAxisMaxMinor(), QwtPlot::setAxisScale(), QwtPlot::setAxisScaleEngine(), and QwtPlot::updateAxes().

{
    d_isValid = false;

    // detach arrays
    for ( int i = 0; i < NTickTypes; i++ )
        d_ticks[i].clear();

    d_lowerBound = d_upperBound = 0;
}
void QwtScaleDiv::invert (  )

Invert the scale divison.

Definition at line 133 of file qwt_scale_div.cpp.

References NTickTypes, and ticks().

Referenced by QwtLog10ScaleEngine::divideScale(), and QwtLinearScaleEngine::divideScale().

{
    qSwap(d_lowerBound, d_upperBound);

    for ( int i = 0; i < NTickTypes; i++ )
    {
        QwtValueList& ticks = d_ticks[i];

        const int size = ticks.count();
        const int size2 = size / 2;
 
        for (int i=0; i < size2; i++)
            qSwap(ticks[i], ticks[size - 1 - i]);
    }
}
bool QwtScaleDiv::isValid (  ) const

Check if the scale division is valid.

Definition at line 110 of file qwt_scale_div.cpp.

Referenced by QwtPlotMagnifier::rescale(), and QwtPlot::updateAxes().

{
    return d_isValid;
}
double QwtScaleDiv::lowerBound (  ) const [inline]
int QwtScaleDiv::operator!= ( const QwtScaleDiv s ) const

Inequality.

Returns:
true if this instance is not equal to s

Definition at line 92 of file qwt_scale_div.cpp.

{
    return (!(*this == s));
}
int QwtScaleDiv::operator== ( const QwtScaleDiv other ) const

Equality operator.

Returns:
true if this instance is equal to other

Definition at line 70 of file qwt_scale_div.cpp.

References NTickTypes.

{
    if ( d_lowerBound != other.d_lowerBound ||
        d_upperBound != other.d_upperBound ||
        d_isValid != other.d_isValid )
    {
        return false;
    }

    for ( int i = 0; i < NTickTypes; i++ )
    {
        if ( d_ticks[i] != other.d_ticks[i] )
            return false;
    }

    return true;
}
double QwtScaleDiv::range (  ) const [inline]
Returns:
upperBound() - lowerBound()

Definition at line 120 of file qwt_scale_div.h.

Referenced by QwtPlotMagnifier::rescale(), and QwtPlotPicker::scaleRect().

{ 
    return d_upperBound - d_lowerBound;
}
void QwtScaleDiv::setInterval ( const QwtDoubleInterval interval )

Change the interval

Parameters:
intervalInterval

Definition at line 61 of file qwt_scale_div.cpp.

References QwtDoubleInterval::maxValue(), QwtDoubleInterval::minValue(), and setInterval().

{
    setInterval(interval.minValue(), interval.maxValue());
}
void QwtScaleDiv::setInterval ( double  lowerBound,
double  upperBound 
) [inline]

Change the interval

Parameters:
lowerBoundlower bound
upperBoundupper bound

Definition at line 85 of file qwt_scale_div.h.

References lowerBound(), and upperBound().

Referenced by setInterval().

{
    d_lowerBound = lowerBound;
    d_upperBound = upperBound;
}
void QwtScaleDiv::setTicks ( int  type,
const QwtValueList ticks 
)

Assign ticks

Parameters:
typeMinorTick, MediumTick or MajorTick
ticksValues of the tick positions

Definition at line 155 of file qwt_scale_div.cpp.

References NTickTypes, and ticks().

{
    if ( type >= 0 || type < NTickTypes )
        d_ticks[type] = ticks;
}
const QwtValueList & QwtScaleDiv::ticks ( int  type ) const

Return a list of ticks

Parameters:
typeMinorTick, MediumTick or MajorTick

Definition at line 166 of file qwt_scale_div.cpp.

References NTickTypes.

Referenced by QwtPlotGrid::draw(), QwtRoundScaleDraw::extent(), QwtScaleDraw::getBorderDistHint(), invert(), QwtScaleDraw::maxLabelHeight(), QwtScaleDraw::maxLabelWidth(), QwtScaleDraw::minLabelDist(), QwtScaleDraw::minLength(), QwtScaleDiv(), setTicks(), QwtPlot::sizeHint(), and QwtPlotRescaler::updateScales().

{
    if ( type >= 0 || type < NTickTypes )
        return d_ticks[type];

    static QwtValueList noTicks;
    return noTicks;
}
double QwtScaleDiv::upperBound (  ) const [inline]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines