aboutsummaryrefslogtreecommitdiff
path: root/scatterplot.h
blob: a155daf6717eb26bb5f4e89650984eb20d603679 (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
43
44
45
46
47
48
49
50
51
52
#ifndef SCATTERPLOT_H
#define SCATTERPLOT_H

#include <armadillo>
#include <QtQuick>

#include "colorscale.h"

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

signals:
    void dataChanged(const arma::mat &data);

public slots:
    void setData(const arma::mat &data);

protected:
    QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *);
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);

private:
    QSGNode *newGlyphNodeTree();
    bool selectGlyphs(bool mergeSelection);
    void updateData();

    float fromDataXToScreenX(float x);
    float fromDataYToScreenY(float y);

    arma::mat m_data;
    float m_xmin, m_xmax, m_ymin, m_ymax;

    ColorScale m_colorScale;

    enum InteractionState {
        INTERACTION_NONE,
        INTERACTION_SELECTING,
        INTERACTION_SELECTED,
        INTERACTION_MOVING
    } m_currentState;
    QPointF m_dragOriginPos, m_dragCurrentPos;

    QSet<int> m_selectedGlyphs;
};

#endif // SCATTERPLOT_H