ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/trad.wsh
Revision: 2.10
Committed: Mon Jul 24 13:31:26 1995 UTC (28 years, 8 months ago) by greg
Branch: MAIN
Changes since 2.9: +6 -6 lines
Log Message:
changed -geometry specification to -width -height

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 [modified] {
31 if $readonly {
32 set warnmess "You have modified variables, but the\
33 file \"[file tail $rifname]\" was opened read-only.
34 Do you wish to save this information somehow?"
35 set yesmess {Go to File Screen}
36 } else {
37 set warnmess "The file \"[file tail $rifname]\" has\
38 been modified since it was last saved.
39 Do you wish to save it now?"
40 set yesmess {Save File}
41 }
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 }
56 return 0
57 }
58 return 1
59 }
60
61 # Set global variable default values
62
63 set readonly 0
64 set alldone 0
65 set rifname [pwd]/
66
67 # Propogate essential variables
68
69 proc setrname {name elem op} {
70 global rifname
71 wm title . $rifname
72 wm iconname . [file tail $rifname]
73 }
74 trace variable rifname w setrname
75
76 # Make main window frames
77
78 set smallscrn [expr [winfo screenwidth .] < 830]
79
80 message .mess -relief ridge -font fixed -textvariable curmess -anchor nw
81 if $smallscrn {
82 frame .upper -width 640 -height 410
83 frame .upper.right -width 120 -height 410
84 .mess configure -width 640
85 } else {
86 frame .upper -width 830 -height 410
87 frame .upper.right -width 130 -height 410
88 .mess configure -width 830
89 }
90 pack .upper -side top
91 place .upper.right -relx .98 -rely 0 -anchor ne
92 pack .mess -side top -expand yes -fill both
93 helplink .mess trad trad messages
94 . configure -cursor top_left_arrow
95
96 # Make mode buttons
97
98 proc changescreen {} { # switch screen according to curmode
99 global curscreen curmode curmess smallscrn
100 if [info exists curscreen] {
101 if {"$curmode" == "$curscreen"} {return}
102 destroy .upper.left
103 do_$curscreen done
104 set curmess {}
105 }
106 set curscreen $curmode
107 do_$curscreen .upper.left
108 if $smallscrn {
109 .upper.left configure -width 520 -height 410
110 } else {
111 .upper.left configure -width 700 -height 410
112 }
113 place .upper.left -x 0 -y 0
114 }
115
116 label .upper.right.title -text "- TRAD -"
117 pack .upper.right.title -side top -pady 10
118
119 proc setbutt v {
120 radiobutton .$v -text [string toupper $v] \
121 -variable curmode -value $v \
122 -width 9 -relief groove -anchor w \
123 -command changescreen
124 pack .$v -in .upper.right -side top -pady 5
125 helplink .$v trad $v intro
126 }
127
128 setbutt file
129 setbutt scene
130 setbutt zone
131 setbutt views
132 setbutt options
133 setbutt action
134 setbutt results
135 rename setbutt {}
136 button .upper.right.help -text HELP -width 9 \
137 -command "gethelp trad trad intro"
138 pack .upper.right.help -side top -pady 10 -anchor se
139 helplink .upper.right.help trad trad help
140 button .upper.right.quit -text QUIT \
141 -command {if [chksave] {destroy .}} -width 9
142 pack .upper.right.quit -side top -pady 10 -anchor se
143 helplink .upper.right.quit trad trad quit
144
145 if $smallscrn {
146 wm minsize . 640 460
147 wm maxsize . 640 512
148 } else {
149 wm minsize . 830 460
150 wm maxsize . 830 512
151 }
152 wm iconbitmap . @$radlib/trad.icon
153
154 proc gotfile {{o 1}} { # set file possession state
155 global oldradvar radvar
156 catch {unset oldradvar}
157 if $o {
158 set mode normal
159 foreach n [array names radvar] {
160 set oldradvar($n) $radvar($n)
161 }
162 } else {
163 set mode disabled
164 .file invoke
165 }
166 foreach b {scene zone views options action results} {
167 .$b configure -state $mode
168 }
169 }
170
171 # Decide where to go and start
172
173 if {[llength $argv] == 0} {
174 set curmess "Choose a Radiance project file."
175 gotfile 0
176 } elseif {[llength $argv] == 1} {
177 cd [file dirname $argv]
178 set curfile [file tail $argv]
179 if {! [file exists $curfile]} {
180 newnew $curfile
181 .scene invoke
182 } elseif {[newload $curfile]} {
183 if $alldone {
184 set curmess "All renderings are finished."
185 .results invoke
186 } else {
187 .action invoke
188 }
189 } else {
190 .file invoke
191 }
192 } else {
193 puts stderr {Usage: trad [rifname]}
194 exit 1
195 }