Changeset 2464
- Timestamp:
- Sep 3, 2011, 1:35:37 PM (13 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/drawing.tcl
r2385 r2464 29 29 } 30 30 public method limits {axis} 31 public method label { elem } 32 public method type { elem } 31 33 public method style { elem } 32 34 public method values { elem } … … 39 41 private variable _actors 40 42 private variable _styles 43 private variable _labels 44 private variable _types 41 45 private variable _data 42 46 private variable _hints … … 73 77 polygon* { 74 78 set _data($elem) [$_xmlobj get $path.$elem.vtk] 79 set _styles($elem) [$_xmlobj get $path.$elem.about.style] 80 set _labels($elem) [$_xmlobj get $path.$elem.about.label] 81 set _types($elem) polydata 82 } 83 streamlines* { 84 set _data($elem) [$_xmlobj get $path.$elem.vtk] 85 set _styles($elem) [$_xmlobj get $path.$elem.about.style] 86 set _labels($elem) [$_xmlobj get $path.$elem.about.label] 87 set _types($elem) streamlines 75 88 } 76 89 } … … 121 134 } 122 135 123 # ---------------------------------------------------------------------- 124 # method style 125 # Returns a base64 encoded, gzipped Tcl list that represents the 126 # Tcl command and data to recreate the uniform rectangular grid 127 # on the nanovis server. 128 # ---------------------------------------------------------------------- 136 # 137 # label -- 138 # 139 # Returns the label of the named drawing element. 140 # 141 itcl::body Rappture::Drawing::label { elem } { 142 if { [info exists _labels($elem)] } { 143 return $_labels($elem) 144 } 145 return "" 146 } 147 148 # 149 # type -- 150 # 151 # Returns the type of the named drawing element. 152 # 153 itcl::body Rappture::Drawing::type { elem } { 154 if { [info exists _types($elem)] } { 155 return $_types($elem) 156 } 157 return "" 158 } 159 160 # 161 # style -- 162 # 163 # Returns the style string of the named drawing element. 164 # 129 165 itcl::body Rappture::Drawing::style { elem } { 130 166 if { [info exists _styles($elem)] } { … … 134 170 } 135 171 136 # ---------------------------------------------------------------------- 137 # method data 138 # Returns a base64 encoded, gzipped Tcl list that represents the 139 # Tcl command and data to recreate the uniform rectangular grid 140 # on the nanovis server. 141 # ---------------------------------------------------------------------- 172 # 173 # data -- 174 # 175 # Returns the data of the named drawing element. 176 # 142 177 itcl::body Rappture::Drawing::data { elem } { 143 178 if { [info exists _data($elem)] } { -
trunk/gui/scripts/sidebarframe.tcl
r1694 r2464 44 44 public method select {which} 45 45 public method pop {what} 46 public method enable { which } 47 public method disable { which } 46 48 47 49 protected method _toggleTab {which} 48 50 protected method _sash {op x} 49 51 protected method _fixLayout {args} 52 protected method TabIndex { which } 50 53 51 54 private variable _dispatcher "" ;# dispatcher for !events … … 400 403 401 404 # ---------------------------------------------------------------------- 405 # USAGE: disable <which> 406 # 407 # Pops open the sidebar and selects the specified panel. The <which> 408 # argument can be a panel index, name, or title. 409 # ---------------------------------------------------------------------- 410 itcl::body Rappture::SidebarFrame::disable {which} { 411 set index [TabIndex $which] 412 set tab [$itk_component(tabs) get $index] 413 $itk_component(tabs) tab configure $tab -state disabled 414 } 415 416 417 # ---------------------------------------------------------------------- 418 # USAGE: enable <which> 419 # 420 # Pops open the sidebar and selects the specified panel. The <which> 421 # argument can be a panel index, name, or title. 422 # ---------------------------------------------------------------------- 423 itcl::body Rappture::SidebarFrame::enable {which} { 424 set index [TabIndex $which] 425 set tab [$itk_component(tabs) get $index] 426 $itk_component(tabs) tab configure $tab -state normal 427 } 428 429 # ---------------------------------------------------------------------- 430 # USAGE: TabIndex <which> 431 # 432 # Pops open the sidebar and selects the specified panel. The <which> 433 # argument can be a panel index, name, or title. 434 # ---------------------------------------------------------------------- 435 itcl::body Rappture::SidebarFrame::TabIndex {which} { 436 set pname "" 437 switch -glob -- $which { 438 [0-9]* { 439 set pname [lindex $_panels(all) $which] 440 } 441 panel[0-9]* { 442 if {[info exists itk_component($which)]} { 443 set pname $which 444 } 445 } 446 default { 447 foreach p $_panels(all) { 448 if {[string equal $_panels($p-title) $which]} { 449 set pname $p 450 break 451 } 452 } 453 } 454 } 455 if {$pname == ""} { 456 error "bad panel name \"$which\": should be panel id, title, or index" 457 } 458 set n [$itk_component(tabs) index -name $pname] 459 return $n 460 } 461 462 # ---------------------------------------------------------------------- 402 463 # USAGE: _toggleTab <which> 403 464 # … … 527 588 } 528 589 } 590 -
trunk/gui/scripts/visviewer.tcl
r2395 r2464 34 34 # server when idle timeout is reached. 35 35 private variable _idleTimeout 43200000; # 12 hours 36 #private variable _idleTimeout 5000; # 5 seconds36 #private variable _idleTimeout 10000; # 5 seconds 37 37 #private variable _idleTimeout 0; # No timeout 38 38 … … 266 266 # 267 267 itcl::body Rappture::VisViewer::IsConnected {} { 268 return [expr {"" != $_sid}] 268 if { $_sid == "" } { 269 return 0 270 } 271 if { [eof $_sid] } { 272 set _sid "" 273 return 0 274 } 275 return 1 269 276 } 270 277 … … 278 285 # 279 286 itcl::body Rappture::VisViewer::CheckConnection {} { 287 $_dispatcher cancel !timeout 288 if { $_idleTimeout > 0 } { 289 $_dispatcher event -after $_idleTimeout !timeout 290 } 280 291 if { [IsConnected] } { 281 if { [eof $_sid] } { 282 error "unexpected eof on socket" 283 } else { 284 $_dispatcher cancel !timeout 285 if { $_idleTimeout > 0 } { 286 $_dispatcher event -after $_idleTimeout !timeout 287 } 288 return 1 289 } 292 return 1 293 } 294 if { $_sid != "" } { 295 fileevent $_sid writable "" 290 296 } 291 297 # If we aren't connected, assume it's because the connection to the … … 332 338 puts -nonewline $_sid $_buffer(out) 333 339 flush $_sid 334 set _done($this) 1; 340 set _done($this) 1; # Success 335 341 } 336 342 -
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.