Qwt User's Guide svn
qwt_plot_rasteritem.h
00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
00002  * Qwt Widget Library
00003  * Copyright (C) 1997   Josef Wilgen
00004  * Copyright (C) 2002   Uwe Rathmann
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the Qwt License, Version 1.0
00008  *****************************************************************************/
00009 
00010 #ifndef QWT_PLOT_RASTERITEM_H
00011 #define QWT_PLOT_RASTERITEM_H
00012 
00013 #include "qwt_global.h"
00014 #include "qwt_plot_item.h"
00015 #include "qwt_interval.h"
00016 #include <qglobal.h>
00017 #include <qstring.h>
00018 #include <qimage.h>
00019 
00037 class QWT_EXPORT QwtPlotRasterItem: public QwtPlotItem
00038 {
00039 public:
00052     enum CachePolicy
00053     {
00054         NoCache,
00055         PaintCache
00056     };
00057 
00062     enum PaintAttribute
00063     {
00076         PaintInDeviceResolution = 1
00077     };
00078 
00080     typedef QFlags<PaintAttribute> PaintAttributes;
00081 
00082     explicit QwtPlotRasterItem( const QString& title = QString::null );
00083     explicit QwtPlotRasterItem( const QwtText& title );
00084     virtual ~QwtPlotRasterItem();
00085 
00086     void setPaintAttribute( PaintAttribute, bool on = true );
00087     bool testPaintAttribute( PaintAttribute ) const;
00088 
00089     void setAlpha( int alpha );
00090     int alpha() const;
00091 
00092     void setCachePolicy( CachePolicy );
00093     CachePolicy cachePolicy() const;
00094 
00095     void invalidateCache();
00096 
00097     virtual void draw( QPainter *p,
00098         const QwtScaleMap &xMap, const QwtScaleMap &yMap,
00099         const QRectF &rect ) const;
00100 
00101     virtual QRectF pixelHint( const QRectF & ) const;
00102 
00103     virtual QwtInterval interval(Qt::Axis) const;
00104     virtual QRectF boundingRect() const;
00105 
00106 protected:
00121     virtual QImage renderImage( const QwtScaleMap &xMap,
00122         const QwtScaleMap &yMap, const QRectF &area,
00123         const QSize &imageSize ) const = 0;
00124 
00125     virtual QwtScaleMap imageMap( Qt::Orientation,
00126         const QwtScaleMap &map, const QRectF &area,
00127         const QSize &imageSize, double pixelSize) const;
00128 
00129 private:
00130     QwtPlotRasterItem( const QwtPlotRasterItem & );
00131     QwtPlotRasterItem &operator=( const QwtPlotRasterItem & );
00132 
00133     void init();
00134 
00135     QImage compose( const QwtScaleMap &, const QwtScaleMap &,
00136         const QRectF &imageArea, const QRectF &paintRect,
00137         const QSize &imageSize, bool doCache) const;
00138 
00139 
00140     class PrivateData;
00141     PrivateData *d_data;
00142 };
00143 
00144 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotRasterItem::PaintAttributes )
00145 
00146 #endif
qmi style