Qwt User's Guide 6.0.2

- 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_interval.h"
15 #include "qwt_plot.h"
16 #include <qobject.h>
17
18 class QwtPlotCanvas;
19 class QwtPlot;
20 class QResizeEvent;
21
29 class QWT_EXPORT QwtPlotRescaler: public QObject
30 {
31 public:
38 enum RescalePolicy
39 {
45 Fixed,
46
55 Expanding,
56
61 Fitting
62 };
63
68 enum ExpandingDirection
69 {
71 ExpandUp,
72
74 ExpandDown,
75
77 ExpandBoth
78 };
79
80 explicit QwtPlotRescaler( QwtPlotCanvas *,
81 int referenceAxis = QwtPlot::xBottom,
82 RescalePolicy = Expanding );
83
84 virtual ~QwtPlotRescaler();
85
86 void setEnabled( bool );
87 bool isEnabled() const;
88
89 void setRescalePolicy( RescalePolicy );
90 RescalePolicy rescalePolicy() const;
91
92 void setExpandingDirection( ExpandingDirection );
93 void setExpandingDirection( int axis, ExpandingDirection );
94 ExpandingDirection expandingDirection( int axis ) const;
95
96 void setReferenceAxis( int axis );
97 int referenceAxis() const;
98
99 void setAspectRatio( double ratio );
100 void setAspectRatio( int axis, double ratio );
101 double aspectRatio( int axis ) const;
102
103 void setIntervalHint( int axis, const QwtInterval& );
104 QwtInterval intervalHint( int axis ) const;
105
106 QwtPlotCanvas *canvas();
107 const QwtPlotCanvas *canvas() const;
108
109 QwtPlot *plot();
110 const QwtPlot *plot() const;
111
112 virtual bool eventFilter( QObject *, QEvent * );
113
114 void rescale() const;
115
116 protected:
117 virtual void canvasResizeEvent( QResizeEvent * );
118
119 virtual void rescale( const QSize &oldSize, const QSize &newSize ) const;
120 virtual QwtInterval expandScale(
121 int axis, const QSize &oldSize, const QSize &newSize ) const;
122
123 virtual QwtInterval syncScale(
124 int axis, const QwtInterval& reference,
125 const QSize &size ) const;
126
127 virtual void updateScales(
128 QwtInterval intervals[QwtPlot::axisCnt] ) const;
129
130 Qt::Orientation orientation( int axis ) const;
131 QwtInterval interval( int axis ) const;
132 QwtInterval expandInterval( const QwtInterval &,
133 double width, ExpandingDirection ) const;
134
135 private:
136 double pixelDist( int axis, const QSize & ) const;
137
138 class AxisData;
139 class PrivateData;
140 PrivateData *d_data;
141 };
142
143 #endif