]> Creatis software - bbtk.git/blob - packages/demo/bbs/appli/SaveAsMhd.bbs
upgrade script
[bbtk.git] / packages / demo / bbs / appli / SaveAsMhd.bbs
1
2 description "Reads and image file / stack of image files, writes it as a MHD file"
3 author "jpr@creatis.insa-lyon.fr"
4 category "tool, read/write"
5
6 load vtk
7 include wxvtk
8 load std
9 load itk
10 include vtk
11 include wx
12 load itkvtk
13
14 new LayoutLine  main
15
16 # Use new box (choose the way you want to select images)
17 # -----------------------------------------------------
18 load creaImageIO
19 //new ImagesChooserDialogBox chooser
20 new ImagesChooserDialogBox reader
21
22 # Concatenate all the supposed-to-be consistent 2D images into a single vtkImageData
23 # WARNING : File names alphabetical order is suposed to be meaningful ...
24
25 //new ConcatImages reader
26 //   connect chooser.OutImages reader.In
27
28
29 new CommandButton cb1
30    set cb1.Label "1) Select File"
31    set cb1.WinDialog true
32    connect cb1.Widget main.Widget1
33  
34 connect cb1.BoxChange reader.BoxExecute
35
36 new SimpleSlicer slc
37    set slc.Orientation 2
38    set slc.SliderReactiveOnTrack 1   
39    connect reader.Out slc.In
40    // It doesn't work ?!?, needs to "exec slc" // JPR
41    connect reader.BoxChange slc.BoxExecute
42
43 exec slc
44
45 new CommandButton cb
46    connect cb.Widget main.Widget2
47    set cb.Label "2) Write (no '.mhd' extention needed!"
48    set cb.WinDialog true
49    
50 new CommandButton next
51    connect next.Widget main.Widget3
52    set next.Label "Next !"
53    set next.WinDialog true
54    // It doesn't work : <<the black box "main" is still connected">>
55    set next.In "delete main"
56
57 # Choose where you want to write
58 # ------------------------------
59 new FileSelector fileDialog
60   set fileDialog.OpenSave Save
61   set fileDialog.Wildcard "*.mhd"
62   
63 new  MakeFileName mfn
64    connect fileDialog.Out mfn.File
65    set mfn.Extent ".mhd"
66     
67 # Write!
68 # ------
69    
70 new MetaImageWriter writer
71   connect reader.Out writer.In 
72   connect mfn.Out writer.Filename
73   connect cb.BoxChange writer.BoxExecute
74    
75 exec main
76