Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef QWT_GRAPHIC_H
00011 #define QWT_GRAPHIC_H
00012
00013 #include "qwt_global.h"
00014 #include "qwt_null_paintdevice.h"
00015 #include <qmetatype.h>
00016 #include <qimage.h>
00017 #include <qpixmap.h>
00018
00019 class QwtPainterCommand;
00020
00074 class QWT_EXPORT QwtGraphic: public QwtNullPaintDevice
00075 {
00076 public:
00081 enum RenderHint
00082 {
00095 RenderPensUnscaled = 0x1
00096 };
00097
00103 typedef QFlags<RenderHint> RenderHints;
00104
00105 QwtGraphic();
00106 QwtGraphic( const QwtGraphic & );
00107
00108 virtual ~QwtGraphic();
00109
00110 QwtGraphic& operator=( const QwtGraphic & );
00111
00112 void reset();
00113
00114 bool isNull() const;
00115 bool isEmpty() const;
00116
00117 void render( QPainter * ) const;
00118
00119 void render( QPainter *, const QSizeF &,
00120 Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
00121
00122 void render( QPainter *, const QRectF &,
00123 Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
00124
00125 void render( QPainter *, const QPointF &,
00126 Qt::Alignment = Qt::AlignTop | Qt::AlignLeft ) const;
00127
00128 QPixmap toPixmap() const;
00129 QPixmap toPixmap( const QSize &,
00130 Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
00131
00132 QImage toImage() const;
00133 QImage toImage( const QSize &,
00134 Qt::AspectRatioMode = Qt::IgnoreAspectRatio ) const;
00135
00136 QRectF scaledBoundingRect( double sx, double sy ) const;
00137
00138 QRectF boundingRect() const;
00139 QRectF controlPointRect() const;
00140
00141 const QVector< QwtPainterCommand > &commands() const;
00142 void setCommands( QVector< QwtPainterCommand > & );
00143
00144 void setDefaultSize( const QSizeF & );
00145 QSizeF defaultSize() const;
00146
00147 void setRenderHint( RenderHint, bool on = true );
00148 bool testRenderHint( RenderHint ) const;
00149
00150 protected:
00151 virtual QSize sizeMetrics() const;
00152
00153 virtual void drawPath( const QPainterPath & );
00154
00155 virtual void drawPixmap( const QRectF &,
00156 const QPixmap &, const QRectF & );
00157
00158 virtual void drawImage( const QRectF &,
00159 const QImage &, const QRectF &, Qt::ImageConversionFlags );
00160
00161 virtual void updateState( const QPaintEngineState &state );
00162
00163 private:
00164 void updateBoundingRect( const QRectF & );
00165 void updateControlPointRect( const QRectF & );
00166
00167 class PathInfo;
00168
00169 class PrivateData;
00170 PrivateData *d_data;
00171 };
00172
00173 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtGraphic::RenderHints )
00174 Q_DECLARE_METATYPE( QwtGraphic )
00175
00176 #endif