Qwt User's Guide 6.3.0
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
10#ifndef QWT_GRAPHIC_H
11#define QWT_GRAPHIC_H
12
13#include "qwt_global.h"
14#include "qwt_null_paintdevice.h"
15
16#include <qmetatype.h>
17
19class QPixmap;
20class QImage;
21
75class QWT_EXPORT QwtGraphic : public QwtNullPaintDevice
76{
77 public:
83 {
96 RenderPensUnscaled = 0x1
97 };
98
99 Q_DECLARE_FLAGS( RenderHints, RenderHint )
100
101
106 {
108 VectorData = 1 << 0,
109
111 RasterData = 1 << 1,
112
114 Transformation = 1 << 2
115 };
116
117 Q_DECLARE_FLAGS( CommandTypes, CommandType )
118
119 QwtGraphic();
120 QwtGraphic( const QwtGraphic& );
121
122 virtual ~QwtGraphic();
123
124 QwtGraphic& operator=( const QwtGraphic& );
125
126 void reset();
127
128 bool isNull() const;
129 bool isEmpty() const;
130
131 CommandTypes commandTypes() const;
132
133 void render( QPainter* ) const;
134
135 void render( QPainter*, const QSizeF&,
136 Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
137
138 void render( QPainter*, const QPointF&,
139 Qt::Alignment = Qt::AlignTop | Qt::AlignLeft ) const;
140
141 void render( QPainter*, const QRectF&,
142 Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
143
144 QPixmap toPixmap( qreal devicePixelRatio = 0.0 ) const;
145
146 QPixmap toPixmap( const QSize&,
147 Qt::AspectRatioMode = Qt::IgnoreAspectRatio,
148 qreal devicePixelRatio = 0.0 ) const;
149
150 QImage toImage( qreal devicePixelRatio = 0.0 ) const;
151
152 QImage toImage( const QSize&,
153 Qt::AspectRatioMode = Qt::IgnoreAspectRatio,
154 qreal devicePixelRatio = 0.0 ) const;
155
156 QRectF scaledBoundingRect( qreal sx, qreal sy ) const;
157
158 QRectF boundingRect() const;
159 QRectF controlPointRect() const;
160
161 const QVector< QwtPainterCommand >& commands() const;
162 void setCommands( const QVector< QwtPainterCommand >& );
163
164 void setDefaultSize( const QSizeF& );
165 QSizeF defaultSize() const;
166
167 qreal heightForWidth( qreal width ) const;
168 qreal widthForHeight( qreal height ) const;
169
170 void setRenderHint( RenderHint, bool on = true );
171 bool testRenderHint( RenderHint ) const;
172
173 RenderHints renderHints() const;
174
175 protected:
176 virtual QSize sizeMetrics() const QWT_OVERRIDE;
177
178 virtual void drawPath( const QPainterPath& ) QWT_OVERRIDE;
179
180 virtual void drawPixmap( const QRectF&,
181 const QPixmap&, const QRectF& ) QWT_OVERRIDE;
182
183 virtual void drawImage( const QRectF&, const QImage&,
184 const QRectF&, Qt::ImageConversionFlags ) QWT_OVERRIDE;
185
186 virtual void updateState( const QPaintEngineState& ) QWT_OVERRIDE;
187
188 private:
189 void renderGraphic( QPainter*, QTransform* ) const;
190
191 void updateBoundingRect( const QRectF& );
192 void updateControlPointRect( const QRectF& );
193
194 class PathInfo;
195
196 class PrivateData;
197 PrivateData* m_data;
198};
199
200Q_DECLARE_OPERATORS_FOR_FLAGS( QwtGraphic::RenderHints )
201Q_DECLARE_OPERATORS_FOR_FLAGS( QwtGraphic::CommandTypes )
202Q_DECLARE_METATYPE( QwtGraphic )
203
204#endif
A paint device for scalable graphics.
Definition qwt_graphic.h:76
QFlags< RenderHint > RenderHints
Definition qwt_graphic.h:99
QFlags< CommandType > CommandTypes
A null paint device doing nothing.
virtual QSize sizeMetrics() const =0