Changeset 1254


Ignore:
Timestamp:
Dec 3, 2008, 2:32:26 PM (16 years ago)
Author:
dkearney
Message:

tabs

File:
1 edited

Legend:

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

    r1250 r1254  
    1 
    2 # ----------------------------------------------------------------------
     1#!/usr/bin/wish
     2# ----------------------------------------------------------------------
     3
     4
    35#  COMPONENT: nanovisviewer - 3D volume rendering
    46#
     
    3739itcl::class Rappture::NanovisViewer {
    3840    inherit Rappture::VisViewer
    39  
     41
    4042    itk_option define -plotforeground plotForeground Foreground ""
    4143    itk_option define -plotbackground plotBackground Background ""
    4244    itk_option define -plotoutline plotOutline PlotOutline ""
    43    
    44     constructor { hostlist args } { 
    45         Rappture::VisViewer::constructor $hostlist 
    46     } { 
    47         # defined below 
    48     }
    49     destructor { 
    50         # defined below 
     45
     46    constructor { hostlist args } {
     47        Rappture::VisViewer::constructor $hostlist
     48    } {
     49        # defined below
     50    }
     51    destructor {
     52        # defined below
    5153    }
    5254    public proc SetServerList { namelist } {
    53         Rappture::VisViewer::SetServerList "nanovis" $namelist
     55        Rappture::VisViewer::SetServerList "nanovis" $namelist
    5456    }
    5557    public method add {dataobj {settings ""}}
     
    5759    public method delete {args}
    5860    public method scale {args}
    59     public method GetLimits { tf } 
     61    public method GetLimits { tf }
    6062    public method download {option args}
    61     public method parameters {title args} { 
    62         # do nothing 
     63    public method parameters {title args} {
     64        # do nothing
    6365    }
    6466    public method isconnected {}
     
    9395    protected method _fixLegend {}
    9496
    95     # The following methods are only used by this class. 
     97    # The following methods are only used by this class.
    9698    private method _NameTransferFunction { ivol }
    9799    private method _ComputeTransferFunction { tf }
     
    119121    private variable isomarkers_    ;# array of isosurface level values 0..1
    120122    private common   settings_
    121     private variable activeTf_ ""  ;# The currently active transfer function. 
    122                                     # This
    123                                     # indicates which isomarkers and transfer
    124                                     # function to use when changing markers,
    125                                     # opacity, or thickness.
     123    private variable activeTf_ ""  ;# The currently active transfer function.
     124    # This
     125    # indicates which isomarkers and transfer
     126    # function to use when changing markers,
     127    # opacity, or thickness.
    126128    #common _downloadPopup          ;# download options from popup
    127129}
     
    500502    # Bindings for zoom via keyboard
    501503    bind $itk_component(3dview) <KeyPress-Prior> \
    502         [itcl::code $this _zoom out]
     504        [itcl::code $this _zoom out]
    503505    bind $itk_component(3dview) <KeyPress-Next> \
    504         [itcl::code $this _zoom in]
     506        [itcl::code $this _zoom in]
    505507
    506508    bind $itk_component(3dview) <Enter> "focus $itk_component(3dview)"
    507509
    508510    if {[string equal "x11" [tk windowingsystem]]} {
    509         # Bindings for zoom via mouse
    510         bind $itk_component(3dview) <4> [itcl::code $this _zoom out]
    511         bind $itk_component(3dview) <5> [itcl::code $this _zoom in]
     511        # Bindings for zoom via mouse
     512        bind $itk_component(3dview) <4> [itcl::code $this _zoom out]
     513        bind $itk_component(3dview) <5> [itcl::code $this _zoom in]
    512514    }
    513515
     
    626628# USAGE: delete ?<dataobj1> <dataobj2> ...?
    627629#
    628 #       Clients use this to delete a dataobj from the plot.  If no dataobjs
    629 #       are specified, then all dataobjs are deleted.  No data objects are
    630 #       deleted.  They are only removed from the display list.
     630#       Clients use this to delete a dataobj from the plot.  If no dataobjs
     631#       are specified, then all dataobjs are deleted.  No data objects are
     632#       deleted.  They are only removed from the display list.
    631633#
    632634# ----------------------------------------------------------------------
     
    737739    set result [VisViewer::Connect $_hosts]
    738740    if { $result } {
    739         set w [winfo width $itk_component(3dview)]
    740         set h [winfo height $itk_component(3dview)]
    741         _send "screen $w $h"
     741        set w [winfo width $itk_component(3dview)]
     742        set h [winfo height $itk_component(3dview)]
     743        _send "screen $w $h"
    742744    }
    743745    return $result
     
    782784        append outbuf_ $string "\n"
    783785    } else {
    784         foreach line [split $string \n] {
    785             SendEcho >>line $line
    786         }
     786        foreach line [split $string \n] {
     787            SendEcho >>line $line
     788        }
    787789        SendBytes $string
    788790    }
     
    814816            set _id2obj($ivol) [list $dataobj $comp]
    815817            set _obj2id($dataobj-$comp) $ivol
    816             _NameTransferFunction $ivol
     818            _NameTransferFunction $ivol
    817819            set _receiveids($ivol) 1
    818820        }
     
    828830            _send "up $axis"
    829831        }
    830         # The active transfer function is by default the first component of
    831         # the first data object.  This assumes that the data is always
    832         # successfully transferred.
    833         set comp [lindex [$first components] 0]
    834         set activeTf_ $_id2style($_obj2id($first-$comp))
     832        # The active transfer function is by default the first component of
     833        # the first data object.  This assumes that the data is always
     834        # successfully transferred.
     835        set comp [lindex [$first components] 0]
     836        set activeTf_ $_id2style($_obj2id($first-$comp))
    835837    }
    836838    foreach key [array names _obj2id *-*] {
    837839        set state [string match $first-* $key]
    838         set ivol $_obj2id($key)
     840        set ivol $_obj2id($key)
    839841        _send "volume state $state $ivol"
    840842    }
     
    850852
    851853    if 0 {
    852         # Add this when we fix grid for volumes
     854    # Add this when we fix grid for volumes
    853855    _send "volume axis label x \"\""
    854856    _send "volume axis label y \"\""
     
    868870itcl::body Rappture::NanovisViewer::_SendTransferFunctions {} {
    869871    if { $activeTf_ == "" } {
    870         return
     872        return
    871873    }
    872874    set tf $activeTf_
     
    886888
    887889    if { ![info exists $_obj2styles($first)] } {
    888         foreach tf $_obj2styles($first) {
    889             _ComputeTransferFunction $tf
    890         }
    891         _fixLegend
     890        foreach tf $_obj2styles($first) {
     891            _ComputeTransferFunction $tf
     892        }
     893        _fixLegend
    892894    }
    893895}
     
    903905itcl::body Rappture::NanovisViewer::_ReceiveImage {option size} {
    904906    if { [isconnected] } {
    905         global counter
    906         incr counter
     907        global counter
     908        incr counter
    907909        set bytes [ReceiveBytes $size]
    908910        $_image(plot) configure -data $bytes
     
    914916# _ReceiveLegend --
    915917#
    916 #       The procedure is the response from the render server to each "legend"
    917 #       command.  The server sends back a "legend" command invoked our
    918 #       the slave interpreter.  The purpose is to collect data of the image
    919 #       representing the legend in the canvas.  In addition, the isomarkers
    920 #       of the active transfer function are displayed.
    921 #
    922 #       I don't know is this is the right place to display the isomarkers.
    923 #       I don't know all the different paths used to draw the plot. There's
    924 #       "_rebuild", "add", etc.
     918#       The procedure is the response from the render server to each "legend"
     919#       command.  The server sends back a "legend" command invoked our
     920#       the slave interpreter.  The purpose is to collect data of the image
     921#       representing the legend in the canvas.  In addition, the isomarkers
     922#       of the active transfer function are displayed.
     923#
     924#       I don't know is this is the right place to display the isomarkers.
     925#       I don't know all the different paths used to draw the plot. There's
     926#       "_rebuild", "add", etc.
    925927#
    926928itcl::body Rappture::NanovisViewer::_ReceiveLegend { tf vmin vmax size } {
    927929    if { ![isconnected] } {
    928         return
     930        return
    929931    }
    930932    set bytes [ReceiveBytes $size]
    931933    $_image(legend) configure -data $bytes
    932934    ReceiveEcho <<line "<read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
    933    
     935
    934936    set c $itk_component(legend)
    935937    set w [winfo width $c]
     
    939941    set ly [expr {$h - 1}]
    940942    if {"" == [$c find withtag transfunc]} {
    941         $c create image 10 10 -anchor nw \
    942             -image $_image(legend) -tags transfunc
    943         $c create text $lx $ly -anchor sw \
    944             -fill $itk_option(-plotforeground) -tags "limits vmin"
    945         $c create text [expr {$w-$lx}] $ly -anchor se \
    946             -fill $itk_option(-plotforeground) -tags "limits vmax"
    947         $c lower transfunc
    948         $c bind transfunc <ButtonRelease-1> \
    949             [itcl::code $this _AddIsoMarker %x %y]
     943        $c create image 10 10 -anchor nw \
     944            -image $_image(legend) -tags transfunc
     945        $c create text $lx $ly -anchor sw \
     946            -fill $itk_option(-plotforeground) -tags "limits vmin"
     947        $c create text [expr {$w-$lx}] $ly -anchor se \
     948            -fill $itk_option(-plotforeground) -tags "limits vmax"
     949        $c lower transfunc
     950        $c bind transfunc <ButtonRelease-1> \
     951            [itcl::code $this _AddIsoMarker %x %y]
    950952    }
    951953    # Display the markers used by the active transfer function.
     
    955957    $c itemconfigure vmin -text [format %.2g $limits(min)]
    956958    $c coords vmin $lx $ly
    957    
     959
    958960    $c itemconfigure vmax -text [format %.2g $limits(max)]
    959961    $c coords vmax [expr {$w-$lx}] $ly
    960962
    961963    if { [info exists isomarkers_($tf)] } {
    962         foreach m $isomarkers_($tf) {
    963             $m Show
    964         }
     964        foreach m $isomarkers_($tf) {
     965            $m Show
     966        }
    965967    }
    966968}
     
    969971# _ReceiveData --
    970972#
    971 #       The procedure is the response from the render server to each "data
    972 #       follows" command.  The server sends back a "data" command invoked our
    973 #       the slave interpreter.  The purpose is to collect the min/max of the
    974 #       volume sent to the render server.  Since the client (nanovisviewer)
    975 #       doesn't parse 3D data formats, we rely on the server (nanovis) to
    976 #       tell us what the limits are.  Once we've received the limits to all
    977 #       the data we've sent (tracked by _receiveids) we can then determine
    978 #       what the transfer functions are for these volumes.
    979 #
    980 #
    981 #       Note: There is a considerable tradeoff in having the server report
    982 #             back what the data limits are.  It means that much of the code
    983 #             having to do with transfer-functions has to wait for the data
    984 #             to come back, since the isomarkers are calculated based upon
    985 #             the data limits.  The client code is much messier because of
    986 #             this.  The alternative is to parse any of the 3D formats on the
    987 #             client side. 
     973#       The procedure is the response from the render server to each "data
     974#       follows" command.  The server sends back a "data" command invoked our
     975#       the slave interpreter.  The purpose is to collect the min/max of the
     976#       volume sent to the render server.  Since the client (nanovisviewer)
     977#       doesn't parse 3D data formats, we rely on the server (nanovis) to
     978#       tell us what the limits are.  Once we've received the limits to all
     979#       the data we've sent (tracked by _receiveids) we can then determine
     980#       what the transfer functions are for these volumes.
     981#
     982#
     983#       Note: There is a considerable tradeoff in having the server report
     984#             back what the data limits are.  It means that much of the code
     985#             having to do with transfer-functions has to wait for the data
     986#             to come back, since the isomarkers are calculated based upon
     987#             the data limits.  The client code is much messier because of
     988#             this.  The alternative is to parse any of the 3D formats on the
     989#             client side.
    988990#
    989991itcl::body Rappture::NanovisViewer::_ReceiveData { args } {
    990992    if { ![isconnected] } {
    991         return
     993        return
    992994    }
    993995    # Arguments from server are name value pairs. Stuff them in an array.
    994996    array set info $args
    995997
    996     set ivol $info(id);                 # Id of volume created by server.
    997 
    998     set limits_($ivol-min) $info(min);  # Minimum value of the volume.
    999     set limits_($ivol-max) $info(max);  # Maximum value of the volume.
    1000     set limits_(vmin)      $info(vmin); # Overall minimum value.
    1001     set limits_(vmax)      $info(vmax); # Overall maximum value.
     998    set ivol $info(id);         # Id of volume created by server.
     999
     1000    set limits_($ivol-min) $info(min);  # Minimum value of the volume.
     1001    set limits_($ivol-max) $info(max);  # Maximum value of the volume.
     1002    set limits_(vmin)      $info(vmin); # Overall minimum value.
     1003    set limits_(vmax)      $info(vmax); # Overall maximum value.
    10021004
    10031005    unset _receiveids($ivol)
    10041006    if { [array size _receiveids] == 0 } {
    1005         UpdateTransferFunctions
     1007        UpdateTransferFunctions
    10061008    }
    10071009}
     
    10171019    if { [isconnected] } {
    10181020        set bytes [ReceiveBytes $size]
    1019         set f [open /tmp/junk "w"]
    1020         puts $f $bytes
    1021         close $f
     1021        set f [open /tmp/junk "w"]
     1022        puts $f $bytes
     1023        close $f
    10221024        $_image(download) configure -data $bytes
    1023         update
     1025        update
    10241026        puts stderr "<read $size bytes for [image width $_image(download)]x[image height $_image(download)] image>"
    10251027    }
     
    10381040
    10391041    foreach tf [array names isomarkers_] {
    1040         foreach m $isomarkers_($tf) {
     1042        foreach m $isomarkers_($tf) {
    10411043            $m Hide
    10421044        }
     
    10501052    # Find any new data that needs to be sent to the server.  Queue this up on
    10511053    # the _sendobjs list, and send it out a little at a time.  Do this first,
    1052     # before we rebuild the rest. 
     1054    # before we rebuild the rest.
    10531055    foreach dataobj [get] {
    10541056        set comp [lindex [$dataobj components] 0]
     
    10701072    _send "camera angle $xyz"
    10711073    _send "camera zoom $view_(zoom)"
    1072    
     1074
    10731075    _fixSettings light
    10741076    _fixSettings transp
    1075     _fixSettings isosurface 
     1077    _fixSettings isosurface
    10761078    _fixSettings grid
    10771079    _fixSettings axes
     
    10811083        # send off new data objects
    10821084        $_dispatcher event -idle !send_dataobjs
    1083         return
    1084     } 
     1085        return
     1086    }
    10851087
    10861088    # nothing to send -- activate the proper ivol
    10871089    set first [lindex [get] 0]
    10881090    if {"" != $first} {
    1089         set axis [$first hints updir]
    1090         if {"" != $axis} {
    1091             _send "up $axis"
    1092         }
    1093         foreach key [array names _obj2id *-*] {
    1094             set state [string match $first-* $key]
    1095             _send "volume state $state $_obj2id($key)"
    1096         }
    1097         #
    1098         # The _obj2id and _id2style arrays may or may not have the right
    1099         # information.  It's possible for the server to know about volumes
    1100         # that the client has assumed it's deleted.  We could add checks.
    1101         # But this problem needs to be fixed not bandaided. 
    1102         set comp [lindex [$first components] 0]
    1103         set ivol $_obj2id($first-$comp)
    1104        
    1105         foreach comp [$first components] {
    1106             foreach ivol $_obj2id($first-$comp) {
    1107                 _NameTransferFunction $ivol
    1108             }
    1109         }
     1091        set axis [$first hints updir]
     1092        if {"" != $axis} {
     1093            _send "up $axis"
     1094        }
     1095        foreach key [array names _obj2id *-*] {
     1096            set state [string match $first-* $key]
     1097            _send "volume state $state $_obj2id($key)"
     1098        }
     1099        #
     1100        # The _obj2id and _id2style arrays may or may not have the right
     1101        # information.  It's possible for the server to know about volumes
     1102        # that the client has assumed it's deleted.  We could add checks.
     1103        # But this problem needs to be fixed not bandaided.
     1104        set comp [lindex [$first components] 0]
     1105        set ivol $_obj2id($first-$comp)
     1106
     1107        foreach comp [$first components] {
     1108            foreach ivol $_obj2id($first-$comp) {
     1109            _NameTransferFunction $ivol
     1110            }
     1111        }
    11101112    }
    11111113
     
    11131115    set vols [_currentVolumeIds -cutplanes]
    11141116    foreach axis {x y z} {
    1115         _send "cutplane state [_state ${axis}slice] $axis $vols"
    1116         set pos [expr {0.01*[$itk_component(${axis}slicer) get]}]
    1117         _send "cutplane position $pos $axis $vols"
     1117        _send "cutplane state [_state ${axis}slice] $axis $vols"
     1118        set pos [expr {0.01*[$itk_component(${axis}slicer) get]}]
     1119        _send "cutplane position $pos $axis $vols"
    11181120    }
    11191121    _send "volume data state [_state volume] $vols"
     
    11701172                psi 0
    11711173                zoom 1.0
    1172                 dx 0
    1173                 dy 0
     1174                dx 0
     1175                dy 0
    11741176            }
    11751177            set xyz [Euler2XYZ $view_(theta) $view_(phi) $view_(psi)]
     
    12641266# USAGE: $this _pan click x y
    12651267#        $this _pan drag x y
    1266 #        $this _pan release x y
     1268#        $this _pan release x y
    12671269#
    12681270# Called automatically when the user clicks on one of the zoom
     
    12741276    set h [winfo height $itk_component(3dview)]
    12751277    if { $option == "set" } {
    1276         set x [expr $x / double($w)]
    1277         set y [expr $y / double($h)]
    1278         set view_(dx) [expr $view_(dx) + $x]
    1279         set view_(dy) [expr $view_(dy) + $y]
     1278        set x [expr $x / double($w)]
     1279        set y [expr $y / double($h)]
     1280        set view_(dx) [expr $view_(dx) + $x]
     1281        set view_(dy) [expr $view_(dy) + $y]
    12801282        _send "camera pan $view_(dx) $view_(dy)"
    1281         return
    1282     }
    1283     if { $option == "click" } { 
    1284         set click_(x) $x
    1285         set click_(y) $y
     1283        return
     1284    }
     1285    if { $option == "click" } {
     1286        set click_(x) $x
     1287        set click_(y) $y
    12861288        $itk_component(3dview) configure -cursor hand1
    12871289    }
    12881290    if { $option == "drag" || $option == "release" } {
    1289         set dx [expr ($click_(x) - $x)/double($w)]
    1290         set dy [expr ($click_(y) - $y)/double($h)]
    1291         set click_(x) $x
    1292         set click_(y) $y
    1293         set view_(dx) [expr $view_(dx) - $dx]
    1294         set view_(dy) [expr $view_(dy) - $dy]
    1295         _send "camera pan $view_(dx) $view_(dy)"
     1291        set dx [expr ($click_(x) - $x)/double($w)]
     1292        set dy [expr ($click_(y) - $y)/double($h)]
     1293        set click_(x) $x
     1294        set click_(y) $y
     1295        set view_(dx) [expr $view_(dx) - $dx]
     1296        set view_(dy) [expr $view_(dy) - $dy]
     1297        _send "camera pan $view_(dx) $view_(dy)"
    12961298    }
    12971299    if { $option == "release" } {
     
    13471349
    13481350            # show the current value in the readout
    1349             #puts "readout: $axis = $newval"
     1351            #puts "readout: $axis = $newval"
    13501352
    13511353            set ids [_currentVolumeIds -cutplanes]
     
    14351437        opacity {
    14361438            if {[isconnected] && $activeTf_ != "" } {
    1437                 set val [$inner.scales.opacity get]
    1438                 set sval [expr { 0.01 * double($val) }]
    1439                 set tf $activeTf_
    1440                 set settings_($this-$tf-opacity) $sval
    1441                 UpdateTransferFunctions
    1442             }
     1439                set val [$inner.scales.opacity get]
     1440                set sval [expr { 0.01 * double($val) }]
     1441                set tf $activeTf_
     1442                set settings_($this-$tf-opacity) $sval
     1443                UpdateTransferFunctions
     1444            }
    14431445        }
    14441446
    14451447        thickness {
    14461448            if {[isconnected] && $activeTf_ != "" } {
    1447                 set val [$inner.scales.thickness get]
    1448                 # Scale values between 0.00001 and 0.01000
    1449                 set sval [expr {0.0001*double($val)}]
    1450                 set tf $activeTf_
    1451                 set settings_($this-$tf-thickness) $sval
    1452                 UpdateTransferFunctions
    1453             }
     1449                set val [$inner.scales.thickness get]
     1450                # Scale values between 0.00001 and 0.01000
     1451                set sval [expr {0.0001*double($val)}]
     1452                set tf $activeTf_
     1453                set settings_($this-$tf-thickness) $sval
     1454                UpdateTransferFunctions
     1455            }
    14541456        }
    14551457        "outline" {
     
    14571459                _send "volume outline state $settings_($this-outline)"
    14581460            }
    1459         }           
     1461        }
    14601462        "isosurface" {
    14611463            if {[isconnected]} {
    14621464                _send "volume shading isosurface $settings_($this-isosurface)"
    14631465            }
    1464         }           
     1466        }
    14651467        "grid" {
    14661468            if { [isconnected] } {
     
    14931495        _send "legend $activeTf_ $w $h"
    14941496    } else {
    1495         # Can't do this as this will remove the items associated with the
    1496         # isomarkers. 
    1497 
    1498         #$itk_component(legend) delete all
     1497    # Can't do this as this will remove the items associated with the
     1498    # isomarkers.
     1499
     1500    #$itk_component(legend) delete all
    14991501    }
    15001502}
     
    15031505# _NameTransferFunction --
    15041506#
    1505 #       Creates a transfer function name based on the <style> settings in the
    1506 #       library run.xml file. This placeholder will be used later to create
    1507 #       and send the actual transfer function once the data info has been sent
    1508 #       to us by the render server. [We won't know the volume limits until the
    1509 #       server parses the 3D data and sends back the limits via _ReceiveData.]
    1510 #
    1511 #       FIXME: The current way we generate transfer-function names completely
    1512 #             ignores the -markers option.  The problem is that we are forced
    1513 #             to compute the name from an increasing complex set of values:
    1514 #             color, levels, marker, opacity.  I think we're stuck doing it
    1515 #             now.
     1507#       Creates a transfer function name based on the <style> settings in the
     1508#       library run.xml file. This placeholder will be used later to create
     1509#       and send the actual transfer function once the data info has been sent
     1510#       to us by the render server. [We won't know the volume limits until the
     1511#       server parses the 3D data and sends back the limits via _ReceiveData.]
     1512#
     1513#       FIXME: The current way we generate transfer-function names completely
     1514#              ignores the -markers option.  The problem is that we are forced
     1515#              to compute the name from an increasing complex set of values:
     1516#              color, levels, marker, opacity.  I think we're stuck doing it
     1517#              now.
    15161518#
    15171519itcl::body Rappture::NanovisViewer::_NameTransferFunction { ivol } {
     
    15331535# _ComputeTransferFunction --
    15341536#
    1535 #       Computes and sends the transfer function to the render server.  It's
    1536 #       assumed that the volume data limits are known and that the global
    1537 #       transfer-functions slider values have be setup.  Both parts are
    1538 #       needed to compute the relative value (location) of the marker, and
    1539 #       the alpha map of the transfer function. 
     1537#   Computes and sends the transfer function to the render server.  It's
     1538#   assumed that the volume data limits are known and that the global
     1539#   transfer-functions slider values have be setup.  Both parts are
     1540#   needed to compute the relative value (location) of the marker, and
     1541#   the alpha map of the transfer function.
    15401542#
    15411543itcl::body Rappture::NanovisViewer::_ComputeTransferFunction { tf } {
    15421544    array set style {
    1543         -color rainbow
    1544         -levels 6
    1545         -opacity 1.0
     1545        -color rainbow
     1546        -levels 6
     1547        -opacity 1.0
    15461548    }
    15471549    set dataobj ""; set comp ""
     
    15631565    # maintain a list of markers for each transfer-function.  We use the one
    15641566    # of the volumes (the first in the list) using the transfer-function as a
    1565     # reference. 
     1567    # reference.
    15661568    #
    15671569    # FIXME: The current way we generate transfer-function names completely
    1568     #        ignores the -markers option.  The problem is that we are forced
     1570    #        ignores the -markers option.  The problem is that we are forced
    15691571    #        to compute the name from an increasing complex set of values:
    15701572    #        color, levels, marker, opacity.  I think the cow's out of the
    1571     #        barn on this one.
     1573    #        barn on this one.
    15721574
    15731575    if { ![info exists isomarkers_($tf)] } {
    1574         # Have to defer creation of isomarkers until we have data limits
    1575         if { [info exists style(-markers)] } {
    1576             _ParseMarkersOption $tf $ivol $style(-markers)
    1577         } else {
    1578             _ParseLevelsOption $tf $ivol $style(-levels)
    1579         }
    1580     } 
     1576        # Have to defer creation of isomarkers until we have data limits
     1577        if { [info exists style(-markers)] } {
     1578            _ParseMarkersOption $tf $ivol $style(-markers)
     1579        } else {
     1580            _ParseLevelsOption $tf $ivol $style(-levels)
     1581        }
     1582    }
    15811583    if {$style(-color) == "rainbow"} {
    15821584        set style(-color) "white:yellow:green:cyan:blue:magenta"
     
    15931595    set tag $this-$tf
    15941596    if { ![info exists settings_($tag-opacity)] } {
    1595         set settings_($tag-opacity) $style(-opacity)
     1597        set settings_($tag-opacity) $style(-opacity)
    15961598    }
    15971599    set max $settings_($tag-opacity)
     
    16051607
    16061608    if { ![info exists settings_($tag-thickness)]} {
    1607         set settings_($tag-thickness) 0.05
     1609        set settings_($tag-thickness) 0.05
    16081610    }
    16091611    set delta $settings_($tag-thickness)
     
    16211623        set x4 [expr {$x+$delta+0.00001}]
    16221624        if { $x1 < 0.0 } {
    1623             set x1 0.0 
     1625            set x1 0.0
    16241626        } elseif { $x1 > 1.0 } {
    1625             set x1 1.0
    1626         }
     1627            set x1 1.0
     1628        }
    16271629        if { $x2 < 0.0 } {
    16281630            set x2 0.0
    16291631        } elseif { $x2 > 1.0 } {
    1630             set x2 1.0
    1631         }
     1632            set x2 1.0
     1633        }
    16321634        if { $x3 < 0.0 } {
    1633             set x3 0.0 
     1635            set x3 0.0
    16341636        } elseif { $x3 > 1.0 } {
    1635             set x3 1.0
    1636         }
     1637            set x3 1.0
     1638        }
    16371639        if { $x4 < 0.0 } {
    1638             set x4 0.0 
    1639         } elseif { $x4 > 1.0 } {
    1640             set x4 1.0
     1640            set x4 0.0
     1641        } elseif { $x4 > 1.0 } {
     1642            set x4 1.0
    16411643        }
    16421644        # add spikes in the middle
    1643         lappend wmap $x1 0.0 
     1645        lappend wmap $x1 0.0
    16441646        lappend wmap $x2 $max
    1645         lappend wmap $x3 $max 
     1647        lappend wmap $x3 $max
    16461648        lappend wmap $x4 0.0
    16471649    }
     
    17021704    regsub -all "," $levels " " levels
    17031705    if {[string is int $levels]} {
    1704         for {set i 1} { $i <= $levels } {incr i} {
    1705             set x [expr {double($i)/($levels+1)}]
    1706             set m [IsoMarker \#auto $c $this $tf]
    1707             $m SetRelativeValue $x
    1708             lappend isomarkers_($tf) $m
    1709         }
     1706        for {set i 1} { $i <= $levels } {incr i} {
     1707            set x [expr {double($i)/($levels+1)}]
     1708            set m [IsoMarker \#auto $c $this $tf]
     1709            $m SetRelativeValue $x
     1710            lappend isomarkers_($tf) $m
     1711        }
    17101712    } else {
    17111713        foreach x $levels {
    1712             set m [IsoMarker \#auto $c $this $tf]
    1713             $m SetRelativeValue $x
    1714             lappend isomarkers_($tf) $m
     1714            set m [IsoMarker \#auto $c $this $tf]
     1715            $m SetRelativeValue $x
     1716            lappend isomarkers_($tf) $m
    17151717        }
    17161718    }
     
    17221724# format:
    17231725#
    1724 #       N%      Percent of current total data range.  Converted to
    1725 #               to a relative value between 0.0 and 1.0.
    1726 #       N       Absolute value of marker.  If the marker is outside of
    1727 #               the current range, it will be displayed on the outer
    1728 #               edge of the legends, but it range it represents will
    1729 #               not be seen.
     1726#   N%  Percent of current total data range.  Converted to
     1727#       to a relative value between 0.0 and 1.0.
     1728#   N   Absolute value of marker.  If the marker is outside of
     1729#       the current range, it will be displayed on the outer
     1730#       edge of the legends, but it range it represents will
     1731#       not be seen.
    17301732#
    17311733itcl::body Rappture::NanovisViewer::_ParseMarkersOption { tf ivol markers } {
     
    17651767itcl::body Rappture::NanovisViewer::_AddIsoMarker { x y } {
    17661768    if { $activeTf_ == "" } {
    1767         error "active transfer function isn't set"
     1769        error "active transfer function isn't set"
    17681770    }
    17691771    set tf $activeTf_
     
    18211823    set limits_(max) ""
    18221824    foreach ivol $_style2ids($tf) {
    1823         if { ![info exists limits_($ivol-min)] } {
    1824             error "can't find $ivol limits"
    1825         }
    1826         if { $limits_(min) == "" || $limits_(min) > $limits_($ivol-min) } {
    1827             set limits_(min) $limits_($ivol-min)
    1828         }
    1829         if { $limits_(max) == "" || $limits_(max) < $limits_($ivol-max) } {
    1830             set limits_(max) $limits_($ivol-max)
    1831         }
    1832     }
    1833     return [array get limits_] 
    1834 }
     1825        if { ![info exists limits_($ivol-min)] } {
     1826            error "can't find $ivol limits"
     1827        }
     1828        if { $limits_(min) == "" || $limits_(min) > $limits_($ivol-min) } {
     1829            set limits_(min) $limits_($ivol-min)
     1830        }
     1831        if { $limits_(max) == "" || $limits_(max) < $limits_($ivol-max) } {
     1832            set limits_(max) $limits_($ivol-max)
     1833        }
     1834    }
     1835    return [array get limits_]
     1836}
Note: See TracChangeset for help on using the changeset viewer.