-//description "Example of the box <a href=#Viewer2D>Viewer2D</a>."
-author "jpr@creatis.univ-lyon1.fr"
-category "tool, writer"
+
+description "Reads and image file / stack of image files, writes it as a MHD file"
+author "jpr@creatis.insa-lyon.fr"
+category "tool, read/write"
load vtk
include wxvtk
include vtk
include wx
load itkvtk
-load creaImageIO
+new LayoutLine main
+
+# Use new box (choose the way you want to select images)
+# -----------------------------------------------------
+load creaImageIO
+//new ImagesChooserDialogBox chooser
+new ImagesChooserDialogBox reader
+
+# Concatenate all the supposed-to-be consistent 2D images into a single vtkImageData
+# WARNING : File names alphabetical order is suposed to be meaningful ...
+
+//new ConcatImages reader
+// connect chooser.OutImages reader.In
+
+
+new CommandButton cb1
+ set cb1.Label "1) Select File"
+ set cb1.WinDialog true
+ connect cb1.Widget main.Widget1
+
+connect cb1.BoxChange reader.BoxExecute
+
+new SimpleSlicer slc
+ set slc.Orientation 2
+ set slc.SliderReactiveOnTrack 1
+ connect reader.Out slc.In
+ // It doesn't work ?!?, needs to "exec slc" // JPR
+ connect reader.BoxChange slc.BoxExecute
+
+exec slc
-new Gimmick reader
+new CommandButton cb
+ connect cb.Widget main.Widget2
+ set cb.Label "2) Write (no '.mhd' extention needed!"
+ set cb.WinDialog true
+
+new CommandButton next
+ connect next.Widget main.Widget3
+ set next.Label "Next !"
+ set next.WinDialog true
+ // It doesn't work : <<the black box "main" is still connected">>
+ set next.In "delete main"
-new FileSelector fs
- set fs.OpenSave "Save"
+# Choose where you want to write
+# ------------------------------
+new FileSelector fileDialog
+ set fileDialog.OpenSave Save
+ set fileDialog.Wildcard "*.mhd"
+new MakeFileName mfn
+ connect fileDialog.Out mfn.File
+ set mfn.Extent ".mhd"
+
+# Write!
+# ------
+
new MetaImageWriter writer
- connect reader.Out writer.In
- connect fs.Out writer.Filename
+ connect reader.Out writer.In
+ connect mfn.Out writer.Filename
+ connect cb.BoxChange writer.BoxExecute
+
+exec main
-exec reader
-exec writer