ScaleEngine.h
Go to the documentation of this file.
/***************************************************************************
File : ScaleEngine.h
Project : QtiPlot
--------------------------------------------------------------------
Copyright : (C) 2007 by Ion Vasilief
Email (use @ for *) : ion_vasilief*yahoo.fr
Description : Extensions to QwtScaleEngine and QwtScaleTransformation
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
***************************************************************************/
#ifndef SCALE_ENGINE_H
#define SCALE_ENGINE_H
#include <qwt_scale_engine.h>
#include <qwt_scale_map.h>
#include <float.h>
class ScaleEngine;
class ScaleTransformation: public QwtScaleTransformation
{
public:
enum Type{Linear, Log10, Ln, Log2, Reciprocal, Probability, Logit};
ScaleTransformation(const ScaleEngine *engine):QwtScaleTransformation(Other), d_engine(engine){};
virtual double xForm(double x, double, double, double p1, double p2) const;
virtual double invXForm(double x, double s1, double s2, double p1, double p2) const;
QwtScaleTransformation* copy() const;
protected:
QwtScaleTransformation* newScaleTransformation() const;
const ScaleEngine* d_engine;
};
class ScaleEngine: public QwtScaleEngine
{
public:
ScaleEngine(ScaleTransformation::Type type = ScaleTransformation::Linear,
double left_break = -DBL_MAX, double right_break = DBL_MAX);
QwtScaleTransformation* transformation() const;
virtual QwtScaleDiv divideScale(double x1, double x2, int maxMajSteps,
int maxMinSteps, double stepSize = 0.0) const;
virtual void autoScale (int maxNumSteps, double &x1, double &x2, double &stepSize) const;
double axisBreakLeft() const;
double axisBreakRight() const;
void setBreakRegion(double from, double to){d_break_left = from; d_break_right = to;};
int breakWidth() const;
void setBreakWidth(int width){d_break_width = width;};
int breakPosition() const;
void setBreakPosition(int pos){d_break_pos = pos;};
double stepBeforeBreak() const;
void setStepBeforeBreak(double step){d_step_before = step;};
double stepAfterBreak() const;
void setStepAfterBreak(double step){d_step_after = step;};
int minTicksBeforeBreak() const;
void setMinTicksBeforeBreak(int ticks){d_minor_ticks_before = ticks;};
int minTicksAfterBreak() const;
void setMinTicksAfterBreak(int ticks){d_minor_ticks_after = ticks;};
bool log10ScaleAfterBreak() const;
void setLog10ScaleAfterBreak(bool on){d_log10_scale_after = on;};
ScaleTransformation::Type type() const;
void setType(ScaleTransformation::Type type){d_type = type;};
bool hasBreak() const;
void clone(const ScaleEngine *engine);
bool hasBreakDecoration() const;
void drawBreakDecoration(bool draw){d_break_decoration = draw;};
private:
QwtScaleEngine *newScaleEngine() const;
ScaleTransformation::Type d_type;
double d_break_left, d_break_right;
int d_break_pos;
double d_step_before, d_step_after;
int d_minor_ticks_before, d_minor_ticks_after;
bool d_log10_scale_after;
int d_break_width;
bool d_break_decoration;
};
#endif
ScaleEngine::minTicksBeforeBreak
int minTicksBeforeBreak() const
Definition: ScaleEngine.cpp:278
ScaleTransformation::d_engine
const ScaleEngine * d_engine
The scale engine that generates the transformation.
Definition: ScaleEngine.h:51
ScaleEngine::d_step_before
double d_step_before
Scale increment before and after break.
Definition: ScaleEngine.h:107
ScaleEngine::minTicksAfterBreak
int minTicksAfterBreak() const
Definition: ScaleEngine.cpp:283
ScaleEngine::drawBreakDecoration
void drawBreakDecoration(bool draw)
Definition: ScaleEngine.h:96
ScaleEngine::log10ScaleAfterBreak
bool log10ScaleAfterBreak() const
Definition: ScaleEngine.cpp:288
ScaleEngine::type
ScaleTransformation::Type type() const
Definition: ScaleEngine.cpp:273
ScaleEngine::setBreakRegion
void setBreakRegion(double from, double to)
Definition: ScaleEngine.h:66
ScaleEngine::d_break_decoration
bool d_break_decoration
If true draw the break decoration.
Definition: ScaleEngine.h:115
ScaleEngine::clone
void clone(const ScaleEngine *engine)
Definition: ScaleEngine.cpp:298
ScaleTransformation::copy
QwtScaleTransformation * copy() const
Definition: ScaleEngine.cpp:185
ScaleEngine::d_break_pos
int d_break_pos
Position of axis break (% of axis length)
Definition: ScaleEngine.h:105
ScaleTransformation::Log10
Definition: ScaleEngine.h:41
ScaleTransformation::Ln
Definition: ScaleEngine.h:41
ScaleEngine::ScaleEngine
ScaleEngine(ScaleTransformation::Type type=ScaleTransformation::Linear, double left_break=-DBL_MAX, double right_break=DBL_MAX)
Definition: ScaleEngine.cpp:224
ScaleEngine::axisBreakLeft
double axisBreakLeft() const
Definition: ScaleEngine.cpp:243
ScaleEngine::d_break_left
double d_break_left
Definition: ScaleEngine.h:103
ScaleEngine::newScaleEngine
QwtScaleEngine * newScaleEngine() const
Definition: ScaleEngine.cpp:407
ScaleEngine::autoScale
virtual void autoScale(int maxNumSteps, double &x1, double &x2, double &stepSize) const
Definition: ScaleEngine.cpp:375
ScaleTransformation::newScaleTransformation
QwtScaleTransformation * newScaleTransformation() const
Definition: ScaleEngine.cpp:190
ScaleEngine::breakPosition
int breakPosition() const
Definition: ScaleEngine.cpp:258
ScaleEngine::hasBreak
bool hasBreak() const
Definition: ScaleEngine.cpp:238
ScaleEngine::d_log10_scale_after
bool d_log10_scale_after
Log10 scale after break.
Definition: ScaleEngine.h:111
ScaleEngine::setStepAfterBreak
void setStepAfterBreak(double step)
Definition: ScaleEngine.h:78
ScaleTransformation::invXForm
virtual double invXForm(double x, double s1, double s2, double p1, double p2) const
Definition: ScaleEngine.cpp:42
ScaleEngine::setBreakWidth
void setBreakWidth(int width)
Definition: ScaleEngine.h:69
ScaleEngine::d_minor_ticks_before
int d_minor_ticks_before
Minor ticks before and after break.
Definition: ScaleEngine.h:109
ScaleEngine::d_break_width
int d_break_width
Width of the axis break in pixels.
Definition: ScaleEngine.h:113
ScaleTransformation::Linear
Definition: ScaleEngine.h:41
ScaleTransformation::Logit
Definition: ScaleEngine.h:41
ScaleTransformation::Probability
Definition: ScaleEngine.h:41
ScaleEngine::d_type
ScaleTransformation::Type d_type
Definition: ScaleEngine.h:102
ScaleTransformation::ScaleTransformation
ScaleTransformation(const ScaleEngine *engine)
Definition: ScaleEngine.h:43
ScaleEngine::setBreakPosition
void setBreakPosition(int pos)
Definition: ScaleEngine.h:72
ScaleEngine::d_step_after
double d_step_after
Definition: ScaleEngine.h:107
ScaleEngine::transformation
QwtScaleTransformation * transformation() const
Definition: ScaleEngine.cpp:37
ScaleEngine::stepAfterBreak
double stepAfterBreak() const
Definition: ScaleEngine.cpp:268
ScaleEngine::stepBeforeBreak
double stepBeforeBreak() const
Definition: ScaleEngine.cpp:263
ScaleEngine::setStepBeforeBreak
void setStepBeforeBreak(double step)
Definition: ScaleEngine.h:75
ScaleTransformation::Log2
Definition: ScaleEngine.h:41
ScaleEngine::hasBreakDecoration
bool hasBreakDecoration() const
Definition: ScaleEngine.cpp:293
ScaleEngine::divideScale
virtual QwtScaleDiv divideScale(double x1, double x2, int maxMajSteps, int maxMinSteps, double stepSize=0.0) const
Definition: ScaleEngine.cpp:315
ScaleTransformation
Definition: ScaleEngine.h:38
ScaleEngine::setType
void setType(ScaleTransformation::Type type)
Definition: ScaleEngine.h:90
ScaleEngine::setMinTicksBeforeBreak
void setMinTicksBeforeBreak(int ticks)
Definition: ScaleEngine.h:81
ScaleEngine::setLog10ScaleAfterBreak
void setLog10ScaleAfterBreak(bool on)
Definition: ScaleEngine.h:87
ScaleEngine::d_minor_ticks_after
int d_minor_ticks_after
Definition: ScaleEngine.h:109
ScaleEngine
Definition: ScaleEngine.h:54
ScaleEngine::breakWidth
int breakWidth() const
Definition: ScaleEngine.cpp:253
ScaleEngine::d_break_right
double d_break_right
Definition: ScaleEngine.h:103
ScaleTransformation::Type
Type
Definition: ScaleEngine.h:41
ScaleEngine::setMinTicksAfterBreak
void setMinTicksAfterBreak(int ticks)
Definition: ScaleEngine.h:84
ScaleTransformation::Reciprocal
Definition: ScaleEngine.h:41
ScaleTransformation::xForm
virtual double xForm(double x, double, double, double p1, double p2) const
Definition: ScaleEngine.cpp:104
ScaleEngine::axisBreakRight
double axisBreakRight() const
Definition: ScaleEngine.cpp:248