Changeset 5733


Ignore:
Timestamp:
Jun 22, 2015 5:18:42 PM (7 years ago)
Author:
ldelgass
Message:

Merge in vtkvolume viewer updates from trunk

Location:
branches/1.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.4

  • branches/1.4/gui/scripts/vtkvolumeviewer.tcl

    r5732 r5733  
    33#  COMPONENT: vtkvolumeviewer - Vtk volume viewer
    44#
    5 #  It connects to the Vtk server running on a rendering farm,
     5#  This widget performs volume rendering on 3D scalar/vector datasets.
     6#  It connects to the Vtkvis server running on a rendering farm,
    67#  transmits data, and displays the results.
    78# ======================================================================
    89#  AUTHOR:  Michael McLennan, Purdue University
    9 #  Copyright (c) 2004-2014  HUBzero Foundation, LLC
     10#  Copyright (c) 2004-2015  HUBzero Foundation, LLC
    1011#
    1112#  See the file "license.terms" for information on usage and
     
    6263    public method scale {args}
    6364
    64     private method GetDatasetsWithComponent { cname }
    65 
    66     private variable _volcomponents   ; # Array of components found
    67     private variable _componentsList   ; # List of component names
    68 
    6965    # The following methods are only used by this class.
    7066    private method AdjustSetting {what {value ""}}
     
    7268    private method BuildCameraTab {}
    7369    private method BuildColormap { name colors }
    74     private method BuildCutplaneTab {}
     70    private method BuildCutplanesTab {}
    7571    private method BuildDownloadPopup { widget command }
    7672    private method BuildViewTab {}
     
    8985    private method EventuallyRotate { q }
    9086    private method EventuallySetCutplane { axis args }
     87    private method GetDatasetsWithComponent { cname }
    9188    private method GetImage { args }
    9289    private method GetVtkData { args }
     
    109106    private method SetColormap { dataobj comp }
    110107    private method SetLegendTip { x y }
    111     private method SetObjectStyle { dataobj comp }
     108    private method SetObjectStyle { dataobj cname }
    112109    private method SetOrientation { side }
    113110    private method Slice {option args}
     
    126123    private variable _dataset2style;    # maps dataobj-component to transfunc
    127124
    128     private variable _click;            # info used for rotate operations
    129     private variable _limits;           # autoscale min/max for all axes
    130     private variable _view;             # view params for 3D view
     125    private variable _reset 1;          # Connection to server has been reset.
     126    private variable _click;            # Info used for rotate operations.
     127    private variable _limits;           # Autoscale min/max for all axes
     128    private variable _view;             # View params for 3D view
    131129    private variable _settings
    132130    private variable _style;            # Array of current component styles.
    133131    private variable _initialStyle;     # Array of initial component styles.
    134     private variable _reset 1;          # Connection to server has been reset.
    135 
    136     private variable _first "";         # This is the topmost dataset.
     132
    137133    private variable _start 0
    138134    private variable _title ""
    139 
    140     private variable _width 0
    141     private variable _height 0
    142     private variable _resizePending 0
    143     private variable _rotatePending 0
    144     private variable _cutplanePending 0
    145     private variable _legendPending 0
    146135    private variable _fields
    147136    private variable _curFldName ""
     
    151140    private variable _allowMultiComponent 0
    152141
     142    private variable _first "";         # This is the topmost dataset.
     143    private variable _volcomponents;    # Maps component name to list of
     144                                        # dataobj-component tags
     145    private variable _componentsList;   # List of components found
     146
     147    private variable _width 0
     148    private variable _height 0
     149    private variable _resizePending 0
     150    private variable _legendPending 0
     151    private variable _rotatePending 0
     152    private variable _cutplanePending 0
     153
    153154    private common _downloadPopup;      # download options from popup
    154155    private common _hardcopy
     
    166167    set _serverType "vtkvis"
    167168
     169    #DebugOn
    168170    EnableWaitDialog 900
    169171
     
    176178    $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list"
    177179
     180    # Legend event
     181    $_dispatcher register !legend
     182    $_dispatcher dispatch $this !legend "[itcl::code $this RequestLegend]; list"
     183
    178184    # Rotate event
    179185    $_dispatcher register !rotate
    180186    $_dispatcher dispatch $this !rotate "[itcl::code $this DoRotate]; list"
    181 
    182     # Legend event
    183     $_dispatcher register !legend
    184     $_dispatcher dispatch $this !legend "[itcl::code $this RequestLegend]; list"
    185187
    186188    # X-Cutplane event
     
    203205    #
    204206    $_parser alias image [itcl::code $this ReceiveImage]
     207    $_parser alias legend [itcl::code $this ReceiveLegend]
    205208    $_parser alias dataset [itcl::code $this ReceiveDataset]
    206     $_parser alias legend [itcl::code $this ReceiveLegend]
    207209
    208210    # Initialize the view to some default parameters.
    209211    array set _view {
    210         -ortho           0
    211         -qw              0.853553
    212         -qx              -0.353553
    213         -qy              0.353553
    214         -qz              0.146447
    215         -xpan            0
    216         -ypan            0
    217         -zoom            1.0
     212        -ortho    0
     213        -qw       0.853553
     214        -qx       -0.353553
     215        -qy       0.353553
     216        -qz       0.146447
     217        -xpan     0
     218        -ypan     0
     219        -zoom     1.0
    218220    }
    219221    set _arcball [blt::arcball create 100 100]
     
    294296    }
    295297    pack $itk_component(reset) -side top -padx 2 -pady 2
    296     Rappture::Tooltip::for $itk_component(reset) "Reset the view to the default zoom level"
     298    Rappture::Tooltip::for $itk_component(reset) \
     299        "Reset the view to the default zoom level"
    297300
    298301    itk_component add zoomin {
     
    346349        BuildViewTab
    347350        BuildVolumeTab
    348         BuildCutplaneTab
     351        BuildCutplanesTab
    349352        BuildAxisTab
    350353        BuildCameraTab
     
    501504# ----------------------------------------------------------------------
    502505itcl::body Rappture::VtkVolumeViewer::add {dataobj {settings ""}} {
     506    DebugTrace "Enter"
    503507    if { ![IsValidObject $dataobj] } {
     508        DebugTrace "Invalid"
    504509        return;                         # Ignore invalid objects.
    505510    }
     
    542547# ----------------------------------------------------------------------
    543548itcl::body Rappture::VtkVolumeViewer::delete {args} {
     549    DebugTrace "Enter"
    544550    if { [llength $args] == 0} {
    545551        set args $_dlist
     
    645651# ----------------------------------------------------------------------
    646652itcl::body Rappture::VtkVolumeViewer::scale {args} {
     653    DebugTrace "Enter"
    647654    array unset _limits
    648655    array unset _volcomponents
     
    828835itcl::body Rappture::VtkVolumeViewer::disconnect {} {
    829836    Disconnect
     837    set _reset 1
    830838}
    831839
     
    981989        StartBufferingCommands
    982990    }
     991
    983992    set _first ""
    984 
    985993    # No volumes are active (i.e. in the working set of displayed volumes).
    986994    # A volume is always invisible if it's not in the working set.  A
     
    9921000            set _first $dataobj
    9931001        }
    994         foreach comp [$dataobj components] {
    995             set tag $dataobj-$comp
     1002        foreach cname [$dataobj components] {
     1003            set tag $dataobj-$cname
    9961004            if { ![info exists _datasets($tag)] } {
    997                 set bytes [$dataobj vtkdata $comp]
     1005                set bytes [$dataobj vtkdata $cname]
    9981006                if 0 {
    9991007                    set f [open /tmp/vtkvolume.vtk "w"]
     
    10181026                SendData $bytes
    10191027                set _datasets($tag) 1
    1020                 SetObjectStyle $dataobj $comp
     1028                SetObjectStyle $dataobj $cname
    10211029            }
    10221030            if { [info exists _obj2ovride($dataobj-raise)] } {
     
    15911599# BuildColormap --
    15921600#
     1601# Alpha map is in the format: normalized_value opacity midpoint sharpness
     1602#
    15931603itcl::body Rappture::VtkVolumeViewer::BuildColormap { name styles } {
    15941604    array set style $styles
     
    15971607        set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
    15981608    }
    1599     set max 1.0
    1600 
     1609
     1610    set amap "0.0 0.0 0.5 0.0 1.0 1.0 0.5 0.0"
    16011611    set opaqueAmap "0.0 1.0 1.0 1.0"
    1602     #set amap "0.0 0.0 0.1 0.0 0.2 0.8 0.98 0.8 0.99 0.0 1.0 0.0"
    1603     # Approximate cubic opacity curve
    1604     set amap "0.0 0.0 0.1 0.001 0.2 0.008 0.3 0.027 0.4 0.064 0.5 0.125 0.6 0.216 0.7 0.343 0.8 0.512 0.9 0.729 1.0 1.0"
    1605     SendCmd "colormap add $name { $cmap } { $amap }"
    1606     SendCmd "colormap add $name-opaque { $cmap } { $opaqueAmap }"
     1612    SendCmd [list colormap define $name $cmap -spline $amap]
     1613    SendCmd [list colormap define $name-opaque $cmap $opaqueAmap]
    16071614}
    16081615
     
    18881895}
    18891896
    1890 itcl::body Rappture::VtkVolumeViewer::BuildCutplaneTab {} {
     1897itcl::body Rappture::VtkVolumeViewer::BuildCutplanesTab {} {
    18911898    set font [option get $itk_component(hull) font Font]
    18921899
Note: See TracChangeset for help on using the changeset viewer.