ScaleEngine.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : ScaleEngine.h
00003     Project              : QtiPlot
00004     --------------------------------------------------------------------
00005     Copyright            : (C) 2007 by Ion Vasilief
00006     Email (use @ for *)  : ion_vasilief*yahoo.fr
00007     Description          : Extensions to QwtScaleEngine and QwtScaleTransformation
00008 
00009  ***************************************************************************/
00010 
00011 /***************************************************************************
00012  *                                                                         *
00013  *  This program is free software; you can redistribute it and/or modify   *
00014  *  it under the terms of the GNU General Public License as published by   *
00015  *  the Free Software Foundation; either version 2 of the License, or      *
00016  *  (at your option) any later version.                                    *
00017  *                                                                         *
00018  *  This program is distributed in the hope that it will be useful,        *
00019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00021  *  GNU General Public License for more details.                           *
00022  *                                                                         *
00023  *   You should have received a copy of the GNU General Public License     *
00024  *   along with this program; if not, write to the Free Software           *
00025  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
00026  *   Boston, MA  02110-1301  USA                                           *
00027  *                                                                         *
00028  ***************************************************************************/
00029 #ifndef SCALE_ENGINE_H
00030 #define SCALE_ENGINE_H
00031 
00032 #include <qwt_scale_engine.h>
00033 #include <qwt_scale_map.h>
00034 #include <float.h>
00035 
00036 class ScaleEngine: public QwtScaleEngine
00037 {
00038 public:
00039     ScaleEngine(QwtScaleTransformation::Type type = QwtScaleTransformation::Linear,
00040                 double left_break = -DBL_MAX, double right_break = DBL_MAX);
00041     QwtScaleTransformation* transformation() const;
00042     virtual QwtScaleDiv divideScale(double x1, double x2, int maxMajSteps,
00043         int maxMinSteps, double stepSize = 0.0) const;
00044     virtual void autoScale (int maxNumSteps, double &x1, double &x2, double &stepSize) const;
00045 
00046     double axisBreakLeft() const;
00047     double axisBreakRight() const;
00048     void setBreakRegion(double from, double to){d_break_left = from; d_break_right = to;};
00049 
00050     int breakWidth() const;
00051     void setBreakWidth(int width){d_break_width = width;};
00052 
00053     int breakPosition() const;
00054     void setBreakPosition(int pos){d_break_pos = pos;};
00055 
00056     double stepBeforeBreak() const;
00057     void setStepBeforeBreak(double step){d_step_before = step;};
00058 
00059     double stepAfterBreak() const;
00060     void setStepAfterBreak(double step){d_step_after = step;};
00061 
00062     int minTicksBeforeBreak() const;
00063     void setMinTicksBeforeBreak(int ticks){d_minor_ticks_before = ticks;};
00064 
00065     int minTicksAfterBreak() const;
00066     void setMinTicksAfterBreak(int ticks){d_minor_ticks_after = ticks;};
00067 
00068     bool log10ScaleAfterBreak() const;
00069     void setLog10ScaleAfterBreak(bool on){d_log10_scale_after = on;};
00070 
00071     QwtScaleTransformation::Type type() const;
00072     void setType(QwtScaleTransformation::Type type){d_type = type;};
00073 
00074     bool hasBreak() const;
00075     void clone(const ScaleEngine *engine);
00076 
00077     bool hasBreakDecoration() const;
00078     void drawBreakDecoration(bool draw){d_break_decoration = draw;};
00079 
00080 private:
00081     QwtScaleTransformation::Type d_type;
00082     double d_break_left, d_break_right;
00084     int d_break_pos;
00086     double d_step_before, d_step_after;
00088     int d_minor_ticks_before, d_minor_ticks_after;
00090     bool d_log10_scale_after;
00092     int d_break_width;
00094     bool d_break_decoration;
00095 };
00096 
00097 class ScaleTransformation: public QwtScaleTransformation
00098 {
00099 public:
00100     ScaleTransformation(const ScaleEngine *engine):QwtScaleTransformation(Other), d_engine(engine){};
00101     virtual double xForm(double x, double, double, double p1, double p2) const;
00102     virtual double invXForm(double x, double s1, double s2, double p1, double p2) const;
00103     QwtScaleTransformation* copy() const;
00104 
00105 private:
00107     const ScaleEngine* d_engine;
00108 };
00109 
00110 #endif

Generated on Tue Jun 17 08:36:13 2008 for QtiPlot by  doxygen 1.5.5