aboutsummaryrefslogtreecommitdiff
path: root/voronoisplat.h
blob: 21d2fb921f3cc01785c1e30749b22c487ef7278e (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef VORONOISPLAT_H
#define VORONOISPLAT_H

#include <QQuickFramebufferObject>

#include <armadillo>

#include "colorscale.h"
#include "scale.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> &colorScale() const { return m_cmap; }
    LinearScale<float> scaleX() const            { return m_sx; }
    LinearScale<float> scaleY() const            { return m_sy; }
    Q_INVOKABLE float alpha() const              { return m_alpha; }
    Q_INVOKABLE float beta() const               { return m_beta; }

    bool sitesChanged() const      { return m_sitesChanged; }
    bool valuesChanged() const     { return m_valuesChanged; }
    bool colorScaleChanged() const { return m_colorScaleChanged; }

    void setSitesChanged(bool sitesChanged) {
        m_sitesChanged = sitesChanged;
    }
    void setValuesChanged(bool valuesChanged) {
        m_valuesChanged = valuesChanged;
    }
    void setColorScaleChanged(bool colorScaleChanged) {
        m_colorScaleChanged = colorScaleChanged;
    }

signals:
    void sitesChanged(const arma::mat &sites) const;
    void valuesChanged(const arma::vec &values) const;
    void colorScaleChanged(const ColorScale &scale) const;
    void scaleChanged(const LinearScale<float> &sx, const LinearScale<float> &sy) const;
    void alphaChanged(float alpha) const;
    void betaChanged(float alpha) const;

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 colorScaleped in each site
    void setValues(const arma::vec &values);

    // Set colorScale data based on the given color scale
    void setColorScale(const ColorScale &scale);

    void setScale(const LinearScale<float> &sx, const LinearScale<float> &sy);

    // Shepard blur radius
    Q_INVOKABLE void setAlpha(float alpha);

    // Maximum blur radius
    Q_INVOKABLE void setBeta(float beta);

private:
    std::vector<float> m_sites, m_values, m_cmap;
    LinearScale<float> m_sx, m_sy;
    float m_alpha, m_beta;
    bool m_sitesChanged, m_valuesChanged, m_colorScaleChanged;
};

#endif // VORONOISPLAT_H