Ignore:
Timestamp:
Apr 14, 2015 9:47:12 PM (9 years ago)
Author:
ldelgass
Message:

whitespace

File:
1 edited

Legend:

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

    r5208 r5225  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22# ----------------------------------------------------------------------
    33#  COMPONENT: vtkvolumeviewer - Vtk volume viewer
     
    5757    public method get {args}
    5858    public method isconnected {}
    59     public method parameters {title args} { 
    60         # do nothing 
     59    public method parameters {title args} {
     60        # do nothing
    6161    }
    6262    public method scale {args}
    6363    public method updateTransferFunctions {}
    6464
    65     private method AddNewMarker { x y } 
     65    private method AddNewMarker { x y }
    6666    private method BuildVolumeComponents {}
    67     private method ComputeAlphamap { cname } 
     67    private method ComputeAlphamap { cname }
    6868    private method ComputeTransferFunction { cname }
    69     private method GetColormap { cname color } 
    70     private method GetDatasetsWithComponent { cname } 
    71     private method HideAllMarkers {} 
    72     private method InitComponentSettings { cname } 
     69    private method GetColormap { cname color }
     70    private method GetDatasetsWithComponent { cname }
     71    private method HideAllMarkers {}
     72    private method InitComponentSettings { cname }
    7373    private method ParseLevelsOption { cname levels }
    7474    private method ParseMarkersOption { cname markers }
     
    7777    private method SendTransferFunctions {}
    7878    private method SetInitialTransferFunction { dataobj cname }
    79     private method SwitchComponent { cname } 
     79    private method SwitchComponent { cname }
    8080
    8181    private variable _alphamap
    82     private variable _current "";       # Currently selected component 
    83     private variable _volcomponents   ; # Array of components found 
     82    private variable _current "";       # Currently selected component
     83    private variable _volcomponents   ; # Array of components found
    8484    private variable _componentsList   ; # List of component names
    8585    private variable _cname2transferFunction
     
    9494    private method BuildCameraTab {}
    9595    private method BuildCutplaneTab {}
    96     private method BuildDownloadPopup { widget command } 
     96    private method BuildDownloadPopup { widget command }
    9797    private method BuildViewTab {}
    9898    private method BuildVolumeTab {}
     
    105105    private method DoResize {}
    106106    private method DoRotate {}
    107     private method EnterLegend { x y } 
    108     private method EventuallyResize { w h } 
    109     private method EventuallyRequestLegend {} 
    110     private method EventuallyRotate { q } 
    111     private method EventuallySetCutplane { axis args } 
    112     private method GetImage { args } 
    113     private method GetVtkData { args } 
     107    private method EnterLegend { x y }
     108    private method EventuallyResize { w h }
     109    private method EventuallyRequestLegend {}
     110    private method EventuallyRotate { q }
     111    private method EventuallySetCutplane { axis args }
     112    private method GetImage { args }
     113    private method GetVtkData { args }
    114114    private method InitSettings { args  }
    115     private method IsValidObject { dataobj } 
     115    private method IsValidObject { dataobj }
    116116    private method LeaveLegend {}
    117117    private method MotionLegend { x y }
     
    119119    private method PanCamera {}
    120120    private method Pick {x y}
    121     private method QuaternionToView { q } { 
     121    private method QuaternionToView { q } {
    122122        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
    123123    }
     
    129129    private method Rotate {option x y}
    130130    private method SetLegendTip { x y }
    131     private method SetObjectStyle { dataobj comp } 
     131    private method SetObjectStyle { dataobj comp }
    132132    private method SetOrientation { side }
    133     private method Slice {option args} 
    134     private method ViewToQuaternion {} { 
     133    private method Slice {option args}
     134    private method ViewToQuaternion {} {
    135135        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
    136136    }
     
    140140    private variable _dlist ""     ;    # list of data objects
    141141    private variable _obj2ovride   ;    # maps dataobj => style override
    142     private variable _datasets     ;    # contains all the dataobj-component 
     142    private variable _datasets     ;    # contains all the dataobj-component
    143143                                   ;    # datasets in the server
    144144    private variable _colormaps    ;    # contains all the colormaps
     
    164164    private variable _cutplanePending 0
    165165    private variable _legendPending 0
    166     private variable _fields 
     166    private variable _fields
    167167    private variable _curFldName ""
    168168    private variable _curFldLabel ""
     
    234234        -xpan            0
    235235        -ypan            0
    236         -zoom            1.0 
     236        -zoom            1.0
    237237    }
    238238    set _arcball [blt::arcball create 100 100]
     
    282282    itk_component add fieldmenu {
    283283        menu $itk_component(plotarea).menu -bg black -fg white -relief flat \
    284             -tearoff no 
     284            -tearoff no
    285285    } {
    286286        usual
     
    302302
    303303    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
    304     set _map(cwidth) -1 
    305     set _map(cheight) -1 
     304    set _map(cwidth) -1
     305    set _map(cheight) -1
    306306    set _map(zoom) 1.0
    307307    set _map(original) ""
     
    349349            -offimage [Rappture::icon volume-off] \
    350350            -variable [itcl::scope _settings(-volumevisible)] \
    351             -command [itcl::code $this AdjustSetting -volumevisible] 
     351            -command [itcl::code $this AdjustSetting -volumevisible]
    352352    }
    353353    $itk_component(volume) select
     
    361361            -offimage [Rappture::icon cutbutton] \
    362362            -variable [itcl::scope _settings(-cutplanesvisible)] \
    363             -command [itcl::code $this AdjustSetting -cutplanesvisible] 
     363            -command [itcl::code $this AdjustSetting -cutplanesvisible]
    364364    }
    365365    Rappture::Tooltip::for $itk_component(cutplane) \
     
    380380    set _image(legend) [image create photo]
    381381    itk_component add legend {
    382         canvas $itk_component(plotarea).legend -height 50 -highlightthickness 0 
     382        canvas $itk_component(plotarea).legend -height 50 -highlightthickness 0
    383383    } {
    384384        usual
     
    391391        [list focus $itk_component(legend)]
    392392
    393     # Hack around the Tk panewindow.  The problem is that the requested 
     393    # Hack around the Tk panewindow.  The problem is that the requested
    394394    # size of the 3d view isn't set until an image is retrieved from
    395395    # the server.  So the panewindow uses the tiny size.
     
    398398    blt::table $itk_component(plotarea) \
    399399        0,0 $itk_component(view) -fill both -reqwidth $w  \
    400         1,0 $itk_component(legend) -fill x 
     400        1,0 $itk_component(legend) -fill x
    401401    blt::table configure $itk_component(plotarea) r1 -resize none
    402402
     
    483483
    484484itcl::body Rappture::VtkVolumeViewer::DoRotate {} {
    485     SendCmd "camera orient [ViewToQuaternion]" 
     485    SendCmd "camera orient [ViewToQuaternion]"
    486486    set _rotatePending 0
    487487}
     
    510510    if { !$_rotatePending } {
    511511        set _rotatePending 1
    512         global rotate_delay 
     512        global rotate_delay
    513513        $_dispatcher event -after $rotate_delay !rotate
    514514    }
     
    617617                    continue
    618618                }
    619                 if {[info exists _obj2ovride($dataobj-raise)] && 
     619                if {[info exists _obj2ovride($dataobj-raise)] &&
    620620                    $_obj2ovride($dataobj-raise)} {
    621621                    set dlist [linsert $dlist 0 $dataobj]
     
    645645            }
    646646            return $dlist
    647         }           
     647        }
    648648        -image {
    649649            if {[llength $args] != 2} {
     
    879879    $_dispatcher cancel !legend
    880880    # disconnected -- no more data sitting on server
    881     array unset _datasets 
    882     array unset _colormaps 
    883     array unset _dataset2style 
     881    array unset _datasets
     882    array unset _colormaps
     883    array unset _dataset2style
    884884
    885885    array unset _parsedFunction
     
    988988    # Turn on buffering of commands to the server.  We don't want to
    989989    # be preempted by a server disconnect/reconnect (which automatically
    990     # generates a new call to Rebuild).   
     990    # generates a new call to Rebuild).
    991991    StartBufferingCommands
    992992
     
    10221022
    10231023    # No volumes are active (i.e. in the working set of displayed volumes).
    1024     # A volume is always invisible if it's not in the working set.  A 
     1024    # A volume is always invisible if it's not in the working set.  A
    10251025    # volume in the working set may be visible/invisible depending upon the
    10261026    # global visibility value.
     
    10341034            if { ![info exists _datasets($tag)] } {
    10351035                set bytes [$dataobj vtkdata $comp]
    1036                 if 0 { 
     1036                if 0 {
    10371037                    set f [open /tmp/vtkvolume.vtk "w"]
    10381038                    fconfigure $f -translation binary -encoding binary
     
    11421142itcl::body Rappture::VtkVolumeViewer::CurrentDatasets {args} {
    11431143    set flag [lindex $args 0]
    1144     switch -- $flag { 
     1144    switch -- $flag {
    11451145        "-all" {
    11461146            if { [llength $args] > 1 } {
     
    11611161                set dlist [get -visible]
    11621162            }
    1163         }           
     1163        }
    11641164        default {
    11651165            set dlist $args
     
    12801280    foreach tag [CurrentDatasets -visible] {
    12811281        SendCmd "dataset getscalar pixel $x $y $tag"
    1282     } 
     1282    }
    12831283}
    12841284
     
    13931393            if { $bool } {
    13941394                blt::table $itk_component(plotarea) \
    1395                     1,0 $itk_component(legend) -fill x 
     1395                    1,0 $itk_component(legend) -fill x
    13961396            } else {
    1397                 blt::table forget $itk_component(legend) 
     1397                blt::table forget $itk_component(legend)
    13981398            }
    13991399        }
     
    14051405            # volume control determines whether they are visible.
    14061406            #
    1407             # Note: The use of the current component is a hold over from 
     1407            # Note: The use of the current component is a hold over from
    14081408            #       nanovis.  If we can't display more than one volume,
    1409             #       we don't have to limit the effects to a specific 
     1409            #       we don't have to limit the effects to a specific
    14101410            #       component.
    14111411            foreach tag [GetDatasetsWithComponent $_current] {
     
    16531653        SendCmd "outline color $rgb"
    16541654        SendCmd "$_cutplaneCmd color $rgb"
    1655         $itk_component(legend) itemconfigure labels -fill $color 
    1656         $itk_component(legend) itemconfigure limits -fill $color 
     1655        $itk_component(legend) itemconfigure labels -fill $color
     1656        $itk_component(legend) itemconfigure limits -fill $color
    16571657    }
    16581658}
     
    16911691        -font "Arial 9"
    16921692
    1693     label $inner.background_l -text "Background" -font "Arial 9" 
     1693    label $inner.background_l -text "Background" -font "Arial 9"
    16941694    itk_component add background {
    16951695        Rappture::Combobox $inner.background -width 10 -editable no
     
    16981698        "black"              "black"            \
    16991699        "white"              "white"            \
    1700         "grey"               "grey"             
     1700        "grey"               "grey"
    17011701
    17021702    $itk_component(background) value $_settings(-background)
     
    17401740    label $inner.lighting_l \
    17411741        -text "Lighting / Material Properties" \
    1742         -font "Arial 9 bold" 
     1742        -font "Arial 9 bold"
    17431743
    17441744    checkbutton $inner.lighting \
     
    18001800
    18011801    label $inner.transferfunction_l \
    1802         -text "Transfer Function" -font "Arial 9 bold" 
     1802        -text "Transfer Function" -font "Arial 9 bold"
    18031803
    18041804    label $inner.thin -text "Thin" -font $font
     
    18631863        14,1 $inner.thin             -anchor e \
    18641864        14,2 $inner.thickness                 -cspan 2 -fill x \
    1865         14,4 $inner.thick -anchor w 
     1865        14,4 $inner.thick -anchor w
    18661866
    18671867    blt::table configure $inner r* c* -resize none
     
    19131913        -font "Arial 9"
    19141914
    1915     label $inner.mode_l -text "Mode" -font "Arial 9" 
     1915    label $inner.mode_l -text "Mode" -font "Arial 9"
    19161916
    19171917    itk_component add axismode {
     
    19221922        "closest_triad"   "closest" \
    19231923        "furthest_triad"  "farthest" \
    1924         "outer_edges"     "outer"         
     1924        "outer_edges"     "outer"
    19251925    $itk_component(axismode) value $_settings(-axisflymode)
    19261926    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode]
     
    19951995
    19961996    set fg [option get $itk_component(hull) font Font]
    1997    
     1997
    19981998    set inner [$itk_component(main) insert end \
    19991999        -title "Cutplane Settings" \
    2000         -icon [Rappture::icon cutbutton]] 
     2000        -icon [Rappture::icon cutbutton]]
    20012001
    20022002    $inner configure -borderwidth 4
     
    21222122
    21232123#
    2124 #  camera -- 
     2124#  camera --
    21252125#
    21262126itcl::body Rappture::VtkVolumeViewer::camera {option args} {
    2127     switch -- $option { 
     2127    switch -- $option {
    21282128        "show" {
    21292129            puts [array get _view]
     
    21732173
    21742174itcl::body Rappture::VtkVolumeViewer::GetImage { args } {
    2175     if { [image width $_image(download)] > 0 && 
     2175    if { [image width $_image(download)] > 0 &&
    21762176         [image height $_image(download)] > 0 } {
    21772177        set bytes [$_image(download) data -format "jpeg -quality 100"]
     
    21862186        -title "[Rappture::filexfer::label downloadWord] as..."
    21872187    set inner [$popup component inner]
    2188     label $inner.summary -text "" -anchor w 
     2188    label $inner.summary -text "" -anchor w
    21892189    radiobutton $inner.vtk_button -text "VTK data file" \
    21902190        -variable [itcl::scope _downloadPopup(format)] \
    21912191        -font "Helvetica 9 " \
    2192         -value vtk 
     2192        -value vtk
    21932193    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
    21942194    radiobutton $inner.image_button -text "Image File" \
    21952195        -variable [itcl::scope _downloadPopup(format)] \
    2196         -value image 
     2196        -value image
    21972197    Rappture::Tooltip::for $inner.image_button \
    21982198        "Save as digital image."
     
    22152215        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
    22162216        4,1 $inner.cancel -width .9i -fill y \
    2217         4,0 $inner.ok -padx 2 -width .9i -fill y 
     2217        4,0 $inner.ok -padx 2 -width .9i -fill y
    22182218    blt::table configure $inner r3 -height 4
    22192219    blt::table configure $inner r4 -pady 4
     
    23512351    set font "Arial 8"
    23522352    set lineht [font metrics $font -linespace]
    2353    
     2353
    23542354    if { [info exists _fields($fname)] } {
    23552355        foreach { title units } $_fields($fname) break
     
    23632363        set x [expr $w - 2]
    23642364        if { [$c find withtag "legend"] == "" } {
    2365             set y 2 
     2365            set y 2
    23662366            $c create text $x $y \
    23672367                -anchor ne \
     
    24382438    set font "Arial 8"
    24392439    set lineht [font metrics $font -linespace]
    2440    
     2440
    24412441    set imgHeight [image height $_image(legend)]
    24422442    set coords [$c coords colormap]
     
    24612461    }
    24622462    set color [eval format "\#%02x%02x%02x" $pixel]
    2463     $_image(swatch) put black  -to 0 0 23 23 
    2464     $_image(swatch) put $color -to 1 1 22 22 
     2463    $_image(swatch) put black  -to 0 0 23 23
     2464    $_image(swatch) put $color -to 1 1 22 22
    24652465    .rappturetooltip configure -icon $_image(swatch)
    24662466
     
    24732473        set value 0.0
    24742474    }
    2475     set tipx [expr $x + 15] 
     2475    set tipx [expr $x + 15]
    24762476    set tipy [expr $y - 5]
    24772477    Rappture::Tooltip::text $c "$title $value"
    2478     Rappture::Tooltip::tooltip show $c +$tipx,+$tipy   
     2478    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy
    24792479}
    24802480
     
    25212521# ----------------------------------------------------------------------
    25222522itcl::body Rappture::VtkVolumeViewer::Combo {option} {
    2523     set c $itk_component(view) 
     2523    set c $itk_component(view)
    25242524    switch -- $option {
    25252525        post {
     
    25342534        }
    25352535        deactivate {
    2536             $c itemconfigure title -fill $itk_option(-plotforeground) 
     2536            $c itemconfigure title -fill $itk_option(-plotforeground)
    25372537        }
    25382538        invoke {
     
    25702570#
    25712571# The -markers option takes a list of zero or more values (the values
    2572 # may be separated either by spaces or commas) that have the following 
     2572# may be separated either by spaces or commas) that have the following
    25732573# format:
    25742574#
     
    25882588        set n [scan $marker "%g%s" value suffix]
    25892589        if { $n == 2 && $suffix == "%" } {
    2590             # $n% : Set relative value (0..1). 
     2590            # $n% : Set relative value (0..1).
    25912591            lappend list [expr {$value * 0.01}]
    25922592        } else {
     
    26792679        set amap $_alphamap($cname)
    26802680    }
    2681     set opaqueAmap "0.0 1.0 1.0 1.0" 
     2681    set opaqueAmap "0.0 1.0 1.0 1.0"
    26822682    set _cname2transferFunction($cname) [list $cmap $amap]
    26832683    SendCmd [list colormap define $cname $cmap $amap]
     
    26902690#       Changes only the colormap portion of the transfer function.
    26912691#
    2692 itcl::body Rappture::VtkVolumeViewer::ResetColormap { cname color } { 
     2692itcl::body Rappture::VtkVolumeViewer::ResetColormap { cname color } {
    26932693    # Get the current transfer function
    26942694    if { ![info exists _cname2transferFunction($cname)] } {
     
    26982698    set cmap [GetColormap $cname $color]
    26992699    set _cname2transferFunction($cname) [list $cmap $amap]
    2700     set opaqueAmap "0.0 1.0 1.0 1.0" 
     2700    set opaqueAmap "0.0 1.0 1.0 1.0"
    27012701    SendCmd [list colormap define $cname $cmap $amap]
    27022702    SendCmd [list colormap define $cname-opaque $cmap $opaqueAmap]
     
    27052705
    27062706# ----------------------------------------------------------------------
    2707 # USAGE: updateTransferFunctions 
     2707# USAGE: updateTransferFunctions
    27082708#
    27092709#       This is called by the transfer function editor whenever the
     
    27312731    }
    27322732    # Add a new marker to the current transfer function
    2733     $_transferFunctionEditors($_current) deleteMarker $x $y 
    2734 }
    2735 
    2736 itcl::body Rappture::VtkVolumeViewer::SetOrientation { side } { 
     2733    $_transferFunctionEditors($_current) deleteMarker $x $y
     2734}
     2735
     2736itcl::body Rappture::VtkVolumeViewer::SetOrientation { side } {
    27372737    array set positions {
    27382738        front "1 0 0 0"
     
    27452745    foreach name { -qw -qx -qy -qz } value $positions($side) {
    27462746        set _view($name) $value
    2747     } 
     2747    }
    27482748    set q [ViewToQuaternion]
    27492749    $_arcball quaternion $q
    2750     SendCmd "camera orient $q" 
     2750    SendCmd "camera orient $q"
    27512751    SendCmd "camera reset"
    27522752    set _view(-xpan) 0
     
    27632763#       in SwitchComponent below.
    27642764#
    2765 itcl::body Rappture::VtkVolumeViewer::InitComponentSettings { cname } { 
     2765itcl::body Rappture::VtkVolumeViewer::InitComponentSettings { cname } {
    27662766    array set _settings [subst {
    27672767        $cname-color                    default
     
    27882788#       volume settings with the settings of the new current component.
    27892789#
    2790 itcl::body Rappture::VtkVolumeViewer::SwitchComponent { cname } { 
     2790itcl::body Rappture::VtkVolumeViewer::SwitchComponent { cname } {
    27912791    if { ![info exists _settings(${cname}-volumeambient)] } {
    27922792        InitComponentSettings $cname
     
    28132813}
    28142814
    2815 itcl::body Rappture::VtkVolumeViewer::ComputeAlphamap { cname } { 
     2815itcl::body Rappture::VtkVolumeViewer::ComputeAlphamap { cname } {
    28162816    if { ![info exists _transferFunctionEditors($cname)] } {
    28172817        return [list 0.0 0.0 1.0 1.0]
     
    28782878# HideAllMarkers --
    28792879#
    2880 #       Hide all the markers in all the transfer functions.  Can't simply 
    2881 #       delete and recreate markers from the <style> since the user may 
     2880#       Hide all the markers in all the transfer functions.  Can't simply
     2881#       delete and recreate markers from the <style> since the user may
    28822882#       have create, deleted, or moved markers.
    28832883#
    2884 itcl::body Rappture::VtkVolumeViewer::HideAllMarkers {} { 
     2884itcl::body Rappture::VtkVolumeViewer::HideAllMarkers {} {
    28852885    foreach cname [array names _transferFunctionEditors] {
    2886         $_transferFunctionEditors($cname) hideMarkers 
     2886        $_transferFunctionEditors($cname) hideMarkers
    28872887    }
    28882888}
     
    28922892#
    28932893#       Returns a list of all the datasets (known by the combination of
    2894 #       their data object and component name) that match the given 
    2895 #       component name.  For example, this is used where we want to change 
     2894#       their data object and component name) that match the given
     2895#       component name.  For example, this is used where we want to change
    28962896#       the settings of volumes that have the current component.
    28972897#
    2898 itcl::body Rappture::VtkVolumeViewer::GetDatasetsWithComponent { cname } { 
     2898itcl::body Rappture::VtkVolumeViewer::GetDatasetsWithComponent { cname } {
    28992899    if { ![info exists _volcomponents($cname)] } {
    29002900        return ""
     
    29132913#       label or the combobox in the volume settings tab.
    29142914#
    2915 itcl::body Rappture::VtkVolumeViewer::BuildVolumeComponents {} { 
     2915itcl::body Rappture::VtkVolumeViewer::BuildVolumeComponents {} {
    29162916    $itk_component(volcomponents) choices delete 0 end
    29172917    foreach name $_componentsList {
     
    29232923    if { [llength $_componentsList] <= 1 } {
    29242924        # Unpack the components label and dropdown if there's only one
    2925         # component. 
     2925        # component.
    29262926        catch {blt::table forget $parent.volcomponents_l $parent.volcomponents}
    29272927    } else {
    2928         # Pack the components label and dropdown into the table there's 
    2929         # more than one component to select. 
     2928        # Pack the components label and dropdown into the table there's
     2929        # more than one component to select.
    29302930        blt::table $parent \
    29312931            0,0 $parent.volcomponents_l -anchor e -cspan 2 \
    2932             0,2 $parent.volcomponents -cspan 3 -fill x 
    2933     }
    2934 }
    2935 
    2936 itcl::body Rappture::VtkVolumeViewer::GetColormap { cname color } { 
     2932            0,2 $parent.volcomponents -cspan 3 -fill x
     2933    }
     2934}
     2935
     2936itcl::body Rappture::VtkVolumeViewer::GetColormap { cname color } {
    29372937    if { $color == "default" } {
    29382938        return $_cname2defaultcolormap($cname)
Note: See TracChangeset for help on using the changeset viewer.