Changeset 4919
- Timestamp:
- Jan 4, 2015 6:52:23 PM (9 years ago)
- Location:
- branches/r9
- Files:
-
- 41 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/r9/apps/Makefile.in
r4914 r4919 26 26 $(srcdir)/execute.tcl \ 27 27 $(srcdir)/launcher.tcl \ 28 $(srcdir)/mapviewer-test \29 28 $(srcdir)/grabdata \ 30 29 $(srcdir)/nanovis-test \ -
branches/r9/apps/launcher.tcl
r4127 r4919 12 12 # rappture -builder ?-tool <toolfile>? 13 13 # rappture -tester ?-tool <toolfile>? ?-testdir <directory>? 14 # rappture -execute driver.xml ?-tool <toolfile>? 14 15 # 15 16 # The default option is "-run", which brings up the GUI used to … … 53 54 set reqpkgs Tk 54 55 } 56 -execute { 57 # for web services and simulation cache -- don't load Tk 58 set reqpkgs "" 59 if {[llength $argv] < 1} { 60 puts stderr "error: missing driver.xml file for -execute option" 61 exit 1 62 } 63 set driverxml [lindex $argv 0] 64 set argv [lrange $argv 1 end] 65 66 if {![file readable $driverxml]} { 67 puts stderr "error: driver file \"$driverxml\" not found" 68 exit 1 69 } 70 71 set dir [file dirname [info script]] 72 set mainscript [file join $dir execute.tcl] 73 } 55 74 -tool { 56 75 set toolxml [lindex $argv 0] … … 89 108 puts stderr " rappture -builder ?-tool toolFile?" 90 109 puts stderr " rappture -tester ?-auto? ?-tool toolFile? ?-testdir directory?" 110 puts stderr " rappture -execute driver.xml ?-tool toolFile?" 91 111 exit 1 92 112 } -
branches/r9/apps/rappture.use.in
r4118 r4919 33 33 prepend TK_LIBRARY ${libdir}/tk${tcl_version} 34 34 35 prepend CLASSPATH ${libdir}/java 36 35 37 prepend R_LIBS ${libdir}/R 36 38 -
branches/r9/apps/rpdiff
r3177 r4919 490 490 } 491 491 } 492 loader { 493 } 492 494 default { 493 error "don't know how to compare type \"$type\""495 puts stderr "ignoring \"$type1\" for \"$path\"" 494 496 } 495 497 } … … 557 559 558 560 # ====================================================================== 559 if {$argc != 2} { 561 562 if {$argc < 2} { 560 563 puts stderr "USAGE: rpdiff file1.xml file2.xml" 561 564 exit 9 … … 563 566 set lib1 [Rappture::library [lindex $argv 0]] 564 567 set lib2 [Rappture::library [lindex $argv 1]] 568 set path "output" 569 if { $argc > 2 } { 570 set arg [lindex $argv 2] 571 if { $arg == "-path" && $argc == 4 } { 572 set path [lindex $argv 3] 573 } 574 } 565 575 566 576 # compute the differences 567 set diffs [diff output$lib1 $lib2]577 set diffs [diff $path $lib1 $lib2] 568 578 569 579 if {[llength $diffs] == 0} { -
branches/r9/gui/scripts/analyzer.tcl
r4261 r4919 800 800 _autoLabel $xmlobj output.$item "Integer" counters 801 801 } 802 mesh* { 803 _autoLabel $xmlobj output.$item "Mesh" counters 804 } 802 805 string* { 803 806 _autoLabel $xmlobj output.$item "String" counters -
branches/r9/gui/scripts/balloon.tcl
r3555 r4919 232 232 # grab the mouse pointer 233 233 update 234 while {[catch {grab set -local$itk_component(hull)}]} {234 while {[catch {grab set $itk_component(hull)}]} { 235 235 after 100 236 236 } … … 249 249 250 250 grab release $itk_component(hull) 251 252 251 wm withdraw $itk_component(hull) 253 252 foreach dir {left right above below} { -
branches/r9/gui/scripts/bugreport.tcl
r4003 r4919 87 87 set h [winfo reqheight .bugreport] 88 88 89 set rootx [winfo rootx .main] 90 set rooty [winfo rooty .main] 91 set mw [winfo reqwidth .main] 92 set mh [winfo reqheight .main] 93 94 set x [expr { $rootx + (($mw-$w)/2) }] 95 if {$x < 0} {set x 0} 96 set y [expr { $rooty + (($mh-$h)/2) }] 97 if {$y < 0} {set y 0} 98 89 set x [winfo rootx .main] 90 set y [winfo rooty .main] 91 92 set mw [winfo width .main] 93 if { $mw == 1 } { 94 set mw [winfo reqwidth .main] 95 } 96 set mh [winfo height .main] 97 if { $mh == 1 } { 98 set mh [winfo reqwidth .main] 99 } 100 if { $mw > $w } { 101 set x [expr { $x + (($mw-$w)/2) }] 102 } 103 if { $mh > $h } { 104 set y [expr { $y + (($mh-$h)/2) }] 105 } 99 106 wm geometry .bugreport +$x+$y 100 107 raise .bugreport … … 151 158 set h [winfo reqheight .bugreport] 152 159 153 set rootx [winfo rootx .main] 154 set rooty [winfo rooty .main] 155 set mw [winfo reqwidth .main] 156 set mh [winfo reqheight .main] 157 158 set x [expr { $rootx + (($mw-$w)/2) }] 159 if {$x < 0} {set x 0} 160 set y [expr { $rooty + (($mh-$h)/2) }] 161 if {$y < 0} {set y 0} 160 set x [winfo rootx .main] 161 set y [winfo rooty .main] 162 163 set mw [winfo width .main] 164 if { $mw == 1 } { 165 set mw [winfo reqwidth .main] 166 } 167 set mh [winfo height .main] 168 if { $mh == 1 } { 169 set mh [winfo reqwidth .main] 170 } 171 172 if { $mw > $w } { 173 set x [expr { $x + (($mw-$w)/2) }] 174 } 175 if { $mh > $h } { 176 set y [expr { $y + (($mh-$h)/2) }] 177 } 162 178 163 179 wm geometry .bugreport +$x+$y … … 165 181 raise .bugreport 166 182 167 catch {grab -localset .bugreport}183 catch {grab set .bugreport} 168 184 update 169 185 } … … 474 490 package require http 475 491 package require tls 476 http::register https 443 ::tls::socket492 http::register https 443 [list ::tls::socket -tls1 1] 477 493 478 494 set report $details(stackTrace) -
branches/r9/gui/scripts/cloud.tcl
r4133 r4919 128 128 foreach label [$_cloud get labels] axis { x y z } { 129 129 if { $label != "" } { 130 set _axis2label s($axis) $label130 set _axis2label($axis) $label 131 131 } else { 132 set _axis2label s($axis) [string toupper $axis]132 set _axis2label($axis) [string toupper $axis] 133 133 } 134 134 } … … 149 149 foreach {x y z} $line break 150 150 foreach axis {x y z} units $_units { 151 set value [Rappture::Units::convert [set $axis] \ 151 if { $units == "" } { 152 set value [set $axis] 153 } else { 154 set value [Rappture::Units::convert [set $axis] \ 152 155 -context $units -to $units -units off] 156 } 153 157 set $axis $value; # Set the (x/y/z) coordinate to 154 158 # converted value. … … 266 270 # 267 271 itcl::body Rappture::Cloud::label { axis } { 268 if { ![info exists axis2label($axis)] } {272 if { ![info exists _axis2label($axis)] } { 269 273 return "" 270 274 } 271 return $ axis2label($axis)275 return $_axis2label($axis) 272 276 } 273 277 -
branches/r9/gui/scripts/curve.tcl
r4042 r4919 112 112 # USAGE: values ?<name>? 113 113 # 114 # Returns the xvec for the specified curve component <name>.114 # Returns the yvec for the specified curve component <name>. 115 115 # If the name is not specified, then it returns the vectors for the 116 116 # overall curve (sum of all components). -
branches/r9/gui/scripts/drawing.tcl
r4002 r4919 1 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 3 # ---------------------------------------------------------------------- 4 # COMPONENT: drawing - 2D drawing of data 2 # ---------------------------------------------------------------------- 3 # COMPONENT: drawing - 3D drawing of data 5 4 # ====================================================================== 6 5 # AUTHOR: Michael McLennan, Purdue University … … 20 19 private variable _drawing 21 20 private variable _xmlobj 22 private variable _actors23 21 private variable _styles 24 22 private variable _shapes … … 28 26 private variable _hints 29 27 private variable _units 30 private variable _limits31 28 32 29 constructor {xmlobj path} { … … 36 33 # defined below 37 34 } 38 public method limits {axis} 35 39 36 public method label { elem } 40 37 public method type { elem } … … 63 60 set xunits "um" 64 61 } 65 array set _limits {66 xMin 067 xMax 068 yMin 069 yMax 070 zMin 071 zMax 072 }73 62 # determine the overall size of the device 74 63 foreach elem [$_xmlobj children $path] { 75 64 switch -glob -- $elem { 76 polygon* { 77 set _data($elem) [$_xmlobj get $path.$elem.vtk] 78 set _data($elem) [string trim $_data($elem)] 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 polydata* { 65 # polygon is deprecated in favor of polydata 66 polygon* - polydata* { 84 67 set _data($elem) [$_xmlobj get $path.$elem.vtk] 85 68 set _data($elem) [string trim $_data($elem)] … … 87 70 set _labels($elem) [$_xmlobj get $path.$elem.about.label] 88 71 set _types($elem) polydata 89 }90 streamlines* {91 set _data($elem) [$_xmlobj get $path.$elem.vtk]92 set _data($elem) [string trim $_data($elem)]93 set _styles($elem) [$_xmlobj get $path.$elem.about.style]94 set _labels($elem) [$_xmlobj get $path.$elem.about.label]95 set _types($elem) streamlines96 72 } 97 73 glyphs* { … … 250 226 251 227 # ---------------------------------------------------------------------- 252 # method limits <axis>253 # Returns a list {min max} representing the limits for the254 # specified axis.255 # ----------------------------------------------------------------------256 itcl::body Rappture::Drawing::limits {which} {257 set min ""258 set max ""259 foreach key [array names _data] {260 set actor $_actors($key)261 foreach key { xMin xMax yMin yMax zMin zMax} value [$actor GetBounds] {262 set _limits($key) $value263 }264 break265 }266 267 foreach key [array names _actors] {268 set actor $_actors($key)269 foreach { xMin xMax yMin yMax zMin zMax} [$actor GetBounds] break270 if { $xMin < $_limits(xMin) } {271 set _limits(xMin) $xMin272 }273 if { $xMax > $_limits(xMax) } {274 set _limits(xMax) $xMax275 }276 if { $yMin < $_limits(yMin) } {277 set _limits(yMin) $yMin278 }279 if { $yMax > $_limits(yMax) } {280 set _limits(yMax) $yMax281 }282 if { $zMin < $_limits(zMin) } {283 set _limits(zMin) $zMin284 }285 if { $zMax > $_limits(zMax) } {286 set _limits(zMax) $zMax287 }288 }289 switch -- $which {290 x {291 set min $_limits(xMin)292 set max $_limits(xMax)293 set axis "xaxis"294 }295 y {296 set min $_limits(yMin)297 set max $_limits(yMax)298 set axis "yaxis"299 }300 v - z {301 set min $_limits(zMin)302 set max $_limits(zMax)303 set axis "zaxis"304 }305 default {306 error "unknown axis description \"$which\""307 }308 }309 return [list $min $max]310 }311 312 # ----------------------------------------------------------------------313 228 # USAGE: hints ?<keyword>? 314 229 # … … 340 255 return [array get _hints] 341 256 } 342 -
branches/r9/gui/scripts/drawingentry.tcl
r4176 r4919 146 146 } 147 147 if {$name eq ""} { 148 puts stderr "no name defined for substitu ion variable \"$cpath\""148 puts stderr "no name defined for substitution variable \"$cpath\"" 149 149 continue 150 150 } … … 672 672 itcl::body Rappture::DrawingEntry::ParsePolygon { cpath cname } { 673 673 array set attr2option { 674 "outline" "-outline" 675 "color" "-fill" 676 "fill" "-fill" 674 677 "linewidth" "-width" 675 "color" "-fill"676 678 } 677 679 # Set default options first and then let tool.xml override them. -
branches/r9/gui/scripts/field.tcl
r4251 r4919 1 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 3 2 # ---------------------------------------------------------------------- 4 3 # COMPONENT: field - extracts data from an XML description of a field … … 82 81 # valid data. 83 82 private variable _isValidComponent; # Array of valid components found 83 private variable _alwaysConvertDX 0; 84 84 85 constructor {xmlobj path} { 85 86 # defined below … … 152 153 private method AvsToVtk { cname contents } 153 154 private method DicomToVtk { cname contents } 154 private method DicomToVtk.old { cname contents }155 155 private method BuildPointsOnMesh { cname } 156 156 protected method GetAssociation { cname } … … 321 321 } 322 322 if {[info exists _comp2dx($cname)]} { 323 return "" ;# no mesh -- it's embedded in the valuedata323 return "" ;# no mesh -- it's embedded in the blob data 324 324 } 325 325 if {[info exists _comp2mesh($cname)]} { … … 365 365 } 366 366 if {[info exists _comp2dx($cname)]} { 367 error "method \"values\" is not implemented for dx data"367 error "method \"values\" is not implemented for dx file data" 368 368 } 369 369 if {[info exists _comp2unirect2d($cname)]} { 370 return [$_comp2unirect2d($cname) values]370 return $_values 371 371 } 372 372 if {[info exists _comp2unirect3d($cname)]} { … … 392 392 } 393 393 if {[info exists _comp2dx($cname)]} { 394 return $_comp2dx($cname) 394 return $_comp2dx($cname) ;# return gzipped, base64-encoded DX data 395 395 } 396 396 if {[info exists _comp2unirect2d($cname)]} { … … 405 405 } 406 406 407 # ---------------------------------------------------------------------- 408 # USAGE: valueLimits <cname> 409 # 410 # Returns an array for the requested component with a list {min max} 411 # representing the limits for each axis. 412 # ---------------------------------------------------------------------- 407 413 itcl::body Rappture::Field::valueLimits { cname } { 408 414 if { [info exists _comp2limits($cname)] } { … … 421 427 set min "" 422 428 set max "" 423 blt::vector tmp zero424 429 425 430 foreach cname [array names _comp2dims] { … … 447 452 448 453 if {$log} { 449 # on a log scale, use abs value and ignore 0's 454 blt::vector tmp zero 455 # on a log scale, use abs value and ignore zeros 450 456 $vname dup tmp 451 457 $vname dup zero 452 zero expr {tmp == 0} ;# find the 0's458 zero expr {tmp == 0} ;# find the zeros 453 459 tmp expr {abs(tmp)} ;# get the abs value 454 tmp expr {tmp + zero*max(tmp)} ;# replace 0 's with abs max460 tmp expr {tmp + zero*max(tmp)} ;# replace 0s with abs max 455 461 set axisMin [blt::vector expr min(tmp)] 456 462 set axisMax [blt::vector expr max(tmp)] 463 blt::vector destroy tmp zero 457 464 } else { 458 465 set axisMin [$vname min] … … 471 478 } 472 479 } 473 2D - 3D{480 default { 474 481 if {[info exists _comp2limits($cname)]} { 475 482 array set limits $_comp2limits($cname) … … 513 520 } 514 521 } 515 blt::vector destroy tmp zero516 522 set val [$_field get "${axis}axis.min"] 517 523 if {"" != $val && "" != $min} { … … 531 537 } 532 538 533 534 539 # ---------------------------------------------------------------------- 535 540 # USAGE: fieldlimits … … 541 546 foreach cname [array names _comp2limits] { 542 547 array set limits $_comp2limits($cname) 543 foreach fname $_comp2fldName($cname){548 foreach fname [fieldnames $cname] { 544 549 if { ![info exists limits($fname)] } { 545 550 puts stderr "ERROR: field \"$fname\" unknown in \"$cname\"" … … 805 810 set _comp2style($cname) "" 806 811 if { $type == "" } { 807 puts stderr "WARNING: ignoring field component \"$_path.$cname\": no data found."812 puts stderr "WARNING: Ignoring field component \"$_path.$cname\": no data found." 808 813 continue 809 814 } … … 881 886 set contents [$_field get $cname.vtk] 882 887 if { $contents == "" } { 883 puts stderr "WARNING: no data fo\"$_path.$cname.vtk\""888 puts stderr "WARNING: No data for \"$_path.$cname.vtk\"" 884 889 continue; # Ignore this component 885 890 } … … 899 904 } 900 905 if { $_viewer == "" } { 901 set _viewer "nanovis" 906 if {[$_field element $cname.flow] != ""} { 907 set _viewer "flowvis" 908 } else { 909 set _viewer "nanovis" 910 } 902 911 } 903 912 set _dim 3 … … 906 915 set contents [Rappture::encoding::decode -as zb64 $data] 907 916 if { $contents == "" } { 908 puts stderr "WARNING: no data for \"$_path.$cname.$type\""917 puts stderr "WARNING: No data for \"$_path.$cname.$type\"" 909 918 continue; # Ignore this component 910 919 } 911 set vector ""912 920 if 0 { 913 921 set f [open /tmp/$_path.$cname.dx "w"] … … 915 923 close $f 916 924 } 917 # This is temporary. I put a check for this in the DxToVtk918 # parser.919 if { [string range $contents 0 3] == "<DX>" } {920 set contents [string range $contents 4 end]921 }922 925 if { [catch { Rappture::DxToVtk $contents } vtkdata] == 0 } { 923 926 ReadVtkDataSet $cname $vtkdata 927 if 0 { 928 set f [open /tmp/$_path.$cname.vtk "w"] 929 puts -nonewline $f $vtkdata 930 close $f 931 } 924 932 } else { 925 933 puts stderr "Can't parse dx data: $vtkdata" 926 934 } 927 if 0 { 928 set f [open /tmp/$_path.$cname.vtk "w"] 929 puts -nonewline $f $vtkdata 930 close $f 931 } 932 if { $_viewer != "nanovis" && $_viewer != "flowvis" } { 935 if { $_alwaysConvertDX || 936 ($_viewer != "nanovis" && $_viewer != "flowvis") } { 933 937 set _type "vtk" 934 938 set _comp2vtk($cname) $vtkdata … … 942 946 [Rappture::FlowHints ::\#auto $_field $cname $_units] 943 947 } 944 set _dim 3945 948 incr _counter 946 949 } elseif { $type == "dicom"} { … … 975 978 } 976 979 if { [array size _isValidComponent] == 0 } { 977 puts stderr " WARNING: no valid components for field \"$_path\""980 puts stderr "ERROR: All components of field \"$_path\" are invalid." 978 981 return 0 979 982 } … … 987 990 } 988 991 if { $dim != $_comp2dims($cname) } { 989 puts stderr "WARNING: field can't have components of different dimensions: [join [array get _comp2dims] ,]"992 puts stderr "WARNING: A field can't have components of different dimensions: [join [array get _comp2dims] ,]" 990 993 return 0 991 994 } … … 1184 1187 set dataAttrs [$dataset GetPointData] 1185 1188 if { $dataAttrs == ""} { 1186 puts stderr "WARNING: no point data found in \"$_path\""1189 puts stderr "WARNING: No point data found in \"$_path\"" 1187 1190 rename $reader "" 1188 1191 return 0 … … 1247 1250 set dataAttrs [$dataset GetPointData] 1248 1251 if { $dataAttrs == ""} { 1249 puts stderr "WARNING: no point data found in \"$_path\""1252 puts stderr "WARNING: No point data found in \"$_path\"" 1250 1253 rename $reader "" 1251 1254 return 0 … … 1253 1256 set array [$dataAttrs GetScalars] 1254 1257 if { $array == ""} { 1255 puts stderr "WARNING: no scalar point data found in \"$_path\""1258 puts stderr "WARNING: No scalar point data found in \"$_path\"" 1256 1259 rename $reader "" 1257 1260 return 0 … … 1269 1272 set dataAttrs [$dataset GetPointData] 1270 1273 if { $dataAttrs == ""} { 1271 puts stderr "WARNING: no point data found in \"$_path\""1274 puts stderr "WARNING: No point data found in \"$_path\"" 1272 1275 rename $reader "" 1273 1276 return 0 … … 1509 1512 set dim 0 1510 1513 foreach axis {x y z} { 1511 foreach {min max} [$mesh limits $axis] { 1514 foreach {min max} [$mesh limits $axis] { 1512 1515 if { $min < $max } { 1513 1516 incr dim … … 1540 1543 # sort x-coords in increasing order 1541 1544 $xv sort $yv 1542 1543 1545 set _comp2dims($cname) "1D" 1544 1546 set _comp2xy($cname) [list $xv $yv] … … 1556 1558 set _viewer "contour" 1557 1559 } 1560 set numFieldValues [$v length] 1561 set numComponentsPerTuple [numComponents $cname] 1562 if { [expr $numFieldValues % $numComponentsPerTuple] != 0 } { 1563 puts stderr "ERROR: Number of field values ($numFieldValues) not divisble by elemsize ($numComponentsPerTuple)" 1564 return 0 1565 } 1566 set numFieldTuples [expr $numFieldValues / $numComponentsPerTuple] 1567 if { $_comp2assoc($cname) == "pointdata" } { 1568 set numPoints [$mesh numpoints] 1569 if { $numPoints != $numFieldTuples } { 1570 puts stderr "ERROR: Number of points in mesh ($numPoints) and number of field tuples ($numFieldTuples) don't agree" 1571 return 0 1572 } 1573 } elseif { $_comp2assoc($cname) == "celldata" } { 1574 set numCells [$mesh numcells] 1575 if { $numCells != $numFieldTuples } { 1576 puts stderr "ERROR: Number of cells in mesh ($numCells) and number of field tuples ($numFieldTuples) don't agree" 1577 return 0 1578 } 1579 } 1558 1580 set _comp2dims($cname) "[$mesh dimensions]D" 1559 1581 set _comp2mesh($cname) [list $mesh $v] … … 1583 1605 return 0 1584 1606 } 1607 set numFieldValues [$v length] 1608 set numComponentsPerTuple [numComponents $cname] 1609 if { [expr $numFieldValues % $numComponentsPerTuple] != 0 } { 1610 puts stderr "ERROR: Number of field values ($numFieldValues) not divisble by elemsize ($numComponentsPerTuple)" 1611 return 0 1612 } 1613 set numFieldTuples [expr $numFieldValues / $numComponentsPerTuple] 1614 if { $_comp2assoc($cname) == "pointdata" } { 1615 set numPoints [$mesh numpoints] 1616 if { $numPoints != $numFieldTuples } { 1617 puts stderr "ERROR: Number of points in mesh ($numPoints) and number of field tuples ($numFieldTuples) don't agree" 1618 return 0 1619 } 1620 } elseif { $_comp2assoc($cname) == "celldata" } { 1621 set numCells [$mesh numcells] 1622 if { $numCells != $numFieldTuples } { 1623 puts stderr "ERROR: Number of cells in mesh ($numCells) and number of field tuples ($numFieldTuples) don't agree" 1624 return 0 1625 } 1626 } 1585 1627 set _comp2dims($cname) "[$mesh dimensions]D" 1586 1628 set _comp2mesh($cname) [list $mesh $v] … … 1659 1701 } 1660 1702 1661 foreach key [array names data] { 1662 if {$key == "vtkdata"} { 1663 if {1} { 1664 set f [open /tmp/$cname.vtk "w"] 1665 fconfigure $f -translation binary -encoding binary 1666 puts -nonewline $f $data(vtkdata) 1667 close $f 1668 } 1669 } else { 1670 puts stderr "$key = \"$data($key)\"" 1703 if 0 { 1704 foreach key [array names data] { 1705 if {$key == "vtkdata"} { 1706 if 0 { 1707 set f [open /tmp/$cname.vtk "w"] 1708 fconfigure $f -translation binary -encoding binary 1709 puts -nonewline $f $data(vtkdata) 1710 close $f 1711 } 1712 } else { 1713 puts stderr "$key = \"$data($key)\"" 1714 } 1671 1715 } 1672 1716 } … … 1678 1722 set _viewer $viewer 1679 1723 return $data(vtkdata) 1680 }1681 1682 itcl::body Rappture::Field::DicomToVtk.old { cname path } {1683 package require vtk1684 1685 if { ![file exists $path] } {1686 puts stderr "path \"$path\" doesn't exist."1687 return 01688 }1689 set reader $this-datasetreader1690 vtkDICOMImageReader $reader1691 if { [file isdir $path] } {1692 set files [glob -nocomplain $path/*.dcm]1693 if { [llength $files] == 0 } {1694 puts stderr "no dicom files found in \"$path\""1695 #return 01696 }1697 $reader SetDirectoryName $path1698 } else {1699 $reader SetFileName $path1700 }1701 $reader Update1702 1703 set dataset [$reader GetOutput]1704 set limits {}1705 foreach {xmin xmax ymin ymax zmin zmax} [$dataset GetBounds] break1706 set _dim 01707 if { $xmax > $xmin } {1708 incr _dim1709 }1710 if { $ymax > $ymin } {1711 incr _dim1712 }1713 if { $zmax > $zmin } {1714 incr _dim1715 }1716 1717 set _comp2dims($cname) "${_dim}D"1718 1719 lappend limits x [list $xmin $xmax]1720 lappend limits y [list $ymin $ymax]1721 lappend limits z [list $zmin $zmax]1722 set dataAttrs [$dataset GetPointData]1723 if { $dataAttrs == ""} {1724 puts stderr "WARNING: no point data found in \"$_path\""1725 rename $reader ""1726 return 01727 }1728 set vmin 01729 set vmax 11730 set numArrays [$dataAttrs GetNumberOfArrays]1731 if { $numArrays > 0 } {1732 for {set i 0} {$i < [$dataAttrs GetNumberOfArrays] } {incr i} {1733 set array [$dataAttrs GetArray $i]1734 set fname [$dataAttrs GetArrayName $i]1735 foreach {min max} [$array GetRange -1] break1736 if {$i == 0} {1737 set vmin $min1738 set vmax $max1739 }1740 lappend limits $fname [list $min $max]1741 set _fld2Units($fname) ""1742 set _fld2Label($fname) $fname1743 # Let the VTK file override the <type> designated.1744 set _fld2Components($fname) [$array GetNumberOfComponents]1745 lappend _comp2fldName($cname) $fname1746 }1747 }1748 lappend limits v [list $vmin $vmax]1749 set _comp2limits($cname) $limits1750 1751 set tmpfile $this-$cname.vtk1752 set writer $this-datasetwriter1753 vtkDataSetWriter $writer1754 $writer SetInputConnection [$reader GetOutputPort]1755 $writer SetFileName $tmpfile1756 $writer SetFileTypeToBinary1757 $writer Write1758 rename $reader ""1759 rename $writer ""1760 1761 set f [open "$tmpfile" "r"]1762 fconfigure $f -translation binary -encoding binary1763 set vtkdata [read $f]1764 close $f1765 file delete $tmpfile1766 return $vtkdata1767 1724 } 1768 1725 -
branches/r9/gui/scripts/fieldresult.tcl
r4344 r4919 156 156 # ---------------------------------------------------------------------- 157 157 itcl::body Rappture::FieldResult::add {dataobj {settings ""}} { 158 if { ![info exists itk_component(renderer)] } { 159 puts stderr "add: no renderer created." 160 return 161 } 158 162 eval $itk_component(renderer) add $dataobj [list $settings] 159 163 } … … 166 170 # ---------------------------------------------------------------------- 167 171 itcl::body Rappture::FieldResult::get {} { 172 if { ![info exists itk_component(renderer)] } { 173 puts stderr "get: no renderer created." 174 return 175 } 168 176 return [$itk_component(renderer) get] 169 177 } … … 191 199 # ---------------------------------------------------------------------- 192 200 itcl::body Rappture::FieldResult::scale {args} { 201 if { ![info exists itk_component(renderer)] } { 202 puts stderr "scale: no renderer created." 203 return 204 } 193 205 eval $itk_component(renderer) scale $args 194 206 } … … 205 217 # ---------------------------------------------------------------------- 206 218 itcl::body Rappture::FieldResult::download {option args} { 219 if { ![info exists itk_component(renderer)] } { 220 puts stderr "download: no renderer created." 221 return 222 } 207 223 eval $itk_component(renderer) download $option $args 208 224 } 209 225 210 226 itcl::body Rappture::FieldResult::snap { w h } { 227 if { ![info exists itk_component(renderer)] } { 228 puts stderr "snap: no renderer created." 229 return 230 } 211 231 return [$itk_component(renderer) snap $w $h] 212 232 } -
branches/r9/gui/scripts/flowvisviewer.tcl
r4336 r4919 250 250 $this-streams 0 251 251 $this-volume 1 252 $this-ambient 60 253 $this-diffuse 40 254 $this-light2side 1 255 $this-opacity 100 256 $this-specularLevel 30 257 $this-specularExponent 90 258 $this-thickness 350 259 $this-transp 50 260 $this-cutplaneVisible 0 261 $this-xcutplane 1 252 $this-xcutplane 0 262 253 $this-xcutposition 0 263 $this-ycutplane 1254 $this-ycutplane 0 264 255 $this-ycutposition 0 265 $this-zcutplane 1256 $this-zcutplane 0 266 257 $this-zcutposition 0 267 258 }] … … 324 315 "Toggle the volume cloud on/off" 325 316 pack $itk_component(volume) -padx 2 -pady 2 326 327 itk_component add cutplane {328 Rappture::PushButton $f.cutplane \329 -onimage [Rappture::icon cutbutton] \330 -offimage [Rappture::icon cutbutton] \331 -variable [itcl::scope _settings($this-cutplaneVisible)] \332 -command [itcl::code $this AdjustSetting cutplaneVisible]333 }334 Rappture::Tooltip::for $itk_component(cutplane) \335 "Show/Hide cutplanes"336 pack $itk_component(cutplane) -padx 2 -pady 2337 317 338 318 if { [catch { … … 736 716 # ---------------------------------------------------------------------- 737 717 itcl::body Rappture::FlowvisViewer::scale {args} { 738 array set style {718 array set styles { 739 719 -color BCGYR 740 720 -levels 6 721 -markers "" 741 722 -opacity 1.0 742 -markers ""743 723 } 744 724 array unset _limits … … 751 731 if { ![info exists _volcomponents($cname)] } { 752 732 lappend _componentsList $cname 753 array set style [lindex [$dataobj components -style $cname] 0]754 set cmap [ColorsToColormap $style (-color)]733 array set styles [lindex [$dataobj components -style $cname] 0] 734 set cmap [ColorsToColormap $styles(-color)] 755 735 set _cname2defaultcolormap($cname) $cmap 756 set _settings($cname-colormap) $style (-color)736 set _settings($cname-colormap) $styles(-color) 757 737 } 758 738 lappend _volcomponents($cname) $dataobj-$cname … … 904 884 set session $env(SESSION) 905 885 } 886 lappend info "version" "$Rappture::version" 887 lappend info "build" "$Rappture::build" 888 lappend info "svnurl" "$Rappture::svnurl" 889 lappend info "installdir" "$Rappture::installdir" 906 890 lappend info "hub" [exec hostname] 907 891 lappend info "client" "flowvisviewer" … … 1057 1041 set tf $_obj2style($tag) 1058 1042 foreach {vmin vmax} [limits $tf] break 1059 $c itemconfigure vmin -text [format % .2g $vmin]1043 $c itemconfigure vmin -text [format %g $vmin] 1060 1044 $c coords vmin $lx $ly 1061 1045 1062 $c itemconfigure vmax -text [format % .2g $vmax]1046 $c itemconfigure vmax -text [format %g $vmax] 1063 1047 $c coords vmax [expr {$w-$lx}] $ly 1064 1048 … … 1189 1173 set _first [lindex [get] 0] 1190 1174 1191 foreach axis {x y z} {1192 # Turn off cutplanes for all volumes1193 SendCmd "cutplane state 0 $axis"1194 }1195 1196 1175 # Reset the camera and other view parameters 1197 InitSettings light2side ambient diffuse specularLevel specularExponent \ 1198 transp isosurface grid axes volume outline \ 1199 cutplaneVisible xcutplane ycutplane zcutplane 1200 1176 InitSettings light2side light transp isosurface grid axes volume outline 1177 1201 1178 # nothing to send -- activate the proper volume 1202 1179 if {"" != $_first} { 1180 AdjustSetting light 1181 AdjustSetting transp 1203 1182 set axis [$_first hints updir] 1204 1183 if {"" != $axis} { … … 1251 1230 set vols [CurrentVolumeIds -cutplanes] 1252 1231 foreach axis {x y z} { 1232 SendCmd "cutplane state $_settings($this-${axis}cutplane) $axis $vols" 1253 1233 set pos [expr {0.01*$_settings($this-${axis}cutposition)}] 1254 1234 SendCmd "cutplane position $pos $axis $vols" … … 1279 1259 foreach key [array names _serverObjs *-*] { 1280 1260 if {[string match $_first-* $key]} { 1281 array set style {1261 array set styles { 1282 1262 -cutplanes 1 1283 1263 } 1284 1264 foreach {dataobj comp} [split $key -] break 1285 array set style [lindex [$dataobj components -style $comp] 0]1286 if {$what != "-cutplanes" || $style (-cutplanes)} {1265 array set styles [lindex [$dataobj components -style $comp] 0] 1266 if {$what != "-cutplanes" || $styles(-cutplanes)} { 1287 1267 lappend rlist $_serverObjs($key) 1288 1268 } … … 1575 1555 #ResetColormap $color 1576 1556 } 1577 ambient {1557 light { 1578 1558 if { $_first != "" } { 1579 1559 set comp [lindex [$_first components] 0] 1580 1560 set tag $_first-$comp 1581 set val $_settings($this-ambient) 1582 set val [expr {0.01*$val}] 1583 SendCmd "$tag configure -ambient $val" 1584 } 1585 } 1586 diffuse { 1587 if { $_first != "" } { 1588 set comp [lindex [$_first components] 0] 1589 set tag $_first-$comp 1590 set val $_settings($this-diffuse) 1591 set val [expr {0.01*$val}] 1592 SendCmd "$tag configure -diffuse $val" 1593 } 1594 } 1595 specularLevel { 1596 if { $_first != "" } { 1597 set comp [lindex [$_first components] 0] 1598 set tag $_first-$comp 1599 set val $_settings($this-specularLevel) 1600 set val [expr {0.01*$val}] 1601 SendCmd "$tag configure -specularLevel $val" 1602 } 1603 } 1604 specularExponent { 1605 if { $_first != "" } { 1606 set comp [lindex [$_first components] 0] 1607 set tag $_first-$comp 1608 set val $_settings($this-specularExponent) 1609 SendCmd "$tag configure -specularExp $val" 1561 set diffuse [expr {0.01*$_settings($this-light)}] 1562 set ambient [expr {1.0 - $diffuse}] 1563 set specularLevel 0.3 1564 set specularExp 90.0 1565 SendCmd "$tag configure -ambient $ambient -diffuse $diffuse -specularLevel $specularLevel -specularExp $specularExp" 1610 1566 } 1611 1567 } … … 1683 1639 SendCmd "$tag configure -volume $_settings($this-volume)" 1684 1640 } 1685 }1686 "cutplaneVisible" {1687 set bool $_settings($this-$what)1688 set datasets [CurrentVolumeIds -cutplanes]1689 set tag [lindex $datasets 0]1690 SendCmd "cutplane visible $bool $tag"1691 1641 } 1692 1642 "xcutplane" - "ycutplane" - "zcutplane" { … … 1757 1707 # 1758 1708 itcl::body Rappture::FlowvisViewer::NameTransferFunc { dataobj cname } { 1759 array set style { 1709 array set styles { 1710 -color BCGYR 1711 -levels 6 1712 -light 40 1713 -opacity 1.0 1714 -transp 50 1715 } 1716 array set styles [lindex [$dataobj components -style $cname] 0] 1717 set _settings($this-light) $styles(-light) 1718 set _settings($this-transp) $styles(-transp) 1719 set _settings($this-opacity) [expr $styles(-opacity) * 100] 1720 set _obj2style($dataobj-$cname) $cname 1721 lappend _style2objs($cname) $dataobj $cname 1722 return $cname 1723 } 1724 1725 # 1726 # ComputeTransferFunc -- 1727 # 1728 # Computes and sends the transfer function to the render server. It's 1729 # assumed that the volume data limits are known and that the global 1730 # transfer-functions slider values have be setup. Both parts are 1731 # needed to compute the relative value (location) of the marker, and 1732 # the alpha map of the transfer function. 1733 # 1734 itcl::body Rappture::FlowvisViewer::ComputeTransferFunc { tf } { 1735 array set styles { 1760 1736 -color BCGYR 1761 1737 -levels 6 … … 1764 1740 -transp 50 1765 1741 } 1766 array set style [lindex [$dataobj components -style $cname] 0]1767 set _settings($this-light) $style(-light)1768 set _settings($this-transp) $style(-transp)1769 set _settings($this-opacity) [expr $style(-opacity) * 100]1770 set _obj2style($dataobj-$cname) $cname1771 lappend _style2objs($cname) $dataobj $cname1772 return $cname1773 }1774 1775 #1776 # ComputeTransferFunc --1777 #1778 # Computes and sends the transfer function to the render server. It's1779 # assumed that the volume data limits are known and that the global1780 # transfer-functions slider values have be setup. Both parts are1781 # needed to compute the relative value (location) of the marker, and1782 # the alpha map of the transfer function.1783 #1784 itcl::body Rappture::FlowvisViewer::ComputeTransferFunc { tf } {1785 array set style {1786 -color BCGYR1787 -levels 61788 -opacity 1.01789 -light 401790 -transp 501791 }1792 1742 set dataobj ""; set comp "" 1793 1743 foreach {dataobj comp} $_style2objs($tf) break … … 1795 1745 return 0 1796 1746 } 1797 array set style [lindex [$dataobj components -style $comp] 0]1747 array set styles [lindex [$dataobj components -style $comp] 0] 1798 1748 1799 1749 … … 1813 1763 if { ![info exists _isomarkers($tf)] } { 1814 1764 # Have to defer creation of isomarkers until we have data limits 1815 if { [info exists style (-markers)] &&1816 [llength $style (-markers)] > 0 } {1817 ParseMarkersOption $tf $style (-markers)1765 if { [info exists styles(-markers)] && 1766 [llength $styles(-markers)] > 0 } { 1767 ParseMarkersOption $tf $styles(-markers) 1818 1768 } else { 1819 ParseLevelsOption $tf $style (-levels)1820 } 1821 } 1822 if { [info exists style (-nonuniformcolors)] } {1823 foreach { value color } $style (-nonuniformcolors) {1769 ParseLevelsOption $tf $styles(-levels) 1770 } 1771 } 1772 if { [info exists styles(-nonuniformcolors)] } { 1773 foreach { value color } $styles(-nonuniformcolors) { 1824 1774 append cmap "$value [Color2RGB $color] " 1825 1775 } 1826 1776 } else { 1827 set cmap [ColorsToColormap $style (-color)]1777 set cmap [ColorsToColormap $styles(-color)] 1828 1778 } 1829 1779 set tag $this-$tf 1830 1780 if { ![info exists _settings($tag-opacity)] } { 1831 set _settings($tag-opacity) $style (-opacity)1781 set _settings($tag-opacity) $styles(-opacity) 1832 1782 } 1833 1783 set max 1.0 ;#$_settings($tag-opacity) … … 2173 2123 2174 2124 itcl::body Rappture::FlowvisViewer::BuildVolumeTab {} { 2125 foreach { key value } { 2126 light2side 1 2127 light 40 2128 transp 50 2129 opacity 100 2130 thickness 350 2131 } { 2132 set _settings($this-$key) $value 2133 } 2134 2175 2135 set inner [$itk_component(main) insert end \ 2176 2136 -title "Volume Settings" \ … … 2193 2153 -command [itcl::code $this AdjustSetting light2side] 2194 2154 2195 label $inner. ambient_l -text "Ambient" -font $fg2196 ::scale $inner. ambient -from 0 -to 100 -orient horizontal \2197 -variable [itcl::scope _settings($this- ambient)] \2155 label $inner.dim -text "Glow" -font $fg 2156 ::scale $inner.light -from 0 -to 100 -orient horizontal \ 2157 -variable [itcl::scope _settings($this-light)] \ 2198 2158 -width 10 \ 2199 -showvalue off -command [itcl::code $this AdjustSetting ambient] 2200 2201 label $inner.diffuse_l -text "Diffuse" -font $fg 2202 ::scale $inner.diffuse -from 0 -to 100 -orient horizontal \ 2203 -variable [itcl::scope _settings($this-diffuse)] \ 2204 -width 10 \ 2205 -showvalue off -command [itcl::code $this AdjustSetting diffuse] 2206 2207 label $inner.specularLevel_l -text "Specular" -font $fg 2208 ::scale $inner.specularLevel -from 0 -to 100 -orient horizontal \ 2209 -variable [itcl::scope _settings($this-specularLevel)] \ 2210 -width 10 \ 2211 -showvalue off -command [itcl::code $this AdjustSetting specularLevel] 2212 2213 label $inner.specularExponent_l -text "Shininess" -font $fg 2214 ::scale $inner.specularExponent -from 10 -to 128 -orient horizontal \ 2215 -variable [itcl::scope _settings($this-specularExponent)] \ 2216 -width 10 \ 2217 -showvalue off -command [itcl::code $this AdjustSetting specularExponent] 2218 2219 label $inner.clear -text "Clear" -font $fg 2159 -showvalue off -command [itcl::code $this AdjustSetting light] 2160 label $inner.bright -text "Surface" -font $fg 2161 2162 label $inner.fog -text "Clear" -font $fg 2220 2163 ::scale $inner.transp -from 0 -to 100 -orient horizontal \ 2221 2164 -variable [itcl::scope _settings($this-transp)] \ 2222 2165 -width 10 \ 2223 2166 -showvalue off -command [itcl::code $this AdjustSetting transp] 2167 label $inner.plastic -text "Opaque" -font $fg 2168 2169 label $inner.clear -text "Clear" -font $fg 2170 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 2171 -variable [itcl::scope _settings($this-opacity)] \ 2172 -width 10 \ 2173 -showvalue off -command [itcl::code $this AdjustSetting opacity] 2224 2174 label $inner.opaque -text "Opaque" -font $fg 2225 2175 … … 2235 2185 Rappture::Combobox $inner.colormap -width 10 -editable no 2236 2186 } 2187 2237 2188 $inner.colormap choices insert end [GetColormapList -includeNone] 2238 2189 $itk_component(colormap) value "BCGYR" … … 2244 2195 1,0 $inner.shading -cspan 4 -anchor w -pady {10 2} \ 2245 2196 2,0 $inner.light2side -cspan 4 -anchor w -pady 2 \ 2246 3,0 $inner.ambient_l -anchor e -pady 2 \ 2247 3,1 $inner.ambient -cspan 3 -pady 2 -fill x \ 2248 4,0 $inner.diffuse_l -anchor e -pady 2 \ 2249 4,1 $inner.diffuse -cspan 3 -pady 2 -fill x \ 2250 5,0 $inner.specularLevel_l -anchor e -pady 2 \ 2251 5,1 $inner.specularLevel -cspan 3 -pady 2 -fill x \ 2252 6,0 $inner.specularExponent_l -anchor e -pady 2 \ 2253 6,1 $inner.specularExponent -cspan 3 -pady 2 -fill x \ 2254 7,0 $inner.clear -anchor e -pady 2 \ 2255 7,1 $inner.transp -cspan 2 -pady 2 -fill x \ 2256 7,3 $inner.opaque -anchor w -pady 2 \ 2257 8,0 $inner.thin -anchor e -pady 2 \ 2258 8,1 $inner.thickness -cspan 2 -pady 2 -fill x \ 2259 8,3 $inner.thick -anchor w -pady 2 2197 3,0 $inner.dim -anchor e -pady 2 \ 2198 3,1 $inner.light -cspan 2 -pady 2 -fill x \ 2199 3,3 $inner.bright -anchor w -pady 2 \ 2200 4,0 $inner.fog -anchor e -pady 2 \ 2201 4,1 $inner.transp -cspan 2 -pady 2 -fill x \ 2202 4,3 $inner.plastic -anchor w -pady 2 \ 2203 5,0 $inner.thin -anchor e -pady 2 \ 2204 5,1 $inner.thickness -cspan 2 -pady 2 -fill x\ 2205 5,3 $inner.thick -anchor w -pady 2 2260 2206 2261 2207 blt::table configure $inner c0 c1 c3 r* -resize none 2262 blt::table configure $inner r 9-resize expand2208 blt::table configure $inner r6 -resize expand 2263 2209 } 2264 2210 … … 2279 2225 Rappture::Tooltip::for $itk_component(xCutButton) \ 2280 2226 "Toggle the X cut plane on/off" 2281 $itk_component(xCutButton) select2282 2227 2283 2228 itk_component add xCutScale { … … 2307 2252 Rappture::Tooltip::for $itk_component(yCutButton) \ 2308 2253 "Toggle the Y cut plane on/off" 2309 $itk_component(yCutButton) select2310 2254 2311 2255 itk_component add yCutScale { … … 2335 2279 Rappture::Tooltip::for $itk_component(zCutButton) \ 2336 2280 "Toggle the Z cut plane on/off" 2337 $itk_component(zCutButton) select2338 2281 2339 2282 itk_component add zCutScale { -
branches/r9/gui/scripts/grab.tcl
r3330 r4919 39 39 # ---------------------------------------------------------------------- 40 40 rename grab _tk_grab 41 proc grab { args} {41 proc grab { args } { 42 42 set op [lindex $args 0] 43 43 if {[winfo exists $op]} { … … 54 54 set state $::Rappture::grab::state 55 55 set window [lindex $args end] 56 56 57 if {[lsearch -exact $args -global] >= 0} { 57 58 set state "-global" … … 91 92 92 93 # and set the next one 93 if { "" != $window} {94 if {[lindex $window 0] != "-global"} {95 # no more global grabs -- resume local grabs96 set ::Rappture::grab::state ""97 }94 if {[lindex $window 0] != "-global"} { 95 # no more global grabs -- resume local grabs 96 set ::Rappture::grab::state "" 97 } 98 if { $window != "" } { 98 99 eval _grabset $window 99 100 } -
branches/r9/gui/scripts/isomarker.tcl
r4166 r4919 113 113 set _value $x 114 114 set y 31 115 $_canvas itemconfigure $_label -text [format % .2g $_value]115 $_canvas itemconfigure $_label -text [format %g $_value] 116 116 set x [screenpos] 117 117 $_canvas coords $_tick $x [expr {$y+3}] -
branches/r9/gui/scripts/map.tcl
r4303 r4919 119 119 set name "layer[incr _nextLayer]" 120 120 set child [$_tree insert $parent -label $name] 121 $_tree set $child "title" [$layers get $layer.label]122 121 set layerType [$layers get $layer.type] 123 122 if { ![info exists _layerTypes($layerType)] } { … … 126 125 $_tree set $child "name" $layer 127 126 $_tree set $child "type" $layerType 128 foreach key { label description url} {127 foreach key { label description } { 129 128 $_tree set $child $key [$layers get $layer.$key] 130 129 } 131 130 # Common settings (for all layer types) with defaults 132 foreach { key defval} { visible true } {131 foreach { key defval } { visible true } { 133 132 $_tree set $child $key $defval 134 133 set val [$layers get $layer.$key] … … 146 145 } 147 146 } 148 set file [$layers get $layer.file] 149 if { $file != "" } { 150 # FIXME: Add test for valid file path 151 $_tree set $child "url" $file 147 $_tree set $child "driver" "debug" 148 set gdal [$layers element -as type $layer.gdal] 149 if { $gdal != "" } { 150 foreach key { url } { 151 set value [$layers get $layer.gdal.$key] 152 $_tree set $child "gdal.$key" $value 153 } 154 set file [$layers get $layer.gdal.file] 155 if { $file != "" } { 156 # FIXME: Add test for valid file path 157 $_tree set $child "gdal.url" $file 158 } 159 $_tree set $child "driver" "gdal" 160 } 161 set ogr [$layers element -as type $layer.ogr] 162 if { $ogr != "" } { 163 foreach key { url } { 164 set value [$layers get $layer.ogr.$key] 165 $_tree set $child "ogr.$key" $value 166 } 167 set file [$layers get $layer.ogr.file] 168 if { $file != "" } { 169 # FIXME: Add test for valid file path 170 $_tree set $child "ogr.url" $file 171 } 172 $_tree set $child "driver" "ogr" 173 } 174 set tfs [$layers element -as type $layer.tfs] 175 if { $tfs != "" } { 176 foreach key { url format } { 177 set value [$layers get $layer.tfs.$key] 178 $_tree set $child "tfs.$key" $value 179 } 180 $_tree set $child "driver" "tfs" 181 } 182 set tms [$layers element -as type $layer.tms] 183 if { $tms != "" } { 184 foreach key { url tmsType format } { 185 set value [$layers get $layer.tms.$key] 186 $_tree set $child "tms.$key" $value 187 } 188 $_tree set $child "driver" "tms" 189 } 190 set wfs [$layers element -as type $layer.wfs] 191 if { $wfs != "" } { 192 foreach key { url typename outputformat maxfeatures request_buffer } { 193 set value [$layers get $layer.wfs.$key] 194 $_tree set $child "wfs.$key" $value 195 } 196 $_tree set $child "driver" "wfs" 197 } 198 set wms [$layers element -as type $layer.wms] 199 if { $wms != "" } { 200 foreach key { url layers format transparent } { 201 set value [$layers get $layer.wms.$key] 202 $_tree set $child "wms.$key" $value 203 } 204 $_tree set $child "driver" "wms" 205 } 206 set xyz [$layers element -as type $layer.xyz] 207 if { $xyz != "" } { 208 foreach key { url } { 209 set value [$layers get $layer.xyz.$key] 210 $_tree set $child "xyz.$key" $value 211 } 212 $_tree set $child "driver" "xyz" 152 213 } 153 214 } -
branches/r9/gui/scripts/mapviewer.tcl
r4336 r4919 72 72 protected method DoResize {} 73 73 protected method DoRotate {} 74 protected method FixSettings { args }74 protected method InitSettings { args } 75 75 protected method KeyPress { key } 76 76 protected method KeyRelease { key } … … 177 177 # to update the Lat/Long coordinate display 178 178 array set _motion { 179 compress 0 180 delay 100 181 enable 0 182 pending 0 179 183 x 0 180 184 y 0 181 pending 0182 delay 100183 compress 0184 185 } 185 186 # This array holds the Viewpoint parameters that the 186 187 # server sends on "camera get". 187 188 array set _view { 189 distance 1.0 190 heading 0.0 191 pitch -89.9 192 srs "" 193 verticalDatum "" 188 194 x 0.0 189 195 y 0.0 190 196 z 0.0 191 heading 0.0192 pitch -89.9193 distance 1.0194 srs ""195 verticalDatum ""196 197 } 197 198 … … 200 201 array set _settings [subst { 201 202 camera-throw 0 203 coords-precision 5 204 coords-units "latlong_decimal_degrees" 205 coords-visible 1 202 206 grid 0 203 207 grid-type "geodetic" … … 334 338 [itcl::code $this MouseRelease 3 %x %y] 335 339 336 bind $itk_component(view) <Motion> \ 337 [itcl::code $this EventuallyHandleMotionEvent %x %y] 340 # Binding for mouse motion events 341 if {$_motion(enable)} { 342 bind $itk_component(view) <Motion> \ 343 [itcl::code $this EventuallyHandleMotionEvent %x %y] 344 } 338 345 } else { 339 346 # Bindings for panning via mouse … … 344 351 bind $itk_component(view) <ButtonRelease-1> \ 345 352 [itcl::code $this Pan release %x %y] 353 bind $itk_component(view) <Button-1> \ 354 +[itcl::code $this SendCmd "map setpos %x %y"] 346 355 bind $itk_component(view) <Double-1> \ 347 356 [itcl::code $this camera go %x %y 0.4] … … 364 373 bind $itk_component(view) <Double-3> \ 365 374 [itcl::code $this camera go %x %y 2.5] 375 bind $itk_component(view) <Double-3> \ 376 +[itcl::code $this SendCmd "map setpos %x %y"] 366 377 367 378 # Bindings for panning via keyboard … … 375 386 [itcl::code $this Pan set 0 10] 376 387 377 # Send (compressed) motion events to update Lat/Long388 # Binding for mouse motion events 378 389 set _motion(compress) 1 379 bind $itk_component(view) <Motion> \ 380 [itcl::code $this EventuallyHandleMotionEvent %x %y] 390 if {$_motion(enable)} { 391 bind $itk_component(view) <Motion> \ 392 [itcl::code $this EventuallyHandleMotionEvent %x %y] 393 } 381 394 } 382 395 … … 954 967 SetTerrainStyle $_mapsettings(style) 955 968 } else { 956 FixSettings terrain-edges terrain-lighting \969 InitSettings terrain-edges terrain-lighting \ 957 970 terrain-vertscale terrain-wireframe 958 971 } 972 InitSettings coords-visible 959 973 } else { 960 974 error "No map settings on reset" … … 971 985 array set info [$dataobj layer $layer] 972 986 if { ![info exists _layers($layer)] } { 973 if { ![info exists info(url)] } {974 continue975 }976 987 if { $_reportClientInfo } { 977 988 set cinfo {} … … 1294 1305 1295 1306 # ---------------------------------------------------------------------- 1296 # USAGE: FixSettings <what> ?<value>?1307 # USAGE: InitSettings <what> ?<value>? 1297 1308 # 1298 1309 # Used internally to update rendering settings whenever parameters … … 1300 1311 # to the back end. 1301 1312 # ---------------------------------------------------------------------- 1302 itcl::body Rappture::MapViewer:: FixSettings { args } {1313 itcl::body Rappture::MapViewer::InitSettings { args } { 1303 1314 foreach setting $args { 1304 1315 AdjustSetting $setting … … 1318 1329 } 1319 1330 switch -- $what { 1331 "coords-visible" - "coords-precision" - "coords-units" { 1332 set bool $_settings(coords-visible) 1333 set units $_settings(coords-units) 1334 set precision $_settings(coords-precision) 1335 SendCmd "map posdisp $bool $units $precision" 1336 } 1320 1337 "grid" - "grid-type" { 1321 1338 set bool $_settings(grid) … … 1324 1341 } 1325 1342 "camera-throw" { 1326 set bool $_settings( camera-throw)1343 set bool $_settings($what) 1327 1344 SendCmd "camera throw $bool" 1328 1345 } 1329 1346 "terrain-edges" { 1330 set bool $_settings( terrain-edges)1347 set bool $_settings($what) 1331 1348 SendCmd "map terrain edges $bool" 1332 1349 } 1333 1350 "terrain-lighting" { 1334 set bool $_settings( terrain-lighting)1351 set bool $_settings($what) 1335 1352 SendCmd "map terrain lighting $bool" 1336 1353 } … … 1340 1357 } 1341 1358 "terrain-vertscale" { 1342 set val $_settings( terrain-vertscale)1359 set val $_settings($what) 1343 1360 SendCmd "map terrain vertscale $val" 1344 1361 } 1345 1362 "terrain-wireframe" { 1346 set bool $_settings( terrain-wireframe)1363 set bool $_settings($what) 1347 1364 SendCmd "map terrain wireframe $bool" 1348 1365 } … … 1387 1404 -icon [Rappture::icon surface]] 1388 1405 $inner configure -borderwidth 4 1406 1407 checkbutton $inner.posdisp \ 1408 -text "Show Coordinate Readout" \ 1409 -variable [itcl::scope _settings(coords-visible)] \ 1410 -command [itcl::code $this AdjustSetting coords-visible] \ 1411 -font "Arial 9" -anchor w 1389 1412 1390 1413 checkbutton $inner.grid \ … … 1432 1455 1433 1456 blt::table $inner \ 1434 0,0 $inner.grid -cspan 2 -anchor w -pady 2 \ 1435 1,0 $inner.wireframe -cspan 2 -anchor w -pady 2 \ 1436 2,0 $inner.lighting -cspan 2 -anchor w -pady 2 \ 1437 3,0 $inner.edges -cspan 2 -anchor w -pady 2 \ 1438 4,0 $inner.vscale_l -anchor w -pady 2 \ 1439 4,1 $inner.vscale -fill x -pady 2 \ 1440 5,0 $inner.palette_l -anchor w -pady 2 \ 1441 5,1 $inner.palette -fill x -pady 2 1457 0,0 $inner.posdisp -cspan 2 -anchor w -pady 2 \ 1458 1,0 $inner.grid -cspan 2 -anchor w -pady 2 \ 1459 2,0 $inner.wireframe -cspan 2 -anchor w -pady 2 \ 1460 3,0 $inner.lighting -cspan 2 -anchor w -pady 2 \ 1461 4,0 $inner.edges -cspan 2 -anchor w -pady 2 \ 1462 5,0 $inner.vscale_l -anchor w -pady 2 \ 1463 5,1 $inner.vscale -fill x -pady 2 \ 1464 6,0 $inner.palette_l -anchor w -pady 2 \ 1465 6,1 $inner.palette -fill x -pady 2 1442 1466 1443 1467 blt::table configure $inner r* c* -resize none 1444 blt::table configure $inner r 7c1 -resize expand1468 blt::table configure $inner r8 c1 -resize expand 1445 1469 } 1446 1470 … … 1452 1476 set inner [$itk_component(main) insert end \ 1453 1477 -title "Layers" \ 1454 -icon [Rappture::icon wrench]]1478 -icon [Rappture::icon layers]] 1455 1479 $inner configure -borderwidth 4 1456 1480 set f [frame $inner.layers] … … 1698 1722 } 1699 1723 if {!$_sendEarthFile} { 1700 SendCmd [list map layer add image gdal $info(url) $layer] 1724 switch -- $info(driver) { 1725 "debug" { 1726 SendCmd [list map layer add image debug $layer] 1727 } 1728 "gdal" { 1729 SendCmd [list map layer add image gdal \ 1730 $info(gdal.url) $layer] 1731 } 1732 "tms" { 1733 SendCmd [list map layer add image tms \ 1734 $info(tms.url) $layer] 1735 } 1736 "wms" { 1737 SendCmd [list map layer add image wms \ 1738 $info(wms.url) \ 1739 $info(wms.layers) \ 1740 $info(wms.format) \ 1741 $info(wms.transparent) \ 1742 $layer] 1743 } 1744 "xyz" { 1745 SendCmd [list map layer add image xyz \ 1746 $info(xyz.url) \ 1747 $layer] 1748 } 1749 } 1701 1750 } 1702 1751 SendCmd "map layer opacity $settings(-opacity) $layer" … … 1711 1760 } 1712 1761 if {!$_sendEarthFile} { 1713 SendCmd [list map layer add elevation gdal $info(url) $layer] 1762 switch -- $info(driver) { 1763 "gdal" { 1764 SendCmd [list map layer add elevation gdal \ 1765 $info(gdal.url) $layer] 1766 } 1767 "tms" { 1768 SendCmd [list map layer add elevation tms \ 1769 $info(tms.url) $layer] 1770 } 1771 } 1714 1772 } 1715 1773 } … … 1727 1785 set settings(-opacity) $info(opacity) 1728 1786 } 1729 SendCmd [list map layer add line $info( url) $layer]1787 SendCmd [list map layer add line $info(ogr.url) $layer] 1730 1788 SendCmd "map layer opacity $settings(-opacity) $layer" 1731 1789 } … … 1742 1800 set settings(-opacity) $info(opacity) 1743 1801 } 1744 SendCmd [list map layer add polygon $info( url) $layer]1802 SendCmd [list map layer add polygon $info(ogr.url) $layer] 1745 1803 SendCmd "map layer opacity $settings(-opacity) $layer" 1746 1804 } … … 1771 1829 set priorityExpr "" 1772 1830 } 1773 SendCmd [list map layer add text $info( url) $contentExpr $priorityExpr $layer]1831 SendCmd [list map layer add text $info(ogr.url) $contentExpr $priorityExpr $layer] 1774 1832 SendCmd "map layer opacity $settings(-opacity) $layer" 1775 1833 } … … 1815 1873 array set info [$dataobj layer $layer] 1816 1874 checkbutton $f.$layer \ 1817 -text $info( title) \1875 -text $info(label) \ 1818 1876 -variable [itcl::scope _visibility($layer)] \ 1819 1877 -command [itcl::code $this \ -
branches/r9/gui/scripts/mesh.tcl
r4259 r4919 33 33 # xmin, xmax, ymin, ymax, ... 34 34 private variable _numPoints 0 ; # # of points in mesh 35 private variable _numCells 0 35 private variable _numCells 0; # # of cells in mesh 36 36 private variable _vtkdata ""; # Mesh in vtk file format. 37 37 private variable _isValid 0; # Indicates if the mesh is valid. … … 63 63 return $_numPoints 64 64 } 65 65 public method numcells {} { 66 return $_numCells 67 } 66 68 67 69 private common _xp2obj ; # used for fetch/release ref counting … … 74 76 75 77 private method ReadNodesElements {path} 78 private method GetCellCount { xNum yNum zNum } 76 79 private method GetDimension { path } 77 80 private method GetDouble { path } … … 83 86 private method WriteTriangles { path xv yv zv triangles } 84 87 private method WriteQuads { path xv yv zv quads } 88 private method WriteVertices { path xv yv zv vertices } 89 private method WriteLines { path xv yv zv lines } 90 private method WritePolygons { path xv yv zv polygons } 91 private method WriteTriangleStrips { path xv yv zv trianglestrips } 85 92 private method WriteTetrahedrons { path xv yv zv tetrahedrons } 86 93 private method WriteHexahedrons { path xv yv zv hexhedrons } … … 420 427 } 421 428 } 429 foreach {key path} { 430 toolid tool.id 431 toolname tool.name 432 toolcommand tool.execute 433 tooltitle tool.title 434 toolrevision tool.version.application.revision 435 } { 436 set str [$_xmlobj get $path] 437 if { "" != $str } { 438 set _hints($key) $str 439 } 440 } 422 441 } 423 442 … … 454 473 return $value 455 474 } 456 457 475 458 476 itcl::body Rappture::Mesh::ReadVtk { path } { … … 482 500 $reader Update 483 501 set output [$reader GetOutput] 502 set _numPoints [$output GetNumberOfPoints] 503 set _numCells [$output GetNumberOfCells] 484 504 foreach { xmin xmax ymin ymax zmin zmax } [$output GetBounds] break 485 505 set _limits(x) [list $xmin $xmax] … … 490 510 rename $reader "" 491 511 return 1 512 } 513 514 itcl::body Rappture::Mesh::GetCellCount { xNum yNum zNum } { 515 set numCells 1 516 if { $xNum > 1 } { 517 set numCells [expr $numCells * ($xNum - 1)] 518 } 519 if { $yNum > 1 } { 520 set numCells [expr $numCells * ($yNum - 1)] 521 } 522 if { $zNum > 1 } { 523 set numCells [expr $numCells * ($zNum - 1)] 524 } 525 return $numCells 492 526 } 493 527 … … 511 545 set ${axis}Max $max 512 546 set ${axis}Num $num 547 if {$min > $max} { 548 puts stderr "ERROR: grid $axis min can't be greater than max" 549 return 0 550 } 513 551 incr numUniform 514 552 } elseif { $coords != "" } { … … 550 588 set _dim 3 551 589 set _numPoints [expr $xNum * $yNum * $zNum] 552 if { ($_numPoints*3) != $numCoords } { 553 puts stderr "WARNING: bad grid \"$path\": invalid grid: \# of points does not match dimensions <xdim> * <ydim> * <zdim>" 590 set _numCells [GetCellCount $xNum $yNum $zNum] 591 if { ($_numPoints * 3) != $numCoords } { 592 puts stderr "WARNING: bad grid \"$path\": \# of points does not match dimensions $xNum * $yNum * $zNum" 554 593 return 0 555 594 } … … 572 611 set _dim 2 573 612 set _numPoints [expr $xNum * $yNum] 574 if { ($_numPoints*2) != $numCoords } { 575 puts stderr "WARNING: bad grid \"$path\": \# of points does not match dimensions <xdim> * <ydim>" 613 set _numCells [GetCellCount $xNum $yNum 1] 614 if { ($_numPoints * 2) != $numCoords } { 615 puts stderr "WARNING: bad grid \"$path\": \# of points does not match dimensions $xNum * $yNum" 576 616 return 0 577 617 } … … 596 636 set _dim 1 597 637 set _numPoints $xNum 638 set _numCells [GetCellCount $xNum 1 1] 598 639 if { $_numPoints != $numCoords } { 599 puts stderr "WARNING: bad grid \"$path\": \# of points does not match <xdim>"640 puts stderr "WARNING: bad grid \"$path\": \# of points does not match $xNum" 600 641 return 0 601 642 } … … 620 661 # This results in a STRUCTURED_POINTS 621 662 if { $_dim == 1 } { 622 set xSpace [expr ($xMax - $xMin) / double($xNum - 1)] 663 set xSpacing 0 664 if { $xNum > 1 } { 665 set xSpacing [expr ($xMax - $xMin) / double($xNum - 1)] 666 } 623 667 set _numPoints $xNum 668 set _numCells [GetCellCount $xNum 1 1] 624 669 append out "DATASET STRUCTURED_POINTS\n" 625 670 append out "DIMENSIONS $xNum 1 1\n" 626 671 append out "ORIGIN $xMin 0 0\n" 627 append out "SPACING $xSpac e0 0\n"672 append out "SPACING $xSpacing 0 0\n" 628 673 set _vtkdata $out 629 674 set _limits(x) [list $xMin $xMax] … … 631 676 set _limits(z) [list 0 0] 632 677 } elseif { $_dim == 2 } { 633 set xSpace [expr ($xMax - $xMin) / double($xNum - 1)] 634 set ySpace [expr ($yMax - $yMin) / double($yNum - 1)] 678 set xSpacing 0 679 set ySpacing 0 680 if { $xNum > 1 } { 681 set xSpacing [expr ($xMax - $xMin) / double($xNum - 1)] 682 } 683 if { $yNum > 1 } { 684 set ySpacing [expr ($yMax - $yMin) / double($yNum - 1)] 685 } 635 686 set _numPoints [expr $xNum * $yNum] 687 set _numCells [GetCellCount $xNum $yNum 1] 636 688 append out "DATASET STRUCTURED_POINTS\n" 637 689 append out "DIMENSIONS $xNum $yNum 1\n" 638 690 append out "ORIGIN $xMin $yMin 0\n" 639 append out "SPACING $xSpac e $ySpace0\n"691 append out "SPACING $xSpacing $ySpacing 0\n" 640 692 set _vtkdata $out 641 693 foreach axis {x y} { … … 644 696 set _limits(z) [list 0 0] 645 697 } elseif { $_dim == 3 } { 646 set xSpace [expr ($xMax - $xMin) / double($xNum - 1)] 647 set ySpace [expr ($yMax - $yMin) / double($yNum - 1)] 648 set zSpace [expr ($zMax - $zMin) / double($zNum - 1)] 698 set xSpacing 0 699 set ySpacing 0 700 set zSpacing 0 701 if {$xNum > 1} { 702 set xSpacing [expr ($xMax - $xMin) / double($xNum - 1)] 703 } 704 if {$yNum > 1} { 705 set ySpacing [expr ($yMax - $yMin) / double($yNum - 1)] 706 } 707 if {$zNum > 1} { 708 set zSpacing [expr ($zMax - $zMin) / double($zNum - 1)] 709 } 649 710 set _numPoints [expr $xNum * $yNum * $zNum] 711 set _numCells [GetCellCount $xNum $yNum $zNum] 650 712 append out "DATASET STRUCTURED_POINTS\n" 651 713 append out "DIMENSIONS $xNum $yNum $zNum\n" 652 714 append out "ORIGIN $xMin $yMin $zMin\n" 653 append out "SPACING $xSpac e $ySpace $zSpace\n"715 append out "SPACING $xSpacing $ySpacing $zSpacing\n" 654 716 set _vtkdata $out 655 717 foreach axis {x y z} { … … 700 762 if { $_dim == 3 } { 701 763 set _numPoints [expr $xNum * $yNum * $zNum] 764 set _numCells [GetCellCount $xNum $yNum $zNum] 702 765 append out "DATASET RECTILINEAR_GRID\n" 703 766 append out "DIMENSIONS $xNum $yNum $zNum\n" … … 719 782 } elseif { $_dim == 2 } { 720 783 set _numPoints [expr $xNum * $yNum] 784 set _numCells [GetCellCount $xNum $yNum 1] 721 785 append out "DATASET RECTILINEAR_GRID\n" 722 786 append out "DIMENSIONS $xNum $yNum 1\n" … … 738 802 } elseif { $_dim == 1 } { 739 803 set _numPoints $xNum 804 set _numCells [GetCellCount $xNum 1 1] 740 805 append out "DATASET RECTILINEAR_GRID\n" 741 806 append out "DIMENSIONS $xNum 1 1\n" … … 787 852 set _type "triangles" 788 853 set _numPoints [$xv length] 789 set count0854 set _numCells 0 790 855 set data {} 791 856 set celltypes {} … … 793 858 append data " 3 $a $b $c\n" 794 859 append celltypes "5\n" 795 incr count860 incr _numCells 796 861 } 797 862 append out "DATASET UNSTRUCTURED_GRID\n" … … 800 865 append out " $x $y $z\n" 801 866 } 802 append out "CELLS $count [expr $count * 4]\n" 867 set count [expr $_numCells * 4] 868 append out "CELLS $_numCells $count\n" 803 869 append out $data 804 append out "CELL_TYPES $ count\n"870 append out "CELL_TYPES $_numCells\n" 805 871 append out $celltypes 806 872 set _limits(x) [$xv limits] … … 818 884 set _type "quads" 819 885 set _numPoints [$xv length] 820 set count0886 set _numCells 0 821 887 set data {} 822 888 set celltypes {} … … 824 890 append data " 4 $a $b $c $d\n" 825 891 append celltypes "9\n" 826 incr count892 incr _numCells 827 893 } 828 894 append out "DATASET UNSTRUCTURED_GRID\n" … … 831 897 append out " $x $y $z\n" 832 898 } 833 append out "CELLS $count [expr $count * 5]\n" 899 set count [expr $_numCells * 5] 900 append out "CELLS $_numCells $count\n" 834 901 append out $data 835 append out "CELL_TYPES $ count\n"902 append out "CELL_TYPES $_numCells\n" 836 903 append out $celltypes 837 904 set _limits(x) [$xv limits] … … 846 913 } 847 914 915 itcl::body Rappture::Mesh::WriteVertices { path xv yv zv vertices } { 916 set _type "vertices" 917 set _numPoints [$xv length] 918 set _numCells 0 919 set data {} 920 set lines [split $vertices \n] 921 set count 0 922 foreach { line } $lines { 923 set numIndices [llength $line] 924 if { $numIndices == 0 } { 925 continue 926 } 927 append data " $numIndices $line\n" 928 incr _numCells 929 set count [expr $count + $numIndices + 1] 930 } 931 append out "DATASET POLYDATA\n" 932 append out "POINTS $_numPoints double\n" 933 foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] { 934 append out " $x $y $z\n" 935 } 936 append out "VERTICES $_numCells $count\n" 937 append out $data 938 set _limits(x) [$xv limits] 939 set _limits(y) [$yv limits] 940 if { $_dim == 3 } { 941 set _limits(z) [$zv limits] 942 } else { 943 set _limits(z) [list 0 0] 944 } 945 set _vtkdata $out 946 return 1 947 } 948 949 itcl::body Rappture::Mesh::WriteLines { path xv yv zv polylines } { 950 set _type "lines" 951 set _numPoints [$xv length] 952 set _numCells 0 953 set data {} 954 set lines [split $polylines \n] 955 set count 0 956 foreach { line } $lines { 957 set numIndices [llength $line] 958 if { $numIndices == 0 } { 959 continue 960 } 961 append data " $numIndices $line\n" 962 incr _numCells 963 set count [expr $count + $numIndices + 1] 964 } 965 append out "DATASET POLYDATA\n" 966 append out "POINTS $_numPoints double\n" 967 foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] { 968 append out " $x $y $z\n" 969 } 970 append out "LINES $_numCells $count\n" 971 append out $data 972 set _limits(x) [$xv limits] 973 set _limits(y) [$yv limits] 974 if { $_dim == 3 } { 975 set _limits(z) [$zv limits] 976 } else { 977 set _limits(z) [list 0 0] 978 } 979 set _vtkdata $out 980 return 1 981 } 982 983 itcl::body Rappture::Mesh::WritePolygons { path xv yv zv polygons } { 984 set _type "polygons" 985 set _numPoints [$xv length] 986 set _numCells 0 987 set data {} 988 set lines [split $polygons \n] 989 set count 0 990 foreach { line } $lines { 991 set numIndices [llength $line] 992 if { $numIndices == 0 } { 993 continue 994 } 995 append data " $numIndices $line\n" 996 incr _numCells 997 set count [expr $count + $numIndices + 1] 998 } 999 append out "DATASET POLYDATA\n" 1000 append out "POINTS $_numPoints double\n" 1001 foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] { 1002 append out " $x $y $z\n" 1003 } 1004 append out "POLYGONS $_numCells $count\n" 1005 append out $data 1006 set _limits(x) [$xv limits] 1007 set _limits(y) [$yv limits] 1008 if { $_dim == 3 } { 1009 set _limits(z) [$zv limits] 1010 } else { 1011 set _limits(z) [list 0 0] 1012 } 1013 set _vtkdata $out 1014 return 1 1015 } 1016 1017 itcl::body Rappture::Mesh::WriteTriangleStrips { path xv yv zv trianglestrips } { 1018 set _type "trianglestrips" 1019 set _numPoints [$xv length] 1020 set _numCells 0 1021 set data {} 1022 set lines [split $trianglestrips \n] 1023 set count 0 1024 foreach { line } $lines { 1025 set numIndices [llength $line] 1026 if { $numIndices == 0 } { 1027 continue 1028 } 1029 append data " $numIndices $line\n" 1030 incr _numCells 1031 set count [expr $count + $numIndices + 1] 1032 } 1033 append out "DATASET POLYDATA\n" 1034 append out "POINTS $_numPoints double\n" 1035 foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] { 1036 append out " $x $y $z\n" 1037 } 1038 append out "TRIANGLE_STRIPS $_numCells $count\n" 1039 append out $data 1040 set _limits(x) [$xv limits] 1041 set _limits(y) [$yv limits] 1042 if { $_dim == 3 } { 1043 set _limits(z) [$zv limits] 1044 } else { 1045 set _limits(z) [list 0 0] 1046 } 1047 set _vtkdata $out 1048 return 1 1049 } 1050 848 1051 itcl::body Rappture::Mesh::WriteTetrahedrons { path xv yv zv tetras } { 849 1052 set _type "tetrahedrons" 850 1053 set _numPoints [$xv length] 851 set count01054 set _numCells 0 852 1055 set data {} 853 1056 set celltypes {} … … 855 1058 append data " 4 $a $b $c $d\n" 856 1059 append celltypes "10\n" 857 incr count1060 incr _numCells 858 1061 } 859 1062 append out "DATASET UNSTRUCTURED_GRID\n" … … 862 1065 append out " $x $y $z\n" 863 1066 } 864 append out "CELLS $count [expr $count * 5]\n" 1067 set count [expr $_numCells * 5] 1068 append out "CELLS $_numCells $count\n" 865 1069 append out $data 866 append out "CELL_TYPES $ count\n"1070 append out "CELL_TYPES $_numCells\n" 867 1071 append out $celltypes 868 1072 set _limits(x) [$xv limits] … … 877 1081 set _type "hexahedrons" 878 1082 set _numPoints [$xv length] 879 set count01083 set _numCells 0 880 1084 set data {} 881 1085 set celltypes {} … … 883 1087 append data " 8 $a $b $c $d $e $f $g $h\n" 884 1088 append celltypes "12\n" 885 incr count1089 incr _numCells 886 1090 } 887 1091 append out "DATASET UNSTRUCTURED_GRID\n" … … 890 1094 append out " $x $y $z\n" 891 1095 } 892 append out "CELLS $count [expr $count * 9]\n" 1096 set count [expr $_numCells * 9] 1097 append out "CELLS $_numCells $count\n" 893 1098 append out $data 894 append out "CELL_TYPES $ count\n"1099 append out "CELL_TYPES $_numCells\n" 895 1100 append out $celltypes 896 1101 set _limits(x) [$xv limits] … … 905 1110 set _type "wedges" 906 1111 set _numPoints [$xv length] 907 set count01112 set _numCells 0 908 1113 set data {} 909 1114 set celltypes {} … … 911 1116 append data " 6 $a $b $c $d $e $f\n" 912 1117 append celltypes "13\n" 913 incr count1118 incr _numCells 914 1119 } 915 1120 append out "DATASET UNSTRUCTURED_GRID\n" … … 918 1123 append out " $x $y $z\n" 919 1124 } 920 append out "CELLS $count [expr $count * 7]\n" 1125 set count [expr $_numCells * 7] 1126 append out "CELLS $_numCells $count\n" 921 1127 append out $data 922 append out "CELL_TYPES $ count\n"1128 append out "CELL_TYPES $_numCells\n" 923 1129 append out $celltypes 924 1130 set _limits(x) [$xv limits] … … 933 1139 set _type "pyramids" 934 1140 set _numPoints [$xv length] 935 set count01141 set _numCells 0 936 1142 set data {} 937 1143 set celltypes {} … … 939 1145 append data " 5 $a $b $c $d $e\n" 940 1146 append celltypes "14\n" 941 incr count1147 incr _numCells 942 1148 } 943 1149 append out "DATASET UNSTRUCTURED_GRID\n" … … 946 1152 append out " $x $y $z\n" 947 1153 } 948 append out "CELLS $count [expr $count * 6]\n" 1154 set count [expr $_numCells * 6] 1155 append out "CELLS $_numCells $count\n" 949 1156 append out $data 950 append out "CELL_TYPES $ count\n"1157 append out "CELL_TYPES $_numCells\n" 951 1158 append out $celltypes 952 1159 set _limits(x) [$xv limits] … … 983 1190 puts stderr "WARNING: bad unstructured grid \"$path\": wrong \# of indices specified for celltype $celltype on line \"$line\"" 984 1191 return 0 1192 } else { 1193 set numIndices $length 985 1194 } 986 1195 append data " $numIndices $line\n" … … 1020 1229 # Step 1: Verify that there's only one cell tag of any kind. 1021 1230 set numCells 0 1022 foreach type { cells triangles quads tetrahedrons 1023 hexahedrons wedges pyramids } { 1231 foreach type { 1232 cells 1233 hexahedrons 1234 lines 1235 polygons 1236 pyramids 1237 quads 1238 tetrahedrons 1239 triangles 1240 trianglestrips 1241 vertices 1242 wedges 1243 } { 1024 1244 set data [$_xmlobj get $path.unstructured.$type] 1025 1245 if { $data != "" } { … … 1037 1257 return 0 1038 1258 } 1039 foreach type { cells triangles quads tetrahedrons 1040 hexahedrons wedges pyramids } { 1259 foreach type { 1260 cells 1261 hexahedrons 1262 lines 1263 polygons 1264 pyramids 1265 quads 1266 tetrahedrons 1267 triangles 1268 trianglestrips 1269 vertices 1270 wedges 1271 } { 1041 1272 set data [$_xmlobj get $path.unstructured.$type] 1042 1273 if { $data != "" } { … … 1153 1384 } 1154 1385 } 1386 set _numPoints [$xv length] 1387 1155 1388 # Step 3: Write the points and cells as vtk data. 1156 1389 if { $numCells == 0 } { … … 1277 1510 itcl::body Rappture::Mesh::GetCellType { name } { 1278 1511 array set name2type { 1279 "triangle" 5 1280 "quad" 9 1281 "tetrahedron" 10 1282 "hexahedron" 12 1283 "wedge" 13 1284 "pyramid" 14 1512 "vertex" 1 1513 "polyvertex" 2 1514 "line" 3 1515 "polyline" 4 1516 "triangle" 5 1517 "trianglestrip" 6 1518 "polygon" 7 1519 "pixel" 8 1520 "quad" 9 1521 "tetrahedron" 10 1522 "voxel" 11 1523 "hexahedron" 12 1524 "wedge" 13 1525 "pyramid" 14 1526 "pentagonalprism" 15 1527 "hexagonalprism" 16 1285 1528 } 1286 1529 if { [info exists name2type($name)] } { … … 1309 1552 13 6 1310 1553 14 5 1311 15 01312 16 01554 15 10 1555 16 12 1313 1556 } 1314 1557 if { [info exists type2indices($type)] } { -
branches/r9/gui/scripts/molvisviewer.tcl
r4075 r4919 691 691 set session $env(SESSION) 692 692 } 693 lappend info "version" "$Rappture::version" 694 lappend info "build" "$Rappture::build" 695 lappend info "svnurl" "$Rappture::svnurl" 696 lappend info "installdir" "$Rappture::installdir" 693 697 lappend info "hub" [exec hostname] 694 698 lappend info "client" "molvisviewer" -
branches/r9/gui/scripts/nanovisviewer.tcl
r4343 r4919 1 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 3 2 # ---------------------------------------------------------------------- 4 3 # COMPONENT: nanovisviewer - 3D volume rendering … … 82 81 public method updateTransferFunctions {} 83 82 84 85 83 # The following methods are only used by this class. 84 85 private method AddNewMarker { x y } 86 86 private method AdjustSetting {what {value ""}} 87 87 private method BuildCameraTab {} … … 105 105 private method GetVolumeInfo { w } 106 106 private method HideAllMarkers {} 107 private method AddNewMarker { x y }108 107 private method InitComponentSettings { cname } 109 108 private method InitSettings { args } … … 118 117 private method ReceiveImage { args } 119 118 private method ReceiveLegend { tf vmin vmax size } 119 private method RemoveMarker { x y } 120 120 private method ResetColormap { cname color } 121 121 private method Rotate {option x y} 122 122 private method SendTransferFunctions {} 123 private method SetObjectStyle { dataobj cname } 123 124 private method SetOrientation { side } 124 125 private method Slice {option args} 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..1 151 private variable _settings 150 private variable _transferFunctionEditors 151 private variable _settings 152 private variable _alphamap 153 private variable _widget 154 152 155 private variable _first "" ; # This is the topmost volume. 153 156 private variable _current ""; # Currently selected component … … 208 211 -qy 0.353553 209 212 -qz 0.146447 210 -zoom 1.0211 213 -xpan 0 212 214 -ypan 0 215 -zoom 1.0 213 216 } 214 217 set _arcball [blt::arcball create 100 100] … … 219 222 220 223 array set _settings { 221 -background black222 -ambient 60223 224 -axesvisible 1 224 - colormap default225 -c utplanevisible 0226 - diffuse 40225 -background black 226 -colormap "default" 227 -cutplanesvisible 0 227 228 -gridvisible 0 228 229 -isosurfaceshading 0 229 230 -legendvisible 1 231 -light 40 230 232 -light2side 1 231 -opacity 50232 233 -outlinevisible 0 233 234 -qw 0.853553 … … 235 236 -qy 0.353553 236 237 -qz 0.146447 237 -specularexponent 90238 -specularlevel 30239 238 -thickness 350 240 239 -volume 1 240 -volumeopacity 0.5 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 } 252 252 array set _widget { 253 -volumeopacity 50 254 } 253 255 itk_component add 3dview { 254 256 label $itk_component(plotarea).view -image $_image(plot) \ … … 557 559 # ---------------------------------------------------------------------- 558 560 itcl::body Rappture::NanovisViewer::scale {args} { 559 array set style {560 -color BCGYR561 -levels 6562 -markers ""561 array set styles { 562 -color BCGYR 563 -levels 6 564 -markers "" 563 565 } 564 566 array unset _limits … … 571 573 if { ![info exists _volcomponents($cname)] } { 572 574 lappend _componentsList $cname 573 array set style [lindex [$dataobj components -style $cname] 0]574 set cmap [ColorsToColormap $style (-color)]575 array set styles [lindex [$dataobj components -style $cname] 0] 576 set cmap [ColorsToColormap $styles(-color)] 575 577 set _cname2defaultcolormap($cname) $cmap 576 set _settings($cname-colormap) $style (-color)578 set _settings($cname-colormap) $styles(-color) 577 579 } 578 580 lappend _volcomponents($cname) $dataobj-$cname … … 674 676 set session $env(SESSION) 675 677 } 678 lappend info "version" "$Rappture::version" 679 lappend info "build" "$Rappture::build" 680 lappend info "svnurl" "$Rappture::svnurl" 681 lappend info "installdir" "$Rappture::installdir" 676 682 lappend info "hub" [exec hostname] 677 683 lappend info "client" "nanovisviewer" … … 721 727 # ---------------------------------------------------------------------- 722 728 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 729 foreach cname [array names _volcomponents] { 748 730 ComputeTransferFunction $cname … … 803 785 804 786 foreach {min max} $_limits($cname) break 805 $c itemconfigure vmin -text [format % .2g $min]787 $c itemconfigure vmin -text [format %g $min] 806 788 $c coords vmin $lx $ly 807 789 808 $c itemconfigure vmax -text [format % .2g $max]790 $c itemconfigure vmax -text [format %g $max] 809 791 $c coords vmax [expr {$w-$lx}] $ly 810 792 … … 818 800 819 801 # The colormap may have changed. Resync the slicers with the colormap. 820 set datasets [CurrentDatasets -cutplanes] 821 822 # Adjust the cutplane for only the first component in the topmost volume 823 # (i.e. the first volume designated in the field). 824 set tag [lindex $datasets 0] 825 foreach axis {x y z} { 826 # Turn off cutplanes for all volumes 827 SendCmd "cutplane state 0 $axis" 828 if { $_settings(-${axis}cutplanevisible) } { 829 # Turn on cutplane for this particular volume and set the position 830 SendCmd "cutplane state 1 $axis $tag" 831 set pos [expr {0.01*$_settings(-${axis}cutplaneposition)}] 832 SendCmd "cutplane position $pos $axis $tag" 833 } 834 } 802 InitSettings -cutplanesvisible -xcutplanevisible -ycutplanevisible \ 803 -zcutplanevisible 835 804 } 836 805 … … 932 901 DoResize 933 902 } 903 934 904 foreach dataobj [get] { 935 905 foreach cname [$dataobj components] { … … 942 912 } 943 913 set data [$dataobj blob $cname] 944 if 0 {945 set f [open "/tmp/values-$cname.txt" "w"]946 puts $f [$dataobj values $cname]947 close $f948 }949 914 } else { 950 915 set data [$dataobj vtkdata $cname] … … 972 937 set _serverDatasets($tag) 0 973 938 } 974 NameTransferFunction $dataobj $cname 975 } 976 } 939 SetObjectStyle $dataobj $cname 940 } 941 } 942 943 # Outline seems to need to be reset every update. 944 InitSettings -outlinevisible -cutplanesvisible -current 945 977 946 set _first [lindex [get] 0] 978 947 if { $_reset } { … … 994 963 PanCamera 995 964 SendCmd "camera zoom $_view(-zoom)" 996 965 966 #cutplane state 0 all 997 967 foreach axis {x y z} { 998 968 # Turn off cutplanes for all volumes … … 1000 970 } 1001 971 1002 InitSettings -light2side -ambient -diffuse -specularlevel \ 1003 -specularexponent -opacity -isosurfaceshading -gridvisible \ 1004 -axesvisible -xcutplanevisible -ycutplanevisible -zcutplanevisible \ 1005 -current 972 InitSettings -light2side -light -volumeopacity \ 973 -isosurfaceshading -gridvisible -axesvisible \ 1006 974 1007 975 if {"" != $_first} { … … 1016 984 } 1017 985 } 1018 # Outline seems to need to be reset every update. 1019 InitSettings -outlinevisible -cutplanesvisible 986 1020 987 # nothing to send -- activate the proper ivol 1021 988 SendCmd "volume state 0" … … 1055 1022 set tag $_first-$cname 1056 1023 if { [info exists _serverDatasets($tag)] && $_serverDatasets($tag) } { 1057 array set style {1024 array set styles { 1058 1025 -cutplanes 1 1059 1026 } 1060 array set style [lindex [$_first components -style $cname] 0]1061 if { $what != "-cutplanes" || $style (-cutplanes) } {1027 array set styles [lindex [$_first components -style $cname] 0] 1028 if { $what != "-cutplanes" || $styles(-cutplanes) } { 1062 1029 lappend rlist $tag 1063 1030 } … … 1093 1060 -qy 0.353553 1094 1061 -qz 0.146447 1062 -xpan 0 1063 -ypan 0 1095 1064 -zoom 1.0 1096 -xpan 01097 -ypan 01098 1065 } 1099 1066 if { $_first != "" } { … … 1249 1216 } 1250 1217 switch -- $what { 1251 "-current" { 1252 set cname [$itk_component(volcomponents) value] 1253 SwitchComponent $cname 1218 "-axesvisible" { 1219 SendCmd "axis visible $_settings($what)" 1254 1220 } 1255 1221 "-background" { … … 1264 1230 DrawLegend $_current 1265 1231 } 1266 "-ambient" {1267 # Other parts of the code use the ambient setting to1268 # tell if the component settings have been initialized1269 if { ![info exists _settings($_current${what})] } {1270 InitComponentSettings $_current1271 }1272 set _settings($_current${what}) $_settings($what)1273 set val $_settings($what)1274 set val [expr {0.01*$val}]1275 foreach tag [GetDatasetsWithComponent $_current] {1276 SendCmd "volume shading ambient $val $tag"1277 }1278 }1279 "-diffuse" {1280 set _settings($_current${what}) $_settings($what)1281 set val $_settings($what)1282 set val [expr {0.01*$val}]1283 foreach tag [GetDatasetsWithComponent $_current] {1284 SendCmd "volume shading diffuse $val $tag"1285 }1286 }1287 "-specularlevel" {1288 set _settings($_current${what}) $_settings($what)1289 set val $_settings($what)1290 set val [expr {0.01*$val}]1291 foreach tag [GetDatasetsWithComponent $_current] {1292 SendCmd "volume shading specularLevel $val $tag"1293 }1294 }1295 "-specularexponent" {1296 set _settings($_current${what}) $_settings($what)1297 set val $_settings($what)1298 foreach tag [GetDatasetsWithComponent $_current] {1299 SendCmd "volume shading specularExp $val $tag"1300 }1301 }1302 "-light2side" {1303 set _settings($_current${what}) $_settings($what)1304 set val $_settings($what)1305 foreach tag [GetDatasetsWithComponent $_current] {1306 SendCmd "volume shading light2side $val $tag"1307 }1308 }1309 "-opacity" {1310 set _settings($_current${what}) $_settings($what)1311 set val $_settings($what)1312 set sval [expr { 0.01 * double($val) }]1313 foreach tag [GetDatasetsWithComponent $_current] {1314 SendCmd "volume shading opacity $sval $tag"1315 }1316 }1317 "-thickness" {1318 set val $_settings($what)1319 set _settings($_current${what}) $val1320 updateTransferFunctions1321 }1322 "-outlinevisible" {1323 SendCmd "volume outline state $_settings($what)"1324 }1325 "-outlinecolor" {1326 set rgb [Color2RGB $_settings($what)]1327 SendCmd "volume outline color $rgb"1328 }1329 "-isosurfaceshading" {1330 SendCmd "volume shading isosurface $_settings($what)"1331 }1332 1232 "-colormap" { 1333 1233 set color [$itk_component(colormap) value] … … 1336 1236 ResetColormap $_current $color 1337 1237 } 1238 "-current" { 1239 set cname [$itk_component(volcomponents) value] 1240 SwitchComponent $cname 1241 } 1242 "-cutplanesvisible" { 1243 set bool $_settings($what) 1244 # We only set cutplanes on the first dataset. 1245 set datasets [CurrentDatasets -cutplanes] 1246 set tag [lindex $datasets 0] 1247 if { $bool } { 1248 foreach axis { x y z } { 1249 if { $_settings(-${axis}cutplanevisible) } { 1250 SendCmd "cutplane state 1 $axis $tag" 1251 } 1252 } 1253 } else { 1254 foreach axis { x y z } { 1255 SendCmd "cutplane state 0 $axis $tag" 1256 } 1257 } 1258 } 1338 1259 "-gridvisible" { 1339 1260 SendCmd "grid visible $_settings($what)" 1340 1261 } 1341 "- axesvisible" {1342 SendCmd " axis visible $_settings($what)"1262 "-isosurfaceshading" { 1263 SendCmd "volume shading isosurface $_settings($what)" 1343 1264 } 1344 1265 "-legendvisible" { … … 1351 1272 blt::table forget $itk_component(legend) 1352 1273 } 1274 } 1275 "-light" { 1276 set _settings($_current${what}) $_settings($what) 1277 set val $_settings($what) 1278 set diffuse [expr {0.01*$val}] 1279 set ambient [expr {1.0-$diffuse}] 1280 set specularLevel 0.3 1281 set specularExp 90.0 1282 foreach tag [GetDatasetsWithComponent $_current] { 1283 SendCmd "volume shading ambient $ambient $tag" 1284 SendCmd "volume shading diffuse $diffuse $tag" 1285 SendCmd "volume shading specularLevel $specularLevel $tag" 1286 SendCmd "volume shading specularExp $specularExp $tag" 1287 } 1288 } 1289 "-light2side" { 1290 set _settings($_current${what}) $_settings($what) 1291 set val $_settings($what) 1292 foreach tag [GetDatasetsWithComponent $_current] { 1293 SendCmd "volume shading light2side $val $tag" 1294 } 1295 } 1296 "-outlinevisible" { 1297 SendCmd "volume outline state $_settings($what)" 1298 } 1299 "-thickness" { 1300 set val $_settings($what) 1301 set _settings($_current${what}) $val 1302 updateTransferFunctions 1353 1303 } 1354 1304 "-volume" { … … 1365 1315 set _settings(-volumevisible) $bool 1366 1316 } 1317 "-volumeopacity" { 1318 set _settings($what) [expr $_widget($what) * 0.01] 1319 set _settings($_current${what}) $_settings($what) 1320 1321 foreach {cmap wmap} $_cname2transferFunction($_current) break 1322 set wmap [ComputeAlphamap $_current] 1323 set _cname2transferFunction($_current) [list $cmap $wmap] 1324 SendCmd [list transfunc define $_current $cmap $wmap] 1325 } 1367 1326 "-volumevisible" { 1368 1327 # This is the component specific control. It changes the … … 1373 1332 } 1374 1333 } 1375 "-cutplanesvisible" {1376 set bool $_settings($what)1377 set datasets [CurrentDatasets -cutplanes]1378 set tag [lindex $datasets 0]1379 SendCmd "cutplane visible $bool $tag"1380 }1381 1334 "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" { 1382 1335 set axis [string range $what 1 1] 1383 1336 set bool $_settings($what) 1337 # We only set cutplanes on the first dataset. 1384 1338 set datasets [CurrentDatasets -cutplanes] 1385 1339 set tag [lindex $datasets 0] 1386 SendCmd "cutplane state $bool $axis $tag" 1340 if { $_settings(-cutplanesvisible) } { 1341 SendCmd "cutplane state $bool $axis $tag" 1342 } 1387 1343 if { $bool } { 1388 1344 $itk_component(${axis}CutScale) configure -state normal \ … … 1428 1384 # 1429 1385 itcl::body Rappture::NanovisViewer::NameTransferFunction { dataobj cname } { 1430 array set style {1386 array set styles { 1431 1387 -color BCGYR 1432 1388 -levels 6 … … 1434 1390 } 1435 1391 set tag $dataobj-$cname 1436 array set style [lindex [$dataobj components -style $cname] 0]1392 array set styles [lindex [$dataobj components -style $cname] 0] 1437 1393 if { ![info exists _cname2transferFunction($cname)] } { 1438 1394 # Get the colormap right now, since it doesn't change with marker 1439 1395 # changes. 1440 set cmap [ColorsToColormap $style (-color)]1396 set cmap [ColorsToColormap $styles(-color)] 1441 1397 set wmap [list 0.0 0.0 1.0 1.0] 1442 1398 set _cname2transferFunction($cname) [list $cmap $wmap] … … 1474 1430 # reference. 1475 1431 if { ![info exists _parsedFunction($cname)] } { 1476 array set style {1432 array set styles { 1477 1433 -color BCGYR 1478 1434 -levels 6 … … 1482 1438 foreach tag [GetDatasetsWithComponent $cname] { 1483 1439 foreach {dataobj cname} [split [lindex $tag 0] -] break 1484 array set style [lindex [$dataobj components -style $cname] 0]1440 array set styles [lindex [$dataobj components -style $cname] 0] 1485 1441 } 1486 1442 eval $_transferFunctionEditors($cname) limits $_limits($cname) 1487 1443 # Have to defer creation of isomarkers until we have data limits 1488 if { [info exists style (-markers)] &&1489 [llength $style (-markers)] > 0 } {1490 ParseMarkersOption $cname $style (-markers)1444 if { [info exists styles(-markers)] && 1445 [llength $styles(-markers)] > 0 } { 1446 ParseMarkersOption $cname $styles(-markers) 1491 1447 } else { 1492 ParseLevelsOption $cname $style (-levels)1448 ParseLevelsOption $cname $styles(-levels) 1493 1449 } 1494 1450 … … 1734 1690 1735 1691 set font [option get $itk_component(hull) font Font] 1736 #set bfont [option get $itk_component(hull) boldFont Font]1737 1738 label $inner.lighting_l \ 1739 -text "Lighting / Material Properties"\1740 - font "Arial 9 bold"1741 1742 checkbutton $inner.light2side \1743 -text "Two-sided lighting" \ 1744 -font $font\1692 set fg [option get $itk_component(hull) font Font] 1693 #set bfg [option get $itk_component(hull) boldFont Font] 1694 1695 checkbutton $inner.vol -text "Show volume" -font $fg \ 1696 -variable [itcl::scope _settings(-volumevisible)] \ 1697 -command [itcl::code $this AdjustSetting -volumevisible] 1698 label $inner.shading -text "Shading:" -font $fg 1699 1700 checkbutton $inner.light2side -text "Two-sided lighting" -font $fg \ 1745 1701 -variable [itcl::scope _settings(-light2side)] \ 1746 1702 -command [itcl::code $this AdjustSetting -light2side] 1747 1703 1748 checkbutton $inner.visibility \ 1749 -text "Visible" \ 1750 -font $font \ 1751 -variable [itcl::scope _settings(-volumevisible)] \ 1752 -command [itcl::code $this AdjustSetting -volumevisible] \ 1753 1754 label $inner.ambient_l \ 1755 -text "Ambient" \ 1756 -font $font 1757 ::scale $inner.ambient -from 0 -to 100 -orient horizontal \ 1758 -variable [itcl::scope _settings(-ambient)] \ 1759 -showvalue off -command [itcl::code $this AdjustSetting -ambient] \ 1760 -troughcolor grey92 1761 1762 label $inner.diffuse_l -text "Diffuse" -font $font 1763 ::scale $inner.diffuse -from 0 -to 100 -orient horizontal \ 1764 -variable [itcl::scope _settings(-diffuse)] \ 1765 -showvalue off -command [itcl::code $this AdjustSetting -diffuse] \ 1766 -troughcolor grey92 1767 1768 label $inner.specularLevel_l -text "Specular" -font $font 1769 ::scale $inner.specularLevel -from 0 -to 100 -orient horizontal \ 1770 -variable [itcl::scope _settings(-specularlevel)] \ 1771 -showvalue off \ 1772 -command [itcl::code $this AdjustSetting -specularlevel] \ 1773 -troughcolor grey92 1774 1775 label $inner.specularExponent_l -text "Shininess" -font $font 1776 ::scale $inner.specularExponent -from 10 -to 128 -orient horizontal \ 1777 -variable [itcl::scope _settings(-specularexponent)] \ 1778 -showvalue off \ 1779 -command [itcl::code $this AdjustSetting -specularexponent] \ 1780 -troughcolor grey92 1781 1782 label $inner.opacity_l -text "Opacity" -font $font 1783 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1784 -variable [itcl::scope _settings(-opacity)] \ 1785 -showvalue off -command [itcl::code $this AdjustSetting -opacity] \ 1786 -troughcolor grey92 1787 1788 label $inner.transferfunction_l \ 1789 -text "Transfer Function" -font "Arial 9 bold" 1790 1791 label $inner.thin -text "Thin" -font $font 1704 label $inner.dim -text "Glow" -font $fg 1705 ::scale $inner.light -from 0 -to 100 -orient horizontal \ 1706 -variable [itcl::scope _settings(-light)] \ 1707 -width 10 \ 1708 -showvalue off -command [itcl::code $this AdjustSetting -light] 1709 label $inner.bright -text "Surface" -font $fg 1710 1711 # Opacity 1712 label $inner.fog -text "Clear" -font $fg 1713 ::scale $inner.transp -from 0 -to 100 -orient horizontal \ 1714 -variable [itcl::scope _widget(-volumeopacity)] \ 1715 -width 10 \ 1716 -showvalue off -command [itcl::code $this AdjustSetting -volumeopacity] 1717 label $inner.plastic -text "Opaque" -font $fg 1718 1719 # Tooth thickness 1720 label $inner.thin -text "Thin" -font $fg 1792 1721 ::scale $inner.thickness -from 0 -to 1000 -orient horizontal \ 1793 1722 -variable [itcl::scope _settings(-thickness)] \ 1794 - showvalue off -command [itcl::code $this AdjustSetting -thickness]\1795 - troughcolor grey921796 1797 label $inner.thick -text "Thick" -font $font 1798 1799 label $inner.colormap_l -text "Colormap" -font $font1723 -width 10 \ 1724 -showvalue off -command [itcl::code $this AdjustSetting -thickness] 1725 label $inner.thick -text "Thick" -font $fg 1726 1727 # Colormap 1728 label $inner.colormap_l -text "Colormap" -font "Arial 9" 1800 1729 itk_component add colormap { 1801 1730 Rappture::Combobox $inner.colormap -width 10 -editable no … … 1808 1737 set _settings(-colormap) "default" 1809 1738 1739 # Component 1810 1740 label $inner.volcomponents_l -text "Component" -font $font 1811 1741 itk_component add volcomponents { … … 1818 1748 0,0 $inner.volcomponents_l -anchor e -cspan 2 \ 1819 1749 0,2 $inner.volcomponents -cspan 3 -fill x \ 1820 1,1 $inner.lighting_l -anchor w -cspan 4 \ 1821 2,1 $inner.ambient_l -anchor e -pady 2 \ 1822 2,2 $inner.ambient -cspan 3 -fill x \ 1823 3,1 $inner.diffuse_l -anchor e -pady 2 \ 1824 3,2 $inner.diffuse -cspan 3 -fill x \ 1825 4,1 $inner.specularLevel_l -anchor e -pady 2 \ 1826 4,2 $inner.specularLevel -cspan 3 -fill x \ 1827 5,1 $inner.specularExponent_l -anchor e -pady 2 \ 1828 5,2 $inner.specularExponent -cspan 3 -fill x \ 1829 6,1 $inner.light2side -cspan 3 -anchor w \ 1830 7,1 $inner.visibility -cspan 3 -anchor w \ 1831 8,1 $inner.transferfunction_l -anchor w -cspan 4 \ 1832 9,1 $inner.opacity_l -anchor e -pady 2 \ 1833 9,2 $inner.opacity -cspan 3 -fill x \ 1834 10,1 $inner.colormap_l -anchor e \ 1835 10,2 $inner.colormap -padx 2 -cspan 3 -fill x \ 1836 11,1 $inner.thin -anchor e \ 1837 11,2 $inner.thickness -cspan 2 -fill x \ 1838 11,4 $inner.thick -anchor w 1839 1840 blt::table configure $inner c* r* -resize none 1841 blt::table configure $inner r* -pady { 2 0 } 1842 blt::table configure $inner c2 c3 r12 -resize expand 1843 blt::table configure $inner c0 -width .1i 1750 1,0 $inner.shading -cspan 4 -anchor w -pady {10 2} \ 1751 2,0 $inner.light2side -cspan 4 -anchor w -pady 2 \ 1752 3,0 $inner.dim -anchor e -pady 2 \ 1753 3,1 $inner.light -cspan 2 -pady 2 -fill x \ 1754 3,3 $inner.bright -anchor w -pady 2 \ 1755 4,0 $inner.fog -anchor e -pady 2 \ 1756 4,1 $inner.transp -cspan 2 -pady 2 -fill x \ 1757 4,3 $inner.plastic -anchor w -pady 2 \ 1758 5,0 $inner.thin -anchor e -pady 2 \ 1759 5,1 $inner.thickness -cspan 2 -pady 2 -fill x\ 1760 5,3 $inner.thick -anchor w -pady 2 1761 1762 blt::table configure $inner c0 c1 c3 r* -resize none 1763 blt::table configure $inner r6 -resize expand 1844 1764 } 1845 1765 … … 1855 1775 -command [itcl::code $this AdjustSetting -cutplanesvisible] \ 1856 1776 -font "Arial 9" 1857 1777 1858 1778 # X-value slicer... 1859 1779 itk_component add xCutButton { … … 1940 1860 1941 1861 blt::table $inner \ 1942 0,1 $inner.visible -anchor w -pady 2 -cspan 4 \ 1943 1,1 $itk_component(xCutScale) \ 1944 1,2 $itk_component(yCutScale) \ 1945 1,3 $itk_component(zCutScale) \ 1946 2,1 $itk_component(xCutButton) \ 1947 2,2 $itk_component(yCutButton) \ 1948 2,3 $itk_component(zCutButton) 1949 1950 blt::table configure $inner r0 r1 r2 c* -resize none 1951 blt::table configure $inner r3 c4 -resize expand 1862 1,1 $itk_component(xCutButton) \ 1863 1,2 $itk_component(yCutButton) \ 1864 1,3 $itk_component(zCutButton) \ 1865 0,1 $itk_component(xCutScale) \ 1866 0,2 $itk_component(yCutScale) \ 1867 0,3 $itk_component(zCutScale) 1868 1869 blt::table configure $inner r0 r1 c* -resize none 1870 blt::table configure $inner r2 c4 -resize expand 1952 1871 blt::table configure $inner c0 -width 2 1953 1872 blt::table configure $inner c1 c2 c3 -padx 2 … … 2180 2099 # InitComponentSettings -- 2181 2100 # 2182 # Initializes the volume settings for a specific component. This 2183 # should match what's used as global settings above. This 2184 # is called the first time we try to switch to a given component 2185 # in SwitchComponent below. 2101 # Initializes the volume settings for a specific component. This should 2102 # match what's used as global settings above. This is called the first 2103 # time we try to switch to a given component in SwitchComponent below. 2186 2104 # 2187 2105 itcl::body Rappture::NanovisViewer::InitComponentSettings { cname } { 2188 # Expanding component name for key. 2189 array set _settings [subst { 2190 $cname-ambient 60 2191 $cname-colormap default 2192 $cname-diffuse 40 2193 $cname-light2side 1 2194 $cname-opacity 50 2195 $cname-specularexponent 90 2196 $cname-specularlevel 30 2197 $cname-thickness 350 2198 $cname-volumevisible 1 2199 }] 2106 foreach {key value} { 2107 -colormap "default" 2108 -light 40 2109 -light2side 1 2110 -thickness 350 2111 -volumeopacity 1.0 2112 -volumevisible 1 2113 } { 2114 if { ![info exists _settings($cname${key})] } { 2115 # Don't override existing component settings 2116 set _settings($cname${key}) $value 2117 } 2118 } 2200 2119 } 2201 2120 … … 2203 2122 # SwitchComponent -- 2204 2123 # 2205 # This is called when the current component is changed by the2206 # dropdown menu in the volume tab. It synchronizes the global2207 # volume settingswith the settings of the new current component.2124 # This is called when the current component is changed by the dropdown 2125 # menu in the volume tab. It synchronizes the global volume settings 2126 # with the settings of the new current component. 2208 2127 # 2209 2128 itcl::body Rappture::NanovisViewer::SwitchComponent { cname } { 2210 if { ![info exists _settings($cname- ambient)] } {2129 if { ![info exists _settings($cname-light)] } { 2211 2130 InitComponentSettings $cname 2212 2131 } 2132 if { $_settings(-colormap) != $_settings($cname-colormap) } { 2133 set _settings(-colormap) $_settings($cname-colormap) 2134 EventuallyRedrawLegend 2135 } 2213 2136 # _settings variables change widgets, except for colormap 2214 set _settings(-ambient) $_settings($cname-ambient) 2215 set _settings(-colormap) $_settings($cname-colormap) 2216 set _settings(-diffuse) $_settings($cname-diffuse) 2137 set _settings(-light) $_settings($cname-light) 2217 2138 set _settings(-light2side) $_settings($cname-light2side) 2218 set _settings(-opacity) $_settings($cname-opacity) 2219 set _settings(-specularexponent) $_settings($cname-specularexponent) 2220 set _settings(-specularlevel) $_settings($cname-specularlevel) 2139 set _settings(-volumeopacity) $_settings($cname-volumeopacity) 2221 2140 set _settings(-thickness) $_settings($cname-thickness) 2222 2141 set _settings(-volumevisible) $_settings($cname-volumevisible) 2223 2142 $itk_component(colormap) value $_settings($cname-colormap) 2143 2144 set _widget(-volumeopacity) [expr $_settings(-volumeopacity) * 100.0] 2145 2224 2146 set _current $cname; # Reset the current component 2225 2147 } … … 2228 2150 # BuildVolumeComponents -- 2229 2151 # 2230 # This is called from the "scale" method which is called when a2231 # new dataset is added or deleted. It repopulates the dropdown2232 # menu of volume component names. It sets the current component2233 # to the first component in the list (of components found).2234 # Finally, if there is only one component, don't displaythe2235 # label or the combobox in thevolume settings tab.2152 # This is called from the "scale" method which is called when a new 2153 # dataset is added or deleted. It repopulates the dropdown menu of 2154 # volume component names. It sets the current component to the first 2155 # component in the list (of components found). Finally, if there is 2156 # only one component, don't display the label or the combobox in the 2157 # volume settings tab. 2236 2158 # 2237 2159 itcl::body Rappture::NanovisViewer::BuildVolumeComponents {} { … … 2259 2181 # GetDatasetsWithComponents -- 2260 2182 # 2261 # Returns a list of all the datasets (known by the combination of2262 # their data object and component name) that match the given2263 # component name. For example, this is used where we want to change2264 # the settings ofvolumes that have the current component.2183 # Returns a list of all the datasets (known by the combination of their 2184 # data object and component name) that match the given component name. 2185 # For example, this is used where we want to change the settings of 2186 # volumes that have the current component. 2265 2187 # 2266 2188 itcl::body Rappture::NanovisViewer::GetDatasetsWithComponent { cname } { … … 2281 2203 # HideAllMarkers -- 2282 2204 # 2283 # Hide all the markers in all the transfer functions. Can't simply2284 # delete and recreate markers from the <style> since the user may2285 # havecreate, deleted, or moved markers.2205 # Hide all the markers in all the transfer functions. Can't simply 2206 # delete and recreate markers from the <style> since the user may have 2207 # create, deleted, or moved markers. 2286 2208 # 2287 2209 itcl::body Rappture::NanovisViewer::HideAllMarkers {} { … … 2321 2243 return [list 0.0 0.0 1.0 1.0] 2322 2244 } 2323 if { ![info exists _settings($cname- ambient)] } {2245 if { ![info exists _settings($cname-light)] } { 2324 2246 InitComponentSettings $cname 2325 2247 } … … 2328 2250 2329 2251 # Currently using volume shading opacity to scale opacity in 2330 # the volume shader. The transfer function always sets full 2331 # opacity 2332 set max 1.0 2252 # the volume shader. 2253 set max $_settings($cname-volumeopacity) 2333 2254 2334 2255 # Use the component-wise thickness setting from the slider … … 2549 2470 } 2550 2471 2551 2472 itcl::body Rappture::NanovisViewer::SetObjectStyle { dataobj cname } { 2473 array set styles { 2474 -opacity 0.6 2475 } 2476 array set styles [lindex [$dataobj components -style $cname] 0] 2477 set _settings($cname-volumeopacity) $styles(-opacity) 2478 NameTransferFunction $dataobj $cname 2479 } -
branches/r9/gui/scripts/resultselector.tcl
r4214 r4919 1295 1295 foreach col [lrange [$_resultset diff names] 1 end] { 1296 1296 set quantity $_cntlInfo($this-$col-label) 1297 set val [lindex [$_resultset get $col $xmlobj] 0] 1297 1298 # Don't know why this was being treated as a list. 1299 #set val [lindex [$_resultset get $col $xmlobj] 0] 1300 1301 set val [$_resultset get $col $xmlobj] 1298 1302 append desc "$quantity = $val\n" 1299 1303 } -
branches/r9/gui/scripts/transferfunctioneditor.tcl
r4121 r4919 199 199 set absval [GetAbsoluteValue $name] 200 200 set y 31 201 $_canvas itemconfigure $_labels($name) -text [format % .2g $absval]201 $_canvas itemconfigure $_labels($name) -text [format %g $absval] 202 202 $_canvas coords $_ticks($name) $x [expr {$y+3}] 203 203 $_canvas coords $_labels($name) $x [expr {$y+5}] … … 215 215 set _values($name) $relval 216 216 set y 31 217 $_canvas itemconfigure $_label -text [format % .2g $absval]217 $_canvas itemconfigure $_label -text [format %g $absval] 218 218 set x [GetScreenPosition $name] 219 219 $_canvas coords $_ticks($name) $x [expr {$y+3}] … … 231 231 set y 31 232 232 set absval [GetAbsoluteValue $name] 233 $_canvas itemconfigure $_labels($name) -text [format % .2g $absval]233 $_canvas itemconfigure $_labels($name) -text [format %g $absval] 234 234 $_canvas coords $_ticks($name) $x [expr {$y+3}] 235 235 $_canvas coords $_labels($name) $x [expr {$y+5}] -
branches/r9/gui/scripts/unirect2d.tcl
r4030 r4919 176 176 # ---------------------------------------------------------------------- 177 177 # method blob 178 # Returns a base64 encoded, gzipped Tcl list that represents the 179 # Tcl command and data to recreate the uniform rectangular grid 180 # on the nanovis server. 178 # Returns a Tcl list that represents the Tcl command and data to 179 # recreate the uniform rectangular grid on the nanovis server. 181 180 # ---------------------------------------------------------------------- 182 181 itcl::body Rappture::Unirect2d::blob {} { … … 184 183 lappend data "xmin" $_xMin "xmax" $_xMax "xnum" $_xNum 185 184 lappend data "ymin" $_yMin "ymax" $_yMax "ynum" $_yNum 186 lappend data "xmin" $_xMin "ymin" $_yMin "xmax" $_xMax "ymax" $_yMax187 185 return $data 188 186 } … … 190 188 # ---------------------------------------------------------------------- 191 189 # method mesh 192 # Returns a base64 encoded, gzipped Tcl list that represents the 193 # Tcl command and data to recreate the uniform rectangular grid 194 # on the nanovis server. 190 # Returns a Tcl list that represents the mesh limits and dims. 195 191 # ---------------------------------------------------------------------- 196 192 itcl::body Rappture::Unirect2d::mesh {} { -
branches/r9/gui/scripts/unirect3d.tcl
r4030 r4919 41 41 private variable _xMax 0 42 42 private variable _xMin 0 43 private variable _xNum 0; # Number of points along x-axis .43 private variable _xNum 0; # Number of points along x-axis 44 44 private variable _yMax 0 45 45 private variable _yMin 0 46 private variable _yNum 0; # Number of points along y-axis .46 private variable _yNum 0; # Number of points along y-axis 47 47 private variable _zMax 0 48 48 private variable _zMin 0 49 private variable _zNum 0; # Number of points along z-axis .50 private variable _compNum 1; # Number of components in values .51 private variable _values ""; # BLT vector containing the z-values49 private variable _zNum 0; # Number of points along z-axis 50 private variable _compNum 1; # Number of components in values 51 private variable _values ""; # BLT vector containing the values 52 52 private variable _hints 53 53 } … … 124 124 # ---------------------------------------------------------------------- 125 125 # method blob 126 # Returns a base64 encoded, gzipped Tcl list that represents the 127 # Tcl command and data to recreate the uniform rectangular grid 128 # on the nanovis server. 126 # Returns a Tcl list that represents the Tcl command and data to 127 # recreate the uniform rectangular grid on the nanovis server. 129 128 # ---------------------------------------------------------------------- 130 129 itcl::body Rappture::Unirect3d::blob {} { … … 142 141 # ---------------------------------------------------------------------- 143 142 # method mesh 144 # Returns a base64 encoded, gzipped Tcl list that represents the 145 # Tcl command and data to recreate the uniform rectangular grid 146 # on the nanovis server. 143 # Returns a Tcl list that represents the points of the uniform 144 # grid. 147 145 # ---------------------------------------------------------------------- 148 146 itcl::body Rappture::Unirect3d::mesh {} { … … 166 164 # ---------------------------------------------------------------------- 167 165 # method values 168 # Returns a base64 encoded, gzipped Tcl list that represents the 169 # Tcl command and data to recreate the uniform rectangular grid 170 # on the nanovis server. 166 # Returns a Tcl list that represents the field values 171 167 # ---------------------------------------------------------------------- 172 168 itcl::body Rappture::Unirect3d::values {} { … … 179 175 # ---------------------------------------------------------------------- 180 176 # method valuesObj 181 # Returns a base64 encoded, gzipped Tcl list that represents the 182 # Tcl command and data to recreate the uniform rectangular grid 183 # on the nanovis server. 177 # Returns a BLT vector that represents the field values 184 178 # ---------------------------------------------------------------------- 185 179 itcl::body Rappture::Unirect3d::valuesObj {} { -
branches/r9/gui/scripts/visviewer.tcl
r4336 r4919 37 37 private variable _icon 0 38 38 39 # Number of milliseconds to wait before idle timeout. If greater than 40 # 0, automatically disconnect from the visualization server when idle41 # timeoutis reached.39 # Number of milliseconds to wait before idle timeout. If greater than 0, 40 # automatically disconnect from the visualization server when idle timeout 41 # is reached. 42 42 private variable _idleTimeout 43200000; # 12 hours 43 43 #private variable _idleTimeout 5000; # 5 seconds … … 284 284 if { [gets $_sid data] <= 0 } { 285 285 set _sid "" 286 puts stderr "reading from server data=($data)"286 puts stderr "reading from server" 287 287 RemoveServerFromList $_serverType $server 288 288 continue … … 454 454 set _done($this) 1 455 455 set _buffer(out) $bytes 456 if {1} { 457 # Let's try this approach: allow a write to block so we don't 458 # re-enter SendBytes 459 SendHelper 460 } else { 461 # This can cause us to re-enter SendBytes during the tkwait, which 462 # is not safe because the _buffer will be clobbered 463 fileevent $_sid writable [itcl::code $this SendHelper] 464 tkwait variable ::Rappture::VisViewer::_done($this) 465 } 456 457 # There's problem when the user is interacting with the GUI at the 458 # same time we're trying to write to the server. Don't want to 459 # block because, the GUI will look like it's dead. We can start 460 # by putting a busy window over plot so that inadvertent things like 461 # mouse movements aren't received. 462 463 blt::busy hold $itk_component(main) 464 fileevent $_sid writable [itcl::code $this SendHelper] 465 tkwait variable ::Rappture::VisViewer::_done($this) 466 blt::busy release $itk_component(main) 467 466 468 set _buffer(out) "" 467 469 if { [IsConnected] } { 468 # The connection may have closed while we were writing to the 469 # server. This can happen if what we sent the server caused it to 470 # barf. 470 # The connection may have closed while we were writing to the server. 471 # This can happen if what we sent the server caused it to barf. 471 472 fileevent $_sid writable "" 472 473 flush $_sid … … 518 519 # Helper routine called from a file event when the connection is readable 519 520 # (i.e. a command response has been sent by the rendering server. Reads 520 # the incoming command and executes it in a safe interpreter to handle 521 # theaction.521 # the incoming command and executes it in a safe interpreter to handle the 522 # action. 522 523 # 523 524 # Note: This routine currently only handles command responses from … … 601 602 # SendEcho -- 602 603 # 603 # Used internally to echo sent data to clients interested in this 604 # widget. If the -sendcommand opti on is set, then it is invoked in605 # the global scope with the <channel> and <data> values as arguments.606 # Otherwise, this doesnothing.604 # Used internally to echo sent data to clients interested in this widget. 605 # If the -sendcommand option is set, then it is invoked in the global scope 606 # with the <channel> and <data> values as arguments. Otherwise, this does 607 # nothing. 607 608 # 608 609 itcl::body Rappture::VisViewer::SendEcho {channel {data ""}} { 609 610 if { $_logging } { 610 set f [open "/tmp/recording.log" "a"] 611 puts $f $data 612 close $f 611 set f [open "/tmp/recording.log" "a"] 612 fconfigure $f -translation binary -encoding binary 613 puts -nonewline $f $data 614 close $f 613 615 } 614 616 #puts stderr ">>($data)" … … 1135 1137 } 1136 1138 } 1137 #regsub -all "\n" $cmap " " cmap1138 1139 return $cmap 1139 1140 } … … 1152 1153 # 1153 1154 # StopBufferingCommands -- 1155 # 1156 # This gets called when we want to stop buffering the commands for 1157 # the server and actually send then to the server. Note that there's 1158 # a reference count on buffering. This is so that you can can 1159 # Start/Stop multiple times without worrying about the current state. 1154 1160 # 1155 1161 itcl::body Rappture::VisViewer::StopBufferingCommands { } { -
branches/r9/gui/scripts/vtkglyphviewer.tcl
r4344 r4919 118 118 # heightmaps displayed. 119 119 private variable _currentColormap "" 120 private variable _currentOpacity ""121 120 122 121 private variable _dataset2style ;# maps dataobj-component to transfunc … … 183 182 $_dispatcher register !xcutplane 184 183 $_dispatcher dispatch $this !xcutplane \ 185 "[itcl::code $this AdjustSetting cutplaneXPosition]; list"184 "[itcl::code $this AdjustSetting -cutplanexposition]; list" 186 185 187 186 # Y-Cutplane event 188 187 $_dispatcher register !ycutplane 189 188 $_dispatcher dispatch $this !ycutplane \ 190 "[itcl::code $this AdjustSetting cutplaneYPosition]; list"189 "[itcl::code $this AdjustSetting -cutplaneyposition]; list" 191 190 192 191 # Z-Cutplane event 193 192 $_dispatcher register !zcutplane 194 193 $_dispatcher dispatch $this !zcutplane \ 195 "[itcl::code $this AdjustSetting cutplaneZPosition]; list"194 "[itcl::code $this AdjustSetting -cutplanezposition]; list" 196 195 197 196 # … … 218 217 219 218 array set _settings [subst { 220 background black 221 colormap BCGYR 222 colormapVisible 1 223 field "Default" 224 axesVisible 1 225 axisLabelsVisible 1 226 axisXGrid 0 227 axisYGrid 0 228 axisZGrid 0 229 cutplaneEdges 0 230 cutplaneLighting 1 231 cutplanePreinterp 1 232 cutplaneOpacity 100 233 cutplaneVisible 0 234 cutplaneWireframe 0 235 cutplaneXPosition 50 236 cutplaneXVisible 1 237 cutplaneYPosition 50 238 cutplaneYVisible 1 239 cutplaneZPosition 50 240 cutplaneZVisible 1 241 glyphEdges 0 242 glyphLighting 1 243 glyphNormscale 1 244 glyphOpacity 100 245 saveGlyphOpacity 100 246 glyphOrient 1 247 glyphOutline 0 248 glyphScale 1 249 glyphScaleMode "vmag" 250 glyphShape "arrow" 251 glyphVisible 1 252 glyphWireframe 0 253 legendVisible 1 219 -axesvisible 1 220 -axislabels 1 221 -axisminorticks 1 222 -axismode "static" 223 -background black 224 -colormap BCGYR 225 -colormapvisible 1 226 -cutplaneedges 0 227 -cutplanelighting 1 228 -cutplanepreinterp 1 229 -cutplaneopacity 100 230 -cutplanevisible 0 231 -cutplanewireframe 0 232 -cutplanexposition 50 233 -cutplanexvisible 1 234 -cutplaneyposition 50 235 -cutplaneyvisible 1 236 -cutplanezposition 50 237 -cutplanezvisible 1 238 -field "Default" 239 -glyphedges 0 240 -glyphlighting 1 241 -glyphopacity 100 242 -glyphoutline 0 243 -glyphscale 1 244 -glyphvisible 1 245 -glyphwireframe 0 246 -legendvisible 1 247 -saveglyphopacity 100 248 -xgrid 0 249 -ygrid 0 250 -zgrid 0 254 251 }] 255 252 array set _changed { 256 glyphOpacity0257 colormap0253 -colormap 0 254 -glyphopacity 0 258 255 } 259 256 … … 335 332 -onimage [Rappture::icon volume-on] \ 336 333 -offimage [Rappture::icon volume-off] \ 337 -variable [itcl::scope _settings( glyphVisible)] \338 -command [itcl::code $this AdjustSetting glyphVisible]334 -variable [itcl::scope _settings(-glyphvisible)] \ 335 -command [itcl::code $this AdjustSetting -glyphvisible] 339 336 } 340 337 $itk_component(glyphs) select … … 348 345 -onimage [Rappture::icon cutbutton] \ 349 346 -offimage [Rappture::icon cutbutton] \ 350 -variable [itcl::scope _settings( cutplaneVisible)] \351 -command [itcl::code $this AdjustSetting cutplaneVisible]347 -variable [itcl::scope _settings(-cutplanevisible)] \ 348 -command [itcl::code $this AdjustSetting -cutplanevisible] 352 349 } 353 350 Rappture::Tooltip::for $itk_component(cutplane) \ … … 439 436 eval itk_initialize $args 440 437 Connect 441 update442 438 } 443 439 … … 547 543 } 548 544 549 550 545 # ---------------------------------------------------------------------- 551 546 # USAGE: delete ?<dataobj1> <dataobj2> ...? 552 547 # 553 # 554 # 555 # 548 # Clients use this to delete a dataobj from the plot. If no dataobjs 549 # are specified, then all dataobjs are deleted. No data objects are 550 # deleted. They are only removed from the display list. 556 551 # 557 552 # ---------------------------------------------------------------------- … … 782 777 set session $env(SESSION) 783 778 } 779 lappend info "version" "$Rappture::version" 780 lappend info "build" "$Rappture::build" 781 lappend info "svnurl" "$Rappture::svnurl" 782 lappend info "installdir" "$Rappture::installdir" 784 783 lappend info "hub" [exec hostname] 785 784 lappend info "client" "vtkglyphviewer" … … 799 798 # isconnected -- 800 799 # 801 # 800 # Indicates if we are currently connected to the visualization server. 802 801 # 803 802 itcl::body Rappture::VtkGlyphViewer::isconnected {} { … … 816 815 # Disconnect -- 817 816 # 818 # 819 # 817 # Clients use this method to disconnect from the current rendering 818 # server. 820 819 # 821 820 itcl::body Rappture::VtkGlyphViewer::Disconnect {} { … … 955 954 PanCamera 956 955 set _first "" 957 InitSettings axisXGrid axisYGrid axisZGrid axisMode \958 axesVisible axisLabelsVisible956 InitSettings -xgrid -ygrid -zgrid -axismode \ 957 -axesvisible -axislabels -axisminorticks 959 958 foreach axis { x y z } { 960 959 SendCmd "axis lformat $axis %g" … … 975 974 if { ![info exists _datasets($tag)] } { 976 975 set bytes [$dataobj vtkdata $comp] 977 978 979 980 976 if 0 { 977 set f [open "/tmp/glyph.vtk" "w"] 978 puts $f $bytes 979 close $f 981 980 } 982 981 set length [string length $bytes] … … 992 991 SendCmd "clientinfo [list $info]" 993 992 } 994 append _outbuf "dataset add $tag data follows $length\n"993 SendCmd "dataset add $tag data follows $length" 995 994 append _outbuf $bytes 996 995 set _datasets($tag) 1 … … 1001 1000 # Setting dataset visible enables outline 1002 1001 # and glyphs 1003 1002 SendCmd "dataset visible 1 $tag" 1004 1003 } 1005 1004 } … … 1007 1006 1008 1007 if { $_first != "" } { 1009 1010 1011 1008 $itk_component(field) choices delete 0 end 1009 $itk_component(fieldmenu) delete 0 end 1010 array unset _fields 1012 1011 set _curFldName "" 1013 1012 foreach cname [$_first components] { … … 1035 1034 $itk_component(field) value $_curFldLabel 1036 1035 } 1037 InitSettings glyphOutline1038 # cutplaneVisible1036 InitSettings -glyphoutline 1037 #-cutplanevisible 1039 1038 if { $_reset } { 1040 1039 # These are settings that rely on a dataset being loaded. 1041 1040 InitSettings \ 1042 glyphLighting \1043 field \1044 glyphEdges glyphLighting glyphOpacity \1045 glyphWireframe1046 1047 # cutplaneXPosition cutplaneYPosition cutplaneZPosition \1048 cutplaneXVisible cutplaneYVisible cutplaneZVisible \1049 cutplanePreinterp1041 -glyphlighting \ 1042 -field \ 1043 -glyphedges -glyphlighting -glyphopacity \ 1044 -glyphwireframe 1045 1046 #-cutplanexposition -cutplaneyposition -cutplanezposition \ 1047 -cutplanexvisible -cutplaneyvisible -cutplanezvisible \ 1048 -cutplanepreinterp 1050 1049 1051 1050 Zoom reset 1052 1051 foreach axis { x y z } { 1053 1052 # Another problem fixed by a <view>. We looking into a data 1054 1053 # object for the name of the axes. This should be global to 1055 1054 # the viewer itself. 1056 1057 1055 set label [$_first hints ${axis}label] 1056 if { $label == "" } { 1058 1057 set label [string toupper $axis] 1059 1060 1061 1058 } 1059 # May be a space in the axis label. 1060 SendCmd [list axis name $axis $label] 1062 1061 } 1063 1062 if { [array size _fields] < 2 } { 1064 blt::table forget $itk_component(field) $itk_component(field_l)1063 catch {blt::table forget $itk_component(field) $itk_component(field_l)} 1065 1064 } 1066 1065 set _reset 0 … … 1166 1165 SendCmd "camera pan $x $y" 1167 1166 } 1168 1169 1167 1170 1168 # ---------------------------------------------------------------------- … … 1287 1285 itcl::body Rappture::VtkGlyphViewer::InitSettings { args } { 1288 1286 foreach spec $args { 1289 if { [info exists _settings($_first -$spec)] } {1287 if { [info exists _settings($_first${spec})] } { 1290 1288 # Reset global setting with dataobj specific setting 1291 set _settings($spec) $_settings($_first -$spec)1289 set _settings($spec) $_settings($_first${spec}) 1292 1290 } 1293 1291 AdjustSetting $spec … … 1298 1296 # AdjustSetting -- 1299 1297 # 1300 # 1301 # 1302 # 1298 # Changes/updates a specific setting in the widget. There are 1299 # usually user-setable option. Commands are sent to the render 1300 # server. 1303 1301 # 1304 1302 itcl::body Rappture::VtkGlyphViewer::AdjustSetting {what {value ""}} { … … 1307 1305 } 1308 1306 switch -- $what { 1309 " background" {1307 "-background" { 1310 1308 set bgcolor [$itk_component(background) value] 1311 1312 1313 1314 "grey""black"1315 1309 array set fgcolors { 1310 "black" "white" 1311 "white" "black" 1312 "grey" "black" 1313 } 1316 1314 configure -plotbackground $bgcolor \ 1317 1318 1319 1320 } 1321 " axesVisible" {1322 set bool $_settings( axesVisible)1315 -plotforeground $fgcolors($bgcolor) 1316 $itk_component(view) delete "legend" 1317 DrawLegend 1318 } 1319 "-axesvisible" { 1320 set bool $_settings($what) 1323 1321 SendCmd "axis visible all $bool" 1324 1322 } 1325 " axisLabelsVisible" {1326 set bool $_settings( axisLabelsVisible)1323 "-axislabels" { 1324 set bool $_settings($what) 1327 1325 SendCmd "axis labels all $bool" 1328 1326 } 1329 "axisXGrid" - "axisYGrid" - "axisZGrid" { 1330 set axis [string tolower [string range $what 4 4]] 1327 "-axisminorticks" { 1328 set bool $_settings($what) 1329 SendCmd "axis minticks all $bool" 1330 } 1331 "-xgrid" - "-ygrid" - "-zgrid" { 1332 set axis [string tolower [string range $what 1 1]] 1331 1333 set bool $_settings($what) 1332 1334 SendCmd "axis grid $axis $bool" 1333 1335 } 1334 " axisMode" {1336 "-axismode" { 1335 1337 set mode [$itk_component(axisMode) value] 1336 1338 set mode [$itk_component(axisMode) translate $mode] … … 1338 1340 SendCmd "axis flymode $mode" 1339 1341 } 1340 " cutplaneEdges" {1342 "-cutplaneedges" { 1341 1343 set bool $_settings($what) 1342 1344 SendCmd "cutplane edges $bool" 1343 1345 } 1344 " cutplaneVisible" {1346 "-cutplanevisible" { 1345 1347 set bool $_settings($what) 1346 1348 SendCmd "cutplane visible $bool" 1347 1349 } 1348 " cutplaneWireframe" {1350 "-cutplanewireframe" { 1349 1351 set bool $_settings($what) 1350 1352 SendCmd "cutplane wireframe $bool" 1351 1353 } 1352 " cutplaneLighting" {1354 "-cutplanelighting" { 1353 1355 set bool $_settings($what) 1354 1356 SendCmd "cutplane lighting $bool" 1355 1357 } 1356 " cutplaneOpacity" {1358 "-cutplaneopacity" { 1357 1359 set val $_settings($what) 1358 1360 set sval [expr { 0.01 * double($val) }] 1359 1361 SendCmd "cutplane opacity $sval" 1360 1362 } 1361 " cutplanePreinterp" {1363 "-cutplanepreinterp" { 1362 1364 set bool $_settings($what) 1363 1365 SendCmd "cutplane preinterp $bool" 1364 1366 } 1365 " cutplaneXVisible" - "cutplaneYVisible" - "cutplaneZVisible" {1366 set axis [string tolower [string range $what 8 8]]1367 "-cutplanexvisible" - "-cutplaneyvisible" - "-cutplanezvisible" { 1368 set axis [string tolower [string range $what 9 9]] 1367 1369 set bool $_settings($what) 1368 1370 if { $bool } { … … 1373 1375 -troughcolor grey82 1374 1376 } 1375 1376 } 1377 " cutplaneXPosition" - "cutplaneYPosition" - "cutplaneZPosition" {1378 set axis [string tolower [string range $what 8 8]]1377 SendCmd "cutplane axis $axis $bool" 1378 } 1379 "-cutplanexposition" - "-cutplaneyposition" - "-cutplanezposition" { 1380 set axis [string tolower [string range $what 9 9]] 1379 1381 set pos [expr $_settings($what) * 0.01] 1380 1382 SendCmd "cutplane slice ${axis} ${pos}" 1381 1383 set _cutplanePending 0 1382 1384 } 1383 " colormap" {1384 set _changed( colormap) 11385 "-colormap" { 1386 set _changed($what) 1 1385 1387 StartBufferingCommands 1386 1388 set color [$itk_component(colormap) value] 1387 set _settings( colormap) $color1388 1389 if { $_settings(colormapVisible) } {1390 1391 set _settings(colormapVisible) 01392 1393 1394 if { !$_settings(colormapVisible) } {1395 1396 set _settings(colormapVisible) 11397 1398 1399 1389 set _settings($what) $color 1390 if { $color == "none" } { 1391 if { $_settings(-colormapvisible) } { 1392 SendCmd "glyphs colormode constant {}" 1393 set _settings(-colormapvisible) 0 1394 } 1395 } else { 1396 if { !$_settings(-colormapvisible) } { 1397 SendCmd "glyphs colormode $_colorMode $_curFldName" 1398 set _settings(-colormapvisible) 1 1399 } 1400 SetCurrentColormap $color 1401 } 1400 1402 StopBufferingCommands 1401 1402 } 1403 " glyphWireframe" {1403 EventuallyRequestLegend 1404 } 1405 "-glyphwireframe" { 1404 1406 set bool $_settings($what) 1405 1406 } 1407 " glyphVisible" {1407 SendCmd "glyphs wireframe $bool" 1408 } 1409 "-glyphvisible" { 1408 1410 set bool $_settings($what) 1409 1411 SendCmd "glyphs visible $bool" 1410 1412 if { $bool } { 1411 1413 Rappture::Tooltip::for $itk_component(glyphs) \ … … 1415 1417 "Show the glyph" 1416 1418 } 1417 1418 } 1419 " glyphLighting" {1419 DrawLegend 1420 } 1421 "-glyphlighting" { 1420 1422 set bool $_settings($what) 1421 1422 } 1423 " glyphEdges" {1423 SendCmd "glyphs lighting $bool" 1424 } 1425 "-glyphedges" { 1424 1426 set bool $_settings($what) 1425 1426 } 1427 " glyphOutline" {1427 SendCmd "glyphs edges $bool" 1428 } 1429 "-glyphoutline" { 1428 1430 set bool $_settings($what) 1429 1430 } 1431 " glyphOpacity" {1431 SendCmd "outline visible $bool" 1432 } 1433 "-glyphopacity" { 1432 1434 set val $_settings($what) 1433 1435 set sval [expr { 0.01 * double($val) }] 1434 SendCmd "glyphs opacity $sval" 1435 } 1436 "glyphNormscale" { 1437 set bool $_settings($what) 1438 SendCmd "glyphs normscale $bool" 1439 } 1440 "glyphOrient" { 1441 set bool $_settings($what) 1442 SendCmd "glyphs gorient $bool {}" 1443 } 1444 "glyphScale" { 1436 SendCmd "glyphs opacity $sval" 1437 } 1438 "-glyphscale" { 1445 1439 set val $_settings($what) 1446 SendCmd "glyphs gscale $val" 1447 } 1448 "glyphScaleMode" { 1449 set label [$itk_component(scaleMode) value] 1450 set mode [$itk_component(scaleMode) translate $label] 1451 set _settings($what) $mode 1452 SendCmd "glyphs smode $mode {}" 1453 } 1454 "glyphShape" { 1455 set label [$itk_component(gshape) value] 1456 set shape [$itk_component(gshape) translate $label] 1457 set _settings($what) $shape 1458 SendCmd "glyphs shape $shape" 1459 } 1460 "field" { 1440 if { [string is double $val] } { 1441 SendCmd "glyphs gscale $val" 1442 } 1443 } 1444 "-field" { 1461 1445 set label [$itk_component(field) value] 1462 1446 set fname [$itk_component(field) translate $label] 1463 set _settings( field) $fname1447 set _settings($what) $fname 1464 1448 if { [info exists _fields($fname)] } { 1465 1449 foreach { label units components } $_fields($fname) break … … 1475 1459 return 1476 1460 } 1477 #if { ![info exists _limits($_curFldName)] } {1478 # SendCmd "dataset maprange all"1479 #} else {1480 # SendCmd "dataset maprange explicit $_limits($_curFldName) $_curFldName"1481 #}1482 #SendCmd "cutplane colormode $_colorMode $_curFldName"1483 1461 SendCmd "glyphs colormode $_colorMode $_curFldName" 1484 1462 DrawLegend 1485 1463 } 1486 " legendVisible" {1464 "-legendvisible" { 1487 1465 if { !$_settings($what) } { 1488 1466 $itk_component(view) delete legend 1489 1490 1467 } 1468 DrawLegend 1491 1469 } 1492 1470 default { … … 1496 1474 } 1497 1475 1498 1499 1476 # 1500 1477 # RequestLegend -- 1501 1478 # 1502 # 1503 # 1479 # Request a new legend from the server. The size of the legend 1480 # is determined from the height of the canvas. 1504 1481 # 1505 1482 # This should be called when 1506 # 1507 # 1508 # 1509 # 1510 # 1483 # 1. A new current colormap is set. 1484 # 2. Window is resized. 1485 # 3. The limits of the data have changed. (Just need a redraw). 1486 # 4. Number of glyph have changed. (Just need a redraw). 1487 # 5. Legend becomes visible (Just need a redraw). 1511 1488 # 1512 1489 itcl::body Rappture::VtkGlyphViewer::RequestLegend {} { … … 1520 1497 set fname $_curFldName 1521 1498 if { [string match "component*" $fname] } { 1522 1499 set title "" 1523 1500 } else { 1524 1525 1526 1527 1528 1529 1530 1531 1501 if { [info exists _fields($fname)] } { 1502 foreach { title units } $_fields($fname) break 1503 if { $units != "" } { 1504 set title [format "%s (%s)" $title $units] 1505 } 1506 } else { 1507 set title $fname 1508 } 1532 1509 } 1533 1510 # If there's a title too, substract one more line … … 1540 1517 # Set the legend on the first heightmap dataset. 1541 1518 if { $_currentColormap != "" } { 1542 1543 1519 set cmap $_currentColormap 1520 SendCmdNoWait "legend $cmap $_colorMode $_curFldName {} $w $h 0" 1544 1521 } 1545 1522 } … … 1561 1538 if { [isconnected] } { 1562 1539 set rgb [Color2RGB $itk_option(-plotforeground)] 1563 1540 SendCmd "axis color all $rgb" 1564 1541 SendCmd "outline color $rgb" 1565 1542 #SendCmd "cutplane color $rgb" … … 1587 1564 checkbutton $inner.glyphs \ 1588 1565 -text "Glyphs" \ 1589 -variable [itcl::scope _settings( glyphVisible)] \1590 -command [itcl::code $this AdjustSetting glyphVisible] \1566 -variable [itcl::scope _settings(-glyphvisible)] \ 1567 -command [itcl::code $this AdjustSetting -glyphvisible] \ 1591 1568 -font "Arial 9" 1592 1593 label $inner.gshape_l -text "Glyph shape" -font "Arial 9"1594 itk_component add gshape {1595 Rappture::Combobox $inner.gshape -width 10 -editable no1596 }1597 $inner.gshape choices insert end \1598 "arrow" "arrow" \1599 "cone" "cone" \1600 "cube" "cube" \1601 "cylinder" "cylinder" \1602 "dodecahedron" "dodecahedron" \1603 "icosahedron" "icosahedron" \1604 "line" "line" \1605 "octahedron" "octahedron" \1606 "point" "point" \1607 "sphere" "sphere" \1608 "tetrahedron" "tetrahedron"1609 1610 $itk_component(gshape) value $_settings(glyphShape)1611 bind $inner.gshape <<Value>> [itcl::code $this AdjustSetting glyphShape]1612 1613 label $inner.scaleMode_l -text "Scale by" -font "Arial 9"1614 itk_component add scaleMode {1615 Rappture::Combobox $inner.scaleMode -width 10 -editable no1616 }1617 $inner.scaleMode choices insert end \1618 "scalar" "Scalar" \1619 "vmag" "Vector magnitude" \1620 "vcomp" "Vector components" \1621 "off" "Constant size"1622 1623 $itk_component(scaleMode) value "[$itk_component(scaleMode) label $_settings(glyphScaleMode)]"1624 bind $inner.scaleMode <<Value>> [itcl::code $this AdjustSetting glyphScaleMode]1625 1626 checkbutton $inner.normscale \1627 -text "Normalize scaling" \1628 -variable [itcl::scope _settings(glyphNormscale)] \1629 -command [itcl::code $this AdjustSetting glyphNormscale] \1630 -font "Arial 9"1631 Rappture::Tooltip::for $inner.normscale "If enabled, field values are normalized to \[0,1\] before scaling and scale factor is relative to a default size"1632 1633 checkbutton $inner.gorient \1634 -text "Orient" \1635 -variable [itcl::scope _settings(glyphOrient)] \1636 -command [itcl::code $this AdjustSetting glyphOrient] \1637 -font "Arial 9"1638 Rappture::Tooltip::for $inner.gorient "Orient glyphs by vector field directions"1639 1569 1640 1570 checkbutton $inner.wireframe \ 1641 1571 -text "Wireframe" \ 1642 -variable [itcl::scope _settings( glyphWireframe)] \1643 -command [itcl::code $this AdjustSetting glyphWireframe] \1572 -variable [itcl::scope _settings(-glyphwireframe)] \ 1573 -command [itcl::code $this AdjustSetting -glyphwireframe] \ 1644 1574 -font "Arial 9" 1645 1575 1646 1576 checkbutton $inner.lighting \ 1647 1577 -text "Enable Lighting" \ 1648 -variable [itcl::scope _settings( glyphLighting)] \1649 -command [itcl::code $this AdjustSetting glyphLighting] \1578 -variable [itcl::scope _settings(-glyphlighting)] \ 1579 -command [itcl::code $this AdjustSetting -glyphlighting] \ 1650 1580 -font "Arial 9" 1651 1581 1652 1582 checkbutton $inner.edges \ 1653 1583 -text "Edges" \ 1654 -variable [itcl::scope _settings( glyphEdges)] \1655 -command [itcl::code $this AdjustSetting glyphEdges] \1584 -variable [itcl::scope _settings(-glyphedges)] \ 1585 -command [itcl::code $this AdjustSetting -glyphedges] \ 1656 1586 -font "Arial 9" 1657 1587 1658 1588 checkbutton $inner.outline \ 1659 1589 -text "Outline" \ 1660 -variable [itcl::scope _settings( glyphOutline)] \1661 -command [itcl::code $this AdjustSetting glyphOutline] \1590 -variable [itcl::scope _settings(-glyphoutline)] \ 1591 -command [itcl::code $this AdjustSetting -glyphoutline] \ 1662 1592 -font "Arial 9" 1663 1593 1664 1594 checkbutton $inner.legend \ 1665 1595 -text "Legend" \ 1666 -variable [itcl::scope _settings( legendVisible)] \1667 -command [itcl::code $this AdjustSetting legendVisible] \1596 -variable [itcl::scope _settings(-legendvisible)] \ 1597 -command [itcl::code $this AdjustSetting -legendvisible] \ 1668 1598 -font "Arial 9" 1669 1599 … … 1677 1607 "grey" "grey" 1678 1608 1679 $itk_component(background) value $_settings( background)1680 bind $inner.background <<Value>> [itcl::code $this AdjustSetting background]1609 $itk_component(background) value $_settings(-background) 1610 bind $inner.background <<Value>> [itcl::code $this AdjustSetting -background] 1681 1611 1682 1612 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1683 1613 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1684 -variable [itcl::scope _settings( glyphOpacity)] \1614 -variable [itcl::scope _settings(-glyphopacity)] \ 1685 1615 -width 10 \ 1686 1616 -showvalue off \ 1687 -command [itcl::code $this AdjustSetting glyphOpacity]1617 -command [itcl::code $this AdjustSetting -glyphopacity] 1688 1618 1689 1619 label $inner.gscale_l -text "Scale factor" -font "Arial 9" 1690 if {0} {1691 1620 ::scale $inner.gscale -from 1 -to 100 -orient horizontal \ 1692 -variable [itcl::scope _settings( glyphScale)] \1621 -variable [itcl::scope _settings(-glyphscale)] \ 1693 1622 -width 10 \ 1694 1623 -showvalue off \ 1695 -command [itcl::code $this AdjustSetting glyphScale] 1696 } else { 1697 itk_component add gscale { 1698 entry $inner.gscale -font "Arial 9" -bg white \ 1699 -textvariable [itcl::scope _settings(glyphScale)] 1700 } { 1701 ignore -font -background 1702 } 1703 bind $inner.gscale <Return> \ 1704 [itcl::code $this AdjustSetting glyphScale] 1705 bind $inner.gscale <KP_Enter> \ 1706 [itcl::code $this AdjustSetting glyphScale] 1707 } 1624 -command [itcl::code $this AdjustSetting -glyphscale] 1708 1625 Rappture::Tooltip::for $inner.gscale "Set scaling multiplier (or constant size)" 1709 1626 … … 1717 1634 } 1718 1635 bind $inner.field <<Value>> \ 1719 [itcl::code $this AdjustSetting field]1636 [itcl::code $this AdjustSetting -field] 1720 1637 1721 1638 label $inner.colormap_l -text "Colormap" -font "Arial 9" … … 1723 1640 Rappture::Combobox $inner.colormap -width 10 -editable no 1724 1641 } 1725 $inner.colormap choices insert end [GetColormapList -includeNone] 1642 1643 $inner.colormap choices insert end [GetColormapList] 1726 1644 $itk_component(colormap) value "BCGYR" 1727 1645 bind $inner.colormap <<Value>> \ 1728 [itcl::code $this AdjustSetting colormap]1646 [itcl::code $this AdjustSetting -colormap] 1729 1647 1730 1648 blt::table $inner \ … … 1733 1651 1,0 $inner.colormap_l -anchor w -pady 2 \ 1734 1652 1,1 $inner.colormap -anchor w -pady 2 -fill x \ 1735 2,0 $inner.gshape_l -anchor w -pady 2 \ 1736 2,1 $inner.gshape -anchor w -pady 2 -fill x \ 1737 3,0 $inner.background_l -anchor w -pady 2 \ 1738 3,1 $inner.background -anchor w -pady 2 -fill x \ 1739 4,0 $inner.scaleMode_l -anchor w -pady 2 \ 1740 4,1 $inner.scaleMode -anchor w -pady 2 -fill x \ 1741 5,0 $inner.gscale_l -anchor w -pady 2 \ 1742 5,1 $inner.gscale -anchor w -pady 2 -fill x \ 1743 6,0 $inner.normscale -anchor w -pady 2 -cspan 2 \ 1744 7,0 $inner.gorient -anchor w -pady 2 -cspan 2 \ 1745 8,0 $inner.wireframe -anchor w -pady 2 -cspan 2 \ 1746 9,0 $inner.lighting -anchor w -pady 2 -cspan 2 \ 1747 10,0 $inner.edges -anchor w -pady 2 -cspan 2 \ 1748 11,0 $inner.outline -anchor w -pady 2 -cspan 2 \ 1749 12,0 $inner.legend -anchor w -pady 2 \ 1750 13,0 $inner.opacity_l -anchor w -pady 2 \ 1751 13,1 $inner.opacity -fill x -pady 2 -fill x \ 1653 3,0 $inner.background_l -anchor w -pady 2 \ 1654 3,1 $inner.background -anchor w -pady 2 -fill x \ 1655 5,0 $inner.wireframe -anchor w -pady 2 -cspan 2 \ 1656 6,0 $inner.lighting -anchor w -pady 2 -cspan 2 \ 1657 7,0 $inner.edges -anchor w -pady 2 -cspan 2 \ 1658 8,0 $inner.outline -anchor w -pady 2 -cspan 2 \ 1659 9,0 $inner.legend -anchor w -pady 2 \ 1660 10,0 $inner.opacity_l -anchor w -pady 2 \ 1661 10,1 $inner.opacity -fill x -pady 2 -fill x \ 1752 1662 1753 1663 blt::table configure $inner r* c* -resize none 1754 blt::table configure $inner r1 4c1 -resize expand1664 blt::table configure $inner r11 c1 -resize expand 1755 1665 } 1756 1666 … … 1766 1676 1767 1677 checkbutton $inner.visible \ 1768 -text " ShowAxes" \1769 -variable [itcl::scope _settings( axesVisible)] \1770 -command [itcl::code $this AdjustSetting axesVisible] \1678 -text "Axes" \ 1679 -variable [itcl::scope _settings(-axesvisible)] \ 1680 -command [itcl::code $this AdjustSetting -axesvisible] \ 1771 1681 -font "Arial 9" 1772 1682 1773 1683 checkbutton $inner.labels \ 1774 -text " ShowAxis Labels" \1775 -variable [itcl::scope _settings( axisLabelsVisible)] \1776 -command [itcl::code $this AdjustSetting axisLabelsVisible] \1684 -text "Axis Labels" \ 1685 -variable [itcl::scope _settings(-axislabels)] \ 1686 -command [itcl::code $this AdjustSetting -axislabels] \ 1777 1687 -font "Arial 9" 1778 1779 checkbutton $inner. gridx\1780 -text " Show X Grid" \1781 -variable [itcl::scope _settings( axisXGrid)] \1782 -command [itcl::code $this AdjustSetting axisXGrid] \1688 label $inner.grid_l -text "Grid" -font "Arial 9" 1689 checkbutton $inner.xgrid \ 1690 -text "X" \ 1691 -variable [itcl::scope _settings(-xgrid)] \ 1692 -command [itcl::code $this AdjustSetting -xgrid] \ 1783 1693 -font "Arial 9" 1784 checkbutton $inner. gridy\1785 -text " Show Y Grid" \1786 -variable [itcl::scope _settings( axisYGrid)] \1787 -command [itcl::code $this AdjustSetting axisYGrid] \1694 checkbutton $inner.ygrid \ 1695 -text "Y" \ 1696 -variable [itcl::scope _settings(-ygrid)] \ 1697 -command [itcl::code $this AdjustSetting -ygrid] \ 1788 1698 -font "Arial 9" 1789 checkbutton $inner.gridz \ 1790 -text "Show Z Grid" \ 1791 -variable [itcl::scope _settings(axisZGrid)] \ 1792 -command [itcl::code $this AdjustSetting axisZGrid] \ 1699 checkbutton $inner.zgrid \ 1700 -text "Z" \ 1701 -variable [itcl::scope _settings(-zgrid)] \ 1702 -command [itcl::code $this AdjustSetting -zgrid] \ 1703 -font "Arial 9" 1704 checkbutton $inner.minorticks \ 1705 -text "Minor Ticks" \ 1706 -variable [itcl::scope _settings(-axisminorticks)] \ 1707 -command [itcl::code $this AdjustSetting -axisminorticks] \ 1793 1708 -font "Arial 9" 1794 1709 … … 1803 1718 "furthest_triad" "farthest" \ 1804 1719 "outer_edges" "outer" 1805 $itk_component(axisMode) value "static"1806 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axisMode]1720 $itk_component(axisMode) value $_settings(-axismode) 1721 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode] 1807 1722 1808 1723 blt::table $inner \ 1809 0,0 $inner.visible -anchor w -cspan 2 \ 1810 1,0 $inner.labels -anchor w -cspan 2 \ 1811 2,0 $inner.gridx -anchor w -cspan 2 \ 1812 3,0 $inner.gridy -anchor w -cspan 2 \ 1813 4,0 $inner.gridz -anchor w -cspan 2 \ 1814 5,0 $inner.mode_l -anchor w -cspan 2 -padx { 2 0 } \ 1815 6,0 $inner.mode -fill x -cspan 2 1724 0,0 $inner.visible -anchor w -cspan 4 \ 1725 1,0 $inner.labels -anchor w -cspan 4 \ 1726 2,0 $inner.minorticks -anchor w -cspan 4 \ 1727 4,0 $inner.grid_l -anchor w \ 1728 4,1 $inner.xgrid -anchor w \ 1729 4,2 $inner.ygrid -anchor w \ 1730 4,3 $inner.zgrid -anchor w \ 1731 5,0 $inner.mode_l -anchor w -padx { 2 0 } \ 1732 5,1 $inner.mode -fill x -cspan 3 1816 1733 1817 1734 blt::table configure $inner r* c* -resize none 1818 blt::table configure $inner r7 c 1-resize expand1819 } 1820 1735 blt::table configure $inner r7 c6 -resize expand 1736 blt::table configure $inner r3 -height 0.125i 1737 } 1821 1738 1822 1739 itcl::body Rappture::VtkGlyphViewer::BuildCameraTab {} { … … 1880 1797 checkbutton $inner.visible \ 1881 1798 -text "Cutplanes" \ 1882 -variable [itcl::scope _settings( cutplaneVisible)] \1883 -command [itcl::code $this AdjustSetting cutplaneVisible] \1799 -variable [itcl::scope _settings(-cutplanevisible)] \ 1800 -command [itcl::code $this AdjustSetting -cutplanevisible] \ 1884 1801 -font "Arial 9" 1885 1802 1886 1803 checkbutton $inner.wireframe \ 1887 1804 -text "Wireframe" \ 1888 -variable [itcl::scope _settings( cutplaneWireframe)] \1889 -command [itcl::code $this AdjustSetting cutplaneWireframe] \1805 -variable [itcl::scope _settings(-cutplanewireframe)] \ 1806 -command [itcl::code $this AdjustSetting -cutplanewireframe] \ 1890 1807 -font "Arial 9" 1891 1808 1892 1809 checkbutton $inner.lighting \ 1893 1810 -text "Enable Lighting" \ 1894 -variable [itcl::scope _settings( cutplaneLighting)] \1895 -command [itcl::code $this AdjustSetting cutplaneLighting] \1811 -variable [itcl::scope _settings(-cutplanelighting)] \ 1812 -command [itcl::code $this AdjustSetting -cutplanelighting] \ 1896 1813 -font "Arial 9" 1897 1814 1898 1815 checkbutton $inner.edges \ 1899 1816 -text "Edges" \ 1900 -variable [itcl::scope _settings( cutplaneEdges)] \1901 -command [itcl::code $this AdjustSetting cutplaneEdges] \1817 -variable [itcl::scope _settings(-cutplaneedges)] \ 1818 -command [itcl::code $this AdjustSetting -cutplaneedges] \ 1902 1819 -font "Arial 9" 1903 1820 1904 1821 checkbutton $inner.preinterp \ 1905 1822 -text "Interpolate Scalars" \ 1906 -variable [itcl::scope _settings( cutplanePreinterp)] \1907 -command [itcl::code $this AdjustSetting cutplanePreinterp] \1823 -variable [itcl::scope _settings(-cutplanepreinterp)] \ 1824 -command [itcl::code $this AdjustSetting -cutplanepreinterp] \ 1908 1825 -font "Arial 9" 1909 1826 1910 1827 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1911 1828 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1912 -variable [itcl::scope _settings( cutplaneOpacity)] \1829 -variable [itcl::scope _settings(-cutplaneopacity)] \ 1913 1830 -width 10 \ 1914 1831 -showvalue off \ 1915 -command [itcl::code $this AdjustSetting cutplaneOpacity]1916 $inner.opacity set $_settings( cutplaneOpacity)1832 -command [itcl::code $this AdjustSetting -cutplaneopacity] 1833 $inner.opacity set $_settings(-cutplaneopacity) 1917 1834 1918 1835 # X-value slicer... … … 1921 1838 -onimage [Rappture::icon x-cutplane-red] \ 1922 1839 -offimage [Rappture::icon x-cutplane-red] \ 1923 -command [itcl::code $this AdjustSetting cutplaneXVisible] \1924 -variable [itcl::scope _settings( cutplaneXVisible)] \1840 -command [itcl::code $this AdjustSetting -cutplanexvisible] \ 1841 -variable [itcl::scope _settings(-cutplanexvisible)] \ 1925 1842 } 1926 1843 Rappture::Tooltip::for $itk_component(xbutton) \ … … 1932 1849 -borderwidth 1 -highlightthickness 0 \ 1933 1850 -command [itcl::code $this EventuallySetCutplane x] \ 1934 -variable [itcl::scope _settings( cutplaneXPosition)] \1935 1851 -variable [itcl::scope _settings(-cutplanexposition)] \ 1852 -foreground red2 -font "Arial 9 bold" 1936 1853 } { 1937 1854 usual … … 1949 1866 -onimage [Rappture::icon y-cutplane-green] \ 1950 1867 -offimage [Rappture::icon y-cutplane-green] \ 1951 -command [itcl::code $this AdjustSetting cutplaneYVisible] \1952 -variable [itcl::scope _settings( cutplaneYVisible)] \1868 -command [itcl::code $this AdjustSetting -cutplaneyvisible] \ 1869 -variable [itcl::scope _settings(-cutplaneyvisible)] \ 1953 1870 } 1954 1871 Rappture::Tooltip::for $itk_component(ybutton) \ … … 1961 1878 -borderwidth 1 -highlightthickness 0 \ 1962 1879 -command [itcl::code $this EventuallySetCutplane y] \ 1963 -variable [itcl::scope _settings( cutplaneYPosition)] \1964 1880 -variable [itcl::scope _settings(-cutplaneyposition)] \ 1881 -foreground green3 -font "Arial 9 bold" 1965 1882 } { 1966 1883 usual … … 1978 1895 -onimage [Rappture::icon z-cutplane-blue] \ 1979 1896 -offimage [Rappture::icon z-cutplane-blue] \ 1980 -command [itcl::code $this AdjustSetting cutplaneZVisible] \1981 -variable [itcl::scope _settings( cutplaneZVisible)] \1897 -command [itcl::code $this AdjustSetting -cutplanezvisible] \ 1898 -variable [itcl::scope _settings(-cutplanezvisible)] \ 1982 1899 } { 1983 1984 1900 usual 1901 ignore -foreground 1985 1902 } 1986 1903 Rappture::Tooltip::for $itk_component(zbutton) \ … … 1993 1910 -borderwidth 1 -highlightthickness 0 \ 1994 1911 -command [itcl::code $this EventuallySetCutplane z] \ 1995 -variable [itcl::scope _settings( cutplaneZPosition)] \1996 1912 -variable [itcl::scope _settings(-cutplanezposition)] \ 1913 -foreground blue3 -font "Arial 9 bold" 1997 1914 } { 1998 1915 usual … … 2005 1922 2006 1923 blt::table $inner \ 2007 0,0 $inner.visible -anchor w -pady 2 -cspan 3 \ 2008 1,0 $inner.lighting -anchor w -pady 2 -cspan 3 \ 2009 2,0 $inner.wireframe -anchor w -pady 2 -cspan 3 \ 2010 3,0 $inner.edges -anchor w -pady 2 -cspan 3 \ 2011 4,0 $inner.preinterp -anchor w -pady 2 -cspan 3 \ 2012 5,0 $inner.opacity_l -anchor w -pady 2 -cspan 1 \ 2013 5,1 $inner.opacity -fill x -pady 2 -cspan 3 \ 2014 6,0 $inner.xbutton -anchor w -padx 2 -pady 2 \ 2015 7,0 $inner.ybutton -anchor w -padx 2 -pady 2 \ 2016 8,0 $inner.zbutton -anchor w -padx 2 -pady 2 \ 2017 6,1 $inner.xval -fill y -rspan 4 \ 2018 6,2 $inner.yval -fill y -rspan 4 \ 2019 6,3 $inner.zval -fill y -rspan 4 \ 2020 1924 0,0 $inner.visible -anchor w -pady 2 -cspan 3 \ 1925 1,0 $inner.lighting -anchor w -pady 2 -cspan 3 \ 1926 2,0 $inner.wireframe -anchor w -pady 2 -cspan 3 \ 1927 3,0 $inner.edges -anchor w -pady 2 -cspan 3 \ 1928 4,0 $inner.preinterp -anchor w -pady 2 -cspan 3 \ 1929 5,0 $inner.opacity_l -anchor w -pady 2 -cspan 1 \ 1930 5,1 $inner.opacity -fill x -pady 2 -cspan 3 \ 1931 6,0 $inner.xbutton -anchor w -padx 2 -pady 2 \ 1932 7,0 $inner.ybutton -anchor w -padx 2 -pady 2 \ 1933 8,0 $inner.zbutton -anchor w -padx 2 -pady 2 \ 1934 6,1 $inner.xval -fill y -rspan 4 \ 1935 6,2 $inner.yval -fill y -rspan 4 \ 1936 6,3 $inner.zval -fill y -rspan 4 \ 2021 1937 2022 1938 blt::table configure $inner r* c* -resize none 2023 1939 blt::table configure $inner r9 c4 -resize expand 2024 1940 } 2025 2026 2027 1941 2028 1942 # … … 2133 2047 set tag $dataobj-$comp 2134 2048 array set style { 2135 -color \#FFFFFF 2136 -colormap BCGYR 2137 -colorMode vmag 2049 -color BCGYR 2138 2050 -edgecolor black 2139 2051 -edges 0 … … 2147 2059 -ptsize 1.0 2148 2060 -quality 1 2149 -scaleMode vmag2150 -shape arrow2061 -scaleMode "vmag" 2062 -shape "arrow" 2151 2063 -wireframe 0 2152 2064 } 2153 set $style(-color) $itk_option(-plotforeground)2154 2065 set numComponents [$dataobj numComponents $comp] 2155 2066 if {$numComponents == 3} { … … 2157 2068 set style(-orientGlyphs) 1 2158 2069 set style(-scaleMode) "vmag" 2159 set style(-colorMode) "vmag"2160 2070 } else { 2161 2071 set style(-shape) "sphere" 2162 2072 set style(-orientGlyphs) 0 2163 2073 set style(-scaleMode) "scalar" 2164 set style(-colorMode) "scalar"2165 2074 } 2166 2075 array set style [$dataobj style $comp] … … 2181 2090 # the code to handle aberrant cases. 2182 2091 2183 if { $_changed( glyphOpacity) } {2184 set style(-opacity) $_settings(glyphOpacity)2185 } 2186 if { $_changed( colormap) } {2187 set style(-color map) $_settings(colormap)2092 if { $_changed(-glyphopacity) } { 2093 set style(-opacity) [expr $_settings(-glyphopacity) * 0.01] 2094 } 2095 if { $_changed(-colormap) } { 2096 set style(-color) $_settings(-colormap) 2188 2097 } 2189 2098 if { $_currentColormap == "" } { 2190 $itk_component(colormap) value $style(-colormap) 2191 } 2192 set _currentOpacity $style(-opacity) 2099 $itk_component(colormap) value $style(-color) 2100 } 2101 2102 SendCmd "outline add $tag" 2103 SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag" 2104 SendCmd "outline visible $style(-outline) $tag" 2105 set _settings(-glyphoutline) $style(-outline) 2106 2193 2107 SendCmd "glyphs add $style(-shape) $tag" 2194 set _settings(glyphShape) $style(-shape)2195 $itk_component(gshape) value $style(-shape)2196 2108 SendCmd "glyphs edges $style(-edges) $tag" 2109 set _settings(-glyphedges) $style(-edges) 2110 2197 2111 # normscale=1 and gscale=1 are defaults 2198 2112 if {$style(-normscale) != 1} { … … 2202 2116 SendCmd "glyphs gscale $style(-gscale) $tag" 2203 2117 } 2204 set _settings(glyphNormscale) $style(-normscale) 2205 set _settings(glyphScale) $style(-gscale) 2206 SendCmd "outline add $tag" 2207 SendCmd "outline color [Color2RGB $style(-color)] $tag" 2208 SendCmd "outline visible $style(-outline) $tag" 2209 set _settings(glyphOutline) $style(-outline) 2210 set _settings(glyphEdges) $style(-edges) 2211 if {$style(-colorMode) == "constant" || $style(-colormap) == "none"} { 2212 SendCmd "glyphs colormode constant {} $tag" 2213 set _settings(colormapVisible) 0 2214 set _settings(colormap) "none" 2215 } else { 2216 SendCmd "glyphs colormode $style(-colorMode) $_curFldName $tag" 2217 set _settings(colormapVisible) 1 2218 set _settings(colormap) $style(-colormap) 2219 SetCurrentColormap $style(-colormap) 2220 } 2221 $itk_component(colormap) value $_settings(colormap) 2222 set _colorMode $style(-colorMode) 2118 2223 2119 # constant color only used if colormode set to constant 2224 SendCmd "glyphs color [Color2RGB $ style(-color)] $tag"2120 SendCmd "glyphs color [Color2RGB $itk_option(-plotforeground)] $tag" 2225 2121 # Omitting field name for gorient and smode commands 2226 2122 # defaults to active scalars or vectors depending on mode 2227 2123 SendCmd "glyphs gorient $style(-orientGlyphs) {} $tag" 2228 2124 SendCmd "glyphs smode $style(-scaleMode) {} $tag" 2229 set _settings(glyphScaleMode) $style(-scaleMode)2230 $itk_component(scaleMode) value "[$itk_component(scaleMode) label $style(-scaleMode)]"2231 2125 SendCmd "glyphs quality $style(-quality) $tag" 2232 2126 SendCmd "glyphs lighting $style(-lighting) $tag" 2233 set _settings( glyphLighting) $style(-lighting)2127 set _settings(-glyphlighting) $style(-lighting) 2234 2128 SendCmd "glyphs linecolor [Color2RGB $style(-edgecolor)] $tag" 2235 2129 SendCmd "glyphs linewidth $style(-linewidth) $tag" 2236 2130 SendCmd "glyphs ptsize $style(-ptsize) $tag" 2237 SendCmd "glyphs opacity $_currentOpacity $tag" 2238 set _settings(glyphOpacity) $style(-opacity) 2131 SendCmd "glyphs opacity $style(-opacity) $tag" 2132 set _settings(-glyphopacity) [expr $style(-opacity) * 100.0] 2133 SetCurrentColormap $style(-color) 2239 2134 SendCmd "glyphs wireframe $style(-wireframe) $tag" 2240 set _settings(glyphWireframe) $style(-wireframe) 2241 set _settings(glyphOpacity) [expr $style(-opacity) * 100.0] 2135 set _settings(-glyphwireframe) $style(-wireframe) 2242 2136 } 2243 2137 … … 2293 2187 2294 2188 if { [string match "component*" $fname] } { 2295 2189 set title "" 2296 2190 } else { 2297 2298 2299 2300 2301 2302 2303 2304 2191 if { [info exists _fields($fname)] } { 2192 foreach { title units } $_fields($fname) break 2193 if { $units != "" } { 2194 set title [format "%s (%s)" $title $units] 2195 } 2196 } else { 2197 set title $fname 2198 } 2305 2199 } 2306 2200 # If there's a legend title, increase the offset by the line height. … … 2334 2228 } 2335 2229 2336 2337 2230 # ---------------------------------------------------------------------- 2338 2231 # USAGE: Slice move x|y|z <newval> … … 2368 2261 # ReceiveLegend -- 2369 2262 # 2370 # 2371 # 2372 # 2263 # Invoked automatically whenever the "legend" command comes in from 2264 # the rendering server. Indicates that binary image data with the 2265 # specified <size> will follow. 2373 2266 # 2374 2267 itcl::body Rappture::VtkGlyphViewer::ReceiveLegend { colormap title min max size } { … … 2384 2277 #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" 2385 2278 if { [catch {DrawLegend} errs] != 0 } { 2386 2387 2279 global errorInfo 2280 puts stderr "errs=$errs errorInfo=$errorInfo" 2388 2281 } 2389 2282 } … … 2393 2286 # DrawLegend -- 2394 2287 # 2395 # 2288 # Draws the legend in the own canvas on the right side of the plot area. 2396 2289 # 2397 2290 itcl::body Rappture::VtkGlyphViewer::DrawLegend {} { … … 2404 2297 2405 2298 if { [string match "component*" $fname] } { 2406 2299 set title "" 2407 2300 } else { 2408 2409 2410 2411 2412 2413 2414 2415 2301 if { [info exists _fields($fname)] } { 2302 foreach { title units } $_fields($fname) break 2303 if { $units != "" } { 2304 set title [format "%s (%s)" $title $units] 2305 } 2306 } else { 2307 set title $fname 2308 } 2416 2309 } 2417 2310 set x [expr $w - 2] 2418 if { !$_settings( legendVisible) } {2419 2420 2311 if { !$_settings(-legendvisible) } { 2312 $c delete legend 2313 return 2421 2314 } 2422 2315 if { [$c find withtag "legend"] == "" } { 2423 2424 2316 set y 2 2317 # If there's a legend title, create a text item for the title. 2425 2318 $c create text $x $y \ 2426 2427 2428 2319 -anchor ne \ 2320 -fill $itk_option(-plotforeground) -tags "title legend" \ 2321 -font $font 2429 2322 if { $title != "" } { 2430 2323 incr y $lineht 2431 2324 } 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2325 $c create text $x $y \ 2326 -anchor ne \ 2327 -fill $itk_option(-plotforeground) -tags "vmax legend" \ 2328 -font $font 2329 incr y $lineht 2330 $c create image $x $y \ 2331 -anchor ne \ 2332 -image $_image(legend) -tags "colormap legend" 2333 $c create rectangle $x $y 1 1 \ 2334 -fill "" -outline "" -tags "sensor legend" 2335 $c create text $x [expr {$h-2}] \ 2336 -anchor se \ 2337 -fill $itk_option(-plotforeground) -tags "vmin legend" \ 2338 -font $font 2339 $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y] 2340 $c bind sensor <Leave> [itcl::code $this LeaveLegend] 2341 $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y] 2449 2342 } 2450 2343 set x2 $x … … 2460 2353 if { [info exists _limits($_curFldName)] } { 2461 2354 foreach { vmin vmax } $_limits($_curFldName) break 2462 2463 2355 $c itemconfigure vmin -text [format %g $vmin] 2356 $c itemconfigure vmax -text [format %g $vmax] 2464 2357 } 2465 2358 set y 2 … … 2467 2360 if { $title != "" } { 2468 2361 $c itemconfigure title -text $title 2469 2470 2362 $c coords title $x $y 2363 incr y $lineht 2471 2364 $c raise title 2472 2365 } … … 2510 2403 invoke { 2511 2404 $itk_component(field) value $_curFldLabel 2512 AdjustSetting field2405 AdjustSetting -field 2513 2406 } 2514 2407 default { … … 2534 2427 # BuildColormap -- 2535 2428 # 2536 # 2429 # Build the designated colormap on the server. 2537 2430 # 2538 2431 itcl::body Rappture::VtkGlyphViewer::BuildColormap { name } { … … 2565 2458 set _view(zoom) 1.0 2566 2459 } 2567 -
branches/r9/gui/scripts/vtkheightmapviewer.tcl
r4344 r4919 123 123 private variable _currentColormap "" 124 124 private variable _currentNumIsolines -1 125 private variable _currentOpacity ""126 125 127 126 private variable _maxScale 100; # This is the # of times the x-axis … … 217 216 218 217 array set _settings { 219 axisFlymode "static" 220 axisMinorTicks 1 221 stretchToFit 0 222 axisLabels 1 223 axisVisible 1 224 axisXGrid 0 225 axisYGrid 0 226 axisZGrid 0 227 colormapVisible 1 228 colormapDiscrete 0 229 edges 0 230 field "Default" 231 heightmapScale 50 232 isHeightmap 0 233 isolineColor black 234 isolinesVisible 1 235 legendVisible 1 236 lighting 1 237 saveLighting 1 238 numIsolines 10 239 opacity 100 240 outline 0 241 wireframe 0 242 saveOpacity 100 243 saveOutline 0 218 -axisflymode "static" 219 -axislabels 1 220 -axisminorticks 1 221 -axisvisible 1 222 -colormap BCGYR 223 -colormapdiscrete 0 224 -colormapvisible 1 225 -edges 0 226 -field "Default" 227 -heightmapscale 50 228 -isheightmap 0 229 -isolinecolor black 230 -isolinesvisible 1 231 -legendvisible 1 232 -lighting 1 233 -numisolines 10 234 -opacity 100 235 -outline 0 236 -savelighting 1 237 -saveopacity 100 238 -saveoutline 0 239 -stretchtofit 0 240 -wireframe 0 241 -xgrid 0 242 -ygrid 0 243 -zgrid 0 244 244 } 245 245 array set _changed { 246 opacity0247 colormap0248 numIsolines0246 -colormap 0 247 -numisolines 0 248 -opacity 0 249 249 } 250 250 itk_component add view { … … 325 325 -onimage [Rappture::icon surface] \ 326 326 -offimage [Rappture::icon surface] \ 327 -variable [itcl::scope _settings( isHeightmap)] \328 -command [itcl::code $this AdjustSetting isHeightmap] \327 -variable [itcl::scope _settings(-isheightmap)] \ 328 -command [itcl::code $this AdjustSetting -isheightmap] \ 329 329 } 330 330 Rappture::Tooltip::for $itk_component(mode) \ … … 336 336 -onimage [Rappture::icon stretchtofit] \ 337 337 -offimage [Rappture::icon stretchtofit] \ 338 -variable [itcl::scope _settings( stretchToFit)] \339 -command [itcl::code $this AdjustSetting stretchToFit] \338 -variable [itcl::scope _settings(-stretchtofit)] \ 339 -command [itcl::code $this AdjustSetting -stretchtofit] \ 340 340 } 341 341 Rappture::Tooltip::for $itk_component(stretchtofit) \ … … 666 666 } 667 667 if { [array size found] > 1 } { 668 set _settings( stretchToFit) 1668 set _settings(-stretchtofit) 1 669 669 } else { 670 670 # Check if the range of the x and y axes requires that we stretch … … 675 675 if { (($xmax - $xmin) > (($ymax -$ymin) * $_maxScale)) || 676 676 ((($xmax - $xmin) * $_maxScale) < ($ymax -$ymin)) } { 677 set _settings( stretchToFit) 1677 set _settings(-stretchtofit) 1 678 678 } 679 679 } … … 767 767 set session $env(SESSION) 768 768 } 769 lappend info "version" "$Rappture::version" 770 lappend info "build" "$Rappture::build" 771 lappend info "svnurl" "$Rappture::svnurl" 772 lappend info "installdir" "$Rappture::installdir" 769 773 lappend info "hub" [exec hostname] 770 774 lappend info "client" "vtkheightmapviewer" … … 924 928 $_arcball resize $w $h 925 929 DoResize 926 if { $_settings( stretchToFit) } {927 AdjustSetting stretchToFit930 if { $_settings(-stretchtofit) } { 931 AdjustSetting -stretchtofit 928 932 } 929 933 } … … 932 936 # Reset the camera and other view parameters 933 937 # 934 InitSettings isHeightmap background 935 936 # Let's see how this goes. I think it's preferable to overloading the 937 # axis title with the exponent. 938 SendCmd "axis exp 0 0 0 1" 938 InitSettings -isheightmap -background 939 940 # Setting a custom exponent and label format for axes is causing 941 # a problem with rounding. Near zero ticks aren't rounded by 942 # the %g format. The VTK CubeAxes seem to currently work best 943 # when allowed to automatically set the exponent and precision 944 # based on the axis ranges. This does tend to result in less 945 # visual clutter, so I think it is best to use the automatic 946 # settings by default. We can test more fine-grained 947 # controls on the axis settings tab if necessary. 948 # -Leif 949 #SendCmd "axis exp 0 0 0 1" 939 950 940 951 SendCmd "axis lrot z 90" 941 952 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 942 953 $_arcball quaternion $q 943 if {$_settings( isHeightmap) } {954 if {$_settings(-isheightmap) } { 944 955 if { $_view(ortho)} { 945 956 SendCmd "camera mode ortho" … … 1033 1044 $itk_component(field) value $_curFldLabel 1034 1045 } 1035 InitSettings stretchToFitoutline1046 InitSettings -stretchtofit -outline 1036 1047 1037 1048 if { $_reset } { … … 1077 1088 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1078 1089 $_arcball quaternion $q 1079 if {$_settings( isHeightmap) } {1090 if {$_settings(-isheightmap) } { 1080 1091 if { $_view(ortho)} { 1081 1092 SendCmd "camera mode ortho" … … 1087 1098 } 1088 1099 PanCamera 1089 InitSettings axisXGrid axisYGrid axisZGrid \1090 axisVisible axisLabels heightmapScale field isHeightmap \1091 numIsolines1100 InitSettings -xgrid -ygrid -zgrid \ 1101 -axisvisible -axislabels -heightmapscale -field -isheightmap \ 1102 -numisolines 1092 1103 if { [array size _fields] < 2 } { 1093 blt::table forget $itk_component(field) $itk_component(field_l) 1104 catch { 1105 blt::table forget $itk_component(field) $itk_component(field_l) 1106 } 1094 1107 } 1095 1108 RequestLegend … … 1169 1182 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1170 1183 $_arcball quaternion $q 1171 if {$_settings( isHeightmap) } {1184 if {$_settings(-isheightmap) } { 1172 1185 DoRotate 1173 1186 } … … 1330 1343 itcl::body Rappture::VtkHeightmapViewer::InitSettings { args } { 1331 1344 foreach spec $args { 1332 if { [info exists _settings($_first -$spec)] } {1345 if { [info exists _settings($_first${spec})] } { 1333 1346 # Reset global setting with dataobj specific setting 1334 set _settings($spec) $_settings($_first -$spec)1347 set _settings($spec) $_settings($_first${spec}) 1335 1348 } 1336 1349 AdjustSetting $spec … … 1350 1363 } 1351 1364 switch -- $what { 1352 " axisFlymode" {1365 "-axisflymode" { 1353 1366 set mode [$itk_component(axisflymode) value] 1354 1367 set mode [$itk_component(axisflymode) translate $mode] … … 1356 1369 SendCmd "axis flymode $mode" 1357 1370 } 1358 " axisLabels" {1371 "-axislabels" { 1359 1372 set bool $_settings($what) 1360 1373 SendCmd "axis labels all $bool" 1361 1374 } 1362 " axisMinorTicks" {1375 "-axisminorticks" { 1363 1376 set bool $_settings($what) 1364 foreach axis { x y z } { 1365 SendCmd "axis minticks ${axis} $bool" 1366 } 1367 } 1368 "axisVisible" { 1377 SendCmd "axis minticks all $bool" 1378 } 1379 "-axisvisible" { 1369 1380 set bool $_settings($what) 1370 1381 SendCmd "axis visible all $bool" 1371 1382 } 1372 " axisXGrid" - "axisYGrid" - "axisZGrid" {1373 set axis [string tolower [string range $what 4 4]]1383 "-xgrid" - "-ygrid" - "-zgrid" { 1384 set axis [string tolower [string range $what 1 1]] 1374 1385 set bool $_settings($what) 1375 1386 SendCmd "axis grid $axis $bool" 1376 1387 } 1377 " background" {1388 "-background" { 1378 1389 set bg [$itk_component(background) value] 1379 1390 array set fgcolors { … … 1390 1401 DrawLegend 1391 1402 } 1392 " colormap" {1403 "-colormap" { 1393 1404 set _changed($what) 1 1394 1405 StartBufferingCommands … … 1396 1407 set _settings($what) $color 1397 1408 if { $color == "none" } { 1398 if { $_settings( colormapVisible) } {1409 if { $_settings(-colormapvisible) } { 1399 1410 SendCmd "heightmap surface 0" 1400 set _settings( colormapVisible) 01411 set _settings(-colormapvisible) 0 1401 1412 } 1402 1413 } else { 1403 if { !$_settings( colormapVisible) } {1414 &nbs