Changeset 5363 for branches/1.3


Ignore:
Timestamp:
Apr 29, 2015, 9:27:26 AM (5 years ago)
Author:
ldelgass
Message:

merge r5354:5361 from trunk

Location:
branches/1.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3

  • branches/1.3/gui/scripts/field.tcl

    r5346 r5363  
    2121# Possible field dataset types:
    2222#
     23# 1D Datasets
     24#       1D              A field contained in a structure
    2325# 2D Datasets
    2426#       vtk             (range of z-axis is zero).
     
    3234#       mesh
    3335#       dx              (FIXME: make dx-to-vtk converter work)
    34 #       ucd avs
     36#       ucd             (AVS ucd format)
    3537#
    3638# Viewers:
    3739#       Format     Dim  Description                     Viewer          Server
     40#       1D          1   structure field                 DeviceViewer1D  N/A
    3841#       vtk         2   vtk file data.                  contour         vtkvis
    3942#       vtk         3   vtk file data.                  isosurface      vtkvis
     
    6467
    6568itcl::class Rappture::Field {
    66     protected variable _dim 0;          # Dimension of the mesh
    67     private variable _xmlobj "";        # ref to XML obj with field data
    68     private variable _limits;           # maps axis name => {z0 z1} limits
    69     private variable _field ""
    70     private variable _comp2fldName ;    # cname => field names.
    71     private variable _comp2type ;       # cname => type (e.g. "vectors")
    72     private variable _comp2size ;       # cname => # of components in element
    73     private variable _comp2assoc;       # cname => association (e.g. pointdata)
    74     private variable _fld2Components;   # field name => number of components
    75     private variable _fld2Label;        # field name => label
    76     private variable _fld2Units;        # field name => units
    77     private variable _hints
    78     private variable _viewer "";        # Hints which viewer to use
    79     private variable _isValid 0;        # Indicates if the field contains
    80                                         # valid data.
    81     private variable _isValidComponent; #  Array of valid components found
    82     private variable _alwaysConvertDX 0;
    83 
    8469    constructor {xmlobj path} {
    8570        # defined below
     
    9277    public method controls {option args}
    9378    public method extents {{cname -overall}}
    94     public method numComponents {cname}
    95     public method fieldlimits {}
    96     public method valueLimits { cname }
    97     public method flowhints { cname }
    98     public method hints {{key ""}}
    99     public method isunirect2d {}
    100     public method isunirect3d {}
    101     public method limits {axis}
    102     public method mesh {{cname -overall}}
    103     public method style { cname }
    104     public method type {}
    105     public method values { cname }
    106     public method vtkdata {cname}
    107     public method xErrorValues { cname } {
    108     }
    109     public method yErrorValues { cname } {
    110     }
    111 
    112     public method fieldnames { cname } {
    113         if { ![info exists _comp2fldName($cname)] } {
    114             return ""
    115         }
    116         return $_comp2fldName($cname)
    117     }
    11879    public method fieldinfo { fname } {
    11980        lappend out $_fld2Label($fname)
     
    12283        return $out
    12384    }
     85    public method fieldlimits {}
     86    public method fieldnames { cname } {
     87        if { ![info exists _comp2fldName($cname)] } {
     88            return ""
     89        }
     90        return $_comp2fldName($cname)
     91    }
     92    public method flowhints { cname }
     93    public method hints {{key ""}}
     94    public method isunirect2d {}
     95    public method isunirect3d {}
    12496    public method isvalid {} {
    12597        return $_isValid
    12698    }
     99    public method limits {axis}
     100    public method mesh {{cname -overall}}
     101    public method numComponents {cname}
     102    public method style { cname }
     103    public method type {}
     104    public method valueLimits { cname }
     105    public method values { cname }
    127106    public method viewer {} {
    128107        return $_viewer
    129108    }
     109    public method vtkdata {cname}
     110    public method xErrorValues { cname } {
     111    }
     112    public method yErrorValues { cname } {
     113    }
     114
    130115    protected method Build {}
    131116    protected method _getValue {expr}
    132 
    133     private variable _path "";          # Path of this object in the XML
    134     private variable _units ""   ;      # system of units for this field
    135     private variable _zmax 0     ;# length of the device
    136 
    137     private variable _comp2dims  ;# maps component name => dimensionality
    138     private variable _comp2xy    ;# maps component name => x,y vectors
    139     private variable _comp2vtk   ;# maps component name => vtk file data
    140     private variable _comp2dx    ;# maps component name => OpenDX data
    141     private variable _comp2unirect2d ;# maps component name => unirect2d obj
    142     private variable _comp2unirect3d ;# maps component name => unirect3d obj
    143     private variable _comp2style ;# maps component name => style settings
    144     private variable _comp2cntls ;# maps component name => x,y control points
    145     private variable _comp2extents
    146     private variable _comp2limits;        #  Array of limits per component
    147     private variable _type ""
    148     private variable _comp2flowhints
    149     private variable _comp2mesh  ;# list of: mesh object, BLT vector of values
    150     private variable _values ""  ;# Only used for unirect2d - list of values
    151     private common _counter 0    ;# counter for unique vector names
     117    protected method GetAssociation { cname }
     118    protected method GetTypeAndSize { cname }
     119    protected method ReadVtkDataSet { cname contents }
    152120
    153121    private method AvsToVtk { cname contents }
    154122    private method DicomToVtk { cname contents }
    155123    private method BuildPointsOnMesh { cname }
    156     protected method GetAssociation { cname }
    157     protected method GetTypeAndSize { cname }
    158     protected method ReadVtkDataSet { cname contents }
    159124    private method InitHints {}
    160125    private method VerifyVtkDataSet { contents }
    161126    private method VectorLimits { vector vectorsize {comp -1} }
    162127    private method VtkDataSetToXy { dataset }
     128
     129    protected variable _dim 0;          # Dimension of the mesh
     130
     131    private variable _xmlobj "";        # ref to XML obj with field data
     132    private variable _path "";          # Path of this object in the XML
     133    private variable _field "";         # This field element as XML obj
     134
     135    private variable _type "";          # Field type: e.g. file type
     136    private variable _hints;            # Hints array
     137    private variable _limits;           # maps axis name => {z0 z1} limits
     138    private variable _units "";         # system of units for this field
     139    private variable _viewer "";        # Hints which viewer to use
     140    private variable _isValid 0;        # Indicates if the field contains
     141                                        # valid data.
     142    private variable _isValidComponent; # Array of valid components found
     143    private variable _zmax 0;           # length of the device (1D only)
     144
     145    private variable _fld2Components;   # field name => number of components
     146    private variable _fld2Label;        # field name => label
     147    private variable _fld2Units;        # field name => units
     148
     149    private variable _comp2fldName;     # cname => field names.
     150    private variable _comp2type;        # cname => type (e.g. "vectors")
     151    private variable _comp2size;        # cname => # of components in element
     152    private variable _comp2assoc;       # cname => association (e.g. pointdata)
     153    private variable _comp2dims;        # cname => dimensionality
     154    private variable _comp2xy;          # cname => x,y vectors
     155    private variable _comp2vtk;         # cname => vtk file data
     156    private variable _comp2dx;          # cname => OpenDX data
     157    private variable _comp2unirect2d;   # cname => unirect2d obj
     158    private variable _comp2unirect3d;   # cname => unirect3d obj
     159    private variable _comp2style;       # cname => style settings
     160    private variable _comp2cntls;       # cname => x,y control points (1D only)
     161    private variable _comp2extents;     # cname => extents (Only for unirect)
     162    private variable _comp2limits;      # Array of limits per component
     163    private variable _comp2flowhints
     164    private variable _comp2mesh;        # list: mesh obj, BLT vector of values
     165
     166    private variable _values "";        # Only for unirect2d - list of values
     167
     168    private common _alwaysConvertDX 0;  # If set, convert DX and store as VTK,
     169                                        # even if viewer is nanovis/flowvis
     170    private common _counter 0;          # counter for unique vector names
    163171}
    164172
  • branches/1.3/gui/scripts/molvisviewer.tcl

    r5353 r5363  
    7070    protected method Rebuild {}
    7171    protected method Rotate {option x y}
     72    protected method Rotate.old {option x y}
    7273    protected method SendCmd { string }
    7374    protected method Unmap {}
    74     protected method Vmouse  {option b m x y}
    75     protected method Vmouse2 {option b m x y}
     75    protected method Vmouse {option b m x y}
    7676    protected method Zoom {option {factor 10}}
    7777
     
    141141    private variable _height
    142142    private variable _reset 1;          # Restore camera settings
    143     private variable _cell 0;           # Restore camera settings
     143    private variable _cell 0;           # Is there a parallelepiped unit cell?
    144144
    145145    private common _settings;           # Array of settings for all known
     
    147147    private common _downloadPopup;      # Download options from popup
    148148    private common _hardcopy
     149    private common _useVmouseEvents 0;  # Flag to enable virtual mouse events
    149150}
    150151
     
    212213        vy      0
    213214        vz      0
    214         zoom    0
    215215        mx      0
    216216        my      0
    217217        mz      0
    218         x       0
    219         y       0
    220         z       0
    221         width   0
    222         height  0
     218        xpan    0
     219        ypan    0
     220        zoom    0
    223221    }
    224222
     
    344342    set _image(id) ""
    345343
    346     # set up bindings for rotation
    347     if 0 {
     344    if { $_useVmouseEvents } {
     345        # set up bindings to bridge mouse events to server
     346        bind $itk_component(3dview) <ButtonPress> \
     347            [itcl::code $this Vmouse click %b %s %x %y]
     348        bind $itk_component(3dview) <ButtonRelease> \
     349            [itcl::code $this Vmouse release %b %s %x %y]
     350        bind $itk_component(3dview) <B1-Motion> \
     351            [itcl::code $this Vmouse drag 1 %s %x %y]
     352        bind $itk_component(3dview) <B2-Motion> \
     353            [itcl::code $this Vmouse drag 2 %s %x %y]
     354        bind $itk_component(3dview) <B3-Motion> \
     355            [itcl::code $this Vmouse drag 3 %s %x %y]
     356        bind $itk_component(3dview) <Motion> \
     357            [itcl::code $this Vmouse move 0 %s %x %y]
     358    } else {
     359        # set up bindings for rotation with mouse
    348360        bind $itk_component(3dview) <ButtonPress-1> \
    349361            [itcl::code $this Rotate click %x %y]
     
    352364        bind $itk_component(3dview) <ButtonRelease-1> \
    353365            [itcl::code $this Rotate release %x %y]
    354     } else {
    355         bind $itk_component(3dview) <ButtonPress-1> \
    356             [itcl::code $this Vmouse click %b %s %x %y]
    357         bind $itk_component(3dview) <B1-Motion> \
    358             [itcl::code $this Vmouse drag 1 %s %x %y]
    359         bind $itk_component(3dview) <ButtonRelease-1> \
    360             [itcl::code $this Vmouse release %b %s %x %y]
    361     }
    362 
    363     bind $itk_component(3dview) <ButtonPress-2> \
    364         [itcl::code $this Pan click %x %y]
    365     bind $itk_component(3dview) <B2-Motion> \
    366         [itcl::code $this Pan drag %x %y]
    367     bind $itk_component(3dview) <ButtonRelease-2> \
    368         [itcl::code $this Pan release %x %y]
    369 
     366
     367        # set up bindings for panning with mouse
     368        bind $itk_component(3dview) <ButtonPress-2> \
     369            [itcl::code $this Pan click %x %y]
     370        bind $itk_component(3dview) <B2-Motion> \
     371            [itcl::code $this Pan drag %x %y]
     372        bind $itk_component(3dview) <ButtonRelease-2> \
     373            [itcl::code $this Pan release %x %y]
     374
     375        # scroll wheel zoom
     376        if {[string equal "x11" [tk windowingsystem]]} {
     377            bind $itk_component(3dview) <4> [itcl::code $this Zoom out 2]
     378            bind $itk_component(3dview) <5> [itcl::code $this Zoom in 2]
     379        }
     380    }
     381
     382    # Set up bindings for panning with keyboard
    370383    bind $itk_component(3dview) <KeyPress-Left> \
    371384        [itcl::code $this Pan set -10 0]
     
    384397    bind $itk_component(3dview) <Shift-KeyPress-Down> \
    385398        [itcl::code $this Pan set 0 50]
     399
     400    # Set up bindings for zoom with keyboard
    386401    bind $itk_component(3dview) <KeyPress-Prior> \
    387402        [itcl::code $this Zoom out 2]
     
    390405
    391406    bind $itk_component(3dview) <Enter> "focus $itk_component(3dview)"
    392 
    393 
    394     if {[string equal "x11" [tk windowingsystem]]} {
    395         bind $itk_component(3dview) <4> [itcl::code $this Zoom out 2]
    396         bind $itk_component(3dview) <5> [itcl::code $this Zoom in 2]
    397     }
    398 
    399     # set up bindings to bridge mouse events to server
    400     #bind $itk_component(3dview) <ButtonPress> \
    401     #   [itcl::code $this Vmouse2 click %b %s %x %y]
    402     #bind $itk_component(3dview) <ButtonRelease> \
    403     #    [itcl::code $this Vmouse2 release %b %s %x %y]
    404     #bind $itk_component(3dview) <B1-Motion> \
    405     #    [itcl::code $this Vmouse2 drag 1 %s %x %y]
    406     #bind $itk_component(3dview) <B2-Motion> \
    407     #    [itcl::code $this Vmouse2 drag 2 %s %x %y]
    408     #bind $itk_component(3dview) <B3-Motion> \
    409     #    [itcl::code $this Vmouse2 drag 3 %s %x %y]
    410     #bind $itk_component(3dview) <Motion> \
    411     #    [itcl::code $this Vmouse2 move 0 %s %x %y]
    412407
    413408    bind $itk_component(3dview) <Configure> \
     
    431426    array unset _settings $this-*
    432427}
    433 
    434428
    435429# ----------------------------------------------------------------------
     
    659653}
    660654
    661 
    662655#
    663656# Connect --
     
    11241117        SendCmd "screen $w $h"
    11251118        SendCmd "rotate $_view(mx) $_view(my) $_view(mz)"
    1126         SendCmd "pan $_view(x) $_view(y)"
     1119        SendCmd "pan $_view(xpan) $_view(ypan)"
    11271120        SendCmd "zoom $_view(zoom)"
    11281121        debug "rotate $_view(mx) $_view(my) $_view(mz)"
     
    12431236        set dx $x
    12441237        set dy $y
    1245         set _view(x) [expr $_view(x) + $dx]
    1246         set _view(y) [expr $_view(y) + $dy]
     1238        set _view(xpan) [expr $_view(xpan) + $dx]
     1239        set _view(ypan) [expr $_view(ypan) + $dy]
    12471240        array unset _imagecache
    12481241        SendCmd "pan $dx $dy"
     
    12581251        set dx [expr $x - $_mevent(x)]
    12591252        set dy [expr $y - $_mevent(y)]
    1260         set _view(x) [expr $_view(x) + $dx]
    1261         set _view(y) [expr $_view(y) + $dy]
     1253        set _view(xpan) [expr $_view(xpan) + $dx]
     1254        set _view(ypan) [expr $_view(ypan) + $dy]
    12621255        array unset _imagecache
    12631256        SendCmd "pan $dx $dy"
     
    13421335}
    13431336
    1344 
    1345 itcl::body Rappture::MolvisViewer::Vmouse2 {option b m x y} {
     1337#
     1338# Send virtual mouse events using the vmouse command
     1339#
     1340itcl::body Rappture::MolvisViewer::Vmouse {option b m x y} {
    13461341    set now [clock clicks -milliseconds]
    13471342    set vButton [expr $b - 1]
     
    13701365}
    13711366
    1372 itcl::body Rappture::MolvisViewer::Vmouse {option b m x y} {
     1367# ----------------------------------------------------------------------
     1368# USAGE: Rotate click <x> <y>
     1369# USAGE: Rotate drag <x> <y>
     1370# USAGE: Rotate release <x> <y>
     1371#
     1372# Called automatically when the user clicks/drags/releases in the
     1373# plot area.  Moves the plot according to the user's actions.
     1374# ----------------------------------------------------------------------
     1375itcl::body Rappture::MolvisViewer::Rotate {option x y} {
    13731376    set now  [clock clicks -milliseconds]
    13741377    # cancel any pending delayed dragging events
     
    13861389    if { $option == "drag" || $option == "release" } {
    13871390        set diff 0
    1388          catch { set diff [expr $now - $_mevent(time) ] }
    1389          if {$diff < 25 && $option == "drag" } { # 75ms between motion updates
    1390              set _mevent(afterid) [after [expr 25 - $diff] [itcl::code $this Vmouse drag $b $m $x $y]]
    1391              return
    1392          }
     1391        catch { set diff [expr $now - $_mevent(time) ] }
     1392        if {$diff < 25 && $option == "drag" } { # 75ms between motion updates
     1393            set _mevent(afterid) [after [expr 25 - $diff] [itcl::code $this Rotate drag $x $y]]
     1394            return
     1395        }
    13931396        set w [winfo width $itk_component(3dview)]
    13941397        set h [winfo height $itk_component(3dview)]
     
    14381441
    14391442# ----------------------------------------------------------------------
    1440 # USAGE: Rotate click <x> <y>
    1441 # USAGE: Rotate drag <x> <y>
    1442 # USAGE: Rotate release <x> <y>
     1443# USAGE: Rotate.old click <x> <y>
     1444# USAGE: Rotate.old drag <x> <y>
     1445# USAGE: Rotate.old release <x> <y>
    14431446#
    14441447# Called automatically when the user clicks/drags/releases in the
    14451448# plot area.  Moves the plot according to the user's actions.
    14461449# ----------------------------------------------------------------------
    1447 itcl::body Rappture::MolvisViewer::Rotate {option x y} {
     1450itcl::body Rappture::MolvisViewer::Rotate.old {option x y} {
    14481451    set now  [clock clicks -milliseconds]
    14491452    #update idletasks
     
    14631466        drag {
    14641467            if {[array size _click] == 0} {
    1465                 Rotate click $x $y
     1468                Rotate.old click $x $y
    14661469            } else {
    14671470                set w [winfo width $itk_component(3dview)]
     
    14701473                    return
    14711474                }
    1472 #         set diff 0
    1473 #          catch { set diff [expr $now - $_mevent(time) ] }
    1474 #          if {$diff < 175 && $option == "drag" } { # 75ms between motion updates
    1475 #              set _mevent(afterid) [after [expr 175 - $diff] [itcl::code $this Rotate drag $x $y]]
    1476 #              return
    1477 #          }
     1475                #set diff 0
     1476                #catch { set diff [expr $now - $_mevent(time) ] }
     1477                #if {$diff < 75 && $option == "drag" } { # 75ms between motion updates
     1478                #    set _mevent(afterid) [after [expr 75 - $diff] [itcl::code $this Rotate.old drag $x $y]]
     1479                #    return
     1480                #}
    14781481
    14791482                if {[catch {
     
    15301533        }
    15311534        release {
    1532             Rotate drag $x $y
     1535            Rotate.old drag $x $y
    15331536            $itk_component(3dview) configure -cursor ""
    15341537            catch {unset _click}
     
    15861589    }
    15871590}
    1588 
    15891591
    15901592# ----------------------------------------------------------------------
     
    16721674}
    16731675
    1674 
    16751676#
    16761677# ResetView
     
    16841685        my      0
    16851686        mz      0
    1686         x       0
    1687         y       0
    1688         z       0
     1687        xpan    0
     1688        ypan    0
    16891689        zoom    0
    1690         width   0
    1691         height  0
    16921690    }
    16931691    SendCmd "reset"
     
    16951693    SendCmd "rotate $_view(mx) $_view(my) $_view(mz)"
    16961694    debug "rotate $_view(mx) $_view(my) $_view(mz)"
    1697     SendCmd "pan $_view(x) $_view(y)"
     1695    SendCmd "pan $_view(xpan) $_view(ypan)"
    16981696    SendCmd "zoom $_view(zoom)"
    16991697}
    17001698
    1701 
    1702 itcl::body Rappture::MolvisViewer::WaitIcon  { option widget } {
     1699itcl::body Rappture::MolvisViewer::WaitIcon { option widget } {
    17031700    switch -- $option {
    17041701        "start" {
     
    18301827#       is inactive, then it overridden with the value "0.1".
    18311828# ----------------------------------------------------------------------
    1832 
    18331829itcl::body Rappture::MolvisViewer::SphereScale { option {models "all"} } {
    18341830    if { $option == "update" } {
     
    18661862#       is inactive, then it overridden with the value "0.25".
    18671863# ----------------------------------------------------------------------
    1868 
    18691864itcl::body Rappture::MolvisViewer::StickRadius { option {models "all"} } {
    18701865    if { $option == "update" } {
     
    19021897#       is inactive, then it overridden with the value "0.75".
    19031898# ----------------------------------------------------------------------
    1904 
    19051899itcl::body Rappture::MolvisViewer::Opacity { option } {
    19061900    array unset _imagecache
     
    21392133}
    21402134
    2141 
    21422135# ----------------------------------------------------------------------
    21432136# OPTION: -device
     
    21582151    }
    21592152}
    2160 
Note: See TracChangeset for help on using the changeset viewer.