qwt_scale_engine.h
Go to the documentation of this file.
00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
00002  * Qwt Widget Library
00003  * Copyright (C) 1997   Josef Wilgen
00004  * Copyright (C) 2002   Uwe Rathmann
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the Qwt License, Version 1.0
00008  *****************************************************************************/
00009 
00010 #ifndef QWT_SCALE_ENGINE_H
00011 #define QWT_SCALE_ENGINE_H
00012 
00013 #include "qwt_global.h"
00014 #include "qwt_scale_div.h"
00015 #include "qwt_interval.h"
00016 
00017 class QwtTransform;
00018 
00022 class QWT_EXPORT QwtScaleArithmetic
00023 {
00024 public:
00025     static double ceilEps( double value, double intervalSize );
00026     static double floorEps( double value, double intervalSize );
00027 
00028     static double divideEps( double interval, double steps );
00029 
00030     static double divideInterval( double interval, 
00031         int numSteps, uint base );
00032 };
00033 
00045 class QWT_EXPORT QwtScaleEngine
00046 {
00047 public:
00054     enum Attribute
00055     {
00057         NoAttribute = 0x00,
00058 
00060         IncludeReference = 0x01,
00061 
00063         Symmetric = 0x02,
00064 
00072         Floating = 0x04,
00073 
00075         Inverted = 0x08
00076     };
00077 
00079     typedef QFlags<Attribute> Attributes;
00080 
00081     explicit QwtScaleEngine( uint base = 10 );
00082     virtual ~QwtScaleEngine();
00083 
00084     void setBase( uint base );
00085     uint base() const;
00086 
00087     void setAttribute( Attribute, bool on = true );
00088     bool testAttribute( Attribute ) const;
00089 
00090     void setAttributes( Attributes );
00091     Attributes attributes() const;
00092 
00093     void setReference( double reference );
00094     double reference() const;
00095 
00096     void setMargins( double lower, double upper );
00097     double lowerMargin() const;
00098     double upperMargin() const;
00099 
00108     virtual void autoScale( int maxNumSteps,
00109         double &x1, double &x2, double &stepSize ) const = 0;
00110 
00123     virtual QwtScaleDiv divideScale( double x1, double x2,
00124         int maxMajorSteps, int maxMinorSteps,
00125         double stepSize = 0.0 ) const = 0;
00126 
00127     void setTransformation( QwtTransform * );
00128     QwtTransform *transformation() const;
00129 
00130 protected:
00131     bool contains( const QwtInterval &, double val ) const;
00132     QList<double> strip( const QList<double>&, const QwtInterval & ) const;
00133 
00134     double divideInterval( double interval, int numSteps ) const;
00135 
00136     QwtInterval buildInterval( double v ) const;
00137 
00138 private:
00139     Q_DISABLE_COPY(QwtScaleEngine)
00140 
00141     class PrivateData;
00142     PrivateData *d_data;
00143 };
00144 
00152 class QWT_EXPORT QwtLinearScaleEngine: public QwtScaleEngine
00153 {
00154 public:
00155     explicit QwtLinearScaleEngine( uint base = 10 );
00156     virtual ~QwtLinearScaleEngine();
00157 
00158     virtual void autoScale( int maxSteps,
00159         double &x1, double &x2, double &stepSize ) const;
00160 
00161     virtual QwtScaleDiv divideScale( double x1, double x2,
00162         int numMajorSteps, int numMinorSteps,
00163                                      double stepSize = 0.0 ) const;
00164 
00165 
00166 protected:
00167     QwtInterval align( const QwtInterval&, double stepSize ) const;
00168 
00169     void buildTicks(
00170         const QwtInterval &, double stepSize, int maxMinSteps,
00171         QList<double> ticks[QwtScaleDiv::NTickTypes] ) const;
00172 
00173     QList<double> buildMajorTicks(
00174         const QwtInterval &interval, double stepSize ) const;
00175 
00176     void buildMinorTicks( const QList<double>& majorTicks,
00177         int maxMinorSteps, double stepSize,
00178         QList<double> &minorTicks, QList<double> &mediumTicks ) const;
00179 };
00180 
00192 class QWT_EXPORT QwtLogScaleEngine: public QwtScaleEngine
00193 {
00194 public:
00195     explicit QwtLogScaleEngine( uint base = 10 );
00196     virtual ~QwtLogScaleEngine();
00197 
00198     virtual void autoScale( int maxSteps,
00199         double &x1, double &x2, double &stepSize ) const;
00200 
00201     virtual QwtScaleDiv divideScale( double x1, double x2,
00202         int numMajorSteps, int numMinorSteps,
00203         double stepSize = 0.0 ) const;
00204 
00205 protected:
00206     QwtInterval align( const QwtInterval&, double stepSize ) const;
00207 
00208     void buildTicks(
00209         const QwtInterval &, double stepSize, int maxMinSteps,
00210         QList<double> ticks[QwtScaleDiv::NTickTypes] ) const;
00211 
00212     QList<double> buildMajorTicks(
00213         const QwtInterval &interval, double stepSize ) const;
00214 
00215     void buildMinorTicks( const QList<double>& majorTicks,
00216         int maxMinorSteps, double stepSize,
00217         QList<double> &minorTicks, QList<double> &mediumTicks ) const;
00218 };
00219 
00220 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtScaleEngine::Attributes )
00221 
00222 #endif


plotjuggler
Author(s): Davide Faconti
autogenerated on Fri Sep 1 2017 02:41:56