diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2019-08-01 20:13:06 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2019-08-01 20:13:06 (GMT) |
commit | 72b66e3813c41c693970e4fba1294844098cd60a (patch) | |
tree | f2077e2d2871301060154784eb505bd040ef5d4b /ds9/library | |
parent | 950c895406e5d8580540a657c27659fc89a99285 (diff) | |
download | blt-72b66e3813c41c693970e4fba1294844098cd60a.zip blt-72b66e3813c41c693970e4fba1294844098cd60a.tar.gz blt-72b66e3813c41c693970e4fba1294844098cd60a.tar.bz2 |
support multiple graphs per plot
Diffstat (limited to 'ds9/library')
-rw-r--r-- | ds9/library/plot.tcl | 66 | ||||
-rw-r--r-- | ds9/library/plotconfig.tcl | 8 | ||||
-rw-r--r-- | ds9/library/plotdialog.tcl | 52 | ||||
-rw-r--r-- | ds9/library/plotstate.tcl | 10 |
4 files changed, 73 insertions, 63 deletions
diff --git a/ds9/library/plot.tcl b/ds9/library/plot.tcl index 3457eb5..3a8c0ea 100644 --- a/ds9/library/plot.tcl +++ b/ds9/library/plot.tcl @@ -439,6 +439,32 @@ proc PlotChangeAxis {varname} { } } +proc PlotChangeLegend {varname} { + upvar #0 $varname var + global $varname + + switch $var(layout) { + grid - + column - + row {PlotUpdateGraph $varname} + strip { + PlotUpdateCanvas $varname + set cc $var(graph,current) + set nn $var(graph,ds,current) + foreach gg $var(graphs) { + set var(graph,current) $gg + set var(graph,ds,current) [lindex $var($gg,dss) 0] + PlotRestoreState $varname + + PlotUpdateGraph $varname + } + set var(graph,current) $cc + set var(graph,ds,current) $nn + PlotRestoreState $varname + } + } +} + # used by backup proc PlotChangeLayout {varname} { upvar #0 $varname var @@ -692,38 +718,14 @@ proc PlotUpdateCanvas {varname} { $var($cc,graph) legend configure \ -bg $var(background) \ - -position $var(legend,position) \ -font "{$ds9($var(legend,font,family))} $var(legend,font,size) $var(legend,font,weight) $var(legend,font,slant)" \ -titlefont "{$ds9($var(legend,title,family))} $var(legend,title,size) $var(legend,title,weight) $var(legend,title,slant)" - switch $var(legend,position) { - top { - if {$cc == $first} { - $var($cc,graph) legend configure -hide [expr !$var(legend)] - } else { - $var($cc,graph) legend configure -hide yes - } - } - bottom { - if {$cc == $last} { - $var($cc,graph) legend configure -hide [expr !$var(legend)] - } else { - $var($cc,graph) legend configure -hide yes - } - } - left - - right - - plotarea { - $var($cc,graph) legend configure -hide [expr !$var(legend)] - } - } - - set var($cc,axis,x,manage) 1 - set var($cc,axis,y,manage) 1 switch $var(layout) { grid - row - column { + set var($cc,axis,x,manage) 1 $var($cc,graph) configure \ -topmargin 0 -bottommargin 0 \ -leftmargin 0 -rightmargin 0 \ @@ -734,15 +736,16 @@ proc PlotUpdateCanvas {varname} { $var($cc,graph) yaxis configure -showticks 1 -linewidth 1 } strip { - if {$cc != $first} { + if {$cc == $first} { + set var($cc,axis,x,manage) 1 + } else { set var($cc,axis,x,manage) 0 - set var($cc,axis,y,manage) 1 } set left [expr 8*$var(axis,font,size) + $var(axis,title,size)] set right 10 - if {$var(legend)} { + if {$var($first,legend)} { # find max legend dataset name width set nc 0 foreach nn $var($first,dss) { @@ -752,7 +755,7 @@ proc PlotUpdateCanvas {varname} { } } set ll [expr $var(legend,title,size)*4 + $var(legend,font,size)*$nc] - switch $var(legend,position) { + switch $var($first,legend,position) { top {} bottom {} right {set right [expr $right + $ll]} @@ -861,7 +864,10 @@ proc PlotUpdateGraph {varname} { } $var(graph) yaxis configure -title $var(graph,axis,y,title) - $var(graph) legend configure -title $var(graph,legend,title) + + $var(graph) legend configure -hide [expr !$var(graph,legend)] \ + -title $var(graph,legend,title) \ + -position $var(graph,legend,position) } proc PlotButtonInvoke {varname cc nn xx yy} { diff --git a/ds9/library/plotconfig.tcl b/ds9/library/plotconfig.tcl index 04040f5..8691d83 100644 --- a/ds9/library/plotconfig.tcl +++ b/ds9/library/plotconfig.tcl @@ -28,8 +28,6 @@ proc PlotLoadConfigFile {varname filename} { set var(graph,title,weight) $analysisplot(graph,title,weight) set var(graph,title,slant) $analysisplot(graph,title,slant) - set var(legend) $analysisplot(legend) - set var(legend,position) $analysisplot(legend,position) set var(legend,title,family) $analysisplot(legend,title,family) set var(legend,title,size) $analysisplot(legend,title,size) set var(legend,title,weight) $analysisplot(legend,title,weight) @@ -50,7 +48,9 @@ proc PlotLoadConfigFile {varname filename} { set var(axis,font,slant) $analysisplot(axis,font,slant) # per Graph + set var(graph,legend) $analysisplot(legend) set var(graph,legend,title) $analysisplot(legend,title) + set var(graph,legend,position) $analysisplot(legend,position) set var(graph,axis,x,title) $analysisplot(axis,x,title) set var(graph,axis,x,grid) $analysisplot(axis,x,grid) @@ -208,8 +208,6 @@ proc PlotSaveConfigFile {varname filename} { set analysisplot(graph,title,weight) $var(graph,title,weight) set analysisplot(graph,title,slant) $var(graph,title,slant) - set analysisplot(legend) $var(legend) - set analysisplot(legend,position) $var(legend,position) set analysisplot(legend,title,family) $var(legend,title,family) set analysisplot(legend,title,size) $var(legend,title,size) set analysisplot(legend,title,weight) $var(legend,title,weight) @@ -232,7 +230,9 @@ proc PlotSaveConfigFile {varname filename} { # per Graph set analysisplot(graph,title) $var(graph,title) + set analysisplot(legend) $var(graph,legend) set analysisplot(legend,title) $var(graph,legend,title) + set analysisplot(legend,position) $var(graph,legend,position) set analysisplot(axis,x,title) $var(graph,axis,x,title) set analysisplot(axis,x,grid) $var(graph,axis,x,grid) diff --git a/ds9/library/plotdialog.tcl b/ds9/library/plotdialog.tcl index ed251dd..b9fcab5 100644 --- a/ds9/library/plotdialog.tcl +++ b/ds9/library/plotdialog.tcl @@ -118,9 +118,6 @@ proc PlotDialog {varname wtt} { $var(mb).canvas add separator $var(mb).canvas add cascade -label [msgcat::mc {Layout}] \ -menu $var(mb).canvas.layout - $var(mb).canvas add separator - $var(mb).canvas add cascade -label [msgcat::mc {Legend}] \ - -menu $var(mb).canvas.legend $var(mb).canvas add cascade -label [msgcat::mc {Font}] \ -menu $var(mb).canvas.font $var(mb).canvas add cascade -label [msgcat::mc {Background}] \ @@ -155,27 +152,6 @@ proc PlotDialog {varname wtt} { -label "[msgcat::mc {Strip Parameters}]..." \ -command [list PlotStripDialog $varname] - menu $var(mb).canvas.legend - $var(mb).canvas.legend add checkbutton -label [msgcat::mc {Show}] \ - -variable ${varname}(legend) \ - -command [list PlotUpdateCanvas $varname] - $var(mb).canvas.legend add separator - $var(mb).canvas.legend add radiobutton -label [msgcat::mc {Right}] \ - -variable ${varname}(legend,position) -value right \ - -command [list PlotUpdateCanvas $varname] - $var(mb).canvas.legend add radiobutton -label [msgcat::mc {Left}] \ - -variable ${varname}(legend,position) -value left \ - -command [list PlotUpdateCanvas $varname] - $var(mb).canvas.legend add radiobutton -label [msgcat::mc {Top}] \ - -variable ${varname}(legend,position) -value top \ - -command [list PlotUpdateCanvas $varname] - $var(mb).canvas.legend add radiobutton -label [msgcat::mc {Bottom}] \ - -variable ${varname}(legend,position) -value bottom \ - -command [list PlotUpdateCanvas $varname] - $var(mb).canvas.legend add radiobutton -label [msgcat::mc {Plot Area}] \ - -variable ${varname}(legend,position) -value plotarea \ - -command [list PlotUpdateCanvas $varname] - menu $var(mb).canvas.font $var(mb).canvas.font add cascade -label [msgcat::mc {Title}] \ -menu $var(mb).canvas.font.title @@ -226,12 +202,13 @@ proc PlotDialog {varname wtt} { $var(mb).graph add cascade -label [msgcat::mc {Axes}] \ -menu $var(mb).graph.axes + $var(mb).graph add cascade -label [msgcat::mc {Legend}] \ + -menu $var(mb).graph.legend + $var(mb).graph add cascade -label [msgcat::mc {Bar Mode}] \ + -menu $var(mb).graph.barmode $var(mb).graph add separator $var(mb).graph add command -label "[msgcat::mc {Titles}]..." \ -command [list PlotGraphTitleDialog $varname] - $var(mb).graph add separator - $var(mb).graph add cascade -label [msgcat::mc {Bar Mode}] \ - -menu $var(mb).graph.barmode menu $var(mb).graph.select @@ -259,6 +236,27 @@ proc PlotDialog {varname wtt} { $var(mb).graph.axes add command -label "[msgcat::mc {Range}]..." \ -command [list PlotRangeDialog $varname] + menu $var(mb).graph.legend + $var(mb).graph.legend add checkbutton -label [msgcat::mc {Show}] \ + -variable ${varname}(graph,legend) \ + -command [list PlotChangeLegend $varname] + $var(mb).graph.legend add separator + $var(mb).graph.legend add radiobutton -label [msgcat::mc {Right}] \ + -variable ${varname}(graph,legend,position) -value right \ + -command [list PlotChangeLegend $varname] + $var(mb).graph.legend add radiobutton -label [msgcat::mc {Left}] \ + -variable ${varname}(graph,legend,position) -value left \ + -command [list PlotChangeLegend $varname] + $var(mb).graph.legend add radiobutton -label [msgcat::mc {Top}] \ + -variable ${varname}(graph,legend,position) -value top \ + -command [list PlotChangeLegend $varname] + $var(mb).graph.legend add radiobutton -label [msgcat::mc {Bottom}] \ + -variable ${varname}(graph,legend,position) -value bottom \ + -command [list PlotChangeLegend $varname] + $var(mb).graph.legend add radiobutton -label [msgcat::mc {Plot Area}] \ + -variable ${varname}(graph,legend,position) -value plotarea \ + -command [list PlotChangeLegend $varname] + # Graph Mode menu $var(mb).graph.barmode $var(mb).graph.barmode add radiobutton -label [msgcat::mc {Normal}] \ diff --git a/ds9/library/plotstate.tcl b/ds9/library/plotstate.tcl index 58e7404..70c1c76 100644 --- a/ds9/library/plotstate.tcl +++ b/ds9/library/plotstate.tcl @@ -28,8 +28,6 @@ proc PlotDefState {} { set pap(graph,title,weight) normal set pap(graph,title,slant) roman - set pap(legend) 0 - set pap(legend,position) right set pap(legend,title,family) helvetica set pap(legend,title,size) 10 set pap(legend,title,weight) normal @@ -49,7 +47,9 @@ proc PlotDefState {} { set pap(axis,font,slant) roman # per Graph + set pap(graph,legend) 0 set pap(graph,legend,title) Legend + set pap(graph,legend,position) right set pap(graph,axis,x,title) {} set pap(graph,axis,x,grid) 1 @@ -115,7 +115,9 @@ proc PlotInitGraph {varname} { set var(graph,seq) 0 set var(graph,dss) {} + set var(graph,legend) $pap(graph,legend) set var(graph,legend,title) $pap(graph,legend,title) + set var(graph,legend,position) $pap(graph,legend,position) set var(graph,axis,x,manage) 1 set var(graph,axis,x,title) $pap(graph,axis,x,title) @@ -189,7 +191,9 @@ proc PlotSaveState {varname} { set var($cc,seq) $var(graph,seq) set var($cc,dss) $var(graph,dss) + set var($cc,legend) $var(graph,legend) set var($cc,legend,title) $var(graph,legend,title) + set var($cc,legend,position) $var(graph,legend,position) set var($cc,axis,x,manage) $var(graph,axis,x,manage) set var($cc,axis,x,title) $var(graph,axis,x,title) @@ -263,7 +267,9 @@ proc PlotRestoreState {varname} { set var(graph,seq) $var($cc,seq) set var(graph,dss) $var($cc,dss) + set var(graph,legend) $var($cc,legend) set var(graph,legend,title) $var($cc,legend,title) + set var(graph,legend,position) $var($cc,legend,position) set var(graph,axis,x,manage) $var($cc,axis,x,manage) set var(graph,axis,x,title) $var($cc,axis,x,title) |