Changeset 894 for trunk/gui/scripts


Ignore:
Timestamp:
Feb 16, 2008 10:57:41 PM (16 years ago)
Author:
dkearney
Message:

reformating code, replacing tabs with spaces.

Location:
trunk/gui/scripts
Files:
3 edited

Legend:

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

    r885 r894  
    203203    }
    204204    if {[info exists _comp2unirect2d($what)]} {
    205         set mobj $_comp2unirect2d($what)
     205        set mobj $_comp2unirect2d($what)
    206206        return [$mobj values]
    207207    }
     
    228228    }
    229229    if {[info exists _comp2unirect2d($what)]} {
    230         set mobj $_comp2unirect2d($what)
     230        set mobj $_comp2unirect2d($what)
    231231        return [$mobj blob]
    232232    }
     
    503503        set class [$mobj info class]
    504504        ${class}::release $mobj
    505        
     505
    506506        set fobj [lindex $_comp2vtk($name) 1]
    507507        rename $fobj ""
     
    516516    catch {unset _comp2style}
    517517    array unset _comp2unirect2d
    518    
     518
    519519    #
    520520    # Scan through the components of the field and create
     
    523523    foreach cname [$_field children -type component] {
    524524        set type ""
    525         if { ([$_field element $cname.constant] != "" && 
    526               [$_field element $cname.domain] != "") ||
    527              [$_field element $cname.xy] != ""} {
     525        if { ([$_field element $cname.constant] != "" &&
     526            [$_field element $cname.domain] != "") ||
     527            [$_field element $cname.xy] != ""} {
    528528            set type "1D"
    529         } elseif {[$_field element $cname.mesh] != "" && 
    530                   [$_field element $cname.values] != ""} {
     529        } elseif {[$_field element $cname.mesh] != "" &&
     530            [$_field element $cname.values] != ""} {
    531531            set type "points-on-mesh"
    532532        } elseif {[$_field element $cname.vtk] != ""} {
     
    538538        }
    539539        set _comp2style($cname) ""
    540        
     540
    541541        if {$type == "1D"} {
    542542            #
     
    546546            set xv ""
    547547            set yv ""
    548            
     548
    549549            set val [$_field get $cname.constant]
    550550            if {$val != ""} {
     
    558558                set xv [blt::vector create x$_counter]
    559559                $xv append $z0 $z1
    560                
     560
    561561                foreach {val pcomp} [_getValue $val] break
    562562                set yv [blt::vector create y$_counter]
    563563                $yv append $val $val
    564                
     564
    565565                if {$pcomp != ""} {
    566566                    set zm [expr {0.5*($z0+$z1)}]
     
    573573                    set xv [blt::vector create x$_counter]
    574574                    set yv [blt::vector create y$_counter]
    575                    
     575
    576576                    foreach line [split $xydata \n] {
    577577                        if {[scan $line {%g %g} xval yval] == 2} {
     
    582582                }
    583583            }
    584            
     584
    585585            if {$xv != "" && $yv != ""} {
    586586                # sort x-coords in increasing order
    587587                $xv sort $yv
    588                
     588
    589589                set _comp2dims($cname) "1D"
    590590                set _comp2xy($cname) [list $xv $yv]
     
    599599            set path [$_field get $cname.mesh]
    600600            if {[$_xmlobj element $path] != ""} {
    601                 set element [$_xmlobj element -as type $path]
    602                 if { $element == "unirect2d" } {
    603                     set _comp2dims($cname) "2D"
    604                     set _comp2unirect2d($cname) \
    605                         [Rappture::UniRect2d \#auto $_xmlobj $_field $cname]
    606                     set _comp2style($cname) [$_field get $cname.style]
    607                     incr _counter
    608                 } elseif { $element == "cloud" || $element == "mesh" } {
    609                     switch -- $element {
    610                         cloud {
    611                             set mobj [Rappture::Cloud::fetch $_xmlobj $path]
    612                         }
    613                         mesh {
    614                             set mobj [Rappture::Mesh::fetch $_xmlobj $path]
    615                         }
    616                     }
    617                     if {[$mobj dimensions] > 1} {
    618                         #
    619                         # 2D/3D data
    620                         # Store cloud/field as components
    621                         #
    622                         set values [$_field get $cname.values]
    623                         set farray [vtkFloatArray ::vals$_counter]
    624                        
    625                         foreach v $values {
    626                             if {"" != $_units} {
    627                                 set v [Rappture::Units::convert $v \
    628                                            -context $_units -to $_units -units off]
    629                             }
    630                             $farray InsertNextValue $v
    631                         }
    632                        
    633                         set _comp2dims($cname) "[$mobj dimensions]D"
    634                         set _comp2vtk($cname) [list $mobj $farray]
    635                         set _comp2style($cname) [$_field get $cname.style]
    636                         incr _counter
    637                     } else {
    638                         #
    639                         # OOPS!  This is 1D data
    640                         # Forget the cloud/field -- store BLT vectors
    641                         #
    642                         set xv [blt::vector create x$_counter]
    643                         set yv [blt::vector create y$_counter]
    644                        
    645                         set vtkpts [$mobj points]
    646                         set max [$vtkpts GetNumberOfPoints]
    647                         for {set i 0} {$i < $max} {incr i} {
    648                             set xval [lindex [$vtkpts GetPoint $i] 0]
    649                             $xv append $xval
    650                         }
    651                         set class [$mobj info class]
    652                         ${class}::release $mobj
    653                        
    654                         set values [$_field get $cname.values]
    655                         foreach yval $values {
    656                             if {"" != $_units} {
    657                                 set yval [Rappture::Units::convert $yval \
    658                                               -context $_units -to $_units -units off]
    659                             }
    660                             $yv append $yval
    661                         }
    662                        
    663                         # sort x-coords in increasing order
    664                         $xv sort $yv
    665                        
    666                         set _comp2dims($cname) "1D"
    667                         set _comp2xy($cname) [list $xv $yv]
    668                         incr _counter
    669                     }
    670                 }
    671             } else {
    672                 puts "WARNING: can't find mesh $path for field component"
    673             }
     601                set element [$_xmlobj element -as type $path]
     602                if { $element == "unirect2d" } {
     603                    set _comp2dims($cname) "2D"
     604                    set _comp2unirect2d($cname) \
     605                        [Rappture::UniRect2d \#auto $_xmlobj $_field $cname]
     606                    set _comp2style($cname) [$_field get $cname.style]
     607                    incr _counter
     608                } elseif { $element == "cloud" || $element == "mesh" } {
     609                    switch -- $element {
     610                        cloud {
     611                            set mobj [Rappture::Cloud::fetch $_xmlobj $path]
     612                        }
     613                        mesh {
     614                            set mobj [Rappture::Mesh::fetch $_xmlobj $path]
     615                        }
     616                    }
     617                    if {[$mobj dimensions] > 1} {
     618                        #
     619                        # 2D/3D data
     620                        # Store cloud/field as components
     621                        #
     622                        set values [$_field get $cname.values]
     623                        set farray [vtkFloatArray ::vals$_counter]
     624
     625                        foreach v $values {
     626                            if {"" != $_units} {
     627                                set v [Rappture::Units::convert $v \
     628                                   -context $_units -to $_units -units off]
     629                            }
     630                            $farray InsertNextValue $v
     631                        }
     632
     633                        set _comp2dims($cname) "[$mobj dimensions]D"
     634                        set _comp2vtk($cname) [list $mobj $farray]
     635                        set _comp2style($cname) [$_field get $cname.style]
     636                        incr _counter
     637                    } else {
     638                        #
     639                        # OOPS!  This is 1D data
     640                        # Forget the cloud/field -- store BLT vectors
     641                        #
     642                        set xv [blt::vector create x$_counter]
     643                        set yv [blt::vector create y$_counter]
     644
     645                        set vtkpts [$mobj points]
     646                        set max [$vtkpts GetNumberOfPoints]
     647                        for {set i 0} {$i < $max} {incr i} {
     648                            set xval [lindex [$vtkpts GetPoint $i] 0]
     649                            $xv append $xval
     650                        }
     651                        set class [$mobj info class]
     652                        ${class}::release $mobj
     653
     654                        set values [$_field get $cname.values]
     655                        foreach yval $values {
     656                            if {"" != $_units} {
     657                                set yval [Rappture::Units::convert $yval \
     658                                      -context $_units -to $_units -units off]
     659                            }
     660                            $yv append $yval
     661                        }
     662
     663                        # sort x-coords in increasing order
     664                        $xv sort $yv
     665
     666                        set _comp2dims($cname) "1D"
     667                        set _comp2xy($cname) [list $xv $yv]
     668                        incr _counter
     669                    }
     670                }
     671            } else {
     672                puts "WARNING: can't find mesh $path for field component"
     673            }
    674674        } elseif {$type == "vtk"} {
    675675            #
  • trunk/gui/scripts/nanovisviewer.tcl

    r890 r894  
    112112    private variable _limits       ;# autoscale min/max for all axes
    113113    private variable _view         ;# view params for 3D view
    114        
     114
    115115    private variable _isomarkers    ;# array of isosurface level values 0..1
    116116    private common _isosurface     ;# indicates to use isosurface shading
     
    123123
    124124itcl::class Rappture::NanovisViewer::IsoMarker {
    125     private variable _value     "";     # Absolute value of marker.
    126     private variable _label     ""
    127     private variable _tick      ""
    128     private variable _canvas    ""
    129     private variable _nvobj     ""
     125    private variable _value    ""; # Absolute value of marker.
     126    private variable _label    ""
     127    private variable _tick     ""
     128    private variable _canvas   ""
     129    private variable _nvobj    ""
    130130    private common _normalIcon ""
    131131    private common _activeIcon ""
     
    133133    private variable _active_press    0
    134134
    135     constructor {c obj args} { 
    136         set _canvas $c
    137         set _nvobj $obj
    138        
    139         if { $_normalIcon == "" } {
    140             set normal_icon_data {
     135    constructor {c obj args} {
     136        set _canvas $c
     137        set _nvobj $obj
     138
     139        if { $_normalIcon == "" } {
     140            set normal_icon_data {
    141141R0lGODlhBwATAOcxAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0N
    142142DQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8f
     
    156156LAAAAAAHABMAAAg2AP8JHEiwoMGDCBFmW0gw259sDR9GhDjQIUWBFidiXPhwYTZTpv6AXBjy
    157157j0iSJk9+BDnSo8uAADs=
    158             }
    159             set active_icon_data {
     158            }
     159            set active_icon_data {
    160160R0lGODlhBwATAOcxAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0N
    161161DQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8f
     
    175175LAAAAAAHABMAAAg2AP8JHEiwoMGDCBFmW0gwG4BsDR9GhDjQIUWBFidiXPhwYbY/fwCAXBgS
    176176gEiSJk9+BDnSo8uAADs=
    177             }
    178             set _normalIcon [image create photo -data $normal_icon_data]
    179             set _activeIcon [image create photo -data $active_icon_data]
    180         }
    181         set w [winfo width $_canvas]
    182         set h [winfo height $_canvas]
    183         set _tick [$c create image 0 $h \
    184                 -image $_normalIcon -anchor s \
    185                 -tags "$this $obj" -state hidden]
    186         set _label [$c create text 0 $h \
    187                 -anchor n -fill white -font "Helvetica 6" \
    188                 -tags "$this $obj" -state hidden]
    189         $c bind $_tick <Enter> [itcl::code $this handle_event "enter"]
    190         $c bind $_tick <Leave> [itcl::code $this handle_event "leave"]
    191         $c bind $_tick <ButtonPress-1> \
    192             [itcl::code $this handle_event "start" %x %y]
    193         $c bind $_tick <B1-Motion> \
    194             [itcl::code $this handle_event "update" %x %y]
    195         $c bind $_tick <ButtonRelease-1> \
    196             [itcl::code $this handle_event "end" %x %y]
    197     }
    198     destructor { 
    199         $_canvas delete $this
     177            }
     178            set _normalIcon [image create photo -data $normal_icon_data]
     179            set _activeIcon [image create photo -data $active_icon_data]
     180        }
     181        set w [winfo width $_canvas]
     182        set h [winfo height $_canvas]
     183        set _tick [$c create image 0 $h \
     184                -image $_normalIcon -anchor s \
     185                -tags "$this $obj" -state hidden]
     186        set _label [$c create text 0 $h \
     187                -anchor n -fill white -font "Helvetica 6" \
     188                -tags "$this $obj" -state hidden]
     189        $c bind $_tick <Enter> [itcl::code $this handle_event "enter"]
     190        $c bind $_tick <Leave> [itcl::code $this handle_event "leave"]
     191        $c bind $_tick <ButtonPress-1> \
     192            [itcl::code $this handle_event "start" %x %y]
     193        $c bind $_tick <B1-Motion> \
     194            [itcl::code $this handle_event "update" %x %y]
     195        $c bind $_tick <ButtonRelease-1> \
     196            [itcl::code $this handle_event "end" %x %y]
     197    }
     198    destructor {
     199        $_canvas delete $this
    200200    }
    201201
    202202    public method get_absolute_value {} {
    203         return $_value
     203        return $_value
    204204    }
    205205    public method get_relative_value {} {
    206         array set limits [$_nvobj get_limits]
    207         if { $limits(vmax) == $limits(vmin) } {
    208             set limits(vmin) 0.0
    209             set limits(vmax) 1.0
    210         }
    211         return [expr {($_value-$limits(vmin))/($limits(vmax) - $limits(vmin))}]
     206        array set limits [$_nvobj get_limits]
     207        if { $limits(vmax) == $limits(vmin) } {
     208            set limits(vmin) 0.0
     209            set limits(vmax) 1.0
     210        }
     211        return [expr {($_value-$limits(vmin))/($limits(vmax) - $limits(vmin))}]
    212212    }
    213213    public method activate { bool } {
    214         if  { $bool || $_active_press || $_active_motion } {
    215             $_canvas itemconfigure $_label -state normal
    216             $_canvas itemconfigure $_tick -image $_activeIcon
    217         } else {
    218             $_canvas itemconfigure $_label -state hidden
    219             $_canvas itemconfigure $_tick -image $_normalIcon
    220         }
     214        if  { $bool || $_active_press || $_active_motion } {
     215            $_canvas itemconfigure $_label -state normal
     216            $_canvas itemconfigure $_tick -image $_activeIcon
     217        } else {
     218            $_canvas itemconfigure $_label -state hidden
     219            $_canvas itemconfigure $_tick -image $_normalIcon
     220        }
    221221    }
    222222    public method show {} {
    223         set_absolute_value $_value
    224         $_canvas itemconfigure $_tick -state normal
    225         $_canvas raise $_tick
     223        set_absolute_value $_value
     224        $_canvas itemconfigure $_tick -state normal
     225        $_canvas raise $_tick
    226226    }
    227227    public method hide {} {
    228         $_canvas itemconfigure $_tick -state hidden
    229     }
    230     public method get_screen_position { } { 
    231         set x [get_relative_value]
    232         if { $x < 0.0 } {
    233             set x 0.0
    234         } elseif { $x > 1.0 } {
    235             set x 1.0
    236         }
    237         set low 10
    238         set w [winfo width $_canvas]
    239         set high [expr {$w  - 10}]
    240         set x [expr {round($x*($high - $low) + $low)}]
    241         return $x
     228        $_canvas itemconfigure $_tick -state hidden
     229    }
     230    public method get_screen_position { } {
     231        set x [get_relative_value]
     232        if { $x < 0.0 } {
     233            set x 0.0
     234        } elseif { $x > 1.0 } {
     235            set x 1.0
     236        }
     237        set low 10
     238        set w [winfo width $_canvas]
     239        set high [expr {$w  - 10}]
     240        set x [expr {round($x*($high - $low) + $low)}]
     241        return $x
    242242    }
    243243    public method set_absolute_value { x } {
    244         set _value $x
    245         set y 31
    246         $_canvas itemconfigure $_label -text [format %.4g $_value]
    247         set x [get_screen_position]
    248         $_canvas coords $_tick $x [expr {$y+3}]
    249         $_canvas coords $_label $x [expr {$y+5}]
     244        set _value $x
     245        set y 31
     246        $_canvas itemconfigure $_label -text [format %.4g $_value]
     247        set x [get_screen_position]
     248        $_canvas coords $_tick $x [expr {$y+3}]
     249        $_canvas coords $_label $x [expr {$y+5}]
    250250    }
    251251    public method set_relative_value { x } {
    252         array set limits [$_nvobj get_limits]
    253         if { $limits(vmax) == $limits(vmin) } {
    254             set limits(vmin) 0.0
    255             set limits(vmax) 1.0
    256         }
    257         set r [expr $limits(vmax) - $limits(vmin)]
    258         set_absolute_value [expr {($x * $r) + $limits(vmin)}]
     252        array set limits [$_nvobj get_limits]
     253        if { $limits(vmax) == $limits(vmin) } {
     254            set limits(vmin) 0.0
     255            set limits(vmax) 1.0
     256        }
     257        set r [expr $limits(vmax) - $limits(vmin)]
     258        set_absolute_value [expr {($x * $r) + $limits(vmin)}]
    259259    }
    260260    public method handle_event { option args } {
    261         switch -- $option {
    262             enter {
    263                 set _active_motion 1
    264                 activate yes
    265                 $_canvas raise $_tick
    266             }
    267             leave {
    268                 set _active_motion 0
    269                 activate no
    270             }
    271             start {
    272                 $_canvas raise $_tick
    273                 set _active_press 1
    274                 activate yes
    275             }
    276             update {
    277                 set w [winfo width $_canvas]
    278                 set x [lindex $args 0]
    279                 set_relative_value [expr {double($x-10)/($w-20)}]
    280                 $_nvobj over_isomarker $this $x
    281                 $_nvobj update_transfer_function
    282             }
    283             end {
    284                 set x [lindex $args 0]
    285                 if { ![$_nvobj remove_duplicate_isomarker $this $x]} {
    286                     eval handle_event update $args
    287                 }
    288                 set _active_press 0
    289                 activate no
    290             }
    291             default {
    292                 error "bad option \"$option\": should be start, update, end"
    293             }
    294         }
     261        switch -- $option {
     262            enter {
     263                set _active_motion 1
     264                activate yes
     265                $_canvas raise $_tick
     266            }
     267            leave {
     268                set _active_motion 0
     269                activate no
     270            }
     271            start {
     272                $_canvas raise $_tick
     273                set _active_press 1
     274                activate yes
     275            }
     276            update {
     277                set w [winfo width $_canvas]
     278                set x [lindex $args 0]
     279                set_relative_value [expr {double($x-10)/($w-20)}]
     280                $_nvobj over_isomarker $this $x
     281                $_nvobj update_transfer_function
     282            }
     283            end {
     284                set x [lindex $args 0]
     285                if { ![$_nvobj remove_duplicate_isomarker $this $x]} {
     286                    eval handle_event update $args
     287                }
     288                set _active_press 0
     289                activate no
     290            }
     291            default {
     292                error "bad option \"$option\": should be start, update, end"
     293            }
     294        }
    295295    }
    296296}
  • trunk/gui/scripts/sequence.tcl

    r822 r894  
    6363                    set obj [Rappture::Curve ::#auto $xmlobj $path.$name.$cname]
    6464                }
    65                 histogram {
     65                histogram {
    6666                    set obj [Rappture::Histogram ::#auto $xmlobj $path.$name.$cname]
    6767                }
     
    7373                }
    7474                structure {
    75                     # extract unique result set prefix
     75                    # extract unique result set prefix
    7676                    scan $xmlobj "::libraryObj%d" rset
    7777
     
    7979                    set obj [$xmlobj element -as object $path.$name.$cname]
    8080
    81                     # scene id (sequence id)
     81                    # scene id (sequence id)
    8282                    set sceneid [$xmlobj element -as id $path]-$rset
    8383
    84                     # sequence/element/frame number starting at 1
     84                    # sequence/element/frame number starting at 1
    8585                    set frameid [expr [$xmlobj element -as id $path.$name] + 1]
    8686
    87                     # only supporting one molecule per structure at the moment
    88                     # otherwise should go through all children that are molecules
    89                     # and insert scene/frame data.
     87                    # only supporting one molecule per structure at the moment
     88                    # otherwise should go through all children that are molecules
     89                    # and insert scene/frame data.
    9090                    $obj put "components.molecule.state" $frameid
    9191                    $obj put "components.molecule.model" $sceneid
    92                 }
     92                }
    9393                default {
    9494                    error "don't know how to handle sequences of $type"
Note: See TracChangeset for help on using the changeset viewer.