Ignore:
Timestamp:
Mar 5, 2008, 5:20:56 PM (16 years ago)
Author:
gah
Message:

untabify; new settings controls for nanovisviewer

File:
1 edited

Legend:

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

    r919 r921  
    4242
    4343    constructor { hostlist args } {
    44         Rappture::VisViewer::constructor $hostlist
     44        Rappture::VisViewer::constructor $hostlist
    4545    } {
    46         # defined below
     46        # defined below
    4747    }
    4848    destructor {
    49         # defined below
     49        # defined below
    5050    }
    5151
     
    5757    public method download {option args}
    5858    public method parameters {title args} {
    59         # do nothing
     59        # do nothing
    6060    }
    6161    protected method Connect {}
     
    9292
    9393    private common _settings      ;# Array used for checkbuttons and radiobuttons
    94                        
     94                       
    9595}
    9696
     
    107107    $_dispatcher register !legend
    108108    $_dispatcher dispatch $this !legend \
    109         "[itcl::code $this _fixSettings legend]; list"
     109        "[itcl::code $this _fixSettings legend]; list"
    110110    # Send dataobjs event
    111111    $_dispatcher register !send_dataobjs
    112112    $_dispatcher dispatch $this !send_dataobjs \
    113         "[itcl::code $this _send_dataobjs]; list"
     113        "[itcl::code $this _send_dataobjs]; list"
    114114    # Rebuild event
    115115    $_dispatcher register !rebuild
     
    126126    # Initialize the view to some default parameters.
    127127    array set _view {
    128         theta   45
    129         phi     45
    130         psi     0
    131         zoom    1.0
    132         xfocus  0
    133         yfocus  0
    134         zfocus  0
     128        theta   45
     129        phi     45
     130        psi     0
     131        zoom    1.0
     132        xfocus  0
     133        yfocus  0
     134        zfocus  0
    135135    }
    136136    set _obj2id(count) 0
     
    209209    set ::Rappture::HeightmapViewer::_settings($this-grid) 1
    210210    ::checkbutton $inner.f.grid \
    211         -text "Show Grid" \
    212         -variable ::Rappture::HeightmapViewer::_settings($this-grid) \
    213         -command [itcl::code $this _fixSettings grid]
     211        -text "Show Grid" \
     212        -variable ::Rappture::HeightmapViewer::_settings($this-grid) \
     213        -command [itcl::code $this _fixSettings grid]
    214214    grid $inner.f.grid -row 0 -column 0 -sticky w
    215215
    216216    set ::Rappture::HeightmapViewer::_settings($this-axes) 1
    217217    ::checkbutton $inner.f.axes \
    218         -text "Show Axes" \
    219         -variable ::Rappture::HeightmapViewer::_settings($this-axes) \
    220         -command [itcl::code $this _fixSettings axes]
     218        -text "Show Axes" \
     219        -variable ::Rappture::HeightmapViewer::_settings($this-axes) \
     220        -command [itcl::code $this _fixSettings axes]
    221221    grid $inner.f.axes -row 1 -column 0 -sticky w
    222222
    223223    set ::Rappture::HeightmapViewer::_settings($this-contourlines) 1
    224224    ::checkbutton $inner.f.contour \
    225         -text "Show Contour Lines" \
    226         -variable ::Rappture::HeightmapViewer::_settings($this-contourlines) \
    227         -command [itcl::code $this _fixSettings contourlines]
     225        -text "Show Contour Lines" \
     226        -variable ::Rappture::HeightmapViewer::_settings($this-contourlines) \
     227        -command [itcl::code $this _fixSettings contourlines]
    228228    grid $inner.f.contour -row 2 -column 0 -sticky w
    229229
     
    305305        set _obj2ovride($dataobj-width) $params(-width)
    306306        set _obj2ovride($dataobj-raise) $params(-raise)
    307         $_dispatcher event -idle !rebuild
     307        $_dispatcher event -idle !rebuild
    308308    }
    309309}
     
    329329        foreach obj $dlist {
    330330            if { [info exists _obj2ovride($obj-raise)] &&
    331                 $_obj2ovride($obj-raise)} {
     331                $_obj2ovride($obj-raise)} {
    332332                set i [lsearch -exact $dlist $obj]
    333333                if {$i >= 0} {
     
    387387    # if anything changed, then rebuild the plot
    388388    if {$changed} {
    389         $_dispatcher event -idle !rebuild
     389        $_dispatcher event -idle !rebuild
    390390    }
    391391}
     
    438438        coming {
    439439            if {[catch {
    440                 blt::winop snap $itk_component(area) $_image(download)
    441             }]} {
     440                blt::winop snap $itk_component(area) $_image(download)
     441            }]} {
    442442                $_image(download) configure -width 1 -height 1
    443443                $_image(download) put #000000
     
    517517# _send
    518518#
    519 #       Send commands off to the rendering server.  If we're currently
    520 #       sending data objects to the server, buffer the commands to be
    521 #       sent later.
     519#       Send commands off to the rendering server.  If we're currently
     520#       sending data objects to the server, buffer the commands to be
     521#       sent later.
    522522#
    523523itcl::body Rappture::HeightmapViewer::_send {string} {
    524524    if {[llength $_sendobjs] > 0} {
    525         append _outbuf $string "\n"
     525        append _outbuf $string "\n"
    526526    } else {
    527         if {[SendBytes $string]} {
    528             foreach line [split $string \n] {
    529                 SendEcho >>line $line
    530             }
    531         }
     527        if {[SendBytes $string]} {
     528            foreach line [split $string \n] {
     529                SendEcho >>line $line
     530            }
     531        }
    532532    }
    533533}
     
    545545    # Reset the overall limits
    546546    if { $_sendobjs != "" } {
    547         set _limits(vmin) ""
    548         set _limits(vmax) ""
     547        set _limits(vmin) ""
     548        set _limits(vmax) ""
    549549    }
    550550    foreach dataobj $_sendobjs {
     
    553553            set data [$dataobj blob $comp]
    554554
    555             foreach { vmin vmax }  [$dataobj limits v] break
    556             if { $_limits(vmin) == "" || $vmin < $_limits(vmin) } {
    557                 set _limits(vmin) $vmin
    558             }
    559             if { $_limits(vmax) == "" || $vmax > $_limits(vmax) } {
    560                 set _limits(vmax) $vmax
    561             }
     555            foreach { vmin vmax }  [$dataobj limits v] break
     556            if { $_limits(vmin) == "" || $vmin < $_limits(vmin) } {
     557                set _limits(vmin) $vmin
     558            }
     559            if { $_limits(vmax) == "" || $vmax > $_limits(vmax) } {
     560                set _limits(vmax) $vmax
     561            }
    562562
    563563            # tell the engine to expect some data
     
    566566                return
    567567            }
    568             if { ![SendBytes $data] } {
    569                 return
    570             }
    571             set id $_obj2id(count)
     568            if { ![SendBytes $data] } {
     569                return
     570            }
     571            set id $_obj2id(count)
    572572            incr _obj2id(count)
    573             set _id2obj($id) [list $dataobj $comp]
     573            set _id2obj($id) [list $dataobj $comp]
    574574            set _obj2id($dataobj-$comp) $id
    575             set _receiveids($id) 1
     575            set _receiveids($id) 1
    576576
    577577            #
     
    738738        }
    739739        "reset" {
    740             array set _view {
    741                 theta   45
    742                 phi     45
    743                 psi     0
    744                 zoom    1.0
    745             }
    746             set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
     740            array set _view {
     741                theta   45
     742                phi     45
     743                psi     0
     744                zoom    1.0
     745            }
     746            set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
    747747            _send "camera angle $xyz"
    748748        }
     
    763763        click {
    764764            $itk_component(3dview) configure -cursor fleur
    765             set _click(x)       $x
    766             set _click(y)       $y
    767             set _click(theta)   $_view(theta)
    768             set _click(phi)     $_view(phi)
     765            set _click(x)       $x
     766            set _click(y)       $y
     767            set _click(theta)   $_view(theta)
     768            set _click(phi)     $_view(phi)
    769769        }
    770770        drag {
     
    809809                }
    810810
    811                 set _view(theta)        $theta
    812                 set _view(phi)          $phi
    813                 set _view(psi)          $psi
    814                 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
     811                set _view(theta)        $theta
     812                set _view(phi)          $phi
     813                set _view(psi)          $psi
     814                set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
    815815                _send "camera angle $xyz"
    816816                set _click(x) $x
     
    852852itcl::body Rappture::HeightmapViewer::_fixSettings { what {value ""} } {
    853853    switch -- $what {
    854         "legend" {
    855             set lineht [font metrics $itk_option(-font) -linespace]
    856             set w [expr {[winfo width $itk_component(legend)]-20}]
    857             set h [expr {[winfo height $itk_component(legend)]-20-$lineht}]
    858             set imap ""
    859            
    860             set dataobj [lindex [get] 0]
    861             if {"" != $dataobj} {
    862                 set comp [lindex [$dataobj components] 0]
    863                 if {[info exists _obj2id($dataobj-$comp)]} {
    864                     set imap $_obj2id($dataobj-$comp)
    865                 }
    866             }
    867             if {$w > 0 && $h > 0 && "" != $imap} {
    868                 _send "heightmap legend $imap $w $h"
    869             } else {
    870                 $itk_component(legend) delete all
    871             }
    872         }
    873         "grid" {
    874             if { [isconnected] } {
    875                 _send "grid visible $_settings($this-grid)"
    876             }
    877         }
    878         "axes" {
    879             if { [isconnected] } {
    880                 _send "axis visible $_settings($this-axes)"
    881             }
    882         }
    883         "contourlines" {
    884             if {[isconnected]} {
    885                 set dataobj [lindex [get] 0]
    886                 if {"" != $dataobj} {
    887                     set comp [lindex [$dataobj components] 0]
    888                     if {[info exists _obj2id($dataobj-$comp)]} {
    889                         set i $_obj2id($dataobj-$comp)
    890                         set bool $_settings($this-contourlines)
    891                         _send "heightmap linecontour visible $bool $i"
    892                     }
    893                 }
    894             }
    895         }
     854        "legend" {
     855            set lineht [font metrics $itk_option(-font) -linespace]
     856            set w [expr {[winfo width $itk_component(legend)]-20}]
     857            set h [expr {[winfo height $itk_component(legend)]-20-$lineht}]
     858            set imap ""
     859           
     860            set dataobj [lindex [get] 0]
     861            if {"" != $dataobj} {
     862                set comp [lindex [$dataobj components] 0]
     863                if {[info exists _obj2id($dataobj-$comp)]} {
     864                    set imap $_obj2id($dataobj-$comp)
     865                }
     866            }
     867            if {$w > 0 && $h > 0 && "" != $imap} {
     868                _send "heightmap legend $imap $w $h"
     869            } else {
     870                $itk_component(legend) delete all
     871            }
     872        }
     873        "grid" {
     874            if { [isconnected] } {
     875                _send "grid visible $_settings($this-grid)"
     876            }
     877        }
     878        "axes" {
     879            if { [isconnected] } {
     880                _send "axis visible $_settings($this-axes)"
     881            }
     882        }
     883        "contourlines" {
     884            if {[isconnected]} {
     885                set dataobj [lindex [get] 0]
     886                if {"" != $dataobj} {
     887                    set comp [lindex [$dataobj components] 0]
     888                    if {[info exists _obj2id($dataobj-$comp)]} {
     889                        set i $_obj2id($dataobj-$comp)
     890                        set bool $_settings($this-contourlines)
     891                        _send "heightmap linecontour visible $bool $i"
     892                    }
     893                }
     894            }
     895        }
    896896        default {
    897897            error "don't know how to fix $what: should be grid, axes, contourlines, or legend"
     
    974974itcl::configbody Rappture::HeightmapViewer::plotoutline {
    975975    if {[isconnected]} {
    976         _send "grid linecolor [Color2RGB $itk_option(-plotoutline)]"
    977     }
    978 }
     976        _send "grid linecolor [Color2RGB $itk_option(-plotoutline)]"
     977    }
     978}
Note: See TracChangeset for help on using the changeset viewer.