From 5e379797126ae52c57fa5fb8e8d3984e6a0a359e Mon Sep 17 00:00:00 2001 From: William Joye Date: Tue, 5 Jun 2018 16:08:38 -0400 Subject: add ds9 send scale, minmax, zscale parsers --- ds9/doc/ref/xpa.html | 83 +++++++++++++++++++++++++++++++++++++++- ds9/library/panzoom.tcl | 2 + ds9/library/scale.tcl | 36 +++++++++++++++-- ds9/library/source.tcl | 6 +++ ds9/parsers/minmaxsendlex.fcl | 15 ++++++++ ds9/parsers/minmaxsendparser.tac | 29 ++++++++++++++ ds9/parsers/scaleparser.tac | 7 +--- ds9/parsers/scalesendlex.fcl | 21 ++++++++++ ds9/parsers/scalesendparser.tac | 41 ++++++++++++++++++++ ds9/parsers/zscalesendlex.fcl | 14 +++++++ ds9/parsers/zscalesendparser.tac | 27 +++++++++++++ 11 files changed, 271 insertions(+), 10 deletions(-) create mode 100644 ds9/parsers/minmaxsendlex.fcl create mode 100644 ds9/parsers/minmaxsendparser.tac create mode 100644 ds9/parsers/scalesendlex.fcl create mode 100644 ds9/parsers/scalesendparser.tac create mode 100644 ds9/parsers/zscalesendlex.fcl create mode 100644 ds9/parsers/zscalesendparser.tac diff --git a/ds9/doc/ref/xpa.html b/ds9/doc/ref/xpa.html index 3f88c5a..7fc293a 100644 --- a/ds9/doc/ref/xpa.html +++ b/ds9/doc/ref/xpa.html @@ -213,6 +213,7 @@ + -p ds9 3d match
$xpaset -p ds9 3d lock yes
@@ -226,6 +227,7 @@ + -p ds9 3d open
$xpaset -p ds9 3d close
@@ -559,6 +561,7 @@ + [crosshair]

        [<ref>] [dec <col>]
@@ -677,6 +680,7 @@ + [match error <value> degrees|arcmin|arcsec]

        [<ref>] @@ -777,6 +781,7 @@ + [match function 1and2|1not2|2not1]
        [<ref>] @@ -877,6 +882,7 @@ + [match return 1and2|1only|2only]
        [<ref>] @@ -977,6 +983,7 @@ + [match unique yes|no]
        [<ref>] [maxrows <number>]
@@ -1027,6 +1034,7 @@ + [symbol shape
circle point|box point|diamond point|cross point|x point|arrow point|boxcircle point]
@@ -1135,6 +1143,7 @@ + [update]

        [<ref>] [x <col>]
@@ -1724,6 +1733,7 @@ + -p ds9 export envi foo.hdr foo.bsq little

$xpaset -p ds9 export tiff foo.tiff jpeg
@@ -2259,6 +2269,7 @@ + quality (1-100)

Syntax:
jpeg [new|slice] [<filename>] [1-100]
@@ -2678,12 +2689,14 @@
     + [new name <plotname> line|bar|scatter]

# create new plot with data from stdin
plot + [new <title> <xaxis label> <yaxis label> xy|xyex|xyey|xyexey]
@@ -2695,19 +2708,24 @@ +
[new
name + <plotname> <title> + <xaxis label> <yaxis label> xy|xyex|xyey|xyexey]
    
[new name + <plotname> line|bar|scatter + <title> <xaxis label> <yaxis label> xy|xyex|xyey|xyexey]

@@ -2718,20 +2736,24 @@     
[new + [line|bar|scatter] + stdin]
     + [new name <plotname> stdin]
     [new name <plotname> line|bar|scatter + stdin]

# load data into existing plot from @@ -2815,6 +2837,7 @@ + duplicate [#]]
     @@ -2888,6 +2911,7 @@ + [[<plotname>] stats yes|no]
    
[[<plotname>] @@ -2960,6 +2984,7 @@ + list yes|no]
    
[[<plotname>] @@ -3032,6 +3057,7 @@ + loadconfig <filename>]
     [[<plotname>] saveconfig <filename>]
@@ -3106,6 +3132,7 @@ + [[<plotname>] pagesetup orient portrait|landscape]
     [[<plotname>] pagesetup size letter|legal|tabloid|poster|a4]

@@ -3180,6 +3207,7 @@ + [[<plotname>] print]
     [[<plotname>] print destination printer|file]
@@ -3276,6 +3304,7 @@ + legend yes|no]
     [[<plotname>] legend position right|left|top|bottom]

@@ -3359,6 +3388,7 @@ + barmode normal|stacked|aligned|overlap]

# configure current dataset
@@ -3434,6 +3464,7 @@ + shape circle|square|diamond|plus|splus|scross|triangle|arrow]

     [[<plotname>] @@ -3507,6 +3538,7 @@ + shape fill yes|no]
     [[<plotname>] @@ -3583,6 +3615,7 @@ + [[<plotname>] @@ -3654,6 +3687,7 @@ + smooth step|linear|cubic|quadratic|catrom]

     @@ -3728,6 +3762,7 @@ + [[<plotname>] @@ -3799,6 +3834,7 @@ + color <value>]
     @@ -3873,6 +3909,7 @@ + [[<plotname>] @@ -3944,6 +3981,7 @@ + width <value>]
     @@ -4018,6 +4056,7 @@ + [[<plotname>] @@ -4089,6 +4128,7 @@ + dash yes|no]
     @@ -4162,6 +4202,7 @@ + [[<plotname>] @@ -4233,6 +4274,7 @@ + error yes|no]
     @@ -4306,6 +4348,7 @@ + [[<plotname>] @@ -4377,6 +4420,7 @@ + error color <value>]
     @@ -4451,6 +4495,7 @@ + [[<plotname>] @@ -4522,6 +4567,7 @@ + color <value>]
     @@ -4596,6 +4642,7 @@ + [[<plotname>] @@ -4667,6 +4714,7 @@ + error width <value>]
     @@ -4741,6 +4789,7 @@ + [[<plotname>] @@ -4812,6 +4861,7 @@ + name <string>]

@@ -4853,6 +4903,7 @@
# load + data into existing plot from stdin
$cat xy.dat | xpaset ds9 plot data xy
$cat xy.dat | xpaset ds9 plot foo data xy
@@ -4958,6 +5009,7 @@ + ds9 plot axis x min
$xpaget @@ -5030,11 +5082,13 @@ + ds9 plot axis x max
$xpaget ds9 plot axis x format
$xpaset + -p ds9 plot axis x grid yes
$xpaset -p ds9 plot axis x log yes

$xpaset -p ds9 plot axis x flip yes
@@ -5122,6 +5176,7 @@ + ds9 plot font numbers size
$xpaget @@ -5194,6 +5249,7 @@ + ds9 plot font numbers weight
$xpaget @@ -5266,10 +5322,12 @@ + ds9 plot font numbers slant
$xpaset + -p ds9 plot font numbers font times
$xpaset -p ds9 plot font numbers size 12
$xpaset -p ds9 plot font numbers weight bold
@@ -5347,6 +5405,7 @@ + ds9 plot title xaxis
$xpaget @@ -5419,10 +5478,12 @@ + ds9 plot title yaxis
$xpaset + -p ds9 plot title {This is a Title}
$xpaset -p ds9 plot title x {X Axis}
$xpaset -p ds9 plot title y {Y Axis}
@@ -5514,6 +5575,7 @@ + ds9 plot dash
$xpaget @@ -5586,6 +5648,7 @@ + ds9 plot error
$xpaget @@ -5658,6 +5721,7 @@ + ds9 plot error color
$xpaget @@ -5731,6 +5795,7 @@ + ds9 plot error width
$xpaget @@ -5804,6 +5869,7 @@ + ds9 plot name
$xpaset @@ -5876,6 +5942,7 @@ + -p ds9 plot show yes
$xpaset -p ds9 plot shape circle
$xpaset -p ds9 plot shape fill no
@@ -5919,6 +5986,7 @@ +
<dms> <arcmin> <arcsec>

@@ -6412,6 +6480,7 @@ + method.

Syntax:
saveimage
[fits|eps|gif|tiff|jpeg|png] <filename>
@@ -6440,7 +6509,7 @@
Example:
$xpaget ds9 scale
- $xpaget ds9 scale log exp
+ $xpaget ds9 scale log exp
$xpaget ds9 scale datasec
$xpaget ds9 scale limits
$xpaget ds9 scale mode
@@ -6448,7 +6517,7 @@ $xpaget ds9 scale lock
$xpaget ds9 scale lock limits
$xpaset -p ds9 scale linear
- $xpaset -p ds9 scale log 100
+ $xpaset -p ds9 scale log exp 100
$xpaset -p ds9 scale datasec yes
$xpaset -p ds9 scale histequ
$xpaset -p ds9 scale limits 1 100
@@ -6640,6 +6709,7 @@ + [sigma <value>]
       @@ -6653,6 +6723,7 @@ + [sigmaminor <value>]
       @@ -6666,6 +6737,7 @@ + [angle <value>]
    @@ -6679,6 +6751,7 @@ +    [match]
       [lock [yes|no]]

       [open|close]
@@ -6700,6 +6773,7 @@ + ds9 smooth sigmaminor
$xpaget ds9 smooth lock
@@ -6721,6 +6795,7 @@ + -p ds9 smooth sigma 2.0
$xpaset @@ -6734,6 +6809,7 @@ + -p ds9 smooth sigmaminor 2.0
$xpaset @@ -6747,6 +6823,7 @@ + -p ds9 smooth angle 45
$xpaset @@ -6760,6 +6837,7 @@ + -p ds9 smooth match
$xpaset -p ds9 smooth lock yes

$xpaset -p ds9 smooth open
@@ -6881,6 +6959,7 @@ +
compression method.

Syntax:
tiff [new|slice] [<filename>] [none|jpeg|packbits|deflate]
diff --git a/ds9/library/panzoom.tcl b/ds9/library/panzoom.tcl index b17d8a6..f885bb7 100644 --- a/ds9/library/panzoom.tcl +++ b/ds9/library/panzoom.tcl @@ -740,6 +740,7 @@ proc ProcessOrientCmd {varname iname} { proc ProcessSendOrientCmd {proc id param {sock {}} {fn {}}} { global current + $proc $id "$current(orient)\n" } @@ -758,6 +759,7 @@ proc ProcessRotateCmd {varname iname} { proc ProcessSendRotateCmd {proc id param {sock {}} {fn {}}} { global current + $proc $id "$current(rotate)\n" } diff --git a/ds9/library/scale.tcl b/ds9/library/scale.tcl index ba0fdb6..240a1ad 100644 --- a/ds9/library/scale.tcl +++ b/ds9/library/scale.tcl @@ -834,9 +834,18 @@ proc ProcessScaleCmd {varname iname} { } proc ProcessSendScaleCmd {proc id param {sock {}} {fn {}}} { + if {1} { + global parse + set parse(proc) $proc + set parse(id) $id + + scalesend::YY_FLUSH_BUFFER + scalesend::yy_scan_string $param + scalesend::yyparse + } else { + global current global scale - switch -- [string tolower $param] { lock {$proc $id [ToYesNo $scale(lock)]} {lock limits} {$proc $id [ToYesNo $scale(lock,limits)]} @@ -854,6 +863,7 @@ proc ProcessSendScaleCmd {proc id param {sock {}} {fn {}}} { default {$proc $id "$scale(type)\n"} } } +} proc ProcessMinMaxCmd {varname iname} { upvar $varname var @@ -866,8 +876,17 @@ proc ProcessMinMaxCmd {varname iname} { } proc ProcessSendMinMaxCmd {proc id param {sock {}} {fn {}}} { - global minmax + if {1} { + global parse + set parse(proc) $proc + set parse(id) $id + minmaxsend::YY_FLUSH_BUFFER + minmaxsend::yy_scan_string $param + minmaxsend::yyparse + } else { + + global minmax switch -- [string tolower $param] { mode {$proc $id "$minmax(mode)\n"} interval {$proc $id "$minmax(sample)\n"} @@ -877,6 +896,7 @@ proc ProcessSendMinMaxCmd {proc id param {sock {}} {fn {}}} { } } } +} proc ProcessZScaleCmd {varname iname} { upvar $varname var @@ -889,11 +909,21 @@ proc ProcessZScaleCmd {varname iname} { } proc ProcessSendZScaleCmd {proc id param {sock {}} {fn {}}} { - global zscale + if {1} { + global parse + set parse(proc) $proc + set parse(id) $id + + zscalesend::YY_FLUSH_BUFFER + zscalesend::yy_scan_string $param + zscalesend::yyparse + } else { + global zscale switch -- [string tolower $param] { contrast {$proc $id "$zscale(contrast)\n"} sample {$proc $id "$zscale(sample)\n"} line {$proc $id "$zscale(line)\n"} } } +} diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl index b97c6a8..6f52cac 100644 --- a/ds9/library/source.tcl +++ b/ds9/library/source.tcl @@ -268,6 +268,8 @@ source $ds9(root)/library/mecubeparser.tcl source $ds9(root)/library/mecubelex.tcl source $ds9(root)/library/minmaxparser.tcl source $ds9(root)/library/minmaxlex.tcl +source $ds9(root)/library/minmaxsendparser.tcl +source $ds9(root)/library/minmaxsendlex.tcl source $ds9(root)/library/modeparser.tcl source $ds9(root)/library/modelex.tcl source $ds9(root)/library/mosaicwcsparser.tcl @@ -338,6 +340,8 @@ source $ds9(root)/library/saveimageparser.tcl source $ds9(root)/library/saveimagelex.tcl source $ds9(root)/library/scaleparser.tcl source $ds9(root)/library/scalelex.tcl +source $ds9(root)/library/scalesendparser.tcl +source $ds9(root)/library/scalesendlex.tcl source $ds9(root)/library/sfitsparser.tcl source $ds9(root)/library/sfitslex.tcl source $ds9(root)/library/shmparser.tcl @@ -392,6 +396,8 @@ source $ds9(root)/library/xpafirstparser.tcl source $ds9(root)/library/xpafirstlex.tcl source $ds9(root)/library/zscaleparser.tcl source $ds9(root)/library/zscalelex.tcl +source $ds9(root)/library/zscalesendparser.tcl +source $ds9(root)/library/zscalesendlex.tcl source $ds9(root)/library/zoomparser.tcl source $ds9(root)/library/zoomlex.tcl diff --git a/ds9/parsers/minmaxsendlex.fcl b/ds9/parsers/minmaxsendlex.fcl new file mode 100644 index 0000000..6a33af6 --- /dev/null +++ b/ds9/parsers/minmaxsendlex.fcl @@ -0,0 +1,15 @@ +#tab minmaxsendparser.tab.tcl + +%{ +%} + +#include defs.fin + +%% + +interval {return $INTERVAL_} +mode {return $MODE_} + +#include string.fin + +%% diff --git a/ds9/parsers/minmaxsendparser.tac b/ds9/parsers/minmaxsendparser.tac new file mode 100644 index 0000000..21fe269 --- /dev/null +++ b/ds9/parsers/minmaxsendparser.tac @@ -0,0 +1,29 @@ +%{ +%} + +#include numeric.tin +#include string.tin + +%start minmaxsend + +%token INTERVAL_ +%token MODE_ + +%% + +#include numeric.trl + +minmaxsend : {ProcessSendCmdGet minmax mode} + | MODE_ {ProcessSendCmdGet minmax mode} + | INTERVAL_ {ProcessSendCmdGet minmax sample} + ; + +%% + +proc minmaxsend::yyerror {msg} { + variable yycnt + variable yy_current_buffer + variable index_ + + ParserError $msg $yycnt $yy_current_buffer $index_ +} diff --git a/ds9/parsers/scaleparser.tac b/ds9/parsers/scaleparser.tac index 7ca2bec..4a437a6 100644 --- a/ds9/parsers/scaleparser.tac +++ b/ds9/parsers/scaleparser.tac @@ -46,9 +46,10 @@ scale : OPEN_ {ScaleDialog} | MATCH_ match | LOCK_ lock | scales {ProcessCmdSet scale type $1 ChangeScale} - | LOG_ log + | LOG_ EXP_ numeric {ProcessCmdSet scale log $3 ChangeScale} | DATASEC_ yesno {ProcessCmdSet scale datasec $2 ChangeDATASEC} | LIMITS_ numeric numeric {ProcessCmdSet scale min $2 {}; ProcessCmdSet scale max $3 ChangeScaleLimit} +# backward compatibility | SCALELIMITS_ numeric numeric {ProcessCmdSet scale min $2 {}; ProcessCmdSet scale max $3 ChangeScaleLimit} | mode {ProcessCmdSet scale mode $1 ChangeScaleMode} | MODE_ mode {ProcessCmdSet scale mode $2 ChangeScaleMode} @@ -76,10 +77,6 @@ lock : yesno {ProcessCmdSet scale lock $1 LockScaleCurrent} | SCALELIMITS_ yesno {ProcessCmdSet scale lock,limits $2 LockScaleLimitsCurrent} ; -log : {ProcessCmdSet scale type log ChangeScale} - | EXP_ numeric {ProcessCmdSet scale log $2 ChangeScale} - ; - mode : numeric {set _ $1} | MINMAX_ {set _ minmax} | ZSCALE_ {set _ zscale} diff --git a/ds9/parsers/scalesendlex.fcl b/ds9/parsers/scalesendlex.fcl new file mode 100644 index 0000000..272efaf --- /dev/null +++ b/ds9/parsers/scalesendlex.fcl @@ -0,0 +1,21 @@ +#tab scalesendparser.tab.tcl + +%{ +%} + +#include defs.fin + +%% + +datasec {return $DATASEC_} +exp {return $EXP_} +limits {return $LIMITS_} +lock {return $LOCK_} +log {return $LOG_} +mode {return $MODE_} +scalelimits {return $SCALELIMITS_} +scope {return $SCOPE_} + +#include string.fin + +%% diff --git a/ds9/parsers/scalesendparser.tac b/ds9/parsers/scalesendparser.tac new file mode 100644 index 0000000..b47f4a6 --- /dev/null +++ b/ds9/parsers/scalesendparser.tac @@ -0,0 +1,41 @@ +%{ +%} + +#include string.tin + +%start scalesend + +%token DATASEC_ +%token EXP_ +%token LIMITS_ +%token LOCK_ +%token LOG_ +%token MODE_ +%token SCALELIMITS_ +%token SCOPE_ + +%% + +scalesend : {ProcessSendCmdGet scale type} + | LOCK_ {ProcessSendCmdYesNo scale lock} + | LOCK_ LIMITS_ {ProcessSendCmdYesNo scale lock,limits} + | DATASEC_ {ProcessSendCmdGet scale datasec} + | LIMITS_ {ProcessSendCmdCurrent "get clip"} +# backward compatibility + | SCALELIMITS_ {ProcessSendCmdCurrent "get clip"} + | MODE_ {ProcessSendCmdGet scale mode} + | SCOPE_ {ProcessSendCmdGet scale scope} + | LOG_ EXP_ {ProcessSendCmdGet scale log} +# backward compatibility + | LOG_ {ProcessSendCmdGet scale log} + ; + +%% + +proc scale::yyerror {msg} { + variable yycnt + variable yy_current_buffer + variable index_ + + ParserError $msg $yycnt $yy_current_buffer $index_ +} diff --git a/ds9/parsers/zscalesendlex.fcl b/ds9/parsers/zscalesendlex.fcl new file mode 100644 index 0000000..ea43480 --- /dev/null +++ b/ds9/parsers/zscalesendlex.fcl @@ -0,0 +1,14 @@ +#tab zscalesendparser.tab.tcl + +%{ +%} + +#include defs.fin + +%% + +contrast {return $CONTRAST_} +sample {return $SAMPLE_} +line {return $LINE_} + +%% diff --git a/ds9/parsers/zscalesendparser.tac b/ds9/parsers/zscalesendparser.tac new file mode 100644 index 0000000..a3ebd96 --- /dev/null +++ b/ds9/parsers/zscalesendparser.tac @@ -0,0 +1,27 @@ +%{ +%} + +#include string.tin + +%start zscalesend + +%token CONTRAST_ +%token SAMPLE_ +%token LINE_ + +%% + +zscalesend : CONTRAST_ {ProcessSendCmdGet zscale contrast} + | SAMPLE_ {ProcessSendCmdGet zscale sample} + | LINE_ {ProcessSendCmdGet zscale line} + ; + +%% + +proc zscalesend::yyerror {msg} { + variable yycnt + variable yy_current_buffer + variable index_ + + ParserError $msg $yycnt $yy_current_buffer $index_ +} -- cgit v0.12