Changeset 4088 for trunk/gui


Ignore:
Timestamp:
Dec 18, 2013 12:51:26 PM (10 years ago)
Author:
gah
Message:

fix editor to handle current component, add binding to delete key to remove markers

Location:
trunk/gui/scripts
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/nanovisviewer.tcl

    r4075 r4088  
    105105    private method GetVolumeInfo { w }
    106106    private method HideAllMarkers {}
     107    private method AddNewMarker { x y }
    107108    private method InitComponentSettings { cname }
    108109    private method InitSettings { args }
     
    126127    private method Zoom {option}
    127128    private method ToggleVolume { tag name }
     129    private method RemoveMarker { x y }
    128130
    129131    private variable _arcball ""
     
    333335    bind $itk_component(legend) <Configure> \
    334336        [itcl::code $this EventuallyRedrawLegend]
     337    bind $itk_component(legend) <KeyPress-Delete> \
     338        [itcl::code $this RemoveMarker %x %y]
     339    bind $itk_component(legend) <Enter> \
     340        [list focus $itk_component(legend)]
    335341
    336342    # Hack around the Tk panewindow.  The problem is that the requested
     
    773779    set lx 10
    774780    set ly [expr {$h - 1}]
    775     if {"" == [$c find withtag transfunc]} {
     781    if {"" == [$c find withtag colorbar]} {
    776782        $c create image 10 10 -anchor nw \
    777             -image $_image(legend) -tags transfunc
     783            -image $_image(legend) -tags colorbar
    778784        $c create text $lx $ly -anchor sw \
    779785            -fill $itk_option(-plotforeground) -tags "limits text vmin"
     
    782788        $c create text [expr {$w/2}] $ly -anchor s \
    783789            -fill $itk_option(-plotforeground) -tags "limits text title"
    784         $c lower transfunc
     790        $c lower colorbar
     791        $c bind colorbar <ButtonRelease-1> [itcl::code $this AddNewMarker %x %y]
    785792    }
    786793
     
    14691476}
    14701477
     1478itcl::body Rappture::NanovisViewer::AddNewMarker { x y } {
     1479    if { ![info exists _transferFunctionEditors($_current)] } {
     1480        continue
     1481    }
     1482    # Add a new marker to the current transfer function
     1483    $_transferFunctionEditors($_current) newMarker $x $y normal
     1484}
     1485
     1486itcl::body Rappture::NanovisViewer::RemoveMarker { x y } {
     1487    if { ![info exists _transferFunctionEditors($_current)] } {
     1488        continue
     1489    }
     1490    # Add a new marker to the current transfer function
     1491    $_transferFunctionEditors($_current) deleteMarker $x $y
     1492}
     1493
    14711494# ----------------------------------------------------------------------
    14721495# CONFIGURATION OPTION: -plotbackground
     
    25132536    return ""
    25142537}
     2538
     2539
  • trunk/gui/scripts/transferfunctioneditor.tcl

    r3984 r4088  
    4141    private method GetScreenPosition { name }
    4242    private method LeaveTick { name }
    43     private method NewMarker { x y state }
    4443    private method SetRelativeValue  { name x }
    4544    private method GetRelativeValue  { name }
     
    6261    public method removeMarkers { list }
    6362    public method addMarkers { values }
     63    public method newMarker { x y state }
     64    public method deleteMarker { x y }
    6465    public method hideMarkers { {list {}} }
    6566    public method showMarkers { {limits {}} }
     
    7071    set _name $name
    7172    set _limits [list 0.0 1.0]
    72     $c bind transfunc <ButtonRelease-1> \
    73         [itcl::code $this NewMarker %x %y normal]
    7473    eval configure $args
    7574}
     
    9998}
    10099
    101 itcl::body Rappture::TransferFunctionEditor::NewMarker { x y state } {
     100itcl::body Rappture::TransferFunctionEditor::deleteMarker { x y } {
     101    foreach marker [GetOverlappingMarkers $x $y] {
     102        $_canvas delete $_ticks($marker)
     103        $_canvas delete $_labels($marker)
     104        array unset _ticks $marker
     105        array unset _labels $marker
     106        array unset _values $marker
     107        bell
     108        UpdateViewer
     109    }
     110}
     111
     112itcl::body Rappture::TransferFunctionEditor::newMarker { x y state } {
    102113    foreach id [$_canvas find overlapping \
    103114                    [expr $x-5] [expr $y-5] [expr $x+5] [expr $y+5]] {
     
    315326itcl::body Rappture::TransferFunctionEditor::addMarkers { values } {
    316327    foreach value $values {
    317         set name [NewMarker 0 0 hidden]
     328        set name [newMarker 0 0 hidden]
    318329        SetRelativeValue $name $value
    319330    }
  • trunk/gui/scripts/vtkvolumeviewer.tcl

    r4084 r4088  
    7070    private method GetDatasetsWithComponent { cname }
    7171    private method HideAllMarkers {}
     72    private method AddNewMarker { x y }
    7273    private method InitComponentSettings { cname }
    7374    private method ParseLevelsOption { cname levels }
     
    7879    private method SetOrientation { side }
    7980    private method SwitchComponent { cname }
     81    private method RemoveMarker { x y }
    8082
    8183    private variable _current "";       # Currently selected component
     
    382384        rename -background -plotbackground plotBackground Background
    383385    }
     386    bind $itk_component(legend) <KeyPress-Delete> \
     387        [itcl::code $this RemoveMarker %x %y]
     388    bind $itk_component(legend) <Enter> \
     389        [list focus $itk_component(legend)]
    384390
    385391    # Hack around the Tk panewindow.  The problem is that the requested
     
    22182224    set lx 10
    22192225    set ly [expr {$h - 1}]
    2220     if {"" == [$c find withtag transfunc]} {
     2226    if {"" == [$c find withtag colorbar]} {
    22212227        $c create image 10 10 -anchor nw \
    2222             -image $_image(legend) -tags transfunc
     2228            -image $_image(legend) -tags colorbar
    22232229        $c create text $lx $ly -anchor sw \
    22242230            -fill $itk_option(-plotforeground) -tags "limits text vmin"
     
    22272233        $c create text [expr {$w/2}] $ly -anchor s \
    22282234            -fill $itk_option(-plotforeground) -tags "limits text title"
    2229         $c lower transfunc
     2235        $c lower colorbar
     2236        $c bind colorbar <ButtonRelease-1> [itcl::code $this AddNewMarker %x %y]
    22302237    }
    22312238
     
    26322639}
    26332640
     2641itcl::body Rappture::VtkVolumeViewer::AddNewMarker { x y } {
     2642    if { ![info exists _transferFunctionEditors($_current)] } {
     2643        continue
     2644    }
     2645    # Add a new marker to the current transfer function
     2646    $_transferFunctionEditors($_current) newMarker $x $y normal
     2647}
     2648
     2649itcl::body Rappture::VtkVolumeViewer::RemoveMarker { x y } {
     2650    if { ![info exists _transferFunctionEditors($_current)] } {
     2651        continue
     2652    }
     2653    # Add a new marker to the current transfer function
     2654    $_transferFunctionEditors($_current) deleteMarker $x $y
     2655}
     2656
    26342657itcl::body Rappture::VtkVolumeViewer::SetOrientation { side } {
    26352658    array set positions {
Note: See TracChangeset for help on using the changeset viewer.