ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/trad.wsh
Revision: 2.8
Committed: Mon Nov 28 12:15:18 1994 UTC (29 years, 4 months ago) by greg
Branch: MAIN
Changes since 2.7: +1 -1 lines
Log Message:
minor change

File Contents

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