diff options
-rw-r--r-- | ds9/library/marker.tcl | 87 | ||||
-rw-r--r-- | ds9/parsers/regionlex.fcl | 2 | ||||
-rw-r--r-- | ds9/parsers/regionparser.tac | 67 |
3 files changed, 123 insertions, 33 deletions
diff --git a/ds9/library/marker.tcl b/ds9/library/marker.tcl index 453a9bc..f9b5618 100644 --- a/ds9/library/marker.tcl +++ b/ds9/library/marker.tcl @@ -67,6 +67,7 @@ proc MarkerDef {} { set marker(load,sky) $marker(sky) set marker(load,sock) {} set marker(load,fn) {} + set marker(tag) {} array set pmarker [array get marker] unset pmarker(copy) @@ -83,6 +84,7 @@ proc MarkerDef {} { unset pmarker(load,sky) unset pmarker(load,sock) unset pmarker(load,fn) + unset pmarker(tag) set pmarker(epsilon) 3 set pmarker(dformat) degrees @@ -1416,6 +1418,7 @@ proc ProcessRegionsCmd {varname iname sock fn} { set marker(load,format) $marker(format) set marker(load,system) $marker(system) set marker(load,sky) $marker(sky) + set marker(group,tag) {} region::YY_FLUSH_BUFFER region::yy_scan_string [lrange $var $i end] @@ -2013,9 +2016,10 @@ proc RegionCmdLoad {} { } } -proc RegionCmdLoadFn {fn all} { +proc RegionCmdLoadFn {fn {all {0}}} { global marker global ds9 + global current if {$all} { set frames $ds9(frames) @@ -2026,7 +2030,7 @@ proc RegionCmdLoadFn {fn all} { $marker(load,format) $marker(load,system) $marker(load,sky) } -proc RegionCmdSaveFn {fn} { +proc RegionCmdSave {fn} { global marker global current @@ -2052,6 +2056,85 @@ proc RegionCmdList {} { $marker(sky) $marker(skyformat) $marker(strip)] } +proc RegionCmdGroup {cmd value} { + global current + global marker + + if {$current(frame) == {} || ![$current(frame) has fits]} { + return + } + + $current(frame) marker $marker(tag) $cmd $value + UpdateGroupDialog +} + +proc RegionCmdGroupTag {tag} { + global marker + + set marker(tag) $1 +} + +proc RegionCmdGroupNew {} { + global current + global marker + + if {$current(frame) == {} || ![$current(frame) has fits]} { + return + } + + set tag $marker(tag) + if {$marker(tag) == {}} { + set tag [$current(frame) get marker tag default name] + } + $current(frame) marker tag $tag + UpdateGroupDialog +} + +proc RegionCmdGroupUpdate {} { + global current + global marker + + if {$current(frame) == {} || ![$current(frame) has fits]} { + return + } + + $current(frame) marker tag update $marker(tag) + UpdateGroupDialog +} + +proc RegionCmdTemplate {fn} { + LoadTemplateMarker $fn + FileLast templatefbox $fn +} + +proc RegionCmdTemplateAt {fn ra dec sys sky} { + LoadTemplateMarker $fn $ra $dec $sys $sky + FileLast templatefbox $fn +} + +proc RegionCmdTemplateSave {fn} { + global marker + global current + + if {$current(frame) == {} || ![$current(frame) has fits]} { + return + } + + $current(frame) marker save template $fn + FileLast templatefbox $fn +} + +proc RegionCmdCommand {cmd} { + global marker + global current + + if {$current(frame) == {} || ![$current(frame) has fits]} { + return + } + + $current(frame) marker command $marker(format) "\{$cmd\}" +} + proc ProcessSendRegionsCmd {proc id param sock fn} { global current global marker diff --git a/ds9/parsers/regionlex.fcl b/ds9/parsers/regionlex.fcl index 499a7bf..49fc5af 100644 --- a/ds9/parsers/regionlex.fcl +++ b/ds9/parsers/regionlex.fcl @@ -37,9 +37,9 @@ front {return $FRONT_} getinfo {return $GETINFO_} group {return $GROUP_} groups {return $GROUPS_} -interation {return $INTERATION_} include {return $INCLUDE_} invert {return $INVERT_} +iteration {return $ITERATION_} list {return $LIST_} load {return $LOAD_} move {return $MOVE_} diff --git a/ds9/parsers/regionparser.tac b/ds9/parsers/regionparser.tac index 698fba0..9df57d4 100644 --- a/ds9/parsers/regionparser.tac +++ b/ds9/parsers/regionparser.tac @@ -40,9 +40,9 @@ %token GETINFO_ %token GROUP_ %token GROUPS_ -%token INTERATION_ %token INCLUDE_ %token INVERT_ +%token ITERATION_ %token LIST_ %token LOAD_ %token MOVE_ @@ -120,11 +120,14 @@ command : region | region {yyclearin; YYACCEPT} STRING_ ; -region : props {RegionCmdLoad} - | LOAD_ loadall props STRING_ {RegionCmdLoadFn $4 $2} +region : {RegionCmdLoad} + | props {RegionCmdLoad} + | STRING_ {RegionCmdLoadFn $1} + | STRING_ props {RegionCmdLoadFn $1} + | LOAD_ loadall STRING_ {RegionCmdLoadFn $3 $2} # backward compatibility | FILE_ loadall STRING_ {RegionCmdLoadFn $3 $2} - | SAVE_ STRING_ {RegionCmdSaveFn $2} + | SAVE_ STRING_ {RegionCmdSave $2} | LIST_ list | EPSILON_ INT_ {PRegionCmdSet epsilon $2 MarkerEpsilon} | SHOW_ yesno {RegionCmdSet show $2 MarkerShow} @@ -142,7 +145,7 @@ region : props {RegionCmdLoad} # backward compatibility | SELECTALL_ {MarkerSelectAll} # backward compatibility - | SELECTNONE_ {MarkerSelectNone} + | SELECTNONE_ {MarkerUnSelectAll} | DELETE_ delete # backward compatibility | DELETEALL_ {MarkerDeleteAll} @@ -166,8 +169,8 @@ region : props {RegionCmdLoad} | EXCLUDE_ {RegionCmdSet include 0 [list MarkerProp include]} | SOURCE_ {RegionCmdSet source 1 [list MarkerProp source]} | BACKGROUND_ {RegionCmdSet source 0 [list MarkerProp source]} - | GROUPS_ group # waj - | GROUP_ group # waj + | GROUPS_ group + | GROUP_ group | COPY_ {MarkerCopy} | CUT_ {MarkerCut} | PASTE_ coordsys {RegionCmdSet paste,system $2 MarkerPaste} @@ -177,9 +180,9 @@ region : props {RegionCmdLoad} | UNDO_ {MarkerUndo} | COMPOSITE_ {CompositeCreate} | DISSOLVE_ {CompositeDelete} - | TEMPLATE_ template # waj - | SAVETEMPLATE_ STRING_ # waj - | COMMAND_ STRING_ # waj + | TEMPLATE_ template + | SAVETEMPLATE_ STRING_ {RegionCmdTemplateSave $2} + | COMMAND_ STRING_ {RegionCmdCommand $2} ; props : props prop @@ -205,7 +208,7 @@ list : {RegionCmdList} centroid : {MarkerCentroid} | AUTO_ yesno {RegionCmdSet centroid,auto $2 MarkerCentroidAuto} | RADIUS_ numeric {RegionCmdSet centroid,radius $2 MarkerCentroidRadius} - | INTERATION_ INT_ {RegionCmdSet centroid,iteration $2 MarkerCentroidInteration} + | ITERATION_ INT_ {RegionCmdSet centroid,iteration $2 MarkerCentroidIteration} ; move : FRONT_ {MarkerFront} @@ -213,10 +216,10 @@ move : FRONT_ {MarkerFront} ; select : ALL_ {MarkerSelectAll} - | NONE_ {MarkerSelectNone} + | NONE_ {MarkerUnselectAll} | INVERT_ {MarkerSelectInvert} # backward compatibility - | GROUP_ STRING_ # waj + | GROUP_ STRING_ {RegionCmdGroupTag $2; RegionCmdGroup select {}} ; delete : ALL_ {MarkerDeleteAll} @@ -268,25 +271,29 @@ delim : NL_ {set _ 0} | yesno {set _ $1} ; -template : STRING_ - | STRING_ AT_ numeric numeric coordsys - | STRING_ AT_ numeric numeric wcssys - | STRING_ AT_ numeric numeric wcssys skyframe +template : STRING_ {RegionCmdTemplate $1} + | STRING_ AT_ numeric numeric {RegionCmdTemplateAt $1 $3 $4 wcs fk5} + | STRING_ AT_ numeric numeric wcssys {RegionCmdTemplateAt $1 $3 $4 $5 fk5} + | STRING_ AT_ numeric numeric skyframe {RegionCmdTemplateAt $1 $3 $4 wcs $5} + | STRING_ AT_ numeric numeric wcssys skyframe {RegionCmdTemplateAt $1 $3 $4 $5 $6} ; -group : NEW_ - | STRING_ NEW_ - | STRING_ UPDATE_ - | STRING_ SELECT_ - | STRING_ COLOR_ STRING_ - | STRING_ COPY_ - | STRING_ CUT_ - | STRING_ DELETE_ - | STRING_ FONT_ - | STRING_ MOVE_ INT_ INT_ - | STRING_ MOVEFRONT_ - | STRING_ MOVEBACK_ - | STRING_ PROPERTY_ property yesno +group : NEW_ {RegionCmdGroupNew} + | STRING_ {RegionCmdGroupTag $1} groupTag + ; + +groupTag : NEW_ {RegionCmdGroupNew} + | UPDATE_ {RegionCmdGroupUpdate} + | DELETE_ {RegionCmdGroup delete {} {}} + | SELECT_ {RegionCmdGroup select {} {}} + | COLOR_ STRING_ {RegionCmdGroup select $2 {}} + | COPY_ {RegionCmdGroup copy {} {}} + | CUT_ {RegionCmdGroup paste {} {}} + | FONT_ STRING_ {RegionCmdGroup font $2 {}} + | MOVE_ INT_ INT_ {RegionCmdGroup move $2 $3} + | MOVEFRONT_ {RegionCmdGroup {move front} {} {}} + | MOVEBACK_ {RegionCmdGroup {move back} {} {}} + | PROPERTY_ property yesno {RegionCmdGroup property $2 $3} ; property : SELECT_ {set _ select} |