summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ds9/library/plot.tcl46
-rw-r--r--ds9/library/plotprint.tcl161
-rw-r--r--ds9/library/plotstate.tcl9
3 files changed, 206 insertions, 10 deletions
diff --git a/ds9/library/plot.tcl b/ds9/library/plot.tcl
index 506bb6b..9b9b438 100644
--- a/ds9/library/plot.tcl
+++ b/ds9/library/plot.tcl
@@ -608,9 +608,13 @@ proc PlotLayoutCanvas {varname} {
set xx 0
set yy 0
foreach cc $var(graphs) {
+ set var($cc,tx) [expr $xx*$z1]
+ set var($cc,ty) [expr $yy*$z2]
+
place $var($cc,graph) -in $var(top) \
-relwidth $z1 -relheight $z2 \
- -relx [expr $xx*$z1] -rely [expr $yy*$z2] -anchor nw
+ -relx [expr $xx*$z1] -rely [expr $yy*$z2] \
+ -anchor nw
incr xx
if {$xx==$nc} {
@@ -623,9 +627,13 @@ proc PlotLayoutCanvas {varname} {
set zz [expr 1./[llength $var(graphs)]]
set ii 0
foreach cc $var(graphs) {
+ set var($cc,tx) [expr $ii*$zz]
+ set var($cc,ty) 0
+
place $var($cc,graph) -in $var(top) \
-relwidth $zz -relheight 1 \
- -relx [expr $ii*$zz] -rely .5 -anchor w
+ -relx [expr $ii*$zz] -rely .5 \
+ -anchor w
incr ii
}
}
@@ -633,9 +641,13 @@ proc PlotLayoutCanvas {varname} {
set zz [expr 1./[llength $var(graphs)]]
set ii 0
foreach cc $var(graphs) {
+ set var($cc,tx) 0
+ set var($cc,ty) [expr $ii*$zz]
+
place $var($cc,graph) -in $var(top) \
-relwidth 1 -relheight $zz \
- -relx .5 -rely [expr $ii*$zz] -anchor n
+ -relx .5 -rely [expr $ii*$zz] \
+ -anchor n
incr ii
}
}
@@ -653,18 +665,28 @@ proc PlotLayoutCanvas {varname} {
set ii 0
foreach cc $var(graphs) {
if {$ii == 0} {
+ set var($cc,tx) 0
+ set var($cc,ty) 0
+
place $var($cc,graph) -in $var(top) \
- -relwidth 1 -relheight $z1 -x 0 -y 0
+ -relwidth 1 -relheight $z1 \
+ -x 0 -y 0
} else {
+ set var($cc,tx) 0
+ set var($cc,ty) [expr ($ii-1)*$z2 + $z1]
+
place $var($cc,graph) -in $var(top) \
-relwidth 1 -relheight $z2 \
- -relx .5 -rely [expr $ii*$z2 + $z1] -anchor s
+ -relx .5 -rely [expr $ii*$z2 + $z1] \
+ -anchor s
}
incr ii
}
}
}
+ PlotRestoreState $varname
+
# needed so layout can be properly realized
update idletasks
}
@@ -811,8 +833,7 @@ proc PlotUpdateCanvas {varname} {
$var($cc,graph) configure \
-topmargin 0 -bottommargin 0 \
-leftmargin 0 -rightmargin 0 \
- -borderwidth 2 \
- -plotrelief flat -plotborderwidth 2
+ -borderwidth 2
$var($cc,graph) xaxis configure -showticks 1 -linewidth 1
$var($cc,graph) yaxis configure -showticks 1 -linewidth 1
@@ -826,8 +847,7 @@ proc PlotUpdateCanvas {varname} {
$var($cc,graph) configure \
-leftmargin $left -rightmargin $right \
- -borderwidth 0 \
- -plotrelief solid -plotborderwidth 1
+ -borderwidth 2
if {$cc == $first} {
$var($cc,graph) configure -topmargin 0 -bottommargin 1
@@ -1081,14 +1101,20 @@ proc PlotBackup {ch dir} {
PlotCurrentGraph $varname
puts $ch "PlotAddGraph $varname $var($cc,type)"
+ # in case of no data
+ PlotSaveConfigFile $varname "$fdir/graph${cc}.plt"
+ puts $ch "PlotLoadConfigFile $varname $fdir/graph${cc}.plt"
+
+ # for each dataset
foreach nn $var($cc,dss) {
set var(graph,ds,current) $nn
PlotCurrentDataSet $varname
PlotSaveDataFile $varname "$fdir/graph${cc}ds${nn}.dat"
+ puts $ch "PlotLoadDataFile $varname $fdir/graph${cc}ds${nn}.dat $var($cc,$nn,dim)"
+
PlotSaveConfigFile $varname "$fdir/graph${cc}ds${nn}.plt"
- puts $ch "PlotLoadDataFile $varname $fdir/graph${cc}ds${nn}.dat $var($cc,$nn,dim)"
puts $ch "PlotLoadConfigFile $varname $fdir/graph${cc}ds${nn}.plt"
}
}
diff --git a/ds9/library/plotprint.tcl b/ds9/library/plotprint.tcl
index 6cc5c27..761598b 100644
--- a/ds9/library/plotprint.tcl
+++ b/ds9/library/plotprint.tcl
@@ -19,6 +19,18 @@ proc PlotPostScript {varname} {
upvar #0 $varname var
global $varname
+ set ll [llength $var(graphs)]
+ if {$ll == 1} {
+ PlotPostScriptSingle $varname
+ } else {
+ PlotPostScriptMulti $varname
+ }
+}
+
+proc PlotPostScriptSingle {varname} {
+ upvar #0 $varname var
+ global $varname
+
global ps
global ds9
@@ -110,3 +122,152 @@ proc PlotPostScript {varname} {
-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)"
}
+
+proc PlotPostScriptMulti {varname} {
+ upvar #0 $varname var
+ global $varname
+
+ global ps
+ global ds9
+
+ #
+ # Options
+ #
+ set options "-decorations false"
+
+ # Color
+ switch -- $ps(color) {
+ rgb -
+ cmyk {append options " -greyscale no"}
+ gray {append options " -greyscale yes"}
+ }
+
+ # can't trust 'tk scaling'
+ switch $ds9(wm) {
+ x11 -
+ win32 {
+ set scaling [tk scaling]
+ if {$scaling == Inf} {
+ set scaling 1.334
+ }
+ }
+ aqua {set scaling 1.4}
+ }
+
+ # Page size
+ switch -- $ps(size) {
+ letter {append options " -paperwidth 8.5i -paperheight 11.i"}
+ legal {append options " -paperwidth 8.5i -paperheight 14.i"}
+ tabloid {append options " -paperwidth 11i -paperheight 17.i"}
+ poster {append options " -paperwidth 36.i -paperheight 48.i"}
+ a4 {append options " -paperwidth 195m -paperheight 282m"}
+ other {
+ if {$ps(width) != {} && $ps(height) != {}} {
+ set pgww "[append ps(width) i]"
+ set pghh "[append ps(height) i]"
+ append options " -paperwidth $pgww -paperheight pghh"
+ }
+ }
+ othermm {
+ if {$ps(width) != {} && $ps(height) != {}} {
+ set pgww "[append ps(width) m]"
+ set pghh "[append ps(height) m]"
+ append options " -paperwidth $pgww -paperheight pghh"
+ }
+ }
+ }
+
+ # Orientation
+ switch -- $ps(orient) {
+ portrait {append options " -landscape false"}
+ landscape {append options " -landscape true"}
+ }
+
+ # Prolog
+
+ set width [expr [winfo width $var(top)]*$ps(scale)/100./$scaling]
+ set height [expr [winfo height $var(top)]*$ps(scale)/100./$scaling]
+ set prolog [eval $var([lindex $var(graphs) 0],graph) postscript output \
+ "$options -width $width -height $height"]
+
+ #
+ # For each graph
+ #
+ foreach cc $var(graphs) {
+
+ # set postscript fonts
+ $var($cc,graph) configure -font "$var(graph,title,family) $var(graph,title,size) $var(graph,title,weight) $var(graph,title,slant)"
+
+ $var($cc,graph) xaxis configure -tickfont "$var(axis,font,family) $var(axis,font,size) $var(axis,font,weight) $var(axis,font,slant)" -titlefont "$var(axis,title,family) $var(axis,title,size) $var(axis,title,weight) $var(axis,title,slant)"
+
+ $var($cc,graph) yaxis configure -tickfont "$var(axis,font,family) $var(axis,font,size) $var(axis,font,weight) $var(axis,font,slant)" -titlefont "$var(axis,title,family) $var(axis,title,size) $var(axis,title,weight) $var(axis,title,slant)"
+
+ $var($cc,graph) legend configure -font "$var(legend,font,family) $var(legend,font,size) $var(legend,font,weight) $var(legend,font,slant)" -titlefont "$var(legend,title,family) $var(legend,title,size) $var(legend,title,weight) $var(legend,title,slant)"
+
+ # Size
+ set ww [expr [winfo width $var($cc,graph)]*$ps(scale)/100./$scaling]
+ set hh [expr [winfo height $var($cc,graph)]*$ps(scale)/100./$scaling]
+
+ set var($cc,ps) [eval $var($cc,graph) postscript output \
+ "$options -width $ww -height $hh"]
+
+ # reset fonts
+ $var($cc,graph) configure \
+ -font "{$ds9($var(graph,title,family))} $var(graph,title,size) $var(graph,title,weight) $var(graph,title,slant)"
+
+ $var($cc,graph) xaxis configure \
+ -tickfont "{$ds9($var(axis,font,family))} $var(axis,font,size) $var(axis,font,weight) $var(axis,font,slant)" \
+ -titlefont "{$ds9($var(axis,title,family))} $var(axis,title,size) $var(axis,title,weight) $var(axis,title,slant)"
+
+ $var($cc,graph) yaxis configure \
+ -tickfont "{$ds9($var(axis,font,family))} $var(axis,font,size) $var(axis,font,weight) $var(axis,font,slant)" \
+ -titlefont "{$ds9($var(axis,title,family))} $var(axis,title,size) $var(axis,title,weight) $var(axis,title,slant)"
+
+ $var($cc,graph) legend configure \
+ -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)"
+ }
+
+ # channel
+ if {$ps(dest) == "file" && $ps(filename) != {}} {
+ set ch [open $ps(filename) w]
+ } else {
+ set ch [open "| $ps(cmd)" w]
+ }
+
+ # prolog
+ set bb [string first {%%EndSetup} $prolog]
+ set bb [expr $bb+9]
+ puts $ch [string range $prolog 0 $bb]
+
+ foreach cc $var(graphs) {
+ set xx [expr $width*$var($cc,tx)]
+ set yy [expr $height*$var($cc,ty)]
+ puts $ch "gsave"
+ puts $ch "$xx $yy translate"
+
+ # begin
+ set bb [string first {%%EndSetup} $var($cc,ps)]
+ set bb [expr $bb+9]
+ incr bb
+
+ # end
+ set ee [string last {showpage} $var($cc,ps)]
+ incr ee -1
+
+ # body
+ puts $ch [string range $var($cc,ps) $bb $ee]
+
+ puts $ch "grestore"
+ }
+
+ # trailer
+ set ee [string last {showpage} $prolog]
+ puts $ch [string range $prolog $ee end]
+
+ close $ch
+
+ foreach cc $var(graphs) {
+ unset var($cc,ps)
+ }
+}
diff --git a/ds9/library/plotstate.tcl b/ds9/library/plotstate.tcl
index f708ac5..c79fd31 100644
--- a/ds9/library/plotstate.tcl
+++ b/ds9/library/plotstate.tcl
@@ -102,6 +102,9 @@ proc PlotInitGraph {varname} {
set var(graph) $var(top).gr$cc
+ set var(graph,tx) 0
+ set var(graph,ty) 0
+
set var(graph,type) {}
set var(graph,proc,updateelement) {}
set var(graph,proc,hightlite) {}
@@ -177,6 +180,9 @@ proc PlotSaveState {varname} {
set var($cc,graph) $var(graph)
+ set var($cc,tx) $var(graph,tx)
+ set var($cc,ty) $var(graph,ty)
+
set var($cc,type) $var(graph,type)
set var($cc,proc,updateelement) $var(graph,proc,updateelement)
set var($cc,proc,highlite) $var(graph,proc,highlite)
@@ -252,6 +258,9 @@ proc PlotRestoreState {varname} {
set var(graph) $var($cc,graph)
+ set var(graph,tx) $var($cc,tx)
+ set var(graph,ty) $var($cc,ty)
+
set var(graph,type) $var($cc,type)
set var(graph,proc,updateelement) $var($cc,proc,updateelement)
set var(graph,proc,highlite) $var($cc,proc,highlite)