Changeset 4266 for trunk


Ignore:
Timestamp:
Mar 25, 2014, 6:30:38 PM (11 years ago)
Author:
ldelgass
Message:

Update mapviewer with geoviewer changes

File:
1 edited

Legend:

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

    r4261 r4266  
    44#  COMPONENT: mapviewer - Map object viewer
    55#
    6 #  It connects to the MapVis server running on a rendering farm,
     6#  It connects to the GeoVis server running on a rendering farm,
    77#  transmits data, and displays the results.
    88# ======================================================================
     
    9595    private method BuildLayerTab {}
    9696    private method BuildDownloadPopup { widget command }
    97     private method BuildPolydataTab {}
    98     private method EventuallySetPolydataOpacity { args }
     97    private method BuildTerrainTab {}
    9998    private method EventuallyResize { w h }
    10099    private method EventuallyRotate { q }
     
    105104    private method SetOpacity { dataset }
    106105    private method SetOrientation { side }
    107     private method SetPolydataOpacity {}
    108106
    109107    private variable _arcball ""
     
    122120    private variable _reset 1;          # Indicates that server was reset and
    123121                                        # needs to be reinitialized.
    124     private variable _havePolydata 0
     122    private variable _haveTerrain 0
    125123
    126124    private variable _first ""     ;# This is the topmost dataset.
     
    134132    private variable _resizePending 0
    135133    private variable _rotatePending 0
    136     private variable _polydataOpacityPending 0
    137     private variable _updatePending 0;
    138134    private variable _rotateDelay 150
    139135    private variable _scaleDelay 100
     
    161157    $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list"
    162158
    163     # Update state event
    164     $_dispatcher register !update
    165     $_dispatcher dispatch $this !update "[itcl::code $this DoUpdate]; list"
    166 
    167159    # Rotate event
    168160    $_dispatcher register !rotate
    169161    $_dispatcher dispatch $this !rotate "[itcl::code $this DoRotate]; list"
    170162
    171     # Polydata opacity event
    172     $_dispatcher register !polydataOpacity
    173     $_dispatcher dispatch $this !polydataOpacity \
    174         "[itcl::code $this SetPolydataOpacity]; list"
    175163    #
    176164    # Populate parser with commands handle incoming requests
     
    197185
    198186    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
    206192    }]
    207193    itk_component add view {
     
    214200
    215201    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]
    219202    bind $c <KeyPress-Left>  [list %W xview scroll 10 units]
    220203    bind $c <KeyPress-Right> [list %W xview scroll -10 units]
     
    339322    bind $itk_component(view) <Motion> \
    340323        [itcl::code $this MouseMotion %x %y]
    341 
    342     #bind $itk_component(view) <ButtonRelease-3> \
    343     #    [itcl::code $this Pick %x %y]
    344324
    345325    # Bindings for panning via keyboard
     
    441421}
    442422
    443 itcl::body Rappture::MapViewer::SetPolydataOpacity {} {
    444     set _polydataOpacityPending 0
    445     foreach dataset [CurrentDatasets -visible $_first] {
    446         foreach { dataobj layer } [split $dataset -] break
    447         if { [$dataobj type $layer] == "polydata" } {
    448             SetOpacity $dataset
    449         }
    450     }
    451 }
    452 
    453 itcl::body Rappture::MapViewer::EventuallySetPolydataOpacity { args } {
    454     if { !$_polydataOpacityPending } {
    455         set _polydataOpacityPending 1
    456         $_dispatcher event -after $_scaleDelay !polydataOpacity
    457     }
    458 }
    459 
    460423# ----------------------------------------------------------------------
    461424# USAGE: add <dataobj> ?<settings>?
     
    617580            set type [$dataobj type $layer]
    618581            switch -- $type {
    619                 "polydata" {
    620                     set _havePolydata 1
     582                "elevation" {
     583                    set _haveTerrain 1
    621584                }
    622585            }
     
    646609        }
    647610    }
    648     if { $_havePolydata } {
    649         if { ![$itk_component(main) exists "Mesh Settings"] } {
    650             if { [catch { BuildPolydataTab } errs ]  != 0 } {
     611    if { $_haveTerrain } {
     612        if { ![$itk_component(main) exists "Terrain Settings"] } {
     613            if { [catch { BuildTerrainTab } errs ]  != 0 } {
    651614                puts stderr "errs=$errs"
    652615            }
     
    883846        #FixSettings ?
    884847
    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
    888850        }
    889851        StopBufferingCommands
     
    907869                    continue
    908870                }
    909                 # Is is a "image", "model", or "terrain" layer?
     871                # FIXME: wms, tms layers have additional options
    910872                switch -- $info(type) {
    911873                    "raster" {
     
    913875                    }
    914876                    default {
    915                         set type "model"
     877                        set type "$info(type)"
    916878                    }
    917879                }
    918                 SendCmd [list map layer add $type $info(url) $tag]
    919880                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]
    929891                set _datasets($tag) 1
    930892                SetObjectStyle $dataobj $layer
     
    12661228    }
    12671229    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"
    13151245        }
    13161246        default {
     
    13691299}
    13701300
    1371 itcl::body Rappture::MapViewer::BuildPolydataTab {} {
     1301itcl::body Rappture::MapViewer::BuildTerrainTab {} {
    13721302
    13731303    set fg [option get $itk_component(hull) font Font]
     
    13751305
    13761306    set inner [$itk_component(main) insert end \
    1377         -title "Mesh Settings" \
     1307        -title "Terrain Settings" \
    13781308        -icon [Rappture::icon mesh]]
    13791309    $inner configure -borderwidth 4
    13801310
    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 w
    1386 
    13871311    checkbutton $inner.wireframe \
    13881312        -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] \
    13911315        -font "Arial 9" -anchor w
    13921316
    13931317    checkbutton $inner.lighting \
    13941318        -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] \
    13971321        -font "Arial 9" -anchor w
    13981322
    13991323    checkbutton $inner.edges \
    14001324        -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] \
    14031327        -font "Arial 9" -anchor w
    14041328
     
    14271351    $itk_component(meshpalette) value "BCGYR"
    14281352    bind $inner.palette <<Value>> \
    1429         [itcl::code $this AdjustSetting polydata-palette]
    1430 
    1431     label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w
    1432     ::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)] \
    14341358        -width 10 \
    14351359        -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)
    14381362
    14391363    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 \
    14461369        5,0 $inner.palette_l -anchor w -pady 2 \
    14471370        5,1 $inner.palette   -fill x   -pady 2 
     
    15941517    }
    15951518    switch -- $type {
    1596         "polydata" {
     1519        "elevation" {
    15971520            array set settings {
    1598                 -color \#FFFFFF
    1599                 -edges 1
    16001521                -edgecolor black
     1522                -edges 0
     1523                -lighting 1
    16011524                -linewidth 1.0
    1602                 -opacity 1.0
     1525                -vertscale 1.0
    16031526                -wireframe 0
    1604                 -lighting 1
    1605                 -visible 1
    16061527            }
    16071528            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)
    16241539        }
    16251540    }
Note: See TracChangeset for help on using the changeset viewer.