Changeset 4729
- Timestamp:
- Nov 14, 2014 3:32:10 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3/gui/scripts/vtkvolumeviewer.tcl
r4670 r4729 61 61 } 62 62 public method scale {args} 63 64 private method SetOrientation { side } 65 private method ViewToQuaternion {} { 66 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 67 } 68 private method QuaternionToView { q } { 69 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 70 } 63 71 64 72 protected method Connect {} … … 140 148 private variable _curFldLabel "" 141 149 private variable _colorMode "vmag";# Mode of colormap (vmag or scalar) 150 private variable _cutplaneCmd "cutplane" 142 151 } 143 152 … … 175 184 $_dispatcher register !xcutplane 176 185 $_dispatcher dispatch $this !xcutplane \ 177 "[itcl::code $this AdjustSetting cutplane-xposition]; list"186 "[itcl::code $this AdjustSetting -xcutplaneposition]; list" 178 187 179 188 # Y-Cutplane event 180 189 $_dispatcher register !ycutplane 181 190 $_dispatcher dispatch $this !ycutplane \ 182 "[itcl::code $this AdjustSetting cutplane-yposition]; list"191 "[itcl::code $this AdjustSetting -ycutplaneposition]; list" 183 192 184 193 # Z-Cutplane event 185 194 $_dispatcher register !zcutplane 186 195 $_dispatcher dispatch $this !zcutplane \ 187 "[itcl::code $this AdjustSetting cutplane-zposition]; list"196 "[itcl::code $this AdjustSetting -zcutplaneposition]; list" 188 197 189 198 # … … 196 205 # Initialize the view to some default parameters. 197 206 array set _view { 198 qw 0.853553199 qx -0.353553200 qy 0.353553201 qz 0.146447202 zoom 1.0203 xpan 0204 ypan 0205 ortho 0207 -qw 0.853553 208 -qx -0.353553 209 -qy 0.353553 210 -qz 0.146447 211 -zoom 1.0 212 -xpan 0 213 -ypan 0 214 -ortho 0 206 215 } 207 216 set _arcball [blt::arcball create 100 100] 208 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 209 $_arcball quaternion $q 217 $_arcball quaternion [ViewToQuaternion] 210 218 211 219 array set _settings { 212 axis-xgrid 0 213 axis-ygrid 0 214 axis-zgrid 0 215 axesVisible 1 216 axisLabels 1 217 background black 218 cutplaneEdges 0 219 cutplane-xvisible 1 220 cutplane-yvisible 1 221 cutplane-zvisible 1 222 cutplane-xposition 50 223 cutplane-yposition 50 224 cutplane-zposition 50 225 cutplaneVisible 0 226 cutplaneLighting 1 227 cutplaneWireframe 0 228 cutplane-opacity 100 229 legendVisible 1 230 outline 0 231 volumeLighting 1 232 volume-material 80 233 volume-opacity 40 234 volume-quality 50 235 volumeVisible 1 236 legendVisible 1 220 -axesvisible 1 221 -axisflymode static 222 -axislabels 1 223 -axisminorticks 1 224 -background black 225 -cutplaneedges 0 226 -cutplanelighting 1 227 -cutplaneopacity 100 228 -cutplanesvisible 0 229 -cutplanewireframe 0 230 -legendvisible 1 231 -volumelighting 1 232 -volumematerial 80 233 -volumeopacity 50 234 -volumeoutline 0 235 -volumequality 80 236 -volumevisible 1 237 -xcutplaneposition 50 238 -xcutplanevisible 1 239 -xgrid 0 240 -ycutplaneposition 50 241 -ycutplanevisible 1 242 -ygrid 0 243 -zcutplaneposition 50 244 -zcutplanevisible 1 245 -zgrid 0 237 246 } 238 247 … … 313 322 -onimage [Rappture::icon volume-on] \ 314 323 -offimage [Rappture::icon volume-off] \ 315 -variable [itcl::scope _settings( volumeVisible)] \316 -command [itcl::code $this AdjustSetting volumeVisible]324 -variable [itcl::scope _settings(-volumevisible)] \ 325 -command [itcl::code $this AdjustSetting -volumevisible] 317 326 } 318 327 $itk_component(volume) select … … 325 334 -onimage [Rappture::icon cutbutton] \ 326 335 -offimage [Rappture::icon cutbutton] \ 327 -variable [itcl::scope _settings( cutplaneVisible)] \328 -command [itcl::code $this AdjustSetting cutplaneVisible]336 -variable [itcl::scope _settings(-cutplanesvisible)] \ 337 -command [itcl::code $this AdjustSetting -cutplanesvisible] 329 338 } 330 339 Rappture::Tooltip::for $itk_component(cutplane) \ … … 446 455 447 456 itcl::body Rappture::VtkVolumeViewer::DoRotate {} { 448 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 449 SendCmd "camera orient $q" 457 SendCmd "camera orient [ViewToQuaternion]" 450 458 set _rotatePending 0 451 459 } … … 464 472 465 473 itcl::body Rappture::VtkVolumeViewer::EventuallyRotate { q } { 466 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break474 QuaternionToView $q 467 475 if { !$_rotatePending } { 468 476 set _rotatePending 1 … … 809 817 array unset _dataset2style 810 818 array unset _obj2datasets 819 820 set _resizePending 0 821 set _rotatePending 0 822 set _cutplanePending 0 823 set _legendPending 0 824 set _reset 1 811 825 } 812 826 … … 901 915 set w [winfo width $itk_component(view)] 902 916 set h [winfo height $itk_component(view)] 917 903 918 if { $w < 2 || $h < 2 } { 904 919 $_dispatcher event -idle !rebuild … … 923 938 # Reset the camera and other view parameters 924 939 # 925 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 926 $_arcball quaternion $q 927 if {$_view(ortho)} { 940 $_arcball quaternion [ViewToQuaternion] 941 if {$_view(-ortho)} { 928 942 SendCmd "camera mode ortho" 929 943 } else { … … 931 945 } 932 946 DoRotate 933 InitSettings outlinebackground \934 axis-xgrid axis-ygrid axis-zgrid axisFlyMode \935 axesVisible axisLabels947 InitSettings -volumeoutline -background \ 948 -xgrid -ygrid -zgrid -axisflymode \ 949 -axesvisible -axislabels -axisminorticks 936 950 PanCamera 937 951 } … … 1022 1036 } 1023 1037 1024 InitSettings volume-palette volume-material volume-quality volumeVisible \ 1025 cutplaneVisible \ 1026 cutplane-xposition cutplane-yposition cutplane-zposition \ 1027 cutplane-xvisible cutplane-yvisible cutplane-zvisible 1038 InitSettings -volumepalette \ 1039 -volumematerial \ 1040 -volumeopacity -volumequality -volumevisible \ 1041 -cutplanesvisible \ 1042 -xcutplaneposition -ycutplaneposition -zcutplaneposition \ 1043 -xcutplanevisible -ycutplanevisible -zcutplanevisible 1028 1044 1029 1045 if { $_reset } { 1030 InitSettings volumeLighting1046 InitSettings -volumelighting 1031 1047 Zoom reset 1032 1048 set _reset 0 … … 1095 1111 switch -- $option { 1096 1112 "in" { 1097 set _view( zoom) [expr {$_view(zoom)*1.25}]1098 SendCmd "camera zoom $_view( zoom)"1113 set _view(-zoom) [expr {$_view(-zoom)*1.25}] 1114 SendCmd "camera zoom $_view(-zoom)" 1099 1115 } 1100 1116 "out" { 1101 set _view( zoom) [expr {$_view(zoom)*0.8}]1102 SendCmd "camera zoom $_view( zoom)"1117 set _view(-zoom) [expr {$_view(-zoom)*0.8}] 1118 SendCmd "camera zoom $_view(-zoom)" 1103 1119 } 1104 1120 "reset" { 1105 1121 array set _view { 1106 qw 0.8535531107 qx -0.3535531108 qy 0.3535531109 qz 0.1464471110 zoom 1.01111 xpan 01112 ypan 01122 -qw 0.853553 1123 -qx -0.353553 1124 -qy 0.353553 1125 -qz 0.146447 1126 -zoom 1.0 1127 -xpan 0 1128 -ypan 0 1113 1129 } 1114 1130 if { $_first != "" } { … … 1118 1134 } 1119 1135 } 1120 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1121 $_arcball quaternion $q 1136 $_arcball quaternion [ViewToQuaternion] 1122 1137 DoRotate 1123 1138 SendCmd "camera reset" … … 1127 1142 1128 1143 itcl::body Rappture::VtkVolumeViewer::PanCamera {} { 1129 set x $_view( xpan)1130 set y $_view( ypan)1144 set x $_view(-xpan) 1145 set y $_view(-ypan) 1131 1146 SendCmd "camera pan $x $y" 1132 1147 } … … 1206 1221 set x [expr $x / double($w)] 1207 1222 set y [expr $y / double($h)] 1208 set _view( xpan) [expr $_view(xpan) + $x]1209 set _view( ypan) [expr $_view(ypan) + $y]1223 set _view(-xpan) [expr $_view(-xpan) + $x] 1224 set _view(-ypan) [expr $_view(-ypan) + $y] 1210 1225 PanCamera 1211 1226 return … … 1229 1244 set _click(x) $x 1230 1245 set _click(y) $y 1231 set _view( xpan) [expr $_view(xpan) - $dx]1232 set _view( ypan) [expr $_view(ypan) - $dy]1246 set _view(-xpan) [expr $_view(-xpan) - $dx] 1247 set _view(-ypan) [expr $_view(-ypan) - $dy] 1233 1248 PanCamera 1234 1249 } … … 1252 1267 itcl::body Rappture::VtkVolumeViewer::InitSettings { args } { 1253 1268 foreach spec $args { 1254 if { [info exists _settings($_first -$spec)] } {1269 if { [info exists _settings($_first${spec})] } { 1255 1270 # Reset global setting with dataobj specific setting 1256 set _settings($spec) $_settings($_first -$spec)1271 set _settings($spec) $_settings($_first${spec}) 1257 1272 } 1258 1273 AdjustSetting $spec … … 1272 1287 } 1273 1288 switch -- $what { 1274 " background" {1289 "-background" { 1275 1290 set bgcolor [$itk_component(background) value] 1291 set _settings($what) $bgcolor 1276 1292 array set fgcolors { 1277 1293 "black" "white" … … 1284 1300 DrawLegend 1285 1301 } 1286 " outline" {1302 "-volumeoutline" { 1287 1303 set bool $_settings($what) 1288 1304 SendCmd "outline visible 0" … … 1291 1307 } 1292 1308 } 1293 " legendVisible" {1309 "-legendvisible" { 1294 1310 set bool $_settings($what) 1295 set _settings($_current-$what) $bool 1296 } 1297 "volumeVisible" { 1311 } 1312 "-volumevisible" { 1298 1313 set bool $_settings($what) 1299 foreach dataset[CurrentDatasets -visible] {1300 SendCmd "volume visible $bool $ dataset"1314 foreach tag [CurrentDatasets -visible] { 1315 SendCmd "volume visible $bool $tag" 1301 1316 } 1302 1317 if { $bool } { … … 1308 1323 } 1309 1324 } 1310 " volume-material" {1325 "-volumematerial" { 1311 1326 set val $_settings($what) 1312 1327 set diffuse [expr {0.01*$val}] … … 1314 1329 #set power [expr {sqrt(160*$val+1.0)}] 1315 1330 set power [expr {$val+1.0}] 1316 foreach dataset[CurrentDatasets -visible] {1317 SendCmd "volume shading diffuse $diffuse $ dataset"1318 SendCmd "volume shading specular $specular $power $ dataset"1319 } 1320 } 1321 " volumeLighting" {1331 foreach tag [CurrentDatasets -visible] { 1332 SendCmd "volume shading diffuse $diffuse $tag" 1333 SendCmd "volume shading specular $specular $power $tag" 1334 } 1335 } 1336 "-volumelighting" { 1322 1337 set bool $_settings($what) 1323 foreach dataset[CurrentDatasets -visible] {1324 SendCmd "volume lighting $bool $ dataset"1325 } 1326 } 1327 " volume-quality" {1338 foreach tag [CurrentDatasets -visible] { 1339 SendCmd "volume lighting $bool $tag" 1340 } 1341 } 1342 "-volumeopacity" { 1328 1343 set val $_settings($what) 1329 1344 set val [expr {0.01*$val}] 1330 foreach dataset [CurrentDatasets -visible] { 1331 SendCmd "volume quality $val $dataset" 1332 } 1333 } 1334 "axesVisible" { 1345 foreach tag [CurrentDatasets -visible] { 1346 SendCmd "volume opacity $val $tag" 1347 } 1348 } 1349 "-volumequality" { 1350 set val $_settings($what) 1351 set val [expr {0.01*$val}] 1352 foreach tag [CurrentDatasets -visible] { 1353 SendCmd "volume quality $val $tag" 1354 } 1355 } 1356 "-axesvisible" { 1335 1357 set bool $_settings($what) 1336 1358 SendCmd "axis visible all $bool" 1337 1359 } 1338 " axisLabels" {1360 "-axislabels" { 1339 1361 set bool $_settings($what) 1340 1362 SendCmd "axis labels all $bool" 1341 1363 } 1342 "axis-xgrid" - "axis-ygrid" - "axis-zgrid" { 1343 set axis [string range $what 5 5] 1364 "-axisminorticks" { 1365 set bool $_settings($what) 1366 SendCmd "axis minticks all $bool" 1367 } 1368 "-xgrid" - "-ygrid" - "-zgrid" { 1369 set axis [string range $what 1 1] 1344 1370 set bool $_settings($what) 1345 1371 SendCmd "axis grid $axis $bool" 1346 1372 } 1347 " axisFlyMode" {1373 "-axisflymode" { 1348 1374 set mode [$itk_component(axismode) value] 1349 1375 set mode [$itk_component(axismode) translate $mode] … … 1351 1377 SendCmd "axis flymode $mode" 1352 1378 } 1353 " cutplaneEdges" {1379 "-cutplaneedges" { 1354 1380 set bool $_settings($what) 1355 1381 foreach dataset [CurrentDatasets -visible] { 1356 SendCmd " cutplaneedges $bool $dataset"1357 } 1358 } 1359 " cutplaneVisible" {1382 SendCmd "$_cutplaneCmd edges $bool $dataset" 1383 } 1384 } 1385 "-cutplanesvisible" { 1360 1386 set bool $_settings($what) 1361 1387 foreach dataset [CurrentDatasets -visible] { 1362 SendCmd " cutplanevisible $bool $dataset"1363 } 1364 } 1365 " cutplaneWireframe" {1388 SendCmd "$_cutplaneCmd visible $bool $dataset" 1389 } 1390 } 1391 "-cutplanewireframe" { 1366 1392 set bool $_settings($what) 1367 1393 foreach dataset [CurrentDatasets -visible] { 1368 SendCmd " cutplanewireframe $bool $dataset"1369 } 1370 } 1371 " cutplaneLighting" {1394 SendCmd "$_cutplaneCmd wireframe $bool $dataset" 1395 } 1396 } 1397 "-cutplanelighting" { 1372 1398 set bool $_settings($what) 1373 1399 foreach dataset [CurrentDatasets -visible] { 1374 SendCmd " cutplanelighting $bool $dataset"1375 } 1376 } 1377 " cutplane-opacity" {1400 SendCmd "$_cutplaneCmd lighting $bool $dataset" 1401 } 1402 } 1403 "-cutplaneopacity" { 1378 1404 set val $_settings($what) 1379 1405 set sval [expr { 0.01 * double($val) }] 1380 1406 foreach dataset [CurrentDatasets -visible] { 1381 SendCmd " cutplaneopacity $sval $dataset"1382 } 1383 } 1384 " cutplane-xvisible" - "cutplane-yvisible" - "cutplane-zvisible" {1385 set axis [string range $what 9 9]1407 SendCmd "$_cutplaneCmd opacity $sval $dataset" 1408 } 1409 } 1410 "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" { 1411 set axis [string range $what 1 1] 1386 1412 set bool $_settings($what) 1387 1413 if { $bool } { … … 1393 1419 } 1394 1420 foreach dataset [CurrentDatasets -visible] { 1395 SendCmd " cutplaneaxis $axis $bool $dataset"1396 } 1397 } 1398 " cutplane-xposition" - "cutplane-yposition" - "cutplane-zposition" {1399 set axis [string range $what 9 9]1421 SendCmd "$_cutplaneCmd axis $axis $bool $dataset" 1422 } 1423 } 1424 "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" { 1425 set axis [string range $what 1 1] 1400 1426 set pos [expr $_settings($what) * 0.01] 1401 1427 foreach dataset [CurrentDatasets -visible] { 1402 SendCmd " cutplaneslice ${axis} ${pos} $dataset"1428 SendCmd "$_cutplaneCmd slice ${axis} ${pos} $dataset" 1403 1429 } 1404 1430 set _cutplanePending 0 1405 1431 } 1406 " volume-palette" {1432 "-volumepalette" { 1407 1433 set palette [$itk_component(palette) value] 1408 1434 set _settings($what) $palette … … 1413 1439 set _legendPending 1 1414 1440 } 1415 " field" {1441 "-field" { 1416 1442 set label [$itk_component(field) value] 1417 1443 set fname [$itk_component(field) translate $label] … … 1433 1459 foreach dataset [CurrentDatasets -visible $_first] { 1434 1460 #SendCmd "volume colormode $_colorMode ${fname} $dataset" 1435 SendCmd " cutplanecolormode $_colorMode ${fname} $dataset"1461 SendCmd "$_cutplaneCmd colormode $_colorMode ${fname} $dataset" 1436 1462 } 1437 1463 SendCmd "camera reset" … … 1517 1543 $_dataset2style($tag) != $name } { 1518 1544 SendCmd "volume colormap $name $tag" 1519 SendCmd " cutplanecolormap $name-opaque $tag"1545 SendCmd "$_cutplaneCmd colormap $name-opaque $tag" 1520 1546 set _dataset2style($tag) $name 1521 1547 } … … 1531 1557 set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0" 1532 1558 } 1533 if { ![info exists _settings( volume-opacity)] } {1534 set _settings( volume-opacity) $style(-opacity)1535 } 1536 set max $_settings( volume-opacity)1559 if { ![info exists _settings(-volumeopacity)] } { 1560 set _settings(-volumeopacity) $style(-opacity) 1561 } 1562 set max $_settings(-volumeopacity) 1537 1563 1538 1564 set opaqueWmap "0.0 1.0 1.0 1.0" … … 1565 1591 SendCmd "axis color all $rgb" 1566 1592 SendCmd "outline color $rgb" 1567 SendCmd " cutplanecolor $rgb"1593 SendCmd "$_cutplaneCmd color $rgb" 1568 1594 $itk_component(legend) itemconfigure labels -fill $color 1569 1595 $itk_component(legend) itemconfigure limits -fill $color … … 1572 1598 1573 1599 itcl::body Rappture::VtkVolumeViewer::BuildViewTab {} { 1574 set f ont[option get $itk_component(hull) font Font]1575 #set bf ont[option get $itk_component(hull) boldFont Font]1600 set fg [option get $itk_component(hull) font Font] 1601 #set bfg [option get $itk_component(hull) boldFont Font] 1576 1602 1577 1603 set inner [$itk_component(main) insert end \ … … 1582 1608 checkbutton $inner.axes \ 1583 1609 -text "Axes" \ 1584 -variable [itcl::scope _settings( axesVisible)] \1585 -command [itcl::code $this AdjustSetting axesVisible] \1610 -variable [itcl::scope _settings(-axesvisible)] \ 1611 -command [itcl::code $this AdjustSetting -axesvisible] \ 1586 1612 -font "Arial 9" 1587 1613 1588 1614 checkbutton $inner.outline \ 1589 1615 -text "Outline" \ 1590 -variable [itcl::scope _settings( outline)] \1591 -command [itcl::code $this AdjustSetting outline] \1616 -variable [itcl::scope _settings(-volumeoutline)] \ 1617 -command [itcl::code $this AdjustSetting -volumeoutline] \ 1592 1618 -font "Arial 9" 1593 1619 1594 1620 checkbutton $inner.legend \ 1595 1621 -text "Legend" \ 1596 -variable [itcl::scope _settings( legendVisible)] \1597 -command [itcl::code $this AdjustSetting legendVisible] \1622 -variable [itcl::scope _settings(-legendvisible)] \ 1623 -command [itcl::code $this AdjustSetting -legendvisible] \ 1598 1624 -font "Arial 9" 1599 1625 1600 1626 checkbutton $inner.volume \ 1601 1627 -text "Volume" \ 1602 -variable [itcl::scope _settings( volumeVisible)] \1603 -command [itcl::code $this AdjustSetting volumeVisible] \1628 -variable [itcl::scope _settings(-volumevisible)] \ 1629 -command [itcl::code $this AdjustSetting -volumevisible] \ 1604 1630 -font "Arial 9" 1605 1631 … … 1613 1639 "grey" "grey" 1614 1640 1615 $itk_component(background) value $_settings( background)1641 $itk_component(background) value $_settings(-background) 1616 1642 bind $inner.background <<Value>> \ 1617 [itcl::code $this AdjustSetting background]1643 [itcl::code $this AdjustSetting -background] 1618 1644 1619 1645 blt::table $inner \ … … 1638 1664 $inner configure -borderwidth 4 1639 1665 1640 checkbutton $inner.v olume\1641 -text " Show Volume" \1642 - variable [itcl::scope _settings(volumeVisible)]\1643 - command [itcl::code $this AdjustSetting volumeVisible] \1644 - font "Arial 9"1666 checkbutton $inner.visibility \ 1667 -text "Visible" \ 1668 -font $font \ 1669 -variable [itcl::scope _settings(-volumevisible)] \ 1670 -command [itcl::code $this AdjustSetting -volumevisible] 1645 1671 1646 1672 checkbutton $inner.lighting \ 1647 1673 -text "Enable Lighting" \ 1648 - variable [itcl::scope _settings(volumeLighting)]\1649 - command [itcl::code $this AdjustSetting volumeLighting] \1650 - font "Arial 9"1651 1652 label $inner.dim_l -text "Dim" -font "Arial 9"1674 -font $font \ 1675 -variable [itcl::scope _settings(-volumelighting)] \ 1676 -command [itcl::code $this AdjustSetting -volumelighting] 1677 1678 label $inner.dim_l -text "Dim" -font $font 1653 1679 ::scale $inner.material -from 0 -to 100 -orient horizontal \ 1654 -variable [itcl::scope _settings(volume-material)] \ 1655 -width 10 \ 1656 -showvalue off -command [itcl::code $this AdjustSetting volume-material] 1657 label $inner.bright_l -text "Bright" -font "Arial 9" 1658 1659 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1680 -variable [itcl::scope _settings(-volumematerial)] \ 1681 -showvalue off -command [itcl::code $this AdjustSetting -volumematerial] 1682 label $inner.bright_l -text "Bright" -font $font 1683 1684 label $inner.opacity_l -text "Opacity" -font $font 1660 1685 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1661 -variable [itcl::scope _settings(volume-opacity)] \ 1662 -width 10 \ 1686 -variable [itcl::scope _settings(-volumeopacity)] \ 1663 1687 -showvalue off \ 1664 -command [itcl::code $this AdjustSetting volume-opacity]1665 1666 label $inner.quality_l -text "Quality" -font "Arial 9"1688 -command [itcl::code $this AdjustSetting -volumeopacity] 1689 1690 label $inner.quality_l -text "Quality" -font $font 1667 1691 ::scale $inner.quality -from 0 -to 100 -orient horizontal \ 1668 -variable [itcl::scope _settings(volume-quality)] \ 1669 -width 10 \ 1670 -showvalue off -command [itcl::code $this AdjustSetting volume-quality] 1671 1672 itk_component add field_l { 1673 label $inner.field_l -text "Field" -font "Arial 9" 1674 } { 1675 ignore -font 1676 } 1692 -variable [itcl::scope _settings(-volumequality)] \ 1693 -showvalue off \ 1694 -command [itcl::code $this AdjustSetting -volumequality] 1695 1696 label $inner.field_l -text "Field" -font $font 1677 1697 itk_component add field { 1678 Rappture::Combobox $inner.field - width 10 -editable no1698 Rappture::Combobox $inner.field -editable no 1679 1699 } 1680 1700 bind $inner.field <<Value>> \ 1681 [itcl::code $this AdjustSetting field]1682 1683 label $inner.palette_l -text "Palette" -font "Arial 9"1701 [itcl::code $this AdjustSetting -field] 1702 1703 label $inner.palette_l -text "Palette" -font $font 1684 1704 itk_component add palette { 1685 Rappture::Combobox $inner.palette -width 10 -editable no 1686 } 1687 1705 Rappture::Combobox $inner.palette -editable no 1706 } 1688 1707 $inner.palette choices insert end [GetColormapList] 1689 1708 $itk_component(palette) value "BCGYR" 1690 1709 bind $inner.palette <<Value>> \ 1691 [itcl::code $this AdjustSetting volume-palette]1710 [itcl::code $this AdjustSetting -volumepalette] 1692 1711 1693 1712 blt::table $inner \ 1694 1713 0,0 $inner.field_l -anchor w -pady 2 \ 1695 0,1 $inner.field - anchor w -pady 2 -cspan 2\1696 1,0 $inner.v olume-anchor w -pady 2 -cspan 4 \1714 0,1 $inner.field -fill x -pady 2 -cspan 3 \ 1715 1,0 $inner.visibility -anchor w -pady 2 -cspan 4 \ 1697 1716 2,0 $inner.lighting -anchor w -pady 2 -cspan 4 \ 1698 1717 3,0 $inner.dim_l -anchor e -pady 2 \ 1699 3,1 $inner.material -fill x -pady 2 \ 1700 3,2 $inner.bright_l -anchor w -pady 2 \ 1701 4,0 $inner.quality_l -anchor w -pady 2 -cspan 2 \ 1702 5,0 $inner.quality -fill x -pady 2 -cspan 2 \ 1703 7,0 $inner.palette_l -anchor w -pady 2 \ 1704 7,1 $inner.palette -anchor w -pady 2 -cspan 2 \ 1705 1706 blt::table configure $inner r* c* -resize none 1707 blt::table configure $inner r8 -resize expand 1718 3,1 $inner.material -fill x -pady 2 -cspan 2 \ 1719 3,3 $inner.bright_l -anchor w -pady 2 \ 1720 4,0 $inner.opacity_l -anchor w -pady 2 -cspan 4 \ 1721 5,0 $inner.opacity -fill x -pady 2 -cspan 4 \ 1722 6,0 $inner.quality_l -anchor w -pady 2 -cspan 4 \ 1723 7,0 $inner.quality -fill x -pady 2 -cspan 4 \ 1724 8,0 $inner.palette_l -anchor w -pady 2 \ 1725 8,1 $inner.palette -fill x -pady 2 -cspan 3 \ 1726 1727 blt::table configure $inner r* c0 c1 c3 -resize none 1728 blt::table configure $inner r9 c2 -resize expand 1708 1729 } 1709 1730 1710 1731 itcl::body Rappture::VtkVolumeViewer::BuildAxisTab {} { 1711 set f ont[option get $itk_component(hull) font Font]1712 #set bf ont[option get $itk_component(hull) boldFont Font]1732 set fg [option get $itk_component(hull) font Font] 1733 #set bfg [option get $itk_component(hull) boldFont Font] 1713 1734 1714 1735 set inner [$itk_component(main) insert end \ 1715 1736 -title "Axis Settings" \ 1716 -icon [Rappture::icon axis 1]]1737 -icon [Rappture::icon axis2]] 1717 1738 $inner configure -borderwidth 4 1718 1739 1719 1740 checkbutton $inner.visible \ 1720 -text " ShowAxes" \1721 -variable [itcl::scope _settings( axesVisible)] \1722 -command [itcl::code $this AdjustSetting axesVisible] \1741 -text "Axes" \ 1742 -variable [itcl::scope _settings(-axesvisible)] \ 1743 -command [itcl::code $this AdjustSetting -axesvisible] \ 1723 1744 -font "Arial 9" 1724 1745 1725 1746 checkbutton $inner.labels \ 1726 -text " ShowAxis Labels" \1727 -variable [itcl::scope _settings( axisLabels)] \1728 -command [itcl::code $this AdjustSetting axisLabels] \1747 -text "Axis Labels" \ 1748 -variable [itcl::scope _settings(-axislabels)] \ 1749 -command [itcl::code $this AdjustSetting -axislabels] \ 1729 1750 -font "Arial 9" 1730 1731 checkbutton $inner. gridx\1732 -text " Show X Grid" \1733 -variable [itcl::scope _settings( axis-xgrid)] \1734 -command [itcl::code $this AdjustSetting axis-xgrid] \1751 label $inner.grid_l -text "Grid" -font "Arial 9" 1752 checkbutton $inner.xgrid \ 1753 -text "X" \ 1754 -variable [itcl::scope _settings(-xgrid)] \ 1755 -command [itcl::code $this AdjustSetting -xgrid] \ 1735 1756 -font "Arial 9" 1736 checkbutton $inner. gridy\1737 -text " Show Y Grid" \1738 -variable [itcl::scope _settings( axis-ygrid)] \1739 -command [itcl::code $this AdjustSetting axis-ygrid] \1757 checkbutton $inner.ygrid \ 1758 -text "Y" \ 1759 -variable [itcl::scope _settings(-ygrid)] \ 1760 -command [itcl::code $this AdjustSetting -ygrid] \ 1740 1761 -font "Arial 9" 1741 checkbutton $inner.gridz \ 1742 -text "Show Z Grid" \ 1743 -variable [itcl::scope _settings(axis-zgrid)] \ 1744 -command [itcl::code $this AdjustSetting axis-zgrid] \ 1762 checkbutton $inner.zgrid \ 1763 -text "Z" \ 1764 -variable [itcl::scope _settings(-zgrid)] \ 1765 -command [itcl::code $this AdjustSetting -zgrid] \ 1766 -font "Arial 9" 1767 checkbutton $inner.minorticks \ 1768 -text "Minor Ticks" \ 1769 -variable [itcl::scope _settings(-axisminorticks)] \ 1770 -command [itcl::code $this AdjustSetting -axisminorticks] \ 1745 1771 -font "Arial 9" 1746 1772 … … 1755 1781 "furthest_triad" "farthest" \ 1756 1782 "outer_edges" "outer" 1757 $itk_component(axismode) value "static"1758 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axisFlyMode]1783 $itk_component(axismode) value $_settings(-axisflymode) 1784 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode] 1759 1785 1760 1786 blt::table $inner \ 1761 0,0 $inner.visible -anchor w -cspan 2 \ 1762 1,0 $inner.labels -anchor w -cspan 2 \ 1763 2,0 $inner.gridx -anchor w -cspan 2 \ 1764 3,0 $inner.gridy -anchor w -cspan 2 \ 1765 4,0 $inner.gridz -anchor w -cspan 2 \ 1766 5,0 $inner.mode_l -anchor w -cspan 2 -padx { 2 0 } \ 1767 6,0 $inner.mode -fill x -cspan 2 1787 0,0 $inner.visible -anchor w -cspan 4 \ 1788 1,0 $inner.labels -anchor w -cspan 4 \ 1789 2,0 $inner.minorticks -anchor w -cspan 4 \ 1790 4,0 $inner.grid_l -anchor w \ 1791 4,1 $inner.xgrid -anchor w \ 1792 4,2 $inner.ygrid -anchor w \ 1793 4,3 $inner.zgrid -anchor w \ 1794 5,0 $inner.mode_l -anchor w -padx { 2 0 } \ 1795 5,1 $inner.mode -fill x -cspan 3 1768 1796 1769 1797 blt::table configure $inner r* c* -resize none 1770 blt::table configure $inner r7 c1 -resize expand 1798 blt::table configure $inner r7 c6 -resize expand 1799 blt::table configure $inner r3 -height 0.125i 1771 1800 } 1772 1801 … … 1777 1806 $inner configure -borderwidth 4 1778 1807 1808 label $inner.view_l -text "view" -font "Arial 9" 1809 set f [frame $inner.view] 1810 foreach side { front back left right top bottom } { 1811 button $f.$side -image [Rappture::icon view$side] \ 1812 -command [itcl::code $this SetOrientation $side] 1813 Rappture::Tooltip::for $f.$side "Change the view to $side" 1814 pack $f.$side -side left 1815 } 1816 blt::table $inner \ 1817 0,0 $inner.view_l -anchor e -pady 2 \ 1818 0,1 $inner.view -anchor w -pady 2 1819 blt::table configure $inner r0 -resize none 1820 1821 set row 1 1779 1822 set labels { qx qy qz qw xpan ypan zoom } 1780 set row 01781 1823 foreach tag $labels { 1782 label $inner.${tag} label -text $tag -font "Arial 9"1824 label $inner.${tag}-label -text $tag -font "Arial 9" 1783 1825 entry $inner.${tag} -font "Arial 9" -bg white \ 1784 -textvariable [itcl::scope _view($tag)] 1785 bind $inner.${tag} <KeyPress-Return> \ 1786 [itcl::code $this camera set ${tag}] 1826 -textvariable [itcl::scope _view(-$tag)] 1827 bind $inner.${tag} <Return> \ 1828 [itcl::code $this camera set -${tag}] 1829 bind $inner.${tag} <KP_Enter> \ 1830 [itcl::code $this camera set -${tag}] 1787 1831 blt::table $inner \ 1788 $row,0 $inner.${tag} label -anchor e -pady 2 \1832 $row,0 $inner.${tag}-label -anchor e -pady 2 \ 1789 1833 $row,1 $inner.${tag} -anchor w -pady 2 1790 1834 blt::table configure $inner r$row -resize none … … 1793 1837 checkbutton $inner.ortho \ 1794 1838 -text "Orthographic Projection" \ 1795 -variable [itcl::scope _view( ortho)] \1796 -command [itcl::code $this camera set ortho] \1839 -variable [itcl::scope _view(-ortho)] \ 1840 -command [itcl::code $this camera set -ortho] \ 1797 1841 -font "Arial 9" 1798 1842 blt::table $inner \ … … 1817 1861 checkbutton $inner.visible \ 1818 1862 -text "Show Cutplanes" \ 1819 -variable [itcl::scope _settings( cutplaneVisible)] \1820 -command [itcl::code $this AdjustSetting cutplaneVisible] \1863 -variable [itcl::scope _settings(-cutplanesvisible)] \ 1864 -command [itcl::code $this AdjustSetting -cutplanesvisible] \ 1821 1865 -font "Arial 9" 1822 1866 1823 1867 checkbutton $inner.wireframe \ 1824 1868 -text "Show Wireframe" \ 1825 -variable [itcl::scope _settings( cutplaneWireframe)] \1826 -command [itcl::code $this AdjustSetting cutplaneWireframe] \1869 -variable [itcl::scope _settings(-cutplanewireframe)] \ 1870 -command [itcl::code $this AdjustSetting -cutplanewireframe] \ 1827 1871 -font "Arial 9" 1828 1872 1829 1873 checkbutton $inner.lighting \ 1830 1874 -text "Enable Lighting" \ 1831 -variable [itcl::scope _settings( cutplaneLighting)] \1832 -command [itcl::code $this AdjustSetting cutplaneLighting] \1875 -variable [itcl::scope _settings(-cutplanelighting)] \ 1876 -command [itcl::code $this AdjustSetting -cutplanelighting] \ 1833 1877 -font "Arial 9" 1834 1878 1835 1879 checkbutton $inner.edges \ 1836 1880 -text "Show Edges" \ 1837 -variable [itcl::scope _settings( cutplaneEdges)] \1838 -command [itcl::code $this AdjustSetting cutplaneEdges] \1881 -variable [itcl::scope _settings(-cutplaneedges)] \ 1882 -command [itcl::code $this AdjustSetting -cutplaneedges] \ 1839 1883 -font "Arial 9" 1840 1884 1841 1885 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1842 1886 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1843 -variable [itcl::scope _settings( cutplane-opacity)] \1887 -variable [itcl::scope _settings(-cutplaneopacity)] \ 1844 1888 -width 10 \ 1845 1889 -showvalue off \ 1846 -command [itcl::code $this AdjustSetting cutplane-opacity]1847 $inner.opacity set $_settings( cutplane-opacity)1890 -command [itcl::code $this AdjustSetting -cutplaneopacity] 1891 $inner.opacity set $_settings(-cutplaneopacity) 1848 1892 1849 1893 # X-value slicer... … … 1852 1896 -onimage [Rappture::icon x-cutplane] \ 1853 1897 -offimage [Rappture::icon x-cutplane] \ 1854 -command [itcl::code $this AdjustSetting cutplane-xvisible] \1855 -variable [itcl::scope _settings( cutplane-xvisible)]1898 -command [itcl::code $this AdjustSetting -xcutplanevisible] \ 1899 -variable [itcl::scope _settings(-xcutplanevisible)] 1856 1900 } 1857 1901 Rappture::Tooltip::for $itk_component(xCutButton) \ … … 1864 1908 -borderwidth 1 -highlightthickness 0 \ 1865 1909 -command [itcl::code $this EventuallySetCutplane x] \ 1866 -variable [itcl::scope _settings( cutplane-xposition)]1910 -variable [itcl::scope _settings(-xcutplaneposition)] 1867 1911 } { 1868 1912 usual … … 1880 1924 -onimage [Rappture::icon y-cutplane] \ 1881 1925 -offimage [Rappture::icon y-cutplane] \ 1882 -command [itcl::code $this AdjustSetting cutplane-yvisible] \1883 -variable [itcl::scope _settings( cutplane-yvisible)]1926 -command [itcl::code $this AdjustSetting -ycutplanevisible] \ 1927 -variable [itcl::scope _settings(-ycutplanevisible)] 1884 1928 } 1885 1929 Rappture::Tooltip::for $itk_component(yCutButton) \ … … 1892 1936 -borderwidth 1 -highlightthickness 0 \ 1893 1937 -command [itcl::code $this EventuallySetCutplane y] \ 1894 -variable [itcl::scope _settings( cutplane-yposition)]1938 -variable [itcl::scope _settings(-ycutplaneposition)] 1895 1939 } { 1896 1940 usual … … 1908 1952 -onimage [Rappture::icon z-cutplane] \ 1909 1953 -offimage [Rappture::icon z-cutplane] \ 1910 -command [itcl::code $this AdjustSetting cutplane-zvisible] \1911 -variable [itcl::scope _settings( cutplane-zvisible)]1954 -command [itcl::code $this AdjustSetting -zcutplanevisible] \ 1955 -variable [itcl::scope _settings(-zcutplanevisible)] 1912 1956 } 1913 1957 Rappture::Tooltip::for $itk_component(zCutButton) \ … … 1920 1964 -borderwidth 1 -highlightthickness 0 \ 1921 1965 -command [itcl::code $this EventuallySetCutplane z] \ 1922 -variable [itcl::scope _settings( cutplane-zposition)]1966 -variable [itcl::scope _settings(-zcutplaneposition)] 1923 1967 } { 1924 1968 usual … … 1964 2008 } 1965 2009 switch -- $who { 1966 " ortho" {1967 if {$_view( ortho)} {2010 "-ortho" { 2011 if {$_view(-ortho)} { 1968 2012 SendCmd "camera mode ortho" 1969 2013 } else { … … 1971 2015 } 1972 2016 } 1973 " xpan" - "ypan" {2017 "-xpan" - "-ypan" { 1974 2018 PanCamera 1975 2019 } 1976 " qx" - "qy" - "qz" - "qw" {1977 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2020 "-qx" - "-qy" - "-qz" - "-qw" { 2021 set q [ViewToQuaternion] 1978 2022 $_arcball quaternion $q 1979 2023 EventuallyRotate $q 1980 2024 } 1981 " zoom" {1982 SendCmd "camera zoom $_view( zoom)"2025 "-zoom" { 2026 SendCmd "camera zoom $_view(-zoom)" 1983 2027 } 1984 2028 } … … 2071 2115 array set settings $style 2072 2116 SendCmd "volume add $tag" 2073 SendCmd " cutplaneadd $tag"2074 SendCmd " cutplanevisible 0 $tag"2117 SendCmd "$_cutplaneCmd add $tag" 2118 SendCmd "$_cutplaneCmd visible 0 $tag" 2075 2119 2076 2120 SendCmd "volume lighting $settings(-lighting) $tag" 2077 set _settings( volumeLighting) $settings(-lighting)2121 set _settings(-volumelighting) $settings(-lighting) 2078 2122 SetColormap $dataobj $comp 2079 2123 SendCmd "outline add $tag" … … 2097 2141 itcl::body Rappture::VtkVolumeViewer::ReceiveLegend { colormap title vmin vmax size } { 2098 2142 set _legendPending 0 2099 #puts stderr "ReceiveLegend colormap=$colormap title=$title range=$vmin,$vmax size=$size" 2100 if { [IsConnected] } { 2143 if { [isconnected] } { 2101 2144 set bytes [ReceiveBytes $size] 2102 2145 if { ![info exists _image(legend)] } { … … 2133 2176 set title $fname 2134 2177 } 2135 if { $_settings( legendVisible) } {2178 if { $_settings(-legendvisible) } { 2136 2179 set x [expr $w - 2] 2137 2180 if { [$c find withtag "legend"] == "" } { … … 2270 2313 } 2271 2314 set newpos [expr {0.01*$newval}] 2272 SendCmd " cutplaneslice $axis $newpos"2315 SendCmd "$_cutplaneCmd slice $axis $newpos" 2273 2316 } 2274 2317 "tooltip" { … … 2321 2364 } 2322 2365 2366 itcl::body Rappture::VtkVolumeViewer::SetOrientation { side } { 2367 array set positions { 2368 front "1 0 0 0" 2369 back "0 0 1 0" 2370 left "0.707107 0 -0.707107 0" 2371 right "0.707107 0 0.707107 0" 2372 top "0.707107 -0.707107 0 0" 2373 bottom "0.707107 0.707107 0 0" 2374 } 2375 foreach name { -qw -qx -qy -qz } value $positions($side) { 2376 set _view($name) $value 2377 } 2378 set q [ViewToQuaternion] 2379 $_arcball quaternion $q 2380 SendCmd "camera orient $q" 2381 SendCmd "camera reset" 2382 set _view(-xpan) 0 2383 set _view(-ypan) 0 2384 set _view(-zoom) 1.0 2385 }
Note: See TracChangeset
for help on using the changeset viewer.