From b73e8ede35c322e24dcb24993e244a66c957e7ec Mon Sep 17 00:00:00 2001 From: William Joye Date: Fri, 30 Mar 2018 13:13:01 -0400 Subject: update ds9 contour parser --- ds9/library/contour.tcl | 189 +++++++++++++++++++++--------------------- ds9/parsers/contourparser.tac | 26 +++--- 2 files changed, 107 insertions(+), 108 deletions(-) diff --git a/ds9/library/contour.tcl b/ds9/library/contour.tcl index f35b516..59d2a91 100644 --- a/ds9/library/contour.tcl +++ b/ds9/library/contour.tcl @@ -1064,7 +1064,8 @@ proc ProcessContourCmd {varname iname} { global contour global current - + # we need to be realized + ProcessRealizeDS9 switch -- [string tolower [lindex $var $i]] { open {ContourDialog} close {ContourDestroyDialog} @@ -1086,25 +1087,26 @@ proc ProcessContourCmd {varname iname} { incr i set dash [lindex $var $i] incr i [ProcessContourFix sys sky color width dash] - - ContourCmdLoadOrg $fn $sys $sky $color $width $dash + $current(frame) contour load $color $width $dash \ + "\{$fn\}" $sys $sky } else { incr i set color [lindex $var $i] if {$color == {} || [string range $color 0 0] == "-"} { + $current(frame) contour load "\{$fn\}" incr i -1 - - ContourCmdLoad $fn } else { incr i set width [lindex $var $i] incr i set dash [FromYesNo [lindex $var $i]] - - ContourCmdLoadParam $fn $color $width $dash + $current(frame) contour load "\{$fn\}" \ + $color $width $dash } } } + FileLast contourlfbox $fn + UpdateContourDialog } save { incr i @@ -1113,7 +1115,6 @@ proc ProcessContourCmd {varname iname} { set sys [lindex $var $i] incr i set sky [lindex $var $i] - # Backward compatibility incr i set color {} @@ -1122,19 +1123,23 @@ proc ProcessContourCmd {varname iname} { incr i set dash {} incr i [ProcessContourFix sys sky color width dash] - - ContourCmdSave $fn $sys $sky + if {$fn != {}} { + $current(frame) contour save "\{$fn\}" $sys $sky + } + FileLast contoursfbox $fn } convert {Contour2Polygons} loadlevels { + ContourDialog incr i - ContourCmdLoadLevels [lindex $var $i] + ContourLoadLevelsNow [lindex $var $i] + UpdateContour } savelevels { + ContourDialog incr i - ContourCmdSaveLevels [lindex $var $i] + ContourSaveLevelsNow [lindex $var $i] } - copy {ContourCCopyDialog} paste { incr i @@ -1149,71 +1154,116 @@ proc ProcessContourCmd {varname iname} { incr i set dash [lindex $var $i] incr i [ProcessContourFix sys sky color width dash] - - ContourCmdPaste $sys $sky $color $width $dash + if {$current(frame) != {} && $contour(copy) != {}} { + set cc [$contour(copy) get contour $sys $sky] + $current(frame) contour paste cc $color $width $dash + } } color { + ContourDialog incr i - ContourCmdColor [lindex $var $i] + set contour(color) [lindex $var $i] + UpdateContour } width { + ContourDialog incr i - ContourCmdWidth [lindex $var $i] + set contour(width) [lindex $var $i] + UpdateContour } dash { + ContourDialog incr i - ContourCmdDash [FromYesNo [lindex $var $i]] + set contour(dash) [FromYesNo [lindex $var $i]] + UpdateContour } smooth { + ContourDialog incr i - ContourCmdSmooth [lindex $var $i] + set contour(smooth) [lindex $var $i] + ContourGenerateDialog + UpdateContour } method { + ContourDialog incr i - ContourCmdMethod [lindex $var $i] + set contour(method) [lindex $var $i] + ContourGenerateDialog + UpdateContour } nlevels { + ContourDialog incr i - ContourCmdNLevels [lindex $var $i] + set contour(numlevel) [lindex $var $i] + ContourGenerateDialog + UpdateContour } scale { + set contour(init,scale) 1 + ContourDialog incr i - ContourCmdScale [lindex $var $i] + set contour(scale) [string tolower [lindex $var $i]] + ContourGenerateDialog + UpdateContour } log { + set contour(init,scale) 1 + ContourDialog incr i switch -- [string tolower [lindex $var $i]] { exp { incr i - ContourCmdLog [lindex $var $i] + set contour(log) [string tolower [lindex $var $i]] } default { - ContourCmdLog [lindex $var $i] + incr i -1 + set contour(log) [string tolower [lindex $var $i]] } } + ContourGenerateDialog + UpdateContour } mode { + set contour(init,mode) 1 + ContourDialog incr i - ContourCmdMode [lindex $var $i] + set contour(mode) [lindex $var $i] + ContourModeDialog + ContourGenerateDialog + UpdateContour } scope { + set contour(init,scope) 1 + ContourDialog incr i - ContourCmdScope [lindex $var $i] + set contour(scope) [lindex $var $i] + ContourModeDialog + ContourGenerateDialog + UpdateContour } limits { - ContourCmdLimits [lindex $var [expr $i+1]] [lindex $var [expr $i+2]] - incr i 2 + set contour(init,limits) 1 + ContourDialog + incr i + set contour(min) [lindex $var $i] + incr i + set contour(max) [lindex $var $i] + ContourGenerateDialog + UpdateContour } - levels { + ContourDialog + global dcontour + $dcontour(txt) delete 1.0 end incr i - ContourCmdLevels [lindex $var $i] + $dcontour(txt) insert end [lindex $var $i] + UpdateContour } - generate { - ContourCmdGenerate + ContourDialog + ContourGenerateDialog + UpdateContour } - yes - true - on - @@ -1225,7 +1275,6 @@ proc ProcessContourCmd {varname iname} { set contour(view) [FromYesNo [lindex $var $i]] UpdateContour } - default { set contour(view) 1 UpdateContour @@ -1303,98 +1352,48 @@ proc ContourCmdPaste {sys sky color width dash} { } } -proc ContourCmdColor {color} { +proc ContourCmdSet {which value} { global contour - ContourDialog - set contour(color) $color + set contour($which) $value UpdateContour } -proc ContourCmdWidth {width} { +proc ContourCmdDialog {which value} { global contour ContourDialog - set contour(width) $width + set contour($which) $value UpdateContour } -proc ContourCmdDash {dash} { +proc ContourCmdGenerateDialog {which value} { global contour ContourDialog - set contour(dash) $dash - UpdateContour -} - -proc ContourCmdSmooth {smooth} { - global contour - - ContourDialog - set contour(smooth) $smooth - ContourGenerateDialog - UpdateContour -} - -proc ContourCmdMethod {method} { - global contour - - ContourDialog - set contour(method) $method + set contour($which) $value ContourGenerateDialog UpdateContour } -proc ContourCmdNLevels {num} { - global contour - - ContourDialog - set contour(numlevel) $num - ContourGenerateDialog - UpdateContour -} - -proc ContourCmdScale {scale} { - global contour - - set contour(init,scale) 1 - ContourDialog - - set contour(scale) $scale - ContourGenerateDialog - UpdateContour -} - -proc ContourCmdLog {exp} { +proc ContourCmdScale {which value} { global contour set contour(init,scale) 1 ContourDialog - set contour(log) $exp - ContourGenerateDialog - UpdateContour -} - -proc ContourCmdMode {mode} { - global contour - - set contour(init,mode) 1 - ContourDialog - - set contour(mode) $mode - ContourModeDialog + set contour($which) $value ContourGenerateDialog UpdateContour } -proc ContourCmdScope {scope} { +proc ContourCmdMode {which value} { global contour - set contour(init,scope) 1 + set contour(init,$which) 1 ContourDialog - set contour(scope) $scope + set contour($which) $value ContourModeDialog ContourGenerateDialog UpdateContour diff --git a/ds9/parsers/contourparser.tac b/ds9/parsers/contourparser.tac index 33f789c..a9ae784 100644 --- a/ds9/parsers/contourparser.tac +++ b/ds9/parsers/contourparser.tac @@ -58,7 +58,7 @@ command : contour | contour {yyclearin; YYACCEPT} STRING_ ; -contour : yesno {global contour; set contour(view) $1; UpdateContour} +contour : yesno {ContourCmdSet view $1} | OPEN_ {ContourDialog} | CLOSE_ {ContourDestroyDialog} | CLEAR_ {ContourOffDialog} @@ -74,16 +74,16 @@ contour : yesno {global contour; set contour(view) $1; UpdateContour} | COPY_ {ContourCCopyDialog} | PASTE_ paste - | COLOR_ STRING_ {ContourCmdColor $2} - | WIDTH_ INT_ {ContourCmdWidth $2} - | DASH_ yesno {ContourCmdDash $2} - | SMOOTH_ INT_ {ContourCmdSmooth $2} - | METHOD_ method {ContourCmdMethod $2} - | NLEVELS_ INT_ {ContourCmdNLevels $2} - | SCALE_ scale {ContourCmdScale $2} + | COLOR_ STRING_ {ContourCmdDialog color $2} + | WIDTH_ INT_ {ContourCmdDialog width $2} + | DASH_ yesno {ContourCmdDialog dash $2} + | SMOOTH_ INT_ {ContourCmdGenerateDialog smooth $2} + | METHOD_ method {ContourCmdGenerateDialog method $2} + | NLEVELS_ INT_ {ContourCmdGenerateDialog nlevel $2} + | SCALE_ scale {ContourCmdScale scale $2} | LOG_ log | MODE_ modes - | SCOPE_ scope {ContourCmdScope $2} + | SCOPE_ scope {ContourCmdMode scope $2} | LIMITS_ numeric numeric {ContourCmdLimits $2 $3} | LEVELS_ STRING_ {ContourCmdLevels $2} | GENERATE_ {ContourCmdGenerate} @@ -126,12 +126,12 @@ scale : LINEAR_ {set _ linear} | HISTEQU_ {set _ histequ} ; -log : numeric {ContourCmdLog $1} - | EXP_ numeric {ContourCmdLog $2} +log : numeric {ContourCmdScale log $1} + | EXP_ numeric {ContourCmdScale log $2} ; -modes : numeric {ContourCmdMode $1} - | mode {ContourCmdMode $1} +modes : numeric {ContourCmdMode mode $1} + | mode {ContourCmdMode mode $1} ; mode : MINMAX_ {set _ minmax} -- cgit v0.12