source: ntrip/branches/BNC_2.13.beta/qwt/qwt_plot_rescaler.h@ 10132

Last change on this file since 10132 was 9383, checked in by stoecker, 4 years ago

update to qwt verion 6.1.1 to fix build with newer Qt5

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 QwtPlot;
19class QResizeEvent;
20
21/*!
22 \brief QwtPlotRescaler takes care of fixed aspect ratios for plot scales
23
24 QwtPlotRescaler auto adjusts the axes of a QwtPlot according
25 to fixed aspect ratios.
26*/
27
28class QWT_EXPORT QwtPlotRescaler: public QObject
29{
30public:
31 /*!
32 The rescale policy defines how to rescale the reference axis and
33 their depending axes.
34
35 \sa ExpandingDirection, setIntervalHint()
36 */
37 enum RescalePolicy
38 {
39 /*!
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.
43 */
44 Fixed,
45
46 /*!
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.
50
51 The interval, that is represented by one pixel is fixed.
52
53 */
54 Expanding,
55
56 /*!
57 The intervals of the axes are calculated, so that all axes include
58 their interval hint.
59 */
60 Fitting
61 };
62
63 /*!
64 When rescalePolicy() is set to Expanding its direction depends
65 on ExpandingDirection
66 */
67 enum ExpandingDirection
68 {
69 //! The upper limit of the scale is adjusted
70 ExpandUp,
71
72 //! The lower limit of the scale is adjusted
73 ExpandDown,
74
75 //! Both limits of the scale are adjusted
76 ExpandBoth
77 };
78
79 explicit QwtPlotRescaler( QWidget *canvas,
80 int referenceAxis = QwtPlot::xBottom,
81 RescalePolicy = Expanding );
82
83 virtual ~QwtPlotRescaler();
84
85 void setEnabled( bool );
86 bool isEnabled() const;
87
88 void setRescalePolicy( RescalePolicy );
89 RescalePolicy rescalePolicy() const;
90
91 void setExpandingDirection( ExpandingDirection );
92 void setExpandingDirection( int axis, ExpandingDirection );
93 ExpandingDirection expandingDirection( int axis ) const;
94
95 void setReferenceAxis( int axis );
96 int referenceAxis() const;
97
98 void setAspectRatio( double ratio );
99 void setAspectRatio( int axis, double ratio );
100 double aspectRatio( int axis ) const;
101
102 void setIntervalHint( int axis, const QwtInterval& );
103 QwtInterval intervalHint( int axis ) const;
104
105 QWidget *canvas();
106 const QWidget *canvas() const;
107
108 QwtPlot *plot();
109 const QwtPlot *plot() const;
110
111 virtual bool eventFilter( QObject *, QEvent * );
112
113 void rescale() const;
114
115protected:
116 virtual void canvasResizeEvent( QResizeEvent * );
117
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;
121
122 virtual QwtInterval syncScale(
123 int axis, const QwtInterval& reference,
124 const QSize &size ) const;
125
126 virtual void updateScales(
127 QwtInterval intervals[QwtPlot::axisCnt] ) const;
128
129 Qt::Orientation orientation( int axis ) const;
130 QwtInterval interval( int axis ) const;
131 QwtInterval expandInterval( const QwtInterval &,
132 double width, ExpandingDirection ) const;
133
134private:
135 double pixelDist( int axis, const QSize & ) const;
136
137 class AxisData;
138 class PrivateData;
139 PrivateData *d_data;
140};
141
142#endif
Note: See TracBrowser for help on using the repository browser.