ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/trad.wsh
Revision: 2.15
Committed: Sat Feb 22 02:07:30 2003 UTC (21 years, 1 month ago) by greg
Branch: MAIN
CVS Tags: rad3R7P2, rad3R7P1, rad4R0, rad3R5, rad3R6, rad3R6P1, rad3R8, rad3R9
Changes since 2.14: +1 -1 lines
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

File Contents

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