Changeset 5975 for trunk/gui/scripts


Ignore:
Timestamp:
Jan 28, 2016 9:59:31 AM (8 years ago)
Author:
ldelgass
Message:

Add feature layer placard config to map object

Location:
trunk/gui/scripts
Files:
2 edited

Legend:

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

    r5962 r5975  
    3535    public method deleteViewpoint { viewpointName }
    3636    public method earthfile {}
     37    public method getPlacardConfig { layerName }
    3738    public method hasLayer { layerName }
    3839    public method hints { args }
     
    4950    public method setExtents { xmin ymin xmax ymax {srs "wgs84"} }
    5051    public method setLabel { label }
     52    public method setPlacardConfig { layerName attrlist style padding }
    5153    public method setProjection { projection }
    5254    public method setStyle { style }
     
    203205            }
    204206            rename $styles ""
     207        }
     208        set placard [$layers element -as object $layer.placard]
     209        if {$placard != ""} {
     210            foreach key { attributes style padding } {
     211                set $key [$placard get $key]
     212            }
     213            setPlacardConfig $name $attributes $style $padding
    205214        }
    206215        $_tree set $child "driver" "debug"
     
    627636}
    628637
     638itcl::body Rappture::Map::setPlacardConfig { layerName attrlist style padding } {
     639    set id [$_tree findchild root->"layers" $layerName]
     640    if { $id < 0 } {
     641        error "unknown layer \"$layerName\""
     642    }
     643    array set placardConf {}
     644    foreach key { padding } {
     645        set placardConf($key) [set $key]
     646    }
     647    foreach key { attrlist style } {
     648        # Normalize whitespace
     649        set val [set $key]
     650        regsub -all "\[ \t\r\n\]+" [string trim $val] " " val
     651        set placardConf($key) $val
     652    }
     653    $_tree set $id "placard" [array get placardConf]
     654}
     655
     656itcl::body Rappture::Map::getPlacardConfig { layerName } {
     657    set id [$_tree findchild root->"layers" $layerName]
     658    if { $id < 0 } {
     659        error "unknown layer \"$layerName\""
     660    }
     661    return [$_tree get $id "placard" ""]
     662}
     663
    629664itcl::body Rappture::Map::deleteLayer { layerName } {
    630665    set id [$_tree findchild root->"layers" $layerName]
  • trunk/gui/scripts/mapviewer.tcl

    r5959 r5975  
    13661366
    13671367itcl::body Rappture::MapViewer::EnablePanningMouseBindings {} {
    1368     if {$_useServerManip} {
     1368    if {1 || $_useServerManip} {
    13691369        bind $itk_component(view) <ButtonPress-1> \
    13701370            [itcl::code $this MouseClick 1 %x %y]
     
    13901390
    13911391itcl::body Rappture::MapViewer::EnableRotationMouseBindings {} {
    1392     if {$_useServerManip} {
    1393         bind $itk_component(view) <ButtonPress-2> \
    1394             [itcl::code $this Rotate click %x %y]
    1395         bind $itk_component(view) <B2-Motion> \
    1396             [itcl::code $this Rotate drag %x %y]
    1397         bind $itk_component(view) <ButtonRelease-2> \
    1398             [itcl::code $this Rotate release %x %y]
    1399     } else {
     1392    if {1 || $_useServerManip} {
    14001393        # Bindings for rotation via mouse
    14011394        bind $itk_component(view) <ButtonPress-2> \
     
    14051398        bind $itk_component(view) <ButtonRelease-2> \
    14061399            [itcl::code $this MouseRelease 2 %x %y]
     1400    } else {
     1401        bind $itk_component(view) <ButtonPress-2> \
     1402            [itcl::code $this Rotate click %x %y]
     1403        bind $itk_component(view) <B2-Motion> \
     1404            [itcl::code $this Rotate drag %x %y]
     1405        bind $itk_component(view) <ButtonRelease-2> \
     1406            [itcl::code $this Rotate release %x %y]
    14071407    }
    14081408}
     
    14151415
    14161416itcl::body Rappture::MapViewer::EnableZoomMouseBindings {} {
    1417     if {$_useServerManip} {
     1417    if {1 || $_useServerManip} {
    14181418        bind $itk_component(view) <ButtonPress-3> \
    14191419            [itcl::code $this MouseClick 3 %x %y]
     
    17091709itcl::body Rappture::MapViewer::Pan {option x y} {
    17101710    switch -- $option {
    1711         "set" {
    1712             set w [winfo width $itk_component(view)]
    1713             set h [winfo height $itk_component(view)]
    1714             set x [expr $x / double($w)]
    1715             set y [expr $y / double($h)]
    1716             if {[expr (abs($x) > 0.0 || abs($y) > 0.0)]} {
    1717                 SendCmd "camera pan $x $y"
    1718             }
    1719             return
    1720         }
    17211711        "click" {
    17221712            set _click(x) $x
     
    17521742            $itk_component(view) configure -cursor ""
    17531743            set _b1mode ""
     1744        }
     1745        "set" {
     1746            set w [winfo width $itk_component(view)]
     1747            set h [winfo height $itk_component(view)]
     1748            set x [expr $x / double($w)]
     1749            set y [expr $y / double($h)]
     1750            if {[expr (abs($x) > 0.0 || abs($y) > 0.0)]} {
     1751                SendCmd "camera pan $x $y"
     1752            }
     1753            return
    17541754        }
    17551755        default {
     
    28232823            SendCmd "map layer opacity $style(-opacity) $layer"
    28242824        }
     2825    }
     2826
     2827    if {[info exists info(placard)]} {
     2828        array set placard [$dataobj getPlacardConfig $layer]
     2829        SendCmd [list placard config $placard(attrlist) $placard(style) $placard(padding) $layer]
    28252830    }
    28262831
Note: See TracChangeset for help on using the changeset viewer.