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

merge r4765 from trunk

Location:
branches/1.3
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3

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

    r4759 r4766  
    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
     
    11911192
    11921193    }
    1193     set _settings($this-qw)    $_view(qw)
    1194     set _settings($this-qx)    $_view(qx)
    1195     set _settings($this-qy)    $_view(qy)
    1196     set _settings($this-qz)    $_view(qz)
    1197     set _settings($this-xpan)  $_view(xpan)
    1198     set _settings($this-ypan)  $_view(ypan)
    1199     set _settings($this-zoom)  $_view(zoom)
    1200 
    1201     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1194    set _settings($this-qw)    $_view(-qw)
     1195    set _settings($this-qx)    $_view(-qx)
     1196    set _settings($this-qy)    $_view(-qy)
     1197    set _settings($this-qz)    $_view(-qz)
     1198    set _settings($this-xpan)  $_view(-xpan)
     1199    set _settings($this-ypan)  $_view(-ypan)
     1200    set _settings($this-zoom)  $_view(-zoom)
     1201
     1202    set q [ViewToQuaternion]
    12021203    $_arcball quaternion $q
    12031204    SendCmd "camera orient $q"
    12041205    SendCmd "camera reset"
    12051206    PanCamera
    1206     SendCmd "camera zoom $_view(zoom)"
     1207    SendCmd "camera zoom $_view(-zoom)"
    12071208
    12081209    foreach dataobj [get] {
     
    12841285    switch -- $option {
    12851286        "in" {
    1286             set _view(zoom) [expr {$_view(zoom)*1.25}]
    1287             set _settings($this-zoom) $_view(zoom)
    1288             SendCmd "camera zoom $_view(zoom)"
     1287            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
     1288            set _settings($this-zoom) $_view(-zoom)
     1289            SendCmd "camera zoom $_view(-zoom)"
    12891290        }
    12901291        "out" {
    1291             set _view(zoom) [expr {$_view(zoom)*0.8}]
    1292             set _settings($this-zoom) $_view(zoom)
    1293             SendCmd "camera zoom $_view(zoom)"
     1292            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
     1293            set _settings($this-zoom) $_view(-zoom)
     1294            SendCmd "camera zoom $_view(-zoom)"
    12941295        }
    12951296        "reset" {
    12961297            array set _view {
    1297                 qw      0.853553
    1298                 qx      -0.353553
    1299                 qy      0.353553
    1300                 qz      0.146447
    1301                 zoom    1.0
    1302                 xpan   0
    1303                 ypan   0
     1298                -qw      0.853553
     1299                -qx      -0.353553
     1300                -qy      0.353553
     1301                -qz      0.146447
     1302                -zoom    1.0
     1303                -xpan    0
     1304                -ypan    0
    13041305            }
    13051306            if { $_first != "" } {
     
    13091310                }
    13101311            }
    1311             set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1312            set q [ViewToQuaternion]
    13121313            $_arcball quaternion $q
    13131314            SendCmd "camera orient $q"
    13141315            SendCmd "camera reset"
    1315             set _settings($this-qw)    $_view(qw)
    1316             set _settings($this-qx)    $_view(qx)
    1317             set _settings($this-qy)    $_view(qy)
    1318             set _settings($this-qz)    $_view(qz)
    1319             set _settings($this-xpan)  $_view(xpan)
    1320             set _settings($this-ypan)  $_view(ypan)
    1321             set _settings($this-zoom)  $_view(zoom)
     1316            set _settings($this-qw)    $_view(-qw)
     1317            set _settings($this-qx)    $_view(-qx)
     1318            set _settings($this-qy)    $_view(-qy)
     1319            set _settings($this-qz)    $_view(-qz)
     1320            set _settings($this-xpan)  $_view(-xpan)
     1321            set _settings($this-ypan)  $_view(-ypan)
     1322            set _settings($this-zoom)  $_view(-zoom)
    13221323        }
    13231324    }
     
    13251326
    13261327itcl::body Rappture::FlowvisViewer::PanCamera {} {
    1327     set x $_view(xpan)
    1328     set y $_view(ypan)
     1328    set x $_view(-xpan)
     1329    set y $_view(-ypan)
    13291330    SendCmd "camera pan $x $y"
    13301331}
     
    13641365
    13651366                set q [$_arcball rotate $x $y $_click(x) $_click(y)]
    1366                 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
    1367                 set _settings($this-qw) $_view(qw)
    1368                 set _settings($this-qx) $_view(qx)
    1369                 set _settings($this-qy) $_view(qy)
    1370                 set _settings($this-qz) $_view(qz)
     1367                QuaternionToView $q
     1368                set _settings($this-qw) $_view(-qw)
     1369                set _settings($this-qx) $_view(-qx)
     1370                set _settings($this-qy) $_view(-qy)
     1371                set _settings($this-qz) $_view(-qz)
    13711372                SendCmd "camera orient $q"
    13721373
     
    14011402        set x [expr $x / double($w)]
    14021403        set y [expr $y / double($h)]
    1403         set _view(xpan) [expr $_view(xpan) + $x]
    1404         set _view(ypan) [expr $_view(ypan) + $y]
     1404        set _view(-xpan) [expr $_view(-xpan) + $x]
     1405        set _view(-ypan) [expr $_view(-ypan) + $y]
    14051406        PanCamera
    1406         set _settings($this-xpan) $_view(xpan)
    1407         set _settings($this-ypan) $_view(ypan)
     1407        set _settings($this-xpan) $_view(-xpan)
     1408        set _settings($this-ypan) $_view(-ypan)
    14081409        return
    14091410    }
     
    14181419        set _click(x) $x
    14191420        set _click(y) $y
    1420         set _view(xpan) [expr $_view(xpan) - $dx]
    1421         set _view(ypan) [expr $_view(ypan) - $dy]
     1421        set _view(-xpan) [expr $_view(-xpan) - $dx]
     1422        set _view(-ypan) [expr $_view(-ypan) - $dy]
    14221423        PanCamera
    1423         set _settings($this-xpan) $_view(xpan)
    1424         set _settings($this-ypan) $_view(ypan)
     1424        set _settings($this-xpan) $_view(-xpan)
     1425        set _settings($this-ypan) $_view(-ypan)
    14251426    }
    14261427    if { $option == "release" } {
     
    23092310            -textvariable [itcl::scope _settings($this-$tag)]
    23102311        bind $inner.${tag} <Return> \
    2311             [itcl::code $this camera set ${tag}]
     2312            [itcl::code $this camera set -${tag}]
    23122313        bind $inner.${tag} <KP_Enter> \
    2313             [itcl::code $this camera set ${tag}]
     2314            [itcl::code $this camera set -${tag}]
    23142315        blt::table $inner \
    23152316            $row,0 $inner.${tag}label -anchor e -pady 2 \
     
    25132514        }
    25142515        "set" {
    2515             set who [lindex $args 0]
    2516             set x $_settings($this-$who)
     2516            set what [lindex $args 0]
     2517            set x $_settings(${this}${what})
    25172518            set code [catch { string is double $x } result]
    25182519            if { $code != 0 || !$result } {
    2519                 set _settings($this-$who) $_view($who)
     2520                set _settings(${this}${what}) $_view($what)
    25202521                return
    25212522            }
    2522             switch -- $who {
    2523                 "xpan" - "ypan" {
    2524                     set _view($who) $_settings($this-$who)
     2523            switch -- $what {
     2524                "-xpan" - "-ypan" {
     2525                    set _view($what) $_settings(${this}${what})
    25252526                    PanCamera
    25262527                }
    2527                 "qx" - "qy" - "qz" - "qw" {
    2528                     set _view($who) $_settings($this-$who)
    2529                     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2528                "-qx" - "-qy" - "-qz" - "-qw" {
     2529                    set _view($what) $_settings(${this}${what})
     2530                    set q [ViewToQuaternion]
    25302531                    $_arcball quaternion $q
    25312532                    SendCmd "camera orient $q"
    25322533                }
    2533                 "zoom" {
    2534                     set _view($who) $_settings($this-$who)
    2535                     SendCmd "camera zoom $_view(zoom)"
     2534                "-zoom" {
     2535                    set _view($what) $_settings(${this}${what})
     2536                    SendCmd "camera zoom $_view($what)"
    25362537                }
    25372538            }
     
    29112912        bottom "0.707107 0.707107 0 0"
    29122913    }
    2913     foreach name { qw qx qy qz } value $positions($side) {
     2914    foreach name { -qw -qx -qy -qz } value $positions($side) {
    29142915        set _view($name) $value
    29152916    }
    2916     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2917    set q [ViewToQuaternion]
    29172918    $_arcball quaternion $q
    29182919    SendCmd "camera orient $q"
    29192920    SendCmd "camera reset"
    2920     set _view(xpan) 0.0
    2921     set _view(ypan) 0.0
    2922     set _view(zoom) 1.0
    2923     set _settings($this-xpan) $_view(xpan)
    2924     set _settings($this-ypan) $_view(ypan)
    2925     set _settings($this-zoom) $_view(zoom)
     2921    set _view(-xpan) 0.0
     2922    set _view(-ypan) 0.0
     2923    set _view(-zoom) 1.0
     2924    set _settings($this-xpan) $_view(-xpan)
     2925    set _settings($this-ypan) $_view(-ypan)
     2926    set _settings($this-zoom) $_view(-zoom)
    29262927}
    29272928
  • branches/1.3/gui/scripts/nanovisviewer.tcl

    r4750 r4766  
    113113    private method ParseLevelsOption { cname levels }
    114114    private method ParseMarkersOption { cname markers }
     115    private method QuaternionToView { q } {
     116        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
     117    }
    115118    private method Rebuild {}
    116119    private method ReceiveData { args }
     
    127130    private method SwitchComponent { cname }
    128131    private method ToggleVolume { tag name }
    129     private method Zoom {option}
    130132    private method ViewToQuaternion {} {
    131133        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
    132134    }
     135    private method Zoom {option}
    133136
    134137    private variable _arcball ""
     
    11261129
    11271130                set q [$_arcball rotate $x $y $_click(x) $_click(y)]
    1128                 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
     1131                QuaternionToView $q
    11291132                set _settings(-qw) $_view(-qw)
    11301133                set _settings(-qx) $_view(-qx)
  • branches/1.3/gui/scripts/vtkglyphviewer.tcl

    r4762 r4766  
    6262    public method scale {args}
    6363
    64     protected method Connect {}
    65     protected method CurrentDatasets {args}
    66     protected method Disconnect {}
    67     protected method DoResize {}
    68     protected method DoRotate {}
    69     protected method AdjustSetting {what {value ""}}
    70     protected method InitSettings { args  }
    71     protected method Pan {option x y}
    72     protected method Pick {x y}
    73     protected method Rebuild {}
    74     protected method ReceiveDataset { args }
    75     protected method ReceiveImage { args }
    76     protected method ReceiveLegend { colormap title vmin vmax size }
    77     protected method Rotate {option x y}
    78     protected method Zoom {option}
    79 
    8064    # The following methods are only used by this class.
     65    private method AdjustSetting {what {value ""}}
    8166    private method BuildAxisTab {}
    8267    private method BuildCameraTab {}
     
    8772    private method DrawLegend {}
    8873    private method Combo { option }
     74    private method Connect {}
     75    private method CurrentDatasets {args}
     76    private method Disconnect {}
     77    private method DoResize {}
     78    private method DoRotate {}
    8979    private method EnterLegend { x y }
    9080    private method EventuallyResize { w h }
     
    9484    private method GetImage { args }
    9585    private method GetVtkData { args }
     86    private method InitSettings { args  }
    9687    private method IsValidObject { dataobj }
    9788    private method LeaveLegend {}
    9889    private method MotionLegend { x y }
     90    private method Pan {option x y}
    9991    private method PanCamera {}
     92    private method Pick {x y}
     93    private method QuaternionToView { q } {
     94        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
     95    }
     96    private method Rebuild {}
     97    private method ReceiveDataset { args }
     98    private method ReceiveImage { args }
     99    private method ReceiveLegend { colormap title vmin vmax size }
    100100    private method RequestLegend {}
     101    private method Rotate {option x y}
    101102    private method SetLegendTip { x y }
    102103    private method SetObjectStyle { dataobj comp }
     
    104105    private method SetCurrentColormap { color }
    105106    private method SetOrientation { side }
     107    private method ViewToQuaternion {} {
     108        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
     109    }
     110    private method Zoom {option}
    106111
    107112    private variable _arcball ""
     
    202207    # Initialize the view to some default parameters.
    203208    array set _view {
    204         qw              0.853553
    205         qx              -0.353553
    206         qy              0.353553
    207         qz              0.146447
    208         zoom            1.0
    209         xpan            0
    210         ypan            0
    211         ortho           0
     209        -ortho           0
     210        -qw              0.853553
     211        -qx              -0.353553
     212        -qy              0.353553
     213        -qz              0.146447
     214        -xpan            0
     215        -ypan            0
     216        -zoom            1.0
    212217    }
    213218    set _arcball [blt::arcball create 100 100]
    214     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    215     $_arcball quaternion $q
     219    $_arcball quaternion [ViewToQuaternion]
    216220
    217221    array set _settings [subst {
     
    466470
    467471itcl::body Rappture::VtkGlyphViewer::DoRotate {} {
    468     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    469     SendCmd "camera orient $q"
     472    SendCmd "camera orient [ViewToQuaternion]"
    470473    set _rotatePending 0
    471474}
     
    491494
    492495itcl::body Rappture::VtkGlyphViewer::EventuallyRotate { q } {
    493     foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
     496    QuaternionToView $q
    494497    if { !$_rotatePending } {
    495498        set _rotatePending 1
     
    836839    array unset _data
    837840    array unset _colormaps
    838     array unset _seeds
    839841    array unset _dataset2style
    840842    array unset _obj2datasets
     
    947949        # Reset the camera and other view parameters
    948950        #
    949         set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    950         $_arcball quaternion $q
    951         if {$_view(ortho)} {
     951        $_arcball quaternion [ViewToQuaternion]
     952        if {$_view(-ortho)} {
    952953            SendCmd "camera mode ortho"
    953954        } else {
     
    11301131    switch -- $option {
    11311132        "in" {
    1132             set _view(zoom) [expr {$_view(zoom)*1.25}]
    1133             SendCmd "camera zoom $_view(zoom)"
     1133            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
     1134            SendCmd "camera zoom $_view(-zoom)"
    11341135        }
    11351136        "out" {
    1136             set _view(zoom) [expr {$_view(zoom)*0.8}]
    1137             SendCmd "camera zoom $_view(zoom)"
     1137            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
     1138            SendCmd "camera zoom $_view(-zoom)"
    11381139        }
    11391140        "reset" {
    11401141            array set _view {
    1141                 qw     0.853553
    1142                 qx     -0.353553
    1143                 qy     0.353553
    1144                 qz     0.146447
    1145                 zoom   1.0
    1146                 xpan   0
    1147                 ypan   0
     1142                -qw      0.853553
     1143                -qx      -0.353553
     1144                -qy      0.353553
     1145                -qz      0.146447
     1146                -xpan    0
     1147                -ypan    0
     1148                -zoom    1.0
    11481149            }
    11491150            if { $_first != "" } {
     
    11531154                }
    11541155            }
    1155             set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    1156             $_arcball quaternion $q
     1156            $_arcball quaternion [ViewToQuaternion]
    11571157            DoRotate
    11581158            SendCmd "camera reset"
     
    11621162
    11631163itcl::body Rappture::VtkGlyphViewer::PanCamera {} {
    1164     set x $_view(xpan)
    1165     set y $_view(ypan)
     1164    set x $_view(-xpan)
     1165    set y $_view(-ypan)
    11661166    SendCmd "camera pan $x $y"
    11671167}
     
    12211221itcl::body Rappture::VtkGlyphViewer::Pick {x y} {
    12221222    foreach tag [CurrentDatasets -visible] {
    1223         SendCmdNoSplash "dataset getscalar pixel $x $y $tag"
     1223        SendCmd "dataset getscalar pixel $x $y $tag"
    12241224    }
    12251225}
     
    12401240            set x [expr $x / double($w)]
    12411241            set y [expr $y / double($h)]
    1242             set _view(xpan) [expr $_view(xpan) + $x]
    1243             set _view(ypan) [expr $_view(ypan) + $y]
     1242            set _view(-xpan) [expr $_view(-xpan) + $x]
     1243            set _view(-ypan) [expr $_view(-ypan) + $y]
    12441244            PanCamera
    12451245            return
     
    12631263            set _click(x) $x
    12641264            set _click(y) $y
    1265             set _view(xpan) [expr $_view(xpan) - $dx]
    1266             set _view(ypan) [expr $_view(ypan) - $dy]
     1265            set _view(-xpan) [expr $_view(-xpan) - $dx]
     1266            set _view(-ypan) [expr $_view(-ypan) - $dy]
    12671267            PanCamera
    12681268        }
     
    18561856        label $inner.${tag}label -text $tag -font "Arial 9"
    18571857        entry $inner.${tag} -font "Arial 9"  -bg white \
    1858             -textvariable [itcl::scope _view($tag)]
     1858            -textvariable [itcl::scope _view(-$tag)]
    18591859        bind $inner.${tag} <Return> \
    1860             [itcl::code $this camera set ${tag}]
     1860            [itcl::code $this camera set -${tag}]
    18611861        bind $inner.${tag} <KP_Enter> \
    1862             [itcl::code $this camera set ${tag}]
     1862            [itcl::code $this camera set -${tag}]
    18631863        blt::table $inner \
    18641864            $row,0 $inner.${tag}label -anchor e -pady 2 \
     
    18691869    checkbutton $inner.ortho \
    18701870        -text "Orthographic Projection" \
    1871         -variable [itcl::scope _view(ortho)] \
    1872         -command [itcl::code $this camera set ortho] \
     1871        -variable [itcl::scope _view(-ortho)] \
     1872        -command [itcl::code $this camera set -ortho] \
    18731873        -font "Arial 9"
    18741874    blt::table $inner \
     
    20462046        }
    20472047        "set" {
    2048             set who [lindex $args 0]
    2049             set x $_view($who)
     2048            set what [lindex $args 0]
     2049            set x $_view($what)
    20502050            set code [catch { string is double $x } result]
    20512051            if { $code != 0 || !$result } {
    20522052                return
    20532053            }
    2054             switch -- $who {
    2055                 "ortho" {
    2056                     if {$_view(ortho)} {
     2054            switch -- $what {
     2055                "-ortho" {
     2056                    if {$_view($what)} {
    20572057                        SendCmd "camera mode ortho"
    20582058                    } else {
     
    20602060                    }
    20612061                }
    2062                 "xpan" - "ypan" {
     2062                "-xpan" - "-ypan" {
    20632063                    PanCamera
    20642064                }
    2065                 "qx" - "qy" - "qz" - "qw" {
    2066                     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2065                "-qx" - "-qy" - "-qz" - "-qw" {
     2066                    set q [ViewToQuaternion]
    20672067                    $_arcball quaternion $q
    20682068                    EventuallyRotate $q
    20692069                }
    2070                 "zoom" {
    2071                     SendCmd "camera zoom $_view(zoom)"
     2070                "-zoom" {
     2071                    SendCmd "camera zoom $_view($what)"
    20722072                }
    20732073             }
     
    25512551        bottom "0.707107 0.707107 0 0"
    25522552    }
    2553     foreach name { qw qx qy qz } value $positions($side) {
     2553    foreach name { -qw -qx -qy -qz } value $positions($side) {
    25542554        set _view($name) $value
    2555     } 
    2556     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2555    }
     2556    set q [ViewToQuaternion]
    25572557    $_arcball quaternion $q
    25582558    SendCmd "camera orient $q"
    25592559    SendCmd "camera reset"
    2560     set _view(xpan) 0
    2561     set _view(ypan) 0
    2562     set _view(zoom) 1.0
    2563 }
     2560    set _view(-xpan) 0
     2561    set _view(-ypan) 0
     2562    set _view(-zoom) 1.0
     2563}
  • branches/1.3/gui/scripts/vtkheightmapviewer.tcl

    r4759 r4766  
    6363    public method scale {args}
    6464
    65     protected method CameraReset {}
    66     protected method Connect {}
    67     protected method CurrentDatasets {args}
    68     protected method Disconnect {}
    69     protected method DoResize {}
    70     protected method DoRotate {}
    71     protected method AdjustSetting {what {value ""}}
    72     protected method AdjustMode {}
    73     protected method InitSettings { args  }
    74     protected method Pan {option x y}
    75     protected method Pick {x y}
    76     protected method Rebuild {}
    77     protected method ReceiveDataset { args }
    78     protected method ReceiveImage { args }
    79     protected method ReceiveLegend { colormap title min max size }
    80     protected method Rotate {option x y}
    81     protected method Zoom {option}
    82 
    8365    # The following methods are only used by this class.
     66    private method AdjustSetting {what {value ""}}
    8467    private method BuildAxisTab {}
    8568    private method BuildCameraTab {}
     
    8770    private method BuildContourTab {}
    8871    private method BuildDownloadPopup { widget command }
     72    private method CameraReset {}
    8973    private method Combo { option }
     74    private method Connect {}
     75    private method CurrentDatasets {args}
     76    private method Disconnect {}
     77    private method DoResize {}
     78    private method DoRotate {}
    9079    private method DrawLegend {}
    9180    private method EnterLegend { x y }
    9281    private method EventuallyRequestLegend {}
    9382    private method EventuallyResize { w h }
    94     private method EventuallyRotate { q }
     83    private method EventuallyRotate { q }
     84    private method GetHeightmapScale {}
    9585    private method GetImage { args }
    9686    private method GetVtkData { args }
     87    private method InitSettings { args  }
    9788    private method IsValidObject { dataobj }
    9889    private method LeaveLegend {}
    9990    private method MotionLegend { x y }
     91    private method Pan {option x y}
    10092    private method PanCamera {}
     93    private method Pick {x y}
     94    private method QuaternionToView { q } {
     95        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
     96    }
     97    private method Rebuild {}
     98    private method ReceiveDataset { args }
     99    private method ReceiveImage { args }
     100    private method ReceiveLegend { colormap title min max size }
    101101    private method RequestLegend {}
     102    private method ResetAxes {}
     103    private method Rotate {option x y}
    102104    private method SetCurrentColormap { color }
    103105    private method SetLegendTip { x y }
    104106    private method SetObjectStyle { dataobj comp }
    105     private method GetHeightmapScale {}
    106     private method ResetAxes {}
    107107    private method SetOrientation { side }
    108108    private method UpdateContourList {}
     109    private method ViewToQuaternion {} {
     110        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
     111    }
     112    private method Zoom {option}
    109113
    110114    private variable _arcball ""
     
    201205    # Initialize the view to some default parameters.
    202206    array set _view {
    203         qw      0.36
    204         qx      0.25
    205         qy      0.50
    206         qz      0.70
    207         zoom    1.0
    208         xpan    0
    209         ypan    0
    210         ortho   0
     207        -ortho           0
     208        -qw              0.36
     209        -qx              0.25
     210        -qy              0.50
     211        -qz              0.70
     212        -xpan            0
     213        -ypan            0
     214        -zoom            1.0
    211215    }
    212216    set _arcball [blt::arcball create 100 100]
    213     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    214     $_arcball quaternion $q
     217    $_arcball quaternion [ViewToQuaternion]
    215218
    216219    array set _settings {
     
    441444
    442445itcl::body Rappture::VtkHeightmapViewer::DoRotate {} {
    443     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    444     SendCmd "camera orient $q"
     446    SendCmd "camera orient [ViewToQuaternion]"
    445447    set _rotatePending 0
    446448}
     
    466468
    467469itcl::body Rappture::VtkHeightmapViewer::EventuallyRotate { q } {
    468     foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
     470    QuaternionToView $q
    469471    if { !$_rotatePending } {
    470472        set _rotatePending 1
     
    949951
    950952        SendCmd "axis lrot z 90"
    951         set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    952         $_arcball quaternion $q
     953        $_arcball quaternion [ViewToQuaternion]
    953954        if {$_settings(-isheightmap) } {
    954             if { $_view(ortho)} {
     955            if { $_view(-ortho)} {
    955956                SendCmd "camera mode ortho"
    956957            } else {
     
    995996                    lappend info "dataset_size"  $length
    996997                    lappend info "dataset_tag"   $tag
    997                     SendCmd [list "clientinfo" $info]
     998                    SendCmd "clientinfo [list $info]"
    998999                }
    9991000                SendCmd "dataset add $tag data follows $length"
     
    10861087        #
    10871088        ResetAxes
    1088         set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    1089         $_arcball quaternion $q
     1089        $_arcball quaternion [ViewToQuaternion]
    10901090        if {$_settings(-isheightmap) } {
    1091             if { $_view(ortho)} {
     1091            if { $_view(-ortho)} {
    10921092                SendCmd "camera mode ortho"
    10931093            } else {
     
    11641164itcl::body Rappture::VtkHeightmapViewer::CameraReset {} {
    11651165    array set _view {
    1166         qw      0.36
    1167         qx      0.25
    1168         qy      0.50
    1169         qz      0.70
    1170         zoom    1.0
    1171         xpan    0
    1172         ypan    0
     1166        -qw      0.36
     1167        -qx      0.25
     1168        -qy      0.50
     1169        -qz      0.70
     1170        -xpan    0
     1171        -ypan    0
     1172        -zoom    1.0
    11731173    }
    11741174    if { $_first != "" } {
     
    11781178        }
    11791179    }
    1180     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    1181     $_arcball quaternion $q
     1180    $_arcball quaternion [ViewToQuaternion]
    11821181    if {$_settings(-isheightmap) } {
    11831182        DoRotate
     
    11971196    switch -- $option {
    11981197        "in" {
    1199             set _view(zoom) [expr {$_view(zoom)*1.25}]
    1200             SendCmd "camera zoom $_view(zoom)"
     1198            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
     1199            SendCmd "camera zoom $_view(-zoom)"
    12011200        }
    12021201        "out" {
    1203             set _view(zoom) [expr {$_view(zoom)*0.8}]
    1204             SendCmd "camera zoom $_view(zoom)"
     1202            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
     1203            SendCmd "camera zoom $_view(-zoom)"
    12051204        }
    12061205        "reset" {
    12071206            array set _view {
    1208                 zoom    1.0
    1209                 xpan    0
    1210                 ypan    0
     1207                -xpan    0
     1208                -ypan    0
     1209                -zoom    1.0
    12111210            }
    12121211            SendCmd "camera reset"
     
    12161215
    12171216itcl::body Rappture::VtkHeightmapViewer::PanCamera {} {
    1218     set x $_view(xpan)
    1219     set y $_view(ypan)
     1217    set x $_view(-xpan)
     1218    set y $_view(-ypan)
    12201219    SendCmd "camera pan $x $y"
    12211220}
     
    12951294            set x [expr $x / double($w)]
    12961295            set y [expr $y / double($h)]
    1297             set _view(xpan) [expr $_view(xpan) + $x]
    1298             set _view(ypan) [expr $_view(ypan) + $y]
     1296            set _view(-xpan) [expr $_view(-xpan) + $x]
     1297            set _view(-ypan) [expr $_view(-ypan) + $y]
    12991298            PanCamera
    13001299            return
     
    13181317            set _click(x) $x
    13191318            set _click(y) $y
    1320             set _view(xpan) [expr $_view(xpan) - $dx]
    1321             set _view(ypan) [expr $_view(ypan) - $dy]
     1319            set _view(-xpan) [expr $_view(-xpan) - $dx]
     1320            set _view(-ypan) [expr $_view(-ypan) - $dy]
    13221321            PanCamera
    13231322        }
     
    15351534                $itk_component(scale_l) configure -state normal
    15361535                $itk_component(outline) configure -state disabled
    1537                 if {$_view(ortho)} {
     1536                if {$_view(-ortho)} {
    15381537                    SendCmd "camera mode ortho"
    15391538                } else {
     
    15581557            ResetAxes
    15591558            if { $bool } {
    1560                 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1559                set q [ViewToQuaternion]
    15611560                $_arcball quaternion $q
    15621561                SendCmd "camera orient $q"
     
    18341833        set rgb [Color2RGB $itk_option(-plotforeground)]
    18351834        if { !$_reset } {
     1835            SendCmd "axis color all $rgb"
    18361836            SendCmd "outline color $rgb"
    1837             SendCmd "axis color all $rgb"
    18381837        }
    18391838    }
     
    21172116        label $inner.${tag}label -text $tag -font "Arial 9"
    21182117        entry $inner.${tag} -font "Arial 9"  -bg white \
    2119             -textvariable [itcl::scope _view($tag)]
     2118            -textvariable [itcl::scope _view(-$tag)]
    21202119        bind $inner.${tag} <Return> \
    2121             [itcl::code $this camera set ${tag}]
     2120            [itcl::code $this camera set -${tag}]
    21222121        bind $inner.${tag} <KP_Enter> \
    2123             [itcl::code $this camera set ${tag}]
     2122            [itcl::code $this camera set -${tag}]
    21242123        blt::table $inner \
    21252124            $row,0 $inner.${tag}label -anchor e -pady 2 \
     
    21302129    checkbutton $inner.ortho \
    21312130        -text "Orthographic Projection" \
    2132         -variable [itcl::scope _view(ortho)] \
    2133         -command [itcl::code $this camera set ortho] \
     2131        -variable [itcl::scope _view(-ortho)] \
     2132        -command [itcl::code $this camera set -ortho] \
    21342133        -font "Arial 9"
    21352134    blt::table $inner \
     
    21522151        }
    21532152        "set" {
    2154             set who [lindex $args 0]
    2155             set x $_view($who)
     2153            set what [lindex $args 0]
     2154            set x $_view($what)
    21562155            set code [catch { string is double $x } result]
    21572156            if { $code != 0 || !$result } {
    21582157                return
    21592158            }
    2160             switch -- $who {
    2161                 "ortho" {
    2162                     if {$_view(ortho)} {
     2159            switch -- $what {
     2160                "-ortho" {
     2161                    if {$_view($what)} {
    21632162                        SendCmd "camera mode ortho"
    21642163                    } else {
     
    21662165                    }
    21672166                }
    2168                 "xpan" - "ypan" {
     2167                "-xpan" - "-ypan" {
    21692168                    PanCamera
    21702169                }
    2171                 "qx" - "qy" - "qz" - "qw" {
    2172                     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2170                "-qx" - "-qy" - "-qz" - "-qw" {
     2171                    set q [ViewToQuaternion]
    21732172                    $_arcball quaternion $q
    21742173                    EventuallyRotate $q
    21752174                }
    2176                 "zoom" {
    2177                     SendCmd "camera zoom $_view(zoom)"
     2175                "-zoom" {
     2176                    SendCmd "camera zoom $_view($what)"
    21782177                }
    21792178            }
     
    26072606        bottom "0 1 0 0"
    26082607    }
    2609     foreach name { qw qx qy qz } value $positions($side) {
     2608    foreach name { -qw -qx -qy -qz } value $positions($side) {
    26102609        set _view($name) $value
    26112610    }
    2612     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2611    set q [ViewToQuaternion]
    26132612    $_arcball quaternion $q
    26142613    SendCmd "camera orient $q"
    26152614    SendCmd "camera reset"
    2616     set _view(xpan) 0
    2617     set _view(ypan) 0
    2618     set _view(zoom) 1.0
     2615    set _view(-xpan) 0
     2616    set _view(-ypan) 0
     2617    set _view(-zoom) 1.0
    26192618}
    26202619
  • branches/1.3/gui/scripts/vtkimageviewer.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 AdjustMode {}
    72     protected method InitSettings { args  }
    73     protected method Pan {option x y}
    74     protected method Pick {x y}
    75     protected method Rebuild {}
    76     protected method ReceiveDataset { args }
    77     protected method ReceiveImage { args }
    78     protected method ReceiveLegend { colormap title min max size }
    79     protected method Rotate {option x y}
    80     protected method Zoom {option}
    81 
    8265    # The following methods are only used by this class.
     66    private method AdjustSetting {what {value ""}}
    8367    private method BuildAxisTab {}
    8468    private method BuildCameraTab {}
     
    8771    private method BuildDownloadPopup { widget command }
    8872    private method Combo { option }
     73    private method Connect {}
     74    private method CurrentDatasets {args}
     75    private method Disconnect {}
     76    private method DoResize {}
     77    private method DoRotate {}
    8978    private method DrawLegend {}
    9079    private method EnterLegend { x y }
     
    9483    private method GetImage { args }
    9584    private method GetVtkData { args }
     85    private method InitSettings { args  }
    9686    private method IsValidObject { dataobj }
    9787    private method LeaveLegend {}
    9888    private method MotionLegend { x y }
     89    private method Pan {option x y}
    9990    private method PanCamera {}
     91    private method Pick {x y}
     92    private method QuaternionToView { q } {
     93        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
     94    }
     95    private method Rebuild {}
     96    private method ReceiveDataset { args }
     97    private method ReceiveImage { args }
     98    private method ReceiveLegend { colormap title min max size }
    10099    private method RequestLegend {}
     100    private method Rotate {option x y}
    101101    private method SetCurrentColormap { color }
    102102    private method SetLegendTip { x y }
    103103    private method SetObjectStyle { dataobj comp }
    104104    private method SetOrientation { side }
     105    private method ViewToQuaternion {} {
     106        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
     107    }
     108    private method Zoom {option}
    105109
    106110    private variable _arcball ""
     
    196200    # Initialize the view to some default parameters.
    197201    array set _view {
    198         qw      0.36
    199         qx      0.25
    200         qy      0.50
    201         qz      0.70
    202         zoom    1.0
    203         xpan    0
    204         ypan    0
    205         ortho   0
     202        -ortho           0
     203        -qw              0.36
     204        -qx              0.25
     205        -qy              0.50
     206        -qz              0.70
     207        -xpan            0
     208        -ypan            0
     209        -zoom            1.0
    206210    }
    207211    set _arcball [blt::arcball create 100 100]
    208     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    209     $_arcball quaternion $q
     212    $_arcball quaternion [ViewToQuaternion]
    210213
    211214    array set _settings {
     
    429432
    430433itcl::body Rappture::VtkImageViewer::DoRotate {} {
    431     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    432     SendCmd "camera orient $q"
     434    SendCmd "camera orient [ViewToQuaternion]"
    433435    set _rotatePending 0
    434436}
     
    454456
    455457itcl::body Rappture::VtkImageViewer::EventuallyRotate { q } {
    456     foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
     458    QuaternionToView $q
    457459    if { !$_rotatePending } {
    458460        set _rotatePending 1
     
    926928
    927929        SendCmd "axis lrot z 90"
    928         set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    929         $_arcball quaternion $q
     930        $_arcball quaternion [ViewToQuaternion]
    930931        if {$_settings(view3D) } {
    931             if { $_view(ortho)} {
     932            if { $_view(-ortho)} {
    932933                SendCmd "camera mode ortho"
    933934            } else {
     
    971972                    lappend info "dataset_size"  $length
    972973                    lappend info "dataset_tag"   $tag
    973                     SendCmd [list "clientinfo" $info]
     974                    SendCmd "clientinfo [list $info]"
    974975                }
    975976                SendCmd "dataset add $tag data follows $length"
     
    10441045        # Reset the camera and other view parameters
    10451046        #
    1046         set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    1047         $_arcball quaternion $q
     1047        $_arcball quaternion [ViewToQuaternion]
    10481048        if {$_settings(view3D) } {
    1049             if { $_view(ortho)} {
     1049            if { $_view(-ortho)} {
    10501050                SendCmd "camera mode ortho"
    10511051            } else {
     
    11301130    switch -- $option {
    11311131        "in" {
    1132             set _view(zoom) [expr {$_view(zoom)*1.25}]
    1133             SendCmd "camera zoom $_view(zoom)"
     1132            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
     1133            SendCmd "camera zoom $_view(-zoom)"
    11341134        }
    11351135        "out" {
    1136             set _view(zoom) [expr {$_view(zoom)*0.8}]
    1137             SendCmd "camera zoom $_view(zoom)"
     1136            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
     1137            SendCmd "camera zoom $_view(-zoom)"
    11381138        }
    11391139        "reset" {
    11401140            array set _view {
    1141                 qw      0.36
    1142                 qx      0.25
    1143                 qy      0.50
    1144                 qz      0.70
    1145                 zoom    1.0
    1146                 xpan    0
    1147                 ypan    0
     1141                -qw      0.36
     1142                -qx      0.25
     1143                -qy      0.50
     1144                -qz      0.70
     1145                -xpan    0
     1146                -ypan    0
     1147                -zoom    1.0
    11481148            }
    11491149            if { $_first != "" } {
     
    11531153                }
    11541154            }
    1155             set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    1156             $_arcball quaternion $q
     1155            $_arcball quaternion [ViewToQuaternion]
    11571156            if {$_settings(view3D) } {
    11581157                DoRotate
     
    11641163
    11651164itcl::body Rappture::VtkImageViewer::PanCamera {} {
    1166     set x $_view(xpan)
    1167     set y $_view(ypan)
     1165    set x $_view(-xpan)
     1166    set y $_view(-ypan)
    11681167    SendCmd "camera pan $x $y"
    11691168}
     
    12431242            set x [expr $x / double($w)]
    12441243            set y [expr $y / double($h)]
    1245             set _view(xpan) [expr $_view(xpan) + $x]
    1246             set _view(ypan) [expr $_view(ypan) + $y]
     1244            set _view(-xpan) [expr $_view(-xpan) + $x]
     1245            set _view(-ypan) [expr $_view(-ypan) + $y]
    12471246            PanCamera
    12481247            return
     
    12661265            set _click(x) $x
    12671266            set _click(y) $y
    1268             set _view(xpan) [expr $_view(xpan) - $dx]
    1269             set _view(ypan) [expr $_view(ypan) - $dy]
     1267            set _view(-xpan) [expr $_view(-xpan) - $dx]
     1268            set _view(-ypan) [expr $_view(-ypan) - $dy]
    12701269            PanCamera
    12711270        }
     
    14271426                $itk_component(opacity) configure -state normal
    14281427                $itk_component(opacity_l) configure -state normal
    1429                 if {$_view(ortho)} {
     1428                if {$_view(-ortho)} {
    14301429                    SendCmd "camera mode ortho"
    14311430                } else {
     
    14421441            }
    14431442            if { $bool } {
    1444                 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1443                set q [ViewToQuaternion]
    14451444                $_arcball quaternion $q
    14461445                SendCmd "camera orient $q"
     
    18871886        label $inner.${tag}label -text $tag -font "Arial 9"
    18881887        entry $inner.${tag} -font "Arial 9"  -bg white \
    1889             -textvariable [itcl::scope _view($tag)]
     1888            -textvariable [itcl::scope _view(-$tag)]
    18901889        bind $inner.${tag} <Return> \
    1891             [itcl::code $this camera set ${tag}]
     1890            [itcl::code $this camera set -${tag}]
    18921891        bind $inner.${tag} <KP_Enter> \
    1893             [itcl::code $this camera set ${tag}]
     1892            [itcl::code $this camera set -${tag}]
    18941893        blt::table $inner \
    18951894            $row,0 $inner.${tag}label -anchor e -pady 2 \
     
    19001899    checkbutton $inner.ortho \
    19011900        -text "Orthographic Projection" \
    1902         -variable [itcl::scope _view(ortho)] \
    1903         -command [itcl::code $this camera set ortho] \
     1901        -variable [itcl::scope _view(-ortho)] \
     1902        -command [itcl::code $this camera set -ortho] \
    19041903        -font "Arial 9"
    19051904    blt::table $inner \
     
    19221921        }
    19231922        "set" {
    1924             set who [lindex $args 0]
    1925             set x $_view($who)
     1923            set what [lindex $args 0]
     1924            set x $_view($what)
    19261925            set code [catch { string is double $x } result]
    19271926            if { $code != 0 || !$result } {
    19281927                return
    19291928            }
    1930             switch -- $who {
    1931                 "ortho" {
    1932                     if {$_view(ortho)} {
     1929            switch -- $what {
     1930                "-ortho" {
     1931                    if {$_view($what)} {
    19331932                        SendCmd "camera mode ortho"
    19341933                    } else {
     
    19361935                    }
    19371936                }
    1938                 "xpan" - "ypan" {
     1937                "-xpan" - "-ypan" {
    19391938                    PanCamera
    19401939                }
    1941                 "qx" - "qy" - "qz" - "qw" {
    1942                     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1940                "-qx" - "-qy" - "-qz" - "-qw" {
     1941                    set q [ViewToQuaternion]
    19431942                    $_arcball quaternion $q
    19441943                    EventuallyRotate $q
    19451944                }
    1946                 "zoom" {
    1947                     SendCmd "camera zoom $_view(zoom)"
     1945                "-zoom" {
     1946                    SendCmd "camera zoom $_view($what)"
    19481947                }
    19491948            }
     
    23232322        bottom "0 1 0 0"
    23242323    }
    2325     foreach name { qw qx qy qz } value $positions($side) {
     2324    foreach name { -qw -qx -qy -qz } value $positions($side) {
    23262325        set _view($name) $value
    23272326    }
    2328     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2327    set q [ViewToQuaternion]
    23292328    $_arcball quaternion $q
    23302329    SendCmd "camera orient $q"
    23312330    SendCmd "camera reset"
    2332     set _view(xpan) 0
    2333     set _view(ypan) 0
    2334     set _view(zoom) 1.0
    2335 }
     2331    set _view(-xpan) 0
     2332    set _view(-ypan) 0
     2333    set _view(-zoom) 1.0
     2334}
  • branches/1.3/gui/scripts/vtkisosurfaceviewer.tcl

    r4759 r4766  
    9595    private method PanCamera {}
    9696    private method Pick {x y}
     97    private method QuaternionToView { q } {
     98        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
     99    }
    97100    private method Rebuild {}
    98101    private method ReceiveDataset { args }
     
    107110    private method SetOrientation { side }
    108111    private method Slice {option args}
    109     private method Zoom {option}
    110112    private method ViewToQuaternion {} {
    111113        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
    112114    }
     115    private method Zoom {option}
    113116
    114117    private variable _arcball ""
     
    464467    EnableWaitDialog 500
    465468    Connect
     469    # FIXME: Removing this update breaks wizard mode (see examples/3D)
     470    # However, it also allows an error in the initialization order
     471    # where FieldResult::add is called from ResultViewer before this
     472    # constructor is completed.
     473    #update
    466474}
    467475
     
    523531
    524532itcl::body Rappture::VtkIsosurfaceViewer::EventuallyRotate { q } {
    525     foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
     533    QuaternionToView $q
    526534    if { !$_rotatePending } {
    527535        set _rotatePending 1
     
    11511159        "reset" {
    11521160            array set _view {
    1153                 -qw     0.853553
    1154                 -qx     -0.353553
    1155                 -qy     0.353553
    1156                 -qz     0.146447
    1157                 -xpan   0
    1158                 -ypan   0
    1159                 -zoom   1.0
     1161                -qw      0.853553
     1162                -qx      -0.353553
     1163                -qy      0.353553
     1164                -qz      0.146447
     1165                -xpan    0
     1166                -ypan    0
     1167                -zoom    1.0
    11601168            }
    11611169            if { $_first != "" } {
     
    12331241itcl::body Rappture::VtkIsosurfaceViewer::Pick {x y} {
    12341242    foreach tag [CurrentDatasets -visible] {
    1235         SendCmdNoSplash "dataset getscalar pixel $x $y $tag"
     1243        SendCmd "dataset getscalar pixel $x $y $tag"
    12361244    }
    12371245}
     
    20212029}
    20222030
    2023 
    2024 
    20252031#
    20262032#  camera --
     
    20552061                }
    20562062                "-zoom" {
    2057                     SendCmd "camera zoom $_view(-zoom)"
     2063                    SendCmd "camera zoom $_view($what)"
    20582064                }
    20592065             }
     
    25662572    foreach name { -qw -qx -qy -qz } value $positions($side) {
    25672573        set _view($name) $value
    2568     } 
     2574    }
    25692575    set q [ViewToQuaternion]
    25702576    $_arcball quaternion $q
  • 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}
  • branches/1.3/gui/scripts/vtkstreamlinesviewer.tcl

    r4759 r4766  
    6262    public method scale {args}
    6363
    64     protected method Connect {}
    65     protected method CurrentDatasets {args}
    66     protected method Disconnect {}
    67     protected method DoResize {}
    68     protected method DoReseed {}
    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 
    8164    # The following methods are only used by this class.
     65    private method AdjustSetting {what {value ""}}
    8266    private method BuildAxisTab {}
    8367    private method BuildCameraTab {}
     
    8973    private method DrawLegend {}
    9074    private method Combo { option }
     75    private method Connect {}
     76    private method CurrentDatasets {args}
     77    private method Disconnect {}
     78    private method DoResize {}
     79    private method DoReseed {}
     80    private method DoRotate {}
    9181    private method EnterLegend { x y }
    9282    private method EventuallyResize { w h }
     
    9686    private method GetImage { args }
    9787    private method GetVtkData { args }
     88    private method InitSettings { args  }
    9889    private method IsValidObject { dataobj }
    9990    private method LeaveLegend {}
    10091    private method MotionLegend { x y }
     92    private method Pan {option x y}
    10193    private method PanCamera {}
     94    private method Pick {x y}
     95    private method QuaternionToView { q } {
     96        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
     97    }
     98    private method Rebuild {}
     99    private method ReceiveDataset { args }
     100    private method ReceiveImage { args }
     101    private method ReceiveLegend { colormap title vmin vmax size }
    102102    private method RequestLegend {}
     103    private method Rotate {option x y}
    103104    private method SetColormap { dataobj comp }
    104105    private method ChangeColormap { dataobj comp color }
     
    107108    private method Slice {option args}
    108109    private method SetOrientation { side }
     110    private method ViewToQuaternion {} {
     111        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
     112    }
     113    private method Zoom {option}
    109114
    110115    private variable _arcball ""
     
    210215    # Initialize the view to some default parameters.
    211216    array set _view {
    212         qw              0.853553
    213         qx              -0.353553
    214         qy              0.353553
    215         qz              0.146447
    216         zoom            1.0
    217         xpan            0
    218         ypan            0
    219         ortho           0
     217        -ortho           0
     218        -qw              0.853553
     219        -qx              -0.353553
     220        -qy              0.353553
     221        -qz              0.146447
     222        -xpan            0
     223        -ypan            0
     224        -zoom            1.0
    220225    }
    221226    set _arcball [blt::arcball create 100 100]
    222     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    223     $_arcball quaternion $q
     227    $_arcball quaternion [ViewToQuaternion]
    224228
    225229    array set _settings [subst {
     
    400404    bind $itk_component(view) <ButtonRelease-1> \
    401405        [itcl::code $this Rotate release %x %y]
    402     bind $itk_component(view) <Configure> \
    403         [itcl::code $this EventuallyResize %w %h]
    404 
    405     if 0 {
    406     bind $itk_component(view) <Configure> \
    407         [itcl::code $this EventuallyResize %w %h]
    408     }
     406
    409407    # Bindings for panning via mouse
    410408    bind $itk_component(view) <ButtonPress-2> \
     
    481479
    482480itcl::body Rappture::VtkStreamlinesViewer::DoRotate {} {
    483     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    484     SendCmd "camera orient $q"
     481    SendCmd "camera orient [ViewToQuaternion]"
    485482    set _rotatePending 0
    486483}
     
    516513
    517514itcl::body Rappture::VtkStreamlinesViewer::EventuallyRotate { q } {
    518     foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
     515    QuaternionToView $q
    519516    if { !$_rotatePending } {
    520517        set _rotatePending 1
     
    10751072
    10761073        # Reset the camera and other view parameters
    1077         set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    1078         $_arcball quaternion $q
    1079         if {$_view(ortho)} {
     1074        $_arcball quaternion [ViewToQuaternion]
     1075        if {$_view(-ortho)} {
    10801076            SendCmd "camera mode ortho"
    10811077        } else {
     
    11511147    switch -- $option {
    11521148        "in" {
    1153             set _view(zoom) [expr {$_view(zoom)*1.25}]
    1154             SendCmd "camera zoom $_view(zoom)"
     1149            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
     1150            SendCmd "camera zoom $_view(-zoom)"
    11551151        }
    11561152        "out" {
    1157             set _view(zoom) [expr {$_view(zoom)*0.8}]
    1158             SendCmd "camera zoom $_view(zoom)"
     1153            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
     1154            SendCmd "camera zoom $_view(-zoom)"
    11591155        }
    11601156        "reset" {
    11611157            array set _view {
    1162                 qw      0.853553
    1163                 qx      -0.353553
    1164                 qy      0.353553
    1165                 qz      0.146447
    1166                 zoom    1.0
    1167                 xpan    0
    1168                 ypan    0
     1158                -qw      0.853553
     1159                -qx      -0.353553
     1160                -qy      0.353553
     1161                -qz      0.146447
     1162                -xpan    0
     1163                -ypan    0
     1164                -zoom    1.0
    11691165            }
    11701166            if { $_first != "" } {
     
    11741170                }
    11751171            }
    1176             set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    1177             $_arcball quaternion $q
     1172            $_arcball quaternion [ViewToQuaternion]
    11781173            DoRotate
    11791174            SendCmd "camera reset"
     
    11831178
    11841179itcl::body Rappture::VtkStreamlinesViewer::PanCamera {} {
    1185     set x $_view(xpan)
    1186     set y $_view(ypan)
     1180    set x $_view(-xpan)
     1181    set y $_view(-ypan)
    11871182    SendCmd "camera pan $x $y"
    11881183}
    1189 
    11901184
    11911185# ----------------------------------------------------------------------
     
    12621256            set x [expr $x / double($w)]
    12631257            set y [expr $y / double($h)]
    1264             set _view(xpan) [expr $_view(xpan) + $x]
    1265             set _view(ypan) [expr $_view(ypan) + $y]
     1258            set _view(-xpan) [expr $_view(-xpan) + $x]
     1259            set _view(-ypan) [expr $_view(-ypan) + $y]
    12661260            PanCamera
    12671261            return
     
    12851279            set _click(x) $x
    12861280            set _click(y) $y
    1287             set _view(xpan) [expr $_view(xpan) - $dx]
    1288             set _view(ypan) [expr $_view(ypan) - $dy]
     1281            set _view(-xpan) [expr $_view(-xpan) - $dx]
     1282            set _view(-ypan) [expr $_view(-ypan) - $dy]
    12891283            PanCamera
    12901284        }
     
    16091603itcl::configbody Rappture::VtkStreamlinesViewer::plotbackground {
    16101604    if { [isconnected] } {
    1611         foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break
    1612         SendCmd "screen bgcolor $r $g $b"
     1605        set rgb [Color2RGB $itk_option(-plotbackground)]
     1606        SendCmd "screen bgcolor $rgb"
    16131607    }
    16141608}
     
    16191613itcl::configbody Rappture::VtkStreamlinesViewer::plotforeground {
    16201614    if { [isconnected] } {
    1621         foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break
    1622         #fix this!
    1623         #SendCmd "color background $r $g $b"
     1615        set rgb [Color2RGB $itk_option(-plotforeground)]
     1616        SendCmd "axis color all $rgb"
     1617        SendCmd "outline color $rgb"
     1618        SendCmd "cutplane color $rgb"
    16241619    }
    16251620}
     
    18691864        label $inner.${tag}label -text $tag -font "Arial 9"
    18701865        entry $inner.${tag} -font "Arial 9"  -bg white \
    1871             -textvariable [itcl::scope _view($tag)]
     1866            -textvariable [itcl::scope _view(-$tag)]
    18721867        bind $inner.${tag} <Return> \
    1873             [itcl::code $this camera set ${tag}]
     1868            [itcl::code $this camera set -${tag}]
    18741869        bind $inner.${tag} <KP_Enter> \
    1875             [itcl::code $this camera set ${tag}]
     1870            [itcl::code $this camera set -${tag}]
    18761871        blt::table $inner \
    18771872            $row,0 $inner.${tag}label -anchor e -pady 2 \
     
    18821877    checkbutton $inner.ortho \
    18831878        -text "Orthographic Projection" \
    1884         -variable [itcl::scope _view(ortho)] \
    1885         -command [itcl::code $this camera set ortho] \
     1879        -variable [itcl::scope _view(-ortho)] \
     1880        -command [itcl::code $this camera set -ortho] \
    18861881        -font "Arial 9"
    18871882    blt::table $inner \
     
    20492044        }
    20502045        "set" {
    2051             set who [lindex $args 0]
    2052             set x $_view($who)
     2046            set what [lindex $args 0]
     2047            set x $_view($what)
    20532048            set code [catch { string is double $x } result]
    20542049            if { $code != 0 || !$result } {
    20552050                return
    20562051            }
    2057             switch -- $who {
    2058                 "ortho" {
    2059                     if {$_view(ortho)} {
     2052            switch -- $what {
     2053                "-ortho" {
     2054                    if {$_view($what)} {
    20602055                        SendCmd "camera mode ortho"
    20612056                    } else {
     
    20632058                    }
    20642059                }
    2065                 "xpan" - "ypan" {
     2060                "-xpan" - "-ypan" {
    20662061                    PanCamera
    20672062                }
    2068                 "qx" - "qy" - "qz" - "qw" {
    2069                     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2063                "-qx" - "-qy" - "-qz" - "-qw" {
     2064                    set q [ViewToQuaternion]
    20702065                    $_arcball quaternion $q
    20712066                    EventuallyRotate $q
    20722067                }
    2073                 "zoom" {
    2074                     SendCmd "camera zoom $_view(zoom)"
     2068                "-zoom" {
     2069                    SendCmd "camera zoom $_view($what)"
    20752070                }
    20762071            }
     
    24322427        bottom "0.707107 0.707107 0 0"
    24332428    }
    2434     foreach name { qw qx qy qz } value $positions($side) {
     2429    foreach name { -qw -qx -qy -qz } value $positions($side) {
    24352430        set _view($name) $value
    24362431    }
    2437     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2432    set q [ViewToQuaternion]
    24382433    $_arcball quaternion $q
    24392434    SendCmd "camera orient $q"
    24402435    SendCmd "camera reset"
    2441     set _view(xpan) 0
    2442     set _view(ypan) 0
    2443     set _view(zoom) 1.0
    2444 }
     2436    set _view(-xpan) 0
     2437    set _view(-ypan) 0
     2438    set _view(-zoom) 1.0
     2439}
  • branches/1.3/gui/scripts/vtksurfaceviewer.tcl

    r4759 r4766  
    6262    public method scale {args}
    6363
    64     protected method Connect {}
    65     protected method CurrentDatasets {args}
    66     protected method Disconnect {}
    67     protected method DoResize {}
    68     protected method DoRotate {}
    69     protected method AdjustSetting {what {value ""}}
    70     protected method InitSettings { args  }
    71     protected method Pan {option x y}
    72     protected method Pick {x y}
    73     protected method Rebuild {}
    74     protected method ReceiveDataset { args }
    75     protected method ReceiveImage { args }
    76     protected method ReceiveLegend { colormap title vmin vmax size }
    77     protected method Rotate {option x y}
    78     protected method Zoom {option}
    79 
    8064    # The following methods are only used by this class.
     65    private method AdjustSetting {what {value ""}}
    8166    private method BuildAxisTab {}
    8267    private method BuildCameraTab {}
     
    8570    private method BuildSurfaceTab {}
    8671    private method Combo { option }
     72    private method Connect {}
     73    private method CurrentDatasets {args}
     74    private method Disconnect {}
     75    private method DoResize {}
     76    private method DoRotate {}
    8777    private method DrawLegend {}
    8878    private method EnterLegend { x y }
     
    9282    private method GetImage { args }
    9383    private method GetVtkData { args }
     84    private method InitSettings { args  }
    9485    private method IsValidObject { dataobj }
    9586    private method LeaveLegend {}
    9687    private method MotionLegend { x y }
     88    private method Pan {option x y}
    9789    private method PanCamera {}
     90    private method Pick {x y}
     91    private method QuaternionToView { q } {
     92        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
     93    }
     94    private method Rebuild {}
     95    private method ReceiveDataset { args }
     96    private method ReceiveImage { args }
     97    private method ReceiveLegend { colormap title vmin vmax size }
    9898    private method RequestLegend {}
     99    private method Rotate {option x y}
    99100    private method SetLegendTip { x y }
    100101    private method SetObjectStyle { dataobj comp }
     
    102103    private method SetOrientation { side }
    103104    private method UpdateContourList {}
     105    private method ViewToQuaternion {} {
     106        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
     107    }
     108    private method Zoom {option}
    104109
    105110    private variable _arcball ""
     
    187192    # Initialize the view to some default parameters.
    188193    array set _view {
    189         qw              0.853553
    190         qx              -0.353553
    191         qy              0.353553
    192         qz              0.146447
    193         zoom            1.0
    194         xpan            0
    195         ypan            0
    196         ortho           0
     194        -ortho           0
     195        -qw              0.853553
     196        -qx              -0.353553
     197        -qy              0.353553
     198        -qz              0.146447
     199        -xpan            0
     200        -ypan            0
     201        -zoom            1.0
    197202    }
    198203    set _arcball [blt::arcball create 100 100]
    199     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    200     $_arcball quaternion $q
     204    $_arcball quaternion [ViewToQuaternion]
    201205
    202206    array set _settings {
     
    320324        puts stderr errs=$errs
    321325    }
     326
    322327    # Legend
    323 
    324328    set _image(legend) [image create photo]
    325329    itk_component add legend {
     
    424428
    425429itcl::body Rappture::VtkSurfaceViewer::DoRotate {} {
    426     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    427     SendCmd "camera orient $q"
     430    SendCmd "camera orient [ViewToQuaternion]"
    428431    set _rotatePending 0
    429432}
     
    449452
    450453itcl::body Rappture::VtkSurfaceViewer::EventuallyRotate { q } {
    451     foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
     454    QuaternionToView $q
    452455    if { !$_rotatePending } {
    453456        set _rotatePending 1
     
    497500}
    498501
    499 
    500502# ----------------------------------------------------------------------
    501503# USAGE: delete ?<dataobj1> <dataobj2> ...?
     
    785787    array unset _data
    786788    array unset _colormaps
    787     array unset _seeds
    788789    array unset _dataset2style
    789790    array unset _obj2datasets
     
    808809        if 0 {
    809810            set f [open "last.ppm" "w"]
    810             puts $f $bytes
     811            fconfigure $f -encoding binary
     812            puts -nonewline $f $bytes
    811813            close $f
    812814        }
     
    898900        # Reset the camera and other view parameters
    899901        #
    900         set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    901         $_arcball quaternion $q
    902         if {$_view(ortho)} {
     902        $_arcball quaternion [ViewToQuaternion]
     903        if {$_view(-ortho)} {
    903904            SendCmd "camera mode ortho"
    904905        } else {
     
    944945                    SendCmd "clientinfo [list $info]"
    945946                }
    946                 append _outbuf "dataset add $tag data follows $length\n"
     947                SendCmd "dataset add $tag data follows $length"
    947948                append _outbuf $bytes
    948949                set _datasets($tag) 1
     
    10781079    switch -- $option {
    10791080        "in" {
    1080             set _view(zoom) [expr {$_view(zoom)*1.25}]
    1081             SendCmd "camera zoom $_view(zoom)"
     1081            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
     1082            SendCmd "camera zoom $_view(-zoom)"
    10821083        }
    10831084        "out" {
    1084             set _view(zoom) [expr {$_view(zoom)*0.8}]
    1085             SendCmd "camera zoom $_view(zoom)"
     1085            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
     1086            SendCmd "camera zoom $_view(-zoom)"
    10861087        }
    10871088        "reset" {
    10881089            array set _view {
    1089                 qw     0.853553
    1090                 qx     -0.353553
    1091                 qy     0.353553
    1092                 qz     0.146447
    1093                 zoom   1.0
    1094                 xpan   0
    1095                 ypan   0
     1090                -qw      0.853553
     1091                -qx      -0.353553
     1092                -qy      0.353553
     1093                -qz      0.146447
     1094                -xpan    0
     1095                -ypan    0
     1096                -zoom    1.0
    10961097            }
    10971098            if { $_first != "" } {
     
    11011102                }
    11021103            }
    1103             set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    1104             $_arcball quaternion $q
     1104            $_arcball quaternion [ViewToQuaternion]
    11051105            DoRotate
    11061106            SendCmd "camera reset"
     
    11101110
    11111111itcl::body Rappture::VtkSurfaceViewer::PanCamera {} {
    1112     set x $_view(xpan)
    1113     set y $_view(ypan)
     1112    set x $_view(-xpan)
     1113    set y $_view(-ypan)
    11141114    SendCmd "camera pan $x $y"
    11151115}
    1116 
    11171116
    11181117# ----------------------------------------------------------------------
     
    11701169itcl::body Rappture::VtkSurfaceViewer::Pick {x y} {
    11711170    foreach tag [CurrentDatasets -visible] {
    1172         SendCmdNoSplash "dataset getscalar pixel $x $y $tag"
     1171        SendCmd "dataset getscalar pixel $x $y $tag"
    11731172    }
    11741173}
     
    11891188            set x [expr $x / double($w)]
    11901189            set y [expr $y / double($h)]
    1191             set _view(xpan) [expr $_view(xpan) + $x]
    1192             set _view(ypan) [expr $_view(ypan) + $y]
     1190            set _view(-xpan) [expr $_view(-xpan) + $x]
     1191            set _view(-ypan) [expr $_view(-ypan) + $y]
    11931192            PanCamera
    11941193            return
     
    12121211            set _click(x) $x
    12131212            set _click(y) $y
    1214             set _view(xpan) [expr $_view(xpan) - $dx]
    1215             set _view(ypan) [expr $_view(ypan) - $dy]
     1213            set _view(-xpan) [expr $_view(-xpan) - $dx]
     1214            set _view(-ypan) [expr $_view(-ypan) - $dy]
    12161215            PanCamera
    12171216        }
     
    17511750        label $inner.${tag}label -text $tag -font "Arial 9"
    17521751        entry $inner.${tag} -font "Arial 9"  -bg white \
    1753             -textvariable [itcl::scope _view($tag)]
     1752            -textvariable [itcl::scope _view(-$tag)]
    17541753        bind $inner.${tag} <Return> \
    1755             [itcl::code $this camera set ${tag}]
     1754            [itcl::code $this camera set -${tag}]
    17561755        bind $inner.${tag} <KP_Enter> \
    1757             [itcl::code $this camera set ${tag}]
     1756            [itcl::code $this camera set -${tag}]
    17581757        blt::table $inner \
    17591758            $row,0 $inner.${tag}label -anchor e -pady 2 \
     
    17641763    checkbutton $inner.ortho \
    17651764        -text "Orthographic Projection" \
    1766         -variable [itcl::scope _view(ortho)] \
    1767         -command [itcl::code $this camera set ortho] \
     1765        -variable [itcl::scope _view(-ortho)] \
     1766        -command [itcl::code $this camera set -ortho] \
    17681767        -font "Arial 9"
    17691768    blt::table $inner \
     
    17861785        }
    17871786        "set" {
    1788             set who [lindex $args 0]
    1789             set x $_view($who)
     1787            set what [lindex $args 0]
     1788            set x $_view($what)
    17901789            set code [catch { string is double $x } result]
    17911790            if { $code != 0 || !$result } {
    17921791                return
    17931792            }
    1794             switch -- $who {
    1795                 "ortho" {
    1796                     if {$_view(ortho)} {
     1793            switch -- $what {
     1794                "-ortho" {
     1795                    if {$_view($what)} {
    17971796                        SendCmd "camera mode ortho"
    17981797                    } else {
     
    18001799                    }
    18011800                }
    1802                 "xpan" - "ypan" {
     1801                "-xpan" - "-ypan" {
    18031802                    PanCamera
    18041803                }
    1805                 "qx" - "qy" - "qz" - "qw" {
    1806                     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1804                "-qx" - "-qy" - "-qz" - "-qw" {
     1805                    set q [ViewToQuaternion]
    18071806                    $_arcball quaternion $q
    18081807                    EventuallyRotate $q
    18091808                }
    1810                 "zoom" {
    1811                     SendCmd "camera zoom $_view(zoom)"
     1809                "-zoom" {
     1810                    SendCmd "camera zoom $_view($what)"
    18121811                }
    18131812             }
     
    22712270        bottom "0.707107 0.707107 0 0"
    22722271    }
    2273     foreach name { qw qx qy qz } value $positions($side) {
     2272    foreach name { -qw -qx -qy -qz } value $positions($side) {
    22742273        set _view($name) $value
    22752274    }
    2276     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2275    set q [ViewToQuaternion]
    22772276    $_arcball quaternion $q
    22782277    SendCmd "camera orient $q"
    22792278    SendCmd "camera reset"
    2280     set _view(xpan) 0
    2281     set _view(ypan) 0
    2282     set _view(zoom) 1.0
     2279    set _view(-xpan) 0
     2280    set _view(-ypan) 0
     2281    set _view(-zoom) 1.0
    22832282}
    22842283
     
    22982297    blt::vector destroy $v
    22992298}
    2300 
  • 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
  • branches/1.3/gui/scripts/vtkvolumeviewer.tcl

    r4750 r4766  
    6262    public method scale {args}
    6363
    64     private method SetOrientation { side }
    65     private method ViewToQuaternion {} {
    66         return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
    67     }
    68     private method QuaternionToView { q } {
    69         foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
    70     }
    71 
    72     protected method Connect {}
    73     protected method CurrentDatasets {args}
    74     protected method Disconnect {}
    75     protected method DoResize {}
    76     protected method DoRotate {}
    77     protected method AdjustSetting {what {value ""}}
    78     protected method InitSettings { args  }
    79     protected method Pan {option x y}
    80     protected method Pick {x y}
    81     protected method Rebuild {}
    82     protected method ReceiveDataset { args }
    83     protected method ReceiveImage { args }
    84     protected method ReceiveLegend { colormap title vmin vmax size }
    85     protected method Rotate {option x y}
    86     protected method Zoom {option}
    87 
    8864    # The following methods are only used by this class.
     65    private method AdjustSetting {what {value ""}}
    8966    private method BuildAxisTab {}
    9067    private method BuildCameraTab {}
     
    9572    private method BuildVolumeTab {}
    9673    private method DrawLegend {}
     74    private method ChangeColormap { dataobj comp color }
    9775    private method Combo { option }
     76    private method Connect {}
     77    private method CurrentDatasets {args}
     78    private method Disconnect {}
     79    private method DoResize {}
     80    private method DoRotate {}
    9881    private method EnterLegend { x y }
    9982    private method EventuallyResize { w h }
     
    10386    private method GetImage { args }
    10487    private method GetVtkData { args }
     88    private method InitSettings { args  }
    10589    private method IsValidObject { dataobj }
    10690    private method LeaveLegend {}
    107     private method MotionLegend { x y }
     91    private method MotionLegend { x y }
     92    private method Pan {option x y}
    10893    private method PanCamera {}
     94    private method Pick {x y}
     95    private method QuaternionToView { q } {
     96        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
     97    }
     98    private method Rebuild {}
     99    private method ReceiveDataset { args }
     100    private method ReceiveImage { args }
     101    private method ReceiveLegend { colormap title vmin vmax size }
    109102    private method RequestLegend {}
    110103    private method SetColormap { dataobj comp }
    111     private method ChangeColormap { dataobj comp color }
     104    private method Rotate {option x y}
    112105    private method SetLegendTip { x y }
    113106    private method SetObjectStyle { dataobj comp }
     107    private method SetOrientation { side }
    114108    private method Slice {option args}
     109    private method ViewToQuaternion {} {
     110        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
     111    }
     112    private method Zoom {option}
    115113
    116114    private variable _arcball ""
     
    206204    # Initialize the view to some default parameters.
    207205    array set _view {
     206        -ortho           0
    208207        -qw              0.853553
    209208        -qx              -0.353553
    210209        -qy              0.353553
    211210        -qz              0.146447
    212         -zoom            1.0
    213211        -xpan            0
    214212        -ypan            0
    215         -ortho           0
     213        -zoom            1.0
    216214    }
    217215    set _arcball [blt::arcball create 100 100]
     
    377375    bind $itk_component(view) <ButtonRelease-1> \
    378376        [itcl::code $this Rotate release %x %y]
    379     bind $itk_component(view) <Configure> \
    380         [itcl::code $this EventuallyResize %w %h]
    381377
    382378    # Bindings for panning via mouse
     
    986982                    lappend info "dataset_size"  $length
    987983                    lappend info "dataset_tag"   $tag
    988                     SendCmd [list "clientinfo" $info]
    989                 }
    990                 append _outbuf "dataset add $tag data follows $length\n"
     984                    SendCmd "clientinfo [list $info]"
     985                }
     986                SendCmd "dataset add $tag data follows $length"
    991987                append _outbuf $bytes
    992988                set _datasets($tag) 1
     
    11351131                -qy      0.353553
    11361132                -qz      0.146447
     1133                -xpan    0
     1134                -ypan    0
    11371135                -zoom    1.0
    1138                 -xpan   0
    1139                 -ypan   0
    11401136            }
    11411137            if { $_first != "" } {
     
    11571153    SendCmd "camera pan $x $y"
    11581154}
    1159 
    11601155
    11611156# ----------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.