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 intervalSize, double numSteps );
static double divideInterval( double intervalSize,
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 );
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 value ) const;
QList<double> strip( const QList<double>&, const QwtInterval & ) const;
double divideInterval( double intervalSize, int numSteps ) const;
QwtInterval buildInterval( double value ) const;
private:
class PrivateData;
PrivateData *d_data;
};
class QWT_EXPORT QwtLinearScaleEngine: public QwtScaleEngine
{
public:
QwtLinearScaleEngine( uint base = 10 );
virtual ~QwtLinearScaleEngine();
virtual void autoScale( int maxNumSteps,
double &x1, double &x2, double &stepSize ) const;
virtual QwtScaleDiv divideScale( double x1, double x2,
int maxMajorSteps, int maxMinorSteps,
double stepSize = 0.0 ) const;
protected:
QwtInterval align( const QwtInterval&, double stepSize ) const;
void buildTicks(
const QwtInterval &, double stepSize, int maxMinorSteps,
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 maxNumSteps,
double &x1, double &x2, double &stepSize ) const;
virtual QwtScaleDiv divideScale( double x1, double x2,
int maxMajorSteps, int maxMinorSteps,
double stepSize = 0.0 ) const;
protected:
QwtInterval align( const QwtInterval&, double stepSize ) const;
void buildTicks(
const QwtInterval &, double stepSize, int maxMinorSteps,
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
QwtScaleEngine::Attributes
QFlags< Attribute > Attributes
Layout attributes.
Definition: qwt_scale_engine.h:79
QwtTransform
A transformation between coordinate systems.
Definition: qwt_transform.h:36
QwtScaleArithmetic
Arithmetic including a tolerance.
Definition: qwt_scale_engine.h:23
QwtScaleEngine
Base class for scale engines.
Definition: qwt_scale_engine.h:46
QwtScaleEngine::divideScale
virtual QwtScaleDiv divideScale(double x1, double x2, int maxMajorSteps, int maxMinorSteps, double stepSize=0.0) const =0
Calculate a scale division.
QwtLinearScaleEngine
A scale engine for linear scales.
Definition: qwt_scale_engine.h:151
QwtScaleEngine::autoScale
virtual void autoScale(int maxNumSteps, double &x1, double &x2, double &stepSize) const =0
QwtLogScaleEngine
A scale engine for logarithmic scales.
Definition: qwt_scale_engine.h:191
QwtScaleEngine::Attribute
Attribute
Definition: qwt_scale_engine.h:55
QwtScaleDiv::NTickTypes
@ NTickTypes
Number of valid tick types.
Definition: qwt_scale_div.h:55
QwtInterval
A class representing an interval.
Definition: qwt_interval.h:27
QwtScaleDiv
A class representing a scale division.
Definition: qwt_scale_div.h:37