QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
| Public 类型 | Public 成员函数 | Protected 成员函数 | 所有成员列表
QwtPlotBarChart类 参考

QwtPlotBarChart displays a series of values as bars 更多...

#include <qwt_plot_barchart.h>

类 QwtPlotBarChart 继承关系图:
QwtPlotAbstractBarChart QwtSeriesStore< QPointF > QwtPlotSeriesItem QwtAbstractSeriesStore QwtPlotItem QwtAbstractSeriesStore

class  PrivateData
 

Public 类型

enum  LegendMode { LegendChartTitle , LegendBarTitles }
 Legend modes 更多...
 
- Public 类型 继承自 QwtPlotAbstractBarChart
enum  LayoutPolicy { AutoAdjustSamples , ScaleSamplesToAxes , ScaleSampleToCanvas , FixedSampleSize }
 Mode how to calculate the bar width 更多...
 
- Public 类型 继承自 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_PlotArrowMarker , Rtti_PlotBoxChart ,
  Rtti_PlotUserItem = 1000
}
 Runtime type information 更多...
 
enum  ItemAttribute { Legend = 0x01 , AutoScale = 0x02 , Margins = 0x04 }
 Plot Item Attributes 更多...
 
enum  ItemInterest { ScaleInterest = 0x01 , LegendInterest = 0x02 }
 Plot Item Interests 更多...
 
enum  RenderHint { RenderAntialiased = 0x1 }
 Render hints 更多...
 

Public 成员函数

 QwtPlotBarChart (const QString &title=QString())
 
 QwtPlotBarChart (const QwtText &title)
 Constructor
 
virtual int rtti () const override
 Get the runtime type information
 
void attach (QwtPlot *plot) override
 Attach the bar chart to a plot
 
void setSamples (const QVector< QPointF > &)
 Initialize data with an array of points
 
void setSamples (const QVector< double > &)
 Initialize data with an array of doubles
 
void setSamples (QwtSeriesData< QPointF > *)
 Assign a series of samples
 
void setSymbol (QwtColumnSymbol *)
 Assign a symbol
 
const QwtColumnSymbolsymbol () const
 Get the current symbol
 
void setPen (const QPen &p)
 Set the bar symbol pen
 
QPen pen () const
 Get the bar symbol pen
 
void setBrush (const QBrush &b)
 Set the bar symbol brush
 
QBrush brush () const
 Get the bar symbol brush
 
void setFrameStyle (QwtColumnSymbol::FrameStyle f)
 Set the bar symbol frame style
 
QwtColumnSymbol::FrameStyle frameStyle () const
 Get the bar symbol frame style
 
void setLegendMode (LegendMode)
 Set the mode that decides what to display on the legend
 
LegendMode legendMode () const
 Get the legend mode
 
virtual void drawSeries (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const override
 Draw an interval of the bar chart
 
virtual QRectF boundingRect () const override
 Get the bounding rectangle of all samples
 
virtual QwtColumnSymbolspecialSymbol (int sampleIndex, const QPointF &) const
 Get a special symbol for a specific sample
 
virtual QwtText barTitle (int sampleIndex) const
 Return the title of a bar
 
- Public 成员函数 继承自 QwtPlotAbstractBarChart
 QwtPlotAbstractBarChart (const QwtText &title)
 Constructor
 
void setLayoutPolicy (LayoutPolicy)
 Set the layout policy
 
LayoutPolicy layoutPolicy () const
 Get the layout policy
 
void setLayoutHint (double)
 Set the layout hint
 
double layoutHint () const
 Get the layout hint
 
void setSpacing (int)
 Set the spacing between bars
 
int spacing () const
 Get the spacing between bars
 
void setMargin (int)
 Set the margin around the bars
 
int margin () const
 Get the margin around the bars
 
void setBaseline (double)
 Set the baseline value
 
double baseline () const
 Get the baseline value
 
virtual void getCanvasMarginHint (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, double &left, double &top, double &right, double &bottom) const override
 Calculate a hint for the canvas margin
 
- Public 成员函数 继承自 QwtPlotSeriesItem
 QwtPlotSeriesItem (const QString &title=QString())
 
 QwtPlotSeriesItem (const QwtText &title)
 Constructor
 
void setOrientation (Qt::Orientation)
 Set the orientation of the item
 
Qt::Orientation orientation () const
 Get the orientation of the plot item
 
virtual void draw (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const override
 Draw the complete series
 
virtual void updateScaleDiv (const QwtScaleDiv &, const QwtScaleDiv &) override
 Update the scale divisions
 
- Public 成员函数 继承自 QwtPlotItem
 QwtPlotItem ()
 Default constructor
 
 QwtPlotItem (const QString &title)
 Constructor with title as QString
 
 QwtPlotItem (const QwtText &title)
 Constructor with title as QwtText
 
virtual ~QwtPlotItem ()
 Destructor
 
void detach ()
 Detach the item from the plot
 
QwtPlotplot () const
 Get the plot the item is attached to
 
void setTitle (const QString &title)
 Set the title using a QString
 
void setTitle (const QwtText &title)
 Set the title using a QwtText
 
const QwtTexttitle () const
 Get the title
 
void setItemAttribute (ItemAttribute, bool on=true)
 Set an item attribute
 
bool testItemAttribute (ItemAttribute) const
 Test an item attribute
 
void setItemInterest (ItemInterest, bool on=true)
 Set an item interest
 
bool testItemInterest (ItemInterest) const
 Test an item interest
 
void setRenderHint (RenderHint, bool on=true)
 Set a render hint
 
bool testRenderHint (RenderHint) const
 Test a render hint
 
void setRenderThreadCount (uint numThreads)
 Set the number of render threads
 
uint renderThreadCount () const
 Get the number of render threads
 
void setLegendIconSize (const QSize &)
 Set the legend icon size
 
QSize legendIconSize () const
 Get the legend icon size
 
double z () const
 Get the z-value
 
void setZ (double z)
 Set the z-value
 
void show ()
 Show the item
 
void hide ()
 Hide the item
 
virtual void setVisible (bool)
 Set the visibility
 
bool isVisible () const
 Check if the item is visible
 
void setAxes (QwtAxisId xAxis, QwtAxisId yAxis)
 Set both axes
 
void setXAxis (QwtAxisId)
 Set the x-axis
 
QwtAxisId xAxis () const
 Get the x-axis
 
void setYAxis (QwtAxisId)
 Set the y-axis
 
QwtAxisId yAxis () const
 Get the y-axis
 
virtual void itemChanged ()
 Notify the plot that the item has changed
 
virtual void legendChanged ()
 Notify the item that the legend has changed
 
virtual void updateLegend (const QwtPlotItem *, const QList< QwtLegendData > &)
 Update the item with changes of the legend
 
QRectF scaleRect (const QwtScaleMap &, const QwtScaleMap &) const
 Calculate the scale rectangle
 
QRectF paintRect (const QwtScaleMap &, const QwtScaleMap &) const
 Calculate the paint rectangle
 
- Public 成员函数 继承自 QwtSeriesStore< QPointF >
void setData (QwtSeriesData< QPointF > *series)
 
QwtSeriesData< QPointF > * data ()
 
const QwtSeriesData< QPointF > * data () const
 
QPointF sample (size_t index) const
 
virtual size_t dataSize () const override
 
virtual QRectF dataRect () const override
 
virtual void setRectOfInterest (const QRectF &rect) override
 Set a the "rectangle of interest" for the stored series
 
QwtSeriesData< QPointF > * swapData (QwtSeriesData< QPointF > *series)
 

Protected 成员函数

virtual void drawSample (QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, const QwtInterval &boundingInterval, int index, const QPointF &sample) const
 Draw a sample
 
virtual void drawBar (QPainter *, int sampleIndex, const QPointF &sample, const QwtColumnRect &) const
 Draw a bar
 
QwtColumnRect columnRect (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, const QwtInterval &boundingInterval, const QPointF &sample) const
 Get column rectangle
 
QList< QwtLegendDatalegendData () const override
 Get legend data
 
QwtGraphic legendIcon (int index, const QSizeF &) const override
 Get legend icon
 
- Protected 成员函数 继承自 QwtPlotAbstractBarChart
double sampleWidth (const QwtScaleMap &map, double canvasSize, double boundingSize, double value) const
 Calculate the width for a sample in paint device coordinates
 
- Protected 成员函数 继承自 QwtPlotSeriesItem
virtual void dataChanged () override
 dataChanged() indicates, that the series has been changed.
 
- Protected 成员函数 继承自 QwtPlotItem
QwtGraphic defaultIcon (const QBrush &, const QSizeF &) const
 Create a default icon
 

详细描述

QwtPlotBarChart displays a series of values as bars

Each bar might be customized individually by implementing a specialSymbol(). Otherwise it is rendered using a default symbol.

Depending on its orientation() the bars are displayed horizontally or vertically. The bars cover the interval between the baseline() and the value.

By activating the LegendBarTitles mode each sample will have its own entry on the legend.

The most common use case of a bar chart is to display a list of y coordinates, where the x coordinate is simply the index in the list. But for other situations ( f.e. when values are related to dates ) it is also possible to set x coordinates explicitly.

参见
QwtPlotMultiBarChart, QwtPlotHistogram, QwtPlotCurve::Sticks, QwtPlotSeriesItem::orientation(), QwtPlotAbstractBarChart::baseline()

成员枚举类型说明

◆ LegendMode

Legend modes

The default setting is QwtPlotBarChart::LegendChartTitle.

参见
setLegendMode(), legendMode()
枚举值
LegendChartTitle 

One entry on the legend showing the default symbol and the title() of the chart

参见
QwtPlotItem::title()
LegendBarTitles 

One entry for each value showing the individual symbol of the corresponding bar and the bar title.

参见
specialSymbol(), barTitle()

构造及析构函数说明

◆ QwtPlotBarChart()

QwtPlotBarChart::QwtPlotBarChart ( const QwtText title)
explicit

Constructor

参数
[in]titleTitle of the chart

Constructor

参数
[in]titleTitle of the chart

Destructor

成员函数说明

◆ attach()

void QwtPlotBarChart::attach ( QwtPlot plot)
overridevirtual

Attach the bar chart to a plot

If the brush has not been explicitly set by the user, the bar chart automatically receives a color from the plot's color cycle. The pen is set to a darker shade of the fill color unless user-set.

参数
plotPlot to attach to (nullptr to detach)

重载 QwtPlotItem .

◆ barTitle()

QwtText QwtPlotBarChart::barTitle ( int  sampleIndex) const
virtual

Return the title of a bar

In LegendBarTitles mode the title is displayed on the legend entry corresponding to a bar. The default implementation is a dummy, that is intended to be overloaded.

参数
[in]sampleIndexIndex of the bar
返回
An empty text
参见
LegendBarTitles

◆ boundingRect()

QRectF QwtPlotBarChart::boundingRect ( ) const
overridevirtual

Get the bounding rectangle of all samples

返回
Bounding rectangle of all samples. For an empty series the rectangle is invalid.

重载 QwtPlotSeriesItem .

◆ brush()

QBrush QwtPlotBarChart::brush ( ) const

Get the bar symbol brush

返回
Brush for filling the bar

◆ columnRect()

QwtColumnRect QwtPlotBarChart::columnRect ( const QwtScaleMap xMap,
const QwtScaleMap yMap,
const QRectF &  canvasRect,
const QwtInterval boundingInterval,
const QPointF &  sample 
) const
protected

Get column rectangle

Calculate the geometry of a bar in widget coordinates

参数
xMapx map
yMapy map
canvasRectContents rect of the canvas
boundingIntervalBounding interval of sample values
sampleValue of the sample
返回
Geometry of the column

◆ drawBar()

void QwtPlotBarChart::drawBar ( QPainter *  painter,
int  sampleIndex,
const QPointF &  sample,
const QwtColumnRect rect 
) const
protectedvirtual

Draw a bar

参数
painterPainter
sampleIndexIndex of the sample represented by the bar
sampleValue of the sample
rectBounding rectangle of the bar

◆ drawSample()

void QwtPlotBarChart::drawSample ( QPainter *  painter,
const QwtScaleMap xMap,
const QwtScaleMap yMap,
const QRectF &  canvasRect,
const QwtInterval boundingInterval,
int  index,
const QPointF &  sample 
) const
protectedvirtual

Draw a sample

参数
painterPainter
xMapx map
yMapy map
canvasRectContents rect of the canvas
boundingIntervalBounding interval of sample values
indexIndex of the sample
sampleValue of the sample
参见
drawSeries()

◆ drawSeries()

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

Draw an interval of the bar chart

参数
[in]painterPainter
[in]xMapMaps x-values into pixel coordinates.
[in]yMapMaps y-values into pixel coordinates.
[in]canvasRectContents rect of the canvas
[in]fromIndex of the first point to be painted
[in]toIndex of the last point to be painted. If to < 0 the curve will be painted to its last point.
参见
drawSymbols()

实现了 QwtPlotSeriesItem.

◆ frameStyle()

QwtColumnSymbol::FrameStyle QwtPlotBarChart::frameStyle ( ) const

Get the bar symbol frame style

返回
Frame style for the bar

◆ legendData()

QList< QwtLegendData > QwtPlotBarChart::legendData ( ) const
overrideprotectedvirtual

Get legend data

Return all information, that is needed to represent the item on the legend

In case of LegendBarTitles an entry for each bar is returned, otherwise the chart is represented like any other plot item from its title() and the legendIcon().

返回
Information, that is needed to represent the item on the legend
参见
title(), setLegendMode(), barTitle(), QwtLegend, QwtPlotLegendItem

重载 QwtPlotItem .

◆ legendIcon()

QwtGraphic QwtPlotBarChart::legendIcon ( int  index,
const QSizeF &  size 
) const
overrideprotectedvirtual

Get legend icon

返回
Icon representing a bar or the chart on the legend

When the legendMode() is LegendBarTitles the icon shows the bar corresponding to index - otherwise the bar displays the default symbol.

参数
indexIndex of the legend entry
sizeIcon size
参见
setLegendMode(), drawBar(), QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()

重载 QwtPlotItem .

◆ legendMode()

QwtPlotBarChart::LegendMode QwtPlotBarChart::legendMode ( ) const

Get the legend mode

返回
Legend mode
参见
setLegendMode()

◆ pen()

QPen QwtPlotBarChart::pen ( ) const

Get the bar symbol pen

返回
Pen for drawing the bar outline

◆ rtti()

int QwtPlotBarChart::rtti ( ) const
overridevirtual

Get the runtime type information

返回
QwtPlotItem::Rtti_PlotBarChart

重载 QwtPlotItem .

◆ setBrush()

void QwtPlotBarChart::setBrush ( const QBrush &  b)

Set the bar symbol brush

参数
[in]bBrush for filling the bar

◆ setFrameStyle()

void QwtPlotBarChart::setFrameStyle ( QwtColumnSymbol::FrameStyle  f)

Set the bar symbol frame style

参数
[in]fFrame style for the bar

◆ setLegendMode()

void QwtPlotBarChart::setLegendMode ( LegendMode  mode)

Set the mode that decides what to display on the legend

In case of LegendBarTitles barTitle() needs to be overloaded to return individual titles for each bar.

参数
[in]modeNew mode
参见
legendMode(), legendData(), barTitle(), QwtPlotItem::ItemAttribute

◆ setPen()

void QwtPlotBarChart::setPen ( const QPen &  p)

Set the bar symbol pen

参数
[in]pPen for drawing the bar outline

◆ setSamples() [1/3]

void QwtPlotBarChart::setSamples ( const QVector< double > &  samples)

Initialize data with an array of doubles

The indices in the array are taken as x coordinate, while the doubles are interpreted as y values.

参数
[in]samplesVector of y coordinates
注解
QVector is implicitly shared.

◆ setSamples() [2/3]

void QwtPlotBarChart::setSamples ( const QVector< QPointF > &  samples)

Initialize data with an array of points

参数
[in]samplesVector of points
注解
QVector is implicitly shared.
QPolygonF is derived from QVector<QPointF>.

◆ setSamples() [3/3]

void QwtPlotBarChart::setSamples ( QwtSeriesData< QPointF > *  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.

参数
[in]dataData
警告
The item takes ownership of the data object, deleting it when its not used anymore.

◆ setSymbol()

void QwtPlotBarChart::setSymbol ( QwtColumnSymbol symbol)

Assign a symbol

The bar chart will take the ownership of the symbol, hence the previously set symbol will be deleted by setting a new one. If symbol is nullptr no symbol will be drawn.

参数
[in]symbolSymbol
参见
symbol()

◆ specialSymbol()

QwtColumnSymbol * QwtPlotBarChart::specialSymbol ( int  sampleIndex,
const QPointF &  sample 
) const
virtual

Get a special symbol for a specific sample

Needs to be overloaded to return a non default symbol for a specific sample.

参数
[in]sampleIndexIndex of the sample represented by the bar
[in]sampleValue of the sample
返回
nullptr, indicating to use the default symbol

◆ symbol()

const QwtColumnSymbol * QwtPlotBarChart::symbol ( ) const

Get the current symbol

返回
Current symbol or nullptr, when no symbol has been assigned.
参见
setSymbol()

该类的文档由以下文件生成: