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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.