QWT 7.0.1
Loading...
Searching...
No Matches
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
60 public:
63 {
65 DiscardNone = 0x00,
66
68 DiscardBackground = 0x01,
69
71 DiscardTitle = 0x02,
72
74 DiscardLegend = 0x04,
75
77 DiscardCanvasBackground = 0x08,
78
80 DiscardFooter = 0x10,
81
89 DiscardCanvasFrame = 0x20
90
91 };
92
93 Q_DECLARE_FLAGS( DiscardFlags, DiscardFlag )
94
95
100 {
102 DefaultLayout = 0x00,
103
108 FrameWithScales = 0x01
109 };
110
111 Q_DECLARE_FLAGS( LayoutFlags, LayoutFlag )
112
113 explicit QwtPlotRenderer( QObject* = NULL );
114 virtual ~QwtPlotRenderer();
115
116 void setDiscardFlag( DiscardFlag flag, bool on = true );
117 bool testDiscardFlag( DiscardFlag flag ) const;
118
119 void setDiscardFlags( DiscardFlags flags );
120 DiscardFlags discardFlags() const;
121
122 void setLayoutFlag( LayoutFlag flag, bool on = true );
123 bool testLayoutFlag( LayoutFlag flag ) const;
124
125 void setLayoutFlags( LayoutFlags flags );
126 LayoutFlags layoutFlags() const;
127
128 void renderDocument( QwtPlot*, const QString& fileName,
129 const QSizeF& sizeMM, int resolution = 85 );
130
131 void renderDocument( QwtPlot*,
132 const QString& fileName, const QString& format,
133 const QSizeF& sizeMM, int resolution = 85 );
134
135#ifndef QWT_NO_SVG
136#ifdef QT_SVG_LIB
137 void renderTo( QwtPlot*, QSvgGenerator& ) const;
138#endif
139#endif
140
141#ifndef QT_NO_PRINTER
142 void renderTo( QwtPlot*, QPrinter& ) const;
143#endif
144
145 void renderTo( QwtPlot*, QPaintDevice& ) const;
146
147 virtual void render( QwtPlot*,
148 QPainter*, const QRectF& plotRect ) const;
149
150 virtual void renderTitle( const QwtPlot*,
151 QPainter*, const QRectF& titleRect ) const;
152
153 virtual void renderFooter( const QwtPlot*,
154 QPainter*, const QRectF& footerRect ) const;
155
156 virtual void renderScale( const QwtPlot*, QPainter*,
157 QwtAxisId, int startDist, int endDist,
158 int baseDist, const QRectF& scaleRect ) const;
159
160 virtual void renderCanvas( const QwtPlot*,
161 QPainter*, const QRectF& canvasRect,
162 const QwtScaleMap* maps ) const;
163
164 virtual void renderLegend(
165 const QwtPlot*, QPainter*, const QRectF& legendRect ) const;
166
167 bool exportTo( QwtPlot*, const QString& documentName,
168 const QSizeF& sizeMM = QSizeF( 300, 200 ), int resolution = 85 );
169
170 private:
171 void buildCanvasMaps( const QwtPlot*,
172 const QRectF&, QwtScaleMap maps[] ) const;
173
174 bool updateCanvasMargins( QwtPlot*,
175 const QRectF&, const QwtScaleMap maps[] ) const;
176
177 private:
178 class PrivateData;
179 PrivateData* m_data;
180};
181
182Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRenderer::DiscardFlags )
183Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRenderer::LayoutFlags )
184
185#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:100
DiscardFlag
Discard flags.
Definition qwt_plot_renderer.h:63
A 2-D plotting widget.
Definition qwt_plot.h:99
A scale map.
Definition qwt_scale_map.h:44