QWT API (中文) 7.0.1
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_plot_renderer.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_RENDERER_H
28#define QWT_PLOT_RENDERER_H
29
30#include "qwt_global.h"
31#include "qwt_axis_id.h"
32
33#include <qobject.h>
34#include <qsize.h>
35
36class QwtPlot;
37class QwtScaleMap;
38class QRectF;
39class QPainter;
40class QPaintDevice;
41
42#ifndef QT_NO_PRINTER
43class QPrinter;
44#endif
45
46#ifndef QWT_NO_SVG
47#ifdef QT_SVG_LIB
48class QSvgGenerator;
49#endif
50#endif
51
62class QWT_EXPORT QwtPlotRenderer : public QObject
63{
64 Q_OBJECT
65
66 public:
79 {
81 DiscardNone = 0x00,
82
84 DiscardBackground = 0x01,
85
87 DiscardTitle = 0x02,
88
90 DiscardLegend = 0x04,
91
93 DiscardCanvasBackground = 0x08,
94
96 DiscardFooter = 0x10,
97
113 DiscardCanvasFrame = 0x20
114
115 };
116
117 Q_DECLARE_FLAGS( DiscardFlags, DiscardFlag )
118
119
133 {
135 DefaultLayout = 0x00,
136
147 FrameWithScales = 0x01
148 };
149
150 Q_DECLARE_FLAGS( LayoutFlags, LayoutFlag )
151
152 // Constructor
153 explicit QwtPlotRenderer( QObject* = nullptr );
154 // Destructor
155 virtual ~QwtPlotRenderer();
156
157 // Set a discard flag
158 void setDiscardFlag( DiscardFlag flag, bool on = true );
159 // Test a discard flag
160 bool testDiscardFlag( DiscardFlag flag ) const;
161
162 // Set discard flags
163 void setDiscardFlags( DiscardFlags flags );
164 // Get discard flags
165 DiscardFlags discardFlags() const;
166
167 // Set a layout flag
168 void setLayoutFlag( LayoutFlag flag, bool on = true );
169 // Test a layout flag
170 bool testLayoutFlag( LayoutFlag flag ) const;
171
172 // Set layout flags
173 void setLayoutFlags( LayoutFlags flags );
174 // Get layout flags
175 LayoutFlags layoutFlags() const;
176
177 // Render the plot to a document
178 void renderDocument( QwtPlot*, const QString& fileName,
179 const QSizeF& sizeMM, int resolution = 85 );
180
181 // Render the plot to a document with specified format
182 void renderDocument( QwtPlot*,
183 const QString& fileName, const QString& format,
184 const QSizeF& sizeMM, int resolution = 85 );
185
186#ifndef QWT_NO_SVG
187#ifdef QT_SVG_LIB
188 // Render the plot to an SVG generator
189 void renderTo( QwtPlot*, QSvgGenerator& ) const;
190#endif
191#endif
192
193#ifndef QT_NO_PRINTER
194 // Render the plot to a printer
195 void renderTo( QwtPlot*, QPrinter& ) const;
196#endif
197
198 // Render the plot to a paint device
199 void renderTo( QwtPlot*, QPaintDevice& ) const;
200
201 // Render the plot
202 virtual void render( QwtPlot*,
203 QPainter*, const QRectF& plotRect ) const;
204
205 // Render the title
206 virtual void renderTitle( const QwtPlot*,
207 QPainter*, const QRectF& titleRect ) const;
208
209 // Render the footer
210 virtual void renderFooter( const QwtPlot*,
211 QPainter*, const QRectF& footerRect ) const;
212
213 // Render a scale
214 virtual void renderScale( const QwtPlot*, QPainter*,
215 QwtAxisId, int startDist, int endDist,
216 int baseDist, const QRectF& scaleRect ) const;
217
218 // Render the canvas
219 virtual void renderCanvas( const QwtPlot*,
220 QPainter*, const QRectF& canvasRect,
221 const QwtScaleMap* maps ) const;
222
223 // Render the legend
224 virtual void renderLegend(
225 const QwtPlot*, QPainter*, const QRectF& legendRect ) const;
226
227 // Export the plot to a document
228 bool exportTo( QwtPlot*, const QString& documentName,
229 const QSizeF& sizeMM = QSizeF( 300, 200 ), int resolution = 85 );
230
231 private:
237 void buildCanvasMaps( const QwtPlot*,
238 const QRectF&, QwtScaleMap maps[] ) const;
239
245 bool updateCanvasMargins( QwtPlot*,
246 const QRectF&, const QwtScaleMap maps[] ) const;
247
248 private:
249 class PrivateData;
250 PrivateData* m_data;
251};
252
253Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRenderer::DiscardFlags )
254Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRenderer::LayoutFlags )
255
256#endif
用于将绘图导出到文档、打印机或其他受 QPainter/QPaintDevice 支持的对象的渲染器
Definition qwt_plot_renderer.h:63
LayoutFlag
布局标志
Definition qwt_plot_renderer.h:133
DiscardFlag
丢弃标志
Definition qwt_plot_renderer.h:79
二维绘图部件
Definition qwt_plot.h:138
刻度映射
Definition qwt_scale_map.h:52