diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2019-06-05 19:35:38 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2019-06-05 19:35:38 (GMT) |
commit | feccecd90c7466d45d7dc6ea0f81fe8620397d4b (patch) | |
tree | f94e28075f86d8e4fed9438bec3f72540930f64d | |
parent | b64f773cedb747da7632a956ec139362ceb6ea3e (diff) | |
download | blt-feccecd90c7466d45d7dc6ea0f81fe8620397d4b.zip blt-feccecd90c7466d45d7dc6ea0f81fe8620397d4b.tar.gz blt-feccecd90c7466d45d7dc6ea0f81fe8620397d4b.tar.bz2 |
add multiple plot support
-rw-r--r-- | ds9/library/plot.tcl | 22 | ||||
-rw-r--r-- | ds9/library/plotbar.tcl | 2 | ||||
-rw-r--r-- | ds9/library/plotdata.tcl | 233 | ||||
-rw-r--r-- | ds9/library/plotline.tcl | 2 | ||||
-rw-r--r-- | ds9/library/plotscatter.tcl | 2 | ||||
-rw-r--r-- | ds9/parsers/plotparser.tac | 18 | ||||
-rw-r--r-- | ds9/parsers/plotparser.tcl | 18 | ||||
-rw-r--r-- | ds9/parsers/plotsendparser.tac | 2 | ||||
-rw-r--r-- | ds9/parsers/plotsendparser.tcl | 2 |
9 files changed, 147 insertions, 154 deletions
diff --git a/ds9/library/plot.tcl b/ds9/library/plot.tcl index 771e1be..b51dc9f 100644 --- a/ds9/library/plot.tcl +++ b/ds9/library/plot.tcl @@ -277,25 +277,13 @@ proc PlotDestroy {varname} { } for {set nn 1} {$nn<=$var($cc,data,total)} {incr nn} { + blt::vector destroy $var($cc,$nn,xdata) $var($cc,$nn,ydata) switch $var($cc,$nn,dim) { - xy { - blt::vector destroy \ - $var($cc,$nn,xdata) $var($cc,$nn,ydata) - } - xyex { - blt::vector destroy \ - $var($cc,$nn,xdata) $var($cc,$nn,ydata) \ - $var($cc,$nn,xedata) - } - xyey { - blt::vector destroy \ - $var($cc,$nn,xdata) $var($cc,$nn,ydata) \ - $var($cc,$nn,yedata) - } + xy {} + xyex {blt::vector destroy $var($cc,$nn,xedata)} + xyey {blt::vector destroy $var($cc,$nn,yedata)} xyexey { - blt::vector destroy \ - $var($cc,$nn,xdata) $var($cc,$nn,ydata) \ - $var($cc,$nn,xedata) $var($cc,$nn,yedata) + blt::vector destroy $var($cc,$nn,xedata) $var($cc,$nn,yedata) } } } diff --git a/ds9/library/plotbar.tcl b/ds9/library/plotbar.tcl index f0af93b..b4bc69a 100644 --- a/ds9/library/plotbar.tcl +++ b/ds9/library/plotbar.tcl @@ -31,8 +31,8 @@ proc PlotBar {tt wtt title xaxis yaxis dim data} { global $varname PlotBarDialog $varname $wtt $title $xaxis $yaxis - PlotDataSet $varname $dim $data + $var(proc,updategraph) $varname PlotStats $varname PlotList $varname diff --git a/ds9/library/plotdata.tcl b/ds9/library/plotdata.tcl index 4d0f516..b3b6d36 100644 --- a/ds9/library/plotdata.tcl +++ b/ds9/library/plotdata.tcl @@ -4,101 +4,6 @@ package provide DS9 1.0 -proc PlotLoadData {varname} { - upvar #0 $varname var - global $varname - - set filename [OpenFileDialog apdatafbox] - if {$filename != {}} { - set dim xy - if {[PlotDataFormatDialog dim]} { - PlotLoadDataFile $varname $filename $dim - } - } -} - -# used by backup -proc PlotLoadDataFile {varname filename dim} { - upvar #0 $varname var - global $varname - - set ch [open $filename] - set data [read $ch] - close $ch - - PlotRaise $varname - - PlotDataSet $varname $dim $data - $var(proc,updategraph) $varname - PlotStats $varname - PlotList $varname -} - -proc PlotSaveData {varname} { - upvar #0 $varname var - global $varname - - set cc $var(graph,current) - - if {$var($cc,xdata) == {}} { - return - } - - PlotSaveDataFile $varname [SaveFileDialog apdatafbox] -} - -proc PlotSaveDataFile {varname filename} { - upvar #0 $varname var - global $varname - - set cc $var(graph,current) - - if {$var($cc,xdata) == {}} { - return - } - - if {$filename == {}} { - return - } - - global $var($cc,xdata) $var($cc,ydata) \ - $var($cc,xedata) $var($cc,yedata) - set ll [$var($cc,xdata) length] - set xx [$var($cc,xdata) range] - set yy [$var($cc,ydata) range] - - set ch [open $filename w] - switch $var($cc,dim) { - xy { - for {set ii 0} {$ii<$ll} {incr ii} { - puts $ch "[lindex $xx $ii] [lindex $yy $ii]" - } - } - xyex { - set xe [$var($cc,xedata) range] - for {set ii 0} {$ii<$ll} {incr ii} { - puts $ch "[lindex $xx $ii] [lindex $yy $ii] [lindex $xe $ii]" - } - } - xyey { - set ye [$var($cc,yedata) range] - for {set ii 0} {$ii<$ll} {incr ii} { - puts $ch "[lindex $xx $ii] [lindex $yy $ii] [lindex $ye $ii]" - } - } - xyexey { - set xe [$var($cc,xedata) range] - set ye [$var($cc,yedata) range] - for {set ii 0} {$ii<$ll} {incr ii} { - puts $ch "[lindex $xx $ii] [lindex $yy $ii] [lindex $xe $ii] [lindex $ye $ii]" - } - } - } - close $ch - - PlotRaise $varname -} - proc PlotDataSet {varname dim data} { upvar #0 $varname var global $varname @@ -172,16 +77,21 @@ proc PlotDataSetOne {varname dim data} { set var(graph,ds,bar,relief) $pap(graph,ds,bar,relief) # new vector names - set xdata ap${varname}xx${nn} - set ydata ap${varname}yy${nn} - set xedata ap${varname}xe${nn} - set yedata ap${varname}ye${nn} + set xdata ap${varname}graph${cc}xx${nn} + set ydata ap${varname}graph${cc}yy${nn} + set xedata ap${varname}graph${cc}xe${nn} + set yedata ap${varname}graph${cc}ye${nn} - # basics xy + # basics set var($cc,manage) 1 set var(graph,ds,name) "Dataset $nn" + + # vectors set var($cc,xdata) $xdata set var($cc,ydata) $ydata + set var($cc,xedata) {} + set var($cc,yedata) {} + global $var($cc,xdata) $var($cc,ydata) blt::vector create $var($cc,xdata) $var($cc,ydata) @@ -198,8 +108,6 @@ proc PlotDataSetOne {varname dim data} { 2 - xy { set var($cc,dim) xy - set var($cc,xedata) {} - set var($cc,yedata) {} for {set ii 0} {$ii<$ll} {incr ii 2} { lappend x [lindex $data $ii] @@ -212,7 +120,6 @@ proc PlotDataSetOne {varname dim data} { xyex { set var($cc,dim) xyex set var($cc,xedata) $xedata - set var($cc,yedata) {} global $var($cc,xedata) blt::vector create $var($cc,xedata) @@ -230,7 +137,6 @@ proc PlotDataSetOne {varname dim data} { 3 - xyey { set var($cc,dim) xyey - set var($cc,xedata) {} set var($cc,yedata) $yedata global $var($cc,yedata) @@ -268,7 +174,6 @@ proc PlotDataSetOne {varname dim data} { 4.1 { set var($cc,dim) xyey - set var($cc,xedata) {} set var($cc,yedata) $yedata global $var($cc,yedata) @@ -286,8 +191,6 @@ proc PlotDataSetOne {varname dim data} { 4.2 { set var($cc,dim) xy - set var($cc,xedata) {} - set var($cc,yedata) {} for {set ii 0} {$ii<$ll} {incr ii 4} { lappend x [lindex $data $ii] @@ -299,7 +202,6 @@ proc PlotDataSetOne {varname dim data} { 5.1 { set var($cc,dim) xyey - set var($cc,xedata) {} set var($cc,yedata) $yedata global $var($cc,yedata) @@ -317,7 +219,6 @@ proc PlotDataSetOne {varname dim data} { 5.2 { set var($cc,dim) xyey - set var($cc,xedata) {} set var($cc,yedata) $yedata global $var($cc,yedata) @@ -369,11 +270,20 @@ proc PlotDupData {varname mm} { set pp [expr $nn-1] # new vector names + set xdata ap${varname}graph${cc}xx${nn} + set ydata ap${varname}graph${cc}yy${nn} + set xedata ap${varname}graph${cc}xe${nn} + set yedata ap${varname}graph${cc}ye${nn} + + # basics + set var($cc,$nn,manage) 1 set var($cc,$nn,name) "Dataset $nn" - set var($cc,$nn,xdata) ap${varname}xx${nn} - set var($cc,$nn,ydata) ap${varname}yy${nn} - set var($cc,$nn,xedata) ap${varname}xe${nn} - set var($cc,$nn,yedata) ap${varname}ye${nn} + + set var($cc,$nn,xdata) $xdata + set var($cc,$nn,ydata) $ydata + set var($cc,$nn,xedata) $xedata + set var($cc,$nn,yedata) $yedata + global $var($cc,$mm,xdata) $var($cc,$mm,ydata) \ $var($cc,$mm,xedata) $var($cc,$mm,yedata) global $var($cc,$nn,xdata) $var($cc,$nn,ydata) \ @@ -392,7 +302,6 @@ proc PlotDupData {varname mm} { set var($cc,$nn,yedata) {} } - set var($cc,$nn,manage) 1 set var($cc,$nn,dim) $var($cc,$mm,dim) set var($cc,$nn,show) $var($cc,$mm,show) @@ -438,3 +347,99 @@ proc PlotDupData {varname mm} { PlotStats $varname PlotList $varname } + +proc PlotLoadData {varname} { + upvar #0 $varname var + global $varname + + set filename [OpenFileDialog apdatafbox] + if {$filename != {}} { + set dim xy + if {[PlotDataFormatDialog dim]} { + PlotLoadDataFile $varname $filename $dim + } + } +} + +# used by backup +proc PlotLoadDataFile {varname filename dim} { + upvar #0 $varname var + global $varname + + set ch [open $filename] + set data [read $ch] + close $ch + + PlotRaise $varname + + PlotDataSet $varname $dim $data + $var(proc,updategraph) $varname + PlotStats $varname + PlotList $varname +} + +proc PlotSaveData {varname} { + upvar #0 $varname var + global $varname + + set cc $var(graph,current) + + if {$var($cc,xdata) == {}} { + return + } + + PlotSaveDataFile $varname [SaveFileDialog apdatafbox] +} + +proc PlotSaveDataFile {varname filename} { + upvar #0 $varname var + global $varname + + set cc $var(graph,current) + + if {$var($cc,xdata) == {}} { + return + } + + if {$filename == {}} { + return + } + + global $var($cc,xdata) $var($cc,ydata) \ + $var($cc,xedata) $var($cc,yedata) + set ll [$var($cc,xdata) length] + set xx [$var($cc,xdata) range] + set yy [$var($cc,ydata) range] + + set ch [open $filename w] + switch $var($cc,dim) { + xy { + for {set ii 0} {$ii<$ll} {incr ii} { + puts $ch "[lindex $xx $ii] [lindex $yy $ii]" + } + } + xyex { + set xe [$var($cc,xedata) range] + for {set ii 0} {$ii<$ll} {incr ii} { + puts $ch "[lindex $xx $ii] [lindex $yy $ii] [lindex $xe $ii]" + } + } + xyey { + set ye [$var($cc,yedata) range] + for {set ii 0} {$ii<$ll} {incr ii} { + puts $ch "[lindex $xx $ii] [lindex $yy $ii] [lindex $ye $ii]" + } + } + xyexey { + set xe [$var($cc,xedata) range] + set ye [$var($cc,yedata) range] + for {set ii 0} {$ii<$ll} {incr ii} { + puts $ch "[lindex $xx $ii] [lindex $yy $ii] [lindex $xe $ii] [lindex $ye $ii]" + } + } + } + close $ch + + PlotRaise $varname +} + diff --git a/ds9/library/plotline.tcl b/ds9/library/plotline.tcl index cf43d38..24e1b71 100644 --- a/ds9/library/plotline.tcl +++ b/ds9/library/plotline.tcl @@ -31,8 +31,8 @@ proc PlotLine {tt wtt title xaxis yaxis dim data} { global $varname PlotLineDialog $varname $wtt $title $xaxis $yaxis - PlotDataSet $varname $dim $data + $var(proc,updategraph) $varname PlotStats $varname PlotList $varname diff --git a/ds9/library/plotscatter.tcl b/ds9/library/plotscatter.tcl index 02b9753..0864f91 100644 --- a/ds9/library/plotscatter.tcl +++ b/ds9/library/plotscatter.tcl @@ -31,8 +31,8 @@ proc PlotScatter {tt wtt title xaxis yaxis dim data} { global $varname PlotScatterDialog $varname $wtt $title $xaxis $yaxis - PlotDataSet $varname $dim $data + $var(proc,updategraph) $varname PlotStats $varname PlotList $varname diff --git a/ds9/parsers/plotparser.tac b/ds9/parsers/plotparser.tac index a2afe27..8a9c559 100644 --- a/ds9/parsers/plotparser.tac +++ b/ds9/parsers/plotparser.tac @@ -250,7 +250,7 @@ plotCmd : LOAD_ load | MODE_ mode {ProcessCmdCVAR mode $2 PlotChangeMode} | AXIS_ axis - | BACKGROUND_ STRING_ {PlotCmdUpdateGraph bg $2} + | BACKGROUND_ STRING_ {PlotCmdUpdateCanvas background $2} | LEGEND_ legend | FONT_ fontt | TITLE_ title @@ -363,17 +363,17 @@ legendPos : RIGHT_ {set _ right} | BOTTOM_ {set _ bottom} ; -fontt : fontType FONT_ font {PlotCmdUpdateGraph "$1,family" $3} +fontt : fontType FONT_ font {PlotCmdUpdateCanvas "$1,family" $3} # backward compatibility - | fontType FAMILY_ font {PlotCmdUpdateGraph "$1,family" $3} - | fontType FONTSIZE_ INT_ {PlotCmdUpdateGraph "$1,size" $3} - | fontType FONTWEIGHT_ fontWeight {PlotCmdUpdateGraph "$1,weight" $3} - | fontType FONTSLANT_ fontSlant {PlotCmdUpdateGraph "$1,slant" $3} + | fontType FAMILY_ font {PlotCmdUpdateCanvas "$1,family" $3} + | fontType FONTSIZE_ INT_ {PlotCmdUpdateCanvas "$1,size" $3} + | fontType FONTWEIGHT_ fontWeight {PlotCmdUpdateCanvas "$1,weight" $3} + | fontType FONTSLANT_ fontSlant {PlotCmdUpdateCanvas "$1,slant" $3} # backward compatibility | fontType FONTSTYLE_ fontStyle {PlotCmdFontStyle $1 $3} - | fontType SIZE_ INT_ {PlotCmdUpdateGraph "$1,size" $3} - | fontType WEIGHT_ fontWeight {PlotCmdUpdateGraph "$1,weight" $3} - | fontType SLANT_ fontSlant {PlotCmdUpdateGraph "$1,slant" $3} + | fontType SIZE_ INT_ {PlotCmdUpdateCanvas "$1,size" $3} + | fontType WEIGHT_ fontWeight {PlotCmdUpdateCanvas "$1,weight" $3} + | fontType SLANT_ fontSlant {PlotCmdUpdateCanvas "$1,slant" $3} | fontType STYLE_ fontStyle {PlotCmdFontStyle $1 $3} ; diff --git a/ds9/parsers/plotparser.tcl b/ds9/parsers/plotparser.tcl index 1f028d7..93d01c5 100644 --- a/ds9/parsers/plotparser.tcl +++ b/ds9/parsers/plotparser.tcl @@ -5428,7 +5428,7 @@ proc plot::yyparse {} { 74 { PlotCmdSaveConfig $2 } 78 { ProcessCmdCVAR0 PlotDestroy } 79 { ProcessCmdCVAR mode $2 PlotChangeMode } - 81 { PlotCmdUpdateGraph bg $2 } + 81 { PlotCmdUpdateCanvas background $2 } 85 { PlotCmdUpdateCanvas bar,mode $2 } 86 { PlotCmdUpdateElement graph,ds,show $2 } 88 { PlotCmdUpdateElement graph,ds,fill $2 } @@ -5493,15 +5493,15 @@ proc plot::yyparse {} { 152 { set _ left } 153 { set _ top } 154 { set _ bottom } - 155 { PlotCmdUpdateGraph "$1,family" $3 } - 156 { PlotCmdUpdateGraph "$1,family" $3 } - 157 { PlotCmdUpdateGraph "$1,size" $3 } - 158 { PlotCmdUpdateGraph "$1,weight" $3 } - 159 { PlotCmdUpdateGraph "$1,slant" $3 } + 155 { PlotCmdUpdateCanvas "$1,family" $3 } + 156 { PlotCmdUpdateCanvas "$1,family" $3 } + 157 { PlotCmdUpdateCanvas "$1,size" $3 } + 158 { PlotCmdUpdateCanvas "$1,weight" $3 } + 159 { PlotCmdUpdateCanvas "$1,slant" $3 } 160 { PlotCmdFontStyle $1 $3 } - 161 { PlotCmdUpdateGraph "$1,size" $3 } - 162 { PlotCmdUpdateGraph "$1,weight" $3 } - 163 { PlotCmdUpdateGraph "$1,slant" $3 } + 161 { PlotCmdUpdateCanvas "$1,size" $3 } + 162 { PlotCmdUpdateCanvas "$1,weight" $3 } + 163 { PlotCmdUpdateCanvas "$1,slant" $3 } 164 { PlotCmdFontStyle $1 $3 } 165 { set _ graph,title } 166 { set _ axis,title } diff --git a/ds9/parsers/plotsendparser.tac b/ds9/parsers/plotsendparser.tac index a5444ba..ea794ec 100644 --- a/ds9/parsers/plotsendparser.tac +++ b/ds9/parsers/plotsendparser.tac @@ -76,7 +76,7 @@ plotCmd : STATS_ {ProcessSendCmdCVAR PlotStatsGenerate} | LIST_ {ProcessSendCmdCVAR PlotListGenerate} | MODE_ {ProcessSendCmdCVARGet mode} | AXIS_ axis - | BACKGROUND_ {ProcessSendCmdCVARGet bg} + | BACKGROUND_ {ProcessSendCmdCVARGet background} | LEGEND_ legend | FONT_ fontt | TITLE_ title diff --git a/ds9/parsers/plotsendparser.tcl b/ds9/parsers/plotsendparser.tcl index d5fad69..2d77e8e 100644 --- a/ds9/parsers/plotsendparser.tcl +++ b/ds9/parsers/plotsendparser.tcl @@ -1489,7 +1489,7 @@ proc plotsend::yyparse {} { 13 { ProcessSendCmdCVAR PlotStatsGenerate } 14 { ProcessSendCmdCVAR PlotListGenerate } 15 { ProcessSendCmdCVARGet mode } - 17 { ProcessSendCmdCVARGet bg } + 17 { ProcessSendCmdCVARGet background } 21 { ProcessSendCmdCVARGet bar,mode } 22 { ProcessSendCmdCVARYesNo graph,ds,show } 23 { ProcessSendCmdCVARGet graph,ds,color } |