Changeset 5004


Ignore:
Timestamp:
Feb 11, 2015, 2:40:57 PM (10 years ago)
Author:
ldelgass
Message:

whitespace

File:
1 edited

Legend:

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

    r4997 r5004  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22# ----------------------------------------------------------------------
    33#  COMPONENT: vtkheightmapviewer - Vtk heightmap viewer
     
    5858    public method get {args}
    5959    public method isconnected {}
    60     public method parameters {title args} { 
    61         # do nothing 
     60    public method parameters {title args} {
     61        # do nothing
    6262    }
    6363    public method scale {args}
     
    6969    private method BuildColormap { name }
    7070    private method BuildContourTab {}
    71     private method BuildDownloadPopup { widget command } 
     71    private method BuildDownloadPopup { widget command }
    7272    private method CameraReset {}
    7373    private method Combo { option }
     
    7878    private method DoRotate {}
    7979    private method DrawLegend {}
    80     private method EnterLegend { x y } 
    81     private method EventuallyRequestLegend {} 
    82     private method EventuallyResize { w h } 
     80    private method EnterLegend { x y }
     81    private method EventuallyRequestLegend {}
     82    private method EventuallyResize { w h }
    8383    private method EventuallyRotate { q }
    84     private method GetHeightmapScale {} 
    85     private method GetImage { args } 
    86     private method GetVtkData { args } 
     84    private method GetHeightmapScale {}
     85    private method GetImage { args }
     86    private method GetVtkData { args }
    8787    private method InitSettings { args  }
    88     private method IsValidObject { dataobj } 
     88    private method IsValidObject { dataobj }
    8989    private method LeaveLegend {}
    90     private method MotionLegend { x y } 
     90    private method MotionLegend { x y }
    9191    private method Pan {option x y}
    9292    private method PanCamera {}
    9393    private method Pick {x y}
    94     private method QuaternionToView { q } { 
     94    private method QuaternionToView { q } {
    9595        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
    9696    }
     
    104104    private method SetCurrentColormap { color }
    105105    private method SetLegendTip { x y }
    106     private method SetObjectStyle { dataobj comp } 
     106    private method SetObjectStyle { dataobj comp }
    107107    private method SetOrientation { side }
    108108    private method UpdateContourList {}
    109     private method ViewToQuaternion {} { 
     109    private method ViewToQuaternion {} {
    110110        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
    111111    }
     
    116116    private variable _obj2datasets
    117117    private variable _obj2ovride   ;    # maps dataobj => style override
    118     private variable _comp2scale;       # maps dataset to the heightmap scale.
    119     private variable _datasets     ;    # contains all the dataobj-component 
     118    private variable _comp2scale;       # maps dataset to the heightmap scale.
     119    private variable _datasets     ;    # contains all the dataobj-component
    120120                                   ;    # datasets in the server
    121121    private variable _colormaps    ;    # contains all the colormaps
     
    133133
    134134    private variable _click        ;    # info used for rotate operations
    135     private variable _limits       ;    # Holds overall limits for all dataobjs 
     135    private variable _limits       ;    # Holds overall limits for all dataobjs
    136136                                        # using the viewer.
    137137    private variable _view         ;    # view params for 3D view
     
    158158    private variable _rotatePending 0
    159159    private variable _legendPending 0
    160     private variable _fieldNames {} 
    161     private variable _fields 
     160    private variable _fieldNames {}
     161    private variable _fields
    162162    private variable _curFldName ""
    163163    private variable _curFldLabel ""
     
    255255    } {
    256256        usual
    257         ignore -highlightthickness -borderwidth -background 
     257        ignore -highlightthickness -borderwidth -background
    258258    }
    259259
     
    261261        menu $itk_component(plotarea).menu \
    262262            -relief flat \
    263             -tearoff no 
     263            -tearoff no
    264264    } {
    265265        usual
     
    281281
    282282    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
    283     set _map(cwidth) -1 
    284     set _map(cheight) -1 
     283    set _map(cwidth) -1
     284    set _map(cheight) -1
    285285    set _map(zoom) 1.0
    286286    set _map(original) ""
     
    350350        BuildCameraTab
    351351    } errs] != 0 } {
    352         global errorInfo
     352        global errorInfo
    353353        puts stderr "errs=$errs errorInfo=$errorInfo"
    354354    }
    355355
    356     # Hack around the Tk panewindow.  The problem is that the requested 
     356    # Hack around the Tk panewindow.  The problem is that the requested
    357357    # size of the 3d view isn't set until an image is retrieved from
    358358    # the server.  So the panewindow uses the tiny size.
     
    360360    pack forget $itk_component(view)
    361361    blt::table $itk_component(plotarea) \
    362         0,0 $itk_component(view) -fill both -reqwidth $w 
     362        0,0 $itk_component(view) -fill both -reqwidth $w
    363363    blt::table configure $itk_component(plotarea) c1 -resize none
    364364
     
    444444
    445445itcl::body Rappture::VtkHeightmapViewer::DoRotate {} {
    446     SendCmd "camera orient [ViewToQuaternion]" 
     446    SendCmd "camera orient [ViewToQuaternion]"
    447447    set _rotatePending 0
    448448}
     
    471471    if { !$_rotatePending } {
    472472        set _rotatePending 1
    473         global rotate_delay 
     473        global rotate_delay
    474474        $_dispatcher event -after $rotate_delay !rotate
    475475    }
     
    570570                    continue
    571571                }
    572                 if {[info exists _obj2ovride($dataobj-raise)] && 
     572                if {[info exists _obj2ovride($dataobj-raise)] &&
    573573                    $_obj2ovride($dataobj-raise)} {
    574574                    set dlist [linsert $dlist 0 $dataobj]
     
    598598            }
    599599            return $dlist
    600         }           
     600        }
    601601        -image {
    602602            if {[llength $args] != 2} {
     
    618618}
    619619
    620 # 
     620#
    621621# scale  --
    622622#
    623623#       This gets called either incrementally as new simulations are
    624624#       added or all at once as a sequence of heightmaps.
    625 #       This  accounts for all objects--even those not showing on the 
    626 #       screen.  Because of this, the limits are appropriate for all 
     625#       This  accounts for all objects--even those not showing on the
     626#       screen.  Because of this, the limits are appropriate for all
    627627#       objects as the user scans through data in the ResultSet viewer.
    628628#
     
    816816    $_dispatcher cancel !legend
    817817    # disconnected -- no more data sitting on server
    818     array unset _datasets 
    819     array unset _data 
    820     array unset _colormaps 
    821     array unset _obj2datasets 
     818    array unset _datasets
     819    array unset _data
     820    array unset _colormaps
     821    array unset _obj2datasets
    822822    global readyForNextFrame
    823823    set readyForNextFrame 1
     
    851851        set time [clock seconds]
    852852        set date [clock format $time]
    853         #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"       
     853        #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"
    854854        if { $_start > 0 } {
    855855            set finish [clock clicks -milliseconds]
     
    922922    # Turn on buffering of commands to the server.  We don't want to
    923923    # be preempted by a server disconnect/reconnect (which automatically
    924     # generates a new call to Rebuild).   
     924    # generates a new call to Rebuild).
    925925    StartBufferingCommands
    926926
    927927    if { $_width != $w || $_height != $h || $_reset } {
    928         set _width $w
    929         set _height $h
    930         $_arcball resize $w $h
    931         DoResize
    932         if { $_settings(-stretchtofit) } {
    933             AdjustSetting -stretchtofit
    934         }
     928        set _width $w
     929        set _height $h
     930        $_arcball resize $w $h
     931        DoResize
     932        if { $_settings(-stretchtofit) } {
     933            AdjustSetting -stretchtofit
     934        }
    935935    }
    936936    if { $_reset } {
    937         #
    938         # Reset the camera and other view parameters
    939         #
     937        #
     938        # Reset the camera and other view parameters
     939        #
    940940        InitSettings -isheightmap -background
    941941
    942942        # Setting a custom exponent and label format for axes is causing
    943         # a problem with rounding.  Near zero ticks aren't rounded by 
     943        # a problem with rounding.  Near zero ticks aren't rounded by
    944944        # the %g format.  The VTK CubeAxes seem to currently work best
    945         # when allowed to automatically set the exponent and precision 
    946         # based on the axis ranges.  This does tend to result in less 
    947         # visual clutter, so I think it is best to use the automatic 
     945        # when allowed to automatically set the exponent and precision
     946        # based on the axis ranges.  This does tend to result in less
     947        # visual clutter, so I think it is best to use the automatic
    948948        # settings by default.  We can test more fine-grained
    949949        # controls on the axis settings tab if necessary.
     
    951951        #SendCmd "axis exp 0 0 0 1"
    952952
    953         SendCmd "axis lrot z 90"
    954         $_arcball quaternion [ViewToQuaternion]
     953        SendCmd "axis lrot z 90"
     954        $_arcball quaternion [ViewToQuaternion]
    955955        if {$_settings(-isheightmap) } {
    956956            if { $_view(-ortho)} {
     
    961961            DoRotate
    962962            SendCmd "camera reset"
    963         }
    964         PanCamera
     963        }
     964        PanCamera
    965965        StopBufferingCommands
    966966        SendCmd "imgflush"
     
    981981            if { ![info exists _datasets($tag)] } {
    982982                set bytes [$dataobj vtkdata $comp]
    983                 if 0 {
     983                if 0 {
    984984                    set f [open /tmp/vtkheightmap.vtk "w"]
    985985                    fconfigure $f -translation binary -encoding binary
    986986                    puts -nonewline $f $bytes
    987987                    close $f
    988                 }
     988                }
    989989                set length [string length $bytes]
    990990                if { $_reportClientInfo }  {
     
    10111011                SendCmd "dataset visible 1 $tag"
    10121012            }
    1013             if { ![info exists _comp2scale($tag)] ||
    1014                 $_comp2scale($tag) != $scale } {
    1015                 SendCmd "heightmap heightscale $scale $tag"
    1016                 set _comp2scale($tag) $scale
    1017             }
     1013            if { ![info exists _comp2scale($tag)] ||
     1014                $_comp2scale($tag) != $scale } {
     1015                SendCmd "heightmap heightscale $scale $tag"
     1016                set _comp2scale($tag) $scale
     1017            }
    10181018        }
    10191019    }
    10201020    if { $_first != ""  } {
    1021         $itk_component(field) choices delete 0 end
    1022         $itk_component(fieldmenu) delete 0 end
    1023         array unset _fields
     1021        $itk_component(field) choices delete 0 end
     1022        $itk_component(fieldmenu) delete 0 end
     1023        array unset _fields
    10241024        set _curFldName ""
    10251025        foreach cname [$_first components] {
     
    10501050
    10511051    if { $_reset } {
    1052         SendCmd "axis tickpos outside"
     1052        SendCmd "axis tickpos outside"
    10531053        #SendCmd "axis lformat all %g"
    1054        
    1055         foreach axis { x y z } {
     1054
     1055        foreach axis { x y z } {
    10561056            if { $axis == "z" } {
    10571057                set label [$_first hints label]
     
    10591059                set label [$_first hints ${axis}label]
    10601060            }
    1061             if { $label == "" } {
    1062                 if {$axis == "z"} {
     1061            if { $label == "" } {
     1062                if {$axis == "z"} {
    10631063                    if { [string match "component*" $_curFldName] } {
    10641064                        set label [string toupper $axis]
     
    10661066                        set label $_curFldLabel
    10671067                    }
    1068                 } else {
    1069                     set label [string toupper $axis]
    1070                 }
    1071             }
    1072             # May be a space in the axis label.
    1073             SendCmd [list axis name $axis $label]
     1068                } else {
     1069                    set label [string toupper $axis]
     1070                }
     1071            }
     1072            # May be a space in the axis label.
     1073            SendCmd [list axis name $axis $label]
    10741074
    10751075            set units ""
    1076             if {$axis == "z" && [$_first hints ${axis}units] == ""} {
     1076            if {$axis == "z" && [$_first hints ${axis}units] == ""} {
    10771077                if {$_curFldName != ""} {
    10781078                    set units [lindex $_fields($_curFldName) 1]
    10791079                }
    1080             } else {
    1081                 set units [$_first hints ${axis}units]
    1082             }
    1083             if { $units != "" } {
    1084                 # May be a space in the axis units.
    1085                 SendCmd [list axis units $axis $units]
    1086             }
    1087         }
    1088         #
    1089         # Reset the camera and other view parameters
    1090         #
    1091         ResetAxes
    1092         $_arcball quaternion [ViewToQuaternion]
     1080            } else {
     1081                set units [$_first hints ${axis}units]
     1082            }
     1083            if { $units != "" } {
     1084                # May be a space in the axis units.
     1085                SendCmd [list axis units $axis $units]
     1086            }
     1087        }
     1088        #
     1089        # Reset the camera and other view parameters
     1090        #
     1091        ResetAxes
     1092        $_arcball quaternion [ViewToQuaternion]
    10931093        if {$_settings(-isheightmap) } {
    10941094            if { $_view(-ortho)} {
     
    11001100            SendCmd "camera reset"
    11011101        }
    1102         PanCamera
    1103         InitSettings -xgrid -ygrid -zgrid \
    1104             -axisvisible -axislabels -heightmapscale -field -isheightmap \
     1102        PanCamera
     1103        InitSettings -xgrid -ygrid -zgrid \
     1104            -axisvisible -axislabels -heightmapscale -field -isheightmap \
    11051105            -numisolines
    11061106        if { [array size _fields] < 2 } {
     
    11111111    }
    11121112    global readyForNextFrame
    1113     set readyForNextFrame 0;            # Don't advance to the next frame
     1113    set readyForNextFrame 0;                # Don't advance to the next frame
    11141114
    11151115    # Actually write the commands to the server socket.  If it fails, we don't
     
    11291129itcl::body Rappture::VtkHeightmapViewer::CurrentDatasets {args} {
    11301130    set flag [lindex $args 0]
    1131     switch -- $flag { 
     1131    switch -- $flag {
    11321132        "-all" {
    11331133            if { [llength $args] > 1 } {
     
    11481148                set dlist [get -visible]
    11491149            }
    1150         }           
     1150        }
    11511151        default {
    11521152            set dlist $args
     
    12791279    foreach tag [CurrentDatasets -visible] {
    12801280        SendCmd "dataset getscalar pixel $x $y $tag"
    1281     } 
     1281    }
    12821282}
    12831283
     
    13831383        "-background" {
    13841384            set bg [$itk_component(background) value]
    1385             array set fgcolors {
    1386                 "black" "white"
    1387                 "white" "black"
    1388                 "grey"  "black"
    1389             }
     1385            array set fgcolors {
     1386                "black" "white"
     1387                "white" "black"
     1388                "grey"  "black"
     1389            }
    13901390            set fg $fgcolors($bg)
    13911391            configure -plotbackground $bg -plotforeground $fg
    1392             $itk_component(view) delete "legend"
     1392            $itk_component(view) delete "legend"
    13931393            SendCmd "screen bgcolor [Color2RGB $bg]"
    13941394            SendCmd "outline color [Color2RGB $fg]"
    13951395            SendCmd "axis color all [Color2RGB $fg]"
    1396             DrawLegend
     1396            DrawLegend
    13971397        }
    13981398        "-colormap" {
     
    14011401            set color [$itk_component(colormap) value]
    14021402            set _settings($what) $color
    1403             if { $color == "none" } {
    1404                 if { $_settings(-colormapvisible) } {
    1405                     SendCmd "heightmap surface 0"
    1406                     set _settings(-colormapvisible) 0
    1407                 }
    1408             } else {
    1409                 if { !$_settings(-colormapvisible) } {
    1410                     SendCmd "heightmap surface 1"
    1411                     set _settings(-colormapvisible) 1
    1412                 }
    1413                 SetCurrentColormap $color
     1403            if { $color == "none" } {
     1404                if { $_settings(-colormapvisible) } {
     1405                    SendCmd "heightmap surface 0"
     1406                    set _settings(-colormapvisible) 0
     1407                }
     1408            } else {
     1409                if { !$_settings(-colormapvisible) } {
     1410                    SendCmd "heightmap surface 1"
     1411                    set _settings(-colormapvisible) 1
     1412                }
     1413                SetCurrentColormap $color
    14141414                if {$_settings(-colormapdiscrete)} {
    14151415                    set numColors [expr $_settings(-numisolines) + 1]
    14161416                    SendCmd "colormap res $numColors $color"
    14171417                }
    1418             }
     1418            }
    14191419            StopBufferingCommands
    1420             EventuallyRequestLegend
     1420            EventuallyRequestLegend
    14211421        }
    14221422        "-colormapvisible" {
     
    14611461                return
    14621462            }
    1463             set label [$_first hints label]
    1464             if { $label == "" } {
     1463            set label [$_first hints label]
     1464            if { $label == "" } {
    14651465                if { [string match "component*" $_curFldName] } {
    14661466                    set label Z
     
    14681468                    set label $_curFldLabel
    14691469                }
    1470             }
    1471             # May be a space in the axis label.
    1472             SendCmd [list axis name z $label]
    1473 
    1474             if { [$_first hints zunits] == "" } {
    1475                 set units [lindex $_fields($_curFldName) 1]
    1476             } else {
    1477                 set units [$_first hints zunits]
    1478             }
    1479             if { $units != "" } {
    1480                 # May be a space in the axis units.
    1481                 SendCmd [list axis units z $units]
    1482             }
     1470            }
     1471            # May be a space in the axis label.
     1472            SendCmd [list axis name z $label]
     1473
     1474            if { [$_first hints zunits] == "" } {
     1475                set units [lindex $_fields($_curFldName) 1]
     1476            } else {
     1477                set units [$_first hints zunits]
     1478            }
     1479            if { $units != "" } {
     1480                # May be a space in the axis units.
     1481                SendCmd [list axis units z $units]
     1482            }
    14831483            # Get the new limits because the field changed.
    14841484            ResetAxes
     
    14901490        }
    14911491        "-heightmapscale" {
    1492             if { $_settings(-isheightmap) } {
    1493                 set scale [GetHeightmapScale]
    1494                 # Have to set the datasets individually because we are 
     1492            if { $_settings(-isheightmap) } {
     1493                set scale [GetHeightmapScale]
     1494                # Have to set the datasets individually because we are
    14951495                # tracking them in _comp2scale.
    14961496                foreach dataset [CurrentDatasets -all] {
    1497                     SendCmd "heightmap heightscale $scale $dataset"
    1498                     set _comp2scale($dataset) $scale
    1499                 }
    1500                 ResetAxes
    1501             }
     1497                    SendCmd "heightmap heightscale $scale $dataset"
     1498                    set _comp2scale($dataset) $scale
     1499                }
     1500                ResetAxes
     1501            }
    15021502        }
    15031503        "-isheightmap" {
    1504             set bool $_settings($what)
     1504            set bool $_settings($what)
    15051505            set c $itk_component(view)
    15061506            StartBufferingCommands
     
    15191519            InitSettings -lighting -opacity -outline
    15201520            set scale [GetHeightmapScale]
    1521             # Have to set the datasets individually because we are 
     1521            # Have to set the datasets individually because we are
    15221522            # tracking them in _comp2scale.
    15231523            foreach dataset [CurrentDatasets -all] {
     
    15251525                set _comp2scale($dataset) $scale
    15261526            }
    1527             if { $bool } {
    1528                 $itk_component(lighting) configure -state normal
    1529                 $itk_component(opacity) configure -state normal
    1530                 $itk_component(scale) configure -state normal
    1531                 $itk_component(opacity_l) configure -state normal
    1532                 $itk_component(scale_l) configure -state normal
    1533                 $itk_component(outline) configure -state disabled
     1527            if { $bool } {
     1528                $itk_component(lighting) configure -state normal
     1529                $itk_component(opacity) configure -state normal
     1530                $itk_component(scale) configure -state normal
     1531                $itk_component(opacity_l) configure -state normal
     1532                $itk_component(scale_l) configure -state normal
     1533                $itk_component(outline) configure -state disabled
    15341534                if {$_view(-ortho)} {
    15351535                    SendCmd "camera mode ortho"
     
    15371537                    SendCmd "camera mode persp"
    15381538                }
    1539             } else {
    1540                 $itk_component(lighting) configure -state disabled
    1541                 $itk_component(opacity) configure -state disabled
    1542                 $itk_component(scale) configure -state disabled
    1543                 $itk_component(opacity_l) configure -state disabled
    1544                 $itk_component(scale_l) configure -state disabled
    1545                 $itk_component(outline) configure -state normal
     1539            } else {
     1540                $itk_component(lighting) configure -state disabled
     1541                $itk_component(opacity) configure -state disabled
     1542                $itk_component(scale) configure -state disabled
     1543                $itk_component(opacity_l) configure -state disabled
     1544                $itk_component(scale_l) configure -state disabled
     1545                $itk_component(outline) configure -state normal
    15461546                SendCmd "camera mode image"
    15471547            }
     
    15571557                set q [ViewToQuaternion]
    15581558                $_arcball quaternion $q
    1559                 SendCmd "camera orient $q" 
     1559                SendCmd "camera orient $q"
    15601560            } else {
    15611561                bind $c <ButtonPress-1> {}
     
    15641564            }
    15651565            Zoom reset
    1566             # Fix the mouse bindings for rotation/panning and the 
     1566            # Fix the mouse bindings for rotation/panning and the
    15671567            # camera mode. Ideally we'd create a bindtag for these.
    15681568            if { $bool } {
     
    15791579        "-isolinecolor" {
    15801580            set color [$itk_component(isolinecolor) value]
    1581             if { $color == "none" } {
    1582                 if { $_settings(-isolinesvisible) } {
    1583                     SendCmd "heightmap isolines 0"
    1584                     set _settings(-isolinesvisible) 0
    1585                 }
    1586             } else {
    1587                 if { !$_settings(-isolinesvisible) } {
    1588                     SendCmd "heightmap isolines 1"
    1589                     set _settings(-isolinesvisible) 1
    1590                 }
    1591                 SendCmd "heightmap isolinecolor [Color2RGB $color]"
    1592             }
    1593             DrawLegend
     1581            if { $color == "none" } {
     1582                if { $_settings(-isolinesvisible) } {
     1583                    SendCmd "heightmap isolines 0"
     1584                    set _settings(-isolinesvisible) 0
     1585                }
     1586            } else {
     1587                if { !$_settings(-isolinesvisible) } {
     1588                    SendCmd "heightmap isolines 1"
     1589                    set _settings(-isolinesvisible) 1
     1590                }
     1591                SendCmd "heightmap isolinecolor [Color2RGB $color]"
     1592            }
     1593            DrawLegend
    15941594        }
    15951595        "-isolinesvisible" {
    1596             set bool $_settings($what)
     1596            set bool $_settings($what)
    15971597            SendCmd "heightmap isolines $bool"
    1598             DrawLegend
     1598            DrawLegend
    15991599        }
    16001600        "-legendvisible" {
    16011601            if { !$_settings($what) } {
    1602                 $itk_component(view) delete legend
    1603             }
    1604             DrawLegend
     1602                $itk_component(view) delete legend
     1603            }
     1604            DrawLegend
    16051605        }
    16061606        "-lighting" {
    1607             if { $_settings(-isheightmap) } {
     1607            if { $_settings(-isheightmap) } {
    16081608                set _settings(-savelighting) $_settings($what)
    1609                 set bool $_settings($what)
    1610                 SendCmd "heightmap lighting $bool"
    1611             } else {
    1612                 SendCmd "heightmap lighting 0"
    1613             }
     1609                set bool $_settings($what)
     1610                SendCmd "heightmap lighting $bool"
     1611            } else {
     1612                SendCmd "heightmap lighting 0"
     1613            }
    16141614        }
    16151615        "-numisolines" {
     
    16301630            set _changed($what) 1
    16311631            set val [expr $_settings($what) * 0.01]
    1632             if { $_settings(-isheightmap) } {
     1632            if { $_settings(-isheightmap) } {
    16331633                set _settings(-saveopacity) $_settings($what)
    16341634                SendCmd "heightmap opacity $val"
    16351635            } else {
    1636                 SendCmd "heightmap opacity 1.0"
     1636                SendCmd "heightmap opacity 1.0"
    16371637            }
    16381638        }
    16391639        "-outline" {
    1640             if { $_settings(-isheightmap) } {
    1641                 SendCmd "outline visible 0"
     1640            if { $_settings(-isheightmap) } {
     1641                SendCmd "outline visible 0"
    16421642            } else {
    16431643                set _settings(-saveoutline) $_settings($what)
     
    16451645                SendCmd "outline visible $bool"
    16461646            }
    1647         }
     1647        }
    16481648        "-stretchtofit" {
    1649             set bool $_settings($what)
    1650             if { $bool } {
    1651                 set heightScale [GetHeightmapScale]
    1652                 if {$heightScale == 0} {
    1653                     SendCmd "camera aspect window"
    1654                 } else {
    1655                     SendCmd "camera aspect square"
    1656                 }
    1657             } else {
    1658                 SendCmd "camera aspect native"
    1659             }
     1649            set bool $_settings($what)
     1650            if { $bool } {
     1651                set heightScale [GetHeightmapScale]
     1652                if {$heightScale == 0} {
     1653                    SendCmd "camera aspect window"
     1654                } else {
     1655                    SendCmd "camera aspect square"
     1656                }
     1657            } else {
     1658                SendCmd "camera aspect native"
     1659            }
    16601660            Zoom reset
    1661         }
     1661        }
    16621662        "-wireframe" {
    16631663            set bool $_settings($what)
     
    16691669            SendCmd "axis grid $axis $bool"
    16701670        }
    1671         default {
     1671        default {
    16721672            error "don't know how to fix $what"
    16731673        }
     
    16791679#
    16801680#       Request a new legend from the server.  The size of the legend
    1681 #       is determined from the height of the canvas. 
     1681#       is determined from the height of the canvas.
    16821682#
    16831683# This should be called when
    1684 #       1.  A new current colormap is set.
    1685 #       2.  Window is resized.
    1686 #       3.  The limits of the data have changed.  (Just need a redraw).
    1687 #       4.  Number of isolines have changed. (Just need a redraw).
    1688 #       5.  Legend becomes visible (Just need a redraw).
     1684#        1.  A new current colormap is set.
     1685#        2.  Window is resized.
     1686#        3.  The limits of the data have changed.  (Just need a redraw).
     1687#        4.  Number of isolines have changed. (Just need a redraw).
     1688#        5.  Legend becomes visible (Just need a redraw).
    16891689#
    16901690itcl::body Rappture::VtkHeightmapViewer::RequestLegend {} {
     
    16931693    set w 12
    16941694    set lineht [font metrics $font -linespace]
    1695     # color ramp height = (canvas height) - (min and max value lines) - 2 
     1695    # color ramp height = (canvas height) - (min and max value lines) - 2
    16961696    set h [expr {$_height - 2 * ($lineht + 2)}]
    16971697    set _legendHeight $h
     
    16991699    set fname $_curFldName
    17001700    if { [string match "component*" $fname] } {
    1701         set title ""
     1701        set title ""
    17021702    } else {
    1703         if { [info exists _fields($fname)] } {
    1704             foreach { title units } $_fields($fname) break
    1705             if { $units != "" } {
    1706                 set title [format "%s (%s)" $title $units]
    1707             }
    1708         } else {
    1709             set title $fname
    1710         }
     1703        if { [info exists _fields($fname)] } {
     1704            foreach { title units } $_fields($fname) break
     1705            if { $units != "" } {
     1706                set title [format "%s (%s)" $title $units]
     1707            }
     1708        } else {
     1709            set title $fname
     1710        }
    17111711    }
    17121712    # If there's a title too, substract one more line
    17131713    if { $title != "" } {
    1714         incr h -$lineht 
     1714        incr h -$lineht
    17151715    }
    17161716    if { $h < 1 } {
     
    17191719    # Set the legend on the first heightmap dataset.
    17201720    if { $_currentColormap != ""  } {
    1721         set cmap $_currentColormap
    1722         #SendCmd "legend $cmap scalar $_curFldName {} $w $h 0"
     1721        set cmap $_currentColormap
     1722        #SendCmd "legend $cmap scalar $_curFldName {} $w $h 0"
    17231723        SendCmd "legend2 $cmap $w $h"
    17241724    }
     
    17741774    # Keep track of the colormaps that we build.
    17751775    if { $name != "none" && ![info exists _colormaps($name)] } {
    1776         BuildColormap $name 
     1776        BuildColormap $name
    17771777        set _colormaps($name) 1
    17781778    }
     
    18001800itcl::configbody Rappture::VtkHeightmapViewer::mode {
    18011801    switch -- $itk_option(-mode) {
    1802         "heightmap" {
    1803             set _settings(-isheightmap) 1
    1804         }
    1805         "contour" {
    1806             set _settings(-isheightmap) 0
    1807         }
    1808         default {
    1809             error "unknown mode settings \"$itk_option(-mode)\""
    1810         }
     1802        "heightmap" {
     1803            set _settings(-isheightmap) 1
     1804        }
     1805        "contour" {
     1806            set _settings(-isheightmap) 0
     1807        }
     1808        default {
     1809            error "unknown mode settings \"$itk_option(-mode)\""
     1810        }
    18111811    }
    18121812    if { !$_reset } {
     
    18241824            SendCmd "screen bgcolor $rgb"
    18251825        }
    1826         $itk_component(view) configure -background $itk_option(-plotbackground)
     1826        $itk_component(view) configure -background $itk_option(-plotbackground)
    18271827    }
    18281828}
     
    18641864
    18651865    itk_component add lighting {
    1866         checkbutton $inner.lighting \
    1867             -text "Enable Lighting" \
    1868             -variable [itcl::scope _settings(-lighting)] \
    1869             -command [itcl::code $this AdjustSetting -lighting] \
    1870             -font "Arial 9"
     1866        checkbutton $inner.lighting \
     1867            -text "Enable Lighting" \
     1868            -variable [itcl::scope _settings(-lighting)] \
     1869            -command [itcl::code $this AdjustSetting -lighting] \
     1870            -font "Arial 9"
    18711871    } {
    1872         ignore -font
     1872        ignore -font
    18731873    }
    18741874    checkbutton $inner.edges \
     
    19061906
    19071907    itk_component add field_l {
    1908         label $inner.field_l -text "Field" -font "Arial 9" 
     1908        label $inner.field_l -text "Field" -font "Arial 9"
    19091909    } {
    19101910        ignore -font
     
    19161916        [itcl::code $this AdjustSetting -field]
    19171917
    1918     label $inner.colormap_l -text "Colormap" -font "Arial 9" 
     1918    label $inner.colormap_l -text "Colormap" -font "Arial 9"
    19191919    itk_component add colormap {
    19201920        Rappture::Combobox $inner.colormap -width 10 -editable no
     
    19251925        [itcl::code $this AdjustSetting -colormap]
    19261926
    1927     label $inner.isolinecolor_l -text "Isolines Color" -font "Arial 9" 
     1927    label $inner.isolinecolor_l -text "Isolines Color" -font "Arial 9"
    19281928    itk_component add isolinecolor {
    19291929        Rappture::Combobox $inner.isolinecolor -width 10 -editable no
     
    19391939        "red"                "red"              \
    19401940        "white"              "white"            \
    1941         "none"               "none"
     1941        "none"               "none"
    19421942
    19431943    $itk_component(isolinecolor) value $_settings(-isolinecolor)
    19441944    bind $inner.isolinecolor <<Value>> \
    1945         [itcl::code $this AdjustSetting -isolinecolor]
    1946 
    1947     label $inner.background_l -text "Background Color" -font "Arial 9" 
     1945        [itcl::code $this AdjustSetting -isolinecolor]
     1946
     1947    label $inner.background_l -text "Background Color" -font "Arial 9"
    19481948    itk_component add background {
    19491949        Rappture::Combobox $inner.background -width 10 -editable no
     
    19521952        "black"              "black"            \
    19531953        "white"              "white"            \
    1954         "grey"               "grey"             
     1954        "grey"               "grey"
    19551955
    19561956    $itk_component(background) value "white"
     
    19991999        2,0 $inner.isolinecolor_l  -anchor w -pady 2  \
    20002000        2,1 $inner.isolinecolor    -anchor w -pady 2 -fill x  \
    2001         3,0 $inner.background_l -anchor w -pady 2 \
    2002         3,1 $inner.background -anchor w -pady 2  -fill x \
     2001        3,0 $inner.background_l -anchor w -pady 2 \
     2002        3,1 $inner.background -anchor w -pady 2  -fill x \
    20032003        4,0 $inner.numisolines_l -anchor w -pady 2 \
    20042004        4,1 $inner.numisolines -anchor w -pady 2 \
     
    20422042        -command [itcl::code $this AdjustSetting -axislabels] \
    20432043        -font "Arial 9"
    2044     label $inner.grid_l -text "Grid" -font "Arial 9" 
     2044    label $inner.grid_l -text "Grid" -font "Arial 9"
    20452045    checkbutton $inner.xgrid \
    20462046        -text "X" \
     
    20642064        -font "Arial 9"
    20652065
    2066     label $inner.mode_l -text "Mode" -font "Arial 9" 
     2066    label $inner.mode_l -text "Mode" -font "Arial 9"
    20672067
    20682068    itk_component add axisflymode {
     
    20732073        "closest_triad"   "closest" \
    20742074        "furthest_triad"  "farthest" \
    2075         "outer_edges"     "outer"         
     2075        "outer_edges"     "outer"
    20762076    $itk_component(axisflymode) value $_settings(-axisflymode)
    20772077    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode]
     
    20812081        1,0 $inner.labels  -anchor w -cspan 4 \
    20822082        2,0 $inner.minorticks  -anchor w -cspan 4 \
    2083         4,0 $inner.grid_l  -anchor w \
     2083        4,0 $inner.grid_l  -anchor w \
    20842084        4,1 $inner.xgrid   -anchor w \
    20852085        4,2 $inner.ygrid   -anchor w \
    20862086        4,3 $inner.zgrid   -anchor w \
    20872087        5,0 $inner.mode_l  -anchor w -padx { 2 0 } \
    2088         5,1 $inner.mode    -fill x -cspan 3 
     2088        5,1 $inner.mode    -fill x -cspan 3
    20892089
    20902090    blt::table configure $inner r* c* -resize none
     
    21452145
    21462146#
    2147 #  camera -- 
     2147#  camera --
    21482148#
    21492149itcl::body Rappture::VtkHeightmapViewer::camera {option args} {
    2150     switch -- $option { 
     2150    switch -- $option {
    21512151        "show" {
    21522152            puts [array get _view]
     
    21962196
    21972197itcl::body Rappture::VtkHeightmapViewer::GetImage { args } {
    2198     if { [image width $_image(download)] > 0 && 
     2198    if { [image width $_image(download)] > 0 &&
    21992199         [image height $_image(download)] > 0 } {
    22002200        set bytes [$_image(download) data -format "jpeg -quality 100"]
     
    22092209        -title "[Rappture::filexfer::label downloadWord] as..."
    22102210    set inner [$popup component inner]
    2211     label $inner.summary -text "" -anchor w 
     2211    label $inner.summary -text "" -anchor w
    22122212    radiobutton $inner.vtk_button -text "VTK data file" \
    22132213        -variable [itcl::scope _downloadPopup(format)] \
    22142214        -font "Arial 9 " \
    2215         -value vtk 
     2215        -value vtk
    22162216    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
    22172217    radiobutton $inner.image_button -text "Image File" \
    22182218        -variable [itcl::scope _downloadPopup(format)] \
    22192219        -font "Arial 9 " \
    2220         -value image 
     2220        -value image
    22212221    Rappture::Tooltip::for $inner.image_button \
    22222222        "Save as digital image."
     
    22392239        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
    22402240        4,1 $inner.cancel -width .9i -fill y \
    2241         4,0 $inner.ok -padx 2 -width .9i -fill y 
     2241        4,0 $inner.ok -padx 2 -width .9i -fill y
    22422242    blt::table configure $inner r3 -height 4
    22432243    blt::table configure $inner r4 -pady 4
     
    22502250# SetObjectStyle --
    22512251#
    2252 #       Set the style of the heightmap/contour object.  This gets calls 
     2252#       Set the style of the heightmap/contour object.  This gets calls
    22532253#       for each dataset once as it is loaded.  It can overridden by
    22542254#       the user controls.
     
    23412341        #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
    23422342        if { [catch {DrawLegend} errs] != 0 } {
    2343             global errorInfo
    2344             puts stderr "errs=$errs errorInfo=$errorInfo"
     2343            global errorInfo
     2344            puts stderr "errs=$errs errorInfo=$errorInfo"
    23452345        }
    23462346    }
     
    23592359    set font "Arial 8"
    23602360    set lineht [font metrics $font -linespace]
    2361    
     2361
    23622362    if { [string match "component*" $fname] } {
    2363         set title ""
     2363        set title ""
    23642364    } else {
    2365         if { [info exists _fields($fname)] } {
    2366             foreach { title units } $_fields($fname) break
    2367             if { $units != "" } {
    2368                 set title [format "%s (%s)" $title $units]
    2369             }
    2370         } else {
    2371             set title $fname
    2372         }
     2365        if { [info exists _fields($fname)] } {
     2366            foreach { title units } $_fields($fname) break
     2367            if { $units != "" } {
     2368                set title [format "%s (%s)" $title $units]
     2369            }
     2370        } else {
     2371            set title $fname
     2372        }
    23732373    }
    23742374    set x [expr $w - 2]
    23752375    if { !$_settings(-legendvisible) } {
    2376         $c delete legend
    2377         return
    2378     } 
     2376        $c delete legend
     2377        return
     2378    }
    23792379    if { [$c find withtag "legend"] == "" } {
    2380         set y 2
    2381         # If there's a legend title, create a text item for the title.
     2380        set y 2
     2381        # If there's a legend title, create a text item for the title.
    23822382        $c create text $x $y \
    23832383            -anchor ne \
     
    23872387            incr y $lineht
    23882388        }
    2389         $c create text $x $y \
     2389        $c create text $x $y \
    23902390            -anchor ne \
    23912391            -fill $itk_option(-plotforeground) -tags "vmax legend" \
    23922392            -font $font
    23932393        incr y $lineht
    2394         $c create image $x $y \
    2395             -anchor ne \
    2396             -image $_image(legend) -tags "colormap legend"
    2397         $c create rectangle $x $y 1 1 \
    2398             -fill "" -outline "" -tags "sensor legend"
    2399         $c create text $x [expr {$h-2}] \
    2400             -anchor se \
    2401             -fill $itk_option(-plotforeground) -tags "vmin legend" \
    2402             -font $font
    2403         $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
    2404         $c bind sensor <Leave> [itcl::code $this LeaveLegend]
    2405         $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
     2394        $c create image $x $y \
     2395            -anchor ne \
     2396            -image $_image(legend) -tags "colormap legend"
     2397        $c create rectangle $x $y 1 1 \
     2398            -fill "" -outline "" -tags "sensor legend"
     2399        $c create text $x [expr {$h-2}] \
     2400            -anchor se \
     2401            -fill $itk_option(-plotforeground) -tags "vmin legend" \
     2402            -font $font
     2403        $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
     2404        $c bind sensor <Leave> [itcl::code $this LeaveLegend]
     2405        $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
    24062406    }
    24072407    $c delete isoline
     
    24142414    # Draw the isolines on the legend.
    24152415    array unset _isolines
    2416     if { $color != "none"  && [info exists _limits($_curFldName)] && 
     2416    if { $color != "none"  && [info exists _limits($_curFldName)] &&
    24172417         $_settings(-isolinesvisible) && $_currentNumIsolines > 0 } {
    24182418
     
    24232423        }
    24242424        set tags "isoline legend"
    2425         set offset [expr 2 + $lineht]
    2426         if { $title != "" } {
    2427             incr offset $lineht
    2428         }
     2425        set offset [expr 2 + $lineht]
     2426        if { $title != "" } {
     2427            incr offset $lineht
     2428        }
    24292429        foreach value $_contourList {
    24302430            set norm [expr 1.0 - (($value - $vmin) / $range)]
     
    24342434                set _isolines([expr $y1 - $off]) $value
    24352435            }
    2436             $c create line $x1 $y1 $x2 $y1 -fill $color -tags $tags
    2437         }
     2436            $c create line $x1 $y1 $x2 $y1 -fill $color -tags $tags
     2437        }
    24382438    }
    24392439
     
    24442444    if { [info exists _limits($_curFldName)] } {
    24452445        foreach { vmin vmax } $_limits($_curFldName) break
    2446         $c itemconfigure vmin -text [format %g $vmin]
    2447         $c itemconfigure vmax -text [format %g $vmax]
     2446        $c itemconfigure vmin -text [format %g $vmin]
     2447        $c itemconfigure vmax -text [format %g $vmax]
    24482448    }
    24492449    set y 2
     
    24512451    if { $title != "" } {
    24522452        $c itemconfigure title -text $title
    2453         $c coords title $x $y
    2454         incr y $lineht
     2453        $c coords title $x $y
     2454        incr y $lineht
    24552455    }
    24562456    $c coords vmax $x $y
     
    25002500    set font "Arial 8"
    25012501    set lineht [font metrics $font -linespace]
    2502    
     2502
    25032503    set ih [image height $_image(legend)]
    25042504    # Subtract off the offset of the color ramp from the top of the canvas
     
    25062506
    25072507    if { [string match "component*" $fname] } {
    2508         set title ""
     2508        set title ""
    25092509    } else {
    2510         if { [info exists _fields($fname)] } {
    2511             foreach { title units } $_fields($fname) break
    2512             if { $units != "" } {
    2513                 set title [format "%s (%s)" $title $units]
    2514             }
    2515         } else {
    2516             set title $fname
    2517         }
     2510        if { [info exists _fields($fname)] } {
     2511            foreach { title units } $_fields($fname) break
     2512            if { $units != "" } {
     2513                set title [format "%s (%s)" $title $units]
     2514            }
     2515        } else {
     2516            set title $fname
     2517        }
    25182518    }
    25192519    # If there's a legend title, increase the offset by the line height.
     
    25312531    }
    25322532    set color [eval format "\#%02x%02x%02x" $pixel]
    2533     $_image(swatch) put black  -to 0 0 23 23 
    2534     $_image(swatch) put $color -to 1 1 22 22 
     2533    $_image(swatch) put black  -to 0 0 23 23
     2534    $_image(swatch) put $color -to 1 1 22 22
    25352535
    25362536    # Compute the value of the point
     
    25422542        set value 0.0
    25432543    }
    2544     set tipx [expr $x + 15] 
     2544    set tipx [expr $x + 15]
    25452545    set tipy [expr $y - 5]
    25462546    .rappturetooltip configure -icon $_image(swatch)
     
    25502550        Rappture::Tooltip::text $c [format "$title %g" $value]
    25512551    }
    2552     Rappture::Tooltip::tooltip show $c +$tipx,+$tipy   
     2552    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy
    25532553}
    25542554
     
    25652565# ----------------------------------------------------------------------
    25662566itcl::body Rappture::VtkHeightmapViewer::Combo {option} {
    2567     set c $itk_component(view) 
     2567    set c $itk_component(view)
    25682568    switch -- $option {
    25692569        post {
     
    25782578        }
    25792579        deactivate {
    2580             $c itemconfigure title -fill $itk_option(-plotforeground) 
     2580            $c itemconfigure title -fill $itk_option(-plotforeground)
    25812581        }
    25822582        invoke {
     
    25922592itcl::body Rappture::VtkHeightmapViewer::GetHeightmapScale {} {
    25932593    if {  $_settings(-isheightmap) } {
    2594         set val $_settings(-heightmapscale)
    2595         set sval [expr { $val >= 50 ? double($val)/50.0 : 1.0/(2.0-(double($val)/50.0)) }]
    2596         return $sval
    2597     }
    2598     return 0 
    2599 }
    2600 
    2601 itcl::body Rappture::VtkHeightmapViewer::SetOrientation { side } { 
     2594        set val $_settings(-heightmapscale)
     2595        set sval [expr { $val >= 50 ? double($val)/50.0 : 1.0/(2.0-(double($val)/50.0)) }]
     2596        return $sval
     2597    }
     2598    return 0
     2599}
     2600
     2601itcl::body Rappture::VtkHeightmapViewer::SetOrientation { side } {
    26022602    array set positions {
    26032603        front  "0.707107 0.707107 0 0"
     
    26102610    foreach name { -qw -qx -qy -qz } value $positions($side) {
    26112611        set _view($name) $value
    2612     } 
     2612    }
    26132613    set q [ViewToQuaternion]
    26142614    $_arcball quaternion $q
     
    26202620}
    26212621
    2622 itcl::body Rappture::VtkHeightmapViewer::UpdateContourList {} { 
     2622itcl::body Rappture::VtkHeightmapViewer::UpdateContourList {} {
    26232623    if {$_currentNumIsolines == 0} {
    26242624        set _contourList ""
Note: See TracChangeset for help on using the changeset viewer.