Qwt User's Guide 6.2.0

qwt_plot_rescaler.h
1 /******************************************************************************
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
12
13 #include "qwt_global.h"
14 #include "qwt_plot.h"
15
16 #include <qobject.h>
17
18 class QwtPlot;
19 class QwtInterval;
20 class QResizeEvent;
21
29 class QWT_EXPORT QwtPlotRescaler : public QObject
30 {
31 Q_OBJECT
32
33 public:
40 enum RescalePolicy
41 {
47 Fixed,
48
57 Expanding,
58
63 Fitting
64 };
65
70 enum ExpandingDirection
71 {
73 ExpandUp,
74
76 ExpandDown,
77
79 ExpandBoth
80 };
81
82 explicit QwtPlotRescaler( QWidget* canvas,
83 QwtAxisId referenceAxis = QwtAxis::XBottom,
84 RescalePolicy = Expanding );
85
86 virtual ~QwtPlotRescaler();
87
88 void setEnabled( bool );
89 bool isEnabled() const;
90
91 void setRescalePolicy( RescalePolicy );
92 RescalePolicy rescalePolicy() const;
93
94 void setExpandingDirection( ExpandingDirection );
95 void setExpandingDirection( QwtAxisId, ExpandingDirection );
96 ExpandingDirection expandingDirection( QwtAxisId ) const;
97
98 void setReferenceAxis( QwtAxisId );
99 QwtAxisId referenceAxis() const;
100
101 void setAspectRatio( double ratio );
102 void setAspectRatio( QwtAxisId, double ratio );
103 double aspectRatio( QwtAxisId ) const;
104
105 void setIntervalHint( QwtAxisId, const QwtInterval& );
106 QwtInterval intervalHint( QwtAxisId ) const;
107
108 QWidget* canvas();
109 const QWidget* canvas() const;
110
111 QwtPlot* plot();
112 const QwtPlot* plot() const;
113
114 virtual bool eventFilter( QObject*, QEvent* ) QWT_OVERRIDE;
115
116 void rescale() const;
117
118 protected:
119 virtual void canvasResizeEvent( QResizeEvent* );
120
121 virtual void rescale( const QSize& oldSize, const QSize& newSize ) const;
122 virtual QwtInterval expandScale(
123 QwtAxisId, const QSize& oldSize, const QSize& newSize ) const;
124
125 virtual QwtInterval syncScale(
126 QwtAxisId, const QwtInterval& reference, const QSize& size ) const;
127
128 virtual void updateScales(
129 QwtInterval intervals[QwtAxis::AxisPositions] ) const;
130
131 Qt::Orientation orientation( QwtAxisId ) const;
132 QwtInterval interval( QwtAxisId ) const;
133 QwtInterval expandInterval( const QwtInterval&,
134 double width, ExpandingDirection ) const;
135
136 private:
137 double pixelDist( QwtAxisId, const QSize& ) const;
138
139 class AxisData;
140 class PrivateData;
141 PrivateData* m_data;
142 };
143
144 #endif
QwtInterval
A class representing an interval.
Definition: qwt_interval.h:23
QwtPlot
A 2-D plotting widget.
Definition: qwt_plot.h:79
QwtPlotRescaler
QwtPlotRescaler takes care of fixed aspect ratios for plot scales.
Definition: qwt_plot_rescaler.h:30
QwtPlotRescaler::ExpandingDirection
ExpandingDirection
Definition: qwt_plot_rescaler.h:71
QwtPlotRescaler::ExpandUp
@ ExpandUp
The upper limit of the scale is adjusted.
Definition: qwt_plot_rescaler.h:73
QwtPlotRescaler::ExpandDown
@ ExpandDown
The lower limit of the scale is adjusted.
Definition: qwt_plot_rescaler.h:76
QwtPlotRescaler::RescalePolicy
RescalePolicy
Definition: qwt_plot_rescaler.h:41
QwtPlotRescaler::Fixed
@ Fixed
Definition: qwt_plot_rescaler.h:47
QwtPlotRescaler::Expanding
@ Expanding
Definition: qwt_plot_rescaler.h:57
QwtAxis::XBottom
@ XBottom
X axis below the canvas.
Definition: qwt_axis.h:30