qwt_scale_engine.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_SCALE_ENGINE_H 00011 #define QWT_SCALE_ENGINE_H 00012 00013 #include "qwt_global.h" 00014 #include "qwt_scale_div.h" 00015 #include "qwt_double_interval.h" 00016 00017 class QwtScaleTransformation; 00018 00022 class QWT_EXPORT QwtScaleArithmetic 00023 { 00024 public: 00025 static int compareEps( 00026 double value1, double value2, double intervalSize); 00027 00028 static double ceilEps(double value, double intervalSize); 00029 static double floorEps(double value, double intervalSize); 00030 00031 static double divideEps(double interval, double steps); 00032 00033 static double ceil125(double x); 00034 static double floor125(double x); 00035 }; 00036 00050 class QWT_EXPORT QwtScaleEngine 00051 { 00052 public: 00069 enum Attribute 00070 { 00071 NoAttribute = 0, 00072 IncludeReference = 1, 00073 Symmetric = 2, 00074 Floating = 4, 00075 Inverted = 8 00076 }; 00077 00078 explicit QwtScaleEngine(); 00079 virtual ~QwtScaleEngine(); 00080 00081 void setAttribute(Attribute, bool on = true); 00082 bool testAttribute(Attribute) const; 00083 00084 void setAttributes(int); 00085 int attributes() const; 00086 00087 void setReference(double reference); 00088 double reference() const; 00089 00090 void setMargins(double lower, double upper); 00091 double lowerMargin() const; 00092 double upperMargin() const; 00093 00102 virtual void autoScale(int maxNumSteps, 00103 double &x1, double &x2, double &stepSize) const = 0; 00104 00115 virtual QwtScaleDiv divideScale(double x1, double x2, 00116 int maxMajSteps, int maxMinSteps, 00117 double stepSize = 0.0) const = 0; 00118 00120 virtual QwtScaleTransformation *transformation() const = 0; 00121 00122 protected: 00123 bool contains(const QwtDoubleInterval &, double val) const; 00124 QwtValueList strip(const QwtValueList&, const QwtDoubleInterval &) const; 00125 double divideInterval(double interval, int numSteps) const; 00126 00127 QwtDoubleInterval buildInterval(double v) const; 00128 00129 private: 00130 class PrivateData; 00131 PrivateData *d_data; 00132 }; 00133 00141 class QWT_EXPORT QwtLinearScaleEngine: public QwtScaleEngine 00142 { 00143 public: 00144 virtual void autoScale(int maxSteps, 00145 double &x1, double &x2, double &stepSize) const; 00146 00147 virtual QwtScaleDiv divideScale(double x1, double x2, 00148 int numMajorSteps, int numMinorSteps, 00149 double stepSize = 0.0) const; 00150 00151 virtual QwtScaleTransformation *transformation() const; 00152 00153 protected: 00154 QwtDoubleInterval align(const QwtDoubleInterval&, 00155 double stepSize) const; 00156 00157 private: 00158 void buildTicks( 00159 const QwtDoubleInterval &, double stepSize, int maxMinSteps, 00160 QwtValueList ticks[QwtScaleDiv::NTickTypes]) const; 00161 00162 void buildMinorTicks( 00163 const QwtValueList& majorTicks, 00164 int maxMinMark, double step, 00165 QwtValueList &, QwtValueList &) const; 00166 00167 QwtValueList buildMajorTicks( 00168 const QwtDoubleInterval &interval, double stepSize) const; 00169 }; 00170 00182 class QWT_EXPORT QwtLog10ScaleEngine: public QwtScaleEngine 00183 { 00184 public: 00185 virtual void autoScale(int maxSteps, 00186 double &x1, double &x2, double &stepSize) const; 00187 00188 virtual QwtScaleDiv divideScale(double x1, double x2, 00189 int numMajorSteps, int numMinorSteps, 00190 double stepSize = 0.0) const; 00191 00192 virtual QwtScaleTransformation *transformation() const; 00193 00194 protected: 00195 QwtDoubleInterval log10(const QwtDoubleInterval&) const; 00196 QwtDoubleInterval pow10(const QwtDoubleInterval&) const; 00197 00198 private: 00199 QwtDoubleInterval align(const QwtDoubleInterval&, 00200 double stepSize) const; 00201 00202 void buildTicks( 00203 const QwtDoubleInterval &, double stepSize, int maxMinSteps, 00204 QwtValueList ticks[QwtScaleDiv::NTickTypes]) const; 00205 00206 QwtValueList buildMinorTicks( 00207 const QwtValueList& majorTicks, 00208 int maxMinMark, double step) const; 00209 00210 QwtValueList buildMajorTicks( 00211 const QwtDoubleInterval &interval, double stepSize) const; 00212 }; 00213 00214 #endif
Generated on Wed Sep 2 18:37:22 2009 for Qwt User's Guide by 1.6.1