Changeset 4208
- Timestamp:
- Mar 6, 2014, 1:05:05 PM (11 years ago)
- Location:
- branches/1.3/gui/scripts
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3/gui/scripts/vtkheightmapviewer.tcl
r3844 r4208 64 64 public method scale {args} 65 65 66 protected method CameraReset {} 66 67 protected method Connect {} 67 68 protected method CurrentDatasets {args} … … 124 125 private variable _currentOpacity "" 125 126 127 private variable _maxScale 100; # This is the # of times the x-axis 128 # and y-axis ranges can differ before 129 # automatically turning on 130 # -stretchtofit 131 126 132 private variable _click ; # info used for rotate operations 127 133 private variable _limits ; # Holds overall limits for all dataobjs … … 154 160 private variable _curFldName "" 155 161 private variable _curFldLabel "" 156 private variable _colorMode " vmag";# Mode of colormap (vmag or scalar)162 private variable _colorMode "scalar";# Mode of colormap (vmag or scalar) 157 163 } 158 164 … … 283 289 -highlightthickness 0 \ 284 290 -image [Rappture::icon reset-view] \ 285 -command [itcl::code $this Zoom reset]291 -command [itcl::code $this CameraReset] 286 292 } { 287 293 usual 288 294 ignore -highlightthickness 289 295 } 290 pack $itk_component(reset) -side top -padx 2 -pady 2296 pack $itk_component(reset) -side top -padx 2 -pady { 2 0 } 291 297 Rappture::Tooltip::for $itk_component(reset) "Reset the view to the default zoom level" 292 298 … … 300 306 ignore -highlightthickness 301 307 } 302 pack $itk_component(zoomin) -side top -padx 2 -pady 2308 pack $itk_component(zoomin) -side top -padx 2 -pady { 2 0 } 303 309 Rappture::Tooltip::for $itk_component(zoomin) "Zoom in" 304 310 … … 312 318 ignore -highlightthickness 313 319 } 314 pack $itk_component(zoomout) -side top -padx 2 -pady 2320 pack $itk_component(zoomout) -side top -padx 2 -pady { 2 0 } 315 321 Rappture::Tooltip::for $itk_component(zoomout) "Zoom out" 316 322 … … 324 330 Rappture::Tooltip::for $itk_component(mode) \ 325 331 "Toggle the surface/contour on/off" 326 pack $itk_component(mode) -padx 2 -pady 2 332 pack $itk_component(mode) -padx 2 -pady { 2 0 } 333 334 itk_component add stretchtofit { 335 Rappture::PushButton $f.stretchtofit \ 336 -onimage [Rappture::icon stretchtofit] \ 337 -offimage [Rappture::icon stretchtofit] \ 338 -variable [itcl::scope _settings(stretchToFit)] \ 339 -command [itcl::code $this AdjustSetting stretchToFit] \ 340 } 341 Rappture::Tooltip::for $itk_component(stretchtofit) \ 342 "Stretch plot to fit window on/off" 343 pack $itk_component(stretchtofit) -padx 2 -pady 2 327 344 328 345 if { [catch { … … 629 646 } 630 647 set _limits($axis) [list $amin $amax] 648 set units [$dataobj hints ${axis}units] 649 set found($units) 1 631 650 } 632 651 foreach { fname lim } [$dataobj fieldlimits] { … … 644 663 } 645 664 set _limits($fname) [list $fmin $fmax] 665 } 666 } 667 if { [array size found] > 1 } { 668 set _settings(stretchToFit) 1 669 } else { 670 # Check if the range of the x and y axes requires that we stretch 671 # the contour to fit the plotting area. This can happen when the 672 # x and y scales differ greatly (> 100x) 673 foreach {xmin xmax} $_limits(x) break 674 foreach {ymin ymax} $_limits(y) break 675 if { (($xmax - $xmin) > (($ymax -$ymin) * $_maxScale)) || 676 ((($xmax - $xmin) * $_maxScale) < ($ymax -$ymin)) } { 677 set _settings(stretchToFit) 1 646 678 } 647 679 } … … 723 755 if { $_reportClientInfo } { 724 756 # Tell the server the viewer, hub, user and session. 725 # Do this immediately on connect before buff ing any commands757 # Do this immediately on connect before buffering any commands 726 758 global env 727 759 … … 1010 1042 1011 1043 foreach axis { x y z } { 1012 set label [$_first hints ${axis}label] 1044 if { $axis == "z" } { 1045 set label [$_first hints label] 1046 } else { 1047 set label [$_first hints ${axis}label] 1048 } 1013 1049 if { $label == "" } { 1014 1050 if {$axis == "z"} { … … 1115 1151 } 1116 1152 1153 itcl::body Rappture::VtkHeightmapViewer::CameraReset {} { 1154 array set _view { 1155 qw 0.36 1156 qx 0.25 1157 qy 0.50 1158 qz 0.70 1159 zoom 1.0 1160 xpan 0 1161 ypan 0 1162 } 1163 if { $_first != "" } { 1164 set location [$_first hints camera] 1165 if { $location != "" } { 1166 array set _view $location 1167 } 1168 } 1169 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1170 $_arcball quaternion $q 1171 if {$_settings(isHeightmap) } { 1172 DoRotate 1173 } 1174 SendCmd "camera reset" 1175 } 1176 1117 1177 # ---------------------------------------------------------------------- 1118 1178 # USAGE: Zoom in … … 1135 1195 "reset" { 1136 1196 array set _view { 1137 qw 0.361138 qx 0.251139 qy 0.501140 qz 0.701141 1197 zoom 1.0 1142 1198 xpan 0 1143 1199 ypan 0 1144 }1145 if { $_first != "" } {1146 set location [$_first hints camera]1147 if { $location != "" } {1148 array set _view $location1149 }1150 }1151 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]1152 $_arcball quaternion $q1153 if {$_settings(isHeightmap) } {1154 DoRotate1155 1200 } 1156 1201 SendCmd "camera reset" … … 1410 1455 return 1411 1456 } 1412 set label [$_first hints zlabel]1457 set label [$_first hints label] 1413 1458 if { $label == "" } { 1414 1459 if { [string match "component*" $_curFldName] } { … … 1434 1479 SendCmd "dataset scalar $_curFldName" 1435 1480 SendCmd "heightmap colormode scalar $_curFldName" 1436 SendCmd "camera reset"1481 Zoom reset 1437 1482 UpdateContourList 1438 1483 DrawLegend … … 1514 1559 bind $c <ButtonRelease-1> {} 1515 1560 } 1516 SendCmd "camera reset"1561 Zoom reset 1517 1562 # Fix the mouse bindings for rotation/panning and the 1518 1563 # camera mode. Ideally we'd create a bindtag for these. … … 1610 1655 SendCmd "camera aspect native" 1611 1656 } 1657 Zoom reset 1612 1658 } 1613 1659 "wireframe" { … … 1660 1706 incr h -$lineht 1661 1707 } 1662 if { $h < 1 } {1708 if { $h < 1 } { 1663 1709 return 1664 1710 } … … 1667 1713 set cmap $_currentColormap 1668 1714 SendCmd "legend $cmap scalar $_curFldName {} $w $h 0" 1669 #SendCmd "heightmap colormode scalar $_curFldName"1670 #SendCmd "dataset scalar $_curFldName"1671 1715 } 1672 1716 } … … 1720 1764 itcl::body Rappture::VtkHeightmapViewer::SetCurrentColormap { name } { 1721 1765 # Keep track of the colormaps that we build. 1722 if { ![info exists _colormaps($name)] } {1766 if { $name != "none" && ![info exists _colormaps($name)] } { 1723 1767 BuildColormap $name 1724 1768 set _colormaps($name) 1 … … 1958 2002 itk_component add numisolines { 1959 2003 Rappture::Spinint $inner.numisolines \ 1960 -min 1-max 50 -font "arial 9"2004 -min 0 -max 50 -font "arial 9" 1961 2005 } 1962 2006 $itk_component(numisolines) value $_settings(numIsolines) … … 2048 2092 "static_triad" "static" \ 2049 2093 "closest_triad" "closest" \ 2050 "furthest_triad" "f urthest" \2094 "furthest_triad" "farthest" \ 2051 2095 "outer_edges" "outer" 2052 2096 $itk_component(axisflymode) value "static" … … 2264 2308 $itk_component(colormap) value $style(-color) 2265 2309 } 2310 if { [info exists style(-stretchtofit)] } { 2311 set _settings(stretchToFit) $style(-stretchtofit) 2312 AdjustSetting stretchToFit 2313 } 2266 2314 set _currentOpacity $style(-opacity) 2267 2315 if { $_currentNumIsolines != $style(-levels) } { … … 2284 2332 SendCmd "heightmap isolinecolor [Color2RGB $color] $tag" 2285 2333 SendCmd "heightmap lighting $_settings(isHeightmap) $tag" 2334 SendCmd "heightmap isolines $_settings(isolinesVisible) $tag" 2335 SendCmd "heightmap surface $_settings(colormapVisible) $tag" 2286 2336 } 2287 2337 … … 2379 2429 2380 2430 # Draw the isolines on the legend. 2431 array unset _isolines 2381 2432 if { $color != "none" && [info exists _limits($_curFldName)] && 2382 2433 $_settings(isolinesVisible) && $_currentNumIsolines > 0 } { … … 2422 2473 incr y $lineht 2423 2474 $c coords colormap $x $y 2424 set ix [image width $_image(legend)]2425 set ih [image height $_image(legend)]2426 2475 $c coords sensor [expr $x - $iw] $y $x [expr $y + $ih] 2427 2476 $c raise sensor … … 2563 2612 return $sval 2564 2613 } 2565 set sval02614 return 0 2566 2615 } 2567 2616 … … 2588 2637 2589 2638 itcl::body Rappture::VtkHeightmapViewer::UpdateContourList {} { 2639 if {$_currentNumIsolines == 0} { 2640 set _contourList "" 2641 return 2642 } 2590 2643 if { ![info exists _limits($_curFldName)] } { 2591 2644 return
Note: See TracChangeset
for help on using the changeset viewer.