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] |
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 |
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 |
|
if {$rpview == " ALL"} { |
78 |
|
set radcom "rad" |
79 |
|
} else { |
87 |
|
set batch_pid [eval exec $radcom >>& $bfname &] |
88 |
|
# Now, write PID and close file |
89 |
|
seek $fo 0 |
90 |
< |
puts -nonewline $fo $batch_pid |
90 |
> |
puts -nonewline $fo "[format $batch_fmt $batch_pid $hostname]\ |
91 |
> |
[exec date]" |
92 |
|
close $fo |
93 |
|
set curmess "Batch rendering process $batch_pid started." |
94 |
|
# Correct button stati |
104 |
|
switch -glob [exec uname] { |
105 |
|
SunOS - |
106 |
|
ULTRIX {set ps "ps -lg"} |
107 |
< |
default {set ps "ps -lu $env(USER)"} |
107 |
> |
default {set ps "ps -lu $env(LOGNAME)"} |
108 |
|
} |
109 |
|
set fi [open "|$ps" r] |
110 |
|
gets $fi li |
150 |
|
catch {destroy $mywin.rbvmb.m} |
151 |
|
if {[llength $radvar(view)] < 2} { |
152 |
|
$mywin.rivmb configure -state disabled |
150 |
– |
$mywin.rbvmb configure -state disabled |
153 |
|
return |
154 |
|
} |
155 |
|
menu $mywin.rivmb.m |
159 |
|
-variable rvview -value [lindex $v 0] |
160 |
|
} |
161 |
|
menu $mywin.rbvmb.m |
162 |
< |
$mywin.rbvmb configure -menu $mywin.rbvmb.m -state normal |
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 |
171 |
|
|
172 |
|
proc do_action w { # Action screen |
173 |
|
global rifname rvview rpview radvar bfname batch_pid \ |
174 |
< |
curmess scname mywin alldone |
174 |
> |
curmess scname mywin alldone batch_fmt hostname |
175 |
|
if {"$w" == "done"} { |
176 |
|
unset rpview bfname batch_pid mywin |
177 |
|
return |
224 |
|
helplink $w.rbce trad action checkerr |
225 |
|
if [file exists $bfname] { |
226 |
|
set fi [open $bfname r] |
227 |
< |
eval set batch_pid [gets $fi] |
227 |
> |
scan [gets $fi] $batch_fmt batch_pid batch_host |
228 |
|
gets $fi radcom |
229 |
|
close $fi |
230 |
< |
if [catch {exec /bin/kill -0 $batch_pid}] { |
230 |
> |
if [string match "rad -v *" $radcom] { |
231 |
> |
set rpview [lindex $radcom 2] |
232 |
> |
} else { |
233 |
> |
set rpview " ALL" |
234 |
> |
} |
235 |
> |
if {"$hostname" != "$batch_host"} { |
236 |
|
if $alldone { |
237 |
+ |
set curmess "Batch rendering finished\ |
238 |
+ |
on host $batch_host." |
239 |
+ |
} else { |
240 |
+ |
set curmess "Unknown batch rendering status\ |
241 |
+ |
on host $batch_host." |
242 |
+ |
$w.rbst configure -state disabled |
243 |
+ |
$w.rbvmb configure -state disabled |
244 |
+ |
} |
245 |
+ |
set batch_pid 0 |
246 |
+ |
$w.rbki configure -state disabled |
247 |
+ |
} elseif {[catch {exec /bin/kill -0 $batch_pid}]} { |
248 |
+ |
if $alldone { |
249 |
|
set curmess "Batch rendering finished." |
250 |
|
} else { |
251 |
|
set curmess "Batch rendering stopped." |
255 |
|
$w.rbki configure -state disabled |
256 |
|
} else { |
257 |
|
set curmess "Batch rendering process $batch_pid running." |
239 |
– |
if [string match "rad -v *" $radcom] { |
240 |
– |
set rpview [lindex $radcom 2] |
241 |
– |
} else { |
242 |
– |
set rpview " ALL" |
243 |
– |
} |
258 |
|
$w.rbst configure -state disabled |
259 |
|
$w.rbvmb configure -state disabled |
260 |
|
} |