ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/do_views3.6.tcl
Revision: 2.1
Committed: Thu Oct 27 15:56:09 1994 UTC (29 years, 5 months ago) by greg
Content type: application/x-tcl
Branch: MAIN
Log Message:
Initial revision

File Contents

# User Rev Content
1 greg 2.1 # SCCSid "$SunId$ LBL"
2     #
3     # Handle view parameters
4     #
5    
6     proc viewchange {nm el op} { # handle changes to radvar(view)
7     global radvar viewbox viewname viewopts
8     if {"$op" == "u"} {
9     set radvar(view) {}
10     trace variable radvar(view) wu viewchange
11     }
12     $viewbox delete 0 end
13     foreach v $radvar(view) {
14     $viewbox insert end [lindex $v 0]
15     }
16     }
17    
18     proc vnchange {nm el op} { # handle changes to viewname
19     global viewname vdefbutt radvar
20     if {"$viewname" == {}} {
21     $vdefbutt configure -text "Set Default" -state disabled
22     } elseif {$radvar(view) != {} &&
23     "[lindex [lindex $radvar(view) 0] 0]" == "$viewname"} {
24     $vdefbutt configure -text "Is Default" -state disabled
25     } else {
26     $vdefbutt configure -text "Set Default" -state normal
27     }
28     }
29    
30     proc selview {} { # change selected view
31     global radvar viewbox viewname viewopts viewseln
32     set viewseln [$viewbox curselection]
33     set viewname [$viewbox get $viewseln]
34     set viewopts [lrange [lindex $radvar(view) $viewseln] 1 end]
35     }
36    
37     proc addview {{pos end}} { # add current view
38     global radvar viewname viewopts curmess viewseln viewbox
39     if {$pos == -1} {return -1}
40     if {[llength $viewname] != 1} {
41     beep
42     set curmess "Illegal view name."
43     return -1
44     }
45     set curmess {}
46     set n [lsearch -glob $radvar(view) "$viewname *"]
47     if {$n >= 0} {
48     set radvar(view) [lreplace $radvar(view) $n $n]
49     if {"$pos" != "end" && $pos > $n} {incr pos -1}
50     }
51     if {"$pos" == "end"} {
52     set viewseln [llength $radvar(view)]
53     lappend radvar(view) "$viewname $viewopts"
54     } else {
55     set viewseln $pos
56     set radvar(view) [linsert $radvar(view) $pos \
57     "$viewname $viewopts"]
58     }
59     vnchange viewname {} w
60     $viewbox select from $pos
61     return $pos
62     }
63    
64     proc delview {} { # delete current view
65     global radvar viewbox curmess viewseln
66     if {! [info exists viewseln]} {
67     beep
68     set curmess "No view selected for deletion."
69     return -1
70     }
71     set n $viewseln
72     set curmess {}
73     set radvar(view) [lreplace $radvar(view) $n $n]
74     vnchange viewname {} w
75     unset viewseln
76     return $n
77     }
78    
79     proc copyviews rf { # copy view settings from another RIF
80     load_vars [file tail $rf] {view UP PICTURE RESOLUTION}
81     vnchange viewname {} w
82     }
83    
84     proc do_views w { # create views screen
85     global radvar viewbox viewseln viewname viewopts vdefbutt rifname
86     if {"$w" == "done"} {
87     trace vdelete radvar(view) wu viewchange
88     trace vdelete viewname w vnchange
89     unset viewbox viewname viewopts vdefbutt
90     return
91     }
92     frame $w
93     # View box
94     label $w.vvl -text Views
95     place $w.vvl -relx .0714 -rely .0610
96     frame $w.vnl
97     scrollbar $w.vnl.sb -relief sunken -command "$w.vnl.lb yview"
98     listbox $w.vnl.lb -relief sunken -yscroll "$w.vnl.sb set"
99     set viewbox $w.vnl.lb
100     tk_listboxSingleSelect $w.vnl.lb
101     bind $w.vnl.lb <ButtonRelease-1> +selview
102     pack $w.vnl.sb -side right -fill y
103     pack $w.vnl.lb -side left -expand yes -fill both
104     place $w.vnl -relwidth .1786 -relheight .3049 -relx .07143 -rely .1220
105     helplink $w.vnl.lb trad views list
106     # View name
107     set viewname {}
108     label $w.vnlb -text Name
109     place $w.vnlb -relx .2857 -rely .0610
110     entry $w.vne -textvariable viewname -relief sunken
111     place $w.vne -relwidth .1429 -relheight .0610 -relx .2857 -rely .1220
112     helplink $w.vne trad views name
113     # View options
114     set viewopts {}
115     label $w.vol -text Options
116     place $w.vol -relx .2857 -rely .1829
117     frame $w.vo
118     entry $w.vo.e -textvariable viewopts -relief sunken \
119     -scroll "$w.vo.s set"
120     scrollbar $w.vo.s -relief sunken -orient horiz -command "$w.vo.e view"
121     pack $w.vo.e $w.vo.s -side top -fill x
122     place $w.vo -relwidth .6429 -relheight .1000 -relx .2857 -rely .2439
123     helplink $w.vo.e trad views options
124     # View change buttons
125     button $w.vclr -text Clear -width 7 -relief raised \
126     -command "set viewname {} ; set viewopts {}
127     focus $w.vne
128     catch {unset viewseln}
129     $w.vnl.lb select clear"
130     place $w.vclr -relx .4643 -rely .1220
131     helplink $w.vclr trad views clear
132     button $w.vdef -text "Set Default" -width 12 \
133     -relief raised -state disabled -command {addview 0}
134     place $w.vdef -relx .6429 -rely .1220
135     helplink $w.vdef trad views default
136     set vdefbutt $w.vdef
137     button $w.vadd -text Add -width 7 -relief raised -command addview
138     place $w.vadd -relx .2857 -rely .3659
139     helplink $w.vadd trad views add
140     button $w.vchg -text Change -width 7 -relief raised \
141     -command {addview [delview]}
142     place $w.vchg -relx .4643 -rely .3659
143     helplink $w.vchg trad views change
144     button $w.vdel -text Delete -width 7 -relief raised -command delview
145     place $w.vdel -relx .6429 -rely .3659
146     helplink $w.vdel trad views delete
147     # Up vector
148     label $w.upl -text Up:
149     place $w.upl -relx .0714 -rely .4878
150     radiobutton $w.upxp -text +X -variable radvar(UP) -value X -relief flat
151     place $w.upxp -relx .2857 -rely .4634
152     radiobutton $w.upxn -text -X -variable radvar(UP) -value -X -relief flat
153     place $w.upxn -relx .2857 -rely .5244
154     radiobutton $w.upyp -text +Y -variable radvar(UP) -value Y -relief flat
155     place $w.upyp -relx .4286 -rely .4634
156     radiobutton $w.upyn -text -Y -variable radvar(UP) -value -Y -relief flat
157     place $w.upyn -relx .4286 -rely .5244
158     radiobutton $w.upzp -text +Z -variable radvar(UP) -value Z -relief flat
159     place $w.upzp -relx .5714 -rely .4634
160     radiobutton $w.upzn -text -Z -variable radvar(UP) -value -Z -relief flat
161     place $w.upzn -relx .5714 -rely .5244
162     helplink "$w.upxp $w.upxn $w.upyp $w.upyn $w.upzp $w.upzn" \
163     trad views up
164     # Picture file name
165     label $w.pfl -text Picture:
166     place $w.pfl -relx .0714 -rely .6498
167     entry $w.pfe -textvariable radvar(PICTURE) -relief sunken
168     place $w.pfe -relwidth .6429 -relheight .0610 -relx .2857 -rely .6498
169     helplink $w.pfe trad views picture
170     # Resolution
171     label $w.rzl -text Resolution:
172     place $w.rzl -relx .0714 -rely .7717
173     entry $w.rze -textvariable radvar(RESOLUTION) -relief sunken
174     place $w.rze -relwidth .2857 -relheight .0610 -relx .2857 -rely .7717
175     helplink $w.rze trad views resolution
176     # Revert and Copy buttons
177     button $w.revert -text Revert -relief raised \
178     -command "copyviews $rifname"
179     place $w.revert -relwidth .1071 -relheight .0610 -relx .98 -rely .98 \
180     -anchor se
181     helplink $w.revert trad views revert
182     button $w.copy -text Copy -relief raised -command {getfile \
183     -send copyviews -view view_txt -glob $rif_glob}
184     place $w.copy -relwidth .1071 -relheight .0610 -relx .98 -rely .90 \
185     -anchor se
186     helplink $w.copy trad views copy
187     # Assign focus
188     bind $w.vne <Return> "focus $w.vo.e"
189     bind $w.vo.e <Return> addview
190     bind $w.vo.e <B2-Motion> {}
191     bind $w.vo.e <Button-2> "$w.vo.e insert insert \[selection get\]"
192     $w.vclr invoke
193     # Track variables
194     vnchange viewname {} w
195     trace variable viewname w vnchange
196     if [info exists radvar(view)] {
197     viewchange radvar view w
198     trace variable radvar(view) wu viewchange
199     } else {
200     viewchange radvar view u
201     }
202     }