1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
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 *****************************************************************************/
10 #ifndef QWT_PLOT_RESCALER_H
11 #define QWT_PLOT_RESCALER_H 1
13 #include "qwt_global.h"
14 #include "qwt_interval.h"
22 \brief QwtPlotRescaler takes care of fixed aspect ratios for plot scales
24 QwtPlotRescaler auto adjusts the axes of a QwtPlot according
25 to fixed aspect ratios.
28 class QWT_EXPORT QwtPlotRescaler
: public QObject
32 The rescale policy defines how to rescale the reference axis and
35 \sa ExpandingDirection, setIntervalHint()
40 The interval of the reference axis remains unchanged, when the
41 geometry of the canvas changes. All other axes
42 will be adjusted according to their aspect ratio.
47 The interval of the reference axis will be shrunk/expanded,
48 when the geometry of the canvas changes. All other axes
49 will be adjusted according to their aspect ratio.
51 The interval, that is represented by one pixel is fixed.
57 The intervals of the axes are calculated, so that all axes include
64 When rescalePolicy() is set to Expanding its direction depends
67 enum ExpandingDirection
69 //! The upper limit of the scale is adjusted
72 //! The lower limit of the scale is adjusted
75 //! Both limits of the scale are adjusted
79 explicit QwtPlotRescaler( QWidget
*canvas
,
80 int referenceAxis
= QwtPlot::xBottom
,
81 RescalePolicy
= Expanding
);
83 virtual ~QwtPlotRescaler();
85 void setEnabled( bool );
86 bool isEnabled() const;
88 void setRescalePolicy( RescalePolicy
);
89 RescalePolicy
rescalePolicy() const;
91 void setExpandingDirection( ExpandingDirection
);
92 void setExpandingDirection( int axis
, ExpandingDirection
);
93 ExpandingDirection
expandingDirection( int axis
) const;
95 void setReferenceAxis( int axis
);
96 int referenceAxis() const;
98 void setAspectRatio( double ratio
);
99 void setAspectRatio( int axis
, double ratio
);
100 double aspectRatio( int axis
) const;
102 void setIntervalHint( int axis
, const QwtInterval
& );
103 QwtInterval
intervalHint( int axis
) const;
106 const QWidget
*canvas() const;
109 const QwtPlot
*plot() const;
111 virtual bool eventFilter( QObject
*, QEvent
* );
113 void rescale() const;
116 virtual void canvasResizeEvent( QResizeEvent
* );
118 virtual void rescale( const QSize
&oldSize
, const QSize
&newSize
) const;
119 virtual QwtInterval
expandScale(
120 int axis
, const QSize
&oldSize
, const QSize
&newSize
) const;
122 virtual QwtInterval
syncScale(
123 int axis
, const QwtInterval
& reference
,
124 const QSize
&size
) const;
126 virtual void updateScales(
127 QwtInterval intervals
[QwtPlot::axisCnt
] ) const;
129 Qt::Orientation
orientation( int axis
) const;
130 QwtInterval
interval( int axis
) const;
131 QwtInterval
expandInterval( const QwtInterval
&,
132 double width
, ExpandingDirection
) const;
135 double pixelDist( int axis
, const QSize
& ) const;