Ignore:
Timestamp:
Feb 12, 2015, 3:31:03 PM (5 years ago)
Author:
ldelgass
Message:

Merge r5001:5003,r5005:5006 from trunk (whitespace)

Location:
branches/1.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3

  • branches/1.3/gui/scripts/vtkstreamlinesviewer.tcl

    r4983 r5011  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22# ----------------------------------------------------------------------
    33#  COMPONENT: vtkstreamlinesviewer - Vtk streamlines object 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}
     
    6868    private method BuildColormap { name colors }
    6969    private method BuildCutplaneTab {}
    70     private method BuildDownloadPopup { widget command } 
     70    private method BuildDownloadPopup { widget command }
    7171    private method BuildStreamsTab {}
    7272    private method BuildVolumeTab {}
     
    7979    private method DoReseed {}
    8080    private method DoRotate {}
    81     private method EnterLegend { x y } 
    82     private method EventuallyResize { w h } 
    83     private method EventuallyReseed { numPoints } 
    84     private method EventuallyRotate { q } 
    85     private method EventuallySetCutplane { axis args } 
    86     private method GetImage { args } 
    87     private method GetVtkData { args } 
     81    private method EnterLegend { x y }
     82    private method EventuallyResize { w h }
     83    private method EventuallyReseed { numPoints }
     84    private method EventuallyRotate { q }
     85    private method EventuallySetCutplane { axis args }
     86    private method GetImage { args }
     87    private method GetVtkData { args }
    8888    private method InitSettings { args  }
    89     private method IsValidObject { dataobj } 
     89    private method IsValidObject { dataobj }
    9090    private method LeaveLegend {}
    91     private method MotionLegend { x y } 
     91    private method MotionLegend { x y }
    9292    private method Pan {option x y}
    9393    private method PanCamera {}
    9494    private method Pick {x y}
    95     private method QuaternionToView { q } { 
     95    private method QuaternionToView { q } {
    9696        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
    9797    }
     
    105105    private method ChangeColormap { dataobj comp color }
    106106    private method SetLegendTip { x y }
    107     private method SetObjectStyle { dataobj comp } 
    108     private method Slice {option args} 
     107    private method SetObjectStyle { dataobj comp }
     108    private method Slice {option args}
    109109    private method SetOrientation { side }
    110     private method ViewToQuaternion {} { 
     110    private method ViewToQuaternion {} {
    111111        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
    112112    }
     
    118118    private variable _obj2datasets
    119119    private variable _obj2ovride   ;    # maps dataobj => style override
    120     private variable _datasets     ;    # contains all the dataobj-component 
     120    private variable _datasets     ;    # contains all the dataobj-component
    121121                                   ;    # datasets in the server
    122122    private variable _colormaps    ;    # contains all the colormaps
     
    147147    private variable _cutplanePending 0
    148148    private variable _legendPending 0
    149     private variable _vectorFields 
    150     private variable _scalarFields 
    151     private variable _fields 
     149    private variable _vectorFields
     150    private variable _scalarFields
     151    private variable _fields
    152152    private variable _curFldName ""
    153153    private variable _curFldLabel ""
     
    271271    itk_component add fieldmenu {
    272272        menu $itk_component(plotarea).menu -bg black -fg white -relief flat \
    273             -tearoff no 
     273            -tearoff no
    274274    } {
    275275        usual
     
    291291
    292292    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
    293     set _map(cwidth) -1 
    294     set _map(cheight) -1 
     293    set _map(cwidth) -1
     294    set _map(cheight) -1
    295295    set _map(zoom) 1.0
    296296    set _map(original) ""
     
    338338            -offimage [Rappture::icon volume-off] \
    339339            -variable [itcl::scope _settings(-volumevisible)] \
    340             -command [itcl::code $this AdjustSetting -volumevisible] 
     340            -command [itcl::code $this AdjustSetting -volumevisible]
    341341    }
    342342    $itk_component(volume) select
     
    362362            -offimage [Rappture::icon cutbutton] \
    363363            -variable [itcl::scope _settings(-cutplanevisible)] \
    364             -command [itcl::code $this AdjustSetting -cutplanevisible] 
     364            -command [itcl::code $this AdjustSetting -cutplanevisible]
    365365    }
    366366    Rappture::Tooltip::for $itk_component(cutplane) \
     
    382382    set _image(legend) [image create photo]
    383383    itk_component add legend {
    384         canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 
     384        canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0
    385385    } {
    386386        usual
     
    389389    }
    390390
    391     # Hack around the Tk panewindow.  The problem is that the requested 
     391    # Hack around the Tk panewindow.  The problem is that the requested
    392392    # size of the 3d view isn't set until an image is retrieved from
    393393    # the server.  So the panewindow uses the tiny size.
     
    395395    pack forget $itk_component(view)
    396396    blt::table $itk_component(plotarea) \
    397         0,0 $itk_component(view) -fill both -reqwidth $w 
     397        0,0 $itk_component(view) -fill both -reqwidth $w
    398398    blt::table configure $itk_component(plotarea) c1 -resize none
    399399
     
    480480
    481481itcl::body Rappture::VtkStreamlinesViewer::DoRotate {} {
    482     SendCmd "camera orient [ViewToQuaternion]" 
     482    SendCmd "camera orient [ViewToQuaternion]"
    483483    set _rotatePending 0
    484484}
     
    517517    if { !$_rotatePending } {
    518518        set _rotatePending 1
    519         global rotate_delay 
     519        global rotate_delay
    520520        $_dispatcher event -after $rotate_delay !rotate
    521521    }
     
    621621                    continue
    622622                }
    623                 if {[info exists _obj2ovride($dataobj-raise)] && 
     623                if {[info exists _obj2ovride($dataobj-raise)] &&
    624624                    $_obj2ovride($dataobj-raise)} {
    625625                    set dlist [linsert $dlist 0 $dataobj]
     
    649649            }
    650650            return $dlist
    651         }           
     651        }
    652652        -image {
    653653            if {[llength $args] != 2} {
     
    791791            set info {}
    792792            set user "???"
    793             if { [info exists env(USER)] } {
     793            if { [info exists env(USER)] } {
    794794                set user $env(USER)
    795             }
     795            }
    796796            set session "???"
    797             if { [info exists env(SESSION)] } {
     797            if { [info exists env(SESSION)] } {
    798798                set session $env(SESSION)
    799             }
     799            }
    800800            lappend info "version" "$Rappture::version"
    801801            lappend info "build" "$Rappture::build"
     
    851851    $_dispatcher cancel !legend
    852852    # disconnected -- no more data sitting on server
    853     array unset _datasets 
    854     array unset _data 
    855     array unset _colormaps 
    856     array unset _seeds 
    857     array unset _dataset2style 
    858     array unset _obj2datasets 
     853    array unset _datasets
     854    array unset _data
     855    array unset _colormaps
     856    array unset _seeds
     857    array unset _dataset2style
     858    array unset _obj2datasets
    859859}
    860860
     
    884884        set time [clock seconds]
    885885        set date [clock format $time]
    886         #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"       
     886        #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"
    887887        if { $_start > 0 } {
    888888            set finish [clock clicks -milliseconds]
     
    964964    set _first ""
    965965    if { $_reset } {
    966         set _width $w
    967         set _height $h
    968         $_arcball resize $w $h
    969         DoResize
    970         InitSettings -xgrid -ygrid -zgrid -axismode \
    971             -axesvisible -axislabelsvisible -axisminorticks
     966        set _width $w
     967        set _height $h
     968        $_arcball resize $w $h
     969        DoResize
     970        InitSettings -xgrid -ygrid -zgrid -axismode \
     971            -axesvisible -axislabelsvisible -axisminorticks
    972972        # This "imgflush" is to force an image returned before vtkvis starts
    973973        # reading a (big) dataset.  This will display an empty plot with axes
     
    988988                set bytes [$dataobj vtkdata $comp]
    989989                set length [string length $bytes]
    990                 if 0 {
     990                if 0 {
    991991                    set f [open /tmp/vtkstreamlines.vtk "w"]
    992992                    fconfigure $f -translation binary -encoding binary
    993993                    puts -nonewline $f $bytes
    994994                    close $f
    995                 }
     995                }
    996996                if { $_reportClientInfo }  {
    997997                    set info {}
     
    10321032            }
    10331033        }
    1034         $itk_component(field) choices delete 0 end
    1035         $itk_component(fieldmenu) delete 0 end
    1036         array unset _fields
     1034        $itk_component(field) choices delete 0 end
     1035        $itk_component(fieldmenu) delete 0 end
     1036        array unset _fields
    10371037        set _curFldName ""
    10381038        foreach cname [$_first components] {
     
    10681068            -volumevisible -volumeedges -volumelighting -volumeopacity \
    10691069            -volumewireframe \
    1070             -cutplanevisible \
    1071             -cutplanexposition -cutplaneyposition -cutplanezposition \
    1072             -cutplanexvisible -cutplaneyvisible -cutplanezvisible
    1073 
    1074         # Reset the camera and other view parameters
    1075         $_arcball quaternion [ViewToQuaternion]
    1076         if {$_view(-ortho)} {
    1077             SendCmd "camera mode ortho"
    1078         } else {
    1079             SendCmd "camera mode persp"
    1080         }
    1081         DoRotate
    1082         PanCamera
     1070            -cutplanevisible \
     1071            -cutplanexposition -cutplaneyposition -cutplanezposition \
     1072            -cutplanexvisible -cutplaneyvisible -cutplanezvisible
     1073
     1074        # Reset the camera and other view parameters
     1075        $_arcball quaternion [ViewToQuaternion]
     1076        if {$_view(-ortho)} {
     1077            SendCmd "camera mode ortho"
     1078        } else {
     1079            SendCmd "camera mode persp"
     1080        }
     1081        DoRotate
     1082        PanCamera
    10831083        Zoom reset
    10841084        SendCmd "camera reset"
     
    11011101itcl::body Rappture::VtkStreamlinesViewer::CurrentDatasets {args} {
    11021102    set flag [lindex $args 0]
    1103     switch -- $flag { 
     1103    switch -- $flag {
    11041104        "-all" {
    11051105            if { [llength $args] > 1 } {
     
    11201120                set dlist [get -visible]
    11211121            }
    1122         }           
     1122        }
    11231123        default {
    11241124            set dlist $args
     
    12391239    foreach tag [CurrentDatasets -visible] {
    12401240        SendCmdNoWait "dataset getscalar pixel $x $y $tag"
    1241     } 
     1241    }
    12421242}
    12431243
     
    16661666        2,0 $inner.edges     -anchor w -pady 2 -cspan 3 \
    16671667        3,0 $inner.opacity_l -anchor w -pady 2 \
    1668         3,1 $inner.opacity   -fill x   -pady 2 
     1668        3,1 $inner.opacity   -fill x   -pady 2
    16691669
    16701670    blt::table configure $inner r* c* -resize none
     
    16871687        -command [itcl::code $this AdjustSetting -streamlinesvisible] \
    16881688        -font "Arial 9"
    1689    
     1689
    16901690    checkbutton $inner.lighting \
    16911691        -text "Enable Lighting" \
     
    17001700        -font "Arial 9"
    17011701
    1702     label $inner.mode_l -text "Mode" -font "Arial 9" 
     1702    label $inner.mode_l -text "Mode" -font "Arial 9"
    17031703    itk_component add streammode {
    17041704        Rappture::Combobox $inner.mode -width 10 -editable no
     
    17071707        "lines"    "lines" \
    17081708        "ribbons"   "ribbons" \
    1709         "tubes"     "tubes" 
     1709        "tubes"     "tubes"
    17101710    $itk_component(streammode) value $_settings(-streamlinesmode)
    17111711    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -streamlinesmode]
     
    17321732        -command [itcl::code $this AdjustSetting -streamlinesscale]
    17331733
    1734     label $inner.field_l -text "Color by" -font "Arial 9" 
     1734    label $inner.field_l -text "Color by" -font "Arial 9"
    17351735    itk_component add field {
    17361736        Rappture::Combobox $inner.field -width 10 -editable no
     
    17391739        [itcl::code $this AdjustSetting -field]
    17401740
    1741     label $inner.colormap_l -text "Colormap" -font "Arial 9" 
     1741    label $inner.colormap_l -text "Colormap" -font "Arial 9"
    17421742    itk_component add colormap {
    17431743        Rappture::Combobox $inner.colormap -width 10 -editable no
     
    17881788        -command [itcl::code $this AdjustSetting -axislabelsvisible] \
    17891789        -font "Arial 9"
    1790     label $inner.grid_l -text "Grid" -font "Arial 9" 
     1790    label $inner.grid_l -text "Grid" -font "Arial 9"
    17911791    checkbutton $inner.xgrid \
    17921792        -text "X" \
     
    18101810        -font "Arial 9"
    18111811
    1812     label $inner.mode_l -text "Mode" -font "Arial 9" 
     1812    label $inner.mode_l -text "Mode" -font "Arial 9"
    18131813
    18141814    itk_component add axismode {
     
    18191819        "closest_triad"   "closest" \
    18201820        "furthest_triad"  "farthest" \
    1821         "outer_edges"     "outer"         
     1821        "outer_edges"     "outer"
    18221822    $itk_component(axismode) value $_settings(-axismode)
    18231823    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
     
    18931893
    18941894    set fg [option get $itk_component(hull) font Font]
    1895    
     1895
    18961896    set inner [$itk_component(main) insert end \
    18971897        -title "Cutplane Settings" \
    1898         -icon [Rappture::icon cutbutton]] 
     1898        -icon [Rappture::icon cutbutton]]
    18991899
    19001900    $inner configure -borderwidth 4
     
    19501950            -command [itcl::code $this EventuallySetCutplane x] \
    19511951            -variable [itcl::scope _settings(-cutplanexposition)] \
    1952             -foreground red3 -font "Arial 9 bold"
     1952            -foreground red3 -font "Arial 9 bold"
    19531953    } {
    19541954        usual
     
    19791979            -command [itcl::code $this EventuallySetCutplane y] \
    19801980            -variable [itcl::scope _settings(-cutplaneyposition)] \
    1981             -foreground green3 -font "Arial 9 bold"
     1981            -foreground green3 -font "Arial 9 bold"
    19821982    } {
    19831983        usual
     
    20082008            -command [itcl::code $this EventuallySetCutplane z] \
    20092009            -variable [itcl::scope _settings(-cutplanezposition)] \
    2010             -foreground blue3 -font "Arial 9 bold"
     2010            -foreground blue3 -font "Arial 9 bold"
    20112011    } {
    20122012        usual
     
    20242024        3,0 $inner.opacity_l            -anchor w -pady 2 -cspan 1 \
    20252025        3,1 $inner.opacity              -fill x   -pady 2 -cspan 3 \
    2026         4,0 $itk_component(xCutButton)  -anchor w -padx 2 -pady 2 \
     2026        4,0 $itk_component(xCutButton)  -anchor w -padx 2 -pady 2 \
    20272027        5,0 $itk_component(yCutButton)  -anchor w -padx 2 -pady 2 \
    20282028        6,0 $itk_component(zCutButton)  -anchor w -padx 2 -pady 2 \
     
    20362036
    20372037#
    2038 #  camera -- 
     2038#  camera --
    20392039#
    20402040itcl::body Rappture::VtkStreamlinesViewer::camera {option args} {
    2041     switch -- $option { 
     2041    switch -- $option {
    20422042        "show" {
    20432043            puts [array get _view]
     
    20872087
    20882088itcl::body Rappture::VtkStreamlinesViewer::GetImage { args } {
    2089     if { [image width $_image(download)] > 0 && 
     2089    if { [image width $_image(download)] > 0 &&
    20902090         [image height $_image(download)] > 0 } {
    20912091        set bytes [$_image(download) data -format "jpeg -quality 100"]
     
    21002100        -title "[Rappture::filexfer::label downloadWord] as..."
    21012101    set inner [$popup component inner]
    2102     label $inner.summary -text "" -anchor w 
     2102    label $inner.summary -text "" -anchor w
    21032103    radiobutton $inner.vtk_button -text "VTK data file" \
    21042104        -variable [itcl::scope _downloadPopup(format)] \
    21052105        -font "Helvetica 9 " \
    2106         -value vtk 
     2106        -value vtk
    21072107    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
    21082108    radiobutton $inner.image_button -text "Image File" \
    21092109        -variable [itcl::scope _downloadPopup(format)] \
    2110         -value image 
     2110        -value image
    21112111    Rappture::Tooltip::for $inner.image_button \
    21122112        "Save as digital image."
     
    21292129        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
    21302130        4,1 $inner.cancel -width .9i -fill y \
    2131         4,0 $inner.ok -padx 2 -width .9i -fill y 
     2131        4,0 $inner.ok -padx 2 -width .9i -fill y
    21322132    blt::table configure $inner r3 -height 4
    21332133    blt::table configure $inner r4 -pady 4
     
    21962196    set _legendPending 0
    21972197    set _title $title
    2198     regsub {\(mag\)} $title "" _title 
     2198    regsub {\(mag\)} $title "" _title
    21992199    if { [IsConnected] } {
    22002200        set bytes [ReceiveBytes $size]
     
    22232223    set font "Arial 8"
    22242224    set lineht [font metrics $font -linespace]
    2225    
     2225
    22262226    if { [info exists _fields($fname)] } {
    22272227        foreach { title units } $_fields($fname) break
     
    22352235        set x [expr $w - 2]
    22362236        if { [$c find withtag "legend"] == "" } {
    2237             set y 2 
     2237            set y 2
    22382238            $c create text $x $y \
    22392239                -anchor ne \
     
    23102310    set font "Arial 8"
    23112311    set lineht [font metrics $font -linespace]
    2312    
     2312
    23132313    set imgHeight [image height $_image(legend)]
    23142314    set coords [$c coords colormap]
     
    23332333    }
    23342334    set color [eval format "\#%02x%02x%02x" $pixel]
    2335     $_image(swatch) put black  -to 0 0 23 23 
    2336     $_image(swatch) put $color -to 1 1 22 22 
     2335    $_image(swatch) put black  -to 0 0 23 23
     2336    $_image(swatch) put $color -to 1 1 22 22
    23372337    .rappturetooltip configure -icon $_image(swatch)
    23382338
     
    23452345        set value 0.0
    23462346    }
    2347     set tipx [expr $x + 15] 
     2347    set tipx [expr $x + 15]
    23482348    set tipy [expr $y - 5]
    23492349    Rappture::Tooltip::text $c "$title $value"
    2350     Rappture::Tooltip::tooltip show $c +$tipx,+$tipy   
     2350    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy
    23512351}
    23522352
     
    23932393# ----------------------------------------------------------------------
    23942394itcl::body Rappture::VtkStreamlinesViewer::Combo {option} {
    2395     set c $itk_component(view) 
     2395    set c $itk_component(view)
    23962396    switch -- $option {
    23972397        post {
     
    24062406        }
    24072407        deactivate {
    2408             $c itemconfigure title -fill white 
     2408            $c itemconfigure title -fill white
    24092409        }
    24102410        invoke {
     
    24182418}
    24192419
    2420 itcl::body Rappture::VtkStreamlinesViewer::SetOrientation { side } { 
     2420itcl::body Rappture::VtkStreamlinesViewer::SetOrientation { side } {
    24212421    array set positions {
    24222422        front "1 0 0 0"
     
    24292429    foreach name { -qw -qx -qy -qz } value $positions($side) {
    24302430        set _view($name) $value
    2431     } 
     2431    }
    24322432    set q [ViewToQuaternion]
    24332433    $_arcball quaternion $q
    2434     SendCmd "camera orient $q" 
     2434    SendCmd "camera orient $q"
    24352435    SendCmd "camera reset"
    24362436    set _view(-xpan) 0
Note: See TracChangeset for help on using the changeset viewer.