qwt_scale_engine.h
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
* 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_ENGINE_H
#define QWT_SCALE_ENGINE_H
#include "qwt_global.h"
#include "qwt_scale_div.h"
#include "qwt_interval.h"
class QwtTransform;
class QWT_EXPORT QwtScaleArithmetic
{
public:
static double ceilEps( double value, double intervalSize );
static double floorEps( double value, double intervalSize );
static double divideEps( double interval, double steps );
static double divideInterval( double interval,
int numSteps, uint base );
};
class QWT_EXPORT QwtScaleEngine
{
public:
enum Attribute
{
NoAttribute = 0x00,
IncludeReference = 0x01,
Symmetric = 0x02,
Floating = 0x04,
Inverted = 0x08
};
typedef QFlags<Attribute> Attributes;
explicit QwtScaleEngine( uint base = 10 );
virtual ~QwtScaleEngine();
void setBase( uint base );
uint base() const;
void setAttribute( Attribute, bool on = true );
bool testAttribute( Attribute ) const;
void setAttributes( Attributes );
Attributes attributes() const;
void setReference( double reference );
double reference() const;
void setMargins( double lower, double upper );
double lowerMargin() const;
double upperMargin() const;
virtual void autoScale( int maxNumSteps,
double &x1, double &x2, double &stepSize ) const = 0;
virtual QwtScaleDiv divideScale( double x1, double x2,
int maxMajorSteps, int maxMinorSteps,
double stepSize = 0.0 ) const = 0;
void setTransformation( QwtTransform * );
QwtTransform *transformation() const;
protected:
bool contains( const QwtInterval &, double val ) const;
QList<double> strip( const QList<double>&, const QwtInterval & ) const;
double divideInterval( double interval, int numSteps ) const;
QwtInterval buildInterval( double v ) const;
private:
class PrivateData;
PrivateData *d_data;
};
class QWT_EXPORT QwtLinearScaleEngine: public QwtScaleEngine
{
public:
QwtLinearScaleEngine( uint base = 10 );
virtual ~QwtLinearScaleEngine();
virtual void autoScale( int maxSteps,
double &x1, double &x2, double &stepSize ) const;
virtual QwtScaleDiv divideScale( double x1, double x2,
int numMajorSteps, int numMinorSteps,
double stepSize = 0.0 ) const;
protected:
QwtInterval align( const QwtInterval&, double stepSize ) const;
void buildTicks(
const QwtInterval &, double stepSize, int maxMinSteps,
QList<double> ticks[QwtScaleDiv::NTickTypes] ) const;
QList<double> buildMajorTicks(
const QwtInterval &interval, double stepSize ) const;
void buildMinorTicks( const QList<double>& majorTicks,
int maxMinorSteps, double stepSize,
QList<double> &minorTicks, QList<double> &mediumTicks ) const;
};
class QWT_EXPORT QwtLogScaleEngine: public QwtScaleEngine
{
public:
QwtLogScaleEngine( uint base = 10 );
virtual ~QwtLogScaleEngine();
virtual void autoScale( int maxSteps,
double &x1, double &x2, double &stepSize ) const;
virtual QwtScaleDiv divideScale( double x1, double x2,
int numMajorSteps, int numMinorSteps,
double stepSize = 0.0 ) const;
protected:
QwtInterval align( const QwtInterval&, double stepSize ) const;
void buildTicks(
const QwtInterval &, double stepSize, int maxMinSteps,
QList<double> ticks[QwtScaleDiv::NTickTypes] ) const;
QList<double> buildMajorTicks(
const QwtInterval &interval, double stepSize ) const;
void buildMinorTicks( const QList<double>& majorTicks,
int maxMinorSteps, double stepSize,
QList<double> &minorTicks, QList<double> &mediumTicks ) const;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtScaleEngine::Attributes )
#endif
QwtTransform
A transformation between coordinate systems.
Definition: qwt_transform.h:35
QwtScaleEngine
Base class for scale engines.
Definition: qwt_scale_engine.h:45
QwtScaleEngine::divideScale
virtual QwtScaleDiv divideScale(double x1, double x2, int maxMajorSteps, int maxMinorSteps, double stepSize=0.0) const =0
Calculate a scale division.
QwtScaleEngine::Attributes
QFlags< Attribute > Attributes
Layout attributes.
Definition: qwt_scale_engine.h:79
QwtScaleDiv
A class representing a scale division.
Definition: qwt_scale_div.h:36
QwtLinearScaleEngine
A scale engine for linear scales.
Definition: qwt_scale_engine.h:150
QwtScaleEngine::autoScale
virtual void autoScale(int maxNumSteps, double &x1, double &x2, double &stepSize) const =0
QwtScaleDiv::NTickTypes
Number of valid tick types.
Definition: qwt_scale_div.h:55
QwtScaleArithmetic
Arithmetic including a tolerance.
Definition: qwt_scale_engine.h:22
QwtLogScaleEngine
A scale engine for logarithmic scales.
Definition: qwt_scale_engine.h:190
QwtInterval
A class representing an interval.
Definition: qwt_interval.h:26
QwtScaleEngine::Attribute
Attribute
Definition: qwt_scale_engine.h:54