Changeset 965 for trunk/gui


Ignore:
Timestamp:
Mar 27, 2008, 4:06:22 PM (17 years ago)
Author:
gah
Message:

add -markers style option to nanovisviewer. The reverts the -levels option back to its old format

File:
1 edited

Legend:

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

    r935 r965  
    6565    }
    6666    public method isconnected {}
     67    public method UpdateTransferFunction {}
     68    public method RemoveDuplicateIsoMarker { m x }
     69    public method OverIsoMarker { m x }
    6770
    6871    protected method Connect {}
    6972    protected method Disconnect {}
     73
    7074    protected method _send {string}
    7175    protected method _send_dataobjs {}
     
    8993    protected method _fixLegend {}
    9094    protected method GenTransfuncData {dataobj comp}
    91     public method UpdateTransferFunction {}
    92     public method RemoveDuplicateIsoMarker { m x }
    93     public method OverIsoMarker { m x }
    94     private method AddIsoMarker { x y }
    95     private method InitIsoMarkers {dataobj comp}
    96     private method HideIsoMarkers {dataobj}
    97     private method ShowIsoMarkers {dataobj}
     95
     96    # The following methods are only used by this class.
     97    private method _AddIsoMarker { x y }
     98    private method _InitIsoMarkers {dataobj comp}
     99    private method _HideIsoMarkers {dataobj}
     100    private method _ShowIsoMarkers {dataobj}
     101    private method _ParseMarkersOption {dataobj markers}
     102    private method _ParseLevelsOption {dataobj markers}
    98103
    99104    private variable _outbuf       ;# buffer for outgoing commands
     
    117122       
    118123    private variable _isomarkers    ;# array of isosurface level values 0..1
    119     private common _settings
     124    private common   _settings
    120125}
    121126
     
    413418    $inner.scales.thickness set 500
    414419
    415     set ::Rappture::NanovisViewer::_settings($this-isosurface) 1
     420    set ::Rappture::NanovisViewer::_settings($this-isosurface) 0
    416421    ::checkbutton $inner.scales.isosurface \
    417422        -text "Isosurface shading" \
     
    809814            #
    810815            if { ![info exists _isomarkers($dataobj)] } {
    811                 InitIsoMarkers $dataobj $comp
     816                _InitIsoMarkers $dataobj $comp
    812817            } else {
    813                 HideIsoMarkers $dataobj
     818                _HideIsoMarkers $dataobj
    814819            }
    815820            foreach {sname cmap wmap} [GenTransfuncData $dataobj $comp] break
     
    833838        }
    834839    }
    835     ShowIsoMarkers $first
     840    _ShowIsoMarkers $first
    836841    # if there are any commands in the buffer, send them now that we're done
    837842    SendBytes $_outbuf
     
    863868# ----------------------------------------------------------------------
    864869itcl::body Rappture::NanovisViewer::_receive_legend { ivol vmin vmax size } {
     870    puts stderr "called _receive_legend $ivol $vmin $vmax $size"
    865871    if { [isconnected] } {
    866872        set bytes [ReceiveBytes $size]
     
    880886            $c lower transfunc
    881887            $c bind transfunc <ButtonRelease-1> \
    882                 [itcl::code $this AddIsoMarker %x %y]
     888                [itcl::code $this _AddIsoMarker %x %y]
    883889        }
    884890        $c itemconfigure vmin -text $vmin
     
    888894        $c coords vmax [expr {$w-10}] [expr {$h-8}]
    889895        set first [lindex [get] 0]
    890         ShowIsoMarkers $first
     896        _ShowIsoMarkers $first
    891897    }
    892898}
     
    900906# ----------------------------------------------------------------------
    901907itcl::body Rappture::NanovisViewer::_receive_data { args } {
     908    puts stderr "called _receive_data $args"
    902909    if { [isconnected] } {
    903910        array set info $args
     
    912919                set _limits($dataobj-vmin) $info(min)
    913920            }
    914             if { $_limits($dataobj-vmax) > $info(max) } {
     921            if { $_limits($dataobj-vmax) < $info(max) } {
    915922                set _limits($dataobj-vmax) $info(max)
    916923            }
     
    923930            $_dispatcher event -idle !send_transfuncs
    924931        }
     932        puts stderr "compute limits are "
     933        parray _limits
    925934    }
    926935}
     
    969978            }
    970979        }
    971         ShowIsoMarkers $first
     980        _ShowIsoMarkers $first
    972981        UpdateTransferFunction
    973982
     
    14771486}
    14781487
    1479 itcl::body Rappture::NanovisViewer::HideIsoMarkers {dataobj} {
     1488itcl::body Rappture::NanovisViewer::_HideIsoMarkers {dataobj} {
    14801489    if { [info exists _isomarkers($dataobj)] } {
    14811490        foreach m $_isomarkers($dataobj) {
     
    14851494}
    14861495
    1487 itcl::body Rappture::NanovisViewer::ShowIsoMarkers {dataobj} {
     1496itcl::body Rappture::NanovisViewer::_ShowIsoMarkers {dataobj} {
    14881497    foreach obj [array names _all_data_objs] {
    1489         HideIsoMarkers $obj
     1498        _HideIsoMarkers $obj
    14901499    }
    14911500    if { ![info exists _isomarkers($dataobj)] } {
     
    14971506}
    14981507
    1499 itcl::body Rappture::NanovisViewer::InitIsoMarkers {dataobj comp} {
    1500     array set style {
    1501         -levels 6x
    1502     }
    1503     array set style [lindex [$dataobj components -style $comp] 0]
    1504     set levels $style(-levels)
     1508#
     1509# The -levels option takes a single value that represents the number
     1510# of evenly distributed markers based on the current data range. Each
     1511# marker is a relative value from 0.0 to 1.0.
     1512#
     1513itcl::body Rappture::NanovisViewer::_ParseLevelsOption {dataobj levels} {
    15051514    set c $itk_component(legend)
    15061515    regsub -all "," $levels " " levels
    1507     foreach level $levels {
    1508         set n [scan $level "%g%s" value suffix]
     1516    for {set i 1} { $i <= $levels } {incr i} {
     1517        set x [expr {double($i)/($nLevels+1)}]
     1518        set m [IsoMarker \#auto $c $this]
     1519        $m SetRelativeValue $x
     1520        lappend _isomarkers($dataobj) $m
     1521    }
     1522}
     1523
     1524#
     1525# The -markers option takes a list of zero or more values (the values
     1526# may be separated either by spaces or commas) that have the following
     1527# format:
     1528#
     1529#       N%      Percent of current total data range.  Converted to
     1530#               to a relative value between 0.0 and 1.0.
     1531#       N       Absolute value of marker.  If the marker is outside of
     1532#               the current range, it will be displayed on the outer
     1533#               edge of the legends, but it range it represents will
     1534#               not be seen.
     1535#
     1536itcl::body Rappture::NanovisViewer::_ParseMarkersOption {dataobj markers} {
     1537    set c $itk_component(legend)
     1538    regsub -all "," $markers " " markers
     1539    foreach marker $markers {
     1540        set n [scan $marker "%g%s" value suffix]
    15091541        if { $n == 2 && $suffix == "%" } {
    15101542            # ${n}% : Set relative value.
     
    15131545            $m SetRelativeValue $value
    15141546            lappend _isomarkers($dataobj) $m
    1515         } elseif { $n == 2 && $suffix == "x" } {
    1516             # ${n}x : Set equal number of levels
    1517             if { $value != round($value) } {
    1518                 error "\# of levels \"$value\" must be an interger"
    1519             }
    1520             set nLevels [expr round($value)]
    1521             for {set i 1} {$i <= $nLevels} {incr i} {
    1522                 set x [expr {double($i)/($nLevels+1)}]
    1523                 set m [IsoMarker \#auto $c $this]
    1524                 $m SetRelativeValue $x
    1525                 lappend _isomarkers($dataobj) $m
    1526             }
    15271547        } else {
    15281548            # ${n} : Set absolute value.
     
    15341554}
    15351555
     1556itcl::body Rappture::NanovisViewer::_InitIsoMarkers {dataobj comp} {
     1557    array set style {
     1558        -levels 6
     1559    }
     1560    array set style [lindex [$dataobj components -style $comp] 0]
     1561    if { [info exists style(-markers)] } {
     1562        _ParseMarkersOption $dataobj $style(-markers)
     1563    } else {
     1564        _ParseLevelsOption $dataobj $style(-levels)
     1565    }
     1566}
     1567
    15361568# ----------------------------------------------------------------------
    15371569# USAGE: _marker start <x> <y>
     
    15611593}
    15621594
    1563 itcl::body Rappture::NanovisViewer::AddIsoMarker { x y } {
     1595itcl::body Rappture::NanovisViewer::_AddIsoMarker { x y } {
    15641596    set dataobj [lindex [get] 0]
    15651597    if {$dataobj == ""} {
Note: See TracChangeset for help on using the changeset viewer.