diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2018-08-01 20:41:49 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2018-08-01 20:41:49 (GMT) |
commit | da9158e193e4310d3550ea1ef94348bcc3210e62 (patch) | |
tree | d58a3cc4bb72180caee5f4e54810ba9c5929489d | |
parent | 8da52eb965f95813fd58cf48ddb78acdc76cad15 (diff) | |
download | blt-da9158e193e4310d3550ea1ef94348bcc3210e62.zip blt-da9158e193e4310d3550ea1ef94348bcc3210e62.tar.gz blt-da9158e193e4310d3550ea1ef94348bcc3210e62.tar.bz2 |
update slider code
-rw-r--r-- | ds9/library/cube.tcl | 125 | ||||
-rw-r--r-- | ds9/library/markeranalysisplot3d.tcl | 9 | ||||
-rw-r--r-- | ds9/library/slider.tcl | 26 |
3 files changed, 69 insertions, 91 deletions
diff --git a/ds9/library/cube.tcl b/ds9/library/cube.tcl index 0190dfc..4e1c830 100644 --- a/ds9/library/cube.tcl +++ b/ds9/library/cube.tcl @@ -14,8 +14,6 @@ proc CubeDef {} { set cube(lock) none set cube(lock,axes) 0 -# needs work, at high values, but cropped, causes problems -# set cube(format) {%.5g} # axes cnt starts at 0 set cube(axis) 2 set cube(system) wcs @@ -430,8 +428,7 @@ proc CubeDialog {} { -value $ii] set dcube(wcsentry,$ii) [ttk::entry $f.slice$ii \ -textvariable dcube(wcs,$ii) -width 10] - bind $dcube(wcsentry,$ii) <Return> \ - [list CubeApplyWCS $ii] + bind $dcube(wcsentry,$ii) <Return> [list CubeApplyWCS $ii] set dcube(slider,$ii) [slider $f.scale$ii 0 100 {} \ dcube(image,$ii) [list CubeApply $ii] 4 10] @@ -568,48 +565,61 @@ proc UpdateCubeDialog {} { } # show it - if {$naxes <= 3} { - # special chase, no checkbox - grid columnconfigure $w.param 1 -weight 1 - grid columnconfigure $w.param 2 -weight 0 - grid x $dcube(twcs) -padx 2 -pady 2 -sticky ew - switch $cube(system) { - image { - grid x $dcube(slider,2) \ - -padx 2 -pady 2 -sticky ew - } - default { - grid $dcube(wcsentry,2) $dcube(slider,2) \ - -padx 2 -pady 2 -sticky ew - } - } - } else { - grid columnconfigure $w.param 1 -weight 0 - grid columnconfigure $w.param 2 -weight 1 - grid $dcube(taxis) x $dcube(twcs) -padx 2 -pady 2 -sticky ew - for {set ii 2} {$ii<$naxes} {incr ii} { + if {[$current(frame) has fits]} { + if {$naxes <= 3} { + # special case, no checkbox + grid columnconfigure $w.param 1 -weight 1 + grid columnconfigure $w.param 2 -weight 0 + grid x $dcube(twcs) -padx 2 -pady 2 -sticky ew switch $cube(system) { image { - grid $dcube(chk,$ii) x \ - $dcube(slider,$ii) -padx 2 -pady 2 -sticky ew + grid x $dcube(slider,2) \ + -padx 2 -pady 2 -sticky ew } default { - grid $dcube(chk,$ii) $dcube(wcsentry,$ii) \ - $dcube(slider,$ii) -padx 2 -pady 2 -sticky ew + grid $dcube(wcsentry,2) $dcube(slider,2) \ + -padx 2 -pady 2 -sticky ew + } + } + } else { + grid columnconfigure $w.param 1 -weight 0 + grid columnconfigure $w.param 2 -weight 1 + grid $dcube(taxis) x $dcube(twcs) -padx 2 -pady 2 -sticky ew + for {set ii 2} {$ii<$naxes} {incr ii} { + switch $cube(system) { + image { + grid $dcube(chk,$ii) x \ + $dcube(slider,$ii) -padx 2 -pady 2 -sticky ew + } + default { + grid $dcube(chk,$ii) $dcube(wcsentry,$ii) \ + $dcube(slider,$ii) -padx 2 -pady 2 -sticky ew + } } } } + } else { + # nothing loaded, no checkbox + grid columnconfigure $w.param 1 -weight 1 + grid columnconfigure $w.param 2 -weight 0 + grid x $dcube(twcs) -padx 2 -pady 2 -sticky ew + grid x $dcube(slider,2) -padx 2 -pady 2 -sticky ew } # set intervals if {$naxes == 2} { SliderFromTo $dcube(slider,2) $dcube(from,2) $dcube(to,2) - SliderMinMax $dcube(slider,2) $dcube(from,2) $dcube(to,2) 4 + SliderMinMax $dcube(slider,2) $dcube(from,2) $dcube(to,2) 1 4 set dcube(vcoord) image } else { for {set ii 2} {$ii<$naxes} {incr ii} { + set diff [expr $dcube(to,$ii)-$dcube(from,$ii)+1] + if {$diff>4} { + set diff 4 + } SliderFromTo $dcube(slider,$ii) $dcube(from,$ii) $dcube(to,$ii) - SliderMinMax $dcube(slider,$ii) $dcube(from,wcs,$ii) $dcube(to,wcs,$ii) 4 + SliderMinMax $dcube(slider,$ii) $dcube(from,wcs,$ii) \ + $dcube(to,wcs,$ii) $diff 4 set dcube(vcoord) $cube(system) switch $cube(system) { @@ -650,10 +660,7 @@ proc UpdateCubeMotionDialog {ii} { global icube global dcube global cube - - # current frame only global current - global ds9 global debug if {$debug(tcl,update)} { @@ -665,56 +672,14 @@ proc UpdateCubeMotionDialog {ii} { if {![winfo exists $icube(top)]} { return } - - set w $icube(top) - set mb $icube(mb) - - # get number of axes - if {$current(frame) != {}} { - set naxes [$current(frame) get fits naxes] - } else { - set naxes 2 - } - - # set from/to - set depth 1 - if {$naxes == 2} { - set dcube(from,2) 1 - set dcube(to,2) 1 - set dcube(from,wcs,2) 1 - set dcube(to,wcs,2) 1 - } else { - if {$ii==2} { - # get cropped version - set ss [$current(frame) get crop 3d image] - set dcube(from,$ii) [lindex $ss 0] - set dcube(to,$ii) [lindex $ss 1] - } else { - set dcube(from,$ii) 1 - set dcube(to,$ii) [$current(frame) get fits depth $ii] - } - - set dcube(from,wcs,$ii) [$current(frame) get coordinates $dcube(from,$ii) image $cube(system) $ii] - set dcube(to,wcs,$ii) [$current(frame) get coordinates $dcube(to,$ii) image $cube(system) $ii] - } - - # set intervals - if {$naxes == 2} { - SliderFromTo $dcube(slider,2) $dcube(from,2) $dcube(to,2) - SliderMinMax $dcube(slider,2) $dcube(from,2) $dcube(to,2) 4 - } else { - SliderFromTo $dcube(slider,$ii) $dcube(from,$ii) $dcube(to,$ii) - SliderMinMax $dcube(slider,$ii) $dcube(from,wcs,$ii) $dcube(to,wcs,$ii) 4 + # current frame only + if {$current(frame) == {}} { + return } # we must do this after the scale has been configured - if {$naxes == 2} { - set dcube(image,2) 1 - set dcube(wcs,2) 1 - } else { - set dcube(image,$ii) [$current(frame) get fits slice $ii] - set dcube(wcs,$ii) [$current(frame) get coordinates $dcube(image,$ii) image $cube(system) $ii] - } + set dcube(image,$ii) [$current(frame) get fits slice $ii] + set dcube(wcs,$ii) [$current(frame) get coordinates $dcube(image,$ii) image $cube(system) $ii] } proc CubeBackup {ch which} { diff --git a/ds9/library/markeranalysisplot3d.tcl b/ds9/library/markeranalysisplot3d.tcl index e5c0dc6..988df67 100644 --- a/ds9/library/markeranalysisplot3d.tcl +++ b/ds9/library/markeranalysisplot3d.tcl @@ -230,8 +230,13 @@ proc MarkerAnalysisPlot3dSliceCB {frame id} { upvar #0 $vvarname vvar global $vvarname - set vvar(slice) [$frame get fits slice 2 $vvar(system)] - MarkerAnalysisPlot3dMarker $vvarname + # if the plot is destroyed, but marker still thinks it is good + # this routine will be called, so check first + + if {[info exists ${vvarname}(system)]} { + set vvar(slice) [$frame get fits slice 2 $vvar(system)] + MarkerAnalysisPlot3dMarker $vvarname + } } # hardcoded marker.C diff --git a/ds9/library/slider.tcl b/ds9/library/slider.tcl index fff5ac1..e62540f 100644 --- a/ds9/library/slider.tcl +++ b/ds9/library/slider.tcl @@ -15,13 +15,12 @@ proc slider {w from to label varname cmd {num {5}} {width {7}}} { ttk::label $w.label -text $label ttk::entry $w.entry -textvariable $varname -width $width - grid $w.label -sticky w -columnspan $num - grid $w.slider -row 1 -columnspan $num -padx 2 -pady 2 -sticky news - grid $w.entry -row 1 -column $num -padx 2 -pady 2 + grid $w.label -sticky w + grid $w.slider -row 1 -padx 2 -pady 2 -sticky news + grid $w.entry -row 1 -padx 2 -pady 2 for {set ii 0} {$ii<$num} {incr ii} { ttk::label $w.t$ii -width $width -anchor center - grid $w.t$ii -row 2 -column $ii grid columnconfigure $w $ii -weight 1 } @@ -32,7 +31,7 @@ proc slider {w from to label varname cmd {num {5}} {width {7}}} { bind $w.entry <Return> $cmd SliderFromTo $w $from $to - SliderMinMax $w $from $to $num + SliderMinMax $w $from $to $num $num return $w } @@ -41,12 +40,20 @@ proc SliderFromTo {w from to} { $w.slider configure -from $from -to $to } -proc SliderMinMax {w from to num} { - if {$from == $to} { - for {set ii 0} {$ii<$num} {incr ii} { +proc SliderMinMax {w from to {num 5} {max 5}} { + grid $w.label -columnspan $num + grid $w.slider -columnspan $num + grid $w.entry -column $num + + # forget all txt + for {set ii 0} {$ii<$max} {incr ii} { + if {[winfo exists $w.t$ii]} { $w.t$ii configure -text {} + grid forget $w.t$ii } - } else { + } + + if {$from != $to} { for {set ii 0} {$ii<$num} {incr ii} { set vv [expr ($to*1.-$from)/($num-1)*$ii + $from] @@ -56,6 +63,7 @@ proc SliderMinMax {w from to num} { set vv [format {%.5g} $vv] } $w.t$ii configure -text $vv + grid $w.t$ii -row 2 -column $ii } } } |