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
109use crate::datatype::{Endianness, Signedness};
pub const WIDTH: u32 = 1366;
pub const HEIGHT: u32 = 1024;
#[derive(PartialEq)]
pub enum PixelStyle {
Grayscale,
Colorful,
Category,
Entropy,
GradientMagma,
GradientPlasma,
GradientViridis,
GradientRainbow,
GradientTurbo,
GradientCubehelix,
RGBA,
ABGR,
RGB,
BGR,
Datatype,
}
#[derive(Clone, PartialEq)]
pub enum GuiDatatype {
Integer8,
Integer16,
Integer32,
Integer64,
Float32,
Float64,
}
pub struct DatatypeSettings {
pub datatype: GuiDatatype,
pub signedness: Signedness,
pub endianness: Endianness,
}
pub struct Settings {
pub zoom: isize,
pub zoom_range: (isize, isize),
pub width: isize,
pub offset: isize,
pub offset_fine: isize,
pub stride: isize,
pub max_stride: isize,
pub pixel_style: PixelStyle,
pub datatype_settings: DatatypeSettings,
pub buffer_length: isize,
pub canvas_width: isize,
pub value_range: (f32, f32),
pub hex_view_visible: bool,
pub hex_view: String,
pub hex_ascii: String,
pub gui_wants_keyboard: bool,
pub gui_wants_mouse: bool,
}
impl Settings {
pub fn zoom_factor(&self) -> isize {
2isize.pow((self.zoom - 1) as u32)
}
pub fn max_offset_fine(&self) -> isize {
3 * self.width * self.stride
}
pub fn max_width(&self) -> isize {
2 * (WIDTH as isize)
}
}
impl Default for Settings {
fn default() -> Self {
Self {
zoom: 1,
zoom_range: (1, 7),
width: 1024,
offset: 0,
offset_fine: 0,
stride: 1,
max_stride: 128,
pixel_style: PixelStyle::Colorful,
datatype_settings: DatatypeSettings {
datatype: GuiDatatype::Integer16,
signedness: Signedness::Unsigned,
endianness: Endianness::Little,
},
buffer_length: 0,
canvas_width: WIDTH as isize,
value_range: (0.0, 100.0),
hex_view_visible: false,
hex_view: "".into(),
hex_ascii: "".into(),
gui_wants_keyboard: false,
gui_wants_mouse: false,
}
}
}