Changeset 5991 for branches/geomap/gui


Ignore:
Timestamp:
Feb 9, 2016, 9:50:20 PM (9 years ago)
Author:
dkearney
Message:

allow users to set placard configuration for layer from layer class
updating generic layer and image layer tests with placard configuration

Location:
branches/geomap/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/geomap/gui/scripts/geomaplayer.tcl

    r5949 r5991  
    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/geomap/gui/test/geomaplayer.test

    r5949 r5991  
    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/geomap/gui/test/geomaplayerimage.test

    r5949 r5991  
    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
Note: See TracChangeset for help on using the changeset viewer.