qwt_scale_div.h 2.56 KB
Newer Older
pixhawk's avatar
pixhawk committed
1 2 3 4
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
 * Qwt Widget Library
 * Copyright (C) 1997   Josef Wilgen
 * Copyright (C) 2002   Uwe Rathmann
5
 *
pixhawk's avatar
pixhawk committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the Qwt License, Version 1.0
 *****************************************************************************/

#ifndef QWT_SCALE_DIV_H
#define QWT_SCALE_DIV_H

#include "qwt_global.h"
#include "qwt_valuelist.h"
#include "qwt_double_interval.h"

class QwtDoubleInterval;

/*!
  \brief 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.

  \sa QwtScaleEngine::subDivideInto, QwtScaleEngine::subDivide
*/

class QWT_EXPORT QwtScaleDiv
{
public:
33
    enum TickType {
pixhawk's avatar
pixhawk committed
34 35 36 37 38 39 40 41 42 43 44
        NoTick = -1,

        MinorTick,
        MediumTick,
        MajorTick,

        NTickTypes
    };

    explicit QwtScaleDiv();
    explicit QwtScaleDiv(const QwtDoubleInterval &,
45
                         QwtValueList[NTickTypes]);
pixhawk's avatar
pixhawk committed
46
    explicit QwtScaleDiv(double lBound, double rBound,
47
                         QwtValueList[NTickTypes]);
pixhawk's avatar
pixhawk committed
48 49 50

    int operator==(const QwtScaleDiv &s) const;
    int operator!=(const QwtScaleDiv &s) const;
51

pixhawk's avatar
pixhawk committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
    void setInterval(double lBound, double rBound);
    void setInterval(const QwtDoubleInterval &);
    QwtDoubleInterval interval() const;

    inline double lBound() const;
    inline double hBound() const;
    inline double range() const;

    bool contains(double v) const;

    void setTicks(int type, const QwtValueList &);
    const QwtValueList &ticks(int type) const;

    void invalidate();
    bool isValid() const;
67

pixhawk's avatar
pixhawk committed
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
    void invert();

private:
    double d_lBound;
    double d_hBound;
    QwtValueList d_ticks[NTickTypes];

    bool d_isValid;
};

/*!
   Change the interval
   \lBound left bound
   \rBound right bound
*/
inline void QwtScaleDiv::setInterval(double lBound, double hBound)
{
    d_lBound = lBound;
    d_hBound = hBound;
}

89
/*!
pixhawk's avatar
pixhawk committed
90 91 92 93 94 95 96
  \return lBound -> hBound
*/
inline QwtDoubleInterval QwtScaleDiv::interval() const
{
    return QwtDoubleInterval(d_lBound, d_hBound);
}

97
/*!
pixhawk's avatar
pixhawk committed
98 99 100
  \return left bound
  \sa QwtScaleDiv::hBound
*/
101 102
inline double QwtScaleDiv::lBound() const
{
pixhawk's avatar
pixhawk committed
103 104 105
    return d_lBound;
}

106
/*!
pixhawk's avatar
pixhawk committed
107 108 109
  \return right bound
  \sa QwtScaleDiv::lBound
*/
110 111
inline double QwtScaleDiv::hBound() const
{
pixhawk's avatar
pixhawk committed
112 113 114
    return d_hBound;
}

115
/*!
pixhawk's avatar
pixhawk committed
116 117
  \return hBound() - lBound()
*/
118 119
inline double QwtScaleDiv::range() const
{
pixhawk's avatar
pixhawk committed
120 121 122
    return d_hBound - d_lBound;
}
#endif