Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

# qwt_dimap.h

    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_DIMAP_H
    00011 #define QWT_DIMAP_H
    00012
    00013 #include "qwt_global.h"
    00014 #include "qwt_math.h"
    00015
    00046 class QWT_EXPORT QwtDiMap
    00047 {
    00048 public:
    00049     QwtDiMap();
    00050     QwtDiMap(int i1, int i2, double d1, double d2, bool lg = FALSE);
    00051     ~QwtDiMap();
    00052
    00053     bool contains(double x) const;
    00054     bool contains(int x) const;
    00055
    00056     void setIntRange(int i1, int i2);
    00057     void setDblRange(double d1, double d2, bool lg = FALSE);
    00058
    00059     int transform(double x) const;
    00060     double invTransform(int i) const;
    00061
    00062     int limTransform(double x) const;
    00063     double xTransform(double x) const;
    00064
    00065     inline double d1() const;
    00066     inline double d2() const;
    00067     inline int i1() const;
    00068     inline int i2() const;
    00069     inline bool logarithmic() const;
    00070
    00071     QT_STATIC_CONST double LogMin;
    00072     QT_STATIC_CONST double LogMax;
    00073
    00074 private:
    00075     void newFactor();
    00076
    00077     double d_x1, d_x2;  // double interval boundaries
    00078     int d_y1, d_y2;     // integer interval boundaries
    00079     double d_cnv;       // conversion factor
    00080     bool d_log;     // logarithmic scale?
    00081 };
    00082
    00086 inline double QwtDiMap::d1() const
    00087 {
    00088     return d_x1;
    00089 }
    00090
    00094 inline double QwtDiMap::d2() const
    00095 {
    00096     return d_x2;
    00097 }
    00098
    00102 inline int QwtDiMap::i1() const
    00103 {
    00104     return d_y1;
    00105 }
    00106
    00110 inline int QwtDiMap::i2() const
    00111 {
    00112     return d_y2;
    00113 }
    00114
    00118 inline bool QwtDiMap::logarithmic() const
    00119 {
    00120     return d_log;
    00121 }
    00122
    00136 inline int QwtDiMap::transform(double x) const
    00137 {
    00138     if (d_log)
    00139         return d_y1 + qRound((log(x) - d_x1) * d_cnv);
    00140     else
    00141         return d_y1 + qRound((x - d_x1) * d_cnv);
    00142 }
    00143
    00144 #endif