aboutsummaryrefslogtreecommitdiff
path: root/voronoisplat.h
blob: fb93f09affdef5fe734d3981381072b1da03b73b (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
#ifndef VORONOISPLAT_H
#define VORONOISPLAT_H

#include <QQuickFramebufferObject>

#include <armadillo>

#include "colorscale.h"

class VoronoiSplat
    : public QQuickFramebufferObject
{
    Q_OBJECT
public:
    VoronoiSplat(QQuickItem *parent = 0);

    Renderer *createRenderer() const;

    const std::vector<float> &sites() const    { return m_sites; }
    const std::vector<float> &values() const   { return m_values; }
    const std::vector<float> &colormap() const { return m_cmap; }

    bool sitesChanged() const    { return m_sitesChanged; }
    bool valuesChanged() const   { return m_valuesChanged; }
    bool colormapChanged() const { return m_colormapChanged; }

    void setSitesChanged(bool sitesChanged)       { m_sitesChanged = sitesChanged; }
    void setValuesChanged(bool valuesChanged)     { m_valuesChanged = valuesChanged; }
    void setColormapChanged(bool colormapChanged) { m_colormapChanged = colormapChanged; }

signals:
    void sitesChanged(const arma::mat &sites);
    void valuesChanged(const arma::vec &values);
    void colormapChanged(const ColorScale *scale);

public slots:
    // 'points' should be a 2D points matrix (each point in a row)
    void setSites(const arma::mat &points);

    // Set the value to be colormapped in each site
    void setValues(const arma::vec &values);

    // Set colormap data based on the given color scale
    void setColormap(const ColorScale *scale);

private:
    std::vector<float> m_sites, m_values, m_cmap;
    bool m_sitesChanged, m_valuesChanged, m_colormapChanged;
};

#endif // VORONOISPLAT_H