1 |
< |
# SCCSid "$SunId$ LBL" |
1 |
> |
# RCSid: $Id$ |
2 |
|
# |
3 |
|
# Action screen for trad |
4 |
|
# |
5 |
|
|
6 |
+ |
set batch_fmt "Process %d on %s started" |
7 |
+ |
set hostname [exec hostname] |
8 |
+ |
set nproc 1 |
9 |
+ |
|
10 |
|
proc make_script {} { # make run script |
11 |
|
global scname rpview curmess |
12 |
< |
set rfn /usr/tmp/rf[pid] |
12 |
> |
set rfn /tmp/rf[pid] |
13 |
|
if {! [save_vars $rfn]} { |
14 |
|
beep |
15 |
|
set curmess "Cannot save variables to temporary file!" |
20 |
|
lappend radcom -v $rpview |
21 |
|
} |
22 |
|
if {"$scname" == {}} { |
23 |
< |
set rof /usr/tmp/ro[pid] |
23 |
> |
set rof /tmp/ro[pid] |
24 |
|
} else { |
25 |
|
set rof $scname |
26 |
|
} |
41 |
|
set fi [open "|make $radvar(OCTREE) $args" r] |
42 |
|
while {[gets $fi curmess] >= 0} { update ; after 1000 } |
43 |
|
catch {close $fi} curmess |
40 |
– |
if {"$args" == {}} {return} |
44 |
|
} |
45 |
|
if {"$args" == {}} { |
46 |
|
run_rad -v 0 |
49 |
|
} |
50 |
|
} |
51 |
|
|
52 |
+ |
proc set_nproc v { # set number of processes |
53 |
+ |
global nproc |
54 |
+ |
set nproc $v |
55 |
+ |
} |
56 |
+ |
|
57 |
|
proc run_rad args { # Run rad command with given arguments |
58 |
|
global curmess |
59 |
< |
set rfn /usr/tmp/rf[pid] |
59 |
> |
set rfn /tmp/rf[pid] |
60 |
|
if {! [save_vars $rfn]} { |
61 |
|
beep |
62 |
|
set curmess "Cannot save variables to temporary file!" |
73 |
|
} |
74 |
|
|
75 |
|
proc run_batch {} { # start rendering in background |
76 |
< |
global rpview bfname batch_pid curmess rifname mywin |
76 |
> |
global rpview bfname batch_pid curmess rifname mywin batch_fmt hostname nproc |
77 |
|
if {! [chksave]} {return} |
78 |
|
if [catch {set fo [open $bfname w]} curmess] { |
79 |
|
return |
80 |
|
} |
81 |
|
# Make space for PID to be written later |
82 |
< |
puts $fo " " |
82 |
> |
puts $fo \ |
83 |
> |
" " |
84 |
|
if {$rpview == " ALL"} { |
85 |
< |
set radcom "rad" |
85 |
> |
set radcom "rad -N $nproc" |
86 |
|
} else { |
87 |
< |
set radcom "rad -v $rpview" |
87 |
> |
set radcom "rad -v $rpview -N $nproc" |
88 |
|
} |
89 |
|
lappend radcom "[file tail $rifname]" |
90 |
|
# Put out command |
94 |
|
set batch_pid [eval exec $radcom >>& $bfname &] |
95 |
|
# Now, write PID and close file |
96 |
|
seek $fo 0 |
97 |
< |
puts -nonewline $fo $batch_pid |
97 |
> |
puts -nonewline $fo "[format $batch_fmt $batch_pid $hostname]\ |
98 |
> |
[exec date]" |
99 |
|
close $fo |
100 |
|
set curmess "Batch rendering process $batch_pid started." |
101 |
|
# Correct button stati |
111 |
|
switch -glob [exec uname] { |
112 |
|
SunOS - |
113 |
|
ULTRIX {set ps "ps -lg"} |
114 |
< |
default {set ps "ps -lu $env(USER)"} |
114 |
> |
default {set ps "ps -lu $env(LOGNAME)"} |
115 |
|
} |
116 |
|
set fi [open "|$ps" r] |
117 |
|
gets $fi li |
157 |
|
catch {destroy $mywin.rbvmb.m} |
158 |
|
if {[llength $radvar(view)] < 2} { |
159 |
|
$mywin.rivmb configure -state disabled |
150 |
– |
$mywin.rbvmb configure -state disabled |
160 |
|
return |
161 |
|
} |
162 |
|
menu $mywin.rivmb.m |
166 |
|
-variable rvview -value [lindex $v 0] |
167 |
|
} |
168 |
|
menu $mywin.rbvmb.m |
169 |
< |
$mywin.rbvmb configure -menu $mywin.rbvmb.m -state normal |
169 |
> |
$mywin.rbvmb configure -menu $mywin.rbvmb.m |
170 |
|
$mywin.rbvmb.m add radiobutton -label ALL \ |
171 |
|
-variable rpview -value " ALL" |
172 |
|
$mywin.rbvmb.m add separator |
177 |
|
} |
178 |
|
|
179 |
|
proc do_action w { # Action screen |
180 |
< |
global rifname rvview rpview radvar bfname batch_pid \ |
181 |
< |
curmess scname mywin alldone |
180 |
> |
global rifname rvview rpview radvar bfname batch_pid nproc \ |
181 |
> |
curmess scname mywin alldone batch_fmt hostname |
182 |
|
if {"$w" == "done"} { |
183 |
< |
unset rpview bfname batch_pid mywin |
183 |
> |
unset rvview rpview bfname batch_pid mywin |
184 |
|
return |
185 |
|
} |
186 |
|
set bfname [file rootname [file tail $rifname]].err |
201 |
|
helplink $w.octf trad action force |
202 |
|
# Render interactively |
203 |
|
label $w.ril -text {Render interactively} |
204 |
< |
place $w.ril -relx .1429 -rely .2439 |
205 |
< |
button $w.rirv -text rview -relief raised \ |
206 |
< |
-command {run_rad -v $rvview -o x11} |
207 |
< |
place $w.rirv -relwidth .1071 -relheight .0610 -relx .4643 -rely .2439 |
208 |
< |
helplink $w.rirv trad action rview |
204 |
> |
place $w.ril -relx .1429 -rely .2329 |
205 |
> |
button $w.rirv -text rvu -relief raised \ |
206 |
> |
-command {run_rad -v $rvview -o x11 -N $nproc} |
207 |
> |
place $w.rirv -relwidth .1071 -relheight .0610 -relx .4643 -rely .2329 |
208 |
> |
helplink $w.rirv trad action rvu |
209 |
|
label $w.rivl -text View: |
210 |
< |
place $w.rivl -relx .6072 -rely .2439 |
210 |
> |
place $w.rivl -relx .6072 -rely .2329 |
211 |
|
menubutton $w.rivmb -textvariable rvview -anchor w -relief raised |
212 |
< |
place $w.rivmb -relwidth .1071 -relheight .0610 -relx .7143 -rely .2439 |
212 |
> |
place $w.rivmb -relwidth .1071 -relheight .0610 -relx .7143 -rely .2329 |
213 |
|
helplink $w.rivmb trad action view |
214 |
+ |
# Number of processes |
215 |
+ |
label $w.rnpl -text {Number of processes:} |
216 |
+ |
place $w.rnpl -relx .1429 -rely .3394 |
217 |
+ |
scale $w.rnps -showvalue yes -from 1 -to 64 \ |
218 |
+ |
-orient horizontal -command set_nproc |
219 |
+ |
$w.rnps set $nproc |
220 |
+ |
place $w.rnps -relwidth .5550 -relheight .1200 -relx .3683 -rely .3000 |
221 |
+ |
helplink $w.rnps trad action processes |
222 |
|
# Render in background |
223 |
|
label $w.rbl -text {Render in background} |
224 |
< |
place $w.rbl -relx .1429 -rely .4268 |
224 |
> |
place $w.rbl -relx .1429 -rely .4458 |
225 |
|
button $w.rbst -text Start -relief raised -command run_batch |
226 |
< |
place $w.rbst -relwidth .1071 -relheight .0610 -relx .4643 -rely .4268 |
226 |
> |
place $w.rbst -relwidth .1071 -relheight .0610 -relx .4643 -rely .4458 |
227 |
|
helplink $w.rbst trad action start |
228 |
|
label $w.rbvl -text View: |
229 |
< |
place $w.rbvl -relx .6072 -rely .4268 |
229 |
> |
place $w.rbvl -relx .6072 -rely .4458 |
230 |
|
menubutton $w.rbvmb -textvariable rpview -anchor w -relief raised |
231 |
< |
place $w.rbvmb -relwidth .1071 -relheight .0610 -relx .7143 -rely .4268 |
231 |
> |
place $w.rbvmb -relwidth .1071 -relheight .0610 -relx .7143 -rely .4458 |
232 |
|
helplink $w.rbvmb trad action view |
233 |
|
button $w.rbki -text Kill -relief raised -command kill_batch |
234 |
< |
place $w.rbki -relwidth .1071 -relheight .0610 -relx .4643 -rely .5488 |
234 |
> |
place $w.rbki -relwidth .1071 -relheight .0610 -relx .4643 -rely .5668 |
235 |
|
helplink $w.rbki trad action kill |
236 |
|
button $w.rbce -text "Check errors" -relief raised \ |
237 |
|
-command {view_txt $bfname} |
238 |
< |
place $w.rbce -relwidth .1786 -relheight .0610 -relx .6429 -rely .5488 |
238 |
> |
place $w.rbce -relwidth .1786 -relheight .0610 -relx .6429 -rely .5668 |
239 |
|
helplink $w.rbce trad action checkerr |
240 |
< |
if [file exists $bfname] { |
240 |
> |
if [file isfile $bfname] { |
241 |
|
set fi [open $bfname r] |
242 |
< |
eval set batch_pid [gets $fi] |
243 |
< |
gets $fi radcom |
242 |
> |
if {[scan [gets $fi] $batch_fmt batch_pid batch_host] != 2} { |
243 |
> |
set batch_host unknown |
244 |
> |
set radcom {} |
245 |
> |
} else { |
246 |
> |
gets $fi radcom |
247 |
> |
} |
248 |
|
close $fi |
249 |
< |
if [catch {exec /bin/kill -0 $batch_pid}] { |
249 |
> |
if [string match "rad -v *" $radcom] { |
250 |
> |
set rpview [lindex $radcom 2] |
251 |
> |
} else { |
252 |
> |
set rpview " ALL" |
253 |
> |
} |
254 |
> |
if {"$hostname" != "$batch_host"} { |
255 |
|
if $alldone { |
256 |
+ |
set curmess "Batch rendering finished\ |
257 |
+ |
on $batch_host." |
258 |
+ |
} else { |
259 |
+ |
set curmess "Batch rendering on\ |
260 |
+ |
$batch_host -- status UNKNOWN." |
261 |
+ |
$w.rbst configure -state disabled |
262 |
+ |
$w.rbvmb configure -state disabled |
263 |
+ |
} |
264 |
+ |
set batch_pid 0 |
265 |
+ |
$w.rbki configure -state disabled |
266 |
+ |
} elseif {[catch {exec /bin/kill -0 $batch_pid}]} { |
267 |
+ |
if $alldone { |
268 |
|
set curmess "Batch rendering finished." |
269 |
|
} else { |
270 |
|
set curmess "Batch rendering stopped." |
274 |
|
$w.rbki configure -state disabled |
275 |
|
} else { |
276 |
|
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 |
– |
} |
277 |
|
$w.rbst configure -state disabled |
278 |
|
$w.rbvmb configure -state disabled |
279 |
|
} |
287 |
|
make_vmenus |
288 |
|
# Dry run |
289 |
|
label $w.drl -text {Dry run} |
290 |
< |
place $w.drl -relx .1429 -rely .7317 |
290 |
> |
place $w.drl -relx .1429 -rely .7357 |
291 |
|
button $w.drsc -text Script -relief raised -command make_script |
292 |
< |
place $w.drsc -relwidth .1071 -relheight .0610 -relx .4643 -rely .7317 |
292 |
> |
place $w.drsc -relwidth .1071 -relheight .0610 -relx .4643 -rely .7357 |
293 |
|
entry $w.drsf -textvariable scname -relief sunken |
294 |
< |
place $w.drsf -relwidth .2143 -relheight .0610 -relx .6429 -rely .7317 |
294 |
> |
place $w.drsf -relwidth .2143 -relheight .0610 -relx .6429 -rely .7357 |
295 |
|
helplink "$w.drsc $w.drsf" trad action script |
296 |
|
button $w.drvw -text Edit -relief raised -command {view_txt $scname} |
297 |
< |
place $w.drvw -relwidth .1071 -relheight .0610 -relx .4643 -rely .8537 |
297 |
> |
place $w.drvw -relwidth .1071 -relheight .0610 -relx .4643 -rely .8577 |
298 |
|
helplink $w.drvw trad action edit |
299 |
|
button $w.drdel -text Delete -relief raised \ |
300 |
|
-command {catch {exec rm $scname < /dev/null} curmess} |
301 |
< |
place $w.drdel -relwidth .1071 -relheight .0610 -relx .6429 -rely .8537 |
301 |
> |
place $w.drdel -relwidth .1071 -relheight .0610 -relx .6429 -rely .8577 |
302 |
|
helplink $w.drdel trad action delete |
303 |
|
} |