Changeset 2426 for trunk/gui


Ignore:
Timestamp:
Aug 27, 2011 2:53:26 AM (13 years ago)
Author:
ldelgass
Message:

Add ortho/perspective camera setting, pick value tests. Also disable camera
reset -- server should be scaling on resizes again.

File:
1 edited

Legend:

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

    r2421 r2426  
    7070    protected method FixSettings {what {value ""}}
    7171    protected method Pan {option x y}
     72    protected method Pick {x y}
    7273    protected method Rebuild {}
    7374    protected method ReceiveDataset { args }
     
    173174        pan-x           0
    174175        pan-y           0
     176        ortho           0
    175177    }
    176178    set _arcball [blt::arcball create 100 100]
     
    291293    bind $itk_component(view) <ButtonRelease-2> \
    292294        [itcl::code $this Pan release %x %y]
     295
     296    bind $itk_component(view) <ButtonRelease-3> \
     297        [itcl::code $this Pick %x %y]
    293298
    294299    # Bindings for panning via keyboard
     
    356361
    357362    # Must reset camera to have object scaling to take effect.
    358     SendCmd "camera reset"
    359     SendCmd "camera zoom $_view(zoom)"
     363    #SendCmd "camera reset"
     364    #SendCmd "camera zoom $_view(zoom)"
    360365    set _resizePending 0
    361366}
     
    736741    set option [lindex $args 0]
    737742    switch -- $option {
    738         "value" {
     743        "scalar" {
    739744            set option [lindex $args 1]
    740745            switch -- $option {
    741746                "world" {
    742                     foreach { x y z value } [lrange $args 2 end] break
     747                    foreach { x y z value tag } [lrange $args 2 end] break
    743748                }
    744749                "pixel" {
    745                     foreach { x y value } [lrange $args 2 end] break
     750                    foreach { x y value tag } [lrange $args 2 end] break
    746751                }
    747752            }
     753        }
     754        "vector" {
     755            set option [lindex $args 1]
     756            switch -- $option {
     757                "world" {
     758                    foreach { x y z vx vy vz tag } [lrange $args 2 end] break
     759                }
     760                "pixel" {
     761                    foreach { x y vx vy vz tag } [lrange $args 2 end] break
     762                }
     763            }
     764        }
     765        "names" {
     766            foreach { name } [lindex $args 1] {
     767                #puts stderr "Dataset: $name"
     768            }
    748769        }
    749770        default {
     
    811832    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    812833    $_arcball quaternion $q
     834    if {$_view(ortho)} {
     835        SendCmd "camera mode ortho"
     836    } else {
     837        SendCmd "camera mode persp"
     838    }
    813839    SendCmd "camera orient $q"
    814840    PanCamera
    815     SendCmd "camera mode persp"
    816841    if { $_reset || $_first == "" } {
    817842        Zoom reset
     
    824849    FixSettings volume
    825850    FixSettings lighting
     851    FixSettings wireframe
    826852    FixSettings axes
    827853    FixSettings edges
     
    932958
    933959itcl::body Rappture::VtkViewer::PanCamera {} {
    934 #    set w [winfo width $itk_component(view)]
    935 #    set h [winfo height $itk_component(view)]
    936 #    set x [expr ($_view(pan-x)) / $w]
    937 #    set y [expr ($_view(pan-y)) / $h]
    938 #    set x [expr $x * $_limits(xmax) - $_limits(xmin)]
    939 #    set y [expr $y * $_limits(ymax) - $_limits(ymin)]
    940960    set x $_view(pan-x)
    941961    set y $_view(pan-y)
     
    9951015        }
    9961016    }
     1017}
     1018
     1019itcl::body Rappture::VtkViewer::Pick {x y} {
     1020    foreach tag [CurrentDatasets -visible] {
     1021        SendCmd "dataset getscalar pixel $x $y $tag"
     1022    }
    9971023}
    9981024
     
    13951421        incr row
    13961422    }
     1423    checkbutton $inner.ortho \
     1424        -text "Orthogrpahic" \
     1425        -variable [itcl::scope _view(ortho)] \
     1426        -command [itcl::code $this camera set ortho] \
     1427        -font "Arial 9"
     1428    blt::table $inner \
     1429            $row,0 $inner.ortho -columnspan 2 -anchor w -pady 2
     1430    blt::table configure $inner r$row -resize none
     1431    incr row
     1432
    13971433    blt::table configure $inner c0 c1 -resize none
    13981434    blt::table configure $inner c2 -resize expand
     
    14141450            set code [catch { string is double $x } result]
    14151451            if { $code != 0 || !$result } {
    1416                 set x _view($who)
    14171452                return
    14181453            }
    14191454            switch -- $who {
     1455                "ortho" {
     1456                    if {$_view(ortho)} {
     1457                        SendCmd "camera mode ortho"
     1458                    } else {
     1459                        SendCmd "camera mode persp"
     1460                    }
     1461                }
    14201462                "pan-x" - "pan-y" {
    14211463                    PanCamera
Note: See TracChangeset for help on using the changeset viewer.