diff options
Diffstat (limited to 'ds9')
-rw-r--r-- | ds9/library/catplot.tcl | 2 | ||||
-rw-r--r-- | ds9/library/ime.tcl | 611 | ||||
-rw-r--r-- | ds9/library/markeranalysishist.tcl | 10 | ||||
-rw-r--r-- | ds9/library/markeranalysispanda.tcl | 2 | ||||
-rw-r--r-- | ds9/library/markeranalysisplot2d.tcl | 10 | ||||
-rw-r--r-- | ds9/library/markeranalysisplot3d.tcl | 10 | ||||
-rw-r--r-- | ds9/library/markeranalysisradial.tcl | 12 | ||||
-rw-r--r-- | ds9/library/plot.tcl | 1179 | ||||
-rw-r--r-- | ds9/library/plotbar.tcl | 186 | ||||
-rw-r--r-- | ds9/library/plotconfig.tcl | 280 | ||||
-rw-r--r-- | ds9/library/plotdata.tcl | 440 | ||||
-rw-r--r-- | ds9/library/plotdialog.tcl | 328 | ||||
-rw-r--r-- | ds9/library/plotline.tcl | 280 | ||||
-rw-r--r-- | ds9/library/plotprint.tcl | 170 | ||||
-rw-r--r-- | ds9/library/plotprocess.tcl | 106 | ||||
-rw-r--r-- | ds9/library/plotscatter.tcl | 207 | ||||
-rw-r--r-- | ds9/library/plotstate.tcl | 243 | ||||
-rw-r--r-- | ds9/library/prefs.tcl | 58 | ||||
-rw-r--r-- | ds9/parsers/plotparser.tac | 116 | ||||
-rw-r--r-- | ds9/parsers/plotparser.tcl | 116 | ||||
-rw-r--r-- | ds9/parsers/plotsendparser.tac | 62 | ||||
-rw-r--r-- | ds9/parsers/plotsendparser.tcl | 62 |
22 files changed, 2143 insertions, 2347 deletions
diff --git a/ds9/library/catplot.tcl b/ds9/library/catplot.tcl index 9072745..567da52 100644 --- a/ds9/library/catplot.tcl +++ b/ds9/library/catplot.tcl @@ -86,7 +86,7 @@ proc CATPlotGenerate {varname} { set var(plot,var) $vvarname } - PlotClearData $vvarname + PlotDeleteData $vvarname PlotDataSet $vvarname $dim $rr PlotTitle $vvarname $var(title) $xtitle $ytitle $vvar(proc,updategraph) $vvarname diff --git a/ds9/library/ime.tcl b/ds9/library/ime.tcl deleted file mode 100644 index 9cf3493..0000000 --- a/ds9/library/ime.tcl +++ /dev/null @@ -1,611 +0,0 @@ -# Copyright (C) 1999-2018 -# Smithsonian Astrophysical Observatory, Cambridge, MA, USA -# For conditions of distribution and use, see copyright notice in "copyright" - -package provide DS9 1.0 - -proc IMEDef {} { - global iime - global ime - global pime - - set ime(task) stats - set ime(shape) circle - - array set pime [array get ime] -} - -proc IMEChangeTask {} { - global current - - if {$current(frame) == {}} { - return - } - - if {$current(mode) != {analysis}} { - return - } - - UpdateTaskMenu - IMEChangeShape -} - -proc IMEChangeShape {} { - global ime - global ds9 - global current - - switch $ime(task) { - stats - - hist { - switch $ime(shape) { - circle - - ellipse - - box - - polygon {} - default {set ime(shape) circle} - } - } - radial { - switch $ime(shape) { - annulus - - ellipseannulus - - boxannulus {} - default {set ime(shape) annulus} - } - } - plot2d {} - plot3d { - switch $ime(shape) { - circle - - ellipse - - box - - polygon - - point {} - default {set ime(shape) point} - } - } - } - - foreach ff $ds9(frames) { - $ff marker analysis unselect all - set coord [$ff get crosshair canvas] - set XX [lindex $coord 0] - set YY [lindex $coord 1] - - $ff analysis shape $ime(shape) $XX $YY - - if {$current(frame) == $ff} { - IMEDoTask $current(frame) - } - } -} - -proc IMEDoTask {which} { - global ime - - if {![$which has fits]} { - return - } - - switch $ime(task) { - stats {IMEStatsTask $which} - hist {IMEHistTask $which} - radial {IMERadialTask $which} - plot2d {IMEPlot2DTask $which} - plot3d {IMEPlot3DTask $which} - } -} - -proc IMEKey {which K xx yy} { - global ime - - # always available - switch $K { - question { - IMEHelp - return - } - } - - if {![$which has fits]} { - return - } - - switch $K { - a { - # FWHM (Aperture Sum) - } - b { - # Box Coords? - } - c { - # Column Cut - } - d { - # remap (Load Display) - set ime(task) plot3d - IMEKeyTask $which $xx $yy - } - e { - # remap (Contour) - } - f { - # remap (Redraw) - } - g { - # remap (Graphics Cursor) - } - h { - set ime(task) hist - IMEKeyTask $which $xx $yy - } - i { - # remap (Image Cursor) - } - j { - # Line Guassian Fit - } - k { - # Col Gaussian Fit - } - l { - # Line Cut - } - m { - set ime(task) stats - IMEKeyTask $which $xx $yy - } - n { - # remap (Next Frame) - } - o { - # remap (Overplot) - } - p { - # remap (Prev Frame) - } - q { - # remap (Quit) - } - r { - set ime(task) radial - IMEKeyTask $which $xx $yy - } - s { - # Surface Plot - } - t { - # remap (Output Image) - } - u { - # Vector Plot - } - v { - set ime(task) plot2d - IMEKeyTask $which $xx $yy - } - w { - # remap (Toggle Logfile) - } - x { - # Print coords/values - } - y { - # remap (Set Origin) - } - z { - # Print value grid - } - , { - # Quick Profile Photometry - } - . { - # Quick Radial Profile Plot and Fit - } - } -} - -proc IMEKeyTask {which xx yy} { - global ime - - $which crosshair canvas $xx $yy - - $which analysis shape $ime(shape) $xx $yy - IMEDoTask $which - - UpdateColormapLevelMosaic $which $xx $yy canvas - UpdateInfoBox $which $xx $yy canvas - UpdatePixelTableDialog $which $xx $yy canvas - UpdateGraphLayout $which - UpdateGraphAxis $which - UpdateGraphData $which $xx $yy canvas -} - -proc IMEButton {which xx yy} { - global ime - global imarker - - global debug - if {$debug(tcl,ime)} { - puts stderr "IMEButton $which $xx $yy" - } - - # see if we are on a handle - set hh [$which get marker analysis handle $xx $yy] - set id [lindex $hh 0] - set imarker(handle) [lindex $hh 1] - - if {$imarker(handle)} { - $which marker analysis $id edit begin $imarker(handle) - set imarker(motion) beginEdit - return - } - - # else, see if we are on a segment of a polygon - set hh [$which get marker analysis polygon segment $xx $yy] - set id [lindex $hh 0] - set segment [lindex $hh 1] - if {$segment} { - $which marker analysis $id create polygon vertex $segment $xx $yy - $which marker analysis $id edit begin $imarker(handle) - set imarker(handle) [expr 4+$segment+1] - set imarker(motion) beginEdit - return - } - - # see if any markers are selected - if {[$which get marker analysis select number]>0} { - # else, see if we are on a marker - if {[$which get marker analysis id $xx $yy]} { - $which marker analysis $id move begin - set imarker(motion) beginMove - return - } else { - $which marker analysis unselect all - set imarker(motion) none - return - } - } - - $which marker analysis $id move begin - set imarker(motion) beginMove - - $which crosshair canvas $xx $yy - $which analysis shape $ime(shape) $xx $yy - IMEDoTask $which -} - -proc IMEShift {which xx yy} { - global ime - global imarker - - global debug - if {$debug(tcl,ime)} { - puts stderr "IMEShift $which $xx $yy" - } - - # see if we are on a handle - set hh [$which get marker analysis handle $xx $yy] - set id [lindex $hh 0] - set imarker(handle) [lindex $hh 1] - - if {$imarker(handle)} { - $which marker analysis $id rotate begin - set imarker(motion) beginRotate - } -} - -proc IMEDouble {which xx yy} { - global ime - global imarker - - global debug - if {$debug(tcl,ime)} { - puts stderr "IMEDouble $which $xx $yy" - } - - if {[$which get marker analysis id $xx $yy]} { - $which marker analysis select only $xx $yy - } -} - -proc IMEMotion {which xx yy} { - global ime - global imarker - - global debug - if {$debug(tcl,ime)} { - puts stderr "IMEMotion $which $xx $yy" - } - - switch -- $imarker(motion) { - none {} - beginMove - - move { - $which marker analysis move motion $x $y - set imarker(motion) move - $which crosshair canvas $xx $yy - $which analysis shape $ime(shape) $xx $yy - IMEDoTask $which - } - beginEdit - - edit { - set imarker(motion) edit - $which marker analysis edit motion $xx $yy $imarker(handle) - IMEDoTask $which - } - beginRotate - - rotate { - set imarker(motion) rotate - $which marker analysis rotate motion $xx $yy $imarker(handle) - IMEDoTask $which - } - region - - shiftregion {} - } -} - -proc IMERelease {which xx yy} { - global ime - global imarker - - global debug - if {$debug(tcl,ime)} { - puts stderr "IMERelease $which $xx $yy" - } - - switch -- $imarker(motion) { - none {} - beginMove - - beginRotate {} - beginEdit {} - move { - $which marker analysis move end - IMEDoTask $which - } - edit { - $which marker analysis edit end - IMEDoTask $which - } - rotate { - $which marker analysis rotate end - IMEDoTask $which - } - region - - shiftregion {} - } - - set imarker(motion) none - set imarker(handle) -1 -} - -proc IMEArrowKey {which xx yy} { - global ime - global ds9 - - global debug - if {$debug(tcl,ime)} { - puts stderr "IMEArrow $which $xx $yy" - } - - $which crosshair warp $xx $yy - - set coord [$which get crosshair canvas] - set XX [lindex $coord 0] - set YY [lindex $coord 1] - - $which analysis shape $ime(shape) $XX $YY - IMEDoTask $which - - UpdateColormapLevelMosaic $which $XX $YY canvas - UpdateInfoBox $which $XX $YY canvas - UpdatePixelTableDialog $which $XX $YY canvas - UpdateGraphData $which $XX $YY canvas -} - -proc IMEHelp {} { - global ime - - set rr "\tAnalysis Help\n\n?\tPrint Help\nd\tPlot 3D\nm\tStatistics\nv\tPlot 2D\n" - - SimpleTextDialog imehlp "Analysis Help" 80 20 insert top $rr -} - -proc IMEStatsTask {which} { - global ime - - set rr [$which get marker analysis hide analysis stats physical fk5] - - SimpleTextDialog "imestat" "Statistics" 80 20 insert top $rr -} - -proc IMEHistTask {which} { - global iime - global ime - - set id 0 - - set varname imehist - global $varname - upvar #0 $varname var - - set vvarname analysishist - upvar #0 $vvarname vvar - global $vvarname - - set xdata ${vvarname}x - set ydata ${vvarname}y - global $xdata $ydata - - set ping [PlotPing $vvarname] - - if {!$ping} { - PlotLineDialog $vvarname Histogram {} Values Counts - - set vvar(manage) 0 - set vvar(dim) xy - set vvar(xdata) $xdata - set vvar(ydata) $ydata - blt::vector create $xdata $ydata - } - - $which get marker analysis hide analysis histogram $xdata $ydata 512 - - if {!$ping} { - PlotExternal $vvarname - set vvar(smooth) step - set vvar(fill) 1 - $vvar(proc,updateelement) $vvarname - $vvar(proc,updategraph) $vvarname - } - - PlotStats $vvarname - PlotList $vvarname -} - -proc IMERadialTask {which} { - global iime - global ime - - set varname imerad - global $varname - upvar #0 $varname var - - set vvarname analysisrad - upvar #0 $vvarname vvar - global $vvarname - - set vvar(system) physical - - set xdata ${vvarname}x - set ydata ${vvarname}y - set yedata ${vvarname}ye - global $xdata $ydata $yedata - - set ping [PlotPing $vvarname] - - if {!$ping} { - PlotLineDialog $vvarname "Radial Profile" {} physical {} - MarkerAnalysisRadialAxisTitle $vvarname - - set vvar(manage) 0 - set vvar(dim) xyey - set vvar(xdata) $xdata - set vvar(ydata) $ydata - set vvar(yedata) $yedata - blt::vector create $xdata $ydata $yedata - } - - $which get marker analysis hide analysis radial $xdata $ydata $yedata physical - - if {!$ping} { - PlotExternal $vvarname - $vvar(proc,updateelement) $vvarname - $vvar(proc,updategraph) $vvarname - } - - PlotStats $vvarname - PlotList $vvarname -} - -proc IMEPlot2DTask {which} { - global iime - global ime - - set varname imeplot2d - global $varname - upvar #0 $varname var - - set vvarname analysisplot2d - upvar #0 $vvarname vvar - global $vvarname - - set vvar(system) physical - set vvar(sky) fk5 - set vvar(method) average - - set xdata ${vvarname}x - set ydata ${vvarname}y - set xcdata ${vvarname}xc - set ycdata ${vvarname}yc - global $xdata $ydata $xcdata $ycdata - - set ping [PlotPing $vvarname] - - if {!$ping} { - PlotLineDialog $vvarname Plot2D {} physical Counts - MarkerAnalysisPlot2dXAxisTitle $vvarname - MarkerAnalysisPlot2dYAxisTitle $vvarname - - # setup our own formatting - set vvar(graph,format) 0 - set vvar(xcdata) $xcdata - set vvar(ycdata) $ycdata - $vvar(graph) xaxis configure \ - -command "MarkerAnalysisPlot2dXAxis $vvarname" - - set vvar(manage) 0 - set vvar(dim) xy - set vvar(xdata) $xdata - set vvar(ydata) $ydata - blt::vector create $xdata $ydata $xcdata $ycdata - } - - $which get marker analysis hide analysis plot2d $xdata $ydata $xcdata $ycdata physical fk5 average - - if {!$ping} { - PlotExternal $vvarname - $vvar(proc,updateelement) $vvarname - $vvar(proc,updategraph) $vvarname - } - - PlotStats $vvarname - PlotList $vvarname -} - -proc IMEPlot3DTask {which} { - global iime - global ime - - set varname imeplot3d - global $varname - upvar #0 $varname var - - set vvarname analysisplot3d - upvar #0 $vvarname vvar - global $vvarname - - set vvar(system) image - set vvar(method) average - - set xdata ${vvarname}x - set ydata ${vvarname}y - global $xdata $ydata - - set ping [PlotPing $vvarname] - - if {!$ping} { - PlotLineDialog $vvarname Plot3D {} image Counts - MarkerAnalysisPlot3dXAxisTitle $vvarname - MarkerAnalysisPlot3dYAxisTitle $vvarname - - set vvar(manage) 0 - set vvar(dim) xy - set vvar(xdata) $xdata - set vvar(ydata) $ydata - blt::vector create $xdata $ydata - } - - $which get marker analysis hide analysis plot3d $xdata $ydata physical fk5 average - - if {!$ping} { - PlotExternal $vvarname - $vvar(proc,updateelement) $vvarname - $vvar(proc,updategraph) $vvarname - } - - PlotStats $vvarname - PlotList $vvarname -} - diff --git a/ds9/library/markeranalysishist.tcl b/ds9/library/markeranalysishist.tcl index 83d57a9..cd1a926 100644 --- a/ds9/library/markeranalysishist.tcl +++ b/ds9/library/markeranalysishist.tcl @@ -80,10 +80,12 @@ proc MarkerAnalysisHistogramCB {frame id} { } PlotLineDialog $vvarname $tt Histogram $bunit Counts - set vvar(manage) 0 - set vvar(dim) xy - set vvar(xdata) $xdata - set vvar(ydata) $ydata + set cc $vvar(graph,current) + + set vvar($cc,manage) 0 + set vvar($cc,dim) xy + set vvar($cc,xdata) $xdata + set vvar($cc,ydata) $ydata blt::vector create $xdata $ydata } diff --git a/ds9/library/markeranalysispanda.tcl b/ds9/library/markeranalysispanda.tcl index ec8f36e..d60b158 100644 --- a/ds9/library/markeranalysispanda.tcl +++ b/ds9/library/markeranalysispanda.tcl @@ -103,7 +103,7 @@ proc MarkerAnalysisPandaCB {frame id} { MarkerAnalysisPandaAxisTitle $vvarname } - PlotClearData $vvarname + PlotDeleteData $vvarname PlotDataSet $vvarname 3 [$frame get marker $id analysis panda $sys] $vvar(proc,updategraph) $vvarname PlotStats $vvarname diff --git a/ds9/library/markeranalysisplot2d.tcl b/ds9/library/markeranalysisplot2d.tcl index a8fdf1d..0fffe24 100644 --- a/ds9/library/markeranalysisplot2d.tcl +++ b/ds9/library/markeranalysisplot2d.tcl @@ -169,10 +169,12 @@ proc MarkerAnalysisPlot2dCB {frame id} { $vvar(graph) xaxis configure \ -command "MarkerAnalysisPlot2dXAxis $vvarname" - set vvar(manage) 0 - set vvar(dim) xy - set vvar(xdata) $xdata - set vvar(ydata) $ydata + set cc $vvar(graph,current) + + set vvar($cc,manage) 0 + set vvar($cc,dim) xy + set vvar($cc,xdata) $xdata + set vvar($cc,ydata) $ydata blt::vector create $xdata $ydata $xcdata $ycdata } diff --git a/ds9/library/markeranalysisplot3d.tcl b/ds9/library/markeranalysisplot3d.tcl index 2b93cbc..3546fba 100644 --- a/ds9/library/markeranalysisplot3d.tcl +++ b/ds9/library/markeranalysisplot3d.tcl @@ -174,10 +174,12 @@ proc MarkerAnalysisPlot3dCB {frame id} { set vvar(mode) pointer PlotChangeMode $vvarname - set vvar(manage) 0 - set vvar(dim) xy - set vvar(xdata) $xdata - set vvar(ydata) $ydata + set cc $vvar(graph,current) + + set vvar($cc,manage) 0 + set vvar($cc,dim) xy + set vvar($cc,xdata) $xdata + set vvar($cc,ydata) $ydata blt::vector create $xdata $ydata } diff --git a/ds9/library/markeranalysisradial.tcl b/ds9/library/markeranalysisradial.tcl index 45a552d..aea882a 100644 --- a/ds9/library/markeranalysisradial.tcl +++ b/ds9/library/markeranalysisradial.tcl @@ -107,11 +107,13 @@ proc MarkerAnalysisRadialCB {frame id} { PlotLineDialog $vvarname $tt "Radial Profile" $sys {} MarkerAnalysisRadialAxisTitle $vvarname - set vvar(manage) 0 - set vvar(dim) xyey - set vvar(xdata) $xdata - set vvar(ydata) $ydata - set vvar(yedata) $yedata + set cc $vvar(graph,current) + + set vvar($cc,manage) 0 + set vvar($cc,dim) xyey + set vvar($cc,xdata) $xdata + set vvar($cc,ydata) $ydata + set vvar($cc,yedata) $yedata blt::vector create $xdata $ydata $yedata } diff --git a/ds9/library/plot.tcl b/ds9/library/plot.tcl index 98cf932..771e1be 100644 --- a/ds9/library/plot.tcl +++ b/ds9/library/plot.tcl @@ -16,110 +16,146 @@ proc PlotDef {} { set iap(tiff,compress) none set iap(error) [msgcat::mc {An error has occurred while creating the image. Please be sure that the plot window is in the upper left corner of the default screen and the entire window is visible.}] - set pap(graph,bg) white - set pap(graph,title) {} - set pap(graph,title,family) helvetica - set pap(graph,title,size) 12 - set pap(graph,title,weight) normal - set pap(graph,title,slant) roman - - set pap(legend) 0 - set pap(legend,title) Legend - set pap(legend,position) right - set pap(legend,title,family) helvetica - set pap(legend,title,size) 10 - set pap(legend,title,weight) normal - set pap(legend,title,slant) roman - set pap(legend,font,family) helvetica - set pap(legend,font,size) 9 - set pap(legend,font,weight) normal - set pap(legend,font,slant) roman - - set pap(axis,x,title) {} - set pap(axis,x,grid) 1 - set pap(axis,x,log) 0 - set pap(axis,x,flip) 0 - set pap(axis,x,auto) 1 - set pap(axis,x,min) {} - set pap(axis,x,max) {} - set pap(axis,x,format) {} - - set pap(axis,y,title) {} - set pap(axis,y,grid) 1 - set pap(axis,y,log) 0 - set pap(axis,y,flip) 0 - set pap(axis,y,auto) 1 - set pap(axis,y,min) {} - set pap(axis,y,max) {} - set pap(axis,y,format) {} - - set pap(axis,title,family) helvetica - set pap(axis,title,size) 9 - set pap(axis,title,weight) normal - set pap(axis,title,slant) roman - - set pap(axis,font,family) helvetica - set pap(axis,font,size) 9 - set pap(axis,font,weight) normal - set pap(axis,font,slant) roman - - set pap(show) 1 - set pap(shape,symbol) none - set pap(shape,fill) 1 - set pap(shape,color) red - set pap(smooth) linear - set pap(color) black - set pap(fill) 0 - set pap(fill,color) black - set pap(width) 1 - set pap(dash) 0 - - set pap(error) 1 - set pap(error,cap) 0 - set pap(error,color) red - set pap(error,width) 1 - - set pap(bar,relief) raised - set pap(bar,mode) normal + PlotDefState } -proc PlotAxisFormat {varname axis w nn} { +# Canvas +proc PlotLayoutCanvas {varname} { upvar #0 $varname var global $varname - return [format $var(axis,$axis,format) $nn] + foreach cc $var(graphs) { + pack forget $var($cc) + } + + foreach cc $var(graphs) { + pack $var($cc) -side top -expand yes -fill both + } } -proc PlotClearData {varname} { +# Graph +proc PlotAddGraph {varname} { upvar #0 $varname var global $varname global ds9 + global pap + + if {$var(graphs) != {}} { + PlotSaveState $varname + } + + incr ${varname}(seq) + set cc "graph$var(seq)" + lappend var(graphs) $cc + set var(graph,current) $cc + + set var($cc,data,total) 0 + set var($cc,data,current) 0 + + set var($cc,xdata) {} + set var($cc,ydata) {} + set var($cc,xedata) {} + set var($cc,yedata) {} + + PlotInitGraph $varname + + $var(proc,addgraph) $varname + + # set up zoom stack, assuming mode is zoom + global ds9 + switch $ds9(wm) { + x11 - + win32 {Blt_ZoomStack $var($cc) -mode release} + aqua {Blt_ZoomStack $var($cc) -mode release -button "ButtonPress-2"} + } + + PlotLayoutCanvas $varname +} - if {$var(data,total) == 0} { +proc PlotDeleteGraph {varname} { + upvar #0 $varname var + global $varname + + set cc $var(graph,current) + if {$cc != {}} { + destroy $var($cc) + list replace ${varname}(graphs) $cc {} + } +} + +# Data +proc PlotAddData {varname} { + upvar #0 $varname var + global $varname + + set cc $var(graph,current) + + # warning: uses current vars + if {$var($cc,data,total) == 0} { + return + } + + # delete current elements + set nn $var($cc,data,current) + foreach el [$var($cc) element names] { + set f [split $el -] + if {[lindex $f 1] == $nn} { + $var($cc) element delete $el + } + } + + global $var($cc,xdata) $var($cc,ydata) + $var($cc) element create "d-${nn}" \ + -xdata $var($cc,xdata) -ydata $var($cc,ydata) + if {$var($cc,xedata) != {}} { + if {[$var($cc,xedata) length] != 0} { + $var($cc) element configure "d-${nn}" \ + -xerror $var($cc,xedata) + } + } + if {$var($cc,yedata) != {}} { + if {[$var($cc,yedata) length] != 0} { + $var($cc) element configure "d-${nn}" \ + -yerror $var($cc,yedata) + } + } +} + +proc PlotDeleteData {varname} { + upvar #0 $varname var + global $varname + + global ds9 + + set cc $var(graph,current) + + if {$var($cc,data,total) == 0} { return } # first set can be external - set clear $var(1,manage) + set clear $var($cc,1,manage) - for {set nn 1} {$nn<=$var(data,total)} {incr nn} { - if {$var($nn,manage)} { + for {set nn 1} {$nn<=$var($cc,data,total)} {incr nn} { + if {$var($cc,$nn,manage)} { # delete elements - foreach el [$var(graph) element names] { + foreach el [$var($cc) element names] { set f [split $el -] if {[lindex $f 1] == $nn} { - $var(graph) element delete $el + $var($cc) element delete $el } } # destroy vectors - blt::vector destroy $var($nn,xdata) $var($nn,ydata) - switch $var($nn,dim) { + blt::vector destroy \ + $var($cc,$nn,xdata) $var($cc,$nn,ydata) + switch $var($cc,$nn,dim) { xy {} - xyex {blt::vector destroy $var($nn,xedata)} - xyey {blt::vector destroy $var($nn,yedata)} - xyexey {blt::vector destroy $var($nn,xedata) $var($nn,yedata)} + xyex {blt::vector destroy $var($cc,$nn,xedata)} + xyey {blt::vector destroy $var($cc,$nn,yedata)} + xyexey {blt::vector destroy \ + $var($cc,$nn,xedata) $var($cc,$nn,yedata)} } foreach x [array names $varname] { @@ -132,372 +168,99 @@ proc PlotClearData {varname} { } if {$clear} { - set var(data,total) 0 - set var(data,current) 0 + set var($cc,data,total) 0 + set var($cc,data,current) 0 - set var(name) {} - set var(xdata) {} - set var(ydata) {} - set var(xedata) {} - set var(yedata) {} + set var(graph,ds,name) {} + set var($cc,xdata) {} + set var($cc,ydata) {} + set var($cc,xedata) {} + set var($cc,yedata) {} # reset other variables - set var(axis,x,auto) 1 - set var(axis,x,min) {} - set var(axis,x,max) {} - set var(axis,x,format) {} - - set var(axis,y,auto) 1 - set var(axis,y,min) {} - set var(axis,y,max) {} - set var(axis,y,format) {} + set var($cc,axis,x,auto) 1 + set var($cc,axis,x,min) {} + set var($cc,axis,x,max) {} + set var($cc,axis,x,format) {} + + set var($cc,axis,y,auto) 1 + set var($cc,axis,y,min) {} + set var($cc,axis,y,max) {} + set var($cc,axis,y,format) {} - $var(mb).select delete $ds9(menu,start) end + $var(mb).graph.select delete $ds9(menu,start) end $var(proc,updategraph) $varname PlotStats $varname PlotList $varname } else { - set var(data,total) 1 - set var(data,current) 1 + set var($cc,data,total) 1 + set var($cc,data,current) 1 - $var(mb).select delete [expr $ds9(menu,start)+1] end + $var(mb).graph.select delete [expr $ds9(menu,start)+1] end PlotCurrentData $varname $var(proc,updategraph) $varname } } -proc PlotCurrentData {varname} { +proc PlotCurrentGraph {varname} { upvar #0 $varname var global $varname - if {$var(data,total) > 0} { - set nn $var(data,current) - - set var(manage) $var($nn,manage) - set var(dim) $var($nn,dim) + set cc $var(graph,current) - set var(xdata) $var($nn,xdata) - set var(ydata) $var($nn,ydata) - set var(xedata) $var($nn,xedata) - set var(yedata) $var($nn,yedata) - - PlotSetVar $varname $nn + if {$cc != {}} { + PlotCurrentData $varname } - - PlotStats $varname - PlotList $varname } -proc PlotDataSet {varname dim data} { +proc PlotCurrentData {varname} { upvar #0 $varname var global $varname - switch -- $dim { - 4 { - # first data set - PlotDataSetOne $varname "4.1" $data + set cc $var(graph,current) - # set color - set cc $var(color) - set var(color) [PlotNextColor $var(color)] + if {$var($cc,data,total) > 0} { + set nn $var($cc,data,current) - # second data set - PlotDataSetOne $varname "4.2" $data - set var(color) $cc - } - 5 { - # first data set - PlotDataSetOne $varname "5.1" $data + set var($cc,manage) $var($cc,$nn,manage) + set var($cc,dim) $var($cc,$nn,dim) - # set color - set cc $var(color) - set var(color) [PlotNextColor $var(color)] + 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) - # second data set - PlotDataSetOne $varname "5.2" $data - set var(color) $cc - } - default {PlotDataSetOne $varname $dim $data} + PlotRestoreState $varname $nn } + + PlotStats $varname + PlotList $varname } -proc PlotDataSetOne {varname dim data} { +proc PlotAxisFormat {varname axis w nn} { upvar #0 $varname var global $varname - # look for no data - if {[string length $data] == 0} { - return - } - - # total length - set ll [llength $data] - - # incr count - incr ${varname}(data,total) - set nn $var(data,total) - set var(data,current) $nn - - # 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} - - # basics xy - set var(manage) 1 - set var(name) "Dataset $nn" - set var(xdata) $xdata - set var(ydata) $ydata - global $var(xdata) $var(ydata) - blt::vector create $var(xdata) $var(ydata) - - # substitute all separtors - regsub -all {[\n\r\t, ]+} $data { } data - # remove all non-numeric data - regsub -all {[^0-9.e\- ]+} $data {} data - - set x {} - set y {} - set xe {} - set ye {} - switch -- $dim { - 2 - - xy { - set var(dim) xy - set var(xedata) {} - set var(yedata) {} - - for {set ii 0} {$ii<$ll} {incr ii 2} { - lappend x [lindex $data $ii] - lappend y [lindex $data [expr $ii+1]] - } - $var(xdata) set $x - $var(ydata) set $y - } - - xyex { - set var(dim) xyex - set var(xedata) $xedata - set var(yedata) {} - - global $var(xedata) - blt::vector create $var(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(xdata) set $x - $var(ydata) set $y - $var(xedata) set $xe - } - - 3 - - xyey { - set var(dim) xyey - set var(xedata) {} - set var(yedata) $yedata - - global $var(yedata) - blt::vector create $var(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(xdata) set $x - $var(ydata) set $y - $var(yedata) set $ye - } - - xyexey { - set var(dim) xyexey - set var(xedata) $xedata - set var(yedata) $yedata - - global $var(xedata) $var(yedata) - blt::vector create $var(xedata) $var(yedata) - - for {set ii 0} {$ii<$ll} {incr ii 4} { - lappend x [lindex $data $ii] - lappend y [lindex $data [expr $ii+1]] - lappend xe [lindex $data [expr $ii+2]] - lappend ye [lindex $data [expr $ii+3]] - } - $var(xdata) set $x - $var(ydata) set $y - $var(xedata) set $xe - $var(yedata) set $ye - } - - 4.1 { - set var(dim) xyey - set var(xedata) {} - set var(yedata) $yedata - - global $var(yedata) - blt::vector create $var(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(xdata) set $x - $var(ydata) set $y - $var(yedata) set $ye - } - - 4.2 { - set var(dim) xy - set var(xedata) {} - set var(yedata) {} - - for {set ii 0} {$ii<$ll} {incr ii 4} { - lappend x [lindex $data $ii] - lappend y [lindex $data [expr $ii+3]] - } - $var(xdata) set $x - $var(ydata) set $y - } - - 5.1 { - set var(dim) xyey - set var(xedata) {} - set var(yedata) $yedata - - global $var(yedata) - blt::vector create $var(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(xdata) set $x - $var(ydata) set $y - $var(yedata) set $ye - } - - 5.2 { - set var(dim) xyey - set var(xedata) {} - set var(yedata) $yedata - - global $var(yedata) - blt::vector create $var(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(xdata) set $x - $var(ydata) set $y - $var(yedata) set $ye - } - } - - set var($nn,manage) 1 - set var($nn,dim) $var(dim) - - set var($nn,xdata) $var(xdata) - set var($nn,ydata) $var(ydata) - set var($nn,xedata) $var(xedata) - set var($nn,yedata) $var(yedata) - - PlotGetVar $varname $nn - - # update data set menu - $var(mb).select add radiobutton -label "$var(name)" \ - -variable ${varname}(data,current) -value $nn \ - -command [list PlotCurrentData $varname] - - PlotCreateElement $varname - $var(proc,updateelement) $varname + return [format $var(graph,axis,$axis,format) $nn] } -proc PlotDupData {varname mm} { +proc PlotChangeMode {varname} { upvar #0 $varname var global $varname - if {$var(data,total) == 0} { - return - } - - # incr count - incr ${varname}(data,total) - set nn $var(data,total) - set pp [expr $nn-1] - - # new vector names - set var($nn,name) "Dataset $nn" - set var($nn,xdata) ap${varname}xx${nn} - set var($nn,ydata) ap${varname}yy${nn} - set var($nn,xedata) ap${varname}xe${nn} - set var($nn,yedata) ap${varname}ye${nn} - global $var($mm,xdata) $var($mm,ydata) $var($mm,xedata) $var($mm,yedata) - global $var($nn,xdata) $var($nn,ydata) $var($nn,xedata) $var($nn,yedata) - - $var($mm,xdata) dup $var($nn,xdata) - $var($mm,ydata) dup $var($nn,ydata) - if {$var($mm,xedata) != {}} { - $var($mm,xedata) dup $var($nn,xedata) - } else { - set var($nn,xedata) {} - } - if {$var($mm,yedata) != {}} { - $var($mm,yedata) dup $var($nn,yedata) - } else { - set var($nn,yedata) {} + foreach cc $var(graphs) { + switch $var(mode) { + pointer { + blt::RemoveBindTag $var($cc) zoom-$var($cc) + bind $var($cc) <1> [list PlotButton $varname %x %y] + } + zoom { + bind $var($cc) <1> {} + blt::AddBindTag $var($cc) zoom-$var($cc) + } + } } - - set var($nn,manage) 1 - set var($nn,dim) $var($mm,dim) - - set var($nn,show) $var($mm,show) - set var($nn,shape,symbol) $var($mm,shape,symbol) - set var($nn,shape,fill) $var($mm,shape,fill) - set var($nn,shape,color) $var($mm,shape,color) - set var($nn,smooth) $var($mm,smooth) - set var($nn,color) [PlotNextColor $var($mm,color)] - set var($nn,fill) $var($mm,fill) - set var($nn,fill,color) [PlotNextColor $var($mm,fill,color)] - set var($nn,width) $var($mm,width) - set var($nn,dash) $var($mm,dash) - set var($nn,error) $var($mm,error) - set var($nn,error,cap) $var($mm,error,cap) - set var($nn,error,color) $var($mm,error,color) - set var($nn,error,width) $var($mm,error,width) - set var($nn,bar,relief) $var($mm,bar,relief) - - # update data set menu - $var(mb).select add radiobutton -label "$var($nn,name)" \ - -variable ${varname}(data,current) -value $nn \ - -command [list PlotCurrentData $varname] - - # make current - set var(data,current) $nn - - set var(manage) $var($nn,manage) - set var(dim) $var($nn,dim) - - set var(xdata) $var($nn,xdata) - set var(ydata) $var($nn,ydata) - set var(xedata) $var($nn,xedata) - set var(yedata) $var($nn,yedata) - - PlotSetVar $varname $nn - - PlotCreateElement $varname - $var(proc,updateelement) $varname - $var(proc,updategraph) $varname - PlotStats $varname - PlotList $varname } proc PlotDestroy {varname} { @@ -506,27 +269,33 @@ proc PlotDestroy {varname} { global iap + set cc $var(graph,current) + # see if it still is around if {![PlotPing $varname]} { return } - for {set nn 1} {$nn<=$var(data,total)} {incr nn} { - switch $var($nn,dim) { + for {set nn 1} {$nn<=$var($cc,data,total)} {incr nn} { + switch $var($cc,$nn,dim) { xy { - blt::vector destroy $var($nn,xdata) $var($nn,ydata) + blt::vector destroy \ + $var($cc,$nn,xdata) $var($cc,$nn,ydata) } xyex { - blt::vector destroy $var($nn,xdata) $var($nn,ydata) \ - $var($nn,xedata) + blt::vector destroy \ + $var($cc,$nn,xdata) $var($cc,$nn,ydata) \ + $var($cc,$nn,xedata) } xyey { - blt::vector destroy $var($nn,xdata) $var($nn,ydata) \ - $var($nn,yedata) + blt::vector destroy \ + $var($cc,$nn,xdata) $var($cc,$nn,ydata) \ + $var($cc,$nn,yedata) } xyexey { - blt::vector destroy $var($nn,xdata) $var($nn,ydata) \ - $var($nn,xedata) $var($nn,yedata) + blt::vector destroy \ + $var($cc,$nn,xdata) $var($cc,$nn,ydata) \ + $var($cc,$nn,xedata) $var($cc,$nn,yedata) } } } @@ -557,29 +326,32 @@ proc PlotExternal {varname} { upvar #0 $varname var global $varname + set cc $var(graph,current) + # incr count - incr ${varname}(data,total) - set nn $var(data,total) - set var(data,current) $nn + incr ${varname}($cc,data,total) + set nn $var($cc,data,total) + set var($cc,data,current) $nn - set var(name) "Dataset $nn" + set var(graph,ds,name) "Dataset $nn" - set var($nn,manage) $var(manage) - set var($nn,dim) $var(dim) + set var($cc,$nn,manage) $var($cc,manage) + set var($cc,$nn,dim) $var($cc,dim) - set var($nn,xdata) $var(xdata) - set var($nn,ydata) $var(ydata) - set var($nn,xedata) $var(xedata) - set var($nn,yedata) $var(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) - PlotGetVar $varname $nn + PlotSaveState $varname # update data set menu - $var(mb).select add radiobutton -label "[msgcat::mc {Dataset}] $nn" \ - -variable ${varname}(data,current) -value $nn \ + $var(mb).graph.select add radiobutton \ + -label "[msgcat::mc {Dataset}] $nn" \ + -variable ${varname}($cc,data,current) -value $nn \ -command "PlotCurrentData $varname" - PlotCreateElement $varname + PlotAddData $varname } proc PlotList {varname} { @@ -599,34 +371,37 @@ proc PlotListGenerate {varname} { upvar #0 $varname var global $varname - set rr {} - if {$var(xdata) != {}} { - global $var(xdata) $var(ydata) $var(xedata) $var(yedata) - set ll [$var(xdata) length] - set xx [$var(xdata) range] - set yy [$var(ydata) range] + set cc $var(graph,current) - switch $var(dim) { + set rr {} + if {$var($cc,xdata) != {}} { + 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] + + switch $var($cc,dim) { xy { for {set ii 0} {$ii<$ll} {incr ii} { append rr "[lindex $xx $ii] [lindex $yy $ii]\n" } } xyex { - set xe [$var(xedata) range] + set xe [$var($cc,xedata) range] for {set ii 0} {$ii<$ll} {incr ii} { append rr "[lindex $xx $ii] [lindex $yy $ii] [lindex $xe $ii]\n" } } xyey { - set ye [$var(yedata) range] + set ye [$var($cc,yedata) range] for {set ii 0} {$ii<$ll} {incr ii} { append rr "[lindex $xx $ii] [lindex $yy $ii] [lindex $ye $ii]\n" } } xyexey { - set xe [$var(xedata) range] - set ye [$var(yedata) range] + set xe [$var($cc,xedata) range] + set ye [$var($cc,yedata) range] for {set ii 0} {$ii<$ll} {incr ii} { append rr "[lindex $xx $ii] [lindex $yy $ii] [lindex $xe $ii] [lindex $ye $ii]\n" } @@ -644,164 +419,6 @@ proc PlotListDestroyCB {varname} { set var(list) 0 } -proc PlotLoadConfig {varname} { - upvar #0 $varname var - global $varname - - PlotLoadConfigFile $varname [OpenFileDialog apconfigfbox] -} - -# used by backup -proc PlotLoadConfigFile {varname filename} { - upvar #0 $varname var - global $varname - - if {$filename != {}} { - source $filename - array set $varname [array get analysisplot] - unset analysisplot - - # backward compatibility - FixVar ${varname}(axis,x,grid) ${varname}(graph,x,grid) - FixVar ${varname}(axis,x,log) ${varname}(graph,x,log) - FixVar ${varname}(axis,x,flip) ${varname}(graph,x,flip) - FixVar ${varname}(axis,y,grid) ${varname}(graph,y,grid) - FixVar ${varname}(axis,y,log) ${varname}(graph,y,log) - FixVar ${varname}(axis,y,flip) ${varname}(graph,y,flip) - - FixVar ${varname}(graph,title,family) ${varname}(titleFont) - FixVar ${varname}(graph,title,size) ${varname}(titleSize) - FixVar ${varname}(graph,title,weight) ${varname}(titleWeight) - FixVar ${varname}(graph,title,slant) ${varname}(titleSlant) - - FixVar ${varname}(axis,title,family) ${varname}(textlabFont) - FixVar ${varname}(axis,title,size) ${varname}(textlabSize) - FixVar ${varname}(axis,title,weight) ${varname}(textlabWeight) - FixVar ${varname}(axis,title,slant) ${varname}(textlabSlant) - - FixVar ${varname}(axis,font,family) ${varname}(numlabFont) - FixVar ${varname}(axis,font,size) ${varname}(numlabSize) - FixVar ${varname}(axis,font,weight) ${varname}(numlabWeight) - FixVar ${varname}(axis,font,slant) ${varname}(numlabSlant) - - FixVar ${varname}(show) ${varname}(linear) - FixVar ${varname}(shape,color) ${varname}(discrete,color) - FixVar ${varname}(shape,fill) ${varname}(discrete,fill) - FixVar ${varname}(width) ${varname}(linear,width) - FixVar ${varname}(color) ${varname}(linear,color) - if {[info exists ${varname}(linear,dash)]} { - set var(linear,dash) [FromYesNo $var(linear,dash)] - } - FixVar ${varname}(dash) ${varname}(linear,dash) - - if {[info exists ${varname}(discrete)]} { - if {$var(discrete)} { - FixVar ${varname}(shape,symbol) ${varname}(discrete,symbol) - } else { - FixVarRm ${varname}(discrete,symbol) - } - } - - FixVarRm ${varname}(bar) - FixVarRm ${varname}(bar,color) - - FixVarRm ${varname}(discrete) - - FixVarRm ${varname}(quadratic) - FixVarRm ${varname}(quadratic,width) - FixVarRm ${varname}(quadratic,color) - FixVarRm ${varname}(quadratic,dash) - - FixVarRm ${varname}(step) - FixVarRm ${varname}(step,color) - FixVarRm ${varname}(step,dash) - FixVarRm ${varname}(step,width) - - if {[info exists var(grid)]} { - set var(axis,x,grid) $var(grid) - set var(axis,y,grid) $var(grid) - unset var(grid) - } - if {[info exists var(format)]} { - set var(graph,format) $var(format) - set var(axis,x,format) $var(format,x) - set var(axis,y,format) $var(format,y) - unset var(format) - unset var(format,x) - unset var(format,y) - } - - if {[info exists var(grid,log)]} { - switch $var(grid,log) { - linearlinear { - set var(axis,x,log) 0 - set var(axis,y,log) 0 - } - linearlog { - set var(axis,x,log) 0 - set var(axis,y,log) 1 - } - loglinear { - set var(axis,x,log) 1 - set var(axis,y,log) 0 - } - loglog { - set var(axis,x,log) 1 - set var(axis,y,log) 1 - } - } - unset var(grid,log) - } - - $var(proc,updategraph) $varname - $var(proc,updateelement) $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 PlotNextColor {which} { - switch -- $which { - black {return red} - red {return green} - green {return blue} - blue {return cyan} - cyan {return magenta} - magenta {return yellow} - yellow {return black} - white {return white} - default {return red} - } -} - proc PlotPing {varname} { upvar #0 $varname var global $varname @@ -825,154 +442,6 @@ proc PlotRaise {varname} { return 0 } -proc PlotSaveConfig {varname} { - upvar #0 $varname var - global $varname - - PlotSaveConfigFile $varname [SaveFileDialog apconfigfbox] -} - -proc PlotSaveConfigFile {varname filename} { - upvar #0 $varname var - global $varname - - if {$filename == {}} { - return - } - - set ch [open $filename w] - - set analysisplot(graph,bg) $var(graph,bg) - - set analysisplot(graph,title) $var(graph,title) - set analysisplot(graph,title,family) $var(graph,title,family) - set analysisplot(graph,title,size) $var(graph,title,size) - 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,title) $var(legend,title) - 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) - set analysisplot(legend,title,slant) $var(legend,title,slant) - set analysisplot(legend,font,family) $var(legend,font,family) - set analysisplot(legend,font,size) $var(legend,font,size) - set analysisplot(legend,font,weight) $var(legend,font,weight) - set analysisplot(legend,font,slant) $var(legend,font,slant) - - set analysisplot(axis,x,title) $var(axis,x,title) - set analysisplot(axis,x,grid) $var(axis,x,grid) - set analysisplot(axis,x,log) $var(axis,x,log) - set analysisplot(axis,x,flip) $var(axis,x,flip) - set analysisplot(axis,x,auto) $var(axis,x,auto) - set analysisplot(axis,x,min) $var(axis,x,min) - set analysisplot(axis,x,max) $var(axis,x,max) - set analysisplot(axis,x,format) $var(axis,x,format) - - set analysisplot(axis,y,title) $var(axis,y,title) - set analysisplot(axis,y,grid) $var(axis,y,grid) - set analysisplot(axis,y,log) $var(axis,y,log) - set analysisplot(axis,y,flip) $var(axis,y,flip) - set analysisplot(axis,y,auto) $var(axis,y,auto) - set analysisplot(axis,y,min) $var(axis,y,min) - set analysisplot(axis,y,max) $var(axis,y,max) - set analysisplot(axis,y,format) $var(axis,y,format) - - set analysisplot(axis,title,family) $var(axis,title,family) - set analysisplot(axis,title,size) $var(axis,title,size) - set analysisplot(axis,title,weight) $var(axis,title,weight) - set analysisplot(axis,title,slant) $var(axis,title,slant) - - set analysisplot(axis,font,family) $var(axis,font,family) - set analysisplot(axis,font,size) $var(axis,font,size) - set analysisplot(axis,font,weight) $var(axis,font,weight) - set analysisplot(axis,font,slant) $var(axis,font,slant) - - set analysisplot(show) $var(show) - set analysisplot(shape,symbol) $var(shape,symbol) - set analysisplot(shape,fill) $var(shape,fill) - set analysisplot(shape,color) $var(shape,color) - set analysisplot(smooth) $var(smooth) - set analysisplot(color) $var(color) - set analysisplot(fill) $var(fill) - set analysisplot(fill,color) $var(fill,color) - set analysisplot(width) $var(width) - set analysisplot(dash) $var(dash) - - set analysisplot(error) $var(error) - set analysisplot(error,cap) $var(error,cap) - set analysisplot(error,color) $var(error,color) - set analysisplot(error,width) $var(error,width) - - set analysisplot(bar,relief) $var(bar,relief) - set analysisplot(bar,mode) $var(bar,mode) - - puts $ch "array set analysisplot \{ [array get analysisplot] \}" - close $ch -} - -proc PlotSaveData {varname} { - upvar #0 $varname var - global $varname - - if {$var(xdata) == {}} { - return - } - - PlotSaveDataFile $varname [SaveFileDialog apdatafbox] -} - -proc PlotSaveDataFile {varname filename} { - upvar #0 $varname var - global $varname - - if {$var(xdata) == {}} { - return - } - - if {$filename == {}} { - return - } - - global $var(xdata) $var(ydata) $var(xedata) $var(yedata) - set ll [$var(xdata) length] - set xx [$var(xdata) range] - set yy [$var(ydata) range] - - set ch [open $filename w] - switch $var(dim) { - xy { - for {set ii 0} {$ii<$ll} {incr ii} { - puts $ch "[lindex $xx $ii] [lindex $yy $ii]" - } - } - xyex { - set xe [$var(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(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(xedata) range] - set ye [$var(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 PlotStats {varname} { upvar #0 $varname var global $varname @@ -990,6 +459,8 @@ proc PlotStatsGenerate {varname} { upvar #0 $varname var global $varname + set cc $var(graph,current) + set min {} set max {} set mean {} @@ -997,14 +468,14 @@ proc PlotStatsGenerate {varname} { set varr {} set sdev {} - if {$var(ydata) != {}} { - if {[$var(ydata) length] > 0} { - set min [format "%6.3f" [blt::vector expr min($var(ydata))]] - set max [format "%6.3f" [blt::vector expr max($var(ydata))]] - set mean [format "%6.3f" [blt::vector expr mean($var(ydata))]] - set median [format "%6.3f" [blt::vector expr median($var(ydata))]] - set varr [format "%6.3f" [expr [blt::vector expr var($var(ydata))]]] - set sdev [format "%6.3f" [expr [blt::vector expr sdev($var(ydata))]]] + if {$var($cc,ydata) != {}} { + if {[$var($cc,ydata) length] > 0} { + set min [format "%6.3f" [blt::vector expr min($var($cc,ydata))]] + set max [format "%6.3f" [blt::vector expr max($var($cc,ydata))]] + set mean [format "%6.3f" [blt::vector expr mean($var($cc,ydata))]] + set median [format "%6.3f" [blt::vector expr median($var($cc,ydata))]] + set varr [format "%6.3f" [expr [blt::vector expr var($var($cc,ydata))]]] + set sdev [format "%6.3f" [expr [blt::vector expr sdev($var($cc,ydata))]]] } } @@ -1025,70 +496,89 @@ proc PlotStatsDestroyCB {varname} { set var(stats) 0 } -proc PlotTitle {varname title xaxis yaxis} { +# procs +proc PlotUpdateCanvas {varname} { upvar #0 $varname var global $varname + global ds9 - set var(graph,title) "$title" - set var(axis,x,title) "$xaxis" - set var(axis,y,title) "$yaxis" + foreach cc $var(graphs) { + $var($cc) 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) + + $var($cc) xaxis configure \ + -bg $var(background) \ + -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) yaxis configure \ + -bg $var(background) \ + -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) legend configure \ + -bg $var(background) \ + -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 PlotUpdateGraph {varname} { upvar #0 $varname var global $varname - global ds9 + set cc $var(graph,current) - if {$var(axis,x,auto)} { + if {$var(graph,axis,x,auto)} { set xmin {} set xmax {} } else { - set xmin $var(axis,x,min) - set xmax $var(axis,x,max) + set xmin $var(graph,axis,x,min) + set xmax $var(graph,axis,x,max) } - if {$var(axis,y,auto)} { + if {$var(graph,axis,y,auto)} { set ymin {} set ymax {} } else { - set ymin $var(axis,y,min) - set ymax $var(axis,y,max) + set ymin $var(graph,axis,y,min) + set ymax $var(graph,axis,y,max) } - $var(graph) xaxis configure -min $xmin -max $xmax \ - -descending $var(axis,x,flip) - $var(graph) yaxis configure -min $ymin -max $ymax \ - -descending $var(axis,y,flip) + $var($cc) xaxis configure -min $xmin -max $xmax \ + -descending $var(graph,axis,x,flip) + $var($cc) yaxis configure -min $ymin -max $ymax \ + -descending $var(graph,axis,y,flip) if {$var(graph,format)} { - if {$var(axis,x,format) != {}} { - $var(graph) xaxis configure \ + if {$var(graph,axis,x,format) != {}} { + $var($cc) xaxis configure \ -command [list PlotAxisFormat $varname x] } else { - $var(graph) xaxis configure -command {} + $var($cc) xaxis configure -command {} } - if {$var(axis,y,format) != {}} { - $var(graph) yaxis configure \ + if {$var(graph,axis,y,format) != {}} { + $var($cc) yaxis configure \ -command [list PlotAxisFormat $varname y] } else { - $var(graph) yaxis configure -command {} + $var($cc) yaxis configure -command {} } } # Menus - if {$var(xdata) != {}} { + if {$var($cc,xdata) != {}} { $var(mb).file entryconfig "[msgcat::mc {Save Data}]..." -state normal $var(mb).file entryconfig [msgcat::mc {Clear Data}] -state normal $var(mb).file entryconfig [msgcat::mc {Statistics}] -state normal $var(mb).file entryconfig [msgcat::mc {List Data}] -state normal - if {$var(1,manage)} { + if {$var($cc,1,manage)} { $var(mb).file entryconfig [msgcat::mc {Duplicate Data}] \ - -state disabled + -state normal } else { $var(mb).file entryconfig [msgcat::mc {Duplicate Data}] \ - -state normal + -state disable } } else { $var(mb).file entryconfig "[msgcat::mc {Save Data}]..." -state disabled @@ -1099,64 +589,31 @@ proc PlotUpdateGraph {varname} { } # Graph - $var(graph) configure -plotpadx 0 -plotpady 0 \ - -title $var(graph,title) \ - -font "{$ds9($var(graph,title,family))} $var(graph,title,size) $var(graph,title,weight) $var(graph,title,slant)" \ - -bg $var(graph,bg) -plotbackground $var(graph,bg) - - $var(graph) xaxis configure \ - -bg $var(graph,bg) \ - -grid $var(axis,x,grid) -logscale $var(axis,x,log) \ - -title $var(axis,x,title) \ - -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(graph) yaxis configure \ - -bg $var(graph,bg) \ - -grid $var(axis,y,grid) -logscale $var(axis,y,log) \ - -title $var(axis,y,title) \ - -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(graph) legend configure -hide [expr !$var(legend)] \ - -bg $var(graph,bg) \ - -position $var(legend,position) -title $var(legend,title) \ - -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)" + $var($cc) configure -plotpadx 0 -plotpady 0 -title $var(graph,title) + + $var($cc) xaxis configure \ + -grid $var(graph,axis,x,grid) -logscale $var(graph,axis,x,log) \ + -title $var(graph,axis,x,title) + + $var($cc) yaxis configure \ + -grid $var(graph,axis,y,grid) -logscale $var(graph,axis,y,log) \ + -title $var(graph,axis,y,title) + + $var($cc) legend configure -hide [expr !$var(graph,legend)] \ + -position $var(graph,legend,position) -title $var(graph,legend,title) } -proc PlotCreateElement {varname} { +proc PlotButton {varname x y} { upvar #0 $varname var global $varname +} - # warning: uses current vars - if {$var(data,total) == 0} { - return - } - - # delete current elements - set nn $var(data,current) - foreach el [$var(graph) element names] { - set f [split $el -] - if {[lindex $f 1] == $nn} { - $var(graph) element delete $el - } - } - - global $var(xdata) $var(ydata) - $var(graph) element create "d-${nn}" -xdata $var(xdata) -ydata $var(ydata) - if {$var(xedata) != {}} { - if {[$var(xedata) length] != 0} { - $var(graph) element configure "d-${nn}" -xerror $var(xedata) - } - } - if {$var(yedata) != {}} { - if {[$var(yedata) length] != 0} { - $var(graph) element configure "d-${nn}" -yerror $var(yedata) - } - } +proc PlotHighliteElement {varname rowlist} { + upvar #0 $varname var + global $varname } +# menus proc PlotColorMenu {w varname color cmd} { upvar #0 $varname var global $varname @@ -1183,48 +640,13 @@ proc PlotColorMenu {w varname color cmd} { -command [list ColorMenuOther $varname $color $cmd] } -proc PlotSetVar {varname nn} { - upvar #0 $varname var - global $varname - - set var(name) $var($nn,name) - set var(show) $var($nn,show) - set var(shape,symbol) $var($nn,shape,symbol) - set var(shape,fill) $var($nn,shape,fill) - set var(shape,color) $var($nn,shape,color) - set var(smooth) $var($nn,smooth) - set var(color) $var($nn,color) - set var(fill) $var($nn,fill) - set var(fill,color) $var($nn,fill,color) - set var(width) $var($nn,width) - set var(dash) $var($nn,dash) - set var(error) $var($nn,error) - set var(error,cap) $var($nn,error,cap) - set var(error,color) $var($nn,error,color) - set var(error,width) $var($nn,error,width) - set var(bar,relief) $var($nn,bar,relief) -} - -proc PlotGetVar {varname nn} { +proc PlotTitle {varname title xaxis yaxis} { upvar #0 $varname var global $varname - set var($nn,name) $var(name) - set var($nn,show) $var(show) - set var($nn,shape,symbol) $var(shape,symbol) - set var($nn,shape,fill) $var(shape,fill) - set var($nn,shape,color) $var(shape,color) - set var($nn,smooth) $var(smooth) - set var($nn,color) $var(color) - set var($nn,fill) $var(fill) - set var($nn,fill,color) $var(fill,color) - set var($nn,width) $var(width) - set var($nn,dash) $var(dash) - set var($nn,error) $var(error) - set var($nn,error,cap) $var(error,cap) - set var($nn,error,color) $var(error,color) - set var($nn,error,width) $var(error,width) - set var($nn,bar,relief) $var(bar,relief) + set var(graph,title) "$title" + set var(graph,axis,x,title) "$xaxis" + set var(graph,axis,y,title) "$yaxis" } proc PlotBackup {ch dir} { @@ -1233,14 +655,16 @@ proc PlotBackup {ch dir} { set rdir "./[lindex [file split $dir] end]" # only save ap plots - foreach tt $iap(windows) { - if {[string range $tt 0 1] == {ap}} { - set fdir [file join $dir $tt] + foreach ww $iap(windows) { + if {[string range $ww 0 1] == {ap}} { + set fdir [file join $dir $ww] - set varname $tt + set varname $ww upvar #0 $varname var global $varname + set cc $var(graph,current) + # create dir if needed if {![file isdirectory $fdir]} { if {[catch {file mkdir $fdir}]} { @@ -1249,24 +673,25 @@ proc PlotBackup {ch dir} { } } - switch $var(type) { + switch $var($cc,type) { line {puts $ch "PlotLineTool"} bar {puts $ch "PlotBarTool"} scatter {puts $ch "PlotScatterTool"} + strip {puts $ch "PlotStripTool"} } - set save $var(data,current) - for {set ii 1} {$ii<=$var(data,total)} {incr ii} { - set ${varname}(data,current) $ii + set save $var($cc,data,current) + for {set ii 1} {$ii<=$var($cc,data,total)} {incr ii} { + set ${varname}($cc,data,current) $ii PlotCurrentData $varname PlotSaveDataFile $varname "$fdir/plot$ii.dat" PlotSaveConfigFile $varname "$fdir/plot$ii.plt" - puts $ch "PlotLoadDataFile $varname $fdir/plot$ii.dat $var(dim)" + puts $ch "PlotLoadDataFile $varname $fdir/plot$ii.dat $var($cc,dim)" puts $ch "PlotLoadConfigFile $varname $fdir/plot$ii.plt" } - set ${varname}(data,current) $save + set ${varname}($cc,data,current) $save PlotCurrentData $varname } } diff --git a/ds9/library/plotbar.tcl b/ds9/library/plotbar.tcl index 3a1a75c..f0af93b 100644 --- a/ds9/library/plotbar.tcl +++ b/ds9/library/plotbar.tcl @@ -7,6 +7,7 @@ package provide DS9 1.0 # used by backup proc PlotBarTool {} { global iap + PlotBar $iap(tt) [msgcat::mc {Bar Plot Tool}] {} {} {} 2 {} } @@ -29,10 +30,8 @@ proc PlotBar {tt wtt title xaxis yaxis dim data} { upvar #0 $varname var global $varname - PlotBarProc $varname - PlotDialog $varname $wtt $title $xaxis $yaxis - PlotDialogBar $varname - + PlotBarDialog $varname $wtt $title $xaxis $yaxis + PlotDataSet $varname $dim $data $var(proc,updategraph) $varname PlotStats $varname @@ -43,26 +42,15 @@ proc PlotBarDialog {varname wtt title xaxis yaxis} { upvar #0 $varname var global $varname - PlotBarProc $varname - PlotDialog $varname $wtt $title $xaxis $yaxis - PlotDialogBar $varname -} - -proc PlotBarProc {varname} { - upvar #0 $varname var - global $varname - - set var(proc,updategraph) PlotBarUpdateGraph + set var(proc,addgraph) PlotBarAddGraph + set var(proc,updatecanvas) PlotBarUpdateCanvas + set var(proc,updategraph) PlotUpdateGraph set var(proc,updateelement) PlotBarUpdateElement - set var(proc,highlite) PlotBarHighliteElement - set var(proc,button) PlotBarButton -} - -proc PlotDialogBar {varname} { - upvar #0 $varname var - global $varname + set var(proc,highlite) PlotHighliteElement + set var(proc,button) PlotButton - global ds9 + PlotDialog $varname $wtt $title $xaxis $yaxis + PlotAddGraph $varname # Graph $var(mb).graph add separator @@ -73,133 +61,129 @@ proc PlotDialogBar {varname} { menu $var(mb).graph.mode $var(mb).graph.mode add radiobutton -label [msgcat::mc {Normal}] \ -variable ${varname}(bar,mode) -value normal \ - -command [list $var(proc,updategraph) $varname] + -command [list $var(proc,updatecanvas) $varname] $var(mb).graph.mode add radiobutton -label [msgcat::mc {Stacked}] \ -variable ${varname}(bar,mode) -value stacked \ - -command [list $var(proc,updategraph) $varname] + -command [list $var(proc,updatecanvas) $varname] $var(mb).graph.mode add radiobutton -label [msgcat::mc {Aligned}] \ -variable ${varname}(bar,mode) -value aligned \ - -command [list $var(proc,updategraph) $varname] + -command [list $var(proc,updatecanvas) $varname] $var(mb).graph.mode add radiobutton -label [msgcat::mc {Overlap}] \ -variable ${varname}(bar,mode) -value overlap \ - -command [list $var(proc,updategraph) $varname] + -command [list $var(proc,updatecanvas) $varname] - # Dataset - $var(mb).dataset add checkbutton -label [msgcat::mc {Show}] \ - -variable ${varname}(show) \ + # Data + $var(mb).data add checkbutton -label [msgcat::mc {Show}] \ + -variable ${varname}(graph,ds,show) \ -command [list PlotBarUpdateElement $varname] - $var(mb).dataset add separator - $var(mb).dataset add cascade -label [msgcat::mc {Color}] \ - -menu $var(mb).dataset.color - $var(mb).dataset add cascade -label [msgcat::mc {Relief}] \ - -menu $var(mb).dataset.relief - $var(mb).dataset add cascade -label [msgcat::mc {Error}] \ - -menu $var(mb).dataset.error - $var(mb).dataset add separator - $var(mb).dataset add command -label "[msgcat::mc {Name}]..." \ + $var(mb).data add separator + $var(mb).data add cascade -label [msgcat::mc {Color}] \ + -menu $var(mb).data.color + $var(mb).data add cascade -label [msgcat::mc {Relief}] \ + -menu $var(mb).data.relief + $var(mb).data add cascade -label [msgcat::mc {Error}] \ + -menu $var(mb).data.error + $var(mb).data add separator + $var(mb).data add command -label "[msgcat::mc {Name}]..." \ -command [list DatasetNameDialog $varname] - PlotColorMenu $var(mb).dataset.color $varname color \ + PlotColorMenu $var(mb).data.color $varname graph,color \ [list PlotBarUpdateElement $varname] # Relief - menu $var(mb).dataset.relief - $var(mb).dataset.relief add radiobutton -label [msgcat::mc {Flat}] \ - -variable ${varname}(bar,relief) -value flat \ + menu $var(mb).data.relief + $var(mb).data.relief add radiobutton -label [msgcat::mc {Flat}] \ + -variable ${varname}(graph,ds,bar,relief) -value flat \ -command [list PlotBarUpdateElement $varname] - $var(mb).dataset.relief add radiobutton -label [msgcat::mc {Sunken}] \ - -variable ${varname}(bar,relief) -value sunken \ + $var(mb).data.relief add radiobutton -label [msgcat::mc {Sunken}] \ + -variable ${varname}(graph,ds,bar,relief) -value sunken \ -command [list PlotBarUpdateElement $varname] - $var(mb).dataset.relief add radiobutton -label [msgcat::mc {Raised}] \ - -variable ${varname}(bar,relief) -value raised \ + $var(mb).data.relief add radiobutton -label [msgcat::mc {Raised}] \ + -variable ${varname}(graph,ds,bar,relief) -value raised \ -command [list PlotBarUpdateElement $varname] - $var(mb).dataset.relief add radiobutton -label [msgcat::mc {Solid}] \ - -variable ${varname}(bar,relief) -value solid \ + $var(mb).data.relief add radiobutton -label [msgcat::mc {Solid}] \ + -variable ${varname}(graph,ds,bar,relief) -value solid \ -command [list PlotBarUpdateElement $varname] - $var(mb).dataset.relief add radiobutton -label [msgcat::mc {Groove}] \ - -variable ${varname}(bar,relief) -value groove \ + $var(mb).data.relief add radiobutton -label [msgcat::mc {Groove}] \ + -variable ${varname}(graph,ds,bar,relief) -value groove \ -command [list PlotBarUpdateElement $varname] # Error - menu $var(mb).dataset.error - $var(mb).dataset.error add checkbutton -label [msgcat::mc {Show}] \ - -variable ${varname}(error) \ + menu $var(mb).data.error + $var(mb).data.error add checkbutton -label [msgcat::mc {Show}] \ + -variable ${varname}(graph,ds,error) \ -command [list PlotBarUpdateElement $varname] - $var(mb).dataset.error add checkbutton -label [msgcat::mc {Cap}] \ - -variable ${varname}(error,cap) \ + $var(mb).data.error add checkbutton -label [msgcat::mc {Cap}] \ + -variable ${varname}(graph,ds,error,cap) \ -command [list PlotBarUpdateElement $varname] - $var(mb).dataset.error add separator - $var(mb).dataset.error add cascade -label [msgcat::mc {Color}] \ - -menu $var(mb).dataset.error.color - $var(mb).dataset.error add cascade -label [msgcat::mc {Width}] \ - -menu $var(mb).dataset.error.width + $var(mb).data.error add separator + $var(mb).data.error add cascade -label [msgcat::mc {Color}] \ + -menu $var(mb).data.error.color + $var(mb).data.error add cascade -label [msgcat::mc {Width}] \ + -menu $var(mb).data.error.width - PlotColorMenu $var(mb).dataset.error.color $varname error,color \ + PlotColorMenu $var(mb).data.error.color $varname graph,ds,error,color \ [list PlotBarUpdateElement $varname] - WidthDashMenu $var(mb).dataset.error.width $varname error,width {} \ + WidthDashMenu $var(mb).data.error.width $varname graph,ds,error,width {} \ [list PlotBarUpdateElement $varname] {} - # graph - set var(type) bar - set var(graph) [blt::barchart $var(top).bar \ - -width 600 \ - -height 500 \ - -highlightthickness 0 \ - ] + $var(proc,updatecanvas) $varname +} - $var(graph) xaxis configure -grid no -stepsize 0 - $var(graph) yaxis configure -grid yes +proc PlotBarAddGraph {varname} { + upvar #0 $varname var + global $varname - pack $var(graph) -expand yes -fill both + set cc $var(graph,current) - # set up zoom stack, assuming mode is zoom - switch $ds9(wm) { - x11 - - win32 {Blt_ZoomStack $var(graph) -mode release} - aqua {Blt_ZoomStack $var(graph) -mode release -button "ButtonPress-2"} - } + set var($cc,type) bar + set var($cc) [blt::barchart $var(canvas).$cc -width 600 -height 500 \ + -highlightthickness 0] + + $var($cc) xaxis configure -grid no -stepsize 0 + $var($cc) yaxis configure -grid yes } -proc PlotBarUpdateGraph {varname} { +proc PlotBarUpdateCanvas {varname} { upvar #0 $varname var global $varname - PlotUpdateGraph $varname - $var(graph) configure -barmode $var(bar,mode) + PlotUpdateCanvas $varname + + foreach cc $var(graphs) { + $var($cc) configure -barmode $var(bar,mode) + } } proc PlotBarUpdateElement {varname} { upvar #0 $varname var global $varname - set nn $var(data,current) - PlotGetVar $varname $nn + set cc $var(graph,current) + + # warning: uses current vars + if {$var($cc,data,total) == 0} { + return + } + + PlotSaveState $varname - if {$var(error)} { + if {$var(graph,ds,error)} { set show both } else { set show none } - if {$var(error,cap)} { - set cap [expr $var(error,width)+3] + if {$var(graph,ds,error,cap)} { + set cap [expr $var(graph,ds,error,width)+3] } else { set cap 0 } - $var(graph) element configure "d-${nn}" \ - -label $var(name) -hide [expr !$var(show)] \ - -relief $var(bar,relief) -color $var(color) \ - -showerrorbars $show -errorbarcolor $var(error,color) \ - -errorbarwidth $var(error,width) -errorbarcap $cap -} - -proc PlotBarButton {varname x y} { - upvar #0 $varname var - global $varname -} - -proc PlotBarHighliteElement {varname rowlist} { - upvar #0 $varname var - global $varname + set nn $var($cc,data,current) + $var($cc) element configure "d-${nn}" \ + -label $var(graph,ds,name) -hide [expr !$var(graph,ds,show)] \ + -relief $var(graph,ds,bar,relief) -color $var(graph,ds,color) \ + -showerrorbars $show -errorbarcolor $var(graph,ds,error,color) \ + -errorbarwidth $var(graph,ds,error,width) -errorbarcap $cap } diff --git a/ds9/library/plotconfig.tcl b/ds9/library/plotconfig.tcl new file mode 100644 index 0000000..4755d93 --- /dev/null +++ b/ds9/library/plotconfig.tcl @@ -0,0 +1,280 @@ +# Copyright (C) 1999-2018 +# Smithsonian Astrophysical Observatory, Cambridge, MA, USA +# For conditions of distribution and use, see copyright notice in "copyright" + +package provide DS9 1.0 + +proc PlotLoadConfig {varname} { + upvar #0 $varname var + global $varname + + PlotLoadConfigFile $varname [OpenFileDialog apconfigfbox] +} + +# used by backup +proc PlotLoadConfigFile {varname filename} { + upvar #0 $varname var + global $varname + + set cc $var(graph,current) + + if {$filename == {}} { + return + } + + source $filename + + set var(graph,title,family) $analysisplot(graph,title,family) + set var(graph,title,size) $analysisplot(graph,title,size) + set var(graph,title,weight) $analysisplot(graph,title,weight) + set var(graph,title,slant) $analysisplot(graph,title,slant) + + 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) + set var(legend,title,slant) $analysisplot(legend,title,slant) + set var(legend,font,family) $analysisplot(legend,font,family) + set var(legend,font,size) $analysisplot(legend,font,size) + set var(legend,font,weight) $analysisplot(legend,font,weight) + set var(legend,font,slant) $analysisplot(legend,font,slant) + + set var(axis,title,family) $analysisplot(axis,title,family) + set var(axis,title,size) $analysisplot(axis,title,size) + set var(axis,title,weight) $analysisplot(axis,title,weight) + set var(axis,title,slant) $analysisplot(axis,title,slant) + + set var(axis,font,family) $analysisplot(axis,font,family) + set var(axis,font,size) $analysisplot(axis,font,size) + set var(axis,font,weight) $analysisplot(axis,font,weight) + set var(axis,font,slant) $analysisplot(axis,font,slant) + + # per Graph + set var(graph,title) $analysisplot(graph,title) + + 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) + set var(graph,axis,x,log) $analysisplot(axis,x,log) + set var(graph,axis,x,flip) $analysisplot(axis,x,flip) + set var(graph,axis,x,auto) $analysisplot(axis,x,auto) + set var(graph,axis,x,min) $analysisplot(axis,x,min) + set var(graph,axis,x,max) $analysisplot(axis,x,max) + set var(graph,axis,x,format) $analysisplot(axis,x,format) + + set var(graph,axis,y,title) $analysisplot(axis,y,title) + set var(graph,axis,y,grid) $analysisplot(axis,y,grid) + set var(graph,axis,y,log) $analysisplot(axis,y,log) + set var(graph,axis,y,flip) $analysisplot(axis,y,flip) + set var(graph,axis,y,auto) $analysisplot(axis,y,auto) + set var(graph,axis,y,min) $analysisplot(axis,y,min) + set var(graph,axis,y,max) $analysisplot(axis,y,max) + set var(graph,axis,y,format) $analysisplot(axis,y,format) + + # per Dataset + set var(graph,ds,show) $analysisplot(show) + set var(graph,ds,smooth) $analysisplot(smooth) + set var(graph,ds,color) $analysisplot(color) + set var(graph,ds,fill) $analysisplot(fill) + set var(graph,ds,fill,color) $analysisplot(fill,color) + set var(graph,ds,width) $analysisplot(width) + set var(graph,ds,dash) $analysisplot(dash) + + set var(graph,ds,shape,symbol) $analysisplot(shape,symbol) + set var(graph,ds,shape,fill) $analysisplot(shape,fill) + set var(graph,ds,shape,color) $analysisplot(shape,color) + + set var(graph,ds,error) $analysisplot(error) + set var(graph,ds,error,cap) $analysisplot(error,cap) + set var(graph,ds,error,color) $analysisplot(error,color) + set var(graph,ds,error,width) $analysisplot(error,width) + + set var(graph,ds,bar,relief) $analysisplot(bar,relief) + + unset analysisplot + + # backward compatibility + FixVar ${varname}(graph,title,family) ${varname}(titleFont) + FixVar ${varname}(graph,title,size) ${varname}(titleSize) + FixVar ${varname}(graph,title,weight) ${varname}(titleWeight) + FixVar ${varname}(graph,title,slant) ${varname}(titleSlant) + + FixVar ${varname}(axis,title,family) ${varname}(textlabFont) + FixVar ${varname}(axis,title,size) ${varname}(textlabSize) + FixVar ${varname}(axis,title,weight) ${varname}(textlabWeight) + FixVar ${varname}(axis,title,slant) ${varname}(textlabSlant) + + FixVar ${varname}(axis,font,family) ${varname}(numlabFont) + FixVar ${varname}(axis,font,size) ${varname}(numlabSize) + FixVar ${varname}(axis,font,weight) ${varname}(numlabWeight) + FixVar ${varname}(axis,font,slant) ${varname}(numlabSlant) + + FixVar ${varname}(graph,ds,show) ${varname}(linear) + FixVar ${varname}(graph,ds,width) ${varname}(linear,width) + FixVar ${varname}(graph,ds,color) ${varname}(linear,color) + if {[info exists ${varname}(linear,dash)]} { + set var(linear,dash) [FromYesNo $var(linear,dash)] + } + FixVar ${varname}(graph,ds,dash) ${varname}(linear,dash) + + FixVar ${varname}(graph,ds,shape,color) ${varname}(discrete,color) + FixVar ${varname}(graph,ds,shape,fill) ${varname}(discrete,fill) + + if {[info exists ${varname}(discrete)]} { + if {$var(discrete)} { + FixVar ${varname}(graph,ds,shape,symbol) \ + ${varname}(discrete,symbol) + } else { + FixVarRm ${varname}(discrete,symbol) + } + } + + FixVarRm ${varname}(bar) + FixVarRm ${varname}(bar,color) + + FixVarRm ${varname}(discrete) + + FixVarRm ${varname}(quadratic) + FixVarRm ${varname}(quadratic,width) + FixVarRm ${varname}(quadratic,color) + FixVarRm ${varname}(quadratic,dash) + + FixVarRm ${varname}(step) + FixVarRm ${varname}(step,color) + FixVarRm ${varname}(step,dash) + FixVarRm ${varname}(step,width) + + if {[info exists var(grid)]} { + set var(graph,axis,x,grid) $var(grid) + set var(graph,axis,y,grid) $var(grid) + unset var(grid) + } + if {[info exists var(format)]} { + set var(graph,format) $var(format) + set var(graph,axis,x,format) $var(format,x) + set var(graph,axis,y,format) $var(format,y) + unset var(format) + unset var(format,x) + unset var(format,y) + } + + if {[info exists var(grid,log)]} { + switch $var(grid,log) { + linearlinear { + set var(graph,axis,x,log) 0 + set var(graph,axis,y,log) 0 + } + linearlog { + set var(graph,axis,x,log) 0 + set var(graph,axis,y,log) 1 + } + loglinear { + set var(graph,axis,x,log) 1 + set var(graph,axis,y,log) 0 + } + loglog { + set var(graph,axis,x,log) 1 + set var(graph,axis,y,log) 1 + } + } + unset var(grid,log) + } + + $var(proc,updategraph) $varname + $var(proc,updateelement) $varname +} + +proc PlotSaveConfig {varname} { + upvar #0 $varname var + global $varname + + PlotSaveConfigFile $varname [SaveFileDialog apconfigfbox] +} + +proc PlotSaveConfigFile {varname filename} { + upvar #0 $varname var + global $varname + + set cc $var(graph,current) + + if {$filename == {}} { + return + } + + set ch [open $filename w] + + set analysisplot(graph,title,family) $var(graph,title,family) + set analysisplot(graph,title,size) $var(graph,title,size) + set analysisplot(graph,title,weight) $var(graph,title,weight) + set analysisplot(graph,title,slant) $var(graph,title,slant) + + 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) + set analysisplot(legend,title,slant) $var(legend,title,slant) + set analysisplot(legend,font,family) $var(legend,font,family) + set analysisplot(legend,font,size) $var(legend,font,size) + set analysisplot(legend,font,weight) $var(legend,font,weight) + set analysisplot(legend,font,slant) $var(legend,font,slant) + + set analysisplot(axis,title,family) $var(axis,title,family) + set analysisplot(axis,title,size) $var(axis,title,size) + set analysisplot(axis,title,weight) $var(axis,title,weight) + set analysisplot(axis,title,slant) $var(axis,title,slant) + + set analysisplot(axis,font,family) $var(axis,font,family) + set analysisplot(axis,font,size) $var(axis,font,size) + set analysisplot(axis,font,weight) $var(axis,font,weight) + set analysisplot(axis,font,slant) $var(axis,font,slant) + + # 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) + set analysisplot(axis,x,log) $var(graph,axis,x,log) + set analysisplot(axis,x,flip) $var(graph,axis,x,flip) + set analysisplot(axis,x,auto) $var(graph,axis,x,auto) + set analysisplot(axis,x,min) $var(graph,axis,x,min) + set analysisplot(axis,x,max) $var(graph,axis,x,max) + set analysisplot(axis,x,format) $var(graph,axis,x,format) + + set analysisplot(axis,y,title) $var(graph,axis,y,title) + set analysisplot(axis,y,grid) $var(graph,axis,y,grid) + set analysisplot(axis,y,log) $var(graph,axis,y,log) + set analysisplot(axis,y,flip) $var(graph,axis,y,flip) + set analysisplot(axis,y,auto) $var(graph,axis,y,auto) + set analysisplot(axis,y,min) $var(graph,axis,y,min) + set analysisplot(axis,y,max) $var(graph,axis,y,max) + set analysisplot(axis,y,format) $var(graph,axis,y,format) + + # per Dataset + set analysisplot(show) $var(graph,ds,show) + set analysisplot(smooth) $var(graph,ds,smooth) + set analysisplot(color) $var(graph,ds,color) + set analysisplot(fill) $var(graph,ds,fill) + set analysisplot(fill,color) $var(graph,ds,fill,color) + set analysisplot(width) $var(graph,ds,width) + set analysisplot(dash) $var(graph,ds,dash) + + set analysisplot(shape,symbol) $var(graph,ds,shape,symbol) + set analysisplot(shape,fill) $var(graph,ds,shape,fill) + set analysisplot(shape,color) $var(graph,ds,shape,color) + + set analysisplot(error) $var(graph,ds,error) + set analysisplot(error,cap) $var(graph,ds,error,cap) + set analysisplot(error,color) $var(graph,ds,error,color) + set analysisplot(error,width) $var(graph,ds,error,width) + + set analysisplot(bar,relief) $var(graph,ds,bar,relief) + + puts $ch "array set analysisplot \{ [array get analysisplot] \}" + close $ch +} + diff --git a/ds9/library/plotdata.tcl b/ds9/library/plotdata.tcl new file mode 100644 index 0000000..4d0f516 --- /dev/null +++ b/ds9/library/plotdata.tcl @@ -0,0 +1,440 @@ +# Copyright (C) 1999-2018 +# Smithsonian Astrophysical Observatory, Cambridge, MA, USA +# For conditions of distribution and use, see copyright notice in "copyright" + +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 + + set cc $var(graph,current) + + switch -- $dim { + 4 { + # first data set + PlotDataSetOne $varname "4.1" $data + + # second data set + PlotDataSetOne $varname "4.2" $data + + $var(proc,updateelement) $varname + } + 5 { + # first data set + PlotDataSetOne $varname "5.1" $data + + # second data set + PlotDataSetOne $varname "5.2" $data + + $var(proc,updateelement) $varname + } + default {PlotDataSetOne $varname $dim $data} + } +} + +proc PlotDataSetOne {varname dim data} { + upvar #0 $varname var + global $varname + + # save current state + PlotSaveState $varname + + set cc $var(graph,current) + + # look for no data + if {[string length $data] == 0} { + return + } + + # total length + set ll [llength $data] + + # incr count + incr ${varname}($cc,data,total) + set nn $var($cc,data,total) + set var($cc,data,current) $nn + + # init new state + 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} + set ydata ap${varname}yy${nn} + set xedata ap${varname}xe${nn} + set yedata ap${varname}ye${nn} + + # basics xy + set var($cc,manage) 1 + set var(graph,ds,name) "Dataset $nn" + 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 + # remove all non-numeric data + regsub -all {[^0-9.e\- ]+} $data {} data + + set x {} + set y {} + set xe {} + set ye {} + switch -- $dim { + 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] + lappend y [lindex $data [expr $ii+1]] + } + $var($cc,xdata) set $x + $var($cc,ydata) set $y + } + + 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) + + 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($cc,xdata) set $x + $var($cc,ydata) set $y + $var($cc,xedata) set $xe + } + + 3 - + xyey { + set var($cc,dim) xyey + set var($cc,xedata) {} + set var($cc,yedata) $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($cc,xdata) set $x + $var($cc,ydata) set $y + $var($cc,yedata) set $ye + } + + xyexey { + set var($cc,dim) xyexey + set var($cc,xedata) $xedata + set var($cc,yedata) $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] + lappend y [lindex $data [expr $ii+1]] + lappend xe [lindex $data [expr $ii+2]] + lappend ye [lindex $data [expr $ii+3]] + } + $var($cc,xdata) set $x + $var($cc,ydata) set $y + $var($cc,xedata) set $xe + $var($cc,yedata) set $ye + } + + 4.1 { + set var($cc,dim) xyey + set var($cc,xedata) {} + set var($cc,yedata) $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($cc,xdata) set $x + $var($cc,ydata) set $y + $var($cc,yedata) set $ye + } + + 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] + lappend y [lindex $data [expr $ii+3]] + } + $var($cc,xdata) set $x + $var($cc,ydata) set $y + } + + 5.1 { + set var($cc,dim) xyey + set var($cc,xedata) {} + set var($cc,yedata) $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($cc,xdata) set $x + $var($cc,ydata) set $y + $var($cc,yedata) set $ye + } + + 5.2 { + set var($cc,dim) xyey + set var($cc,xedata) {} + set var($cc,yedata) $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($cc,xdata) set $x + $var($cc,ydata) set $y + $var($cc,yedata) set $ye + } + } + + set var($cc,$nn,manage) 1 + set var($cc,$nn,dim) $var($cc,dim) + + 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}($cc,data,current) -value $nn \ + -command [list PlotCurrentData $varname] + + PlotAddData $varname + $var(proc,updateelement) $varname +} + +proc PlotDupData {varname mm} { + upvar #0 $varname var + global $varname + + set cc $var(graph,current) + + if {$var($cc,data,total) == 0} { + return + } + + # incr count + incr ${varname}($cc,data,total) + set nn $var($cc,data,total) + set pp [expr $nn-1] + + # new vector names + 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($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($cc,$nn,xedata) {} + } + if {$var($cc,$mm,yedata) != {}} { + $var($cc,$mm,yedata) dup $var($cc,$nn,yedata) + } else { + 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) + 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($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($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($cc,$nn,bar,relief) $var($cc,$mm,bar,relief) + + # update data set menu + $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($cc,data,current) $nn + + set var($cc,manage) $var($cc,$nn,manage) + set var($cc,dim) $var($cc,$nn,dim) + + 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 + + PlotAddData $varname + $var(proc,updateelement) $varname + $var(proc,updategraph) $varname + PlotStats $varname + PlotList $varname +} diff --git a/ds9/library/plotdialog.tcl b/ds9/library/plotdialog.tcl index 1054014..e966d77 100644 --- a/ds9/library/plotdialog.tcl +++ b/ds9/library/plotdialog.tcl @@ -27,20 +27,12 @@ proc PlotDialog {varname wtt title xaxis yaxis} { set var(mode) zoom set var(callback) {} - set var(data,total) 0 - set var(data,current) 0 - - set var(name) {} - set var(xdata) {} - set var(ydata) {} - set var(xedata) {} - set var(yedata) {} + set var(graphs) {} + set var(seq) 0 array set $varname [array get pap] - set var(graph,title) "$title" - set var(axis,x,title) "$xaxis" - set var(axis,y,title) "$yaxis" + PlotTitle $varname $title $xaxis $yaxis # can be turned off for external line plots set var(graph,format) 1 @@ -50,17 +42,18 @@ proc PlotDialog {varname wtt title xaxis yaxis} { $var(mb) add cascade -label [msgcat::mc {File}] -menu $var(mb).file $var(mb) add cascade -label [msgcat::mc {Edit}] -menu $var(mb).edit + $var(mb) add cascade -label [msgcat::mc {Canvas}] -menu $var(mb).canvas $var(mb) add cascade -label [msgcat::mc {Graph}] -menu $var(mb).graph - $var(mb) add cascade -label [msgcat::mc {Dataset}] -menu $var(mb).dataset - $var(mb) add cascade -label [msgcat::mc {Select}] -menu $var(mb).select + $var(mb) add cascade -label [msgcat::mc {Data}] -menu $var(mb).data + # File menu $var(mb).file $var(mb).file add command -label "[msgcat::mc {Load Data}]..." \ -command [list PlotLoadData $varname] $var(mb).file add command -label "[msgcat::mc {Save Data}]..." \ -command [list PlotSaveData $varname] $var(mb).file add command -label [msgcat::mc {Clear Data}] \ - -command [list PlotClearData $varname] + -command [list PlotDeleteData $varname] $var(mb).file add command -label [msgcat::mc {Duplicate Data}] \ -command [list PlotDupData $varname 1] $var(mb).file add separator @@ -99,7 +92,6 @@ proc PlotDialog {varname wtt title xaxis yaxis} { $var(mb).file add command -label [msgcat::mc {Close}] \ -command [list PlotDestroy $varname] - # Export Menu menu $var(mb).file.export $var(mb).file.export add command -label {GIF...} \ -command [list PlotExportDialog $varname gif] @@ -127,39 +119,90 @@ proc PlotDialog {varname wtt title xaxis yaxis} { -variable ${varname}(mode) -value zoom \ -command [list PlotChangeMode $varname] + # Canvas + menu $var(mb).canvas + + $var(mb).canvas add cascade -label [msgcat::mc {Select Graph}] \ + -menu $var(mb).canvas.select + $var(mb).canvas add separator + $var(mb).canvas add command -label [msgcat::mc {Add Graph}] \ + -command [list PlotAddGraph $varname] + $var(mb).canvas add command -label [msgcat::mc {Delete Graph}] \ + -command [list PlotDeleteGraph $varname] + $var(mb).canvas add separator + menu $var(mb).canvas.select + + $var(mb).canvas add cascade -label [msgcat::mc {Font}] \ + -menu $var(mb).canvas.font + $var(mb).canvas add cascade -label [msgcat::mc {Background}] \ + -menu $var(mb).canvas.bg + + menu $var(mb).canvas.font + $var(mb).canvas.font add cascade -label [msgcat::mc {Title}] \ + -menu $var(mb).canvas.font.title + $var(mb).canvas.font add cascade -label [msgcat::mc {Axes Title}] \ + -menu $var(mb).canvas.font.textlab + $var(mb).canvas.font add cascade -label [msgcat::mc {Axes Number}] \ + -menu $var(mb).canvas.font.numlab + $var(mb).canvas.font add cascade -label [msgcat::mc {Legend Title}] \ + -menu $var(mb).canvas.font.legendtitle + $var(mb).canvas.font add cascade -label [msgcat::mc {Legend}] \ + -menu $var(mb).canvas.font.legend + + FontMenu $var(mb).canvas.font.title \ + $varname graph,title,family graph,title,size graph,title,weight \ + graph,title,slant [list $var(proc,updatecanvas) $varname] + FontMenu $var(mb).canvas.font.textlab \ + $varname axis,title,family axis,title,size axis,title,weight \ + axis,title,slant [list $var(proc,updatecanvas) $varname] + FontMenu $var(mb).canvas.font.numlab \ + $varname axis,font,family axis,font,size axis,font,weight \ + axis,font,slant [list $var(proc,updatecanvas) $varname] + FontMenu $var(mb).canvas.font.legendtitle \ + $varname legend,title,family legend,title,size legend,title,weight \ + legend,title,slant [list $var(proc,updatecanvas) $varname] + FontMenu $var(mb).canvas.font.legend \ + $varname legend,font,family legend,font,size legend,font,weight \ + legend,font,slant [list $var(proc,updatecanvas) $varname] + + PlotColorMenu $var(mb).canvas.bg $varname background \ + [list $var(proc,updatecanvas) $varname] + # Graph menu $var(mb).graph + + $var(mb).graph add cascade -label [msgcat::mc {Select Dataset}] \ + -menu $var(mb).graph.select + $var(mb).graph add separator + menu $var(mb).graph.select + $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 {Font}] \ - -menu $var(mb).graph.font - $var(mb).graph add cascade -label [msgcat::mc {Background}] \ - -menu $var(mb).graph.bg $var(mb).graph add separator - $var(mb).graph add command -label "[msgcat::mc {Title}]..." \ - -command [list PlotTitleDialog $varname] + $var(mb).graph add command -label "[msgcat::mc {Titles}]..." \ + -command [list PlotGraphTitleDialog $varname] menu $var(mb).graph.axes $var(mb).graph.axes add checkbutton -label [msgcat::mc {X Grid}] \ - -variable ${varname}(axis,x,grid) \ + -variable ${varname}(graph,axis,x,grid) \ -command [list $var(proc,updategraph) $varname] $var(mb).graph.axes add checkbutton -label [msgcat::mc {Log}] \ - -variable ${varname}(axis,x,log) \ + -variable ${varname}(graph,axis,x,log) \ -command [list $var(proc,updategraph) $varname] $var(mb).graph.axes add checkbutton -label [msgcat::mc {Flip}] \ - -variable ${varname}(axis,x,flip) \ + -variable ${varname}(graph,axis,x,flip) \ -command [list $var(proc,updategraph) $varname] $var(mb).graph.axes add separator $var(mb).graph.axes add checkbutton -label [msgcat::mc {Y Grid}] \ - -variable ${varname}(axis,y,grid) \ + -variable ${varname}(graph,axis,y,grid) \ -command [list $var(proc,updategraph) $varname] $var(mb).graph.axes add checkbutton -label [msgcat::mc {Log}] \ - -variable ${varname}(axis,y,log) \ + -variable ${varname}(graph,axis,y,log) \ -command [list $var(proc,updategraph) $varname] $var(mb).graph.axes add checkbutton -label [msgcat::mc {Flip}] \ - -variable ${varname}(axis,y,flip) \ + -variable ${varname}(graph,axis,y,flip) \ -command [list $var(proc,updategraph) $varname] $var(mb).graph.axes add separator $var(mb).graph.axes add command -label "[msgcat::mc {Range}]..." \ @@ -167,65 +210,27 @@ proc PlotDialog {varname wtt title xaxis yaxis} { menu $var(mb).graph.legend $var(mb).graph.legend add checkbutton -label [msgcat::mc {Show}] \ - -variable ${varname}(legend) \ + -variable ${varname}(graph,legend) \ -command [list $var(proc,updategraph) $varname] $var(mb).graph.legend add separator $var(mb).graph.legend add radiobutton -label [msgcat::mc {Right}] \ - -variable ${varname}(legend,position) -value right \ + -variable ${varname}(graph,legend,position) -value right \ -command [list $var(proc,updategraph) $varname] $var(mb).graph.legend add radiobutton -label [msgcat::mc {Left}] \ - -variable ${varname}(legend,position) -value left \ + -variable ${varname}(graph,legend,position) -value left \ -command [list $var(proc,updategraph) $varname] $var(mb).graph.legend add radiobutton -label [msgcat::mc {Top}] \ - -variable ${varname}(legend,position) -value top \ + -variable ${varname}(graph,legend,position) -value top \ -command [list $var(proc,updategraph) $varname] $var(mb).graph.legend add radiobutton -label [msgcat::mc {Bottom}] \ - -variable ${varname}(legend,position) -value bottom \ + -variable ${varname}(graph,legend,position) -value bottom \ -command [list $var(proc,updategraph) $varname] - menu $var(mb).graph.font - $var(mb).graph.font add cascade -label [msgcat::mc {Title}] \ - -menu $var(mb).graph.font.title - $var(mb).graph.font add cascade -label [msgcat::mc {Axes Title}] \ - -menu $var(mb).graph.font.textlab - $var(mb).graph.font add cascade -label [msgcat::mc {Axes Number}] \ - -menu $var(mb).graph.font.numlab - $var(mb).graph.font add cascade -label [msgcat::mc {Legend Title}] \ - -menu $var(mb).graph.font.legendtitle - $var(mb).graph.font add cascade -label [msgcat::mc {Legend}] \ - -menu $var(mb).graph.font.legend - - FontMenu $var(mb).graph.font.title $varname graph,title,family graph,title,size graph,title,weight graph,title,slant [list $var(proc,updategraph) $varname] - FontMenu $var(mb).graph.font.textlab $varname axis,title,family axis,title,size axis,title,weight axis,title,slant [list $var(proc,updategraph) $varname] - FontMenu $var(mb).graph.font.numlab $varname axis,font,family axis,font,size axis,font,weight axis,font,slant [list $var(proc,updategraph) $varname] - FontMenu $var(mb).graph.font.legendtitle $varname legend,title,family legend,title,size legend,title,weight legend,title,slant [list $var(proc,updategraph) $varname] - FontMenu $var(mb).graph.font.legend $varname legend,font,family legend,font,size legend,font,weight legend,font,slant [list $var(proc,updategraph) $varname] - - PlotColorMenu $var(mb).graph.bg $varname graph,bg [list $var(proc,updategraph) $varname] - # dataset - menu $var(mb).dataset + menu $var(mb).data - # select - menu $var(mb).select -} - -proc PlotChangeMode {varname} { - upvar #0 $varname var - global $varname - - global ds9 - - switch $var(mode) { - pointer { - blt::RemoveBindTag $var(graph) zoom-$var(graph) - bind $var(graph) <1> [list PlotButton $varname %x %y] - } - zoom { - bind $var(graph) <1> {} - blt::AddBindTag $var(graph) zoom-$var(graph) - } - } + set var(canvas) [ttk::frame $var(top).fr] + pack $var(canvas) -expand yes -fill both } proc PlotDataFormatDialog {xarname} { @@ -292,15 +297,15 @@ proc PlotRangeDialog {varname} { set ed(ok) 0 - set ed(x,auto) $var(axis,x,auto) - set ed(x,min) $var(axis,x,min) - set ed(x,max) $var(axis,x,max) - set ed(x,format) $var(axis,x,format) + set ed(graph,axis,x,auto) $var(graph,axis,x,auto) + set ed(graph,axis,x,min) $var(graph,axis,x,min) + set ed(graph,axis,x,max) $var(graph,axis,x,max) + set ed(graph,axis,x,format) $var(graph,axis,x,format) - set ed(y,auto) $var(axis,y,auto) - set ed(y,min) $var(axis,y,min) - set ed(y,max) $var(axis,y,max) - set ed(y,format) $var(axis,y,format) + set ed(graph,axis,y,auto) $var(graph,axis,y,auto) + set ed(graph,axis,y,min) $var(graph,axis,y,min) + set ed(graph,axis,y,max) $var(graph,axis,y,max) + set ed(graph,axis,y,format) $var(graph,axis,y,format) DialogCreate $w [msgcat::mc {Range}] ed(ok) @@ -313,16 +318,16 @@ proc PlotRangeDialog {varname} { ttk::label $f.tauto -text [msgcat::mc {Automatic}] ttk::label $f.x -text [msgcat::mc {X}] - ttk::entry $f.xmin -textvariable ed(x,min) -width 12 - ttk::entry $f.xmax -textvariable ed(x,max) -width 12 - ttk::entry $f.xformat -textvariable ed(x,format) -width 8 - ttk::checkbutton $f.xauto -variable ed(x,auto) + ttk::entry $f.xmin -textvariable ed(graph,axis,x,min) -width 12 + ttk::entry $f.xmax -textvariable ed(graph,axis,x,max) -width 12 + ttk::entry $f.xformat -textvariable ed(graph,axis,x,format) -width 8 + ttk::checkbutton $f.xauto -variable ed(graph,axis,x,auto) ttk::label $f.y -text [msgcat::mc {Y}] - ttk::entry $f.ymin -textvariable ed(y,min) -width 12 - ttk::entry $f.ymax -textvariable ed(y,max) -width 12 - ttk::entry $f.yformat -textvariable ed(y,format) -width 8 - ttk::checkbutton $f.yauto -variable ed(y,auto) + ttk::entry $f.ymin -textvariable ed(graph,axis,y,min) -width 12 + ttk::entry $f.ymax -textvariable ed(graph,axis,y,max) -width 12 + ttk::entry $f.yformat -textvariable ed(graph,axis,y,format) -width 8 + ttk::checkbutton $f.yauto -variable ed(graph,axis,y,auto) grid $f.t $f.tfrom $f.tto $f.tformat $f.tauto -padx 2 -pady 2 -sticky w grid $f.x $f.xmin $f.xmax $f.xformat $f.xauto -padx 2 -pady 2 -sticky w @@ -347,15 +352,15 @@ proc PlotRangeDialog {varname} { DialogDismiss $w if {$ed(ok)} { - set var(axis,x,auto) $ed(x,auto) - set var(axis,x,min) $ed(x,min) - set var(axis,x,max) $ed(x,max) - set var(axis,x,format) $ed(x,format) + set var(graph,axis,x,auto) $ed(graph,axis,x,auto) + set var(graph,axis,x,min) $ed(graph,axis,x,min) + set var(graph,axis,x,max) $ed(graph,axis,x,max) + set var(graph,axis,x,format) $ed(graph,axis,x,format) - set var(axis,y,auto) $ed(y,auto) - set var(axis,y,min) $ed(y,min) - set var(axis,y,max) $ed(y,max) - set var(axis,y,format) $ed(y,format) + set var(graph,axis,y,auto) $ed(graph,axis,y,auto) + set var(graph,axis,y,min) $ed(graph,axis,y,min) + set var(graph,axis,y,max) $ed(graph,axis,y,max) + set var(graph,axis,y,format) $ed(graph,axis,y,format) $var(proc,updategraph) $varname } @@ -365,31 +370,31 @@ proc PlotRangeDialog {varname} { return $rr } -proc PlotTitleDialog {varname} { +proc PlotGraphTitleDialog {varname} { upvar #0 $varname var global $varname global ed - set w {.aptitle} + set w {.applottitle} set ed(ok) 0 set ed(graph,title) $var(graph,title) - set ed(axis,x,title) $var(axis,x,title) - set ed(axis,y,title) $var(axis,y,title) - set ed(legend,title) $var(legend,title) + set ed(graph,axis,x,title) $var(graph,axis,x,title) + set ed(graph,axis,y,title) $var(graph,axis,y,title) + set ed(graph,legend,title) $var(graph,legend,title) DialogCreate $w [msgcat::mc {Title}] ed(ok) # Param set f [ttk::frame $w.param] - ttk::label $f.label -text [msgcat::mc {Plot Title}] + ttk::label $f.label -text [msgcat::mc {Title}] ttk::entry $f.title -textvariable ed(graph,title) -width 30 ttk::label $f.xlabel -text [msgcat::mc {X Axis Title}] - ttk::entry $f.xtitle -textvariable ed(axis,x,title) -width 30 + ttk::entry $f.xtitle -textvariable ed(graph,axis,x,title) -width 30 ttk::label $f.ylabel -text [msgcat::mc {Y Axis Title}] - ttk::entry $f.ytitle -textvariable ed(axis,y,title) -width 30 + ttk::entry $f.ytitle -textvariable ed(graph,axis,y,title) -width 30 ttk::label $f.legendlabel -text [msgcat::mc {Legend Title}] - ttk::entry $f.legendtitle -textvariable ed(legend,title) -width 30 + ttk::entry $f.legendtitle -textvariable ed(graph,legend,title) -width 30 grid $f.label $f.title -padx 2 -pady 2 -sticky ew grid $f.xlabel $f.xtitle -padx 2 -pady 2 -sticky ew @@ -417,9 +422,9 @@ proc PlotTitleDialog {varname} { if {$ed(ok)} { set var(graph,title) $ed(graph,title) - set var(axis,x,title) $ed(axis,x,title) - set var(axis,y,title) $ed(axis,y,title) - set var(legend,title) $ed(legend,title) + set var(graph,axis,x,title) $ed(graph,axis,x,title) + set var(graph,axis,y,title) $ed(graph,axis,y,title) + set var(graph,legend,title) $ed(graph,legend,title) $var(proc,updategraph) $varname } @@ -437,9 +442,9 @@ proc DatasetNameDialog {varname} { set w {.aptitle} set ed(ok) 0 - set ed(name) $var(name) + set ed(name) $var(graph,ds,name) - DialogCreate $w [msgcat::mc {Dataset}] ed(ok) + DialogCreate $w [msgcat::mc {Data}] ed(ok) # Param set f [ttk::frame $w.param] @@ -468,8 +473,9 @@ proc DatasetNameDialog {varname} { DialogDismiss $w if {$ed(ok)} { - $var(mb).select entryconfig "$var(name)" -label "$ed(name)" - set var(name) $ed(name) + $var(mb).graph.select entryconfig "$var(graph,ds,name)" \ + -label "$ed(name)" + set var(graph,ds,name) $ed(name) $var(proc,updateelement) $varname } @@ -509,21 +515,91 @@ proc PlotLineShapeMenu {which var} { -variable $var -value arrow } -proc PlotLineSmoothMenu {which var} { - menu $which - $which add radiobutton -label [msgcat::mc {Step}] \ - -variable $var -value step - $which add radiobutton -label [msgcat::mc {Linear}] \ - -variable $var -value linear - $which add radiobutton -label [msgcat::mc {Cubic}] \ - -variable $var -value cubic - $which add radiobutton -label [msgcat::mc {Quadratic}] \ - -variable $var -value quadratic - $which add radiobutton -label [msgcat::mc {Catrom}] \ - -variable $var -value catrom +proc PlotShapeMenu {varname} { + upvar #0 $varname var + global $varname + + # Shape + menu $var(mb).data.shape + $var(mb).data.shape add radiobutton \ + -label [msgcat::mc {None}] \ + -variable ${varname}(graph,ds,shape,symbol) -value none \ + -command [list $var(proc,updateelement) $varname] + $var(mb).data.shape add radiobutton \ + -label [msgcat::mc {Circle}] \ + -variable ${varname}(graph,ds,shape,symbol) -value circle \ + -command [list $var(proc,updateelement) $varname] + $var(mb).data.shape add radiobutton \ + -label [msgcat::mc {Square}] \ + -variable ${varname}(graph,ds,shape,symbol) -value square \ + -command [list $var(proc,updateelement) $varname] + $var(mb).data.shape add radiobutton \ + -label [msgcat::mc {Diamond}] \ + -variable ${varname}(graph,ds,shape,symbol) -value diamond \ + -command [list $var(proc,updateelement) $varname] + $var(mb).data.shape add radiobutton \ + -label [msgcat::mc {Plus}] \ + -variable ${varname}(graph,ds,shape,symbol) -value plus \ + -command [list $var(proc,updateelement) $varname] + $var(mb).data.shape add radiobutton \ + -label [msgcat::mc {Cross}] \ + -variable ${varname}(graph,ds,shape,symbol) -value cross \ + -command [list $var(proc,updateelement) $varname] + $var(mb).data.shape add radiobutton \ + -label [msgcat::mc {Simple Plus}] \ + -variable ${varname}(graph,ds,shape,symbol) -value splus \ + -command [list $var(proc,updateelement) $varname] + $var(mb).data.shape add radiobutton \ + -label [msgcat::mc {Simple Cross}] \ + -variable ${varname}(graph,ds,shape,symbol) -value scross \ + -command [list $var(proc,updateelement) $varname] + $var(mb).data.shape add radiobutton \ + -label [msgcat::mc {Triangle}] \ + -variable ${varname}(graph,ds,shape,symbol) -value triangle \ + -command [list $var(proc,updateelement) $varname] + $var(mb).data.shape add radiobutton \ + -label [msgcat::mc {Arrow}] \ + -variable ${varname}(graph,ds,shape,symbol) -value arrow \ + -command [list $var(proc,updateelement) $varname] + $var(mb).data.shape add separator + $var(mb).data.shape add checkbutton \ + -label [msgcat::mc {Fill}] \ + -variable ${varname}(graph,ds,shape,fill) \ + -command [list $var(proc,updateelement) $varname] + $var(mb).data.shape add cascade -label [msgcat::mc {Color}] \ + -menu $var(mb).data.shape.color + + PlotColorMenu $var(mb).data.shape.color $varname graph,ds,shape,color \ + [list $var(proc,updateelement) $varname] +} + +proc PlotErrorMenu {varname} { + upvar #0 $varname var + global $varname + + menu $var(mb).data.error + $var(mb).data.error add checkbutton -label [msgcat::mc {Show}] \ + -variable ${varname}(graph,ds,error) \ + -command [list $var(proc,updateelement) $varname] + $var(mb).data.error add checkbutton -label [msgcat::mc {Cap}] \ + -variable ${varname}(graph,ds,error,cap) \ + -command [list $var(proc,updateelement) $varname] + $var(mb).data.error add separator + $var(mb).data.error add cascade -label [msgcat::mc {Color}] \ + -menu $var(mb).data.error.color + $var(mb).data.error add cascade -label [msgcat::mc {Width}] \ + -menu $var(mb).data.error.width + + PlotColorMenu $var(mb).data.error.color $varname graph,ds,error,color \ + [list $var(proc,updateelement) $varname] + WidthDashMenu $var(mb).data.error.width $varname graph,ds,error,width {} \ + [list $var(proc,updateelement) $varname] {} } proc PlotExportDialog {varname format} { + upvar #0 $varname var + global $varname + global giffbox global jpegfbox global tifffbox @@ -566,7 +642,7 @@ proc PlotExport {varname fn format} { # besure we are on top raise $var(top) - set rr [catch {image create photo -format window -data $var(graph)} ph] + set rr [catch {image create photo -format window -data $var(canvas)} ph] if {$rr} { Error $iap(error) return diff --git a/ds9/library/plotline.tcl b/ds9/library/plotline.tcl index 7ad08cc..cf43d38 100644 --- a/ds9/library/plotline.tcl +++ b/ds9/library/plotline.tcl @@ -7,6 +7,7 @@ package provide DS9 1.0 # used by backup proc PlotLineTool {} { global iap + PlotLine $iap(tt) [msgcat::mc {Line Plot Tool}] {} {} {} 2 {} } @@ -29,9 +30,7 @@ proc PlotLine {tt wtt title xaxis yaxis dim data} { upvar #0 $varname var global $varname - PlotLineProc $varname - PlotDialog $varname $wtt $title $xaxis $yaxis - PlotDialogLine $varname + PlotLineDialog $varname $wtt $title $xaxis $yaxis PlotDataSet $varname $dim $data $var(proc,updategraph) $varname @@ -43,260 +42,171 @@ proc PlotLineDialog {varname wtt title xaxis yaxis} { upvar #0 $varname var global $varname - PlotLineProc $varname - PlotDialog $varname $wtt $title $xaxis $yaxis - PlotDialogLine $varname -} - -proc PlotLineProc {varname} { - upvar #0 $varname var - global $varname - + set var(proc,addgraph) PlotLineAddGraph + set var(proc,updatecanvas) PlotUpdateCanvas set var(proc,updategraph) PlotUpdateGraph set var(proc,updateelement) PlotLineUpdateElement set var(proc,highlite) PlotLineHighliteElement set var(proc,button) PlotLineButton -} - -proc PlotDialogLine {varname} { - upvar #0 $varname var - global $varname - global ds9 - - # Dataset - $var(mb).dataset add checkbutton -label [msgcat::mc {Show}] \ - -variable ${varname}(show) \ - -command [list PlotLineUpdateElement $varname] - $var(mb).dataset add separator - $var(mb).dataset add cascade -label [msgcat::mc {Shape}] \ - -menu $var(mb).dataset.shape - $var(mb).dataset add cascade -label [msgcat::mc {Smooth}] \ - -menu $var(mb).dataset.smooth - $var(mb).dataset add cascade -label [msgcat::mc {Color}] \ - -menu $var(mb).dataset.color - $var(mb).dataset add cascade -label [msgcat::mc {Width}] \ - -menu $var(mb).dataset.width - $var(mb).dataset add cascade -label [msgcat::mc {Fill}] \ - -menu $var(mb).dataset.fill - $var(mb).dataset add cascade -label [msgcat::mc {Error}] \ - -menu $var(mb).dataset.error - $var(mb).dataset add separator - $var(mb).dataset add command -label "[msgcat::mc {Name}]..." \ + PlotDialog $varname $wtt $title $xaxis $yaxis + PlotAddGraph $varname + + # Data + $var(mb).data add checkbutton -label [msgcat::mc {Show}] \ + -variable ${varname}(graph,ds,show) \ + -command [list PlotLineUpdateElement $varname] + $var(mb).data add separator + $var(mb).data add cascade -label [msgcat::mc {Shape}] \ + -menu $var(mb).data.shape + $var(mb).data add cascade -label [msgcat::mc {Smooth}] \ + -menu $var(mb).data.smooth + $var(mb).data add cascade -label [msgcat::mc {Color}] \ + -menu $var(mb).data.color + $var(mb).data add cascade -label [msgcat::mc {Width}] \ + -menu $var(mb).data.width + $var(mb).data add cascade -label [msgcat::mc {Fill}] \ + -menu $var(mb).data.fill + $var(mb).data add cascade -label [msgcat::mc {Error}] \ + -menu $var(mb).data.error + $var(mb).data add separator + $var(mb).data add command -label "[msgcat::mc {Name}]..." \ -command [list DatasetNameDialog $varname] # Shape - menu $var(mb).dataset.shape - $var(mb).dataset.shape add radiobutton \ - -label [msgcat::mc {None}] \ - -variable ${varname}(shape,symbol) -value none \ - -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.shape add radiobutton \ - -label [msgcat::mc {Circle}] \ - -variable ${varname}(shape,symbol) -value circle \ - -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.shape add radiobutton \ - -label [msgcat::mc {Square}] \ - -variable ${varname}(shape,symbol) -value square \ - -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.shape add radiobutton \ - -label [msgcat::mc {Diamond}] \ - -variable ${varname}(shape,symbol) -value diamond \ - -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.shape add radiobutton \ - -label [msgcat::mc {Plus}] \ - -variable ${varname}(shape,symbol) -value plus \ - -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.shape add radiobutton \ - -label [msgcat::mc {Cross}] \ - -variable ${varname}(shape,symbol) -value cross \ - -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.shape add radiobutton \ - -label [msgcat::mc {Simple Plus}] \ - -variable ${varname}(shape,symbol) -value splus \ - -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.shape add radiobutton \ - -label [msgcat::mc {Simple Cross}] \ - -variable ${varname}(shape,symbol) -value scross \ - -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.shape add radiobutton \ - -label [msgcat::mc {Triangle}] \ - -variable ${varname}(shape,symbol) -value triangle \ - -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.shape add radiobutton \ - -label [msgcat::mc {Arrow}] \ - -variable ${varname}(shape,symbol) -value arrow \ - -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.shape add separator - $var(mb).dataset.shape add checkbutton \ - -label [msgcat::mc {Fill}] \ - -variable ${varname}(shape,fill) \ - -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.shape add cascade -label [msgcat::mc {Color}] \ - -menu $var(mb).dataset.shape.color - - PlotColorMenu $var(mb).dataset.shape.color $varname shape,color \ - [list PlotLineUpdateElement $varname] + PlotShapeMenu $varname # Smooth - menu $var(mb).dataset.smooth - $var(mb).dataset.smooth add radiobutton \ + menu $var(mb).data.smooth + $var(mb).data.smooth add radiobutton \ -label [msgcat::mc {Step}] \ - -variable ${varname}(smooth) -value step \ + -variable ${varname}(graph,ds,smooth) -value step \ -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.smooth add radiobutton \ + $var(mb).data.smooth add radiobutton \ -label [msgcat::mc {Linear}] \ - -variable ${varname}(smooth) -value linear \ + -variable ${varname}(graph,ds,smooth) -value linear \ -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.smooth add radiobutton \ + $var(mb).data.smooth add radiobutton \ -label [msgcat::mc {Cubic}] \ - -variable ${varname}(smooth) -value cubic \ + -variable ${varname}(graph,ds,smooth) -value cubic \ -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.smooth add radiobutton \ + $var(mb).data.smooth add radiobutton \ -label [msgcat::mc {Quadratic}] \ - -variable ${varname}(smooth) -value quadratic \ + -variable ${varname}(graph,ds,smooth) -value quadratic \ -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.smooth add radiobutton \ + $var(mb).data.smooth add radiobutton \ -label [msgcat::mc {Catrom}] \ - -variable ${varname}(smooth) -value catrom \ + -variable ${varname}(graph,ds,smooth) -value catrom \ -command [list PlotLineUpdateElement $varname] # Color - PlotColorMenu $var(mb).dataset.color $varname color \ + PlotColorMenu $var(mb).data.color $varname graph,ds,color \ [list PlotLineUpdateElement $varname] # Width - menu $var(mb).dataset.width - $var(mb).dataset.width add radiobutton \ - -label {0} -variable ${varname}(width) \ + menu $var(mb).data.width + $var(mb).data.width add radiobutton \ + -label {0} -variable ${varname}(graph,ds,width) \ -value 0 -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.width add radiobutton \ - -label {1} -variable ${varname}(width) \ + $var(mb).data.width add radiobutton \ + -label {1} -variable ${varname}(graph,ds,width) \ -value 1 -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.width add radiobutton \ - -label {2} -variable ${varname}(width) \ + $var(mb).data.width add radiobutton \ + -label {2} -variable ${varname}(graph,ds,width) \ -value 2 -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.width add radiobutton \ - -label {3} -variable ${varname}(width) \ + $var(mb).data.width add radiobutton \ + -label {3} -variable ${varname}(graph,ds,width) \ -value 3 -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.width add radiobutton \ - -label {4} -variable ${varname}(width) \ + $var(mb).data.width add radiobutton \ + -label {4} -variable ${varname}(graph,ds,width) \ -value 4 -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.width add separator - $var(mb).dataset.width add checkbutton \ - -label [msgcat::mc {Dash}] -variable ${varname}(dash) \ + $var(mb).data.width add separator + $var(mb).data.width add checkbutton \ + -label [msgcat::mc {Dash}] -variable ${varname}(graph,ds,dash) \ -command [list PlotLineUpdateElement $varname] # Fill - menu $var(mb).dataset.fill - $var(mb).dataset.fill add checkbutton \ + menu $var(mb).data.fill + $var(mb).data.fill add checkbutton \ -label [msgcat::mc {Show}] \ - -variable ${varname}(fill) \ + -variable ${varname}(graph,ds,fill) \ -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.fill add separator - $var(mb).dataset.fill add cascade -label [msgcat::mc {Color}] \ - -menu $var(mb).dataset.fill.color + $var(mb).data.fill add separator + $var(mb).data.fill add cascade -label [msgcat::mc {Color}] \ + -menu $var(mb).data.fill.color - PlotColorMenu $var(mb).dataset.fill.color $varname fill,color \ + PlotColorMenu $var(mb).data.fill.color $varname graph,fill,color \ [list PlotLineUpdateElement $varname] # Error - menu $var(mb).dataset.error - $var(mb).dataset.error add checkbutton -label [msgcat::mc {Show}] \ - -variable ${varname}(error) \ - -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.error add checkbutton -label [msgcat::mc {Cap}] \ - -variable ${varname}(error,cap) \ - -command [list PlotLineUpdateElement $varname] - $var(mb).dataset.error add separator - $var(mb).dataset.error add cascade -label [msgcat::mc {Color}] \ - -menu $var(mb).dataset.error.color - $var(mb).dataset.error add cascade -label [msgcat::mc {Width}] \ - -menu $var(mb).dataset.error.width + PlotErrorMenu $varname - PlotColorMenu $var(mb).dataset.error.color $varname error,color \ - [list PlotLineUpdateElement $varname] - WidthDashMenu $var(mb).dataset.error.width $varname error,width {} \ - [list PlotLineUpdateElement $varname] {} - - # graph - set var(type) line - set var(graph) [blt::graph $var(top).line \ - -width 600 \ - -height 500 \ - -highlightthickness 0 \ - ] - - pack $var(graph) -expand yes -fill both - - # set up zoom stack, assuming mode is zoom - switch $ds9(wm) { - x11 - - win32 {Blt_ZoomStack $var(graph) -mode release} - aqua {Blt_ZoomStack $var(graph) -mode release -button "ButtonPress-2"} - } + $var(proc,updatecanvas) $varname +} + +proc PlotLineAddGraph {varname} { + upvar #0 $varname var + global $varname + + set cc $var(graph,current) + + set var($cc,type) line + set var($cc) [blt::graph $var(canvas).$cc -width 600 -height 500 \ + -highlightthickness 0] } proc PlotLineUpdateElement {varname} { upvar #0 $varname var global $varname + set cc $var(graph,current) + # warning: uses current vars - if {$var(data,total) == 0} { + if {$var($cc,data,total) == 0} { return } - set nn $var(data,current) - PlotGetVar $varname $nn + PlotSaveState $varname - if {$var(fill)} { - set fillClr $var(fill,color) + if {$var(graph,ds,fill)} { + set fillClr $var(graph,ds,fill,color) } else { set fillClr {} } - if {$var(shape,fill)} { - set clr $var(shape,color) + if {$var(graph,ds,shape,fill)} { + set clr $var(graph,ds,shape,color) } else { set clr {} } - if {$var(dash)} { + if {$var(graph,ds,dash)} { set dash {8 3} } else { set dash { } } - if {$var(error)} { + if {$var(graph,ds,error)} { set show both } else { set show none } - if {$var(error,cap)} { - set cap [expr $var(error,width)+3] + if {$var(graph,ds,error,cap)} { + set cap [expr $var(graph,ds,error,width)+3] } else { set cap 0 } - $var(graph) element configure "d-${nn}" \ - -label $var(name) -hide [expr !$var(show)] \ - -symbol $var(shape,symbol) -fill $clr -scalesymbols no \ - -pixels 5 -outline $var(shape,color) \ - -smooth $var(smooth) \ - -color $var(color) -areabackground $fillClr \ - -linewidth $var(width) -dashes $dash \ - -showerrorbars $show -errorbarcolor $var(error,color) \ - -errorbarwidth $var(error,width) -errorbarcap $cap -} - -proc PlotLineButton {varname x y} { - upvar #0 $varname var - global $varname -} - -proc PlotLineHighliteElement {varname rowlist} { - upvar #0 $varname var - global $varname + set nn $var($cc,data,current) + $var($cc) element configure "d-${nn}" \ + -label $var(graph,ds,name) -hide [expr !$var(graph,ds,show)] \ + -symbol $var(graph,ds,shape,symbol) -fill $clr -scalesymbols no \ + -pixels 5 -outline $var(graph,ds,shape,color) \ + -smooth $var(graph,ds,smooth) \ + -color $var(graph,ds,color) -areabackground $fillClr \ + -linewidth $var(graph,ds,width) -dashes $dash \ + -showerrorbars $show -errorbarcolor $var(graph,ds,error,color) \ + -errorbarwidth $var(graph,ds,error,width) -errorbarcap $cap } diff --git a/ds9/library/plotprint.tcl b/ds9/library/plotprint.tcl index 8d6c98c..fbf6ad6 100644 --- a/ds9/library/plotprint.tcl +++ b/ds9/library/plotprint.tcl @@ -22,98 +22,100 @@ proc PlotPostScript {varname} { global ps global ds9 - # set postscript fonts - $var(graph) configure \ - -font "$var(graph,title,family) $var(graph,title,size) $var(graph,title,weight) $var(graph,title,slant)" - - $var(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(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(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)" - - set options "-decorations false" - - # Color - switch -- $ps(color) { - rgb - - cmyk {append options " -greyscale no"} - gray {append options " -greyscale yes"} - } + foreach cc $var(graphs) { + # set postscript fonts + $var($cc) configure \ + -font "$var(graph,title,family) $var(graph,title,size) $var(graph,title,weight) $var(graph,title,slant)" + + $var($cc) 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) 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) 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)" + + 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 + # 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} } - aqua {set scaling 1.4} - } - # Size - set ww [expr [winfo width $var(top)]*$ps(scale)/100./$scaling] - set hh [expr [winfo height $var(top)]*$ps(scale)/100./$scaling] - append options " -width $ww -height $hh" - - # 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" - } - } - } + # Size + set ww [expr [winfo width $var(top)]*$ps(scale)/100./$scaling] + set hh [expr [winfo height $var(top)]*$ps(scale)/100./$scaling] + append options " -width $ww -height $hh" + + # 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"} - } + # Orientation + switch -- $ps(orient) { + portrait {append options " -landscape false"} + landscape {append options " -landscape true"} + } - if {$ps(dest) == "file" && $ps(filename) != {}} { - eval $var(graph) postscript output $ps(filename) $options - } else { - set ch [open "| $ps(cmd)" w] - puts $ch [eval $var(graph) postscript output $options] - close $ch - } + if {$ps(dest) == "file" && $ps(filename) != {}} { + eval $var($cc) postscript output $ps(filename) $options + } else { + set ch [open "| $ps(cmd)" w] + puts $ch [eval $var($cc) postscript output $options] + close $ch + } - # reset fonts - $var(graph) configure \ - -font "{$ds9($var(graph,title,family))} $var(graph,title,size) $var(graph,title,weight) $var(graph,title,slant)" + # reset fonts + $var($cc) configure \ + -font "{$ds9($var(graph,title,family))} $var(graph,title,size) $var(graph,title,weight) $var(graph,title,slant)" - $var(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) 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(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) 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(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)" + $var($cc) 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)" + } } diff --git a/ds9/library/plotprocess.tcl b/ds9/library/plotprocess.tcl index f21ccc3..e4af856 100644 --- a/ds9/library/plotprocess.tcl +++ b/ds9/library/plotprocess.tcl @@ -15,7 +15,7 @@ proc PrefsDialogPlot {} { # Graph set f [ttk::labelframe $w.plot.graph -text [msgcat::mc {Graph}]] ttk::label $f.tbg -text [msgcat::mc {Background}] - ColorMenuButton $f.bg pap graph,bg {} + ColorMenuButton $f.bg pap background {} grid $f.tbg $f.bg -padx 2 -pady 2 -sticky w @@ -30,18 +30,18 @@ proc PrefsDialogPlot {} { set f [ttk::labelframe $w.plot.axis -text [msgcat::mc {Axis}]] ttk::label $f.xtitle -text [msgcat::mc {X}] - ttk::checkbutton $f.x -text [msgcat::mc {Grid}] -variable pap(axis,x,grid) + ttk::checkbutton $f.x -text [msgcat::mc {Grid}] -variable pap(graph,axis,x,grid) ttk::radiobutton $f.xlinear -text [msgcat::mc {Linear}] \ - -variable pap(axis,x,log) -value 0 + -variable pap(graph,axis,x,log) -value 0 ttk::radiobutton $f.xlog -text [msgcat::mc {Log}] \ - -variable pap(axis,x,log) -value 1 + -variable pap(graph,axis,x,log) -value 1 ttk::label $f.ytitle -text [msgcat::mc {Y}] - ttk::checkbutton $f.y -text [msgcat::mc {Grid}] -variable pap(axis,y,grid) + ttk::checkbutton $f.y -text [msgcat::mc {Grid}] -variable pap(graph,axis,y,grid) ttk::radiobutton $f.ylinear -text [msgcat::mc {Linear}] \ - -variable pap(axis,y,log) -value 0 + -variable pap(graph,axis,y,log) -value 0 ttk::radiobutton $f.ylog -text [msgcat::mc {Log}] \ - -variable pap(axis,y,log) -value 1 + -variable pap(graph,axis,y,log) -value 1 ttk::label $f.ttextlab -text [msgcat::mc {Axis Title}] FontMenuButton $f.textlab pap axis,title,family axis,title,size axis,title,weight axis,title,slant {} @@ -53,56 +53,69 @@ proc PrefsDialogPlot {} { grid $f.ttextlab $f.textlab -padx 2 -pady 2 -sticky w grid $f.tnumlab $f.numlab -padx 2 -pady 2 -sticky w - # Dataset - set f [ttk::labelframe $w.plot.dataset -text [msgcat::mc {Dataset}]] + # Data + set f [ttk::labelframe $w.plot.data -text [msgcat::mc {Dataset}]] # Show - ttk::checkbutton $f.show -text [msgcat::mc {Show}] -variable pap(show) + ttk::checkbutton $f.show -text [msgcat::mc {Show}] \ + -variable pap(graph,ds,show) grid $f.show -padx 2 -pady 2 -sticky w # Shape ttk::label $f.shapetitle -text [msgcat::mc {Shape}] - ttk::menubutton $f.shape -textvariable pap(shape,symbol) \ + ttk::menubutton $f.shape -textvariable pap(graph,ds,shape,symbol) \ -menu $f.shape.menu - PlotLineShapeMenu $f.shape.menu pap(shape,symbol) + PlotLineShapeMenu $f.shape.menu pap(graph,ds,shape,symbol) ttk::checkbutton $f.shapefill -text [msgcat::mc {Fill}] \ - -variable pap(shape,fill) - ColorMenuButton $f.shapecolor pap shape,color {} + -variable pap(graph,ds,shape,fill) + ColorMenuButton $f.shapecolor pap graph,ds,shape,color {} grid $f.shapetitle $f.shape $f.shapefill $f.shapecolor \ -padx 2 -pady 2 -sticky w # Smooth ttk::label $f.smoothtitle -text [msgcat::mc {Smooth}] - ttk::menubutton $f.smooth -textvariable pap(smooth) \ + ttk::menubutton $f.smooth -textvariable pap(graph,ds,smooth) \ -menu $f.smooth.menu - PlotLineSmoothMenu $f.smooth.menu pap(smooth) + menu $f.smooth.menu + $f.smooth.menu add radiobutton -label [msgcat::mc {Step}] \ + -variable pap(graph,ds,smooth) -value step + $f.smooth.menu add radiobutton -label [msgcat::mc {Linear}] \ + -variable pap(graph,ds,smooth) -value linear + $f.smooth.menu add radiobutton -label [msgcat::mc {Cubic}] \ + -variable pap(graph,ds,smooth) -value cubic + $f.smooth.menu add radiobutton -label [msgcat::mc {Quadratic}] \ + -variable pap(graph,ds,smooth) -value quadratic + $f.smooth.menu add radiobutton -label [msgcat::mc {Catrom}] \ + -variable pap(graph,ds,smooth) -value catrom grid $f.smoothtitle $f.smooth -padx 2 -pady 2 -sticky w # Color ttk::label $f.colortitle -text [msgcat::mc {Color}] - ColorMenuButton $f.color pap color {} + ColorMenuButton $f.color pap graph,ds,color {} grid $f.colortitle $f.color -padx 2 -pady 2 -sticky w # Width ttk::label $f.widthtitle -text [msgcat::mc {Width}] - ttk::menubutton $f.width -textvariable pap(width) -menu $f.width.menu - WidthDashMenu $f.width.menu pap width dash {} {} + ttk::menubutton $f.width -textvariable pap(graph,ds,width) \ + -menu $f.width.menu + WidthDashMenu $f.width.menu pap graph,ds,width graph,ds,dash {} {} grid $f.widthtitle $f.width -padx 2 -pady 2 -sticky w # Error ttk::label $f.errortitle -text [msgcat::mc {Error}] ttk::checkbutton $f.error -text [msgcat::mc {Show}] \ - -variable pap(error) + -variable pap(graph,ds,error) ttk::checkbutton $f.errorcap -text [msgcat::mc {Cap}] \ - -variable pap(error,cap) - ColorMenuButton $f.errorcolor pap error,color {} - ttk::menubutton $f.errorwidth -textvariable pap(error,width) \ + -variable pap(graph,ds,error,cap) + ColorMenuButton $f.errorcolor pap graph,ds,error,color {} + ttk::menubutton $f.errorwidth -textvariable pap(graph,ds,error,width) \ -menu $f.errorwidth.menu - WidthDashMenu $f.errorwidth.menu pap width dash {} {} + WidthDashMenu $f.errorwidth.menu pap \ + graph,ds,error,width graph,ds,error,dash {} {} grid $f.errortitle $f.error $f.errorcap $f.errorcolor $f.errorwidth \ -padx 2 -pady 2 -sticky w - pack $w.plot.graph $w.plot.grid $w.plot.axis $w.plot.dataset \ + pack $w.plot.graph $w.plot.grid $w.plot.axis $w.plot.data \ -side top -fill both -expand true } @@ -190,6 +203,11 @@ proc PlotCmdScatter {title xaxis yaxis dim} { PlotScatter $parse(tt) {} $title $xaxis $yaxis $dim $parse(buf) } +proc PlotCmdStrip {title xaxis yaxis dim} { + global parse + PlotStrip $parse(tt) {} $title $xaxis $yaxis $dim $parse(buf) +} + proc PlotCmdAnalysisPlotStdin {which} { global parse AnalysisPlotStdin $which $parse(tt) {} $parse(buf) @@ -256,6 +274,14 @@ proc PlotCmdSaveConfig {fn} { } } +proc PlotCmdUpdateCanvas {which value} { + global cvarname + upvar #0 $cvarname cvar + + set cvar($which) $value + $cvar(proc,updatecanvas) $cvarname +} + proc PlotCmdUpdateGraph {which value} { global cvarname upvar #0 $cvarname cvar @@ -311,6 +337,15 @@ proc PlotCmdExport {format fn} { PlotExport $cvarname $fn $format } +proc PlotCmdSelectData {which} { + global cvarname + upvar #0 $cvarname cvar + + set cc $cvar(graph,current) + set cvar($cc,data,current) $which + PlotCurrentData $cvarname +} + proc ProcessSendPlotCmd {proc id param {sock {}} {fn {}}} { global iap global parse @@ -326,3 +361,24 @@ proc ProcessSendPlotCmd {proc id param {sock {}} {fn {}}} { plotsend::yy_scan_string $param plotsend::yyparse } + +proc PlotSendCmdCVARGet {key} { + global cvarname + upvar #0 $cvarname cvar + + set cc $cvar(graph,current) + + global parse + $parse(proc) $parse(id) "$cvar($cc,$key)\n" +} + +proc PlotSendCmdCVARYesNo {key} { + global cvarname + upvar #0 $cvarname cvar + + set cc $cvar(graph,current) + + global parse + $parse(proc) $parse(id) [ToYesNo $cvar($cc,$key)] +} + diff --git a/ds9/library/plotscatter.tcl b/ds9/library/plotscatter.tcl index a9b7fc5..02b9753 100644 --- a/ds9/library/plotscatter.tcl +++ b/ds9/library/plotscatter.tcl @@ -7,6 +7,7 @@ package provide DS9 1.0 # used by backup proc PlotScatterTool {} { global iap + PlotScatter $iap(tt) [msgcat::mc {Scatter Plot Tool}] {} {} {} 2 {} } @@ -29,10 +30,8 @@ proc PlotScatter {tt wtt title xaxis yaxis dim data} { upvar #0 $varname var global $varname - PlotScatterProc $varname - PlotDialog $varname $wtt $title $xaxis $yaxis - PlotDialogScatter $varname - + PlotScatterDialog $varname $wtt $title $xaxis $yaxis + PlotDataSet $varname $dim $data $var(proc,updategraph) $varname PlotStats $varname @@ -43,181 +42,107 @@ proc PlotScatterDialog {varname wtt title xaxis yaxis} { upvar #0 $varname var global $varname - PlotScatterProc $varname - PlotDialog $varname $wtt $title $xaxis $yaxis - PlotDialogScatter $varname -} - -proc PlotScatterProc {varname} { - upvar #0 $varname var - global $varname - + set var(proc,addgraph) PlotScatterAddGraph + set var(proc,updatecanvas) PlotUpdateCanvas set var(proc,updategraph) PlotUpdateGraph set var(proc,updateelement) PlotScatterUpdateElement set var(proc,highlite) PlotScatterHighliteElement set var(proc,button) PlotScatterButton -} -proc PlotDialogScatter {varname} { - upvar #0 $varname var - global $varname - - global ds9 + PlotDialog $varname $wtt $title $xaxis $yaxis + PlotAddGraph $varname - # Dataset - $var(mb).dataset add checkbutton -label [msgcat::mc {Show}] \ - -variable ${varname}(show) \ + # Data + $var(mb).data add checkbutton -label [msgcat::mc {Show}] \ + -variable ${varname}(graph,ds,show) \ -command [list PlotScatterUpdateElement $varname] - $var(mb).dataset add separator - $var(mb).dataset add cascade -label [msgcat::mc {Shape}] \ - -menu $var(mb).dataset.shape - $var(mb).dataset add cascade -label [msgcat::mc {Error}] \ - -menu $var(mb).dataset.error - $var(mb).dataset add separator - $var(mb).dataset add command -label "[msgcat::mc {Name}]..." \ + $var(mb).data add separator + $var(mb).data add cascade -label [msgcat::mc {Shape}] \ + -menu $var(mb).data.shape + $var(mb).data add cascade -label [msgcat::mc {Error}] \ + -menu $var(mb).data.error + $var(mb).data add separator + $var(mb).data add command -label "[msgcat::mc {Name}]..." \ -command [list DatasetNameDialog $varname] # Shape - menu $var(mb).dataset.shape - $var(mb).dataset.shape add radiobutton \ - -label [msgcat::mc {Circle}] \ - -variable ${varname}(shape,symbol) -value circle \ - -command [list PlotScatterUpdateElement $varname] - $var(mb).dataset.shape add radiobutton \ - -label [msgcat::mc {Square}] \ - -variable ${varname}(shape,symbol) -value square \ - -command [list PlotScatterUpdateElement $varname] - $var(mb).dataset.shape add radiobutton \ - -label [msgcat::mc {Diamond}] \ - -variable ${varname}(shape,symbol) -value diamond \ - -command [list PlotScatterUpdateElement $varname] - $var(mb).dataset.shape add radiobutton \ - -label [msgcat::mc {Plus}] \ - -variable ${varname}(shape,symbol) -value plus \ - -command [list PlotScatterUpdateElement $varname] - $var(mb).dataset.shape add radiobutton \ - -label [msgcat::mc {Cross}] \ - -variable ${varname}(shape,symbol) -value cross \ - -command [list PlotScatterUpdateElement $varname] - $var(mb).dataset.shape add radiobutton \ - -label [msgcat::mc {Simple Plus}] \ - -variable ${varname}(shape,symbol) -value splus \ - -command [list PlotScatterUpdateElement $varname] - $var(mb).dataset.shape add radiobutton \ - -label [msgcat::mc {Simple Cross}] \ - -variable ${varname}(shape,symbol) -value scross \ - -command [list PlotScatterUpdateElement $varname] - $var(mb).dataset.shape add radiobutton \ - -label [msgcat::mc {Triangle}] \ - -variable ${varname}(shape,symbol) -value triangle \ - -command [list PlotScatterUpdateElement $varname] - $var(mb).dataset.shape add radiobutton \ - -label [msgcat::mc {Arrow}] \ - -variable ${varname}(shape,symbol) -value arrow \ - -command [list PlotScatterUpdateElement $varname] - $var(mb).dataset.shape add separator - $var(mb).dataset.shape add checkbutton \ - -label [msgcat::mc {Fill}] \ - -variable ${varname}(shape,fill) \ - -command [list PlotScatterUpdateElement $varname] - $var(mb).dataset.shape add cascade -label [msgcat::mc {Color}] \ - -menu $var(mb).dataset.shape.color - - # Color - PlotColorMenu $var(mb).dataset.shape.color $varname shape,color \ - [list PlotScatterUpdateElement $varname] + PlotShapeMenu $varname # Error - menu $var(mb).dataset.error - $var(mb).dataset.error add checkbutton -label [msgcat::mc {Show}] \ - -variable ${varname}(error) \ - -command [list PlotScatterUpdateElement $varname] - $var(mb).dataset.error add checkbutton -label [msgcat::mc {Cap}] \ - -variable ${varname}(error,cap) \ - -command [list PlotScatterUpdateElement $varname] - $var(mb).dataset.error add separator - $var(mb).dataset.error add cascade -label [msgcat::mc {Color}] \ - -menu $var(mb).dataset.error.color - $var(mb).dataset.error add cascade -label [msgcat::mc {Width}] \ - -menu $var(mb).dataset.error.width - - PlotColorMenu $var(mb).dataset.error.color $varname error,color \ - [list PlotScatterUpdateElement $varname] - WidthDashMenu $var(mb).dataset.error.width $varname error,width {} \ - [list PlotScatterUpdateElement $varname] {} - - # graph - set var(type) scatter - set var(graph) [blt::graph $var(top).scatter \ - -width 600 \ - -height 500 \ - -highlightthickness 0 \ - ] - - pack $var(graph) -expand yes -fill both - - # set up zoom stack, assuming mode is zoom - switch $ds9(wm) { - x11 - - win32 {Blt_ZoomStack $var(graph) -mode release} - aqua {Blt_ZoomStack $var(graph) -mode release -button "ButtonPress-2"} - } + PlotErrorMenu $varname + + $var(proc,updatecanvas) $varname +} + +proc PlotScatterAddGraph {varname} { + upvar #0 $varname var + global $varname + + set cc $var(graph,current) + + set var($cc,type) scatter + set var($cc) [blt::graph $var(canvas).$cc -width 600 -height 500 \ + -highlightthickness 0] } proc PlotScatterUpdateElement {varname} { upvar #0 $varname var global $varname + set cc $var(graph,current) + # warning: uses current vars - if {$var(data,total) == 0} { + if {$var($cc,data,total) == 0} { return } - set nn $var(data,current) - PlotGetVar $varname $nn + PlotSaveState $varname - if {$var(shape,symbol) == "none"} { - set var(shape,symbol) circle + if {$var(graph,ds,shape,symbol) == "none"} { + set var(graph,ds,shape,symbol) circle } - if {$var(shape,fill)} { - set clr $var(shape,color) + if {$var(graph,ds,shape,fill)} { + set clr $var(graph,ds,shape,color) } else { set clr {} } - if {$var(error)} { + if {$var(graph,ds,error)} { set show both } else { set show none } - if {$var(error,cap)} { - set cap [expr $var(error,width)+3] + if {$var(graph,ds,error,cap)} { + set cap [expr $var(graph,ds,error,width)+3] } else { set cap 0 } - $var(graph) element configure "d-${nn}" \ - -label $var(name) -hide [expr !$var(show)] \ - -symbol $var(shape,symbol) -fill $clr -scalesymbols no \ - -outline $var(shape,color) \ + set nn $var($cc,data,current) + $var($cc) element configure "d-${nn}" \ + -label $var(graph,ds,name) -hide [expr !$var(graph,ds,show)] \ + -symbol $var(graph,ds,shape,symbol) -fill $clr -scalesymbols no \ + -outline $var(graph,ds,shape,color) \ -linewidth 0 -pixels 5 \ - -showerrorbars $show -errorbarcolor $var(error,color) \ - -errorbarwidth $var(error,width) -errorbarcap $cap + -showerrorbars $show -errorbarcolor $var(graph,ds,error,color) \ + -errorbarwidth $var(graph,ds,error,width) -errorbarcap $cap - $var(graph) pen configure active -color blue \ - -symbol $var(shape,symbol) \ + $var($cc) pen configure active -color blue \ + -symbol $var(graph,ds,shape,symbol) \ -linewidth 0 -pixels 5 \ - -showerrorbars $show -errorbarcolor $var(error,color) \ - -errorbarwidth $var(error,width) -errorbarcap $cap + -showerrorbars $show -errorbarcolor $var(graph,ds,error,color) \ + -errorbarwidth $var(graph,ds,error,width) -errorbarcap $cap } proc PlotScatterButton {varname x y} { upvar #0 $varname var global $varname - if {$var(data,total) == 0} { + set cc $var(graph,current) + + if {$var($cc,data,total) == 0} { return } @@ -225,18 +150,18 @@ proc PlotScatterButton {varname x y} { return } - set rr [$var(graph) element closest $x $y] + set rr [$var($cc) element closest $x $y] set elem [lindex $rr 1] set row [lindex $rr 3] if {$elem != {}} { if {$row != {}} { - $var(graph) element deactivate $elem - $var(graph) element activate $elem $row + $var($cc) element deactivate $elem + $var($cc) element activate $elem $row # rows start at 1 eval "$var(callback) [expr $row+1]" } else { - $var(graph) element deactivate $elem + $var($cc) element deactivate $elem eval "$var(callback) {}" } } @@ -246,15 +171,17 @@ proc PlotScatterHighliteElement {varname rowlist} { upvar #0 $varname var global $varname - if {$var(data,total) == 0} { + set cc $var(graph,current) + + if {$var($cc,data,total) == 0} { return } - if {$var(show)} { - $var(graph) element deactivate d-1 + if {$var(graph,ds,show)} { + $var($cc) element deactivate d-1 if {$rowlist != {}} { # can have multiple rows - eval "$var(graph) element activate d-1 $rowlist" + eval "$var($cc) element activate d-1 $rowlist" } } } diff --git a/ds9/library/plotstate.tcl b/ds9/library/plotstate.tcl new file mode 100644 index 0000000..8d20eb9 --- /dev/null +++ b/ds9/library/plotstate.tcl @@ -0,0 +1,243 @@ +# Copyright (C) 1999-2018 +# Smithsonian Astrophysical Observatory, Cambridge, MA, USA +# For conditions of distribution and use, see copyright notice in "copyright" + +package provide DS9 1.0 + +# Plot State +proc PlotDefState {} { + global pap + + # per Canvas + set pap(background) white + set pap(bar,mode) normal + + set pap(graph,title,family) helvetica + set pap(graph,title,size) 12 + set pap(graph,title,weight) normal + set pap(graph,title,slant) roman + + set pap(legend,title,family) helvetica + set pap(legend,title,size) 10 + set pap(legend,title,weight) normal + set pap(legend,title,slant) roman + set pap(legend,font,family) helvetica + set pap(legend,font,size) 9 + set pap(legend,font,weight) normal + set pap(legend,font,slant) roman + + set pap(axis,title,family) helvetica + set pap(axis,title,size) 9 + set pap(axis,title,weight) normal + set pap(axis,title,slant) roman + + set pap(axis,font,family) helvetica + set pap(axis,font,size) 9 + set pap(axis,font,weight) normal + set pap(axis,font,slant) roman + + # per Graph + set pap(graph,title) {} + + 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 + set pap(graph,axis,x,log) 0 + set pap(graph,axis,x,flip) 0 + set pap(graph,axis,x,auto) 1 + set pap(graph,axis,x,min) {} + set pap(graph,axis,x,max) {} + set pap(graph,axis,x,format) {} + + set pap(graph,axis,y,title) {} + set pap(graph,axis,y,grid) 1 + set pap(graph,axis,y,log) 0 + set pap(graph,axis,y,flip) 0 + set pap(graph,axis,y,auto) 1 + set pap(graph,axis,y,min) {} + set pap(graph,axis,y,max) {} + set pap(graph,axis,y,format) {} + + # per DataSet + set pap(graph,ds,name) {} + set pap(graph,ds,show) 1 + set pap(graph,ds,smooth) linear + set pap(graph,ds,color) black + set pap(graph,ds,fill) 0 + set pap(graph,ds,fill,color) black + set pap(graph,ds,width) 1 + set pap(graph,ds,dash) 0 + + set pap(graph,ds,shape,symbol) none + set pap(graph,ds,shape,fill) 1 + set pap(graph,ds,shape,color) red + + set pap(graph,ds,error) 1 + set pap(graph,ds,error,cap) 0 + set pap(graph,ds,error,color) red + set pap(graph,ds,error,width) 1 + + set pap(graph,ds,bar,relief) raised +} + +proc PlotInitGraph {varname} { + upvar #0 $varname var + global $varname + + global pap + + # per Graph + 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,title) $pap(graph,axis,x,title) + set var(graph,axis,x,grid) $pap(graph,axis,x,grid) + set var(graph,axis,x,log) $pap(graph,axis,x,log) + set var(graph,axis,x,flip) $pap(graph,axis,x,flip) + set var(graph,axis,x,auto) $pap(graph,axis,x,auto) + set var(graph,axis,x,min) $pap(graph,axis,x,min) + set var(graph,axis,x,max) $pap(graph,axis,x,max) + set var(graph,axis,x,format) $pap(graph,axis,x,format) + + set var(graph,axis,y,title) $pap(graph,axis,y,title) + set var(graph,axis,y,grid) $pap(graph,axis,y,grid) + set var(graph,axis,y,log) $pap(graph,axis,y,log) + set var(graph,axis,y,flip) $pap(graph,axis,y,flip) + set var(graph,axis,y,auto) $pap(graph,axis,y,auto) + set var(graph,axis,y,min) $pap(graph,axis,y,min) + set var(graph,axis,y,max) $pap(graph,axis,y,max) + set var(graph,axis,y,format) $pap(graph,axis,y,format) + + # per DataSet + set var(graph,ds,name) $pap(graph,ds,name) + 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) +} + +proc PlotSaveState {varname} { + upvar #0 $varname var + global $varname + + set cc $var(graph,current) + set nn $var($cc,data,current) + + # per Graph + set var($cc,title) $var(graph,title) + + 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,title) $var(graph,axis,x,title) + set var($cc,axis,x,grid) $var(graph,axis,x,grid) + set var($cc,axis,x,log) $var(graph,axis,x,log) + set var($cc,axis,x,flip) $var(graph,axis,x,flip) + set var($cc,axis,x,auto) $var(graph,axis,x,auto) + set var($cc,axis,x,min) $var(graph,axis,x,min) + set var($cc,axis,x,max) $var(graph,axis,x,max) + set var($cc,axis,x,format) $var(graph,axis,x,format) + + set var($cc,axis,y,title) $var(graph,axis,y,title) + set var($cc,axis,y,grid) $var(graph,axis,y,grid) + set var($cc,axis,y,log) $var(graph,axis,y,log) + set var($cc,axis,y,flip) $var(graph,axis,y,flip) + set var($cc,axis,y,auto) $var(graph,axis,y,auto) + set var($cc,axis,y,min) $var(graph,axis,y,min) + set var($cc,axis,y,max) $var(graph,axis,y,max) + set var($cc,axis,y,format) $var(graph,axis,y,format) + + # per DataSet + set var($cc,$nn,name) $var(graph,ds,name) + set var($cc,$nn,show) $var(graph,ds,show) + set var($cc,$nn,smooth) $var(graph,ds,smooth) + set var($cc,$nn,color) $var(graph,ds,color) + set var($cc,$nn,fill) $var(graph,ds,fill) + set var($cc,$nn,fill,color) $var(graph,ds,fill,color) + set var($cc,$nn,width) $var(graph,ds,width) + set var($cc,$nn,dash) $var(graph,ds,dash) + + set var($cc,$nn,shape,symbol) $var(graph,ds,shape,symbol) + set var($cc,$nn,shape,fill) $var(graph,ds,shape,fill) + set var($cc,$nn,shape,color) $var(graph,ds,shape,color) + + set var($cc,$nn,error) $var(graph,ds,error) + set var($cc,$nn,error,cap) $var(graph,ds,error,cap) + set var($cc,$nn,error,color) $var(graph,ds,error,color) + set var($cc,$nn,error,width) $var(graph,ds,error,width) + + set var($cc,$nn,bar,relief) $var(graph,ds,bar,relief) +} + +proc PlotRestoreState {varname nn} { + upvar #0 $varname var + global $varname + + set cc $var(graph,current) + set nn $var($cc,data,current) + + # per Graph + set var(graph,title) $var($cc,title) + + 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,title) $var($cc,axis,x,title) + set var(graph,axis,x,grid) $var($cc,axis,x,grid) + set var(graph,axis,x,log) $var($cc,axis,x,log) + set var(graph,axis,x,flip) $var($cc,axis,x,flip) + set var(graph,axis,x,auto) $var($cc,axis,x,auto) + set var(graph,axis,x,min) $var($cc,axis,x,min) + set var(graph,axis,x,max) $var($cc,axis,x,max) + set var(graph,axis,x,format) $var($cc,axis,x,format) + + set var(graph,axis,y,title) $var($cc,axis,y,title) + set var(graph,axis,y,grid) $var($cc,axis,y,grid) + set var(graph,axis,y,log) $var($cc,axis,y,log) + set var(graph,axis,y,flip) $var($cc,axis,y,flip) + set var(graph,axis,y,auto) $var($cc,axis,y,auto) + set var(graph,axis,y,min) $var($cc,axis,y,min) + set var(graph,axis,y,max) $var($cc,axis,y,max) + set var(graph,axis,y,format) $var($cc,axis,y,format) + + # per DataSet + set var(graph,ds,name) $var($cc,$nn,name) + set var(graph,ds,show) $var($cc,$nn,show) + set var(graph,ds,smooth) $var($cc,$nn,smooth) + set var(graph,ds,color) $var($cc,$nn,color) + set var(graph,ds,fill) $var($cc,$nn,fill) + set var(graph,ds,fill,color) $var($cc,$nn,fill,color) + set var(graph,ds,width) $var($cc,$nn,width) + set var(graph,ds,dash) $var($cc,$nn,dash) + + set var(graph,ds,shape,symbol) $var($cc,$nn,shape,symbol) + set var(graph,ds,shape,fill) $var($cc,$nn,shape,fill) + set var(graph,ds,shape,color) $var($cc,$nn,shape,color) + + set var(graph,ds,error) $var($cc,$nn,error) + set var(graph,ds,error,cap) $var($cc,$nn,error,cap) + set var(graph,ds,error,color) $var($cc,$nn,error,color) + set var(graph,ds,error,width) $var($cc,$nn,error,width) + + set var(graph,ds,bar,relief) $var($cc,$nn,bar,relief) +} diff --git a/ds9/library/prefs.tcl b/ds9/library/prefs.tcl index fe6283d..4563a08 100644 --- a/ds9/library/prefs.tcl +++ b/ds9/library/prefs.tcl @@ -464,6 +464,8 @@ proc FixPrefs {version} { FixPrefs7.3to7.4 FixPrefs7.4to7.5 FixPrefs7.5to7.6 + FixPrefs7.6to8.0 + FixPrefs8.0to8.1 } 6.0 { FixPrefs6.0to6.1 @@ -475,6 +477,8 @@ proc FixPrefs {version} { FixPrefs7.3to7.4 FixPrefs7.4to7.5 FixPrefs7.5to7.6 + FixPrefs7.6to8.0 + FixPrefs8.0to8.1 } 6.1 - 6.1.1 - @@ -487,6 +491,8 @@ proc FixPrefs {version} { FixPrefs7.3to7.4 FixPrefs7.4to7.5 FixPrefs7.5to7.6 + FixPrefs7.6to8.0 + FixPrefs8.0to8.1 } 6.2 { FixPrefs6.2to7.0 @@ -496,6 +502,8 @@ proc FixPrefs {version} { FixPrefs7.3to7.4 FixPrefs7.4to7.5 FixPrefs7.5to7.6 + FixPrefs7.6to8.0 + FixPrefs8.0to8.1 } 7.0 { FixPrefs7.0to7.1 @@ -504,6 +512,8 @@ proc FixPrefs {version} { FixPrefs7.3to7.4 FixPrefs7.4to7.5 FixPrefs7.5to7.6 + FixPrefs7.6to8.0 + FixPrefs8.0to8.1 } 7.1 { FixPrefs7.1to7.2 @@ -511,12 +521,16 @@ proc FixPrefs {version} { FixPrefs7.3to7.4 FixPrefs7.4to7.5 FixPrefs7.5to7.6 + FixPrefs7.6to8.0 + FixPrefs8.0to8.1 } 7.2 { FixPrefs7.2to7.3 FixPrefs7.3to7.4 FixPrefs7.4to7.5 FixPrefs7.5to7.6 + FixPrefs7.6to8.0 + FixPrefs8.0to8.1 } 7.3 - 7.3.1 - @@ -524,20 +538,60 @@ proc FixPrefs {version} { FixPrefs7.3to7.4 FixPrefs7.4to7.5 FixPrefs7.5to7.6 + FixPrefs7.6to8.0 + FixPrefs8.0to8.1 } 7.4 { FixPrefs7.4to7.5 FixPrefs7.5to7.6 + FixPrefs7.6to8.0 + FixPrefs8.0to8.1 } 7.5 { FixPrefs7.5to7.6 + FixPrefs7.6to8.0 + FixPrefs8.0to8.1 + } + 7.6 { + FixPrefs7.6to8.0 + FixPrefs8.0to8.1 + } + 8.0 { + FixPrefs7.6to8.0 + FixPrefs8.0to8.1 } - 7.6 {} } } +proc FixPrefs8.0to8.1 {} { + global pap + + FixVar pap(graph,ds,show) pap(show) + FixVar pap(graph,ds,smooth) pap(smooth) + FixVar pap(graph,ds,color) pap(color) + FixVar pap(graph,ds,fill) pap(fill) + FixVar pap(graph,ds,fill,color) pap(fill,color) + FixVar pap(graph,ds,width) pap(width) + FixVar pap(graph,ds,dash) pap(dash) + + FixVar pap(graph,ds,shape,symbol) pap(shape,symbol) + FixVar pap(graph,ds,shape,fill) pap(shape,fill) + FixVar pap(graph,ds,shape,color) pap(shape,color) + + FixVar pap(graph,ds,error) pap(error) + FixVar pap(graph,ds,error,color) pap(error,color) + FixVar pap(graph,ds,error,width) pap(error,width) + FixVar pap(graph,ds,error,style) pap(error,style) + + FixVar pap(graph,ds,bar,relief) pap(relief) +} + +proc FixPrefs7.6to8.0 {} { +} + proc FixPrefs7.5to7.6 {} { global smooth + set smooth(radius,minor) $smooth(radius) set smooth(sigma) [expr int($smooth(radius)/2.)] set smooth(sigma,minor) $smooth(sigma) @@ -552,6 +606,7 @@ proc FixPrefs7.3to7.4 {} { proc FixPrefs7.2to7.3 {} { global current + if {$current(mode) == {pointer}} { set current(mode) region } @@ -625,6 +680,7 @@ proc FixPrefs7.1to7.2 {} { proc FixPrefs7.0to7.1 {} { global pap + if {[info exists pap(grid)]} { set pap(grid,x) $pap(grid) set pap(grid,y) $pap(grid) diff --git a/ds9/parsers/plotparser.tac b/ds9/parsers/plotparser.tac index cbbfdbf..a2afe27 100644 --- a/ds9/parsers/plotparser.tac +++ b/ds9/parsers/plotparser.tac @@ -230,7 +230,7 @@ plotCmd : LOAD_ load | SAVE_ STRING_ {PlotCmdSave $2} # xpa/samp only | DATA_ dim {PlotCmdData $2} - | CLEAR_ {ProcessCmdCVAR0 PlotClearData} + | CLEAR_ {ProcessCmdCVAR0 PlotDeleteData} | EXPORT_ export | DUPLICATE_ duplicate # backward compatibility @@ -250,29 +250,29 @@ plotCmd : LOAD_ load | MODE_ mode {ProcessCmdCVAR mode $2 PlotChangeMode} | AXIS_ axis - | BACKGROUND_ STRING_ {PlotCmdUpdateGraph graph,bg $2} + | BACKGROUND_ STRING_ {PlotCmdUpdateGraph bg $2} | LEGEND_ legend | FONT_ fontt | TITLE_ title - | BARMODE_ barmode {PlotCmdUpdateGraph bar,mode $2} + | BARMODE_ barmode {PlotCmdUpdateCanvas bar,mode $2} - | SHOW_ yesno {PlotCmdUpdateElement show $2} + | SHOW_ yesno {PlotCmdUpdateElement graph,ds,show $2} | COLOR_ color - | FILL_ yesno {PlotCmdUpdateElement fill $2} - | FILLCOLOR_ STRING_ {PlotCmdUpdateElement fill,color $2} + | FILL_ yesno {PlotCmdUpdateElement graph,ds,fill $2} + | FILLCOLOR_ STRING_ {PlotCmdUpdateElement graph,ds,fill,color $2} | ERROR_ errorr # backward compatibility | ERRORBAR_ errorr - | NAME_ STRING_ {PlotCmdUpdateElement name $2} + | NAME_ STRING_ {PlotCmdUpdateElement graph,ds,name $2} | SHAPE_ shape - | RELIEF_ relief {PlotCmdUpdateElement bar,relief $2} - | SMOOTH_ smooth {PlotCmdUpdateElement smooth $2} - | WIDTH_ INT_ {PlotCmdUpdateElement width $2} - | DASH_ yesno {PlotCmdUpdateElement dash $2} + | RELIEF_ relief {PlotCmdUpdateElement graph,ds,bar,relief $2} + | SMOOTH_ smooth {PlotCmdUpdateElement graph,ds,smooth $2} + | WIDTH_ INT_ {PlotCmdUpdateElement graph,ds,width $2} + | DASH_ yesno {PlotCmdUpdateElement graph,ds,dash $2} - | SELECT_ INT_ {ProcessCmdCVAR data,current $2 PlotCurrentData} + | SELECT_ INT_ {PlotCmdSelectData $2} # backward compatibility - | DATASET_ INT_ {ProcessCmdCVAR data,current $2 PlotCurrentData} + | DATASET_ INT_ {PlotCmdSelectData $2} # backward compatibility | GRAPH_ oldGraph @@ -344,17 +344,17 @@ mode : POINTER_ {set _ pointer} | ZOOM_ {set _ zoom} ; -axis : xy GRID_ yesno {PlotCmdUpdateGraph "axis,$1,grid" $3} - | xy LOG_ yesno {PlotCmdUpdateGraph "axis,$1,log" $3} - | xy FLIP_ yesno {PlotCmdUpdateGraph "axis,$1,flip" $3} - | xy AUTO_ yesno {PlotCmdUpdateGraph "axis,$1,auto" $3} - | xy MIN_ numeric {PlotCmdUpdateGraph "axis,$1,min" $3} - | xy MAX_ numeric {PlotCmdUpdateGraph "axis,$1,max" $3} - | xy FORMAT_ STRING_ {PlotCmdUpdateGraph "axis,$1,format" $3} +axis : xy GRID_ yesno {PlotCmdUpdateGraph "graph,axis,$1,grid" $3} + | xy LOG_ yesno {PlotCmdUpdateGraph "graph,axis,$1,log" $3} + | xy FLIP_ yesno {PlotCmdUpdateGraph "graph,axis,$1,flip" $3} + | xy AUTO_ yesno {PlotCmdUpdateGraph "graph,axis,$1,auto" $3} + | xy MIN_ numeric {PlotCmdUpdateGraph "graph,axis,$1,min" $3} + | xy MAX_ numeric {PlotCmdUpdateGraph "graph,axis,$1,max" $3} + | xy FORMAT_ STRING_ {PlotCmdUpdateGraph "graph,axis,$1,format" $3} ; -legend : yesno {PlotCmdUpdateGraph legend $1} - | POSITION_ legendPos {PlotCmdUpdateGraph "legend,position" $2} +legend : yesno {PlotCmdUpdateGraph graph,legend $1} + | POSITION_ legendPos {PlotCmdUpdateGraph graph,legend,position $2} ; legendPos : RIGHT_ {set _ right} @@ -389,9 +389,9 @@ fontType : TITLE_ {set _ graph,title} ; title : STRING_ {PlotCmdUpdateGraph graph,title $1} - | xy STRING_ {PlotCmdUpdateGraph "axis,$1,title" $2} - | xyaxis STRING_ {PlotCmdUpdateGraph "axis,$1,title" $2} - | LEGEND_ STRING_ {PlotCmdUpdateGraph legend,title $2} + | xy STRING_ {PlotCmdUpdateGraph "graph,axis,$1,title" $2} + | xyaxis STRING_ {PlotCmdUpdateGraph "graph,axis,$1,title" $2} + | LEGEND_ STRING_ {PlotCmdUpdateGraph graph,legend,title $2} ; barmode : NORMAL_ {set _ normal} @@ -400,9 +400,9 @@ barmode : NORMAL_ {set _ normal} | OVERLAP_ {set _ overlap} ; -color : STRING_ {PlotCmdUpdateElement color $1} +color : STRING_ {PlotCmdUpdateElement graph,ds,color $1} # backward compatiabilty - | dummy1 STRING_ {PlotCmdUpdateElement color $2} + | dummy1 STRING_ {PlotCmdUpdateElement graph,ds,color $2} ; dummy1 : DISCRETE_ @@ -414,15 +414,15 @@ dummy1 : DISCRETE_ | ERRORBAR_ ; -errorr : yesno {PlotCmdUpdateElement error $1} - | CAP_ yesno {PlotCmdUpdateElement error,cap $2} - | COLOR_ STRING_ {PlotCmdUpdateElement error,color $2} - | WIDTH_ INT_ {PlotCmdUpdateElement error,width $2} +errorr : yesno {PlotCmdUpdateElement graph,ds,error $1} + | CAP_ yesno {PlotCmdUpdateElement graph,ds,error,cap $2} + | COLOR_ STRING_ {PlotCmdUpdateElement graph,ds,error,color $2} + | WIDTH_ INT_ {PlotCmdUpdateElement graph,ds,error,width $2} ; -shape : shapes {PlotCmdUpdateElement shape,symbol $1} - | FILL_ yesno {PlotCmdUpdateElement shape,file $2} - | COLOR_ STRING_ {PlotCmdUpdateElement shape,color $2} +shape : shapes {PlotCmdUpdateElement graph,ds,shape,symbol $1} + | FILL_ yesno {PlotCmdUpdateElement graph,ds,shape,file $2} + | COLOR_ STRING_ {PlotCmdUpdateElement graph,ds,shape,color $2} ; shapes : NONE_ {set _ none} @@ -454,44 +454,44 @@ smooth : STEP_ {set _ step} # backward compatibility oldGraph : GRID_ oldGraphGrid - | LOG_ xy yesno {PlotCmdUpdateGraph "axis,$2,log" $3} - | FLIP_ xy yesno {PlotCmdUpdateGraph "axis,$2,flip" $3} - | FORMAT_ xy STRING_ {PlotCmdUpdateGraph "axis,$3,format" $3} + | LOG_ xy yesno {PlotCmdUpdateGraph "graph,axis,$2,log" $3} + | FLIP_ xy yesno {PlotCmdUpdateGraph "graph,axis,$2,flip" $3} + | FORMAT_ xy STRING_ {PlotCmdUpdateGraph "graph,axis,$3,format" $3} | RANGE_ oldGraphRange | LABELS_ oldGraphLabels | TYPE_ oldGraphType | SCALE_ oldGraphScale ; -oldGraphGrid : xy yesno {PlotCmdUpdateGraph "axis,$1,grid" $2} - | yesno {PlotCmdUpdateGraph "axis,x,grid" $1; PlotCmdUpdateGraph "axis,y,grid" $1} +oldGraphGrid : xy yesno {PlotCmdUpdateGraph "graph,axis,$1,grid" $2} + | yesno {PlotCmdUpdateGraph "graph,axis,x,grid" $1; PlotCmdUpdateGraph "graph,axis,y,grid" $1} ; -oldGraphRange : xy AUTO_ yesno {PlotCmdUpdateGraph "axis,$1,auto" $3} - | xy MIN_ numeric {PlotCmdUpdateGraph "axis,$1,min" $3} - | xy MAX_ numeric {PlotCmdUpdateGraph "axis,$1,max" $3} +oldGraphRange : xy AUTO_ yesno {PlotCmdUpdateGraph "graph,axis,$1,auto" $3} + | xy MIN_ numeric {PlotCmdUpdateGraph "graph,axis,$1,min" $3} + | xy MAX_ numeric {PlotCmdUpdateGraph "graph,axis,$1,max" $3} ; oldGraphLabels : TITLE_ STRING_ {PlotCmdUpdateGraph graph,title $2} - | xyaxis STRING_ {PlotCmdUpdateGraph "axis,$1,title" $2} - | LEGEND_ STRING_ {PlotCmdUpdateGraph legend,title $2} + | xyaxis STRING_ {PlotCmdUpdateGraph "graph,axis,$1,title" $2} + | LEGEND_ STRING_ {PlotCmdUpdateGraph graph,legend,title $2} ; oldGraphType : LINE_ | BAR_ ; -oldGraphScale : LINEARLINEAR_ {PlotCmdUpdateGraph "axis,x,log" 0; PlotCmdUpdateGraph "axis,y,log" 0} - | LINEARLOG_ {PlotCmdUpdateGraph "axis,x,log" 0; PlotCmdUpdateGraph "axis,y,log" 1} - | LOGLINEAR_ {PlotCmdUpdateGraph "axis,x,log" 1; PlotCmdUpdateGraph "axis,y,log" 0} - | LOGLOG_ {PlotCmdUpdateGraph "axis,x,log" 1; PlotCmdUpdateGraph "axis,y,log" 1} +oldGraphScale : LINEARLINEAR_ {PlotCmdUpdateGraph "graph,axis,x,log" 0; PlotCmdUpdateGraph "graph,axis,y,log" 0} + | LINEARLOG_ {PlotCmdUpdateGraph "graph,axis,x,log" 0; PlotCmdUpdateGraph "graph,axis,y,log" 1} + | LOGLINEAR_ {PlotCmdUpdateGraph "graph,axis,x,log" 1; PlotCmdUpdateGraph "graph,axis,y,log" 0} + | LOGLOG_ {PlotCmdUpdateGraph "graph,axis,x,log" 1; PlotCmdUpdateGraph "graph,axis,y,log" 1} ; # backward compatibility -oldLine : DISCRETE_ shapes {PlotCmdUpdateElement shape,symbol $2} - | dummy2 WIDTH_ INT_ {PlotCmdUpdateElement width $3} - | dummy2 DASH_ yesno {PlotCmdUpdateElement dash $3} - | dummy2 STYLE_ INT_ {PlotCmdUpdateElement error $3} +oldLine : DISCRETE_ shapes {PlotCmdUpdateElement graph,ds,shape,symbol $2} + | dummy2 WIDTH_ INT_ {PlotCmdUpdateElement graph,ds,width $3} + | dummy2 DASH_ yesno {PlotCmdUpdateElement graph,ds,dash $3} + | dummy2 STYLE_ INT_ {PlotCmdUpdateElement graph,ds,error $3} ; dummy2 : LINE_ @@ -503,12 +503,12 @@ dummy2 : LINE_ ; # backward compatibility -oldView : DISCRETE_ yesno {PlotCmdUpdateElement show $2} - | LINE_ yesno {PlotCmdUpdateElement show $2; PlotCmdUpdateElement smooth linear} - | STEP_ yesno {PlotCmdUpdateElement show $2; PlotCmdUpdateElement smooth step} - | QUADRATIC_ yesno {PlotCmdUpdateElement show $2; PlotCmdUpdateElement smooth quadratic} - | ERROR_ yesno {PlotCmdUpdateElement error $2} - | ERRORBAR_ yesno {PlotCmdUpdateElement error $2} +oldView : DISCRETE_ yesno {PlotCmdUpdateElement graph,ds,show $2} + | LINE_ yesno {PlotCmdUpdateElement graph,ds,show $2; PlotCmdUpdateElement graph,ds,smooth linear} + | STEP_ yesno {PlotCmdUpdateElement graph,ds,show $2; PlotCmdUpdateElement graph,ds,smooth step} + | QUADRATIC_ yesno {PlotCmdUpdateElement graph,ds,show $2; PlotCmdUpdateElement graph,ds,smooth quadratic} + | ERROR_ yesno {PlotCmdUpdateElement graph,ds,error $2} + | ERRORBAR_ yesno {PlotCmdUpdateElement graph,ds,error $2} ; %% diff --git a/ds9/parsers/plotparser.tcl b/ds9/parsers/plotparser.tcl index def123e..1f028d7 100644 --- a/ds9/parsers/plotparser.tcl +++ b/ds9/parsers/plotparser.tcl @@ -5420,7 +5420,7 @@ proc plot::yyparse {} { 62 { set _ xyexey } 64 { PlotCmdSave $2 } 65 { PlotCmdData $2 } - 66 { ProcessCmdCVAR0 PlotClearData } + 66 { ProcessCmdCVAR0 PlotDeleteData } 70 { ProcessCmdCVAR stats $2 PlotStats } 71 { ProcessCmdCVAR stats $2 PlotStats } 72 { ProcessCmdCVAR list $2 PlotList } @@ -5428,18 +5428,18 @@ proc plot::yyparse {} { 74 { PlotCmdSaveConfig $2 } 78 { ProcessCmdCVAR0 PlotDestroy } 79 { ProcessCmdCVAR mode $2 PlotChangeMode } - 81 { PlotCmdUpdateGraph graph,bg $2 } - 85 { PlotCmdUpdateGraph bar,mode $2 } - 86 { PlotCmdUpdateElement show $2 } - 88 { PlotCmdUpdateElement fill $2 } - 89 { PlotCmdUpdateElement fill,color $2 } - 92 { PlotCmdUpdateElement name $2 } - 94 { PlotCmdUpdateElement bar,relief $2 } - 95 { PlotCmdUpdateElement smooth $2 } - 96 { PlotCmdUpdateElement width $2 } - 97 { PlotCmdUpdateElement dash $2 } - 98 { ProcessCmdCVAR data,current $2 PlotCurrentData } - 99 { ProcessCmdCVAR data,current $2 PlotCurrentData } + 81 { PlotCmdUpdateGraph bg $2 } + 85 { PlotCmdUpdateCanvas bar,mode $2 } + 86 { PlotCmdUpdateElement graph,ds,show $2 } + 88 { PlotCmdUpdateElement graph,ds,fill $2 } + 89 { PlotCmdUpdateElement graph,ds,fill,color $2 } + 92 { PlotCmdUpdateElement graph,ds,name $2 } + 94 { PlotCmdUpdateElement graph,ds,bar,relief $2 } + 95 { PlotCmdUpdateElement graph,ds,smooth $2 } + 96 { PlotCmdUpdateElement graph,ds,width $2 } + 97 { PlotCmdUpdateElement graph,ds,dash $2 } + 98 { PlotCmdSelectData $2 } + 99 { PlotCmdSelectData $2 } 102 { PlotCmdExport [ExtToFormat $1] $1 } 103 { PlotCmdExport [ExtToFormat $1] $1 } 104 { PlotCmdExport $1 $2 } @@ -5480,15 +5480,15 @@ proc plot::yyparse {} { 139 { set _ gray } 140 { set _ pointer } 141 { set _ zoom } - 142 { PlotCmdUpdateGraph "axis,$1,grid" $3 } - 143 { PlotCmdUpdateGraph "axis,$1,log" $3 } - 144 { PlotCmdUpdateGraph "axis,$1,flip" $3 } - 145 { PlotCmdUpdateGraph "axis,$1,auto" $3 } - 146 { PlotCmdUpdateGraph "axis,$1,min" $3 } - 147 { PlotCmdUpdateGraph "axis,$1,max" $3 } - 148 { PlotCmdUpdateGraph "axis,$1,format" $3 } - 149 { PlotCmdUpdateGraph legend $1 } - 150 { PlotCmdUpdateGraph "legend,position" $2 } + 142 { PlotCmdUpdateGraph "graph,axis,$1,grid" $3 } + 143 { PlotCmdUpdateGraph "graph,axis,$1,log" $3 } + 144 { PlotCmdUpdateGraph "graph,axis,$1,flip" $3 } + 145 { PlotCmdUpdateGraph "graph,axis,$1,auto" $3 } + 146 { PlotCmdUpdateGraph "graph,axis,$1,min" $3 } + 147 { PlotCmdUpdateGraph "graph,axis,$1,max" $3 } + 148 { PlotCmdUpdateGraph "graph,axis,$1,format" $3 } + 149 { PlotCmdUpdateGraph graph,legend $1 } + 150 { PlotCmdUpdateGraph graph,legend,position $2 } 151 { set _ right } 152 { set _ left } 153 { set _ top } @@ -5511,22 +5511,22 @@ proc plot::yyparse {} { 170 { set _ legend,font } 171 { set _ legend,title } 172 { PlotCmdUpdateGraph graph,title $1 } - 173 { PlotCmdUpdateGraph "axis,$1,title" $2 } - 174 { PlotCmdUpdateGraph "axis,$1,title" $2 } - 175 { PlotCmdUpdateGraph legend,title $2 } + 173 { PlotCmdUpdateGraph "graph,axis,$1,title" $2 } + 174 { PlotCmdUpdateGraph "graph,axis,$1,title" $2 } + 175 { PlotCmdUpdateGraph graph,legend,title $2 } 176 { set _ normal } 177 { set _ stacked } 178 { set _ aligned } 179 { set _ overlap } - 180 { PlotCmdUpdateElement color $1 } - 181 { PlotCmdUpdateElement color $2 } - 189 { PlotCmdUpdateElement error $1 } - 190 { PlotCmdUpdateElement error,cap $2 } - 191 { PlotCmdUpdateElement error,color $2 } - 192 { PlotCmdUpdateElement error,width $2 } - 193 { PlotCmdUpdateElement shape,symbol $1 } - 194 { PlotCmdUpdateElement shape,file $2 } - 195 { PlotCmdUpdateElement shape,color $2 } + 180 { PlotCmdUpdateElement graph,ds,color $1 } + 181 { PlotCmdUpdateElement graph,ds,color $2 } + 189 { PlotCmdUpdateElement graph,ds,error $1 } + 190 { PlotCmdUpdateElement graph,ds,error,cap $2 } + 191 { PlotCmdUpdateElement graph,ds,error,color $2 } + 192 { PlotCmdUpdateElement graph,ds,error,width $2 } + 193 { PlotCmdUpdateElement graph,ds,shape,symbol $1 } + 194 { PlotCmdUpdateElement graph,ds,shape,file $2 } + 195 { PlotCmdUpdateElement graph,ds,shape,color $2 } 196 { set _ none } 197 { set _ circle } 198 { set _ square } @@ -5547,31 +5547,31 @@ proc plot::yyparse {} { 213 { set _ cubic } 214 { set _ quadratic } 215 { set _ catrom } - 217 { PlotCmdUpdateGraph "axis,$2,log" $3 } - 218 { PlotCmdUpdateGraph "axis,$2,flip" $3 } - 219 { PlotCmdUpdateGraph "axis,$3,format" $3 } - 224 { PlotCmdUpdateGraph "axis,$1,grid" $2 } - 225 { PlotCmdUpdateGraph "axis,x,grid" $1; PlotCmdUpdateGraph "axis,y,grid" $1 } - 226 { PlotCmdUpdateGraph "axis,$1,auto" $3 } - 227 { PlotCmdUpdateGraph "axis,$1,min" $3 } - 228 { PlotCmdUpdateGraph "axis,$1,max" $3 } + 217 { PlotCmdUpdateGraph "graph,axis,$2,log" $3 } + 218 { PlotCmdUpdateGraph "graph,axis,$2,flip" $3 } + 219 { PlotCmdUpdateGraph "graph,axis,$3,format" $3 } + 224 { PlotCmdUpdateGraph "graph,axis,$1,grid" $2 } + 225 { PlotCmdUpdateGraph "graph,axis,x,grid" $1; PlotCmdUpdateGraph "graph,axis,y,grid" $1 } + 226 { PlotCmdUpdateGraph "graph,axis,$1,auto" $3 } + 227 { PlotCmdUpdateGraph "graph,axis,$1,min" $3 } + 228 { PlotCmdUpdateGraph "graph,axis,$1,max" $3 } 229 { PlotCmdUpdateGraph graph,title $2 } - 230 { PlotCmdUpdateGraph "axis,$1,title" $2 } - 231 { PlotCmdUpdateGraph legend,title $2 } - 234 { PlotCmdUpdateGraph "axis,x,log" 0; PlotCmdUpdateGraph "axis,y,log" 0 } - 235 { PlotCmdUpdateGraph "axis,x,log" 0; PlotCmdUpdateGraph "axis,y,log" 1 } - 236 { PlotCmdUpdateGraph "axis,x,log" 1; PlotCmdUpdateGraph "axis,y,log" 0 } - 237 { PlotCmdUpdateGraph "axis,x,log" 1; PlotCmdUpdateGraph "axis,y,log" 1 } - 238 { PlotCmdUpdateElement shape,symbol $2 } - 239 { PlotCmdUpdateElement width $3 } - 240 { PlotCmdUpdateElement dash $3 } - 241 { PlotCmdUpdateElement error $3 } - 248 { PlotCmdUpdateElement show $2 } - 249 { PlotCmdUpdateElement show $2; PlotCmdUpdateElement smooth linear } - 250 { PlotCmdUpdateElement show $2; PlotCmdUpdateElement smooth step } - 251 { PlotCmdUpdateElement show $2; PlotCmdUpdateElement smooth quadratic } - 252 { PlotCmdUpdateElement error $2 } - 253 { PlotCmdUpdateElement error $2 } + 230 { PlotCmdUpdateGraph "graph,axis,$1,title" $2 } + 231 { PlotCmdUpdateGraph graph,legend,title $2 } + 234 { PlotCmdUpdateGraph "graph,axis,x,log" 0; PlotCmdUpdateGraph "graph,axis,y,log" 0 } + 235 { PlotCmdUpdateGraph "graph,axis,x,log" 0; PlotCmdUpdateGraph "graph,axis,y,log" 1 } + 236 { PlotCmdUpdateGraph "graph,axis,x,log" 1; PlotCmdUpdateGraph "graph,axis,y,log" 0 } + 237 { PlotCmdUpdateGraph "graph,axis,x,log" 1; PlotCmdUpdateGraph "graph,axis,y,log" 1 } + 238 { PlotCmdUpdateElement graph,ds,shape,symbol $2 } + 239 { PlotCmdUpdateElement graph,ds,width $3 } + 240 { PlotCmdUpdateElement graph,ds,dash $3 } + 241 { PlotCmdUpdateElement graph,ds,error $3 } + 248 { PlotCmdUpdateElement graph,ds,show $2 } + 249 { PlotCmdUpdateElement graph,ds,show $2; PlotCmdUpdateElement graph,ds,smooth linear } + 250 { PlotCmdUpdateElement graph,ds,show $2; PlotCmdUpdateElement graph,ds,smooth step } + 251 { PlotCmdUpdateElement graph,ds,show $2; PlotCmdUpdateElement graph,ds,smooth quadratic } + 252 { PlotCmdUpdateElement graph,ds,error $2 } + 253 { PlotCmdUpdateElement graph,ds,error $2 } } unsetupvalues $dc # pop off tokens from the stack if normal rule diff --git a/ds9/parsers/plotsendparser.tac b/ds9/parsers/plotsendparser.tac index f731b69..a5444ba 100644 --- a/ds9/parsers/plotsendparser.tac +++ b/ds9/parsers/plotsendparser.tac @@ -76,40 +76,40 @@ plotCmd : STATS_ {ProcessSendCmdCVAR PlotStatsGenerate} | LIST_ {ProcessSendCmdCVAR PlotListGenerate} | MODE_ {ProcessSendCmdCVARGet mode} | AXIS_ axis - | BACKGROUND_ {ProcessSendCmdCVARGet graph,bg} + | BACKGROUND_ {ProcessSendCmdCVARGet bg} | LEGEND_ legend | FONT_ fontt | TITLE_ title | BARMODE_ {ProcessSendCmdCVARGet bar,mode} - | SHOW_ {ProcessSendCmdCVARYesNo show} - | COLOR_ {ProcessSendCmdCVARGet color} - | FILL_ {ProcessSendCmdCVARGet fill} - | FILLCOLOR_ {ProcessSendCmdCVARGet fill,color} + | SHOW_ {ProcessSendCmdCVARYesNo graph,ds,show} + | COLOR_ {ProcessSendCmdCVARGet graph,ds,color} + | FILL_ {ProcessSendCmdCVARGet graph,ds,fill} + | FILLCOLOR_ {ProcessSendCmdCVARGet graph,ds,fill,color} | ERROR_ errorr # backward compatibility | ERRORBAR_ errorr - | NAME_ {ProcessSendCmdCVARGet name} + | NAME_ {ProcessSendCmdCVARGet graph,ds,name} | SHAPE_ shape - | RELIEF_ {ProcessSendCmdCVARGet bar,relief} - | SMOOTH_ {ProcessSendCmdCVARGet smooth} - | WIDTH_ {ProcessSendCmdCVARGet width} - | DASH_ {ProcessSendCmdCVARYesNo dash} - | SELECT_ {ProcessSendCmdCVARGet data,current} + | RELIEF_ {ProcessSendCmdCVARGet graph,ds,bar,relief} + | SMOOTH_ {ProcessSendCmdCVARGet graph,ds,smooth} + | WIDTH_ {ProcessSendCmdCVARGet graph,ds,width} + | DASH_ {ProcessSendCmdCVARYesNo graph,ds,dash} + | SELECT_ {PlotSendCmdCVARGet data,current} # backward compatibility - | DATASET_ {ProcessSendCmdCVARGet data,current} + | DATASET_ {PlotSendCmdCVARGet data,current} ; -axis : xy GRID_ {ProcessSendCmdCVARYesNo "axis,$1,grid"} - | xy LOG_ {ProcessSendCmdCVARYesNo "axis,$1,log"} - | xy FLIP_ {ProcessSendCmdCVARYesNo "axis,$1,flip"} - | xy AUTO_ {ProcessSendCmdCVARYesNo "axis,$1,auto"} - | xy MIN_ {ProcessSendCmdCVARGet "axis,$1,min"} - | xy MAX_ {ProcessSendCmdCVARGet "axis,$1,max"} - | xy FORMAT_ {ProcessSendCmdCVARGet "axis,$1,format"} +axis : xy GRID_ {ProcessSendCmdCVARYesNo "graph,axis,$1,grid"} + | xy LOG_ {ProcessSendCmdCVARYesNo "graph,axis,$1,log"} + | xy FLIP_ {ProcessSendCmdCVARYesNo "graph,axis,$1,flip"} + | xy AUTO_ {ProcessSendCmdCVARYesNo "graph,axis,$1,auto"} + | xy MIN_ {ProcessSendCmdCVARGet "graph,axis,$1,min"} + | xy MAX_ {ProcessSendCmdCVARGet "graph,axis,$1,max"} + | xy FORMAT_ {ProcessSendCmdCVARGet "graph,axis,$1,format"} ; -legend : {ProcessSendCmdCVARYesNo legend} - | POSITION_ {ProcessSendCmdCVARGet legend,position} +legend : {ProcessSendCmdCVARYesNo graph,legend} + | POSITION_ {ProcessSendCmdCVARGet graph,legend,position} ; fontt : fontType FONT_ {ProcessSendCmdCVARGet "$1,family"} @@ -138,20 +138,20 @@ fontType : TITLE_ {set _ graph,title} ; title : {ProcessSendCmdCVARGet graph,title} - | xy {ProcessSendCmdCVARGet "axis,$1,title"} - | xyaxis {ProcessSendCmdCVARGet "axis,$1,title"} - | LEGEND_ {ProcessSendCmdCVARGet legend,title} + | xy {ProcessSendCmdCVARGet "graph,axis,$1,title"} + | xyaxis {ProcessSendCmdCVARGet "graph,axis,$1,title"} + | LEGEND_ {ProcessSendCmdCVARGet graph,legend,title} ; -errorr : {ProcessSendCmdCVARYesNo error} - | CAP_ {ProcessSendCmdCVARYesNo error,cap} - | COLOR_ {ProcessSendCmdCVARGet error,color} - | WIDTH_ {ProcessSendCmdCVARGet error,width} +errorr : {ProcessSendCmdCVARYesNo graph,ds,error} + | CAP_ {ProcessSendCmdCVARYesNo graph,ds,error,cap} + | COLOR_ {ProcessSendCmdCVARGet graph,ds,error,color} + | WIDTH_ {ProcessSendCmdCVARGet graph,ds,error,width} ; -shape : {ProcessSendCmdCVARGet shape,symbol} - | FILL_ {ProcessSendCmdCVARYesNo shape,fill} - | COLOR_ {ProcessSendCmdCVARGet shape,color} +shape : {ProcessSendCmdCVARGet graph,ds,shape,symbol} + | FILL_ {ProcessSendCmdCVARYesNo graph,ds,shape,fill} + | COLOR_ {ProcessSendCmdCVARGet graph,ds,shape,color} ; %% diff --git a/ds9/parsers/plotsendparser.tcl b/ds9/parsers/plotsendparser.tcl index 16298e7..d5fad69 100644 --- a/ds9/parsers/plotsendparser.tcl +++ b/ds9/parsers/plotsendparser.tcl @@ -1489,28 +1489,28 @@ proc plotsend::yyparse {} { 13 { ProcessSendCmdCVAR PlotStatsGenerate } 14 { ProcessSendCmdCVAR PlotListGenerate } 15 { ProcessSendCmdCVARGet mode } - 17 { ProcessSendCmdCVARGet graph,bg } + 17 { ProcessSendCmdCVARGet bg } 21 { ProcessSendCmdCVARGet bar,mode } - 22 { ProcessSendCmdCVARYesNo show } - 23 { ProcessSendCmdCVARGet color } - 24 { ProcessSendCmdCVARGet fill } - 25 { ProcessSendCmdCVARGet fill,color } - 28 { ProcessSendCmdCVARGet name } - 30 { ProcessSendCmdCVARGet bar,relief } - 31 { ProcessSendCmdCVARGet smooth } - 32 { ProcessSendCmdCVARGet width } - 33 { ProcessSendCmdCVARYesNo dash } - 34 { ProcessSendCmdCVARGet data,current } - 35 { ProcessSendCmdCVARGet data,current } - 36 { ProcessSendCmdCVARYesNo "axis,$1,grid" } - 37 { ProcessSendCmdCVARYesNo "axis,$1,log" } - 38 { ProcessSendCmdCVARYesNo "axis,$1,flip" } - 39 { ProcessSendCmdCVARYesNo "axis,$1,auto" } - 40 { ProcessSendCmdCVARGet "axis,$1,min" } - 41 { ProcessSendCmdCVARGet "axis,$1,max" } - 42 { ProcessSendCmdCVARGet "axis,$1,format" } - 43 { ProcessSendCmdCVARYesNo legend } - 44 { ProcessSendCmdCVARGet legend,position } + 22 { ProcessSendCmdCVARYesNo graph,ds,show } + 23 { ProcessSendCmdCVARGet graph,ds,color } + 24 { ProcessSendCmdCVARGet graph,ds,fill } + 25 { ProcessSendCmdCVARGet graph,ds,fill,color } + 28 { ProcessSendCmdCVARGet graph,ds,name } + 30 { ProcessSendCmdCVARGet graph,ds,bar,relief } + 31 { ProcessSendCmdCVARGet graph,ds,smooth } + 32 { ProcessSendCmdCVARGet graph,ds,width } + 33 { ProcessSendCmdCVARYesNo graph,ds,dash } + 34 { PlotSendCmdCVARGet data,current } + 35 { PlotSendCmdCVARGet data,current } + 36 { ProcessSendCmdCVARYesNo "graph,axis,$1,grid" } + 37 { ProcessSendCmdCVARYesNo "graph,axis,$1,log" } + 38 { ProcessSendCmdCVARYesNo "graph,axis,$1,flip" } + 39 { ProcessSendCmdCVARYesNo "graph,axis,$1,auto" } + 40 { ProcessSendCmdCVARGet "graph,axis,$1,min" } + 41 { ProcessSendCmdCVARGet "graph,axis,$1,max" } + 42 { ProcessSendCmdCVARGet "graph,axis,$1,format" } + 43 { ProcessSendCmdCVARYesNo graph,legend } + 44 { ProcessSendCmdCVARGet graph,legend,position } 45 { ProcessSendCmdCVARGet "$1,family" } 46 { ProcessSendCmdCVARGet "$1,family" } 47 { ProcessSendCmdCVARGet "$1,size" } @@ -1529,16 +1529,16 @@ proc plotsend::yyparse {} { 60 { set _ legend,font } 61 { set _ legend,title } 62 { ProcessSendCmdCVARGet graph,title } - 63 { ProcessSendCmdCVARGet "axis,$1,title" } - 64 { ProcessSendCmdCVARGet "axis,$1,title" } - 65 { ProcessSendCmdCVARGet legend,title } - 66 { ProcessSendCmdCVARYesNo error } - 67 { ProcessSendCmdCVARYesNo error,cap } - 68 { ProcessSendCmdCVARGet error,color } - 69 { ProcessSendCmdCVARGet error,width } - 70 { ProcessSendCmdCVARGet shape,symbol } - 71 { ProcessSendCmdCVARYesNo shape,fill } - 72 { ProcessSendCmdCVARGet shape,color } + 63 { ProcessSendCmdCVARGet "graph,axis,$1,title" } + 64 { ProcessSendCmdCVARGet "graph,axis,$1,title" } + 65 { ProcessSendCmdCVARGet graph,legend,title } + 66 { ProcessSendCmdCVARYesNo graph,ds,error } + 67 { ProcessSendCmdCVARYesNo graph,ds,error,cap } + 68 { ProcessSendCmdCVARGet graph,ds,error,color } + 69 { ProcessSendCmdCVARGet graph,ds,error,width } + 70 { ProcessSendCmdCVARGet graph,ds,shape,symbol } + 71 { ProcessSendCmdCVARYesNo graph,ds,shape,fill } + 72 { ProcessSendCmdCVARGet graph,ds,shape,color } } unsetupvalues $dc # pop off tokens from the stack if normal rule |