Qwt User's Guide: qwt_plot_rescaler.h Source File

Qwt User's Guide 5.2.3

- Main Page
- Related Pages
- Classes

qwt_plot_rescaler.h
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *****************************************************************************/
9
10 #ifndef QWT_PLOT_RESCALER_H
11 #define QWT_PLOT_RESCALER_H 1
12
13 #include "qwt_global.h"
14 #include "qwt_double_rect.h"
15 #include "qwt_double_interval.h"
16 #include "qwt_plot.h"
17 #include <qobject.h>
18
19 class QwtPlotCanvas;
20 class QResizeEvent;
21
29 class QWT_EXPORT QwtPlotRescaler: public QObject
30 {
31 public:
58 enum RescalePolicy
59 {
60 Fixed,
61 Expanding,
62 Fitting
63 };
64
65 enum ExpandingDirection
66 {
67 ExpandUp,
68 ExpandDown,
69 ExpandBoth
70 };
71
72 explicit QwtPlotRescaler(QwtPlotCanvas *,
73 int referenceAxis = QwtPlot::xBottom,
74 RescalePolicy = Expanding );
75
76 virtual ~QwtPlotRescaler();
77
78 void setEnabled(bool);
79 bool isEnabled() const;
80
81 void setRescalePolicy(RescalePolicy);
82 RescalePolicy rescalePolicy() const;
83
84 void setExpandingDirection(ExpandingDirection);
85 void setExpandingDirection(int axis, ExpandingDirection);
86 ExpandingDirection expandingDirection(int axis) const;
87
88 void setReferenceAxis(int axis);
89 int referenceAxis() const;
90
91 void setAspectRatio(double ratio);
92 void setAspectRatio(int axis, double ratio);
93 double aspectRatio(int axis) const;
94
95 void setIntervalHint(int axis, const QwtDoubleInterval&);
96 QwtDoubleInterval intervalHint(int axis) const;
97
98 QwtPlotCanvas *canvas();
99 const QwtPlotCanvas *canvas() const;
100
101 QwtPlot *plot();
102 const QwtPlot *plot() const;
103
104 virtual bool eventFilter(QObject *, QEvent *);
105
106 void rescale() const;
107
108 protected:
109 virtual void canvasResizeEvent(QResizeEvent *);
110
111 virtual void rescale(const QSize &oldSize, const QSize &newSize) const;
112 virtual QwtDoubleInterval expandScale( int axis,
113 const QSize &oldSize, const QSize &newSize) const;
114
115 virtual QwtDoubleInterval syncScale(
116 int axis, const QwtDoubleInterval& reference,
117 const QSize &size) const;
118
119 virtual void updateScales(
120 QwtDoubleInterval intervals[QwtPlot::axisCnt]) const;
121
122 Qt::Orientation orientation(int axis) const;
123 QwtDoubleInterval interval(int axis) const;
124 QwtDoubleInterval expandInterval(const QwtDoubleInterval &,
125 double width, ExpandingDirection) const;
126
127 private:
128 double pixelDist(int axis, const QSize &) const;
129
130 class AxisData;
131 class PrivateData;
132 PrivateData *d_data;
133 };
134
135 #endif