-
Notifications
You must be signed in to change notification settings - Fork 1
/
geom.rs
148 lines (132 loc) · 3.32 KB
/
geom.rs
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
use bevy::prelude::Component;
use serde::{Deserialize, Serialize};
/// When in a Entity with `Aesthetics`, it will plot whatever aes to
/// the arrows in the map.
#[derive(Component)]
pub struct GeomArrow {
pub plotted: bool,
}
/// Side of the arrow a plot (box point, histogram or legend) is referring to.
#[derive(Hash, PartialEq, Eq, Debug, Clone, Deserialize, Serialize, Default, Component)]
pub enum Side {
Left,
#[default]
Right,
/// for hovering instances
Up,
}
#[derive(Debug, Clone)]
pub enum HistPlot {
Hist,
Kde,
// Point estimate.
BoxPoint,
}
/// When in a Entity with `Aesthetics`, it will plot whatever aes to
/// a histogram/KDE/box on the side of the arrows in the map.
#[derive(Component, Clone, Debug)]
pub struct GeomHist {
pub side: Side,
pub rendered: bool,
pub mean: Option<f32>,
pub in_axis: bool,
pub plot: HistPlot,
}
impl GeomHist {
pub fn left(plot: HistPlot) -> Self {
Self {
side: Side::Left,
rendered: false,
in_axis: false,
mean: None,
plot,
}
}
pub fn right(plot: HistPlot) -> Self {
Self {
side: Side::Right,
rendered: false,
mean: None,
in_axis: false,
plot,
}
}
pub fn up(plot: HistPlot) -> Self {
Self {
side: Side::Up,
rendered: false,
in_axis: false,
mean: None,
plot,
}
}
}
/// When in a Entity with `Aesthetics`, it will plot whatever aes to
/// the circles in the map.
#[derive(Component)]
pub struct GeomMetabolite {
pub plotted: bool,
}
/// Component applied to all Hist-like entities (spawned by a GeomKde, GeomHist, etc. aesthetic)
/// This allow us to query for systems like normalize or drag.
#[derive(Component)]
pub struct HistTag {
pub side: Side,
pub node_id: u64,
pub follow_scale: bool,
}
#[derive(Component)]
pub struct VisCondition {
pub condition: Option<String>,
}
/// Component that indicates the plot position and axis.
#[derive(Debug, Component)]
pub struct Xaxis {
pub id: String,
pub arrow_size: f32,
pub xlimits: (f32, f32),
pub side: Side,
pub plot: HistPlot,
pub node_id: u64,
pub conditions: Vec<String>,
}
/// Component that marks something susceptible of being dragged/rotated.
#[derive(Debug, Component, Default)]
pub struct Drag {
pub dragged: bool,
pub rotating: bool,
pub scaling: bool,
}
impl std::fmt::Display for Side {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match self {
Side::Right => "right",
Side::Left => "left",
Side::Up => "up",
}
)
}
}
impl std::fmt::Display for Xaxis {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Xaxis = [ id = {}, side = {} ]", self.id, self.side)
}
}
/// Component of all popups.
#[derive(Component)]
pub struct PopUp;
/// Component of all popups.
#[derive(Component, Debug)]
pub struct AnyTag {
pub id: u64,
}
/// Mark aesthetics as pertaining to mets.
/// Used to filter removal queries.
#[derive(Component, Clone)]
pub struct AesFilter {
pub met: bool,
pub pbox: bool,
}