QwtPlotRasterItem - A class, which displays raster data.
Contents
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.
Seealso:QwtPlotSpectrogramMember Enumeration Documentation
enumQwtPlotRasterItem::CachePolicy
Cache policy The default policy is NoCache.
EnumeratorNoCacherenderImage() is called each time the item has to be repainted
PaintCacherenderImage() 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.
enumQwtPlotRasterItem::PaintAttribute
Attributes to modify the drawing algorithm.
Seealso:setPaintAttribute(), testPaintAttribute()EnumeratorPaintInDeviceResolution
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
intQwtPlotRasterItem::alpha()constReturns:
Alpha value of the raster item
Seealso:setAlpha()QRectFQwtPlotRasterItem::boundingRect()const[virtual]Returns:
Bounding rectangle of the data
Seealso:QwtPlotRasterItem::interval()
Reimplemented from QwtPlotItem.
QwtPlotRasterItem::CachePolicyQwtPlotRasterItem::cachePolicy()constReturns:
Cache policy
Seealso:CachePolicy, setCachePolicy()voidQwtPlotRasterItem::draw(QPainter*painter,constQwtScaleMap&xMap,constQwtScaleMap&yMap,constQRectF&canvasRect)const[virtual]
Draw the raster data.
Parameters:painter Painter
xMap X-Scale Map
yMap Y-Scale Map
canvasRect Contents rectangle of the plot canvas
Implements QwtPlotItem.
Reimplemented in QwtPlotSpectrogram.
QwtScaleMapQwtPlotRasterItem::imageMap(Qt::Orientationorientation,constQwtScaleMap&map,constQRectF&area,constQSize&imageSize,doublepixelSize)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
Returns:
Calculated scale map
QwtIntervalQwtPlotRasterItem::interval(Qt::Axisaxis)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.
voidQwtPlotRasterItem::invalidateCache()
Invalidate the paint cache
Seealso:setCachePolicy()QRectFQwtPlotRasterItem::pixelHint(constQRectF&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.
Parameters:area In most implementations the resolution of the data doesn't depend on the requested area.
Returns:
Bounding rectangle of a pixel
Seealso:
render(), renderImage()
Reimplemented in QwtPlotSpectrogram.
virtualQImageQwtPlotRasterItem::renderImage(constQwtScaleMap&xMap,constQwtScaleMap&yMap,constQRectF&area,constQSize&imageSize)const[protected],[purevirtual]
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
Returns:
Rendered image
Implemented in QwtPlotSpectrogram.
voidQwtPlotRasterItem::setAlpha(intalpha)
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.
Seealso:alpha()voidQwtPlotRasterItem::setCachePolicy(QwtPlotRasterItem::CachePolicypolicy)
Change the cache policy
The default policy is NoCache
Parameters:policy Cache policy
Seealso:CachePolicy, cachePolicy()voidQwtPlotRasterItem::setPaintAttribute(PaintAttributeattribute,boolon=true)
Specify an attribute how to draw the raster item
Parameters:attribute Paint attribute
on On/Off /sa PaintAttribute, testPaintAttribute()boolQwtPlotRasterItem::testPaintAttribute(PaintAttributeattribute)constReturns:
True, when attribute is enabled
Seealso:PaintAttribute, setPaintAttribute()Name
QwtPlotRasterItem - A class, which displays raster data.
Synopsis
#include <qwt_plot_rasteritem.h>
Inherits QwtPlotItem.
Inherited by QwtPlotSpectrogram.
PublicTypes
enum CachePolicy { NoCache, PaintCache }
Cache policy The default policy is NoCache.
enum PaintAttribute { PaintInDeviceResolution = 1 }
typedef QFlags< PaintAttribute > PaintAttributes
Paint attributes.
PublicMemberFunctionsQwtPlotRasterItem (const QString &title=QString())
Constructor.
QwtPlotRasterItem (const QwtText &title)
Constructor.
virtual ~QwtPlotRasterItem ()
Destructor.
void setPaintAttribute (PaintAttribute, bool on=true)
bool testPaintAttribute (PaintAttribute) const
void setAlpha (int alpha)
Set an alpha value for the raster data.
int alpha () const
void setCachePolicy (CachePolicy)
CachePolicycachePolicy () const
void invalidateCache ()
virtual void draw (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF
&canvasRect) const
Draw the raster data.
virtual QRectF pixelHint (const QRectF &) const
Pixel hint.
virtual QwtIntervalinterval (Qt::Axis) const
virtual QRectF boundingRect () const
ProtectedMemberFunctions
virtual QImage renderImage (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &area, const
QSize &imageSize) const =0
Render an image.
virtual QwtScaleMapimageMap (Qt::Orientation, const QwtScaleMap &map, const QRectF &area, const QSize
&imageSize, double pixelSize) const
Calculate a scale map for painting to an image.
