ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/trad.wsh
Revision: 2.2
Committed: Fri Oct 28 10:43:38 1994 UTC (29 years, 5 months ago) by greg
Branch: MAIN
Changes since 2.1: +6 -6 lines
Log Message:
fixed size defaults for smaller dispaly

File Contents

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