qwt_scale_engine.h
/******************************************************************************
* 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"
class QwtInterval;
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
};
Q_DECLARE_FLAGS( Attributes, Attribute )
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:
Q_DISABLE_COPY(QwtScaleEngine)
class PrivateData;
PrivateData* m_data;
};
class QWT_EXPORT QwtLinearScaleEngine : public QwtScaleEngine
{
public:
explicit QwtLinearScaleEngine( uint base = 10 );
virtual ~QwtLinearScaleEngine();
virtual void autoScale( int maxNumSteps,
double& x1, double& x2, double& stepSize ) const QWT_OVERRIDE;
virtual QwtScaleDiv divideScale( double x1, double x2,
int maxMajorSteps, int maxMinorSteps,
double stepSize = 0.0 ) const QWT_OVERRIDE;
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:
explicit QwtLogScaleEngine( uint base = 10 );
virtual ~QwtLogScaleEngine();
virtual void autoScale( int maxNumSteps,
double& x1, double& x2, double& stepSize ) const QWT_OVERRIDE;
virtual QwtScaleDiv divideScale( double x1, double x2,
int maxMajorSteps, int maxMinorSteps,
double stepSize = 0.0 ) const QWT_OVERRIDE;
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
QList< double >
QwtInterval
A class representing an interval.
Definition: qwt_interval.h:23
QwtLinearScaleEngine
A scale engine for linear scales.
Definition: qwt_scale_engine.h:152
QwtLogScaleEngine
A scale engine for logarithmic scales.
Definition: qwt_scale_engine.h:192
QwtScaleArithmetic
Arithmetic including a tolerance.
Definition: qwt_scale_engine.h:23
QwtScaleDiv
A class representing a scale division.
Definition: qwt_scale_div.h:34
QwtScaleDiv::NTickTypes
@ NTickTypes
Number of valid tick types.
Definition: qwt_scale_div.h:52
QwtScaleEngine
Base class for scale engines.
Definition: qwt_scale_engine.h:46
QwtScaleEngine::Attributes
QFlags< Attribute > Attributes
Definition: qwt_scale_engine.h:78
QwtScaleEngine::Attribute
Attribute
Definition: qwt_scale_engine.h:55
QwtScaleEngine::autoScale
virtual void autoScale(int maxNumSteps, double &x1, double &x2, double &stepSize) const =0
QwtScaleEngine::divideScale
virtual QwtScaleDiv divideScale(double x1, double x2, int maxMajorSteps, int maxMinorSteps, double stepSize=0.0) const =0
Calculate a scale division.
QwtTransform
A transformation between coordinate systems.
Definition: qwt_transform.h:36