]> Creatis software - bbtk.git/blob - packages/demo/bbs/appli/demoViewing1.bbs
801003b125bbafe50c8c3ad1de0ca92bd6881664
[bbtk.git] / packages / demo / bbs / appli / demoViewing1.bbs
1 description "3 slicers and a 3D view"
2 author "jpr@creatis.insa-lyon.fr"
3 category "demo"
4
5 // To show how easy it is to add smthing
6 // =====================================
7
8 load vtk
9 include wxvtk
10 load std
11 load itk
12 include vtk
13 include wx
14 load itkvtk
15 load gdcmvtk
16
17 include wxvtk/boxes/bbSimpleSlicer
18
19 new LayoutX4 main
20
21 new LayoutLine  upright
22 new LayoutLine  upleft
23 new LayoutLine  downleft
24 new LayoutSplit downright
25    set downright.Proportion 85
26
27 connect upright.Widget   main.Widget1
28 connect upleft.Widget    main.Widget2
29 connect downleft.Widget  main.Widget3
30 connect downright.Widget main.Widget4
31
32 # Here loads 'hola.mhd'
33 # ---------------------
34
35 # Don't forget to comment out the following 2 lines
36 # If you want to check someting else.
37
38 include vtk/boxes/bbLoadHola
39 new LoadHola reader
40
41 # uncomment next lines to have a file selector
42 # --------------------------------------------
43 /*
44 new FileSelector openFileDialog
45 new ImageReader reader
46   connect openFileDialog.Out reader.In
47 */
48
49 # uncomment next lines to use a vtkgdcmReader
50 # -------------------------------------
51 /*
52 new FileSelector openFileDialog
53 new GetInfoGdcmReader reader
54   connect openFileDialog.Out reader.In
55 */
56
57 # uncomment next lines to use Gimmick
58 # -----------------------------------
59 /*
60 load creaImageIO
61 new Gimmick reader
62 */
63
64 # uncomment next lines to Read a MHD file (and nothing else !)
65 # ------------------------------------------------------------
66 /*
67 new FileSelector openFileDialog
68  set openFileDialog.Wildcard  "(*.mhd)|*.mhd"
69 new MetaImageReader reader
70    connect openFileDialog.Out reader.In
71 */
72
73 # uncomment the following lines to read a 3D images stack
74 # (only if file name order is meaningfull)
75 # -------------------------------------------------------
76 /*
77 // To choose the directory
78 new DirectorySelector ds
79 // To get the image names into a vector
80 new FilesFromDirectory fd
81 // To read all the files, as a bbitk::ImagePointer
82 new ImageSeriesReader reader
83 // user choosen directory as input
84 connect ds.Out fd.In
85 set fd.Recursive false
86 // list of files as input
87 #print "Files found in $ds.Out$\n
88 connect fd.Out reader.FileNames
89 */
90
91 # uncomment the following lines to read a 3D images stack
92 # (if the directory contains a 'XCoherent" Serie)
93 # -------------------------------------------------------
94 /*
95 // To choose the directory
96 new DirectorySelector ds
97 // To get the image names into a vector
98 new FilesFromDirectory fd
99 // user choosen directory as input
100 connect ds.Out fd.In 
101 // order the files, computes an accurate ZSpacing
102 new GetXCoherentInfoGdcmReader reader
103 connect fd.Out reader.In
104 */
105
106 # uncomment the following lines to read a 3D images stack
107 # (with DICOMDirReader)
108 # -------------------------------------------------------
109 /*
110 include itk/boxes/bbDICOMDirReader
111 // To choose the directory
112 new DirectorySelector ds
113 new DICOMDirReader reader
114    connect ds.Out reader.In
115 */
116
117 // We need that to set Sliders sizes
118
119 #Get image dimensions, ...
120 new ImageProperties mc
121    connect reader.Out mc.In
122
123 #print "Image properties : $reader.Out"
124
125 #Get number of column (X)
126 new GetVectorIntElement gveX
127    connect mc.Size gveX.In
128    set gveX.I 0
129
130 #Get number of rows (Y)
131 new GetVectorIntElement gveY
132    connect mc.Size gveY.In
133    set gveY.I 1
134
135 #Get number of planes  (Z)
136 new GetVectorIntElement gveZ
137    connect mc.Size gveZ.In
138    set gveZ.I 2
139 //print "Dim Z $gveZ.Out"
140
141 #Compute the number of the 'middle' slice on X axis
142 new Div div0
143   connect   gveX.Out div0.In1
144   set div0.In2 2
145
146 #Compute the number of the 'middle' slice on Y axis
147 new Div div1
148   connect   gveY.Out div1.In1
149   set div1.In2 2
150
151 #Compute the number of the 'middle' slice on Z axis
152 new Div div2
153   connect   gveZ.Out div2.In1
154   set div2.In2 2
155
156 // For X axis
157 new SimpleSlicer viewerUL
158   connect reader.Out viewerUL.In
159   connect viewerUL.Widget upleft.Widget1
160   #initial slice is the middle one
161   connect div0.Out viewerUL.Slice
162   #Slider size is the number of planes
163   connect  gveX.Out viewerUL.SliderSize
164   set viewerUL.SliderReactiveOnTrack 1
165   set viewerUL.Orientation 0
166   set viewerUL.SliderOrientation H
167   set viewerUL.SliderTitle "Planes YZ"
168
169 // For Y axis
170 new SimpleSlicer viewerUR
171   connect reader.Out viewerUR.In
172   connect viewerUR.Widget upright.Widget1
173   #initial slice is the middle one
174   connect div1.Out viewerUR.Slice
175   #Slider size is the number of planes
176   connect  gveY.Out viewerUR.SliderSize
177   set viewerUR.SliderReactiveOnTrack 1
178   set viewerUR.SliderOrientation H
179   set viewerUR.Orientation 1
180   set viewerUR.SliderTitle "Planes XZ"
181
182 // For Z axis
183 new SimpleSlicer viewerTD
184   connect reader.Out viewerTD.In
185   connect viewerTD.Widget downleft.Widget1
186   #initial slice is the middle one
187   connect div2.Out viewerTD.Slice
188   #Slider size is the number of planes
189   connect  gveZ.Out viewerTD.SliderSize
190   set viewerTD.SliderReactiveOnTrack 1
191   set viewerTD.SliderOrientation H
192   set viewerTD.Orientation 2
193   set viewerTD.SliderTitle "Planes XY"
194
195 //For 3D Viewer
196
197 new ImagePlanes planes
198   connect reader.Out planes.In
199
200 new Viewer3D viewer
201   connect planes.PlaneX viewer.Obs1
202   connect planes.PlaneY viewer.Obs2
203   connect planes.PlaneZ viewer.Obs3
204
205 new CheckBox   chkbox
206   set chkbox.Title "Interpolate Pixels (in '2D' images)"
207   set chkbox.In 1
208   connect chkbox.BoxChange   viewerUL.BoxExecute
209   connect chkbox.BoxChange   viewerUR.BoxExecute
210   connect chkbox.BoxChange   viewerTD.BoxExecute
211
212   connect viewer.Widget downright.Widget1
213   connect chkbox.Widget downright.Widget2
214
215   connect chkbox.Out viewerUL.Interpolate
216   connect chkbox.Out viewerUR.Interpolate
217   connect chkbox.Out viewerTD.Interpolate
218
219 set main.WinTitle "demoViewing1"
220 exec main
221 exec viewerTD
222