#!/local/pkg/tk4.0/wish -f # ^^^^^^^^^^^^^^^^^^^^^ Give the path to "wish". # Tcl/Tk must be installed for this script to work! "wish", which this # script uses, is part of Tk 4.0 (and higher?). # # If you do not have Tcl/Tk installed, you can probably find what you need # from the web site http://web.cs.ualberta.ca/~wade/Auto/Tcl.html # (or try using a Web search engine and look for tcl/tk). # # Usage: sniff root wait zoom norm decades color [1|2] # # root: root of data file name # wait: delay between loads in seconds # zoom: zoom factor (must be an integer) # norm: normalization # decades: # decades # color: 1 for grayscale, 2 for color # if color is selected, the last argument selects one or two-sided color # if {[llength $argv] < 6} { puts stderr "Usage: $argv0 root wait zoom norm decades color \[1\|2\]" destroy . exit } # Set PATH appropriate for the rw2pnm1 routine which converts raw files # to ppm or pnm files. set PATH "./" # Check that rw2pnm1 exists. if {![file exists ${PATH}/rw2pnm1]} { puts stderr "cannot find ${PATH}/rw2pnm1" destroy . exit } #flag for one-time initialization set init 0 # root of .ppm file names (e.g., foo -> foo.1.ppm, foo.2.ppm, ....) set root [lindex $argv 0] # time in milliseconds set time [expr 1000 * [lindex $argv 1]] #zoom factor set zoom [lindex $argv 2] #normalization set norm [lindex $argv 3] # decades set decades [lindex $argv 4] #color set color [lindex $argv 5] if {$color == 2} { if {[llength $argv] < 7} { puts stderr "one- or two-sided color must be specified on the command line." destroy . exit } } set side [lindex $argv 6] # number of frames plus 1 set frameindex 1 # currently displayed frame set dispframe 1 # increment between frame file indices set frameindexincr 1 bind . q {exit} label .l bind .l q {exit} pack .l -side top proc loadFrame {} { global frameindex root zoom init frameindexincr norm decades color side PATH if {![file exists $root.[expr $frameindex + 1]]} { return 0 } else { puts stderr "rawfile $frameindex" if {$color == 1} { exec $PATH/rw2pnm1 -r $root.$frameindex -n $norm -d $decades -c $color } else { exec $PATH/rw2pnm1 -r $root.$frameindex -n $norm -d $decades -c $color -s $side } if {$color == 1} { image create photo temp -file $root.$frameindex.pgm image create photo frame$frameindex frame$frameindex copy temp -zoom $zoom $zoom } else { image create photo temp -file $root.$frameindex.ppm image create photo frame$frameindex frame$frameindex copy temp -zoom $zoom $zoom } if {!$init} { set w [image width frame$frameindex] set h [image height frame$frameindex] wm geometry . ${w}x${h} set init 1 } .l configure -image frame$frameindex wm title . "frame $frameindex" update incr frameindex $frameindexincr } } loadFrame pack .l -side top while {1} { after $time; loadFrame }