- Timestamp:
- Feb 10, 2015, 7:59:54 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/uiuc_vtk_viewers (added) merged: 4952-4954,4991-4992
- Property svn:mergeinfo changed
-
trunk/gui/scripts/vtkisosurfaceviewer.tcl
r4967 r4993 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: vtkisosurfaceviewer - Vtk 3D contour object viewer … … 57 57 public method get {args} 58 58 public method isconnected {} 59 public method parameters {title args} { 60 # do nothing 59 public method parameters {title args} { 60 # do nothing 61 61 } 62 62 public method scale {args} … … 68 68 private method BuildColormap { name } 69 69 private method BuildCutplaneTab {} 70 private method BuildDownloadPopup { widget command } 70 private method BuildDownloadPopup { widget command } 71 71 private method BuildIsosurfaceTab {} 72 private method Combo { option }73 72 private method Connect {} 74 73 private method CurrentDatasets {args} 74 private method DisableMouseRotationBindings {} 75 75 private method Disconnect {} 76 76 private method DoChangeContourLevels {} … … 78 78 private method DoRotate {} 79 79 private method DrawLegend {} 80 private method EnterLegend { x y } 81 private method EventuallyChangeContourLevels {} 82 private method EventuallyRequestLegend {} 83 private method EventuallyResize { w h } 84 private method EventuallyRotate { q } 85 private method EventuallySetCutplane { axis args } 80 private method EnterLegend { x y } 81 private method EventuallyChangeContourLevels {} 82 private method EventuallyRequestLegend {} 83 private method EventuallyResize { w h } 84 private method EventuallyRotate { q } 85 private method EventuallySetCutplane { axis args } 86 86 private method GenerateContourList {} 87 private method GetImage { args } 88 private method GetVtkData { args } 87 private method GetImage { args } 88 private method GetVtkData { args } 89 89 private method InitSettings { args } 90 private method IsValidObject { dataobj } 90 private method IsValidObject { dataobj } 91 91 private method LeaveLegend {} 92 private method MotionLegend { x y } 92 private method LegendB1Motion {status x y} 93 private method LegendPointToValue { x y } 94 private method LegendProbeSingleContour { x y } 95 private method LegendRangeAction { option args } 96 private method LegendTitleAction { option } 97 private method MotionLegend { x y } 93 98 private method Pan {option x y} 94 99 private method PanCamera {} 95 100 private method Pick {x y} 96 private method QuaternionToView { q } { 101 private method QuaternionToView { q } { 97 102 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 98 103 } … … 108 113 private method SetObjectStyle { dataobj comp } 109 114 private method SetOrientation { side } 115 private method SetupMouseRotationBindings {} 116 private method SetupMousePanningBindings {} 117 private method SetupKeyboardBindings {} 110 118 private method Slice {option args} 111 private method ViewToQuaternion {} { 119 private method ViewToQuaternion {} { 112 120 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 113 121 } … … 119 127 private variable _obj2datasets 120 128 private variable _obj2ovride ; # maps dataobj => style override 121 private variable _datasets ; # contains all the dataobj-component 129 private variable _datasets ; # contains all the dataobj-component 122 130 ; # datasets in the server 123 131 private variable _colormaps ; # contains all the colormaps … … 157 165 private variable _legendPending 0 158 166 private variable _field "" 159 private variable _colorMode "scalar"; 160 private variable _fieldNames {} 161 private variable _fields 167 private variable _colorMode "scalar"; # Mode of colormap (vmag or scalar) 168 private variable _fieldNames {} 169 private variable _fields 162 170 private variable _curFldName "" 163 171 private variable _curFldLabel "" 172 173 private variable _mouseOver ""; # what called LegendRangeAction, vmin or vmax 164 174 } 165 175 … … 247 257 -colormap BCGYR 248 258 -colormapvisible 1 259 -customrange 0 260 -customrangevmin 0 261 -customrangevmax 1 249 262 -cutplaneedges 0 250 263 -cutplanelighting 1 … … 294 307 itk_component add fieldmenu { 295 308 menu $itk_component(plotarea).menu -bg black -fg white -relief flat \ 296 -tearoff 0 309 -tearoff 0 297 310 } { 298 311 usual 299 312 ignore -background -foreground -relief -tearoff 300 313 } 314 315 # add an editor for adjusting the legend min and max values 316 itk_component add editor { 317 Rappture::Editor $itk_interior.editor \ 318 -activatecommand [itcl::code $this LegendRangeAction activate] \ 319 -validatecommand [itcl::code $this LegendRangeAction validate] \ 320 -applycommand [itcl::code $this LegendRangeAction apply] 321 } 322 301 323 set c $itk_component(view) 302 324 bind $c <Configure> [itcl::code $this EventuallyResize %w %h] … … 314 336 315 337 set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)] 316 set _map(cwidth) -1 317 set _map(cheight) -1 338 set _map(cwidth) -1 339 set _map(cheight) -1 318 340 set _map(zoom) 1.0 319 341 set _map(original) "" … … 362 384 -offimage [Rappture::icon volume-off] \ 363 385 -variable [itcl::scope _settings(-isosurfacevisible)] \ 364 -command [itcl::code $this AdjustSetting -isosurfacevisible] 386 -command [itcl::code $this AdjustSetting -isosurfacevisible] 365 387 } 366 388 $itk_component(contour) select … … 374 396 -offimage [Rappture::icon cutbutton] \ 375 397 -variable [itcl::scope _settings(-cutplanesvisible)] \ 376 -command [itcl::code $this AdjustSetting -cutplanesvisible] 398 -command [itcl::code $this AdjustSetting -cutplanesvisible] 377 399 } 378 400 Rappture::Tooltip::for $itk_component(cutplane) \ … … 393 415 set _image(legend) [image create photo] 394 416 itk_component add legend { 395 canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 417 canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 396 418 } { 397 419 usual … … 400 422 } 401 423 402 # Hack around the Tk panewindow. The problem is that the requested 424 # Hack around the Tk panewindow. The problem is that the requested 403 425 # size of the 3d view isn't set until an image is retrieved from 404 426 # the server. So the panewindow uses the tiny size. … … 406 428 pack forget $itk_component(view) 407 429 blt::table $itk_component(plotarea) \ 408 0,0 $itk_component(view) -fill both -reqwidth $w 430 0,0 $itk_component(view) -fill both -reqwidth $w 409 431 blt::table configure $itk_component(plotarea) c1 -resize none 410 432 433 SetupMouseRotationBindings 434 SetupMousePanningBindings 435 SetupKeyboardBindings 436 437 438 #bind $itk_component(view) <ButtonRelease-3> \ 439 # [itcl::code $this Pick %x %y] 440 441 442 if {[string equal "x11" [tk windowingsystem]]} { 443 # Bindings for zoom via mouse 444 bind $itk_component(view) <4> [itcl::code $this Zoom out] 445 bind $itk_component(view) <5> [itcl::code $this Zoom in] 446 } 447 448 set _image(download) [image create photo] 449 450 eval itk_initialize $args 451 452 EnableWaitDialog 500 453 Connect 454 # FIXME: Removing this update breaks wizard mode (see examples/3D) 455 # However, it also allows an error in the initialization order 456 # where FieldResult::add is called from ResultViewer before this 457 # constructor is completed. 458 #update 459 } 460 461 # ---------------------------------------------------------------------- 462 # DESTRUCTOR 463 # ---------------------------------------------------------------------- 464 itcl::body Rappture::VtkIsosurfaceViewer::destructor {} { 465 Disconnect 466 image delete $_image(plot) 467 image delete $_image(download) 468 catch { blt::arcball destroy $_arcball } 469 } 470 471 itcl::body Rappture::VtkIsosurfaceViewer::SetupMouseRotationBindings {} { 411 472 # Bindings for rotation via mouse 412 473 bind $itk_component(view) <ButtonPress-1> \ … … 416 477 bind $itk_component(view) <ButtonRelease-1> \ 417 478 [itcl::code $this Rotate release %x %y] 418 479 } 480 481 itcl::body Rappture::VtkIsosurfaceViewer::DisableMouseRotationBindings {} { 482 # Bindings for rotation via mouse 483 bind $itk_component(view) <ButtonPress-1> "" 484 bind $itk_component(view) <B1-Motion> "" 485 bind $itk_component(view) <ButtonRelease-1> "" 486 } 487 488 itcl::body Rappture::VtkIsosurfaceViewer::SetupMousePanningBindings {} { 419 489 # Bindings for panning via mouse 420 490 bind $itk_component(view) <ButtonPress-2> \ … … 424 494 bind $itk_component(view) <ButtonRelease-2> \ 425 495 [itcl::code $this Pan release %x %y] 426 427 #bind $itk_component(view) <ButtonRelease-3> \ 428 # [itcl::code $this Pick %x %y] 429 496 } 497 498 itcl::body Rappture::VtkIsosurfaceViewer::SetupKeyboardBindings {} { 430 499 # Bindings for panning via keyboard 431 500 bind $itk_component(view) <KeyPress-Left> \ … … 453 522 454 523 bind $itk_component(view) <Enter> "focus $itk_component(view)" 455 456 if {[string equal "x11" [tk windowingsystem]]} {457 # Bindings for zoom via mouse458 bind $itk_component(view) <4> [itcl::code $this Zoom out]459 bind $itk_component(view) <5> [itcl::code $this Zoom in]460 }461 462 set _image(download) [image create photo]463 464 eval itk_initialize $args465 466 EnableWaitDialog 500467 Connect468 }469 470 # ----------------------------------------------------------------------471 # DESTRUCTOR472 # ----------------------------------------------------------------------473 itcl::body Rappture::VtkIsosurfaceViewer::destructor {} {474 Disconnect475 image delete $_image(plot)476 image delete $_image(download)477 catch { blt::arcball destroy $_arcball }478 524 } 479 525 … … 501 547 502 548 itcl::body Rappture::VtkIsosurfaceViewer::DoRotate {} { 503 SendCmd "camera orient [ViewToQuaternion]" 549 SendCmd "camera orient [ViewToQuaternion]" 504 550 set _rotatePending 0 505 551 } … … 528 574 if { !$_rotatePending } { 529 575 set _rotatePending 1 530 global rotate_delay 576 global rotate_delay 531 577 $_dispatcher event -after $rotate_delay !rotate 532 578 } … … 545 591 if { !$_contourList(updatePending) } { 546 592 set _contourList(updatePending) 1 547 global rotate_delay 593 global rotate_delay 548 594 $_dispatcher event -after $rotate_delay !contours 549 595 } … … 644 690 continue 645 691 } 646 if {[info exists _obj2ovride($dataobj-raise)] && 692 if {[info exists _obj2ovride($dataobj-raise)] && 647 693 $_obj2ovride($dataobj-raise)} { 648 694 set dlist [linsert $dlist 0 $dataobj] … … 672 718 } 673 719 return $dlist 674 } 720 } 675 721 -image { 676 722 if {[llength $args] != 2} { … … 725 771 if { ![info exists _limits($fname)] } { 726 772 set _limits($fname) $lim 773 774 # set reasonable defaults for 775 # customrangevmin and customrangevmax 776 foreach {min max} $lim break 777 if { ![info exists _settings(-customrangevmin)] } { 778 set _settings(-customrangevmin) $min 779 } 780 if { ![info exists _settings(-customrangevmax)] } { 781 set _settings(-customrangevmax) $max 782 } 783 727 784 continue 728 785 } 729 786 foreach {min max} $lim break 730 787 foreach {fmin fmax} $_limits($fname) break 788 # if { $fname == $_curFldName && ! $_settings(-customrange) } {} 789 if { ! $_settings(-customrange) } { 790 set _settings(-customrangevmin) $fmin 791 set _settings(-customrangevmax) $fmax 792 } 731 793 if { $fmin > $min } { 732 794 set fmin $min … … 911 973 #set w [image width $_image(plot)] 912 974 #set h [image height $_image(plot)] 913 #puts stderr "$date: received image ${w}x${h} image" 975 #puts stderr "$date: received image ${w}x${h} image" 914 976 if { $_start > 0 } { 915 977 set finish [clock clicks -milliseconds] … … 982 1044 # Turn on buffering of commands to the server. We don't want to 983 1045 # be preempted by a server disconnect/reconnect (which automatically 984 # generates a new call to Rebuild). 1046 # generates a new call to Rebuild). 985 1047 StartBufferingCommands 986 1048 … … 1044 1106 lappend _obj2datasets($dataobj) $tag 1045 1107 if { [info exists _obj2ovride($dataobj-raise)] } { 1046 1108 SendCmd "contour3d visible 1 $tag" 1047 1109 } 1048 1110 } … … 1051 1113 InitSettings -cutplanesvisible -isosurfacevisible -outline 1052 1114 if { $_reset } { 1053 1115 # These are settings that rely on a dataset being loaded. 1054 1116 InitSettings \ 1055 1117 -isosurfacelighting \ … … 1057 1119 -isosurfacevisible \ 1058 1120 -isosurfaceedges -isosurfacelighting -isosurfaceopacity \ 1059 1121 -isosurfacewireframe \ 1060 1122 -cutplanesvisible \ 1061 1062 1123 -xcutplaneposition -ycutplaneposition -zcutplaneposition \ 1124 -xcutplanevisible -ycutplanevisible -zcutplanevisible \ 1063 1125 -cutplanepreinterp -numcontours 1064 1126 1065 1127 Zoom reset 1066 1128 foreach axis { x y z } { 1067 1129 # Another problem fixed by a <view>. We looking into a data 1068 1130 # object for the name of the axes. This should be global to 1069 1131 # the viewer itself. 1070 1071 1132 set label [$_first hints ${axis}label] 1133 if { $label == "" } { 1072 1134 set label [string toupper $axis] 1073 1135 } 1074 1136 # May be a space in the axis label 1075 1137 SendCmd [list axis name $axis $label] 1076 1138 } 1077 1139 if { [array size _fields] < 2 } { … … 1100 1162 itcl::body Rappture::VtkIsosurfaceViewer::CurrentDatasets {args} { 1101 1163 set flag [lindex $args 0] 1102 switch -- $flag { 1164 switch -- $flag { 1103 1165 "-all" { 1104 1166 if { [llength $args] > 1 } { … … 1119 1181 set dlist [get -visible] 1120 1182 } 1121 } 1183 } 1122 1184 default { 1123 1185 set dlist $args … … 1238 1300 foreach tag [CurrentDatasets -visible] { 1239 1301 SendCmd "dataset getscalar pixel $x $y $tag" 1240 } 1302 } 1241 1303 } 1242 1304 … … 1342 1404 "-background" { 1343 1405 set bgcolor [$itk_component(background) value] 1344 1345 1346 1347 "grey""black"1348 1406 array set fgcolors { 1407 "black" "white" 1408 "white" "black" 1409 "grey" "black" 1410 } 1349 1411 configure -plotbackground $bgcolor \ 1350 1351 1352 1412 -plotforeground $fgcolors($bgcolor) 1413 $itk_component(view) delete "legend" 1414 DrawLegend 1353 1415 } 1354 1416 "-cutplaneedges" { … … 1370 1432 "-cutplanesvisible" { 1371 1433 set bool $_settings($what) 1372 1434 SendCmd "cutplane visible 0" 1373 1435 if { $bool } { 1374 1436 foreach tag [CurrentDatasets -visible] { … … 1393 1455 set color [$itk_component(colormap) value] 1394 1456 set _settings($what) $color 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1457 if { $color == "none" } { 1458 if { $_settings(-colormapvisible) } { 1459 SendCmd "contour3d colormode constant {}" 1460 set _settings(-colormapvisible) 0 1461 } 1462 } else { 1463 if { !$_settings(-colormapvisible) } { 1464 SendCmd "contour3d colormode $_colorMode $_curFldName" 1465 set _settings(-colormapvisible) 1 1466 } 1467 SetCurrentColormap $color 1468 } 1407 1469 StopBufferingCommands 1408 1470 EventuallyRequestLegend 1409 1471 } 1410 1472 "-field" { … … 1429 1491 SendCmd "dataset maprange all" 1430 1492 } else { 1431 SendCmd "dataset maprange explicit $_limits($_curFldName) $_curFldName" 1493 foreach { vmin vmax } $_limits($_curFldName) break 1494 if { $_settings(-customrange) } { 1495 if { $_settings(-customrangevmin) > $vmin } { 1496 set vmin $_settings(-customrangevmin) 1497 } 1498 if { $_settings(-customrangevmax) < $vmax } { 1499 set vmax $_settings(-customrangevmax) 1500 } 1501 } 1502 SendCmd "dataset maprange explicit $vmin $vmax $_curFldName" 1432 1503 } 1433 1504 SendCmd "cutplane colormode $_colorMode $_curFldName" … … 1439 1510 "-isolinecolor" { 1440 1511 set color [$itk_component(isolineColor) value] 1441 1442 1512 set _settings($what) $color 1513 DrawLegend 1443 1514 } 1444 1515 "-isosurfaceedges" { 1445 1516 set bool $_settings($what) 1446 1517 SendCmd "contour3d edges $bool" 1447 1518 } 1448 1519 "-isosurfacelighting" { 1449 1520 set bool $_settings($what) 1450 1521 SendCmd "contour3d lighting $bool" 1451 1522 } 1452 1523 "-isosurfaceopacity" { 1453 1524 set _settings($what) [expr $_widget($what) * 0.01] 1454 1525 SendCmd "contour3d opacity $_settings($what)" 1455 1526 } 1456 1527 "-isosurfacevisible" { 1457 1528 set bool $_settings($what) 1458 1529 SendCmd "contour3d visible 0" 1459 1530 if { $bool } { 1460 1531 foreach tag [CurrentDatasets -visible] { … … 1472 1543 "-isosurfacewireframe" { 1473 1544 set bool $_settings($what) 1474 1545 SendCmd "contour3d wireframe $bool" 1475 1546 } 1476 1547 "-legendvisible" { 1477 1548 if { !$_settings($what) } { 1478 1549 $itk_component(view) delete legend 1479 1480 1550 } 1551 DrawLegend 1481 1552 } 1482 1553 "-numcontours" { … … 1497 1568 "-outline" { 1498 1569 set bool $_settings($what) 1499 1570 SendCmd "outline visible 0" 1500 1571 if { $bool } { 1501 1572 foreach tag [CurrentDatasets -visible] { … … 1503 1574 } 1504 1575 } 1576 } 1577 "-range" { 1578 foreach { vmin vmax } $_limits($_curFldName) break 1579 if { $_settings(-customrange) } { 1580 $itk_component(l_min) configure -state normal 1581 $itk_component(min) configure -state normal 1582 $itk_component(l_max) configure -state normal 1583 $itk_component(max) configure -state normal 1584 # foreach { vmin vmax } $_limits($_curFldName) break 1585 # if { $_settings(-customrangevmin) < $vmin } { 1586 # set _settings(-customrangevmin) $vmin 1587 # } 1588 # if { $_settings(-customrangevmin) > $vmax } { 1589 # set _settings(-customrangevmin) $vmax 1590 # } 1591 # if { $_settings(-customrangevmax) < $vmin } { 1592 # set _settings(-customrangevmax) $vmin 1593 # } 1594 # if { $_settings(-customrangevmax) > $vmax } { 1595 # set _settings(-customrangevmax) $vmax 1596 # } 1597 # 1598 if { $_settings(-customrangevmin) > $vmin } { 1599 set vmin $_settings(-customrangevmin) 1600 } 1601 if { $_settings(-customrangevmax) < $vmax } { 1602 set vmax $_settings(-customrangevmax) 1603 } 1604 } else { 1605 $itk_component(l_min) configure -state disabled 1606 $itk_component(min) configure -state disabled 1607 $itk_component(l_max) configure -state disabled 1608 $itk_component(max) configure -state disabled 1609 } 1610 GenerateContourList 1611 SendCmd [list contour3d contourlist $_contourList(values)] 1612 SendCmd "dataset maprange explicit $vmin $vmax $_curFldName" 1613 DrawLegend 1505 1614 } 1506 1615 "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" { … … 1514 1623 -troughcolor grey82 1515 1624 } 1516 1625 SendCmd "cutplane axis $axis $bool" 1517 1626 } 1518 1627 "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" { … … 1537 1646 # 1538 1647 # Request a new legend from the server. The size of the legend 1539 # is determined from the height of the canvas. 1648 # is determined from the height of the canvas. 1540 1649 # 1541 1650 # This should be called when 1542 # 1543 # 1544 # 1545 # 1546 # 1651 # 1. A new current colormap is set. 1652 # 2. Window is resized. 1653 # 3. The limits of the data have changed. (Just need a redraw). 1654 # 4. Number of isolines have changed. (Just need a redraw). 1655 # 5. Legend becomes visible (Just need a redraw). 1547 1656 # 1548 1657 itcl::body Rappture::VtkIsosurfaceViewer::RequestLegend {} { … … 1560 1669 } 1561 1670 if { [string match "component*" $fname] } { 1562 1671 set title "" 1563 1672 } else { 1564 1565 1566 1567 1568 1569 1570 1571 1673 if { [info exists _fields($fname)] } { 1674 foreach { title units } $_fields($fname) break 1675 if { $units != "" } { 1676 set title [format "%s (%s)" $title $units] 1677 } 1678 } else { 1679 set title $fname 1680 } 1572 1681 } 1573 1682 # If there's a title too, subtract one more line 1574 1683 if { $title != "" } { 1575 incr h -$lineht 1576 } 1577 # Set the legend on the first heightmapdataset.1684 incr h -$lineht 1685 } 1686 # Set the legend on the first isosurface dataset. 1578 1687 if { $_currentColormap != "" } { 1579 1580 1688 set cmap $_currentColormap 1689 SendCmdNoWait "legend $cmap scalar $_curFldName {} $w $h 0" 1581 1690 } 1582 1691 } … … 1598 1707 if { [isconnected] } { 1599 1708 set rgb [Color2RGB $itk_option(-plotforeground)] 1600 1709 SendCmd "axis color all $rgb" 1601 1710 SendCmd "outline color $rgb" 1602 1711 SendCmd "cutplane color $rgb" … … 1650 1759 -font "Arial 9" 1651 1760 1652 label $inner.linecolor_l -text "Isolines" -font "Arial 9" 1761 label $inner.linecolor_l -text "Isolines" -font "Arial 9" 1653 1762 itk_component add isolineColor { 1654 1763 Rappture::Combobox $inner.linecolor -width 10 -editable 0 … … 1664 1773 "red" "red" \ 1665 1774 "white" "white" \ 1666 "none""none"1775 "none" "none" 1667 1776 1668 1777 $itk_component(isolineColor) value "white" 1669 1778 bind $inner.linecolor <<Value>> \ 1670 1671 1672 label $inner.background_l -text "Background" -font "Arial 9" 1779 [itcl::code $this AdjustSetting -isolinecolor] 1780 1781 label $inner.background_l -text "Background" -font "Arial 9" 1673 1782 itk_component add background { 1674 1783 Rappture::Combobox $inner.background -width 10 -editable 0 … … 1677 1786 "black" "black" \ 1678 1787 "white" "white" \ 1679 "grey" "grey" 1788 "grey" "grey" 1680 1789 1681 1790 $itk_component(background) value $_settings(-background) … … 1692 1801 1693 1802 itk_component add field_l { 1694 label $inner.field_l -text "Field" -font "Arial 9" 1803 label $inner.field_l -text "Field" -font "Arial 9" 1695 1804 } { 1696 1805 ignore -font … … 1702 1811 [itcl::code $this AdjustSetting -field] 1703 1812 1704 label $inner.colormap_l -text "Colormap" -font "Arial 9" 1813 label $inner.colormap_l -text "Colormap" -font "Arial 9" 1705 1814 itk_component add colormap { 1706 1815 Rappture::Combobox $inner.colormap -width 10 -editable 0 … … 1720 1829 bind $itk_component(numcontours) <<Value>> \ 1721 1830 [itcl::code $this AdjustSetting -numcontours] 1831 1832 1833 # add widgets for setting a custom range on the legend 1834 1835 itk_component add crange { 1836 checkbutton $inner.crange \ 1837 -text "Use Custom Range:" \ 1838 -variable [itcl::scope _settings(-customrange)] \ 1839 -command [itcl::code $this AdjustSetting -range] \ 1840 -font "Arial 9" 1841 } 1842 1843 itk_component add l_min { 1844 label $inner.l_min -text "Min" -font "Arial 9" 1845 } 1846 itk_component add min { 1847 entry $inner.min -font "Arial 9" -bg white \ 1848 -textvariable [itcl::scope _settings(-customrangevmin)] 1849 } { 1850 ignore -font -background 1851 } 1852 bind $inner.min <Return> \ 1853 [itcl::code $this AdjustSetting -range] 1854 bind $inner.min <KP_Enter> \ 1855 [itcl::code $this AdjustSetting -range] 1856 1857 itk_component add l_max { 1858 label $inner.l_max -text "Max" -font "Arial 9" 1859 } 1860 itk_component add max { 1861 entry $inner.max -font "Arial 9" -bg white \ 1862 -textvariable [itcl::scope _settings(-customrangevmax)] 1863 } { 1864 ignore -font -background 1865 } 1866 bind $inner.max <Return> \ 1867 [itcl::code $this AdjustSetting -range] 1868 bind $inner.max <KP_Enter> \ 1869 [itcl::code $this AdjustSetting -range] 1870 1871 $itk_component(min) configure -state disabled 1872 $itk_component(max) configure -state disabled 1873 1722 1874 1723 1875 blt::table $inner \ … … 1728 1880 2,0 $inner.linecolor_l -anchor w -pady 2 \ 1729 1881 2,1 $inner.linecolor -anchor w -pady 2 -fill x \ 1730 1731 1882 3,0 $inner.background_l -anchor w -pady 2 \ 1883 3,1 $inner.background -anchor w -pady 2 -fill x \ 1732 1884 4,0 $inner.numcontours_l -anchor w -pady 2 \ 1733 1885 4,1 $inner.numcontours -anchor w -pady 2 \ … … 1739 1891 10,0 $inner.opacity_l -anchor w -pady 2 \ 1740 1892 10,1 $inner.opacity -fill x -pady 2 -fill x \ 1893 11,0 $inner.crange -anchor w -pady 2 -cspan 2 \ 1894 12,0 $inner.l_min -anchor w -pady 2 \ 1895 12,1 $inner.min -anchor w -pady 2 -fill x \ 1896 13,0 $inner.l_max -anchor w -pady 2 \ 1897 13,1 $inner.max -anchor w -pady 2 -fill x \ 1741 1898 1742 1899 blt::table configure $inner r* c* -resize none 1743 blt::table configure $inner r1 1c1 -resize expand1900 blt::table configure $inner r14 c1 -resize expand 1744 1901 } 1745 1902 … … 1765 1922 -command [itcl::code $this AdjustSetting -axislabels] \ 1766 1923 -font "Arial 9" 1767 label $inner.grid_l -text "Grid" -font "Arial 9" 1924 label $inner.grid_l -text "Grid" -font "Arial 9" 1768 1925 checkbutton $inner.xgrid \ 1769 1926 -text "X" \ … … 1787 1944 -font "Arial 9" 1788 1945 1789 label $inner.mode_l -text "Mode" -font "Arial 9" 1946 label $inner.mode_l -text "Mode" -font "Arial 9" 1790 1947 1791 1948 itk_component add axisMode { … … 1796 1953 "closest_triad" "closest" \ 1797 1954 "furthest_triad" "farthest" \ 1798 "outer_edges" "outer" 1955 "outer_edges" "outer" 1799 1956 $itk_component(axisMode) value $_settings(-axismode) 1800 1957 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode] … … 1871 2028 1872 2029 set fg [option get $itk_component(hull) font Font] 1873 2030 1874 2031 set inner [$itk_component(main) insert end \ 1875 2032 -title "Cutplane Settings" \ 1876 -icon [Rappture::icon cutbutton]] 2033 -icon [Rappture::icon cutbutton]] 1877 2034 1878 2035 $inner configure -borderwidth 4 … … 1933 2090 -command [itcl::code $this EventuallySetCutplane x] \ 1934 2091 -variable [itcl::scope _settings(-xcutplaneposition)] \ 1935 2092 -foreground red2 -font "Arial 9 bold" 1936 2093 } { 1937 2094 usual … … 1962 2119 -command [itcl::code $this EventuallySetCutplane y] \ 1963 2120 -variable [itcl::scope _settings(-ycutplaneposition)] \ 1964 2121 -foreground green3 -font "Arial 9 bold" 1965 2122 } { 1966 2123 usual … … 1981 2138 -variable [itcl::scope _settings(-zcutplanevisible)] \ 1982 2139 } { 1983 1984 2140 usual 2141 ignore -foreground 1985 2142 } 1986 2143 Rappture::Tooltip::for $itk_component(zbutton) \ … … 1994 2151 -command [itcl::code $this EventuallySetCutplane z] \ 1995 2152 -variable [itcl::scope _settings(-zcutplaneposition)] \ 1996 2153 -foreground blue3 -font "Arial 9 bold" 1997 2154 } { 1998 2155 usual … … 2012 2169 5,0 $inner.opacity_l -anchor w -pady 2 -cspan 1 \ 2013 2170 5,1 $inner.opacity -fill x -pady 2 -cspan 3 \ 2014 6,0 $inner.xbutton 2015 7,0 $inner.ybutton 2016 8,0 $inner.zbutton 2017 6,1 $inner.xval 2018 6,2 $inner.yval 2019 6,3 $inner.zval 2171 6,0 $inner.xbutton -anchor w -padx 2 -pady 2 \ 2172 7,0 $inner.ybutton -anchor w -padx 2 -pady 2 \ 2173 8,0 $inner.zbutton -anchor w -padx 2 -pady 2 \ 2174 6,1 $inner.xval -fill y -rspan 4 \ 2175 6,2 $inner.yval -fill y -rspan 4 \ 2176 6,3 $inner.zval -fill y -rspan 4 \ 2020 2177 2021 2178 … … 2025 2182 2026 2183 # 2027 # camera -- 2184 # camera -- 2028 2185 # 2029 2186 itcl::body Rappture::VtkIsosurfaceViewer::camera {option args} { 2030 switch -- $option { 2187 switch -- $option { 2031 2188 "show" { 2032 2189 puts [array get _view] … … 2076 2233 2077 2234 itcl::body Rappture::VtkIsosurfaceViewer::GetImage { args } { 2078 if { [image width $_image(download)] > 0 && 2235 if { [image width $_image(download)] > 0 && 2079 2236 [image height $_image(download)] > 0 } { 2080 2237 set bytes [$_image(download) data -format "jpeg -quality 100"] … … 2089 2246 -title "[Rappture::filexfer::label downloadWord] as..." 2090 2247 set inner [$popup component inner] 2091 label $inner.summary -text "" -anchor w 2248 label $inner.summary -text "" -anchor w 2092 2249 radiobutton $inner.vtk_button -text "VTK data file" \ 2093 2250 -variable [itcl::scope _downloadPopup(format)] \ 2094 2251 -font "Arial 9 " \ 2095 -value vtk 2252 -value vtk 2096 2253 Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file." 2097 2254 radiobutton $inner.image_button -text "Image File" \ 2098 2255 -variable [itcl::scope _downloadPopup(format)] \ 2099 2256 -font "Arial 9 " \ 2100 -value image 2257 -value image 2101 2258 Rappture::Tooltip::for $inner.image_button \ 2102 2259 "Save as digital image." … … 2119 2276 2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \ 2120 2277 4,1 $inner.cancel -width .9i -fill y \ 2121 4,0 $inner.ok -padx 2 -width .9i -fill y 2278 4,0 $inner.ok -padx 2 -width .9i -fill y 2122 2279 blt::table configure $inner r3 -height 4 2123 2280 blt::table configure $inner r4 -pady 4 … … 2132 2289 array set style { 2133 2290 -color BCGYR 2134 -cutplanesvisible 0 2291 -cutplanesvisible 0 2135 2292 -edgecolor black 2136 2293 -edges 0 … … 2184 2341 set _contourList(numLevels) $style(-levels) 2185 2342 } 2186 EventuallyChangeContourLevels 2343 EventuallyChangeContourLevels 2187 2344 } 2188 2345 set _settings(-isosurfacevisible) $style(-isosurfacevisible) … … 2194 2351 set _settings(-ycutplaneposition) $style(-ycutplaneposition) 2195 2352 set _settings(-zcutplaneposition) $style(-zcutplaneposition) 2196 2353 2197 2354 SendCmd "cutplane add $tag" 2198 2355 SendCmd "cutplane color [Color2RGB $itk_option(-plotforeground)] $tag" … … 2209 2366 SendCmd "outline visible $style(-outline) $tag" 2210 2367 set _settings(-outline) $style(-outline) 2211 2368 2212 2369 GenerateContourList 2213 2370 SendCmd [list contour3d add contourlist $_contourList(values) $tag] … … 2222 2379 SendCmd "contour3d opacity $style(-opacity) $tag" 2223 2380 set _settings(-isosurfaceopacity) $style(-opacity) 2224 SetCurrentColormap $style(-color) 2381 SetCurrentColormap $style(-color) 2225 2382 SendCmd "contour3d wireframe $style(-wireframe) $tag" 2226 2383 set _settings(-isosurfacewireframe) $style(-wireframe) … … 2262 2419 } 2263 2420 2421 # ---------------------------------------------------------------------- 2422 # USAGE: LegendB1Motion press <x> <y> 2423 # USAGE: LegendB1Motion motion <x> <y> 2424 # USAGE: LegendB1Motion release <x> <y> 2425 # 2426 # Manage actions for Button 1 presses that happen over the legend. 2427 # Pressing mouse Button 1 on the legend sends a command to the 2428 # visualization server to show a specific isosurface. 2429 # ---------------------------------------------------------------------- 2430 itcl::body Rappture::VtkIsosurfaceViewer::LegendB1Motion { status x y } { 2431 2432 switch -- $status { 2433 "press" { 2434 DisableMouseRotationBindings 2435 LegendProbeSingleContour $x $y 2436 } 2437 "motion" { 2438 DisableMouseRotationBindings 2439 LegendProbeSingleContour $x $y 2440 } 2441 "release" { 2442 AdjustSetting -range 2443 SetupMouseRotationBindings 2444 } 2445 default { 2446 error "bad option \"$option\": should be one of press, motion, release." 2447 } 2448 } 2449 } 2450 2451 2452 # ---------------------------------------------------------------------- 2453 # USAGE: LegendPointToValue <x> <y> 2454 # 2455 # Convert an x,y point on the legend to a numeric isosurface value. 2456 # ---------------------------------------------------------------------- 2457 itcl::body Rappture::VtkIsosurfaceViewer::LegendPointToValue { x y } { 2458 2459 set fname $_curFldName 2460 2461 set font "Arial 8" 2462 set lineht [font metrics $font -linespace] 2463 2464 set ih [image height $_image(legend)] 2465 set iy [expr $y - ($lineht + 2)] 2466 2467 # Compute the value of the point 2468 if { [info exists _limits($fname)] } { 2469 if { $_settings(-customrange) } { 2470 set vmin $_settings(-customrangevmin) 2471 set vmax $_settings(-customrangevmax) 2472 } else { 2473 foreach { vmin vmax } $_limits($fname) break 2474 } 2475 set t [expr 1.0 - (double($iy) / double($ih-1))] 2476 set value [expr $t * ($vmax - $vmin) + $vmin] 2477 } else { 2478 set value 0.0 2479 } 2480 return $value 2481 } 2482 2483 2484 # ---------------------------------------------------------------------- 2485 # USAGE: LegendProbeSingleContour <x> <y> 2486 # 2487 # Calculate the isosurface value for the x,y point and send a commands 2488 # to the visualization server to show that isosurface. 2489 # ---------------------------------------------------------------------- 2490 itcl::body Rappture::VtkIsosurfaceViewer::LegendProbeSingleContour { x y } { 2491 2492 set value [LegendPointToValue $x $y] 2493 SendCmd [list contour3d contourlist $value] 2494 } 2495 2496 2264 2497 # 2265 2498 # SetLegendTip -- … … 2273 2506 set font "Arial 8" 2274 2507 set lineht [font metrics $font -linespace] 2275 2508 2276 2509 set ih [image height $_image(legend)] 2277 2510 set iy [expr $y - ($lineht + 2)] 2278 2511 2279 2512 if { [string match "component*" $fname] } { 2280 2513 set title "" 2281 2514 } else { 2282 2283 2284 2285 2286 2287 2288 2289 2515 if { [info exists _fields($fname)] } { 2516 foreach { title units } $_fields($fname) break 2517 if { $units != "" } { 2518 set title [format "%s (%s)" $title $units] 2519 } 2520 } else { 2521 set title $fname 2522 } 2290 2523 } 2291 2524 # If there's a legend title, increase the offset by the line height. … … 2301 2534 } 2302 2535 set color [eval format "\#%02x%02x%02x" $pixel] 2303 $_image(swatch) put black -to 0 0 23 23 2304 $_image(swatch) put $color -to 1 1 22 22 2536 $_image(swatch) put black -to 0 0 23 23 2537 $_image(swatch) put $color -to 1 1 22 22 2305 2538 .rappturetooltip configure -icon $_image(swatch) 2306 2539 2307 2540 # Compute the value of the point 2308 if { [info exists _limits($_curFldName)] } { 2309 foreach { vmin vmax } $_limits($_curFldName) break 2310 set t [expr 1.0 - (double($iy) / double($ih-1))] 2311 set value [expr $t * ($vmax - $vmin) + $vmin] 2312 } else { 2313 set value 0.0 2314 } 2315 set tx [expr $x + 15] 2541 set value [LegendPointToValue $x $y] 2542 2543 # Setup the location of the tooltip 2544 set tx [expr $x + 15] 2316 2545 set ty [expr $y - 5] 2546 2547 # Setup the text for the tooltip 2317 2548 if { [info exists _isolines($y)] } { 2318 2549 Rappture::Tooltip::text $c [format "$title %g (isosurface)" $_isolines($y)] … … 2320 2551 Rappture::Tooltip::text $c [format "$title %g" $value] 2321 2552 } 2322 Rappture::Tooltip::tooltip show $c +$tx,+$ty 2553 2554 # Show the tooltip 2555 Rappture::Tooltip::tooltip show $c +$tx,+$ty 2323 2556 } 2324 2557 … … 2354 2587 2355 2588 # 2356 # ReceiveLegend -- 2357 # 2358 # 2359 # 2360 # 2589 # ReceiveLegend -- 2590 # 2591 # Invoked automatically whenever the "legend" command comes in from 2592 # the rendering server. Indicates that binary image data with the 2593 # specified <size> will follow. 2361 2594 # 2362 2595 itcl::body Rappture::VtkIsosurfaceViewer::ReceiveLegend { colormap title min max size } { 2363 # puts stderr "ReceiveLegend colormap=$colormap title=$title range=$min,$max size=$size"2596 # puts stderr "ReceiveLegend colormap=$colormap title=$title range=$min,$max size=$size" 2364 2597 set _title $title 2365 regsub {\(mag\)} $title "" _title 2598 regsub {\(mag\)} $title "" _title 2366 2599 if { [IsConnected] } { 2367 2600 set bytes [ReceiveBytes $size] … … 2372 2605 #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" 2373 2606 if { [catch {DrawLegend} errs] != 0 } { 2374 2375 2607 global errorInfo 2608 puts stderr "errs=$errs errorInfo=$errorInfo" 2376 2609 } 2377 2610 } … … 2381 2614 # DrawLegend -- 2382 2615 # 2383 # Draws the legend in the owncanvas on the right side of the plot area.2616 # Draws the legend on the canvas on the right side of the plot area. 2384 2617 # 2385 2618 itcl::body Rappture::VtkIsosurfaceViewer::DrawLegend {} { … … 2392 2625 2393 2626 if { [string match "component*" $fname] } { 2394 2627 set title "" 2395 2628 } else { 2396 2397 2398 2399 2400 2401 2402 2403 2629 if { [info exists _fields($fname)] } { 2630 foreach { title units } $_fields($fname) break 2631 if { $units != "" } { 2632 set title [format "%s (%s)" $title $units] 2633 } 2634 } else { 2635 set title $fname 2636 } 2404 2637 } 2405 2638 set x [expr $w - 2] 2406 2639 if { !$_settings(-legendvisible) } { 2407 2408 2409 } 2640 $c delete legend 2641 return 2642 } 2410 2643 if { [$c find withtag "legend"] == "" } { 2411 set y 2 2412 2644 set y 2 2645 # If there's a legend title, create a text item for the title. 2413 2646 $c create text $x $y \ 2414 2415 2416 -font $font 2647 -anchor ne \ 2648 -fill $itk_option(-plotforeground) -tags "title legend" \ 2649 -font $font 2417 2650 if { $title != "" } { 2418 2651 incr y $lineht 2419 2652 } 2420 $c create text $x $y \ 2421 -anchor ne \ 2422 -fill $itk_option(-plotforeground) -tags "vmax legend" \ 2423 -font $font 2424 incr y $lineht 2425 $c create image $x $y \ 2426 -anchor ne \ 2427 -image $_image(legend) -tags "colormap legend" 2428 $c create rectangle $x $y 1 1 \ 2429 -fill "" -outline "" -tags "sensor legend" 2430 $c create text $x [expr {$h-2}] \ 2431 -anchor se \ 2432 -fill $itk_option(-plotforeground) -tags "vmin legend" \ 2433 -font $font 2434 $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y] 2435 $c bind sensor <Leave> [itcl::code $this LeaveLegend] 2436 $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y] 2653 $c create text $x $y \ 2654 -anchor ne \ 2655 -fill $itk_option(-plotforeground) -tags "vmax legend" \ 2656 -font $font 2657 incr y $lineht 2658 $c create image $x $y \ 2659 -anchor ne \ 2660 -image $_image(legend) -tags "colormap legend" 2661 $c create rectangle $x $y 1 1 \ 2662 -fill "" -outline "" -tags "sensor legend" 2663 $c create text $x [expr {$h-2}] \ 2664 -anchor se \ 2665 -fill $itk_option(-plotforeground) -tags "vmin legend" \ 2666 -font $font 2667 $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y] 2668 $c bind sensor <Leave> [itcl::code $this LeaveLegend] 2669 $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y] 2670 $c bind sensor <ButtonPress-1> [itcl::code $this LegendB1Motion press %x %y] 2671 # $c bind sensor <B1-Motion> [itcl::code $this LegendB1Motion motion %x %y] 2672 $c bind sensor <ButtonRelease-1> [itcl::code $this LegendB1Motion release %x %y] 2673 2437 2674 } 2438 2675 $c delete isoline … … 2447 2684 $_settings(-numcontours) > 0 } { 2448 2685 2449 foreach { vmin vmax } $_limits($_curFldName) break 2686 if { $_settings(-customrange) } { 2687 set vmin $_settings(-customrangevmin) 2688 set vmax $_settings(-customrangevmax) 2689 } else { 2690 foreach { vmin vmax } $_limits($_curFldName) break 2691 } 2450 2692 set range [expr double($vmax - $vmin)] 2451 2693 if { $range <= 0.0 } { … … 2453 2695 } 2454 2696 set tags "isoline legend" 2455 2456 2457 2458 2697 set offset [expr 2 + $lineht] 2698 if { $title != "" } { 2699 incr offset $lineht 2700 } 2459 2701 foreach value $_contourList(values) { 2460 2702 set norm [expr 1.0 - (($value - $vmin) / $range)] … … 2468 2710 } 2469 2711 2470 $c bind title <ButtonPress> [itcl::code $this Combopost]2471 $c bind title <Enter> [itcl::code $this Combo activate]2472 $c bind title <Leave> [itcl::code $this Combo deactivate]2712 $c bind title <ButtonPress> [itcl::code $this LegendTitleAction post] 2713 $c bind title <Enter> [itcl::code $this LegendTitleAction enter] 2714 $c bind title <Leave> [itcl::code $this LegendTitleAction leave] 2473 2715 # Reset the item coordinates according the current size of the plot. 2474 2716 $c itemconfigure title -text $title 2475 2717 if { [info exists _limits($_curFldName)] } { 2476 foreach { vmin vmax } $_limits($_curFldName) break 2477 $c itemconfigure vmin -text [format %g $vmin] 2478 $c itemconfigure vmax -text [format %g $vmax] 2718 if { $_settings(-customrange) } { 2719 set vmin $_settings(-customrangevmin) 2720 set vmax $_settings(-customrangevmax) 2721 } else { 2722 foreach { vmin vmax } $_limits($_curFldName) break 2723 } 2724 $c itemconfigure vmin -text [format %g $vmin] 2725 $c itemconfigure vmax -text [format %g $vmax] 2479 2726 } 2480 2727 set y 2 … … 2482 2729 if { $title != "" } { 2483 2730 $c itemconfigure title -text $title 2484 2485 2731 $c coords title $x $y 2732 incr y $lineht 2486 2733 $c raise title 2487 2734 } … … 2492 2739 $c raise sensor 2493 2740 $c coords vmin $x [expr {$h - 2}] 2494 } 2495 2496 # ---------------------------------------------------------------------- 2497 # USAGE: _dropdown post 2498 # USAGE: _dropdown unpost 2499 # USAGE: _dropdown select 2500 # 2501 # Used internally to handle the dropdown list for this combobox. The 2502 # post/unpost options are invoked when the list is posted or unposted 2503 # to manage the relief of the controlling button. The select option 2504 # is invoked whenever there is a selection from the list, to assign 2505 # the value back to the gauge. 2506 # ---------------------------------------------------------------------- 2507 itcl::body Rappture::VtkIsosurfaceViewer::Combo {option} { 2508 set c $itk_component(view) 2741 2742 $c bind vmin <ButtonPress> [itcl::code $this LegendRangeAction popup vmin] 2743 $c bind vmin <Enter> [itcl::code $this LegendRangeAction enter vmin] 2744 $c bind vmin <Leave> [itcl::code $this LegendRangeAction leave vmin] 2745 2746 $c bind vmax <ButtonPress> [itcl::code $this LegendRangeAction popup vmax] 2747 $c bind vmax <Enter> [itcl::code $this LegendRangeAction enter vmax] 2748 $c bind vmax <Leave> [itcl::code $this LegendRangeAction leave vmax] 2749 } 2750 2751 # ---------------------------------------------------------------------- 2752 # USAGE: LegendTitleAction post 2753 # USAGE: LegendTitleAction enter 2754 # USAGE: LegendTitleAction leave 2755 # USAGE: LegendTitleAction save 2756 # 2757 # Used internally to handle the dropdown list for the fields menu combobox. 2758 # The post option is invoked when the field title is pressed to launch the 2759 # dropdown. The enter option is invoked when the user mouses over the field 2760 # title. The leave option is invoked when the user moves the mouse away 2761 # from the field title. The save option is invoked whenever there is a 2762 # selection from the list, to alert the visualization server. 2763 # 2764 # ---------------------------------------------------------------------- 2765 itcl::body Rappture::VtkIsosurfaceViewer::LegendTitleAction {option} { 2766 set c $itk_component(view) 2509 2767 switch -- $option { 2510 2768 post { … … 2517 2775 tk_popup $itk_component(fieldmenu) $x $y 2518 2776 } 2519 activate{2777 enter { 2520 2778 $c itemconfigure title -fill red 2521 2779 } 2522 deactivate {2523 $c itemconfigure title -fill $itk_option(-plotforeground) 2524 } 2525 invoke {2780 leave { 2781 $c itemconfigure title -fill $itk_option(-plotforeground) 2782 } 2783 save { 2526 2784 $itk_component(field) value $_curFldLabel 2527 2785 AdjustSetting -field 2528 2786 } 2529 2787 default { 2530 error "bad option \"$option\": should be post, unpost, select" 2788 error "bad option \"$option\": should be post, enter, leave, save" 2789 } 2790 } 2791 } 2792 2793 # ---------------------------------------------------------------------- 2794 # USAGE: LegendRangeAction enter <which> 2795 # USAGE: LegendRangeAction leave <which> 2796 # 2797 # USAGE: LegendTitleAction popup <which> 2798 # USAGE: LegendTitleAction activate 2799 # USAGE: LegendTitleAction validate <value> 2800 # USAGE: LegendTitleAction apply <value> 2801 # 2802 # Used internally to handle the mouseover and popup entry for the field range 2803 # inputs. The enter option is invoked when the user moves the mouse over the 2804 # min or max field range. The leave option is invoked when the user moves the 2805 # mouse away from the min or max field range. The popup option is invoked when 2806 # the user click's on a field range. The popup option stores internally which 2807 # widget is requesting a popup ( in the _mouseOver variable) and calls the 2808 # activate command of the widget. The widget's activate command calls back to 2809 # this method to get the xywh dimensions of the popup editor. After the user 2810 # changes focus or sets the value in the editor, the editor calls this methods 2811 # validate and apply options to set the value. 2812 # 2813 # ---------------------------------------------------------------------- 2814 itcl::body Rappture::VtkIsosurfaceViewer::LegendRangeAction {option args} { 2815 set c $itk_component(view) 2816 # FIXME: check $which for valid values 2817 switch -- $option { 2818 enter { 2819 set which [lindex $args 0] 2820 $c itemconfigure $which -fill red 2821 } 2822 leave { 2823 set which [lindex $args 0] 2824 $c itemconfigure $which -fill $itk_option(-plotforeground) 2825 } 2826 popup { 2827 DisableMouseRotationBindings 2828 set which [lindex $args 0] 2829 set _mouseOver $which 2830 $itk_component(editor) activate 2831 } 2832 activate { 2833 foreach { x1 y1 x2 y2 } [$c bbox $_mouseOver] break 2834 set info(text) $_settings(-customrange$_mouseOver) 2835 set info(x) [expr $x1 + [winfo rootx $c]] 2836 set info(y) [expr $y1 + [winfo rooty $c]] 2837 set info(w) [expr $x2 - $x1] 2838 set info(h) [expr $y2 - $y1] 2839 return [array get info] 2840 } 2841 validate { 2842 if {[llength $args] != 1} { 2843 error "wrong # args: should be \"editor validate value\"" 2844 } 2845 SetupMouseRotationBindings 2846 } 2847 apply { 2848 if {[llength $args] != 1} { 2849 error "wrong # args: should be \"editor apply value\"" 2850 } 2851 set _settings(-customrange$_mouseOver) [lindex $args 0] 2852 $itk_component(crange) select 2853 AdjustSetting -range 2854 } 2855 default { 2856 error "bad option \"$option\": should be enter, leave, activate, validate, apply" 2531 2857 } 2532 2858 } … … 2539 2865 # Keep track of the colormaps that we build. 2540 2866 if { ![info exists _colormaps($name)] } { 2541 BuildColormap $name 2867 BuildColormap $name 2542 2868 set _colormaps($name) 1 2543 2869 } … … 2561 2887 } 2562 2888 2563 itcl::body Rappture::VtkIsosurfaceViewer::SetOrientation { side } { 2889 itcl::body Rappture::VtkIsosurfaceViewer::SetOrientation { side } { 2564 2890 array set positions { 2565 2891 front "1 0 0 0" … … 2582 2908 } 2583 2909 2584 itcl::body Rappture::VtkIsosurfaceViewer::GenerateContourList {} { 2910 itcl::body Rappture::VtkIsosurfaceViewer::GenerateContourList {} { 2585 2911 if { ![info exists _limits($_curFldName)] } { 2586 2912 puts stderr "no _curFldName" … … 2595 2921 set values $_contourList(reqValues) 2596 2922 } else { 2923 # use the field limits to calculate the contour list values 2597 2924 foreach { vmin vmax } $_limits($_curFldName) break 2925 2926 # if custom range has been set and are within the field's 2927 # range, use the custom min and max to generate contour list values 2928 if { $_settings(-customrange) } { 2929 if { $_settings(-customrangevmin) > $vmin } { 2930 set vmin $_settings(-customrangevmin) 2931 } 2932 if { $_settings(-customrangevmax) < $vmax } { 2933 set vmax $_settings(-customrangevmax) 2934 } 2935 } 2936 2598 2937 set v [blt::vector create \#auto] 2599 2938 $v seq $vmin $vmax [expr $_contourList(numLevels)+2] … … 2605 2944 } 2606 2945 2607 itcl::body Rappture::VtkIsosurfaceViewer::SetCurrentFieldName { dataobj } { 2946 itcl::body Rappture::VtkIsosurfaceViewer::SetCurrentFieldName { dataobj } { 2608 2947 set _first $dataobj 2609 2948 $itk_component(field) choices delete 0 end … … 2625 2964 -activeforeground $itk_option(-plotforeground) \ 2626 2965 -font "Arial 8" \ 2627 -command [itcl::code $this Combo invoke]2966 -command [itcl::code $this LegendTitleAction save] 2628 2967 set _fields($fname) [list $label $units $components] 2629 2968 if { $_curFldName == "" } {
Note: See TracChangeset
for help on using the changeset viewer.