26 #ifndef QCP_PLOTTABLE_FINANCIAL_H
27 #define QCP_PLOTTABLE_FINANCIAL_H
29 #include "../global.h"
31 #include "../plottable.h"
32 #include "../painter.h"
41 QCPFinancialData(
double key,
double open,
double high,
double low,
double close);
42 double key, open, high, low, close;
54 typedef QMapIterator<double, QCPFinancialData> QCPFinancialDataMapIterator;
55 typedef QMutableMapIterator<double, QCPFinancialData> QCPFinancialDataMutableMapIterator;
62 Q_PROPERTY(
ChartStyle chartStyle READ chartStyle WRITE setChartStyle)
63 Q_PROPERTY(
double width READ width WRITE setWidth)
64 Q_PROPERTY(
bool twoColored READ twoColored WRITE setTwoColored)
65 Q_PROPERTY(QBrush brushPositive READ brushPositive WRITE setBrushPositive)
66 Q_PROPERTY(QBrush brushNegative READ brushNegative WRITE setBrushNegative)
67 Q_PROPERTY(QPen penPositive READ penPositive WRITE setPenPositive)
68 Q_PROPERTY(QPen penNegative READ penNegative WRITE setPenNegative)
86 ChartStyle chartStyle()
const {
return mChartStyle; }
87 double width()
const {
return mWidth; }
88 bool twoColored()
const {
return mTwoColored; }
89 QBrush brushPositive()
const {
return mBrushPositive; }
90 QBrush brushNegative()
const {
return mBrushNegative; }
91 QPen penPositive()
const {
return mPenPositive; }
92 QPen penNegative()
const {
return mPenNegative; }
97 void setData(
const QVector<double> &key,
const QVector<double> &open,
const QVector<double> &high,
const QVector<double> &low,
const QVector<double> &close);
98 void setChartStyle(ChartStyle style);
99 void setWidth(
double width);
100 void setTwoColored(
bool twoColored);
101 void setBrushPositive(
const QBrush &brush);
102 void setBrushNegative(
const QBrush &brush);
103 void setPenPositive(
const QPen &pen);
104 void setPenNegative(
const QPen &pen);
109 void addData(
double key,
double open,
double high,
double low,
double close);
110 void addData(
const QVector<double> &key,
const QVector<double> &open,
const QVector<double> &high,
const QVector<double> &low,
const QVector<double> &close);
111 void removeDataBefore(
double key);
112 void removeDataAfter(
double key);
113 void removeData(
double fromKey,
double toKey);
114 void removeData(
double key);
118 virtual double selectTest(
const QPointF &pos,
bool onlySelectable, QVariant *details=0)
const;
121 static QCPFinancialDataMap timeSeriesToOhlc(
const QVector<double> &time,
const QVector<double> &value,
double timeBinSize,
double timeBinOffset = 0);
126 ChartStyle mChartStyle;
129 QBrush mBrushPositive, mBrushNegative;
130 QPen mPenPositive, mPenNegative;
139 void drawOhlcPlot(
QCPPainter *painter,
const QCPFinancialDataMap::const_iterator &begin,
const QCPFinancialDataMap::const_iterator &end);
140 void drawCandlestickPlot(
QCPPainter *painter,
const QCPFinancialDataMap::const_iterator &begin,
const QCPFinancialDataMap::const_iterator &end);
141 double ohlcSelectTest(
const QPointF &pos,
const QCPFinancialDataMap::const_iterator &begin,
const QCPFinancialDataMap::const_iterator &end)
const;
142 double candlestickSelectTest(
const QPointF &pos,
const QCPFinancialDataMap::const_iterator &begin,
const QCPFinancialDataMap::const_iterator &end)
const;
143 void getVisibleDataBounds(QCPFinancialDataMap::const_iterator &lower, QCPFinancialDataMap::const_iterator &upper)
const;
149 #endif // QCP_PLOTTABLE_FINANCIAL_H