QwtPlotTradingCurve illustrates movements in the price of a financial instrument over time. More...
#include <qwt_plot_tradingcurve.h>
Classes | |
class | PrivateData |
Public Member Functions | |
virtual QRectF | boundingRect () const |
virtual void | drawSeries (QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const |
virtual QwtGraphic | legendIcon (int index, const QSizeF &) const |
double | maxSymbolWidth () const |
double | minSymbolWidth () const |
QwtPlotTradingCurve (const QString &title=QString()) | |
QwtPlotTradingCurve (const QwtText &title) | |
virtual int | rtti () const |
void | setMaxSymbolWidth (double) |
void | setMinSymbolWidth (double) |
void | setPaintAttribute (PaintAttribute, bool on=true) |
void | setSamples (const QVector< QwtOHLCSample > &) |
void | setSamples (QwtSeriesData< QwtOHLCSample > *) |
void | setSymbolBrush (Direction, const QBrush &) |
void | setSymbolExtent (double width) |
Set the extent of the symbol. More... | |
void | setSymbolPen (const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine) |
void | setSymbolPen (const QPen &) |
Set the symbol pen. More... | |
void | setSymbolStyle (SymbolStyle style) |
QBrush | symbolBrush (Direction) const |
double | symbolExtent () const |
QPen | symbolPen () const |
SymbolStyle | symbolStyle () const |
bool | testPaintAttribute (PaintAttribute) const |
virtual | ~QwtPlotTradingCurve () |
Destructor. More... | |
Public Member Functions inherited from QwtPlotSeriesItem | |
virtual void | draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &) const |
Draw the complete series. More... | |
Qt::Orientation | orientation () const |
QwtPlotSeriesItem (const QString &title=QString()) | |
QwtPlotSeriesItem (const QwtText &title) | |
void | setOrientation (Qt::Orientation) |
virtual void | updateScaleDiv (const QwtScaleDiv &, const QwtScaleDiv &) |
Update the item to changes of the axes scale division. More... | |
virtual | ~QwtPlotSeriesItem () |
Destructor. More... | |
Public Member Functions inherited from 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... | |
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... | |
void | hide () |
Hide the item. More... | |
bool | isVisible () const |
virtual void | itemChanged () |
virtual void | legendChanged () |
virtual QList< QwtLegendData > | legendData () const |
Return all information, that is needed to represent the item on the legend. More... | |
QSize | legendIconSize () const |
QRectF | paintRect (const QwtScaleMap &, const QwtScaleMap &) const |
Calculate the bounding paint rectangle of 2 maps. More... | |
QwtPlot * | plot () const |
Return attached plot. More... | |
QwtPlotItem (const QwtText &title=QwtText()) | |
uint | renderThreadCount () const |
QRectF | scaleRect (const QwtScaleMap &, const QwtScaleMap &) const |
Calculate the bounding scale rectangle of 2 maps. More... | |
void | setAxes (int xAxis, int yAxis) |
void | setItemAttribute (ItemAttribute, bool on=true) |
void | setItemInterest (ItemInterest, bool on=true) |
void | setLegendIconSize (const QSize &) |
void | setRenderHint (RenderHint, bool on=true) |
void | setRenderThreadCount (uint numThreads) |
void | setTitle (const QString &title) |
void | setTitle (const QwtText &title) |
virtual void | setVisible (bool) |
void | setXAxis (int axis) |
void | setYAxis (int axis) |
void | setZ (double z) |
Set the z value. More... | |
void | show () |
Show the item. More... | |
bool | testItemAttribute (ItemAttribute) const |
bool | testItemInterest (ItemInterest) const |
bool | testRenderHint (RenderHint) const |
const QwtText & | title () const |
virtual void | updateLegend (const QwtPlotItem *, const QList< QwtLegendData > &) |
Update the item to changes of the legend info. More... | |
int | xAxis () const |
Return xAxis. More... | |
int | yAxis () const |
Return yAxis. More... | |
double | z () const |
virtual | ~QwtPlotItem () |
Destroy the QwtPlotItem. More... | |
Public Member Functions inherited from QwtSeriesStore< QwtOHLCSample > | |
QwtSeriesData< QwtOHLCSample > * | data () |
const QwtSeriesData< QwtOHLCSample > * | data () const |
virtual QRectF | dataRect () const |
virtual size_t | dataSize () const |
QwtSeriesStore () | |
Constructor The store contains no series. More... | |
QwtOHLCSample | sample (int index) const |
void | setData (QwtSeriesData< QwtOHLCSample > *series) |
virtual void | setRectOfInterest (const QRectF &rect) |
QwtSeriesData< QwtOHLCSample > * | swapData (QwtSeriesData< QwtOHLCSample > *series) |
~QwtSeriesStore () | |
Destructor. More... | |
Protected Member Functions | |
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 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 | init () |
Initialize internal members. 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. More... | |
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. More... | |
Private Attributes | |
PrivateData * | d_data |
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.
Definition at line 38 of file qwt_plot_tradingcurve.h.
typedef QFlags<PaintAttribute> QwtPlotTradingCurve::PaintAttributes |
Paint attributes.
Definition at line 102 of file qwt_plot_tradingcurve.h.
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. |
Definition at line 82 of file qwt_plot_tradingcurve.h.
Attributes to modify the drawing algorithm.
Enumerator | |
---|---|
ClipSymbols |
Check if a symbol is on the plot canvas before painting it. |
Definition at line 95 of file qwt_plot_tradingcurve.h.
Symbol styles.
The default setting is QwtPlotSeriesItem::CandleStick.
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.
|
Definition at line 48 of file qwt_plot_tradingcurve.h.
|
explicit |
Constructor
title | Title of the curve |
Definition at line 67 of file qwt_plot_tradingcurve.cpp.
|
explicit |
Constructor
title | Title of the curve |
Definition at line 57 of file qwt_plot_tradingcurve.cpp.
|
virtual |
Destructor.
Definition at line 74 of file qwt_plot_tradingcurve.cpp.
|
virtual |
Reimplemented from QwtPlotSeriesItem.
Definition at line 353 of file qwt_plot_tradingcurve.cpp.
|
protected |
Draw a bar.
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 |
Definition at line 550 of file qwt_plot_tradingcurve.cpp.
|
protected |
Draw a candle stick.
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 |
Definition at line 589 of file qwt_plot_tradingcurve.cpp.
|
virtual |
Draw an interval of the curve
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. |
Implements QwtPlotSeriesItem.
Definition at line 375 of file qwt_plot_tradingcurve.cpp.
|
protectedvirtual |
Draw symbols
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 |
Definition at line 408 of file qwt_plot_tradingcurve.cpp.
|
protectedvirtual |
Draw a symbol for a symbol style >= UserSymbol.
The implementation does nothing and is intended to be overloaded
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 |
Definition at line 522 of file qwt_plot_tradingcurve.cpp.
|
protected |
Initialize internal members.
Definition at line 80 of file qwt_plot_tradingcurve.cpp.
|
virtual |
index | Index of the legend entry ( usually there is only one ) |
size | Icon size |
Reimplemented from QwtPlotItem.
Definition at line 630 of file qwt_plot_tradingcurve.cpp.
double QwtPlotTradingCurve::maxSymbolWidth | ( | ) | const |
Definition at line 344 of file qwt_plot_tradingcurve.cpp.
double QwtPlotTradingCurve::minSymbolWidth | ( | ) | const |
Definition at line 316 of file qwt_plot_tradingcurve.cpp.
|
virtual |
Reimplemented from QwtPlotItem.
Definition at line 92 of file qwt_plot_tradingcurve.cpp.
|
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.
xMap | Maps x-values into pixel coordinates. |
yMap | Maps y-values into pixel coordinates. |
canvasRect | Contents rectangle of the canvas |
Definition at line 652 of file qwt_plot_tradingcurve.cpp.
void QwtPlotTradingCurve::setMaxSymbolWidth | ( | double | width | ) |
Set a maximum for the symbol width
A value <= 0.0 means an unlimited width
width | Width in paint device coordinates |
Definition at line 329 of file qwt_plot_tradingcurve.cpp.
void QwtPlotTradingCurve::setMinSymbolWidth | ( | double | width | ) |
Set a minimum for the symbol width
width | Width in paint device coordinates |
Definition at line 300 of file qwt_plot_tradingcurve.cpp.
void QwtPlotTradingCurve::setPaintAttribute | ( | PaintAttribute | attribute, |
bool | on = true |
||
) |
Specify an attribute how to draw the curve
attribute | Paint attribute |
on | On/Off |
Definition at line 104 of file qwt_plot_tradingcurve.cpp.
void QwtPlotTradingCurve::setSamples | ( | const QVector< QwtOHLCSample > & | samples | ) |
Initialize data with an array of samples.
samples | Vector of samples |
Definition at line 129 of file qwt_plot_tradingcurve.cpp.
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.
data | Data |
Definition at line 145 of file qwt_plot_tradingcurve.cpp.
void QwtPlotTradingCurve::setSymbolBrush | ( | Direction | direction, |
const QBrush & | brush | ||
) |
Set the symbol brush
direction | Direction type |
brush | Brush used to fill the body of all candlestick symbols with the direction |
Definition at line 235 of file qwt_plot_tradingcurve.cpp.
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()
extent | Symbol width in scale coordinates |
Definition at line 272 of file qwt_plot_tradingcurve.cpp.
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.
color | Pen color |
width | Pen width |
style | Pen style |
Definition at line 192 of file qwt_plot_tradingcurve.cpp.
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
Definition at line 206 of file qwt_plot_tradingcurve.cpp.
void QwtPlotTradingCurve::setSymbolStyle | ( | SymbolStyle | style | ) |
Set the symbol style
style | Symbol style |
Definition at line 159 of file qwt_plot_tradingcurve.cpp.
QBrush QwtPlotTradingCurve::symbolBrush | ( | Direction | direction | ) | const |
direction |
Definition at line 254 of file qwt_plot_tradingcurve.cpp.
double QwtPlotTradingCurve::symbolExtent | ( | ) | const |
Definition at line 289 of file qwt_plot_tradingcurve.cpp.
QPen QwtPlotTradingCurve::symbolPen | ( | ) | const |
Definition at line 221 of file qwt_plot_tradingcurve.cpp.
QwtPlotTradingCurve::SymbolStyle QwtPlotTradingCurve::symbolStyle | ( | ) | const |
Definition at line 174 of file qwt_plot_tradingcurve.cpp.
bool QwtPlotTradingCurve::testPaintAttribute | ( | PaintAttribute | attribute | ) | const |
Definition at line 117 of file qwt_plot_tradingcurve.cpp.
|
private |
Definition at line 168 of file qwt_plot_tradingcurve.h.