aboutsummaryrefslogtreecommitdiff
path: root/colormap.h
blob: 7d26a86631ff5c259a0032ec56844f57eb4652f2 (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
#ifndef COLORMAP_H
#define COLORMAP_H

#include <memory>
#include <vector>

#include <armadillo>
#include <glad/gl.h>
#include <nod.hpp>

#include "colorscale.h"

class Colormap
{
public:
    static const int SAMPLES = 128;

    enum Orientation {
        Horizontal,
        Vertical
    };

    Colormap();
    ~Colormap();

    GLuint texture() const { return m_texture; }
    size_t width() const { return m_width; }
    size_t height() const { return m_height; }

    void update();
    void setOrientation(Orientation orientation);
    Orientation orientation() const { return m_orientation; }

    nod::signal<void(std::shared_ptr<const ColorScale>)> colorScaleChanged;
    nod::signal<void(Orientation)> orientationChanged;

    void setColorScale(std::shared_ptr<const ColorScale> scale);

private:
    void updateTexture();

    size_t m_width, m_height;
    GLuint m_texture;
    bool m_shouldUpdateTexture;
    Orientation m_orientation;
    std::vector<float> m_cmap;
};

#endif // COLORMAP_H