1use crate::{types::ViewImage, GeoFig};
2use rvimage_domain::{BbF, Canvas, Circle, TPtF};
3use std::default::Default;
4
5#[derive(Clone, Debug)]
6pub struct Stroke {
7 pub thickness: TPtF,
8 pub color: [u8; 3],
9}
10
11impl Stroke {
12 pub fn from_color(color: [u8; 3]) -> Self {
13 Stroke {
14 thickness: 2.0,
15 color,
16 }
17 }
18}
19
20#[derive(Clone, Debug)]
21pub struct BboxAnnotation {
22 pub geofig: GeoFig,
23 pub fill_color: Option<[u8; 3]>,
24 pub fill_alpha: u8,
25 pub outline: Stroke,
26 pub outline_alpha: u8,
27 pub label: Option<String>,
28 pub is_selected: Option<bool>,
29 pub highlight_circles: Vec<Circle>,
30}
31
32#[derive(Clone, Debug)]
33pub struct BrushAnnotation {
34 pub canvas: Canvas,
35 pub color: [u8; 3],
36 pub label: Option<String>,
37 pub is_selected: Option<bool>,
38 pub fill_alpha: u8,
39}
40
41#[derive(Clone, Debug)]
42pub enum Annotation {
43 Bbox(BboxAnnotation),
44 Brush(BrushAnnotation),
45}
46
47#[derive(Clone, Debug, Default)]
48pub enum Update<T> {
49 Yes(T),
50 #[default]
51 No,
52}
53
54pub type UpdateImage = Update<ViewImage>;
55pub type UpdatePermAnnos = Update<Vec<Annotation>>;
57pub type UpdateTmpAnno = Update<Annotation>;
59pub type UpdateZoomBox = Update<Option<BbF>>;
60
61impl UpdatePermAnnos {
62 pub fn clear() -> Self {
63 Self::Yes(vec![])
64 }
65}
66
67#[derive(Clone, Debug, Default)]
68pub struct ImageInfo {
69 pub filename: String,
70 pub shape_info: String,
71 pub pixel_value: String,
72 pub tool_info: String,
73}
74
75#[derive(Clone, Debug, Default)]
76pub struct UpdateView {
77 pub image: UpdateImage,
78 pub perm_annos: UpdatePermAnnos,
79 pub tmp_annos: UpdateTmpAnno,
80 pub zoom_box: UpdateZoomBox,
81 pub image_info: Option<ImageInfo>,
82
83 pub tmp_anno_buffer: Option<Annotation>,
85}
86
87impl UpdateView {
88 pub fn from_zoombox(zoom_box: Option<BbF>) -> Self {
89 UpdateView {
90 image: UpdateImage::No,
91 perm_annos: UpdatePermAnnos::No,
92 tmp_annos: UpdateTmpAnno::No,
93 zoom_box: UpdateZoomBox::Yes(zoom_box),
94 image_info: None,
95 tmp_anno_buffer: None,
96 }
97 }
98}