openslide/properties/
mod.rs1mod openslide;
5mod tiff;
6mod aperio;
7use std::collections::HashMap;
10
11use self::openslide::LevelProperties;
12
13#[derive(Clone, Debug)]
36pub struct Properties {
37 openslide_properties: openslide::OpenSlide,
38 tiff_properties: tiff::Tiff,
39 aperio_properties: aperio::Aperio,
40}
41
42impl Properties {
43
44 pub fn new(property_map: &HashMap<String, String>) -> Self {
50 let mut tiff_properties = tiff::Tiff::default();
51 let mut openslide_properties = openslide::OpenSlide::new(property_map);
54 let mut aperio_properties = aperio::Aperio::default();
55
56 for (key, value) in property_map {
57 let parent = key.split('.').nth(0);
58 match parent {
59 Some("openslide") => openslide_properties.parse_property_name(key, value),
60 Some("tiff") => tiff_properties.parse_property_name(key, value),
61 Some("aperio") => aperio_properties.parse_property_name(key, value),
62 _ => println!("Could not parse {}", key),
63 }
64 }
65
66 Properties {
67 tiff_properties: tiff_properties,
68 openslide_properties: openslide_properties,
69 aperio_properties: aperio_properties,
70 }
71 }
72
73 pub fn print_available(&self) {
77 self.openslide_properties.print_available();
78 self.tiff_properties.print_available();
79 self.aperio_properties.print_available();
80 }
81
82 pub fn vendor(&self) -> Option<String> {
86 self.openslide_properties.vendor.clone()
87 }
88
89 pub fn quickhash_1(&self) -> Option<String> {
91 self.openslide_properties.quickhash_1.clone()
92 }
93
94 pub fn mpp_x(&self) -> Option<f32> {
96 self.openslide_properties.mpp_x
98 }
99
100 pub fn mpp_y(&self) -> Option<f32> {
102 self.openslide_properties.mpp_y
104 }
105
106 pub fn objective_power(&self) -> Option<u32> {
108 self.openslide_properties.objective_power
109 }
110
111 pub fn comment(&self) -> Option<String> {
113 self.openslide_properties.comment.clone()
114 }
115
116 pub fn level_count(&self) -> Option<u32> {
118 self.openslide_properties.level_count
119 }
120
121 pub fn levels(&self) -> Option<Vec<LevelProperties>> {
126 self.openslide_properties.levels.clone()
127 }
128
129 pub fn image_description(&self) -> Option<String> {
132 self.tiff_properties.image_description.clone()
133 }
134
135 pub fn software(&self) -> Option<String> {
136 self.tiff_properties.software.clone()
137 }
138
139 pub fn model(&self) -> Option<String> {
141 self.tiff_properties.model.clone()
142 }
143
144 pub fn date_time(&self) -> Option<String> {
145 self.tiff_properties.date_time.clone()
146 }
147
148 pub fn make(&self) -> Option<String> {
149 self.tiff_properties.make.clone()
150 }
151
152 pub fn x_resolution(&self) -> Option<f32> {
154 self.tiff_properties.x_resolution
156 }
157
158 pub fn y_resolution(&self) -> Option<f32> {
160 self.tiff_properties.y_resolution
162 }
163
164 pub fn resolution_unit(&self) -> Option<String> {
168 self.tiff_properties.resolution_unit.clone()
169 }
170
171 pub fn filename(&self) -> Option<String> {
175 self.aperio_properties.filename.clone()
176 }
177
178 pub fn image_id(&self) -> Option<String> {
180 self.aperio_properties.image_id.clone()
181 }
182
183 pub fn scan_scope_id(&self) -> Option<String> {
185 self.aperio_properties.scan_scope_id.clone()
186 }
187
188 pub fn date(&self) -> Option<String> {
190 self.aperio_properties.date.clone()
192 }
193
194 pub fn time(&self) -> Option<String> {
196 self.aperio_properties.time.clone()
198 }
199
200 pub fn user(&self) -> Option<String> {
202 self.aperio_properties.user.clone()
203 }
204
205 pub fn icc_profile(&self) -> Option<String> {
207 self.aperio_properties.icc_profile.clone()
208 }
209
210 pub fn parmset(&self) -> Option<String> {
212 self.aperio_properties.parmset.clone()
213 }
214
215 pub fn original_height(&self) -> Option<u32> {
217 self.aperio_properties.original_height
218 }
219
220 pub fn original_width(&self) -> Option<u32> {
222 self.aperio_properties.original_height
223 }
224
225 pub fn top(&self) -> Option<f32> {
226 self.aperio_properties.top
227 }
228
229 pub fn left(&self) -> Option<f32> {
230 self.aperio_properties.left
231 }
232
233 pub fn mpp(&self) -> Option<f32> {
235 self.aperio_properties.mpp
236 }
237
238 pub fn line_camera_skew(&self) -> Option<f32> {
240 self.aperio_properties.line_camera_skew
241 }
242
243 pub fn line_area_x_offset(&self) -> Option<f32> {
245 self.aperio_properties.line_area_x_offset
246 }
247
248 pub fn line_area_y_offset(&self) -> Option<f32> {
250 self.aperio_properties.line_area_y_offset
251 }
252
253 pub fn focus_offset(&self) -> Option<f32> {
255 self.aperio_properties.focus_offset
256 }
257
258 pub fn app_mag(&self) -> Option<u32> {
259 self.aperio_properties.app_mag
260 }
261
262 pub fn stripe_width(&self) -> Option<u32> {
264 self.aperio_properties.stripe_width
265 }
266
267 pub fn filtered(&self) -> Option<u32> {
268 self.aperio_properties.filtered
269 }
270}