Changeset 971 for trunk


Ignore:
Timestamp:
Mar 29, 2008, 4:38:06 PM (16 years ago)
Author:
gah
Message:

yet another fix for isomarkers

Location:
trunk/gui/scripts
Files:
2 edited

Legend:

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

    r968 r971  
    5353        $_canvas delete $this
    5454    }
    55 
     55    public method GetVolume {} {
     56        return $_ivol
     57    }
    5658    public method GetAbsoluteValue {} {
    5759        return $_value
     
    137139                SetRelativeValue [expr {double($x-10)/($w-20)}]
    138140                $_nvobj OverIsoMarker $this $x
    139                 foreach { dataobj comp } [$_nvobj GetDataObj $_ivol] break
    140                 $_nvobj UpdateTransferFunction $dataobj $comp
     141                $_nvobj UpdateTransferFunction $_ivol
    141142            }
    142143            end {
  • trunk/gui/scripts/nanovisviewer.tcl

    r970 r971  
    7575    }
    7676    public method isconnected {}
    77     public method UpdateTransferFunction { dataobj comp }
     77    public method UpdateTransferFunction { ivol }
    7878    public method RemoveDuplicateIsoMarker { m x }
    7979    public method OverIsoMarker { m x }
     
    8787
    8888    protected method _ReceiveImage {option size}
    89     protected method _ReceiveLegend {ivol vmin vmax size}
    90     protected method _ReceiveData {args}
     89    protected method _ReceiveLegend { ivol vmin vmax size }
     90    protected method _ReceiveData { args }
    9191
    9292    protected method _rebuild {}
     
    102102    protected method _fixSettings {what {value ""}}
    103103    protected method _fixLegend {}
    104     protected method GenTransfuncData {dataobj comp}
    105104
    106105    # The following methods are only used by this class.
    107     private method _AddIsoMarker { x y }
    108     private method _InitIsoMarkers {dataobj comp}
    109     private method _HideIsoMarkers {dataobj comp}
    110     private method _ShowIsoMarkers {dataobj comp}
    111     private method _ParseMarkersOption { tag markers }
    112     private method _ParseLevelsOption { tag levels }
     106    private method _SetTransfuncData { ivol }
     107    private method _AddIsoMarker { ivol x y }
     108    private method _InitIsoMarkers { ivol }
     109    private method _HideIsoMarkers { ivol }
     110    private method _ShowIsoMarkers { ivol }
     111    private method _ParseMarkersOption { ivol markers }
     112    private method _ParseLevelsOption { ivol levels }
    113113
    114114    private variable _outbuf       ;# buffer for outgoing commands
     
    117117    private variable _all_data_objs
    118118    private variable _dims ""      ;# dimensionality of data objects
    119     private variable _obj2style    ;# maps dataobj => style settings
     119    private variable _id2style     ;# maps id => style settings
    120120    private variable _obj2ovride   ;# maps dataobj => style override
    121121    private variable _obj2id       ;# maps dataobj => volume ID in server
     
    795795    foreach key [array names _obj2id *-*] {
    796796        set state [string match $first-* $key]
    797         _send "volume state $state $_obj2id($key)"
    798         if {[info exists _obj2style($key)]} {
    799             _send "volume shading transfunc $_obj2style($key) $_obj2id($key)"
     797        set ivol $_obj2id($key)
     798        _send "volume state $state $ivol"
     799        if {[info exists _id2style($ivol)]} {
     800            _send "volume shading transfunc $_id2style($ivol) $ivol"
    800801        }
    801802    }
     
    828829            # and make sure that it's defined on the server.
    829830            #
    830             if { ![info exists _isomarkers($dataobj-$comp)] } {
    831                 _InitIsoMarkers $dataobj $comp
     831            set ivol $_obj2id($dataobj-$comp)
     832            if { ![info exists _isomarkers($ivol)] } {
     833                _InitIsoMarkers $ivol
    832834            } else {
    833                 _HideIsoMarkers $dataobj $comp
    834             }
    835             foreach {sname cmap wmap} [GenTransfuncData $dataobj $comp] break
    836             set cmdstr [list transfunc define $sname $cmap $wmap]
    837             if {![SendBytes $cmdstr] } {
     835                _HideIsoMarkers $ivol
     836            }
     837            if { ![_SetTransfuncData $ivol] } {
    838838                return
    839839            }
    840             set _obj2style($dataobj-$comp) $sname
    841840        }
    842841    }
     
    848847    foreach key [array names _obj2id *-*] {
    849848        set state [string match $first-* $key]
    850         _send "volume state $state $_obj2id($key)"
    851         if {[info exists _obj2style($key)]} {
    852             _send "volume shading transfunc $_obj2style($key) $_obj2id($key)"
     849        set ivol $_obj2id($key)
     850        _send "volume state $state $ivol"
     851        if {[info exists _id2style($ivol)]} {
     852            _send "volume shading transfunc $_id2style($ivol) $ivol"
    853853        }
    854854    }
    855855    set comp [lindex [$dataobj components] 0]
    856     _ShowIsoMarkers $first $comp
     856    _ShowIsoMarkers $_obj2id($first-$comp)
    857857    # if there are any commands in the buffer, send them now that we're done
    858858    SendBytes $_outbuf
     
    892892        set w [winfo width $c]
    893893        set h [winfo height $c]
     894        foreach { dataobj comp } $_id2obj($ivol) break
    894895        if {"" == [$c find withtag transfunc]} {
    895896            $c create image 10 10 -anchor nw \
     
    901902            $c lower transfunc
    902903            $c bind transfunc <ButtonRelease-1> \
    903                 [itcl::code $this _AddIsoMarker %x %y]
     904                [itcl::code $this _AddIsoMarker $ivol %x %y]
    904905        }
    905906        $c itemconfigure vmin -text $_limits($ivol-min)
     
    909910        $c coords vmax [expr {$w-10}] [expr {$h-8}]
    910911
    911         foreach { dataobj comp } $_id2obj($ivol) break
    912         _ShowIsoMarkers $dataobj $comp
     912        _ShowIsoMarkers $ivol
    913913    }
    914914}
     
    995995        }
    996996        set comp [lindex [$dataobj components] 0]
    997         _ShowIsoMarkers $first $comp
    998         UpdateTransferFunction $first $comp
     997        set ivol $_obj2id($first-$comp)
     998
     999        _ShowIsoMarkers $ivol
     1000        UpdateTransferFunction $ivol
    9991001
    10001002        # sync the state of slicers
     
    13131315                    set val [$inner.scales.opacity get]
    13141316                    set sval [expr { 0.01 * double($val) }]
     1317                    # FIXME: This will change when we can select the current
     1318                    #        volume.
    13151319                    set comp [lindex [$dataobj components] 0]
    13161320                    set tag $dataobj-$comp
    13171321                    set _settings($this-$tag-opacity) $sval
    1318                     UpdateTransferFunction $dataobj $comp
     1322                    UpdateTransferFunction $_obj2id($tag)
    13191323                }
    13201324            }
     
    13281332                    # Scale values between 0.00001 and 0.01000
    13291333                    set sval [expr {0.0001*double($val)}]
     1334                    # FIXME: This will change when we can select the current
     1335                    #        volume.
    13301336                    set comp [lindex [$dataobj components] 0]
    13311337                    set tag $dataobj-$comp
    13321338                    set _settings($this-$tag-thickness) $sval
    1333                     UpdateTransferFunction $dataobj $comp
     1339                    UpdateTransferFunction $_obj2id($dataobj-$comp)
    13341340                }
    13351341            }
     
    13741380    set ivol ""
    13751381
     1382    # The changes when we can select the current volume.
    13761383    set dataobj [lindex [get] 0]
    13771384    if {"" != $dataobj} {
     
    13891396
    13901397# ----------------------------------------------------------------------
    1391 # USAGE: GenTransfuncData <dataobj> <comp>
     1398# USAGE: _SetTransfuncData <ivol>
    13921399#
    13931400# Used internally to compute the colormap and alpha map used to define
     
    13951402# Returns: name {v r g b ...} {v w ...}
    13961403# ----------------------------------------------------------------------
    1397 itcl::body Rappture::NanovisViewer::GenTransfuncData {dataobj comp} {
     1404itcl::body Rappture::NanovisViewer::_SetTransfuncData { ivol } {
    13981405    array set style {
    13991406        -color rainbow
     
    14011408        -opacity 1.0
    14021409    }
     1410    foreach {dataobj comp} $_id2obj($ivol) break
    14031411    array set style [lindex [$dataobj components -style $comp] 0]
    14041412    set sname "$style(-color):$style(-levels):$style(-opacity)"
     
    14161424    append cmap "1.0 [Color2RGB $color]"
    14171425
    1418     set tag $dataobj-$comp
    1419     if { ![info exists _settings($this-$tag-opacity)] } {
    1420         set _settings($this-$tag-opacity) $style(-opacity)
    1421     }
    1422     set max $_settings($this-$tag-opacity)
     1426    set tag $this-$ivol
     1427    if { ![info exists _settings($tag-opacity)] } {
     1428        set _settings($tag-opacity) $style(-opacity)
     1429    }
     1430    set max $_settings($tag-opacity)
    14231431
    14241432    set isovalues {}
    1425     foreach m $_isomarkers($tag) {
     1433    foreach m $_isomarkers($ivol) {
    14261434        lappend isovalues [$m GetRelativeValue]
    14271435    }
     
    14311439
    14321440    set delta 0.01
    1433     if { [info exists _settings($this-$tag-thickness)]} {
    1434         set delta $_settings($this-$tag-thickness)
     1441    if { [info exists _settings($tag-thickness)]} {
     1442        set delta $_settings($tag-thickness)
    14351443    }
    14361444    set first [lindex $isovalues 0]
     
    14661474        lappend wmap 1.0 0.0
    14671475    }
    1468     return [list $sname $cmap $wmap]
     1476    set _id2style($ivol) $sname
     1477    return [_send transfunc define $sname $cmap $wmap]
    14691478}
    14701479
     
    15091518}
    15101519
    1511 itcl::body Rappture::NanovisViewer::_HideIsoMarkers {dataobj comp} {
    1512     set tag $dataobj-$comp
    1513     if { [info exists _isomarkers($tag)] } {
    1514         foreach m $_isomarkers($tag) {
     1520itcl::body Rappture::NanovisViewer::_HideIsoMarkers { ivol } {
     1521    if { [info exists _isomarkers($ivol)] } {
     1522        foreach m $_isomarkers($ivol) {
    15151523            $m Hide
    15161524        }
     
    15181526}
    15191527
    1520 itcl::body Rappture::NanovisViewer::_ShowIsoMarkers {dataobj comp} {
    1521     set tag $dataobj-$comp
     1528itcl::body Rappture::NanovisViewer::_ShowIsoMarkers { ivol } {
     1529    # Clear all markers
    15221530    foreach dataobj [array names _all_data_objs] {
    15231531        foreach comp [$dataobj components] {
    1524             _HideIsoMarkers $dataobj $comp
     1532            _HideIsoMarkers _$obj2id($dataobj-$comp)
    15251533        }
    15261534    }
    1527     if { ![info exists _isomarkers($tag)] } {
     1535    if { ![info exists _isomarkers($ivol)] } {
    15281536        return
    15291537    }
    1530     foreach m $_isomarkers($tag) {
     1538    foreach m $_isomarkers($ivol) {
    15311539        $m Show
    15321540    }
     
    15381546# marker is a relative value from 0.0 to 1.0.
    15391547#
    1540 itcl::body Rappture::NanovisViewer::_ParseLevelsOption { tag levels } {
     1548itcl::body Rappture::NanovisViewer::_ParseLevelsOption { ivol levels } {
    15411549    set c $itk_component(legend)
    1542     set ivol $_obj2id($tag)
    15431550    regsub -all "," $levels " " levels
    15441551    for {set i 1} { $i <= $levels } {incr i} {
     
    15461553        set m [IsoMarker \#auto $c $this $ivol]
    15471554        $m SetRelativeValue $x
    1548         lappend _isomarkers($tag) $m
     1555        lappend _isomarkers($ivol) $m
    15491556    }
    15501557}
     
    15621569#               not be seen.
    15631570#
    1564 itcl::body Rappture::NanovisViewer::_ParseMarkersOption {tag markers} {
     1571itcl::body Rappture::NanovisViewer::_ParseMarkersOption { ivol markers } {
    15651572    set c $itk_component(legend)
    15661573    regsub -all "," $markers " " markers
    1567     set ivol $_obj2id($tag)
    15681574    foreach marker $markers {
    15691575        set n [scan $marker "%g%s" value suffix]
     
    15731579            set m [IsoMarker \#auto $c $this $ivol]
    15741580            $m SetRelativeValue $value
    1575             lappend _isomarkers($tag) $m
     1581            lappend _isomarkers($ivol) $m
    15761582        } else {
    15771583            # ${n} : Set absolute value.
    15781584            set m [IsoMarker \#auto $c $this $ivol]
    15791585            $m SetAbsoluteValue $value
    1580             lappend _isomarkers($tag) $m
    1581         }
    1582     }
    1583 }
    1584 
    1585 itcl::body Rappture::NanovisViewer::_InitIsoMarkers {dataobj comp} {
     1586            lappend _isomarkers($ivol) $m
     1587        }
     1588    }
     1589}
     1590
     1591itcl::body Rappture::NanovisViewer::_InitIsoMarkers { ivol } {
    15861592    array set style {
    15871593        -levels 6
    15881594    }
     1595    foreach {dataobj comp} $_id2obj($ivol) break
    15891596    array set style [lindex [$dataobj components -style $comp] 0]
    1590     set tag $dataobj-$comp
     1597
    15911598    if { [info exists style(-markers)] } {
    1592         _ParseMarkersOption $tag $style(-markers)
     1599        _ParseMarkersOption $ivol $style(-markers)
    15931600    } else {
    1594         _ParseLevelsOption $tag $style(-levels)
     1601        _ParseLevelsOption $ivol $style(-levels)
    15951602    }
    15961603}
     
    16061613# legend.
    16071614# ----------------------------------------------------------------------
    1608 itcl::body Rappture::NanovisViewer::UpdateTransferFunction { dataobj comp } {
    1609     if {"" == $dataobj} {
     1615itcl::body Rappture::NanovisViewer::UpdateTransferFunction { ivol } {
     1616    if {![info exists _id2style($ivol)]} {
    16101617        return
    16111618    }
    1612     set tag $dataobj-$comp
    1613     if {![info exists _obj2style($tag)]} {
    1614         return
    1615     }
    16161619    # Compute a transfer function for the current data set.
    1617     foreach {sname cmap wmap} [GenTransfuncData $dataobj $comp] break
    1618     _send [list transfunc define $_obj2style($tag) $cmap $wmap]
    1619     _send [list volume shading transfunc $_obj2style($tag) $_obj2id($tag)]
     1620    _SetTransfuncData $ivol
     1621    _send [list volume shading transfunc $_id2style($ivol) $ivol]
    16201622    _fixLegend
    16211623}
    16221624
    1623 itcl::body Rappture::NanovisViewer::_AddIsoMarker { x y } {
    1624     set dataobj [lindex [get] 0]
    1625     if {$dataobj == ""} {
    1626         return 0;                       # No data sets defined
    1627     }
    1628     set comp [lindex [$dataobj components] 0]
    1629     set ivol $_obj2id($dataobj-$comp)
     1625itcl::body Rappture::NanovisViewer::_AddIsoMarker { ivol x y } {
    16301626    set c $itk_component(legend)
    16311627    set m [IsoMarker \#auto $c $this $ivol]
     
    16331629    $m SetRelativeValue [expr {double($x-10)/($w-20)}]
    16341630    $m Show
    1635     lappend _isomarkers($dataobj) $m
    1636     UpdateTransferFunction $dataobj $comp
     1631    lappend _isomarkers($ivol) $m
     1632    UpdateTransferFunction $ivol
    16371633    return 1
    16381634}
    16391635
    16401636itcl::body Rappture::NanovisViewer::RemoveDuplicateIsoMarker { marker x } {
    1641     set dataobj [lindex [get] 0]
    1642     if {"" == $dataobj} {
    1643         return 0
    1644     }
     1637    set ivol [$marker GetVolume]
    16451638    set bool 0
    1646     set comp [lindex [$dataobj components] 0]
    1647     if { [info exists _isomarkers($dataobj)] } {
     1639    if { [info exists _isomarkers($ivol)] } {
    16481640        set list {}
    16491641        set marker [namespace tail $marker]
    1650         foreach m $_isomarkers($dataobj) {
     1642        foreach m $_isomarkers($tag) {
    16511643            set sx [$m GetScreenPosition]
    16521644            if { $m != $marker } {
     
    16611653            lappend list $m
    16621654        }
    1663         set _isomarkers($dataobj) $list
    1664         UpdateTransferFunction $dataobj $comp
     1655        set _isomarkers($ivol) $list
     1656        UpdateTransferFunction $ivol
    16651657    }
    16661658    return $bool
     
    16681660
    16691661itcl::body Rappture::NanovisViewer::OverIsoMarker { marker x } {
    1670     set dataobj [lindex [get] 0]
    1671     if {"" == $dataobj} {
    1672         return ""
    1673     }
    1674     if { [info exists _isomarkers($dataobj)] } {
     1662    set ivol [$marker GetVolume]
     1663    if { [info exists _isomarkers($ivol)] } {
    16751664        set marker [namespace tail $marker]
    1676         foreach m $_isomarkers($dataobj) {
     1665        foreach m $_isomarkers($ivol) {
    16771666            set sx [$m GetScreenPosition]
    16781667            if { $m != $marker } {
Note: See TracChangeset for help on using the changeset viewer.