ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/trad.wsh
Revision: 2.4
Committed: Fri Oct 28 19:35:02 1994 UTC (29 years, 6 months ago) by greg
Branch: MAIN
Changes since 2.3: +1 -0 lines
Log Message:
added explicit cursor assignment for main window

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 .file invoke
50 set curmess {Rename file or uncheck read-only to save.}
51 return 0
52 } else {
53 catch {unset oldradvar}
54 save_vars $rifname
55 }
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 if $smallscrn {
79 frame .upper -geometry 640x410
80 frame .upper.right -geometry 120x410
81 } else {
82 frame .upper -geometry 830x410
83 frame .upper.right -geometry 130x410
84 }
85 pack .upper -side top
86 place .upper.right -relx .98 -rely 0 -anchor ne
87 message .mess -relief ridge -font fixed -textvariable curmess \
88 -anchor nw -width 620
89 pack .mess -side top -expand yes -fill both
90 helplink .mess trad trad messages
91 . configure -cursor top_left_arrow
92
93 # Make mode buttons
94
95 proc changescreen {} { # switch screen according to curmode
96 global curscreen curmode curmess smallscrn
97 if [info exists curscreen] {
98 if {"$curmode" == "$curscreen"} {return}
99 destroy .upper.left
100 do_$curscreen done
101 set curmess {}
102 }
103 set curscreen $curmode
104 do_$curscreen .upper.left
105 if $smallscrn {
106 .upper.left configure -geometry 520x410
107 } else {
108 .upper.left configure -geometry 700x410
109 }
110 place .upper.left -x 0 -y 0
111 }
112
113 label .upper.right.title -text "- TRAD -"
114 pack .upper.right.title -side top -pady 10
115
116 proc setbutt v {
117 radiobutton .$v -text [string toupper $v] \
118 -variable curmode -value $v \
119 -width 9 -relief groove -anchor w \
120 -command changescreen
121 pack .$v -in .upper.right -side top -pady 5
122 helplink .$v trad $v intro
123 }
124
125 setbutt file
126 setbutt scene
127 setbutt zone
128 setbutt views
129 setbutt options
130 setbutt action
131 setbutt results
132 rename setbutt {}
133 button .upper.right.help -text HELP -width 9 \
134 -command "gethelp trad trad intro"
135 pack .upper.right.help -side top -pady 10 -anchor se
136 helplink .upper.right.help trad trad help
137 button .upper.right.quit -text QUIT \
138 -command {if [chksave] {destroy .}} -width 9
139 pack .upper.right.quit -side top -pady 10 -anchor se
140 helplink .upper.right.quit trad trad quit
141
142 if $smallscrn {
143 wm minsize . 640 460
144 } else {
145 wm minsize . 830 460
146 }
147 wm iconbitmap . @$radlib/trad.icon
148
149 proc gotfile {{o 1}} { # set file possession state
150 global oldradvar radvar
151 catch {unset oldradvar}
152 if $o {
153 set mode normal
154 foreach n [array names radvar] {
155 set oldradvar($n) $radvar($n)
156 }
157 } else {
158 set mode disabled
159 }
160 foreach b {scene zone views options action results} {
161 .$b configure -state $mode
162 }
163 }
164
165 # Decide where to go and start
166
167 if {[llength $argv] == 0} {
168 gotfile 0
169 set curmess "Choose a Radiance project file."
170 .file invoke
171 } elseif {[llength $argv] == 1} {
172 cd [file dirname $argv]
173 set curfile [file tail $argv]
174 if {! [file exists $curfile]} {
175 newnew $argv
176 .scene invoke
177 } elseif {[newload $curfile]} {
178 if $alldone {
179 set curmess "All renderings are finished."
180 .results invoke
181 } else {
182 .action invoke
183 }
184 } else {
185 .file invoke
186 }
187 } else {
188 puts stderr {Usage: trad [rifname]}
189 exit 1
190 }