Changeset 1545 for trunk


Ignore:
Timestamp:
Jul 7, 2009, 3:51:50 PM (15 years ago)
Author:
gah
Message:

add transparency to heightmap

Location:
trunk/gui/scripts
Files:
6 edited

Legend:

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

    r1526 r1545  
    763763            set _comp2dims($cname) "3D"
    764764            set data [$_field get -decode yes $cname.opendx]
    765             set data [Rappture::encoding::decode -as zb64 $data]
    766 
    767765            set data "<ODX>$data"
    768766            set data [Rappture::encoding::encode -as zb64 $data]
  • trunk/gui/scripts/flowvisviewer.tcl

    r1543 r1545  
    257257    }]
    258258
     259    itk_component add 3dview {
     260        label $itk_component(plotarea).vol -image $_image(plot) \
     261            -highlightthickness 0 -borderwidth 0
     262    } {
     263        usual
     264        ignore -highlightthickness -borderwidth  -background
     265    }
    259266    set f [$itk_component(main) component controls]
    260267    itk_component add reset {
  • trunk/gui/scripts/heightmapviewer.tcl

    r1543 r1545  
    11
    22# ----------------------------------------------------------------------
    3 #  COMPONENT: heightmapviewer - 3D surface rendering
     3#  Component: heightmapviewer - 3D surface rendering
    44#
    55#  This widget performs surface rendering on 3D scalar/vector datasets.
     
    7070    private method BuildCameraTab {}
    7171    private method PanCamera {}
    72 
     72    protected method CurrentSurfaces {{what -all}}
    7373    protected method Rebuild {}
    7474    protected method Zoom {option}
     
    9494    private variable _serverObjs   ;# contains all the dataobj-component
    9595                                   ;# to heightmaps in the server
     96    private variable _location ""
    9697    private variable _first ""
    9798    private variable _width 0
     
    142143        pan-y   0
    143144    }
    144 
     145    foreach val {xmin xmax ymin ymax zmin zmax vmin vmax} {
     146        set _limits($val) ""
     147    }
    145148    array set _settings [subst {
    146149        $this-pan-x             $_view(pan-x)
     
    159162    }]
    160163
     164    itk_component add 3dview {
     165        canvas $itk_component(plotarea).vol \
     166            -highlightthickness 0 -borderwidth 0
     167    } {
     168        usual
     169        ignore -highlightthickness -borderwidth  -background
     170    }
     171    $_image(plot) configure -data ""
     172    $itk_component(3dview) create image 0 0 -anchor nw -image $_image(plot)
    161173    set f [$itk_component(main) component controls]
    162174    itk_component add zoom {
     
    175187    }
    176188    pack $itk_component(reset) -side top -padx 1 -pady { 4 0 }
    177     Rappture::Tooltip::for $itk_component(reset) "Reset the view to the default zoom level"
     189    Rappture::Tooltip::for $itk_component(reset) \
     190        "Reset the view to the default zoom level"
    178191
    179192    itk_component add zoomin {
     
    216229    BuildCameraTab
    217230
    218     # Legend
    219     set _image(legend) [image create photo]
    220     itk_component add legend {
    221         canvas $itk_component(plotarea).legend -width 30 -highlightthickness 0
    222     } {
    223         usual
    224         ignore -highlightthickness
    225         rename -background -plotbackground plotBackground Background
    226     }
    227231    set w [expr [winfo reqwidth $itk_component(hull)] - 80]
    228232    pack forget $itk_component(3dview)
    229233    pack $itk_component(3dview) -side left -fill both -expand yes
    230     pack $itk_component(legend) -side left -fill y
    231 
    232     bind $itk_component(legend) <Configure> \
    233         [list $_dispatcher event -idle !legend]
     234
    234235
    235236    # Bindings for rotation via mouse
     
    331332        set _obj2ovride($dataobj-width) $params(-width)
    332333        set _obj2ovride($dataobj-raise) $params(-raise)
     334        set _obj2ovride($dataobj-brightness) $params(-brightness)
    333335        $_dispatcher event -idle !rebuild
    334336    }
     
    429431# ----------------------------------------------------------------------
    430432itcl::body Rappture::HeightmapViewer::scale { args } {
     433    if 0 {
    431434    foreach val {xmin xmax ymin ymax zmin zmax vmin vmax} {
    432435        set _limits($val) ""
     436    }
    433437    }
    434438    foreach obj $args {
     
    586590    if { [IsConnected] } {
    587591        set bytes [ReceiveBytes $size]
     592        if { ![info exists _image(legend)] } {
     593            set _image(legend) [image create photo]
     594        }
    588595        ReceiveEcho <<line "<read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
    589         if 1 {
    590596        set src [image create photo -data $bytes]
    591597        blt::winop image rotate $src $_image(legend) 90
    592598        set dst $_image(legend)
    593         } else {
    594         $_image(legend) configure -data $bytes
    595         }
    596         set c $itk_component(legend)
     599
     600        set c $itk_component(3dview)
    597601        set w [winfo width $c]
    598602        set h [winfo height $c]
    599         set lineht [expr [font metrics $itk_option(-font) -linespace] + 4]
    600         if {"" == [$c find withtag transfunc]} {
    601             $c create image 0 [expr $lineht] -anchor ne \
    602                  -image $_image(legend) -tags transfunc
    603             $c create text 10 [expr {$h-8}] -anchor se \
    604                 -fill $itk_option(-plotforeground) -tags vmin \
    605                 -font "Arial 8 bold"
    606             $c create text [expr {$w-10}] [expr {$h-8}] -anchor ne \
    607                  -fill $itk_option(-plotforeground) -tags vmax \
    608                 -font "Arial 8 bold"
    609         }
    610         $c coords transfunc [expr $w - 5] [expr $lineht]
    611         $c itemconfigure vmin -text $vmin
    612         $c itemconfigure vmax -text $vmax
    613         $c coords vmax [expr $w - 5] 2
    614         $c coords vmin [expr $w - 5] [expr $h - 2]
     603        set lineht [font metrics $itk_option(-font) -linespace]
     604
     605        if { $_settings($this-legend) } {
     606            if { [$c find withtag "legend"] == "" } {
     607                $c create image [expr {$w-2}] [expr {$lineht+2}] -anchor ne \
     608                    -image $_image(legend) -tags "transfunc legend"
     609                $c create text [expr {$w-2}] 2 -anchor ne \
     610                    -fill $itk_option(-plotforeground) -tags "vmax legend" \
     611                    -font "Arial 8 bold"
     612                $c create text [expr {$w-2}] [expr {$h-2}] -anchor se \
     613                    -fill $itk_option(-plotforeground) -tags "vmin legend" \
     614                    -font "Arial 8 bold"
     615            }
     616            # Reset the item coordinates according the current size of the plot.
     617            $c coords transfunc [expr {$w-2}] [expr {$lineht+2}]
     618            $c itemconfigure vmin -text $vmin
     619            $c itemconfigure vmax -text $vmax
     620            $c coords vmin [expr {$w-2}] [expr {$h-2}]
     621            $c coords vmax [expr {$w-2}] 2
     622        }
    615623    }
    616624}
     
    647655        foreach comp [$dataobj components] {
    648656            # Tell the engine to expect some data
    649             set data [$dataobj blob $comp]
    650             set nbytes [string length $data]
    651             append _outbuf "heightmap data follows $nbytes $dataobj-$comp\n"
    652             append _outbuf $data
    653 
    654657            set tag $dataobj-$comp
    655             set _serverObjs($tag) $tag
    656 
    657             #
    658             # Determine the transfer function needed for this surface
    659             # and make sure that it's defined on the server.
    660             #
    661             foreach {sname cmap wmap} [GetTransfuncData $dataobj $comp] break
    662             SendCmd [list "transfunc" "define" $sname $cmap $wmap]
    663             set _obj2style($tag) $sname
     658            if { ![info exists _serverObjs($tag)] } {
     659                set data [$dataobj blob $comp]
     660                set nbytes [string length $data]
     661                append _outbuf "heightmap data follows $nbytes $dataobj-$comp\n"
     662                append _outbuf $data
     663               
     664                set _serverObjs($tag) $tag
     665               
     666                # Determine the transfer function needed for this surface
     667                # and make sure that it's defined on the server.
     668                foreach {sname cmap wmap} [GetTransfuncData $dataobj $comp] break
     669                SendCmd [list "transfunc" "define" $sname $cmap $wmap]
     670                set _obj2style($tag) $sname
     671            }
    664672        }
    665673    }
     
    674682        # This is where the initial camera position is set.
    675683        set location [$_first hints camera]
    676         if { $location != "" } {
     684        if { $_location == "" && $location != "" } {
    677685            array set _view $location
     686            set _location $location
    678687        }
    679688    }
    680689    SendCmd "heightmap data visible 0"
    681     set heightmaps [array names _serverObjs $_first-*]
     690    set heightmaps [CurrentSurfaces]
    682691    if { $heightmaps != ""  && $_settings($this-surface) } {
    683692        SendCmd "heightmap data visible 1 $heightmaps"
     693    }
     694    set heightmaps [CurrentSurfaces -raise]
     695    if { $heightmaps != "" } {
     696        SendCmd "heightmap opacity 0.25"
     697        SendCmd "heightmap opacity 0.95 $heightmaps"
     698    } else {
     699        SendCmd "heightmap opacity 0.85"
    684700    }
    685701    foreach key $heightmaps {
     
    923939    switch -- $what {
    924940        "legend" {
    925             if { $_settings($this-legend) } {
    926                 pack $itk_component(legend) -side left -fill y
    927             } else {
    928                 pack forget $itk_component(legend)
    929             }
    930             set lineht [expr [font metrics $itk_option(-font) -linespace] + 4]
    931             set w [expr {[winfo height $itk_component(legend)] - 2*$lineht}]
    932             set h [expr {[winfo width $itk_component(legend)] - 16}]
     941            if { !$_settings($this-legend) } {
     942                $itk_component(3dview) delete "legend"
     943            }
     944            set lineht [font metrics $itk_option(-font) -linespace]
     945            set w [winfo height $itk_component(3dview)]
     946            set h [winfo width $itk_component(3dview)]
     947            set w [expr {$w - 2*$lineht - 4}]
     948            set h 12
    933949            set tag ""
    934950            if {"" != $_first} {
     
    939955                SendCmd "heightmap legend $tag $w $h"
    940956            } else {
    941                 $itk_component(legend) delete all
     957                #$itk_component(legend) delete all
    942958            }
    943959        }
     
    11981214    SendCmd "screen $_width $_height"
    11991215    set _resizePending 0
     1216    $_dispatcher event -idle !legend
    12001217}
    12011218
     
    12081225    }
    12091226}
     1227
     1228# ----------------------------------------------------------------------
     1229# USAGE: CurrentVolumes ?-cutplanes?
     1230#
     1231# Returns a list of volume server IDs for the current volume being
     1232# displayed.  This is normally a single ID, but it might be a list
     1233# of IDs if the current data object has multiple components.
     1234# ----------------------------------------------------------------------
     1235itcl::body Rappture::HeightmapViewer::CurrentSurfaces {{what -all}} {
     1236    set list {}
     1237    if { $what == "-all" } {
     1238        foreach key [array names _serverObjs] {
     1239            foreach {dataobj comp} [split $key -] break
     1240            if { [info exists _obj2ovride($dataobj-raise)] } {
     1241                lappend list $dataobj-$comp
     1242            }
     1243        }
     1244    } else {
     1245        foreach key [array names _serverObjs] {
     1246            foreach {dataobj comp} [split $key -] break
     1247            if { [info exists _obj2ovride($dataobj$what)] &&
     1248                 $_obj2ovride($dataobj$what) } {
     1249                lappend list $dataobj-$comp
     1250            }
     1251        }
     1252    }
     1253    return $list
     1254}
  • trunk/gui/scripts/molvisviewer.tcl

    r1543 r1545  
    197197    }]
    198198   
    199     #
    200     # Set up the widgets in the main body
    201     #
     199    itk_component add 3dview {
     200        label $itk_component(plotarea).vol -image $_image(plot) \
     201            -highlightthickness 0 -borderwidth 0
     202    } {
     203        usual
     204        ignore -highlightthickness -borderwidth  -background
     205    }
     206
    202207    set f [$itk_component(main) component controls]
    203208    itk_component add reset {
  • trunk/gui/scripts/nanovisviewer.tcl

    r1543 r1545  
    207207        $this-zoom              $_view(zoom)
    208208    }]
     209
     210    itk_component add 3dview {
     211        label $itk_component(plotarea).vol -image $_image(plot) \
     212            -highlightthickness 0 -borderwidth 0
     213    } {
     214        usual
     215        ignore -highlightthickness -borderwidth  -background
     216    }
    209217
    210218    set f [$itk_component(main) component controls]
  • trunk/gui/scripts/visviewer.tcl

    r1539 r1545  
    133133    pack $itk_component(plotarea) -fill both -expand yes
    134134    set _image(plot) [image create photo]
    135     itk_component add 3dview {
    136         label $itk_component(plotarea).vol -image $_image(plot) \
    137             -highlightthickness 0 -borderwidth 0
    138     } {
    139         usual
    140         ignore -highlightthickness -borderwidth  -background
    141     }
    142135    eval itk_initialize $args
    143136}
Note: See TracChangeset for help on using the changeset viewer.