Ignore:
Timestamp:
Sep 20, 2013 1:30:29 PM (11 years ago)
Author:
gah
Message:

fix flowvisviewer for limits method in field, refactored isomarkers into transferfunctioneditor for nanovisviewer

File:
1 edited

Legend:

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

    r3930 r3940  
    7676    public method isconnected {}
    7777    public method limits { tf }
    78     public method overMarker { m x }
    7978    public method parameters {title args} {
    8079        # do nothing
    8180    }
    82     public method removeDuplicateMarker { m x }
    8381    public method scale {args}
    8482    public method updateTransferFunctions {}
    8583
    86     protected method Connect {}
    87     protected method CurrentDatasets {{what -all}}
    88     protected method Disconnect {}
    89     protected method DoResize {}
    90     protected method FixLegend {}
    91     protected method AdjustSetting {what {value ""}}
    92     protected method InitSettings { args }
    93     protected method Pan {option x y}
    94     protected method Rebuild {}
    95     protected method ReceiveData { args }
    96     protected method ReceiveImage { args }
    97     protected method ReceiveLegend { tf vmin vmax size }
    98     protected method DrawLegend { cname }
    99     protected method Rotate {option x y}
    100     protected method SendTransferFuncs {}
    101     protected method Slice {option args}
    102     protected method SlicerTip {axis}
    103     protected method Zoom {option}
    10484
    10585    # The following methods are only used by this class.
    106     private method AddIsoMarker { x y }
     86    private method AdjustSetting {what {value ""}}
    10787    private method BuildCameraTab {}
    10888    private method BuildCutplanesTab {}
    10989    private method BuildViewTab {}
     90    private method BuildVolumeComponents {}
    11091    private method BuildVolumeTab {}
     92    private method ComputeAlphamap { cname }
     93    private method ComputeTransferFunction { cname }
     94    private method Connect {}
     95    private method CurrentDatasets {{what -all}}
     96    private method Disconnect {}
     97    private method DoResize {}
     98    private method DrawLegend { cname }
     99    private method EventuallyRedrawLegend { }
     100    private method EventuallyResize { w h }
     101    private method FixLegend {}
     102    private method GetAlphamap { cname color }
     103    private method GetColormap { cname color }
     104    private method GetDatasetsWithComponent { cname }
     105    private method GetVolumeInfo { w }
     106    private method HideAllMarkers {}
     107    private method InitComponentSettings { cname }
     108    private method InitSettings { args }
     109    private method NameToAlphamap { name }
     110    private method NameTransferFunction { dataobj comp }
     111    private method Pan {option x y}
     112    private method PanCamera {}
     113    private method ParseLevelsOption { cname levels }
     114    private method ParseMarkersOption { cname markers }
     115    private method Rebuild {}
     116    private method ReceiveData { args }
     117    private method ReceiveImage { args }
     118    private method ReceiveLegend { tf vmin vmax size }
    111119    private method ResetColormap { cname color }
    112     private method ComputeTransferFunc { cname }
    113     private method EventuallyResize { w h }
    114     private method EventuallyRedrawLegend { }
    115     private method NameTransferFunc { dataobj comp }
    116     private method PanCamera {}
    117     private method ParseLevelsOption { tf levels }
    118     private method ParseMarkersOption { tf markers }
    119     private method volume { tag name }
    120     private method GetVolumeInfo { w }
     120    private method Rotate {option x y}
     121    private method SendTransferFunctions {}
    121122    private method SetOrientation { side }
    122     private method BuildVolumeComponents {}
     123    private method Slice {option args}
     124    private method SlicerTip {axis}
    123125    private method SwitchComponent { cname }
    124     private method InitComponentSettings { cname }
    125     private method GetDatasetsWithComponent { cname }
    126     private method ComputeAlphamap { cname }
    127     private method GetColormap { cname color }
    128     private method HideAllMarkers {}
     126    private method Zoom {option}
     127    private method ToggleVolume { tag name }
    129128
    130129    private variable _arcball ""
     
    135134    private variable _serverDatasets   ;# contains all the dataobj-component
    136135                                   ;# to volumes in the server
    137     private variable _serverTfs    ;# contains all the transfer functions
    138                                    ;# in the server.
    139136    private variable _recvdDatasets;    # list of data objs to send to server
    140137    private variable _dataset2style;    # maps dataobj-component to transfunc
     
    146143    private variable _limits;           # Autoscale min/max for all axes
    147144    private variable _view;             # View params for 3D view
    148     private variable _isomarkers;       # Array of isosurface level values 0..1
     145    private variable _parsedFunction
     146    private variable _transferFunctionEditors;# Array of isosurface level values 0..1
    149147    private variable  _settings
    150     # Array of transfer functions in server.  If 0 the transfer has been
    151     # defined but not loaded.  If 1 the transfer function has been named
    152     # and loaded.
    153     private variable _activeTfs
    154148    private variable _first "" ;        # This is the topmost volume.
    155149    private variable _current "";       # Currently selected component
     
    157151    private variable _componentsList   ; # Array of components found
    158152    private variable _cname2style
     153    private variable _cname2transferFunction
    159154    private variable _cname2defaultcolormap
    160155    private variable _cname2defaultalphamap
    161156
    162     # This
    163     # indicates which isomarkers and transfer
    164     # function to use when changing markers,
    165     # opacity, or thickness.
    166157    common _downloadPopup          ;# download options from popup
    167158    private common _hardcopy
     
    190181    $_dispatcher register !send_transfunc
    191182    $_dispatcher dispatch $this !send_transfunc \
    192         "[itcl::code $this SendTransferFuncs]; list"
     183        "[itcl::code $this SendTransferFunctions]; list"
    193184
    194185    # Rebuild event
     
    249240        $this-zcutposition      0
    250241        $this-zoom              $_view(zoom)   
     242        $this-volumeVisible     1
    251243    }]
    252244
     
    420412    image delete $_image(legend)
    421413    image delete $_image(download)
     414    foreach name [array names _transferFunctionEditors] {
     415        itcl::delete object $_transferFunctionEditors($cname)
     416    }
    422417    catch { blt::arcball destroy $_arcball }
    423418    array unset _settings $this-*
     
    713708
    714709# ----------------------------------------------------------------------
    715 # USAGE: SendTransferFuncs
    716 # ----------------------------------------------------------------------
    717 itcl::body Rappture::NanovisViewer::SendTransferFuncs {} {
     710# USAGE: SendTransferFunctions
     711# ----------------------------------------------------------------------
     712itcl::body Rappture::NanovisViewer::SendTransferFunctions {} {
     713    if 0 {
    718714    if { $_first == "" } {
    719715        puts stderr "first not set"
     
    735731        set cname $_dataset2style($tag)
    736732
    737         ComputeTransferFunc $cname
     733        ComputeTransferFunction $cname
    738734        SendCmd "volume shading transfunc $cname $tag"
     735    }
     736    }
     737    foreach cname [array names _volcomponents] {
     738        ComputeTransferFunction $cname
    739739    }
    740740    FixLegend
     
    785785            -fill $itk_option(-plotforeground) -tags "limits text title"
    786786        $c lower transfunc
    787         $c bind transfunc <ButtonRelease-1> \
    788             [itcl::code $this AddIsoMarker %x %y]
    789     }
    790     # Display the markers used by the active transfer function.
     787    }
     788
     789    # Display the markers used by the current transfer function.
     790    HideAllMarkers
     791    $_transferFunctionEditors($cname) showMarkers $_limits($cname)
    791792
    792793    foreach {min max} $_limits($cname) break
     
    805806    $c coords title [expr {$w/2}] $ly
    806807
    807     HideAllMarkers
    808     if { [info exists _isomarkers($cname)] } {
    809         foreach m $_isomarkers($cname) {
    810             $m visible yes
    811         }
    812     }
    813808
    814809    # The colormap may have changed. Resync the slicers with the colormap.
     
    838833#       command.  The server sends back a "legend" command invoked our
    839834#       the slave interpreter.  The purpose is to collect data of the image
    840 #       representing the legend in the canvas.  In addition, the isomarkers
    841 #       of the active transfer function are displayed.
    842 #
    843 #       I don't know is this is the right place to display the isomarkers.
    844 #       I don't know all the different paths used to draw the plot. There's
    845 #       "Rebuild", "add", etc.
     835#       representing the legend in the canvas.  In addition, the
     836#       active transfer function is displayed.
     837#
    846838#
    847839itcl::body Rappture::NanovisViewer::ReceiveLegend { cname vmin vmax size } {
     
    901893    unset _recvdDatasets($tag)
    902894    if { [array size _recvdDatasets] == 0 } {
    903         # The active transfer function is by default the first component of
    904         # the first data object.  This assumes that the data is always
    905         # successfully transferred.
    906895        updateTransferFunctions
    907896    }
     
    927916    # generates a new call to Rebuild).   
    928917    StartBufferingCommands
    929 
    930     # Hide all the isomarkers. Can't remove them. Have to remember the
    931     # settings since the user may have created/deleted/moved markers.
    932 
    933     HideAllMarkers
    934918
    935919    if { $_width != $w || $_height != $h || $_reset } {
     
    948932                        puts stderr "??? $dataobj is invalid"
    949933                    }
    950                     set data [$dataobj values $cname]
     934                    set data [$dataobj blob $cname]
     935                    if 1 {
     936                        set f [open "/tmp/values-$cname.txt" "w"]
     937                        puts $f [$dataobj values $cname]
     938                        close $f
     939                    }
    951940                } else {
    952941                    set data [$dataobj vtkdata $cname]
     
    974963                set _serverDatasets($tag) 0
    975964            }
    976             NameTransferFunc $dataobj $cname
     965            NameTransferFunction $dataobj $cname
    977966        }
    978967    }
     
    13381327            SendCmd "volume data state $_settings($this-volume) $datasets"
    13391328        }
     1329        "volumeVisible" {
     1330            set _settings($_current-volumeVisible) \
     1331                $_settings($this-volumeVisible)
     1332            foreach tag [GetDatasetsWithComponent $_current] {
     1333                SendCmd "volume data state $_settings($this-volumeVisible) $tag"
     1334            }
     1335        }
    13401336        "cutplaneVisible" {
    13411337            set bool $_settings($this-$what)
     
    13771373    set h [expr {[winfo height $itk_component(legend)]-20-$lineht}]
    13781374    if {$w > 0 && $h > 0 && $_first != "" } {
    1379         if { [info exists _cname2style($_current)] } {
     1375        if { [info exists _cname2transferFunction($_current)] } {
    13801376            SendCmd "legend $_current $w $h"
    13811377        }
     
    13841380
    13851381#
    1386 # NameTransferFunc --
     1382# NameTransferFunction --
    13871383#
    13881384#       Creates a transfer function name based on the <style> settings in the
     
    13921388#       server parses the 3D data and sends back the limits via ReceiveData.]
    13931389#
    1394 #       FIXME: The current way we generate transfer-function names completely
    1395 #              ignores the -markers option.  The problem is that we are forced
    1396 #              to compute the name from an increasing complex set of values:
    1397 #              color, levels, marker, opacity.  I think we're stuck doing it
    1398 #              now.
    1399 #
    1400 itcl::body Rappture::NanovisViewer::NameTransferFunc { dataobj cname } {
     1390itcl::body Rappture::NanovisViewer::NameTransferFunction { dataobj cname } {
    14011391    array set style {
    14021392        -color BCGYR
     
    14071397    set tag $dataobj-$cname
    14081398    array set style [lindex [$dataobj components -style $cname] 0]
    1409     if { ![info exists _cname2style($cname)] } {
     1399    if { ![info exists _cname2transferFunction($cname)] } {
    14101400        # Get the colormap right now, since it doesn't change with marker
    14111401        # changes.
    14121402        set cmap [ColorsToColormap $style(-color)]
    1413         set wmap [ComputeAlphamap $cname];# Default alphamap is a linear ramp.
    1414         set _cname2style($cname) [list $cmap $wmap]
     1403        set wmap [list 0.0 0.0 1.0 1.0]
     1404        set _cname2transferFunction($cname) [list $cmap $wmap]
    14151405        SendCmd [list transfunc define $cname $cmap $wmap]
     1406    }
     1407    SendCmd "volume shading transfunc $cname $tag"
     1408    if { ![info exists _transferFunctionEditors($cname)] } {
     1409        set _transferFunctionEditors($cname) \
     1410            [Rappture::TransferFunctionEditor ::\#auto $itk_component(legend) \
     1411                 $cname \
     1412                 -command [itcl::code $this updateTransferFunctions]]
    14161413    }
    14171414    set _dataset2style($tag) $cname
     
    14211418
    14221419#
    1423 # ComputeTransferFunc --
    1424 #
    1425 #   Computes and sends the transfer function to the render server.  It's
    1426 #   assumed that the volume data limits are known and that the global
    1427 #   transfer-functions slider values have been set up.  Both parts are
    1428 #   needed to compute the relative value (location) of the marker, and
    1429 #   the alpha map of the transfer function.
    1430 #
    1431 itcl::body Rappture::NanovisViewer::ComputeTransferFunc { cname } {
    1432     array set style {
    1433         -color BCGYR
    1434         -levels 6
    1435         -opacity 1.0
    1436         -markers ""
    1437     }
    1438     foreach {cmap wmap} $_cname2style($cname) break
    1439 
    1440     # Update the style
    1441    
    1442     foreach {dataobj cname} [split [lindex $_style2datasets($cname) 0] -] break
    1443     array set style [lindex [$dataobj components -style $cname] 0]
     1420# ComputeTransferFunction --
     1421#
     1422#       Computes and sends the transfer function to the render server.  It's
     1423#       assumed that the volume data limits are known and that the global
     1424#       transfer-functions slider values have been set up.  Both parts are
     1425#       needed to compute the relative value (location) of the marker, and
     1426#       the alpha map of the transfer function.
     1427#
     1428itcl::body Rappture::NanovisViewer::ComputeTransferFunction { cname } {
     1429    foreach {cmap wmap} $_cname2transferFunction($cname) break
    14441430
    14451431    # We have to parse the style attributes for a volume using this
     
    14491435    # of the volumes (the first in the list) using the transfer-function as a
    14501436    # reference.
    1451     #
    1452     # FIXME: The current way we generate transfer-function names completely
    1453     #        ignores the -markers option.  The problem is that we are forced
    1454     #        to compute the name from an increasing complex set of values:
    1455     #        color, levels, marker, opacity.  I think the cow's out of the
    1456     #        barn on this one.
    1457     if { ![info exists _isomarkers($cname)] } {
     1437    if { ![info exists _parsedFunction($cname)] } {
     1438        array set style {
     1439            -color BCGYR
     1440            -levels 6
     1441            -opacity 1.0
     1442            -markers ""
     1443        }
     1444        # Accumulate the style from all the datasets using it.
     1445        foreach tag [GetDatasetsWithComponent $cname] {
     1446            foreach {dataobj cname} [split [lindex $tag 0] -] break
     1447            array set style [lindex [$dataobj components -style $cname] 0]
     1448        }
     1449        eval $_transferFunctionEditors($cname) limits $_limits($cname)
    14581450        # Have to defer creation of isomarkers until we have data limits
    14591451        if { [info exists style(-markers)] &&
     
    14631455            ParseLevelsOption $cname $style(-levels)
    14641456        }
     1457       
    14651458    }
    14661459    set wmap [ComputeAlphamap $cname]
    1467     set _cname2style($cname) [list $cmap $wmap]
     1460    set _cname2transferFunction($cname) [list $cmap $wmap]
    14681461    SendCmd [list transfunc define $cname $cmap $wmap]
    14691462}
     
    15161509itcl::body Rappture::NanovisViewer::ParseLevelsOption { cname levels } {
    15171510    set c $itk_component(legend)
     1511    set list {}
    15181512    regsub -all "," $levels " " levels
    15191513    if {[string is int $levels]} {
    15201514        for {set i 1} { $i <= $levels } {incr i} {
    1521             set x [expr {double($i)/($levels+1)}]
    1522             set m [Rappture::IsoMarker \#auto $c $this $cname]
    1523             $m relval $x
    1524             lappend _isomarkers($cname) $m
     1515            lappend list [expr {double($i)/($levels+1)}]
    15251516        }
    15261517    } else {
    15271518        foreach x $levels {
    1528             set m [Rappture::IsoMarker \#auto $c $this $cname]
    1529             $m relval $x
    1530             lappend _isomarkers($cname) $m
    1531         }
    1532     }
     1519            lappend list $x
     1520        }
     1521    }
     1522    set _parsedFunction($cname) 1
     1523    $_transferFunctionEditors($cname) addMarkers $list
    15331524}
    15341525
     
    15471538itcl::body Rappture::NanovisViewer::ParseMarkersOption { cname markers } {
    15481539    set c $itk_component(legend)
     1540    set list {}
     1541    foreach { min max } $_limits($cname) break
    15491542    regsub -all "," $markers " " markers
    15501543    foreach marker $markers {
    15511544        set n [scan $marker "%g%s" value suffix]
    15521545        if { $n == 2 && $suffix == "%" } {
    1553             # ${n}% : Set relative value.
    1554             set value [expr {$value * 0.01}]
    1555             set m [Rappture::IsoMarker \#auto $c $this $cname]
    1556             $m relval $value
    1557             lappend _isomarkers($cname) $m
     1546            # $n% : Set relative value (0..1).
     1547            lappend list [expr {$value * 0.01}]
    15581548        } else {
    1559             # ${n} : Set absolute value.
    1560             set m [Rappture::IsoMarker \#auto $c $this $cname]
    1561             $m absval $value
    1562             lappend _isomarkers($cname) $m
    1563         }
    1564     }
     1549            # $n : absolute value, compute relative
     1550            lappend list  [expr {(double($value)-$min)/($max-$min)]}
     1551        }
     1552    }
     1553    set _parsedFunction($cname) 1
     1554    $_transferFunctionEditors($cname) addMarkers $list
    15651555}
    15661556
     
    15701560itcl::body Rappture::NanovisViewer::updateTransferFunctions {} {
    15711561    $_dispatcher event -idle !send_transfunc
    1572 }
    1573 
    1574 itcl::body Rappture::NanovisViewer::AddIsoMarker { x y } {
    1575     if { $_first == "" } {
    1576         error "active transfer function isn't set"
    1577     }
    1578     set tag [lindex [CurrentDatasets] 0]
    1579     set cname $_current
    1580     set c $itk_component(legend)
    1581     set m [Rappture::IsoMarker \#auto $c $this $cname]
    1582     set w [winfo width $c]
    1583     $m relval [expr {double($x-10)/($w-20)}]
    1584     lappend _isomarkers($cname) $m
    1585     updateTransferFunctions
    1586     return 1
    1587 }
    1588 
    1589 itcl::body Rappture::NanovisViewer::removeDuplicateMarker { marker x } {
    1590     set bool 0
    1591     if { [info exists _isomarkers($_current)] } {
    1592         set list {}
    1593         set marker [namespace tail $marker]
    1594         foreach m $_isomarkers($_current) {
    1595             set sx [$m screenpos]
    1596             if { $m != $marker } {
    1597                 if { $x >= ($sx-3) && $x <= ($sx+3) } {
    1598                     $marker relval [$m relval]
    1599                     itcl::delete object $m
    1600                     bell
    1601                     set bool 1
    1602                     continue
    1603                 }
    1604             }
    1605             lappend list $m
    1606         }
    1607         set _isomarkers($_current) $list
    1608         updateTransferFunctions
    1609     }
    1610     return $bool
    1611 }
    1612 
    1613 itcl::body Rappture::NanovisViewer::overMarker { marker x } {
    1614     if { [info exists _isomarkers($_current)] } {
    1615         set marker [namespace tail $marker]
    1616         foreach m $_isomarkers($_current) {
    1617             set sx [$m screenpos]
    1618             if { $m != $marker } {
    1619                 set bool [expr { $x >= ($sx-3) && $x <= ($sx+3) }]
    1620                 $m activate $bool
    1621             }
    1622         }
    1623     }
    1624     return ""
    16251562}
    16261563
     
    17371674    label $inner.shading_l -text "Lighting" -font "Arial 9 bold"
    17381675
    1739     checkbutton $inner.light2side -text "Two-sided lighting" -font $font \
     1676    checkbutton $inner.light2side \
     1677        -text "Two-sided lighting" \
     1678        -font $font \
    17401679        -variable [itcl::scope _settings($this-light2side)] \
    17411680        -command [itcl::code $this AdjustSetting light2side]
    17421681
    1743     label $inner.ambient_l -text "Ambient" -font $font
     1682    checkbutton $inner.visibility \
     1683        -text "Visible" \
     1684        -font $font \
     1685        -variable [itcl::scope _settings($this-volumeVisible)] \
     1686        -command [itcl::code $this AdjustSetting volumeVisible] \
     1687
     1688    label $inner.ambient_l \
     1689        -text "Ambient" \
     1690        -font $font
    17441691    ::scale $inner.ambient -from 0 -to 100 -orient horizontal \
    17451692        -variable [itcl::scope _settings($this-ambient)] \
     
    18261773        5,2 $inner.specularExponent          -cspan 3 -fill x \
    18271774        6,1 $inner.light2side -cspan 3 -anchor w \
    1828         7,0 $inner.tf -anchor w              -cspan 5 \
    1829         8,1 $inner.transp_l -anchor e -pady 2 \
    1830         8,2 $inner.transp                    -cspan 3 -fill x \
    1831         9,1 $inner.colormap_l       -anchor e \
    1832         9,2 $inner.colormap                  -cspan 3 -fill x \
    1833         10,1 $inner.thin             -anchor e \
    1834         10,2 $inner.thickness                 -cspan 2 -fill x \
    1835         10,4 $inner.thick -anchor w 
     1775        7,1 $inner.visibility -cspan 3 -anchor w \
     1776        8,0 $inner.tf -anchor w              -cspan 5 \
     1777        9,1 $inner.transp_l -anchor e -pady 2 \
     1778        9,2 $inner.transp                    -cspan 3 -fill x \
     1779        10,1 $inner.colormap_l       -anchor e \
     1780        10,2 $inner.colormap                  -cspan 3 -fill x \
     1781        11,1 $inner.thin             -anchor e \
     1782        11,2 $inner.thickness                 -cspan 2 -fill x \
     1783        11,4 $inner.thick -anchor w 
    18361784
    18371785    blt::table configure $inner c* r* -resize none
    18381786    blt::table configure $inner r* -pady { 2 0 }
    1839     blt::table configure $inner c2 c3 r11 -resize expand
     1787    blt::table configure $inner c2 c3 r12 -resize expand
    18401788    blt::table configure $inner c0 -width .1i
    18411789}
     
    21292077            -variable [itcl::scope _settings($this-volume-$name)] \
    21302078            -onvalue 0 -offvalue 1 \
    2131             -command [itcl::code $this volume $key $name] \
     2079            -command [itcl::code $this ToggleVolume $key $name] \
    21322080            -font "Arial 9"
    21332081        Rappture::Tooltip::for $inner.vol$row $info(description)
     
    21442092}
    21452093
    2146 itcl::body Rappture::NanovisViewer::volume { tag name } {
     2094itcl::body Rappture::NanovisViewer::ToggleVolume { tag name } {
    21472095    set bool $_settings($this-volume-$name)
    2148     SendCmd "volume statue $bool $name"
     2096    SendCmd "volume state $bool $name"
    21492097}
    21502098
     
    21862134        $cname-thickness         350
    21872135        $cname-transp            50
     2136        $cname-volumeVisible     1
    21882137    }]
    21892138}
     
    22052154    set _settings($this-thickness)        $_settings($cname-thickness)
    22062155    set _settings($this-transp)           $_settings($cname-transp)
     2156    set _settings($this-volumeVisible)    $_settings($cname-volumeVisible)
    22072157    $itk_component(colormap) value        $_settings($cname-colormap)
    22082158    set _current $cname;                # Reset the current component
     
    22342184}
    22352185
     2186#
     2187# HideAllMarkers --
     2188#
     2189#       Hide all the markers.  Can't simply delete and recreate markers
     2190#       from the <style> since the user may have create, deleted, or moved
     2191#       markers.
     2192#
    22362193itcl::body Rappture::NanovisViewer::HideAllMarkers {} {
    2237     foreach key [array names _isomarkers] {
    2238         foreach m $_isomarkers($key) {
    2239             $m visible no
    2240         }
     2194    foreach cname [array names _transferFunctionEditors] {
     2195        $_transferFunctionEditors($cname) hideMarkers
    22412196    }
    22422197}
     
    22492204}
    22502205
     2206itcl::body Rappture::NanovisViewer::GetAlphamap { cname name } {
     2207    if { $name == "default" } {
     2208        return $_cname2defaultalphamap($cname)
     2209    }
     2210    return [NameToAlphamap $name]
     2211}
     2212
    22512213itcl::body Rappture::NanovisViewer::ResetColormap { cname color } {
    22522214    # Get the current transfer function
    2253     if { ![info exists _cname2style($cname)] } {
     2215    if { ![info exists _cname2transferFunction($cname)] } {
    22542216        return
    22552217    }
    2256     foreach { cmap wmap } $_cname2style($cname) break
     2218    foreach { cmap wmap } $_cname2transferFunction($cname) break
    22572219    set cmap [GetColormap $cname $color]
    2258     set _cname2style($cname) [list $cmap $wmap]
     2220    set _cname2transferFunction($cname) [list $cmap $wmap]
    22592221    SendCmd [list transfunc define $cname $cmap $wmap]
    22602222    EventuallyRedrawLegend
     
    22622224
    22632225itcl::body Rappture::NanovisViewer::ComputeAlphamap { cname } {
    2264     if { ![info exists _isomarkers($cname)] } {
     2226    if { ![info exists _transferFunctionEditors($cname)] } {
    22652227        return [list 0.0 0.0 1.0 1.0]
    22662228    }
     
    22702232    set max 1.0 ;                       #$_settings($tag-opacity)
    22712233
    2272     set isovalues {}
    2273     foreach m $_isomarkers($cname) {
    2274         lappend isovalues [$m relval]
    2275     }
    2276     # Sort the isovalues
    2277     set isovalues [lsort -real $isovalues]
     2234    set isovalues [$_transferFunctionEditors($cname) values]
    22782235
    22792236    # Ensure that the global opacity and thickness settings (in the slider
     
    23282285}
    23292286
     2287
     2288itcl::body Rappture::NanovisViewer::NameToAlphamap { name } {
     2289    switch -- $name {
     2290        "ramp-up" {
     2291            set wmap {
     2292                0.0 0.0
     2293                1.0 1.0
     2294            }
     2295        }
     2296        "ramp-down" {
     2297            set wmap {
     2298                0.0 1.0
     2299                1.0 0.0
     2300            }
     2301        }
     2302        "vee" {
     2303            set wmap {
     2304                0.0 1.0
     2305                0.5 0.0
     2306                1.0 1.0
     2307            }
     2308        }
     2309        "tent-1" {
     2310            set wmap {
     2311                0.0 0.0
     2312                0.5 1.0
     2313                1.0 0.0
     2314            }
     2315        }
     2316        "tent-2" {
     2317            set wmap {
     2318                0.0 0.0
     2319                0.25 1.0
     2320                0.5 0.0
     2321                0.75 1.0
     2322                1.0 0.0
     2323            }
     2324        }
     2325        "tent-3" {
     2326            set wmap {
     2327                0.0 0.0
     2328                0.16666 1.0
     2329                0.33333 0.0
     2330                0.5     1.0
     2331                0.66666 0.0
     2332                0.83333 1.0
     2333                1.0 0.0
     2334            }
     2335        }
     2336        "tent-4" {
     2337            set wmap {
     2338                0.0     0.0
     2339                0.125   1.0
     2340                0.25    0.0
     2341                0.375   1.0
     2342                0.5     0.0       
     2343                0.625   1.0
     2344                0.75    0.0
     2345                0.875   1.0
     2346                1.0     0.0
     2347            }
     2348        }
     2349        "sinusoid-1" {
     2350            set wmap {
     2351                0.0                     0.000 0.600 0.800
     2352                0.14285714285714285     0.400 0.900 1.000
     2353                0.2857142857142857      0.600 1.000 1.000
     2354                0.42857142857142855     0.800 1.000 1.000
     2355                0.5714285714285714      0.900 0.900 0.900
     2356                0.7142857142857143      0.600 0.600 0.600
     2357                0.8571428571428571      0.400 0.400 0.400
     2358                1.0                     0.200 0.200 0.200
     2359            }
     2360        }
     2361        "sinusoid-2" {
     2362            set wmap {
     2363                0.0                     0.900 1.000 1.000
     2364                0.1111111111111111      0.800 0.983 1.000
     2365                0.2222222222222222      0.700 0.950 1.000
     2366                0.3333333333333333      0.600 0.900 1.000
     2367                0.4444444444444444      0.500 0.833 1.000
     2368                0.5555555555555556      0.400 0.750 1.000
     2369                0.6666666666666666      0.300 0.650 1.000
     2370                0.7777777777777778      0.200 0.533 1.000
     2371                0.8888888888888888      0.100 0.400 1.000
     2372                1.0                     0.000 0.250 1.000
     2373            }
     2374        }
     2375        "sinusoid-6" {
     2376            set wmap {
     2377                0.0                             0.200   0.100   0.000
     2378                0.09090909090909091             0.400   0.187   0.000
     2379                0.18181818181818182             0.600   0.379   0.210
     2380                0.2727272727272727              0.800   0.608   0.480
     2381                0.36363636363636365             0.850   0.688   0.595
     2382                0.45454545454545453             0.950   0.855   0.808
     2383                0.5454545454545454              0.800   0.993   1.000
     2384                0.6363636363636364              0.600   0.973   1.000
     2385                0.7272727272727273              0.400   0.940   1.000
     2386                0.8181818181818182              0.200   0.893   1.000
     2387                0.9090909090909091              0.000   0.667   0.800
     2388                1.0                             0.000   0.480   0.600
     2389            }
     2390        }
     2391        "sinusoid-10" {
     2392            set wmap {
     2393                0.0                             0.000   0.480   0.600
     2394                0.09090909090909091             0.000   0.667   0.800
     2395                0.18181818181818182             0.200   0.893   1.000
     2396                0.2727272727272727              0.400   0.940   1.000
     2397                0.36363636363636365             0.600   0.973   1.000
     2398                0.45454545454545453             0.800   0.993   1.000
     2399                0.5454545454545454              0.950   0.855   0.808
     2400                0.6363636363636364              0.850   0.688   0.595
     2401                0.7272727272727273              0.800   0.608   0.480
     2402                0.8181818181818182              0.600   0.379   0.210
     2403                0.9090909090909091              0.400   0.187   0.000
     2404                1.0                             0.200   0.100   0.000
     2405            }
     2406        }
     2407        "step-2" {
     2408            set wmap {
     2409                0.0                             0.000   0.167   1.000
     2410                0.09090909090909091             0.100   0.400   1.000
     2411                0.18181818181818182             0.200   0.600   1.000
     2412                0.2727272727272727              0.400   0.800   1.000
     2413                0.36363636363636365             0.600   0.933   1.000
     2414                0.45454545454545453             0.800   1.000   1.000
     2415                0.5454545454545454              1.000   1.000   0.800
     2416                0.6363636363636364              1.000   0.933   0.600
     2417                0.7272727272727273              1.000   0.800   0.400
     2418                0.8181818181818182              1.000   0.600   0.200
     2419                0.9090909090909091              1.000   0.400   0.100
     2420                1.0                             1.000   0.167   0.000
     2421            }
     2422        }
     2423        "step-5" {
     2424            set wmap {
     2425                0.0                             1.000   0.167   0.000
     2426                0.09090909090909091             1.000   0.400   0.100
     2427                0.18181818181818182             1.000   0.600   0.200
     2428                0.2727272727272727              1.000   0.800   0.400
     2429                0.36363636363636365             1.000   0.933   0.600
     2430                0.45454545454545453             1.000   1.000   0.800
     2431                0.5454545454545454              0.800   1.000   1.000
     2432                0.6363636363636364              0.600   0.933   1.000
     2433                0.7272727272727273              0.400   0.800   1.000
     2434                0.8181818181818182              0.200   0.600   1.000
     2435                0.9090909090909091              0.100   0.400   1.000
     2436                1.0                             0.000   0.167   1.000
     2437            }
     2438        }
     2439        "step-12" {
     2440            set wmap {
     2441                "#EE82EE"
     2442                "#4B0082"
     2443                "blue"
     2444                "#008000"
     2445                "yellow"
     2446                "#FFA500"
     2447                "red"
     2448            }
     2449        }
     2450        default {
     2451        }
     2452    }
     2453    # Multiply each component by the global opacity value.
     2454    return ""
     2455}
Note: See TracChangeset for help on using the changeset viewer.