- Timestamp:
- Jul 16, 2014 2:02:26 PM (10 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/field.tcl
r4502 r4509 1 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 3 2 # ---------------------------------------------------------------------- 4 3 # COMPONENT: field - extracts data from an XML description of a field … … 90 89 # defined below 91 90 } 92 public method blob { cname } 91 public method blob { cname } 93 92 public method components {args} 94 93 public method controls {option args} -
trunk/gui/scripts/nanovisviewer.tcl
r4499 r4509 82 82 public method updateTransferFunctions {} 83 83 84 85 84 # The following methods are only used by this class. 85 86 private method AddNewMarker { x y } 86 87 private method AdjustSetting {what {value ""}} 87 88 private method BuildCameraTab {} … … 105 106 private method GetVolumeInfo { w } 106 107 private method HideAllMarkers {} 107 private method AddNewMarker { x y }108 108 private method InitComponentSettings { cname } 109 109 private method InitSettings { args } … … 118 118 private method ReceiveImage { args } 119 119 private method ReceiveLegend { tf vmin vmax size } 120 private method RemoveMarker { x y } 120 121 private method ResetColormap { cname color } 121 122 private method Rotate {option x y} … … 125 126 private method SlicerTip {axis} 126 127 private method SwitchComponent { cname } 128 private method ToggleVolume { tag name } 127 129 private method Zoom {option} 128 private method ToggleVolume { tag name }129 private method RemoveMarker { x y }130 130 private method ViewToQuaternion {} { 131 131 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] … … 148 148 private variable _view; # View params for 3D view 149 149 private variable _parsedFunction 150 private variable _transferFunctionEditors ;# Array of isosurface level values 0..1150 private variable _transferFunctionEditors 151 151 private variable _settings 152 152 private variable _first "" ; # This is the topmost volume. … … 208 208 -qy 0.353553 209 209 -qz 0.146447 210 -zoom 1.0211 210 -xpan 0 212 211 -ypan 0 212 -zoom 1.0 213 213 } 214 214 set _arcball [blt::arcball create 100 100] … … 240 240 -volume 1 241 241 -volumevisible 1 242 -xcutplaneposition 50 242 243 -xcutplanevisible 1 243 -xcutplaneposition 50244 244 -xpan 0 245 -ycutplaneposition 50 245 246 -ycutplanevisible 1 246 -ycutplaneposition 50247 247 -ypan 0 248 -zcutplaneposition 50 248 249 -zcutplanevisible 1 249 -zcutplaneposition 50250 250 -zoom 1.0 251 251 } … … 721 721 # ---------------------------------------------------------------------- 722 722 itcl::body Rappture::NanovisViewer::SendTransferFunctions {} { 723 if 0 {724 if { $_first == "" } {725 puts stderr "first not set"726 return727 }728 729 foreach tag [CurrentDatasets] {730 if { ![info exists _serverDatasets($tag)] || !$_serverDatasets($tag) } {731 # The volume hasn't reached the server yet. How did we get732 # here?733 puts stderr "Don't have $tag in _serverDatasets"734 continue735 }736 if { ![info exists _dataset2style($tag)] } {737 puts stderr "don't have style for volume $tag"738 continue; # How does this happen?739 }740 foreach {dataobj cname} [split $tag -] break741 set cname $_dataset2style($tag)742 743 ComputeTransferFunction $cname744 SendCmd "volume shading transfunc $cname $tag"745 }746 }747 723 foreach cname [array names _volcomponents] { 748 724 ComputeTransferFunction $cname … … 989 965 PanCamera 990 966 SendCmd "camera zoom $_view(-zoom)" 991 967 968 #cutplane state 0 all 992 969 foreach axis {x y z} { 993 970 # Turn off cutplanes for all volumes … … 1088 1065 -qy 0.353553 1089 1066 -qz 0.146447 1067 -xpan 0 1068 -ypan 0 1090 1069 -zoom 1.0 1091 -xpan 01092 -ypan 01093 1070 } 1094 1071 if { $_first != "" } { … … 1244 1221 } 1245 1222 switch -- $what { 1246 "-current" { 1247 set cname [$itk_component(volcomponents) value] 1248 SwitchComponent $cname 1223 "-ambient" { 1224 # Other parts of the code use the ambient setting to 1225 # tell if the component settings have been initialized 1226 if { ![info exists _settings($_current${what})] } { 1227 InitComponentSettings $_current 1228 } 1229 set _settings($_current${what}) $_settings($what) 1230 set val $_settings($what) 1231 set val [expr {0.01*$val}] 1232 foreach tag [GetDatasetsWithComponent $_current] { 1233 SendCmd "volume shading ambient $val $tag" 1234 } 1235 } 1236 "-axesvisible" { 1237 SendCmd "axis visible $_settings($what)" 1249 1238 } 1250 1239 "-background" { … … 1259 1248 DrawLegend $_current 1260 1249 } 1261 "-ambient" { 1262 # Other parts of the code use the ambient setting to 1263 # tell if the component settings have been initialized 1264 if { ![info exists _settings($_current${what})] } { 1265 InitComponentSettings $_current 1266 } 1267 set _settings($_current${what}) $_settings($what) 1268 set val $_settings($what) 1269 set val [expr {0.01*$val}] 1270 foreach tag [GetDatasetsWithComponent $_current] { 1271 SendCmd "volume shading ambient $val $tag" 1272 } 1250 "-colormap" { 1251 set color [$itk_component(colormap) value] 1252 set _settings($what) $color 1253 set _settings($_current${what}) $color 1254 ResetColormap $_current $color 1255 } 1256 "-current" { 1257 set cname [$itk_component(volcomponents) value] 1258 SwitchComponent $cname 1259 } 1260 "-cutplanesvisible" { 1261 set bool $_settings($what) 1262 set datasets [CurrentDatasets -cutplanes] 1263 set tag [lindex $datasets 0] 1264 SendCmd "cutplane visible $bool $tag" 1273 1265 } 1274 1266 "-diffuse" { … … 1280 1272 } 1281 1273 } 1282 "-specularlevel" { 1283 set _settings($_current${what}) $_settings($what) 1284 set val $_settings($what) 1285 set val [expr {0.01*$val}] 1286 foreach tag [GetDatasetsWithComponent $_current] { 1287 SendCmd "volume shading specularLevel $val $tag" 1288 } 1289 } 1290 "-specularexponent" { 1291 set _settings($_current${what}) $_settings($what) 1292 set val $_settings($what) 1293 foreach tag [GetDatasetsWithComponent $_current] { 1294 SendCmd "volume shading specularExp $val $tag" 1295 } 1296 } 1297 "-light2side" { 1298 set _settings($_current${what}) $_settings($what) 1299 set val $_settings($what) 1300 foreach tag [GetDatasetsWithComponent $_current] { 1301 SendCmd "volume shading light2side $val $tag" 1302 } 1303 } 1304 "-opacity" { 1305 set _settings($_current${what}) $_settings($what) 1306 set val $_settings($what) 1307 set sval [expr { 0.01 * double($val) }] 1308 foreach tag [GetDatasetsWithComponent $_current] { 1309 SendCmd "volume shading opacity $sval $tag" 1310 } 1311 } 1312 "-thickness" { 1313 set val $_settings($what) 1314 set _settings($_current${what}) $val 1315 updateTransferFunctions 1316 } 1317 "-outlinevisible" { 1318 SendCmd "volume outline state $_settings($what)" 1319 } 1320 "-outlinecolor" { 1321 set rgb [Color2RGB $_settings($what)] 1322 SendCmd "volume outline color $rgb" 1274 "-gridvisible" { 1275 SendCmd "grid visible $_settings($what)" 1323 1276 } 1324 1277 "-isosurfaceshading" { 1325 1278 SendCmd "volume shading isosurface $_settings($what)" 1326 }1327 "-colormap" {1328 set color [$itk_component(colormap) value]1329 set _settings($what) $color1330 set _settings($_current${what}) $color1331 ResetColormap $_current $color1332 }1333 "-gridvisible" {1334 SendCmd "grid visible $_settings($what)"1335 }1336 "-axesvisible" {1337 SendCmd "axis visible $_settings($what)"1338 1279 } 1339 1280 "-legendvisible" { … … 1346 1287 blt::table forget $itk_component(legend) 1347 1288 } 1289 } 1290 "-light2side" { 1291 set _settings($_current${what}) $_settings($what) 1292 set val $_settings($what) 1293 foreach tag [GetDatasetsWithComponent $_current] { 1294 SendCmd "volume shading light2side $val $tag" 1295 } 1296 } 1297 "-opacity" { 1298 set _settings($_current${what}) $_settings($what) 1299 set val $_settings($what) 1300 set sval [expr { 0.01 * double($val) }] 1301 foreach tag [GetDatasetsWithComponent $_current] { 1302 SendCmd "volume shading opacity $sval $tag" 1303 } 1304 } 1305 "-outlinevisible" { 1306 SendCmd "volume outline state $_settings($what)" 1307 } 1308 "-outlinecolor" { 1309 set rgb [Color2RGB $_settings($what)] 1310 SendCmd "volume outline color $rgb" 1311 } 1312 "-specularlevel" { 1313 set _settings($_current${what}) $_settings($what) 1314 set val $_settings($what) 1315 set val [expr {0.01*$val}] 1316 foreach tag [GetDatasetsWithComponent $_current] { 1317 SendCmd "volume shading specularLevel $val $tag" 1318 } 1319 } 1320 "-specularexponent" { 1321 set _settings($_current${what}) $_settings($what) 1322 set val $_settings($what) 1323 foreach tag [GetDatasetsWithComponent $_current] { 1324 SendCmd "volume shading specularExp $val $tag" 1325 } 1326 } 1327 "-thickness" { 1328 set val $_settings($what) 1329 set _settings($_current${what}) $val 1330 updateTransferFunctions 1348 1331 } 1349 1332 "-volume" { … … 1367 1350 SendCmd "volume data state $_settings($what) $tag" 1368 1351 } 1369 }1370 "-cutplanesvisible" {1371 set bool $_settings($what)1372 set datasets [CurrentDatasets -cutplanes]1373 set tag [lindex $datasets 0]1374 SendCmd "cutplane visible $bool $tag"1375 1352 } 1376 1353 "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" { -
trunk/gui/scripts/vtkisosurfaceviewer.tcl
r4454 r4509 68 68 protected method DoResize {} 69 69 protected method DoRotate {} 70 protected method DoChangeContourLevels {} 70 71 protected method AdjustSetting {what {value ""}} 71 72 protected method InitSettings { args } … … 90 91 private method EnterLegend { x y } 91 92 private method EventuallyResize { w h } 93 private method EventuallyChangeContourLevels {} 92 94 private method EventuallyRotate { q } 93 95 private method EventuallyRequestLegend {} … … 105 107 private method SetCurrentColormap { color } 106 108 private method SetOrientation { side } 107 private method UpdateContourList {}109 private method GenerateContourList {} 108 110 109 111 private variable _arcball "" … … 137 139 private variable _title "" 138 140 private variable _isolines 139 private variable _contourList "" 141 private variable _contourList 142 private variable _currentLimits "" 143 private variable _widget 140 144 141 145 common _downloadPopup; # download options from popup … … 183 187 $_dispatcher dispatch $this !legend "[itcl::code $this RequestLegend]; list" 184 188 189 # Contour levels event 190 $_dispatcher register !contours 191 $_dispatcher dispatch $this !contours \ 192 "[itcl::code $this DoChangeContourLevels]; list" 193 185 194 # X-Cutplane event 186 195 $_dispatcher register !xcutplane … … 220 229 $_arcball quaternion $q 221 230 231 array set _contourList { 232 numLevels 10 233 reqValues "" 234 updatePending 0 235 values "" 236 } 222 237 array set _settings { 223 238 -axesvisible 1 … … 229 244 -cutplaneedges 0 230 245 -cutplanelighting 1 231 -cutplaneopacity 1 00246 -cutplaneopacity 1.0 232 247 -cutplanepreinterp 1 233 248 -cutplanesvisible 0 … … 237 252 -isosurfaceedges 0 238 253 -isosurfacelighting 1 239 -isosurfaceopacity 60254 -isosurfaceopacity 0.6 240 255 -isosurfacevisible 1 241 256 -isosurfacewireframe 0 … … 256 271 -colormap 0 257 272 -isosurfaceopacity 0 273 -cutplaneopacity 0 258 274 -numcontours 0 275 } 276 array set _widget { 277 -isosurfaceopacity 0 278 -cutplaneopacity 0 259 279 } 260 280 … … 467 487 } 468 488 489 itcl::body Rappture::VtkIsosurfaceViewer::DoChangeContourLevels {} { 490 GenerateContourList 491 SendCmd [list contour3d contourlist $_contourList(values)] 492 SendCmd [list camera reset] 493 DrawLegend 494 set _contourList(updatePending) 0 495 } 496 469 497 itcl::body Rappture::VtkIsosurfaceViewer::DoRotate {} { 470 498 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] … … 505 533 set _cutplanePending 1 506 534 $_dispatcher event -after 100 !${axis}cutplane 535 } 536 } 537 538 itcl::body Rappture::VtkIsosurfaceViewer::EventuallyChangeContourLevels {} { 539 set n $_contourList(numLevels) 540 set _contourList(values) "" 541 if { !$_contourList(updatePending) } { 542 set _contourList(updatePending) 1 543 global rotate_delay 544 $_dispatcher event -after $rotate_delay !contours 507 545 } 508 546 } … … 939 977 # generates a new call to Rebuild). 940 978 StartBufferingCommands 941 942 979 if { $_reset } { 943 980 set _width $w … … 960 997 InitSettings -xgrid -ygrid -zgrid -axismode \ 961 998 -axesvisible -axislabelsvisible 962 foreach axis { x y z } {963 SendCmd "axis lformat $axis %g" 964 } 999 SendCmd "axis lformat all %g" 1000 # Too many major ticks, so turn off minor ticks 1001 SendCmd "axis minticks all 0" 965 1002 StopBufferingCommands 966 1003 SendCmd "imgflush" … … 1035 1072 } 1036 1073 $itk_component(field) value $_curFldLabel 1074 1075 if { ![info exists _limits($_curFldName)] } { 1076 SendCmd "dataset maprange all" 1077 } else { 1078 set limits $_limits($_curFldName) 1079 SendCmd "dataset maprange explicit $limits $_curFldName" 1080 if { $limits != $_currentLimits } { 1081 set _currentLimits $limits 1082 EventuallyChangeContourLevels 1083 } 1084 } 1037 1085 } 1038 1086 InitSettings -cutplanesvisible -isosurfacevisible -outline … … 1059 1107 set label [string toupper $axis] 1060 1108 } 1061 # May be a space in the axis label.1062 1109 SendCmd [list axis name $axis $label] 1063 1110 } … … 1348 1395 "-cutplanesvisible" { 1349 1396 set bool $_settings($what) 1350 1397 SendCmd "cutplane visible 0" 1351 1398 if { $bool } { 1352 1399 foreach tag [CurrentDatasets -visible] { … … 1371 1418 } 1372 1419 "-cutplaneopacity" { 1373 set val $_settings($what) 1374 set sval [expr { 0.01 * double($val) }] 1375 SendCmd "cutplane opacity $sval" 1420 set _settings($what) [$_widget(-cutplaneopacity) * 0.01] 1421 SendCmd "cutplane opacity $_settings($what)" 1376 1422 } 1377 1423 "-cutplanepreinterp" { … … 1419 1465 "-numcontours" { 1420 1466 set _settings($what) [$itk_component(numcontours) value] 1421 set _currentNumContours $_settings($what) 1422 UpdateContourList 1423 set _changed($what) 1 1424 SendCmd "contour3d contourlist [list $_contourList]" 1425 DrawLegend 1467 if { $_contourList(numLevels) != $_settings($what) } { 1468 set _contourList(numLevels) $_settings($what) 1469 EventuallyChangeContourLevels 1470 } 1426 1471 } 1427 1472 "-isosurfacewireframe" { … … 1468 1513 } 1469 1514 "-isosurfaceopacity" { 1470 set val $_settings($what) 1471 set sval [expr { 0.01 * double($val) }] 1472 SendCmd "contour3d opacity $sval" 1515 set _settings($what) [$_widget(-isosurfaceopacity) * 0.01] 1516 SendCmd "contour3d opacity $_settings($what)" 1473 1517 } 1474 1518 "-field" { … … 1674 1718 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1675 1719 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1676 -variable [itcl::scope _ settings(-isosurfaceopacity)] \1720 -variable [itcl::scope _widget(-isosurfaceopacity)] \ 1677 1721 -width 10 \ 1678 1722 -showvalue off \ 1679 1723 -command [itcl::code $this AdjustSetting -isosurfaceopacity] 1724 $inner.opacity set [expr $_settings(-isosurfaceeopacity) * 100.0] 1680 1725 1681 1726 itk_component add field_l { … … 1887 1932 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1888 1933 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1889 -variable [itcl::scope _ settings(-cutplaneopacity)] \1934 -variable [itcl::scope _widget(-cutplaneopacity)] \ 1890 1935 -width 10 \ 1891 1936 -showvalue off \ 1892 1937 -command [itcl::code $this AdjustSetting -cutplaneopacity] 1893 $inner.opacity set $_settings(-cutplaneopacity)1938 $inner.opacity set [expr $_settings(-cutplaneopacity) * 100.0] 1894 1939 1895 1940 # X-value slicer... … … 2110 2155 set tag $dataobj-$comp 2111 2156 array set style { 2112 -color BCGYR2113 -cutplanesvisible 02114 -edgecolor black2115 -edges 02116 -isosurface visible 12117 - levels 102118 -l ighting 12119 -li newidth 1.02120 - opacity 0.62121 -outline 02122 -wireframe 02123 -xcutplaneposition 502124 -xcutplanevisible 12125 -ycutplaneposition 502126 -ycutplanevisible 12127 -zcutplaneposition 502128 -zcutplanevisible 12157 -color BCGYR 2158 -cutplanesvisible 0 2159 -edgecolor black 2160 -edges 0 2161 -isosurfaceopacity 0.6 2162 -isosurfacevisible 1 2163 -levels 10 2164 -lighting 1 2165 -linewidth 1.0 2166 -outline 0 2167 -wireframe 0 2168 -xcutplaneposition 50 2169 -xcutplanevisible 1 2170 -ycutplaneposition 50 2171 -ycutplanevisible 1 2172 -zcutplaneposition 50 2173 -zcutplanevisible 1 2129 2174 } 2130 2175 array set style [$dataobj style $comp] 2131 2176 if { $dataobj != $_first || $style(-levels) == 1 } { 2132 set style(- opacity) 12177 set style(-isosurfaceopacity) 1.0 2133 2178 } 2134 2179 … … 2143 2188 2144 2189 if { $_changed(-isosurfaceopacity) } { 2145 set style(- opacity) [expr $_settings(-isosurfaceopacity) * 0.01]2190 set style(-isosurfaceopacity) $_settings(-isosurfaceopacity) 2146 2191 } 2147 2192 if { $_changed(-numcontours) } { … … 2155 2200 $itk_component(colormap) value $style(-color) 2156 2201 } 2157 if { $_currentNumContours != $style(-levels) } { 2158 set _currentNumContours $style(-levels) 2159 set _settings(-numcontours) $_currentNumContours 2160 $itk_component(numcontours) value $_currentNumContours 2161 UpdateContourList 2162 DrawLegend 2202 if { $_contourList(numLevels) != $style(-levels) } { 2203 if { [llength $style(-levels)] > 1 } { 2204 set _contourList(reqValues) [lsort -real $style(-levels)] 2205 } else { 2206 set _settings(-numcontours) $style(-levels) 2207 $itk_component(numcontours) value $style(-levels) 2208 set _contourList(numLevels) $style(-levels) 2209 } 2210 EventuallyChangeContourLevels 2163 2211 } 2164 2212 set _settings(-isosurfacevisible) $style(-isosurfacevisible) … … 2170 2218 set _settings(-ycutplaneposition) $style(-ycutplaneposition) 2171 2219 set _settings(-zcutplaneposition) $style(-zcutplaneposition) 2172 2220 2173 2221 SendCmd "cutplane add $tag" 2174 2222 SendCmd "cutplane visible $style(-cutplanesvisible) $tag" … … 2179 2227 set _settings(-outline) $style(-outline) 2180 2228 2181 SendCmd [list contour3d add contourlist $_contourList $tag] 2229 GenerateContourList 2230 SendCmd [list contour3d add contourlist $_contourList(values) $tag] 2182 2231 SendCmd "contour3d visible $style(-isosurfacevisible) $tag" 2183 2232 SendCmd "contour3d edges $style(-edges) $tag" … … 2188 2237 SendCmd "contour3d linecolor [Color2RGB $style(-edgecolor)] $tag" 2189 2238 SendCmd "contour3d linewidth $style(-linewidth) $tag" 2190 SendCmd "contour3d opacity $style(- opacity) $tag"2191 set _settings(-isosurfaceopacity) [expr $style(-opacity) * 100.0]2239 SendCmd "contour3d opacity $style(-isosurfaceopacity) $tag" 2240 set _settings(-isosurfaceopacity) $style(-isosurfaceopacity) 2192 2241 SetCurrentColormap $style(-color) 2193 2242 SendCmd "contour3d wireframe $style(-wireframe) $tag" … … 2426 2475 incr offset $lineht 2427 2476 } 2428 foreach value $_contourList {2477 foreach value $_contourList(values) { 2429 2478 set norm [expr 1.0 - (($value - $vmin) / $range)] 2430 2479 set y1 [expr int(round(($norm * $ih) + $offset))] … … 2551 2600 } 2552 2601 2553 itcl::body Rappture::VtkIsosurfaceViewer:: UpdateContourList {} {2602 itcl::body Rappture::VtkIsosurfaceViewer::GenerateContourList {} { 2554 2603 if { ![info exists _limits($_curFldName)] } { 2555 return 2556 } 2557 if { $_currentNumContours < 1 } { 2558 set _contourList "" 2559 return 2560 } 2561 foreach { vmin vmax } $_limits($_curFldName) break 2562 set v [blt::vector create \#auto] 2563 $v seq $vmin $vmax [expr $_currentNumContours+2] 2564 $v delete end 0 2565 set _contourList [$v range 0 end] 2566 blt::vector destroy $v 2567 } 2568 2604 puts stderr "no _curFldName" 2605 return "" 2606 } 2607 if { $_contourList(numLevels) < 1 } { 2608 puts stderr "numLevels < 1" 2609 return "" 2610 } 2611 if { [llength $_contourList(reqValues)] > 1 } { 2612 set values $_contourList(reqValues) 2613 } else { 2614 foreach { vmin vmax } $_limits($_curFldName) break 2615 set v [blt::vector create \#auto] 2616 $v seq $vmin $vmax [expr $_contourList(numLevels)+2] 2617 $v delete end 0 2618 set values [$v range 0 end] 2619 blt::vector destroy $v 2620 } 2621 set _contourList(values) $values 2622 }
Note: See TracChangeset
for help on using the changeset viewer.