1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
|
# Copyright (C) 1999-2018
# Smithsonian Astrophysical Observatory, Cambridge, MA, USA
# For conditions of distribution and use, see copyright notice in "copyright"
package provide DS9 1.0
# used by backup
proc PlotLineTool {} {
global iap
PlotLine $iap(tt) [msgcat::mc {Line Plot Tool}] {} {} {} 2 {}
}
proc PlotLine {tt wtt title xaxis yaxis dim data} {
global iap
# make the window name unique
set ii [lsearch $iap(windows) $tt]
if {$ii>=0} {
incr iap(unique)
append tt $iap(unique)
}
# set the window title if none
if {$wtt == {}} {
set wtt $tt
}
set varname $tt
upvar #0 $varname var
global $varname
PlotLineProc $varname
PlotDialog $varname $wtt $title $xaxis $yaxis
PlotDialogLine $varname
PlotDataSet $varname $dim $data
$var(proc,updategraph) $varname
PlotStats $varname
PlotList $varname
}
proc PlotLineDialog {varname wtt title xaxis yaxis} {
upvar #0 $varname var
global $varname
PlotLineProc $varname
PlotDialog $varname $wtt $title $xaxis $yaxis
PlotDialogLine $varname
}
proc PlotLineProc {varname} {
upvar #0 $varname var
global $varname
set var(proc,updategraph) PlotUpdateGraph
set var(proc,updateelement) PlotLineUpdateElement
set var(proc,highlite) PlotLineHighliteElement
set var(proc,button) PlotLineButton
}
proc PlotDialogLine {varname} {
upvar #0 $varname var
global $varname
global ds9
# Data
$var(mb).data add checkbutton -label [msgcat::mc {Show}] \
-variable ${varname}(show) \
-command [list PlotLineUpdateElement $varname]
$var(mb).data add separator
$var(mb).data add cascade -label [msgcat::mc {Shape}] \
-menu $var(mb).data.shape
$var(mb).data add cascade -label [msgcat::mc {Smooth}] \
-menu $var(mb).data.smooth
$var(mb).data add cascade -label [msgcat::mc {Color}] \
-menu $var(mb).data.color
$var(mb).data add cascade -label [msgcat::mc {Width}] \
-menu $var(mb).data.width
$var(mb).data add cascade -label [msgcat::mc {Fill}] \
-menu $var(mb).data.fill
$var(mb).data add cascade -label [msgcat::mc {Error}] \
-menu $var(mb).data.error
$var(mb).data add separator
$var(mb).data add command -label "[msgcat::mc {Name}]..." \
-command [list DatasetNameDialog $varname]
# Shape
menu $var(mb).data.shape
$var(mb).data.shape add radiobutton \
-label [msgcat::mc {None}] \
-variable ${varname}(shape,symbol) -value none \
-command [list PlotLineUpdateElement $varname]
$var(mb).data.shape add radiobutton \
-label [msgcat::mc {Circle}] \
-variable ${varname}(shape,symbol) -value circle \
-command [list PlotLineUpdateElement $varname]
$var(mb).data.shape add radiobutton \
-label [msgcat::mc {Square}] \
-variable ${varname}(shape,symbol) -value square \
-command [list PlotLineUpdateElement $varname]
$var(mb).data.shape add radiobutton \
-label [msgcat::mc {Diamond}] \
-variable ${varname}(shape,symbol) -value diamond \
-command [list PlotLineUpdateElement $varname]
$var(mb).data.shape add radiobutton \
-label [msgcat::mc {Plus}] \
-variable ${varname}(shape,symbol) -value plus \
-command [list PlotLineUpdateElement $varname]
$var(mb).data.shape add radiobutton \
-label [msgcat::mc {Cross}] \
-variable ${varname}(shape,symbol) -value cross \
-command [list PlotLineUpdateElement $varname]
$var(mb).data.shape add radiobutton \
-label [msgcat::mc {Simple Plus}] \
-variable ${varname}(shape,symbol) -value splus \
-command [list PlotLineUpdateElement $varname]
$var(mb).data.shape add radiobutton \
-label [msgcat::mc {Simple Cross}] \
-variable ${varname}(shape,symbol) -value scross \
-command [list PlotLineUpdateElement $varname]
$var(mb).data.shape add radiobutton \
-label [msgcat::mc {Triangle}] \
-variable ${varname}(shape,symbol) -value triangle \
-command [list PlotLineUpdateElement $varname]
$var(mb).data.shape add radiobutton \
-label [msgcat::mc {Arrow}] \
-variable ${varname}(shape,symbol) -value arrow \
-command [list PlotLineUpdateElement $varname]
$var(mb).data.shape add separator
$var(mb).data.shape add checkbutton \
-label [msgcat::mc {Fill}] \
-variable ${varname}(shape,fill) \
-command [list PlotLineUpdateElement $varname]
$var(mb).data.shape add cascade -label [msgcat::mc {Color}] \
-menu $var(mb).data.shape.color
PlotColorMenu $var(mb).data.shape.color $varname shape,color \
[list PlotLineUpdateElement $varname]
# Smooth
menu $var(mb).data.smooth
$var(mb).data.smooth add radiobutton \
-label [msgcat::mc {Step}] \
-variable ${varname}(smooth) -value step \
-command [list PlotLineUpdateElement $varname]
$var(mb).data.smooth add radiobutton \
-label [msgcat::mc {Linear}] \
-variable ${varname}(smooth) -value linear \
-command [list PlotLineUpdateElement $varname]
$var(mb).data.smooth add radiobutton \
-label [msgcat::mc {Cubic}] \
-variable ${varname}(smooth) -value cubic \
-command [list PlotLineUpdateElement $varname]
$var(mb).data.smooth add radiobutton \
-label [msgcat::mc {Quadratic}] \
-variable ${varname}(smooth) -value quadratic \
-command [list PlotLineUpdateElement $varname]
$var(mb).data.smooth add radiobutton \
-label [msgcat::mc {Catrom}] \
-variable ${varname}(smooth) -value catrom \
-command [list PlotLineUpdateElement $varname]
# Color
PlotColorMenu $var(mb).data.color $varname color \
[list PlotLineUpdateElement $varname]
# Width
menu $var(mb).data.width
$var(mb).data.width add radiobutton \
-label {0} -variable ${varname}(width) \
-value 0 -command [list PlotLineUpdateElement $varname]
$var(mb).data.width add radiobutton \
-label {1} -variable ${varname}(width) \
-value 1 -command [list PlotLineUpdateElement $varname]
$var(mb).data.width add radiobutton \
-label {2} -variable ${varname}(width) \
-value 2 -command [list PlotLineUpdateElement $varname]
$var(mb).data.width add radiobutton \
-label {3} -variable ${varname}(width) \
-value 3 -command [list PlotLineUpdateElement $varname]
$var(mb).data.width add radiobutton \
-label {4} -variable ${varname}(width) \
-value 4 -command [list PlotLineUpdateElement $varname]
$var(mb).data.width add separator
$var(mb).data.width add checkbutton \
-label [msgcat::mc {Dash}] -variable ${varname}(dash) \
-command [list PlotLineUpdateElement $varname]
# Fill
menu $var(mb).data.fill
$var(mb).data.fill add checkbutton \
-label [msgcat::mc {Show}] \
-variable ${varname}(fill) \
-command [list PlotLineUpdateElement $varname]
$var(mb).data.fill add separator
$var(mb).data.fill add cascade -label [msgcat::mc {Color}] \
-menu $var(mb).data.fill.color
PlotColorMenu $var(mb).data.fill.color $varname fill,color \
[list PlotLineUpdateElement $varname]
# Error
menu $var(mb).data.error
$var(mb).data.error add checkbutton -label [msgcat::mc {Show}] \
-variable ${varname}(error) \
-command [list PlotLineUpdateElement $varname]
$var(mb).data.error add checkbutton -label [msgcat::mc {Cap}] \
-variable ${varname}(error,cap) \
-command [list PlotLineUpdateElement $varname]
$var(mb).data.error add separator
$var(mb).data.error add cascade -label [msgcat::mc {Color}] \
-menu $var(mb).data.error.color
$var(mb).data.error add cascade -label [msgcat::mc {Width}] \
-menu $var(mb).data.error.width
PlotColorMenu $var(mb).data.error.color $varname error,color \
[list PlotLineUpdateElement $varname]
WidthDashMenu $var(mb).data.error.width $varname error,width {} \
[list PlotLineUpdateElement $varname] {}
# graph
set var(type) line
set var(graph) [ttk::frame $var(top).fr]
set var(plot) [blt::graph $var(graph).line \
-width 600 \
-height 500 \
-highlightthickness 0 \
]
pack $var(plot) -expand yes -fill both
pack $var(graph) -expand yes -fill both
# set up zoom stack, assuming mode is zoom
switch $ds9(wm) {
x11 -
win32 {Blt_ZoomStack $var(plot) -mode release}
aqua {Blt_ZoomStack $var(plot) -mode release -button "ButtonPress-2"}
}
}
proc PlotLineUpdateElement {varname} {
upvar #0 $varname var
global $varname
# warning: uses current vars
if {$var(data,total) == 0} {
return
}
set nn $var(data,current)
PlotGetVar $varname $nn
if {$var(fill)} {
set fillClr $var(fill,color)
} else {
set fillClr {}
}
if {$var(shape,fill)} {
set clr $var(shape,color)
} else {
set clr {}
}
if {$var(dash)} {
set dash {8 3}
} else {
set dash { }
}
if {$var(error)} {
set show both
} else {
set show none
}
if {$var(error,cap)} {
set cap [expr $var(error,width)+3]
} else {
set cap 0
}
$var(plot) element configure "d-${nn}" \
-label $var(name) -hide [expr !$var(show)] \
-symbol $var(shape,symbol) -fill $clr -scalesymbols no \
-pixels 5 -outline $var(shape,color) \
-smooth $var(smooth) \
-color $var(color) -areabackground $fillClr \
-linewidth $var(width) -dashes $dash \
-showerrorbars $show -errorbarcolor $var(error,color) \
-errorbarwidth $var(error,width) -errorbarcap $cap
}
proc PlotLineButton {varname x y} {
upvar #0 $varname var
global $varname
}
proc PlotLineHighliteElement {varname rowlist} {
upvar #0 $varname var
global $varname
}
|