Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef QWT_PLOT_RESCALER_H
00011 #define QWT_PLOT_RESCALER_H 1
00012
00013 #include "qwt_global.h"
00014 #include "qwt_interval.h"
00015 #include "qwt_plot.h"
00016 #include <qobject.h>
00017
00018 class QwtPlot;
00019 class QResizeEvent;
00020
00028 class QWT_EXPORT QwtPlotRescaler: public QObject
00029 {
00030 public:
00037 enum RescalePolicy
00038 {
00044 Fixed,
00045
00054 Expanding,
00055
00060 Fitting
00061 };
00062
00067 enum ExpandingDirection
00068 {
00070 ExpandUp,
00071
00073 ExpandDown,
00074
00076 ExpandBoth
00077 };
00078
00079 explicit QwtPlotRescaler( QWidget *canvas,
00080 int referenceAxis = QwtPlot::xBottom,
00081 RescalePolicy = Expanding );
00082
00083 virtual ~QwtPlotRescaler();
00084
00085 void setEnabled( bool );
00086 bool isEnabled() const;
00087
00088 void setRescalePolicy( RescalePolicy );
00089 RescalePolicy rescalePolicy() const;
00090
00091 void setExpandingDirection( ExpandingDirection );
00092 void setExpandingDirection( int axis, ExpandingDirection );
00093 ExpandingDirection expandingDirection( int axis ) const;
00094
00095 void setReferenceAxis( int axis );
00096 int referenceAxis() const;
00097
00098 void setAspectRatio( double ratio );
00099 void setAspectRatio( int axis, double ratio );
00100 double aspectRatio( int axis ) const;
00101
00102 void setIntervalHint( int axis, const QwtInterval& );
00103 QwtInterval intervalHint( int axis ) const;
00104
00105 QWidget *canvas();
00106 const QWidget *canvas() const;
00107
00108 QwtPlot *plot();
00109 const QwtPlot *plot() const;
00110
00111 virtual bool eventFilter( QObject *, QEvent * );
00112
00113 void rescale() const;
00114
00115 protected:
00116 virtual void canvasResizeEvent( QResizeEvent * );
00117
00118 virtual void rescale( const QSize &oldSize, const QSize &newSize ) const;
00119 virtual QwtInterval expandScale(
00120 int axis, const QSize &oldSize, const QSize &newSize ) const;
00121
00122 virtual QwtInterval syncScale(
00123 int axis, const QwtInterval& reference,
00124 const QSize &size ) const;
00125
00126 virtual void updateScales(
00127 QwtInterval intervals[QwtPlot::axisCnt] ) const;
00128
00129 Qt::Orientation orientation( int axis ) const;
00130 QwtInterval interval( int axis ) const;
00131 QwtInterval expandInterval( const QwtInterval &,
00132 double width, ExpandingDirection ) const;
00133
00134 private:
00135 double pixelDist( int axis, const QSize & ) const;
00136
00137 class AxisData;
00138 class PrivateData;
00139 PrivateData *d_data;
00140 };
00141
00142 #endif