Ignore:
Timestamp:
Nov 23, 2014, 1:12:25 AM (10 years ago)
Author:
ldelgass
Message:

merge r4765 from trunk

Location:
branches/1.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3

    • Property svn:mergeinfo changed
      /trunkmerged: 4765
  • branches/1.3/gui/scripts/vtkviewer.tcl

    r4759 r4766  
    6363    public method scale {args}
    6464
    65     protected method Connect {}
    66     protected method CurrentDatasets {args}
    67     protected method Disconnect {}
    68     protected method DoResize {}
    69     protected method DoRotate {}
    70     protected method AdjustSetting {what {value ""}}
    71     protected method InitSettings { args  }
    72     protected method Pan {option x y}
    73     protected method Pick {x y}
    74     protected method Rebuild {}
    75     protected method ReceiveDataset { args }
    76     protected method ReceiveImage { args }
    77     protected method ReceiveLegend { colormap title vmin vmax size }
    78     protected method Rotate {option x y}
    79     protected method Zoom {option}
    80 
    8165    # The following methods are only used by this class.
     66    private method AdjustSetting {what {value ""}}
    8267    private method BuildAxisTab {}
    8368    private method BuildCameraTab {}
     
    8974    private method BuildPolydataTab {}
    9075    private method ChangeColormap { dataobj comp color }
     76    private method Connect {}
     77    private method CurrentDatasets {args}
     78    private method Disconnect {}
     79    private method DoResize {}
     80    private method DoRotate {}
    9181    private method DrawLegend {}
    9282    private method EnterLegend { x y }
     
    10191    private method GetImage { args }
    10292    private method GetVtkData { args }
     93    private method InitSettings { args  }
    10394    private method IsValidObject { dataobj }
    10495    private method LeaveLegend {}
    10596    private method MotionLegend { x y }
     97    private method Pan {option x y}
    10698    private method PanCamera {}
     99    private method Pick {x y}
     100    private method QuaternionToView { q } {
     101        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
     102    }
     103    private method Rebuild {}
     104    private method ReceiveDataset { args }
     105    private method ReceiveImage { args }
     106    private method ReceiveLegend { colormap title vmin vmax size }
    107107    private method RequestLegend {}
     108    private method Rotate {option x y}
    108109    private method SetAtomScale {}
    109110    private method SetBondScale {}
     
    118119    private method SetPolydataOpacity {}
    119120    private method Slice {option args}
     121    private method ViewToQuaternion {} {
     122        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
     123    }
     124    private method Zoom {option}
    120125
    121126    private variable _arcball ""
     
    220225    # Populate parser with commands handle incoming requests
    221226    #
    222     $_parser alias image    [itcl::code $this ReceiveImage]
    223     $_parser alias dataset  [itcl::code $this ReceiveDataset]
    224     $_parser alias legend   [itcl::code $this ReceiveLegend]
     227    $_parser alias image [itcl::code $this ReceiveImage]
     228    $_parser alias dataset [itcl::code $this ReceiveDataset]
     229    $_parser alias legend [itcl::code $this ReceiveLegend]
    225230
    226231    # Initialize the view to some default parameters.
    227232    array set _view {
    228         qw              0.853553
    229         qx              -0.353553
    230         qy              0.353553
    231         qz              0.146447
    232         zoom            1.0
    233         xpan            0
    234         ypan            0
    235         ortho           0
     233        -ortho           0
     234        -qw              0.853553
     235        -qx              -0.353553
     236        -qy              0.353553
     237        -qz              0.146447
     238        -xpan            0
     239        -ypan            0
     240        -zoom            1.0
    236241    }
    237242    set _arcball [blt::arcball create 100 100]
    238     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    239     $_arcball quaternion $q
     243    $_arcball quaternion [ViewToQuaternion]
    240244
    241245    set _limits(zmin) 0.0
     
    358362    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
    359363
    360     BuildAxisTab
    361     #BuildCutawayTab
    362     BuildCameraTab
     364    if { [catch {
     365        BuildAxisTab
     366        #BuildCutawayTab
     367        BuildCameraTab
     368    } errs] != 0 } {
     369        puts stderr errs=$errs
     370    }
    363371
    364372    # Legend
    365 
    366373    set _image(legend) [image create photo]
    367374    itk_component add legend {
     
    389396    bind $itk_component(view) <ButtonRelease-1> \
    390397        [itcl::code $this Rotate release %x %y]
    391     bind $itk_component(view) <Configure> \
    392         [itcl::code $this EventuallyResize %w %h]
    393398
    394399    # Bindings for panning via mouse
     
    468473
    469474itcl::body Rappture::VtkViewer::DoRotate {} {
    470     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    471     SendCmd "camera orient $q"
     475    SendCmd "camera orient [ViewToQuaternion]"
    472476    set _rotatePending 0
    473477}
     
    484488
    485489itcl::body Rappture::VtkViewer::EventuallyRotate { q } {
    486     foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
     490    QuaternionToView $q
    487491    if { !$_rotatePending } {
    488492        set _rotatePending 1
     
    920924
    921925    # disconnected -- no more data sitting on server
     926    set _outbuf ""
    922927    array unset _datasets
    923928    array unset _data
     
    10681073                    lappend info "dataset_size"  $length
    10691074                    lappend info "dataset_tag"   $tag
    1070                     SendCmd [list "clientinfo" $info]
     1075                    SendCmd "clientinfo [list $info]"
    10711076                }
    10721077                SendCmd "dataset add $tag data follows $length"
     
    11231128        }
    11241129
    1125         set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    1126         $_arcball quaternion $q
     1130        $_arcball quaternion [ViewToQuaternion]
    11271131        SendCmd "camera reset"
    1128         if { $_view(ortho)} {
     1132        if { $_view(-ortho)} {
    11291133            SendCmd "camera mode ortho"
    11301134        } else {
     
    12071211    switch -- $option {
    12081212        "in" {
    1209             set _view(zoom) [expr {$_view(zoom)*1.25}]
    1210             SendCmd "camera zoom $_view(zoom)"
     1213            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
     1214            SendCmd "camera zoom $_view(-zoom)"
    12111215        }
    12121216        "out" {
    1213             set _view(zoom) [expr {$_view(zoom)*0.8}]
    1214             SendCmd "camera zoom $_view(zoom)"
     1217            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
     1218            SendCmd "camera zoom $_view(-zoom)"
    12151219        }
    12161220        "reset" {
    12171221            array set _view {
    1218                 qw      0.853553
    1219                 qx      -0.353553
    1220                 qy      0.353553
    1221                 qz      0.146447
    1222                 zoom    1.0
    1223                 xpan    0
    1224                 ypan    0
     1222                -qw      0.853553
     1223                -qx      -0.353553
     1224                -qy      0.353553
     1225                -qz      0.146447
     1226                -xpan    0
     1227                -ypan    0
     1228                -zoom    1.0
    12251229            }
    12261230            if { $_first != "" } {
     
    12301234                }
    12311235            }
    1232             set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    1233             $_arcball quaternion $q
     1236            $_arcball quaternion [ViewToQuaternion]
    12341237            DoRotate
    12351238            SendCmd "camera reset"
     
    12391242
    12401243itcl::body Rappture::VtkViewer::PanCamera {} {
    1241     set x $_view(xpan)
    1242     set y $_view(ypan)
     1244    set x $_view(-xpan)
     1245    set y $_view(-ypan)
    12431246    SendCmd "camera pan $x $y"
    12441247}
     
    13171320            set x [expr $x / double($w)]
    13181321            set y [expr $y / double($h)]
    1319             set _view(xpan) [expr $_view(xpan) + $x]
    1320             set _view(ypan) [expr $_view(ypan) + $y]
     1322            set _view(-xpan) [expr $_view(-xpan) + $x]
     1323            set _view(-ypan) [expr $_view(-ypan) + $y]
    13211324            PanCamera
    13221325            return
     
    13401343            set _click(x) $x
    13411344            set _click(y) $y
    1342             set _view(xpan) [expr $_view(xpan) - $dx]
    1343             set _view(ypan) [expr $_view(ypan) - $dy]
     1345            set _view(-xpan) [expr $_view(-xpan) - $dx]
     1346            set _view(-ypan) [expr $_view(-ypan) - $dy]
    13441347            PanCamera
    13451348        }
     
    18761879itcl::configbody Rappture::VtkViewer::plotbackground {
    18771880    if { [isconnected] } {
    1878         foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break
    1879         SendCmd "screen bgcolor $r $g $b"
     1881        set rgb [Color2RGB $itk_option(-plotbackground)]
     1882        SendCmd "screen bgcolor $rgb"
    18801883    }
    18811884}
     
    18861889itcl::configbody Rappture::VtkViewer::plotforeground {
    18871890    if { [isconnected] } {
    1888         foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break
    1889         #fix this!
    1890         #SendCmd "color background $r $g $b"
     1891        set rgb [Color2RGB $itk_option(-plotforeground)]
     1892        SendCmd "axis color all $rgb"
     1893        SendCmd "outline color $rgb"
    18911894    }
    18921895}
     
    22232226        label $inner.${tag}label -text $tag -font "Arial 9"
    22242227        entry $inner.${tag} -font "Arial 9"  -bg white \
    2225             -textvariable [itcl::scope _view($tag)]
     2228            -textvariable [itcl::scope _view(-$tag)]
    22262229        bind $inner.${tag} <Return> \
    2227             [itcl::code $this camera set ${tag}]
     2230            [itcl::code $this camera set -${tag}]
    22282231        bind $inner.${tag} <KP_Enter> \
    2229             [itcl::code $this camera set ${tag}]
     2232            [itcl::code $this camera set -${tag}]
    22302233        blt::table $inner \
    22312234            $row,0 $inner.${tag}label -anchor e -pady 2 \
     
    22362239    checkbutton $inner.ortho \
    22372240        -text "Orthographic Projection" \
    2238         -variable [itcl::scope _view(ortho)] \
    2239         -command [itcl::code $this camera set ortho] \
     2241        -variable [itcl::scope _view(-ortho)] \
     2242        -command [itcl::code $this camera set -ortho] \
    22402243        -font "Arial 9"
    22412244    blt::table $inner \
     
    25472550        }
    25482551        "set" {
    2549             set who [lindex $args 0]
    2550             set x $_view($who)
     2552            set what [lindex $args 0]
     2553            set x $_view($what)
    25512554            set code [catch { string is double $x } result]
    25522555            if { $code != 0 || !$result } {
    25532556                return
    25542557            }
    2555             switch -- $who {
    2556                 "ortho" {
    2557                     if {$_view(ortho)} {
     2558            switch -- $what {
     2559                "-ortho" {
     2560                    if {$_view($what)} {
    25582561                        SendCmd "camera mode ortho"
    25592562                    } else {
     
    25612564                    }
    25622565                }
    2563                 "xpan" - "ypan" {
     2566                "-xpan" - "-ypan" {
    25642567                    PanCamera
    25652568                }
    2566                 "qx" - "qy" - "qz" - "qw" {
    2567                     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2569                "-qx" - "-qy" - "-qz" - "-qw" {
     2570                    set q [ViewToQuaternion]
    25682571                    $_arcball quaternion $q
    25692572                    EventuallyRotate $q
    25702573                }
    2571                 "zoom" {
    2572                     SendCmd "camera zoom $_view(zoom)"
     2574                "-zoom" {
     2575                    SendCmd "camera zoom $_view($what)"
    25732576                }
    25742577            }
     
    30403043        bottom "0.707107 0.707107 0 0"
    30413044    }
    3042     foreach name { qw qx qy qz } value $positions($side) {
     3045    foreach name { -qw -qx -qy -qz } value $positions($side) {
    30433046        set _view($name) $value
    30443047    }
    3045     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     3048    set q [ViewToQuaternion]
    30463049    $_arcball quaternion $q
    30473050    SendCmd "camera orient $q"
    30483051    SendCmd "camera reset"
    3049     set _view(xpan) 0
    3050     set _view(ypan) 0
    3051     set _view(zoom) 1.0
     3052    set _view(-xpan) 0
     3053    set _view(-ypan) 0
     3054    set _view(-zoom) 1.0
    30523055}
    30533056
Note: See TracChangeset for help on using the changeset viewer.