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

QwtPlotTradingCurve illustrates movements in the price of a financial instrument over time 更多...

#include <qwt_plot_tradingcurve.h>

类 QwtPlotTradingCurve 继承关系图:
QwtPlotSeriesItem QwtSeriesStore< QwtOHLCSample > QwtPlotItem QwtAbstractSeriesStore QwtAbstractSeriesStore

class  PrivateData
 

Public 类型

enum  SymbolStyle { NoSymbol = -1 , Bar , CandleStick , UserSymbol = 100 }
 Symbol styles 更多...
 
enum  Direction { Increasing , Decreasing }
 Direction of a price movement 更多...
 
enum  PaintAttribute { ClipSymbols = 0x01 }
 Paint attributes 更多...
 
- 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 成员函数

 QwtPlotTradingCurve (const QString &title=QString())
 
 QwtPlotTradingCurve (const QwtText &title)
 Constructor
 
virtual int rtti () const override
 Get the runtime type information
 
void setPaintAttribute (PaintAttribute, bool on=true)
 Specify an attribute how to draw the curve
 
bool testPaintAttribute (PaintAttribute) const
 Test a paint attribute
 
void setSamples (const QVector< QwtOHLCSample > &)
 Initialize data with an array of samples
 
void setSamples (QwtSeriesData< QwtOHLCSample > *)
 Assign a series of samples
 
void setSymbolStyle (SymbolStyle style)
 Set the symbol style
 
SymbolStyle symbolStyle () const
 Get the symbol style
 
void setSymbolPen (const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
 Build and assign the symbol pen
 
void setSymbolPen (const QPen &)
 Set the symbol pen
 
QPen symbolPen () const
 Get the symbol pen
 
void setSymbolBrush (Direction, const QBrush &)
 Set the symbol brush
 
QBrush symbolBrush (Direction) const
 Get the symbol brush
 
void setSymbolExtent (double)
 Set the extent of the symbol
 
double symbolExtent () const
 Get the extent of the symbol
 
void setMinSymbolWidth (double)
 Set a minimum for the symbol width
 
double minSymbolWidth () const
 Get the minimum for the symbol width
 
void setMaxSymbolWidth (double)
 Set a maximum for the symbol width
 
double maxSymbolWidth () const
 Get the maximum for the symbol width
 
virtual void drawSeries (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const override
 Draw an interval of the curve
 
virtual QRectF boundingRect () const override
 Get the bounding rectangle of all samples
 
virtual QwtGraphic legendIcon (int index, const QSizeF &) const override
 Get a legend icon
 
- 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
 
virtual void attach (QwtPlot *plot)
 Attach the item to a plot
 
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 getCanvasMarginHint (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, double &left, double &top, double &right, double &bottom) const
 Get margin hints for the canvas
 
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
 
virtual QList< QwtLegendDatalegendData () const
 Return legend data
 
- Public 成员函数 继承自 QwtSeriesStore< QwtOHLCSample >
void setData (QwtSeriesData< QwtOHLCSample > *series)
 
QwtSeriesData< QwtOHLCSample > * data ()
 
const QwtSeriesData< QwtOHLCSample > * data () const
 
QwtOHLCSample 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< QwtOHLCSample > * swapData (QwtSeriesData< QwtOHLCSample > *series)
 

Protected 成员函数

void init ()
 Initialize internal members
 
virtual void drawSymbols (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
 Draw symbols
 
virtual void drawUserSymbol (QPainter *, SymbolStyle, const QwtOHLCSample &, Qt::Orientation, bool inverted, double symbolWidth) const
 Draw a symbol for a symbol style >= UserSymbol
 
void drawBar (QPainter *, const QwtOHLCSample &, Qt::Orientation, bool inverted, double width) const
 Draw a bar
 
void drawCandleStick (QPainter *, const QwtOHLCSample &, Qt::Orientation, double width) const
 Draw a candle stick
 
virtual double scaledSymbolWidth (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const
 Calculate the symbol width in paint 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
 

详细描述

QwtPlotTradingCurve illustrates movements in the price of a financial instrument over time

QwtPlotTradingCurve supports candlestick or bar ( OHLC ) charts that are used in the domain of technical analysis.

While the length ( height or width depending on orientation() ) of each symbol depends on the corresponding OHLC sample the size of the other dimension can be controlled using:

The extent is a size in scale coordinates, so that the symbol width is increasing when the plot is zoomed in. Minimum/Maximum width is in widget coordinates independent from the zoom level. When setting the minimum and maximum to the same value, the width of the symbol is fixed.

成员枚举类型说明

◆ Direction

Direction of a price movement

枚举值
Increasing 

The closing price is higher than the opening price

Decreasing 

The closing price is lower than the opening price

◆ PaintAttribute

Paint attributes

Attributes to modify the drawing algorithm.

参见
setPaintAttribute(), testPaintAttribute()
枚举值
ClipSymbols 

Check if a symbol is on the plot canvas before painting it.

◆ SymbolStyle

Symbol styles

The default setting is QwtPlotSeriesItem::CandleStick.

参见
setSymbolStyle(), symbolStyle()
枚举值
NoSymbol 

Nothing is displayed

Bar 

A line on the chart shows the price range (the highest and lowest prices) over one unit of time, e.g. one day or one hour. Tick marks project from each side of the line indicating the opening and closing price.

CandleStick 

The range between opening/closing price are displayed as a filled box. The fill brush depends on the direction of the price movement. The box is connected to the highest/lowest values by lines.

UserSymbol 

SymbolTypes >= UserSymbol are displayed by drawUserSymbol(), that needs to be overloaded and implemented in derived curve classes.

参见
drawUserSymbol()

构造及析构函数说明

◆ QwtPlotTradingCurve()

QwtPlotTradingCurve::QwtPlotTradingCurve ( const QwtText title)
explicit

Constructor

参数
[in]titleTitle of the curve

Constructor

参数
[in]titleTitle of the curve

Destructor

成员函数说明

◆ boundingRect()

QRectF QwtPlotTradingCurve::boundingRect ( ) const
overridevirtual

Get the bounding rectangle of all samples

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

重载 QwtPlotSeriesItem .

◆ drawBar()

void QwtPlotTradingCurve::drawBar ( QPainter *  painter,
const QwtOHLCSample sample,
Qt::Orientation  orientation,
bool  inverted,
double  width 
) const
protected

Draw a bar

参数
[in]painterQt painter, initialized with pen/brush
[in]sampleSample, already translated into paint device coordinates
[in]orientationVertical or horizontal
[in]invertedWhen inverted is false the open tick is painted to the left/top, otherwise it is painted right/bottom. The close tick is painted in the opposite direction of the open tick.
[in]widthWidth or height of the candle, depending on the orientation
参见
Bar

◆ drawCandleStick()

void QwtPlotTradingCurve::drawCandleStick ( QPainter *  painter,
const QwtOHLCSample sample,
Qt::Orientation  orientation,
double  width 
) const
protected

Draw a candle stick

参数
[in]painterQt painter, initialized with pen/brush
[in]sampleSamples already translated into paint device coordinates
[in]orientationVertical or horizontal
[in]widthWidth or height of the candle, depending on the orientation
参见
CandleStick

◆ drawSeries()

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

Draw an interval of the curve

参数
[in]painterPainter
[in]xMapMaps x-values into pixel coordinates.
[in]yMapMaps y-values into pixel coordinates.
[in]canvasRectContents rectangle 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.

◆ drawSymbols()

void QwtPlotTradingCurve::drawSymbols ( QPainter *  painter,
const QwtScaleMap xMap,
const QwtScaleMap yMap,
const QRectF &  canvasRect,
int  from,
int  to 
) const
protectedvirtual

Draw symbols

参数
[in]painterPainter
[in]xMapx map
[in]yMapy map
[in]canvasRectContents rectangle of the canvas
[in]fromIndex of the first point to be painted
[in]toIndex of the last point to be painted
参见
drawSeries()

◆ drawUserSymbol()

void QwtPlotTradingCurve::drawUserSymbol ( QPainter *  painter,
SymbolStyle  symbolStyle,
const QwtOHLCSample sample,
Qt::Orientation  orientation,
bool  inverted,
double  symbolWidth 
) const
protectedvirtual

Draw a symbol for a symbol style >= UserSymbol

The implementation does nothing and is intended to be overloaded

参数
[in]painterQt painter, initialized with pen/brush
[in]symbolStyleSymbol style
[in]sampleSamples already translated into paint device coordinates
[in]orientationVertical or horizontal
[in]invertedTrue, when the opposite scale ( Qt::Vertical: x, Qt::Horizontal: y ) is increasing in the opposite direction as QPainter coordinates.
[in]symbolWidthWidth of the symbol in paint device coordinates

◆ init()

void QwtPlotTradingCurve::init ( )
protected

Initialize internal members

Sets default attributes and creates internal data storage.

◆ legendIcon()

QwtGraphic QwtPlotTradingCurve::legendIcon ( int  index,
const QSizeF &  size 
) const
overridevirtual

Get a legend icon

Returns a rectangle filled with the color of the symbol pen

参数
[in]indexIndex of the legend entry ( usually there is only one )
[in]sizeIcon size
返回
Legend icon
参见
setLegendIconSize(), legendData()

重载 QwtPlotItem .

◆ maxSymbolWidth()

double QwtPlotTradingCurve::maxSymbolWidth ( ) const

Get the maximum for the symbol width

返回
Maximum for the symbol width
参见
setMaxSymbolWidth(), minSymbolWidth(), symbolExtent()

◆ minSymbolWidth()

double QwtPlotTradingCurve::minSymbolWidth ( ) const

Get the minimum for the symbol width

返回
Minimum for the symbol width
参见
setMinSymbolWidth(), maxSymbolWidth(), symbolExtent()

◆ rtti()

int QwtPlotTradingCurve::rtti ( ) const
overridevirtual

Get the runtime type information

返回
QwtPlotItem::Rtti_PlotTradingCurve

重载 QwtPlotItem .

◆ scaledSymbolWidth()

double QwtPlotTradingCurve::scaledSymbolWidth ( const QwtScaleMap xMap,
const QwtScaleMap yMap,
const QRectF &  canvasRect 
) const
protectedvirtual

Calculate the symbol width in paint coordinates

The width is calculated by scaling the symbol extent into paint device coordinates bounded by the minimum/maximum symbol width.

参数
[in]xMapMaps x-values into pixel coordinates.
[in]yMapMaps y-values into pixel coordinates.
[in]canvasRectContents rectangle of the canvas
返回
Symbol width in paint coordinates
参见
symbolExtent(), minSymbolWidth(), maxSymbolWidth()

◆ setMaxSymbolWidth()

void QwtPlotTradingCurve::setMaxSymbolWidth ( double  width)

Set a maximum for the symbol width

A value <= 0.0 means an unlimited width

参数
[in]widthWidth in paint device coordinates
参见
maxSymbolWidth(), setMinSymbolWidth(), setSymbolExtent()

◆ setMinSymbolWidth()

void QwtPlotTradingCurve::setMinSymbolWidth ( double  width)

Set a minimum for the symbol width

参数
[in]widthWidth in paint device coordinates
参见
minSymbolWidth(), setMaxSymbolWidth(), setSymbolExtent()

◆ setPaintAttribute()

void QwtPlotTradingCurve::setPaintAttribute ( PaintAttribute  attribute,
bool  on = true 
)

Specify an attribute how to draw the curve

参数
[in]attributePaint attribute
[in]onOn/Off
参见
testPaintAttribute()

◆ setSamples() [1/2]

void QwtPlotTradingCurve::setSamples ( const QVector< QwtOHLCSample > &  samples)

Initialize data with an array of samples

参数
[in]samplesVector of samples
参见
QwtPlotSeriesItem::setData()

◆ setSamples() [2/2]

void QwtPlotTradingCurve::setSamples ( QwtSeriesData< QwtOHLCSample > *  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.

◆ setSymbolBrush()

void QwtPlotTradingCurve::setSymbolBrush ( Direction  direction,
const QBrush &  brush 
)

Set the symbol brush

参数
[in]directionDirection type
[in]brushBrush used to fill the body of all candlestick symbols with the direction
参见
symbolBrush(), setSymbolPen()

◆ setSymbolExtent()

void QwtPlotTradingCurve::setSymbolExtent ( double  extent)

Set the extent of the symbol

The width of the symbol is given in scale coordinates. When painting a symbol the width is scaled into paint device coordinates by scaledSymbolWidth(). The scaled width is bounded by minSymbolWidth(), maxSymbolWidth()

参数
[in]extentSymbol width in scale coordinates
参见
symbolExtent(), scaledSymbolWidth(), setMinSymbolWidth(), setMaxSymbolWidth()

◆ setSymbolPen() [1/2]

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

Build and assign the symbol 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.

参数
[in]colorPen color
[in]widthPen width
[in]stylePen style
参见
pen(), brush()

◆ setSymbolPen() [2/2]

void QwtPlotTradingCurve::setSymbolPen ( const QPen &  pen)

Set the symbol pen

The symbol pen is used for rendering the lines of the bar or candlestick symbols

参数
[in]penPen
参见
symbolPen(), setSymbolBrush()

◆ setSymbolStyle()

void QwtPlotTradingCurve::setSymbolStyle ( SymbolStyle  style)

Set the symbol style

参数
[in]styleSymbol style
参见
symbolStyle(), setSymbolExtent(), setSymbolPen(), setSymbolBrush()

◆ symbolBrush()

QBrush QwtPlotTradingCurve::symbolBrush ( Direction  direction) const

Get the symbol brush

参数
[in]directionDirection type
返回
Brush used to fill the body of all candlestick symbols with the direction
参见
setSymbolPen(), symbolBrush()

◆ symbolExtent()

double QwtPlotTradingCurve::symbolExtent ( ) const

Get the extent of the symbol

返回
Extent of a symbol in scale coordinates
参见
setSymbolExtent(), scaledSymbolWidth(), minSymbolWidth(), maxSymbolWidth()

◆ symbolPen()

QPen QwtPlotTradingCurve::symbolPen ( ) const

Get the symbol pen

返回
Symbol pen
参见
setSymbolPen(), symbolBrush()

◆ symbolStyle()

QwtPlotTradingCurve::SymbolStyle QwtPlotTradingCurve::symbolStyle ( ) const

Get the symbol style

返回
Symbol style
参见
setSymbolStyle(), symbolExtent(), symbolPen(), symbolBrush()

◆ testPaintAttribute()

bool QwtPlotTradingCurve::testPaintAttribute ( PaintAttribute  attribute) const

Test a paint attribute

返回
True when attribute is enabled
参见
PaintAttribute, setPaintAttribute()

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