- Timestamp:
- Mar 25, 2014, 6:30:38 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/mapviewer.tcl
r4261 r4266 4 4 # COMPONENT: mapviewer - Map object viewer 5 5 # 6 # It connects to the MapVis server running on a rendering farm,6 # It connects to the GeoVis server running on a rendering farm, 7 7 # transmits data, and displays the results. 8 8 # ====================================================================== … … 95 95 private method BuildLayerTab {} 96 96 private method BuildDownloadPopup { widget command } 97 private method BuildPolydataTab {} 98 private method EventuallySetPolydataOpacity { args } 97 private method BuildTerrainTab {} 99 98 private method EventuallyResize { w h } 100 99 private method EventuallyRotate { q } … … 105 104 private method SetOpacity { dataset } 106 105 private method SetOrientation { side } 107 private method SetPolydataOpacity {}108 106 109 107 private variable _arcball "" … … 122 120 private variable _reset 1; # Indicates that server was reset and 123 121 # needs to be reinitialized. 124 private variable _have Polydata0122 private variable _haveTerrain 0 125 123 126 124 private variable _first "" ;# This is the topmost dataset. … … 134 132 private variable _resizePending 0 135 133 private variable _rotatePending 0 136 private variable _polydataOpacityPending 0137 private variable _updatePending 0;138 134 private variable _rotateDelay 150 139 135 private variable _scaleDelay 100 … … 161 157 $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list" 162 158 163 # Update state event164 $_dispatcher register !update165 $_dispatcher dispatch $this !update "[itcl::code $this DoUpdate]; list"166 167 159 # Rotate event 168 160 $_dispatcher register !rotate 169 161 $_dispatcher dispatch $this !rotate "[itcl::code $this DoRotate]; list" 170 162 171 # Polydata opacity event172 $_dispatcher register !polydataOpacity173 $_dispatcher dispatch $this !polydataOpacity \174 "[itcl::code $this SetPolydataOpacity]; list"175 163 # 176 164 # Populate parser with commands handle incoming requests … … 197 185 198 186 array set _settings [subst { 199 legend 1 200 -globe 0 201 polydata-lighting 1 202 polydata-opacity 100 203 polydata-texture 1 204 polydata-visible 1 205 polydata-wireframe 0 187 legend 1 188 terrain-edges 0 189 terrain-lighting 1 190 terrain-vertscale 1.0 191 terrain-wireframe 0 206 192 }] 207 193 itk_component add view { … … 214 200 215 201 set c $itk_component(view) 216 bind $c <Configure> [itcl::code $this EventuallyResize %w %h]217 bind $c <4> [itcl::code $this Zoom in 0.25]218 bind $c <5> [itcl::code $this Zoom out 0.25]219 202 bind $c <KeyPress-Left> [list %W xview scroll 10 units] 220 203 bind $c <KeyPress-Right> [list %W xview scroll -10 units] … … 339 322 bind $itk_component(view) <Motion> \ 340 323 [itcl::code $this MouseMotion %x %y] 341 342 #bind $itk_component(view) <ButtonRelease-3> \343 # [itcl::code $this Pick %x %y]344 324 345 325 # Bindings for panning via keyboard … … 441 421 } 442 422 443 itcl::body Rappture::MapViewer::SetPolydataOpacity {} {444 set _polydataOpacityPending 0445 foreach dataset [CurrentDatasets -visible $_first] {446 foreach { dataobj layer } [split $dataset -] break447 if { [$dataobj type $layer] == "polydata" } {448 SetOpacity $dataset449 }450 }451 }452 453 itcl::body Rappture::MapViewer::EventuallySetPolydataOpacity { args } {454 if { !$_polydataOpacityPending } {455 set _polydataOpacityPending 1456 $_dispatcher event -after $_scaleDelay !polydataOpacity457 }458 }459 460 423 # ---------------------------------------------------------------------- 461 424 # USAGE: add <dataobj> ?<settings>? … … 617 580 set type [$dataobj type $layer] 618 581 switch -- $type { 619 " polydata" {620 set _have Polydata1582 "elevation" { 583 set _haveTerrain 1 621 584 } 622 585 } … … 646 609 } 647 610 } 648 if { $_have Polydata} {649 if { ![$itk_component(main) exists " MeshSettings"] } {650 if { [catch { Build PolydataTab } errs ] != 0 } {611 if { $_haveTerrain } { 612 if { ![$itk_component(main) exists "Terrain Settings"] } { 613 if { [catch { BuildTerrainTab } errs ] != 0 } { 651 614 puts stderr "errs=$errs" 652 615 } … … 883 846 #FixSettings ? 884 847 885 if { $_havePolydata } { 886 FixSettings polydata-edges polydata-lighting polydata-opacity \ 887 polydata-visible polydata-wireframe 848 if { $_haveTerrain } { 849 FixSettings terrain-edges terrain-lighting terrain-wireframe terrain-vertscale 888 850 } 889 851 StopBufferingCommands … … 907 869 continue 908 870 } 909 # Is is a "image", "model", or "terrain" layer? 871 # FIXME: wms, tms layers have additional options 910 872 switch -- $info(type) { 911 873 "raster" { … … 913 875 } 914 876 default { 915 set type " model"877 set type "$info(type)" 916 878 } 917 879 } 918 SendCmd [list map layer add $type $info(url) $tag]919 880 if { $_reportClientInfo } { 920 set list {} 921 lappend list "tool_id" [$dataobj hints toolId] 922 lappend list "tool_name" [$dataobj hints toolName] 923 lappend list "tool_version" [$dataobj hints toolRevision] 924 lappend list "tool_title" [$dataobj hints toolTitle] 925 lappend list "dataset_label" [$dataobj hints label] 926 lappend list "dataset_tag" $tag 927 SendCmd [list "clientinfo" $list] 928 } 881 set cinfo {} 882 lappend cinfo "tool_id" [$dataobj hints toolId] 883 lappend cinfo "tool_name" [$dataobj hints toolName] 884 lappend cinfo "tool_version" [$dataobj hints toolRevision] 885 lappend cinfo "tool_title" [$dataobj hints toolTitle] 886 lappend cinfo "dataset_label" [$dataobj hints label] 887 lappend cinfo "dataset_tag" $tag 888 SendCmd [list "clientinfo" $cinfo] 889 } 890 SendCmd [list map layer add $type $info(url) $tag] 929 891 set _datasets($tag) 1 930 892 SetObjectStyle $dataobj $layer … … 1266 1228 } 1267 1229 switch -- $what { 1268 "polydata-opacity" { 1269 foreach dataset [CurrentDatasets -visible $_first] { 1270 foreach { dataobj layer } [split $dataset -] break 1271 if { [$dataobj type $layer] == "polydata" } { 1272 SetOpacity $dataset 1273 } 1274 } 1275 } 1276 "polydata-wireframe" { 1277 set bool $_settings(polydata-wireframe) 1278 foreach dataset [CurrentDatasets -visible $_first] { 1279 foreach { dataobj layer } [split $dataset -] break 1280 set type [$dataobj type $layer] 1281 if { $type == "polydata" } { 1282 SendCmd "$type wireframe $bool $dataset" 1283 } 1284 } 1285 } 1286 "polydata-visible" { 1287 set bool $_settings(polydata-visible) 1288 foreach dataset [CurrentDatasets -visible $_first] { 1289 foreach { dataobj layer } [split $dataset -] break 1290 set type [$dataobj type $layer] 1291 if { $type == "polydata" } { 1292 SendCmd "$type visible $bool $dataset" 1293 } 1294 } 1295 } 1296 "polydata-lighting" { 1297 set bool $_settings(polydata-lighting) 1298 foreach dataset [CurrentDatasets -visible $_first] { 1299 foreach { dataobj layer } [split $dataset -] break 1300 set type [$dataobj type $layer] 1301 if { $type == "polydata" } { 1302 SendCmd "$type lighting $bool $dataset" 1303 } 1304 } 1305 } 1306 "polydata-edges" { 1307 set bool $_settings(polydata-edges) 1308 foreach dataset [CurrentDatasets -visible $_first] { 1309 foreach { dataobj layer } [split $dataset -] break 1310 set type [$dataobj type $layer] 1311 if { $type == "polydata" } { 1312 SendCmd "$type edges $bool $dataset" 1313 } 1314 } 1230 "terrain-edges" { 1231 set bool $_settings(terrain-edges) 1232 SendCmd "map terrain edges $bool" 1233 } 1234 "terrain-lighting" { 1235 set bool $_settings(terrain-lighting) 1236 SendCmd "map terrain lighting $bool" 1237 } 1238 "terrain-vertscale" { 1239 set val $_settings(terrain-vertscale) 1240 SendCmd "map terrain vertscale $val" 1241 } 1242 "terrain-wireframe" { 1243 set bool $_settings(terrain-wireframe) 1244 SendCmd "map terrain wireframe $bool" 1315 1245 } 1316 1246 default { … … 1369 1299 } 1370 1300 1371 itcl::body Rappture::MapViewer::Build PolydataTab {} {1301 itcl::body Rappture::MapViewer::BuildTerrainTab {} { 1372 1302 1373 1303 set fg [option get $itk_component(hull) font Font] … … 1375 1305 1376 1306 set inner [$itk_component(main) insert end \ 1377 -title " MeshSettings" \1307 -title "Terrain Settings" \ 1378 1308 -icon [Rappture::icon mesh]] 1379 1309 $inner configure -borderwidth 4 1380 1310 1381 checkbutton $inner.mesh \1382 -text "Show Mesh" \1383 -variable [itcl::scope _settings(polydata-visible)] \1384 -command [itcl::code $this AdjustSetting polydata-visible] \1385 -font "Arial 9" -anchor w1386 1387 1311 checkbutton $inner.wireframe \ 1388 1312 -text "Show Wireframe" \ 1389 -variable [itcl::scope _settings( polydata-wireframe)] \1390 -command [itcl::code $this AdjustSetting polydata-wireframe] \1313 -variable [itcl::scope _settings(terrain-wireframe)] \ 1314 -command [itcl::code $this AdjustSetting terrain-wireframe] \ 1391 1315 -font "Arial 9" -anchor w 1392 1316 1393 1317 checkbutton $inner.lighting \ 1394 1318 -text "Enable Lighting" \ 1395 -variable [itcl::scope _settings( polydata-lighting)] \1396 -command [itcl::code $this AdjustSetting polydata-lighting] \1319 -variable [itcl::scope _settings(terrain-lighting)] \ 1320 -command [itcl::code $this AdjustSetting terrain-lighting] \ 1397 1321 -font "Arial 9" -anchor w 1398 1322 1399 1323 checkbutton $inner.edges \ 1400 1324 -text "Show Edges" \ 1401 -variable [itcl::scope _settings( polydata-edges)] \1402 -command [itcl::code $this AdjustSetting polydata-edges] \1325 -variable [itcl::scope _settings(terrain-edges)] \ 1326 -command [itcl::code $this AdjustSetting terrain-edges] \ 1403 1327 -font "Arial 9" -anchor w 1404 1328 … … 1427 1351 $itk_component(meshpalette) value "BCGYR" 1428 1352 bind $inner.palette <<Value>> \ 1429 [itcl::code $this AdjustSetting polydata-palette]1430 1431 label $inner. opacity_l -text "Opacity" -font "Arial 9" -anchor w1432 ::scale $inner. opacity-from 0 -to 100 -orient horizontal \1433 -variable [itcl::scope _settings( polydata-opacity)] \1353 [itcl::code $this AdjustSetting terrain-palette] 1354 1355 label $inner.vscale_l -text "Vertical Scale" -font "Arial 9" -anchor w 1356 ::scale $inner.vscale -from 0 -to 100 -orient horizontal \ 1357 -variable [itcl::scope _settings(terrain-vertscale)] \ 1434 1358 -width 10 \ 1435 1359 -showvalue off \ 1436 -command [itcl::code $this AdjustSetting polydata-opacity]1437 $inner. opacity set $_settings(polydata-opacity)1360 -command [itcl::code $this AdjustSetting terrain-vertscale] 1361 $inner.vscale set $_settings(terrain-vertscale) 1438 1362 1439 1363 blt::table $inner \ 1440 0,0 $inner.mesh -cspan 2 -anchor w -pady 2 \ 1441 1,0 $inner.wireframe -cspan 2 -anchor w -pady 2 \ 1442 2,0 $inner.lighting -cspan 2 -anchor w -pady 2 \ 1443 3,0 $inner.edges -cspan 2 -anchor w -pady 2 \ 1444 4,0 $inner.opacity_l -anchor w -pady 2 \ 1445 4,1 $inner.opacity -fill x -pady 2 \ 1364 0,0 $inner.wireframe -cspan 2 -anchor w -pady 2 \ 1365 1,0 $inner.lighting -cspan 2 -anchor w -pady 2 \ 1366 2,0 $inner.edges -cspan 2 -anchor w -pady 2 \ 1367 4,0 $inner.vscale_l -anchor w -pady 2 \ 1368 4,1 $inner.vscale -fill x -pady 2 \ 1446 1369 5,0 $inner.palette_l -anchor w -pady 2 \ 1447 1370 5,1 $inner.palette -fill x -pady 2 … … 1594 1517 } 1595 1518 switch -- $type { 1596 " polydata" {1519 "elevation" { 1597 1520 array set settings { 1598 -color \#FFFFFF1599 -edges 11600 1521 -edgecolor black 1522 -edges 0 1523 -lighting 1 1601 1524 -linewidth 1.0 1602 - opacity1.01525 -vertscale 1.0 1603 1526 -wireframe 0 1604 -lighting 11605 -visible 11606 1527 } 1607 1528 array set settings $style 1608 SendCmd "polydata add $tag" 1609 SendCmd "polydata visible $settings(-visible) $tag" 1610 set _settings(polydata-visible) $settings(-visible) 1611 SendCmd "polydata edges $settings(-edges) $tag" 1612 set _settings(polydata-edges) $settings(-edges) 1613 SendCmd "polydata color [Color2RGB $settings(-color)] $tag" 1614 #SendCmd "polydata colormode constant {} $tag" 1615 SendCmd "polydata lighting $settings(-lighting) $tag" 1616 set _settings(polydata-lighting) $settings(-lighting) 1617 SendCmd "polydata linecolor [Color2RGB $settings(-edgecolor)] $tag" 1618 SendCmd "polydata linewidth $settings(-linewidth) $tag" 1619 SendCmd "polydata opacity $settings(-opacity) $tag" 1620 set _settings(polydata-opacity) [expr 100.0 * $settings(-opacity)] 1621 SendCmd "polydata wireframe $settings(-wireframe) $tag" 1622 set _settings(polydata-wireframe) $settings(-wireframe) 1623 set havePolyData 1 1529 SendCmd "map terrain edges $settings(-edges) $tag" 1530 set _settings(terrain-edges) $settings(-edges) 1531 SendCmd "map terrain color [Color2RGB $settings(-color)] $tag" 1532 #SendCmd "map terrain colormode constant {} $tag" 1533 SendCmd "map terrain lighting $settings(-lighting) $tag" 1534 set _settings(terrain-lighting) $settings(-lighting) 1535 SendCmd "map terrain linecolor [Color2RGB $settings(-edgecolor)] $tag" 1536 SendCmd "map terrain linewidth $settings(-linewidth) $tag" 1537 SendCmd "map terrain wireframe $settings(-wireframe) $tag" 1538 set _settings(terrain-wireframe) $settings(-wireframe) 1624 1539 } 1625 1540 }
Note: See TracChangeset
for help on using the changeset viewer.