QWT API (中文) 7.0.1
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_graphic.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_GRAPHIC_H
28#define QWT_GRAPHIC_H
29
30#include "qwt_global.h"
31#include "qwt_null_paintdevice.h"
32#include "qwt_painter_command.h"
33
34#include <qmetatype.h>
35
127class QWT_EXPORT QwtGraphic : public QwtNullPaintDevice
128{
129 public:
140 {
162 RenderPensUnscaled = 0x1
163 };
164
165 Q_DECLARE_FLAGS( RenderHints, RenderHint )
166
167
177 {
179 VectorData = 1 << 0,
180
182 RasterData = 1 << 1,
183
185 Transformation = 1 << 2
186 };
187
188 Q_DECLARE_FLAGS( CommandTypes, CommandType )
189
190 // Constructor
191 QwtGraphic();
192 // Copy constructor
193 QwtGraphic( const QwtGraphic& );
194
195 // Destructor
196 virtual ~QwtGraphic();
197
198 // Assignment operator
199 QwtGraphic& operator=( const QwtGraphic& );
200
201 // Clear all stored commands
202 void reset();
203
204 // Check if the graphic is null
205 bool isNull() const;
206 // Check if the graphic is empty
207 bool isEmpty() const;
208
209 // Get the types of painter commands being used
210 CommandTypes commandTypes() const;
211
212 // Replay all recorded painter commands
213 void render( QPainter* ) const;
214
215 // Render graphic scaled to fit into given size
216 void render( QPainter*, const QSizeF&,
217 Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
218
219 // Render graphic aligned to a position
220 void render( QPainter*, const QPointF&,
221 Qt::Alignment = Qt::AlignTop | Qt::AlignLeft ) const;
222
223 // Render graphic scaled to fit into given rectangle
224 void render( QPainter*, const QRectF&,
225 Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
226
227 // Convert graphic to QPixmap in default size
228 QPixmap toPixmap( qreal devicePixelRatio = 0.0 ) const;
229
230 // Convert graphic to QPixmap with specified size
231 QPixmap toPixmap( const QSize&,
232 Qt::AspectRatioMode = Qt::IgnoreAspectRatio,
233 qreal devicePixelRatio = 0.0 ) const;
234
235 // Convert graphic to QImage in default size
236 QImage toImage( qreal devicePixelRatio = 0.0 ) const;
237
238 // Convert graphic to QImage with specified size
239 QImage toImage( const QSize&,
240 Qt::AspectRatioMode = Qt::IgnoreAspectRatio,
241 qreal devicePixelRatio = 0.0 ) const;
242
243 // Calculate the scaled bounding rectangle
244 QRectF scaledBoundingRect( qreal sx, qreal sy ) const;
245
246 // Get the bounding rectangle
247 QRectF boundingRect() const;
248 // Get the control point rectangle
249 QRectF controlPointRect() const;
250
251 // Get the list of recorded paint commands
252 const QVector< QwtPainterCommand >& commands() const;
253 // Set the paint commands
254 void setCommands( const QVector< QwtPainterCommand >& );
255
256 // Set the default size
257 void setDefaultSize( const QSizeF& );
258 // Get the default size
259 QSizeF defaultSize() const;
260
261 // Get the height for a given width
262 qreal heightForWidth( qreal width ) const;
263 // Get the width for a given height
264 qreal widthForHeight( qreal height ) const;
265
266 // Set a render hint
267 void setRenderHint( RenderHint, bool on = true );
268 // Test a render hint
269 bool testRenderHint( RenderHint ) const;
270
271 // Get the render hints
272 RenderHints renderHints() const;
273
274 protected:
275 virtual QSize sizeMetrics() const override;
276
277 virtual void drawPath( const QPainterPath& ) override;
278
279 virtual void drawPixmap( const QRectF&,
280 const QPixmap&, const QRectF& ) override;
281
282 virtual void drawImage( const QRectF&, const QImage&,
283 const QRectF&, Qt::ImageConversionFlags ) override;
284
285 virtual void updateState( const QPaintEngineState& ) override;
286
287 private:
288 void renderGraphic( QPainter*, QTransform* ) const;
289
290 void updateBoundingRect( const QRectF& );
291 void updateControlPointRect( const QRectF& );
292
293 class PathInfo;
294
295 class PrivateData;
296 PrivateData* m_data;
297};
298
299Q_DECLARE_OPERATORS_FOR_FLAGS( QwtGraphic::RenderHints )
300Q_DECLARE_OPERATORS_FOR_FLAGS( QwtGraphic::CommandTypes )
301Q_DECLARE_METATYPE( QwtGraphic )
302
303#endif
Definition qwt_clipper.h:40
可缩放图形的绘制设备
Definition qwt_graphic.h:128
RenderHint
渲染图形的提示
Definition qwt_graphic.h:140
CommandType
指示图形是否包含特定类型的绘制命令
Definition qwt_graphic.h:177
一个不执行任何操作的空绘制设备
Definition qwt_null_paintdevice.h:55
virtual void drawPixmap(const QRectF &, const QPixmap &, const QRectF &)
Draw a pixmap
Definition qwt_null_paintdevice.cpp:640
virtual void drawPath(const QPainterPath &)
Draw a painter path
Definition qwt_null_paintdevice.cpp:598
virtual void drawImage(const QRectF &, const QImage &, const QRectF &, Qt::ImageConversionFlags)
Draw an image
Definition qwt_null_paintdevice.cpp:667
virtual void updateState(const QPaintEngineState &)
Update the paint engine state
Definition qwt_null_paintdevice.cpp:678
virtual QSize sizeMetrics() const =0