summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2019-06-06 19:12:24 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2019-06-06 19:12:24 (GMT)
commitd96b6868ce44cf9094f22a17054a7b6d316fbb3e (patch)
treeca3a3ed40b979c174297354d8e6aff4283d27dcd
parentd953f256a5c736b285d0a762caf0dabcbe5df4b5 (diff)
downloadblt-d96b6868ce44cf9094f22a17054a7b6d316fbb3e.zip
blt-d96b6868ce44cf9094f22a17054a7b6d316fbb3e.tar.gz
blt-d96b6868ce44cf9094f22a17054a7b6d316fbb3e.tar.bz2
support multiple graphs per plot
-rw-r--r--ds9/library/markeranalysispanda.tcl5
-rw-r--r--ds9/library/markeranalysisplot2d.tcl9
-rw-r--r--ds9/library/markeranalysisplot3d.tcl17
-rw-r--r--ds9/library/markeranalysisradial.tcl5
-rw-r--r--ds9/library/plot.tcl66
-rw-r--r--ds9/library/plotbar.tcl2
-rw-r--r--ds9/library/plotline.tcl2
-rw-r--r--ds9/library/plotscatter.tcl16
-rw-r--r--ds9/library/plotstate.tcl7
9 files changed, 60 insertions, 69 deletions
diff --git a/ds9/library/markeranalysispanda.tcl b/ds9/library/markeranalysispanda.tcl
index d14871a..619fb96 100644
--- a/ds9/library/markeranalysispanda.tcl
+++ b/ds9/library/markeranalysispanda.tcl
@@ -155,7 +155,6 @@ proc MarkerAnalysisPandaAxisTitle {vvarname} {
set vvar(graph,axis,y,title) $ytitle
# update now (may not make it into plot code)
- set cc $vvar(graph,current)
- $vvar($cc) xaxis configure -title $xtitle
- $vvar($cc) yaxis configure -title $ytitle
+ $vvar(graph) xaxis configure -title $xtitle
+ $vvar(graph) yaxis configure -title $ytitle
}
diff --git a/ds9/library/markeranalysisplot2d.tcl b/ds9/library/markeranalysisplot2d.tcl
index ae5748e..a791ca9 100644
--- a/ds9/library/markeranalysisplot2d.tcl
+++ b/ds9/library/markeranalysisplot2d.tcl
@@ -167,8 +167,7 @@ proc MarkerAnalysisPlot2dCB {frame id} {
set vvar(xcdata) $xcdata
set vvar(ycdata) $ycdata
- set cc $vvar(graph,current)
- $vvar($cc) xaxis configure \
+ $vvar(graph) xaxis configure \
-command "MarkerAnalysisPlot2dXAxis $vvarname"
set vvar(graph,ds,manage) 0
@@ -238,8 +237,7 @@ proc MarkerAnalysisPlot2dXAxisTitle {vvarname} {
set vvar(graph,axis,x,title) $xtitle
# update now (may not make it into plot code)
- set cc $vvar(graph,current)
- $vvar($cc) xaxis configure -title $xtitle
+ $vvar(graph) xaxis configure -title $xtitle
}
proc MarkerAnalysisPlot2dYAxisTitle {vvarname} {
@@ -250,8 +248,7 @@ proc MarkerAnalysisPlot2dYAxisTitle {vvarname} {
set vvar(graph,axis,y,title) "$vvar(bunit) [string totitle $vvar(method)]"
# update now (may not make it into plot code)
- set cc $vvar(graph,current)
- $vvar($cc) yaxis configure -title $vvar(graph,axis,y,title)
+ $vvar(graph) yaxis configure -title $vvar(graph,axis,y,title)
}
proc MarkerAnalysisPlot2dXAxis {vvarname w xx} {
diff --git a/ds9/library/markeranalysisplot3d.tcl b/ds9/library/markeranalysisplot3d.tcl
index 19f57f3..5f5f178 100644
--- a/ds9/library/markeranalysisplot3d.tcl
+++ b/ds9/library/markeranalysisplot3d.tcl
@@ -165,11 +165,10 @@ proc MarkerAnalysisPlot3dCB {frame id} {
MarkerAnalysisPlot3dXAxisTitle $vvarname
MarkerAnalysisPlot3dYAxisTitle $vvarname
- set cc $vvar(graph,current)
- set vvar(markerslice) [$vvar($cc) marker create line -element bar1 \
+ set vvar(markerslice) [$vvar(graph) marker create line -element bar1 \
-outline cyan -linewidth 2 \
-bindtags [list slice]]
- $vvar($cc) marker bind slice <B1-Motion> \
+ $vvar(graph) marker bind slice <B1-Motion> \
[list MarkerAnalysisPlot3dMotion $vvarname %x %y]
set vvar(mode) pointer
@@ -206,8 +205,7 @@ proc MarkerAnalysisPlot3dMotion {vvarname xx yy} {
return
}
- set cc $vvar(graph,current)
- set vvar(slice) [lindex [$vvar($cc) invtransform $xx $yy] 0]
+ set vvar(slice) [lindex [$vvar(graph) invtransform $xx $yy] 0]
$vvar(frame) update fits slice $vvar(slice) $vvar(system) $vvar(sky)
MarkerAnalysisPlot3dMarker $vvarname
@@ -237,8 +235,7 @@ proc MarkerAnalysisPlot3dMarker {vvarname} {
set vvar(slice) [expr $max-$delta]
}
- set cc $vvar(graph,current)
- $vvar($cc) marker configure $vvar(markerslice) \
+ $vvar(graph) marker configure $vvar(markerslice) \
-coords "$vvar(slice) -Inf $vvar(slice) Inf"
}
@@ -302,8 +299,7 @@ proc MarkerAnalysisPlot3dXAxisTitle {vvarname} {
set vvar(graph,axis,x,title) $xtitle
# update now (may not make it into plot code)
- set cc $vvar(graph,current)
- $vvar($cc) xaxis configure -title $xtitle
+ $vvar(graph) xaxis configure -title $xtitle
}
proc MarkerAnalysisPlot3dYAxisTitle {vvarname} {
@@ -314,6 +310,5 @@ proc MarkerAnalysisPlot3dYAxisTitle {vvarname} {
set vvar(graph,axis,y,title) "$vvar(bunit) [string totitle $vvar(method)]"
# update now (may not make it into plot code)
- set cc $vvar(graph,current)
- $vvar($cc) yaxis configure -title $vvar(graph,axis,y,title)
+ $vvar(graph) yaxis configure -title $vvar(graph,axis,y,title)
}
diff --git a/ds9/library/markeranalysisradial.tcl b/ds9/library/markeranalysisradial.tcl
index 251cd25..480dbe8 100644
--- a/ds9/library/markeranalysisradial.tcl
+++ b/ds9/library/markeranalysisradial.tcl
@@ -172,7 +172,6 @@ proc MarkerAnalysisRadialAxisTitle {vvarname} {
set vvar(graph,axis,y,title) $ytitle
# update now (may not make it into plot code)
- set cc $vvar(graph,current)
- $vvar($cc) xaxis configure -title $xtitle
- $vvar($cc) yaxis configure -title $ytitle
+ $vvar(graph) xaxis configure -title $xtitle
+ $vvar(graph) yaxis configure -title $ytitle
}
diff --git a/ds9/library/plot.tcl b/ds9/library/plot.tcl
index 71a9b42..f488be6 100644
--- a/ds9/library/plot.tcl
+++ b/ds9/library/plot.tcl
@@ -53,16 +53,16 @@ proc PlotAddGraph {varname} {
set var($cc,data,total) 0
set var($cc,data,current) 0
- PlotInitGraph $varname
-
$var(proc,addgraph) $varname
+ PlotInitGraph $varname
+
# set up zoom stack, assuming mode is zoom
global ds9
switch $ds9(wm) {
x11 -
- win32 {Blt_ZoomStack $var($cc) -mode release}
- aqua {Blt_ZoomStack $var($cc) -mode release -button "ButtonPress-2"}
+ win32 {Blt_ZoomStack $var(graph) -mode release}
+ aqua {Blt_ZoomStack $var(graph) -mode release -button "ButtonPress-2"}
}
PlotLayoutCanvas $varname
@@ -72,11 +72,15 @@ proc PlotDeleteGraph {varname} {
upvar #0 $varname var
global $varname
- set cc $var(graph,current)
- if {$cc != {}} {
- destroy $var($cc)
- list replace ${varname}(graphs) $cc {}
+ if {[llength $var(graphs)] <= 1} {
+ return
}
+
+ destroy $var(graph)
+ list replace ${varname}(graphs) $var(graph,current) {}
+
+ set var(graph,current) [lindex $var(graphs) 0]
+ PlotRestoreState $varname
}
# Data
@@ -93,25 +97,25 @@ proc PlotAddData {varname} {
}
# delete current elements
- foreach el [$var($cc) element names] {
+ foreach el [$var(graph) element names] {
set f [split $el -]
if {[lindex $f 1] == $nn} {
- $var($cc) element delete $el
+ $var(graph) element delete $el
}
}
global $var(graph,ds,xdata) $var(graph,ds,ydata)
- $var($cc) element create "d-${nn}" \
+ $var(graph) element create "d-${nn}" \
-xdata $var(graph,ds,xdata) -ydata $var(graph,ds,ydata)
if {$var(graph,ds,xedata) != {}} {
if {[$var(graph,ds,xedata) length] != 0} {
- $var($cc) element configure "d-${nn}" \
+ $var(graph) element configure "d-${nn}" \
-xerror $var(graph,ds,xedata)
}
}
if {$var(graph,ds,yedata) != {}} {
if {[$var(graph,ds,yedata) length] != 0} {
- $var($cc) element configure "d-${nn}" \
+ $var(graph) element configure "d-${nn}" \
-yerror $var(graph,ds,yedata)
}
}
@@ -135,10 +139,10 @@ proc PlotDeleteData {varname} {
for {set nn 1} {$nn<=$var($cc,data,total)} {incr nn} {
if {$var($cc,$nn,manage)} {
# delete elements
- foreach el [$var($cc) element names] {
+ foreach el [$var(graph) element names] {
set f [split $el -]
if {[lindex $f 1] == $nn} {
- $var($cc) element delete $el
+ $var(graph) element delete $el
}
}
@@ -216,7 +220,6 @@ proc PlotCurrentData {varname} {
set cc $var(graph,current)
if {$var($cc,data,total) > 0} {
- set nn $var($cc,data,current)
PlotRestoreState $varname
}
@@ -491,8 +494,6 @@ proc PlotUpdateGraph {varname} {
upvar #0 $varname var
global $varname
- set cc $var(graph,current)
-
if {$var(graph,axis,x,auto)} {
set xmin {}
set xmax {}
@@ -509,23 +510,23 @@ proc PlotUpdateGraph {varname} {
set ymax $var(graph,axis,y,max)
}
- $var($cc) xaxis configure -min $xmin -max $xmax \
+ $var(graph) xaxis configure -min $xmin -max $xmax \
-descending $var(graph,axis,x,flip)
- $var($cc) yaxis configure -min $ymin -max $ymax \
+ $var(graph) yaxis configure -min $ymin -max $ymax \
-descending $var(graph,axis,y,flip)
if {$var(graph,format)} {
if {$var(graph,axis,x,format) != {}} {
- $var($cc) xaxis configure \
+ $var(graph) xaxis configure \
-command [list PlotAxisFormat $varname x]
} else {
- $var($cc) xaxis configure -command {}
+ $var(graph) xaxis configure -command {}
}
if {$var(graph,axis,y,format) != {}} {
- $var($cc) yaxis configure \
+ $var(graph) yaxis configure \
-command [list PlotAxisFormat $varname y]
} else {
- $var($cc) yaxis configure -command {}
+ $var(graph) yaxis configure -command {}
}
}
@@ -533,16 +534,9 @@ proc PlotUpdateGraph {varname} {
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
-
- if {$var($cc,1,manage)} {
- $var(mb).file entryconfig [msgcat::mc {Duplicate Data}] \
- -state normal
- } else {
- $var(mb).file entryconfig [msgcat::mc {Duplicate Data}] \
- -state disable
- }
} else {
$var(mb).file entryconfig "[msgcat::mc {Save Data}]..." -state disabled
$var(mb).file entryconfig [msgcat::mc {Clear Data}] -state disabled
@@ -552,17 +546,17 @@ proc PlotUpdateGraph {varname} {
}
# Graph
- $var($cc) configure -plotpadx 0 -plotpady 0 -title $var(graph,title)
+ $var(graph) configure -plotpadx 0 -plotpady 0 -title $var(graph,title)
- $var($cc) xaxis configure \
+ $var(graph) xaxis configure \
-grid $var(graph,axis,x,grid) -logscale $var(graph,axis,x,log) \
-title $var(graph,axis,x,title)
- $var($cc) yaxis configure \
+ $var(graph) yaxis configure \
-grid $var(graph,axis,y,grid) -logscale $var(graph,axis,y,log) \
-title $var(graph,axis,y,title)
- $var($cc) legend configure -hide [expr !$var(graph,legend)] \
+ $var(graph) legend configure -hide [expr !$var(graph,legend)] \
-position $var(graph,legend,position) -title $var(graph,legend,title)
}
diff --git a/ds9/library/plotbar.tcl b/ds9/library/plotbar.tcl
index b4bc69a..01fe9f2 100644
--- a/ds9/library/plotbar.tcl
+++ b/ds9/library/plotbar.tcl
@@ -181,7 +181,7 @@ proc PlotBarUpdateElement {varname} {
}
set nn $var($cc,data,current)
- $var($cc) element configure "d-${nn}" \
+ $var(graph) element configure "d-${nn}" \
-label $var(graph,ds,name) -hide [expr !$var(graph,ds,show)] \
-relief $var(graph,ds,bar,relief) -color $var(graph,ds,color) \
-showerrorbars $show -errorbarcolor $var(graph,ds,error,color) \
diff --git a/ds9/library/plotline.tcl b/ds9/library/plotline.tcl
index 24e1b71..9960805 100644
--- a/ds9/library/plotline.tcl
+++ b/ds9/library/plotline.tcl
@@ -199,7 +199,7 @@ proc PlotLineUpdateElement {varname} {
}
set nn $var($cc,data,current)
- $var($cc) element configure "d-${nn}" \
+ $var(graph) element configure "d-${nn}" \
-label $var(graph,ds,name) -hide [expr !$var(graph,ds,show)] \
-symbol $var(graph,ds,shape,symbol) -fill $clr -scalesymbols no \
-pixels 5 -outline $var(graph,ds,shape,color) \
diff --git a/ds9/library/plotscatter.tcl b/ds9/library/plotscatter.tcl
index 0864f91..85ad1f0 100644
--- a/ds9/library/plotscatter.tcl
+++ b/ds9/library/plotscatter.tcl
@@ -121,7 +121,7 @@ proc PlotScatterUpdateElement {varname} {
}
set nn $var($cc,data,current)
- $var($cc) element configure "d-${nn}" \
+ $var(graph) element configure "d-${nn}" \
-label $var(graph,ds,name) -hide [expr !$var(graph,ds,show)] \
-symbol $var(graph,ds,shape,symbol) -fill $clr -scalesymbols no \
-outline $var(graph,ds,shape,color) \
@@ -129,7 +129,7 @@ proc PlotScatterUpdateElement {varname} {
-showerrorbars $show -errorbarcolor $var(graph,ds,error,color) \
-errorbarwidth $var(graph,ds,error,width) -errorbarcap $cap
- $var($cc) pen configure active -color blue \
+ $var(graph) pen configure active -color blue \
-symbol $var(graph,ds,shape,symbol) \
-linewidth 0 -pixels 5 \
-showerrorbars $show -errorbarcolor $var(graph,ds,error,color) \
@@ -150,18 +150,18 @@ proc PlotScatterButton {varname x y} {
return
}
- set rr [$var($cc) element closest $x $y]
+ set rr [$var(graph) element closest $x $y]
set elem [lindex $rr 1]
set row [lindex $rr 3]
if {$elem != {}} {
if {$row != {}} {
- $var($cc) element deactivate $elem
- $var($cc) element activate $elem $row
+ $var(graph) element deactivate $elem
+ $var(graph) element activate $elem $row
# rows start at 1
eval "$var(callback) [expr $row+1]"
} else {
- $var($cc) element deactivate $elem
+ $var(graph) element deactivate $elem
eval "$var(callback) {}"
}
}
@@ -178,10 +178,10 @@ proc PlotScatterHighliteElement {varname rowlist} {
}
if {$var(graph,ds,show)} {
- $var($cc) element deactivate d-1
+ $var(graph) element deactivate d-1
if {$rowlist != {}} {
# can have multiple rows
- eval "$var($cc) element activate d-1 $rowlist"
+ eval "$var(graph) element activate d-1 $rowlist"
}
}
}
diff --git a/ds9/library/plotstate.tcl b/ds9/library/plotstate.tcl
index 2b9cf53..aeacd6b 100644
--- a/ds9/library/plotstate.tcl
+++ b/ds9/library/plotstate.tcl
@@ -89,6 +89,11 @@ proc PlotInitGraph {varname} {
global pap
+ set cc $var(graph,current)
+ set nn $var($cc,data,current)
+ set var(graph) $var($cc)
+ set var(graph,ds) $nn
+
# per Graph
set var(graph,legend) $pap(graph,legend)
set var(graph,legend,title) $pap(graph,legend,title)
@@ -210,6 +215,8 @@ proc PlotRestoreState {varname} {
set cc $var(graph,current)
set nn $var($cc,data,current)
+ set var(graph) $var($cc)
+ set var(graph,ds) $nn
# per Graph
set var(graph,title) $var($cc,title)