source: ntrip/trunk/GnssCenter/qwt/qwt_plot_rescaler.h@ 10280

Last change on this file since 10280 was 4839, checked in by mervart, 12 years ago
File size: 3.8 KB
Line 
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
18class QwtPlotCanvas;
19class QwtPlot;
20class QResizeEvent;
21
22/*!
23 \brief QwtPlotRescaler takes care of fixed aspect ratios for plot scales
24
25 QwtPlotRescaler autoadjusts the axes of a QwtPlot according
26 to fixed aspect ratios.
27*/
28
29class QWT_EXPORT QwtPlotRescaler: public QObject
30{
31public:
32 /*!
33 The rescale policy defines how to rescale the reference axis and
34 their depending axes.
35
36 \sa ExpandingDirection, setIntervalHint()
37 */
38 enum RescalePolicy
39 {
40 /*!
41 The interval of the reference axis remains unchanged, when the
42 geometry of the canvas changes. All other axes
43 will be adjusted according to their aspect ratio.
44 */
45 Fixed,
46
47 /*!
48 The interval of the reference axis will be shrinked/expanded,
49 when the geometry of the canvas changes. All other axes
50 will be adjusted according to their aspect ratio.
51
52 The interval, that is represented by one pixel is fixed.
53
54 */
55 Expanding,
56
57 /*!
58 The intervals of the axes are calculated, so that all axes include
59 their interval hint.
60 */
61 Fitting
62 };
63
64 /*!
65 When rescalePolicy() is set to Expanding its direction depends
66 on ExpandingDirection
67 */
68 enum ExpandingDirection
69 {
70 //! The upper limit of the scale is adjusted
71 ExpandUp,
72
73 //! The lower limit of the scale is adjusted
74 ExpandDown,
75
76 //! Both limits of the scale are adjusted
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
116protected:
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
135private:
136 double pixelDist( int axis, const QSize & ) const;
137
138 class AxisData;
139 class PrivateData;
140 PrivateData *d_data;
141};
142
143#endif
Note: See TracBrowser for help on using the repository browser.