Changeset 6318 for trunk


Ignore:
Timestamp:
May 6, 2016, 7:05:00 AM (9 years ago)
Author:
ldelgass
Message:

Add dirty flag to map object to track changes to (immutable) layer properties.
When one of these properties is changed, the layer must be re-created. Bugs
still remain: the layer cache can hang around after the delete/add (need to
determine if the server can invalidate that layer's cache), and the layer order
is not retained when re-creating the layer.

Location:
trunk/gui/scripts
Files:
2 edited

Legend:

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

    r6264 r6318  
    3131
    3232    public method addLayer { type name paramArray driver driverParamArray {stylesheet {}} {script {}} {selectors {}} }
     33    public method addSelector { layerName selectorName paramArray }
    3334    public method addViewpoint { name props }
    3435    public method clearExtents {}
    3536    public method deleteLayer { layerName }
     37    public method deleteSelector { layerName selectorName }
    3638    public method deleteViewpoint { viewpointName }
     39    public method dirty { key args } {
     40        if {[llength $args] == 0} {
     41            if { [info exists _dirty($key)] } {
     42                return $_dirty($key)
     43            } else {
     44                return 0
     45            }
     46        } else {
     47            set _dirty($key) [lindex $args 0]
     48        }
     49    }
    3750    public method getPlacardConfig { layerName }
    3851    public method hasLayer { layerName }
     
    5063    public method setAttribution { attribution }
    5164    public method setCamera { camera }
     65    public method setColormap { layerName colormap }
    5266    public method setDescription { description }
    5367    public method setExtents { xmin ymin xmax ymax {srs "wgs84"} }
     
    5569    public method setPlacardConfig { layerName attrlist style padding }
    5670    public method setProjection { projection }
     71    public method setScript { layerName script }
    5772    public method setStyle { style }
     73    public method setStylesheet { layerName stylesheet }
    5874    public method setToolInfo { id name command title revision }
    5975    public method setType { type }
     
    7086    private variable _tree "";         # Tree of information about the map.
    7187    private variable _isValid 0;
     88    private variable _dirty;
     89    array set _dirty {
     90        viewpoints 0
     91    }
    7292    private common _nextSelector 0;
    7393    private common _layerTypes
     
    765785        }
    766786    }
     787    set _dirty($id) 1
    767788    return $id
    768789}
     
    804825    }
    805826    $_tree delete $id
     827    array unset _dirty $layerName
    806828}
    807829
     
    868890}
    869891
     892itcl::body Rappture::Map::setScript { layerName script } {
     893    set id [$_tree findchild root->"layers" $layerName]
     894    if { $id < 0 } {
     895        error "unknown layer \"$layerName\""
     896    }
     897    $_tree set $id "script" $script
     898    set _dirty($layerName) 1
     899}
     900
     901itcl::body Rappture::Map::setStylesheet { layerName stylesheet } {
     902    set id [$_tree findchild root->"layers" $layerName]
     903    if { $id < 0 } {
     904        error "unknown layer \"$layerName\""
     905    }
     906    $_tree set $id "stylesheet" $stylesheet
     907    set _dirty($layerName) 1
     908}
     909
     910itcl::body Rappture::Map::setColormap { layerName colormap } {
     911    set id [$_tree findchild root->"layers" $layerName]
     912    if { $id < 0 } {
     913        error "unknown layer \"$layerName\""
     914    }
     915    $_tree set $id "colorramp.colormap" $colormap
     916    set _dirty($layerName) 1
     917}
     918
    870919# ----------------------------------------------------------------------
    871920# USAGE: selectors
     
    904953        return 1
    905954    }
     955}
     956
     957itcl::body Rappture::Map::addSelector { layerName name params } {
     958    set nodeid $name
     959    set layerid [$_tree findchild root->"layers" $layerName]
     960    if { $layerid < 0 } {
     961        error "unknown layer \"$layerName\""
     962    }
     963    if {[hasSelector $layerName $nodeid]} {
     964        error "Selector '$nodeid' already exists"
     965    }
     966    set parent [$_tree findchild root->"layers"->"$layerName" "selectors"]
     967    if { $parent == "" } {
     968        set parent [$_tree insert $layerid -label "selectors"]
     969    }
     970    set child [$_tree insert $parent -label $nodeid]
     971    array set info $params
     972    foreach key { name style styleExpression query queryBounds queryOrderBy } {
     973        if { [info exists info($key)] &&
     974             $info($key) != ""} {
     975            $_tree set $child $key $info($key)
     976        }
     977    }
     978    set _dirty($layerName) 1
     979}
     980
     981itcl::body Rappture::Map::deleteSelector { layerName selectorName } {
     982    set id [$_tree findchild root->"layers"->"$layerName"->"selectors" $selectorName]
     983    if { $id < 0 } {
     984        error "unknown selector \"$selectorName\""
     985    }
     986    $_tree delete $id
     987    set _dirty($layerName) 1
    906988}
    907989
     
    9711053        $_tree set $child z $info(altitude)
    9721054    }
     1055    set _dirty(viewpoints) 1
    9731056}
    9741057
     
    9791062    }
    9801063    $_tree delete $id
     1064    set _dirty(viewpoints) 1
    9811065}
    9821066
  • trunk/gui/scripts/mapviewer.tcl

    r6304 r6318  
    14671467                set _layers($tag) 1
    14681468                SetLayerStyle $dataobj $layer
    1469             }
     1469            } elseif { [$dataobj dirty $layer] } {
     1470                # Recreate layer
     1471                # FIXME: retain layer order
     1472                SendCmd "map layer delete $tag"
     1473                SetLayerStyle $dataobj $layer
     1474            }
     1475            $dataobj dirty $layer 0
    14701476            # Don't change visibility of shared/base layers
    14711477            if { !$info(shared) } {
Note: See TracChangeset for help on using the changeset viewer.