Skip to content
qwt_scale_div.h 2.69 KiB
Newer Older
pixhawk's avatar
pixhawk committed
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
 * Qwt Widget Library
 * Copyright (C) 1997   Josef Wilgen
 * Copyright (C) 2002   Uwe Rathmann
pixhawk's avatar
pixhawk committed
 * 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
#include "qwt_interval.h"
#include <qlist.h>
pixhawk's avatar
pixhawk committed

Bryant's avatar
Bryant committed
#ifndef QT_NO_DEBUG_STREAM
#include <qdebug.h>
#endif
pixhawk's avatar
pixhawk committed

/*!
  \brief A class representing a scale division

Bryant's avatar
Bryant committed
  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

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

Bryant's avatar
Bryant committed
  \sa QwtScaleEngine::divideScale(), QwtPlot::setAxisScaleDiv(),
      QwtAbstractSlider::setScaleDiv()
pixhawk's avatar
pixhawk committed
*/

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

Bryant's avatar
Bryant committed
        //! Minor ticks
pixhawk's avatar
pixhawk committed
        MinorTick,
Bryant's avatar
Bryant committed

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

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

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

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

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

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

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

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

Bryant's avatar
Bryant committed
    void setLowerBound( double );
    double lowerBound() const;
Bryant's avatar
Bryant committed
    void setUpperBound( double );
    double upperBound() const;
pixhawk's avatar
pixhawk committed

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

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

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

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

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

Bryant's avatar
Bryant committed
    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

#endif