11use std:: error;
22
3- use crate :: sampler3d ;
3+ use crate :: { utils , widgets } ;
44
55/// Application result type.
66pub type AppResult < T > = std:: result:: Result < T , Box < dyn error:: Error > > ;
@@ -11,54 +11,53 @@ pub enum AppMode {
1111 MetaData ,
1212}
1313
14- #[ derive( Debug , Clone , Copy ) ]
15- pub enum ColorMode {
16- TrueColor ,
17- Ansi256 ,
18- Bw ,
19- }
20-
2114/// Application.
2215#[ derive( Debug ) ]
2316pub struct App {
2417 /// Is the application running?
2518 pub running : bool ,
2619
2720 pub file_path : String ,
28- pub image_sampler : sampler3d:: Sampler3D ,
29- pub image_cache : sampler3d:: ImageCache ,
21+ pub image_sampler : utils :: sampler3d:: Sampler3D ,
22+ pub image_cache : utils :: sampler3d:: ImageCache ,
3023 pub intensity_range : ( f32 , f32 ) ,
3124 pub slice_position : Vec < usize > ,
3225 pub increment : usize ,
3326 pub mode : AppMode ,
3427 pub color_map : colorous:: Gradient ,
35- pub color_mode : ColorMode ,
28+ pub color_mode : utils:: colors:: ColorMode ,
29+ pub metadata : widgets:: key_value_list_widget:: KeyValueList ,
30+ pub metadata_index : usize ,
3631}
3732
3833impl App {
3934 /// Constructs a new instance of [`App`].
40- pub fn new ( file_path : & str , color_mode : ColorMode ) -> Self {
35+ pub fn new ( file_path : & str , color_mode : utils :: colors :: ColorMode ) -> Self {
4136 println ! ( "Read nifti..." ) ;
42- let sampler = sampler3d:: Sampler3D :: from_nifti ( file_path) . unwrap ( ) ;
37+ let sampler = utils :: sampler3d:: Sampler3D :: from_nifti ( file_path) . unwrap ( ) ;
4338 let intensity_range = sampler. intensity_range ( ) ;
4439 let middle_slice = sampler. middle_slice ( ) ;
4540
4641 let increment = sampler. shape ( ) . iter ( ) . copied ( ) . sum :: < usize > ( ) / sampler. shape ( ) . len ( ) / 32 ;
4742
43+ let metadata = utils:: metadata:: make_metadata_key_value_list ( & sampler) ;
44+
4845 println ! ( " done!" ) ;
49- println ! ( "Image dimensions {:?}" , sampler. shape( ) ) ;
46+ // println!("Image dimensions {:?}", sampler.shape());
5047
5148 Self {
5249 running : true ,
5350 file_path : file_path. to_string ( ) ,
5451 image_sampler : sampler,
55- image_cache : sampler3d:: ImageCache :: new ( ) ,
52+ image_cache : utils :: sampler3d:: ImageCache :: new ( ) ,
5653 intensity_range : intensity_range,
5754 slice_position : middle_slice,
5855 increment : increment,
5956 mode : AppMode :: Xyz ,
6057 color_map : colorous:: INFERNO ,
6158 color_mode : color_mode,
59+ metadata : metadata,
60+ metadata_index : 0 ,
6261 }
6362 }
6463
0 commit comments