ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/trad.wsh
Revision: 2.3
Committed: Fri Oct 28 17:55:06 1994 UTC (29 years, 5 months ago) by greg
Branch: MAIN
Changes since 2.2: +20 -5 lines
Log Message:
made windows compatible with large AND small screens

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