summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-05-09 17:40:14 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-05-09 17:40:14 (GMT)
commit564e1f08a369740a5b081c0c29d88459c9ae1002 (patch)
tree8d1612660f2e751f187fe487395e3e6e60d26943
parent20f0238cf86a6819ed9071d84a4620e6b2ce5d2d (diff)
downloadblt-564e1f08a369740a5b081c0c29d88459c9ae1002.zip
blt-564e1f08a369740a5b081c0c29d88459c9ae1002.tar.gz
blt-564e1f08a369740a5b081c0c29d88459c9ae1002.tar.bz2
add ds9 photo parsers
-rw-r--r--ds9/library/array.tcl20
-rw-r--r--ds9/library/photo.tcl50
-rw-r--r--ds9/library/rgbarray.tcl20
-rw-r--r--ds9/library/source.tcl2
-rw-r--r--ds9/parsers/arrayparser.tac4
-rw-r--r--ds9/parsers/photolex.fcl15
-rw-r--r--ds9/parsers/photoparser.tac34
-rw-r--r--ds9/parsers/scaleparser.tac2
8 files changed, 123 insertions, 24 deletions
diff --git a/ds9/library/array.tcl b/ds9/library/array.tcl
index 08b7a92..3f95167 100644
--- a/ds9/library/array.tcl
+++ b/ds9/library/array.tcl
@@ -158,26 +158,6 @@ proc ArrayCmdLoad {param} {
FinishLoad
}
-proc ArrayCmdLoadRGB {param} {
- global array
-
- if {$array(load,sock) != {}} {
- # xpa
- if {![ImportRGBArraySocket $array(load,sock) $param]} {
- InitError xpa
- ImportRGBArrayFile $param
- }
- } else {
- # comm
- if {$array(load,fn) != {}} {
- ImportRGBArrayAlloc $array(load,fn) $param
- } else {
- ImportRGBArrayFile $param
- }
- }
- FinishLoad
-}
-
proc ProcessSendArrayCmd {proc id param sock fn} {
global current
diff --git a/ds9/library/photo.tcl b/ds9/library/photo.tcl
index 60d5557..5fc43f1 100644
--- a/ds9/library/photo.tcl
+++ b/ds9/library/photo.tcl
@@ -203,11 +203,22 @@ proc ProcessPhotoCmd {varname iname ch fn} {
upvar 2 $varname var
upvar 2 $iname i
+ global debug
+ if {$debug(tcl,parser)} {
+ global photo
+ set photo(load,ch) $ch
+ set photo(load,fn) $fn
+ set photo(load,mode) {}
+
+ photo::YY_FLUSH_BUFFER
+ photo::yy_scan_string [lrange $var $i end]
+ photo::yyparse
+ incr i [expr $photo::yycnt-1]
+ } else {
+
global loadParam
global current
-
set mode {}
-
switch -- [string tolower [lindex $var $i]] {
new {
incr i
@@ -248,6 +259,41 @@ proc ProcessPhotoCmd {varname iname ch fn} {
}
FinishLoad
}
+}
+
+proc PhotoCmdLoad {param} {
+ global photo
+
+ if {$photo(load,ch) != {}} {
+ # xpa
+ global tcl_platform
+ switch $tcl_platform(os) {
+ Linux -
+ Darwin -
+ SunOS {
+ if {![ImportPhotoSocket $photo(load,ch) $param $photo(load,mode)]} {
+ InitError xpa
+ ImportPhotoFile $param $photo(load,mode)
+ }
+ }
+ {Windows NT} {ImportPhotoFile $param $photo(load,mode)}
+ }
+ } else {
+ # comm
+ if {$photo(load,fn) != {}} {
+ ImportPhotoAlloc $photo(load,fn) $param $photo(load,mode)
+ } else {
+ ImportPhotoFile $param $phto(load,mode)
+ }
+ }
+ FinishLoad
+}
+
+proc PhotoCmdSet {which value} {
+ global photo
+
+ set photo($which) $value
+}
proc ProcessSendGIFCmd {proc id param ch fn} {
global current
diff --git a/ds9/library/rgbarray.tcl b/ds9/library/rgbarray.tcl
index 44054bb..1bcccc1 100644
--- a/ds9/library/rgbarray.tcl
+++ b/ds9/library/rgbarray.tcl
@@ -163,6 +163,26 @@ proc ProcessRGBArrayCmd {varname iname sock fn} {
FinishLoad
}
+proc RGBArrayCmdLoad {param} {
+ global array
+
+ if {$array(load,sock) != {}} {
+ # xpa
+ if {![ImportRGBArraySocket $array(load,sock) $param]} {
+ InitError xpa
+ ImportRGBArrayFile $param
+ }
+ } else {
+ # comm
+ if {$array(load,fn) != {}} {
+ ImportRGBArrayAlloc $array(load,fn) $param
+ } else {
+ ImportRGBArrayFile $param
+ }
+ }
+ FinishLoad
+}
+
proc ProcessSendRGBArrayCmd {proc id param sock fn} {
global current
diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl
index b7b76c1..1f1204f 100644
--- a/ds9/library/source.tcl
+++ b/ds9/library/source.tcl
@@ -264,6 +264,8 @@ source $ds9(root)/library/pagesetupparser.tcl
source $ds9(root)/library/pagesetuplex.tcl
source $ds9(root)/library/panparser.tcl
source $ds9(root)/library/panlex.tcl
+source $ds9(root)/library/photoparser.tcl
+source $ds9(root)/library/photolex.tcl
source $ds9(root)/library/pixeltableparser.tcl
source $ds9(root)/library/pixeltablelex.tcl
source $ds9(root)/library/plotparser.tcl
diff --git a/ds9/parsers/arrayparser.tac b/ds9/parsers/arrayparser.tac
index 8729a5e..da70625 100644
--- a/ds9/parsers/arrayparser.tac
+++ b/ds9/parsers/arrayparser.tac
@@ -18,8 +18,8 @@ command : array
array : opts {ArrayCmdLoad {}}
| opts STRING_ {ArrayCmdLoad $2}
# backward compatibility
- | RGB_ STRING_ {ArrayCmdLoadRGB $2}
- | NEW_ RGB_ STRING_ {CreateRGBFrame; ArrayCmdLoadRGB $3}
+ | RGB_ STRING_ {RGBArrayCmdLoad $2}
+ | NEW_ RGB_ STRING_ {CreateRGBFrame; RGBArrayCmdLoad $3}
;
opts :
diff --git a/ds9/parsers/photolex.fcl b/ds9/parsers/photolex.fcl
new file mode 100644
index 0000000..c39bd1b
--- /dev/null
+++ b/ds9/parsers/photolex.fcl
@@ -0,0 +1,15 @@
+#tab photoparser.tab.tcl
+
+%{
+%}
+
+#include defs.fin
+
+%%
+
+new {return $NEW_}
+slice {return $SLICE_}
+
+#include string.fin
+
+%%
diff --git a/ds9/parsers/photoparser.tac b/ds9/parsers/photoparser.tac
new file mode 100644
index 0000000..2cf3dc7
--- /dev/null
+++ b/ds9/parsers/photoparser.tac
@@ -0,0 +1,34 @@
+%{
+%}
+
+#include string.tin
+
+%start command
+
+%token NEW_
+%token SLICE_
+
+%%
+
+command : photo
+ | photo {yyclearin; YYACCEPT} STRING_
+ ;
+
+photo : opts {PhotoCmdLoad {}}
+ | opts STRING_ {PhotoCmdLoad $2}
+ ;
+
+opts :
+ | NEW_ {CreateFrame}
+ | SLICE_ {PhotoCmdSet load,mode slice}
+ ;
+
+%%
+
+proc photo::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 61ffc87..865f11f 100644
--- a/ds9/parsers/scaleparser.tac
+++ b/ds9/parsers/scaleparser.tac
@@ -57,10 +57,12 @@ scale : OPEN_ {ScaleDialog}
;
scales : LINEAR_ {set _ linear}
+ | LOG_ {set _ log}
| POW_ {set _ pow}
| SQRT_ {set _ sqrt}
| SQUARED_ {set _ squared}
| ASINH_ {set _ asinh}
+ | SINH_ {set _ sinh}
| HISTEQU_ {set _ histequ}
;