qwt_scale_div.h 2.69 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
 * 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"
Bryant's avatar
Bryant committed
14
15
#include "qwt_interval.h"
#include <qlist.h>
pixhawk's avatar
pixhawk committed
16

Bryant's avatar
Bryant committed
17
18
19
#ifndef QT_NO_DEBUG_STREAM
#include <qdebug.h>
#endif
pixhawk's avatar
pixhawk committed
20
21
22
23

/*!
  \brief A class representing a scale division

Bryant's avatar
Bryant committed
24
25
26
27
28
  A Qwt scale is defined by its boundaries and 3 list
  for the positions of the major, medium and minor ticks.

  The upperLimit() might be smaller than the lowerLimit()
  to indicate inverted scales.
pixhawk's avatar
pixhawk committed
29

Bryant's avatar
Bryant committed
30
  Scale divisions can be calculated from a QwtScaleEngine.
pixhawk's avatar
pixhawk committed
31

Bryant's avatar
Bryant committed
32
33
  \sa QwtScaleEngine::divideScale(), QwtPlot::setAxisScaleDiv(),
      QwtAbstractSlider::setScaleDiv()
pixhawk's avatar
pixhawk committed
34
35
36
37
38
*/

class QWT_EXPORT QwtScaleDiv
{
public:
Bryant's avatar
Bryant committed
39
40
41
42
    //! Scale tick types
    enum TickType
    {
        //! No ticks
pixhawk's avatar
pixhawk committed
43
44
        NoTick = -1,

Bryant's avatar
Bryant committed
45
        //! Minor ticks
pixhawk's avatar
pixhawk committed
46
        MinorTick,
Bryant's avatar
Bryant committed
47
48

        //! Medium ticks
pixhawk's avatar
pixhawk committed
49
        MediumTick,
Bryant's avatar
Bryant committed
50
51

        //! Major ticks
pixhawk's avatar
pixhawk committed
52
53
        MajorTick,

Bryant's avatar
Bryant committed
54
        //! Number of valid tick types
pixhawk's avatar
pixhawk committed
55
56
57
        NTickTypes
    };

Bryant's avatar
Bryant committed
58
59
    explicit QwtScaleDiv( double lowerBound = 0.0, 
        double upperBound = 0.0 );
pixhawk's avatar
pixhawk committed
60

Bryant's avatar
Bryant committed
61
    explicit QwtScaleDiv( const QwtInterval &, QList<double>[NTickTypes] );
62

Bryant's avatar
Bryant committed
63
64
    explicit QwtScaleDiv( double lowerBound, double upperBound,
        QList<double>[NTickTypes] );
pixhawk's avatar
pixhawk committed
65

Bryant's avatar
Bryant committed
66
67
68
    explicit QwtScaleDiv( double lowerBound, double upperBound, 
        const QList<double> &minorTicks, const QList<double> &mediumTicks,
        const QList<double> &majorTicks );
pixhawk's avatar
pixhawk committed
69

Bryant's avatar
Bryant committed
70
71
    bool operator==( const QwtScaleDiv & ) const;
    bool operator!=( const QwtScaleDiv & ) const;
pixhawk's avatar
pixhawk committed
72

Bryant's avatar
Bryant committed
73
74
75
    void setInterval( double lowerBound, double upperBound );
    void setInterval( const QwtInterval & );
    QwtInterval interval() const;
pixhawk's avatar
pixhawk committed
76

Bryant's avatar
Bryant committed
77
78
    void setLowerBound( double );
    double lowerBound() const;
79

Bryant's avatar
Bryant committed
80
81
    void setUpperBound( double );
    double upperBound() const;
pixhawk's avatar
pixhawk committed
82

Bryant's avatar
Bryant committed
83
    double range() const;
pixhawk's avatar
pixhawk committed
84

Bryant's avatar
Bryant committed
85
    bool contains( double value ) const;
pixhawk's avatar
pixhawk committed
86

Bryant's avatar
Bryant committed
87
88
    void setTicks( int tickType, const QList<double> & );
    QList<double> ticks( int tickType ) const;
pixhawk's avatar
pixhawk committed
89

Bryant's avatar
Bryant committed
90
91
    bool isEmpty() const;
    bool isIncreasing() const;
pixhawk's avatar
pixhawk committed
92

Bryant's avatar
Bryant committed
93
94
    void invert();
    QwtScaleDiv inverted() const;
pixhawk's avatar
pixhawk committed
95

Bryant's avatar
Bryant committed
96
97
98
99
100
101
102
103
104
105
106
107
108
    QwtScaleDiv bounded( double lowerBound, double upperBound ) const;

private:
    double d_lowerBound;
    double d_upperBound;
    QList<double> d_ticks[NTickTypes];
};

Q_DECLARE_TYPEINFO( QwtScaleDiv, Q_MOVABLE_TYPE );

#ifndef QT_NO_DEBUG_STREAM
QWT_EXPORT QDebug operator<<( QDebug, const QwtScaleDiv & );
#endif
pixhawk's avatar
pixhawk committed
109
110

#endif