Qwt User's Guide svn
Public Types | Public Member Functions | Protected Member Functions
QwtPlotRasterItem Class Reference

#include <qwt_plot_rasteritem.h>

Inherits QwtPlotItem.

Inherited by QwtPlotSpectrogram.

List of all members.

Public Types

enum  CachePolicy {
  NoCache,
  PaintCache
}
enum  ItemAttribute {
  Legend = 0x01,
  AutoScale = 0x02
}
typedef QFlags< ItemAttributeItemAttributes
enum  PaintAttribute { PaintInDeviceResolution = 1 }
typedef QFlags< PaintAttributePaintAttributes
enum  RenderHint { RenderAntialiased = 1 }
typedef QFlags< RenderHintRenderHints
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

int alpha () const
void attach (QwtPlot *plot)
virtual QRectF boundingRect () const
CachePolicy cachePolicy () const
void detach ()
virtual void draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &rect) const
virtual void drawLegendIdentifier (QPainter *, const QRectF &) const
void hide ()
virtual QwtInterval interval (Qt::Axis) const
void invalidateCache ()
bool isVisible () const
virtual void itemChanged ()
virtual QWidget * legendItem () const
QRectF paintRect (const QwtScaleMap &, const QwtScaleMap &) const
virtual QRectF pixelHint (const QRectF &) const
QwtPlotplot () const
 QwtPlotRasterItem (const QString &title=QString::null)
 QwtPlotRasterItem (const QwtText &title)
virtual int rtti () const
QRectF scaleRect (const QwtScaleMap &, const QwtScaleMap &) const
void setAlpha (int alpha)
void setAxes (int xAxis, int yAxis)
void setCachePolicy (CachePolicy)
void setItemAttribute (ItemAttribute, bool on=true)
void setPaintAttribute (PaintAttribute, 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 testPaintAttribute (PaintAttribute) const
bool testRenderHint (RenderHint) const
const QwtTexttitle () const
virtual void updateLegend (QwtLegend *) const
virtual void updateScaleDiv (const QwtScaleDiv &, const QwtScaleDiv &)
int xAxis () const
int yAxis () const
double z () const
virtual ~QwtPlotRasterItem ()

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 Typedef Documentation

typedef QFlags<ItemAttribute> QwtPlotItem::ItemAttributes [inherited]

Plot Item Attributes.

Paint attributes.

typedef QFlags<RenderHint> QwtPlotItem::RenderHints [inherited]

Render hints.


Member Enumeration Documentation

  • 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 QwtPlotItem::ItemAttribute [inherited]

Plot Item Attributes

See also:
setItemAttribute(), testItemAttribute()
Enumerator:
Legend 

The item is represented on the legend.

AutoScale 

The boundingRect() of the item is included in the autoscaling calculation.

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.

enum QwtPlotItem::RenderHint [inherited]

Render hints.

Enumerator:
RenderAntialiased 

Enable antialiasing.

enum QwtPlotItem::RttiValues [inherited]

Runtime type information.

RttiValues is used to cast plot items, without having to enable runtime type information of the compiler.

Enumerator:
Rtti_PlotItem 

Unspecific value, that can be used, when it doesn't matter.

Rtti_PlotGrid 

For QwtPlotGrid.

Rtti_PlotScale 

For QwtPlotScaleItem.

Rtti_PlotMarker 

For QwtPlotMarker.

Rtti_PlotCurve 

For QwtPlotCurve.

Rtti_PlotSpectroCurve 

For QwtPlotSpectroCurve.

Rtti_PlotIntervalCurve 

For QwtPlotIntervalCurve.

Rtti_PlotHistogram 

For QwtPlotHistogram.

Rtti_PlotSpectrogram 

For QwtPlotSpectrogram.

Rtti_PlotSVG 

For QwtPlotSvgItem.

Rtti_PlotUserItem 

Values >= Rtti_PlotUserItem are reserved for plot items not implemented in the Qwt library.


Constructor & Destructor Documentation

QwtPlotRasterItem::QwtPlotRasterItem ( const QString &  title = QString::null) [explicit]

Constructor.

QwtPlotRasterItem::QwtPlotRasterItem ( const QwtText title) [explicit]

Constructor.

QwtPlotRasterItem::~QwtPlotRasterItem ( ) [virtual]

Destructor.


Member Function Documentation

int QwtPlotRasterItem::alpha ( ) const
Returns:
Alpha value of the raster item
See also:
setAlpha()
void QwtPlotItem::attach ( QwtPlot plot) [inherited]

Attach the item to a plot.

This method will attach a QwtPlotItem to the QwtPlot argument. It will first detach the QwtPlotItem from any plot from a previous call to attach (if necessary). If a NULL argument is passed, it will detach from any QwtPlot it was attached to.

Parameters:
plotPlot widget
See also:
detach()
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 QwtPlotItem::detach ( ) [inherited]

This method detaches a QwtPlotItem from any QwtPlot it has been associated with.

detach() is equivalent to calling attach( NULL )

See also:
attach()
void QwtPlotRasterItem::draw ( QPainter *  painter,
const QwtScaleMap xMap,
const QwtScaleMap yMap,
const QRectF &  canvasRect 
) const [virtual]

Draw the raster data.

Parameters:
painterPainter
xMapX-Scale Map
yMapY-Scale Map
canvasRectContents rect of the plot canvas

Implements QwtPlotItem.

Reimplemented in QwtPlotSpectrogram.

virtual void QwtLegendItemManager::drawLegendIdentifier ( QPainter *  ,
const QRectF &   
) const [inline, virtual, inherited]

QwtLegendItem can display an icon-identifier followed by a text. The icon helps to identify a plot item on the plot canvas and depends on the type of information, that is displayed.

The default implementation paints nothing.

Reimplemented in QwtPlotCurve, QwtPlotIntervalCurve, QwtPlotMarker, and QwtPlotHistogram.

void QwtPlotItem::hide ( ) [inherited]

Hide the item.

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:
orientationOrientation, Qt::Horizontal means a X axis
mapScale map for rendering the plot item
areaArea to be painted on the image
imageSizeImage size
pixelSizeWidth/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:
axisX, Y, or Z axis

Reimplemented in QwtPlotSpectrogram.

void QwtPlotRasterItem::invalidateCache ( )

Invalidate the paint cache

See also:
setCachePolicy()
bool QwtPlotItem::isVisible ( ) const [inherited]
Returns:
true if visible
See also:
setVisible(), show(), hide()
void QwtPlotItem::itemChanged ( ) [virtual, inherited]

Update the legend and call QwtPlot::autoRefresh for the parent plot.

See also:
updateLegend()
QWidget * QwtPlotItem::legendItem ( ) const [virtual, inherited]

Allocate the widget that represents the item on the legend.

The default implementation returns a QwtLegendItem(), but an item could be represented by any type of widget, by overloading legendItem() and updateLegend().

Returns:
QwtLegendItem()
See also:
updateLegend() QwtLegend()

Implements QwtLegendItemManager.

QRectF QwtPlotItem::paintRect ( const QwtScaleMap xMap,
const QwtScaleMap yMap 
) const [inherited]

Calculate the bounding paint rect of 2 maps.

Parameters:
xMapX map
yMapX map
Returns:
Bounding paint rect of the scale maps, normalized
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:
areaIn 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.

QwtPlot * QwtPlotItem::plot ( ) const [inherited]

Return attached plot.

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:
xMapX-Scale Map
yMapY-Scale Map
areaRequested area for the image in scale coordinates
imageSizeRequested size of the image

Implemented in QwtPlotSpectrogram.

int QwtPlotItem::rtti ( ) const [virtual, inherited]

Return rtti for the specific class represented. QwtPlotItem is simply a virtual interface class, and base classes will implement this method with specific rtti values so a user can differentiate them.

The rtti value is useful for environments, where the runtime type information is disabled and it is not possible to do a dynamic_cast<...>.

Returns:
rtti value
See also:
RttiValues

Reimplemented in QwtPlotCurve, QwtPlotIntervalCurve, QwtPlotSpectrogram, QwtPlotHistogram, QwtPlotMarker, QwtPlotScaleItem, QwtPlotSvgItem, QwtPlotSpectroCurve, and QwtPlotGrid.

QRectF QwtPlotItem::scaleRect ( const QwtScaleMap xMap,
const QwtScaleMap yMap 
) const [inherited]

Calculate the bounding scale rect of 2 maps.

Parameters:
xMapX map
yMapX map
Returns:
Bounding scale rect of the scale maps, normalized
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:
alphaAlpha 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 QwtPlotItem::setAxes ( int  xAxis,
int  yAxis 
) [inherited]

Set X and Y axis

The item will painted according to the coordinates its Axes.

Parameters:
xAxisX Axis
yAxisY Axis
See also:
setXAxis(), setYAxis(), xAxis(), yAxis()
void QwtPlotRasterItem::setCachePolicy ( QwtPlotRasterItem::CachePolicy  policy)

Change the cache policy

The default policy is NoCache

Parameters:
policyCache policy
See also:
CachePolicy, cachePolicy()
void QwtPlotItem::setItemAttribute ( ItemAttribute  attribute,
bool  on = true 
) [inherited]

Toggle an item attribute

Parameters:
attributeAttribute type
ontrue/false
See also:
testItemAttribute(), ItemAttribute
void QwtPlotRasterItem::setPaintAttribute ( PaintAttribute  attribute,
bool  on = true 
)

Specify an attribute how to draw the raster item

Parameters:
attributePaint attribute
onOn/Off /sa PaintAttribute, testPaintAttribute()
void QwtPlotItem::setRenderHint ( RenderHint  hint,
bool  on = true 
) [inherited]

Toggle an render hint

Parameters:
hintRender hint
ontrue/false
See also:
testRenderHint(), RenderHint
void QwtPlotItem::setTitle ( const QString &  title) [inherited]

Set a new title

Parameters:
titleTitle
See also:
title()
void QwtPlotItem::setTitle ( const QwtText title) [inherited]

Set a new title

Parameters:
titleTitle
See also:
title()
void QwtPlotItem::setVisible ( bool  on) [virtual, inherited]

Show/Hide the item

Parameters:
onShow if true, otherwise hide
See also:
isVisible(), show(), hide()
void QwtPlotItem::setXAxis ( int  axis) [inherited]

Set the X axis

The item will painted according to the coordinates its Axes.

Parameters:
axisX Axis
See also:
setAxes(), setYAxis(), xAxis()
void QwtPlotItem::setYAxis ( int  axis) [inherited]

Set the Y axis

The item will painted according to the coordinates its Axes.

Parameters:
axisY Axis
See also:
setAxes(), setXAxis(), yAxis()
void QwtPlotItem::setZ ( double  z) [inherited]

Set the z value.

Plot items are painted in increasing z-order.

Parameters:
zZ-value
See also:
z(), QwtPlotDict::itemList()
void QwtPlotItem::show ( ) [inherited]

Show the item.

bool QwtPlotItem::testItemAttribute ( ItemAttribute  attribute) const [inherited]

Test an item attribute

Parameters:
attributeAttribute type
Returns:
true/false
See also:
setItemAttribute(), ItemAttribute
bool QwtPlotRasterItem::testPaintAttribute ( PaintAttribute  attribute) const

Return the current paint attributes.

See also:
PaintAttribute, setPaintAttribute()
bool QwtPlotItem::testRenderHint ( RenderHint  hint) const [inherited]

Test a render hint

Parameters:
hintRender hint
Returns:
true/false
See also:
setRenderHint(), RenderHint
const QwtText & QwtPlotItem::title ( ) const [inherited]
Returns:
Title of the item
See also:
setTitle()
void QwtPlotItem::updateLegend ( QwtLegend legend) const [virtual, inherited]

Update the widget that represents the item on the legend.

updateLegend() is called from itemChanged() to adopt the widget representing the item on the legend to its new configuration.

The default implementation updates a QwtLegendItem(), but an item could be represented by any type of widget, by overloading legendItem() and updateLegend().

Parameters:
legendLegend
See also:
legendItem(), itemChanged(), QwtLegend()

Implements QwtLegendItemManager.

Reimplemented in QwtPlotCurve, and QwtPlotMarker.

void QwtPlotItem::updateScaleDiv ( const QwtScaleDiv xScaleDiv,
const QwtScaleDiv yScaleDiv 
) [virtual, inherited]

Update the item to changes of the axes scale division.

Update the item, when the axes of plot have changed. The default implementation does nothing, but items that depend on the scale division (like QwtPlotGrid()) have to reimplement updateScaleDiv()

Parameters:
xScaleDivScale division of the x-axis
yScaleDivScale division of the y-axis
See also:
QwtPlot::updateAxes()

Reimplemented in QwtPlotScaleItem, QwtPlotSeriesItem< T >, QwtPlotSeriesItem< QwtIntervalSample >, QwtPlotSeriesItem< QPointF >, QwtPlotSeriesItem< QwtPoint3D >, and QwtPlotGrid.

int QwtPlotItem::xAxis ( ) const [inherited]

Return xAxis.

int QwtPlotItem::yAxis ( ) const [inherited]

Return yAxis.

double QwtPlotItem::z ( ) const [inherited]

Plot items are painted in increasing z-order.

Returns:
setZ(), QwtPlotDict::itemList()
qmi style