aboutsummaryrefslogtreecommitdiff
path: root/historygraph.h
blob: 6c5bd9a7458af41dfc89a8733d7a8ed04d353efe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef HISTORYGRAPH_H
#define HISTORYGRAPH_H

#include <QtQuick>
#include <QMatrix4x4>
#include <armadillo>

class HistoryGraph : public QQuickItem
{
    Q_OBJECT
public:
    HistoryGraph(QQuickItem *parent = 0);
    ~HistoryGraph();

signals:
    void currentItemChanged(const arma::mat &item);

public slots:
    void addHistoryItem(const arma::mat &item);

protected:
    QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *);
    void hoverMoveEvent(QHoverEvent *event);
    void mousePressEvent(QMouseEvent *event);

private:
    class HistoryItemNode;

    HistoryItemNode *nodeAt(const QPointF &pos) const;
    HistoryItemNode *nodeAt(const QPointF &pos, HistoryItemNode *node) const;

    QSGNode *createNodeTree();
    void updateNodeTree(QSGNode *root);
    void addScatterplot(QSGNode *node, const HistoryItemNode *historyItemNode, float x, float y, float w, float h);

    HistoryItemNode *m_firstNode, *m_currentNode;
    QMatrix4x4 m_viewportTransform;
    float m_currentWidth;
    bool m_needsUpdate;
};

#endif // HISTORYGRAPH_H