Changeset 5994 for branches/blt4_geovis


Ignore:
Timestamp:
Feb 9, 2016 10:23:21 PM (6 years ago)
Author:
dkearney
Message:

merging in placard configuration updates, placard example, feature select example, and add-remove layer example from geomap branch r5971,r5990,r5991,r5993

Location:
branches/blt4_geovis
Files:
8 edited
7 copied

Legend:

Unmodified
Added
Removed
  • branches/blt4_geovis

  • branches/blt4_geovis/gui/scripts/geomaplayer.tcl

    r5964 r5994  
    2727
    2828    private variable _provider ""
     29    private variable _placardstyle_default {fill: #B6B6B688; text-fill: #000000; text-size: 12.0;}
    2930
    3031    public variable label ""
     
    3334    public variable visibility "true"
    3435    public variable opacity "1.0"
     36    public variable placardattributes ""
     37    public variable placardstyle ""
     38    public variable placardpadding 5
    3539
    3640    private method Provider { provider }
     
    5155    Provider $provider
    5256
     57    set placardstyle ${_placardstyle_default}
     58
    5359    eval configure $args
    5460}
     
    8288
    8389    if {[string compare "" $label] == 0} {
    84         error "bad value: \"$label\": should be a non-empty string"
     90        error "bad value: \"$label\": label should be a non-empty string"
    8591    }
    8692}
     
    9399
    94100    if {[string compare "" $description] == 0} {
    95         error "bad value: \"$description\": should be a non-empty string"
     101        error "bad value: \"$description\": description should be a non-empty string"
    96102    }
    97103}
     
    104110
    105111    if {[string compare "" $attribution] == 0} {
    106         error "bad value: \"$attribution\": should be a non-empty string"
     112        error "bad value: \"$attribution\": attribution should be a non-empty string"
    107113    }
    108114}
     
    115121
    116122    if {[string is bool $visibility] == 0} {
    117         error "bad value: \"$visibility\": should be a boolean"
     123        error "bad value: \"$visibility\": visibility should be a boolean"
    118124    }
    119125}
     
    126132
    127133    if {[string is double $opacity] == 0} {
    128         error "bad value: \"$opacity\": should be a double"
     134        error "bad value: \"$opacity\": opacity should be a double"
    129135    }
    130136
    131137    if {[expr {$opacity < 0.0}] == 1 || [expr {$opacity > 1.0}] == 1} {
    132         error "bad value: \"$opacity\": should be in range \[0.0,1.0\]"
     138        error "bad value: \"$opacity\": opacity should be in range \[0.0,1.0\]"
     139    }
     140}
     141
     142
     143# ----------------------------------------------------------------------
     144# placardattributes: key value list of attributes to show in the placard
     145# ----------------------------------------------------------------------
     146itcl::configbody Rappture::GeoMapLayer::placardattributes {
     147
     148    if { [expr {[llength $placardattributes] % 2}] != 0 } {
     149        error "bad value \"$placardattributes\": uneven number of placard attributes"
     150    }
     151
     152    regsub -all "\[ \t\r\n\]+" [string trim $placardattributes] " " placardattributes
     153}
     154
     155
     156# ----------------------------------------------------------------------
     157# placardstyle: CSS formatted style definition for text and background
     158# ----------------------------------------------------------------------
     159itcl::configbody Rappture::GeoMapLayer::placardstyle {
     160
     161    if {[string equal $placardstyle ""]} {
     162        # blank value sets style back to the default
     163        set placardstyle ${_placardstyle_default}
     164    }
     165
     166    regsub -all "\[ \t\r\n\]+" [string trim $placardstyle] " " placardstyle
     167}
     168
     169
     170# ----------------------------------------------------------------------
     171# placardpadding: pixels between attribute labels and edge of the backing quad
     172# ----------------------------------------------------------------------
     173itcl::configbody Rappture::GeoMapLayer::placardpadding {
     174
     175    if {[string is integer $placardpadding] == 0} {
     176        error "bad value \"$placardpadding\": placardpadding should be a positive integer"
     177    }
     178
     179    if {$placardpadding < 0} {
     180        error "bad value \"$placardpadding\": placardpadding should be a positive integer"
    133181    }
    134182}
     
    213261                visible $visibility \
    214262                opacity $opacity \
    215 
     263                placard [list \
     264                    attrlist $placardattributes\
     265                    style $placardstyle\
     266                    padding $placardpadding\
     267                ]
    216268        }
    217269        default {
  • branches/blt4_geovis/gui/scripts/map.tcl

    r5965 r5994  
    3131
    3232    public method addViewpoint { name props }
     33    public method deleteViewpoint { viewpointName }
    3334    public method earthfile {}
     35    public method getPlacardConfig { layerName }
    3436    public method hints { args }
    3537    public method isGeocentric {}
     
    4547    public method setExtents { xmin ymin xmax ymax {srs "wgs84"} }
    4648    public method setLabel { label }
     49    public method setPlacardConfig { layerName attrlist style padding }
    4750    public method setProjection { projection }
    4851    public method setStyle { style }
     
    203206            }
    204207            rename $styles ""
     208        }
     209        set placard [$layers element -as object $layer.placard]
     210        if {$placard != ""} {
     211            foreach key { attributes style padding } {
     212                set $key [$placard get $key]
     213            }
     214            setPlacardConfig $name $attributes $style $padding
    205215        }
    206216        $_tree set $child "driver" "debug"
     
    578588#       layer names
    579589#       layer settings layerName
    580 #
     590# ----------------------------------------------------------------------
    581591itcl::body Rappture::Map::layer {option args} {
    582592    set result ""
     
    601611}
    602612
     613
     614itcl::body Rappture::Map::setPlacardConfig { layerName attrlist style padding } {
     615    set id [$_tree findchild root->"layers" $layerName]
     616    if { $id < 0 } {
     617        error "unknown layer \"$layerName\""
     618    }
     619    array set placardConf {}
     620    foreach key { padding } {
     621        set placardConf($key) [set $key]
     622    }
     623    foreach key { attrlist style } {
     624        # Normalize whitespace
     625        set val [set $key]
     626        regsub -all "\[ \t\r\n\]+" [string trim $val] " " val
     627        set placardConf($key) $val
     628    }
     629    $_tree set $id "placard" [array get placardConf]
     630}
     631
     632
     633itcl::body Rappture::Map::getPlacardConfig { layerName } {
     634    set id [$_tree findchild root->"layers" $layerName]
     635    if { $id < 0 } {
     636        error "unknown layer \"$layerName\""
     637    }
     638    return [$_tree get $id "placard" ""]
     639}
    603640
    604641# ----------------------------------------------------------------------
     
    686723}
    687724
     725itcl::body Rappture::Map::deleteViewpoint { viewopintName } {
     726    set id [$_tree findchild root->"viewpoints" $viewpointName]
     727    if { $id < 0 } {
     728        error "unknown viewpoint \"$viewpointName\""
     729    }
     730    $_tree delete $id
     731}
     732
    688733# ----------------------------------------------------------------------
    689734# USAGE: type <layerName>
  • branches/blt4_geovis/gui/scripts/mapviewer.tcl

    r5964 r5994  
    14271427
    14281428itcl::body Rappture::MapViewer::EnablePanningMouseBindings {} {
    1429     if {$_useServerManip} {
     1429    if {1 || $_useServerManip} {
    14301430        bind $itk_component(view) <ButtonPress-1> \
    14311431            [itcl::code $this MouseClick 1 %x %y]
     
    14511451
    14521452itcl::body Rappture::MapViewer::EnableRotationMouseBindings {} {
    1453     if {$_useServerManip} {
    1454         bind $itk_component(view) <ButtonPress-2> \
    1455             [itcl::code $this Rotate click %x %y]
    1456         bind $itk_component(view) <B2-Motion> \
    1457             [itcl::code $this Rotate drag %x %y]
    1458         bind $itk_component(view) <ButtonRelease-2> \
    1459             [itcl::code $this Rotate release %x %y]
    1460     } else {
     1453    if {1 || $_useServerManip} {
    14611454        # Bindings for rotation via mouse
    14621455        bind $itk_component(view) <ButtonPress-2> \
     
    14661459        bind $itk_component(view) <ButtonRelease-2> \
    14671460            [itcl::code $this MouseRelease 2 %x %y]
     1461    } else {
     1462        bind $itk_component(view) <ButtonPress-2> \
     1463            [itcl::code $this Rotate click %x %y]
     1464        bind $itk_component(view) <B2-Motion> \
     1465            [itcl::code $this Rotate drag %x %y]
     1466        bind $itk_component(view) <ButtonRelease-2> \
     1467            [itcl::code $this Rotate release %x %y]
    14681468    }
    14691469}
     
    14761476
    14771477itcl::body Rappture::MapViewer::EnableZoomMouseBindings {} {
    1478     if {$_useServerManip} {
     1478    if {1 || $_useServerManip} {
    14791479        bind $itk_component(view) <ButtonPress-3> \
    14801480            [itcl::code $this MouseClick 3 %x %y]
     
    17701770itcl::body Rappture::MapViewer::Pan {option x y} {
    17711771    switch -- $option {
    1772         "set" {
    1773             set w [winfo width $itk_component(view)]
    1774             set h [winfo height $itk_component(view)]
    1775             set x [expr $x / double($w)]
    1776             set y [expr $y / double($h)]
    1777             if {[expr (abs($x) > 0.0 || abs($y) > 0.0)]} {
    1778                 SendCmd "camera pan $x $y"
    1779             }
    1780             return
    1781         }
    17821772        "click" {
    17831773            set _click(x) $x
     
    18131803            $itk_component(view) configure -cursor ""
    18141804            set _b1mode ""
     1805        }
     1806        "set" {
     1807            set w [winfo width $itk_component(view)]
     1808            set h [winfo height $itk_component(view)]
     1809            set x [expr $x / double($w)]
     1810            set y [expr $y / double($h)]
     1811            if {[expr (abs($x) > 0.0 || abs($y) > 0.0)]} {
     1812                SendCmd "camera pan $x $y"
     1813            }
     1814            return
    18151815        }
    18161816        default {
     
    28842884            SendCmd "map layer opacity $style(-opacity) $layer"
    28852885        }
     2886    }
     2887
     2888    if {[info exists info(placard)]} {
     2889        array set placard [$dataobj getPlacardConfig $layer]
     2890        SendCmd [list placard config $placard(attrlist) $placard(style) $placard(padding) $layer]
    28862891    }
    28872892
  • branches/blt4_geovis/gui/scripts/visviewer.tcl

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/blt4_geovis/gui/test/geomaplayer.test

    r5964 r5994  
    4545#   ?-attribution <attrib>? \
    4646#   ?-visibility <visibility>? \
    47 #   ?-opacity <opacity>?
     47#   ?-opacity <opacity>? \
     48#   ?-placardattributes <attributes>? \
     49#   ?-placardstyle <style>? \
     50#   ?-placardpadding <padding>?
    4851#----------------------------------------------------------
    4952test geomaplayer-1.1 {Rappture::GeoMapLayer, 0 arguments} {
     
    5659
    5760
     61#----------------------------------------------------------
     62# export command
     63#----------------------------------------------------------
     64
     65set l1 [Rappture::GeoMapLayer #auto $provider]
     66
    5867test geomaplayer-11.0 {Rappture::GeoMapLayer, export (default format)} {
    59     set l [Rappture::GeoMapLayer #auto $provider]
    60     set t [$l export]
     68    set t [$l1 export]
    6169    list [catch {lindex [$t dump 0] 3} msg] $msg
    62 } {0 {type image driver xyz cache true attribution {} xyz.url http://myurl.com/ label {} description {} visible true opacity 1.0}}
     70} {0 {type image driver xyz cache true attribution {} xyz.url http://myurl.com/ label {} description {} visible true opacity 1.0 placard {attrlist {} style {fill: #B6B6B688; text-fill: #000000; text-size: 12.0;} padding 5}}}
    6371
    6472test geomaplayer-11.1 {Rappture::GeoMapLayer, export bad format} {
    65     set l [Rappture::GeoMapLayer #auto $provider]
    66     list [catch {$l export -format blahh} msg] $msg
     73    list [catch {$l1 export -format blahh} msg] $msg
    6774} {1 {bad format "blahh": should be one of blt_tree}}
    6875
    6976test geomaplayer-11.2 {Rappture::GeoMapLayer, export -format blt_tree} {
    70     set l [Rappture::GeoMapLayer #auto $provider]
    71     set t [$l export -format blt_tree]
     77    set t [$l1 export -format blt_tree]
    7278    list [catch {lindex [$t dump 0] 3} msg] $msg
    73 } {0 {type image driver xyz cache true attribution {} xyz.url http://myurl.com/ label {} description {} visible true opacity 1.0}}
     79} {0 {type image driver xyz cache true attribution {} xyz.url http://myurl.com/ label {} description {} visible true opacity 1.0 placard {attrlist {} style {fill: #B6B6B688; text-fill: #000000; text-size: 12.0;} padding 5}}}
     80
     81
     82#----------------------------------------------------------
     83# -placardattributes flag validation
     84#----------------------------------------------------------
     85
     86set l2 [Rappture::GeoMapLayer #auto $provider]
     87
     88test geomaplayer-12.1 {-placardattributes string} {
     89    set err [catch {$l2 configure -placardattributes {name Name aland "Land Area"}} msg]
     90    catch {$l2 cget -placardattributes} stored
     91    list $err $msg $stored
     92} {0 {} {name Name aland "Land Area"}}
     93
     94test geomaplayer-12.2 {-placardattributes string with extra spaces} {
     95    set err [catch {$l2 configure -placardattributes "name Name\naland LandArea"} msg]
     96    catch {$l2 cget -placardattributes} stored
     97    list $err $msg $stored
     98} {0 {} {name Name aland LandArea}}
     99
     100
     101
     102#----------------------------------------------------------
     103# -placardstyle flag validation
     104#----------------------------------------------------------
     105
     106test geomaplayer-13.1 {-placardstyle string} {
     107    set err [catch {$l2 configure -placardstyle {fill: #00FF0088;}} msg]
     108    catch {$l2 cget -placardstyle} stored
     109    list $err $msg $stored
     110} {0 {} {fill: #00FF0088;}}
     111
     112test geomaplayer-13.2 {-placardstyle string with extra spaces} {
     113    set err [catch {$l2 configure -placardstyle "fill:\t#00FF0088;"} msg]
     114    catch {$l2 cget -placardstyle} stored
     115    list $err $msg $stored
     116} {0 {} {fill: #00FF0088;}}
     117
     118test geomaplayer-13.3 {-placardstyle empty string sets widget default} {
     119    set err [catch {$l2 configure -placardstyle ""} msg]
     120    catch {$l2 cget -placardstyle} stored
     121    list $err $msg $stored
     122} {0 {} {fill: #B6B6B688; text-fill: #000000; text-size: 12.0;}}
     123
     124
     125#----------------------------------------------------------
     126# -placardpadding flag validation
     127#----------------------------------------------------------
     128
     129test geomaplayer-14.1 {-placardpadding integer} {
     130    set err [catch {$l2 configure -placardpadding 7} msg]
     131    catch {$l2 cget -placardpadding} stored
     132    list $err $msg $stored
     133} {0 {} 7}
     134
     135test geomaplayer-14.2 {-placardpadding double} {
     136    list [catch {$l2 configure -placardpadding 8.0} msg] $msg
     137} {1 {bad value "8.0": placardpadding should be a positive integer}}
     138
     139test geomaplayer-14.3 {-placardpadding negative integer} {
     140    list [catch {$l2 configure -placardpadding -5} msg] $msg
     141} {1 {bad value "-5": placardpadding should be a positive integer}}
     142
    74143
    75144
  • branches/blt4_geovis/gui/test/geomaplayerimage.test

    r5964 r5994  
    7171    set t [$l export -format blt_tree]
    7272    list [catch {lindex [$t dump 0] 3} msg] $msg
    73 } {0 {type image driver xyz cache true attribution {} xyz.url http://myurl.com/ label {} description {} visible true opacity 1.0 coverage false}}
     73} {0 {type image driver xyz cache true attribution {} xyz.url http://myurl.com/ label {} description {} visible true opacity 1.0 placard {attrlist {} style {fill: #B6B6B688; text-fill: #000000; text-size: 12.0;} padding 5} coverage false}}
    7474
    7575
  • branches/blt4_geovis/lang/tcl/pkgIndex.tcl.in

    • Property svn:mergeinfo changed (with no actual effect on merging)
Note: See TracChangeset for help on using the changeset viewer.