Changeset 2464 for trunk/gui/scripts/vtkviewer.tcl
- Timestamp:
- Sep 3, 2011, 1:35:37 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/vtkviewer.tcl
r2426 r2464 80 80 # The following methods are only used by this class. 81 81 private method BuildCameraTab {} 82 private method BuildViewTab {} 82 private method BuildVolumeTab {} 83 private method BuildStreamsTab {} 83 84 private method BuildAxisTab {} 84 85 private method BuildColormap { colormap dataobj comp } … … 114 115 private variable _reset 1 ;# indicates if camera needs to be reset 115 116 # to starting position. 116 117 private variable _haveStreams 0 117 118 # Array of transfer functions in server. If 0 the transfer has been 118 119 # defined but not loaded. If 1 the transfer function has been named … … 185 186 array set _settings [subst { 186 187 $this-axes 1 188 $this-seeds 1 189 $this-streamlines 1 187 190 $this-edges 1 188 191 $this-lighting 1 … … 259 262 Rappture::Tooltip::for $itk_component(zoomout) "Zoom out" 260 263 261 BuildViewTab 262 BuildAxisTab 263 BuildCameraTab 264 if { [catch { 265 BuildVolumeTab 266 BuildAxisTab 267 BuildStreamsTab 268 BuildCameraTab 269 } errs] != 0 } { 270 puts stderr err=$errs 271 } 264 272 265 273 # Hack around the Tk panewindow. The problem is that the requested … … 539 547 foreach dataobj $args { 540 548 array set bounds [limits $dataobj] 549 puts stderr bounds=[array get bounds] 541 550 if {![info exists _limits(xmin)] || $_limits(xmin) > $bounds(xmin)} { 542 551 set _limits(xmin) $bounds(xmin) … … 803 812 set _limits(vmax) "" 804 813 set _first "" 814 set _haveStreams 0 805 815 foreach dataobj [get -objects] { 806 816 if { [info exists _obj2ovride($dataobj-raise)] && $_first == "" } { … … 852 862 FixSettings axes 853 863 FixSettings edges 864 FixSettings seeds 865 FixSettings streamlines 854 866 FixSettings axismode 855 867 868 if { !$_haveStreams } { 869 $itk_component(main) disable "Streams Settings" 870 } 856 871 if {"" != $_first} { 857 872 set location [$_first hints camera] … … 1049 1064 } 1050 1065 "drag" { 1066 if { ![info exists _click(x)] } { 1067 set _click(x) $x 1068 } 1069 if { ![info exists _click(y)] } { 1070 set _click(y) $y 1071 } 1051 1072 set w [winfo width $itk_component(view)] 1052 1073 set h [winfo height $itk_component(view)] … … 1077 1098 # ---------------------------------------------------------------------- 1078 1099 itcl::body Rappture::VtkViewer::FixSettings {what {value ""}} { 1100 if { ![isconnected] } { 1101 return 1102 } 1079 1103 switch -- $what { 1080 1104 "opacity" { 1081 if {[isconnected]} { 1082 set val $_settings($this-opacity) 1083 set sval [expr { 0.01 * double($val) }] 1084 foreach dataset [CurrentDatasets -visible $_first] { 1085 SendCmd "polydata opacity $sval $dataset" 1086 } 1105 set val $_settings($this-opacity) 1106 set sval [expr { 0.01 * double($val) }] 1107 foreach dataset [CurrentDatasets -visible $_first] { 1108 SendCmd "polydata opacity $sval $dataset" 1109 } 1110 } 1111 "wireframe" { 1112 set bool $_settings($this-wireframe) 1113 foreach dataset [CurrentDatasets -visible $_first] { 1114 SendCmd "polydata wireframe $bool $dataset" 1087 1115 } 1088 1116 } 1089 "wireframe" { 1090 if {[isconnected]} { 1091 set bool $_settings($this-wireframe) 1092 foreach dataset [CurrentDatasets -visible $_first] { 1093 SendCmd "polydata wireframe $bool $dataset" 1094 } 1117 "volume" { 1118 set bool $_settings($this-volume) 1119 foreach dataset [CurrentDatasets -visible $_first] { 1120 SendCmd "polydata visible $bool $dataset" 1095 1121 } 1096 1122 } 1097 "volume" { 1098 if {[isconnected]} { 1099 set bool $_settings($this-volume) 1100 foreach dataset [CurrentDatasets -visible $_first] { 1101 SendCmd "polydata visible $bool $dataset" 1102 } 1123 "lighting" { 1124 set bool $_settings($this-lighting) 1125 foreach dataset [CurrentDatasets -visible $_first] { 1126 SendCmd "polydata lighting $bool $dataset" 1103 1127 } 1104 1128 } 1105 "lighting" {1106 if {[isconnected]} {1107 set bool $_settings($this-lighting)1108 foreach dataset [CurrentDatasets -visible $_first] {1109 SendCmd "polydata lighting $bool $dataset"1110 }1111 }1112 }1113 1129 "grid-x" { 1114 if {[isconnected]} { 1115 set bool $_settings($this-grid-x) 1116 SendCmd "axis grid x $bool" 1117 } 1130 set bool $_settings($this-grid-x) 1131 SendCmd "axis grid x $bool" 1118 1132 } 1119 1133 "grid-y" { 1120 if {[isconnected]} { 1121 set bool $_settings($this-grid-y) 1122 SendCmd "axis grid y $bool" 1123 } 1134 set bool $_settings($this-grid-y) 1135 SendCmd "axis grid y $bool" 1124 1136 } 1125 1137 "grid-z" { 1126 if {[isconnected]} { 1127 set bool $_settings($this-grid-z) 1128 SendCmd "axis grid z $bool" 1129 } 1138 set bool $_settings($this-grid-z) 1139 SendCmd "axis grid z $bool" 1140 } 1141 "axes" { 1142 set bool $_settings($this-axes) 1143 SendCmd "axis visible all $bool" 1144 } 1145 "axismode" { 1146 set mode [$itk_component(axismode) value] 1147 set mode [$itk_component(axismode) translate $mode] 1148 SendCmd "axis flymode $mode" 1130 1149 } 1131 1150 "edges" { 1132 if {[isconnected]} { 1133 set bool $_settings($this-edges) 1134 foreach dataset [CurrentDatasets -visible $_first] { 1151 set bool $_settings($this-edges) 1152 foreach dataset [CurrentDatasets -visible $_first] { 1153 foreach {dataobj comp} [split $dataset -] break 1154 if { [$dataobj type $comp] != "streamlines" } { 1135 1155 SendCmd "polydata edges $bool $dataset" 1136 1156 } 1137 1157 } 1138 1158 } 1139 "axes" { 1140 if { [isconnected] } { 1141 set bool $_settings($this-axes) 1142 SendCmd "axis visible all $bool" 1159 "seeds" { 1160 set bool $_settings($this-seeds) 1161 foreach dataset [CurrentDatasets -visible $_first] { 1162 foreach {dataobj comp} [split $dataset -] break 1163 if { [$dataobj type $comp] == "streamlines" } { 1164 SendCmd "streamlines seed visible $bool $dataset" 1165 } 1166 } 1167 } 1168 "streamlines" { 1169 set bool $_settings($this-streamlines) 1170 foreach dataset [CurrentDatasets -visible $_first] { 1171 foreach {dataobj comp} [split $dataset -] break 1172 if { [$dataobj type $comp] == "streamlines" } { 1173 if { $bool } { 1174 SendCmd "streamlines add $dataset" 1175 } else { 1176 SendCmd "streamlines delete $dataset" 1177 } 1178 } 1143 1179 } 1144 1180 } 1145 "axismode" { 1146 if { [isconnected] } { 1147 set mode [$itk_component(axismode) value] 1148 set mode [$itk_component(axismode) translate $mode] 1149 SendCmd "axis flymode $mode" 1181 "streammode" { 1182 set mode [$itk_component(streammode) value] 1183 foreach dataset [CurrentDatasets -visible $_first] { 1184 foreach {dataobj comp} [split $dataset -] break 1185 if { [$dataobj type $comp] == "streamlines" } { 1186 switch -- $mode { 1187 "lines" { 1188 SendCmd "streamlines lines $dataset" 1189 } 1190 "ribbons" { 1191 SendCmd "streamlines ribbons 3.0 20 $dataset" 1192 } 1193 "tubes" { 1194 SendCmd "streamlines tubes 20 10 $dataset" 1195 } 1196 } 1197 } 1150 1198 } 1151 1199 } … … 1279 1327 } 1280 1328 1281 1282 itcl::body Rappture::VtkViewer::BuildViewTab {} { 1329 itcl::body Rappture::VtkViewer::BuildVolumeTab {} { 1283 1330 1284 1331 set fg [option get $itk_component(hull) font Font] … … 1286 1333 1287 1334 set inner [$itk_component(main) insert end \ 1288 -title "V iewSettings" \1289 -icon [Rappture::icon wrench]]1335 -title "Volume Settings" \ 1336 -icon [Rappture::icon volume-on]] 1290 1337 $inner configure -borderwidth 4 1338 1339 checkbutton $inner.volume \ 1340 -text "Visible" \ 1341 -variable [itcl::scope _settings($this-volume)] \ 1342 -command [itcl::code $this FixSettings volume] \ 1343 -font "Arial 9" 1291 1344 1292 1345 checkbutton $inner.wireframe \ … … 1296 1349 -font "Arial 9" 1297 1350 1298 checkbutton $inner.axes \1299 -text "Axes" \1300 -variable [itcl::scope _settings($this-axes)] \1301 -command [itcl::code $this FixSettings axes] \1302 -font "Arial 9"1303 1304 checkbutton $inner.volume \1305 -text "Volume" \1306 -variable [itcl::scope _settings($this-volume)] \1307 -command [itcl::code $this FixSettings volume] \1308 -font "Arial 9"1309 1310 1351 checkbutton $inner.lighting \ 1311 1352 -text "Lighting" \ … … 1320 1361 -font "Arial 9" 1321 1362 1322 label $inner. clear -text "Clear" -font "Arial 9"1363 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1323 1364 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1324 1365 -variable [itcl::scope _settings($this-opacity)] \ 1325 1366 -width 10 \ 1326 1367 -showvalue off -command [itcl::code $this FixSettings opacity] 1327 label $inner.opaque -text "Opaque" -font "Arial 9"1328 1368 1329 1369 blt::table $inner \ 1330 0,0 $inner.axes -columnspan 4 -anchor w -pady 2 \ 1331 1,0 $inner.volume -columnspan 4 -anchor w -pady 2 \ 1332 2,0 $inner.wireframe -columnspan 4 -anchor w -pady 2 \ 1333 3,0 $inner.lighting -columnspan 4 -anchor w \ 1334 4,0 $inner.edges -columnspan 4 -anchor w -pady 2 \ 1335 6,0 $inner.clear -anchor e -pady 2 \ 1336 6,1 $inner.opacity -columnspan 2 -pady 2 -fill x\ 1337 6,3 $inner.opaque -anchor w -pady 2 1370 0,0 $inner.volume -columnspan 4 -anchor w -pady 2 \ 1371 1,0 $inner.wireframe -columnspan 4 -anchor w -pady 2 \ 1372 2,0 $inner.lighting -columnspan 4 -anchor w \ 1373 3,0 $inner.edges -columnspan 4 -anchor w -pady 2 \ 1374 4,0 $inner.opacity_l -anchor w -pady 2 \ 1375 5,0 $inner.opacity -columnspan 2 -pady 2 -fill x 1338 1376 1339 1377 blt::table configure $inner r* -resize none 1340 blt::table configure $inner r7 -resize expand 1341 } 1342 1343 itcl::body Rappture::VtkViewer::BuildAxisTab {} { 1378 blt::table configure $inner r6 -resize expand 1379 } 1380 1381 1382 itcl::body Rappture::VtkViewer::BuildStreamsTab {} { 1344 1383 1345 1384 set fg [option get $itk_component(hull) font Font] … … 1347 1386 1348 1387 set inner [$itk_component(main) insert end \ 1388 -title "Streams Settings" \ 1389 -icon [Rappture::icon stream]] 1390 $inner configure -borderwidth 4 1391 1392 checkbutton $inner.streamlines \ 1393 -text "Visible" \ 1394 -variable [itcl::scope _settings($this-streamlines)] \ 1395 -command [itcl::code $this FixSettings streamlines] \ 1396 -font "Arial 9" 1397 1398 checkbutton $inner.seeds \ 1399 -text "Show seeds" \ 1400 -variable [itcl::scope _settings($this-seeds)] \ 1401 -command [itcl::code $this FixSettings seeds] \ 1402 -font "Arial 9" 1403 1404 label $inner.streammode -text "Mode" \ 1405 -font "Arial 9" 1406 1407 itk_component add streammode { 1408 Rappture::Combobox $inner.streammode_combo -width 10 -editable no 1409 } 1410 $inner.streammode_combo choices insert end \ 1411 "lines" "lines" \ 1412 "ribbons" "ribbons" \ 1413 "tubes" "tubes" 1414 $itk_component(streammode) value "lines" 1415 bind $inner.streammode_combo <<Value>> \ 1416 [itcl::code $this FixSettings streammode] 1417 1418 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1419 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1420 -variable [itcl::scope _settings($this-opacity)] \ 1421 -width 10 \ 1422 -showvalue off -command [itcl::code $this FixSettings opacity] 1423 1424 blt::table $inner \ 1425 0,0 $inner.streamlines -columnspan 4 -anchor w -pady 2 \ 1426 1,0 $inner.seeds -columnspan 4 -anchor w -pady 2 \ 1427 2,0 $inner.streammode -anchor w -pady 2 \ 1428 2,1 $inner.streammode_combo -cspan 3 -anchor w -pady 2 \ 1429 3,0 $inner.opacity_l -pady 2 -fill x\ 1430 4,0 $inner.opacity -columnspan 2 -pady 2 -fill x 1431 1432 blt::table configure $inner r* -resize none 1433 blt::table configure $inner r5 -resize expand 1434 } 1435 1436 itcl::body Rappture::VtkViewer::BuildAxisTab {} { 1437 1438 set fg [option get $itk_component(hull) font Font] 1439 #set bfg [option get $itk_component(hull) boldFont Font] 1440 1441 set inner [$itk_component(main) insert end \ 1349 1442 -title "Axis Settings" \ 1350 -icon [Rappture::icon cog]]1443 -icon [Rappture::icon axis1]] 1351 1444 $inner configure -borderwidth 4 1352 1445 … … 1559 1652 1560 1653 itcl::body Rappture::VtkViewer::SetObjectStyle { dataobj comp } { 1561 array set props {1562 -color \#6666FF1563 -edgevisibility 11564 -edgecolor black1565 -linewidth 1.01566 -opacity 1.01567 -wireframe 01568 -lighting 11569 }1570 1654 # Parse style string. 1655 set tag $dataobj-$comp 1656 set type [$dataobj type $comp] 1657 if { $type == "streamlines" } { 1658 array set props { 1659 -color \#808080 1660 -edgevisibility 0 1661 -edgecolor black 1662 -linewidth 1.0 1663 -opacity 0.4 1664 -wireframe 0 1665 -lighting 1 1666 -seeds 1 1667 -seedcolor white 1668 } 1669 SendCmd "streamlines add $tag" 1670 SendCmd "streamlines seed visible off" 1671 set _haveStreams 1 1672 } else { 1673 array set props { 1674 -color \#6666FF 1675 -edgevisibility 1 1676 -edgecolor black 1677 -linewidth 1.0 1678 -opacity 1.0 1679 -wireframe 0 1680 -lighting 1 1681 } 1682 } 1571 1683 set style [$dataobj style $comp] 1572 set tag $dataobj-$comp1573 1684 array set props $style 1685 1686 SendCmd "polydata edges $props(-edgevisibility) $tag" 1574 1687 SendCmd "polydata color [Color2RGB $props(-color)] $tag" 1575 SendCmd "polydata edges $props(-edgevisibility) $tag"1576 1688 SendCmd "polydata lighting $props(-lighting) $tag" 1577 1689 SendCmd "polydata linecolor [Color2RGB $props(-edgecolor)] $tag"
Note: See TracChangeset
for help on using the changeset viewer.