ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/trad.wsh
Revision: 2.17
Committed: Wed May 1 16:47:54 2019 UTC (3 years, 7 months ago) by greg
Branch: MAIN
CVS Tags: rad5R3, HEAD
Changes since 2.16: +2 -2 lines
Log Message:
Changed default path for wish to "/usr/bin/wish"

File Contents

# User Rev Content
1 greg 2.17 #!/usr/bin/wish
2     # RCSid: $Id: trad.wsh,v 2.16 2011/10/26 20:06:17 greg Exp $
3 greg 2.16 # the next line restarts using wish in case of shell execution \
4     exec wish "$0" "$@"
5 greg 2.1 #
6     # TCL/TK-based Rad Input File Editor
7     #
8    
9     # Insert our autoload directory (may require local system modification)
10    
11     set radlib /usr/local/lib/ray/tcl
12     set helplib $radlib
13    
14     set auto_path [linsert $auto_path 0 $radlib]
15    
16 greg 2.14 # Assign global globbing variables
17    
18     set myglob(rif) *.rif
19     set myglob(materials) *.mat
20     set myglob(illum) *.rad
21     set myglob(scene) *.rad
22     set myglob(objects) *
23    
24 greg 2.1 # Create required procedures
25    
26     proc modified {} { # check for radvar modification
27     global radvar oldradvar
28     if {! [info exists oldradvar]} {return 0}
29     foreach n [array names oldradvar] {
30     if {! [info exists radvar($n)] ||
31     "$radvar($n)" != "$oldradvar($n)"} {
32     return 1
33     }
34     }
35     return 0
36     }
37    
38     proc chksave {} { # check if RIF is saved and accost user if not
39     global readonly rifname oldradvar curmess
40 greg 2.9 if [modified] {
41     if $readonly {
42     set warnmess "You have modified variables, but the\
43     file \"[file tail $rifname]\" was opened read-only.
44 greg 2.1 Do you wish to save this information somehow?"
45 greg 2.9 set yesmess {Go to File Screen}
46     } else {
47     set warnmess "The file \"[file tail $rifname]\" has\
48     been modified since it was last saved.
49 greg 2.1 Do you wish to save it now?"
50 greg 2.9 set yesmess {Save File}
51     }
52 greg 2.1 switch [tk_dialog .dlg {File Modified} $warnmess \
53     warning 0 $yesmess {Discard Changes} \
54     {Cancel Operation}] {
55     1 { return 1 }
56     2 { return 0 }
57     }
58     if $readonly {
59 greg 2.8 set curmess {Rename file or uncheck read-only to save.}
60 greg 2.1 .file invoke
61     return 0
62 greg 2.7 } elseif {[save_vars $rifname]} {
63     gotfile 1
64     return 1
65 greg 2.9 }
66     return 0
67     }
68     return 1
69 greg 2.1 }
70    
71     # Set global variable default values
72    
73     set readonly 0
74     set alldone 0
75     set rifname [pwd]/
76    
77     # Propogate essential variables
78    
79     proc setrname {name elem op} {
80     global rifname
81     wm title . $rifname
82     wm iconname . [file tail $rifname]
83     }
84     trace variable rifname w setrname
85    
86     # Make main window frames
87    
88 greg 2.3 set smallscrn [expr [winfo screenwidth .] < 830]
89    
90 greg 2.5 message .mess -relief ridge -font fixed -textvariable curmess -anchor nw
91 greg 2.3 if $smallscrn {
92 greg 2.10 frame .upper -width 640 -height 410
93     frame .upper.right -width 120 -height 410
94 greg 2.5 .mess configure -width 640
95 greg 2.3 } else {
96 greg 2.10 frame .upper -width 830 -height 410
97     frame .upper.right -width 130 -height 410
98 greg 2.5 .mess configure -width 830
99 greg 2.3 }
100 greg 2.1 pack .upper -side top
101 greg 2.2 place .upper.right -relx .98 -rely 0 -anchor ne
102 greg 2.1 pack .mess -side top -expand yes -fill both
103     helplink .mess trad trad messages
104 greg 2.4 . configure -cursor top_left_arrow
105 greg 2.1
106     # Make mode buttons
107    
108     proc changescreen {} { # switch screen according to curmode
109 greg 2.3 global curscreen curmode curmess smallscrn
110 greg 2.1 if [info exists curscreen] {
111     if {"$curmode" == "$curscreen"} {return}
112     destroy .upper.left
113     do_$curscreen done
114     set curmess {}
115     }
116     set curscreen $curmode
117     do_$curscreen .upper.left
118 greg 2.3 if $smallscrn {
119 greg 2.10 .upper.left configure -width 520 -height 410
120 greg 2.3 } else {
121 greg 2.10 .upper.left configure -width 700 -height 410
122 greg 2.3 }
123 greg 2.1 place .upper.left -x 0 -y 0
124     }
125    
126     label .upper.right.title -text "- TRAD -"
127     pack .upper.right.title -side top -pady 10
128    
129     proc setbutt v {
130     radiobutton .$v -text [string toupper $v] \
131     -variable curmode -value $v \
132 greg 2.16 -width 10 -relief groove -anchor w \
133 greg 2.1 -command changescreen
134     pack .$v -in .upper.right -side top -pady 5
135     helplink .$v trad $v intro
136     }
137    
138     setbutt file
139     setbutt scene
140     setbutt zone
141     setbutt views
142     setbutt options
143     setbutt action
144     setbutt results
145     rename setbutt {}
146     button .upper.right.help -text HELP -width 9 \
147     -command "gethelp trad trad intro"
148 greg 2.11 pack .upper.right.help -side top -pady 5 -anchor se
149 greg 2.1 helplink .upper.right.help trad trad help
150     button .upper.right.quit -text QUIT \
151     -command {if [chksave] {destroy .}} -width 9
152 greg 2.11 pack .upper.right.quit -side top -pady 5 -anchor se
153 greg 2.1 helplink .upper.right.quit trad trad quit
154    
155 greg 2.3 if $smallscrn {
156     wm minsize . 640 460
157 greg 2.5 wm maxsize . 640 512
158 greg 2.3 } else {
159     wm minsize . 830 460
160 greg 2.5 wm maxsize . 830 512
161 greg 2.3 }
162 greg 2.1 wm iconbitmap . @$radlib/trad.icon
163    
164 greg 2.12 proc gotfile o { # set file possession state
165 greg 2.1 global oldradvar radvar
166     catch {unset oldradvar}
167     if $o {
168     set mode normal
169     foreach n [array names radvar] {
170     set oldradvar($n) $radvar($n)
171     }
172     } else {
173     set mode disabled
174     }
175     foreach b {scene zone views options action results} {
176     .$b configure -state $mode
177     }
178     }
179    
180     # Decide where to go and start
181    
182 greg 2.12 gotfile 0
183 greg 2.1 if {[llength $argv] == 0} {
184 greg 2.7 set curmess "Choose a Radiance project file."
185 greg 2.12 .file invoke
186 greg 2.1 } elseif {[llength $argv] == 1} {
187     cd [file dirname $argv]
188     set curfile [file tail $argv]
189 greg 2.13 if {! [file isfile $curfile]} {
190     if [newnew $curfile] {
191     .scene invoke
192     } else {
193     .file invoke
194     }
195 greg 2.1 } elseif {[newload $curfile]} {
196     if $alldone {
197     set curmess "All renderings are finished."
198     .results invoke
199     } else {
200     .action invoke
201     }
202     } else {
203     .file invoke
204     }
205     } else {
206     puts stderr {Usage: trad [rifname]}
207     exit 1
208     }