ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/do_action.tcl
(Generate patch)

Comparing ray/src/util/do_action.tcl (file contents):
Revision 2.1 by greg, Thu Oct 27 15:56:06 1994 UTC vs.
Revision 2.9 by greg, Tue Oct 17 21:28:06 1995 UTC

# Line 3 | Line 3
3   # Action screen for trad
4   #
5  
6 + set batch_fmt "Process %d on %s started"
7 + set hostname [exec hostname]
8 +
9   proc make_script {} {           # make run script
10          global scname rpview curmess
11          set rfn /usr/tmp/rf[pid]
# Line 37 | Line 40 | proc make_oct args {           # Make octree file ($args is {-t
40                  set fi [open "|make $radvar(OCTREE) $args" r]
41                  while {[gets $fi curmess] >= 0} { update ; after 1000 }
42                  catch {close $fi} curmess
40                if {"$args" == {}} {return}
43          }
44          if {"$args" == {}} {
45                  run_rad -v 0
# Line 65 | Line 67 | proc run_rad args {            # Run rad command with given argu
67   }
68  
69   proc run_batch {} {             # start rendering in background
70 <        global rpview bfname batch_pid curmess rifname mywin
70 >        global rpview bfname batch_pid curmess rifname mywin batch_fmt hostname
71          if {! [chksave]} {return}
72          if [catch {set fo [open $bfname w]} curmess] {
73                  return
74          }
75          # Make space for PID to be written later
76 <        puts $fo "        "
76 >        puts $fo \
77 > "                                                                             "
78          if {$rpview == " ALL"} {
79                  set radcom "rad"
80          } else {
# Line 85 | Line 88 | proc run_batch {} {            # start rendering in background
88          set batch_pid [eval exec $radcom >>& $bfname &]
89          # Now, write PID and close file
90          seek $fo 0
91 <        puts -nonewline $fo $batch_pid
91 >        puts -nonewline $fo "[format $batch_fmt $batch_pid $hostname]\
92 >                                [exec date]"
93          close $fo
94          set curmess "Batch rendering process $batch_pid started."
95          # Correct button stati
# Line 101 | Line 105 | proc kill_batch {} {           # kill batch rendering
105          switch -glob [exec uname] {
106                  SunOS -
107                  ULTRIX {set ps "ps -lg"}
108 <                default {set ps "ps -lu $env(USER)"}
108 >                default {set ps "ps -lu $env(LOGNAME)"}
109          }
110          set fi [open "|$ps" r]
111          gets $fi li
# Line 144 | Line 148 | proc make_vmenus {} {          # make/update view menus
148                  set rvview [lindex [lindex $radvar(view) 0] 0]
149          }
150          catch {destroy $mywin.rivmb.m}
151 +        catch {destroy $mywin.rbvmb.m}
152          if {[llength $radvar(view)] < 2} {
153                  $mywin.rivmb configure -state disabled
154 <        } else {
150 <                menu $mywin.rivmb.m
151 <                $mywin.rivmb configure -menu $mywin.rivmb.m
152 <                foreach v $radvar(view) {
153 <                        $mywin.rivmb.m add radiobutton -label [lindex $v 0] \
154 <                                        -variable rvview -value [lindex $v 0]
155 <                }
154 >                return
155          }
156 <        catch {destroy $mywin.rbvmb.m}
157 <        if {[llength $radvar(view)] < 2} {
158 <                $mywin.rbvmb configure -state disabled
159 <        } else {
160 <                menu $mywin.rbvmb.m
162 <                $mywin.rbvmb configure -menu $mywin.rbvmb.m
163 <                $mywin.rbvmb.m add radiobutton -label ALL \
164 <                                -variable rpview -value " ALL"
165 <                $mywin.rbvmb.m add separator
166 <                foreach v $radvar(view) {
167 <                        $mywin.rbvmb.m add radiobutton -label [lindex $v 0] \
168 <                                        -variable rpview -value [lindex $v 0]
169 <                }
156 >        menu $mywin.rivmb.m
157 >        $mywin.rivmb configure -menu $mywin.rivmb.m -state normal
158 >        foreach v $radvar(view) {
159 >                $mywin.rivmb.m add radiobutton -label [lindex $v 0] \
160 >                                -variable rvview -value [lindex $v 0]
161          }
162 +        menu $mywin.rbvmb.m
163 +        $mywin.rbvmb configure -menu $mywin.rbvmb.m
164 +        $mywin.rbvmb.m add radiobutton -label ALL \
165 +                        -variable rpview -value " ALL"
166 +        $mywin.rbvmb.m add separator
167 +        foreach v $radvar(view) {
168 +                $mywin.rbvmb.m add radiobutton -label [lindex $v 0] \
169 +                                -variable rpview -value [lindex $v 0]
170 +        }
171   }
172  
173   proc do_action w {              # Action screen
174          global rifname rvview rpview radvar bfname batch_pid \
175 <                        curmess scname mywin alldone
175 >                        curmess scname mywin alldone batch_fmt hostname
176          if {"$w" == "done"} {
177 <                unset rpview bfname batch_pid mywin
177 >                unset rvview rpview bfname batch_pid mywin
178                  return
179          }
180          set bfname [file rootname [file tail $rifname]].err
# Line 223 | Line 223 | proc do_action w {             # Action screen
223                          -command {view_txt $bfname}
224          place $w.rbce -relwidth .1786 -relheight .0610 -relx .6429 -rely .5488
225          helplink $w.rbce trad action checkerr
226 <        if [file exists $bfname] {
226 >        if [file isfile $bfname] {
227                  set fi [open $bfname r]
228 <                eval set batch_pid [gets $fi]
229 <                gets $fi radcom
228 >                if {[scan [gets $fi] $batch_fmt batch_pid batch_host] != 2} {
229 >                        set batch_host unknown
230 >                        set radcom {}
231 >                } else {
232 >                        gets $fi radcom
233 >                }
234                  close $fi
235 <                if [catch {exec /bin/kill -0 $batch_pid}] {
235 >                if [string match "rad -v *" $radcom] {
236 >                        set rpview [lindex $radcom 2]
237 >                } else {
238 >                        set rpview " ALL"
239 >                }
240 >                if {"$hostname" != "$batch_host"} {
241                          if $alldone {
242 +                                set curmess "Batch rendering finished\
243 +                                                on $batch_host."
244 +                        } else {
245 +                                set curmess "Batch rendering on\
246 +                                                $batch_host -- status UNKNOWN."
247 +                                $w.rbst configure -state disabled
248 +                                $w.rbvmb configure -state disabled
249 +                        }
250 +                        set batch_pid 0
251 +                        $w.rbki configure -state disabled
252 +                } elseif {[catch {exec /bin/kill -0 $batch_pid}]} {
253 +                        if $alldone {
254                                  set curmess "Batch rendering finished."
255                          } else {
256                                  set curmess "Batch rendering stopped."
# Line 239 | Line 260 | proc do_action w {             # Action screen
260                          $w.rbki configure -state disabled
261                  } else {
262                          set curmess "Batch rendering process $batch_pid running."
242                        if [string match "rad -v *" $radcom] {
243                                set rpview [lindex $radcom 2]
244                        } else {
245                                set rpview " ALL"
246                        }
263                          $w.rbst configure -state disabled
264                          $w.rbvmb configure -state disabled
265                  }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines