Changeset 1294 for trunk


Ignore:
Timestamp:
Mar 6, 2009 8:41:16 PM (15 years ago)
Author:
dkearney
Message:

code clean up, hate tabs

Location:
trunk/gui/scripts
Files:
2 edited

Legend:

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

    r1250 r1294  
    1 
    21# ----------------------------------------------------------------------
    32#  COMPONENT: heightmapviewer - 3D volume rendering
     
    4241    itk_option define -plotoutline plotOutline PlotOutline ""
    4342
    44     constructor { hostlist args } { 
    45         Rappture::VisViewer::constructor $hostlist 
    46     } { 
    47         # defined below 
    48     }
    49     destructor { 
    50         # defined below 
     43    constructor { hostlist args } {
     44        Rappture::VisViewer::constructor $hostlist
     45    } {
     46        # defined below
     47    }
     48    destructor {
     49        # defined below
    5150    }
    5251
    5352    public proc SetServerList { namelist } {
    54         Rappture::VisViewer::SetServerList "nanovis" $namelist
     53        Rappture::VisViewer::SetServerList "nanovis" $namelist
    5554    }
    5655    public method add {dataobj {settings ""}}
     
    5958    public method scale {args}
    6059    public method download {option args}
    61     public method parameters {title args} { 
    62         # do nothing 
     60    public method parameters {title args} {
     61        # do nothing
    6362    }
    6463    protected method Connect {}
     
    9594
    9695    private common settings_      ;# Array used for checkbuttons and radiobuttons
    97                        
     96
    9897}
    9998
     
    133132        psi     0
    134133        zoom    1.0
    135         dx      0
    136         dy      0
     134        dx      0
     135        dy      0
    137136    }
    138137    set obj2id_(count) 0
     
    203202    Rappture::Balloon $itk_component(controls).panel -title "Settings"
    204203    set inner [$itk_component(controls).panel component inner]
    205    
     204
    206205    frame $inner.f
    207206    pack $inner.f -side top -fill x
    208207    grid columnconfigure $inner.f 1 -weight 1
    209208    set fg [option get $itk_component(hull) font Font]
    210    
     209
    211210    set ::Rappture::HeightmapViewer::settings_($this-grid) 1
    212211    ::checkbutton $inner.f.grid \
     
    233232    ::checkbutton $inner.f.wireframe \
    234233        -text "Wireframe" \
    235         -onvalue "wireframe" -offvalue "fill" \
     234        -onvalue "wireframe" -offvalue "fill" \
    236235        -variable ::Rappture::HeightmapViewer::settings_($this-wireframe) \
    237236        -command [itcl::code $this _fixSettings wireframe]
     
    289288    # Bindings for zoom via keyboard
    290289    bind $itk_component(3dview) <KeyPress-Prior> \
    291         [itcl::code $this _zoom out]
     290        [itcl::code $this _zoom out]
    292291    bind $itk_component(3dview) <KeyPress-Next> \
    293         [itcl::code $this _zoom in]
     292        [itcl::code $this _zoom in]
    294293
    295294    bind $itk_component(3dview) <Enter> "focus $itk_component(3dview)"
    296295
    297296    if {[string equal "x11" [tk windowingsystem]]} {
    298         # Bindings for zoom via mouse
    299         bind $itk_component(3dview) <4> [itcl::code $this _zoom out]
    300         bind $itk_component(3dview) <5> [itcl::code $this _zoom in]
     297        # Bindings for zoom via mouse
     298        bind $itk_component(3dview) <4> [itcl::code $this _zoom out]
     299        bind $itk_component(3dview) <5> [itcl::code $this _zoom in]
    301300    }
    302301
     
    601600            # tell the engine to expect some data
    602601            set nbytes [string length $data]
    603             if { ![SendBytes "heightmap data follows $nbytes"] } {
     602            if { ![SendBytes "heightmap data follows $nbytes"] } {
    604603                return
    605604
     
    787786                psi     0
    788787                zoom    1.0
    789                 dx 0
    790                 dy 0
     788                dx      0
     789                dy      0
    791790            }
    792791            set xyz [Euler2XYZ $view_(theta) $view_(phi) $view_(psi)]
     
    801800# USAGE: $this _pan click x y
    802801#        $this _pan drag x y
    803 #        $this _pan release x y
     802#        $this _pan release x y
    804803#
    805804# Called automatically when the user clicks on one of the zoom
     
    811810    set h [winfo height $itk_component(3dview)]
    812811    if { $option == "set" } {
    813         set x [expr $x / double($w)]
    814         set y [expr $y / double($h)]
    815         set view_(dx) [expr $view_(dx) + $x]
    816         set view_(dy) [expr $view_(dy) + $y]
     812        set x [expr $x / double($w)]
     813        set y [expr $y / double($h)]
     814        set view_(dx) [expr $view_(dx) + $x]
     815        set view_(dy) [expr $view_(dy) + $y]
    817816        _send "camera pan $view_(dx) $view_(dy)"
    818         return
    819     }
    820     if { $option == "click" } { 
    821         set click_(x) $x
    822         set click_(y) $y
     817        return
     818    }
     819    if { $option == "click" } {
     820        set click_(x) $x
     821        set click_(y) $y
    823822        $itk_component(3dview) configure -cursor hand1
    824823    }
    825824    if { $option == "drag" || $option == "release" } {
    826         set dx [expr ($click_(x) - $x)/double($w)]
    827         set dy [expr ($click_(y) - $y)/double($h)]
    828         set click_(x) $x
    829         set click_(y) $y
    830         set view_(dx) [expr $view_(dx) - $dx]
    831         set view_(dy) [expr $view_(dy) - $dy]
    832         _send "camera pan $view_(dx) $view_(dy)"
     825        set dx [expr ($click_(x) - $x)/double($w)]
     826        set dy [expr ($click_(y) - $y)/double($h)]
     827        set click_(x) $x
     828        set click_(y) $y
     829        set view_(dx) [expr $view_(dx) - $dx]
     830        set view_(dy) [expr $view_(dy) - $dy]
     831        _send "camera pan $view_(dx) $view_(dy)"
    833832    }
    834833    if { $option == "release" } {
     
    849848        click {
    850849            $itk_component(3dview) configure -cursor fleur
    851             array set click_ [subst {
    852                 x       $x
    853                 y       $y
    854                 theta   $view_(theta)
    855                 phi     $view_(phi)
    856             }]
     850            array set click_ [subst {
     851                x       $x
     852                y       $y
     853                theta   $view_(theta)
     854                phi     $view_(phi)
     855            }]
    857856        }
    858857        drag {
     
    945944            set h [expr {[winfo height $itk_component(legend)]-20-$lineht}]
    946945            set imap ""
    947            
     946
    948947            set dataobj [lindex [get] 0]
    949948            if {"" != $dataobj} {
     
    10321031            # add spikes in the middle
    10331032            set xval [expr {double($i)/($levels+1)}]
    1034             lappend wmap [expr {$xval-$delta-0.01}] 0.0
    1035             lappend wmap [expr {$xval-$delta}] $opacity
    1036             lappend wmap [expr {$xval+$delta}] $opacity
    1037             lappend wmap [expr {$xval+$delta+0.01}] 0.0
     1033            lappend wmap [expr {$xval-$delta-0.01}] 0.0
     1034            lappend wmap [expr {$xval-$delta}] $opacity
     1035            lappend wmap [expr {$xval+$delta}] $opacity
     1036            lappend wmap [expr {$xval+$delta+0.01}] 0.0
    10381037        }
    10391038        lappend wmap 1.0 0.0
     
    10421041        set delta 0.05
    10431042        foreach xval [split $levels ,] {
    1044             lappend wmap [expr {$xval-$delta}] 0.0 
    1045             lappend $xval $opacity
    1046             lappend [expr {$xval+$delta}] 0.0
     1043            lappend wmap [expr {$xval-$delta}] 0.0
     1044            lappend $xval $opacity
     1045            lappend [expr {$xval+$delta}] 0.0
    10471046        }
    10481047        lappend wmap 1.0 0.0
  • trunk/gui/scripts/visviewer.tcl

    r1277 r1294  
    3535    private variable idleTimeout_ 43200000; # 12 hours
    3636    #private variable idleTimeout_ 5000;    # 5 seconds
    37     #private variable idleTimeout_ 0;       # No timeout
     37    #private variable idleTimeout_ 0;       # No timeout
    3838
    3939    protected variable _dispatcher ""   ;# dispatcher for !events
     
    133133    #
    134134    itk_component add drawer {
    135         panedwindow $itk_interior.drawer \
    136             -orient horizontal -opaqueresize 1 -handlepad 0 \
    137             -handlesize 1 -sashwidth 2     
     135        panedwindow $itk_interior.drawer \
     136            -orient horizontal -opaqueresize 1 -handlepad 0 \
     137            -handlesize 1 -sashwidth 2
    138138    }
    139139    pack $itk_component(drawer) -expand yes -fill both
     
    207207# Connect --
    208208#
    209 #    Connect to the visualization server (e.g. nanovis, pymolproxy). 
    210 #    Creates an event callback that is triggered when we are idle 
    211 #    (no I/O with the server) for some specified time. Sends the server 
    212 #    some estimate of the size of our job [soon to be deprecated]. 
    213 #    If it's too busy, that server may forward us to another [this 
     209#    Connect to the visualization server (e.g. nanovis, pymolproxy).
     210#    Creates an event callback that is triggered when we are idle
     211#    (no I/O with the server) for some specified time. Sends the server
     212#    some estimate of the size of our job [soon to be deprecated].
     213#    If it's too busy, that server may forward us to another [this
    214214#    was been turned off in nanoscale].
    215215#
     
    260260            # release the busy window over the hull.
    261261            $_dispatcher cancel !serverDown
    262             if { $idleTimeout_ > 0 } {
    263                 $_dispatcher event -after $idleTimeout_ !timeout
    264             }
     262            if { $idleTimeout_ > 0 } {
     263                $_dispatcher event -after $idleTimeout_ !timeout
     264            }
    265265            blt::busy release $itk_component(hull)
    266266            fconfigure $sid_ -buffering line
     
    308308itcl::body Rappture::VisViewer::_CheckConnection {} {
    309309    if { [IsConnected] } {
    310         if { [eof $sid_] } {
    311             error "unexpected eof on socket"
    312         }
    313         $_dispatcher cancel !timeout
    314         if { $idleTimeout_ > 0 } {
    315             $_dispatcher event -after $idleTimeout_ !timeout
    316         }
    317         return 1
     310        if { [eof $sid_] } {
     311            error "unexpected eof on socket"
     312        }
     313        $_dispatcher cancel !timeout
     314        if { $idleTimeout_ > 0 } {
     315            $_dispatcher event -after $idleTimeout_ !timeout
     316        }
     317        return 1
    318318    }
    319319    # If we aren't connected, assume it's because the connection to the
     
    326326    set code [catch { Connect } ok]
    327327    if { $code == 0 && $ok} {
    328         $_dispatcher event -idle !rebuild
    329         Rappture::Tooltip::cue hide
    330         return 1
     328        $_dispatcher event -idle !rebuild
     329        Rappture::Tooltip::cue hide
     330        return 1
    331331    } else {
    332         Rappture::Tooltip::cue @$x,$y "Can't connect to visualization server.  This may be a network problem.  Wait a few moments and try resetting the view."
    333         return 0
     332        Rappture::Tooltip::cue @$x,$y "Can't connect to visualization server.  This may be a network problem.  Wait a few moments and try resetting the view."
     333        return 0
    334334    }
    335335}
     
    356356itcl::body Rappture::VisViewer::_SendHelper {} {
    357357    if { ![_CheckConnection] } {
    358         return 0
     358        return 0
    359359    }
    360360    puts $sid_ $buffer_(out)
     
    374374itcl::body Rappture::VisViewer::_SendHelper.old {} {
    375375    if { ![_CheckConnection] } {
    376         return 0
     376        return 0
    377377    }
    378378    set bytesLeft [string length $buffer_(out)]
     
    407407
    408408    if { ![_CheckConnection] } {
    409         return 0
     409        return 0
    410410    }
    411411    # Even though the data is sent in only 1 "puts", we need to verify that
     
    429429itcl::body Rappture::VisViewer::ReceiveBytes { size } {
    430430    if { ![_CheckConnection] } {
    431         return 0
     431        return 0
    432432    }
    433433    set bytes [read $sid_ $size]
     
    457457itcl::body Rappture::VisViewer::_ReceiveHelper {} {
    458458    if { ![_CheckConnection] } {
    459         return 0
     459        return 0
    460460    }
    461461    set n [gets $sid_ line]
    462    
     462
    463463    if { $n < 0 } {
    464         Disconnect
    465         return 0
     464        Disconnect
     465        return 0
    466466    }
    467467    set line [string trim $line]
    468468    if { $line == "" } {
    469         return
     469        return
    470470    }
    471471    if { [string compare -length 3 $line "nv>"] == 0 } {
    472         ReceiveEcho <<line $line
    473         append buffer_(in) [string range $line 3 end]
    474         append buffer_(in) "\n"
    475         if {[info complete $buffer_(in)]} {
    476             set request $buffer_(in)
    477             set buffer_(in) ""
    478             $_parser eval $request
    479         }
     472        ReceiveEcho <<line $line
     473        append buffer_(in) [string range $line 3 end]
     474        append buffer_(in) "\n"
     475        if {[info complete $buffer_(in)]} {
     476            set request $buffer_(in)
     477            set buffer_(in) ""
     478            $_parser eval $request
     479        }
    480480    } elseif { [string compare -length 20 $line "NanoVis Server Error:"] == 0} {
    481         # this shows errors coming back from the engine
    482         ReceiveEcho <<error $line
    483         puts stderr "Render Server Error: $line\n"
     481        # this shows errors coming back from the engine
     482        ReceiveEcho <<error $line
     483        puts stderr "Render Server Error: $line\n"
    484484    } else {
    485         # this shows errors coming back from the engine
    486         ReceiveEcho <<error $line
    487         puts stderr "Garbled message: $line\n"
     485        # this shows errors coming back from the engine
     486        ReceiveEcho <<error $line
     487        puts stderr "Garbled message: $line\n"
    488488    }
    489489}
Note: See TracChangeset for help on using the changeset viewer.