Changeset 4280
- Timestamp:
- Mar 26, 2014 5:15:26 PM (10 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/map.tcl
r4275 r4280 25 25 itcl::class Rappture::Map { 26 26 private variable _tree ""; # Tree of information about the map. 27 private variable _isGeocentric 0; 27 28 private variable _isValid 0; 28 29 private variable _nextLayer 0; # Counter used to generate unique 29 30 # layer names. 30 private common _layerTypes { 31 private common _layerTypes 32 private common _mapTypes 33 34 protected method Parse { xmlobj path } 35 36 constructor {xmlobj path} { 37 # defined below 38 } 39 destructor { 40 # defined below 41 } 42 public method isGeocentric {} 43 public method layers {} 44 public method layer { name } 45 public method hints { args } 46 public method isvalid {} { 47 return $_isValid; 48 } 49 public method type { name } { 50 set id [$_tree findchild root->"layers" $name] 51 if { $id < 0 } { 52 error "unknown layer \"$name\"" 53 } 54 return [$_tree get $id "type" ""] 55 } 56 public method style { name } { 57 set id [$_tree findchild root->"layers" $name] 58 if { $id < 0 } { 59 error "unknown layer \"$name\"" 60 } 61 return [$_tree get $id "style" ""] 62 } 63 } 64 65 # ---------------------------------------------------------------------- 66 # CONSTRUCTOR 67 # ---------------------------------------------------------------------- 68 itcl::body Rappture::Map::constructor {xmlobj path} { 69 if {![Rappture::library isvalid $xmlobj]} { 70 error "bad value \"$xmlobj\": should be LibraryObj" 71 } 72 array set _layerTypes { 31 73 "raster" 0 32 74 "elevation" 1 … … 36 78 "line" 5 37 79 } 38 private common_mapTypes {80 array set _mapTypes { 39 81 "geocentric" 0 40 82 "projected" 1 41 83 } 42 protected method Parse { xmlobj path } 43 44 constructor {xmlobj path} { 45 # defined below 46 } 47 destructor { 48 # defined below 49 } 50 public method layers {} 51 public method layer { name } 52 public method hints { args } 53 public method isvalid {} { 54 return $_isValid; 55 } 56 public method type { name } { 57 set id [$_tree findchild root->"layers" $name] 58 if { $id < 0 } { 59 error "unknown layer \"$name\"" 60 } 61 return [$_tree get $id "type" ""] 62 } 63 } 64 65 # ---------------------------------------------------------------------- 66 # CONSTRUCTOR 67 # ---------------------------------------------------------------------- 68 itcl::body Rappture::Map::constructor {xmlobj path} { 69 if {![Rappture::library isvalid $xmlobj]} { 70 error "bad value \"$xmlobj\": should be LibraryObj" 71 } 84 72 85 Parse $xmlobj $path 73 86 } … … 121 134 $_tree set $child "title" [$layers get $layer.label] 122 135 set type [$layers get $layer.type] 123 if { [info exists _layerTypes($type)] } {124 error "invalid layer type \"$type\" "136 if { ![info exists _layerTypes($type)] } { 137 error "invalid layer type \"$type\": should be one of [array names _layerTypes]" 125 138 } 126 139 $_tree set $child "type" $type … … 138 151 $_tree set root "projection" [$map get "projection"] 139 152 140 set type [$map get "type"]141 if { $ type == "" } {142 set type "projected"153 set mapType [$map get "type"] 154 if { $mapType == "" } { 155 set mapType "projected" 143 156 } 144 if { [info exists _mapTypes($type)] } { 157 puts stderr "Map type: $mapType" 158 if { ![info exists _mapTypes($mapType)] } { 145 159 error "unknown map type \"$mapType\": should be one of [array names _mapTypes]" 146 } 147 $_tree set root "type" $type 160 } elseif {$mapType == "geocentric"} { 161 set _isGeocentric 1 162 } 163 $_tree set root "type" $mapType 148 164 149 165 foreach {key path} { … … 190 206 } 191 207 208 # ---------------------------------------------------------------------- 209 # Returns if the map is geocentric (1) or projected (0) 210 # ---------------------------------------------------------------------- 211 itcl::body Rappture::Map::isGeocentric {} { 212 return $_isGeocentric 213 } -
trunk/gui/scripts/mapviewer.tcl
r4279 r4280 619 619 620 620 foreach layer [$dataobj layers] { 621 set type [$dataobj layer$layer]622 switch -- $ type {621 set layerType [$dataobj type $layer] 622 switch -- $layerType { 623 623 "elevation" { 624 624 set _haveTerrain 1 … … 871 871 SendCmd "map reset geocentric" 872 872 } else { 873 if { $_mapsettings(extents) == ""} { 874 SendCmd "map reset projected global-mercator" 873 if { $_mapsettings(extents) == "" } { 874 if { $_mapsettings(projection) == "" } { 875 SendCmd "map reset projected global-mercator" 876 } else { 877 SendCmd "map reset projected $_mapsettings(projection)" 878 } 875 879 } else { 876 SendCmd \ 877 "map reset projected $_mapsettings(projection) $_mapsettings(extents)" 880 SendCmd "map reset projected $_mapsettings(projection) $_mapsettings(extents)" 878 881 } 879 882 } … … 1567 1570 set _visibility($tag) 1 1568 1571 1569 return1570 1571 # The following code is a place holder for terrain styles.1572 1573 1572 set type [$dataobj type $layer] 1574 1573 set style [$dataobj style $layer] 1575 if { $dataobj != $_first } {1576 set settings(-wireframe) 11577 }1578 1574 switch -- $type { 1579 1575 "elevation" { … … 1589 1585 SendCmd "map terrain edges $settings(-edges) $tag" 1590 1586 set _settings(terrain-edges) $settings(-edges) 1591 SendCmd "map terrain color [Color2RGB $settings(-color)] $tag"1587 #SendCmd "map terrain color [Color2RGB $settings(-color)] $tag" 1592 1588 #SendCmd "map terrain colormode constant {} $tag" 1593 1589 SendCmd "map terrain lighting $settings(-lighting) $tag" 1594 1590 set _settings(terrain-lighting) $settings(-lighting) 1595 1591 SendCmd "map terrain linecolor [Color2RGB $settings(-edgecolor)] $tag" 1596 SendCmd "map terrain linewidth $settings(-linewidth) $tag"1592 #SendCmd "map terrain linewidth $settings(-linewidth) $tag" 1597 1593 SendCmd "map terrain wireframe $settings(-wireframe) $tag" 1598 1594 set _settings(terrain-wireframe) $settings(-wireframe)
Note: See TracChangeset
for help on using the changeset viewer.