[89] | 1 | /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
---|
| 2 | * Qwt Widget Library
|
---|
| 3 | * Copyright (C) 1997 Josef Wilgen
|
---|
| 4 | * Copyright (C) 2002 Uwe Rathmann
|
---|
| 5 | *
|
---|
| 6 | * This library is free software; you can redistribute it and/or
|
---|
| 7 | * modify it under the terms of the Qwt License, Version 1.0
|
---|
| 8 | *****************************************************************************/
|
---|
| 9 |
|
---|
| 10 | #ifndef QWT_SCALE_DIV_H
|
---|
| 11 | #define QWT_SCALE_DIV_H
|
---|
| 12 |
|
---|
| 13 | #include "qwt_global.h"
|
---|
| 14 | #include "qwt_valuelist.h"
|
---|
| 15 | #include "qwt_double_interval.h"
|
---|
| 16 |
|
---|
| 17 | class QwtDoubleInterval;
|
---|
| 18 |
|
---|
| 19 | /*!
|
---|
| 20 | \brief A class representing a scale division
|
---|
| 21 |
|
---|
| 22 | A scale division consists of its limits and 3 list
|
---|
| 23 | of tick values qualified as major, medium and minor ticks.
|
---|
| 24 |
|
---|
| 25 | In most cases scale divisions are calculated by a QwtScaleEngine.
|
---|
| 26 |
|
---|
| 27 | \sa subDivideInto(), subDivide()
|
---|
| 28 | */
|
---|
| 29 |
|
---|
| 30 | class QWT_EXPORT QwtScaleDiv
|
---|
| 31 | {
|
---|
| 32 | public:
|
---|
| 33 | //! Scale tick types
|
---|
| 34 | enum TickType
|
---|
| 35 | {
|
---|
| 36 | NoTick = -1,
|
---|
| 37 |
|
---|
| 38 | MinorTick,
|
---|
| 39 | MediumTick,
|
---|
| 40 | MajorTick,
|
---|
| 41 |
|
---|
| 42 | NTickTypes
|
---|
| 43 | };
|
---|
| 44 |
|
---|
| 45 | explicit QwtScaleDiv();
|
---|
| 46 | explicit QwtScaleDiv(const QwtDoubleInterval &,
|
---|
| 47 | QwtValueList[NTickTypes]);
|
---|
| 48 | explicit QwtScaleDiv(double lowerBound, double upperBound,
|
---|
| 49 | QwtValueList[NTickTypes]);
|
---|
| 50 |
|
---|
| 51 | int operator==(const QwtScaleDiv &s) const;
|
---|
| 52 | int operator!=(const QwtScaleDiv &s) const;
|
---|
| 53 |
|
---|
| 54 | void setInterval(double lowerBound, double upperBound);
|
---|
| 55 | void setInterval(const QwtDoubleInterval &);
|
---|
| 56 | QwtDoubleInterval interval() const;
|
---|
| 57 |
|
---|
| 58 | double lowerBound() const;
|
---|
| 59 | double upperBound() const;
|
---|
| 60 | double range() const;
|
---|
| 61 |
|
---|
| 62 | bool contains(double v) const;
|
---|
| 63 |
|
---|
| 64 | void setTicks(int type, const QwtValueList &);
|
---|
| 65 | const QwtValueList &ticks(int type) const;
|
---|
| 66 |
|
---|
| 67 | void invalidate();
|
---|
| 68 | bool isValid() const;
|
---|
| 69 |
|
---|
| 70 | void invert();
|
---|
| 71 |
|
---|
| 72 | private:
|
---|
| 73 | double d_lowerBound;
|
---|
| 74 | double d_upperBound;
|
---|
| 75 | QwtValueList d_ticks[NTickTypes];
|
---|
| 76 |
|
---|
| 77 | bool d_isValid;
|
---|
| 78 | };
|
---|
| 79 |
|
---|
| 80 | /*!
|
---|
| 81 | Change the interval
|
---|
| 82 | \param lowerBound lower bound
|
---|
| 83 | \param upperBound upper bound
|
---|
| 84 | */
|
---|
| 85 | inline void QwtScaleDiv::setInterval(double lowerBound, double upperBound)
|
---|
| 86 | {
|
---|
| 87 | d_lowerBound = lowerBound;
|
---|
| 88 | d_upperBound = upperBound;
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | /*!
|
---|
| 92 | \return lowerBound -> upperBound
|
---|
| 93 | */
|
---|
| 94 | inline QwtDoubleInterval QwtScaleDiv::interval() const
|
---|
| 95 | {
|
---|
| 96 | return QwtDoubleInterval(d_lowerBound, d_upperBound);
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | /*!
|
---|
| 100 | \return lower bound
|
---|
| 101 | \sa upperBound()
|
---|
| 102 | */
|
---|
| 103 | inline double QwtScaleDiv::lowerBound() const
|
---|
| 104 | {
|
---|
| 105 | return d_lowerBound;
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | /*!
|
---|
| 109 | \return upper bound
|
---|
| 110 | \sa lowerBound()
|
---|
| 111 | */
|
---|
| 112 | inline double QwtScaleDiv::upperBound() const
|
---|
| 113 | {
|
---|
| 114 | return d_upperBound;
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | /*!
|
---|
| 118 | \return upperBound() - lowerBound()
|
---|
| 119 | */
|
---|
| 120 | inline double QwtScaleDiv::range() const
|
---|
| 121 | {
|
---|
| 122 | return d_upperBound - d_lowerBound;
|
---|
| 123 | }
|
---|
| 124 | #endif
|
---|