diff options
Diffstat (limited to 'ds9/library/plotdata.tcl')
-rw-r--r-- | ds9/library/plotdata.tcl | 289 |
1 files changed, 151 insertions, 138 deletions
diff --git a/ds9/library/plotdata.tcl b/ds9/library/plotdata.tcl index 800deef..4d0f516 100644 --- a/ds9/library/plotdata.tcl +++ b/ds9/library/plotdata.tcl @@ -38,10 +38,9 @@ proc PlotSaveData {varname} { upvar #0 $varname var global $varname - set tt $var(graph,total) set cc $var(graph,current) - if {$var(graph$cc,xdata) == {}} { + if {$var($cc,xdata) == {}} { return } @@ -52,10 +51,9 @@ proc PlotSaveDataFile {varname filename} { upvar #0 $varname var global $varname - set tt $var(graph,total) set cc $var(graph,current) - if {$var(graph$cc,xdata) == {}} { + if {$var($cc,xdata) == {}} { return } @@ -63,34 +61,34 @@ proc PlotSaveDataFile {varname filename} { return } - global $var(graph$cc,xdata) $var(graph$cc,ydata) \ - $var(graph$cc,xedata) $var(graph$cc,yedata) - set ll [$var(graph$cc,xdata) length] - set xx [$var(graph$cc,xdata) range] - set yy [$var(graph$cc,ydata) range] + 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(graph$cc,dim) { + 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(graph$cc,xedata) range] + 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(graph$cc,yedata) range] + 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(graph$cc,xedata) range] - set ye [$var(graph$cc,yedata) range] + 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]" } @@ -105,7 +103,6 @@ proc PlotDataSet {varname dim data} { upvar #0 $varname var global $varname - set tt $var(graph,total) set cc $var(graph,current) switch -- $dim { @@ -138,7 +135,6 @@ proc PlotDataSetOne {varname dim data} { # save current state PlotSaveState $varname - set tt $var(graph,total) set cc $var(graph,current) # look for no data @@ -150,12 +146,30 @@ proc PlotDataSetOne {varname dim data} { set ll [llength $data] # incr count - incr ${varname}(graph$cc,data,total) - set nn $var(graph$cc,data,total) - set var(graph$cc,data,current) $nn + incr ${varname}($cc,data,total) + set nn $var($cc,data,total) + set var($cc,data,current) $nn # init new state - PlotInitState $varname + global pap + set var(graph,ds,show) $pap(graph,ds,show) + set var(graph,ds,smooth) $pap(graph,ds,smooth) + set var(graph,ds,color) $pap(graph,ds,color) + set var(graph,ds,fill) $pap(graph,ds,fill) + set var(graph,ds,fill,color) $pap(graph,ds,fill,color) + set var(graph,ds,width) $pap(graph,ds,width) + set var(graph,ds,dash) $pap(graph,ds,dash) + + set var(graph,ds,shape,symbol) $pap(graph,ds,shape,symbol) + set var(graph,ds,shape,fill) $pap(graph,ds,shape,fill) + set var(graph,ds,shape,color) $pap(graph,ds,shape,color) + + set var(graph,ds,error) $pap(graph,ds,error) + set var(graph,ds,error,cap) $pap(graph,ds,error,cap) + set var(graph,ds,error,color) $pap(graph,ds,error,color) + set var(graph,ds,error,width) $pap(graph,ds,error,width) + + set var(graph,ds,bar,relief) $pap(graph,ds,bar,relief) # new vector names set xdata ap${varname}xx${nn} @@ -164,12 +178,12 @@ proc PlotDataSetOne {varname dim data} { set yedata ap${varname}ye${nn} # basics xy - set var(graph$cc,manage) 1 + set var($cc,manage) 1 set var(graph,ds,name) "Dataset $nn" - set var(graph$cc,xdata) $xdata - set var(graph$cc,ydata) $ydata - global $var(graph$cc,xdata) $var(graph$cc,ydata) - blt::vector create $var(graph$cc,xdata) $var(graph$cc,ydata) + set var($cc,xdata) $xdata + set var($cc,ydata) $ydata + global $var($cc,xdata) $var($cc,ydata) + blt::vector create $var($cc,xdata) $var($cc,ydata) # substitute all separtors regsub -all {[\n\r\t, ]+} $data { } data @@ -183,62 +197,62 @@ proc PlotDataSetOne {varname dim data} { switch -- $dim { 2 - xy { - set var(graph$cc,dim) xy - set var(graph$cc,xedata) {} - set var(graph$cc,yedata) {} + 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] lappend y [lindex $data [expr $ii+1]] } - $var(graph$cc,xdata) set $x - $var(graph$cc,ydata) set $y + $var($cc,xdata) set $x + $var($cc,ydata) set $y } xyex { - set var(graph$cc,dim) xyex - set var(graph$cc,xedata) $xedata - set var(graph$cc,yedata) {} + set var($cc,dim) xyex + set var($cc,xedata) $xedata + set var($cc,yedata) {} - global $var(graph$cc,xedata) - blt::vector create $var(graph$cc,xedata) + global $var($cc,xedata) + blt::vector create $var($cc,xedata) for {set ii 0} {$ii<$ll} {incr ii 3} { lappend x [lindex $data $ii] lappend y [lindex $data [expr $ii+1]] lappend xe [lindex $data [expr $ii+2]] } - $var(graph$cc,xdata) set $x - $var(graph$cc,ydata) set $y - $var(graph$cc,xedata) set $xe + $var($cc,xdata) set $x + $var($cc,ydata) set $y + $var($cc,xedata) set $xe } 3 - xyey { - set var(graph$cc,dim) xyey - set var(graph$cc,xedata) {} - set var(graph$cc,yedata) $yedata + set var($cc,dim) xyey + set var($cc,xedata) {} + set var($cc,yedata) $yedata - global $var(graph$cc,yedata) - blt::vector create $var(graph$cc,yedata) + global $var($cc,yedata) + blt::vector create $var($cc,yedata) for {set ii 0} {$ii<$ll} {incr ii 3} { lappend x [lindex $data $ii] lappend y [lindex $data [expr $ii+1]] lappend ye [lindex $data [expr $ii+2]] } - $var(graph$cc,xdata) set $x - $var(graph$cc,ydata) set $y - $var(graph$cc,yedata) set $ye + $var($cc,xdata) set $x + $var($cc,ydata) set $y + $var($cc,yedata) set $ye } xyexey { - set var(graph$cc,dim) xyexey - set var(graph$cc,xedata) $xedata - set var(graph$cc,yedata) $yedata + set var($cc,dim) xyexey + set var($cc,xedata) $xedata + set var($cc,yedata) $yedata - global $var(graph$cc,xedata) $var(graph$cc,yedata) - blt::vector create $var(graph$cc,xedata) $var(graph$cc,yedata) + global $var($cc,xedata) $var($cc,yedata) + blt::vector create $var($cc,xedata) $var($cc,yedata) for {set ii 0} {$ii<$ll} {incr ii 4} { lappend x [lindex $data $ii] @@ -246,93 +260,93 @@ proc PlotDataSetOne {varname dim data} { lappend xe [lindex $data [expr $ii+2]] lappend ye [lindex $data [expr $ii+3]] } - $var(graph$cc,xdata) set $x - $var(graph$cc,ydata) set $y - $var(graph$cc,xedata) set $xe - $var(graph$cc,yedata) set $ye + $var($cc,xdata) set $x + $var($cc,ydata) set $y + $var($cc,xedata) set $xe + $var($cc,yedata) set $ye } 4.1 { - set var(graph$cc,dim) xyey - set var(graph$cc,xedata) {} - set var(graph$cc,yedata) $yedata + set var($cc,dim) xyey + set var($cc,xedata) {} + set var($cc,yedata) $yedata - global $var(graph$cc,yedata) - blt::vector create $var(graph$cc,yedata) + global $var($cc,yedata) + blt::vector create $var($cc,yedata) for {set ii 0} {$ii<$ll} {incr ii 4} { lappend x [lindex $data $ii] lappend y [lindex $data [expr $ii+1]] lappend ye [lindex $data [expr $ii+2]] } - $var(graph$cc,xdata) set $x - $var(graph$cc,ydata) set $y - $var(graph$cc,yedata) set $ye + $var($cc,xdata) set $x + $var($cc,ydata) set $y + $var($cc,yedata) set $ye } 4.2 { - set var(graph$cc,dim) xy - set var(graph$cc,xedata) {} - set var(graph$cc,yedata) {} + 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] lappend y [lindex $data [expr $ii+3]] } - $var(graph$cc,xdata) set $x - $var(graph$cc,ydata) set $y + $var($cc,xdata) set $x + $var($cc,ydata) set $y } 5.1 { - set var(graph$cc,dim) xyey - set var(graph$cc,xedata) {} - set var(graph$cc,yedata) $yedata + set var($cc,dim) xyey + set var($cc,xedata) {} + set var($cc,yedata) $yedata - global $var(graph$cc,yedata) - blt::vector create $var(graph$cc,yedata) + global $var($cc,yedata) + blt::vector create $var($cc,yedata) for {set ii 0} {$ii<$ll} {incr ii 5} { lappend x [lindex $data $ii] lappend y [lindex $data [expr $ii+1]] lappend ye [lindex $data [expr $ii+2]] } - $var(graph$cc,xdata) set $x - $var(graph$cc,ydata) set $y - $var(graph$cc,yedata) set $ye + $var($cc,xdata) set $x + $var($cc,ydata) set $y + $var($cc,yedata) set $ye } 5.2 { - set var(graph$cc,dim) xyey - set var(graph$cc,xedata) {} - set var(graph$cc,yedata) $yedata + set var($cc,dim) xyey + set var($cc,xedata) {} + set var($cc,yedata) $yedata - global $var(graph$cc,yedata) - blt::vector create $var(graph$cc,yedata) + global $var($cc,yedata) + blt::vector create $var($cc,yedata) for {set ii 0} {$ii<$ll} {incr ii 5} { lappend x [lindex $data $ii] lappend y [lindex $data [expr $ii+3]] lappend ye [lindex $data [expr $ii+4]] } - $var(graph$cc,xdata) set $x - $var(graph$cc,ydata) set $y - $var(graph$cc,yedata) set $ye + $var($cc,xdata) set $x + $var($cc,ydata) set $y + $var($cc,yedata) set $ye } } - set var(graph$cc,$nn,manage) 1 - set var(graph$cc,$nn,dim) $var(graph$cc,dim) + set var($cc,$nn,manage) 1 + set var($cc,$nn,dim) $var($cc,dim) - set var(graph$cc,$nn,xdata) $var(graph$cc,xdata) - set var(graph$cc,$nn,ydata) $var(graph$cc,ydata) - set var(graph$cc,$nn,xedata) $var(graph$cc,xedata) - set var(graph$cc,$nn,yedata) $var(graph$cc,yedata) + set var($cc,$nn,xdata) $var($cc,xdata) + set var($cc,$nn,ydata) $var($cc,ydata) + set var($cc,$nn,xedata) $var($cc,xedata) + set var($cc,$nn,yedata) $var($cc,yedata) PlotSaveState $varname # update data set menu $var(mb).graph.select add radiobutton -label "$var(graph,ds,name)" \ - -variable ${varname}(graph$cc,data,current) -value $nn \ + -variable ${varname}($cc,data,current) -value $nn \ -command [list PlotCurrentData $varname] PlotAddData $varname @@ -343,79 +357,78 @@ proc PlotDupData {varname mm} { upvar #0 $varname var global $varname - set tt $var(graph,total) set cc $var(graph,current) - if {$var(graph$cc,data,total) == 0} { + if {$var($cc,data,total) == 0} { return } # incr count - incr ${varname}(graph$cc,data,total) - set nn $var(graph$cc,data,total) + incr ${varname}($cc,data,total) + set nn $var($cc,data,total) set pp [expr $nn-1] # new vector names - set var(graph$cc,$nn,name) "Dataset $nn" - set var(graph$cc,$nn,xdata) ap${varname}xx${nn} - set var(graph$cc,$nn,ydata) ap${varname}yy${nn} - set var(graph$cc,$nn,xedata) ap${varname}xe${nn} - set var(graph$cc,$nn,yedata) ap${varname}ye${nn} - global $var(graph$cc,$mm,xdata) $var(graph$cc,$mm,ydata) \ - $var(graph$cc,$mm,xedata) $var(graph$cc,$mm,yedata) - global $var(graph$cc,$nn,xdata) $var(graph$cc,$nn,ydata) \ - $var(graph$cc,$nn,xedata) $var(graph$cc,$nn,yedata) + 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} + 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) \ + $var($cc,$nn,xedata) $var($cc,$nn,yedata) - $var(graph$cc,$mm,xdata) dup $var(graph$cc,$nn,xdata) - $var(graph$cc,$mm,ydata) dup $var(graph$cc,$nn,ydata) - if {$var(graph$cc,$mm,xedata) != {}} { - $var(graph$cc,$mm,xedata) dup $var(graph$cc,$nn,xedata) + $var($cc,$mm,xdata) dup $var($cc,$nn,xdata) + $var($cc,$mm,ydata) dup $var($cc,$nn,ydata) + if {$var($cc,$mm,xedata) != {}} { + $var($cc,$mm,xedata) dup $var($cc,$nn,xedata) } else { - set var(graph$cc,$nn,xedata) {} + set var($cc,$nn,xedata) {} } - if {$var(graph$cc,$mm,yedata) != {}} { - $var(graph$cc,$mm,yedata) dup $var(graph$cc,$nn,yedata) + if {$var($cc,$mm,yedata) != {}} { + $var($cc,$mm,yedata) dup $var($cc,$nn,yedata) } else { - set var(graph$cc,$nn,yedata) {} + set var($cc,$nn,yedata) {} } - set var(graph$cc,$nn,manage) 1 - set var(graph$cc,$nn,dim) $var(graph$cc,$mm,dim) + set var($cc,$nn,manage) 1 + set var($cc,$nn,dim) $var($cc,$mm,dim) - set var(graph$cc,$nn,show) $var(graph$cc,$mm,show) - set var(graph$cc,$nn,smooth) $var(graph$cc,$mm,smooth) - set var(graph$cc,$nn,color) $var(graph$cc,$mm,color) - set var(graph$cc,$nn,fill) $var(graph$cc,$mm,fill) - set var(graph$cc,$nn,fill,color) $var(graph$cc,$mm,fill,color) - set var(graph$cc,$nn,width) $var(graph$cc,$mm,width) - set var(graph$cc,$nn,dash) $var(graph$cc,$mm,dash) + set var($cc,$nn,show) $var($cc,$mm,show) + set var($cc,$nn,smooth) $var($cc,$mm,smooth) + set var($cc,$nn,color) $var($cc,$mm,color) + set var($cc,$nn,fill) $var($cc,$mm,fill) + set var($cc,$nn,fill,color) $var($cc,$mm,fill,color) + set var($cc,$nn,width) $var($cc,$mm,width) + set var($cc,$nn,dash) $var($cc,$mm,dash) - set var(graph$cc,$nn,shape,symbol) $var(graph$cc,$mm,shape,symbol) - set var(graph$cc,$nn,shape,fill) $var(graph$cc,$mm,shape,fill) - set var(graph$cc,$nn,shape,color) $var(graph$cc,$mm,shape,color) + set var($cc,$nn,shape,symbol) $var($cc,$mm,shape,symbol) + set var($cc,$nn,shape,fill) $var($cc,$mm,shape,fill) + set var($cc,$nn,shape,color) $var($cc,$mm,shape,color) - set var(graph$cc,$nn,error) $var(graph$cc,$mm,error) - set var(graph$cc,$nn,error,cap) $var(graph$cc,$mm,error,cap) - set var(graph$cc,$nn,error,color) $var(graph$cc,$mm,error,color) - set var(graph$cc,$nn,error,width) $var(graph$cc,$mm,error,width) + set var($cc,$nn,error) $var($cc,$mm,error) + set var($cc,$nn,error,cap) $var($cc,$mm,error,cap) + set var($cc,$nn,error,color) $var($cc,$mm,error,color) + set var($cc,$nn,error,width) $var($cc,$mm,error,width) - set var(graph$cc,$nn,bar,relief) $var(graph$cc,$mm,bar,relief) + set var($cc,$nn,bar,relief) $var($cc,$mm,bar,relief) # update data set menu - $var(mb).graph.select add radiobutton -label "$var(graph$cc,$nn,name)" \ - -variable ${varname}(graph$cc,data,current) -value $nn \ + $var(mb).graph.select add radiobutton -label "$var($cc,$nn,name)" \ + -variable ${varname}($cc,data,current) -value $nn \ -command [list PlotCurrentData $varname] # make current - set var(graph$cc,data,current) $nn + set var($cc,data,current) $nn - set var(graph$cc,manage) $var(graph$cc,$nn,manage) - set var(graph$cc,dim) $var(graph$cc,$nn,dim) + set var($cc,manage) $var($cc,$nn,manage) + set var($cc,dim) $var($cc,$nn,dim) - set var(graph$cc,xdata) $var(graph$cc,$nn,xdata) - set var(graph$cc,ydata) $var(graph$cc,$nn,ydata) - set var(graph$cc,xedata) $var(graph$cc,$nn,xedata) - set var(graph$cc,yedata) $var(graph$cc,$nn,yedata) + set var($cc,xdata) $var($cc,$nn,xdata) + set var($cc,ydata) $var($cc,$nn,ydata) + set var($cc,xedata) $var($cc,$nn,xedata) + set var($cc,yedata) $var($cc,$nn,yedata) PlotRestoreState $varname $nn |