summaryrefslogtreecommitdiffstats
path: root/ds9/library/plotprocess.tcl
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-04-04 18:24:37 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-04-04 18:24:37 (GMT)
commitaf94af4531e00d53fc38d5efee2631544575cb41 (patch)
tree38c2845dad6fb10ae6cb7177770e5d8555548211 /ds9/library/plotprocess.tcl
parent761d5e2c12845b4731298d206e27f44979d2be79 (diff)
downloadblt-af94af4531e00d53fc38d5efee2631544575cb41.zip
blt-af94af4531e00d53fc38d5efee2631544575cb41.tar.gz
blt-af94af4531e00d53fc38d5efee2631544575cb41.tar.bz2
add ds9 plot parser
Diffstat (limited to 'ds9/library/plotprocess.tcl')
-rw-r--r--ds9/library/plotprocess.tcl118
1 files changed, 114 insertions, 4 deletions
diff --git a/ds9/library/plotprocess.tcl b/ds9/library/plotprocess.tcl
index 376dc75..fc95984 100644
--- a/ds9/library/plotprocess.tcl
+++ b/ds9/library/plotprocess.tcl
@@ -100,17 +100,25 @@ proc PrefsDialogPlot {} {
}
proc ProcessPlotCmd {xarname iname buf fn} {
+ upvar $xarname xar
+ upvar $iname i
+ global iap
+
global debug
if {$debug(tcl,parser)} {
+ set ref [lindex $iap(windows) end]
+ global cvarname
+ set cvarname $ref
+ set iap(name) $iap(tt)
+ set iap(buf) $buf
+ set iap(fn) $fn
+
plot::YY_FLUSH_BUFFER
- plot::yy_scan_string [lrange $var $i end]
+ plot::yy_scan_string [lrange $xar $i end]
plot::yyparse
incr i [expr $plot::yycnt-1]
} else {
- upvar $xarname xar
- upvar $iname i
- global iap
set varname $iap(tt)
set id 0
@@ -537,6 +545,102 @@ proc ProcessPlotData {varname xarname iname buf} {
PlotList $varname
}
+proc PlotCmdCheck {} {
+ global cvarname
+ upvar #0 $cvarname cvar
+
+ if {![info exists cvar(top)]} {
+ Error "[msgcat::mc {Unable to find plot window}] $cvarname"
+ plot::YYABORT
+ return
+ }
+ if {![winfo exists $cvar(top)]} {
+ Error "[msgcat::mc {Unable to find plot window}] $cvarname"
+ plot::YYABORT
+ return
+ }
+}
+
+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"
+ plot::YYABORT
+ return
+ }
+ set cvarname $ref
+ PlotCmdCheck
+}
+
+proc PlotCmdNew {name} {
+ global iap
+
+ if {$name != {}} {
+ set iap(name) $name
+ }
+
+ if {$iap(buf) != {}} {
+ return
+ } elseif {$iap(fn) != {}} {
+ if {[file exists $iap(fn)]} {
+ set ch [open $iap(fn) r]
+ set iap(buf) [read $ch]
+ close $ch
+ return
+ }
+ }
+ set iap(buf) {}
+}
+
+proc PlotCmdLine {title xaxis yaxis dim} {
+ global iap
+ PlotLine $iap(name) {} $title $xaxis $yaxis $dim $iap(buf)
+}
+
+proc PlotCmdBar {title xaxis yaxis dim} {
+ global iap
+ PlotBar $iap(name) {} $title $xaxis $yaxis $dim $iap(buf)
+}
+
+proc PlotCmdScatter {title xaxis yaxis dim} {
+ global iap
+ PlotScatter $iap(name) {} $title $xaxis $yaxis $dim $iap(buf)
+}
+
+proc PlotCmdAnalysisPlotStdin {which} {
+ global iap
+ AnalysisPlotStdin $which $iap(name) {} $iap(buf)
+}
+
+proc PlotCmdData {dim} {
+ global cvarname
+ upvar #0 $cvarname cvar
+
+ if {$iap(buf) == {}} {
+ if {$iap(fn) != {}} {
+ if {[file exists $iap(fn)]} {
+ set ch [open $iap(fn) r]
+ set iap(buf) [read $ch]
+ close $ch
+ }
+ }
+ if {$iap(buf) == {}} {
+ Error "[msgcat:: mc {Unable to load plot data}] $fn"
+ plot::YYABORT
+ return
+ }
+ }
+
+ PlotRaise $cvarname
+ PlotDataSet $cvarname $dim $iap(buf)
+ $var(proc,updategraph) $cvarname
+ PlotStats $cvarname
+ PlotList $cvarname
+}
+
proc PlotCmdLoad {fn dim} {
global cvarname
@@ -583,6 +687,12 @@ proc PlotCmdSet {which value {cmd {}}} {
}
}
+proc PlotCmdPrint {} {
+ global cvarname
+
+ PlotPostScript $cvarname
+}
+
proc PlotCmdUpdateGraph {which value} {
global cvarname
upvar #0 $cvarname cvar