ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/do_file.tcl
(Generate patch)

Comparing ray/src/util/do_file.tcl (file contents):
Revision 2.1 by greg, Thu Oct 27 15:56:06 1994 UTC vs.
Revision 2.17 by greg, Sat Feb 22 02:07:30 2003 UTC

# Line 1 | Line 1
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} {
9 >                        RAWFILE ZFILE AMBFILE OPTFILE EXPOSURE ZONE REPORT} {
10                  if {! [info exists radvar($n)]} {
11                          set radvar($n) {}
12                  }
# Line 19 | Line 17 | proc preen {} {                        # clean up radvar
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
# Line 45 | Line 43 | proc preen {} {                        # clean up radvar
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 {
# Line 75 | Line 76 | proc preen {} {                        # clean up radvar
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 }
# Line 93 | Line 94 | proc setradvar stmt {          # assign a rad variable
94                  AMB* { set radvar(AMBFILE) $vval }
95                  OPT* { set radvar(OPTFILE) $vval }
96                  EXP* { set radvar(EXPOSURE) $vval }
97 +                EYE* { set radvar(EYESEP) $vval }
98                  RES* { set radvar(RESOLUTION) $vval }
99                  UP { set radvar(UP) $vval }
100                  IND* { set radvar(INDIRECT) $vval }
# Line 100 | Line 102 | proc setradvar stmt {          # assign a rad variable
102                  PEN* { set radvar(PENUMBRAS) $vval }
103                  VAR* { set radvar(VARIABILITY) $vval }
104                  REP* { set radvar(REPORT) $vval }
105 +                RAW* { set radvar(RAWFILE) $vval }
106 +                ZF* {set radvar(ZFILE) $vval }
107          }
108                  
109   }
# Line 119 | Line 123 | proc putradvar {fi vn} {       # print out a rad variable
123          }
124          if {[lsearch -exact {ZONE QUALITY OCTREE PICTURE AMBFILE OPTFILE
125                          EXPOSURE RESOLUTION UP INDIRECT DETAIL PENUMBRAS
126 <                        VARIABILITY REPORT} $vn] >= 0} {
126 >                        EYESEP RAWFILE ZFILE VARIABILITY REPORT} $vn] >= 0} {
127                  puts $fi "$vn= $radvar($vn)"
128                  return
129          }
# Line 141 | Line 145 | proc putradvar {fi vn} {       # print out a rad variable
145   proc load_vars {f {vl all}} {   # load RIF variables
146          global curmess radvar alldone
147          if {"$f" == ""} {return 0}
148 <        if {! [file exists $f]} {
148 >        if {! [file isfile $f]} {
149                  beep
150                  set curmess "$f: no such file."
151                  return 0
152          }
153          if {"$vl" == "all" && ! [chksave]} {return 0}
154          set curmess {Please wait...}
155 <        update idletasks
155 >        update
156          if [catch {exec rad -n -w -e $f >& /usr/tmp/ro[pid]}] {
157                  set curmess [exec cat /usr/tmp/ro[pid]]
158                  exec rm -f /usr/tmp/ro[pid]
# Line 158 | Line 162 | proc load_vars {f {vl all}} {  # load RIF variables
162          if {"$vl" == "all"} {
163                  catch {unset radvar}
164                  while {[gets $fi curli] != -1} {
165 <                        if [regexp {^[a-zA-Z][a-zA-Z0-9]*= } $curli] {
165 >                        if [regexp {^[a-zA-Z][a-zA-Z0-9]* *=} $curli] {
166                                  setradvar $curli
167                          } else {
168                                  break
# Line 167 | Line 171 | proc load_vars {f {vl all}} {  # load RIF variables
171                  set curmess {Project loaded.}
172          } else {
173                  foreach n $vl {
174 <                        set radvar($n) {}
174 >                        if [regexp {[a-z][a-z]*} $n] {
175 >                                set radvar($n) {}
176 >                        } else {
177 >                                catch {unset radvar($n)}
178 >                        }
179                  }
180                  while {[gets $fi curli] != -1} {
181                          if [regexp {^[a-zA-Z][a-zA-Z0-9]* *=} $curli] {
# Line 236 | Line 244 | proc newsave f {               # save a RIF
244                          return 0
245                  }
246          } elseif {[file exists $f]} {
247 +                set ftyp [file type $f]
248 +                if { $ftyp != "file" } {
249 +                        beep
250 +                        set curmess "Selected file $f is a $ftyp."
251 +                        return 0
252 +                }
253                  if [tk_dialog .dlg {Verification} \
254                                  "Overwrite existing file $f?" \
255                                  questhead 1 {Go Ahead} {Cancel}] {
256                          return 0
257                  }
258          }
259 +        if {[file isfile $f] && ! [file writable $f] &&
260 +                        [catch {exec chmod u+w $f} curmess]} {
261 +                beep
262 +                return 0
263 +        }
264          if [save_vars $f] {
265                  set rifname [pwd]/$f
266                  set readonly 0
# Line 254 | Line 273 | proc newsave f {               # save a RIF
273   proc newnew f {                 # create a new RIF
274          global rifname readonly curmess radvar
275          if [file exists $f] {
276 +                set ftyp [file type $f]
277 +                if { $ftyp != "file" } {
278 +                        beep
279 +                        set curmess "Selected file $f is a $ftyp."
280 +                        return 0
281 +                }
282                  if [tk_dialog .dlg {Verification} \
283                                  "File $f exists -- disregard it?" \
284                                  questhead 1 {Yes} {Cancel}] {
# Line 271 | Line 296 | proc newnew f {                        # create a new RIF
296   }
297  
298   proc do_file w {
299 <        global rifname readonly rif_glob curfile curpat
299 >        global rifname readonly myglob curfile curpat
300          if {"$w" == "done"} {
301 <                set rif_glob $curpat
301 >                cd [file dirname $rifname]
302 >                set myglob(rif) $curpat
303                  return
304          }
305          frame $w
# Line 281 | Line 307 | proc do_file w {
307          pack $w.left -side left
308          button $w.left.load -text LOAD -width 5 \
309                          -relief raised -command {newload $curfile}
310 <        button $w.left.save -text SAVE -width 5 \
311 <                        -relief raised -command {newsave $curfile}
310 >        button $w.left.save -text SAVE -width 5 -relief raised \
311 >                        -command "newsave \$curfile; update_dir $w.right"
312          button $w.left.new -text NEW -width 5 \
313                          -relief raised -command {newnew $curfile}
314          pack $w.left.load $w.left.save $w.left.new -side top -pady 15 -padx 20
# Line 294 | Line 320 | proc do_file w {
320          helplink $w.left.new trad file new
321          helplink $w.left.ro trad file readonly
322          getfile -view view_txt -perm \
323 <                        -win $w.right -glob [file dirname $rifname]/$rif_glob
323 >                        -win $w.right -glob [file dirname $rifname]/$myglob(rif)
324          set curfile [file tail $rifname]
325   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines