Qwt User's Guide
svn
|
#include <qwt_plot_rasteritem.h>
Inherits QwtPlotItem.
Inherited by QwtPlotSpectrogram.
Public Types | |
enum | CachePolicy { NoCache, PaintCache } |
enum | ItemAttribute { Legend = 0x01, AutoScale = 0x02 } |
typedef QFlags< ItemAttribute > | ItemAttributes |
enum | PaintAttribute { PaintInDeviceResolution = 1 } |
typedef QFlags< PaintAttribute > | PaintAttributes |
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 | |
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 |
QwtPlot * | plot () 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 QwtText & | title () 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 |
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.
typedef QFlags<ItemAttribute> QwtPlotItem::ItemAttributes [inherited] |
Plot Item Attributes.
typedef QFlags<PaintAttribute> QwtPlotRasterItem::PaintAttributes |
Paint attributes.
typedef QFlags<RenderHint> QwtPlotItem::RenderHints [inherited] |
Render hints.
The default policy is NoCache
enum QwtPlotItem::ItemAttribute [inherited] |
Plot Item Attributes
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.
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] |
enum QwtPlotItem::RttiValues [inherited] |
Runtime type information.
RttiValues is used to cast plot items, without having to enable runtime type information of the compiler.
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. |
QwtPlotRasterItem::QwtPlotRasterItem | ( | const QString & | title = QString::null | ) | [explicit] |
Constructor.
QwtPlotRasterItem::QwtPlotRasterItem | ( | const QwtText & | title | ) | [explicit] |
Constructor.
QwtPlotRasterItem::~QwtPlotRasterItem | ( | ) | [virtual] |
Destructor.
int QwtPlotRasterItem::alpha | ( | ) | const |
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.
plot | Plot widget |
QRectF QwtPlotRasterItem::boundingRect | ( | ) | const [virtual] |
Reimplemented from QwtPlotItem.
QwtPlotRasterItem::CachePolicy QwtPlotRasterItem::cachePolicy | ( | ) | const |
void QwtPlotItem::detach | ( | ) | [inherited] |
This method detaches a QwtPlotItem from any QwtPlot it has been associated with.
detach() is equivalent to calling attach( NULL )
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 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.
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] |
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.
void QwtPlotRasterItem::invalidateCache | ( | ) |
Invalidate the paint cache
bool QwtPlotItem::isVisible | ( | ) | const [inherited] |
void QwtPlotItem::itemChanged | ( | ) | [virtual, inherited] |
Update the legend and call QwtPlot::autoRefresh for the parent plot.
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().
Implements QwtLegendItemManager.
QRectF QwtPlotItem::paintRect | ( | const QwtScaleMap & | xMap, |
const QwtScaleMap & | yMap | ||
) | const [inherited] |
Calculate the bounding paint rect of 2 maps.
xMap | X map |
yMap | X map |
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.
area | In most implementations the resolution of the data doesn't depend on the requested area. |
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.
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.
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<...>.
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.
xMap | X map |
yMap | X map |
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.
void QwtPlotItem::setAxes | ( | int | xAxis, |
int | yAxis | ||
) | [inherited] |
Set X and Y axis
The item will painted according to the coordinates its Axes.
xAxis | X Axis |
yAxis | Y Axis |
void QwtPlotRasterItem::setCachePolicy | ( | QwtPlotRasterItem::CachePolicy | policy | ) |
Change the cache policy
The default policy is NoCache
policy | Cache policy |
void QwtPlotItem::setItemAttribute | ( | ItemAttribute | attribute, |
bool | on = true |
||
) | [inherited] |
Toggle an item attribute
attribute | Attribute type |
on | true/false |
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() |
void QwtPlotItem::setRenderHint | ( | RenderHint | hint, |
bool | on = true |
||
) | [inherited] |
Toggle an render hint
hint | Render hint |
on | true/false |
void QwtPlotItem::setTitle | ( | const QString & | title | ) | [inherited] |
void QwtPlotItem::setTitle | ( | const QwtText & | title | ) | [inherited] |
void QwtPlotItem::setVisible | ( | bool | on | ) | [virtual, inherited] |
void QwtPlotItem::setXAxis | ( | int | axis | ) | [inherited] |
Set the X axis
The item will painted according to the coordinates its Axes.
axis | X Axis |
void QwtPlotItem::setYAxis | ( | int | axis | ) | [inherited] |
Set the Y axis
The item will painted according to the coordinates its Axes.
axis | Y Axis |
void QwtPlotItem::setZ | ( | double | z | ) | [inherited] |
Set the z value.
Plot items are painted in increasing z-order.
z | Z-value |
void QwtPlotItem::show | ( | ) | [inherited] |
Show the item.
bool QwtPlotItem::testItemAttribute | ( | ItemAttribute | attribute | ) | const [inherited] |
Test an item attribute
attribute | Attribute type |
bool QwtPlotRasterItem::testPaintAttribute | ( | PaintAttribute | attribute | ) | const |
Return the current paint attributes.
bool QwtPlotItem::testRenderHint | ( | RenderHint | hint | ) | const [inherited] |
Test a render hint
hint | Render hint |
const QwtText & QwtPlotItem::title | ( | ) | const [inherited] |
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().
legend | Legend |
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()
xScaleDiv | Scale division of the x-axis |
yScaleDiv | Scale division of the y-axis |
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.