Eneboo - Documentación para desarrolladores
|
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: 00054 enum Attribute 00055 { 00056 NoAttribute = 0, 00057 IncludeReference = 1, 00058 Symmetric = 2, 00059 Floating = 4, 00060 Inverted = 8 00061 }; 00062 00063 explicit QwtScaleEngine(); 00064 virtual ~QwtScaleEngine(); 00065 00066 void setAttribute(Attribute, bool on = true); 00067 bool testAttribute(Attribute) const; 00068 00069 void setAttributes(int); 00070 int attributes() const; 00071 00072 void setReference(double reference); 00073 double reference() const; 00074 00075 void setMargins(double m1, double m2); 00076 double loMargin() const; 00077 double hiMargin() const; 00078 00087 virtual void autoScale(int maxNumSteps, 00088 double &x1, double &x2, double &stepSize) const = 0; 00089 00100 virtual QwtScaleDiv divideScale(double x1, double x2, 00101 int maxMajSteps, int maxMinSteps, 00102 double stepSize = 0.0) const = 0; 00103 00105 virtual QwtScaleTransformation *transformation() const = 0; 00106 00107 protected: 00108 bool contains(const QwtDoubleInterval &, double val) const; 00109 QwtValueList strip(const QwtValueList&, const QwtDoubleInterval &) const; 00110 double divideInterval(double interval, int numSteps) const; 00111 00112 QwtDoubleInterval buildInterval(double v) const; 00113 00114 private: 00115 class PrivateData; 00116 PrivateData *d_data; 00117 }; 00118 00126 class QWT_EXPORT QwtLinearScaleEngine: public QwtScaleEngine 00127 { 00128 public: 00129 virtual void autoScale(int maxSteps, 00130 double &x1, double &x2, double &stepSize) const; 00131 00132 virtual QwtScaleDiv divideScale(double x1, double x2, 00133 int numMajorSteps, int numMinorSteps, 00134 double stepSize = 0.0) const; 00135 00136 virtual QwtScaleTransformation *transformation() const; 00137 00138 protected: 00139 QwtDoubleInterval align(const QwtDoubleInterval&, 00140 double stepSize) const; 00141 00142 private: 00143 void buildTicks( 00144 const QwtDoubleInterval &, double stepSize, int maxMinSteps, 00145 QwtValueList ticks[QwtScaleDiv::NTickTypes]) const; 00146 00147 void buildMinorTicks( 00148 const QwtValueList& majorTicks, 00149 int maxMinMark, double step, 00150 QwtValueList &, QwtValueList &) const; 00151 00152 QwtValueList buildMajorTicks( 00153 const QwtDoubleInterval &interval, double stepSize) const; 00154 }; 00155 00167 class QWT_EXPORT QwtLog10ScaleEngine: public QwtScaleEngine 00168 { 00169 public: 00170 virtual void autoScale(int maxSteps, 00171 double &x1, double &x2, double &stepSize) const; 00172 00173 virtual QwtScaleDiv divideScale(double x1, double x2, 00174 int numMajorSteps, int numMinorSteps, 00175 double stepSize = 0.0) const; 00176 00177 virtual QwtScaleTransformation *transformation() const; 00178 00179 protected: 00180 QwtDoubleInterval log10(const QwtDoubleInterval&) const; 00181 QwtDoubleInterval pow10(const QwtDoubleInterval&) const; 00182 00183 private: 00184 QwtDoubleInterval align(const QwtDoubleInterval&, 00185 double stepSize) const; 00186 00187 void buildTicks( 00188 const QwtDoubleInterval &, double stepSize, int maxMinSteps, 00189 QwtValueList ticks[QwtScaleDiv::NTickTypes]) const; 00190 00191 QwtValueList buildMinorTicks( 00192 const QwtValueList& majorTicks, 00193 int maxMinMark, double step) const; 00194 00195 QwtValueList buildMajorTicks( 00196 const QwtDoubleInterval &interval, double stepSize) const; 00197 }; 00198 00199 #endif