Changeset 5356 for trunk


Ignore:
Timestamp:
Apr 29, 2015, 3:35:42 AM (9 years ago)
Author:
ldelgass
Message:

Make it easier to test virtual mouse events vs. client side event handling in
pymol viewer.

File:
1 edited

Legend:

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

    r5351 r5356  
    7070    protected method Rebuild {}
    7171    protected method Rotate {option x y}
     72    protected method Rotate.old {option x y}
    7273    protected method SendCmd { string }
    7374    protected method Unmap {}
    74     protected method Vmouse  {option b m x y}
    75     protected method Vmouse2 {option b m x y}
     75    protected method Vmouse {option b m x y}
    7676    protected method Zoom {option {factor 10}}
    7777
     
    344344    set _image(id) ""
    345345
    346     # set up bindings for rotation
    347346    if 0 {
     347        # set up bindings to bridge mouse events to server
     348        bind $itk_component(3dview) <ButtonPress> \
     349            [itcl::code $this Vmouse click %b %s %x %y]
     350        bind $itk_component(3dview) <ButtonRelease> \
     351            [itcl::code $this Vmouse release %b %s %x %y]
     352        bind $itk_component(3dview) <B1-Motion> \
     353            [itcl::code $this Vmouse drag 1 %s %x %y]
     354        bind $itk_component(3dview) <B2-Motion> \
     355            [itcl::code $this Vmouse drag 2 %s %x %y]
     356        bind $itk_component(3dview) <B3-Motion> \
     357            [itcl::code $this Vmouse drag 3 %s %x %y]
     358        bind $itk_component(3dview) <Motion> \
     359            [itcl::code $this Vmouse move 0 %s %x %y]
     360    } else {
     361        # set up bindings for rotation with mouse
    348362        bind $itk_component(3dview) <ButtonPress-1> \
    349363            [itcl::code $this Rotate click %x %y]
     
    352366        bind $itk_component(3dview) <ButtonRelease-1> \
    353367            [itcl::code $this Rotate release %x %y]
    354     } else {
    355         bind $itk_component(3dview) <ButtonPress-1> \
    356             [itcl::code $this Vmouse click %b %s %x %y]
    357         bind $itk_component(3dview) <B1-Motion> \
    358             [itcl::code $this Vmouse drag 1 %s %x %y]
    359         bind $itk_component(3dview) <ButtonRelease-1> \
    360             [itcl::code $this Vmouse release %b %s %x %y]
    361     }
    362 
    363     bind $itk_component(3dview) <ButtonPress-2> \
    364         [itcl::code $this Pan click %x %y]
    365     bind $itk_component(3dview) <B2-Motion> \
    366         [itcl::code $this Pan drag %x %y]
    367     bind $itk_component(3dview) <ButtonRelease-2> \
    368         [itcl::code $this Pan release %x %y]
    369 
     368
     369        # set up bindings for panning with mouse
     370        bind $itk_component(3dview) <ButtonPress-2> \
     371            [itcl::code $this Pan click %x %y]
     372        bind $itk_component(3dview) <B2-Motion> \
     373            [itcl::code $this Pan drag %x %y]
     374        bind $itk_component(3dview) <ButtonRelease-2> \
     375            [itcl::code $this Pan release %x %y]
     376
     377        # scroll wheel zoom
     378        if {[string equal "x11" [tk windowingsystem]]} {
     379            bind $itk_component(3dview) <4> [itcl::code $this Zoom out 2]
     380            bind $itk_component(3dview) <5> [itcl::code $this Zoom in 2]
     381        }
     382    }
     383
     384    # Set up bindings for panning with keyboard
    370385    bind $itk_component(3dview) <KeyPress-Left> \
    371386        [itcl::code $this Pan set -10 0]
     
    384399    bind $itk_component(3dview) <Shift-KeyPress-Down> \
    385400        [itcl::code $this Pan set 0 50]
     401
     402    # Set up bindings for zoom with keyboard
    386403    bind $itk_component(3dview) <KeyPress-Prior> \
    387404        [itcl::code $this Zoom out 2]
     
    390407
    391408    bind $itk_component(3dview) <Enter> "focus $itk_component(3dview)"
    392 
    393 
    394     if {[string equal "x11" [tk windowingsystem]]} {
    395         bind $itk_component(3dview) <4> [itcl::code $this Zoom out 2]
    396         bind $itk_component(3dview) <5> [itcl::code $this Zoom in 2]
    397     }
    398 
    399     # set up bindings to bridge mouse events to server
    400     #bind $itk_component(3dview) <ButtonPress> \
    401     #   [itcl::code $this Vmouse2 click %b %s %x %y]
    402     #bind $itk_component(3dview) <ButtonRelease> \
    403     #    [itcl::code $this Vmouse2 release %b %s %x %y]
    404     #bind $itk_component(3dview) <B1-Motion> \
    405     #    [itcl::code $this Vmouse2 drag 1 %s %x %y]
    406     #bind $itk_component(3dview) <B2-Motion> \
    407     #    [itcl::code $this Vmouse2 drag 2 %s %x %y]
    408     #bind $itk_component(3dview) <B3-Motion> \
    409     #    [itcl::code $this Vmouse2 drag 3 %s %x %y]
    410     #bind $itk_component(3dview) <Motion> \
    411     #    [itcl::code $this Vmouse2 move 0 %s %x %y]
    412409
    413410    bind $itk_component(3dview) <Configure> \
     
    13421339}
    13431340
    1344 
    1345 itcl::body Rappture::MolvisViewer::Vmouse2 {option b m x y} {
     1341#
     1342# Send virtual mouse events using the vmouse command
     1343#
     1344itcl::body Rappture::MolvisViewer::Vmouse {option b m x y} {
    13461345    set now [clock clicks -milliseconds]
    13471346    set vButton [expr $b - 1]
     
    13701369}
    13711370
    1372 itcl::body Rappture::MolvisViewer::Vmouse {option b m x y} {
     1371# ----------------------------------------------------------------------
     1372# USAGE: Rotate click <x> <y>
     1373# USAGE: Rotate drag <x> <y>
     1374# USAGE: Rotate release <x> <y>
     1375#
     1376# Called automatically when the user clicks/drags/releases in the
     1377# plot area.  Moves the plot according to the user's actions.
     1378# ----------------------------------------------------------------------
     1379itcl::body Rappture::MolvisViewer::Rotate {option x y} {
    13731380    set now  [clock clicks -milliseconds]
    13741381    # cancel any pending delayed dragging events
     
    13861393    if { $option == "drag" || $option == "release" } {
    13871394        set diff 0
    1388          catch { set diff [expr $now - $_mevent(time) ] }
    1389          if {$diff < 25 && $option == "drag" } { # 75ms between motion updates
    1390              set _mevent(afterid) [after [expr 25 - $diff] [itcl::code $this Vmouse drag $b $m $x $y]]
    1391              return
    1392          }
     1395        catch { set diff [expr $now - $_mevent(time) ] }
     1396        if {$diff < 25 && $option == "drag" } { # 75ms between motion updates
     1397            set _mevent(afterid) [after [expr 25 - $diff] [itcl::code $this Rotate drag $x $y]]
     1398            return
     1399        }
    13931400        set w [winfo width $itk_component(3dview)]
    13941401        set h [winfo height $itk_component(3dview)]
     
    14381445
    14391446# ----------------------------------------------------------------------
    1440 # USAGE: Rotate click <x> <y>
    1441 # USAGE: Rotate drag <x> <y>
    1442 # USAGE: Rotate release <x> <y>
     1447# USAGE: Rotate.old click <x> <y>
     1448# USAGE: Rotate.old drag <x> <y>
     1449# USAGE: Rotate.old release <x> <y>
    14431450#
    14441451# Called automatically when the user clicks/drags/releases in the
    14451452# plot area.  Moves the plot according to the user's actions.
    14461453# ----------------------------------------------------------------------
    1447 itcl::body Rappture::MolvisViewer::Rotate {option x y} {
     1454itcl::body Rappture::MolvisViewer::Rotate.old {option x y} {
    14481455    set now  [clock clicks -milliseconds]
    14491456    #update idletasks
     
    14631470        drag {
    14641471            if {[array size _click] == 0} {
    1465                 Rotate click $x $y
     1472                Rotate.old click $x $y
    14661473            } else {
    14671474                set w [winfo width $itk_component(3dview)]
     
    14701477                    return
    14711478                }
    1472 #         set diff 0
    1473 #          catch { set diff [expr $now - $_mevent(time) ] }
    1474 #          if {$diff < 175 && $option == "drag" } { # 75ms between motion updates
    1475 #              set _mevent(afterid) [after [expr 175 - $diff] [itcl::code $this Rotate drag $x $y]]
    1476 #              return
    1477 #          }
     1479                #set diff 0
     1480                #catch { set diff [expr $now - $_mevent(time) ] }
     1481                #if {$diff < 75 && $option == "drag" } { # 75ms between motion updates
     1482                #    set _mevent(afterid) [after [expr 75 - $diff] [itcl::code $this Rotate.old drag $x $y]]
     1483                #    return
     1484                #}
    14781485
    14791486                if {[catch {
     
    15301537        }
    15311538        release {
    1532             Rotate drag $x $y
     1539            Rotate.old drag $x $y
    15331540            $itk_component(3dview) configure -cursor ""
    15341541            catch {unset _click}
Note: See TracChangeset for help on using the changeset viewer.