--- ray/src/util/do_file.tcl 1994/12/08 17:16:38 2.5 +++ ray/src/util/do_file.tcl 1996/07/10 11:48:58 2.14 @@ -3,12 +3,10 @@ # Choose the Rad Input File to work on. # -set rif_glob *.rif - proc preen {} { # clean up radvar global radvar rifname foreach n {objects scene materials illum mkillum render oconv pfilt - AMBFILE OPTFILE EXPOSURE ZONE REPORT} { + RAWFILE ZFILE AMBFILE OPTFILE EXPOSURE ZONE REPORT} { if {! [info exists radvar($n)]} { set radvar($n) {} } @@ -19,7 +17,7 @@ proc preen {} { # clean up radvar set n 1 foreach v $oldval { if {"[string index $v 0]" == "-"} { - lappend radvar(view) "$n $v" + lappend radvar(view) "u$n $v" } elseif {[lsearch -glob $radvar(view) \ "[lindex $v 0] *"] >= 0} { continue @@ -100,6 +98,8 @@ proc setradvar stmt { # assign a rad variable PEN* { set radvar(PENUMBRAS) $vval } VAR* { set radvar(VARIABILITY) $vval } REP* { set radvar(REPORT) $vval } + RAW* { set radvar(RAWFILE) $vval } + ZF* {set radvar(ZFILE) $vval } } } @@ -119,7 +119,7 @@ proc putradvar {fi vn} { # print out a rad variable } if {[lsearch -exact {ZONE QUALITY OCTREE PICTURE AMBFILE OPTFILE EXPOSURE RESOLUTION UP INDIRECT DETAIL PENUMBRAS - VARIABILITY REPORT} $vn] >= 0} { + RAWFILE ZFILE VARIABILITY REPORT} $vn] >= 0} { puts $fi "$vn= $radvar($vn)" return } @@ -141,7 +141,7 @@ proc putradvar {fi vn} { # print out a rad variable proc load_vars {f {vl all}} { # load RIF variables global curmess radvar alldone if {"$f" == ""} {return 0} - if {! [file exists $f]} { + if {! [file isfile $f]} { beep set curmess "$f: no such file." return 0 @@ -167,7 +167,11 @@ proc load_vars {f {vl all}} { # load RIF variables set curmess {Project loaded.} } else { foreach n $vl { - set radvar($n) {} + if [regexp {[a-z][a-z]*} $n] { + set radvar($n) {} + } else { + catch {unset radvar($n)} + } } while {[gets $fi curli] != -1} { if [regexp {^[a-zA-Z][a-zA-Z0-9]* *=} $curli] { @@ -236,13 +240,20 @@ proc newsave f { # save a RIF return 0 } } elseif {[file exists $f]} { + set ftyp [file type $f] + if { $ftyp != "file" } { + beep + set curmess "Selected file $f is a $ftyp." + return 0 + } if [tk_dialog .dlg {Verification} \ "Overwrite existing file $f?" \ questhead 1 {Go Ahead} {Cancel}] { return 0 } } - if {! [file writable $f] && [catch {exec chmod u+w $f} curmess]} { + if {[file isfile $f] && ! [file writable $f] && + [catch {exec chmod u+w $f} curmess]} { beep return 0 } @@ -258,6 +269,12 @@ proc newsave f { # save a RIF proc newnew f { # create a new RIF global rifname readonly curmess radvar if [file exists $f] { + set ftyp [file type $f] + if { $ftyp != "file" } { + beep + set curmess "Selected file $f is a $ftyp." + return 0 + } if [tk_dialog .dlg {Verification} \ "File $f exists -- disregard it?" \ questhead 1 {Yes} {Cancel}] { @@ -275,10 +292,10 @@ proc newnew f { # create a new RIF } proc do_file w { - global rifname readonly rif_glob curfile curpat + global rifname readonly myglob curfile curpat if {"$w" == "done"} { cd [file dirname $rifname] - set rif_glob $curpat + set myglob(rif) $curpat return } frame $w @@ -299,6 +316,6 @@ proc do_file w { helplink $w.left.new trad file new helplink $w.left.ro trad file readonly getfile -view view_txt -perm \ - -win $w.right -glob [file dirname $rifname]/$rif_glob + -win $w.right -glob [file dirname $rifname]/$myglob(rif) set curfile [file tail $rifname] }