Qwt User's Guide 6.1.2

- Main Page
- Related Pages
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Functions Variables Typedefs Enumerations Enumerator Pages
Public Types | Public Member Functions | Protected Member Functions | List of all members
QwtPlotTradingCurve Class Reference

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

`#include <qwt_plot_tradingcurve.h>`

Inheritance diagram for QwtPlotTradingCurve:
[legend]

## Public Types
enum | SymbolStyle { NoSymbol = -1, Bar, CandleStick, UserSymbol = 100 }
| Symbol styles. More...
enum | Direction { Increasing, Decreasing }
| Direction of a price movement. More...
enum | PaintAttribute { ClipSymbols = 0x01 }
typedef QFlags< PaintAttribute > | PaintAttributes
| Paint attributes.
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_PlotSVG, Rtti_PlotTradingCurve, Rtti_PlotBarChart, Rtti_PlotMultiBarChart, Rtti_PlotShape, Rtti_PlotTextLabel, Rtti_PlotZone, 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...
typedef QFlags< ItemAttribute > | ItemAttributes
| Plot Item Attributes.
typedef QFlags< ItemInterest > | ItemInterests
| Plot Item Interests.
typedef QFlags< RenderHint > | RenderHints
| Render hints.

## Public Member Functions
| QwtPlotTradingCurve (const QString &title=QString::null)
| QwtPlotTradingCurve (const QwtText &title)
virtual | ~QwtPlotTradingCurve ()
| Destructor.
virtual int | rtti () const
void | setPaintAttribute (PaintAttribute, bool on=true)
bool | testPaintAttribute (PaintAttribute) const
void | setSamples (const QVector< QwtOHLCSample > &)
void | setSamples (QwtSeriesData< QwtOHLCSample > *)
void | setSymbolStyle (SymbolStyle style)
SymbolStyle | symbolStyle () const
void | setSymbolPen (const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
void | setSymbolPen (const QPen &)
| Set the symbol pen. More...
QPen | symbolPen () const
void | setSymbolBrush (Direction, const QBrush &)
QBrush | symbolBrush (Direction) const
void | setSymbolExtent (double width)
| Set the extent of the symbol. More...
double | symbolExtent () const
void | setMinSymbolWidth (double)
double | minSymbolWidth () const
void | setMaxSymbolWidth (double)
double | maxSymbolWidth () const
virtual void | drawSeries (QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
virtual QRectF | boundingRect () const
virtual QwtGraphic | legendIcon (int index, const QSizeF &) const
Public Member Functions inherited from QwtPlotSeriesItem
| QwtPlotSeriesItem (const QString &title=QString::null)
| QwtPlotSeriesItem (const QwtText &title)
virtual | ~QwtPlotSeriesItem ()
| Destructor.
void | setOrientation (Qt::Orientation)
Qt::Orientation | orientation () const
virtual void | draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &) const
| Draw the complete series. More...
virtual void | updateScaleDiv (const QwtScaleDiv &, const QwtScaleDiv &)
| Update the item to changes of the axes scale division. More...
Public Member Functions inherited from QwtPlotItem
| QwtPlotItem (const QwtText &title=QwtText())
virtual | ~QwtPlotItem ()
| Destroy the QwtPlotItem.
void | attach (QwtPlot *plot)
| Attach the item to a plot. More...
void | detach ()
| This method detaches a QwtPlotItem from any QwtPlot it has been associated with. More...
QwtPlot * | plot () const
| Return attached plot.
void | setTitle (const QString &title)
void | setTitle (const QwtText &title)
const QwtText & | title () const
void | setItemAttribute (ItemAttribute, bool on=true)
bool | testItemAttribute (ItemAttribute) const
void | setItemInterest (ItemInterest, bool on=true)
bool | testItemInterest (ItemInterest) const
void | setRenderHint (RenderHint, bool on=true)
bool | testRenderHint (RenderHint) const
void | setRenderThreadCount (uint numThreads)
uint | renderThreadCount () const
void | setLegendIconSize (const QSize &)
QSize | legendIconSize () const
double | z () const
void | setZ (double z)
| Set the z value. More...
void | show ()
| Show the item.
void | hide ()
| Hide the item.
virtual void | setVisible (bool)
bool | isVisible () const
void | setAxes (int xAxis, int yAxis)
void | setXAxis (int axis)
int | xAxis () const
| Return xAxis.
void | setYAxis (int axis)
int | yAxis () const
| Return yAxis.
virtual void | itemChanged ()
virtual void | legendChanged ()
virtual void | getCanvasMarginHint (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasSize, double &left, double &top, double &right, double &bottom) const
| Calculate a hint for the canvas margin. More...
virtual void | updateLegend (const QwtPlotItem *, const QList< QwtLegendData > &)
| Update the item to changes of the legend info. More...
QRectF | scaleRect (const QwtScaleMap &, const QwtScaleMap &) const
| Calculate the bounding scale rectangle of 2 maps. More...
QRectF | paintRect (const QwtScaleMap &, const QwtScaleMap &) const
| Calculate the bounding paint rectangle of 2 maps. More...
virtual QList< QwtLegendData > | legendData () const
| Return all information, that is needed to represent the item on the legend. More...

## Protected Member Functions
void | init ()
| Initialize internal members.
virtual void | drawSymbols (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const
virtual void | drawUserSymbol (QPainter *, SymbolStyle, const QwtOHLCSample &, Qt::Orientation, bool inverted, double width) const
| Draw a symbol for a symbol style >= UserSymbol. More...
void | drawBar (QPainter *painter, const QwtOHLCSample &, Qt::Orientation, bool inverted, double width) const
| Draw a bar. More...
void | drawCandleStick (QPainter *, const QwtOHLCSample &, Qt::Orientation, double width) const
| Draw a candle stick. More...
virtual double | scaledSymbolWidth (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const
Protected Member Functions inherited from QwtPlotSeriesItem
virtual void | dataChanged ()
| 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. More...
Protected Member Functions inherited from QwtAbstractSeriesStore
virtual | ~QwtAbstractSeriesStore ()
| Destructor.

## Detailed Description

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:

- setSymbolExtent()
- setSymbolMinWidth()
- setSymbolMaxWidth()

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.

## Member Enumeration Documentation

enum QwtPlotTradingCurve::Direction

Direction of a price movement.

Enumerator
Increasing | The closing price is higher than the opening price.
Decreasing | The closing price is lower than the opening price.

enum QwtPlotTradingCurve::PaintAttribute

Attributes to modify the drawing algorithm.

See Also
  setPaintAttribute(), testPaintAttribute()

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

enum QwtPlotTradingCurve::SymbolStyle

Symbol styles.

The default setting is QwtPlotSeriesItem::CandleStick.

See Also
  setSymbolStyle(), symbolStyle()

Enumerator
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. See Also drawUserSymbol()

## Constructor & Destructor Documentation

QwtPlotTradingCurve::QwtPlotTradingCurve | ( | const QString & | title = `QString::null` | ) |
| explicit

Constructor

Parameters

  title | Title of the curve

QwtPlotTradingCurve::QwtPlotTradingCurve | ( | const QwtText & | title | ) |
| explicit

Constructor

Parameters

  title | Title of the curve

## Member Function Documentation

QRectF QwtPlotTradingCurve::boundingRect | ( |  | ) | const
| virtual

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

Reimplemented from QwtPlotSeriesItem.

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

Draw a bar.

Parameters

  painter | Qt painter, initialized with pen/brush
  sample | Sample, already translated into paint device coordinates
  orientation | Vertical or horizontal
  inverted | When 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. painted in the opposite d opposite direction.
  width | Width or height of the candle, depending on the orientation

See Also
  Bar

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

Draw a candle stick.

Parameters

  painter | Qt painter, initialized with pen/brush
  sample | Samples already translated into paint device coordinates
  orientation | Vertical or horizontal
  width | Width or height of the candle, depending on the orientation

See Also
  CandleStick

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

Draw an interval of the curve

Parameters

  painter | Painter
  xMap | Maps x-values into pixel coordinates.
  yMap | Maps y-values into pixel coordinates.
  canvasRect | Contents rectangle of the canvas
  from | Index of the first point to be painted
  to | Index of the last point to be painted. If to < 0 the curve will be painted to its last point.

See Also
  drawSymbols()

Implements QwtPlotSeriesItem.

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

Draw symbols

Parameters

  painter | Painter
  xMap | x map
  yMap | y map
  canvasRect | Contents rectangle of the canvas
  from | Index of the first point to be painted
  to | Index of the last point to be painted

See Also
  drawSeries()

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

Draw a symbol for a symbol style >= UserSymbol.

The implementation does nothing and is intended to be overloaded

Parameters

  painter | Qt painter, initialized with pen/brush
  symbolStyle | Symbol style
  sample | Samples already translated into paint device coordinates
  orientation | Vertical or horizontal
  inverted | True, when the opposite scale ( Qt::Vertical: x, Qt::Horizontal: y ) is increasing in the opposite direction as QPainter coordinates.
  symbolWidth | Width of the symbol in paint device coordinates

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

Returns
  A rectangle filled with the color of the symbol pen

Parameters

  index | Index of the legend entry ( usually there is only one )
  size | Icon size

See Also
  setLegendIconSize(), legendData()

Reimplemented from QwtPlotItem.

double QwtPlotTradingCurve::maxSymbolWidth | ( |  | ) | const

Returns
  Maximum for the symbol width

See Also
  setMaxSymbolWidth(), minSymbolWidth(), symbolExtent()

double QwtPlotTradingCurve::minSymbolWidth | ( |  | ) | const

Returns
  Minmum for the symbol width

See Also
  setMinSymbolWidth(), maxSymbolWidth(), symbolExtent()

int QwtPlotTradingCurve::rtti | ( |  | ) | const
| virtual

Returns
  QwtPlotItem::Rtti_PlotTradingCurve

Reimplemented from QwtPlotItem.

double QwtPlotTradingCurve::scaledSymbolWidth | ( | const QwtScaleMap & | xMap,
|  | const QwtScaleMap & | yMap,
|  | const QRectF & | canvasRect
| ) |  | const
| protected virtual

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.

Parameters

  xMap | Maps x-values into pixel coordinates.
  yMap | Maps y-values into pixel coordinates.
  canvasRect | Contents rectangle of the canvas

Returns
  Symbol width in paint coordinates

See Also
  symbolExtent(), minSymbolWidth(), maxSymbolWidth()

void QwtPlotTradingCurve::setMaxSymbolWidth | ( | double | width | ) |

Set a maximum for the symbol width

A value <= 0.0 means an unlimited width

Parameters

  width | Width in paint device coordinates

See Also
  maxSymbolWidth(), setMinSymbolWidth(), setSymbolExtent()

void QwtPlotTradingCurve::setMinSymbolWidth | ( | double | width | ) |

Set a minimum for the symbol width

Parameters

  width | Width in paint device coordinates

See Also
  minSymbolWidth(), setMaxSymbolWidth(), setSymbolExtent()

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

Specify an attribute how to draw the curve

Parameters

  attribute | Paint attribute
  on | On/Off

See Also
  testPaintAttribute()

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

Initialize data with an array of samples.

Parameters

  samples | Vector of samples

See Also
  QwtPlotSeriesItem::setData()

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.

Parameters

  data | Data

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

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

Set the symbol brush

Parameters

  direction | Direction type
  brush | Brush used to fill the body of all candlestick symbols with the direction

See Also
  symbolBrush(), setSymbolPen()

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

Parameters

  extent | Symbol width in scale coordinates

See Also
  symbolExtent(), scaledSymbolWidth(), setMinSymbolWidth(), setMaxSymbolWidth()

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.

Parameters

  color | Pen color
  width | Pen width
  style | Pen style

See Also
  pen(), brush()

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

See Also
  symbolPen(), setSymbolBrush()

void QwtPlotTradingCurve::setSymbolStyle | ( | SymbolStyle | style | ) |

Set the symbol style

Parameters

  style | Symbol style

See Also
  symbolStyle(), setSymbolExtent(), setSymbolPen(), setSymbolBrush()

QBrush QwtPlotTradingCurve::symbolBrush | ( | Direction | direction | ) | const

Parameters

  direction |

Returns
  Brush used to fill the body of all candlestick symbols with the direction

See Also
  setSymbolPen(), symbolBrush()

double QwtPlotTradingCurve::symbolExtent | ( |  | ) | const

Returns
  Extent of a symbol in scale coordinates

See Also
  setSymbolExtent(), scaledSymbolWidth(), minSymbolWidth(), maxSymbolWidth()

QPen QwtPlotTradingCurve::symbolPen | ( |  | ) | const

Returns
  Symbol pen

See Also
  setSymbolPen(), symbolBrush()

QwtPlotTradingCurve::SymbolStyle QwtPlotTradingCurve::symbolStyle | ( |  | ) | const

Returns
  Symbol style

See Also
  setSymbolStyle(), symbolExtent(), symbolPen(), symbolBrush()

bool QwtPlotTradingCurve::testPaintAttribute | ( | PaintAttribute | attribute | ) | const

Returns
  True, when attribute is enabled

See Also
  PaintAttribute, setPaintAttribute()