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

sync up camera settings across viewers

File:
1 edited

Legend:

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

    r4757 r4765  
    4343    itk_option define -plotbackground plotBackground Background ""
    4444    itk_option define -plotoutline plotOutline PlotOutline ""
    45 
    46     private variable _volcomponents   ; # Array of components found
    47     private variable _componentsList   ; # Array of components found
    48     private method BuildVolumeComponents {}
    49     private method GetDatasetsWithComponent { cname }
    5045
    5146    constructor { hostlist args } {
     
    7772    public method updateTransferFunctions {}
    7873
    79     protected method Connect {}
    80     protected method CurrentVolumeIds {{what -all}}
    81     protected method Disconnect {}
    82     protected method Resize {}
    83     protected method ResizeLegend {}
    84     protected method AdjustSetting {what {value ""}}
    85     protected method InitSettings { args }
    86     protected method Pan {option x y}
    87     protected method Rebuild {}
    88     protected method ReceiveData { args }
    89     protected method ReceiveImage { args }
    90     protected method ReceiveLegend { tf vmin vmax size }
    91     protected method Rotate {option x y}
    92     protected method SendTransferFuncs {}
    93     protected method Slice {option args}
    94     protected method SlicerTip {axis}
    95     protected method Zoom {option}
    96 
    9774    # soon to be removed.
    98     protected method Flow {option args}
    99     protected method Play {}
    100     protected method Pause {}
    101 
     75    private method Flow {option args}
     76    private method Play {}
     77    private method Pause {}
    10278
    10379    # The following methods are only used by this class.
    104 
     80    private method AdjustSetting {what {value ""}}
    10581    private method AddIsoMarker { x y }
    10682    private method BuildCameraTab {}
    10783    private method BuildCutplanesTab {}
    10884    private method BuildViewTab {}
     85    private method BuildVolumeComponents {}
    10986    private method BuildVolumeTab {}
    11087    private method ComputeTransferFunc { tf }
     88    private method Connect {}
     89    private method CurrentVolumeIds {{what -all}}
     90    private method Disconnect {}
    11191    private method EventuallyResize { w h }
    11292    private method EventuallyGoto { nSteps }
    11393    private method EventuallyResizeLegend { }
    11494    private method FlowCmd { dataobj comp nbytes extents }
     95    private method GetDatasetsWithComponent { cname }
     96    private method GetFlowInfo { widget }
    11597    private method GetMovie { widget width height }
    11698    private method GetPngImage { widget width height }
     99    private method InitSettings { args }
    117100    private method NameTransferFunc { dataobj comp }
     101    private method Pan {option x y}
    118102    private method PanCamera {}
    119103    private method ParseLevelsOption { tf levels }
    120104    private method ParseMarkersOption { tf markers }
     105    private method QuaternionToView { q } {
     106        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
     107    }
     108    private method Rebuild {}
     109    private method ReceiveData { args }
     110    private method ReceiveImage { args }
     111    private method ReceiveLegend { tf vmin vmax size }
     112    private method Resize {}
     113    private method ResizeLegend {}
     114    private method Rotate {option x y}
     115    private method SendTransferFuncs {}
     116    private method SetOrientation { side }
     117    private method Slice {option args}
     118    private method SlicerTip {axis}
     119    private method ViewToQuaternion {} {
     120        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
     121    }
    121122    private method WaitIcon { option widget }
     123    private method Zoom {option}
     124    private method arrows { tag name }
     125    private method box { tag name }
     126    private method millisecs2str { value }
     127    private method particles { tag name }
    122128    private method str2millisecs { value }
    123     private method millisecs2str { value }
    124     private method GetFlowInfo { widget }
    125     private method particles { tag name }
    126     private method box { tag name }
    127129    private method streams { tag name }
    128     private method arrows { tag name }
    129     private method SetOrientation { side }
    130130
    131131    private variable _arcball ""
     
    149149    private variable _activeTf ""  ;# The currently active transfer function.
    150150    private variable _first ""     ;# This is the topmost volume.
     151    private variable _volcomponents   ; # Array of components found
     152    private variable _componentsList   ; # Array of components found
    151153    private variable _nextToken 0
    152154    private variable _icon 0
     
    218220    # Initialize the view to some default parameters.
    219221    array set _view {
    220         qw      0.853553
    221         qx      -0.353553
    222         qy      0.353553
    223         qz      0.146447
    224         zoom    1.0
    225         xpan    0
    226         ypan    0
     222        -qw      0.853553
     223        -qx      -0.353553
     224        -qy      0.353553
     225        -qz      0.146447
     226        -xpan    0
     227        -ypan    0
     228        -zoom    1.0
    227229    }
    228230    set _arcball [blt::arcball create 100 100]
    229     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    230     $_arcball quaternion $q
     231    $_arcball quaternion [ViewToQuaternion]
    231232
    232233    set _limits(v) [list 0.0 1.0]
     
    234235
    235236    array set _settings [subst {
    236         $this-qw                $_view(qw)
    237         $this-qx                $_view(qx)
    238         $this-qy                $_view(qy)
    239         $this-qz                $_view(qz)
    240         $this-zoom              $_view(zoom)   
    241         $this-xpan              $_view(xpan)
    242         $this-ypan              $_view(ypan)
     237        $this-qw                $_view(-qw)
     238        $this-qx                $_view(-qx)
     239        $this-qy                $_view(-qy)
     240        $this-qz                $_view(-qz)
     241        $this-zoom              $_view(-zoom)   
     242        $this-xpan              $_view(-xpan)
     243        $this-ypan              $_view(-ypan)
    243244        $this-arrows            0
    244245        $this-currenttime       0
     
    12131214
    12141215    }
    1215     set _settings($this-qw)    $_view(qw)
    1216     set _settings($this-qx)    $_view(qx)
    1217     set _settings($this-qy)    $_view(qy)
    1218     set _settings($this-qz)    $_view(qz)
    1219     set _settings($this-xpan)  $_view(xpan)
    1220     set _settings($this-ypan)  $_view(ypan)
    1221     set _settings($this-zoom)  $_view(zoom)
    1222 
    1223     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1216    set _settings($this-qw)    $_view(-qw)
     1217    set _settings($this-qx)    $_view(-qx)
     1218    set _settings($this-qy)    $_view(-qy)
     1219    set _settings($this-qz)    $_view(-qz)
     1220    set _settings($this-xpan)  $_view(-xpan)
     1221    set _settings($this-ypan)  $_view(-ypan)
     1222    set _settings($this-zoom)  $_view(-zoom)
     1223
     1224    set q [ViewToQuaternion]
    12241225    $_arcball quaternion $q
    12251226    SendCmd "camera orient $q"
    12261227    SendCmd "camera reset"
    12271228    PanCamera
    1228     SendCmd "camera zoom $_view(zoom)"
     1229    SendCmd "camera zoom $_view(-zoom)"
    12291230
    12301231    foreach dataobj [get] {
     
    13051306    switch -- $option {
    13061307        "in" {
    1307             set _view(zoom) [expr {$_view(zoom)*1.25}]
    1308             set _settings($this-zoom) $_view(zoom)
    1309             SendCmd "camera zoom $_view(zoom)"
     1308            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
     1309            set _settings($this-zoom) $_view(-zoom)
     1310            SendCmd "camera zoom $_view(-zoom)"
    13101311        }
    13111312        "out" {
    1312             set _view(zoom) [expr {$_view(zoom)*0.8}]
    1313             set _settings($this-zoom) $_view(zoom)
    1314             SendCmd "camera zoom $_view(zoom)"
     1313            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
     1314            set _settings($this-zoom) $_view(-zoom)
     1315            SendCmd "camera zoom $_view(-zoom)"
    13151316        }
    13161317        "reset" {
    13171318            array set _view {
    1318                 qw      0.853553
    1319                 qx      -0.353553
    1320                 qy      0.353553
    1321                 qz      0.146447
    1322                 zoom    1.0
    1323                 xpan   0
    1324                 ypan   0
     1319                -qw      0.853553
     1320                -qx      -0.353553
     1321                -qy      0.353553
     1322                -qz      0.146447
     1323                -zoom    1.0
     1324                -xpan    0
     1325                -ypan    0
    13251326            }
    13261327            if { $_first != "" } {
     
    13301331                }
    13311332            }
    1332             set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1333            set q [ViewToQuaternion]
    13331334            $_arcball quaternion $q
    13341335            SendCmd "camera orient $q"
    13351336            SendCmd "camera reset"
    1336             set _settings($this-qw)    $_view(qw)
    1337             set _settings($this-qx)    $_view(qx)
    1338             set _settings($this-qy)    $_view(qy)
    1339             set _settings($this-qz)    $_view(qz)
    1340             set _settings($this-xpan)  $_view(xpan)
    1341             set _settings($this-ypan)  $_view(ypan)
    1342             set _settings($this-zoom)  $_view(zoom)
     1337            set _settings($this-qw)    $_view(-qw)
     1338            set _settings($this-qx)    $_view(-qx)
     1339            set _settings($this-qy)    $_view(-qy)
     1340            set _settings($this-qz)    $_view(-qz)
     1341            set _settings($this-xpan)  $_view(-xpan)
     1342            set _settings($this-ypan)  $_view(-ypan)
     1343            set _settings($this-zoom)  $_view(-zoom)
    13431344        }
    13441345    }
     
    13461347
    13471348itcl::body Rappture::FlowvisViewer::PanCamera {} {
    1348     set x $_view(xpan)
    1349     set y $_view(ypan)
     1349    set x $_view(-xpan)
     1350    set y $_view(-ypan)
    13501351    SendCmd "camera pan $x $y"
    13511352}
     
    13851386
    13861387                set q [$_arcball rotate $x $y $_click(x) $_click(y)]
    1387                 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
    1388                 set _settings($this-qw) $_view(qw)
    1389                 set _settings($this-qx) $_view(qx)
    1390                 set _settings($this-qy) $_view(qy)
    1391                 set _settings($this-qz) $_view(qz)
     1388                QuaternionToView $q
     1389                set _settings($this-qw) $_view(-qw)
     1390                set _settings($this-qx) $_view(-qx)
     1391                set _settings($this-qy) $_view(-qy)
     1392                set _settings($this-qz) $_view(-qz)
    13921393                SendCmd "camera orient $q"
    13931394
     
    14221423        set x [expr $x / double($w)]
    14231424        set y [expr $y / double($h)]
    1424         set _view(xpan) [expr $_view(xpan) + $x]
    1425         set _view(ypan) [expr $_view(ypan) + $y]
     1425        set _view(-xpan) [expr $_view(-xpan) + $x]
     1426        set _view(-ypan) [expr $_view(-ypan) + $y]
    14261427        PanCamera
    1427         set _settings($this-xpan) $_view(xpan)
    1428         set _settings($this-ypan) $_view(ypan)
     1428        set _settings($this-xpan) $_view(-xpan)
     1429        set _settings($this-ypan) $_view(-ypan)
    14291430        return
    14301431    }
     
    14391440        set _click(x) $x
    14401441        set _click(y) $y
    1441         set _view(xpan) [expr $_view(xpan) - $dx]
    1442         set _view(ypan) [expr $_view(ypan) - $dy]
     1442        set _view(-xpan) [expr $_view(-xpan) - $dx]
     1443        set _view(-ypan) [expr $_view(-ypan) - $dy]
    14431444        PanCamera
    1444         set _settings($this-xpan) $_view(xpan)
    1445         set _settings($this-ypan) $_view(ypan)
     1445        set _settings($this-xpan) $_view(-xpan)
     1446        set _settings($this-ypan) $_view(-ypan)
    14461447    }
    14471448    if { $option == "release" } {
     
    23842385            -textvariable [itcl::scope _settings($this-$tag)]
    23852386        bind $inner.${tag} <Return> \
    2386             [itcl::code $this camera set ${tag}]
     2387            [itcl::code $this camera set -${tag}]
    23872388        bind $inner.${tag} <KP_Enter> \
    2388             [itcl::code $this camera set ${tag}]
     2389            [itcl::code $this camera set -${tag}]
    23892390        blt::table $inner \
    23902391            $row,0 $inner.${tag}label -anchor e -pady 2 \
     
    25882589        }
    25892590        "set" {
    2590             set who [lindex $args 0]
    2591             set x $_settings($this-$who)
     2591            set what [lindex $args 0]
     2592            set x $_settings(${this}${what})
    25922593            set code [catch { string is double $x } result]
    25932594            if { $code != 0 || !$result } {
    2594                 set _settings($this-$who) $_view($who)
     2595                set _settings(${this}${what}) $_view($what)
    25952596                return
    25962597            }
    2597             switch -- $who {
    2598                 "xpan" - "ypan" {
    2599                     set _view($who) $_settings($this-$who)
     2598            switch -- $what {
     2599                "-xpan" - "-ypan" {
     2600                    set _view($what) $_settings(${this}${what})
    26002601                    PanCamera
    26012602                }
    2602                 "qx" - "qy" - "qz" - "qw" {
    2603                     set _view($who) $_settings($this-$who)
    2604                     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2603                "-qx" - "-qy" - "-qz" - "-qw" {
     2604                    set _view($what) $_settings(${this}${what})
     2605                    set q [ViewToQuaternion]
    26052606                    $_arcball quaternion $q
    26062607                    SendCmd "camera orient $q"
    26072608                }
    2608                 "zoom" {
    2609                     set _view($who) $_settings($this-$who)
    2610                     SendCmd "camera zoom $_view(zoom)"
     2609                "-zoom" {
     2610                    set _view($what) $_settings(${this}${what})
     2611                    SendCmd "camera zoom $_view($what)"
    26112612                }
    26122613            }
     
    29862987        bottom "0.707107 0.707107 0 0"
    29872988    }
    2988     foreach name { qw qx qy qz } value $positions($side) {
     2989    foreach name { -qw -qx -qy -qz } value $positions($side) {
    29892990        set _view($name) $value
    29902991    }
    2991     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2992    set q [ViewToQuaternion]
    29922993    $_arcball quaternion $q
    29932994    SendCmd "camera orient $q"
    29942995    SendCmd "camera reset"
    2995     set _view(xpan) 0.0
    2996     set _view(ypan) 0.0
    2997     set _view(zoom) 1.0
    2998     set _settings($this-xpan) $_view(xpan)
    2999     set _settings($this-ypan) $_view(ypan)
    3000     set _settings($this-zoom) $_view(zoom)
     2996    set _view(-xpan) 0.0
     2997    set _view(-ypan) 0.0
     2998    set _view(-zoom) 1.0
     2999    set _settings($this-xpan) $_view(-xpan)
     3000    set _settings($this-ypan) $_view(-ypan)
     3001    set _settings($this-zoom) $_view(-zoom)
    30013002}
    30023003
Note: See TracChangeset for help on using the changeset viewer.