- Timestamp:
- Jul 17, 2014, 1:44:41 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/vtkmeshviewer.tcl
r4421 r4535 86 86 private method EventuallyResize { w h } 87 87 private method EventuallyRotate { q } 88 private method EventuallySetPolydataOpacity { args}88 private method EventuallySetPolydataOpacity {} 89 89 private method GetImage { args } 90 90 private method GetVtkData { args } … … 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 {} … … 112 111 private variable _view; # view params for 3D view 113 112 private variable _settings 113 private variable _widget 114 114 private variable _style; # Array of current component styles. 115 115 private variable _initialStyle; # Array of initial component styles. 116 private variable _axis117 116 private variable _reset 1; # Indicates that server was reset and 118 117 # needs to be reinitialized. 119 118 120 private variable _first "" ;# This is the topmost dataset.119 private variable _first ""; # This is the topmost dataset. 121 120 private variable _start 0 122 121 private variable _title "" 123 122 124 common _downloadPopup ;# download options from popup123 common _downloadPopup; # download options from popup 125 124 private common _hardcopy 126 125 private variable _width 0 … … 130 129 private variable _polydataOpacityPending 0 131 130 private variable _rotateDelay 150 131 private variable _opacityDelay 150 132 132 } 133 133 … … 184 184 set _limits(zmax) 1.0 185 185 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 }] 186 array set _settings { 187 -axesvisible 1 188 -axislabels 1 189 -outline 0 190 -polydataedges 0 191 -polydatalighting 1 192 -polydataopacity 1.0 193 -polydatavisible 1 194 -polydatawireframe 0 195 -xcutaway 0 196 -xdirection -1 197 -xgrid 0 198 -xposition 0 199 -ycutaway 0 200 -ydirection -1 201 -ygrid 0 202 -yposition 0 203 -zcutaway 0 204 -zdirection -1 205 -zgrid 0 206 -zposition 0 207 } 208 array set _widget { 209 -polydataopacity 100 210 } 210 211 itk_component add view { 211 212 canvas $itk_component(plotarea).view \ … … 407 408 itcl::body Rappture::VtkMeshViewer::SetPolydataOpacity {} { 408 409 set _polydataOpacityPending 0 409 foreach dataset [CurrentDatasets -visible $_first] { 410 SetOpacity $dataset 411 } 412 } 413 414 itcl::body Rappture::VtkMeshViewer::EventuallySetPolydataOpacity { args } { 410 set val $_settings(-polydataopacity) 411 SendCmd "polydata opacity $val" 412 } 413 414 itcl::body Rappture::VtkMeshViewer::EventuallySetPolydataOpacity {} { 415 415 if { !$_polydataOpacityPending } { 416 416 set _polydataOpacityPending 1 417 $_dispatcher event -after $_ scaleDelay !polydataOpacity417 $_dispatcher event -after $_opacityDelay !polydataOpacity 418 418 } 419 419 } … … 478 478 set _dlist [lreplace $_dlist $pos $pos] 479 479 array unset _obj2ovride $dataobj-* 480 array unset _settings $dataobj-*481 480 set changed 1 482 481 } … … 832 831 $_arcball resize $w $h 833 832 DoResize 834 InitSettings axis-xgrid axis-ygrid axis-zgrid axis-mode \ 835 axis-visible axis-labels 836 833 InitSettings -xgrid -ygrid -zgrid -axismode -axesvisible -axislabels 837 834 StopBufferingCommands 838 835 SendCmd "imgflush" … … 876 873 if { [info exists _obj2ovride($dataobj-raise)] } { 877 874 SendCmd "dataset visible 1 $tag" 878 SetOpacity $tag875 EventuallySetPolydataOpacity 879 876 } 880 877 } … … 896 893 } 897 894 } 898 InitSettings outline895 InitSettings -outline 899 896 if { $_reset } { 900 897 # These are settings that rely on a dataset being loaded. 901 InitSettings polydata-edges polydata-lighting polydata-opacity \902 polydata-visible polydata-wireframe898 InitSettings -polydataedges -polydatalighting -polydataopacity \ 899 -polydatavisible -polydatawireframe 903 900 901 SendCmd "axis lformat all %g" 902 # Too many major ticks, so turn off minor ticks 903 SendCmd "axis minticks all 0" 904 904 905 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 905 906 $_arcball quaternion $q … … 1152 1153 } 1153 1154 switch -- $what { 1154 "outline" { 1155 set bool $_settings(outline) 1156 foreach dataset [CurrentDatasets -visible $_first] { 1155 "-outline" { 1156 set bool $_settings($what) 1157 # Only display a outline for the currently visible sets. 1158 SendCmd "outline visible 0" 1159 foreach dataset [CurrentDatasets -visible] { 1157 1160 SendCmd "outline visible $bool $dataset" 1158 1161 } 1159 1162 } 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] { 1163 "-polydataopacity" { 1164 EventuallySetPolydataOpacity 1165 } 1166 "-polydatawireframe" { 1167 set bool $_settings($what) 1168 SendCmd "polydata wireframe $bool" 1169 } 1170 "-polydatavisible" { 1171 set bool $_settings($what) 1172 # Only change visibility of data sets marked "visible". 1173 foreach dataset [CurrentDatasets -visible] { 1174 1174 SendCmd "polydata visible $bool $dataset" 1175 1175 } 1176 1176 } 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) 1177 "-polydatalighting" { 1178 set bool $_settings($what) 1179 SendCmd "polydata lighting $bool" 1180 } 1181 "-polydataedges" { 1182 set bool $_settings($what) 1183 SendCmd "polydata edges $bool" 1184 } 1185 "-axesvisible" { 1186 set bool $_settings($what) 1191 1187 SendCmd "axis visible all $bool" 1192 1188 } 1193 " axis-labels" {1194 set bool $_ axis(labels)1189 "-axislabels" { 1190 set bool $_settings($what) 1195 1191 SendCmd "axis labels all $bool" 1196 1192 } 1197 " axis-xgrid" {1198 set bool $_ axis(xgrid)1193 "-xgrid" { 1194 set bool $_settings($what) 1199 1195 SendCmd "axis grid x $bool" 1200 1196 } 1201 " axis-ygrid" {1202 set bool $_ axis(ygrid)1197 "-ygrid" { 1198 set bool $_settings($what) 1203 1199 SendCmd "axis grid y $bool" 1204 1200 } 1205 " axis-zgrid" {1206 set bool $_ axis(zgrid)1201 "-zgrid" { 1202 set bool $_settings($what) 1207 1203 SendCmd "axis grid z $bool" 1208 1204 } 1209 " axis-mode" {1205 "-axismode" { 1210 1206 set mode [$itk_component(axismode) value] 1211 1207 set mode [$itk_component(axismode) translate $mode] 1212 1208 SendCmd "axis flymode $mode" 1213 1209 } 1214 " axis-xcutaway" - "axis-ycutaway" - "axis-zcutaway" {1215 set axis [string range $what 5 5]1216 set bool $_ axis(${axis}cutaway)1210 "-xcutaway" - "-ycutaway" - "-zcutaway" { 1211 set axis [string range $what 1 1] 1212 set bool $_settings($what) 1217 1213 if { $bool } { 1218 set pos [expr $_ axis(${axis}position) * 0.01]1219 set dir $_ axis(${axis}direction)1214 set pos [expr $_settings(-${axis}position) * 0.01] 1215 set dir $_settings(-${axis}direction) 1220 1216 $itk_component(${axis}CutScale) configure -state normal \ 1221 1217 -troughcolor white … … 1227 1223 } 1228 1224 } 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] 1225 "-xposition" - "-yposition" - "-zposition" { 1226 set axis [string range $what 1 1] 1227 set pos [expr $_settings($what) * 0.01] 1234 1228 SendCmd "renderer clipplane ${axis} $pos -1" 1229 } 1230 "-xdirection" - "-ydirection" - "-zdirection" { 1231 set axis [string range $what 1 1] 1232 puts stderr "direction not implemented" 1235 1233 } 1236 1234 default { … … 1317 1315 checkbutton $inner.mesh \ 1318 1316 -text "Show Mesh" \ 1319 -variable [itcl::scope _settings( polydata-visible)] \1320 -command [itcl::code $this AdjustSetting polydata-visible] \1317 -variable [itcl::scope _settings(-polydatavisible)] \ 1318 -command [itcl::code $this AdjustSetting -polydatavisible] \ 1321 1319 -font "Arial 9" -anchor w 1322 1320 1323 1321 checkbutton $inner.outline \ 1324 1322 -text "Show Outline" \ 1325 -variable [itcl::scope _settings( outline)] \1326 -command [itcl::code $this AdjustSetting outline] \1323 -variable [itcl::scope _settings(-outline)] \ 1324 -command [itcl::code $this AdjustSetting -outline] \ 1327 1325 -font "Arial 9" -anchor w 1328 1326 1329 1327 checkbutton $inner.wireframe \ 1330 1328 -text "Show Wireframe" \ 1331 -variable [itcl::scope _settings( polydata-wireframe)] \1332 -command [itcl::code $this AdjustSetting polydata-wireframe] \1329 -variable [itcl::scope _settings(-polydatawireframe)] \ 1330 -command [itcl::code $this AdjustSetting -polydatawireframe] \ 1333 1331 -font "Arial 9" -anchor w 1334 1332 1335 1333 checkbutton $inner.lighting \ 1336 1334 -text "Enable Lighting" \ 1337 -variable [itcl::scope _settings( polydata-lighting)] \1338 -command [itcl::code $this AdjustSetting polydata-lighting] \1335 -variable [itcl::scope _settings(-polydatalighting)] \ 1336 -command [itcl::code $this AdjustSetting -polydatalighting] \ 1339 1337 -font "Arial 9" -anchor w 1340 1338 1341 1339 checkbutton $inner.edges \ 1342 1340 -text "Show Edges" \ 1343 -variable [itcl::scope _settings( polydata-edges)] \1344 -command [itcl::code $this AdjustSetting polydata-edges] \1341 -variable [itcl::scope _settings(-polydataedges)] \ 1342 -command [itcl::code $this AdjustSetting -polydataedges] \ 1345 1343 -font "Arial 9" -anchor w 1346 1344 … … 1354 1352 } 1355 1353 bind $inner.field <<Value>> \ 1356 [itcl::code $this AdjustSetting field]1354 [itcl::code $this AdjustSetting -field] 1357 1355 1358 1356 label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w 1359 1357 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1360 -variable [itcl::scope _ settings(polydata-opacity)] \1358 -variable [itcl::scope _widget(-polydataopacity)] \ 1361 1359 -width 10 \ 1362 1360 -showvalue off \ 1363 -command [itcl::code $this AdjustSetting polydata-opacity]1364 $inner.opacity set $_settings(polydata-opacity)1361 -command [itcl::code $this AdjustSetting -polydataopacity] 1362 $inner.opacity set [expr $_settings(-polydataopacity) * 100.0] 1365 1363 1366 1364 blt::table $inner \ … … 1389 1387 checkbutton $inner.visible \ 1390 1388 -text "Show Axes" \ 1391 -variable [itcl::scope _ axis(visible)] \1392 -command [itcl::code $this AdjustSetting axis-visible] \1389 -variable [itcl::scope _settings(-axesvisible)] \ 1390 -command [itcl::code $this AdjustSetting -axesvisible] \ 1393 1391 -font "Arial 9" 1394 1392 1395 1393 checkbutton $inner.labels \ 1396 1394 -text "Show Axis Labels" \ 1397 -variable [itcl::scope _ axis(labels)] \1398 -command [itcl::code $this AdjustSetting axis-labels] \1395 -variable [itcl::scope _settings(-axislabels)] \ 1396 -command [itcl::code $this AdjustSetting -axislabels] \ 1399 1397 -font "Arial 9" 1400 1398 1401 1399 checkbutton $inner.gridx \ 1402 1400 -text "Show X Grid" \ 1403 -variable [itcl::scope _ axis(xgrid)] \1404 -command [itcl::code $this AdjustSetting axis-xgrid] \1401 -variable [itcl::scope _settings(-xgrid)] \ 1402 -command [itcl::code $this AdjustSetting -xgrid] \ 1405 1403 -font "Arial 9" 1406 1404 checkbutton $inner.gridy \ 1407 1405 -text "Show Y Grid" \ 1408 -variable [itcl::scope _ axis(ygrid)] \1409 -command [itcl::code $this AdjustSetting axis-ygrid] \1406 -variable [itcl::scope _settings(-ygrid)] \ 1407 -command [itcl::code $this AdjustSetting -ygrid] \ 1410 1408 -font "Arial 9" 1411 1409 checkbutton $inner.gridz \ 1412 1410 -text "Show Z Grid" \ 1413 -variable [itcl::scope _ axis(zgrid)] \1414 -command [itcl::code $this AdjustSetting axis-zgrid] \1411 -variable [itcl::scope _settings(-zgrid)] \ 1412 -command [itcl::code $this AdjustSetting -zgrid] \ 1415 1413 -font "Arial 9" 1416 1414 … … 1426 1424 "outer_edges" "outer" 1427 1425 $itk_component(axismode) value "static" 1428 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axis-mode]1426 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode] 1429 1427 1430 1428 blt::table $inner \ … … 1504 1502 -onimage [Rappture::icon x-cutplane] \ 1505 1503 -offimage [Rappture::icon x-cutplane] \ 1506 -command [itcl::code $this AdjustSetting axis-xcutaway] \1507 -variable [itcl::scope _ axis(xcutaway)]1504 -command [itcl::code $this AdjustSetting -xcutaway] \ 1505 -variable [itcl::scope _settings(-xcutaway)] 1508 1506 } 1509 1507 Rappture::Tooltip::for $itk_component(xCutButton) \ … … 1515 1513 -borderwidth 1 -highlightthickness 0 \ 1516 1514 -command [itcl::code $this Slice move x] \ 1517 -variable [itcl::scope _ axis(xposition)]1515 -variable [itcl::scope _settings(-xposition)] 1518 1516 } { 1519 1517 usual … … 1532 1530 -offimage [Rappture::icon arrow-up] \ 1533 1531 -offvalue 1 \ 1534 -command [itcl::code $this AdjustSetting axis-xdirection] \1535 -variable [itcl::scope _ axis(xdirection)]1536 } 1537 set _ axis(xdirection) -11532 -command [itcl::code $this AdjustSetting -xdirection] \ 1533 -variable [itcl::scope _settings(-xdirection)] 1534 } 1535 set _settings(-xdirection) -1 1538 1536 Rappture::Tooltip::for $itk_component(xDirButton) \ 1539 1537 "Toggle the direction of the X-axis cutaway" … … 1544 1542 -onimage [Rappture::icon y-cutplane] \ 1545 1543 -offimage [Rappture::icon y-cutplane] \ 1546 -command [itcl::code $this AdjustSetting axis-ycutaway] \1547 -variable [itcl::scope _ axis(ycutaway)]1544 -command [itcl::code $this AdjustSetting -ycutaway] \ 1545 -variable [itcl::scope _settings(-ycutaway)] 1548 1546 } 1549 1547 Rappture::Tooltip::for $itk_component(yCutButton) \ … … 1555 1553 -borderwidth 1 -highlightthickness 0 \ 1556 1554 -command [itcl::code $this Slice move y] \ 1557 -variable [itcl::scope _ axis(yposition)]1555 -variable [itcl::scope _settings(-yposition)] 1558 1556 } { 1559 1557 usual … … 1572 1570 -offimage [Rappture::icon arrow-up] \ 1573 1571 -offvalue 1 \ 1574 -command [itcl::code $this AdjustSetting axis-ydirection] \1575 -variable [itcl::scope _ axis(ydirection)]1572 -command [itcl::code $this AdjustSetting -ydirection] \ 1573 -variable [itcl::scope _settings(-ydirection)] 1576 1574 } 1577 1575 Rappture::Tooltip::for $itk_component(yDirButton) \ 1578 1576 "Toggle the direction of the Y-axis cutaway" 1579 set _ axis(ydirection) -11577 set _settings(-ydirection) -1 1580 1578 1581 1579 # Z-value slicer... … … 1584 1582 -onimage [Rappture::icon z-cutplane] \ 1585 1583 -offimage [Rappture::icon z-cutplane] \ 1586 -command [itcl::code $this AdjustSetting axis-zcutaway] \1587 -variable [itcl::scope _ axis(zcutaway)]1584 -command [itcl::code $this AdjustSetting -zcutaway] \ 1585 -variable [itcl::scope _settings(-zcutaway)] 1588 1586 } 1589 1587 Rappture::Tooltip::for $itk_component(zCutButton) \ … … 1595 1593 -borderwidth 1 -highlightthickness 0 \ 1596 1594 -command [itcl::code $this Slice move z] \ 1597 -variable [itcl::scope _ axis(zposition)]1595 -variable [itcl::scope _settings(-zposition)] 1598 1596 } { 1599 1597 usual … … 1611 1609 -offimage [Rappture::icon arrow-up] \ 1612 1610 -offvalue 1 \ 1613 -command [itcl::code $this AdjustSetting axis-zdirection] \1614 -variable [itcl::scope _ axis(zdirection)]1615 } 1616 set _ axis(zdirection) -11611 -command [itcl::code $this AdjustSetting -zdirection] \ 1612 -variable [itcl::scope _settings(-zdirection)] 1613 } 1614 set _settings(-zdirection) -1 1617 1615 Rappture::Tooltip::for $itk_component(zDirButton) \ 1618 1616 "Toggle the direction of the Z-axis cutaway" … … 1733 1731 set tag $dataobj 1734 1732 set type [$dataobj type] 1735 set color [$dataobj hints color] 1736 set style [$dataobj hints style] 1737 if { $dataobj != $_first } { 1738 set settings(-wireframe) 1 1739 } 1740 1741 array set settings { 1733 1734 array set style { 1742 1735 -cloudstyle mesh 1743 1736 -color white … … 1751 1744 -wireframe 0 1752 1745 } 1746 if { $dataobj != $_first } { 1747 set style(-wireframe) 1 1748 } 1753 1749 if {$type == "cloud"} { 1754 set settings(-cloudstyle) points 1755 set settings(-edges) 0 1756 set settings(-edgecolor) white 1757 } 1758 array set settings $style 1759 if {$color != ""} { 1760 set settings(-color) $color 1750 set style(-cloudstyle) points 1751 set style(-edges) 0 1752 set style(-edgecolor) white 1753 } 1754 array set style [$dataobj hints style] 1755 1756 if {[$dataobj hints color] != ""} { 1757 set style(-color) [$dataobj hints color] 1761 1758 } 1762 1759 SendCmd "outline add $tag" 1763 SendCmd "outline color [Color2RGB $s ettings(-color)] $tag"1764 SendCmd "outline visible $s ettings(-outline) $tag"1765 set _settings( outline) $settings(-outline)1760 SendCmd "outline color [Color2RGB $style(-color)] $tag" 1761 SendCmd "outline visible $style(-outline) $tag" 1762 set _settings(-outline) $style(-outline) 1766 1763 1767 1764 SendCmd "polydata add $tag" 1768 SendCmd "polydata visible $s ettings(-visible) $tag"1769 SendCmd "polydata cloudstyle $settings(-cloudstyle) $tag"1770 set _settings(polydata-visible) $settings(-visible)1771 SendCmd "polydata edges $s ettings(-edges) $tag"1772 set _settings( polydata-edges) $settings(-edges)1773 SendCmd "polydata color [Color2RGB $s ettings(-color)] $tag"1774 #SendCmd "polydata colormode constant {}$tag"1775 SendCmd "polydata lighting $settings(-lighting) $tag"1776 set _settings(polydata-lighting) $settings(-lighting)1777 SendCmd "polydata line color [Color2RGB $settings(-edgecolor)]$tag"1778 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 $s ettings(-wireframe) $tag"1782 set _settings( polydata-wireframe) $settings(-wireframe)1765 SendCmd "polydata visible $style(-visible) $tag" 1766 set _settings(-polydatavisible) $style(-visible) 1767 SendCmd "polydata cloudstyle $style(-cloudstyle) $tag" 1768 SendCmd "polydata edges $style(-edges) $tag" 1769 set _settings(-polydataedges) $style(-edges) 1770 SendCmd "polydata color [Color2RGB $style(-color)] $tag" 1771 SendCmd "polydata lighting $style(-lighting) $tag" 1772 set _settings(-polydatalighting) $style(-lighting) 1773 SendCmd "polydata linecolor [Color2RGB $style(-edgecolor)] $tag" 1774 SendCmd "polydata linewidth $style(-linewidth) $tag" 1775 SendCmd "polydata opacity $style(-opacity) $tag" 1776 set _settings(-polydataopacity) $style(-opacity) 1777 set _widget(-polydataopacity) [expr 100.0 * $style(-opacity)] 1778 SendCmd "polydata wireframe $style(-wireframe) $tag" 1779 set _settings(-polydatawireframe) $style(-wireframe) 1783 1780 set havePolyData 1 1784 1781 } … … 1842 1839 } 1843 1840 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.