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.7 by greg, Tue Mar 21 16:19:26 1995 UTC vs.
Revision 2.22 by greg, Sat Aug 26 16:07:22 2017 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} {
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                  }
# 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 }
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 }
# Line 93 | Line 97 | proc setradvar stmt {          # assign a rad variable
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 }
# Line 100 | Line 105 | proc setradvar stmt {          # assign a rad variable
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   }
# Line 117 | Line 126 | proc putradvar {fi vn} {       # print out a rad variable
126                  }
127                  return
128          }
120        if {[lsearch -exact {ZONE QUALITY OCTREE PICTURE AMBFILE OPTFILE
121                        EXPOSURE RESOLUTION UP INDIRECT DETAIL PENUMBRAS
122                        VARIABILITY REPORT} $vn] >= 0} {
123                puts $fi "$vn= $radvar($vn)"
124                return
125        }
129          puts -nonewline $fi "$vn="
130          set vnl [expr [string length $vn] + 1]
131          set pos $vnl
# Line 141 | Line 144 | proc putradvar {fi vn} {       # print out a rad variable
144   proc load_vars {f {vl all}} {   # load RIF variables
145          global curmess radvar alldone
146          if {"$f" == ""} {return 0}
147 <        if {! [file exists $f]} {
147 >        if {! [file isfile $f]} {
148                  beep
149                  set curmess "$f: no such file."
150                  return 0
# Line 149 | Line 152 | proc load_vars {f {vl all}} {  # load RIF variables
152          if {"$vl" == "all" && ! [chksave]} {return 0}
153          set curmess {Please wait...}
154          update
155 <        if [catch {exec rad -n -w -e $f >& /usr/tmp/ro[pid]}] {
156 <                set curmess [exec cat /usr/tmp/ro[pid]]
157 <                exec rm -f /usr/tmp/ro[pid]
155 >        if [catch {exec rad -n -w -e $f >& /tmp/ro[pid]}] {
156 >                set curmess [exec cat /tmp/ro[pid]]
157 >                exec rm -f /tmp/ro[pid]
158                  return 0
159          }
160 <        set fi [open /usr/tmp/ro[pid] r]
160 >        set fi [open /tmp/ro[pid] r]
161          if {"$vl" == "all"} {
162                  catch {unset radvar}
163                  while {[gets $fi curli] != -1} {
164 <                        if [regexp {^[a-zA-Z][a-zA-Z0-9]*= } $curli] {
164 >                        if [regexp {^[a-zA-Z][a-zA-Z0-9]* *=} $curli] {
165                                  setradvar $curli
166                          } else {
167                                  break
# Line 167 | Line 170 | proc load_vars {f {vl all}} {  # load RIF variables
170                  set curmess {Project loaded.}
171          } else {
172                  foreach n $vl {
173 <                        catch {unset radvar($n)}
173 >                        if [regexp {[a-z][a-z]*} $n] {
174 >                                set radvar($n) {}
175 >                        } else {
176 >                                catch {unset radvar($n)}
177 >                        }
178                  }
179                  while {[gets $fi curli] != -1} {
180                          if [regexp {^[a-zA-Z][a-zA-Z0-9]* *=} $curli] {
# Line 183 | Line 190 | proc load_vars {f {vl all}} {  # load RIF variables
190          }
191          set alldone [eof $fi]
192          close $fi
193 <        exec rm -f /usr/tmp/ro[pid]
193 >        exec rm -f /tmp/ro[pid]
194          preen
195          return 1
196   }
# Line 236 | Line 243 | proc newsave f {               # save a RIF
243                          return 0
244                  }
245          } elseif {[file exists $f]} {
246 +                set ftyp [file type $f]
247 +                if { $ftyp != "file" } {
248 +                        beep
249 +                        set curmess "Selected file $f is a $ftyp."
250 +                        return 0
251 +                }
252                  if [tk_dialog .dlg {Verification} \
253                                  "Overwrite existing file $f?" \
254                                  questhead 1 {Go Ahead} {Cancel}] {
255                          return 0
256                  }
257          }
258 <        if {[file exists $f] && ! [file writable $f] &&
258 >        if {[file isfile $f] && ! [file writable $f] &&
259                          [catch {exec chmod u+w $f} curmess]} {
260                  beep
261                  return 0
# Line 259 | Line 272 | proc newsave f {               # save a RIF
272   proc newnew f {                 # create a new RIF
273          global rifname readonly curmess radvar
274          if [file exists $f] {
275 +                set ftyp [file type $f]
276 +                if { $ftyp != "file" } {
277 +                        beep
278 +                        set curmess "Selected file $f is a $ftyp."
279 +                        return 0
280 +                }
281                  if [tk_dialog .dlg {Verification} \
282                                  "File $f exists -- disregard it?" \
283                                  questhead 1 {Yes} {Cancel}] {
# Line 276 | Line 295 | proc newnew f {                        # create a new RIF
295   }
296  
297   proc do_file w {
298 <        global rifname readonly rif_glob curfile curpat
298 >        global rifname readonly myglob curfile curpat
299          if {"$w" == "done"} {
300                  cd [file dirname $rifname]
301 <                set rif_glob $curpat
301 >                set myglob(rif) $curpat
302                  return
303          }
304          frame $w
# Line 300 | Line 319 | proc do_file w {
319          helplink $w.left.new trad file new
320          helplink $w.left.ro trad file readonly
321          getfile -view view_txt -perm \
322 <                        -win $w.right -glob [file dirname $rifname]/$rif_glob
322 >                        -win $w.right -glob [file dirname $rifname]/$myglob(rif)
323          set curfile [file tail $rifname]
324   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines