From 671eda8b795f09fa708fb36c5212c9b8c339eb83 Mon Sep 17 00:00:00 2001 From: William Joye Date: Mon, 18 Jun 2018 14:17:21 -0400 Subject: add ds9 frame send parser --- ds9/library/frame.tcl | 26 ++++++++++ ds9/library/source.tcl | 2 + ds9/library/util.tcl | 9 ++++ ds9/parsers/framesendlex.fcl | 40 ++++++++++++++++ ds9/parsers/framesendparser.tac | 102 ++++++++++++++++++++++++++++++++++++++++ tksao/frame/base.h | 1 + tksao/frame/basecommand.C | 5 ++ tksao/frame/parser.Y | 1 + 8 files changed, 186 insertions(+) create mode 100644 ds9/parsers/framesendlex.fcl create mode 100644 ds9/parsers/framesendparser.tac diff --git a/ds9/library/frame.tcl b/ds9/library/frame.tcl index efd630b..b1d3719 100644 --- a/ds9/library/frame.tcl +++ b/ds9/library/frame.tcl @@ -2063,6 +2063,15 @@ proc ProcessFrameCmd {varname iname} { } proc ProcessSendFrameCmd {proc id param {sock {}} {fn {}}} { + global parse + set parse(proc) $proc + set parse(id) $id + + framesend::YY_FLUSH_BUFFER + framesend::yy_scan_string $param + framesend::yyparse + return + global ds9 global current global rgb @@ -2136,6 +2145,23 @@ proc ProcessSendFrameCmd {proc id param {sock {}} {fn {}}} { } } +proc FrameSendCmd {} { + global parse + global current + $parse(proc) $parse(id) "[string range $current(frame) 5 end]\n" +} + +proc FrameSendCmdGet {which} { + global parse + global ds9 + + set rr {} + foreach ff $ds9($which) { + append rr "[string range $ff 5 end] " + } + $parse(proc) $parse(id) "$rr\n" +} + proc ProcessSingleCmd {varname iname} { upvar $varname var upvar $iname i diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl index 29e11c7..823dded 100644 --- a/ds9/library/source.tcl +++ b/ds9/library/source.tcl @@ -260,6 +260,8 @@ source $ds9(root)/library/fitsparser.tcl source $ds9(root)/library/fitslex.tcl source $ds9(root)/library/frameparser.tcl source $ds9(root)/library/framelex.tcl +source $ds9(root)/library/framesendparser.tcl +source $ds9(root)/library/framesendlex.tcl source $ds9(root)/library/gridparser.tcl source $ds9(root)/library/gridlex.tcl source $ds9(root)/library/gridsendparser.tcl diff --git a/ds9/library/util.tcl b/ds9/library/util.tcl index 04073f2..6ae250f 100644 --- a/ds9/library/util.tcl +++ b/ds9/library/util.tcl @@ -357,6 +357,15 @@ proc ProcessSendCmdCurrent2 {key cmd cmd2} { } } +proc ProcessSendCmdCurrentYesNo {key cmd} { + global parse + global current + + if {$current($key) != {}} { + $parse(proc) $parse(id) "[ToYesNo [$current($key) $cmd]]" + } +} + proc ProcessSendCmdSend {ext cmd} { global parse global current diff --git a/ds9/parsers/framesendlex.fcl b/ds9/parsers/framesendlex.fcl new file mode 100644 index 0000000..4fe5af3 --- /dev/null +++ b/ds9/parsers/framesendlex.fcl @@ -0,0 +1,40 @@ +#tab framesendparser.tab.tcl + +%{ +%} + +#include defs.fin + +%% + +active {return $ACTIVE_} +all {return $ALL_} +aux {return $AUX_} +bin {return $BIN_} +contour {return $CONTOUR_} +cube {return $CUBE_} +datamin {return $DATAMIN_} +datasec {return $DATASEC_} +equatorial {return $EQUATORIAL_} +fits {return $FITS_} +frameno {return $FRAMENO_} +grid {return $GRID_} +has {return $HAS_} +highlite {return $HIGHLITE_} +iis {return $IIS_} +irafmin {return $IRAFMIN_} +linear {return $LINEAR_} +lock {return $LOCK_} +marker {return $MARKER_} +mosaic {return $MOSAIC_} +paste {return $PASTE_} +select {return $SELECT_} +smooth {return $SMOOTH_} +system {return $SYSTEM_} +undo {return $UNDO_} + +#include coordsys.fin +#include wcssys.fin +#include ws.fin + +%% diff --git a/ds9/parsers/framesendparser.tac b/ds9/parsers/framesendparser.tac new file mode 100644 index 0000000..1efe865 --- /dev/null +++ b/ds9/parsers/framesendparser.tac @@ -0,0 +1,102 @@ +%{ +%} + +#include coordsys.tin +#include wcssys.tin + +%start framesend + +%token ACTIVE_ +%token ALL_ +%token AUX_ +%token BIN_ +%token CONTOUR_ +%token CUBE_ +%token DATAMIN_ +%token DATASEC_ +%token EQUATORIAL_ +%token FITS_ +%token FRAMENO_ +%token GRID_ +%token HAS_ +%token HIGHLITE_ +%token IIS_ +%token IRAFMIN_ +%token LINEAR_ +%token LOCK_ +%token MARKER_ +%token MOSAIC_ +%token PASTE_ +%token SELECT_ +%token SMOOTH_ +%token SYSTEM_ +%token UNDO_ + +%% + +#include coordsys.trl +#include wcssys.trl + +framesend : {FrameSendCmd} + | FRAMENO_ {FrameSendCmd} + | LOCK_ {ProcessSendCmdGet panzoom lock} + | ACTIVE_ {FrameSendCmdGet active} + | ALL_ {FrameSendCmdGet frames} + | HAS_ has + ; + +has : coordsys {ProcessSendCmdCurrentYesNo frame "has $1"} + | wcssys {ProcessSendCmdCurrentYesNo frame "has wcs $1"} + | param {ProcessSendCmdCurrentYesNo frame "has $1"} + | CONTOUR_ contour {ProcessSendCmdCurrentYesNo frame "has contour $2"} + | FITS_ fits {ProcessSendCmdCurrentYesNo frame "has fits $2"} + | MARKER_ marker {ProcessSendCmdCurrentYesNo frame "has marker $2"} + | SYSTEM_ system + | WCS_ wcs + ; + +param : IIS_ {set _ iis} + | DATAMIN_ {set _ datamin} + | IRAFMIN_ {set _ irafmin} + | DATASEC_ {set _ datasec} + | GRID_ {set _ grid} + | SMOOTH_ {set _ smooth} + ; + +contour : {set _ {}} + | AUX_ {set _ aux} + ; + +fits : {set _ {}} + | BIN_ {set _ bin} + | CUBE_ {set _ cube} + | MOSAIC_ {set _ mosaic} + ; + +marker : HIGHLITE_ {set _ highlite} + | PASTE_ {set _ paste} + | SELECT_ {set _ select} + | UNDO_ {set _ undo} + ; + +system : coordsys {ProcessSendCmdCurrentYesNo frame "has $1"} + | wcssys {ProcessSendCmdCurrentYesNo frame "has wcs $1"} + ; + +wcs : wcssys {ProcessSendCmdCurrentYesNo frame "has wcs $1"} + | wcstype wcssys {ProcessSendCmdCurrentYesNo frame "has wcs $1 $2"} + ; + +wcstype : EQUATORIAL_ {set _ equatorial} + | LINEAR_ {set _ linear} + ; + +%% + +proc framesend::yyerror {msg} { + variable yycnt + variable yy_current_buffer + variable index_ + + ParserError $msg $yycnt $yy_current_buffer $index_ +} diff --git a/tksao/frame/base.h b/tksao/frame/base.h index 73b1b12..baad9d4 100644 --- a/tksao/frame/base.h +++ b/tksao/frame/base.h @@ -720,6 +720,7 @@ public: void hasAmplifierCmd(); void hasDetectorCmd(); void hasPhysicalCmd(); + void hasImageCmd(); void hasWCSAltCmd(); void hasWCSCmd(Coord::CoordSystem); void hasWCSEquCmd(Coord::CoordSystem); diff --git a/tksao/frame/basecommand.C b/tksao/frame/basecommand.C index 69280a5..96b0d91 100644 --- a/tksao/frame/basecommand.C +++ b/tksao/frame/basecommand.C @@ -2306,6 +2306,11 @@ void Base::hasPhysicalCmd() Tcl_AppendResult(interp, "0", NULL); } +void Base::hasImageCmd() +{ + Tcl_AppendResult(interp, "1", NULL); +} + void Base::hasSmoothCmd() { if (currentContext->hasSmooth()) diff --git a/tksao/frame/parser.Y b/tksao/frame/parser.Y index 05f37e8..4415927 100644 --- a/tksao/frame/parser.Y +++ b/tksao/frame/parser.Y @@ -1339,6 +1339,7 @@ has : AMPLIFIER_ {fr->hasAmplifierCmd();} | IRAFMIN_ {fr->hasIRAFMINCmd();} | MARKER_ hasMarker | PHYSICAL_ {fr->hasPhysicalCmd();} + | IMAGE_ {fr->hasImageCmd();} | SMOOTH_ {fr->hasSmoothCmd();} | SYSTEM_ coordSystem {fr->hasSystemCmd((Coord::CoordSystem)$2);} | WCS_ hasWCS -- cgit v0.12