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
proc PrefsDialogPlot {} {
global dprefs
set w $dprefs(tab)
$dprefs(list) insert end [msgcat::mc {Plot}]
lappend dprefs(tabs) [ttk::frame $w.plot]
# 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(axis,x,grid)
ttk::radiobutton $f.xlinear -text [msgcat::mc {Linear}] \
-variable pap(axis,x,log) -value 0
ttk::radiobutton $f.xlog -text [msgcat::mc {Log}] \
-variable pap(axis,x,log) -value 1
ttk::label $f.ytitle -text [msgcat::mc {Y}]
ttk::checkbutton $f.y -text [msgcat::mc {Grid}] -variable pap(axis,y,grid)
ttk::radiobutton $f.ylinear -text [msgcat::mc {Linear}] \
-variable pap(axis,y,log) -value 0
ttk::radiobutton $f.ylog -text [msgcat::mc {Log}] \
-variable pap(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
# Dataset
set f [ttk::labelframe $w.plot.dataset -text [msgcat::mc {Dataset}]]
# Show
ttk::checkbutton $f.show -text [msgcat::mc {Show}] -variable pap(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(shape,symbol) \
-menu $f.shape.menu
PlotLineShapeMenu $f.shape.menu pap(shape,symbol)
ttk::checkbutton $f.shapefill -text [msgcat::mc {Fill}] \
-variable pap(shape,fill)
ColorMenuButton $f.shapecolor pap 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(smooth) \
-menu $f.smooth.menu
PlotLineSmoothMenu $f.smooth.menu pap(smooth)
grid $f.smoothtitle $f.smooth -padx 2 -pady 2 -sticky w
# Color
ttk::label $f.colortitle -text [msgcat::mc {Color}]
ColorMenuButton $f.color pap 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(width) -menu $f.width.menu
WidthDashMenu $f.width.menu pap width 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(error)
ttk::checkbutton $f.errorcap -text [msgcat::mc {Cap}] \
-variable pap(error,cap)
ColorMenuButton $f.errorcolor pap error,color {}
ttk::menubutton $f.errorwidth -textvariable pap(error,width) \
-menu $f.errorwidth.menu
WidthDashMenu $f.errorwidth.menu pap width dash {} {}
grid $f.errortitle $f.error $f.errorcap $f.errorcolor $f.errorwidth \
-padx 2 -pady 2 -sticky w
pack $w.plot.grid $w.plot.axis $w.plot.dataset \
-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 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 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 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
}
|