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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
|
# 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
proc PrefsDialogPlot {} {
global dprefs
set w $dprefs(tab)
$dprefs(list) insert end [msgcat::mc {Plot}]
lappend dprefs(tabs) [ttk::frame $w.plot]
# Graph
set f [ttk::labelframe $w.plot.graph -text [msgcat::mc {Graph}]]
ttk::label $f.tbg -text [msgcat::mc {Background}]
ColorMenuButton $f.bg pap background {}
grid $f.tbg $f.bg -padx 2 -pady 2 -sticky w
# Grid
set f [ttk::labelframe $w.plot.grid -text [msgcat::mc {Grid}]]
ttk::label $f.ttitle -text [msgcat::mc {Title}]
FontMenuButton $f.title pap graph,title,family graph,title,size graph,title,weight graph,title,slant {}
grid $f.ttitle $f.title -padx 2 -pady 2 -sticky w
# Axis
set f [ttk::labelframe $w.plot.axis -text [msgcat::mc {Axis}]]
ttk::label $f.xtitle -text [msgcat::mc {X}]
ttk::checkbutton $f.x -text [msgcat::mc {Grid}] -variable pap(graph,axis,x,grid)
ttk::radiobutton $f.xlinear -text [msgcat::mc {Linear}] \
-variable pap(graph,axis,x,log) -value 0
ttk::radiobutton $f.xlog -text [msgcat::mc {Log}] \
-variable pap(graph,axis,x,log) -value 1
ttk::label $f.ytitle -text [msgcat::mc {Y}]
ttk::checkbutton $f.y -text [msgcat::mc {Grid}] -variable pap(graph,axis,y,grid)
ttk::radiobutton $f.ylinear -text [msgcat::mc {Linear}] \
-variable pap(graph,axis,y,log) -value 0
ttk::radiobutton $f.ylog -text [msgcat::mc {Log}] \
-variable pap(graph,axis,y,log) -value 1
ttk::label $f.ttextlab -text [msgcat::mc {Axis Title}]
FontMenuButton $f.textlab pap axis,title,family axis,title,size axis,title,weight axis,title,slant {}
ttk::label $f.tnumlab -text [msgcat::mc {Axis Numbers}]
FontMenuButton $f.numlab pap axis,font,family axis,font,size axis,font,weight axis,font,slant {}
grid $f.xtitle $f.x $f.xlinear $f.xlog -padx 2 -pady 2 -sticky w
grid $f.ytitle $f.y $f.ylinear $f.ylog -padx 2 -pady 2 -sticky w
grid $f.ttextlab $f.textlab -padx 2 -pady 2 -sticky w
grid $f.tnumlab $f.numlab -padx 2 -pady 2 -sticky w
# Data
set f [ttk::labelframe $w.plot.data -text [msgcat::mc {Dataset}]]
# Show
ttk::checkbutton $f.show -text [msgcat::mc {Show}] \
-variable pap(graph,ds,show)
grid $f.show -padx 2 -pady 2 -sticky w
# Shape
ttk::label $f.shapetitle -text [msgcat::mc {Shape}]
ttk::menubutton $f.shape -textvariable pap(graph,ds,shape,symbol) \
-menu $f.shape.menu
PlotLineShapeMenu $f.shape.menu pap(graph,ds,shape,symbol)
ttk::checkbutton $f.shapefill -text [msgcat::mc {Fill}] \
-variable pap(graph,ds,shape,fill)
ColorMenuButton $f.shapecolor pap graph,ds,shape,color {}
grid $f.shapetitle $f.shape $f.shapefill $f.shapecolor \
-padx 2 -pady 2 -sticky w
# Smooth
ttk::label $f.smoothtitle -text [msgcat::mc {Smooth}]
ttk::menubutton $f.smooth -textvariable pap(graph,ds,smooth) \
-menu $f.smooth.menu
menu $f.smooth.menu
$f.smooth.menu add radiobutton -label [msgcat::mc {Step}] \
-variable pap(graph,ds,smooth) -value step
$f.smooth.menu add radiobutton -label [msgcat::mc {Linear}] \
-variable pap(graph,ds,smooth) -value linear
$f.smooth.menu add radiobutton -label [msgcat::mc {Cubic}] \
-variable pap(graph,ds,smooth) -value cubic
$f.smooth.menu add radiobutton -label [msgcat::mc {Quadratic}] \
-variable pap(graph,ds,smooth) -value quadratic
$f.smooth.menu add radiobutton -label [msgcat::mc {Catrom}] \
-variable pap(graph,ds,smooth) -value catrom
grid $f.smoothtitle $f.smooth -padx 2 -pady 2 -sticky w
# Color
ttk::label $f.colortitle -text [msgcat::mc {Color}]
ColorMenuButton $f.color pap graph,ds,color {}
grid $f.colortitle $f.color -padx 2 -pady 2 -sticky w
# Width
ttk::label $f.widthtitle -text [msgcat::mc {Width}]
ttk::menubutton $f.width -textvariable pap(graph,ds,width) \
-menu $f.width.menu
WidthDashMenu $f.width.menu pap graph,ds,width graph,ds,dash {} {}
grid $f.widthtitle $f.width -padx 2 -pady 2 -sticky w
# Error
ttk::label $f.errortitle -text [msgcat::mc {Error}]
ttk::checkbutton $f.error -text [msgcat::mc {Show}] \
-variable pap(graph,ds,error)
ttk::checkbutton $f.errorcap -text [msgcat::mc {Cap}] \
-variable pap(graph,ds,error,cap)
ColorMenuButton $f.errorcolor pap graph,ds,error,color {}
ttk::menubutton $f.errorwidth -textvariable pap(graph,ds,error,width) \
-menu $f.errorwidth.menu
WidthDashMenu $f.errorwidth.menu pap \
graph,ds,error,width graph,ds,error,dash {} {}
grid $f.errortitle $f.error $f.errorcap $f.errorcolor $f.errorwidth \
-padx 2 -pady 2 -sticky w
pack $w.plot.graph $w.plot.grid $w.plot.axis $w.plot.data \
-side top -fill both -expand true
}
proc ProcessPlotCmd {xarname iname buf fn} {
upvar $xarname xar
upvar $iname i
global iap
global parse
set parse(buf) $buf
set parse(fn) $fn
set parse(tt) $iap(tt)
set ref [lindex $iap(windows) end]
global cvarname
set cvarname $ref
plot::YY_FLUSH_BUFFER
plot::yy_scan_string [lrange $xar $i end]
plot::yyparse
incr i [expr $plot::yycnt-1]
}
proc PlotCmdCheck {} {
global cvarname
upvar #0 $cvarname cvar
if {![info exists cvar(top)]} {
Error "[msgcat::mc {Unable to find plot window}] $cvarname"
return 0
}
if {![winfo exists $cvar(top)]} {
Error "[msgcat::mc {Unable to find plot window}] $cvarname"
return 0
}
return 1
}
proc PlotCmdRef {ref} {
global iap
global cvarname
# look for reference in current list
if {[lsearch $iap(windows) $ref] < 0} {
Error "[msgcat::mc {Unable to find plot window}] $ref"
return 0
}
set cvarname $ref
return [PlotCmdCheck]
}
proc PlotCmdNew {name} {
global parse
if {$name != {}} {
set parse(tt) $name
}
if {$parse(buf) != {}} {
return
} elseif {$parse(fn) != {}} {
if {[file exists $parse(fn)]} {
set ch [open $parse(fn) r]
set parse(buf) [read $ch]
close $ch
return
}
}
set parse(buf) {}
}
proc PlotCmdLine {title xaxis yaxis dim} {
global parse
PlotLine $parse(tt) {} $title $xaxis $yaxis $dim $parse(buf)
}
proc PlotCmdBar {title xaxis yaxis dim} {
global parse
PlotBar $parse(tt) {} $title $xaxis $yaxis $dim $parse(buf)
}
proc PlotCmdScatter {title xaxis yaxis dim} {
global parse
PlotScatter $parse(tt) {} $title $xaxis $yaxis $dim $parse(buf)
}
proc PlotCmdStrip {title xaxis yaxis dim} {
global parse
PlotStrip $parse(tt) {} $title $xaxis $yaxis $dim $parse(buf)
}
proc PlotCmdAnalysisPlotStdin {which} {
global parse
AnalysisPlotStdin $which $parse(tt) {} $parse(buf)
}
proc PlotCmdData {dim} {
global parse
global cvarname
upvar #0 $cvarname cvar
if {$parse(buf) == {}} {
if {$parse(fn) != {}} {
if {[file exists $parse(fn)]} {
set ch [open $parse(fn) r]
set parse(buf) [read $ch]
close $ch
}
}
if {$parse(buf) == {}} {
Error "[msgcat::mc {Unable to load plot data}] $fn"
}
}
PlotRaise $cvarname
PlotDataSet $cvarname $dim $parse(buf)
$cvar(proc,updategraph) $cvarname
PlotStats $cvarname
PlotList $cvarname
}
proc PlotCmdLoad {fn dim} {
global cvarname
if {$fn != {}} {
PlotLoadDataFile $cvarname $fn $dim
FileLast apdatafbox $fn
}
}
proc PlotCmdSave {fn} {
global cvarname
if {$fn != {}} {
PlotSaveDataFile $cvarname $fn
FileLast apdatafbox $fn
}
}
proc PlotCmdLoadConfig {fn} {
global cvarname
if {$fn != {}} {
PlotLoadConfigFile $cvarname $fn
FileLast apconfigfbox $fn
}
}
proc PlotCmdSaveConfig {fn} {
global cvarname
if {$fn != {}} {
PlotSaveConfigFile $cvarname $fn
FileLast apconfigfbox $fn
}
}
proc PlotCmdUpdateCanvas {which value} {
global cvarname
upvar #0 $cvarname cvar
set cvar($which) $value
$cvar(proc,updatecanvas) $cvarname
}
proc PlotCmdUpdateGraph {which value} {
global cvarname
upvar #0 $cvarname cvar
set cvar($which) $value
$cvar(proc,updategraph) $cvarname
}
proc PlotCmdUpdateElement {which value} {
global cvarname
upvar #0 $cvarname cvar
set cvar($which) $value
$cvar(proc,updateelement) $cvarname
}
proc PlotCmdFontStyle {which value} {
global cvarname
upvar #0 $cvarname cvar
switch $value {
normal {
set cvar($which,weight) normal
set cvar($which,slant) roman
}
bold {
set cvar($which,weight) bold
set cvar($which,slant) roman
}
italic {
set cvar($which,weight) normal
set cvar($which,slant) italic
}
}
$cvar(proc,updategraph) $cvarname
}
proc PlotCmdExport {format fn} {
global cvarname
upvar #0 $cvarname cvar
switch -- $format {
gif {FileLast giffbox $fn}
jpeg {FileLast jpegfbox $fn}
tiff {FileLast tifffbox $fn}
png {FileLast pngfbox $fn}
default {
Error "[msgcat::mc {Not valid export format}] $format"
return
}
}
PlotExport $cvarname $fn $format
}
proc PlotCmdSelectData {which} {
global cvarname
upvar #0 $cvarname cvar
set cc $cvar(graph,current)
set cvar($cc,data,current) $which
PlotCurrentData $cvarname
}
proc ProcessSendPlotCmd {proc id param {sock {}} {fn {}}} {
global iap
global parse
set parse(proc) $proc
set parse(id) $id
set ref [lindex $iap(windows) end]
global cvarname
set cvarname $ref
global parse
plotsend::YY_FLUSH_BUFFER
plotsend::yy_scan_string $param
plotsend::yyparse
}
proc PlotSendCmdCVARGet {key} {
global cvarname
upvar #0 $cvarname cvar
set cc $cvar(graph,current)
global parse
$parse(proc) $parse(id) "$cvar($cc,$key)\n"
}
proc PlotSendCmdCVARYesNo {key} {
global cvarname
upvar #0 $cvarname cvar
set cc $cvar(graph,current)
global parse
$parse(proc) $parse(id) [ToYesNo $cvar($cc,$key)]
}
|