Changeset 5022 for trunk


Ignore:
Timestamp:
Feb 13, 2015 2:11:32 PM (5 years ago)
Author:
ldelgass
Message:

add key bindings for rotation, reset heading/pitch

File:
1 edited

Legend:

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

    r5008 r5022  
    104104    private method Rotate {option x y}
    105105    private method Select {option x y}
    106     private method SetLayerOpacity { dataobj layer {value 100}}
     106    private method SetHeading { {value 0} }
     107    private method SetLayerOpacity { dataobj layer {value 100} }
    107108    private method SetLayerStyle { dataobj layer }
    108109    private method SetLayerVisibility { dataobj layer }
     110    private method SetPitch { {value -89.999} }
    109111    private method SetTerrainStyle { style }
    110112    private method UpdateLayerControls {}
     
    310312    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
    311313
    312     if { [catch {
    313         BuildLayerTab
    314         BuildMapTab
    315         BuildTerrainTab
    316         BuildCameraTab
    317     } errs] != 0 } {
    318         puts stderr errs=$errs
    319     }
     314    BuildLayerTab
     315    BuildMapTab
     316    BuildTerrainTab
     317    BuildCameraTab
    320318
    321319    # Legend
     
    441439            [itcl::code $this Pan set 0 10]
    442440
     441        bind $itk_component(view) <Shift-KeyPress-Left> \
     442            [itcl::code $this Pan set 2 0]
     443        bind $itk_component(view) <Shift-KeyPress-Right> \
     444            [itcl::code $this Pan set -2 0]
     445        bind $itk_component(view) <Shift-KeyPress-Up> \
     446            [itcl::code $this Pan set 0 -2]
     447        bind $itk_component(view) <Shift-KeyPress-Down> \
     448            [itcl::code $this Pan set 0 2]
     449
     450        # Bindings for rotation via keyboard
     451        bind $itk_component(view) <Control-Left> \
     452            [itcl::code $this Rotate set 10 0]
     453        bind $itk_component(view) <Control-Right> \
     454            [itcl::code $this Rotate set -10 0]
     455        bind $itk_component(view) <Control-Up> \
     456            [itcl::code $this Rotate set 0 -10]
     457        bind $itk_component(view) <Control-Down> \
     458            [itcl::code $this Rotate set 0 10]
     459
     460        bind $itk_component(view) <Control-Shift-Left> \
     461            [itcl::code $this Rotate set 2 0]
     462        bind $itk_component(view) <Control-Shift-Right> \
     463            [itcl::code $this Rotate set -2 0]
     464        bind $itk_component(view) <Control-Shift-Up> \
     465            [itcl::code $this Rotate set 0 -2]
     466        bind $itk_component(view) <Control-Shift-Down> \
     467            [itcl::code $this Rotate set 0 2]
     468
     469        # Bindings for zoom via keyboard
     470        bind $itk_component(view) <KeyPress-Prior> \
     471            [itcl::code $this Zoom out]
     472        bind $itk_component(view) <KeyPress-Next> \
     473            [itcl::code $this Zoom in]
     474        bind $itk_component(view) <KeyPress-Home> \
     475            [itcl::code $this camera reset]
     476
     477        # Keyboard shortcuts
     478        # Reset heading to North
     479        bind $itk_component(view) <n> \
     480            [itcl::code $this SetHeading]
     481        # Reset pitch to top-down (2D) view
     482        bind $itk_component(view) <p> \
     483            [itcl::code $this SetPitch]
     484
    443485        # Binding for mouse motion events
    444486        set _motion(compress) 1
     
    450492        #    +[itcl::code $this SendCmd "map pin hover %x %y"]
    451493    }
    452 
    453     bind $itk_component(view) <Shift-KeyPress-Left> \
    454         [itcl::code $this Pan set 2 0]
    455     bind $itk_component(view) <Shift-KeyPress-Right> \
    456         [itcl::code $this Pan set -2 0]
    457     bind $itk_component(view) <Shift-KeyPress-Up> \
    458         [itcl::code $this Pan set 0 -2]
    459     bind $itk_component(view) <Shift-KeyPress-Down> \
    460         [itcl::code $this Pan set 0 2]
    461 
    462     # Bindings for zoom via keyboard
    463     bind $itk_component(view) <KeyPress-Prior> \
    464         [itcl::code $this Zoom out]
    465     bind $itk_component(view) <KeyPress-Next> \
    466         [itcl::code $this Zoom in]
    467494
    468495    bind $itk_component(view) <Enter> "focus $itk_component(view)"
     
    14021429            catch {unset _click}
    14031430        }
     1431        "set" {
     1432            set w [winfo width $itk_component(view)]
     1433            set h [winfo height $itk_component(view)]
     1434            set dx [expr $x / double($w)]
     1435            set dy [expr $y / double($h)]
     1436            if {[expr (abs($dx) > 0.0 || abs($dy) > 0.0)]} {
     1437                EventuallyRotate $dx $dy
     1438            }
     1439        }
    14041440        default {
    14051441            error "bad option \"$option\": should be click, drag, release"
     
    15051541        }
    15061542    }
     1543}
     1544
     1545itcl::body Rappture::MapViewer::SetHeading { {value 0} } {
     1546    set _view(heading) $value
     1547    camera set heading
     1548}
     1549
     1550itcl::body Rappture::MapViewer::SetPitch { {value -89.999} } {
     1551    set _view(pitch) $value
     1552    camera set pitch
    15071553}
    15081554
Note: See TracChangeset for help on using the changeset viewer.