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

merge r4765 from trunk

Location:
branches/1.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3

    • Property svn:mergeinfo changed
      /trunkmerged: 4765
  • branches/1.3/gui/scripts/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}
Note: See TracChangeset for help on using the changeset viewer.