Ignore:
Timestamp:
Jun 2, 2016 8:19:06 AM (8 years ago)
Author:
dkearney
Message:

merging changes from trunk into multichoice branch

Location:
branches/multichoice
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/multichoice

  • branches/multichoice/examples/mapviewer/select/select_feature_example.tcl

    r6209 r6371  
     1package require Tk
    12package require Rappture
    23package require RapptureGUI
     
    78source [file join $commondir geovis_settings.tcl]
    89
    9 # this method is called when a user clicks on a icon in the map
    10 # the method is used at the bottom of this example
    11 # the callback is called with two arguments:
    12 # option - should be one of "annotation", "clear", "feature"
    13 proc handler {option {args ""}} {
     10# This method is called when a user modifies the selection in the map view.
     11# This callback is installed in the viewer using setSelectCallback in the code below.
     12# The callback has two arguments:
     13#   option - should be one of "annotation", "clear", "feature", "region"
     14#   args - depends on option, see below
     15proc selectHandler {option {args ""}} {
    1416    switch $option {
    1517        "annotation" {
    16             # pass
     18            # An annotation (not in a feature layer) was selected, the single argument
     19            # is a list of the selected annotation names.
    1720        }
    1821        "clear" {
    19             # previously selected features have been unselected.
    20             # no arguments associated with this option.
     22            # Previously selected features or annotations have been deselected.
     23            # No arguments.
     24            puts "select clear"
    2125        }
    2226        "feature" {
    23             # a feature was selected, the server returns 4 values about the feature
    24             # that are held in args:
    25             # globalObjId - the global object identifier
    26             # featureIdList - a single value or list of feature identifiers.
    27             #                 if multiple features are returned, they arei
    28             #                 enclosed in curly brackets.
    29             # numFeaturesInLayer - the number of features in the layer
    30             # layerName - the name of the layer the features were found in.
    31             #             only features from a single layer can be selected
    32             #             at a time.
    33             foreach {globalObjId featureIdList numFeaturesInLayer layerName} $args break
    34             puts "handler caught\
    35                 globalObjId=\"$globalObjId\"\
    36                 featureIdList=\"$featureIdList\"\
    37                 numFeaturesInLayer=\"$numFeaturesInLayer\"\
    38                 layerName=\"$layerName\""
     27            # The feature selection set changed, the arguments are:
     28            #   op - "add", "delete" or "set"
     29            #   featureIdList - a list of feature identifiers.
     30            #   layerName - the name of the layer the features were found in.
     31            foreach {op featureIdList layerName} $args break
     32            switch $op {
     33                "add" {
     34                    puts "select feature add:\nfeatureIDList=\"$featureIdList\"\nlayerName=\"$layerName\""
     35                }
     36                "delete" {
     37                    puts "select feature delete:\nfeatureIDList=\"$featureIdList\"\nlayerName=\"$layerName\""
     38                }
     39                "set" {
     40                    puts "select feature set:\nfeatureIDList=\"$featureIdList\"\nlayerName=\"$layerName\""
     41                }
     42                default {
     43                    error "bad op \"$op\": should be one of: add, delete or set"
     44                }
     45            }
     46        }
     47        "region" {
     48            # An area defined by two wgs84 corner points was selected.
     49            # Here x is wgs84 decimal degrees longitude and y is wgs84 decimal degrees latitude.
     50            foreach {xmin ymin xmax ymax} $args break
     51            puts "select region: ($xmin, $ymin) - ($xmax, $ymax)"
    3952        }
    4053        default {
    41             error "bad option \"$option\": should be one of annotation,\
    42                 clean, or feature"
     54            error "bad option \"$option\": should be one of: annotation, clear, feature or region"
    4355        }
    4456    }
     
    8799"
    88100
    89 # create a map object
     101# Create a map object
    90102set map [Rappture::Map #auto]
    91103
    92 # add all layers to the map object
     104# Add all layers to the map object
    93105$map addLayer image \
    94106    osm [array get osmParams] \
     
    102114    $stylesheet
    103115
    104 # add a map to the vis client
     116# Add a map to the vis client
    105117$mapviewer scale $map
    106118$mapviewer add $map
    107119
    108120
    109 # set the proc/method to be called when a feature is selected on the map.
    110 # in this case we give the full path to the previously defined
    111 # procedure named "handler". for an itcl class method, you may need to
    112 # use itcl::code to get the full path of the  callback method:
    113 # for example: [itcl::code $this handler]
    114 $mapviewer setSelectCallback ::handler
     121# Set the proc/method to be called when a feature is selected on the map.
     122# In this case we give the full path to the previously defined
     123# procedure named "selectHandler". For an itcl class method, you may need to
     124# use itcl::code to get the full path of the callback method, e.g.
     125# [itcl::code $this selectHandler]
     126$mapviewer setSelectCallback ::selectHandler
Note: See TracChangeset for help on using the changeset viewer.