QWT 7.0.1
Loading...
Searching...
No Matches
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
33#include <qmetatype.h>
34
36class QPixmap;
37class QImage;
38
92class QWT_EXPORT QwtGraphic : public QwtNullPaintDevice
93{
94 public:
100 {
113 RenderPensUnscaled = 0x1
114 };
115
116 Q_DECLARE_FLAGS( RenderHints, RenderHint )
117
118
123 {
125 VectorData = 1 << 0,
126
128 RasterData = 1 << 1,
129
131 Transformation = 1 << 2
132 };
133
134 Q_DECLARE_FLAGS( CommandTypes, CommandType )
135
136 QwtGraphic();
137 QwtGraphic( const QwtGraphic& );
138
139 virtual ~QwtGraphic();
140
141 QwtGraphic& operator=( const QwtGraphic& );
142
143 void reset();
144
145 bool isNull() const;
146 bool isEmpty() const;
147
148 CommandTypes commandTypes() const;
149
150 void render( QPainter* ) const;
151
152 void render( QPainter*, const QSizeF&,
153 Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
154
155 void render( QPainter*, const QPointF&,
156 Qt::Alignment = Qt::AlignTop | Qt::AlignLeft ) const;
157
158 void render( QPainter*, const QRectF&,
159 Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
160
161 QPixmap toPixmap( qreal devicePixelRatio = 0.0 ) const;
162
163 QPixmap toPixmap( const QSize&,
164 Qt::AspectRatioMode = Qt::IgnoreAspectRatio,
165 qreal devicePixelRatio = 0.0 ) const;
166
167 QImage toImage( qreal devicePixelRatio = 0.0 ) const;
168
169 QImage toImage( const QSize&,
170 Qt::AspectRatioMode = Qt::IgnoreAspectRatio,
171 qreal devicePixelRatio = 0.0 ) const;
172
173 QRectF scaledBoundingRect( qreal sx, qreal sy ) const;
174
175 QRectF boundingRect() const;
176 QRectF controlPointRect() const;
177
178 const QVector< QwtPainterCommand >& commands() const;
179 void setCommands( const QVector< QwtPainterCommand >& );
180
181 void setDefaultSize( const QSizeF& );
182 QSizeF defaultSize() const;
183
184 qreal heightForWidth( qreal width ) const;
185 qreal widthForHeight( qreal height ) const;
186
187 void setRenderHint( RenderHint, bool on = true );
188 bool testRenderHint( RenderHint ) const;
189
190 RenderHints renderHints() const;
191
192 protected:
193 virtual QSize sizeMetrics() const QWT_OVERRIDE;
194
195 virtual void drawPath( const QPainterPath& ) QWT_OVERRIDE;
196
197 virtual void drawPixmap( const QRectF&,
198 const QPixmap&, const QRectF& ) QWT_OVERRIDE;
199
200 virtual void drawImage( const QRectF&, const QImage&,
201 const QRectF&, Qt::ImageConversionFlags ) QWT_OVERRIDE;
202
203 virtual void updateState( const QPaintEngineState& ) QWT_OVERRIDE;
204
205 private:
206 void renderGraphic( QPainter*, QTransform* ) const;
207
208 void updateBoundingRect( const QRectF& );
209 void updateControlPointRect( const QRectF& );
210
211 class PathInfo;
212
213 class PrivateData;
214 PrivateData* m_data;
215};
216
217Q_DECLARE_OPERATORS_FOR_FLAGS( QwtGraphic::RenderHints )
218Q_DECLARE_OPERATORS_FOR_FLAGS( QwtGraphic::CommandTypes )
219Q_DECLARE_METATYPE( QwtGraphic )
220
221#endif
Definition qwt_clipper.h:40
A paint device for scalable graphics.
Definition qwt_graphic.h:93
RenderHint
Hint how to render a graphic.
Definition qwt_graphic.h:100
CommandType
Indicator if the graphic contains a specific type of painter command.
Definition qwt_graphic.h:123
A null paint device doing nothing.
Definition qwt_null_paintdevice.h:50
virtual QSize sizeMetrics() const =0
QwtPainterCommand represents the attributes of a paint operation how it is used between QPainter and ...
Definition qwt_painter_command.h:50