summaryrefslogtreecommitdiffstats
path: root/ds9
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2019-08-02 18:29:35 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2019-08-02 18:29:35 (GMT)
commit4ede751525acf5dca111a33b3c821db7efe5c864 (patch)
tree6d3f1f136a836481d12336f4e98edea0e3eab1fd /ds9
parent1a5a00c2a843498895f02b66e738c2ab19332291 (diff)
downloadblt-4ede751525acf5dca111a33b3c821db7efe5c864.zip
blt-4ede751525acf5dca111a33b3c821db7efe5c864.tar.gz
blt-4ede751525acf5dca111a33b3c821db7efe5c864.tar.bz2
support multiple graphs per plot
Diffstat (limited to 'ds9')
-rw-r--r--ds9/library/plot.tcl247
-rw-r--r--ds9/library/plotdialog.tcl36
-rw-r--r--ds9/parsers/plotparser.tac10
-rw-r--r--ds9/parsers/plotparser.tcl10
4 files changed, 180 insertions, 123 deletions
diff --git a/ds9/library/plot.tcl b/ds9/library/plot.tcl
index a8a1857..efd0c03 100644
--- a/ds9/library/plot.tcl
+++ b/ds9/library/plot.tcl
@@ -61,78 +61,6 @@ proc PlotDestroy {varname} {
unset $varname
}
-proc PlotLayoutCanvas {varname} {
- upvar #0 $varname var
- global $varname
-
- set ss [grid size $var(top)]
- for {set jj 0} {$jj<[lindex $ss 0]} {incr jj} {
- grid columnconfigure $var(top) $jj -weight 0
- }
- for {set ii 0} {$ii<[lindex $ss 1]} {incr ii} {
- grid rowconfigure $var(top) $ii -weight 0
- }
-
- foreach cc $var(graphs) {
- grid forget $var($cc,canvas)
- }
-
- switch $var(layout) {
- grid {
- set num [llength $var(graphs)]
- set nr [expr int(sqrt($num)+.5)]
- set nc [expr int(sqrt($num-1))+1]
-
- set xx 0
- set yy 0
- foreach cc $var(graphs) {
- grid columnconfigure $var(top) $xx -weight 1
- grid rowconfigure $var(top) $yy -weight 1
- grid $var($cc,canvas) -row $yy -column $xx -sticky news
-
- incr xx
- if {$xx==$nc} {
- set xx 0
- incr yy
- }
- }
- }
- column {
- set ii 0
- grid columnconfigure $var(top) 0 -weight 1
- foreach cc $var(graphs) {
- grid rowconfigure $var(top) $ii -weight 1
- grid $var($cc,canvas) -row $ii -column 0 -sticky news
- incr ii
- }
- }
- row {
- set ii 0
- grid rowconfigure $var(top) 0 -weight 1
- foreach cc $var(graphs) {
- grid columnconfigure $var(top) $ii -weight 1
- grid $var($cc,canvas) -row 0 -column $ii -sticky news
- incr ii
- }
- }
- strip {
- set ww 1
- set ii 0
- grid columnconfigure $var(top) 0 -weight 1
- foreach cc $var(graphs) {
- grid rowconfigure $var(top) $ii -weight $ww
- grid $var($cc,canvas) -row $ii -column 0 -sticky news
-
- set ww [expr int(100./$var(layout,strip,weight))]
- incr ii
- }
- }
- }
-
- # needed so layout can be properly realized
- update idletasks
-}
-
# Graph
# used by backup
proc PlotAddGraph {varname type} {
@@ -405,14 +333,6 @@ proc PlotCurrentDataSet {varname} {
PlotStats $varname
PlotList $varname
}
-
-proc PlotAxisFormat {varname axis w nn} {
- upvar #0 $varname var
- global $varname
-
- return [format $var(graph,axis,$axis,format) $nn]
-}
-
proc PlotChangeAxis {varname} {
upvar #0 $varname var
global $varname
@@ -447,7 +367,10 @@ proc PlotChangeLegend {varname} {
grid -
column -
row {PlotUpdateGraph $varname}
- strip {PlotUpdateCanvas $varname}
+ strip {
+ PlotUpdateCanvas $varname
+ PlotUpdateGraph $varname
+ }
}
}
@@ -474,6 +397,21 @@ proc PlotChangeLayout {varname} {
PlotLayoutCanvas $varname
}
+proc PlotChangeTitle {varname} {
+ upvar #0 $varname var
+ global $varname
+
+ switch $var(layout) {
+ grid -
+ column -
+ row {PlotUpdateGraph $varname}
+ strip {
+ PlotUpdateCanvas $varname
+ PlotUpdateGraph $varname
+ }
+ }
+}
+
# used by backup
proc PlotChangeMode {varname} {
upvar #0 $varname var
@@ -495,6 +433,13 @@ proc PlotChangeMode {varname} {
}
}
+proc PlotAxisFormat {varname axis w nn} {
+ upvar #0 $varname var
+ global $varname
+
+ return [format $var(graph,axis,$axis,format) $nn]
+}
+
proc PlotList {varname} {
upvar #0 $varname var
global $varname
@@ -635,6 +580,78 @@ proc PlotStatsDestroyCB {varname} {
set var(stats) 0
}
+proc PlotLayoutCanvas {varname} {
+ upvar #0 $varname var
+ global $varname
+
+ set ss [grid size $var(top)]
+ for {set jj 0} {$jj<[lindex $ss 0]} {incr jj} {
+ grid columnconfigure $var(top) $jj -weight 0
+ }
+ for {set ii 0} {$ii<[lindex $ss 1]} {incr ii} {
+ grid rowconfigure $var(top) $ii -weight 0
+ }
+
+ foreach cc $var(graphs) {
+ grid forget $var($cc,canvas)
+ }
+
+ switch $var(layout) {
+ grid {
+ set num [llength $var(graphs)]
+ set nr [expr int(sqrt($num)+.5)]
+ set nc [expr int(sqrt($num-1))+1]
+
+ set xx 0
+ set yy 0
+ foreach cc $var(graphs) {
+ grid columnconfigure $var(top) $xx -weight 1
+ grid rowconfigure $var(top) $yy -weight 1
+ grid $var($cc,canvas) -row $yy -column $xx -sticky news
+
+ incr xx
+ if {$xx==$nc} {
+ set xx 0
+ incr yy
+ }
+ }
+ }
+ column {
+ set ii 0
+ grid columnconfigure $var(top) 0 -weight 1
+ foreach cc $var(graphs) {
+ grid rowconfigure $var(top) $ii -weight 1
+ grid $var($cc,canvas) -row $ii -column 0 -sticky news
+ incr ii
+ }
+ }
+ row {
+ set ii 0
+ grid rowconfigure $var(top) 0 -weight 1
+ foreach cc $var(graphs) {
+ grid columnconfigure $var(top) $ii -weight 1
+ grid $var($cc,canvas) -row 0 -column $ii -sticky news
+ incr ii
+ }
+ }
+ strip {
+ set ww 1
+ set ii 0
+ grid columnconfigure $var(top) 0 -weight 1
+ foreach cc $var(graphs) {
+ grid rowconfigure $var(top) $ii -weight $ww
+ grid $var($cc,canvas) -row $ii -column 0 -sticky news
+
+ set ww [expr int(100./$var(layout,strip,weight))]
+ incr ii
+ }
+ }
+ }
+
+ # needed so layout can be properly realized
+ update idletasks
+}
+
# procs
# used by backup
proc PlotUpdateCanvas {varname} {
@@ -643,7 +660,7 @@ proc PlotUpdateCanvas {varname} {
global ds9
PlotSaveState $varname
-
+
set first [lindex $var(graphs) 0]
set last [lindex $var(graphs) end]
@@ -682,12 +699,6 @@ proc PlotUpdateCanvas {varname} {
}
foreach cc $var(graphs) {
- switch $var($cc,type) {
- line {}
- bar {$var($cc,graph) configure -barmode $var(bar,mode)}
- scatter {}
- }
-
$var($cc,graph) configure -plotpadx 0 -plotpady 0 \
-font "{$ds9($var(graph,title,family))} $var(graph,title,size) $var(graph,title,weight) $var(graph,title,slant)" \
-bg $var(background) -plotbackground $var(background)
@@ -728,10 +739,12 @@ proc PlotUpdateCanvas {varname} {
set var($cc,axis,x,manage) 0
}
- set left [expr 8*$var(axis,font,size) + $var(axis,title,size)]
- set right 10
+# set left [expr 8*$var(axis,font,size) + $var(axis,title,size)]
+# set right 10
+ set left 100
+ set right 100
- if {$var($first,legend)} {
+ if {$var($first,legend) &&0} {
# find max legend dataset name width
set nc 0
foreach nn $var($first,dss) {
@@ -814,6 +827,12 @@ proc PlotUpdateGraph {varname} {
set xflip $var(layout,axis,x,flip)
}
+ switch $var(graph,type) {
+ line {}
+ bar {$var(graph) configure -barmode $var(bar,mode)}
+ scatter {}
+ }
+
if {$var(graph,format)} {
if {$var(graph,axis,x,format) != {}} {
$var(graph) xaxis configure \
@@ -851,9 +870,47 @@ proc PlotUpdateGraph {varname} {
$var(graph) yaxis configure -title $var(graph,axis,y,title)
- $var(graph) legend configure -hide [expr !$var(graph,legend)] \
- -title $var(graph,legend,title) \
- -position $var(graph,legend,position)
+ switch $var(layout) {
+ grid -
+ row -
+ column {
+ $var(graph) legend configure -hide [expr !$var(graph,legend)] \
+ -title $var(graph,legend,title) \
+ -position $var(graph,legend,position)
+ }
+ strip {
+ switch $var(graph,legend,position) {
+ top {
+ if {$var(graph,axis,x,manage)} {
+ $var(graph) legend configure \
+ -hide [expr !$var(graph,legend)] \
+ -title $var(graph,legend,title) \
+ -position $var(graph,legend,position)
+ } else {
+ $var(graph) legend configure -hide yes
+ }
+ }
+ bottom {
+ if {[$var(graph) xaxis cget -showticks]} {
+ $var(graph) legend configure \
+ -hide [expr !$var(graph,legend)] \
+ -title $var(graph,legend,title) \
+ -position $var(graph,legend,position)
+ } else {
+ $var(graph) legend configure -hide yes
+ }
+ }
+ right -
+ left -
+ plotarea {
+ $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} {
@@ -910,7 +967,7 @@ proc PlotTitle {varname title xaxis yaxis} {
set var(graph,axis,x,title) "$xaxis"
set var(graph,axis,y,title) "$yaxis"
- PlotUpdateGraph $varname
+ PlotChangeTitle $varname
}
proc PlotBackup {ch dir} {
diff --git a/ds9/library/plotdialog.tcl b/ds9/library/plotdialog.tcl
index 1fd3211..4a2fd3b 100644
--- a/ds9/library/plotdialog.tcl
+++ b/ds9/library/plotdialog.tcl
@@ -122,9 +122,6 @@ proc PlotDialog {varname wtt} {
-menu $var(mb).canvas.font
$var(mb).canvas add cascade -label [msgcat::mc {Background}] \
-menu $var(mb).canvas.bg
- $var(mb).canvas add separator
- $var(mb).canvas add cascade -label [msgcat::mc {Bar Mode}] \
- -menu $var(mb).canvas.barmode
menu $var(mb).canvas.select
@@ -186,20 +183,6 @@ proc PlotDialog {varname wtt} {
PlotColorMenu $var(mb).canvas.bg $varname background \
[list PlotUpdateCanvas $varname]
- menu $var(mb).canvas.barmode
- $var(mb).canvas.barmode add radiobutton -label [msgcat::mc {Normal}] \
- -variable ${varname}(bar,mode) -value normal \
- -command [list PlotUpdateCanvas $varname]
- $var(mb).canvas.barmode add radiobutton -label [msgcat::mc {Stacked}] \
- -variable ${varname}(bar,mode) -value stacked \
- -command [list PlotUpdateCanvas $varname]
- $var(mb).canvas.barmode add radiobutton -label [msgcat::mc {Aligned}] \
- -variable ${varname}(bar,mode) -value aligned \
- -command [list PlotUpdateCanvas $varname]
- $var(mb).canvas.barmode add radiobutton -label [msgcat::mc {Overlap}] \
- -variable ${varname}(bar,mode) -value overlap \
- -command [list PlotUpdateCanvas $varname]
-
# Graph
menu $var(mb).graph
@@ -222,6 +205,9 @@ proc PlotDialog {varname wtt} {
$var(mb).graph add cascade -label [msgcat::mc {Legend}] \
-menu $var(mb).graph.legend
$var(mb).graph add separator
+ $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]
@@ -272,6 +258,20 @@ proc PlotDialog {varname wtt} {
-variable ${varname}(graph,legend,position) -value plotarea \
-command [list PlotChangeLegend $varname]
+ menu $var(mb).graph.barmode
+ $var(mb).graph.barmode add radiobutton -label [msgcat::mc {Normal}] \
+ -variable ${varname}(bar,mode) -value normal \
+ -command [list PlotUpdateGraph $varname]
+ $var(mb).graph.barmode add radiobutton -label [msgcat::mc {Stacked}] \
+ -variable ${varname}(bar,mode) -value stacked \
+ -command [list PlotUpdateGraph $varname]
+ $var(mb).graph.barmode add radiobutton -label [msgcat::mc {Aligned}] \
+ -variable ${varname}(bar,mode) -value aligned \
+ -command [list PlotUpdateGraph $varname]
+ $var(mb).graph.barmode add radiobutton -label [msgcat::mc {Overlap}] \
+ -variable ${varname}(bar,mode) -value overlap \
+ -command [list PlotUpdateGraph $varname]
+
PlotLineMenus $varname
PlotBarMenus $varname
PlotScatterMenus $varname
@@ -520,7 +520,7 @@ proc PlotGraphTitleDialog {varname} {
set var(graph,axis,y,title) $ed(graph,axis,y,title)
set var(graph,legend,title) $ed(graph,legend,title)
- PlotUpdateCanvas $varname
+ PlotChangeTitle $varname
}
set rr $ed(ok)
diff --git a/ds9/parsers/plotparser.tac b/ds9/parsers/plotparser.tac
index 0a1f8db..ac6d581 100644
--- a/ds9/parsers/plotparser.tac
+++ b/ds9/parsers/plotparser.tac
@@ -259,7 +259,7 @@ plotCmd : LOAD_ load
{ProcessCmdCVAR layout,strip,weight $4 PlotChangeLayout}
| FONT_ fontt
| BACKGROUND_ STRING_ {ProcessCmdCVAR background $2 PlotUpdateCanvas}
- | BARMODE_ barmode {ProcessCmdCVAR bar,mode $2 PlotUpdateCanvas}
+ | BARMODE_ barmode {ProcessCmdCVAR bar,mode $2 PlotUpdateGraph}
# Graph Menu
| SELECT_ DATASET_ INT_ {ProcessCmdCVAR graph,ds,current $3 PlotCurrentDataSet}
@@ -440,10 +440,10 @@ relief : FLAT_ {set _ flat}
| GROOVE_ {set _ groove}
;
-title : STRING_ {ProcessCmdCVAR graph,title $1 PlotUpdateGraph}
- | xy STRING_ {ProcessCmdCVAR "graph,axis,$1,title" $2 PlotUpdateGraph}
- | xyaxis STRING_ {ProcessCmdCVAR "graph,axis,$1,title" $2 PlotUpdateGraph}
- | LEGEND_ STRING_ {ProcessCmdCVAR graph,legend,title $2 PlotUpdateGraph}
+title : STRING_ {ProcessCmdCVAR graph,title $1 PlotChangeTitle}
+ | xy STRING_ {ProcessCmdCVAR "graph,axis,$1,title" $2 PlotChangeTitle}
+ | xyaxis STRING_ {ProcessCmdCVAR "graph,axis,$1,title" $2 PlotChangeTitle}
+ | LEGEND_ STRING_ {ProcessCmdCVAR graph,legend,title $2 PlotChangeTitle}
;
# Data Menu params
diff --git a/ds9/parsers/plotparser.tcl b/ds9/parsers/plotparser.tcl
index 01e0f45..630dd8b 100644
--- a/ds9/parsers/plotparser.tcl
+++ b/ds9/parsers/plotparser.tcl
@@ -5688,7 +5688,7 @@ proc plot::yyparse {} {
77 { ProcessCmdCVAR layout $2 PlotChangeLayout }
78 { ProcessCmdCVAR layout,strip,weight $4 PlotChangeLayout }
80 { ProcessCmdCVAR background $2 PlotUpdateCanvas }
- 81 { ProcessCmdCVAR bar,mode $2 PlotUpdateCanvas }
+ 81 { ProcessCmdCVAR bar,mode $2 PlotUpdateGraph }
82 { ProcessCmdCVAR graph,ds,current $3 PlotCurrentDataSet }
83 { ProcessCmdCVAR graph,ds,current $2 PlotCurrentDataSet }
84 { ProcessCmdCVAR graph,ds,current $2 PlotCurrentDataSet }
@@ -5793,10 +5793,10 @@ proc plot::yyparse {} {
194 { set _ raised }
195 { set _ solid }
196 { set _ groove }
- 197 { ProcessCmdCVAR graph,title $1 PlotUpdateGraph }
- 198 { ProcessCmdCVAR "graph,axis,$1,title" $2 PlotUpdateGraph }
- 199 { ProcessCmdCVAR "graph,axis,$1,title" $2 PlotUpdateGraph }
- 200 { ProcessCmdCVAR graph,legend,title $2 PlotUpdateGraph }
+ 197 { ProcessCmdCVAR graph,title $1 PlotChangeTitle }
+ 198 { ProcessCmdCVAR "graph,axis,$1,title" $2 PlotChangeTitle }
+ 199 { ProcessCmdCVAR "graph,axis,$1,title" $2 PlotChangeTitle }
+ 200 { ProcessCmdCVAR graph,legend,title $2 PlotChangeTitle }
201 { PlotCmdUpdateElement graph,ds,shape,symbol $1 }
202 { PlotCmdUpdateElement graph,ds,shape,file $2 }
203 { PlotCmdUpdateElement graph,ds,shape,color $2 }