1use std::{f32, u32};
5use num::Num;
6
7#[derive(Clone, Debug, Default)]
8pub struct Aperio {
9 pub filename: Option<String>,
10 pub image_id: Option<String>,
11 pub scan_scope_id: Option<String>,
12 pub date: Option<String>,
13 pub time: Option<String>,
14 pub user: Option<String>,
15 pub icc_profile: Option<String>,
16 pub parmset: Option<String>,
17 pub original_height: Option<u32>,
18 pub original_width: Option<u32>,
19 pub top: Option<f32>,
20 pub left: Option<f32>,
21 pub mpp: Option<f32>,
22 pub line_camera_skew: Option<f32>,
23 pub line_area_x_offset: Option<f32>,
24 pub line_area_y_offset: Option<f32>,
25 pub focus_offset: Option<f32>,
26 pub app_mag: Option<u32>,
27 pub stripe_width: Option<u32>,
28 pub filtered: Option<u32>,
29}
30
31impl Aperio {
32 pub fn parse_property_name(&mut self, name: &str, value: &str) {
33 match name {
34 "aperio.Filename" => self.filename = Some(String::from(value)),
35 "aperio.ImageID" => self.image_id = Some(String::from(value)),
36 "aperio.ScanScope ID" => self.scan_scope_id = Some(String::from(value)),
37 "aperio.Date" => self.date = Some(String::from(value)),
38 "aperio.Time" => self.time = Some(String::from(value)),
39 "aperio.User" => self.user = Some(String::from(value)),
40 "aperio.ICC Profile" => self.icc_profile = Some(String::from(value)),
41 "aperio.Parmset" => self.parmset = Some(String::from(value)),
42 "aperio.Originalheight" => self.original_height = Some(u32::from_str_radix(value, 10).unwrap()),
43 "aperio.OriginalWidth" => self.original_width = Some(u32::from_str_radix(value, 10).unwrap()),
44 "aperio.Top" => self.top = Some(f32::from_str_radix(value, 10).unwrap()),
45 "aperio.Left" => self.left = Some(f32::from_str_radix(value, 10).unwrap()),
46 "aperio.MPP" => self.mpp = Some(f32::from_str_radix(value, 10).unwrap()),
47 "aperio.LineCameraSkew" => self.line_camera_skew = Some(f32::from_str_radix(value, 10).unwrap()),
48 "aperio.LineAreaXOffset" => self.line_area_x_offset = Some(f32::from_str_radix(value, 10).unwrap()),
49 "aperio.LineAreaYOffset" => self.line_area_y_offset = Some(f32::from_str_radix(value, 10).unwrap()),
50 "aperio.Focus Offset" => self.focus_offset = Some(f32::from_str_radix(value, 10).unwrap()),
51 "aperio.AppMag" => self.app_mag = Some(u32::from_str_radix(value, 10).unwrap()),
52 "aperio.StripeWidth" => self.stripe_width = Some(u32::from_str_radix(value, 10).unwrap()),
53 "aperio.Filtered" => self.filtered = Some(u32::from_str_radix(value, 10).unwrap()),
54 _ => println!("Could not parse property name {} and value {}", name, value),
55 }
56 }
57
58 pub fn print_available(&self) {
60 match self.filename {
61 Some(ref val) => println!("Filename: {}", val),
62 None => {},
63 }
64 match self.image_id {
65 Some(ref val) => println!("Image ID: {}", val),
66 None => {},
67 }
68 match self.scan_scope_id {
69 Some(ref val) => println!("ScanScope ID: {}", val),
70 None => {},
71 }
72 match self.date {
73 Some(ref val) => println!("Date: {}", val),
74 None => {},
75 }
76 match self.time {
77 Some(ref val) => println!("Time: {}", val),
78 None => {},
79 }
80 match self.user {
81 Some(ref val) => println!("User: {}", val),
82 None => {},
83 }
84 match self.icc_profile {
85 Some(ref val) => println!("ICC Profile: {}", val),
86 None => {},
87 }
88 match self.parmset {
89 Some(ref val) => println!("Parmset: {}", val),
90 None => {},
91 }
92 match self.original_height {
93 Some(ref val) => println!("Original height: {}", val),
94 None => {},
95 }
96 match self.original_width {
97 Some(ref val) => println!("Original width: {}", val),
98 None => {},
99 }
100 match self.top {
101 Some(ref val) => println!("Top: {}", val),
102 None => {},
103 }
104 match self.left {
105 Some(ref val) => println!("Left: {}", val),
106 None => {},
107 }
108 match self.mpp {
109 Some(ref val) => println!("Microns per pixel: {}", val),
110 None => {},
111 }
112 match self.line_camera_skew {
113 Some(ref val) => println!("Line camera skew: {}", val),
114 None => {},
115 }
116 match self.line_area_x_offset {
117 Some(ref val) => println!("Line area x offset: {}", val),
118 None => {},
119 }
120 match self.line_area_y_offset {
121 Some(ref val) => println!("Line area y offset: {}", val),
122 None => {},
123 }
124 match self.focus_offset {
125 Some(ref val) => println!("Focus offset: {}", val),
126 None => {},
127 }
128 match self.app_mag {
129 Some(ref val) => println!("AppMag: {}", val),
130 None => {},
131 }
132 match self.stripe_width {
133 Some(ref val) => println!("Stripe width: {}", val),
134 None => {},
135 }
136 match self.filtered {
137 Some(ref val) => println!("Filtered: {}", val),
138 None => {},
139 }
140 }
141
142}