QtiPlot  0.9.8.2
ScaleEngine.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : ScaleEngine.h
3  Project : QtiPlot
4  --------------------------------------------------------------------
5  Copyright : (C) 2007 by Ion Vasilief
6  Email (use @ for *) : ion_vasilief*yahoo.fr
7  Description : Extensions to QwtScaleEngine and QwtScaleTransformation
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
29 #ifndef SCALE_ENGINE_H
30 #define SCALE_ENGINE_H
31 
32 #include <qwt_scale_engine.h>
33 #include <qwt_scale_map.h>
34 #include <float.h>
35 
36 class ScaleEngine;
37 
38 class ScaleTransformation: public QwtScaleTransformation
39 {
40 public:
42 
43  ScaleTransformation(const ScaleEngine *engine):QwtScaleTransformation(Other), d_engine(engine){};
44  virtual double xForm(double x, double, double, double p1, double p2) const;
45  virtual double invXForm(double x, double s1, double s2, double p1, double p2) const;
46  QwtScaleTransformation* copy() const;
47 
48 protected:
49  QwtScaleTransformation* newScaleTransformation() const;
52 };
53 
54 class ScaleEngine: public QwtScaleEngine
55 {
56 public:
58  double left_break = -DBL_MAX, double right_break = DBL_MAX);
59  QwtScaleTransformation* transformation() const;
60  virtual QwtScaleDiv divideScale(double x1, double x2, int maxMajSteps,
61  int maxMinSteps, double stepSize = 0.0) const;
62  virtual void autoScale (int maxNumSteps, double &x1, double &x2, double &stepSize) const;
63 
64  double axisBreakLeft() const;
65  double axisBreakRight() const;
66  void setBreakRegion(double from, double to){d_break_left = from; d_break_right = to;};
67 
68  int breakWidth() const;
69  void setBreakWidth(int width){d_break_width = width;};
70 
71  int breakPosition() const;
72  void setBreakPosition(int pos){d_break_pos = pos;};
73 
74  double stepBeforeBreak() const;
75  void setStepBeforeBreak(double step){d_step_before = step;};
76 
77  double stepAfterBreak() const;
78  void setStepAfterBreak(double step){d_step_after = step;};
79 
80  int minTicksBeforeBreak() const;
81  void setMinTicksBeforeBreak(int ticks){d_minor_ticks_before = ticks;};
82 
83  int minTicksAfterBreak() const;
84  void setMinTicksAfterBreak(int ticks){d_minor_ticks_after = ticks;};
85 
86  bool log10ScaleAfterBreak() const;
88 
91 
92  bool hasBreak() const;
93  void clone(const ScaleEngine *engine);
94 
95  bool hasBreakDecoration() const;
96  void drawBreakDecoration(bool draw){d_break_decoration = draw;};
97 
98 private:
99 
100  QwtScaleEngine *newScaleEngine() const;
101 
116 };
117 
118 #endif