1 |
< |
# SCCSid "$SunId$ LBL" |
1 |
> |
# RCSid: $Id$ |
2 |
|
# |
3 |
|
# Choose the Rad Input File to work on. |
4 |
|
# |
5 |
|
|
6 |
– |
set rif_glob *.rif |
7 |
– |
|
6 |
|
proc preen {} { # clean up radvar |
7 |
|
global radvar rifname |
8 |
< |
foreach n {objects scene materials illum mkillum render oconv pfilt |
9 |
< |
AMBFILE OPTFILE EXPOSURE ZONE REPORT} { |
8 |
> |
foreach n {objects scene materials illum mkillum render oconv rvu rpict pfilt |
9 |
> |
RAWFILE ZFILE AMBFILE OPTFILE EXPOSURE ZONE REPORT} { |
10 |
|
if {! [info exists radvar($n)]} { |
11 |
|
set radvar($n) {} |
12 |
|
} |
17 |
|
set n 1 |
18 |
|
foreach v $oldval { |
19 |
|
if {"[string index $v 0]" == "-"} { |
20 |
< |
lappend radvar(view) "$n $v" |
20 |
> |
lappend radvar(view) "u$n $v" |
21 |
|
} elseif {[lsearch -glob $radvar(view) \ |
22 |
|
"[lindex $v 0] *"] >= 0} { |
23 |
|
continue |
43 |
|
if {! [info exists radvar(RESOLUTION)]} { |
44 |
|
set radvar(RESOLUTION) 512 |
45 |
|
} |
46 |
+ |
if {! [info exists radvar(EYESEP)]} { |
47 |
+ |
set radvar(EYESEP) 1 |
48 |
+ |
} |
49 |
|
if [info exists radvar(QUALITY)] { |
50 |
|
cardval radvar(QUALITY) {High Medium Low} |
51 |
|
} else { |
76 |
|
|
77 |
|
proc setradvar stmt { # assign a rad variable |
78 |
|
global radvar |
79 |
< |
regexp {^([a-zA-Z][a-zA-Z0-9]*) *= *(.*)$} $stmt dummy vnam vval |
79 |
> |
regexp {^([a-zA-Z][a-zA-Z0-9]*) *=[ ]*(.*)$} $stmt dummy vnam vval |
80 |
|
switch -glob $vnam { |
81 |
|
obj* { eval lappend radvar(objects) $vval } |
82 |
|
sce* { eval lappend radvar(scene) $vval } |
85 |
|
mki* { eval lappend radvar(mkillum) $vval } |
86 |
|
ren* { eval lappend radvar(render) $vval } |
87 |
|
oco* { eval lappend radvar(oconv) $vval } |
88 |
+ |
rvu { eval lappend radvar(rvu) $vval } |
89 |
+ |
rpi* { eval lappend radvar(rpict) $vval } |
90 |
|
pf* { eval lappend radvar(pfilt) $vval } |
91 |
|
vi* { lappend radvar(view) $vval } |
92 |
|
ZO* { set radvar(ZONE) $vval } |
96 |
|
AMB* { set radvar(AMBFILE) $vval } |
97 |
|
OPT* { set radvar(OPTFILE) $vval } |
98 |
|
EXP* { set radvar(EXPOSURE) $vval } |
99 |
+ |
EYE* { set radvar(EYESEP) $vval } |
100 |
|
RES* { set radvar(RESOLUTION) $vval } |
101 |
|
UP { set radvar(UP) $vval } |
102 |
|
IND* { set radvar(INDIRECT) $vval } |
104 |
|
PEN* { set radvar(PENUMBRAS) $vval } |
105 |
|
VAR* { set radvar(VARIABILITY) $vval } |
106 |
|
REP* { set radvar(REPORT) $vval } |
107 |
+ |
RAW* { set radvar(RAWFILE) $vval } |
108 |
+ |
ZF* {set radvar(ZFILE) $vval } |
109 |
|
} |
110 |
|
|
111 |
|
} |
125 |
|
} |
126 |
|
if {[lsearch -exact {ZONE QUALITY OCTREE PICTURE AMBFILE OPTFILE |
127 |
|
EXPOSURE RESOLUTION UP INDIRECT DETAIL PENUMBRAS |
128 |
< |
VARIABILITY REPORT} $vn] >= 0} { |
128 |
> |
EYESEP RAWFILE ZFILE VARIABILITY REPORT} $vn] >= 0} { |
129 |
|
puts $fi "$vn= $radvar($vn)" |
130 |
|
return |
131 |
|
} |
147 |
|
proc load_vars {f {vl all}} { # load RIF variables |
148 |
|
global curmess radvar alldone |
149 |
|
if {"$f" == ""} {return 0} |
150 |
< |
if {! [file exists $f]} { |
150 |
> |
if {! [file isfile $f]} { |
151 |
|
beep |
152 |
|
set curmess "$f: no such file." |
153 |
|
return 0 |
154 |
|
} |
155 |
|
if {"$vl" == "all" && ! [chksave]} {return 0} |
156 |
|
set curmess {Please wait...} |
157 |
< |
update idletasks |
158 |
< |
if [catch {exec rad -n -w -e $f >& /usr/tmp/ro[pid]}] { |
159 |
< |
set curmess [exec cat /usr/tmp/ro[pid]] |
160 |
< |
exec rm -f /usr/tmp/ro[pid] |
157 |
> |
update |
158 |
> |
if [catch {exec rad -n -w -e $f >& /tmp/ro[pid]}] { |
159 |
> |
set curmess [exec cat /tmp/ro[pid]] |
160 |
> |
exec rm -f /tmp/ro[pid] |
161 |
|
return 0 |
162 |
|
} |
163 |
< |
set fi [open /usr/tmp/ro[pid] r] |
163 |
> |
set fi [open /tmp/ro[pid] r] |
164 |
|
if {"$vl" == "all"} { |
165 |
|
catch {unset radvar} |
166 |
|
while {[gets $fi curli] != -1} { |
167 |
< |
if [regexp {^[a-zA-Z][a-zA-Z0-9]*= } $curli] { |
167 |
> |
if [regexp {^[a-zA-Z][a-zA-Z0-9]* *=} $curli] { |
168 |
|
setradvar $curli |
169 |
|
} else { |
170 |
|
break |
173 |
|
set curmess {Project loaded.} |
174 |
|
} else { |
175 |
|
foreach n $vl { |
176 |
< |
set radvar($n) {} |
176 |
> |
if [regexp {[a-z][a-z]*} $n] { |
177 |
> |
set radvar($n) {} |
178 |
> |
} else { |
179 |
> |
catch {unset radvar($n)} |
180 |
> |
} |
181 |
|
} |
182 |
|
while {[gets $fi curli] != -1} { |
183 |
|
if [regexp {^[a-zA-Z][a-zA-Z0-9]* *=} $curli] { |
193 |
|
} |
194 |
|
set alldone [eof $fi] |
195 |
|
close $fi |
196 |
< |
exec rm -f /usr/tmp/ro[pid] |
196 |
> |
exec rm -f /tmp/ro[pid] |
197 |
|
preen |
198 |
|
return 1 |
199 |
|
} |
246 |
|
return 0 |
247 |
|
} |
248 |
|
} elseif {[file exists $f]} { |
249 |
+ |
set ftyp [file type $f] |
250 |
+ |
if { $ftyp != "file" } { |
251 |
+ |
beep |
252 |
+ |
set curmess "Selected file $f is a $ftyp." |
253 |
+ |
return 0 |
254 |
+ |
} |
255 |
|
if [tk_dialog .dlg {Verification} \ |
256 |
|
"Overwrite existing file $f?" \ |
257 |
|
questhead 1 {Go Ahead} {Cancel}] { |
258 |
|
return 0 |
259 |
|
} |
260 |
|
} |
261 |
+ |
if {[file isfile $f] && ! [file writable $f] && |
262 |
+ |
[catch {exec chmod u+w $f} curmess]} { |
263 |
+ |
beep |
264 |
+ |
return 0 |
265 |
+ |
} |
266 |
|
if [save_vars $f] { |
267 |
|
set rifname [pwd]/$f |
268 |
|
set readonly 0 |
275 |
|
proc newnew f { # create a new RIF |
276 |
|
global rifname readonly curmess radvar |
277 |
|
if [file exists $f] { |
278 |
+ |
set ftyp [file type $f] |
279 |
+ |
if { $ftyp != "file" } { |
280 |
+ |
beep |
281 |
+ |
set curmess "Selected file $f is a $ftyp." |
282 |
+ |
return 0 |
283 |
+ |
} |
284 |
|
if [tk_dialog .dlg {Verification} \ |
285 |
|
"File $f exists -- disregard it?" \ |
286 |
|
questhead 1 {Yes} {Cancel}] { |
298 |
|
} |
299 |
|
|
300 |
|
proc do_file w { |
301 |
< |
global rifname readonly rif_glob curfile curpat |
301 |
> |
global rifname readonly myglob curfile curpat |
302 |
|
if {"$w" == "done"} { |
303 |
|
cd [file dirname $rifname] |
304 |
< |
set rif_glob $curpat |
304 |
> |
set myglob(rif) $curpat |
305 |
|
return |
306 |
|
} |
307 |
|
frame $w |
309 |
|
pack $w.left -side left |
310 |
|
button $w.left.load -text LOAD -width 5 \ |
311 |
|
-relief raised -command {newload $curfile} |
312 |
< |
button $w.left.save -text SAVE -width 5 \ |
313 |
< |
-relief raised -command {newsave $curfile} |
312 |
> |
button $w.left.save -text SAVE -width 5 -relief raised \ |
313 |
> |
-command "newsave \$curfile; update_dir $w.right" |
314 |
|
button $w.left.new -text NEW -width 5 \ |
315 |
|
-relief raised -command {newnew $curfile} |
316 |
|
pack $w.left.load $w.left.save $w.left.new -side top -pady 15 -padx 20 |
322 |
|
helplink $w.left.new trad file new |
323 |
|
helplink $w.left.ro trad file readonly |
324 |
|
getfile -view view_txt -perm \ |
325 |
< |
-win $w.right -glob [file dirname $rifname]/$rif_glob |
325 |
> |
-win $w.right -glob [file dirname $rifname]/$myglob(rif) |
326 |
|
set curfile [file tail $rifname] |
327 |
|
} |