Changeset 5949


Ignore:
Timestamp:
Dec 18, 2015 1:19:46 AM (7 years ago)
Author:
dkearney
Message:

adding data provider and layer objects, updating mapviewer to remove layers from client and server.

Location:
branches/geomap/gui
Files:
23 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/geomap/gui/scripts/Makefile.in

    r5331 r5949  
    6161                $(srcdir)/gauge.tcl \
    6262                $(srcdir)/getopts.tcl \
     63                $(srcdir)/geomapdataprovider.tcl \
     64                $(srcdir)/geomapdataprovidercolorramp.tcl \
     65                $(srcdir)/geomapdataprovidergdal.tcl \
     66                $(srcdir)/geomapdataproviderogr.tcl \
     67                $(srcdir)/geomapdataprovidertfs.tcl \
     68                $(srcdir)/geomapdataprovidertms.tcl \
     69                $(srcdir)/geomapdataproviderwfs.tcl \
     70                $(srcdir)/geomapdataproviderwms.tcl \
     71                $(srcdir)/geomapdataproviderxyz.tcl \
     72                $(srcdir)/geomaplayer.tcl \
     73                $(srcdir)/geomaplayerimage.tcl \
    6374                $(srcdir)/grab.tcl \
    6475                $(srcdir)/groupentry.tcl \
  • branches/geomap/gui/scripts/map.tcl

    r5917 r5949  
    3737        return $_isValid;
    3838    }
    39     public method layer { layerName }
     39    public method layer { option args }
    4040    public method layers {}
    4141    public method selectors { layerName }
     
    5454
    5555    protected method Parse { xmlobj path }
     56
     57    private method AddLayer { args }
     58    private method DeleteLayer { layerName }
     59    private method GetLayerNames {}
     60    private method GetLayerSettings { layerName }
     61
    5662
    5763    private variable _tree "";         # Tree of information about the map.
     
    446452
    447453# ----------------------------------------------------------------------
    448 # USAGE: layers
    449 #
    450 # Returns a list of IDs for the layers in the map
    451 # ----------------------------------------------------------------------
    452 itcl::body Rappture::Map::layers {} {
    453     set list {}
    454     foreach node [$_tree children root->"layers"] {
    455         lappend list [$_tree label $node]
    456     }
    457     return $list
    458 }
    459 
    460 # ----------------------------------------------------------------------
    461454# USAGE: viewpoints
    462455#
     
    472465
    473466# ----------------------------------------------------------------------
     467# USAGE: AddLayer -format <format>
     468#
     469# Associate a new layer to the map
     470# ----------------------------------------------------------------------
     471itcl::body Rappture::Map::AddLayer { args } {
     472    set layerName ""
     473    set valids "-format"
     474    set format "blt_tree"
     475
     476    set layerObj [lrange $args end end]
     477    set args [lrange $args 0 end-1]
     478
     479    while {[llength $args] > 0} {
     480        set flag [lindex $args 0]
     481        switch -- $flag {
     482            "-format" {
     483                if {[llength $args] > 1} {
     484                    set format [lindex $args 1]
     485                    set args [lrange $args 2 end]
     486                } else {
     487                    error "wrong number args: should be ?-format <format>?"
     488                }
     489            }
     490            default {
     491                error "invalid option \"$flag\": should be one of $valids"
     492            }
     493        }
     494    }
     495
     496    set valids "blt_tree"
     497
     498    switch -- $format {
     499        "blt_tree" {
     500            # check if a layer by the same name already exists
     501            set layerName "layer[incr _nextLayer]"
     502            if {[$_tree findchild root->"layers" $layerName] != -1} {
     503                error "key error \"$layerName\": layer name exists"
     504            }
     505            # copy the incomming layer data into our map object
     506            set id [$layerObj copy root $_tree root->"layers"]
     507            # give the layer a searchable layer name
     508            $_tree label $id $layerName
     509        }
     510        default {
     511            error "bad format \"$format\": should be one of $valids"
     512        }
     513    }
     514
     515    return $layerName
     516}
     517
     518# ----------------------------------------------------------------------
     519# USAGE: DeleteLayer <layerName>
     520#
     521# Remove a layer from the map
     522# ----------------------------------------------------------------------
     523itcl::body Rappture::Map::DeleteLayer { layerName } {
     524    set id [$_tree findchild root->"layers" $layerName]
     525    if {$id <= 0} {
     526        # layer not found
     527        error "invalid layer \"$layerName\": should be one of [GetLayerNames]"
     528    }
     529    # delete the layer
     530    $_tree delete $id
     531}
     532
     533
     534# ----------------------------------------------------------------------
     535# USAGE: GetLayerNames
     536# USAGE: layers
     537#
     538# Returns a list of IDs for the layers in the map
     539# ----------------------------------------------------------------------
     540itcl::body Rappture::Map::GetLayerNames {} {
     541    set list {}
     542    foreach node [$_tree children root->"layers"] {
     543        lappend list [$_tree label $node]
     544    }
     545    return $list
     546}
     547
     548# ----------------------------------------------------------------------
     549# USAGE: GetLayerSettings <layerName>
    474550# USAGE: layer <layerName>
    475551#
    476 # Returns an array of settings for the named layer
    477 # ----------------------------------------------------------------------
    478 itcl::body Rappture::Map::layer { layerName } {
     552# Returns a list of settings for the named layer
     553# ----------------------------------------------------------------------
     554itcl::body Rappture::Map::GetLayerSettings { layerName } {
    479555    set id [$_tree findchild root->"layers" $layerName]
    480556    if { $id < 0 } {
     
    483559    return [$_tree get $id]
    484560}
     561
     562# ----------------------------------------------------------------------
     563# USAGE: layer
     564#
     565#   This public method is called by clients using this widget to manage
     566#   layers in the map.
     567#
     568#       layer add ?-type type? layerData
     569#       layer delete layerName
     570#       layer names
     571#       layer settings layerName
     572#
     573itcl::body Rappture::Map::layer {option args} {
     574    set result ""
     575    switch -- $option {
     576        "add" {
     577            set result [eval AddLayer $args]
     578        }
     579        "delete" {
     580            set result [eval DeleteLayer $args]
     581        }
     582        "names" {
     583            set result [GetLayerNames]
     584        }
     585        "settings" {
     586            set result [GetLayerSettings $args]
     587        }
     588        default {
     589            error "unknown layer option \"$option\""
     590        }
     591    }
     592    return $result
     593}
     594
    485595
    486596# ----------------------------------------------------------------------
  • branches/geomap/gui/scripts/mapviewer.tcl

    r5922 r5949  
    5353    public method camera {option args}
    5454    public method delete {args}
     55    public method remove {args}
    5556    public method disconnect {}
    5657    public method download {option args}
     
    6263    public method scale {args}
    6364    public method select {option {args ""}}
     65
     66    public method send { cmd }
    6467
    6568    private method KeyPress { key }
     
    535538}
    536539
     540#
     541# send --
     542#
     543#   Test method for dsk
     544#
     545#       send [list my command]
     546#
     547itcl::body Rappture::MapViewer::send {cmd} {
     548    puts "sending: \"$cmd\""
     549    SendCmd $cmd
     550}
     551
    537552itcl::body Rappture::MapViewer::DoResize {} {
    538553    set sendResize 1
     
    693708        }
    694709        # When a map is marked deleted, we hide its layers.
    695         foreach layer [$dataobj layers] {
     710        foreach layer [$dataobj layer names] {
    696711            SendCmd "map layer visible 0 $layer"
    697712            set _visibility($layer) 0
     713        }
     714        # Remove it from the dataobj list.
     715        set _dlist [lreplace $_dlist $pos $pos]
     716        array unset _obj2ovride $dataobj-*
     717        array unset _settings $dataobj-*
     718        set changed 1
     719    }
     720    # If anything changed, then rebuild the plot
     721    if { $changed } {
     722        $_dispatcher event -idle !rebuild
     723    }
     724}
     725
     726# ----------------------------------------------------------------------
     727# USAGE: remove ?<dataobj1> <dataobj2> ...?
     728#
     729# Clients use this to permanantly remove a dataobj from the client
     730# and the server. If no dataobjs are specified, then all dataobjs
     731# are removed. Unlike the delete method, dataobjects are permenantly
     732# removed from both the client and the server and it is safe to add
     733# them again without conflict in layer names.
     734# ----------------------------------------------------------------------
     735itcl::body Rappture::MapViewer::remove {args} {
     736    DebugTrace "Enter"
     737    if { [llength $args] == 0} {
     738        set args $_dlist
     739    }
     740    # Remove all specified dataobjs
     741    set changed 0
     742    foreach dataobj $args {
     743        set pos [lsearch -exact $_dlist $dataobj]
     744        if { $pos < 0 } {
     745            continue;                   # Don't know anything about it.
     746        }
     747        # Remove the layers from the client and server.
     748        foreach layer [$dataobj layer names] {
     749            SendCmd "map layer delete $layer"
     750            if { [info exists _layers($layer)] } {
     751                array unset _layers $layer
     752            }
     753            if { [info exists _opacity($layer)] } {
     754                array unset _opacity $layer
     755            }
     756            if { [info exists _visibility($layer)] } {
     757                array unset _visibility $layer
     758            }
    698759        }
    699760        # Remove it from the dataobj list.
     
    851912            }
    852913        }
    853         foreach layer [$dataobj layers] {
     914        foreach layer [$dataobj layer names] {
    854915            if { [$dataobj type $layer] == "elevation" } {
    855916                set _haveTerrain 1
     
    12581319            set _first $dataobj
    12591320        }
    1260         foreach layer [$dataobj layers] {
     1321        foreach layer [$dataobj layer names] {
    12611322            array unset info
    1262             array set info [$dataobj layer $layer]
     1323            array set info [$dataobj layer settings $layer]
    12631324            if { ![info exists _layers($layer)] } {
    12641325                if { $_reportClientInfo }  {
     
    14301491    set rlist ""
    14311492    foreach dataobj $dlist {
    1432         foreach layer [$dataobj layers] {
     1493        foreach layer [$dataobj layer names] {
    14331494            if { [info exists _layers($layer)] && $_layers($layer) } {
    14341495                lappend rlist $layer
     
    23642425
    23652426itcl::body Rappture::MapViewer::SetLayerStyle { dataobj layer } {
    2366     array set info [$dataobj layer $layer]
     2427    array set info [$dataobj layer settings $layer]
    23672428    if { [info exists info(visible)] &&
    23682429         !$info(visible) } {
     
    28022863    set imgIdx 0
    28032864    foreach dataobj [get -objects] {
    2804         foreach layer [$dataobj layers] {
     2865        foreach layer [$dataobj layer names] {
    28052866            array unset info
    2806             array set info [$dataobj layer $layer]
     2867            array set info [$dataobj layer settings $layer]
    28072868            checkbutton $f.${layer}_visible \
    28082869                -text $info(label) \
     
    29463007
    29473008    foreach dataobj [get -objects] {
    2948         foreach layer [$dataobj layers] {
     3009        foreach layer [$dataobj layer names] {
    29493010            set _layers($layer) 1
    29503011            array unset info
    2951             array set info [$dataobj layer $layer]
     3012            array set info [$dataobj layer settings $layer]
    29523013            switch -- $info(type) {
    29533014                "image" {
Note: See TracChangeset for help on using the changeset viewer.