Changeset 5362 for branches/1.4
- Timestamp:
- Apr 29, 2015, 6:23:39 AM (9 years ago)
- Location:
- branches/1.4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.4
-
branches/1.4/gui/scripts/field.tcl
r5344 r5362 21 21 # Possible field dataset types: 22 22 # 23 # 1D Datasets 24 # 1D A field contained in a structure 23 25 # 2D Datasets 24 26 # vtk (range of z-axis is zero). … … 32 34 # mesh 33 35 # dx (FIXME: make dx-to-vtk converter work) 34 # ucd avs36 # ucd (AVS ucd format) 35 37 # 36 38 # Viewers: 37 39 # Format Dim Description Viewer Server 40 # 1D 1 structure field DeviceViewer1D N/A 38 41 # vtk 2 vtk file data. contour vtkvis 39 42 # vtk 3 vtk file data. isosurface vtkvis … … 64 67 65 68 itcl::class Rappture::Field { 66 protected variable _dim 0; # Dimension of the mesh67 private variable _xmlobj ""; # ref to XML obj with field data68 private variable _limits; # maps axis name => {z0 z1} limits69 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 element73 private variable _comp2assoc; # cname => association (e.g. pointdata)74 private variable _fld2Components; # field name => number of components75 private variable _fld2Label; # field name => label76 private variable _fld2Units; # field name => units77 private variable _hints78 private variable _viewer ""; # Hints which viewer to use79 private variable _isValid 0; # Indicates if the field contains80 # valid data.81 private variable _isValidComponent; # Array of valid components found82 private variable _alwaysConvertDX 0;83 84 69 constructor {xmlobj path} { 85 70 # defined below … … 92 77 public method controls {option args} 93 78 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 }118 79 public method fieldinfo { fname } { 119 80 lappend out $_fld2Label($fname) … … 122 83 return $out 123 84 } 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 {} 124 96 public method isvalid {} { 125 97 return $_isValid 126 98 } 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 } 127 106 public method viewer {} { 128 107 return $_viewer 129 108 } 109 public method vtkdata {cname} 110 public method xErrorValues { cname } { 111 } 112 public method yErrorValues { cname } { 113 } 114 130 115 protected method Build {} 131 116 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 } 152 120 153 121 private method AvsToVtk { cname contents } 154 122 private method DicomToVtk { cname contents } 155 123 private method BuildPointsOnMesh { cname } 156 protected method GetAssociation { cname }157 protected method GetTypeAndSize { cname }158 protected method ReadVtkDataSet { cname contents }159 124 private method InitHints {} 160 125 private method VerifyVtkDataSet { contents } 161 126 private method VectorLimits { vector vectorsize {comp -1} } 162 127 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 163 171 } 164 172 -
branches/1.4/gui/scripts/molvisviewer.tcl
r5352 r5362 70 70 protected method Rebuild {} 71 71 protected method Rotate {option x y} 72 protected method Rotate.old {option x y} 72 73 protected method SendCmd { string } 73 74 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} 76 76 protected method Zoom {option {factor 10}} 77 77 … … 141 141 private variable _height 142 142 private variable _reset 1; # Restore camera settings 143 private variable _cell 0; # Restore camera settings143 private variable _cell 0; # Is there a parallelepiped unit cell? 144 144 145 145 private common _settings; # Array of settings for all known … … 147 147 private common _downloadPopup; # Download options from popup 148 148 private common _hardcopy 149 private common _useVmouseEvents 0; # Flag to enable virtual mouse events 149 150 } 150 151 … … 212 213 vy 0 213 214 vz 0 214 zoom 0215 215 mx 0 216 216 my 0 217 217 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 223 221 } 224 222 … … 344 342 set _image(id) "" 345 343 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 348 360 bind $itk_component(3dview) <ButtonPress-1> \ 349 361 [itcl::code $this Rotate click %x %y] … … 352 364 bind $itk_component(3dview) <ButtonRelease-1> \ 353 365 [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 370 383 bind $itk_component(3dview) <KeyPress-Left> \ 371 384 [itcl::code $this Pan set -10 0] … … 384 397 bind $itk_component(3dview) <Shift-KeyPress-Down> \ 385 398 [itcl::code $this Pan set 0 50] 399 400 # Set up bindings for zoom with keyboard 386 401 bind $itk_component(3dview) <KeyPress-Prior> \ 387 402 [itcl::code $this Zoom out 2] … … 390 405 391 406 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 server400 #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]412 407 413 408 bind $itk_component(3dview) <Configure> \ … … 431 426 array unset _settings $this-* 432 427 } 433 434 428 435 429 # ---------------------------------------------------------------------- … … 659 653 } 660 654 661 662 655 # 663 656 # Connect -- … … 1124 1117 SendCmd "screen $w $h" 1125 1118 SendCmd "rotate $_view(mx) $_view(my) $_view(mz)" 1126 SendCmd "pan $_view(x ) $_view(y)"1119 SendCmd "pan $_view(xpan) $_view(ypan)" 1127 1120 SendCmd "zoom $_view(zoom)" 1128 1121 debug "rotate $_view(mx) $_view(my) $_view(mz)" … … 1243 1236 set dx $x 1244 1237 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] 1247 1240 array unset _imagecache 1248 1241 SendCmd "pan $dx $dy" … … 1258 1251 set dx [expr $x - $_mevent(x)] 1259 1252 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] 1262 1255 array unset _imagecache 1263 1256 SendCmd "pan $dx $dy" … … 1342 1335 } 1343 1336 1344 1345 itcl::body Rappture::MolvisViewer::Vmouse2 {option b m x y} { 1337 # 1338 # Send virtual mouse events using the vmouse command 1339 # 1340 itcl::body Rappture::MolvisViewer::Vmouse {option b m x y} { 1346 1341 set now [clock clicks -milliseconds] 1347 1342 set vButton [expr $b - 1] … … 1370 1365 } 1371 1366 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 # ---------------------------------------------------------------------- 1375 itcl::body Rappture::MolvisViewer::Rotate {option x y} { 1373 1376 set now [clock clicks -milliseconds] 1374 1377 # cancel any pending delayed dragging events … … 1386 1389 if { $option == "drag" || $option == "release" } { 1387 1390 set diff 0 1388 1389 1390 set _mevent(afterid) [after [expr 25 - $diff] [itcl::code $this Vmouse drag $b $m$x $y]]1391 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 } 1393 1396 set w [winfo width $itk_component(3dview)] 1394 1397 set h [winfo height $itk_component(3dview)] … … 1438 1441 1439 1442 # ---------------------------------------------------------------------- 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> 1443 1446 # 1444 1447 # Called automatically when the user clicks/drags/releases in the 1445 1448 # plot area. Moves the plot according to the user's actions. 1446 1449 # ---------------------------------------------------------------------- 1447 itcl::body Rappture::MolvisViewer::Rotate {option x y} {1450 itcl::body Rappture::MolvisViewer::Rotate.old {option x y} { 1448 1451 set now [clock clicks -milliseconds] 1449 1452 #update idletasks … … 1463 1466 drag { 1464 1467 if {[array size _click] == 0} { 1465 Rotate click $x $y1468 Rotate.old click $x $y 1466 1469 } else { 1467 1470 set w [winfo width $itk_component(3dview)] … … 1470 1473 return 1471 1474 } 1472 #set diff 01473 #catch { set diff [expr $now - $_mevent(time) ] }1474 # if {$diff < 175 && $option == "drag" } { # 75ms between motion updates1475 # set _mevent(afterid) [after [expr 175 - $diff] [itcl::code $this Rotatedrag $x $y]]1476 #return1477 #}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 #} 1478 1481 1479 1482 if {[catch { … … 1530 1533 } 1531 1534 release { 1532 Rotate drag $x $y1535 Rotate.old drag $x $y 1533 1536 $itk_component(3dview) configure -cursor "" 1534 1537 catch {unset _click} … … 1586 1589 } 1587 1590 } 1588 1589 1591 1590 1592 # ---------------------------------------------------------------------- … … 1672 1674 } 1673 1675 1674 1675 1676 # 1676 1677 # ResetView … … 1684 1685 my 0 1685 1686 mz 0 1686 x 0 1687 y 0 1688 z 0 1687 xpan 0 1688 ypan 0 1689 1689 zoom 0 1690 width 01691 height 01692 1690 } 1693 1691 SendCmd "reset" … … 1695 1693 SendCmd "rotate $_view(mx) $_view(my) $_view(mz)" 1696 1694 debug "rotate $_view(mx) $_view(my) $_view(mz)" 1697 SendCmd "pan $_view(x ) $_view(y)"1695 SendCmd "pan $_view(xpan) $_view(ypan)" 1698 1696 SendCmd "zoom $_view(zoom)" 1699 1697 } 1700 1698 1701 1702 itcl::body Rappture::MolvisViewer::WaitIcon { option widget } { 1699 itcl::body Rappture::MolvisViewer::WaitIcon { option widget } { 1703 1700 switch -- $option { 1704 1701 "start" { … … 1830 1827 # is inactive, then it overridden with the value "0.1". 1831 1828 # ---------------------------------------------------------------------- 1832 1833 1829 itcl::body Rappture::MolvisViewer::SphereScale { option {models "all"} } { 1834 1830 if { $option == "update" } { … … 1866 1862 # is inactive, then it overridden with the value "0.25". 1867 1863 # ---------------------------------------------------------------------- 1868 1869 1864 itcl::body Rappture::MolvisViewer::StickRadius { option {models "all"} } { 1870 1865 if { $option == "update" } { … … 1902 1897 # is inactive, then it overridden with the value "0.75". 1903 1898 # ---------------------------------------------------------------------- 1904 1905 1899 itcl::body Rappture::MolvisViewer::Opacity { option } { 1906 1900 array unset _imagecache … … 2139 2133 } 2140 2134 2141 2142 2135 # ---------------------------------------------------------------------- 2143 2136 # OPTION: -device … … 2158 2151 } 2159 2152 } 2160
Note: See TracChangeset
for help on using the changeset viewer.