From 7676a38ea8a06d3d31228cb7eb1be00f90de46d3 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Thu, 7 Jan 2016 15:10:20 +0100 Subject: Added a bar chart. * HistoryGraph replaced by BarChart * HistoryGraph not removed from code, might be useful in the future --- barchart.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 barchart.h (limited to 'barchart.h') diff --git a/barchart.h b/barchart.h new file mode 100644 index 0000000..ccbb13e --- /dev/null +++ b/barchart.h @@ -0,0 +1,34 @@ +#ifndef BARCHART_H +#define BARCHART_H + +#include +#include + +class BarChart : public QQuickItem +{ + Q_OBJECT +public: + BarChart(QQuickItem *parent = 0); + ~BarChart(); + +signals: + void valuesChanged(const arma::vec &values); + +public slots: + void setValues(const arma::vec &values); + +protected: + QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *); + void hoverMoveEvent(QHoverEvent *event); + void mousePressEvent(QMouseEvent *event); + +private: + QSGNode *newBarNode(); + void updateBarNodeGeom(QSGNode *barNode, float x, float width, float height); + void updateBars(QSGNode *root); + + arma::vec m_values; + bool m_shouldUpdateBars; +}; + +#endif // BARCHART_H -- cgit v1.2.3