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/vtkmeshviewer.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 Rotate {option x y}
    78     protected method Zoom {option}
    79 
    8065    # The following methods are only used by this class.
     66    private method AdjustSetting {what {value ""}}
    8167    private method BuildAxisTab {}
    8268    private method BuildCameraTab {}
    8369    private method BuildDownloadPopup { widget command }
    8470    private method BuildPolydataTab {}
     71    private method Connect {}
     72    private method CurrentDatasets {args}
     73    private method Disconnect {}
     74    private method DoResize {}
     75    private method DoRotate {}
    8576    private method EventuallyResize { w h }
    8677    private method EventuallyRotate { q }
     
    8879    private method GetImage { args }
    8980    private method GetVtkData { args }
     81    private method InitSettings { args  }
    9082    private method IsValidObject { dataobj }
     83    private method Pan {option x y}
    9184    private method PanCamera {}
     85    private method Pick {x y}
     86    private method QuaternionToView { q } {
     87        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
     88    }
     89    private method Rebuild {}
     90    private method ReceiveDataset { args }
     91    private method ReceiveImage { args }
     92    private method Rotate {option x y}
    9293    private method SetObjectStyle { dataobj }
    9394    private method SetOrientation { side }
    9495    private method SetPolydataOpacity {}
     96    private method ViewToQuaternion {} {
     97        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
     98    }
     99    private method Zoom {option}
    95100
    96101    private variable _arcball ""
     
    164169    # Initialize the view to some default parameters.
    165170    array set _view {
    166         qw              0.853553
    167         qx              -0.353553
    168         qy              0.353553
    169         qz              0.146447
    170         zoom            1.0
    171         xpan            0
    172         ypan            0
    173         ortho           0
     171        -ortho           0
     172        -qw              0.853553
     173        -qx              -0.353553
     174        -qy              0.353553
     175        -qz              0.146447
     176        -xpan            0
     177        -ypan            0
     178        -zoom            1.0
    174179    }
    175180    set _arcball [blt::arcball create 100 100]
    176     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    177     $_arcball quaternion $q
     181    $_arcball quaternion [ViewToQuaternion]
    178182
    179183    set _limits(zmin) 0.0
     
    291295    bind $itk_component(view) <ButtonRelease-1> \
    292296        [itcl::code $this Rotate release %x %y]
    293     bind $itk_component(view) <Configure> \
    294         [itcl::code $this EventuallyResize %w %h]
    295297
    296298    # Bindings for panning via mouse
     
    370372
    371373itcl::body Rappture::VtkMeshViewer::DoRotate {} {
    372     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    373     SendCmd "camera orient $q"
     374    SendCmd "camera orient [ViewToQuaternion]"
    374375    set _rotatePending 0
    375376}
     
    386387
    387388itcl::body Rappture::VtkMeshViewer::EventuallyRotate { q } {
    388     foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
     389    QuaternionToView $q
    389390    if { !$_rotatePending } {
    390391        set _rotatePending 1
     
    855856                lappend info "dataset_size"  $length
    856857                lappend info "dataset_tag"   $tag
    857                 SendCmd [list "clientinfo" $info]
     858                SendCmd "clientinfo [list $info]"
    858859            }
    859860            SendCmd "dataset add $tag data follows $length"
     
    893894        #SendCmd "axis lformat all %g"
    894895
    895         set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    896         $_arcball quaternion $q
     896        $_arcball quaternion [ViewToQuaternion]
    897897        SendCmd "camera reset"
    898         if { $_view(ortho)} {
     898        if { $_view(-ortho)} {
    899899            SendCmd "camera mode ortho"
    900900        } else {
     
    971971    switch -- $option {
    972972        "in" {
    973             set _view(zoom) [expr {$_view(zoom)*1.25}]
    974             SendCmd "camera zoom $_view(zoom)"
     973            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
     974            SendCmd "camera zoom $_view(-zoom)"
    975975        }
    976976        "out" {
    977             set _view(zoom) [expr {$_view(zoom)*0.8}]
    978             SendCmd "camera zoom $_view(zoom)"
     977            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
     978            SendCmd "camera zoom $_view(-zoom)"
    979979        }
    980980        "reset" {
    981981            array set _view {
    982                 qw      0.853553
    983                 qx      -0.353553
    984                 qy      0.353553
    985                 qz      0.146447
    986                 zoom    1.0
    987                 xpan    0
    988                 ypan    0
     982                -qw      0.853553
     983                -qx      -0.353553
     984                -qy      0.353553
     985                -qz      0.146447
     986                -xpan    0
     987                -ypan    0
     988                -zoom    1.0
    989989            }
    990990            if { $_first != "" } {
     
    994994                }
    995995            }
    996             set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    997             $_arcball quaternion $q
     996            $_arcball quaternion [ViewToQuaternion]
    998997            DoRotate
    999998            SendCmd "camera reset"
     
    10031002
    10041003itcl::body Rappture::VtkMeshViewer::PanCamera {} {
    1005     set x $_view(xpan)
    1006     set y $_view(ypan)
     1004    set x $_view(-xpan)
     1005    set y $_view(-ypan)
    10071006    SendCmd "camera pan $x $y"
    10081007}
     
    10811080            set x [expr $x / double($w)]
    10821081            set y [expr $y / double($h)]
    1083             set _view(xpan) [expr $_view(xpan) + $x]
    1084             set _view(ypan) [expr $_view(ypan) + $y]
     1082            set _view(-xpan) [expr $_view(-xpan) + $x]
     1083            set _view(-ypan) [expr $_view(-ypan) + $y]
    10851084            PanCamera
    10861085            return
     
    11041103            set _click(x) $x
    11051104            set _click(y) $y
    1106             set _view(xpan) [expr $_view(xpan) - $dx]
    1107             set _view(ypan) [expr $_view(ypan) - $dy]
     1105            set _view(-xpan) [expr $_view(-xpan) - $dx]
     1106            set _view(-ypan) [expr $_view(-ypan) - $dy]
    11081107            PanCamera
    11091108        }
     
    12141213itcl::configbody Rappture::VtkMeshViewer::plotbackground {
    12151214    if { [isconnected] } {
    1216         foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break
    1217         SendCmd "screen bgcolor $r $g $b"
     1215        set rgb [Color2RGB $itk_option(-plotbackground)]
     1216        SendCmd "screen bgcolor $rgb"
    12181217    }
    12191218}
     
    12241223itcl::configbody Rappture::VtkMeshViewer::plotforeground {
    12251224    if { [isconnected] } {
    1226         foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break
    1227         #fix this!
    1228         #SendCmd "color background $r $g $b"
     1225        set rgb [Color2RGB $itk_option(-plotforeground)]
     1226        SendCmd "axis color all $rgb"
     1227        SendCmd "outline color $rgb"
    12291228    }
    12301229}
     
    14421441        label $inner.${tag}label -text $tag -font "Arial 9"
    14431442        entry $inner.${tag} -font "Arial 9"  -bg white \
    1444             -textvariable [itcl::scope _view($tag)]
     1443            -textvariable [itcl::scope _view(-$tag)]
    14451444        bind $inner.${tag} <Return> \
    1446             [itcl::code $this camera set ${tag}]
     1445            [itcl::code $this camera set -${tag}]
    14471446        bind $inner.${tag} <KP_Enter> \
    1448             [itcl::code $this camera set ${tag}]
     1447            [itcl::code $this camera set -${tag}]
    14491448        blt::table $inner \
    14501449            $row,0 $inner.${tag}label -anchor e -pady 2 \
     
    14551454    checkbutton $inner.ortho \
    14561455        -text "Orthographic Projection" \
    1457         -variable [itcl::scope _view(ortho)] \
    1458         -command [itcl::code $this camera set ortho] \
     1456        -variable [itcl::scope _view(-ortho)] \
     1457        -command [itcl::code $this camera set -ortho] \
    14591458        -font "Arial 9"
    14601459    blt::table $inner \
     
    14771476        }
    14781477        "set" {
    1479             set who [lindex $args 0]
    1480             set x $_view($who)
     1478            set what [lindex $args 0]
     1479            set x $_view($what)
    14811480            set code [catch { string is double $x } result]
    14821481            if { $code != 0 || !$result } {
    14831482                return
    14841483            }
    1485             switch -- $who {
    1486                 "ortho" {
    1487                     if {$_view(ortho)} {
     1484            switch -- $what {
     1485                "-ortho" {
     1486                    if {$_view($what)} {
    14881487                        SendCmd "camera mode ortho"
    14891488                    } else {
     
    14911490                    }
    14921491                }
    1493                 "xpan" - "ypan" {
     1492                "-xpan" - "-ypan" {
    14941493                    PanCamera
    14951494                }
    1496                 "qx" - "qy" - "qz" - "qw" {
    1497                     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1495                "-qx" - "-qy" - "-qz" - "-qw" {
     1496                    set q [ViewToQuaternion]
    14981497                    $_arcball quaternion $q
    14991498                    EventuallyRotate $q
    15001499                }
    1501                 "zoom" {
    1502                     SendCmd "camera zoom $_view(zoom)"
     1500                "-zoom" {
     1501                    SendCmd "camera zoom $_view($what)"
    15031502                }
    15041503            }
     
    16371636        bottom "0.707107 0.707107 0 0"
    16381637    }
    1639     foreach name { qw qx qy qz } value $positions($side) {
     1638    foreach name { -qw -qx -qy -qz } value $positions($side) {
    16401639        set _view($name) $value
    16411640    }
    1642     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1641    set q [ViewToQuaternion]
    16431642    $_arcball quaternion $q
    16441643    SendCmd "camera orient $q"
    16451644    SendCmd "camera reset"
    1646     set _view(xpan) 0
    1647     set _view(ypan) 0
    1648     set _view(zoom) 1.0
    1649 }
     1645    set _view(-xpan) 0
     1646    set _view(-ypan) 0
     1647    set _view(-zoom) 1.0
     1648}
Note: See TracChangeset for help on using the changeset viewer.