Changeset 5027 for trunk/gui


Ignore:
Timestamp:
Feb 16, 2015, 2:25:28 AM (10 years ago)
Author:
ldelgass
Message:

Add viewpoints, attributions to maps

Location:
trunk/gui/scripts
Files:
2 added
2 edited

Legend:

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

    r5008 r5027  
    8686}
    8787
    88 #
    89 # hints --
    90 #
    9188itcl::body Rappture::Map::hints { args } {
    9289    switch -- [llength $args] {
     
    107104# Parse --
    108105#
    109 #       Parses the map description in the XML object.
     106#   Parses the map description in the XML object.
    110107#
    111108itcl::body Rappture::Map::Parse { xmlobj path } {
     
    129126        $_tree set $child "name" $layer
    130127        $_tree set $child "type" $layerType
    131         foreach key { label description } {
     128        foreach key { label description attribution } {
    132129            $_tree set $child $key [$layers get $layer.$key]
    133130        }
     
    218215    }
    219216    $_tree set root "label"       [$map get "about.label"]
     217    $_tree set root "attribution" [$map get "about.attribution"]
    220218    $_tree set root "style"       [$map get "style"]
    221219    $_tree set root "camera"      [$map get "camera"]
  • trunk/gui/scripts/mapviewer.tcl

    r5023 r5027  
    3939    itk_option define -plotbackground plotBackground Background ""
    4040
    41     private variable _layersFrame "";   # Name of layers frame widget
    42     private variable _mapsettings;      # Global map settings
     41    private variable _layersFrame "";     # Name of layers frame widget
     42    private variable _viewpointsFrame ""; # Name of viewpoints frame widget
     43    private variable _mapsettings;        # Global map settings
    4344
    4445    constructor { hostlist args } {
     
    8182    private method BuildMapTab {}
    8283    private method BuildTerrainTab {}
     84    private method BuildViewpointsTab {}
    8385    private method Connect {}
    8486    private method CurrentLayers {args}
     
    9496    private method GetImage { args }
    9597    private method GetNormalizedMouse { x y }
     98    private method GoToViewpoint { dataobj viewpoint }
    9699    private method InitSettings { args  }
    97100    private method MapIsGeocentric {}
     
    114117    private method ToggleWireframe {}
    115118    private method UpdateLayerControls {}
     119    private method UpdateViewpointControls {}
    116120    private method Zoom {option {x 0} {y 0}}
    117121
     
    312316
    313317    BuildLayerTab
     318    BuildViewpointsTab
    314319    BuildMapTab
    315320    BuildTerrainTab
     
    392397        bind $itk_component(view) <Double-1> \
    393398            [itcl::code $this camera go %x %y 0.4]
     399        bind $itk_component(view) <Shift-Double-1> \
     400            [itcl::code $this camera go %x %y 1.0]
    394401
    395402        # Pin placemark annotations
     
    641648# USAGE: delete ?<dataobj1> <dataobj2> ...?
    642649#
    643 #       Clients use this to delete a dataobj from the plot.  If no dataobjs
    644 #       are specified, then all dataobjs are deleted.  No data objects are
    645 #       deleted.  They are only removed from the display list.
    646 #
     650# Clients use this to delete a dataobj from the plot.  If no dataobjs
     651# are specified, then all dataobjs are deleted.  No data objects are
     652# deleted.  They are only removed from the display list.
    647653# ----------------------------------------------------------------------
    648654itcl::body Rappture::MapViewer::delete {args} {
     
    823829            set _viewpoints($viewpoint) [$dataobj viewpoint $viewpoint]
    824830            array set vp $_viewpoints($viewpoint)
    825             foreach key { x y z distance heading pitch srs verticalDatum } {
     831            foreach key { label description x y z distance heading pitch srs verticalDatum } {
    826832                if { [info exists vp($key)] } {
    827833                    puts stderr "$viewpoint $key $vp($key)"
     
    943949# isconnected --
    944950#
    945 #       Indicates if we are currently connected to the visualization server.
     951#   Indicates if we are currently connected to the visualization server.
    946952#
    947953itcl::body Rappture::MapViewer::isconnected {} {
     
    960966# Disconnect --
    961967#
    962 #       Clients use this method to disconnect from the current rendering
    963 #       server.
     968#   Clients use this method to disconnect from the current rendering
     969#   server.
    964970#
    965971itcl::body Rappture::MapViewer::Disconnect {} {
     
    12141220
    12151221    UpdateLayerControls
     1222    UpdateViewpointControls
    12161223    set _reset 0
    12171224    global readyForNextFrame
     
    13221329# EventuallyHandleMotionEvent --
    13231330#
    1324 #       This routine compresses (no button press) motion events.  It
    1325 #       delivers a server mouse command once every 100 milliseconds (if a
    1326 #       motion event is pending).
     1331#   This routine compresses (no button press) motion events.  It
     1332#   delivers a server mouse command once every 100 milliseconds (if a
     1333#   motion event is pending).
    13271334#
    13281335itcl::body Rappture::MapViewer::EventuallyHandleMotionEvent {x y} {
     
    15741581# AdjustSetting --
    15751582#
    1576 #       Changes/updates a specific setting in the widget.  There are
    1577 #       usually user-setable option.  Commands are sent to the render
    1578 #       server.
     1583#   Changes/updates a specific setting in the widget.  There are
     1584#   usually user-setable option.  Commands are sent to the render
     1585#   server.
    15791586#
    15801587itcl::body Rappture::MapViewer::AdjustSetting {what {value ""}} {
     
    16731680        ignore -font
    16741681    }
     1682    Rappture::Tooltip::for $inner.grid "Toggle graticule (grid) display <g>"
    16751683
    16761684    checkbutton $inner.wireframe \
     
    16791687        -command [itcl::code $this AdjustSetting terrain-wireframe] \
    16801688        -font "Arial 9" -anchor w
     1689    Rappture::Tooltip::for $inner.wireframe "Toggle wireframe rendering of terrain geometry <w>"
    16811690
    16821691    checkbutton $inner.lighting \
     
    16851694        -command [itcl::code $this AdjustSetting terrain-lighting] \
    16861695        -font "Arial 9" -anchor w
     1696    Rappture::Tooltip::for $inner.lighting "Toggle sky lighting of terrain <l>"
    16871697
    16881698    checkbutton $inner.edges \
     
    17251735    set inner [$itk_component(main) insert end \
    17261736        -title "Terrain Settings" \
    1727         -icon [Rappture::icon surface]]
     1737        -icon [Rappture::icon terrain]]
    17281738    $inner configure -borderwidth 4
    17291739
     
    17621772
    17631773itcl::body Rappture::MapViewer::BuildLayerTab {} {
    1764 
    17651774    set fg [option get $itk_component(hull) font Font]
    17661775    #set bfg [option get $itk_component(hull) boldFont Font]
     
    17741783        0,0 $f -fill both
    17751784    set _layersFrame $inner
     1785}
     1786
     1787itcl::body Rappture::MapViewer::BuildViewpointsTab {} {
     1788    set fg [option get $itk_component(hull) font Font]
     1789    #set bfg [option get $itk_component(hull) boldFont Font]
     1790
     1791    set inner [$itk_component(main) insert end \
     1792        -title "Places" \
     1793        -icon [Rappture::icon placemark16]]
     1794    $inner configure -borderwidth 4
     1795    set f [frame $inner.viewpoints]
     1796    blt::table $inner \
     1797        0,0 $f -fill both
     1798    set _viewpointsFrame $inner
    17761799}
    17771800
     
    19501973        }
    19511974    }
     1975}
     1976
     1977itcl::body Rappture::MapViewer::GoToViewpoint { dataobj viewpoint } {
     1978    if 0 {
     1979    array set view {
     1980        x 0
     1981        y 0
     1982        z 0
     1983        heading 0
     1984        pitch -89.999
     1985        distance 0
     1986        srs ""
     1987        verticalDatum ""
     1988    }
     1989    }
     1990    array set view [$dataobj viewpoint $viewpoint]
     1991    foreach key {x y z heading pitch distance srs verticalDatum} {
     1992        if { [info exists view($key)] } {
     1993            set _view($key) $view($key)
     1994        }
     1995    }
     1996    set duration 2.0
     1997    SendCmd [list camera set $_view(x) $_view(y) $_view(z) $_view(heading) $_view(pitch) $_view(distance) $duration $_view(srs) $_view(verticalDatum)]
    19521998}
    19531999
     
    22022248    }
    22032249    set f $inner.layers
     2250    set attrib [list]
    22042251    foreach dataobj [get -objects] {
    22052252        foreach layer [$dataobj layers] {
    22062253            array unset info
    22072254            array set info [$dataobj layer $layer]
    2208             checkbutton $f.${layer}-visible \
     2255            checkbutton $f.${layer}_visible \
    22092256                -text $info(label) \
    22102257                -font "Arial 9" -anchor w \
     
    22122259                -command [itcl::code $this \
    22132260                              SetLayerVisibility $dataobj $layer]
    2214             blt::table $f $row,0 $f.${layer}-visible -anchor w -pady 2 -cspan 2
    2215             Rappture::Tooltip::for $f.${layer}-visible $info(description)
     2261            blt::table $f $row,0 $f.${layer}_visible -anchor w -pady 2 -cspan 2
    22162262            incr row
    22172263            if { $info(type) != "elevation" } {
    2218                 label $f.${layer}-opacity_l -text "Opacity" -font "Arial 9"
    2219                 ::scale $f.${layer}-opacity -from 0 -to 100 \
     2264                label $f.${layer}_opacity_l -text "Opacity" -font "Arial 9"
     2265                ::scale $f.${layer}_opacity -from 0 -to 100 \
    22202266                    -orient horizontal -showvalue off \
    22212267                    -variable [itcl::scope _opacity($layer)] \
    22222268                    -command [itcl::code $this \
    22232269                                  SetLayerOpacity $dataobj $layer]
    2224                 blt::table $f $row,0 $f.${layer}-opacity_l -anchor w -pady 2
    2225                 blt::table $f $row,1 $f.${layer}-opacity -anchor w -pady 2
     2270                Rappture::Tooltip::for $f.${layer}_opacity "Set opacity of $info(label) layer"
     2271                blt::table $f $row,0 $f.${layer}_opacity_l -anchor w -pady 2
     2272                blt::table $f $row,1 $f.${layer}_opacity -anchor w -pady 2
    22262273                incr row
    22272274            }
     2275            set tooltip [list $info(description)]
     2276            if { [info exists info(attribution)] &&
     2277                 $info(attribution) != ""} {
     2278                lappend tooltip $info(attribution)
     2279            }
     2280            Rappture::Tooltip::for $f.${layer}_visible [join $tooltip \n]
     2281        }
     2282        set mapAttrib [$dataobj hints "attribution"]
     2283        if { $mapAttrib != "" } {
     2284            lappend attrib $mapAttrib
     2285        }
     2286    }
     2287    SendCmd "[list map attrib [join $attrib ,]]"
     2288    label $f.map_attrib -text [join $attrib \n] -font "Arial 9"
     2289    blt::table $f $row,0 $f.map_attrib -anchor sw -pady 2 -cspan 2
     2290    #incr row
     2291    if { $row > 0 } {
     2292        blt::table configure $f r* c* -resize none
     2293        blt::table configure $f r$row c1 -resize expand
     2294    }
     2295}
     2296
     2297itcl::body Rappture::MapViewer::UpdateViewpointControls {} {
     2298    set row 0
     2299    set inner $_viewpointsFrame
     2300    if { [winfo exists $inner.viewpoints] } {
     2301        foreach w [winfo children $inner.viewpoints] {
     2302            destroy $w
     2303        }
     2304    }
     2305    set f $inner.viewpoints
     2306    foreach dataobj [get -objects] {
     2307        foreach viewpoint [$dataobj viewpoints] {
     2308            array unset info
     2309            array set info [$dataobj viewpoint $viewpoint]
     2310            button $f.${viewpoint}_go \
     2311                -relief flat -compound left \
     2312                -image [Rappture::icon placemark16] \
     2313                -text $info(label) \
     2314                -font "Arial 9" -anchor w \
     2315                -command [itcl::code $this \
     2316                              GoToViewpoint $dataobj $viewpoint]
     2317            label $f.${viewpoint}_label \
     2318                -text $info(label) \
     2319                -font "Arial 9" -anchor w
     2320            blt::table $f $row,0 $f.${viewpoint}_go -anchor w -pady 2 -cspan 2
     2321            #blt::table $f $row,1 $f.${viewpoint}_label -anchor w -pady 2
     2322            Rappture::Tooltip::for $f.${viewpoint}_go $info(description)
     2323            incr row
    22282324        }
    22292325    }
Note: See TracChangeset for help on using the changeset viewer.