Changeset 6124 for trunk/gui/scripts


Ignore:
Timestamp:
Mar 15, 2016, 2:21:58 AM (9 years ago)
Author:
ldelgass
Message:

Add option to get legend image to MapViewer::get

File:
1 edited

Legend:

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

    r6106 r6124  
    5757    public method get {args}
    5858    public method isconnected {}
    59     public method parameters {title args} {
    60         # do nothing
    61     }
     59    public method parameters {title args} { # do nothing }
    6260    public method scale {args}
    6361    public method select {option {args ""}}
     
    730728# USAGE: get ?-visible?
    731729# USAGE: get ?-image view?
     730# USAGE: get ?-image legend <dataobj> <layer>?
    732731#
    733732# Clients use this to query the list of objects being plotted, in
     
    800799        }
    801800        -image {
    802             if {[llength $args] != 2} {
    803                 error "wrong # args: should be \"get -image view\""
    804             }
    805             switch -- [lindex $args end] {
     801            if {[llength $args] < 2} {
     802                error "wrong # args: should be \"get -image view|legend\""
     803            }
     804            switch -- [lindex $args 1] {
     805                legend {
     806                    if {[llength $args] < 4} {
     807                        error "wrong # args: should be \"get -image legend <dataobj> <layer>\""
     808                    }
     809                    set dataobj [lindex $args 2]
     810                    set layer [lindex $args 3]
     811                    set colormap $layer
     812                    if {![$dataobj layer $layer shared]} {
     813                        set colormap $dataobj-$layer
     814                        set colormap "[regsub -all {::} ${colormap} {}]"
     815                    }
     816                    return $_image(legend-$colormap)
     817                }
    806818                view {
    807819                    return $_image(plot)
    808820                }
    809821                default {
    810                     error "bad image name \"[lindex $args end]\": should be view"
     822                    error "bad image name \"[lindex $args 1]\": should be view|legend"
    811823                }
    812824            }
    813825        }
    814826        default {
    815             error "bad option \"$op\": should be -objects or -image"
     827            error "bad option \"$op\": should be -objects, -hidden, -visible or -image"
    816828        }
    817829    }
Note: See TracChangeset for help on using the changeset viewer.