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

QwtPlotHistogram represents a series of samples, where an interval is associated with a value ( $y = f([x1,x2])$ ). More...

#include <qwt_plot_histogram.h>

Inheritance diagram for QwtPlotHistogram:
QwtPlotSeriesItem QwtSeriesStore< QwtIntervalSample > QwtPlotItem QwtAbstractSeriesStore QwtAbstractSeriesStore

Classes

class  PrivateData
 

Public Types

enum  HistogramStyle { Outline , Columns , Lines , UserStyle = 100 }
 Histogram styles. 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

 QwtPlotHistogram (const QString &title=QString())
 Constructor.
 
 QwtPlotHistogram (const QwtText &title)
 Constructor.
 
virtual ~QwtPlotHistogram ()
 Destructor.
 
virtual int rtti () const QWT_OVERRIDE
 
void setPen (const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
 Build and assign a pen.
 
void setPen (const QPen &)
 Assign a pen, that is used in a style() depending way.
 
const QPen & pen () const
 
void setBrush (const QBrush &)
 Assign a brush, that is used in a style() depending way.
 
const QBrush & brush () const
 
void setSamples (const QVector< QwtIntervalSample > &)
 Initialize data with an array of samples.
 
void setSamples (QwtSeriesData< QwtIntervalSample > *)
 Assign a series of samples.
 
void setBaseline (double)
 Set the value of the baseline.
 
double baseline () const
 
void setStyle (HistogramStyle style)
 Set the histogram's drawing style.
 
HistogramStyle style () const
 
void setSymbol (const QwtColumnSymbol *)
 Assign a symbol.
 
const QwtColumnSymbolsymbol () const
 
virtual void drawSeries (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const QWT_OVERRIDE
 Draw a subset of the histogram samples.
 
virtual QRectF boundingRect () const QWT_OVERRIDE
 
virtual QwtGraphic legendIcon (int index, const QSizeF &) const QWT_OVERRIDE
 A plain rectangle without pen using the brush()
 
- Public Member Functions inherited from QwtPlotSeriesItem
 QwtPlotSeriesItem (const QString &title=QString())
 Constructor.
 
 QwtPlotSeriesItem (const QwtText &title)
 Constructor.
 
virtual ~QwtPlotSeriesItem ()
 Destructor.
 
void setOrientation (Qt::Orientation)
 Set the orientation of the item.
 
Qt::Orientation orientation () const
 
virtual void draw (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const QWT_OVERRIDE
 Draw the complete series.
 
virtual void updateScaleDiv (const QwtScaleDiv &, const QwtScaleDiv &) QWT_OVERRIDE
 Update the item to changes of the axes scale division.
 
- 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 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.
 
- Public Member Functions inherited from QwtAbstractSeriesStore
virtual ~QwtAbstractSeriesStore ()
 Destructor.
 
- Public Member Functions inherited from QwtSeriesStore< QwtIntervalSample >
 QwtSeriesStore ()
 Constructor The store contains no series.
 
 ~QwtSeriesStore ()
 Destructor.
 
void setData (QwtSeriesData< QwtIntervalSample > *series)
 Assign a series of samples.
 
QwtSeriesData< QwtIntervalSample > * data ()
 
const QwtSeriesData< QwtIntervalSample > * data () const
 
QwtIntervalSample sample (size_t index) const
 
virtual size_t dataSize () const QWT_OVERRIDE
 
virtual QRectF dataRect () const QWT_OVERRIDE
 
virtual void setRectOfInterest (const QRectF &rect) QWT_OVERRIDE
 Set a the "rect of interest" for the series.
 
QwtSeriesData< QwtIntervalSample > * swapData (QwtSeriesData< QwtIntervalSample > *series)
 Replace a series without deleting the previous one.
 

Protected Member Functions

virtual QwtColumnRect columnRect (const QwtIntervalSample &, const QwtScaleMap &, const QwtScaleMap &) const
 Calculate the area that is covered by a sample.
 
virtual void drawColumn (QPainter *, const QwtColumnRect &, const QwtIntervalSample &) const
 Draw a column for a sample in Columns style().
 
void drawColumns (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const
 Draw a histogram in Columns style()
 
void drawOutline (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const
 Draw a histogram in Outline style()
 
void drawLines (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const
 Draw a histogram in Lines style()
 
- Protected Member Functions inherited from QwtPlotSeriesItem
virtual void dataChanged () QWT_OVERRIDE
 dataChanged() indicates, that the series has been changed.
 
- Protected Member Functions inherited from QwtPlotItem
QwtGraphic defaultIcon (const QBrush &, const QSizeF &) const
 Return a default icon from a brush.
 

Detailed Description

QwtPlotHistogram represents a series of samples, where an interval is associated with a value ( $y = f([x1,x2])$ ).

The representation depends on the style() and an optional symbol() that is displayed for each interval.

Note
The term "histogram" is used in a different way in the areas of digital image processing and statistics. Wikipedia introduces the terms "image histogram" and "color histogram" to avoid confusions. While "image histograms" can be displayed by a QwtPlotCurve there is no applicable plot item for a "color histogram" yet.
See also
QwtPlotBarChart, QwtPlotMultiBarChart

Member Enumeration Documentation

◆ HistogramStyle

Histogram styles.

The default style is QwtPlotHistogram::Columns.

See also
setStyle(), style(), setSymbol(), symbol(), setBaseline()
Enumerator
Outline 

Draw an outline around the area, that is build by all intervals using the pen() and fill it with the brush().

The outline style requires, that the intervals are in increasing order and not overlapping.

Columns 

Draw a column for each interval.

When a symbol() has been set the symbol is used otherwise the column is displayed as plain rectangle using pen() and brush().

Lines 

Draw a simple line using the pen() for each interval.

UserStyle 

Styles >= UserStyle are reserved for derived classes that overload drawSeries() with additional application specific ways to display a histogram.

Constructor & Destructor Documentation

◆ QwtPlotHistogram() [1/2]

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

Constructor.

Parameters
titleTitle of the histogram.

◆ QwtPlotHistogram() [2/2]

QwtPlotHistogram::QwtPlotHistogram ( const QwtText title)
explicit

Constructor.

Parameters
titleTitle of the histogram.

Member Function Documentation

◆ baseline()

double QwtPlotHistogram::baseline ( ) const
Returns
Value of the baseline
See also
setBaseline()

◆ boundingRect()

QRectF QwtPlotHistogram::boundingRect ( ) const
virtual
Returns
Bounding rectangle of all samples. For an empty series the rectangle is invalid.

Reimplemented from QwtPlotSeriesItem.

◆ brush()

const QBrush & QwtPlotHistogram::brush ( ) const
Returns
Brush used in a style() depending way.
See also
setPen(), brush()

◆ columnRect()

QwtColumnRect QwtPlotHistogram::columnRect ( const QwtIntervalSample sample,
const QwtScaleMap xMap,
const QwtScaleMap yMap 
) const
protectedvirtual

Calculate the area that is covered by a sample.

Parameters
sampleSample
xMapMaps x-values into pixel coordinates.
yMapMaps y-values into pixel coordinates.
Returns
Rectangle, that is covered by a sample

◆ drawColumn()

void QwtPlotHistogram::drawColumn ( QPainter *  painter,
const QwtColumnRect rect,
const QwtIntervalSample sample 
) const
protectedvirtual

Draw a column for a sample in Columns style().

When a symbol() has been set the symbol is used otherwise the column is displayed as plain rectangle using pen() and brush().

Parameters
painterPainter
rectRectangle where to paint the column in paint device coordinates
sampleSample to be displayed
Note
In applications, where different intervals need to be displayed in a different way ( f.e different colors or even using different symbols) it is recommended to overload drawColumn().

◆ drawColumns()

void QwtPlotHistogram::drawColumns ( QPainter *  painter,
const QwtScaleMap xMap,
const QwtScaleMap yMap,
int  from,
int  to 
) const
protected

Draw a histogram in Columns style()

Parameters
painterPainter
xMapMaps x-values into pixel coordinates.
yMapMaps y-values into pixel coordinates.
fromIndex of the first sample to be painted
toIndex of the last sample to be painted. If to < 0 the histogram will be painted to its last point.
See also
setStyle(), style(), setSymbol(), drawColumn()

◆ drawLines()

void QwtPlotHistogram::drawLines ( QPainter *  painter,
const QwtScaleMap xMap,
const QwtScaleMap yMap,
int  from,
int  to 
) const
protected

Draw a histogram in Lines style()

Parameters
painterPainter
xMapMaps x-values into pixel coordinates.
yMapMaps y-values into pixel coordinates.
fromIndex of the first sample to be painted
toIndex of the last sample to be painted. If to < 0 the histogram will be painted to its last point.
See also
setStyle(), style(), setPen()

◆ drawOutline()

void QwtPlotHistogram::drawOutline ( QPainter *  painter,
const QwtScaleMap xMap,
const QwtScaleMap yMap,
int  from,
int  to 
) const
protected

Draw a histogram in Outline style()

Parameters
painterPainter
xMapMaps x-values into pixel coordinates.
yMapMaps y-values into pixel coordinates.
fromIndex of the first sample to be painted
toIndex of the last sample to be painted. If to < 0 the histogram will be painted to its last point.
See also
setStyle(), style()
Warning
The outline style requires, that the intervals are in increasing order and not overlapping.

◆ drawSeries()

void QwtPlotHistogram::drawSeries ( QPainter *  painter,
const QwtScaleMap xMap,
const QwtScaleMap yMap,
const QRectF &  canvasRect,
int  from,
int  to 
) const
virtual

Draw a subset of the histogram samples.

Parameters
painterPainter
xMapMaps x-values into pixel coordinates.
yMapMaps y-values into pixel coordinates.
canvasRectContents rectangle of the canvas
fromIndex of the first sample to be painted
toIndex of the last sample to be painted. If to < 0 the series will be painted to its last sample.
See also
drawOutline(), drawLines(), drawColumns

Implements QwtPlotSeriesItem.

◆ legendIcon()

QwtGraphic QwtPlotHistogram::legendIcon ( int  index,
const QSizeF &  size 
) const
virtual

A plain rectangle without pen using the brush()

Parameters
indexIndex of the legend entry ( ignored as there is only one )
sizeIcon size
Returns
A graphic displaying the icon
See also
QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()

Reimplemented from QwtPlotItem.

◆ pen()

const QPen & QwtPlotHistogram::pen ( ) const
Returns
Pen used in a style() depending way.
See also
setPen(), brush()

◆ rtti()

int QwtPlotHistogram::rtti ( ) const
virtual
Returns
QwtPlotItem::Rtti_PlotHistogram

Reimplemented from QwtPlotItem.

◆ setBaseline()

void QwtPlotHistogram::setBaseline ( double  value)

Set the value of the baseline.

Each column representing an QwtIntervalSample is defined by its interval and the interval between baseline and the value of the sample.

The default value of the baseline is 0.0.

Parameters
valueValue of the baseline
See also
baseline()

◆ setBrush()

void QwtPlotHistogram::setBrush ( const QBrush &  brush)

Assign a brush, that is used in a style() depending way.

Parameters
brushNew brush
See also
pen(), brush()

◆ setPen() [1/2]

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

Build and assign a pen.

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()

◆ setPen() [2/2]

void QwtPlotHistogram::setPen ( const QPen &  pen)

Assign a pen, that is used in a style() depending way.

Parameters
penNew pen
See also
pen(), brush()

◆ setSamples() [1/2]

void QwtPlotHistogram::setSamples ( const QVector< QwtIntervalSample > &  samples)

Initialize data with an array of samples.

Parameters
samplesVector of points

◆ setSamples() [2/2]

void QwtPlotHistogram::setSamples ( QwtSeriesData< QwtIntervalSample > *  data)

Assign a series of samples.

setSamples() is just a wrapper for setData() without any additional value - beside that it is easier to find for the developer.

Parameters
dataData
Warning
The item takes ownership of the data object, deleting it when its not used anymore.

◆ setStyle()

void QwtPlotHistogram::setStyle ( HistogramStyle  style)

Set the histogram's drawing style.

Parameters
styleHistogram style
See also
HistogramStyle, style()

◆ setSymbol()

void QwtPlotHistogram::setSymbol ( const QwtColumnSymbol symbol)

Assign a symbol.

In Column style an optional symbol can be assigned, that is responsible for displaying the rectangle that is defined by the interval and the distance between baseline() and value. When no symbol has been defined the area is displayed as plain rectangle using pen() and brush().

See also
style(), symbol(), drawColumn(), pen(), brush()
Note
In applications, where different intervals need to be displayed in a different way ( f.e different colors or even using different symbols) it is recommended to overload drawColumn().

◆ style()

QwtPlotHistogram::HistogramStyle QwtPlotHistogram::style ( ) const
Returns
Style of the histogram
See also
HistogramStyle, setStyle()

◆ symbol()

const QwtColumnSymbol * QwtPlotHistogram::symbol ( ) const
Returns
Current symbol or NULL, when no symbol has been assigned
See also
setSymbol()

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