--- ray/src/util/do_file.tcl 1994/12/06 15:54:45 2.3 +++ ray/src/util/do_file.tcl 1996/05/17 13:53:07 2.13 @@ -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,7 @@ proc load_vars {f {vl all}} { # load RIF variables set curmess {Project loaded.} } else { foreach n $vl { - set radvar($n) {} + catch {unset radvar($n)} } while {[gets $fi curli] != -1} { if [regexp {^[a-zA-Z][a-zA-Z0-9]* *=} $curli] { @@ -236,12 +236,23 @@ 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 isfile $f] && ! [file writable $f] && + [catch {exec chmod u+w $f} curmess]} { + beep + return 0 + } if [save_vars $f] { set rifname [pwd]/$f set readonly 0 @@ -254,6 +265,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}] { @@ -271,10 +288,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 @@ -282,8 +299,8 @@ proc do_file w { pack $w.left -side left button $w.left.load -text LOAD -width 5 \ -relief raised -command {newload $curfile} - button $w.left.save -text SAVE -width 5 \ - -relief raised -command {newsave $curfile} + button $w.left.save -text SAVE -width 5 -relief raised \ + -command "newsave \$curfile; update_dir $w.right" button $w.left.new -text NEW -width 5 \ -relief raised -command {newnew $curfile} pack $w.left.load $w.left.save $w.left.new -side top -pady 15 -padx 20 @@ -295,6 +312,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] }