QWT 7.0.1
Loading...
Searching...
No Matches
qwt_plot_rescaler.h
1/******************************************************************************
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 * Modified by ChenZongYan in 2024 <czy.t@163.com>
10 * Summary of major modifications (see ChangeLog.md for full history):
11 * 1. CMake build system & C++11 throughout.
12 * 2. Core panner/ zoomer refactored:
13 * - QwtPanner → QwtCachePanner (pixmap-cache version)
14 * - New real-time QwtPlotPanner derived from QwtPicker.
15 * 3. Zoomer supports multi-axis.
16 * 4. Parasite-plot framework:
17 * - QwtFigure, QwtPlotParasiteLayout, QwtPlotTransparentCanvas,
18 * - QwtPlotScaleEventDispatcher, built-in pan/zoom on axis.
19 * 5. New picker: QwtPlotSeriesDataPicker (works with date axis).
20 * 6. Raster & color-map extensions:
21 * - QwtGridRasterData (2-D table + interpolation)
22 * - QwtLinearColorMap::stopColors(), stopPos() API rename.
23 * 7. Bar-chart: expose pen/brush control.
24 * 8. Amalgamated build: single QwtPlot.h / QwtPlot.cpp pair in src-amalgamate.
25 *****************************************************************************/
26
27#ifndef QWT_PLOT_RESCALER_H
28#define QWT_PLOT_RESCALER_H
29
30#include "qwt_global.h"
31#include "qwt_plot.h"
32
33#include <qobject.h>
34
35class QwtPlot;
36class QwtInterval;
37class QResizeEvent;
38
46class QWT_EXPORT QwtPlotRescaler : public QObject
47{
48 Q_OBJECT
49
50 public:
58 {
65
75
80 Fitting
81 };
82
88 {
91
94
96 ExpandBoth
97 };
98
99 explicit QwtPlotRescaler( QWidget* canvas,
100 QwtAxisId referenceAxis = QwtAxis::XBottom,
101 RescalePolicy = Expanding );
102
103 virtual ~QwtPlotRescaler();
104
105 void setEnabled( bool );
106 bool isEnabled() const;
107
108 void setRescalePolicy( RescalePolicy );
109 RescalePolicy rescalePolicy() const;
110
111 void setExpandingDirection( ExpandingDirection );
112 void setExpandingDirection( QwtAxisId, ExpandingDirection );
113 ExpandingDirection expandingDirection( QwtAxisId ) const;
114
115 void setReferenceAxis( QwtAxisId );
116 QwtAxisId referenceAxis() const;
117
118 void setAspectRatio( double ratio );
119 void setAspectRatio( QwtAxisId, double ratio );
120 double aspectRatio( QwtAxisId ) const;
121
122 void setIntervalHint( QwtAxisId, const QwtInterval& );
123 QwtInterval intervalHint( QwtAxisId ) const;
124
125 QWidget* canvas();
126 const QWidget* canvas() const;
127
128 QwtPlot* plot();
129 const QwtPlot* plot() const;
130
131 virtual bool eventFilter( QObject*, QEvent* ) QWT_OVERRIDE;
132
133 void rescale() const;
134
135 protected:
136 virtual void canvasResizeEvent( QResizeEvent* );
137
138 virtual void rescale( const QSize& oldSize, const QSize& newSize ) const;
139 virtual QwtInterval expandScale(
140 QwtAxisId, const QSize& oldSize, const QSize& newSize ) const;
141
142 virtual QwtInterval syncScale(
143 QwtAxisId, const QwtInterval& reference, const QSize& size ) const;
144
145 virtual void updateScales(
146 QwtInterval intervals[QwtAxis::AxisPositions] ) const;
147
148 Qt::Orientation orientation( QwtAxisId ) const;
149 QwtInterval interval( QwtAxisId ) const;
150 QwtInterval expandInterval( const QwtInterval&,
151 double width, ExpandingDirection ) const;
152
153 private:
154 double pixelDist( QwtAxisId, const QSize& ) const;
155
156 class AxisData;
157 class PrivateData;
158 PrivateData* m_data;
159};
160
161#endif
A class representing an interval.
Definition qwt_interval.h:40
QwtPlotRescaler takes care of fixed aspect ratios for plot scales.
Definition qwt_plot_rescaler.h:47
ExpandingDirection
When rescalePolicy() is set to Expanding its direction depends on ExpandingDirection.
Definition qwt_plot_rescaler.h:88
@ ExpandUp
The upper limit of the scale is adjusted.
Definition qwt_plot_rescaler.h:90
@ ExpandDown
The lower limit of the scale is adjusted.
Definition qwt_plot_rescaler.h:93
RescalePolicy
The rescale policy defines how to rescale the reference axis and their depending axes.
Definition qwt_plot_rescaler.h:58
@ Fixed
The interval of the reference axis remains unchanged, when the geometry of the canvas changes.
Definition qwt_plot_rescaler.h:64
@ Expanding
The interval of the reference axis will be shrunk/expanded, when the geometry of the canvas changes.
Definition qwt_plot_rescaler.h:74
A 2-D plotting widget.
Definition qwt_plot.h:99
@ XBottom
X axis below the canvas.
Definition qwt_axis.h:47