From 26a96ff43d7f7b838c8ea7343bd738895c122e9e Mon Sep 17 00:00:00 2001 From: William Joye Date: Mon, 27 May 2019 16:01:56 -0400 Subject: add multiple plot support --- ds9/library/plot.tcl | 34 ++++++++++++++++++++++------------ ds9/library/plotbar.tcl | 7 +++++-- ds9/library/plotdialog.tcl | 12 +++++++----- ds9/library/plotline.tcl | 7 +++++-- ds9/library/plotprocess.tcl | 23 +++++++++++++++++++++++ ds9/library/plotscatter.tcl | 9 ++++++--- ds9/parsers/plotsendparser.tac | 8 ++++---- ds9/parsers/plotsendparser.tcl | 8 ++++---- 8 files changed, 76 insertions(+), 32 deletions(-) diff --git a/ds9/library/plot.tcl b/ds9/library/plot.tcl index 94edf2f..8468285 100644 --- a/ds9/library/plot.tcl +++ b/ds9/library/plot.tcl @@ -106,6 +106,7 @@ proc PlotAddGraph {varname} { global $varname global ds9 + global pap incr ${varname}(graph,total) incr ${varname}(graph,current) @@ -116,12 +117,15 @@ proc PlotAddGraph {varname} { set var(graph$cc,data,total) 0 set var(graph$cc,data,current) 0 - set var(name) {} + set var(graph$cc,name) {} set var(graph$cc,xdata) {} set var(graph$cc,ydata) {} set var(graph$cc,xedata) {} set var(graph$cc,yedata) {} + array set $varname [array get pap] + set var(graph$cc,show) $pap(show) + $var(proc,addgraph) $varname # set up zoom stack, assuming mode is zoom @@ -266,7 +270,7 @@ proc PlotDeleteData {varname} { set var(graph$cc,data,total) 0 set var(graph$cc,data,current) 0 - set var(name) {} + set var(graph$cc,name) {} set var(graph$cc,xdata) {} set var(graph$cc,ydata) {} set var(graph$cc,xedata) {} @@ -384,7 +388,7 @@ proc PlotDataSetOne {varname dim data} { # basics xy set var(graph$cc,manage) 1 - set var(name) "Dataset $nn" + set var(graph$cc,name) "Dataset $nn" set var(graph$cc,xdata) $xdata set var(graph$cc,ydata) $ydata global $var(graph$cc,xdata) $var(graph$cc,ydata) @@ -550,7 +554,7 @@ proc PlotDataSetOne {varname dim data} { PlotGetVar $varname $nn # update data set menu - $var(mb).graph.select add radiobutton -label "$var(name)" \ + $var(mb).graph.select add radiobutton -label "$var(graph$cc,name)" \ -variable ${varname}(graph$cc,data,current) -value $nn \ -command [list PlotCurrentData $varname] @@ -575,7 +579,7 @@ proc PlotDupData {varname mm} { set pp [expr $nn-1] # new vector names - set var($nn,name) "Dataset $nn" + set var(graph$cc,$nn,name) "Dataset $nn" set var(graph$cc,$nn,xdata) ap${varname}xx${nn} set var(graph$cc,$nn,ydata) ap${varname}yy${nn} set var(graph$cc,$nn,xedata) ap${varname}xe${nn} @@ -601,7 +605,7 @@ proc PlotDupData {varname mm} { set var(graph$cc,$nn,manage) 1 set var(graph$cc,$nn,dim) $var(graph$cc,$mm,dim) - set var($nn,show) $var($mm,show) + set var(graph$cc,$nn,show) $var(graph$cc,$mm,show) set var($nn,shape,symbol) $var($mm,shape,symbol) set var($nn,shape,fill) $var($mm,shape,fill) set var($nn,shape,color) $var($mm,shape,color) @@ -618,7 +622,7 @@ proc PlotDupData {varname mm} { set var($nn,bar,relief) $var($mm,bar,relief) # update data set menu - $var(mb).graph.select add radiobutton -label "$var($nn,name)" \ + $var(mb).graph.select add radiobutton -label "$var(graph$cc,$nn,name)" \ -variable ${varname}(graph$cc,data,current) -value $nn \ -command [list PlotCurrentData $varname] @@ -714,7 +718,7 @@ proc PlotExternal {varname} { set nn $var(graph$cc,data,total) set var(graph$cc,data,current) $nn - set var(name) "Dataset $nn" + set var(graph$cc,name) "Dataset $nn" set var(graph$cc,$nn,manage) $var(graph$cc,manage) set var(graph$cc,$nn,dim) $var(graph$cc,dim) @@ -1325,8 +1329,11 @@ proc PlotSetVar {varname nn} { upvar #0 $varname var global $varname - set var(name) $var($nn,name) - set var(show) $var($nn,show) + set tt $var(graph,total) + set cc $var(graph,current) + + set var(graph$cc,name) $var(graph$cc,$nn,name) + set var(graph$cc,show) $var(graph$cc,$nn,show) set var(shape,symbol) $var($nn,shape,symbol) set var(shape,fill) $var($nn,shape,fill) set var(shape,color) $var($nn,shape,color) @@ -1347,8 +1354,11 @@ proc PlotGetVar {varname nn} { upvar #0 $varname var global $varname - set var($nn,name) $var(name) - set var($nn,show) $var(show) + set tt $var(graph,total) + set cc $var(graph,current) + + set var(graph$cc,$nn,name) $var(graph$cc,name) + set var(graph$cc,$nn,show) $var(graph$cc,show) set var($nn,shape,symbol) $var(shape,symbol) set var($nn,shape,fill) $var(shape,fill) set var($nn,shape,color) $var(shape,color) diff --git a/ds9/library/plotbar.tcl b/ds9/library/plotbar.tcl index 109d6a5..baad691 100644 --- a/ds9/library/plotbar.tcl +++ b/ds9/library/plotbar.tcl @@ -51,6 +51,9 @@ proc PlotBarDialog {varname wtt title xaxis yaxis} { PlotDialog $varname $wtt $title $xaxis $yaxis PlotAddGraph $varname + set tt $var(graph,total) + set cc $var(graph,current) + # Graph $var(mb).graph add separator $var(mb).graph add cascade -label "[msgcat::mc {Mode}]..." \ @@ -73,7 +76,7 @@ proc PlotBarDialog {varname wtt title xaxis yaxis} { # Data $var(mb).data add checkbutton -label [msgcat::mc {Show}] \ - -variable ${varname}(show) \ + -variable ${varname}(graph$cc,show) \ -command [list PlotBarUpdateElement $varname] $var(mb).data add separator $var(mb).data add cascade -label [msgcat::mc {Color}] \ @@ -186,7 +189,7 @@ proc PlotBarUpdateElement {varname} { } $var(graph$cc) element configure "d-${nn}" \ - -label $var(name) -hide [expr !$var(show)] \ + -label $var(graph$cc,name) -hide [expr !$var(graph$cc,show)] \ -relief $var(bar,relief) -color $var(color) \ -showerrorbars $show -errorbarcolor $var(error,color) \ -errorbarwidth $var(error,width) -errorbarcap $cap diff --git a/ds9/library/plotdialog.tcl b/ds9/library/plotdialog.tcl index ce56ad5..45fd2e1 100644 --- a/ds9/library/plotdialog.tcl +++ b/ds9/library/plotdialog.tcl @@ -30,8 +30,6 @@ proc PlotDialog {varname wtt title xaxis yaxis} { set var(graph,total) 0 set var(graph,current) 0 - array set $varname [array get pap] - PlotTitle $varname $title $xaxis $yaxis # can be turned off for external line plots @@ -474,10 +472,13 @@ proc DatasetNameDialog {varname} { global $varname global ed + set tt $var(graph,total) + set cc $var(graph,current) + set w {.aptitle} set ed(ok) 0 - set ed(name) $var(name) + set ed(name) $var(graph$cc,name) DialogCreate $w [msgcat::mc {Data}] ed(ok) @@ -508,8 +509,9 @@ proc DatasetNameDialog {varname} { DialogDismiss $w if {$ed(ok)} { - $var(mb).graph.select entryconfig "$var(name)" -label "$ed(name)" - set var(name) $ed(name) + $var(mb).graph.select entryconfig "$var(graph$cc,name)" \ + -label "$ed(name)" + set var(graph$cc,name) $ed(name) $var(proc,updateelement) $varname } diff --git a/ds9/library/plotline.tcl b/ds9/library/plotline.tcl index e5b0a05..f61f456 100644 --- a/ds9/library/plotline.tcl +++ b/ds9/library/plotline.tcl @@ -51,9 +51,12 @@ proc PlotLineDialog {varname wtt title xaxis yaxis} { PlotDialog $varname $wtt $title $xaxis $yaxis PlotAddGraph $varname + set tt $var(graph,total) + set cc $var(graph,current) + # Data $var(mb).data add checkbutton -label [msgcat::mc {Show}] \ - -variable ${varname}(show) \ + -variable ${varname}(graph$cc,show) \ -command [list PlotLineUpdateElement $varname] $var(mb).data add separator $var(mb).data add cascade -label [msgcat::mc {Shape}] \ @@ -268,7 +271,7 @@ proc PlotLineUpdateElement {varname} { } $var(graph$cc) element configure "d-${nn}" \ - -label $var(name) -hide [expr !$var(show)] \ + -label $var(graph$cc,name) -hide [expr !$var(graph$cc,show)] \ -symbol $var(shape,symbol) -fill $clr -scalesymbols no \ -pixels 5 -outline $var(shape,color) \ -smooth $var(smooth) \ diff --git a/ds9/library/plotprocess.tcl b/ds9/library/plotprocess.tcl index 738d083..9a9fa16 100644 --- a/ds9/library/plotprocess.tcl +++ b/ds9/library/plotprocess.tcl @@ -343,3 +343,26 @@ proc ProcessSendPlotCmd {proc id param {sock {}} {fn {}}} { plotsend::yy_scan_string $param plotsend::yyparse } + +proc PlotSendCmdCVARGet {key} { + global cvarname + upvar #0 $cvarname cvar + + set tt $cvar(graph,total) + set cc $cvar(graph,current) + + global parse + $parse(proc) $parse(id) "$cvar(graph$cc,$key)\n" +} + +proc PlotSendCmdCVARYesNo {key} { + global cvarname + upvar #0 $cvarname cvar + + set tt $cvar(graph,total) + set cc $cvar(graph,current) + + global parse + $parse(proc) $parse(id) [ToYesNo $cvar(graph$cc,$key)] +} + diff --git a/ds9/library/plotscatter.tcl b/ds9/library/plotscatter.tcl index 08308cc..55fa8e0 100644 --- a/ds9/library/plotscatter.tcl +++ b/ds9/library/plotscatter.tcl @@ -51,9 +51,12 @@ proc PlotScatterDialog {varname wtt title xaxis yaxis} { PlotDialog $varname $wtt $title $xaxis $yaxis PlotAddGraph $varname + set tt $var(graph,total) + set cc $var(graph,current) + # Data $var(mb).data add checkbutton -label [msgcat::mc {Show}] \ - -variable ${varname}(show) \ + -variable ${varname}(graph$cc,show) \ -command [list PlotScatterUpdateElement $varname] $var(mb).data add separator $var(mb).data add cascade -label [msgcat::mc {Shape}] \ @@ -186,7 +189,7 @@ proc PlotScatterUpdateElement {varname} { } $var(graph$cc) element configure "d-${nn}" \ - -label $var(name) -hide [expr !$var(show)] \ + -label $var(graph$cc,name) -hide [expr !$var(graph$cc,show)] \ -symbol $var(shape,symbol) -fill $clr -scalesymbols no \ -outline $var(shape,color) \ -linewidth 0 -pixels 5 \ @@ -243,7 +246,7 @@ proc PlotScatterHighliteElement {varname rowlist} { return } - if {$var(show)} { + if {$var(graph$cc,show)} { $var(graph$cc) element deactivate d-1 if {$rowlist != {}} { # can have multiple rows diff --git a/ds9/parsers/plotsendparser.tac b/ds9/parsers/plotsendparser.tac index b3f43da..5bb9769 100644 --- a/ds9/parsers/plotsendparser.tac +++ b/ds9/parsers/plotsendparser.tac @@ -81,22 +81,22 @@ plotCmd : STATS_ {ProcessSendCmdCVAR PlotStatsGenerate} | FONT_ fontt | TITLE_ title | BARMODE_ {ProcessSendCmdCVARGet bar,mode} - | SHOW_ {ProcessSendCmdCVARYesNo show} + | SHOW_ {PlotSendCmdCVARYesNo show} | COLOR_ {ProcessSendCmdCVARGet color} | FILL_ {ProcessSendCmdCVARGet fill} | FILLCOLOR_ {ProcessSendCmdCVARGet fill,color} | ERROR_ errorr # backward compatibility | ERRORBAR_ errorr - | NAME_ {ProcessSendCmdCVARGet name} + | NAME_ {PlotSendCmdCVARGet name} | SHAPE_ shape | RELIEF_ {ProcessSendCmdCVARGet bar,relief} | SMOOTH_ {ProcessSendCmdCVARGet smooth} | WIDTH_ {ProcessSendCmdCVARGet width} | DASH_ {ProcessSendCmdCVARYesNo dash} - | SELECT_ {ProcessSendCmdCVARGet graph1,data,current} + | SELECT_ {PlotSendCmdCVARGet data,current} # backward compatibility - | DATASET_ {ProcessSendCmdCVARGet graph1,data,current} + | DATASET_ {PlotSendCmdCVARGet data,current} ; axis : xy GRID_ {ProcessSendCmdCVARYesNo "axis,$1,grid"} diff --git a/ds9/parsers/plotsendparser.tcl b/ds9/parsers/plotsendparser.tcl index 703f0ec..bee2627 100644 --- a/ds9/parsers/plotsendparser.tcl +++ b/ds9/parsers/plotsendparser.tcl @@ -1491,17 +1491,17 @@ proc plotsend::yyparse {} { 15 { ProcessSendCmdCVARGet mode } 17 { ProcessSendCmdCVARGet graph,bg } 21 { ProcessSendCmdCVARGet bar,mode } - 22 { ProcessSendCmdCVARYesNo show } + 22 { PlotSendCmdCVARYesNo show } 23 { ProcessSendCmdCVARGet color } 24 { ProcessSendCmdCVARGet fill } 25 { ProcessSendCmdCVARGet fill,color } - 28 { ProcessSendCmdCVARGet name } + 28 { PlotSendCmdCVARGet name } 30 { ProcessSendCmdCVARGet bar,relief } 31 { ProcessSendCmdCVARGet smooth } 32 { ProcessSendCmdCVARGet width } 33 { ProcessSendCmdCVARYesNo dash } - 34 { ProcessSendCmdCVARGet graph1,data,current } - 35 { ProcessSendCmdCVARGet graph1,data,current } + 34 { PlotSendCmdCVARGet data,current } + 35 { PlotSendCmdCVARGet data,current } 36 { ProcessSendCmdCVARYesNo "axis,$1,grid" } 37 { ProcessSendCmdCVARYesNo "axis,$1,log" } 38 { ProcessSendCmdCVARYesNo "axis,$1,flip" } -- cgit v0.12