QWT 7.0.1
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
QwtPlotSpectrogram Class Reference

A plot item, which displays a spectrogram. More...

#include <qwt_plot_spectrogram.h>

Inheritance diagram for QwtPlotSpectrogram:
QwtPlotRasterItem QwtPlotItem

Classes

class  PrivateData
 

Public Types

enum  DisplayMode { ImageMode = 0x01 , ContourMode = 0x02 }
 The display mode controls how the raster data will be represented. More...
 
- Public Types inherited from QwtPlotRasterItem
enum  CachePolicy { NoCache , PaintCache }
 Cache policy The default policy is NoCache. More...
 
enum  PaintAttribute { PaintInDeviceResolution = 1 }
 Attributes to modify the drawing algorithm. More...
 
- Public Types inherited from QwtPlotItem
enum  RttiValues {
  Rtti_PlotItem = 0 , Rtti_PlotGrid , Rtti_PlotScale , Rtti_PlotLegend ,
  Rtti_PlotMarker , Rtti_PlotCurve , Rtti_PlotSpectroCurve , Rtti_PlotIntervalCurve ,
  Rtti_PlotHistogram , Rtti_PlotSpectrogram , Rtti_PlotGraphic , Rtti_PlotTradingCurve ,
  Rtti_PlotBarChart , Rtti_PlotMultiBarChart , Rtti_PlotShape , Rtti_PlotTextLabel ,
  Rtti_PlotZone , Rtti_PlotVectorField , Rtti_PlotUserItem = 1000
}
 Runtime type information. More...
 
enum  ItemAttribute { Legend = 0x01 , AutoScale = 0x02 , Margins = 0x04 }
 Plot Item Attributes. More...
 
enum  ItemInterest { ScaleInterest = 0x01 , LegendInterest = 0x02 }
 Plot Item Interests/绘图项关注的事件类型 More...
 
enum  RenderHint { RenderAntialiased = 0x1 }
 Render hints. More...
 

Public Member Functions

 QwtPlotSpectrogram (const QString &title=QString())
 Sets the following item attributes:
 
virtual ~QwtPlotSpectrogram ()
 Destructor.
 
void setDisplayMode (DisplayMode, bool on=true)
 The display mode controls how the raster data will be represented.
 
bool testDisplayMode (DisplayMode) const
 The display mode controls how the raster data will be represented.
 
void setData (QwtRasterData *data)
 Set the data to be displayed.
 
const QwtRasterDatadata () const
 
QwtRasterDatadata ()
 
void setColorMap (QwtColorMap *)
 Change the color map.
 
const QwtColorMapcolorMap () const
 
void setColorTableSize (int numColors)
 Limit the number of colors being used by the color map.
 
int colorTableSize () const
 
virtual QwtInterval interval (Qt::Axis) const QWT_OVERRIDE
 
virtual QRectF pixelHint (const QRectF &) const QWT_OVERRIDE
 Pixel hint.
 
void setDefaultContourPen (const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
 Build and assign the default pen for the contour lines.
 
void setDefaultContourPen (const QPen &)
 Set the default pen for the contour lines.
 
QPen defaultContourPen () const
 
virtual QPen contourPen (double level) const
 Calculate the pen for a contour line.
 
void setConrecFlag (QwtRasterData::ConrecFlag, bool on)
 Modify an attribute of the CONREC algorithm, used to calculate the contour lines.
 
bool testConrecFlag (QwtRasterData::ConrecFlag) const
 Test an attribute of the CONREC algorithm, used to calculate the contour lines.
 
void setContourLevels (const QList< double > &)
 Set the levels of the contour lines.
 
QList< double > contourLevels () const
 
virtual int rtti () const QWT_OVERRIDE
 
virtual void draw (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const QWT_OVERRIDE
 Draw the spectrogram.
 
- Public Member Functions inherited from QwtPlotRasterItem
 QwtPlotRasterItem (const QString &title=QString())
 Constructor.
 
 QwtPlotRasterItem (const QwtText &title)
 Constructor.
 
virtual ~QwtPlotRasterItem ()
 Destructor.
 
void setPaintAttribute (PaintAttribute, bool on=true)
 Specify an attribute how to draw the raster item.
 
bool testPaintAttribute (PaintAttribute) const
 
void setAlpha (int alpha)
 Set an alpha value for the raster data.
 
int alpha () const
 
void setCachePolicy (CachePolicy)
 Change the cache policy.
 
CachePolicy cachePolicy () const
 
void invalidateCache ()
 Invalidate the paint cache.
 
virtual QRectF boundingRect () const QWT_OVERRIDE
 
- Public Member Functions inherited from QwtPlotItem
 QwtPlotItem ()
 Constructor.
 
 QwtPlotItem (const QString &title)
 Constructor.
 
 QwtPlotItem (const QwtText &title)
 Constructor.
 
virtual ~QwtPlotItem ()
 Destroy the QwtPlotItem.
 
void attach (QwtPlot *plot)
 Attach the item to a plot.
 
void detach ()
 This method detaches a QwtPlotItem from any QwtPlot it has been associated with.
 
QwtPlotplot () const
 Return attached plot.
 
void setTitle (const QString &title)
 Set a new title.
 
void setTitle (const QwtText &title)
 Set a new title.
 
const QwtTexttitle () const
 
void setItemAttribute (ItemAttribute, bool on=true)
 Toggle an item attribute.
 
bool testItemAttribute (ItemAttribute) const
 Test an item attribute.
 
void setItemInterest (ItemInterest, bool on=true)
 Toggle an item interest.
 
bool testItemInterest (ItemInterest) const
 Test an item interest.
 
void setRenderHint (RenderHint, bool on=true)
 Toggle an render hint.
 
bool testRenderHint (RenderHint) const
 Test a render hint.
 
void setRenderThreadCount (uint numThreads)
 On multi core systems rendering of certain plot item ( f.e QwtPlotRasterItem ) can be done in parallel in several threads.
 
uint renderThreadCount () const
 
void setLegendIconSize (const QSize &)
 Set the size of the legend icon.
 
QSize legendIconSize () const
 
double z () const
 Plot items are painted in increasing z-order.
 
void setZ (double z)
 Set the z value.
 
void show ()
 Show the item.
 
void hide ()
 Hide the item.
 
virtual void setVisible (bool)
 Show/Hide the item.
 
bool isVisible () const
 
void setAxes (QwtAxisId xAxis, QwtAxisId yAxis)
 Set X and Y axis.
 
void setXAxis (QwtAxisId)
 Set the X axis.
 
QwtAxisId xAxis () const
 Return xAxis.
 
void setYAxis (QwtAxisId)
 Set the Y axis.
 
QwtAxisId yAxis () const
 Return yAxis.
 
virtual void itemChanged ()
 Update the legend and call QwtPlot::autoRefresh() for the parent plot.
 
virtual void legendChanged ()
 Update the legend of the parent plot.
 
virtual void getCanvasMarginHint (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, double &left, double &top, double &right, double &bottom) const
 Calculate a hint for the canvas margin.
 
virtual void updateScaleDiv (const QwtScaleDiv &, const QwtScaleDiv &)
 Update the item to changes of the axes scale division.
 
virtual void updateLegend (const QwtPlotItem *, const QList< QwtLegendData > &)
 Update the item to changes of the legend info.
 
QRectF scaleRect (const QwtScaleMap &, const QwtScaleMap &) const
 Calculate the bounding scale rectangle of 2 maps.
 
QRectF paintRect (const QwtScaleMap &, const QwtScaleMap &) const
 Calculate the bounding paint rectangle of 2 maps.
 
virtual QList< QwtLegendDatalegendData () const
 Return all information, that is needed to represent the item on the legend.
 
virtual QwtGraphic legendIcon (int index, const QSizeF &) const
 

Protected Member Functions

virtual QImage renderImage (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &area, const QSize &imageSize) const QWT_OVERRIDE
 Render an image from data and color map.
 
virtual QSize contourRasterSize (const QRectF &, const QRect &) const
 Return the raster to be used by the CONREC contour algorithm.
 
virtual QwtRasterData::ContourLines renderContourLines (const QRectF &rect, const QSize &raster) const
 Calculate contour lines.
 
virtual void drawContourLines (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QwtRasterData::ContourLines &) const
 Paint the contour lines.
 
void renderTile (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &tile, QImage *) const
 Render a tile of an image.
 
- Protected Member Functions inherited from QwtPlotRasterItem
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.
 
- Protected Member Functions inherited from QwtPlotItem
QwtGraphic defaultIcon (const QBrush &, const QSizeF &) const
 Return a default icon from a brush.
 

Detailed Description

A plot item, which displays a spectrogram.

A spectrogram displays 3-dimensional data, where the 3rd dimension ( the intensity ) is displayed using colors. The colors are calculated from the values using a color map.

On multi-core systems the performance of the image composition can often be improved by dividing the area into tiles - each of them rendered in a different thread ( see QwtPlotItem::setRenderThreadCount() ).

In ContourMode contour lines are painted for the contour levels.

See also
QwtRasterData, QwtColorMap, QwtPlotItem::setRenderThreadCount()

Member Enumeration Documentation

◆ DisplayMode

The display mode controls how the raster data will be represented.

See also
setDisplayMode(), testDisplayMode()
Enumerator
ImageMode 

The values are mapped to colors using a color map.

ContourMode 

The data is displayed using contour lines.

Constructor & Destructor Documentation

◆ QwtPlotSpectrogram()

QwtPlotSpectrogram::QwtPlotSpectrogram ( const QString &  title = QString())
explicit

Sets the following item attributes:

The z value is initialized by 8.0.

Parameters
titleTitle
See also
QwtPlotItem::setItemAttribute(), QwtPlotItem::setZ()

Member Function Documentation

◆ colorMap()

const QwtColorMap * QwtPlotSpectrogram::colorMap ( ) const
Returns
Color Map used for mapping the intensity values to colors
See also
setColorMap()

◆ colorTableSize()

int QwtPlotSpectrogram::colorTableSize ( ) const
Returns
Size of the color table, 0 means not using a color table
See also
QwtColorMap::colorTable(), setColorTableSize()

◆ contourLevels()

QList< double > QwtPlotSpectrogram::contourLevels ( ) const
Returns
Levels of the contour lines.

The levels are sorted in increasing order.

See also
contourLevels(), renderContourLines(), QwtRasterData::contourLines()

◆ contourPen()

QPen QwtPlotSpectrogram::contourPen ( double  level) const
virtual

Calculate the pen for a contour line.

The color of the pen is the color for level calculated by the color map

Parameters
levelContour level
Returns
Pen for the contour line
Note
contourPen is only used if defaultContourPen().style() == Qt::NoPen
See also
setDefaultContourPen(), setColorMap(), setContourLevels()

◆ contourRasterSize()

QSize QwtPlotSpectrogram::contourRasterSize ( const QRectF &  area,
const QRect &  rect 
) const
protectedvirtual

Return the raster to be used by the CONREC contour algorithm.

A larger size will improve the precision of the CONREC algorithm, but will slow down the time that is needed to calculate the lines.

The default implementation returns rect.size() / 2 bounded to the resolution depending on pixelSize().

Parameters
areaRectangle, where to calculate the contour lines
rectRectangle in pixel coordinates, where to paint the contour lines
Returns
Raster to be used by the CONREC contour algorithm.
Note
The size will be bounded to rect.size().
See also
drawContourLines(), QwtRasterData::contourLines()

◆ data() [1/2]

QwtRasterData * QwtPlotSpectrogram::data ( )
Returns
Spectrogram data
See also
setData()

◆ data() [2/2]

const QwtRasterData * QwtPlotSpectrogram::data ( ) const
Returns
Spectrogram data
See also
setData()

◆ defaultContourPen()

QPen QwtPlotSpectrogram::defaultContourPen ( ) const
Returns
Default contour pen
See also
setDefaultContourPen()

◆ draw()

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

Draw the spectrogram.

Parameters
painterPainter
xMapMaps x-values into pixel coordinates.
yMapMaps y-values into pixel coordinates.
canvasRectContents rectangle of the canvas in painter coordinates
See also
setDisplayMode(), renderImage(), QwtPlotRasterItem::draw(), drawContourLines()

Reimplemented from QwtPlotRasterItem.

◆ drawContourLines()

void QwtPlotSpectrogram::drawContourLines ( QPainter *  painter,
const QwtScaleMap xMap,
const QwtScaleMap yMap,
const QwtRasterData::ContourLines contourLines 
) const
protectedvirtual

Paint the contour lines.

Parameters
painterPainter
xMapMaps x-values into pixel coordinates.
yMapMaps y-values into pixel coordinates.
contourLinesContour lines
See also
renderContourLines(), defaultContourPen(), contourPen()

◆ interval()

QwtInterval QwtPlotSpectrogram::interval ( Qt::Axis  axis) const
virtual
Returns
Bounding interval for an axis

The default implementation returns the interval of the associated raster data object.

Parameters
axisX, Y, or Z axis
See also
QwtRasterData::interval()

Reimplemented from QwtPlotRasterItem.

◆ pixelHint()

QRectF QwtPlotSpectrogram::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.

The default implementation returns data()->pixelHint( rect );

Parameters
areaIn most implementations the resolution of the data doesn't depend on the requested area.
Returns
Bounding rectangle of a pixel
See also
QwtPlotRasterItem::pixelHint(), QwtRasterData::pixelHint(), render(), renderImage()

Reimplemented from QwtPlotRasterItem.

◆ renderContourLines()

QwtRasterData::ContourLines QwtPlotSpectrogram::renderContourLines ( const QRectF &  rect,
const QSize &  raster 
) const
protectedvirtual

Calculate contour lines.

Parameters
rectRectangle, where to calculate the contour lines
rasterRaster, used by the CONREC algorithm
Returns
Calculated contour lines
See also
contourLevels(), setConrecFlag(), QwtRasterData::contourLines()

◆ renderImage()

QImage QwtPlotSpectrogram::renderImage ( const QwtScaleMap xMap,
const QwtScaleMap yMap,
const QRectF &  area,
const QSize &  imageSize 
) const
protectedvirtual

Render an image from data and color map.

For each pixel of area the value is mapped into a color.

Parameters
xMapX-Scale Map
yMapY-Scale Map
areaRequested area for the image in scale coordinates
imageSizeSize of the requested image
Returns
A QImage::Format_Indexed8 or QImage::Format_ARGB32 depending on the color map.
See also
QwtRasterData::value(), QwtColorMap::rgb(), QwtColorMap::colorIndex()

Implements QwtPlotRasterItem.

◆ renderTile()

void QwtPlotSpectrogram::renderTile ( const QwtScaleMap xMap,
const QwtScaleMap yMap,
const QRect &  tile,
QImage *  image 
) const
protected

Render a tile of an image.

Rendering in tiles can be used to composite an image in parallel threads.

Parameters
xMapX-Scale Map
yMapY-Scale Map
tileGeometry of the tile in image coordinates
imageImage to be rendered

◆ rtti()

int QwtPlotSpectrogram::rtti ( ) const
virtual
Returns
QwtPlotItem::Rtti_PlotSpectrogram

Reimplemented from QwtPlotItem.

◆ setColorMap()

void QwtPlotSpectrogram::setColorMap ( QwtColorMap colorMap)

Change the color map.

Often it is useful to display the mapping between intensities and colors as an additional plot axis, showing a color bar.

Parameters
colorMapColor Map
See also
colorMap(), QwtScaleWidget::setColorBarEnabled(), QwtScaleWidget::setColorMap()

◆ setColorTableSize()

void QwtPlotSpectrogram::setColorTableSize ( int  numColors)

Limit the number of colors being used by the color map.

When using a color table the mapping from the value into a color is usually faster as it can be done by simple lookups into a precalculated color table.

Setting a table size > 0 enables using a color table, while setting the size to 0 disables it.

The default size = 0, and no color table is used.

Parameters
numColorsNumber of colors. 0 means not using a color table
Note
The colorTableSize has no effect when using a color table of QwtColorMap::Indexed, where the size is always 256.
See also
QwtColorMap::colorTable(), colorTableSize()

◆ setConrecFlag()

void QwtPlotSpectrogram::setConrecFlag ( QwtRasterData::ConrecFlag  flag,
bool  on 
)

Modify an attribute of the CONREC algorithm, used to calculate the contour lines.

Parameters
flagCONREC flag
onOn/Off
See also
testConrecFlag(), renderContourLines(), QwtRasterData::contourLines()

◆ setContourLevels()

void QwtPlotSpectrogram::setContourLevels ( const QList< double > &  levels)

Set the levels of the contour lines.

Parameters
levelsValues of the contour levels
See also
contourLevels(), renderContourLines(), QwtRasterData::contourLines()
Note
contourLevels returns the same levels but sorted.

◆ setData()

void QwtPlotSpectrogram::setData ( QwtRasterData data)

Set the data to be displayed.

The ownership of the data is managed by QwtPlotSpectrogram

Parameters
dataSpectrogram Data
See also
data()

◆ setDefaultContourPen() [1/2]

void QwtPlotSpectrogram::setDefaultContourPen ( const QColor &  color,
qreal  width = 0.0,
Qt::PenStyle  style = Qt::SolidLine 
)

Build and assign the default pen for the contour lines.

In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it non cosmetic ( see QPen::isCosmetic() ). This method has been introduced to hide this incompatibility.

Parameters
colorPen color
widthPen width
stylePen style
See also
pen(), brush()

◆ setDefaultContourPen() [2/2]

void QwtPlotSpectrogram::setDefaultContourPen ( const QPen &  pen)

Set the default pen for the contour lines.

If the spectrogram has a valid default contour pen a contour line is painted using the default contour pen. Otherwise (pen.style() == Qt::NoPen) the pen is calculated for each contour level using contourPen().

See also
defaultContourPen(), contourPen()

◆ setDisplayMode()

void QwtPlotSpectrogram::setDisplayMode ( DisplayMode  mode,
bool  on = true 
)

The display mode controls how the raster data will be represented.

Parameters
modeDisplay mode
onOn/Off

The default setting enables ImageMode.

See also
DisplayMode, displayMode()

◆ testConrecFlag()

bool QwtPlotSpectrogram::testConrecFlag ( QwtRasterData::ConrecFlag  flag) const

Test an attribute of the CONREC algorithm, used to calculate the contour lines.

Parameters
flagCONREC flag
Returns
true, is enabled

The default setting enables QwtRasterData::IgnoreAllVerticesOnLevel

See also
setConrecClag(), renderContourLines(), QwtRasterData::contourLines()

◆ testDisplayMode()

bool QwtPlotSpectrogram::testDisplayMode ( DisplayMode  mode) const

The display mode controls how the raster data will be represented.

Parameters
modeDisplay mode
Returns
true if mode is enabled

The documentation for this class was generated from the following files: