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 mkpmap render oconv rvu rpict pfilt |
9 |
> |
RAWFILE ZFILE AMBFILE PGMAP PCMAP 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 } |
83 |
|
mat* { eval lappend radvar(materials) $vval } |
84 |
|
ill* { eval lappend radvar(illum) $vval } |
85 |
|
mki* { eval lappend radvar(mkillum) $vval } |
86 |
+ |
mkp* { eval lappend radvar(mkpmap) $vval } |
87 |
|
ren* { eval lappend radvar(render) $vval } |
88 |
|
oco* { eval lappend radvar(oconv) $vval } |
89 |
+ |
rvu { eval lappend radvar(rvu) $vval } |
90 |
+ |
rpi* { eval lappend radvar(rpict) $vval } |
91 |
|
pf* { eval lappend radvar(pfilt) $vval } |
92 |
|
vi* { lappend radvar(view) $vval } |
93 |
|
ZO* { set radvar(ZONE) $vval } |
97 |
|
AMB* { set radvar(AMBFILE) $vval } |
98 |
|
OPT* { set radvar(OPTFILE) $vval } |
99 |
|
EXP* { set radvar(EXPOSURE) $vval } |
100 |
+ |
EYE* { set radvar(EYESEP) $vval } |
101 |
|
RES* { set radvar(RESOLUTION) $vval } |
102 |
|
UP { set radvar(UP) $vval } |
103 |
|
IND* { set radvar(INDIRECT) $vval } |
105 |
|
PEN* { set radvar(PENUMBRAS) $vval } |
106 |
|
VAR* { set radvar(VARIABILITY) $vval } |
107 |
|
REP* { set radvar(REPORT) $vval } |
108 |
+ |
RAW* { set radvar(RAWFILE) $vval } |
109 |
+ |
ZF* {set radvar(ZFILE) $vval } |
110 |
+ |
PGM* {set radvar(PGMAP) $vval } |
111 |
+ |
PCM* {set radvar(PCMAP) $vval } |
112 |
|
} |
113 |
|
|
114 |
|
} |
128 |
|
} |
129 |
|
if {[lsearch -exact {ZONE QUALITY OCTREE PICTURE AMBFILE OPTFILE |
130 |
|
EXPOSURE RESOLUTION UP INDIRECT DETAIL PENUMBRAS |
131 |
< |
VARIABILITY REPORT} $vn] >= 0} { |
131 |
> |
EYESEP RAWFILE ZFILE VARIABILITY REPORT} $vn] >= 0} { |
132 |
|
puts $fi "$vn= $radvar($vn)" |
133 |
|
return |
134 |
|
} |
150 |
|
proc load_vars {f {vl all}} { # load RIF variables |
151 |
|
global curmess radvar alldone |
152 |
|
if {"$f" == ""} {return 0} |
153 |
< |
if {! [file exists $f]} { |
153 |
> |
if {! [file isfile $f]} { |
154 |
|
beep |
155 |
|
set curmess "$f: no such file." |
156 |
|
return 0 |
158 |
|
if {"$vl" == "all" && ! [chksave]} {return 0} |
159 |
|
set curmess {Please wait...} |
160 |
|
update |
161 |
< |
if [catch {exec rad -n -w -e $f >& /usr/tmp/ro[pid]}] { |
162 |
< |
set curmess [exec cat /usr/tmp/ro[pid]] |
163 |
< |
exec rm -f /usr/tmp/ro[pid] |
161 |
> |
if [catch {exec rad -n -w -e $f >& /tmp/ro[pid]}] { |
162 |
> |
set curmess [exec cat /tmp/ro[pid]] |
163 |
> |
exec rm -f /tmp/ro[pid] |
164 |
|
return 0 |
165 |
|
} |
166 |
< |
set fi [open /usr/tmp/ro[pid] r] |
166 |
> |
set fi [open /tmp/ro[pid] r] |
167 |
|
if {"$vl" == "all"} { |
168 |
|
catch {unset radvar} |
169 |
|
while {[gets $fi curli] != -1} { |
170 |
< |
if [regexp {^[a-zA-Z][a-zA-Z0-9]*= } $curli] { |
170 |
> |
if [regexp {^[a-zA-Z][a-zA-Z0-9]* *=} $curli] { |
171 |
|
setradvar $curli |
172 |
|
} else { |
173 |
|
break |
176 |
|
set curmess {Project loaded.} |
177 |
|
} else { |
178 |
|
foreach n $vl { |
179 |
< |
set radvar($n) {} |
179 |
> |
if [regexp {[a-z][a-z]*} $n] { |
180 |
> |
set radvar($n) {} |
181 |
> |
} else { |
182 |
> |
catch {unset radvar($n)} |
183 |
> |
} |
184 |
|
} |
185 |
|
while {[gets $fi curli] != -1} { |
186 |
|
if [regexp {^[a-zA-Z][a-zA-Z0-9]* *=} $curli] { |
196 |
|
} |
197 |
|
set alldone [eof $fi] |
198 |
|
close $fi |
199 |
< |
exec rm -f /usr/tmp/ro[pid] |
199 |
> |
exec rm -f /tmp/ro[pid] |
200 |
|
preen |
201 |
|
return 1 |
202 |
|
} |
249 |
|
return 0 |
250 |
|
} |
251 |
|
} elseif {[file exists $f]} { |
252 |
+ |
set ftyp [file type $f] |
253 |
+ |
if { $ftyp != "file" } { |
254 |
+ |
beep |
255 |
+ |
set curmess "Selected file $f is a $ftyp." |
256 |
+ |
return 0 |
257 |
+ |
} |
258 |
|
if [tk_dialog .dlg {Verification} \ |
259 |
|
"Overwrite existing file $f?" \ |
260 |
|
questhead 1 {Go Ahead} {Cancel}] { |
261 |
|
return 0 |
262 |
|
} |
263 |
|
} |
264 |
+ |
if {[file isfile $f] && ! [file writable $f] && |
265 |
+ |
[catch {exec chmod u+w $f} curmess]} { |
266 |
+ |
beep |
267 |
+ |
return 0 |
268 |
+ |
} |
269 |
|
if [save_vars $f] { |
270 |
|
set rifname [pwd]/$f |
271 |
|
set readonly 0 |
278 |
|
proc newnew f { # create a new RIF |
279 |
|
global rifname readonly curmess radvar |
280 |
|
if [file exists $f] { |
281 |
+ |
set ftyp [file type $f] |
282 |
+ |
if { $ftyp != "file" } { |
283 |
+ |
beep |
284 |
+ |
set curmess "Selected file $f is a $ftyp." |
285 |
+ |
return 0 |
286 |
+ |
} |
287 |
|
if [tk_dialog .dlg {Verification} \ |
288 |
|
"File $f exists -- disregard it?" \ |
289 |
|
questhead 1 {Yes} {Cancel}] { |
301 |
|
} |
302 |
|
|
303 |
|
proc do_file w { |
304 |
< |
global rifname readonly rif_glob curfile curpat |
304 |
> |
global rifname readonly myglob curfile curpat |
305 |
|
if {"$w" == "done"} { |
306 |
|
cd [file dirname $rifname] |
307 |
< |
set rif_glob $curpat |
307 |
> |
set myglob(rif) $curpat |
308 |
|
return |
309 |
|
} |
310 |
|
frame $w |
312 |
|
pack $w.left -side left |
313 |
|
button $w.left.load -text LOAD -width 5 \ |
314 |
|
-relief raised -command {newload $curfile} |
315 |
< |
button $w.left.save -text SAVE -width 5 \ |
316 |
< |
-relief raised -command {newsave $curfile} |
315 |
> |
button $w.left.save -text SAVE -width 5 -relief raised \ |
316 |
> |
-command "newsave \$curfile; update_dir $w.right" |
317 |
|
button $w.left.new -text NEW -width 5 \ |
318 |
|
-relief raised -command {newnew $curfile} |
319 |
|
pack $w.left.load $w.left.save $w.left.new -side top -pady 15 -padx 20 |
325 |
|
helplink $w.left.new trad file new |
326 |
|
helplink $w.left.ro trad file readonly |
327 |
|
getfile -view view_txt -perm \ |
328 |
< |
-win $w.right -glob [file dirname $rifname]/$rif_glob |
328 |
> |
-win $w.right -glob [file dirname $rifname]/$myglob(rif) |
329 |
|
set curfile [file tail $rifname] |
330 |
|
} |