Changeset 4507 for branches/1.3/gui
- Timestamp:
- Jul 16, 2014 1:54:18 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3/gui/scripts/vtkmeshviewer.tcl
r4474 r4507 92 92 private method PanCamera {} 93 93 private method SetObjectStyle { dataobj } 94 private method SetOpacity { dataset }95 94 private method SetOrientation { side } 96 95 private method SetPolydataOpacity {} … … 114 113 private variable _style; # Array of current component styles. 115 114 private variable _initialStyle; # Array of initial component styles. 116 private variable _axis117 115 private variable _reset 1; # Indicates that server was reset and 118 116 # needs to be reinitialized. 119 117 120 private variable _first "" ;# This is the topmost dataset.118 private variable _first ""; # This is the topmost dataset. 121 119 private variable _start 0 122 120 private variable _title "" 123 121 124 common _downloadPopup ;# download options from popup122 common _downloadPopup; # download options from popup 125 123 private common _hardcopy 126 124 private variable _width 0 … … 184 182 set _limits(zmax) 1.0 185 183 186 array set _axis [subst { 187 xgrid 0 188 ygrid 0 189 zgrid 0 190 xcutaway 0 191 ycutaway 0 192 zcutaway 0 193 xposition 0 194 yposition 0 195 zposition 0 196 xdirection -1 197 ydirection -1 198 zdirection -1 199 visible 1 200 labels 1 201 }] 202 array set _settings [subst { 203 outline 0 204 polydata-edges 0 205 polydata-lighting 1 206 polydata-opacity 100 207 polydata-visible 1 208 polydata-wireframe 0 209 }] 184 array set _settings { 185 -axesvisible 1 186 -axislabels 1 187 -outline 0 188 -polydataedges 0 189 -polydatalighting 1 190 -polydataopacity 100 191 -polydatavisible 1 192 -polydatawireframe 0 193 -xcutaway 0 194 -xdirection -1 195 -xgrid 0 196 -xposition 0 197 -ycutaway 0 198 -ydirection -1 199 -ygrid 0 200 -yposition 0 201 -zcutaway 0 202 -zdirection -1 203 -zgrid 0 204 -zposition 0 205 } 210 206 itk_component add view { 211 207 canvas $itk_component(plotarea).view \ … … 407 403 itcl::body Rappture::VtkMeshViewer::SetPolydataOpacity {} { 408 404 set _polydataOpacityPending 0 409 foreach dataset [CurrentDatasets -visible $_first] { 410 SetOpacity $dataset 411 } 412 } 413 414 itcl::body Rappture::VtkMeshViewer::EventuallySetPolydataOpacity { args } { 405 set val $_settings(-polydataopacity) 406 set sval [expr { 0.01 * double($val) }] 407 SendCmd "polydata opacity $sval" 408 } 409 410 itcl::body Rappture::VtkMeshViewer::EventuallySetPolydataOpacity { val } { 411 set _settings(-polydataopacity) $val 415 412 if { !$_polydataOpacityPending } { 416 413 set _polydataOpacityPending 1 … … 478 475 set _dlist [lreplace $_dlist $pos $pos] 479 476 array unset _obj2ovride $dataobj-* 480 array unset _settings $dataobj-*481 477 set changed 1 482 478 } … … 832 828 $_arcball resize $w $h 833 829 DoResize 834 InitSettings axis-xgrid axis-ygrid axis-zgrid axis-mode \ 835 axis-visible axis-labels 836 830 InitSettings -xgrid -ygrid -zgrid -axismode -axesvisible -axislabels 837 831 StopBufferingCommands 838 832 SendCmd "imgflush" … … 874 868 } 875 869 lappend _obj2datasets($dataobj) $tag 876 if { [info exists _obj2ovride($dataobj-raise)] } { 870 if { [info exists _obj2ovride($dataobj-raise)] && 871 $_obj2ovride($dataobj-raise) } { 877 872 SendCmd "dataset visible 1 $tag" 878 873 SetOpacity $tag … … 896 891 } 897 892 } 898 InitSettings outline893 InitSettings -outline 899 894 if { $_reset } { 900 895 # These are settings that rely on a dataset being loaded. 901 InitSettings polydata-edges polydata-lighting polydata-opacity \902 polydata-visible polydata-wireframe896 InitSettings -polydataedges -polydatalighting -polydataopacity \ 897 -polydatavisible -polydatawireframe 903 898 904 899 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] … … 1152 1147 } 1153 1148 switch -- $what { 1154 "outline" { 1155 set bool $_settings(outline) 1156 foreach dataset [CurrentDatasets -visible $_first] { 1149 "-outline" { 1150 set bool $_settings($what) 1151 # Only display a outline for the currently visible sets. 1152 SendCmd "outline visible 0" 1153 foreach dataset [CurrentDatasets -visible] { 1157 1154 SendCmd "outline visible $bool $dataset" 1158 1155 } 1159 1156 } 1160 "polydata-opacity" { 1161 foreach dataset [CurrentDatasets -visible $_first] { 1162 SetOpacity $dataset 1163 } 1164 } 1165 "polydata-wireframe" { 1166 set bool $_settings(polydata-wireframe) 1167 foreach dataset [CurrentDatasets -visible $_first] { 1168 SendCmd "polydata wireframe $bool $dataset" 1169 } 1170 } 1171 "polydata-visible" { 1172 set bool $_settings(polydata-visible) 1173 foreach dataset [CurrentDatasets -visible $_first] { 1157 "-polydataopacity" { 1158 EventuallySetPolydataOpacity 1159 } 1160 "-polydatawireframe" { 1161 set bool $_settings($what) 1162 SendCmd "polydata wireframe $bool" 1163 } 1164 "-polydatavisible" { 1165 set bool $_settings($what) 1166 # Only change visibility of data sets marked "visible". 1167 foreach dataset [CurrentDatasets -visible] { 1174 1168 SendCmd "polydata visible $bool $dataset" 1175 1169 } 1176 1170 } 1177 "polydata-lighting" { 1178 set bool $_settings(polydata-lighting) 1179 foreach dataset [CurrentDatasets -visible $_first] { 1180 SendCmd "polydata lighting $bool $dataset" 1181 } 1182 } 1183 "polydata-edges" { 1184 set bool $_settings(polydata-edges) 1185 foreach dataset [CurrentDatasets -visible $_first] { 1186 SendCmd "polydata edges $bool $dataset" 1187 } 1188 } 1189 "axis-visible" { 1190 set bool $_axis(visible) 1171 "-polydatalighting" { 1172 set bool $_settings($what) 1173 SendCmd "polydata lighting $bool" 1174 } 1175 "-polydataedges" { 1176 set bool $_settings($what) 1177 SendCmd "polydata edges $bool" 1178 } 1179 "-axesvisible" { 1180 set bool $_settings($what) 1191 1181 SendCmd "axis visible all $bool" 1192 1182 } 1193 " axis-labels" {1194 set bool $_ axis(labels)1183 "-axislabels" { 1184 set bool $_settings($what) 1195 1185 SendCmd "axis labels all $bool" 1196 1186 } 1197 " axis-xgrid" {1198 set bool $_ axis(xgrid)1187 "-xgrid" { 1188 set bool $_settings($what) 1199 1189 SendCmd "axis grid x $bool" 1200 1190 } 1201 " axis-ygrid" {1202 set bool $_ axis(ygrid)1191 "-ygrid" { 1192 set bool $_settings($what) 1203 1193 SendCmd "axis grid y $bool" 1204 1194 } 1205 " axis-zgrid" {1206 set bool $_ axis(zgrid)1195 "-zgrid" { 1196 set bool $_settings($what) 1207 1197 SendCmd "axis grid z $bool" 1208 1198 } 1209 " axis-mode" {1199 "-axismode" { 1210 1200 set mode [$itk_component(axismode) value] 1211 1201 set mode [$itk_component(axismode) translate $mode] 1212 1202 SendCmd "axis flymode $mode" 1213 1203 } 1214 " axis-xcutaway" - "axis-ycutaway" - "axis-zcutaway" {1215 set axis [string range $what 5 5]1216 set bool $_ axis(${axis}cutaway)1204 "-xcutaway" - "-ycutaway" - "-zcutaway" { 1205 set axis [string range $what 1 1] 1206 set bool $_settings($what) 1217 1207 if { $bool } { 1218 set pos [expr $_ axis(${axis}position) * 0.01]1219 set dir $_ axis(${axis}direction)1208 set pos [expr $_settings(-${axis}position) * 0.01] 1209 set dir $_settings(-${axis}direction) 1220 1210 $itk_component(${axis}CutScale) configure -state normal \ 1221 1211 -troughcolor white … … 1227 1217 } 1228 1218 } 1229 "axis-xposition" - "axis-yposition" - "axis-zposition" - 1230 "axis-xdirection" - "axis-ydirection" - "axis-zdirection" { 1231 set axis [string range $what 5 5] 1232 #set dir $_axis(${axis}direction) 1233 set pos [expr $_axis(${axis}position) * 0.01] 1219 "-xposition" - "-yposition" - "-zposition" { 1220 set axis [string range $what 1 1] 1221 set pos [expr $_settings($what) * 0.01] 1234 1222 SendCmd "renderer clipplane ${axis} $pos -1" 1223 } 1224 "-xdirection" - "-ydirection" - "-zdirection" { 1225 set axis [string range $what 1 1] 1226 puts stderr "direction not implemented" 1235 1227 } 1236 1228 default { … … 1317 1309 checkbutton $inner.mesh \ 1318 1310 -text "Show Mesh" \ 1319 -variable [itcl::scope _settings( polydata-visible)] \1320 -command [itcl::code $this AdjustSetting polydata-visible] \1311 -variable [itcl::scope _settings(-polydatavisible)] \ 1312 -command [itcl::code $this AdjustSetting -polydatavisible] \ 1321 1313 -font "Arial 9" -anchor w 1322 1314 1323 1315 checkbutton $inner.outline \ 1324 1316 -text "Show Outline" \ 1325 -variable [itcl::scope _settings( outline)] \1326 -command [itcl::code $this AdjustSetting outline] \1317 -variable [itcl::scope _settings(-outline)] \ 1318 -command [itcl::code $this AdjustSetting -outline] \ 1327 1319 -font "Arial 9" -anchor w 1328 1320 1329 1321 checkbutton $inner.wireframe \ 1330 1322 -text "Show Wireframe" \ 1331 -variable [itcl::scope _settings( polydata-wireframe)] \1332 -command [itcl::code $this AdjustSetting polydata-wireframe] \1323 -variable [itcl::scope _settings(-polydatawireframe)] \ 1324 -command [itcl::code $this AdjustSetting -polydatawireframe] \ 1333 1325 -font "Arial 9" -anchor w 1334 1326 1335 1327 checkbutton $inner.lighting \ 1336 1328 -text "Enable Lighting" \ 1337 -variable [itcl::scope _settings( polydata-lighting)] \1338 -command [itcl::code $this AdjustSetting polydata-lighting] \1329 -variable [itcl::scope _settings(-polydatalighting)] \ 1330 -command [itcl::code $this AdjustSetting -polydatalighting] \ 1339 1331 -font "Arial 9" -anchor w 1340 1332 1341 1333 checkbutton $inner.edges \ 1342 1334 -text "Show Edges" \ 1343 -variable [itcl::scope _settings( polydata-edges)] \1344 -command [itcl::code $this AdjustSetting polydata-edges] \1335 -variable [itcl::scope _settings(-polydataedges)] \ 1336 -command [itcl::code $this AdjustSetting -polydataedges] \ 1345 1337 -font "Arial 9" -anchor w 1346 1338 … … 1354 1346 } 1355 1347 bind $inner.field <<Value>> \ 1356 [itcl::code $this AdjustSetting field]1348 [itcl::code $this AdjustSetting -field] 1357 1349 1358 1350 label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w 1359 1351 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1360 -variable [itcl::scope _settings( polydata-opacity)] \1352 -variable [itcl::scope _settings(-polydataopacity)] \ 1361 1353 -width 10 \ 1362 1354 -showvalue off \ 1363 -command [itcl::code $this AdjustSetting polydata-opacity]1364 $inner.opacity set $_settings( polydata-opacity)1355 -command [itcl::code $this AdjustSetting -polydataopacity] 1356 $inner.opacity set $_settings(-polydataopacity) 1365 1357 1366 1358 blt::table $inner \ … … 1389 1381 checkbutton $inner.visible \ 1390 1382 -text "Show Axes" \ 1391 -variable [itcl::scope _ axis(visible)] \1392 -command [itcl::code $this AdjustSetting axis-visible] \1383 -variable [itcl::scope _settings(-axesvisible)] \ 1384 -command [itcl::code $this AdjustSetting -axesvisible] \ 1393 1385 -font "Arial 9" 1394 1386 1395 1387 checkbutton $inner.labels \ 1396 1388 -text "Show Axis Labels" \ 1397 -variable [itcl::scope _ axis(labels)] \1398 -command [itcl::code $this AdjustSetting axis-labels] \1389 -variable [itcl::scope _settings(-axislabels)] \ 1390 -command [itcl::code $this AdjustSetting -axislabels] \ 1399 1391 -font "Arial 9" 1400 1392 1401 1393 checkbutton $inner.gridx \ 1402 1394 -text "Show X Grid" \ 1403 -variable [itcl::scope _ axis(xgrid)] \1404 -command [itcl::code $this AdjustSetting axis-xgrid] \1395 -variable [itcl::scope _settings(-xgrid)] \ 1396 -command [itcl::code $this AdjustSetting -xgrid] \ 1405 1397 -font "Arial 9" 1406 1398 checkbutton $inner.gridy \ 1407 1399 -text "Show Y Grid" \ 1408 -variable [itcl::scope _ axis(ygrid)] \1409 -command [itcl::code $this AdjustSetting axis-ygrid] \1400 -variable [itcl::scope _settings(-ygrid)] \ 1401 -command [itcl::code $this AdjustSetting -ygrid] \ 1410 1402 -font "Arial 9" 1411 1403 checkbutton $inner.gridz \ 1412 1404 -text "Show Z Grid" \ 1413 -variable [itcl::scope _ axis(zgrid)] \1414 -command [itcl::code $this AdjustSetting axis-zgrid] \1405 -variable [itcl::scope _settings(-zgrid)] \ 1406 -command [itcl::code $this AdjustSetting -zgrid] \ 1415 1407 -font "Arial 9" 1416 1408 … … 1426 1418 "outer_edges" "outer" 1427 1419 $itk_component(axismode) value "static" 1428 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axis-mode]1420 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode] 1429 1421 1430 1422 blt::table $inner \ … … 1504 1496 -onimage [Rappture::icon x-cutplane] \ 1505 1497 -offimage [Rappture::icon x-cutplane] \ 1506 -command [itcl::code $this AdjustSetting axis-xcutaway] \1507 -variable [itcl::scope _ axis(xcutaway)]1498 -command [itcl::code $this AdjustSetting -xcutaway] \ 1499 -variable [itcl::scope _settings(-xcutaway)] 1508 1500 } 1509 1501 Rappture::Tooltip::for $itk_component(xCutButton) \ … … 1515 1507 -borderwidth 1 -highlightthickness 0 \ 1516 1508 -command [itcl::code $this Slice move x] \ 1517 -variable [itcl::scope _ axis(xposition)]1509 -variable [itcl::scope _settings(-xposition)] 1518 1510 } { 1519 1511 usual … … 1532 1524 -offimage [Rappture::icon arrow-up] \ 1533 1525 -offvalue 1 \ 1534 -command [itcl::code $this AdjustSetting axis-xdirection] \1535 -variable [itcl::scope _ axis(xdirection)]1536 } 1537 set _ axis(xdirection) -11526 -command [itcl::code $this AdjustSetting -xdirection] \ 1527 -variable [itcl::scope _settings(-xdirection)] 1528 } 1529 set _settings(-xdirection) -1 1538 1530 Rappture::Tooltip::for $itk_component(xDirButton) \ 1539 1531 "Toggle the direction of the X-axis cutaway" … … 1544 1536 -onimage [Rappture::icon y-cutplane] \ 1545 1537 -offimage [Rappture::icon y-cutplane] \ 1546 -command [itcl::code $this AdjustSetting axis-ycutaway] \1547 -variable [itcl::scope _ axis(ycutaway)]1538 -command [itcl::code $this AdjustSetting -ycutaway] \ 1539 -variable [itcl::scope _settings(-ycutaway)] 1548 1540 } 1549 1541 Rappture::Tooltip::for $itk_component(yCutButton) \ … … 1555 1547 -borderwidth 1 -highlightthickness 0 \ 1556 1548 -command [itcl::code $this Slice move y] \ 1557 -variable [itcl::scope _ axis(yposition)]1549 -variable [itcl::scope _settings(-yposition)] 1558 1550 } { 1559 1551 usual … … 1572 1564 -offimage [Rappture::icon arrow-up] \ 1573 1565 -offvalue 1 \ 1574 -command [itcl::code $this AdjustSetting axis-ydirection] \1575 -variable [itcl::scope _ axis(ydirection)]1566 -command [itcl::code $this AdjustSetting -ydirection] \ 1567 -variable [itcl::scope _settings(-ydirection)] 1576 1568 } 1577 1569 Rappture::Tooltip::for $itk_component(yDirButton) \ 1578 1570 "Toggle the direction of the Y-axis cutaway" 1579 set _ axis(ydirection) -11571 set _settings(-ydirection) -1 1580 1572 1581 1573 # Z-value slicer... … … 1584 1576 -onimage [Rappture::icon z-cutplane] \ 1585 1577 -offimage [Rappture::icon z-cutplane] \ 1586 -command [itcl::code $this AdjustSetting axis-zcutaway] \1587 -variable [itcl::scope _ axis(zcutaway)]1578 -command [itcl::code $this AdjustSetting -zcutaway] \ 1579 -variable [itcl::scope _settings(-zcutaway)] 1588 1580 } 1589 1581 Rappture::Tooltip::for $itk_component(zCutButton) \ … … 1595 1587 -borderwidth 1 -highlightthickness 0 \ 1596 1588 -command [itcl::code $this Slice move z] \ 1597 -variable [itcl::scope _ axis(zposition)]1589 -variable [itcl::scope _settings(-zposition)] 1598 1590 } { 1599 1591 usual … … 1611 1603 -offimage [Rappture::icon arrow-up] \ 1612 1604 -offvalue 1 \ 1613 -command [itcl::code $this AdjustSetting axis-zdirection] \1614 -variable [itcl::scope _ axis(zdirection)]1615 } 1616 set _ axis(zdirection) -11605 -command [itcl::code $this AdjustSetting -zdirection] \ 1606 -variable [itcl::scope _settings(-zdirection)] 1607 } 1608 set _settings(-zdirection) -1 1617 1609 Rappture::Tooltip::for $itk_component(zDirButton) \ 1618 1610 "Toggle the direction of the Z-axis cutaway" … … 1736 1728 set style [$dataobj hints style] 1737 1729 if { $dataobj != $_first } { 1738 set settings(- wireframe) 11730 set settings(-polydatawireframe) 1 1739 1731 } 1740 1732 … … 1743 1735 -color white 1744 1736 -edgecolor black 1745 -edges 11746 1737 -lighting 1 1747 1738 -linewidth 1.0 1748 -opacity 1.01749 1739 -outline 0 1750 -visible 1 1751 -wireframe 0 1740 -polydataedges 1 1741 -polydataopacity 1.0 1742 -polydatavisible 1 1743 -polydatawireframe 0 1752 1744 } 1753 1745 if {$type == "cloud"} { 1754 1746 set settings(-cloudstyle) points 1755 set settings(- edges) 01747 set settings(-polydataedges) 0 1756 1748 set settings(-edgecolor) white 1757 1749 } … … 1763 1755 SendCmd "outline color [Color2RGB $settings(-color)] $tag" 1764 1756 SendCmd "outline visible $settings(-outline) $tag" 1765 set _settings( outline) $settings(-outline)1757 set _settings(-outline) $settings(-outline) 1766 1758 1767 1759 SendCmd "polydata add $tag" 1768 SendCmd "polydata visible $settings(- visible) $tag"1760 SendCmd "polydata visible $settings(-polydatavisible) $tag" 1769 1761 SendCmd "polydata cloudstyle $settings(-cloudstyle) $tag" 1770 set _settings( polydata-visible) $settings(-visible)1771 SendCmd "polydata edges $settings(- edges) $tag"1772 set _settings( polydata-edges) $settings(-edges)1762 set _settings(-polydatavisible) $settings(-polydatavisible) 1763 SendCmd "polydata edges $settings(-polydataedges) $tag" 1764 set _settings(-polydataedges) $settings(-polydataedges) 1773 1765 SendCmd "polydata color [Color2RGB $settings(-color)] $tag" 1774 #SendCmd "polydata colormode constant {} $tag" 1775 SendCmd "polydata lighting $settings(- lighting) $tag"1776 set _settings( polydata-lighting) $settings(-lighting)1766 1767 SendCmd "polydata lighting $settings(-polydatalighting) $tag" 1768 set _settings(-polydatalighting) $settings(-polydatalighting) 1777 1769 SendCmd "polydata linecolor [Color2RGB $settings(-edgecolor)] $tag" 1778 1770 SendCmd "polydata linewidth $settings(-linewidth) $tag" 1779 SendCmd "polydata opacity $settings(- opacity) $tag"1780 set _settings( polydata-opacity) [expr 100.0 * $settings(-opacity)]1781 SendCmd "polydata wireframe $settings(- wireframe) $tag"1782 set _settings( polydata-wireframe) $settings(-wireframe)1771 SendCmd "polydata opacity $settings(-polydataopacity) $tag" 1772 set _settings(-polydataopacity) [expr 100.0 * $settings(-polydataopacity)] 1773 SendCmd "polydata wireframe $settings(-polydatawireframe) $tag" 1774 set _settings(-polydatawireframe) $settings(-polydatawireframe) 1783 1775 set havePolyData 1 1784 1776 } … … 1842 1834 } 1843 1835 1844 itcl::body Rappture::VtkMeshViewer::SetOpacity { dataset } {1845 set val $_settings(polydata-opacity)1846 set sval [expr { 0.01 * double($val) }]1847 if { !$_obj2ovride($dataset-raise) } {1848 # This is wrong. Need to figure out why raise isn't set with 11849 #set sval [expr $sval * .6]1850 }1851 SendCmd "polydata opacity $sval $dataset"1852 }
Note: See TracChangeset
for help on using the changeset viewer.