Changeset 1880 for branches/blt4/gui/scripts
- Timestamp:
- Aug 24, 2010, 8:38:37 PM (14 years ago)
- Location:
- branches/blt4/gui/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/blt4/gui/scripts/drawing3d.tcl
r1879 r1880 31 31 public method style { elem } 32 32 public method values { elem } 33 public method data { elem } 33 34 public method hints {{keyword ""}} 34 35 public method components { args } … … 38 39 private variable _actors 39 40 private variable _styles 41 private variable _data 40 42 private variable _hints 41 43 private variable _units … … 68 70 # determine the overall size of the device 69 71 foreach elem [$_xmlobj children $path] { 70 puts stderr elem=$elem71 72 switch -glob -- $elem { 72 73 polygon* { 73 74 set data [$_xmlobj get $path.$elem.vtk] 74 puts stderr "data=$data"75 75 set arr [vtkCharArray $this-xvtkCharArray] 76 76 $arr SetArray $data [string length $data] 1 … … 85 85 set _limits($elem) [$actor GetBounds] 86 86 set _styles($elem) [$_xmlobj get $path.$elem.style] 87 set _data($elem) $mapper 87 88 } 88 89 } … … 129 130 130 131 # ---------------------------------------------------------------------- 131 # method mesh132 # method style 132 133 # Returns a base64 encoded, gzipped Tcl list that represents the 133 134 # Tcl command and data to recreate the uniform rectangular grid … … 142 143 143 144 # ---------------------------------------------------------------------- 145 # method data 146 # Returns a base64 encoded, gzipped Tcl list that represents the 147 # Tcl command and data to recreate the uniform rectangular grid 148 # on the nanovis server. 149 # ---------------------------------------------------------------------- 150 itcl::body Rappture::Drawing3d::data { elem } { 151 if { [info exists _data($elem)] } { 152 return $_data($elem) 153 } 154 return "" 155 } 156 157 # ---------------------------------------------------------------------- 144 158 # method values 145 159 # Returns a base64 encoded, gzipped Tcl list that represents the … … 155 169 156 170 itcl::body Rappture::Drawing3d::components { args } { 157 puts stderr "components=[array names _actors]"158 171 return [array names _actors] 159 172 } -
branches/blt4/gui/scripts/vtkviewer.tcl
r1879 r1880 33 33 inherit itk::Widget 34 34 35 itk_option define -plotforeground plotForeground Foreground "" 36 itk_option define -plotbackground plotBackground Background "" 37 35 38 private variable _dlist "" ;# list of data objects 36 39 private variable _dims "" ;# dimensionality of data objects … … 51 54 private variable _interactor ""; 52 55 private variable _style ""; 56 private variable _light ""; 53 57 private variable _cubeAxesActor "" 54 58 private variable _axesActor "" 55 59 private variable _axesWidget ""; 56 60 private variable _settings 57 61 constructor {args} { 58 62 # defined below … … 82 86 protected method SetActorProperties { actor style } 83 87 84 itk_option define -plotforeground plotForeground Foreground "" 85 itk_option define -plotbackground plotBackground Background "" 88 private method BuildCameraTab {} 89 private method BuildCutplanesTab {} 90 private method BuildViewTab {} 91 private method BuildVolumeTab {} 92 protected method FixSettings {what {value ""}} 86 93 87 94 } … … 109 116 set _view(phi) 0 110 117 111 foreach val {xmin xmax ymin ymax zmin zmax vmin vmax} { 112 set _limits($val) "" 113 } 118 array set _limits { 119 xmin 0 120 xmax 1 121 ymin 0 122 ymax 1 123 zmin 0 124 zmax 1 125 vmin 0 126 vmax 1 127 } 128 129 itk_component add main { 130 Rappture::SidebarFrame $itk_interior.main 131 } 132 pack $itk_component(main) -expand yes -fill both 133 set f [$itk_component(main) component frame] 114 134 115 135 itk_component add controls { 116 frame $ itk_interior.cntls136 frame $f.cntls 117 137 } { 118 138 usual … … 169 189 170 190 # 171 # Create slicer controls...172 #173 itk_component add slicers {174 frame $itk_component(controls).slicers175 } {176 usual177 rename -background -controlbackground controlBackground Background178 }179 pack $itk_component(slicers) -side bottom -padx 4 -pady 4180 grid rowconfigure $itk_component(slicers) 1 -weight 1181 182 #183 # X-value slicer...184 #185 itk_component add xslice {186 label $itk_component(slicers).xslice \187 -borderwidth 1 -relief raised -padx 1 -pady 1 \188 -bitmap [Rappture::icon x]189 } {190 usual191 ignore -borderwidth192 rename -highlightbackground -controlbackground controlBackground Background193 }194 bind $itk_component(xslice) <ButtonPress> \195 [itcl::code $this Slice axis x toggle]196 Rappture::Tooltip::for $itk_component(xslice) \197 "Toggle the X cut plane on/off"198 grid $itk_component(xslice) -row 0 -column 0 -sticky ew -padx 1199 200 itk_component add xslicer {201 ::scale $itk_component(slicers).xval -from 100 -to 0 \202 -width 10 -orient vertical -showvalue off -state disabled \203 -borderwidth 1 -highlightthickness 0 \204 -command [itcl::code $this Slice move x]205 } {206 usual207 ignore -borderwidth208 ignore -highlightthickness209 rename -highlightbackground -controlbackground controlBackground Background210 rename -troughcolor -controldarkbackground controlDarkBackground Background211 }212 grid $itk_component(xslicer) -row 1 -column 0 -padx 1213 Rappture::Tooltip::for $itk_component(xslicer) \214 "@[itcl::code $this Slicertip x]"215 216 #217 # Y-value slicer...218 #219 itk_component add yslice {220 label $itk_component(slicers).yslice \221 -borderwidth 1 -relief raised -padx 1 -pady 1 \222 -bitmap [Rappture::icon y]223 } {224 usual225 ignore -borderwidth226 rename -highlightbackground -controlbackground controlBackground Background227 }228 bind $itk_component(yslice) <ButtonPress> \229 [itcl::code $this Slice axis y toggle]230 Rappture::Tooltip::for $itk_component(yslice) \231 "Toggle the Y cut plane on/off"232 grid $itk_component(yslice) -row 0 -column 1 -sticky ew -padx 1233 234 itk_component add yslicer {235 ::scale $itk_component(slicers).yval -from 100 -to 0 \236 -width 10 -orient vertical -showvalue off -state disabled \237 -borderwidth 1 -highlightthickness 0 \238 -command [itcl::code $this Slice move y]239 } {240 usual241 ignore -borderwidth242 ignore -highlightthickness243 rename -highlightbackground -controlbackground controlBackground Background244 rename -troughcolor -controldarkbackground controlDarkBackground Background245 }246 grid $itk_component(yslicer) -row 1 -column 1 -padx 1247 Rappture::Tooltip::for $itk_component(yslicer) \248 "@[itcl::code $this Slicertip y]"249 250 #251 # Z-value slicer...252 #253 itk_component add zslice {254 label $itk_component(slicers).zslice \255 -borderwidth 1 -relief raised -padx 1 -pady 1 \256 -bitmap [Rappture::icon z]257 } {258 usual259 ignore -borderwidth260 rename -highlightbackground -controlbackground controlBackground Background261 }262 grid $itk_component(zslice) -row 0 -column 2 -sticky ew -padx 1263 bind $itk_component(zslice) <ButtonPress> \264 [itcl::code $this Slice axis z toggle]265 Rappture::Tooltip::for $itk_component(zslice) \266 "Toggle the Z cut plane on/off"267 268 itk_component add zslicer {269 ::scale $itk_component(slicers).zval -from 100 -to 0 \270 -width 10 -orient vertical -showvalue off -state disabled \271 -borderwidth 1 -highlightthickness 0 \272 -command [itcl::code $this Slice move z]273 } {274 usual275 ignore -borderwidth276 ignore -highlightthickness277 rename -highlightbackground -controlbackground controlBackground Background278 rename -troughcolor -controldarkbackground controlDarkBackground Background279 }280 grid $itk_component(zslicer) -row 1 -column 2 -padx 1281 Rappture::Tooltip::for $itk_component(zslicer) \282 "@[itcl::code $this Slicertip z]"283 284 #285 191 # RENDERING AREA 286 192 # 287 193 itk_component add area { 288 frame $ itk_interior.area194 frame $f.area 289 195 } 290 196 pack $itk_component(area) -expand yes -fill both … … 321 227 $_axesWidget SetViewport 0 0 0.3 0.3 322 228 323 $_window LineSmoothingOn324 $_window PolygonSmoothingOn325 326 229 $_cubeAxesActor SetXTitle "X Axis (units)" 327 230 $_cubeAxesActor SetYTitle "Y Axis (units)" 328 231 329 if 0 { 330 vtkRenderer $this-ren2 331 vtkRenderWindow $this-vtkRenderWindow2 332 $this-vtkRenderWindow2 AddRenderer $this-vtkRenderer2 333 vtkRenderWindowInteractor $this-vtkInteractor2 334 $this-vtkInteractor2 SetRenderWindow $this-vtkRenderWindow2 335 336 itk_component add legend { 337 vtkTkRenderWidget $itk_component(area).legend \ 338 -rw $this-vtkRenderWindow2 -width 1 -height 40 339 } { 340 } 341 pack $itk_component(legend) -side bottom -fill x 342 } 232 BuildViewTab 233 BuildVolumeTab 234 BuildCutplanesTab 235 BuildCameraTab 236 237 set v0 0 238 set v1 1 239 set _lookup [vtkLookupTable $this-Lookup] 240 $_lookup SetTableRange $v0 $v1 241 $_lookup SetHueRange 0.66667 0.0 242 $_lookup Build 243 244 245 # 246 # 3D CUT PLANES 247 # 248 foreach axis {x y z} norm {{1 0 0} {0 1 0} {0 0 1}} { 249 250 set plane [vtkPlane $this-${axis}cutplane] 251 eval $plane SetNormal $norm 252 set _slicer(${axis}plane) $plane 253 254 set cutter [vtkCutter $this-${axis}cutter] 255 $cutter SetCutFunction $plane 256 257 set mapper [vtkPolyDataMapper $this-${axis}cutmapper] 258 $mapper SetInput [$cutter GetOutput] 259 $mapper SetScalarRange $v0 $v1 260 $mapper SetLookupTable $_lookup 261 262 #lappend _obj2vtk($dataobj) $cutplane $cutter $mapper 263 264 set actor [vtkActor $this-${axis}actor] 265 $actor VisibilityOn 266 $actor SetMapper $mapper 267 $actor SetPosition 0 0 0 268 [$actor GetProperty] SetColor 0 0 0 269 set _slicer(${axis}slice) $actor 270 271 $_renderer AddActor $actor 272 lappend _actors($_renderer) $actor 273 #lappend _obj2vtk($dataobj) $actor 274 } 275 276 # 277 # CUT PLANE READOUT 278 # 279 set mapper [vtkTextMapper $this-text] 280 set props [$mapper GetTextProperty] 281 #eval $props SetColor [_color2rgb $itk_option(-plotforeground)] 282 $props SetVerticalJustificationToTop 283 set _slicer(readout) $mapper 284 285 set actor [vtkActor2D $this-texta] 286 $actor SetMapper $mapper 287 set coords [$actor GetPositionCoordinate] 288 $coords SetCoordinateSystemToNormalizedDisplay 289 $coords SetValue 0.02 0.98 290 291 $_renderer AddActor $actor 292 lappend _actors($_renderer) $actor 293 #lappend _obj2vtk($dataobj) $mapper $actor 294 295 # turn off all slicers by default 296 foreach axis {x y z} { 297 $itk_component(${axis}CutScale) configure -state normal 298 $itk_component(${axis}CutScale) set 50 299 Slice move $axis 50 300 Slice axis $axis off 301 } 302 303 set _light [vtkLight $this-Light] 304 $_light SetColor 1 1 1 305 $_light SetAttenuationValues 0 0 0 306 $_light SetFocalPoint 0 0 0 307 $_light SetLightTypeToHeadlight 308 $_renderer AddLight $_light 309 343 310 # 344 311 # Create a picture for download snapshots … … 680 647 if {$op == ""} { set op "on" } 681 648 682 if {[$itk_component(${axis}slice) cget -relief] == "raised"} { 683 set current "off" 649 set current $_settings($this-${axis}cutplane) 650 if {$op == "toggle"} { 651 set op [expr $current==0] 652 } 653 654 if {$op} { 655 $itk_component(${axis}CutScale) configure -state normal 656 $_slicer(${axis}slice) VisibilityOn 657 $itk_component(${axis}CutButton) select 684 658 } else { 685 set current "on" 686 } 687 688 if {$op == "toggle"} { 689 if {$current == "on"} { set op "off" } else { set op "on" } 690 } 691 692 if {$op} { 693 $itk_component(${axis}slicer) configure -state normal 694 $_slicer(${axis}slice) VisibilityOn 695 $itk_component(${axis}slice) configure -relief sunken 696 } else { 697 $itk_component(${axis}slicer) configure -state disabled 659 $itk_component(${axis}CutScale) configure -state disabled 698 660 $_slicer(${axis}slice) VisibilityOff 699 $itk_component(${axis} slice) configure -relief raised661 $itk_component(${axis}CutButton) deselect 700 662 } 701 663 $_window Render … … 840 802 itcl::body Rappture::VtkViewer::SetActorProperties { actor style } { 841 803 array set props { 842 -color blue804 -color \#6666FF 843 805 -edgevisibility yes 844 806 -edgecolor black … … 855 817 $prop EdgeVisibilityOff 856 818 } 819 set _settings($this-edges) $props(-edgevisibility) 857 820 eval $prop SetEdgeColor [_color2rgb $props(-edgecolor)] 858 821 $prop SetLineWidth $props(-linewidth) 859 822 $prop SetOpacity $props(-opacity) 823 set _settings($this-opacity) [expr $props(-opacity) * 100.0] 860 824 } 861 825 … … 899 863 900 864 if 0 { 901 set lu $this-vtkLookup $id902 865 set lu $this-vtkLookup 866 vtkLookupTable $lu 903 867 $lu SetTableRange $v0 $v1 904 868 $lu SetHueRange 0.66667 0.0 … … 924 888 set zr [expr {$z1-$z0}] 925 889 926 set light [vtkLight $this-vtkLight $id]890 set light [vtkLight $this-vtkLight] 927 891 $light SetColor 1 1 1 928 892 $light SetAttenuationValues 0 0 0 … … 945 909 $_cubeAxesActor SetCamera [$_renderer GetActiveCamera] 946 910 eval $_cubeAxesActor SetBounds [$actor GetBounds] 947 puts stderr "added action $actor to $_renderer" 911 912 set mapper [$dataobj data $comp] 913 $this-xcutter SetInput [$mapper GetInput] 914 948 915 if 0 { 949 916 # … … 970 937 vtkPoints { 971 938 # handle cloud of 3D points 972 set pd $this-polydata $id939 set pd $this-polydata 973 940 vtkPolyData $pd 974 941 $pd SetPoints $mesh 975 942 [$pd GetPointData] SetScalars [$dataobj values $comp] 976 943 977 set tr $this-triangles $id944 set tr $this-triangles 978 945 vtkDelaunay3D $tr 979 946 $tr SetInput $pd … … 981 948 set source [$tr GetOutput] 982 949 983 set mp $this-mapper $id950 set mp $this-mapper 984 951 vtkPolyDataMapper $mp 985 952 … … 988 955 vtkUnstructuredGrid { 989 956 # handle 3D grid with connectivity 990 set gr $this-grdata $id957 set gr $this-grdata 991 958 vtkUnstructuredGrid $gr 992 959 $gr ShallowCopy $mesh … … 998 965 vtkRectilinearGrid { 999 966 # handle 3D grid with connectivity 1000 set gr $this-grdata $id967 set gr $this-grdata 1001 968 vtkRectilinearGrid $gr 1002 969 $gr ShallowCopy $mesh … … 1014 981 # 3D ISOSURFACES 1015 982 # 1016 set iso $this-iso $id983 set iso $this-iso 1017 984 vtkContourFilter $iso 1018 985 $iso SetInput $source 1019 986 1020 set mp $this-isomap $id987 set mp $this-isomap 1021 988 vtkPolyDataMapper $mp 1022 989 $mp SetInput [$iso GetOutput] 1023 990 1024 set ac $this-isoactor $id991 set ac $this-isoactor 1025 992 vtkActor $ac 1026 993 $ac SetMapper $mp … … 1318 1285 } 1319 1286 1287 itcl::body Rappture::VtkViewer::BuildViewTab {} { 1288 foreach { key value } { 1289 edges 1 1290 axes 1 1291 wireframe 0 1292 volume 1 1293 legend 1 1294 particles 1 1295 lic 1 1296 } { 1297 set _settings($this-$key) $value 1298 } 1299 1300 set fg [option get $itk_component(hull) font Font] 1301 #set bfg [option get $itk_component(hull) boldFont Font] 1302 1303 set tab [$itk_component(main) insert end \ 1304 -title "View Settings" \ 1305 -icon [Rappture::icon wrench]] 1306 blt::scrollset $tab.ss \ 1307 -xscrollbar $tab.ss.xs \ 1308 -yscrollbar $tab.ss.ys \ 1309 -window $tab.ss.frame 1310 pack $tab.ss -fill both -expand yes 1311 blt::tk::scrollbar $tab.ss.xs 1312 blt::tk::scrollbar $tab.ss.ys 1313 set inner [blt::tk::frame $tab.ss.frame] 1314 $inner configure -borderwidth 4 1315 1316 set ::Rappture::VtkViewer::_settings($this-isosurface) 0 1317 checkbutton $inner.isosurface \ 1318 -text "Isosurface shading" \ 1319 -variable [itcl::scope _settings($this-isosurface)] \ 1320 -command [itcl::code $this FixSettings isosurface] \ 1321 -font "Arial 9" 1322 1323 checkbutton $inner.axes \ 1324 -text "Axes" \ 1325 -variable [itcl::scope _settings($this-axes)] \ 1326 -command [itcl::code $this FixSettings axes] \ 1327 -font "Arial 9" 1328 1329 checkbutton $inner.edges \ 1330 -text "Edges" \ 1331 -variable [itcl::scope _settings($this-edges)] \ 1332 -command [itcl::code $this FixSettings edges] \ 1333 -font "Arial 9" 1334 1335 checkbutton $inner.wireframe \ 1336 -text "Wireframe" \ 1337 -variable [itcl::scope _settings($this-wireframe)] \ 1338 -command [itcl::code $this FixSettings wireframe] \ 1339 -font "Arial 9" 1340 1341 checkbutton $inner.legend \ 1342 -text "Legend" \ 1343 -variable [itcl::scope _settings($this-legend)] \ 1344 -command [itcl::code $this FixSettings legend] \ 1345 -font "Arial 9" 1346 1347 checkbutton $inner.volume \ 1348 -text "Volume" \ 1349 -variable [itcl::scope _settings($this-volume)] \ 1350 -command [itcl::code $this FixSettings volume] \ 1351 -font "Arial 9" 1352 1353 blt::table $inner \ 1354 0,0 $inner.axes -columnspan 2 -anchor w \ 1355 1,0 $inner.edges -columnspan 2 -anchor w \ 1356 2,0 $inner.wireframe -columnspan 2 -anchor w \ 1357 3,0 $inner.volume -columnspan 2 -anchor w \ 1358 4,0 $inner.legend -columnspan 2 -anchor w 1359 1360 if 0 { 1361 bind $inner <Map> [itcl::code $this GetVolumeInfo $inner] 1362 } 1363 blt::table configure $inner r* -resize none 1364 blt::table configure $inner r5 -resize expand 1365 } 1366 1367 itcl::body Rappture::VtkViewer::BuildVolumeTab {} { 1368 foreach { key value } { 1369 light 40 1370 transp 50 1371 opacity 1000 1372 } { 1373 set _settings($this-$key) $value 1374 } 1375 1376 set tab [$itk_component(main) insert end \ 1377 -title "Volume Settings" \ 1378 -icon [Rappture::icon volume-on]] 1379 blt::scrollset $tab.ss \ 1380 -xscrollbar $tab.ss.xs \ 1381 -yscrollbar $tab.ss.ys \ 1382 -window $tab.ss.frame 1383 pack $tab.ss -fill both -expand yes 1384 blt::tk::scrollbar $tab.ss.xs 1385 blt::tk::scrollbar $tab.ss.ys 1386 set inner [blt::tk::frame $tab.ss.frame] 1387 $inner configure -borderwidth 4 1388 1389 set fg [option get $itk_component(hull) font Font] 1390 #set bfg [option get $itk_component(hull) boldFont Font] 1391 1392 checkbutton $inner.vol -text "Show volume" -font $fg \ 1393 -variable [itcl::scope _settings($this-volume)] \ 1394 -command [itcl::code $this FixSettings volume] 1395 label $inner.shading -text "Shading:" -font $fg 1396 1397 label $inner.dim -text "Dim" -font $fg 1398 ::scale $inner.light -from 0 -to 100 -orient horizontal \ 1399 -variable [itcl::scope _settings($this-light)] \ 1400 -width 10 \ 1401 -showvalue off -command [itcl::code $this FixSettings light] 1402 label $inner.bright -text "Bright" -font $fg 1403 1404 label $inner.fog -text "Fog" -font $fg 1405 ::scale $inner.transp -from 0 -to 100 -orient horizontal \ 1406 -variable [itcl::scope _settings($this-transp)] \ 1407 -width 10 \ 1408 -showvalue off -command [itcl::code $this FixSettings transp] 1409 label $inner.plastic -text "Plastic" -font $fg 1410 1411 label $inner.clear -text "Clear" -font $fg 1412 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1413 -variable [itcl::scope _settings($this-opacity)] \ 1414 -width 10 \ 1415 -showvalue off -command [itcl::code $this FixSettings opacity] 1416 label $inner.opaque -text "Opaque" -font $fg 1417 1418 blt::table $inner \ 1419 0,0 $inner.vol -columnspan 4 -anchor w -pady 2 \ 1420 1,0 $inner.shading -columnspan 4 -anchor w -pady {10 2} \ 1421 2,0 $inner.dim -anchor e -pady 2 \ 1422 2,1 $inner.light -columnspan 2 -pady 2 -fill x \ 1423 2,3 $inner.bright -anchor w -pady 2 \ 1424 3,0 $inner.fog -anchor e -pady 2 \ 1425 3,1 $inner.transp -columnspan 2 -pady 2 -fill x \ 1426 3,3 $inner.plastic -anchor w -pady 2 \ 1427 4,0 $inner.clear -anchor e -pady 2 \ 1428 4,1 $inner.opacity -columnspan 2 -pady 2 -fill x\ 1429 4,3 $inner.opaque -anchor w -pady 2 1430 1431 blt::table configure $inner c0 c1 c3 r* -resize none 1432 blt::table configure $inner r6 -resize expand 1433 } 1434 1435 itcl::body Rappture::VtkViewer::BuildCutplanesTab {} { 1436 1437 set tab [$itk_component(main) insert end \ 1438 -title "Cutplane Settings" \ 1439 -icon [Rappture::icon cutbutton]] 1440 blt::scrollset $tab.ss \ 1441 -xscrollbar $tab.ss.xs \ 1442 -yscrollbar $tab.ss.ys \ 1443 -window $tab.ss.frame 1444 pack $tab.ss -fill both -expand yes 1445 blt::tk::scrollbar $tab.ss.xs 1446 blt::tk::scrollbar $tab.ss.ys 1447 set inner [blt::tk::frame $tab.ss.frame] 1448 $inner configure -borderwidth 4 1449 1450 # X-value slicer... 1451 itk_component add xCutButton { 1452 Rappture::PushButton $inner.xbutton \ 1453 -onimage [Rappture::icon x-cutplane] \ 1454 -offimage [Rappture::icon x-cutplane] \ 1455 -command [itcl::code $this FixSettings xcutplane] \ 1456 -variable [itcl::scope _settings($this-xcutplane)] 1457 } 1458 Rappture::Tooltip::for $itk_component(xCutButton) \ 1459 "Toggle the X cut plane on/off" 1460 1461 itk_component add xCutScale { 1462 ::scale $inner.xval -from 100 -to 0 \ 1463 -width 10 -orient vertical -showvalue off -state disabled \ 1464 -borderwidth 1 -highlightthickness 0 \ 1465 -command [itcl::code $this Slice move x] 1466 } { 1467 usual 1468 ignore -borderwidth -highlightthickness 1469 } 1470 # Set the default cutplane value before disabling the scale. 1471 $itk_component(xCutScale) set 50 1472 $itk_component(xCutScale) configure -state disabled 1473 Rappture::Tooltip::for $itk_component(xCutScale) \ 1474 "@[itcl::code $this SlicerTip x]" 1475 1476 # Y-value slicer... 1477 itk_component add yCutButton { 1478 Rappture::PushButton $inner.ybutton \ 1479 -onimage [Rappture::icon y-cutplane] \ 1480 -offimage [Rappture::icon y-cutplane] \ 1481 -command [itcl::code $this FixSettings ycutplane] \ 1482 -variable [itcl::scope _settings($this-ycutplane)] 1483 } 1484 Rappture::Tooltip::for $itk_component(yCutButton) \ 1485 "Toggle the Y cut plane on/off" 1486 1487 itk_component add yCutScale { 1488 ::scale $inner.yval -from 100 -to 0 \ 1489 -width 10 -orient vertical -showvalue off -state disabled \ 1490 -borderwidth 1 -highlightthickness 0 \ 1491 -command [itcl::code $this Slice move y] 1492 } { 1493 usual 1494 ignore -borderwidth -highlightthickness 1495 } 1496 Rappture::Tooltip::for $itk_component(yCutScale) \ 1497 "@[itcl::code $this SlicerTip y]" 1498 # Set the default cutplane value before disabling the scale. 1499 $itk_component(yCutScale) set 50 1500 $itk_component(yCutScale) configure -state disabled 1501 1502 # Z-value slicer... 1503 itk_component add zCutButton { 1504 Rappture::PushButton $inner.zbutton \ 1505 -onimage [Rappture::icon z-cutplane] \ 1506 -offimage [Rappture::icon z-cutplane] \ 1507 -command [itcl::code $this FixSettings zcutplane] \ 1508 -variable [itcl::scope _settings($this-zcutplane)] 1509 } 1510 Rappture::Tooltip::for $itk_component(zCutButton) \ 1511 "Toggle the Z cut plane on/off" 1512 1513 itk_component add zCutScale { 1514 ::scale $inner.zval -from 100 -to 0 \ 1515 -width 10 -orient vertical -showvalue off -state disabled \ 1516 -borderwidth 1 -highlightthickness 0 \ 1517 -command [itcl::code $this Slice move z] 1518 } { 1519 usual 1520 ignore -borderwidth -highlightthickness 1521 } 1522 $itk_component(zCutScale) set 50 1523 $itk_component(zCutScale) configure -state disabled 1524 #$itk_component(zCutScale) configure -state disabled 1525 Rappture::Tooltip::for $itk_component(zCutScale) \ 1526 "@[itcl::code $this SlicerTip z]" 1527 1528 blt::table $inner \ 1529 1,1 $itk_component(xCutButton) \ 1530 1,2 $itk_component(yCutButton) \ 1531 1,3 $itk_component(zCutButton) \ 1532 0,1 $itk_component(xCutScale) \ 1533 0,2 $itk_component(yCutScale) \ 1534 0,3 $itk_component(zCutScale) 1535 1536 blt::table configure $inner r0 r1 c* -resize none 1537 blt::table configure $inner r2 c4 -resize expand 1538 blt::table configure $inner c0 -width 2 1539 blt::table configure $inner c1 c2 c3 -padx 2 1540 } 1541 1542 itcl::body Rappture::VtkViewer::BuildCameraTab {} { 1543 set tab [$itk_component(main) insert end \ 1544 -title "Camera Settings" \ 1545 -icon [Rappture::icon camera]] 1546 blt::scrollset $tab.ss \ 1547 -xscrollbar $tab.ss.xs \ 1548 -yscrollbar $tab.ss.ys \ 1549 -window $tab.ss.frame 1550 blt::tk::scrollbar $tab.ss.xs 1551 blt::tk::scrollbar $tab.ss.ys 1552 pack $tab.ss -fill both -expand yes 1553 set inner [blt::tk::frame $tab.ss.frame] 1554 $inner configure -borderwidth 4 1555 1556 set labels { phi theta psi pan-x pan-y zoom } 1557 set row 0 1558 foreach tag $labels { 1559 label $inner.${tag}label -text $tag -font "Arial 9" 1560 entry $inner.${tag} -font "Arial 9" -bg white \ 1561 -textvariable [itcl::scope _settings($this-$tag)] 1562 bind $inner.${tag} <KeyPress-Return> \ 1563 [itcl::code $this camera set ${tag}] 1564 blt::table $inner \ 1565 $row,0 $inner.${tag}label -anchor e -pady 2 \ 1566 $row,1 $inner.${tag} -anchor w -pady 2 1567 blt::table configure $inner r$row -resize none 1568 incr row 1569 } 1570 blt::table configure $inner c0 c1 -resize none 1571 blt::table configure $inner c2 -resize expand 1572 blt::table configure $inner r$row -resize expand 1573 } 1574 1575 # ---------------------------------------------------------------------- 1576 # USAGE: FixSettings <what> ?<value>? 1577 # 1578 # Used internally to update rendering settings whenever parameters 1579 # change in the popup settings panel. Sends the new settings off 1580 # to the back end. 1581 # ---------------------------------------------------------------------- 1582 itcl::body Rappture::VtkViewer::FixSettings {what {value ""}} { 1583 switch -- $what { 1584 light { 1585 } 1586 transp { 1587 } 1588 opacity { 1589 set new [expr $_settings($this-opacity) * 0.01] 1590 foreach dataobj [get] { 1591 foreach comp [$dataobj components] { 1592 set actor [$dataobj values $comp] 1593 set prop [$actor GetProperty] 1594 $prop SetOpacity $new 1595 } 1596 } 1597 $_window Render 1598 } 1599 1600 "wireframe" { 1601 foreach dataobj [get] { 1602 foreach comp [$dataobj components] { 1603 set actor [$dataobj values $comp] 1604 set prop [$actor GetProperty] 1605 if { $_settings($this-wireframe) } { 1606 $prop SetRepresentationToWireframe 1607 } else { 1608 $prop SetRepresentationToSurface 1609 } 1610 } 1611 } 1612 $_window Render 1613 } 1614 "isosurface" { 1615 } 1616 "edges" { 1617 foreach dataobj [get] { 1618 foreach comp [$dataobj components] { 1619 set actor [$dataobj values $comp] 1620 set prop [$actor GetProperty] 1621 if { $_settings($this-edges) } { 1622 $prop EdgeVisibilityOn 1623 } else { 1624 $prop EdgeVisibilityOff 1625 } 1626 } 1627 } 1628 $_window Render 1629 } 1630 "axes" { 1631 if { $_settings($this-axes) } { 1632 $_cubeAxesActor VisibilityOn 1633 } else { 1634 $_cubeAxesActor VisibilityOff 1635 } 1636 $_window Render 1637 } 1638 "legend" { 1639 if { $_settings($this-legend) } { 1640 blt::table $itk_component(plotarea) \ 1641 0,0 $itk_component(3dview) -fill both \ 1642 1,0 $itk_component(legend) -fill x 1643 blt::table configure $itk_component(plotarea) r1 -resize none 1644 } else { 1645 blt::table forget $itk_component(legend) 1646 } 1647 } 1648 "volume" { 1649 } 1650 "xcutplane" - "ycutplane" - "zcutplane" { 1651 set axis [string range $what 0 0] 1652 set bool $_settings($this-$what) 1653 if { $bool } { 1654 $itk_component(${axis}CutScale) configure -state normal \ 1655 -troughcolor white 1656 } else { 1657 $itk_component(${axis}CutScale) configure -state disabled \ 1658 -troughcolor grey82 1659 } 1660 } 1661 default { 1662 error "don't know how to fix $what" 1663 } 1664 } 1665 } 1666 1667 if 0 { 1668 # 1669 # Create slicer controls... 1670 # 1671 itk_component add slicers { 1672 frame $itk_component(controls).slicers 1673 } { 1674 usual 1675 rename -background -controlbackground controlBackground Background 1676 } 1677 pack $itk_component(slicers) -side bottom -padx 4 -pady 4 1678 grid rowconfigure $itk_component(slicers) 1 -weight 1 1679 1680 # 1681 # X-value slicer... 1682 # 1683 itk_component add xslice { 1684 label $itk_component(slicers).xslice \ 1685 -borderwidth 1 -relief raised -padx 1 -pady 1 \ 1686 -bitmap [Rappture::icon x] 1687 } { 1688 usual 1689 ignore -borderwidth 1690 rename -highlightbackground -controlbackground controlBackground Background 1691 } 1692 bind $itk_component(xslice) <ButtonPress> \ 1693 [itcl::code $this Slice axis x toggle] 1694 Rappture::Tooltip::for $itk_component(xslice) \ 1695 "Toggle the X cut plane on/off" 1696 grid $itk_component(xslice) -row 0 -column 0 -sticky ew -padx 1 1697 1698 itk_component add xslicer { 1699 ::scale $itk_component(slicers).xval -from 100 -to 0 \ 1700 -width 10 -orient vertical -showvalue off -state disabled \ 1701 -borderwidth 1 -highlightthickness 0 \ 1702 -command [itcl::code $this Slice move x] 1703 } { 1704 usual 1705 ignore -borderwidth 1706 ignore -highlightthickness 1707 rename -highlightbackground -controlbackground controlBackground Background 1708 rename -troughcolor -controldarkbackground controlDarkBackground Background 1709 } 1710 grid $itk_component(xslicer) -row 1 -column 0 -padx 1 1711 Rappture::Tooltip::for $itk_component(xslicer) \ 1712 "@[itcl::code $this Slicertip x]" 1713 1714 # 1715 # Y-value slicer... 1716 # 1717 itk_component add yslice { 1718 label $itk_component(slicers).yslice \ 1719 -borderwidth 1 -relief raised -padx 1 -pady 1 \ 1720 -bitmap [Rappture::icon y] 1721 } { 1722 usual 1723 ignore -borderwidth 1724 rename -highlightbackground -controlbackground controlBackground Background 1725 } 1726 bind $itk_component(yslice) <ButtonPress> \ 1727 [itcl::code $this Slice axis y toggle] 1728 Rappture::Tooltip::for $itk_component(yslice) \ 1729 "Toggle the Y cut plane on/off" 1730 grid $itk_component(yslice) -row 0 -column 1 -sticky ew -padx 1 1731 1732 itk_component add yslicer { 1733 ::scale $itk_component(slicers).yval -from 100 -to 0 \ 1734 -width 10 -orient vertical -showvalue off -state disabled \ 1735 -borderwidth 1 -highlightthickness 0 \ 1736 -command [itcl::code $this Slice move y] 1737 } { 1738 usual 1739 ignore -borderwidth 1740 ignore -highlightthickness 1741 rename -highlightbackground -controlbackground controlBackground Background 1742 rename -troughcolor -controldarkbackground controlDarkBackground Background 1743 } 1744 grid $itk_component(yslicer) -row 1 -column 1 -padx 1 1745 Rappture::Tooltip::for $itk_component(yslicer) \ 1746 "@[itcl::code $this Slicertip y]" 1747 1748 # 1749 # Z-value slicer... 1750 # 1751 itk_component add zslice { 1752 label $itk_component(slicers).zslice \ 1753 -borderwidth 1 -relief raised -padx 1 -pady 1 \ 1754 -bitmap [Rappture::icon z] 1755 } { 1756 usual 1757 ignore -borderwidth 1758 rename -highlightbackground -controlbackground controlBackground Background 1759 } 1760 grid $itk_component(zslice) -row 0 -column 2 -sticky ew -padx 1 1761 bind $itk_component(zslice) <ButtonPress> \ 1762 [itcl::code $this Slice axis z toggle] 1763 Rappture::Tooltip::for $itk_component(zslice) \ 1764 "Toggle the Z cut plane on/off" 1765 1766 itk_component add zslicer { 1767 ::scale $itk_component(slicers).zval -from 100 -to 0 \ 1768 -width 10 -orient vertical -showvalue off -state disabled \ 1769 -borderwidth 1 -highlightthickness 0 \ 1770 -command [itcl::code $this Slice move z] 1771 } { 1772 usual 1773 ignore -borderwidth 1774 ignore -highlightthickness 1775 rename -highlightbackground -controlbackground controlBackground Background 1776 rename -troughcolor -controldarkbackground controlDarkBackground Background 1777 } 1778 grid $itk_component(zslicer) -row 1 -column 2 -padx 1 1779 Rappture::Tooltip::for $itk_component(zslicer) \ 1780 "@[itcl::code $this Slicertip z]" 1781 1782 }
Note: See TracChangeset
for help on using the changeset viewer.