Changeset 4995


Ignore:
Timestamp:
Feb 11, 2015, 2:46:21 AM (10 years ago)
Author:
ldelgass
Message:

Add camera/viewpoint settings to map object

Location:
trunk/gui/scripts
Files:
2 edited

Legend:

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

    r4958 r4995  
    2626    private variable _tree "";         # Tree of information about the map.
    2727    private variable _isValid 0;
    28     private common _nextLayer 0;        # Counter used to generate unique
     28    private common _nextLayer 0;       # Counter used to generate unique
    2929                                       # layer names.
     30    private common _nextViewpoint 0;   # Counter used to generate unique
     31                                       # viewpoint names.
    3032    private common _layerTypes
    3133    private common _mapTypes
     
    5254    }
    5355
    54     public method isGeocentric {}
    55     public method layers {}
    56     public method layer { layerName }
     56    public method earthfile {}
    5757    public method hints { args }
     58    public method isGeocentric {}
    5859    public method isvalid {} {
    5960        return $_isValid;
    6061    }
     62    public method layer { layerName }
     63    public method layers {}
    6164    public method type { layerName }
    62     public method earthfile {}
     65    public method viewpoint { viewpointName }
     66    public method viewpoints {}
    6367}
    6468
     
    215219    $_tree set root "label"       [$map get "about.label"]
    216220    $_tree set root "style"       [$map get "style"]
    217  
     221    $_tree set root "camera"      [$map get "camera"]
     222    set parent [$_tree insert root -label "viewpoints"]
     223    set viewpoints [$map element -as object "viewpoints"]
     224    if { $viewpoints != "" } {
     225        foreach viewpoint [$viewpoints children -type viewpoint] {
     226            set name "viewpoint[incr _nextViewpoint]"
     227            set child [$_tree insert $parent -label $name]
     228            $_tree set $child "name" $viewpoint
     229            foreach key { label description x y z distance heading pitch srs verticalDatum } {
     230                set val [$viewpoints get $viewpoint.$key]
     231                $_tree set $child $key $val
     232            }
     233        }
     234    }
     235
    218236    set projection [$map get "projection"]
    219237    set extents    [$map get "extents"]
    220238    if { $projection  == "" } {
    221         if {$extents != ""} {
     239        if { $extents != "" } {
    222240            error "cannot specify extents without a projection"
    223241        }
     
    268286
    269287# ----------------------------------------------------------------------
     288# USAGE: viewpoints
     289#
     290# Returns a list of IDs for the viewpoints in the map
     291# ----------------------------------------------------------------------
     292itcl::body Rappture::Map::viewpoints {} {
     293    set list {}
     294    foreach node [$_tree children root->"viewpoints"] {
     295        lappend list [$_tree label $node]
     296    }
     297    return $list
     298}
     299
     300# ----------------------------------------------------------------------
    270301# USAGE: layer <layerName>
    271302#
     
    276307    if { $id < 0 } {
    277308        error "unknown layer \"$layerName\""
     309    }
     310    return [$_tree get $id]
     311}
     312
     313# ----------------------------------------------------------------------
     314# USAGE: viewopint <viewopintName>
     315#
     316# Returns an array of settings for the named viewpoint
     317# ----------------------------------------------------------------------
     318itcl::body Rappture::Map::viewpoint { viewopintName } {
     319    set id [$_tree findchild root->"viewpoints" $viewopintName]
     320    if { $id < 0 } {
     321        error "unknown viewpoint \"$viewpointName\""
    278322    }
    279323    return [$_tree get $id]
  • trunk/gui/scripts/mapviewer.tcl

    r4990 r4995  
    116116    private variable _layers;           # Contains the names of all the
    117117                                        # layer in the server.
     118    private variable _viewpoints;
    118119    private variable _click;            # info used for rotate operations
    119120    private variable _view;             # view params for 3D view
     
    772773            }
    773774        }
     775        if { [info exists hints(camera)] } {
     776            if { ![info exists _mapsettings(camera)] } {
     777                set _mapsettings(camera) $hints(camera)
     778            }
     779        }
    774780        foreach layer [$dataobj layers] {
    775781            if { [$dataobj type $layer] == "elevation" } {
     
    777783                break
    778784            }
     785        }
     786        foreach viewpoint [$dataobj viewpoints] {
     787            set _viewpoints($viewpoint) [$dataobj viewpoint $viewpoint]
     788            array set vp $_viewpoints($viewpoint)
     789            foreach key { x y z distance heading pitch srs verticalDatum } {
     790                puts stderr "$viewpoint $key $vp($key)"
     791            }
    779792        }
    780793    }
Note: See TracChangeset for help on using the changeset viewer.