Ignore:
Timestamp:
Jan 6, 2016, 4:43:18 PM (9 years ago)
Author:
ldelgass
Message:

Add selection callback to map viewer, make public select method notify server
of selections originating from outside the map viewer widget.

File:
1 edited

Legend:

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

    r5943 r5950  
    6262    public method scale {args}
    6363    public method select {option {args ""}}
     64    public method setSelectCallback {cmd}
    6465
    6566    private method KeyPress { key }
     
    9192    private method DoRotate {}
    9293    private method DoSelect {}
     94    private method DoSelectCallback {option {args ""}}
    9395    private method DrawLegend { colormap min max }
    9496    private method EarthFile {}
     
    113115    private method ReceiveMapInfo { args }
    114116    private method ReceiveScreenInfo { args }
     117    private method ReceiveSelect { option {args ""} }
    115118    private method RequestLegend { colormap w h }
    116119    private method Rotate {option x y}
     
    139142                                        # layer in the server.
    140143    private variable _viewpoints;
     144    private variable _selectCallback "";
    141145    private variable _click;            # info used for rotate operations
    142146    private variable _view;             # view params for 3D view
     
    215219    $_parser alias camera   [itcl::code $this camera]
    216220    $_parser alias screen   [itcl::code $this ReceiveScreenInfo]
    217     $_parser alias select   [itcl::code $this select]
     221    $_parser alias select   [itcl::code $this ReceiveSelect]
    218222
    219223    # Millisecond delay before animated wait dialog appears
     
    877881}
    878882
    879 # ----------------------------------------------------------------------
    880 # USAGE: select clear
    881 # USAGE: select feature
    882 # USAGE: select annotation
    883 # ----------------------------------------------------------------------
    884 itcl::body Rappture::MapViewer::select {option {args ""}} {
     883itcl::body Rappture::MapViewer::setSelectCallback {cmd} {
     884    set _selectCallback $cmd
     885}
     886
     887itcl::body Rappture::MapViewer::DoSelectCallback {option {args ""}} {
     888    if { $_selectCallback != "" } {
     889        set cmd [concat $_selectCallback $option $args]
     890        uplevel #0 $cmd
     891    }
     892}
     893
     894# ----------------------------------------------------------------------
     895# USAGE: ReceiveSelect clear
     896# USAGE: ReceiveSelect feature <args...>
     897# USAGE: ReceiveSelect annotation <args...>
     898# ----------------------------------------------------------------------
     899itcl::body Rappture::MapViewer::ReceiveSelect {option {args ""}} {
    885900    DebugTrace "Enter"
    886901    switch $option {
     
    889904        }
    890905        "clear" {
    891              puts stderr "select clear"
     906            puts stderr "select clear"
    892907        }
    893908        "feature" {
    894              puts stderr "select feature $args"
     909            puts stderr "select feature $args"
     910        }
     911    }
     912    eval DoSelectCallback $option $args
     913}
     914
     915# ----------------------------------------------------------------------
     916# USAGE: select clear
     917# USAGE: select feature <args...>
     918# USAGE: select annotation <args...>
     919#
     920# Clients use this method to notify the map widget of a selection event
     921# originating from outside the map
     922# ----------------------------------------------------------------------
     923itcl::body Rappture::MapViewer::select {option {args ""}} {
     924    switch $option {
     925        "annotation" {
     926            SendCmd "select annotation $args"
     927        }
     928        "clear" {
     929            SendCmd "select clear"
     930        }
     931        "feature" {
     932            SendCmd "select feature $args"
     933        }
     934        default {
     935            puts stderr "Unknown select option \"$option\""
    895936        }
    896937    }
     
    12541295    set _first ""
    12551296    set haveTerrain 0
     1297    #SendCmd "map layer visible 0"
    12561298    foreach dataobj [get -objects] {
    12571299        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
     
    24792521            set selectors [list]
    24802522            foreach selector [$dataobj selectors $layer] {
    2481                array set sinfo [$dataobj selector $layer $selector]
     2523                array set sinfo [$dataobj selector $layer $selector]
    24822524                DebugTrace "$selector: [array get sinfo]"
    24832525                lappend selectors [array get sinfo]
Note: See TracChangeset for help on using the changeset viewer.