Qwt User's Guide 6.0.2

- Main Page
- Related Pages
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Protected Member Functions
QwtPlotRasterItem Class Reference

`#include <qwt_plot_rasteritem.h>`

Inheritance diagram for QwtPlotRasterItem:
[legend]

List of all members.

## Public Types
enum | CachePolicy { NoCache, PaintCache }
enum | PaintAttribute { PaintInDeviceResolution = 1 }
typedef QFlags< PaintAttribute > | PaintAttributes
Public Types inherited from QwtPlotItem
enum | ItemAttribute { Legend = 0x01, AutoScale = 0x02 }
typedef QFlags< ItemAttribute > | ItemAttributes
enum | RenderHint { RenderAntialiased = 1 }
typedef QFlags< RenderHint > | RenderHints
enum | RttiValues { Rtti_PlotItem = 0, Rtti_PlotGrid, Rtti_PlotScale, Rtti_PlotMarker, Rtti_PlotCurve, Rtti_PlotSpectroCurve, Rtti_PlotIntervalCurve, Rtti_PlotHistogram, Rtti_PlotSpectrogram, Rtti_PlotSVG, Rtti_PlotUserItem = 1000 }

## Public Member Functions
| QwtPlotRasterItem (const QString &title=QString::null)
| QwtPlotRasterItem (const QwtText &title)
virtual | ~QwtPlotRasterItem ()
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
virtual QwtInterval | interval (Qt::Axis) const
void | invalidateCache ()
virtual QRectF | pixelHint (const QRectF &) const
void | setAlpha (int alpha)
void | setCachePolicy (CachePolicy)
void | setPaintAttribute (PaintAttribute, bool on=true)
bool | testPaintAttribute (PaintAttribute) const
Public Member Functions inherited from QwtPlotItem
| QwtPlotItem (const QwtText &title=QwtText())
virtual | ~QwtPlotItem ()
void | attach (QwtPlot *plot)
void | detach ()
void | hide ()
bool | isVisible () const
virtual void | itemChanged ()
virtual QWidget * | legendItem () const
QRectF | paintRect (const QwtScaleMap &, const QwtScaleMap &) const
QwtPlot * | plot () const
virtual int | rtti () const
QRectF | scaleRect (const QwtScaleMap &, const QwtScaleMap &) const
void | setAxes (int xAxis, int yAxis)
void | setItemAttribute (ItemAttribute, bool on=true)
void | setRenderHint (RenderHint, bool on=true)
void | setTitle (const QString &title)
void | setTitle (const QwtText &title)
virtual void | setVisible (bool)
void | setXAxis (int axis)
void | setYAxis (int axis)
void | setZ (double z)
void | show ()
bool | testItemAttribute (ItemAttribute) const
bool | testRenderHint (RenderHint) const
const QwtText & | title () const
virtual void | updateLegend (QwtLegend *) const
virtual void | updateScaleDiv (const QwtScaleDiv &, const QwtScaleDiv &)
int | xAxis () const
int | yAxis () const
double | z () const
Public Member Functions inherited from QwtLegendItemManager
| QwtLegendItemManager ()
virtual | ~QwtLegendItemManager ()
virtual void | drawLegendIdentifier (QPainter *, const QRectF &) const

## Protected Member Functions
virtual QwtScaleMap | imageMap (Qt::Orientation, const QwtScaleMap &map, const QRectF &area, const QSize &imageSize, double pixelSize) const
virtual QImage | renderImage (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &area, const QSize &imageSize) const =0

## Detailed Description

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.

See also:
  QwtPlotSpectrogram

## Member Enumeration Documentation

enum QwtPlotRasterItem::CachePolicy

- NoCache
  renderImage() is called, whenever 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 only useful for improving the performance of hide/show operations. All other situations are already handled by the plot canvas cache.

The default policy is NoCache

enum QwtPlotRasterItem::PaintAttribute

Attributes to modify the drawing algorithm.

See also:
  setPaintAttribute(), testPaintAttribute()

Enumerator:

  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.

## Member Function Documentation

int QwtPlotRasterItem::alpha | ( |  | ) | const

Returns:
  Alpha value of the raster item

See also:
  setAlpha()

QRectF QwtPlotRasterItem::boundingRect | ( |  | ) | const
| virtual

Returns:
  Bounding rect of the data

See also:
  QwtPlotRasterItem::interval()

Reimplemented from QwtPlotItem.

QwtPlotRasterItem::CachePolicy QwtPlotRasterItem::cachePolicy | ( |  | ) | const

Returns:
  Cache policy

See also:
  CachePolicy, setCachePolicy()

void QwtPlotRasterItem::draw | ( | QPainter * | painter,
|  | const QwtScaleMap & | xMap,
|  | const QwtScaleMap & | yMap,
|  | const QRectF & | canvasRect
| ) |  | const
| virtual

Draw the raster data.

Parameters:

  painter | Painter
  xMap | X-Scale Map
  yMap | Y-Scale Map
  canvasRect | Contents rect of the plot canvas

Implements QwtPlotItem.

Reimplemented in QwtPlotSpectrogram.

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.

Parameters:

  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

QwtInterval QwtPlotRasterItem::interval | ( | Qt::Axis | axis | ) | const
| virtual

Returns:
  Bounding interval for an axis

This method is intended to be reimplemented by derived classes. The default implementation returns an invalid interval.

Parameters:

  axis | X, Y, or Z axis

Reimplemented in QwtPlotSpectrogram.

void QwtPlotRasterItem::invalidateCache | ( |  | ) |

Invalidate the paint cache

See also:
  setCachePolicy()

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 neighboured 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.

Parameters:

  area | In most implementations the resolution of the data doesn't depend on the requested area.

Returns:
  Bounding rectangle of a pixel

See also:
  render(), renderImage()

Reimplemented in QwtPlotSpectrogram.

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.

Parameters:

  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.

Parameters:

  alpha | Alpha value

- alpha >= 0
  All alpha values of the pixels returned by renderImage() will be set to alpha, beside those with an alpha value of 0 (invalid pixels).
- alpha < 0 The alpha values returned by renderImage() are not changed.

The default alpha value is -1.

See also:
  alpha()

void QwtPlotRasterItem::setCachePolicy | ( | QwtPlotRasterItem::CachePolicy | policy | ) |

Change the cache policy

The default policy is NoCache

Parameters:

  policy | Cache policy

See also:
  CachePolicy, cachePolicy()

void QwtPlotRasterItem::setPaintAttribute | ( | PaintAttribute | attribute,
|  | bool | on = `true`
| ) |  |

Specify an attribute how to draw the raster item

Parameters:

  attribute | Paint attribute
  on | On/Off /sa PaintAttribute, testPaintAttribute()

bool QwtPlotRasterItem::testPaintAttribute | ( | PaintAttribute | attribute | ) | const

Return the current paint attributes.

See also:
  PaintAttribute, setPaintAttribute()