From d376cd8ca9710c393bbdf99adf652d8a8d103233 Mon Sep 17 00:00:00 2001 From: William Joye Date: Thu, 27 Jun 2019 14:07:29 -0400 Subject: support multiple graph plots --- ds9/library/plot.tcl | 28 ++++++++++++++++------------ ds9/library/plotstate.tcl | 5 ++++- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/ds9/library/plot.tcl b/ds9/library/plot.tcl index 74f992d..095b4cc 100644 --- a/ds9/library/plot.tcl +++ b/ds9/library/plot.tcl @@ -170,6 +170,7 @@ proc PlotAddElement {varname} { global $var(graph,ds,xdata) $var(graph,ds,ydata) $var(graph) element create ${nn} \ -xdata $var(graph,ds,xdata) -ydata $var(graph,ds,ydata) + puts "add $nn $var(graph,ds,xdata) $var(graph,ds,ydata)" if {$var(graph,ds,xedata) != {}} { if {[$var(graph,ds,xedata) length] != 0} { $var(graph) element configure ${nn} \ @@ -200,7 +201,7 @@ proc PlotDeleteDataSetCurrent {varname} { return } - PlotDeleteDataSet $varname $var(graph,ds,current) + PlotDeleteDataSet $varname } proc PlotDeleteDataSetAll {varname} { @@ -212,15 +213,17 @@ proc PlotDeleteDataSetAll {varname} { } foreach nn $var(graph,dss) { - PlotDeleteDataSet $varname $nn + set var(graph,ds,current) $nn + PlotDeleteDataSet $varname } } -proc PlotDeleteDataSet {varname nn} { +proc PlotDeleteDataSet {varname} { upvar #0 $varname var global $varname set cc $var(graph,current) + set nn $var($cc,ds,current) if {[llength $var($cc,dss)] == 0} { return @@ -234,16 +237,16 @@ proc PlotDeleteDataSet {varname nn} { $var(mb).graph.select delete $var($cc,$nn,name) # delete element - $var(graph) element delete $nn + $var($cc) element delete $nn # destroy vectors + puts "delete $nn $var($cc,$nn,xdata) $var($cc,$nn,ydata)" blt::vector destroy $var($cc,$nn,xdata) $var($cc,$nn,ydata) switch $var($cc,$nn,dim) { xy {} xyex {blt::vector destroy $var($cc,$nn,xedata)} xyey {blt::vector destroy $var($cc,$nn,yedata)} - xyexey {blt::vector destroy \ - $var($cc,$nn,xedata) $var($cc,$nn,yedata)} + xyexey {blt::vector destroy $var($cc,$nn,xedata) $var($cc,$nn,yedata)} } set ii [lsearch $var($cc,dss) $nn] if {$ii>=0} { @@ -261,18 +264,19 @@ proc PlotDeleteDataSet {varname nn} { # set current dataset set var($cc,ds,current) [lindex $var($cc,dss) 0] PlotRestoreState $varname - PlotStats $varname - PlotList $varname # update menus $var(proc,updateelement) $varname + + PlotStats $varname + PlotList $varname } proc PlotCurrentGraph {varname} { upvar #0 $varname var global $varname - PlotRestoreState $varname + PlotSaveState $varname PlotStats $varname PlotList $varname } @@ -281,7 +285,7 @@ proc PlotCurrentDataSet {varname} { upvar #0 $varname var global $varname - PlotRestoreState $varname + PlotSaveState $varname PlotStats $varname PlotList $varname } @@ -333,8 +337,8 @@ proc PlotList {varname} { upvar #0 $varname var global $varname - puts "***" - DumpCallStack +# puts "***" +# DumpCallStack if {!$var(list)} { return diff --git a/ds9/library/plotstate.tcl b/ds9/library/plotstate.tcl index 9c43184..ce7d950 100644 --- a/ds9/library/plotstate.tcl +++ b/ds9/library/plotstate.tcl @@ -154,6 +154,8 @@ proc PlotSaveState {varname} { upvar #0 $varname var global $varname + puts "SaveState $var(graph,current) $var(graph,ds,current)" + # per Graph set cc $var(graph,current) @@ -189,7 +191,7 @@ proc PlotSaveState {varname} { set var($cc,axis,y,format) $var(graph,axis,y,format) # per DataSet - set nn $var($cc,ds,current) + set nn $var(graph,ds,current) set var($cc,$nn,name) $var(graph,ds,name) set var($cc,$nn,dim) $var(graph,ds,dim) @@ -260,6 +262,7 @@ proc PlotRestoreState {varname} { # per DataSet set nn $var($cc,ds,current) + puts "RestoreState $cc $nn" set var(graph,ds,name) $var($cc,$nn,name) set var(graph,ds,dim) $var($cc,$nn,dim) -- cgit v0.12