diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2019-06-07 15:44:38 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2019-06-07 15:44:38 (GMT) |
commit | 72cee7539e883903b6bfec4fd03738753457b992 (patch) | |
tree | 9b81edba6628086708626189978191423f3b4a56 /ds9/library | |
parent | 86fcbe6827bd920c0fc8317d63f37697f0c22ad8 (diff) | |
download | blt-72cee7539e883903b6bfec4fd03738753457b992.zip blt-72cee7539e883903b6bfec4fd03738753457b992.tar.gz blt-72cee7539e883903b6bfec4fd03738753457b992.tar.bz2 |
support multiple graphs per plot
Diffstat (limited to 'ds9/library')
-rw-r--r-- | ds9/library/catplot.tcl | 2 | ||||
-rw-r--r-- | ds9/library/markeranalysispanda.tcl | 2 | ||||
-rw-r--r-- | ds9/library/plot.tcl | 96 | ||||
-rw-r--r-- | ds9/library/plotdata.tcl | 128 | ||||
-rw-r--r-- | ds9/library/plotdialog.tcl | 23 | ||||
-rw-r--r-- | ds9/library/plotline.tcl | 2 |
6 files changed, 146 insertions, 107 deletions
diff --git a/ds9/library/catplot.tcl b/ds9/library/catplot.tcl index 567da52..d8040dd 100644 --- a/ds9/library/catplot.tcl +++ b/ds9/library/catplot.tcl @@ -86,7 +86,7 @@ proc CATPlotGenerate {varname} { set var(plot,var) $vvarname } - PlotDeleteData $vvarname + PlotDeleteAllDataSet $vvarname PlotDataSet $vvarname $dim $rr PlotTitle $vvarname $var(title) $xtitle $ytitle $vvar(proc,updategraph) $vvarname diff --git a/ds9/library/markeranalysispanda.tcl b/ds9/library/markeranalysispanda.tcl index 619fb96..b99a0c4 100644 --- a/ds9/library/markeranalysispanda.tcl +++ b/ds9/library/markeranalysispanda.tcl @@ -103,7 +103,7 @@ proc MarkerAnalysisPandaCB {frame id} { MarkerAnalysisPandaAxisTitle $vvarname } - PlotDeleteData $vvarname + PlotDeleteAllDataSet $vvarname PlotDataSet $vvarname 3 [$frame get marker $id analysis panda $sys] $vvar(proc,updategraph) $vvarname PlotStats $vvarname diff --git a/ds9/library/plot.tcl b/ds9/library/plot.tcl index f488be6..880d18a 100644 --- a/ds9/library/plot.tcl +++ b/ds9/library/plot.tcl @@ -91,11 +91,6 @@ proc PlotAddData {varname} { set cc $var(graph,current) set nn $var($cc,data,current) - # warning: uses current vars - if {$var($cc,data,total) == 0} { - return - } - # delete current elements foreach el [$var(graph) element names] { set f [split $el -] @@ -121,87 +116,6 @@ proc PlotAddData {varname} { } } -proc PlotDeleteData {varname} { - upvar #0 $varname var - global $varname - - global ds9 - - set cc $var(graph,current) - - if {$var($cc,data,total) == 0} { - return - } - - # first set can be external - set clear $var($cc,1,manage) - - for {set nn 1} {$nn<=$var($cc,data,total)} {incr nn} { - if {$var($cc,$nn,manage)} { - # delete elements - foreach el [$var(graph) element names] { - set f [split $el -] - if {[lindex $f 1] == $nn} { - $var(graph) element delete $el - } - } - - # destroy vectors - 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)} - } - - foreach x [array names $varname] { - set f [split $x ,] - if {([lindex $f 0] == $nn)} { - unset ${varname}($x) - } - } - } - } - - if {$clear} { - set var($cc,data,total) 0 - set var($cc,data,current) 0 - - set var(graph,ds,name) {} - set var(graph,ds,xdata) {} - set var(graph,ds,ydata) {} - set var(graph,ds,xedata) {} - set var(graph,ds,yedata) {} - - # reset other variables - set var($cc,axis,x,auto) 1 - set var($cc,axis,x,min) {} - set var($cc,axis,x,max) {} - set var($cc,axis,x,format) {} - - set var($cc,axis,y,auto) 1 - set var($cc,axis,y,min) {} - set var($cc,axis,y,max) {} - set var($cc,axis,y,format) {} - - $var(mb).graph.select delete $ds9(menu,start) end - - $var(proc,updategraph) $varname - PlotStats $varname - PlotList $varname - } else { - set var($cc,data,total) 1 - set var($cc,data,current) 1 - - $var(mb).graph.select delete [expr $ds9(menu,start)+1] end - PlotCurrentData $varname - $var(proc,updategraph) $varname - } -} - proc PlotCurrentGraph {varname} { upvar #0 $varname var global $varname @@ -533,16 +447,10 @@ proc PlotUpdateGraph {varname} { # Menus if {$var(graph,ds,xdata) != {}} { $var(mb).file entryconfig "[msgcat::mc {Save Data}]..." -state normal - $var(mb).file entryconfig [msgcat::mc {Clear Data}] -state normal - $var(mb).file entryconfig [msgcat::mc {Duplicate Data}] -state normal - $var(mb).file entryconfig [msgcat::mc {Statistics}] -state normal - $var(mb).file entryconfig [msgcat::mc {List Data}] -state normal + $var(mb).file entryconfig [msgcat::mc {Clear All Data}] -state normal } else { $var(mb).file entryconfig "[msgcat::mc {Save Data}]..." -state disabled - $var(mb).file entryconfig [msgcat::mc {Clear Data}] -state disabled - $var(mb).file entryconfig [msgcat::mc {Duplicate Data}] -state disabled - $var(mb).file entryconfig [msgcat::mc {Statistics}] -state disabled - $var(mb).file entryconfig [msgcat::mc {List Data}] -state disabled + $var(mb).file entryconfig [msgcat::mc {Clear All Data}] -state disabled } # Graph diff --git a/ds9/library/plotdata.tcl b/ds9/library/plotdata.tcl index 5ab66e7..fc2e7dd 100644 --- a/ds9/library/plotdata.tcl +++ b/ds9/library/plotdata.tcl @@ -244,7 +244,7 @@ proc PlotDataSetOne {varname dim data} { $var(proc,updateelement) $varname } -proc PlotDupData {varname mm} { +proc PlotDupDataSet {varname mm} { upvar #0 $varname var global $varname @@ -420,3 +420,129 @@ proc PlotSaveDataFile {varname filename} { PlotRaise $varname } +proc PlotDeleteDataSet {varname} { + upvar #0 $varname var + global $varname + + global ds9 + + set cc $var(graph,current) + set nn $var(graph,data,current) + + if {$var($cc,data,total) == 0} { + return + } + + if {$var($cc,$nn,manage)} { + # delete elements + foreach el [$var(graph) element names] { + set f [split $el -] + if {[lindex $f 1] == $nn} { + $var(graph) element delete $el + } + } + + # destroy vectors + 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)} + } + + foreach vv [array names $varname] { + set ds [split $vv ,] + if {([lindex $ds 1] == $nn)} { + unset ${varname}($ds) + } + } + + incr ${varname}($cc,data,total) -1 + set ${varname}($cc,data,current) 0 + } +} + +proc PlotDeleteAllDataSet {varname} { + upvar #0 $varname var + global $varname + + global ds9 + + set cc $var(graph,current) + + if {$var($cc,data,total) == 0} { + return + } + + # first set can be external + set clear $var($cc,1,manage) + + for {set nn 1} {$nn<=$var($cc,data,total)} {incr nn} { + if {$var($cc,$nn,manage)} { + # delete elements + foreach el [$var(graph) element names] { + set f [split $el -] + if {[lindex $f 1] == $nn} { + $var(graph) element delete $el + } + } + + # destroy vectors + 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)} + } + + foreach x [array names $varname] { + set f [split $x ,] + if {([lindex $f 0] == $nn)} { + unset ${varname}($x) + } + } + } + } + + if {$clear} { + set var($cc,data,total) 0 + set var($cc,data,current) 0 + + set var(graph,ds,name) {} + set var(graph,ds,xdata) {} + set var(graph,ds,ydata) {} + set var(graph,ds,xedata) {} + set var(graph,ds,yedata) {} + + # reset other variables + set var($cc,axis,x,auto) 1 + set var($cc,axis,x,min) {} + set var($cc,axis,x,max) {} + set var($cc,axis,x,format) {} + + set var($cc,axis,y,auto) 1 + set var($cc,axis,y,min) {} + set var($cc,axis,y,max) {} + set var($cc,axis,y,format) {} + + $var(mb).graph.select delete $ds9(menu,start) end + + $var(proc,updategraph) $varname + PlotStats $varname + PlotList $varname + } else { + set var($cc,data,total) 1 + set var($cc,data,current) 1 + + $var(mb).graph.select delete [expr $ds9(menu,start)+1] end + PlotCurrentData $varname + $var(proc,updategraph) $varname + } +} + + diff --git a/ds9/library/plotdialog.tcl b/ds9/library/plotdialog.tcl index 558925b..3ef4dd9 100644 --- a/ds9/library/plotdialog.tcl +++ b/ds9/library/plotdialog.tcl @@ -49,19 +49,13 @@ proc PlotDialog {varname wtt title xaxis yaxis} { -command [list PlotLoadData $varname] $var(mb).file add command -label "[msgcat::mc {Save Data}]..." \ -command [list PlotSaveData $varname] - $var(mb).file add command -label [msgcat::mc {Clear Data}] \ - -command [list PlotDeleteData $varname] - $var(mb).file add command -label [msgcat::mc {Duplicate Data}] \ - -command [list PlotDupData $varname 1] + $var(mb).file add separator + $var(mb).file add command -label [msgcat::mc {Clear All Data}] \ + -command [list PlotDeleteAllData $varname] $var(mb).file add separator $var(mb).file add cascade -label [msgcat::mc {Export}] \ -menu $var(mb).file.export $var(mb).file add separator - $var(mb).file add command -label [msgcat::mc {Statistics}] \ - -command "set ${varname}(stats) 1; PlotStats $varname" - $var(mb).file add command -label [msgcat::mc {List Data}] \ - -command "set ${varname}(list) 1; PlotList $varname" - $var(mb).file add separator $var(mb).file add command -label "[msgcat::mc {Load Configuration}]..." \ -command [list PlotLoadConfig $varname] $var(mb).file add command -label "[msgcat::mc {Save Configuration}]..." \ @@ -171,6 +165,17 @@ proc PlotDialog {varname wtt title xaxis yaxis} { $var(mb).graph add cascade -label [msgcat::mc {Select Dataset}] \ -menu $var(mb).graph.select $var(mb).graph add separator + $var(mb).graph add command -label [msgcat::mc {Delete Dataset}] \ + -command [list PlotDeleteDataSet $varname] + $var(mb).graph add command -label [msgcat::mc {Duplicate Dataset}] \ + -command [list PlotDupDataSet $varname 1] + $var(mb).graph add separator + $var(mb).graph add command -label [msgcat::mc {Statistics}] \ + -command "set ${varname}(stats) 1; PlotStats $varname" + $var(mb).graph add command -label [msgcat::mc {List Data}] \ + -command "set ${varname}(list) 1; PlotList $varname" + $var(mb).graph add separator + menu $var(mb).graph.select $var(mb).graph add cascade -label [msgcat::mc {Axes}] \ diff --git a/ds9/library/plotline.tcl b/ds9/library/plotline.tcl index 9960805..6516d71 100644 --- a/ds9/library/plotline.tcl +++ b/ds9/library/plotline.tcl @@ -135,7 +135,7 @@ proc PlotLineDialog {varname wtt title xaxis yaxis} { $var(mb).data.fill add cascade -label [msgcat::mc {Color}] \ -menu $var(mb).data.fill.color - PlotColorMenu $var(mb).data.fill.color $varname graph,fill,color \ + PlotColorMenu $var(mb).data.fill.color $varname graph,ds,fill,color \ [list PlotLineUpdateElement $varname] # Error |