A class, which displays raster data. More...
#include <qwt_plot_rasteritem.h>
Classes | |
class | PrivateData |
Public Types | |
enum | CachePolicy { NoCache, PaintCache } |
Cache policy The default policy is NoCache. More... | |
enum | PaintAttribute { PaintInDeviceResolution = 1 } |
typedef QFlags< PaintAttribute > | PaintAttributes |
Paint attributes. | |
Public Member Functions | |
int | alpha () const |
virtual QRectF | boundingRect () const |
CachePolicy | cachePolicy () const |
virtual void | draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &rect) const |
Draw the raster data. | |
virtual QwtInterval | interval (Qt::Axis) const |
void | invalidateCache () |
virtual QRectF | pixelHint (const QRectF &) const |
Pixel hint. | |
QwtPlotRasterItem (const QString &title=QString::null) | |
Constructor. | |
QwtPlotRasterItem (const QwtText &title) | |
Constructor. | |
void | setAlpha (int alpha) |
Set an alpha value for the raster data. | |
void | setCachePolicy (CachePolicy) |
void | setPaintAttribute (PaintAttribute, bool on=true) |
bool | testPaintAttribute (PaintAttribute) const |
virtual | ~QwtPlotRasterItem () |
Destructor. | |
Protected Member Functions | |
virtual QwtScaleMap | imageMap (Qt::Orientation, const QwtScaleMap &map, const QRectF &area, const QSize &imageSize, double pixelSize) const |
Calculate a scale map for painting to an image. | |
virtual QImage | renderImage (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &area, const QSize &imageSize) const =0 |
Render an image. | |
Private Member Functions | |
QImage | compose (const QwtScaleMap &, const QwtScaleMap &, const QRectF &imageArea, const QRectF &paintRect, const QSize &imageSize, bool doCache) const |
void | init () |
QwtPlotRasterItem & | operator= (const QwtPlotRasterItem &) |
QwtPlotRasterItem (const QwtPlotRasterItem &) | |
Private Attributes | |
PrivateData * | d_data |
A class, which displays raster data.
Raster data is a grid of pixel values, that can be represented as a QImage. It is used for many types of information like spectrograms, cartograms, geographical maps ...
Often a plot has several types of raster data organized in layers. ( f.e a geographical map, with weather statistics ). Using setAlpha() raster items can be stacked easily.
QwtPlotRasterItem is only implemented for images of the following formats: QImage::Format_Indexed8, QImage::Format_ARGB32.
Definition at line 37 of file qwt_plot_rasteritem.h.
typedef QFlags<PaintAttribute> QwtPlotRasterItem::PaintAttributes |
Paint attributes.
Definition at line 84 of file qwt_plot_rasteritem.h.
Cache policy The default policy is NoCache.
NoCache |
renderImage() is called each time the item has to be repainted |
PaintCache |
renderImage() is called, whenever the image cache is not valid, or the scales, or the size of the canvas has changed. This type of cache is useful for improving the performance of hide/show operations or manipulations of the alpha value. All other situations are handled by the canvas backing store. |
Definition at line 44 of file qwt_plot_rasteritem.h.
Attributes to modify the drawing algorithm.
PaintInDeviceResolution |
When the image is rendered according to the data pixels ( QwtRasterData::pixelHint() ) it can be expanded to paint device resolution before it is passed to QPainter. The expansion algorithm rounds the pixel borders in the same way as the axis ticks, what is usually better than the scaling algorithm implemented in Qt. Disabling this flag might make sense, to reduce the size of a document/file. If this is possible for a document format depends on the implementation of the specific QPaintEngine. |
Definition at line 66 of file qwt_plot_rasteritem.h.
QwtPlotRasterItem::QwtPlotRasterItem | ( | const QString & | title = QString::null | ) | [explicit] |
Constructor.
Definition at line 428 of file qwt_plot_rasteritem.cpp.
QwtPlotRasterItem::QwtPlotRasterItem | ( | const QwtText & | title | ) | [explicit] |
Constructor.
Definition at line 435 of file qwt_plot_rasteritem.cpp.
QwtPlotRasterItem::~QwtPlotRasterItem | ( | ) | [virtual] |
Destructor.
Definition at line 442 of file qwt_plot_rasteritem.cpp.
QwtPlotRasterItem::QwtPlotRasterItem | ( | const QwtPlotRasterItem & | ) | [explicit, private] |
int QwtPlotRasterItem::alpha | ( | ) | const |
Definition at line 524 of file qwt_plot_rasteritem.cpp.
QRectF QwtPlotRasterItem::boundingRect | ( | ) | const [virtual] |
Reimplemented from QwtPlotItem.
Definition at line 782 of file qwt_plot_rasteritem.cpp.
Definition at line 553 of file qwt_plot_rasteritem.cpp.
QImage QwtPlotRasterItem::compose | ( | const QwtScaleMap & | xMap, |
const QwtScaleMap & | yMap, | ||
const QRectF & | imageArea, | ||
const QRectF & | paintRect, | ||
const QSize & | imageSize, | ||
bool | doCache | ||
) | const [private] |
Definition at line 817 of file qwt_plot_rasteritem.cpp.
void QwtPlotRasterItem::draw | ( | QPainter * | painter, |
const QwtScaleMap & | xMap, | ||
const QwtScaleMap & | yMap, | ||
const QRectF & | canvasRect | ||
) | const [virtual] |
Draw the raster data.
painter | Painter |
xMap | X-Scale Map |
yMap | Y-Scale Map |
canvasRect | Contents rectangle of the plot canvas |
Implements QwtPlotItem.
Reimplemented in QwtPlotSpectrogram.
Definition at line 608 of file qwt_plot_rasteritem.cpp.
QwtScaleMap QwtPlotRasterItem::imageMap | ( | Qt::Orientation | orientation, |
const QwtScaleMap & | map, | ||
const QRectF & | area, | ||
const QSize & | imageSize, | ||
double | pixelSize | ||
) | const [protected, virtual] |
Calculate a scale map for painting to an image.
orientation | Orientation, Qt::Horizontal means a X axis |
map | Scale map for rendering the plot item |
area | Area to be painted on the image |
imageSize | Image size |
pixelSize | Width/Height of a data pixel |
Definition at line 915 of file qwt_plot_rasteritem.cpp.
void QwtPlotRasterItem::init | ( | ) | [private] |
Definition at line 447 of file qwt_plot_rasteritem.cpp.
QwtInterval QwtPlotRasterItem::interval | ( | Qt::Axis | axis | ) | const [virtual] |
This method is intended to be reimplemented by derived classes. The default implementation returns an invalid interval.
axis | X, Y, or Z axis |
Reimplemented in QwtPlotSpectrogram.
Definition at line 772 of file qwt_plot_rasteritem.cpp.
void QwtPlotRasterItem::invalidateCache | ( | ) |
Invalidate the paint cache
Definition at line 562 of file qwt_plot_rasteritem.cpp.
QwtPlotRasterItem& QwtPlotRasterItem::operator= | ( | const QwtPlotRasterItem & | ) | [private] |
QRectF QwtPlotRasterItem::pixelHint | ( | const QRectF & | area | ) | const [virtual] |
Pixel hint.
The geometry of a pixel is used to calculated the resolution and alignment of the rendered image.
Width and height of the hint need to be the horizontal and vertical distances between 2 neighbored points. The center of the hint has to be the position of any point ( it doesn't matter which one ).
Limiting the resolution of the image might significantly improve the performance and heavily reduce the amount of memory when rendering a QImage from the raster data.
The default implementation returns an empty rectangle (QRectF()), meaning, that the image will be rendered in target device ( f.e screen ) resolution.
area | In most implementations the resolution of the data doesn't depend on the requested area. |
Reimplemented in QwtPlotSpectrogram.
Definition at line 595 of file qwt_plot_rasteritem.cpp.
virtual QImage QwtPlotRasterItem::renderImage | ( | const QwtScaleMap & | xMap, |
const QwtScaleMap & | yMap, | ||
const QRectF & | area, | ||
const QSize & | imageSize | ||
) | const [protected, pure virtual] |
Render an image.
An implementation of render() might iterate over all pixels of imageRect. Each pixel has to be translated into the corresponding position in scale coordinates using the maps. This position can be used to look up a value in a implementation specific way and to map it into a color.
xMap | X-Scale Map |
yMap | Y-Scale Map |
area | Requested area for the image in scale coordinates |
imageSize | Requested size of the image |
Implemented in QwtPlotSpectrogram.
void QwtPlotRasterItem::setAlpha | ( | int | alpha | ) |
Set an alpha value for the raster data.
Often a plot has several types of raster data organized in layers. ( f.e a geographical map, with weather statistics ). Using setAlpha() raster items can be stacked easily.
The alpha value is a value [0, 255] to control the transparency of the image. 0 represents a fully transparent color, while 255 represents a fully opaque color.
alpha | Alpha value |
The default alpha value is -1.
Definition at line 504 of file qwt_plot_rasteritem.cpp.
void QwtPlotRasterItem::setCachePolicy | ( | QwtPlotRasterItem::CachePolicy | policy | ) |
Change the cache policy
The default policy is NoCache
policy | Cache policy |
Definition at line 537 of file qwt_plot_rasteritem.cpp.
void QwtPlotRasterItem::setPaintAttribute | ( | PaintAttribute | attribute, |
bool | on = true |
||
) |
Specify an attribute how to draw the raster item
attribute | Paint attribute |
on | On/Off /sa PaintAttribute, testPaintAttribute() |
Definition at line 464 of file qwt_plot_rasteritem.cpp.
bool QwtPlotRasterItem::testPaintAttribute | ( | PaintAttribute | attribute | ) | const |
Definition at line 476 of file qwt_plot_rasteritem.cpp.
PrivateData* QwtPlotRasterItem::d_data [private] |
Reimplemented from QwtPlotItem.
Reimplemented in QwtPlotSpectrogram.
Definition at line 146 of file qwt_plot_rasteritem.h.