Changeset 5224


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

cleanups in vtkvolume viewer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3/gui/scripts/vtkvolumeviewer.tcl

    r5221 r5224  
    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}
     
    6666    protected method Disconnect {}
    6767    protected method DoResize {}
    68     protected method DoReseed {}
    6968    protected method DoRotate {}
    7069    protected method AdjustSetting {what {value ""}}
     
    8483    private method BuildColormap { name colors }
    8584    private method BuildCutplaneTab {}
    86     private method BuildDownloadPopup { widget command } 
     85    private method BuildDownloadPopup { widget command }
    8786    private method BuildVolumeTab {}
    8887    private method DrawLegend {}
    8988    private method Combo { option }
    90     private method EnterLegend { x y }
    91     private method EventuallyResize { w h }
    92     private method EventuallyReseed { numPoints }
    93     private method EventuallyRotate { q }
    94     private method EventuallySetCutplane { axis args }
    95     private method GetImage { args }
    96     private method GetVtkData { args }
    97     private method IsValidObject { dataobj }
     89    private method EnterLegend { x y }
     90    private method EventuallyResize { w h }
     91    private method EventuallyRotate { q }
     92    private method EventuallySetCutplane { axis args }
     93    private method GetImage { args }
     94    private method GetVtkData { args }
     95    private method IsValidObject { dataobj }
    9896    private method LeaveLegend {}
    99     private method MotionLegend { x y } 
     97    private method MotionLegend { x y }
    10098    private method PanCamera {}
    10199    private method RequestLegend {}
     
    103101    private method ChangeColormap { dataobj comp color }
    104102    private method SetLegendTip { x y }
    105     private method SetObjectStyle { dataobj comp } 
    106     private method Slice {option args} 
     103    private method SetObjectStyle { dataobj comp }
     104    private method Slice {option args}
    107105
    108106    private variable _arcball ""
     
    110108    private variable _obj2datasets
    111109    private variable _obj2ovride   ;    # maps dataobj => style override
    112     private variable _datasets     ;    # contains all the dataobj-component 
     110    private variable _datasets     ;    # contains all the dataobj-component
    113111                                   ;    # datasets in the server
    114112    private variable _colormaps    ;    # contains all the colormaps
     
    127125    private variable _start 0
    128126    private variable _title ""
    129     private variable _seeds
    130127
    131128    common _downloadPopup;              # download options from popup
     
    134131    private variable _height 0
    135132    private variable _resizePending 0
    136     private variable _reseedPending 0
    137133    private variable _rotatePending 0
    138134    private variable _cutplanePending 0
    139135    private variable _legendPending 0
    140     private variable _fields 
     136    private variable _fields
    141137    private variable _curFldName ""
    142138    private variable _curFldLabel ""
     
    163159    $_dispatcher register !resize
    164160    $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list"
    165 
    166     # Reseed event
    167     $_dispatcher register !reseed
    168     $_dispatcher dispatch $this !reseed "[itcl::code $this DoReseed]; list"
    169161
    170162    # Rotate event
     
    204196        qy              0.353553
    205197        qz              0.146447
    206         zoom            1.0 
     198        zoom            1.0
    207199        xpan            0
    208200        ypan            0
     
    248240    itk_component add fieldmenu {
    249241        menu $itk_component(plotarea).menu -bg black -fg white -relief flat \
    250             -tearoff no 
     242            -tearoff no
    251243    } {
    252244        usual
     
    268260
    269261    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
    270     set _map(cwidth) -1 
    271     set _map(cheight) -1 
     262    set _map(cwidth) -1
     263    set _map(cheight) -1
    272264    set _map(zoom) 1.0
    273265    set _map(original) ""
     
    315307            -offimage [Rappture::icon volume-off] \
    316308            -variable [itcl::scope _settings(volumeVisible)] \
    317             -command [itcl::code $this AdjustSetting volumeVisible] 
     309            -command [itcl::code $this AdjustSetting volumeVisible]
    318310    }
    319311    $itk_component(volume) select
     
    327319            -offimage [Rappture::icon cutbutton] \
    328320            -variable [itcl::scope _settings(cutplaneVisible)] \
    329             -command [itcl::code $this AdjustSetting cutplaneVisible] 
     321            -command [itcl::code $this AdjustSetting cutplaneVisible]
    330322    }
    331323    Rappture::Tooltip::for $itk_component(cutplane) \
    332324        "Show/Hide cutplanes"
    333325    pack $itk_component(cutplane) -padx 2 -pady 2
    334 
    335326
    336327    if { [catch {
     
    342333        puts stderr errs=$errs
    343334    }
     335
    344336    # Legend
    345 
    346337    set _image(legend) [image create photo]
    347338    itk_component add legend {
    348         canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 
     339        canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0
    349340    } {
    350341        usual
     
    353344    }
    354345
    355     # Hack around the Tk panewindow.  The problem is that the requested 
     346    # Hack around the Tk panewindow.  The problem is that the requested
    356347    # size of the 3d view isn't set until an image is retrieved from
    357348    # the server.  So the panewindow uses the tiny size.
     
    359350    pack forget $itk_component(view)
    360351    blt::table $itk_component(plotarea) \
    361         0,0 $itk_component(view) -fill both -reqwidth $w 
     352        0,0 $itk_component(view) -fill both -reqwidth $w
    362353    blt::table configure $itk_component(plotarea) c1 -resize none
    363354
     
    445436itcl::body Rappture::VtkVolumeViewer::DoRotate {} {
    446437    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    447     SendCmd "camera orient $q" 
     438    SendCmd "camera orient $q"
    448439    set _rotatePending 0
    449440}
     
    459450}
    460451
    461 itcl::body Rappture::VtkVolumeViewer::EventuallyReseed { numPoints } {
    462     set _numSeeds $numPoints
    463     if { !$_reseedPending } {
    464         set _reseedPending 1
    465         $_dispatcher event -after 600 !reseed
    466     }
    467 }
    468 
    469452set rotate_delay 100
    470453
     
    473456    if { !$_rotatePending } {
    474457        set _rotatePending 1
    475         global rotate_delay 
     458        global rotate_delay
    476459        $_dispatcher event -after $rotate_delay !rotate
    477460    }
     
    577560                    continue
    578561                }
    579                 if {[info exists _obj2ovride($dataobj-raise)] && 
     562                if {[info exists _obj2ovride($dataobj-raise)] &&
    580563                    $_obj2ovride($dataobj-raise)} {
    581564                    set dlist [linsert $dlist 0 $dataobj]
     
    605588            }
    606589            return $dlist
    607         }           
     590        }
    608591        -image {
    609592            if {[llength $args] != 2} {
     
    801784    $_dispatcher cancel !rebuild
    802785    $_dispatcher cancel !resize
    803     $_dispatcher cancel !reseed
    804786    $_dispatcher cancel !rotate
    805787    $_dispatcher cancel !xcutplane
     
    808790    $_dispatcher cancel !legend
    809791    # disconnected -- no more data sitting on server
    810     array unset _datasets
    811     array unset _data
    812     array unset _colormaps
    813     array unset _seeds
    814     array unset _dataset2style
    815     array unset _obj2datasets
     792    array unset _datasets
     793    array unset _data
     794    array unset _colormaps
     795    array unset _dataset2style
     796    array unset _obj2datasets
    816797}
    817798
     
    842823        set time [clock seconds]
    843824        set date [clock format $time]
    844         #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"       
     825        #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"
    845826        if { $_start > 0 } {
    846827            set finish [clock clicks -milliseconds]
     
    917898    # Turn on buffering of commands to the server.  We don't want to
    918899    # be preempted by a server disconnect/reconnect (which automatically
    919     # generates a new call to Rebuild).   
     900    # generates a new call to Rebuild).
    920901    StartBufferingCommands
    921902
     
    10561037itcl::body Rappture::VtkVolumeViewer::CurrentDatasets {args} {
    10571038    set flag [lindex $args 0]
    1058     switch -- $flag { 
     1039    switch -- $flag {
    10591040        "-all" {
    10601041            if { [llength $args] > 1 } {
     
    10751056                set dlist [get -visible]
    10761057            }
    1077         }           
     1058        }
    10781059        default {
    10791060            set dlist $args
     
    11961177    foreach tag [CurrentDatasets -visible] {
    11971178        SendCmd "dataset getscalar pixel $x $y $tag"
    1198     } 
     1179    }
    11991180}
    12001181
     
    16011582
    16021583    itk_component add field_l {
    1603         label $inner.field_l -text "Field" -font "Arial 9" 
     1584        label $inner.field_l -text "Field" -font "Arial 9"
    16041585    } {
    16051586        ignore -font
     
    16111592        [itcl::code $this AdjustSetting field]
    16121593
    1613     label $inner.palette_l -text "Palette" -font "Arial 9" 
     1594    label $inner.palette_l -text "Palette" -font "Arial 9"
    16141595    itk_component add palette {
    16151596        Rappture::Combobox $inner.palette -width 10 -editable no
     
    16761657        -font "Arial 9"
    16771658
    1678     label $inner.mode_l -text "Mode" -font "Arial 9" 
     1659    label $inner.mode_l -text "Mode" -font "Arial 9"
    16791660
    16801661    itk_component add axismode {
     
    16851666        "closest_triad"   "closest" \
    16861667        "furthest_triad"  "farthest" \
    1687         "outer_edges"     "outer"         
     1668        "outer_edges"     "outer"
    16881669    $itk_component(axismode) value "static"
    16891670    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axisFlyMode]
     
    16961677        4,0 $inner.gridz   -anchor w -cspan 2 \
    16971678        5,0 $inner.mode_l  -anchor w -cspan 2 -padx { 2 0 } \
    1698         6,0 $inner.mode    -fill x   -cspan 2 
     1679        6,0 $inner.mode    -fill x   -cspan 2
    16991680
    17001681    blt::table configure $inner r* c* -resize none
     
    17411722
    17421723    set fg [option get $itk_component(hull) font Font]
    1743    
     1724
    17441725    set inner [$itk_component(main) insert end \
    17451726        -title "Cutplane Settings" \
    1746         -icon [Rappture::icon cutbutton]] 
     1727        -icon [Rappture::icon cutbutton]]
    17471728
    17481729    $inner configure -borderwidth 4
     
    18821863
    18831864#
    1884 #  camera -- 
     1865#  camera --
    18851866#
    18861867itcl::body Rappture::VtkVolumeViewer::camera {option args} {
    1887     switch -- $option { 
     1868    switch -- $option {
    18881869        "show" {
    18891870            puts [array get _view]
     
    19331914
    19341915itcl::body Rappture::VtkVolumeViewer::GetImage { args } {
    1935     if { [image width $_image(download)] > 0 && 
     1916    if { [image width $_image(download)] > 0 &&
    19361917         [image height $_image(download)] > 0 } {
    19371918        set bytes [$_image(download) data -format "jpeg -quality 100"]
     
    19461927        -title "[Rappture::filexfer::label downloadWord] as..."
    19471928    set inner [$popup component inner]
    1948     label $inner.summary -text "" -anchor w 
     1929    label $inner.summary -text "" -anchor w
    19491930    radiobutton $inner.vtk_button -text "VTK data file" \
    19501931        -variable [itcl::scope _downloadPopup(format)] \
    19511932        -font "Helvetica 9 " \
    1952         -value vtk 
     1933        -value vtk
    19531934    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
    19541935    radiobutton $inner.image_button -text "Image File" \
    19551936        -variable [itcl::scope _downloadPopup(format)] \
    1956         -value image 
     1937        -value image
    19571938    Rappture::Tooltip::for $inner.image_button \
    19581939        "Save as digital image."
     
    19751956        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
    19761957        4,1 $inner.cancel -width .9i -fill y \
    1977         4,0 $inner.ok -padx 2 -width .9i -fill y 
     1958        4,0 $inner.ok -padx 2 -width .9i -fill y
    19781959    blt::table configure $inner r3 -height 4
    19791960    blt::table configure $inner r4 -pady 4
     
    19951976        -wireframe 0
    19961977        -lighting 1
    1997         -seeds 1
    1998         -seedcolor white
    19991978        -visible 1
    20001979    }
     
    20552034    set font "Arial 8"
    20562035    set lineht [font metrics $font -linespace]
    2057    
     2036
    20582037    if { [info exists _fields($fname)] } {
    20592038        foreach { title units } $_fields($fname) break
     
    20672046        set x [expr $w - 2]
    20682047        if { [$c find withtag "legend"] == "" } {
    2069             set y 2 
     2048            set y 2
    20702049            $c create text $x $y \
    20712050                -anchor ne \
     
    21422121    set font "Arial 8"
    21432122    set lineht [font metrics $font -linespace]
    2144    
     2123
    21452124    set imgHeight [image height $_image(legend)]
    21462125    set coords [$c coords colormap]
     
    21652144    }
    21662145    set color [eval format "\#%02x%02x%02x" $pixel]
    2167     $_image(swatch) put black  -to 0 0 23 23 
    2168     $_image(swatch) put $color -to 1 1 22 22 
     2146    $_image(swatch) put black  -to 0 0 23 23
     2147    $_image(swatch) put $color -to 1 1 22 22
    21692148    .rappturetooltip configure -icon $_image(swatch)
    21702149
     
    21772156        set value 0.0
    21782157    }
    2179     set tipx [expr $x + 15] 
     2158    set tipx [expr $x + 15]
    21802159    set tipy [expr $y - 5]
    21812160    Rappture::Tooltip::text $c "$title $value"
    2182     Rappture::Tooltip::tooltip show $c +$tipx,+$tipy   
     2161    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy
    21832162}
    21842163
     
    22272206# ----------------------------------------------------------------------
    22282207itcl::body Rappture::VtkVolumeViewer::Combo {option} {
    2229     set c $itk_component(view) 
     2208    set c $itk_component(view)
    22302209    switch -- $option {
    22312210        post {
     
    22402219        }
    22412220        deactivate {
    2242             $c itemconfigure title -fill white 
     2221            $c itemconfigure title -fill white
    22432222        }
    22442223        invoke {
Note: See TracChangeset for help on using the changeset viewer.