Horizon
Loading...
Searching...
No Matches
src
canvas
marker.hpp
1
#pragma once
2
#include "common/common.hpp"
3
#include "util/uuid.hpp"
4
#include "util/uuid_vec.hpp"
5
#include <deque>
6
#include <epoxy/gl.h>
7
8
namespace
horizon {
9
10
class
Marker
{
11
public
:
12
float
x;
13
float
y;
14
float
r;
15
float
g;
16
float
b;
17
uint8_t flags;
18
enum
Flags { F_SMALL = (1 << 0) };
19
20
Marker
(
const
Coordf
&p,
const
Color
&co, uint8_t f = 0) : x(p.x), y(p.y), r(co.r), g(co.g), b(co.b), flags(f)
21
{
22
}
23
} __attribute__((packed));
24
25
enum class
MarkerDomain { CHECK, SEARCH, N_DOMAINS };
26
27
class
MarkerRef
{
28
public
:
29
Coordf
position;
30
UUIDVec sheet;
31
Color
color;
32
std::string label;
33
bool
visible =
true
;
34
enum class
Size { DEFAULT, SMALL };
35
Size size = Size::DEFAULT;
36
MarkerRef
(
const
Coordf
&pos,
const
Color
&co,
const
UUIDVec &s = {},
const
std::string &la =
""
)
37
: position(pos), sheet(s), color(co), label(la)
38
{
39
}
40
};
41
42
class
Markers
{
43
friend
class
MarkerRenderer
;
44
45
public
:
46
Markers
(
class
CanvasGL
&c);
47
48
std::deque<MarkerRef> &get_domain(MarkerDomain dom);
49
void
set_domain_visible(MarkerDomain dom,
bool
vis);
50
void
update();
51
void
set_sheet_filter(
const
UUIDVec &uu);
52
std::vector<const MarkerRef *> get_markers_at_screen_pos(
int
x,
int
y)
const
;
53
54
private
:
55
bool
marker_is_visible(
const
MarkerRef
&mrk)
const
;
56
bool
hit_test_marker_ref(
const
MarkerRef
&ref,
const
Coordf
&p)
const
;
57
58
struct
Domain {
59
std::deque<MarkerRef> markers;
60
bool
visible =
false
;
61
};
62
std::array<Domain, static_cast<int>(MarkerDomain::N_DOMAINS)> domains;
63
UUIDVec sheet_filter;
64
CanvasGL
&ca;
65
};
66
67
class
MarkerRenderer
{
68
friend
class
CanvasGL
;
69
70
public
:
71
MarkerRenderer
(
const
class
CanvasGL
&c,
Markers
&ma);
72
void
realize();
73
void
render();
74
void
push();
75
void
update();
76
77
private
:
78
const
CanvasGL
&ca;
79
std::vector<Marker> markers;
80
Markers
&markers_ref;
81
82
GLuint program;
83
GLuint vao;
84
GLuint vbo;
85
86
GLuint screenmat_loc;
87
GLuint viewmat_loc;
88
GLuint scale_loc;
89
GLuint alpha_loc;
90
GLuint border_color_loc;
91
};
92
}
// namespace horizon
horizon::CanvasGL
Definition
canvas_gl.hpp:20
horizon::Color
Definition
common.hpp:278
horizon::Coord< float >
horizon::MarkerRef
Definition
marker.hpp:27
horizon::MarkerRenderer
Definition
marker.hpp:67
horizon::Marker
Definition
marker.hpp:10
horizon::Markers
Definition
marker.hpp:42
Generated by
1.9.8