QWT API (中文) 7.3.0
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
56class QWT_EXPORT QwtPlotRenderer : public QObject
57{
58 Q_OBJECT
59
60public:
66 {
68 DiscardNone = 0x00,
69
71 DiscardBackground = 0x01,
72
74 DiscardTitle = 0x02,
75
77 DiscardLegend = 0x04,
78
80 DiscardCanvasBackground = 0x08,
81
83 DiscardFooter = 0x10,
84
87 DiscardCanvasFrame = 0x20
88
89 };
90
91 Q_DECLARE_FLAGS(DiscardFlags, DiscardFlag)
92
93
99 {
101 DefaultLayout = 0x00,
102
104 FrameWithScales = 0x01
105 };
106
107 Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag)
108
109 // Constructor
110 explicit QwtPlotRenderer(QObject* = nullptr);
111 // Destructor
112 ~QwtPlotRenderer() override;
113
114 // Set a discard flag
115 void setDiscardFlag(DiscardFlag flag, bool on = true);
116 // Test a discard flag
117 bool testDiscardFlag(DiscardFlag flag) const;
118
119 // Set discard flags
120 void setDiscardFlags(DiscardFlags flags);
121 // Get discard flags
122 DiscardFlags discardFlags() const;
123
124 // Set a layout flag
125 void setLayoutFlag(LayoutFlag flag, bool on = true);
126 // Test a layout flag
127 bool testLayoutFlag(LayoutFlag flag) const;
128
129 // Set layout flags
130 void setLayoutFlags(LayoutFlags flags);
131 // Get layout flags
132 LayoutFlags layoutFlags() const;
133
134 // Render the plot to a document
135 void renderDocument(QwtPlot*, const QString& fileName, const QSizeF& sizeMM, int resolution = 85);
136
137 // Render the plot to a document with specified format
138 void renderDocument(QwtPlot*, const QString& fileName, const QString& format, const QSizeF& sizeMM, int resolution = 85);
139
140#ifndef QWT_NO_SVG
141#ifdef QT_SVG_LIB
142 // Render the plot to an SVG generator
143 void renderTo(QwtPlot*, QSvgGenerator&) const;
144#endif
145#endif
146
147#ifndef QT_NO_PRINTER
148 // Render the plot to a printer
149 void renderTo(QwtPlot*, QPrinter&) const;
150#endif
151
152 // Render the plot to a paint device
153 void renderTo(QwtPlot*, QPaintDevice&) const;
154
155 // Render the plot
156 virtual void render(QwtPlot*, QPainter*, const QRectF& plotRect) const;
157
158 // Render the title
159 virtual void renderTitle(const QwtPlot*, QPainter*, const QRectF& titleRect) const;
160
161 // Render the footer
162 virtual void renderFooter(const QwtPlot*, QPainter*, const QRectF& footerRect) const;
163
164 // Render a scale
165 virtual void
166 renderScale(const QwtPlot*, QPainter*, QwtAxisId, int startDist, int endDist, int baseDist, const QRectF& scaleRect) const;
167
168 // Render the canvas
169 virtual void renderCanvas(const QwtPlot*, QPainter*, const QRectF& canvasRect, const QwtScaleMap* maps) const;
170
171 // Render the legend
172 virtual void renderLegend(const QwtPlot*, QPainter*, const QRectF& legendRect) const;
173
174 // Export the plot to a document
175 bool exportTo(QwtPlot*, const QString& documentName, const QSizeF& sizeMM = QSizeF(300, 200), int resolution = 85);
176
177private:
178 // Build canvas maps
179 void buildCanvasMaps(const QwtPlot*, const QRectF&, QwtScaleMap maps[]) const;
180
181 // Update canvas margins
182 bool updateCanvasMargins(QwtPlot*, const QRectF&, const QwtScaleMap maps[]) const;
183
184private:
185 QWT_DECLARE_PRIVATE(QwtPlotRenderer)
186};
187
188Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotRenderer::DiscardFlags)
189Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotRenderer::LayoutFlags)
190
191#endif
Renderer for exporting a plot to a document, a printer or anything else, that is supported by QPainte...
Definition qwt_plot_renderer.h:57
LayoutFlag
Layout flags
Definition qwt_plot_renderer.h:99
DiscardFlag
Discard flags
Definition qwt_plot_renderer.h:66
A 2-D plotting widget
Definition qwt_plot.h:99
A scale map
Definition qwt_scale_map.h:44