# qwt_plot_rescaler.h

    00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
    00002  * Qwt Widget Library
    00003  * Copyright (C) 1997   Josef Wilgen
    00004  * Copyright (C) 2002   Uwe Rathmann
    00005  *
    00006  * This library is free software; you can redistribute it and/or
    00007  * modify it under the terms of the Qwt License, Version 1.0
    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 QwtPlotCanvas;
    00019 class QwtPlot;
    00020 class QResizeEvent;
    00021
    00029 class QWT_EXPORT QwtPlotRescaler: public QObject
    00030 {
    00031 public:
    00038     enum RescalePolicy
    00039     {
    00045         Fixed,
    00046
    00055         Expanding,
    00056
    00061         Fitting
    00062     };
    00063
    00068     enum ExpandingDirection
    00069     {
    00071         ExpandUp,
    00072
    00074         ExpandDown,
    00075
    00077         ExpandBoth
    00078     };
    00079
    00080     explicit QwtPlotRescaler( QwtPlotCanvas *,
    00081         int referenceAxis = QwtPlot::xBottom,
    00082         RescalePolicy = Expanding );
    00083
    00084     virtual ~QwtPlotRescaler();
    00085
    00086     void setEnabled( bool );
    00087     bool isEnabled() const;
    00088
    00089     void setRescalePolicy( RescalePolicy );
    00090     RescalePolicy rescalePolicy() const;
    00091
    00092     void setExpandingDirection( ExpandingDirection );
    00093     void setExpandingDirection( int axis, ExpandingDirection );
    00094     ExpandingDirection expandingDirection( int axis ) const;
    00095
    00096     void setReferenceAxis( int axis );
    00097     int referenceAxis() const;
    00098
    00099     void setAspectRatio( double ratio );
    00100     void setAspectRatio( int axis, double ratio );
    00101     double aspectRatio( int axis ) const;
    00102
    00103     void setIntervalHint( int axis, const QwtInterval& );
    00104     QwtInterval intervalHint( int axis ) const;
    00105
    00106     QwtPlotCanvas *canvas();
    00107     const QwtPlotCanvas *canvas() const;
    00108
    00109     QwtPlot *plot();
    00110     const QwtPlot *plot() const;
    00111
    00112     virtual bool eventFilter( QObject *, QEvent * );
    00113
    00114     void rescale() const;
    00115
    00116 protected:
    00117     virtual void canvasResizeEvent( QResizeEvent * );
    00118
    00119     virtual void rescale( const QSize &oldSize, const QSize &newSize ) const;
    00120     virtual QwtInterval expandScale(
    00121         int axis, const QSize &oldSize, const QSize &newSize ) const;
    00122
    00123     virtual QwtInterval syncScale(
    00124         int axis, const QwtInterval& reference,
    00125         const QSize &size ) const;
    00126
    00127     virtual void updateScales(
    00128         QwtInterval intervals[QwtPlot::axisCnt] ) const;
    00129
    00130     Qt::Orientation orientation( int axis ) const;
    00131     QwtInterval interval( int axis ) const;
    00132     QwtInterval expandInterval( const QwtInterval &,
    00133         double width, ExpandingDirection ) const;
    00134
    00135 private:
    00136     double pixelDist( int axis, const QSize & ) const;
    00137
    00138     class AxisData;
    00139     class PrivateData;
    00140     PrivateData *d_data;
    00141 };
    00142
    00143 #endif