Changeset 5008
- Timestamp:
- Feb 12, 2015, 3:08:08 AM (10 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/map.tcl
r4995 r5008 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 3 3 # ---------------------------------------------------------------------- … … 19 19 package require BLT 20 20 21 namespace eval Rappture { 22 # forward declaration 21 namespace eval Rappture { 22 # forward declaration 23 23 } 24 24 … … 47 47 protected method Parse { xmlobj path } 48 48 49 constructor {xmlobj path} { 50 # defined below 51 } 52 destructor { 53 # defined below 49 constructor {xmlobj path} { 50 # defined below 51 } 52 destructor { 53 # defined below 54 54 } 55 55 … … 123 123 set name "layer[incr _nextLayer]" 124 124 set child [$_tree insert $parent -label $name] 125 set layerType [$layers get $layer.type] 125 set layerType [$layers get $layer.type] 126 126 if { ![info exists _layerTypes($layerType)] } { 127 127 error "invalid layer type \"$layerType\": should be one of [array names _layerTypes]" … … 130 130 $_tree set $child "type" $layerType 131 131 foreach key { label description } { 132 $_tree set $child $key [$layers get $layer.$key] 132 $_tree set $child $key [$layers get $layer.$key] 133 133 } 134 134 # Common settings (for all layer types) with defaults … … 156 156 $_tree set $child "gdal.$key" $value 157 157 } 158 set file [$layers get $layer.gdal.file] 158 set file [$layers get $layer.gdal.file] 159 159 if { $file != "" } { 160 160 # FIXME: Add test for valid file path … … 169 169 $_tree set $child "ogr.$key" $value 170 170 } 171 set file [$layers get $layer.ogr.file] 171 set file [$layers get $layer.ogr.file] 172 172 if { $file != "" } { 173 173 # FIXME: Add test for valid file path … … 251 251 if { $mapType == "" } { 252 252 set mapType "projected"; # Default type is "projected". 253 } 253 } 254 254 if { ![info exists _mapTypes($mapType)] } { 255 255 error "unknown map type \"$mapType\": should be one of [array names _mapTypes]" … … 280 280 set list {} 281 281 foreach node [$_tree children root->"layers"] { 282 lappend list [$_tree label $node] 282 lappend list [$_tree label $node] 283 283 } 284 284 return $list … … 293 293 set list {} 294 294 foreach node [$_tree children root->"viewpoints"] { 295 lappend list [$_tree label $node] 295 lappend list [$_tree label $node] 296 296 } 297 297 return $list … … 340 340 # USAGE: isGeocentric 341 341 # 342 # Returns if the map is geocentric (1) or projected (0) 343 # ---------------------------------------------------------------------- 344 itcl::body Rappture::Map::isGeocentric {} { 342 # Returns if the map is geocentric (1) or projected (0) 343 # ---------------------------------------------------------------------- 344 itcl::body Rappture::Map::isGeocentric {} { 345 345 return [expr {[hints "type"] eq "geocentric"}] 346 } 347 348 itcl::body Rappture::Map::earthfile {} { 346 } 347 348 itcl::body Rappture::Map::earthfile {} { 349 349 array set info [$_tree get root] 350 350 append out "<map" … … 408 408 } 409 409 append out "</map>\n" 410 } 410 } -
trunk/gui/scripts/mapviewer.tcl
r4996 r5008 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: mapviewer - Map object viewer … … 39 39 itk_option define -plotbackground plotBackground Background "" 40 40 41 private variable _layersFrame ""; 41 private variable _layersFrame ""; # Name of layers frame widget 42 42 private variable _mapsettings; # Global map settings 43 43 … … 60 60 public method get {args} 61 61 public method isconnected {} 62 public method parameters {title args} { 63 # do nothing 62 public method parameters {title args} { 63 # do nothing 64 64 } 65 65 public method scale {args} … … 77 77 private method AdjustSetting {what {value ""}} 78 78 private method BuildCameraTab {} 79 private method BuildDownloadPopup { widget command } 79 private method BuildDownloadPopup { widget command } 80 80 private method BuildLayerTab {} 81 81 private method BuildMapTab {} … … 90 90 private method EventuallyHandleMotionEvent { x y } 91 91 private method EventuallyPan { dx dy } 92 private method EventuallyResize { w h } 93 private method EventuallyRotate { dx dy } 94 private method GetImage { args } 92 private method EventuallyResize { w h } 93 private method EventuallyRotate { dx dy } 94 private method GetImage { args } 95 95 private method GetNormalizedMouse { x y } 96 96 private method InitSettings { args } … … 111 111 private method Zoom {option {x 0} {y 0}} 112 112 113 private variable _dlist ""; 113 private variable _dlist ""; # list of data objects 114 114 private variable _obj2datasets 115 private variable _obj2ovride; 116 private variable _layers; # Contains the names of all the117 115 private variable _obj2ovride; # maps dataobj => style override 116 private variable _layers; # Contains the names of all the 117 # layer in the server. 118 118 private variable _viewpoints; 119 119 private variable _click; # info used for rotate operations … … 159 159 160 160 if { [catch { 161 161 162 162 # Rebuild event 163 163 $_dispatcher register !rebuild … … 267 267 268 268 set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)] 269 set _map(cwidth) -1 270 set _map(cheight) -1 269 set _map(cwidth) -1 270 set _map(cheight) -1 271 271 set _map(zoom) 1.0 272 272 set _map(original) "" … … 323 323 set _image(legend) [image create photo] 324 324 itk_component add legend { 325 canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 325 canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 326 326 } { 327 327 usual … … 330 330 } 331 331 332 # Hack around the Tk panewindow. The problem is that the requested 332 # Hack around the Tk panewindow. The problem is that the requested 333 333 # size of the 3d view isn't set until an image is retrieved from 334 334 # the server. So the panewindow uses the tiny size. … … 336 336 pack forget $itk_component(view) 337 337 blt::table $itk_component(plotarea) \ 338 0,0 $itk_component(view) -fill both -reqwidth $w 338 0,0 $itk_component(view) -fill both -reqwidth $w 339 339 blt::table configure $itk_component(plotarea) c1 -resize none 340 340 … … 484 484 Connect 485 485 } errs] != 0 } { 486 486 puts stderr errs=$errs 487 487 } 488 488 } … … 665 665 continue 666 666 } 667 if {[info exists _obj2ovride($dataobj-raise)] && 667 if {[info exists _obj2ovride($dataobj-raise)] && 668 668 $_obj2ovride($dataobj-raise)} { 669 669 set dlist [linsert $dlist 0 $dataobj] … … 693 693 } 694 694 return $dlist 695 } 695 } 696 696 -image { 697 697 if {[llength $args] != 2} { … … 741 741 continue 742 742 } 743 array unset hints 743 array unset hints 744 744 array set hints [$dataobj hints] 745 745 if { ![info exists _mapsettings(label)] } { … … 786 786 set _haveTerrain 1 787 787 break 788 } 788 } 789 789 } 790 790 foreach viewpoint [$dataobj viewpoints] { … … 941 941 # disconnected -- no more data sitting on server 942 942 array unset _layers 943 array unset _layersFrame 943 array unset _layersFrame 944 944 global readyForNextFrame 945 945 set readyForNextFrame 1 … … 1085 1085 $itk_component(time) configure -state disabled 1086 1086 set proj $_mapsettings(projection) 1087 if { $proj == "" } { 1087 if { $proj == "" } { 1088 1088 SendCmd "map reset projected global-mercator" 1089 1089 } elseif { ![info exists _mapsettings(extents)] || $_mapsettings(extents) == "" } { … … 1094 1094 set $key $_mapsettings($key) 1095 1095 } 1096 SendCmd [list map reset "projected" $proj $x1 $y1 $x2 $y2] 1096 SendCmd [list map reset "projected" $proj $x1 $y1 $x2 $y2] 1097 1097 } 1098 1098 } … … 1102 1102 1103 1103 # Most terrain settings are global to the map and apply even 1104 # if there is no elevation layer. The exception is the 1104 # if there is no elevation layer. The exception is the 1105 1105 # vertical scale, which only applies if there is an elevation 1106 1106 # layer … … 1124 1124 set _obj2datasets($dataobj) "" 1125 1125 foreach layer [$dataobj layers] { 1126 1127 1126 array unset info 1127 array set info [$dataobj layer $layer] 1128 1128 if { ![info exists _layers($layer)] } { 1129 1129 if { $_reportClientInfo } { … … 1203 1203 itcl::body Rappture::MapViewer::CurrentLayers {args} { 1204 1204 set flag [lindex $args 0] 1205 switch -- $flag { 1205 switch -- $flag { 1206 1206 "-all" { 1207 1207 if { [llength $args] > 1 } { … … 1222 1222 set dlist [get -visible] 1223 1223 } 1224 } 1224 } 1225 1225 default { 1226 1226 set dlist $args … … 1611 1611 -variable [itcl::scope _settings(coords-visible)] \ 1612 1612 -command [itcl::code $this AdjustSetting coords-visible] \ 1613 -font "Arial 9" -anchor w 1613 -font "Arial 9" -anchor w 1614 1614 1615 1615 itk_component add grid { … … 1618 1618 -variable [itcl::scope _settings(grid)] \ 1619 1619 -command [itcl::code $this AdjustSetting grid] \ 1620 -font "Arial 9" -anchor w 1620 -font "Arial 9" -anchor w 1621 1621 } { 1622 1622 ignore -font 1623 1623 } 1624 1624 … … 1627 1627 -variable [itcl::scope _settings(terrain-wireframe)] \ 1628 1628 -command [itcl::code $this AdjustSetting terrain-wireframe] \ 1629 -font "Arial 9" -anchor w 1629 -font "Arial 9" -anchor w 1630 1630 1631 1631 checkbutton $inner.lighting \ … … 1704 1704 0,1 $inner.vscale -fill x -pady 2 1705 1705 # 1,0 $inner.palette_l -anchor w -pady 2 \ 1706 # 1,1 $inner.palette -fill x -pady 2 1706 # 1,1 $inner.palette -fill x -pady 2 1707 1707 1708 1708 blt::table configure $inner r* c* -resize none … … 1721 1721 set f [frame $inner.layers] 1722 1722 blt::table $inner \ 1723 0,0 $f -fill both 1723 0,0 $f -fill both 1724 1724 set _layersFrame $inner 1725 1725 } … … 1802 1802 1803 1803 # 1804 # camera -- 1804 # camera -- 1805 1805 # 1806 1806 # USAGE: camera get … … 1811 1811 # 1812 1812 itcl::body Rappture::MapViewer::camera {option args} { 1813 switch -- $option { 1813 switch -- $option { 1814 1814 "get" { 1815 1815 # We got the camera settings from the server … … 1874 1874 1875 1875 itcl::body Rappture::MapViewer::GetImage { args } { 1876 if { [image width $_image(download)] > 0 && 1876 if { [image width $_image(download)] > 0 && 1877 1877 [image height $_image(download)] > 0 } { 1878 1878 set bytes [$_image(download) data -format "jpeg -quality 100"] … … 1887 1887 -title "[Rappture::filexfer::label downloadWord] as..." 1888 1888 set inner [$popup component inner] 1889 label $inner.summary -text "" -anchor w 1889 label $inner.summary -text "" -anchor w 1890 1890 1891 1891 radiobutton $inner.image_button -text "Image File" \ 1892 1892 -variable [itcl::scope _downloadPopup(format)] \ 1893 -value image 1893 -value image 1894 1894 Rappture::Tooltip::for $inner.image_button \ 1895 1895 "Save as digital image." … … 1911 1911 2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \ 1912 1912 4,1 $inner.cancel -width .9i -fill y \ 1913 4,0 $inner.ok -padx 2 -width .9i -fill y 1913 4,0 $inner.ok -padx 2 -width .9i -fill y 1914 1914 blt::table configure $inner r3 -height 4 1915 1915 blt::table configure $inner r4 -pady 4 … … 1990 1990 $layer] 1991 1991 } 1992 } 1992 } 1993 1993 } 1994 1994 SendCmd "map layer opacity $settings(-opacity) $layer" … … 2099 2099 } 2100 2100 2101 itcl::body Rappture::MapViewer::UpdateLayerControls {} { 2101 itcl::body Rappture::MapViewer::UpdateLayerControls {} { 2102 2102 set row 0 2103 2103 set inner $_layersFrame … … 2110 2110 foreach dataobj [get -objects] { 2111 2111 foreach layer [$dataobj layers] { 2112 2113 2112 array unset info 2113 array set info [$dataobj layer $layer] 2114 2114 checkbutton $f.${layer}-visible \ 2115 2115 -text $info(label) \ … … 2132 2132 incr row 2133 2133 } 2134 2134 } 2135 2135 } 2136 2136 if { $row > 0 } { … … 2143 2143 # Generate an OSG Earth file to send to server. This is inteneded 2144 2144 # as a stopgap and testing tool until the protocol is fleshed out. 2145 # 2145 # 2146 2146 # Note that the lighting settings are required to be "hard-coded" 2147 2147 # as below for the runtime control to work. Don't make those user … … 2151 2151 # the parser in OSG Earth accepts all of Tcl's forms of boolean vals. 2152 2152 # 2153 itcl::body Rappture::MapViewer::EarthFile {} { 2153 itcl::body Rappture::MapViewer::EarthFile {} { 2154 2154 append out "<map" 2155 2155 append out " name=\"$_mapsettings(label)\"" … … 2221 2221 append out "</map>\n" 2222 2222 return $out 2223 } 2223 }
Note: See TracChangeset
for help on using the changeset viewer.