[3330] | 1 | # -*- mode: tcl; indent-tabs-mode: nil -*- |
---|
[2731] | 2 | # ---------------------------------------------------------------------- |
---|
| 3 | # COMPONENT: vtkheightmapviewer - Vtk heightmap viewer |
---|
| 4 | # |
---|
| 5 | # It connects to the Vtk server running on a rendering farm, |
---|
| 6 | # transmits data, and displays the results. |
---|
| 7 | # ====================================================================== |
---|
| 8 | # AUTHOR: Michael McLennan, Purdue University |
---|
[4438] | 9 | # Copyright (c) 2004-2014 HUBzero Foundation, LLC |
---|
[2731] | 10 | # |
---|
| 11 | # See the file "license.terms" for information on usage and |
---|
| 12 | # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
| 13 | # ====================================================================== |
---|
| 14 | package require Itk |
---|
| 15 | package require BLT |
---|
| 16 | #package require Img |
---|
| 17 | |
---|
| 18 | option add *VtkHeightmapViewer.width 4i widgetDefault |
---|
| 19 | option add *VtkHeightmapViewer*cursor crosshair widgetDefault |
---|
| 20 | option add *VtkHeightmapViewer.height 4i widgetDefault |
---|
| 21 | option add *VtkHeightmapViewer.foreground black widgetDefault |
---|
| 22 | option add *VtkHeightmapViewer.controlBackground gray widgetDefault |
---|
| 23 | option add *VtkHeightmapViewer.controlDarkBackground #999999 widgetDefault |
---|
| 24 | option add *VtkHeightmapViewer.plotBackground black widgetDefault |
---|
| 25 | option add *VtkHeightmapViewer.plotForeground white widgetDefault |
---|
| 26 | option add *VtkHeightmapViewer.font \ |
---|
| 27 | -*-helvetica-medium-r-normal-*-12-* widgetDefault |
---|
| 28 | |
---|
| 29 | # must use this name -- plugs into Rappture::resources::load |
---|
| 30 | proc VtkHeightmapViewer_init_resources {} { |
---|
| 31 | Rappture::resources::register \ |
---|
| 32 | vtkvis_server Rappture::VtkHeightmapViewer::SetServerList |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | itcl::class Rappture::VtkHeightmapViewer { |
---|
| 36 | inherit Rappture::VisViewer |
---|
| 37 | |
---|
| 38 | itk_option define -plotforeground plotForeground Foreground "" |
---|
| 39 | itk_option define -plotbackground plotBackground Background "" |
---|
[3330] | 40 | itk_option define -mode mode Mode "contour" |
---|
[2731] | 41 | |
---|
| 42 | constructor { hostlist args } { |
---|
| 43 | Rappture::VisViewer::constructor $hostlist |
---|
| 44 | } { |
---|
| 45 | # defined below |
---|
| 46 | } |
---|
| 47 | destructor { |
---|
| 48 | # defined below |
---|
| 49 | } |
---|
| 50 | public proc SetServerList { namelist } { |
---|
| 51 | Rappture::VisViewer::SetServerList "vtkvis" $namelist |
---|
| 52 | } |
---|
| 53 | public method add {dataobj {settings ""}} |
---|
| 54 | public method camera {option args} |
---|
| 55 | public method delete {args} |
---|
| 56 | public method disconnect {} |
---|
| 57 | public method download {option args} |
---|
| 58 | public method get {args} |
---|
| 59 | public method isconnected {} |
---|
| 60 | public method parameters {title args} { |
---|
| 61 | # do nothing |
---|
| 62 | } |
---|
| 63 | public method scale {args} |
---|
| 64 | |
---|
[4208] | 65 | protected method CameraReset {} |
---|
[2731] | 66 | protected method Connect {} |
---|
| 67 | protected method CurrentDatasets {args} |
---|
| 68 | protected method Disconnect {} |
---|
| 69 | protected method DoResize {} |
---|
| 70 | protected method DoRotate {} |
---|
| 71 | protected method AdjustSetting {what {value ""}} |
---|
[3330] | 72 | protected method AdjustMode {} |
---|
[2731] | 73 | protected method InitSettings { args } |
---|
| 74 | protected method Pan {option x y} |
---|
| 75 | protected method Pick {x y} |
---|
| 76 | protected method Rebuild {} |
---|
| 77 | protected method ReceiveDataset { args } |
---|
| 78 | protected method ReceiveImage { args } |
---|
[3330] | 79 | protected method ReceiveLegend { colormap title min max size } |
---|
[2731] | 80 | protected method Rotate {option x y} |
---|
| 81 | protected method Zoom {option} |
---|
[3656] | 82 | |
---|
[2731] | 83 | # The following methods are only used by this class. |
---|
| 84 | private method BuildAxisTab {} |
---|
| 85 | private method BuildCameraTab {} |
---|
[3454] | 86 | private method BuildColormap { name } |
---|
[3330] | 87 | private method BuildContourTab {} |
---|
[2731] | 88 | private method BuildDownloadPopup { widget command } |
---|
[3330] | 89 | private method Combo { option } |
---|
[3421] | 90 | private method DrawLegend {} |
---|
[2731] | 91 | private method EnterLegend { x y } |
---|
[3330] | 92 | private method EventuallyRequestLegend {} |
---|
[2731] | 93 | private method EventuallyResize { w h } |
---|
| 94 | private method EventuallyRotate { q } |
---|
| 95 | private method GetImage { args } |
---|
| 96 | private method GetVtkData { args } |
---|
| 97 | private method IsValidObject { dataobj } |
---|
| 98 | private method LeaveLegend {} |
---|
| 99 | private method MotionLegend { x y } |
---|
| 100 | private method PanCamera {} |
---|
| 101 | private method RequestLegend {} |
---|
[3454] | 102 | private method SetCurrentColormap { color } |
---|
[2731] | 103 | private method SetLegendTip { x y } |
---|
| 104 | private method SetObjectStyle { dataobj comp } |
---|
[3330] | 105 | private method GetHeightmapScale {} |
---|
| 106 | private method ResetAxes {} |
---|
[3517] | 107 | private method SetOrientation { side } |
---|
[3623] | 108 | private method UpdateContourList {} |
---|
[2731] | 109 | |
---|
| 110 | private variable _arcball "" |
---|
[2744] | 111 | private variable _dlist "" ; # list of data objects |
---|
[2731] | 112 | private variable _obj2datasets |
---|
[2744] | 113 | private variable _obj2ovride ; # maps dataobj => style override |
---|
[3330] | 114 | private variable _comp2scale; # maps dataset to the heightmap scale. |
---|
[2744] | 115 | private variable _datasets ; # contains all the dataobj-component |
---|
| 116 | ; # datasets in the server |
---|
| 117 | private variable _colormaps ; # contains all the colormaps |
---|
| 118 | ; # in the server. |
---|
[2731] | 119 | |
---|
[3330] | 120 | # The name of the current colormap used. The colormap is global to all |
---|
| 121 | # heightmaps displayed. |
---|
[3623] | 122 | private variable _currentColormap "" |
---|
| 123 | private variable _currentNumIsolines -1 |
---|
[3330] | 124 | |
---|
[4208] | 125 | private variable _maxScale 100; # This is the # of times the x-axis |
---|
| 126 | # and y-axis ranges can differ before |
---|
| 127 | # automatically turning on |
---|
| 128 | # -stretchtofit |
---|
| 129 | |
---|
[2744] | 130 | private variable _click ; # info used for rotate operations |
---|
[3424] | 131 | private variable _limits ; # Holds overall limits for all dataobjs |
---|
[3330] | 132 | # using the viewer. |
---|
[2744] | 133 | private variable _view ; # view params for 3D view |
---|
[2731] | 134 | private variable _settings |
---|
[3454] | 135 | private variable _changed |
---|
[3330] | 136 | private variable _initialStyle ""; # First found style in dataobjects. |
---|
| 137 | private variable _reset 1; # Indicates if camera needs to be reset |
---|
[2744] | 138 | # to starting position. |
---|
[3330] | 139 | private variable _beforeConnect 1; # Indicates if camera needs to be reset |
---|
| 140 | # to starting position. |
---|
[2731] | 141 | |
---|
[2744] | 142 | private variable _first "" ; # This is the topmost dataset. |
---|
[2731] | 143 | private variable _start 0 |
---|
[3439] | 144 | private variable _isolines |
---|
[3623] | 145 | private variable _contourList "" |
---|
[2731] | 146 | |
---|
[2744] | 147 | common _downloadPopup; # download options from popup |
---|
[2731] | 148 | private common _hardcopy |
---|
| 149 | private variable _width 0 |
---|
| 150 | private variable _height 0 |
---|
[3421] | 151 | private variable _legendWidth 0 |
---|
| 152 | private variable _legendHeight 0 |
---|
[2731] | 153 | private variable _resizePending 0 |
---|
| 154 | private variable _rotatePending 0 |
---|
| 155 | private variable _legendPending 0 |
---|
[3330] | 156 | private variable _fieldNames {} |
---|
[2731] | 157 | private variable _fields |
---|
[3409] | 158 | private variable _curFldName "" |
---|
| 159 | private variable _curFldLabel "" |
---|
[4208] | 160 | private variable _colorMode "scalar";# Mode of colormap (vmag or scalar) |
---|
[2731] | 161 | } |
---|
| 162 | |
---|
| 163 | itk::usual VtkHeightmapViewer { |
---|
| 164 | keep -background -foreground -cursor -font |
---|
[3330] | 165 | keep -plotbackground -plotforeground -mode |
---|
[2731] | 166 | } |
---|
| 167 | |
---|
| 168 | # ---------------------------------------------------------------------- |
---|
| 169 | # CONSTRUCTOR |
---|
| 170 | # ---------------------------------------------------------------------- |
---|
| 171 | itcl::body Rappture::VtkHeightmapViewer::constructor {hostlist args} { |
---|
| 172 | set _serverType "vtkvis" |
---|
| 173 | |
---|
[3587] | 174 | EnableWaitDialog 900 |
---|
[2731] | 175 | # Rebuild event |
---|
| 176 | $_dispatcher register !rebuild |
---|
| 177 | $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list" |
---|
| 178 | |
---|
| 179 | # Resize event |
---|
| 180 | $_dispatcher register !resize |
---|
| 181 | $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list" |
---|
| 182 | |
---|
| 183 | # Rotate event |
---|
| 184 | $_dispatcher register !rotate |
---|
| 185 | $_dispatcher dispatch $this !rotate "[itcl::code $this DoRotate]; list" |
---|
| 186 | |
---|
| 187 | # Legend event |
---|
| 188 | $_dispatcher register !legend |
---|
| 189 | $_dispatcher dispatch $this !legend "[itcl::code $this RequestLegend]; list" |
---|
| 190 | |
---|
| 191 | # |
---|
| 192 | # Populate parser with commands handle incoming requests |
---|
| 193 | # |
---|
| 194 | $_parser alias image [itcl::code $this ReceiveImage] |
---|
| 195 | $_parser alias dataset [itcl::code $this ReceiveDataset] |
---|
| 196 | $_parser alias legend [itcl::code $this ReceiveLegend] |
---|
| 197 | |
---|
[3656] | 198 | # Create image for legend colorbar. |
---|
| 199 | set _image(legend) [image create photo] |
---|
| 200 | |
---|
[2731] | 201 | # Initialize the view to some default parameters. |
---|
| 202 | array set _view { |
---|
[3482] | 203 | qw 0.36 |
---|
| 204 | qx 0.25 |
---|
| 205 | qy 0.50 |
---|
| 206 | qz 0.70 |
---|
[3330] | 207 | zoom 1.0 |
---|
| 208 | xpan 0 |
---|
| 209 | ypan 0 |
---|
[3593] | 210 | ortho 0 |
---|
[2731] | 211 | } |
---|
| 212 | set _arcball [blt::arcball create 100 100] |
---|
| 213 | set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] |
---|
| 214 | $_arcball quaternion $q |
---|
| 215 | |
---|
[3454] | 216 | array set _settings { |
---|
[4399] | 217 | -axisflymode "static" |
---|
[4435] | 218 | -axislabels 1 |
---|
[4399] | 219 | -axisminorticks 1 |
---|
| 220 | -axisvisible 1 |
---|
[4438] | 221 | -colormap BCGYR |
---|
[4435] | 222 | -colormapdiscrete 0 |
---|
[4399] | 223 | -colormapvisible 1 |
---|
| 224 | -edges 0 |
---|
| 225 | -field "Default" |
---|
| 226 | -heightmapscale 50 |
---|
| 227 | -isheightmap 0 |
---|
| 228 | -isolinecolor black |
---|
[4436] | 229 | -isolinesvisible 1 |
---|
[4399] | 230 | -legendvisible 1 |
---|
| 231 | -lighting 1 |
---|
| 232 | -numisolines 10 |
---|
[4432] | 233 | -opacity 100 |
---|
[4399] | 234 | -outline 0 |
---|
[4435] | 235 | -savelighting 1 |
---|
[4432] | 236 | -saveopacity 100 |
---|
[4399] | 237 | -saveoutline 0 |
---|
[4435] | 238 | -stretchtofit 0 |
---|
| 239 | -wireframe 0 |
---|
| 240 | -xgrid 0 |
---|
| 241 | -ygrid 0 |
---|
| 242 | -zgrid 0 |
---|
[3454] | 243 | } |
---|
| 244 | array set _changed { |
---|
[4438] | 245 | -colormap 0 |
---|
| 246 | -numisolines 0 |
---|
| 247 | -opacity 0 |
---|
[3454] | 248 | } |
---|
[2731] | 249 | itk_component add view { |
---|
| 250 | canvas $itk_component(plotarea).view \ |
---|
| 251 | -highlightthickness 0 -borderwidth 0 |
---|
| 252 | } { |
---|
| 253 | usual |
---|
[3330] | 254 | ignore -highlightthickness -borderwidth -background |
---|
[2731] | 255 | } |
---|
| 256 | |
---|
| 257 | itk_component add fieldmenu { |
---|
[3330] | 258 | menu $itk_component(plotarea).menu \ |
---|
[3656] | 259 | -relief flat \ |
---|
[2744] | 260 | -tearoff no |
---|
[2731] | 261 | } { |
---|
[2744] | 262 | usual |
---|
| 263 | ignore -background -foreground -relief -tearoff |
---|
[2731] | 264 | } |
---|
| 265 | set c $itk_component(view) |
---|
| 266 | bind $c <Configure> [itcl::code $this EventuallyResize %w %h] |
---|
| 267 | bind $c <4> [itcl::code $this Zoom in 0.25] |
---|
| 268 | bind $c <5> [itcl::code $this Zoom out 0.25] |
---|
| 269 | bind $c <KeyPress-Left> [list %W xview scroll 10 units] |
---|
| 270 | bind $c <KeyPress-Right> [list %W xview scroll -10 units] |
---|
| 271 | bind $c <KeyPress-Up> [list %W yview scroll 10 units] |
---|
| 272 | bind $c <KeyPress-Down> [list %W yview scroll -10 units] |
---|
| 273 | bind $c <Enter> "focus %W" |
---|
[3330] | 274 | bind $c <Control-F1> [itcl::code $this ToggleConsole] |
---|
[2731] | 275 | |
---|
| 276 | # Fix the scrollregion in case we go off screen |
---|
| 277 | $c configure -scrollregion [$c bbox all] |
---|
| 278 | |
---|
| 279 | set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)] |
---|
| 280 | set _map(cwidth) -1 |
---|
| 281 | set _map(cheight) -1 |
---|
| 282 | set _map(zoom) 1.0 |
---|
| 283 | set _map(original) "" |
---|
| 284 | |
---|
| 285 | set f [$itk_component(main) component controls] |
---|
| 286 | itk_component add reset { |
---|
| 287 | button $f.reset -borderwidth 1 -padx 1 -pady 1 \ |
---|
| 288 | -highlightthickness 0 \ |
---|
| 289 | -image [Rappture::icon reset-view] \ |
---|
[4208] | 290 | -command [itcl::code $this CameraReset] |
---|
[2731] | 291 | } { |
---|
| 292 | usual |
---|
| 293 | ignore -highlightthickness |
---|
| 294 | } |
---|
[4208] | 295 | pack $itk_component(reset) -side top -padx 2 -pady { 2 0 } |
---|
[2731] | 296 | Rappture::Tooltip::for $itk_component(reset) "Reset the view to the default zoom level" |
---|
| 297 | |
---|
| 298 | itk_component add zoomin { |
---|
| 299 | button $f.zin -borderwidth 1 -padx 1 -pady 1 \ |
---|
| 300 | -highlightthickness 0 \ |
---|
| 301 | -image [Rappture::icon zoom-in] \ |
---|
| 302 | -command [itcl::code $this Zoom in] |
---|
| 303 | } { |
---|
| 304 | usual |
---|
| 305 | ignore -highlightthickness |
---|
| 306 | } |
---|
[4208] | 307 | pack $itk_component(zoomin) -side top -padx 2 -pady { 2 0 } |
---|
[2731] | 308 | Rappture::Tooltip::for $itk_component(zoomin) "Zoom in" |
---|
| 309 | |
---|
| 310 | itk_component add zoomout { |
---|
| 311 | button $f.zout -borderwidth 1 -padx 1 -pady 1 \ |
---|
| 312 | -highlightthickness 0 \ |
---|
| 313 | -image [Rappture::icon zoom-out] \ |
---|
| 314 | -command [itcl::code $this Zoom out] |
---|
| 315 | } { |
---|
| 316 | usual |
---|
| 317 | ignore -highlightthickness |
---|
| 318 | } |
---|
[4208] | 319 | pack $itk_component(zoomout) -side top -padx 2 -pady { 2 0 } |
---|
[2731] | 320 | Rappture::Tooltip::for $itk_component(zoomout) "Zoom out" |
---|
| 321 | |
---|
[3330] | 322 | itk_component add mode { |
---|
| 323 | Rappture::PushButton $f.mode \ |
---|
| 324 | -onimage [Rappture::icon surface] \ |
---|
| 325 | -offimage [Rappture::icon surface] \ |
---|
[4399] | 326 | -variable [itcl::scope _settings(-isheightmap)] \ |
---|
| 327 | -command [itcl::code $this AdjustSetting -isheightmap] \ |
---|
[2731] | 328 | } |
---|
[3330] | 329 | Rappture::Tooltip::for $itk_component(mode) \ |
---|
| 330 | "Toggle the surface/contour on/off" |
---|
[4208] | 331 | pack $itk_component(mode) -padx 2 -pady { 2 0 } |
---|
[2731] | 332 | |
---|
[4208] | 333 | itk_component add stretchtofit { |
---|
| 334 | Rappture::PushButton $f.stretchtofit \ |
---|
| 335 | -onimage [Rappture::icon stretchtofit] \ |
---|
| 336 | -offimage [Rappture::icon stretchtofit] \ |
---|
[4399] | 337 | -variable [itcl::scope _settings(-stretchtofit)] \ |
---|
| 338 | -command [itcl::code $this AdjustSetting -stretchtofit] \ |
---|
[4208] | 339 | } |
---|
| 340 | Rappture::Tooltip::for $itk_component(stretchtofit) \ |
---|
| 341 | "Stretch plot to fit window on/off" |
---|
| 342 | pack $itk_component(stretchtofit) -padx 2 -pady 2 |
---|
| 343 | |
---|
[2731] | 344 | if { [catch { |
---|
[3330] | 345 | BuildContourTab |
---|
[2744] | 346 | BuildAxisTab |
---|
| 347 | BuildCameraTab |
---|
[2731] | 348 | } errs] != 0 } { |
---|
[3330] | 349 | global errorInfo |
---|
| 350 | puts stderr "errs=$errs errorInfo=$errorInfo" |
---|
[2731] | 351 | } |
---|
| 352 | |
---|
| 353 | # Hack around the Tk panewindow. The problem is that the requested |
---|
| 354 | # size of the 3d view isn't set until an image is retrieved from |
---|
| 355 | # the server. So the panewindow uses the tiny size. |
---|
| 356 | set w 10000 |
---|
| 357 | pack forget $itk_component(view) |
---|
| 358 | blt::table $itk_component(plotarea) \ |
---|
| 359 | 0,0 $itk_component(view) -fill both -reqwidth $w |
---|
| 360 | blt::table configure $itk_component(plotarea) c1 -resize none |
---|
| 361 | |
---|
| 362 | # Bindings for panning via mouse |
---|
| 363 | bind $itk_component(view) <ButtonPress-2> \ |
---|
| 364 | [itcl::code $this Pan click %x %y] |
---|
| 365 | bind $itk_component(view) <B2-Motion> \ |
---|
| 366 | [itcl::code $this Pan drag %x %y] |
---|
| 367 | bind $itk_component(view) <ButtonRelease-2> \ |
---|
| 368 | [itcl::code $this Pan release %x %y] |
---|
| 369 | |
---|
[3443] | 370 | #bind $itk_component(view) <ButtonRelease-3> \ |
---|
| 371 | # [itcl::code $this Pick %x %y] |
---|
[2731] | 372 | |
---|
| 373 | # Bindings for panning via keyboard |
---|
| 374 | bind $itk_component(view) <KeyPress-Left> \ |
---|
| 375 | [itcl::code $this Pan set -10 0] |
---|
| 376 | bind $itk_component(view) <KeyPress-Right> \ |
---|
| 377 | [itcl::code $this Pan set 10 0] |
---|
| 378 | bind $itk_component(view) <KeyPress-Up> \ |
---|
| 379 | [itcl::code $this Pan set 0 -10] |
---|
| 380 | bind $itk_component(view) <KeyPress-Down> \ |
---|
| 381 | [itcl::code $this Pan set 0 10] |
---|
| 382 | bind $itk_component(view) <Shift-KeyPress-Left> \ |
---|
| 383 | [itcl::code $this Pan set -2 0] |
---|
| 384 | bind $itk_component(view) <Shift-KeyPress-Right> \ |
---|
| 385 | [itcl::code $this Pan set 2 0] |
---|
| 386 | bind $itk_component(view) <Shift-KeyPress-Up> \ |
---|
| 387 | [itcl::code $this Pan set 0 -2] |
---|
| 388 | bind $itk_component(view) <Shift-KeyPress-Down> \ |
---|
| 389 | [itcl::code $this Pan set 0 2] |
---|
| 390 | |
---|
| 391 | # Bindings for zoom via keyboard |
---|
| 392 | bind $itk_component(view) <KeyPress-Prior> \ |
---|
| 393 | [itcl::code $this Zoom out] |
---|
| 394 | bind $itk_component(view) <KeyPress-Next> \ |
---|
| 395 | [itcl::code $this Zoom in] |
---|
| 396 | |
---|
| 397 | bind $itk_component(view) <Enter> "focus $itk_component(view)" |
---|
| 398 | |
---|
| 399 | if {[string equal "x11" [tk windowingsystem]]} { |
---|
| 400 | # Bindings for zoom via mouse |
---|
| 401 | bind $itk_component(view) <4> [itcl::code $this Zoom out] |
---|
| 402 | bind $itk_component(view) <5> [itcl::code $this Zoom in] |
---|
| 403 | } |
---|
| 404 | |
---|
| 405 | set _image(download) [image create photo] |
---|
| 406 | eval itk_initialize $args |
---|
| 407 | Connect |
---|
[3330] | 408 | set _beforeConnect 0 |
---|
[2731] | 409 | } |
---|
| 410 | |
---|
| 411 | # ---------------------------------------------------------------------- |
---|
| 412 | # DESTRUCTOR |
---|
| 413 | # ---------------------------------------------------------------------- |
---|
| 414 | itcl::body Rappture::VtkHeightmapViewer::destructor {} { |
---|
| 415 | Disconnect |
---|
| 416 | image delete $_image(plot) |
---|
| 417 | image delete $_image(download) |
---|
| 418 | catch { blt::arcball destroy $_arcball } |
---|
| 419 | } |
---|
| 420 | |
---|
| 421 | itcl::body Rappture::VtkHeightmapViewer::DoResize {} { |
---|
| 422 | if { $_width < 2 } { |
---|
[2744] | 423 | set _width 500 |
---|
[2731] | 424 | } |
---|
| 425 | if { $_height < 2 } { |
---|
[2744] | 426 | set _height 500 |
---|
[2731] | 427 | } |
---|
| 428 | set _start [clock clicks -milliseconds] |
---|
[3330] | 429 | SendCmd "screen size [expr $_width - 20] $_height" |
---|
[3421] | 430 | |
---|
| 431 | set font "Arial 8" |
---|
| 432 | set lh [font metrics $font -linespace] |
---|
| 433 | set h [expr {$_height - 2 * ($lh + 2)}] |
---|
| 434 | if { $h != $_legendHeight } { |
---|
| 435 | EventuallyRequestLegend |
---|
| 436 | } else { |
---|
| 437 | DrawLegend |
---|
| 438 | } |
---|
[2731] | 439 | set _resizePending 0 |
---|
| 440 | } |
---|
| 441 | |
---|
| 442 | itcl::body Rappture::VtkHeightmapViewer::DoRotate {} { |
---|
| 443 | set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] |
---|
| 444 | SendCmd "camera orient $q" |
---|
| 445 | set _rotatePending 0 |
---|
| 446 | } |
---|
| 447 | |
---|
[3330] | 448 | itcl::body Rappture::VtkHeightmapViewer::EventuallyRequestLegend {} { |
---|
| 449 | if { !$_legendPending } { |
---|
| 450 | set _legendPending 1 |
---|
| 451 | $_dispatcher event -idle !legend |
---|
| 452 | } |
---|
| 453 | } |
---|
| 454 | |
---|
[2731] | 455 | itcl::body Rappture::VtkHeightmapViewer::EventuallyResize { w h } { |
---|
| 456 | set _width $w |
---|
| 457 | set _height $h |
---|
| 458 | $_arcball resize $w $h |
---|
| 459 | if { !$_resizePending } { |
---|
| 460 | set _resizePending 1 |
---|
[3434] | 461 | $_dispatcher event -after 250 !resize |
---|
[2731] | 462 | } |
---|
| 463 | } |
---|
| 464 | |
---|
| 465 | set rotate_delay 100 |
---|
| 466 | |
---|
| 467 | itcl::body Rappture::VtkHeightmapViewer::EventuallyRotate { q } { |
---|
| 468 | foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break |
---|
| 469 | if { !$_rotatePending } { |
---|
| 470 | set _rotatePending 1 |
---|
[2744] | 471 | global rotate_delay |
---|
[2731] | 472 | $_dispatcher event -after $rotate_delay !rotate |
---|
| 473 | } |
---|
| 474 | } |
---|
| 475 | |
---|
| 476 | # ---------------------------------------------------------------------- |
---|
| 477 | # USAGE: add <dataobj> ?<settings>? |
---|
| 478 | # |
---|
| 479 | # Clients use this to add a data object to the plot. The optional |
---|
| 480 | # <settings> are used to configure the plot. Allowed settings are |
---|
| 481 | # -color, -brightness, -width, -linestyle, and -raise. |
---|
| 482 | # ---------------------------------------------------------------------- |
---|
| 483 | itcl::body Rappture::VtkHeightmapViewer::add {dataobj {settings ""}} { |
---|
[3571] | 484 | if { ![$dataobj isvalid] } { |
---|
| 485 | return; # Object doesn't contain valid data. |
---|
| 486 | } |
---|
[2731] | 487 | array set params { |
---|
| 488 | -color auto |
---|
| 489 | -width 1 |
---|
| 490 | -linestyle solid |
---|
| 491 | -brightness 0 |
---|
| 492 | -raise 0 |
---|
| 493 | -description "" |
---|
| 494 | -param "" |
---|
[2744] | 495 | -type "" |
---|
[2731] | 496 | } |
---|
| 497 | array set params $settings |
---|
| 498 | set params(-description) "" |
---|
| 499 | set params(-param) "" |
---|
[3800] | 500 | array set params $settings |
---|
| 501 | |
---|
[2731] | 502 | if {$params(-color) == "auto" || $params(-color) == "autoreset"} { |
---|
| 503 | # can't handle -autocolors yet |
---|
[3330] | 504 | set params(-color) white |
---|
[2731] | 505 | } |
---|
[3844] | 506 | set pos [lsearch -exact $_dlist $dataobj] |
---|
[2731] | 507 | if {$pos < 0} { |
---|
[2744] | 508 | lappend _dlist $dataobj |
---|
[2731] | 509 | } |
---|
| 510 | set _obj2ovride($dataobj-color) $params(-color) |
---|
| 511 | set _obj2ovride($dataobj-width) $params(-width) |
---|
| 512 | set _obj2ovride($dataobj-raise) $params(-raise) |
---|
| 513 | $_dispatcher event -idle !rebuild |
---|
| 514 | } |
---|
| 515 | |
---|
| 516 | |
---|
| 517 | # ---------------------------------------------------------------------- |
---|
| 518 | # USAGE: delete ?<dataobj1> <dataobj2> ...? |
---|
| 519 | # |
---|
| 520 | # Clients use this to delete a dataobj from the plot. If no dataobjs |
---|
| 521 | # are specified, then all dataobjs are deleted. No data objects are |
---|
| 522 | # deleted. They are only removed from the display list. |
---|
| 523 | # |
---|
| 524 | # ---------------------------------------------------------------------- |
---|
| 525 | itcl::body Rappture::VtkHeightmapViewer::delete {args} { |
---|
| 526 | if { [llength $args] == 0} { |
---|
| 527 | set args $_dlist |
---|
| 528 | } |
---|
| 529 | # Delete all specified dataobjs |
---|
| 530 | set changed 0 |
---|
| 531 | foreach dataobj $args { |
---|
| 532 | set pos [lsearch -exact $_dlist $dataobj] |
---|
[2744] | 533 | if { $pos < 0 } { |
---|
| 534 | continue; # Don't know anything about it. |
---|
| 535 | } |
---|
| 536 | # Remove it from the dataobj list. |
---|
| 537 | set _dlist [lreplace $_dlist $pos $pos] |
---|
| 538 | array unset _obj2ovride $dataobj-* |
---|
| 539 | array unset _settings $dataobj-* |
---|
| 540 | set changed 1 |
---|
[2731] | 541 | } |
---|
| 542 | # If anything changed, then rebuild the plot |
---|
| 543 | if { $changed } { |
---|
| 544 | $_dispatcher event -idle !rebuild |
---|
| 545 | } |
---|
| 546 | } |
---|
| 547 | |
---|
| 548 | # ---------------------------------------------------------------------- |
---|
| 549 | # USAGE: get ?-objects? |
---|
| 550 | # USAGE: get ?-visible? |
---|
| 551 | # USAGE: get ?-image view? |
---|
| 552 | # |
---|
| 553 | # Clients use this to query the list of objects being plotted, in |
---|
| 554 | # order from bottom to top of this result. The optional "-image" |
---|
| 555 | # flag can also request the internal images being shown. |
---|
| 556 | # ---------------------------------------------------------------------- |
---|
| 557 | itcl::body Rappture::VtkHeightmapViewer::get {args} { |
---|
| 558 | if {[llength $args] == 0} { |
---|
| 559 | set args "-objects" |
---|
| 560 | } |
---|
| 561 | set op [lindex $args 0] |
---|
| 562 | switch -- $op { |
---|
[2744] | 563 | "-objects" { |
---|
| 564 | # put the dataobj list in order according to -raise options |
---|
| 565 | set dlist {} |
---|
| 566 | foreach dataobj $_dlist { |
---|
| 567 | if { ![IsValidObject $dataobj] } { |
---|
| 568 | continue |
---|
| 569 | } |
---|
| 570 | if {[info exists _obj2ovride($dataobj-raise)] && |
---|
| 571 | $_obj2ovride($dataobj-raise)} { |
---|
| 572 | set dlist [linsert $dlist 0 $dataobj] |
---|
| 573 | } else { |
---|
| 574 | lappend dlist $dataobj |
---|
| 575 | } |
---|
| 576 | } |
---|
| 577 | return $dlist |
---|
| 578 | } |
---|
| 579 | "-visible" { |
---|
| 580 | set dlist {} |
---|
| 581 | foreach dataobj $_dlist { |
---|
| 582 | if { ![IsValidObject $dataobj] } { |
---|
| 583 | continue |
---|
| 584 | } |
---|
| 585 | if { ![info exists _obj2ovride($dataobj-raise)] } { |
---|
| 586 | # No setting indicates that the object isn't visible. |
---|
| 587 | continue |
---|
| 588 | } |
---|
| 589 | # Otherwise use the -raise parameter to put the object to |
---|
| 590 | # the front of the list. |
---|
| 591 | if { $_obj2ovride($dataobj-raise) } { |
---|
| 592 | set dlist [linsert $dlist 0 $dataobj] |
---|
| 593 | } else { |
---|
| 594 | lappend dlist $dataobj |
---|
| 595 | } |
---|
| 596 | } |
---|
| 597 | return $dlist |
---|
| 598 | } |
---|
| 599 | -image { |
---|
| 600 | if {[llength $args] != 2} { |
---|
| 601 | error "wrong # args: should be \"get -image view\"" |
---|
| 602 | } |
---|
| 603 | switch -- [lindex $args end] { |
---|
| 604 | view { |
---|
| 605 | return $_image(plot) |
---|
| 606 | } |
---|
| 607 | default { |
---|
| 608 | error "bad image name \"[lindex $args end]\": should be view" |
---|
| 609 | } |
---|
| 610 | } |
---|
| 611 | } |
---|
| 612 | default { |
---|
| 613 | error "bad option \"$op\": should be -objects or -image" |
---|
| 614 | } |
---|
[2731] | 615 | } |
---|
| 616 | } |
---|
| 617 | |
---|
[3429] | 618 | # |
---|
| 619 | # scale -- |
---|
[2731] | 620 | # |
---|
[3429] | 621 | # This gets called either incrementally as new simulations are |
---|
| 622 | # added or all at once as a sequence of heightmaps. |
---|
| 623 | # This accounts for all objects--even those not showing on the |
---|
| 624 | # screen. Because of this, the limits are appropriate for all |
---|
| 625 | # objects as the user scans through data in the ResultSet viewer. |
---|
| 626 | # |
---|
[2731] | 627 | itcl::body Rappture::VtkHeightmapViewer::scale {args} { |
---|
| 628 | foreach dataobj $args { |
---|
[3571] | 629 | if { ![$dataobj isvalid] } { |
---|
| 630 | continue; # Object doesn't contain valid data. |
---|
| 631 | } |
---|
[3428] | 632 | foreach axis { x y } { |
---|
| 633 | set lim [$dataobj limits $axis] |
---|
[3330] | 634 | if { ![info exists _limits($axis)] } { |
---|
[3428] | 635 | set _limits($axis) $lim |
---|
[3330] | 636 | continue |
---|
| 637 | } |
---|
[3428] | 638 | foreach {min max} $lim break |
---|
[3330] | 639 | foreach {amin amax} $_limits($axis) break |
---|
| 640 | if { $amin > $min } { |
---|
| 641 | set amin $min |
---|
| 642 | } |
---|
| 643 | if { $amax < $max } { |
---|
| 644 | set amax $max |
---|
| 645 | } |
---|
| 646 | set _limits($axis) [list $amin $amax] |
---|
[4208] | 647 | set units [$dataobj hints ${axis}units] |
---|
| 648 | set found($units) 1 |
---|
[2744] | 649 | } |
---|
[3429] | 650 | foreach { fname lim } [$dataobj fieldlimits] { |
---|
[3428] | 651 | if { ![info exists _limits($fname)] } { |
---|
| 652 | set _limits($fname) $lim |
---|
| 653 | continue |
---|
| 654 | } |
---|
| 655 | foreach {min max} $lim break |
---|
| 656 | foreach {fmin fmax} $_limits($fname) break |
---|
| 657 | if { $fmin > $min } { |
---|
| 658 | set fmin $min |
---|
| 659 | } |
---|
| 660 | if { $fmax < $max } { |
---|
| 661 | set fmax $max |
---|
| 662 | } |
---|
| 663 | set _limits($fname) [list $fmin $fmax] |
---|
| 664 | } |
---|
[2731] | 665 | } |
---|
[4208] | 666 | if { [array size found] > 1 } { |
---|
[4399] | 667 | set _settings(-stretchtofit) 1 |
---|
[4208] | 668 | } else { |
---|
| 669 | # Check if the range of the x and y axes requires that we stretch |
---|
| 670 | # the contour to fit the plotting area. This can happen when the |
---|
| 671 | # x and y scales differ greatly (> 100x) |
---|
| 672 | foreach {xmin xmax} $_limits(x) break |
---|
| 673 | foreach {ymin ymax} $_limits(y) break |
---|
| 674 | if { (($xmax - $xmin) > (($ymax -$ymin) * $_maxScale)) || |
---|
| 675 | ((($xmax - $xmin) * $_maxScale) < ($ymax -$ymin)) } { |
---|
[4399] | 676 | set _settings(-stretchtofit) 1 |
---|
[4208] | 677 | } |
---|
| 678 | } |
---|
[2731] | 679 | } |
---|
| 680 | |
---|
| 681 | # ---------------------------------------------------------------------- |
---|
| 682 | # USAGE: download coming |
---|
| 683 | # USAGE: download controls <downloadCommand> |
---|
| 684 | # USAGE: download now |
---|
| 685 | # |
---|
| 686 | # Clients use this method to create a downloadable representation |
---|
| 687 | # of the plot. Returns a list of the form {ext string}, where |
---|
| 688 | # "ext" is the file extension (indicating the type of data) and |
---|
| 689 | # "string" is the data itself. |
---|
| 690 | # ---------------------------------------------------------------------- |
---|
| 691 | itcl::body Rappture::VtkHeightmapViewer::download {option args} { |
---|
| 692 | switch $option { |
---|
| 693 | coming { |
---|
| 694 | if {[catch { |
---|
| 695 | blt::winop snap $itk_component(plotarea) $_image(download) |
---|
| 696 | }]} { |
---|
| 697 | $_image(download) configure -width 1 -height 1 |
---|
| 698 | $_image(download) put #000000 |
---|
| 699 | } |
---|
| 700 | } |
---|
| 701 | controls { |
---|
| 702 | set popup .vtkviewerdownload |
---|
| 703 | if { ![winfo exists .vtkviewerdownload] } { |
---|
| 704 | set inner [BuildDownloadPopup $popup [lindex $args 0]] |
---|
| 705 | } else { |
---|
| 706 | set inner [$popup component inner] |
---|
| 707 | } |
---|
| 708 | set _downloadPopup(image_controls) $inner.image_frame |
---|
| 709 | set num [llength [get]] |
---|
| 710 | set num [expr {($num == 1) ? "1 result" : "$num results"}] |
---|
| 711 | set word [Rappture::filexfer::label downloadWord] |
---|
| 712 | $inner.summary configure -text "$word $num in the following format:" |
---|
[2744] | 713 | update idletasks ;# Fix initial sizes |
---|
[2731] | 714 | return $popup |
---|
| 715 | } |
---|
| 716 | now { |
---|
| 717 | set popup .vtkviewerdownload |
---|
| 718 | if {[winfo exists .vtkviewerdownload]} { |
---|
| 719 | $popup deactivate |
---|
| 720 | } |
---|
| 721 | switch -- $_downloadPopup(format) { |
---|
| 722 | "image" { |
---|
| 723 | return [$this GetImage [lindex $args 0]] |
---|
| 724 | } |
---|
| 725 | "vtk" { |
---|
| 726 | return [$this GetVtkData [lindex $args 0]] |
---|
| 727 | } |
---|
| 728 | } |
---|
| 729 | return "" |
---|
| 730 | } |
---|
| 731 | default { |
---|
| 732 | error "bad option \"$option\": should be coming, controls, now" |
---|
| 733 | } |
---|
| 734 | } |
---|
| 735 | } |
---|
| 736 | |
---|
| 737 | # ---------------------------------------------------------------------- |
---|
| 738 | # USAGE: Connect ?<host:port>,<host:port>...? |
---|
| 739 | # |
---|
| 740 | # Clients use this method to establish a connection to a new |
---|
| 741 | # server, or to reestablish a connection to the previous server. |
---|
| 742 | # Any existing connection is automatically closed. |
---|
| 743 | # ---------------------------------------------------------------------- |
---|
| 744 | itcl::body Rappture::VtkHeightmapViewer::Connect {} { |
---|
[3330] | 745 | global readyForNextFrame |
---|
| 746 | set readyForNextFrame 1 |
---|
| 747 | set _reset 1 |
---|
[2731] | 748 | set _hosts [GetServerList "vtkvis"] |
---|
| 749 | if { "" == $_hosts } { |
---|
| 750 | return 0 |
---|
| 751 | } |
---|
| 752 | set result [VisViewer::Connect $_hosts] |
---|
| 753 | if { $result } { |
---|
[3592] | 754 | if { $_reportClientInfo } { |
---|
| 755 | # Tell the server the viewer, hub, user and session. |
---|
[4208] | 756 | # Do this immediately on connect before buffering any commands |
---|
[3592] | 757 | global env |
---|
| 758 | |
---|
| 759 | set info {} |
---|
| 760 | set user "???" |
---|
| 761 | if { [info exists env(USER)] } { |
---|
| 762 | set user $env(USER) |
---|
| 763 | } |
---|
| 764 | set session "???" |
---|
| 765 | if { [info exists env(SESSION)] } { |
---|
| 766 | set session $env(SESSION) |
---|
| 767 | } |
---|
[4670] | 768 | lappend info "version" "$Rappture::version" |
---|
| 769 | lappend info "build" "$Rappture::build" |
---|
| 770 | lappend info "svnurl" "$Rappture::svnurl" |
---|
| 771 | lappend info "installdir" "$Rappture::installdir" |
---|
[3592] | 772 | lappend info "hub" [exec hostname] |
---|
| 773 | lappend info "client" "vtkheightmapviewer" |
---|
| 774 | lappend info "user" $user |
---|
| 775 | lappend info "session" $session |
---|
| 776 | SendCmd "clientinfo [list $info]" |
---|
| 777 | } |
---|
[2731] | 778 | set w [winfo width $itk_component(view)] |
---|
| 779 | set h [winfo height $itk_component(view)] |
---|
| 780 | EventuallyResize $w $h |
---|
| 781 | } |
---|
| 782 | return $result |
---|
| 783 | } |
---|
| 784 | |
---|
| 785 | # |
---|
| 786 | # isconnected -- |
---|
| 787 | # |
---|
| 788 | # Indicates if we are currently connected to the visualization server. |
---|
| 789 | # |
---|
| 790 | itcl::body Rappture::VtkHeightmapViewer::isconnected {} { |
---|
| 791 | return [VisViewer::IsConnected] |
---|
| 792 | } |
---|
| 793 | |
---|
| 794 | # |
---|
| 795 | # disconnect -- |
---|
| 796 | # |
---|
| 797 | itcl::body Rappture::VtkHeightmapViewer::disconnect {} { |
---|
| 798 | Disconnect |
---|
| 799 | set _reset 1 |
---|
| 800 | } |
---|
| 801 | |
---|
| 802 | # |
---|
| 803 | # Disconnect -- |
---|
| 804 | # |
---|
| 805 | # Clients use this method to disconnect from the current rendering |
---|
| 806 | # server. |
---|
| 807 | # |
---|
| 808 | itcl::body Rappture::VtkHeightmapViewer::Disconnect {} { |
---|
| 809 | VisViewer::Disconnect |
---|
| 810 | |
---|
| 811 | $_dispatcher cancel !rebuild |
---|
| 812 | $_dispatcher cancel !resize |
---|
| 813 | $_dispatcher cancel !rotate |
---|
| 814 | $_dispatcher cancel !legend |
---|
| 815 | # disconnected -- no more data sitting on server |
---|
| 816 | array unset _datasets |
---|
| 817 | array unset _data |
---|
| 818 | array unset _colormaps |
---|
| 819 | array unset _obj2datasets |
---|
[3330] | 820 | global readyForNextFrame |
---|
| 821 | set readyForNextFrame 1 |
---|
[2731] | 822 | } |
---|
| 823 | |
---|
| 824 | # ---------------------------------------------------------------------- |
---|
| 825 | # USAGE: ReceiveImage -bytes <size> -type <type> -token <token> |
---|
| 826 | # |
---|
| 827 | # Invoked automatically whenever the "image" command comes in from |
---|
| 828 | # the rendering server. Indicates that binary image data with the |
---|
| 829 | # specified <size> will follow. |
---|
| 830 | # ---------------------------------------------------------------------- |
---|
| 831 | itcl::body Rappture::VtkHeightmapViewer::ReceiveImage { args } { |
---|
[3330] | 832 | global readyForNextFrame |
---|
| 833 | set readyForNextFrame 1 |
---|
[2731] | 834 | array set info { |
---|
| 835 | -token "???" |
---|
| 836 | -bytes 0 |
---|
| 837 | -type image |
---|
| 838 | } |
---|
| 839 | array set info $args |
---|
| 840 | set bytes [ReceiveBytes $info(-bytes)] |
---|
| 841 | if { $info(-type) == "image" } { |
---|
[2744] | 842 | if 0 { |
---|
| 843 | set f [open "last.ppm" "w"] |
---|
| 844 | puts $f $bytes |
---|
| 845 | close $f |
---|
| 846 | } |
---|
[2731] | 847 | $_image(plot) configure -data $bytes |
---|
[2744] | 848 | set time [clock seconds] |
---|
| 849 | set date [clock format $time] |
---|
[2731] | 850 | #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>" |
---|
[2744] | 851 | if { $_start > 0 } { |
---|
| 852 | set finish [clock clicks -milliseconds] |
---|
| 853 | #puts stderr "round trip time [expr $finish -$_start] milliseconds" |
---|
| 854 | set _start 0 |
---|
| 855 | } |
---|
[2731] | 856 | } elseif { $info(type) == "print" } { |
---|
| 857 | set tag $this-print-$info(-token) |
---|
| 858 | set _hardcopy($tag) $bytes |
---|
| 859 | } |
---|
| 860 | } |
---|
| 861 | |
---|
| 862 | # |
---|
| 863 | # ReceiveDataset -- |
---|
| 864 | # |
---|
| 865 | itcl::body Rappture::VtkHeightmapViewer::ReceiveDataset { args } { |
---|
| 866 | if { ![isconnected] } { |
---|
| 867 | return |
---|
| 868 | } |
---|
| 869 | set option [lindex $args 0] |
---|
| 870 | switch -- $option { |
---|
[2744] | 871 | "scalar" { |
---|
| 872 | set option [lindex $args 1] |
---|
| 873 | switch -- $option { |
---|
| 874 | "world" { |
---|
| 875 | foreach { x y z value tag } [lrange $args 2 end] break |
---|
| 876 | } |
---|
| 877 | "pixel" { |
---|
| 878 | foreach { x y value tag } [lrange $args 2 end] break |
---|
| 879 | } |
---|
| 880 | } |
---|
| 881 | } |
---|
| 882 | "vector" { |
---|
| 883 | set option [lindex $args 1] |
---|
| 884 | switch -- $option { |
---|
| 885 | "world" { |
---|
| 886 | foreach { x y z vx vy vz tag } [lrange $args 2 end] break |
---|
| 887 | } |
---|
| 888 | "pixel" { |
---|
| 889 | foreach { x y vx vy vz tag } [lrange $args 2 end] break |
---|
| 890 | } |
---|
| 891 | } |
---|
| 892 | } |
---|
| 893 | "names" { |
---|
[2731] | 894 | foreach { name } [lindex $args 1] { |
---|
| 895 | #puts stderr "Dataset: $name" |
---|
| 896 | } |
---|
[2744] | 897 | } |
---|
| 898 | default { |
---|
| 899 | error "unknown dataset option \"$option\" from server" |
---|
| 900 | } |
---|
[2731] | 901 | } |
---|
| 902 | } |
---|
| 903 | |
---|
| 904 | # ---------------------------------------------------------------------- |
---|
| 905 | # USAGE: Rebuild |
---|
| 906 | # |
---|
| 907 | # Called automatically whenever something changes that affects the |
---|
| 908 | # data in the widget. Clears any existing data and rebuilds the |
---|
| 909 | # widget to display new data. |
---|
| 910 | # ---------------------------------------------------------------------- |
---|
| 911 | itcl::body Rappture::VtkHeightmapViewer::Rebuild {} { |
---|
| 912 | set w [winfo width $itk_component(view)] |
---|
| 913 | set h [winfo height $itk_component(view)] |
---|
| 914 | if { $w < 2 || $h < 2 } { |
---|
[2744] | 915 | $_dispatcher event -idle !rebuild |
---|
| 916 | return |
---|
[2731] | 917 | } |
---|
| 918 | |
---|
| 919 | # Turn on buffering of commands to the server. We don't want to |
---|
| 920 | # be preempted by a server disconnect/reconnect (which automatically |
---|
| 921 | # generates a new call to Rebuild). |
---|
[3498] | 922 | StartBufferingCommands |
---|
| 923 | |
---|
[3330] | 924 | if { $_width != $w || $_height != $h || $_reset } { |
---|
| 925 | set _width $w |
---|
| 926 | set _height $h |
---|
| 927 | $_arcball resize $w $h |
---|
| 928 | DoResize |
---|
[4399] | 929 | if { $_settings(-stretchtofit) } { |
---|
| 930 | AdjustSetting -stretchtofit |
---|
[3330] | 931 | } |
---|
[2731] | 932 | } |
---|
[3330] | 933 | if { $_reset } { |
---|
| 934 | # |
---|
| 935 | # Reset the camera and other view parameters |
---|
| 936 | # |
---|
[4399] | 937 | InitSettings -isheightmap -background |
---|
[3532] | 938 | |
---|
[4716] | 939 | # Setting a custom exponent and label format for axes is causing |
---|
| 940 | # a problem with rounding. Near zero ticks aren't rounded by |
---|
| 941 | # the %g format. The VTK CubeAxes seem to currently work best |
---|
| 942 | # when allowed to automatically set the exponent and precision |
---|
| 943 | # based on the axis ranges. This does tend to result in less |
---|
| 944 | # visual clutter, so I think it is best to use the automatic |
---|
| 945 | # settings by default. We can test more fine-grained |
---|
| 946 | # controls on the axis settings tab if necessary. |
---|
| 947 | # -Leif |
---|
| 948 | #SendCmd "axis exp 0 0 0 1" |
---|
[3532] | 949 | |
---|
[3330] | 950 | SendCmd "axis lrot z 90" |
---|
| 951 | set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] |
---|
| 952 | $_arcball quaternion $q |
---|
[4399] | 953 | if {$_settings(-isheightmap) } { |
---|
[3550] | 954 | if { $_view(ortho)} { |
---|
| 955 | SendCmd "camera mode ortho" |
---|
| 956 | } else { |
---|
| 957 | SendCmd "camera mode persp" |
---|
| 958 | } |
---|
[3416] | 959 | DoRotate |
---|
[3550] | 960 | SendCmd "camera reset" |
---|
| 961 | } |
---|
[3330] | 962 | PanCamera |
---|
[3514] | 963 | StopBufferingCommands |
---|
[3418] | 964 | SendCmd "imgflush" |
---|
[3514] | 965 | StartBufferingCommands |
---|
[3330] | 966 | } |
---|
[2731] | 967 | |
---|
| 968 | set _first "" |
---|
[3330] | 969 | # Start off with no datasets are visible. |
---|
| 970 | SendCmd "dataset visible 0" |
---|
| 971 | set scale [GetHeightmapScale] |
---|
[2731] | 972 | foreach dataobj [get -objects] { |
---|
[2744] | 973 | if { [info exists _obj2ovride($dataobj-raise)] && $_first == "" } { |
---|
| 974 | set _first $dataobj |
---|
| 975 | } |
---|
| 976 | set _obj2datasets($dataobj) "" |
---|
[2731] | 977 | foreach comp [$dataobj components] { |
---|
| 978 | set tag $dataobj-$comp |
---|
| 979 | if { ![info exists _datasets($tag)] } { |
---|
[3330] | 980 | set bytes [$dataobj vtkdata $comp] |
---|
[3421] | 981 | if 0 { |
---|
[3392] | 982 | set f [open /tmp/vtkheightmap.vtk "w"] |
---|
| 983 | puts $f $bytes |
---|
| 984 | close $f |
---|
[3330] | 985 | } |
---|
[2731] | 986 | set length [string length $bytes] |
---|
[3421] | 987 | if { $_reportClientInfo } { |
---|
[3392] | 988 | set info {} |
---|
| 989 | lappend info "tool_id" [$dataobj hints toolId] |
---|
| 990 | lappend info "tool_name" [$dataobj hints toolName] |
---|
| 991 | lappend info "tool_version" [$dataobj hints toolRevision] |
---|
| 992 | lappend info "tool_title" [$dataobj hints toolTitle] |
---|
| 993 | lappend info "dataset_label" [$dataobj hints label] |
---|
| 994 | lappend info "dataset_size" $length |
---|
[3394] | 995 | lappend info "dataset_tag" $tag |
---|
[3392] | 996 | SendCmd [list "clientinfo" $info] |
---|
| 997 | } |
---|
[3421] | 998 | SendCmd "dataset add $tag data follows $length" |
---|
[2731] | 999 | append _outbuf $bytes |
---|
| 1000 | set _datasets($tag) 1 |
---|
[2744] | 1001 | SetObjectStyle $dataobj $comp |
---|
| 1002 | } |
---|
| 1003 | lappend _obj2datasets($dataobj) $tag |
---|
| 1004 | if { [info exists _obj2ovride($dataobj-raise)] } { |
---|
[3553] | 1005 | # Setting dataset visible enables outline |
---|
[3447] | 1006 | # and heightmap |
---|
| 1007 | SendCmd "dataset visible 1 $tag" |
---|
[2744] | 1008 | } |
---|
[3330] | 1009 | if { ![info exists _comp2scale($tag)] || |
---|
| 1010 | $_comp2scale($tag) != $scale } { |
---|
| 1011 | SendCmd "heightmap heightscale $scale $tag" |
---|
| 1012 | set _comp2scale($tag) $scale |
---|
| 1013 | } |
---|
[2731] | 1014 | } |
---|
| 1015 | } |
---|
[3405] | 1016 | if { $_first != "" } { |
---|
[3330] | 1017 | $itk_component(field) choices delete 0 end |
---|
| 1018 | $itk_component(fieldmenu) delete 0 end |
---|
| 1019 | array unset _fields |
---|
[3421] | 1020 | set _curFldName "" |
---|
[3405] | 1021 | foreach cname [$_first components] { |
---|
| 1022 | foreach fname [$_first fieldnames $cname] { |
---|
| 1023 | if { [info exists _fields($fname)] } { |
---|
| 1024 | continue |
---|
| 1025 | } |
---|
| 1026 | foreach { label units components } \ |
---|
| 1027 | [$_first fieldinfo $fname] break |
---|
| 1028 | $itk_component(field) choices insert end "$fname" "$label" |
---|
| 1029 | $itk_component(fieldmenu) add radiobutton -label "$label" \ |
---|
[3409] | 1030 | -value $label -variable [itcl::scope _curFldLabel] \ |
---|
[3405] | 1031 | -selectcolor red \ |
---|
| 1032 | -activebackground $itk_option(-plotbackground) \ |
---|
| 1033 | -activeforeground $itk_option(-plotforeground) \ |
---|
| 1034 | -font "Arial 8" \ |
---|
| 1035 | -command [itcl::code $this Combo invoke] |
---|
| 1036 | set _fields($fname) [list $label $units $components] |
---|
[3421] | 1037 | if { $_curFldName == "" } { |
---|
| 1038 | set _curFldName $fname |
---|
| 1039 | set _curFldLabel $label |
---|
| 1040 | } |
---|
[3405] | 1041 | } |
---|
| 1042 | } |
---|
[3409] | 1043 | $itk_component(field) value $_curFldLabel |
---|
[2731] | 1044 | } |
---|
[4399] | 1045 | InitSettings -stretchtofit -outline |
---|
[2731] | 1046 | |
---|
[3330] | 1047 | if { $_reset } { |
---|
| 1048 | SendCmd "axis tickpos outside" |
---|
[4716] | 1049 | #SendCmd "axis lformat all %g" |
---|
[3409] | 1050 | |
---|
[3330] | 1051 | foreach axis { x y z } { |
---|
[4208] | 1052 | if { $axis == "z" } { |
---|
| 1053 | set label [$_first hints label] |
---|
| 1054 | } else { |
---|
| 1055 | set label [$_first hints ${axis}label] |
---|
| 1056 | } |
---|
[3330] | 1057 | if { $label == "" } { |
---|
| 1058 | if {$axis == "z"} { |
---|
[3445] | 1059 | if { [string match "component*" $_curFldName] } { |
---|
[3330] | 1060 | set label [string toupper $axis] |
---|
| 1061 | } else { |
---|
[3409] | 1062 | set label $_curFldLabel |
---|
[3330] | 1063 | } |
---|
| 1064 | } else { |
---|
| 1065 | set label [string toupper $axis] |
---|
| 1066 | } |
---|
| 1067 | } |
---|
| 1068 | # May be a space in the axis label. |
---|
| 1069 | SendCmd [list axis name $axis $label] |
---|
[2731] | 1070 | |
---|
[3330] | 1071 | if {$axis == "z" && [$_first hints ${axis}units] == ""} { |
---|
| 1072 | set units [lindex $_fields($_curFldName) 1] |
---|
| 1073 | } else { |
---|
| 1074 | set units [$_first hints ${axis}units] |
---|
| 1075 | } |
---|
| 1076 | if { $units != "" } { |
---|
| 1077 | # May be a space in the axis units. |
---|
| 1078 | SendCmd [list axis units $axis $units] |
---|
| 1079 | } |
---|
| 1080 | } |
---|
| 1081 | # |
---|
| 1082 | # Reset the camera and other view parameters |
---|
| 1083 | # |
---|
| 1084 | ResetAxes |
---|
| 1085 | set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] |
---|
| 1086 | $_arcball quaternion $q |
---|
[4399] | 1087 | if {$_settings(-isheightmap) } { |
---|
[3550] | 1088 | if { $_view(ortho)} { |
---|
| 1089 | SendCmd "camera mode ortho" |
---|
| 1090 | } else { |
---|
| 1091 | SendCmd "camera mode persp" |
---|
| 1092 | } |
---|
[3416] | 1093 | DoRotate |
---|
[3550] | 1094 | SendCmd "camera reset" |
---|
| 1095 | } |
---|
[3330] | 1096 | PanCamera |
---|
[4399] | 1097 | InitSettings -xgrid -ygrid -zgrid \ |
---|
| 1098 | -axisvisible -axislabels -heightmapscale -field -isheightmap \ |
---|
| 1099 | -numisolines |
---|
[3421] | 1100 | if { [array size _fields] < 2 } { |
---|
[4676] | 1101 | catch {blt::table forget $itk_component(field) $itk_component(field_l)} |
---|
[3421] | 1102 | } |
---|
[3424] | 1103 | RequestLegend |
---|
[2744] | 1104 | set _reset 0 |
---|
[2731] | 1105 | } |
---|
[3330] | 1106 | global readyForNextFrame |
---|
| 1107 | set readyForNextFrame 0; # Don't advance to the next frame |
---|
[2731] | 1108 | |
---|
| 1109 | # Actually write the commands to the server socket. If it fails, we don't |
---|
| 1110 | # care. We're finished here. |
---|
| 1111 | blt::busy hold $itk_component(hull) |
---|
[3421] | 1112 | StopBufferingCommands |
---|
[2731] | 1113 | blt::busy release $itk_component(hull) |
---|
| 1114 | } |
---|
| 1115 | |
---|
| 1116 | # ---------------------------------------------------------------------- |
---|
| 1117 | # USAGE: CurrentDatasets ?-all -visible? ?dataobjs? |
---|
| 1118 | # |
---|
| 1119 | # Returns a list of server IDs for the current datasets being displayed. This |
---|
| 1120 | # is normally a single ID, but it might be a list of IDs if the current data |
---|
| 1121 | # object has multiple components. |
---|
| 1122 | # ---------------------------------------------------------------------- |
---|
| 1123 | itcl::body Rappture::VtkHeightmapViewer::CurrentDatasets {args} { |
---|
| 1124 | set flag [lindex $args 0] |
---|
| 1125 | switch -- $flag { |
---|
[2744] | 1126 | "-all" { |
---|
| 1127 | if { [llength $args] > 1 } { |
---|
| 1128 | error "CurrentDatasets: can't specify dataobj after \"-all\"" |
---|
| 1129 | } |
---|
| 1130 | set dlist [get -objects] |
---|
| 1131 | } |
---|
| 1132 | "-visible" { |
---|
| 1133 | if { [llength $args] > 1 } { |
---|
| 1134 | set dlist {} |
---|
| 1135 | set args [lrange $args 1 end] |
---|
| 1136 | foreach dataobj $args { |
---|
| 1137 | if { [info exists _obj2ovride($dataobj-raise)] } { |
---|
| 1138 | lappend dlist $dataobj |
---|
| 1139 | } |
---|
| 1140 | } |
---|
| 1141 | } else { |
---|
| 1142 | set dlist [get -visible] |
---|
| 1143 | } |
---|
| 1144 | } |
---|
| 1145 | default { |
---|
| 1146 | set dlist $args |
---|
| 1147 | } |
---|
[2731] | 1148 | } |
---|
| 1149 | set rlist "" |
---|
| 1150 | foreach dataobj $dlist { |
---|
[2744] | 1151 | foreach comp [$dataobj components] { |
---|
| 1152 | set tag $dataobj-$comp |
---|
| 1153 | if { [info exists _datasets($tag)] && $_datasets($tag) } { |
---|
| 1154 | lappend rlist $tag |
---|
| 1155 | } |
---|
| 1156 | } |
---|
[2731] | 1157 | } |
---|
| 1158 | return $rlist |
---|
| 1159 | } |
---|
| 1160 | |
---|
[4208] | 1161 | itcl::body Rappture::VtkHeightmapViewer::CameraReset {} { |
---|
| 1162 | array set _view { |
---|
| 1163 | qw 0.36 |
---|
| 1164 | qx 0.25 |
---|
| 1165 | qy 0.50 |
---|
| 1166 | qz 0.70 |
---|
| 1167 | zoom 1.0 |
---|
| 1168 | xpan 0 |
---|
| 1169 | ypan 0 |
---|
| 1170 | } |
---|
| 1171 | if { $_first != "" } { |
---|
| 1172 | set location [$_first hints camera] |
---|
| 1173 | if { $location != "" } { |
---|
| 1174 | array set _view $location |
---|
| 1175 | } |
---|
| 1176 | } |
---|
| 1177 | set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] |
---|
| 1178 | $_arcball quaternion $q |
---|
[4399] | 1179 | if {$_settings(-isheightmap) } { |
---|
[4208] | 1180 | DoRotate |
---|
| 1181 | } |
---|
| 1182 | SendCmd "camera reset" |
---|
| 1183 | } |
---|
| 1184 | |
---|
[2731] | 1185 | # ---------------------------------------------------------------------- |
---|
| 1186 | # USAGE: Zoom in |
---|
| 1187 | # USAGE: Zoom out |
---|
| 1188 | # USAGE: Zoom reset |
---|
| 1189 | # |
---|
| 1190 | # Called automatically when the user clicks on one of the zoom |
---|
| 1191 | # controls for this widget. Changes the zoom for the current view. |
---|
| 1192 | # ---------------------------------------------------------------------- |
---|
| 1193 | itcl::body Rappture::VtkHeightmapViewer::Zoom {option} { |
---|
| 1194 | switch -- $option { |
---|
| 1195 | "in" { |
---|
| 1196 | set _view(zoom) [expr {$_view(zoom)*1.25}] |
---|
[2744] | 1197 | SendCmd "camera zoom $_view(zoom)" |
---|
[2731] | 1198 | } |
---|
| 1199 | "out" { |
---|
| 1200 | set _view(zoom) [expr {$_view(zoom)*0.8}] |
---|
[2744] | 1201 | SendCmd "camera zoom $_view(zoom)" |
---|
[2731] | 1202 | } |
---|
| 1203 | "reset" { |
---|
| 1204 | array set _view { |
---|
| 1205 | zoom 1.0 |
---|
[3330] | 1206 | xpan 0 |
---|
| 1207 | ypan 0 |
---|
[2731] | 1208 | } |
---|
[3550] | 1209 | SendCmd "camera reset" |
---|
[2731] | 1210 | } |
---|
| 1211 | } |
---|
| 1212 | } |
---|
| 1213 | |
---|
| 1214 | itcl::body Rappture::VtkHeightmapViewer::PanCamera {} { |
---|
| 1215 | set x $_view(xpan) |
---|
| 1216 | set y $_view(ypan) |
---|
| 1217 | SendCmd "camera pan $x $y" |
---|
| 1218 | } |
---|
| 1219 | |
---|
| 1220 | |
---|
| 1221 | # ---------------------------------------------------------------------- |
---|
| 1222 | # USAGE: Rotate click <x> <y> |
---|
| 1223 | # USAGE: Rotate drag <x> <y> |
---|
| 1224 | # USAGE: Rotate release <x> <y> |
---|
| 1225 | # |
---|
| 1226 | # Called automatically when the user clicks/drags/releases in the |
---|
| 1227 | # plot area. Moves the plot according to the user's actions. |
---|
| 1228 | # ---------------------------------------------------------------------- |
---|
| 1229 | itcl::body Rappture::VtkHeightmapViewer::Rotate {option x y} { |
---|
| 1230 | switch -- $option { |
---|
| 1231 | "click" { |
---|
| 1232 | $itk_component(view) configure -cursor fleur |
---|
| 1233 | set _click(x) $x |
---|
| 1234 | set _click(y) $y |
---|
| 1235 | } |
---|
| 1236 | "drag" { |
---|
| 1237 | if {[array size _click] == 0} { |
---|
| 1238 | Rotate click $x $y |
---|
| 1239 | } else { |
---|
| 1240 | set w [winfo width $itk_component(view)] |
---|
| 1241 | set h [winfo height $itk_component(view)] |
---|
| 1242 | if {$w <= 0 || $h <= 0} { |
---|
| 1243 | return |
---|
| 1244 | } |
---|
| 1245 | |
---|
| 1246 | if {[catch { |
---|
| 1247 | # this fails sometimes for no apparent reason |
---|
| 1248 | set dx [expr {double($x-$_click(x))/$w}] |
---|
| 1249 | set dy [expr {double($y-$_click(y))/$h}] |
---|
| 1250 | }]} { |
---|
| 1251 | return |
---|
| 1252 | } |
---|
[2744] | 1253 | if { $dx == 0 && $dy == 0 } { |
---|
| 1254 | return |
---|
| 1255 | } |
---|
| 1256 | set q [$_arcball rotate $x $y $_click(x) $_click(y)] |
---|
| 1257 | EventuallyRotate $q |
---|
[2731] | 1258 | set _click(x) $x |
---|
| 1259 | set _click(y) $y |
---|
| 1260 | } |
---|
| 1261 | } |
---|
| 1262 | "release" { |
---|
| 1263 | Rotate drag $x $y |
---|
| 1264 | $itk_component(view) configure -cursor "" |
---|
| 1265 | catch {unset _click} |
---|
| 1266 | } |
---|
| 1267 | default { |
---|
| 1268 | error "bad option \"$option\": should be click, drag, release" |
---|
| 1269 | } |
---|
| 1270 | } |
---|
| 1271 | } |
---|
| 1272 | |
---|
| 1273 | itcl::body Rappture::VtkHeightmapViewer::Pick {x y} { |
---|
| 1274 | foreach tag [CurrentDatasets -visible] { |
---|
| 1275 | SendCmd "dataset getscalar pixel $x $y $tag" |
---|
| 1276 | } |
---|
| 1277 | } |
---|
| 1278 | |
---|
| 1279 | # ---------------------------------------------------------------------- |
---|
| 1280 | # USAGE: $this Pan click x y |
---|
| 1281 | # $this Pan drag x y |
---|
| 1282 | # $this Pan release x y |
---|
| 1283 | # |
---|
| 1284 | # Called automatically when the user clicks on one of the zoom |
---|
| 1285 | # controls for this widget. Changes the zoom for the current view. |
---|
| 1286 | # ---------------------------------------------------------------------- |
---|
| 1287 | itcl::body Rappture::VtkHeightmapViewer::Pan {option x y} { |
---|
| 1288 | switch -- $option { |
---|
[2744] | 1289 | "set" { |
---|
| 1290 | set w [winfo width $itk_component(view)] |
---|
| 1291 | set h [winfo height $itk_component(view)] |
---|
| 1292 | set x [expr $x / double($w)] |
---|
| 1293 | set y [expr $y / double($h)] |
---|
| 1294 | set _view(xpan) [expr $_view(xpan) + $x] |
---|
| 1295 | set _view(ypan) [expr $_view(ypan) + $y] |
---|
| 1296 | PanCamera |
---|
| 1297 | return |
---|
| 1298 | } |
---|
| 1299 | "click" { |
---|
| 1300 | set _click(x) $x |
---|
| 1301 | set _click(y) $y |
---|
| 1302 | $itk_component(view) configure -cursor hand1 |
---|
| 1303 | } |
---|
| 1304 | "drag" { |
---|
| 1305 | if { ![info exists _click(x)] } { |
---|
| 1306 | set _click(x) $x |
---|
| 1307 | } |
---|
| 1308 | if { ![info exists _click(y)] } { |
---|
| 1309 | set _click(y) $y |
---|
| 1310 | } |
---|
| 1311 | set w [winfo width $itk_component(view)] |
---|
| 1312 | set h [winfo height $itk_component(view)] |
---|
| 1313 | set dx [expr ($_click(x) - $x)/double($w)] |
---|
| 1314 | set dy [expr ($_click(y) - $y)/double($h)] |
---|
| 1315 | set _click(x) $x |
---|
| 1316 | set _click(y) $y |
---|
| 1317 | set _view(xpan) [expr $_view(xpan) - $dx] |
---|
| 1318 | set _view(ypan) [expr $_view(ypan) - $dy] |
---|
| 1319 | PanCamera |
---|
| 1320 | } |
---|
| 1321 | "release" { |
---|
| 1322 | Pan drag $x $y |
---|
| 1323 | $itk_component(view) configure -cursor "" |
---|
| 1324 | } |
---|
| 1325 | default { |
---|
| 1326 | error "unknown option \"$option\": should set, click, drag, or release" |
---|
| 1327 | } |
---|
[2731] | 1328 | } |
---|
| 1329 | } |
---|
| 1330 | |
---|
| 1331 | # ---------------------------------------------------------------------- |
---|
| 1332 | # USAGE: InitSettings <what> ?<value>? |
---|
| 1333 | # |
---|
| 1334 | # Used internally to update rendering settings whenever parameters |
---|
| 1335 | # change in the popup settings panel. Sends the new settings off |
---|
| 1336 | # to the back end. |
---|
| 1337 | # ---------------------------------------------------------------------- |
---|
| 1338 | itcl::body Rappture::VtkHeightmapViewer::InitSettings { args } { |
---|
| 1339 | foreach spec $args { |
---|
[4399] | 1340 | if { [info exists _settings($_first${spec})] } { |
---|
[2744] | 1341 | # Reset global setting with dataobj specific setting |
---|
[4399] | 1342 | set _settings($spec) $_settings($_first${spec}) |
---|
[2744] | 1343 | } |
---|
| 1344 | AdjustSetting $spec |
---|
[2731] | 1345 | } |
---|
| 1346 | } |
---|
| 1347 | |
---|
| 1348 | # |
---|
| 1349 | # AdjustSetting -- |
---|
| 1350 | # |
---|
[2744] | 1351 | # Changes/updates a specific setting in the widget. There are |
---|
| 1352 | # usually user-setable option. Commands are sent to the render |
---|
| 1353 | # server. |
---|
[2731] | 1354 | # |
---|
| 1355 | itcl::body Rappture::VtkHeightmapViewer::AdjustSetting {what {value ""}} { |
---|
[3330] | 1356 | if { $_beforeConnect } { |
---|
[2744] | 1357 | return |
---|
[2731] | 1358 | } |
---|
| 1359 | switch -- $what { |
---|
[4399] | 1360 | "-axisflymode" { |
---|
[3330] | 1361 | set mode [$itk_component(axisflymode) value] |
---|
| 1362 | set mode [$itk_component(axisflymode) translate $mode] |
---|
[2744] | 1363 | set _settings($what) $mode |
---|
| 1364 | SendCmd "axis flymode $mode" |
---|
[2731] | 1365 | } |
---|
[4399] | 1366 | "-axislabels" { |
---|
| 1367 | set bool $_settings($what) |
---|
[3417] | 1368 | SendCmd "axis labels all $bool" |
---|
| 1369 | } |
---|
[4399] | 1370 | "-axisminorticks" { |
---|
| 1371 | set bool $_settings($what) |
---|
[4716] | 1372 | SendCmd "axis minticks all $bool" |
---|
[2731] | 1373 | } |
---|
[4399] | 1374 | "-axisvisible" { |
---|
| 1375 | set bool $_settings($what) |
---|
[3417] | 1376 | SendCmd "axis visible all $bool" |
---|
[2731] | 1377 | } |
---|
[4399] | 1378 | "-xgrid" - "-ygrid" - "-zgrid" { |
---|
| 1379 | set axis [string tolower [string range $what 1 1]] |
---|
[2744] | 1380 | set bool $_settings($what) |
---|
[3417] | 1381 | SendCmd "axis grid $axis $bool" |
---|
[2731] | 1382 | } |
---|
[4399] | 1383 | "-background" { |
---|
[3593] | 1384 | set bg [$itk_component(background) value] |
---|
[3330] | 1385 | array set fgcolors { |
---|
| 1386 | "black" "white" |
---|
| 1387 | "white" "black" |
---|
| 1388 | "grey" "black" |
---|
| 1389 | } |
---|
[3593] | 1390 | set fg $fgcolors($bg) |
---|
| 1391 | configure -plotbackground $bg -plotforeground $fg |
---|
[3330] | 1392 | $itk_component(view) delete "legend" |
---|
[3593] | 1393 | SendCmd "screen bgcolor [Color2RGB $bg]" |
---|
| 1394 | SendCmd "outline color [Color2RGB $fg]" |
---|
| 1395 | SendCmd "axis color all [Color2RGB $fg]" |
---|
[3421] | 1396 | DrawLegend |
---|
[2731] | 1397 | } |
---|
[4399] | 1398 | "-colormap" { |
---|
| 1399 | set _changed($what) 1 |
---|
[3421] | 1400 | StartBufferingCommands |
---|
[3330] | 1401 | set color [$itk_component(colormap) value] |
---|
[4399] | 1402 | set _settings($what) $color |
---|
[3330] | 1403 | if { $color == "none" } { |
---|
[4399] | 1404 | if { $_settings(-colormapvisible) } { |
---|
[3330] | 1405 | SendCmd "heightmap surface 0" |
---|
[4399] | 1406 | set _settings(-colormapvisible) 0 |
---|
[3330] | 1407 | } |
---|
| 1408 | } else { |
---|
[4399] | 1409 | if { !$_settings(-colormapvisible) } { |
---|
[3330] | 1410 | SendCmd "heightmap surface 1" |
---|
[4399] | 1411 | set _settings(-colormapvisible) 1 |
---|
[3330] | 1412 | } |
---|
[3454] | 1413 | SetCurrentColormap $color |
---|
[4399] | 1414 | if {$_settings(-colormapdiscrete)} { |
---|
| 1415 | set numColors [expr $_settings(-numisolines) + 1] |
---|
[3462] | 1416 | SendCmd "colormap res $numColors $color" |
---|
| 1417 | } |
---|
[3330] | 1418 | } |
---|
[3421] | 1419 | StopBufferingCommands |
---|
[3330] | 1420 | EventuallyRequestLegend |
---|
[2744] | 1421 | } |
---|
[4399] | 1422 | "-colormapvisible" { |
---|
[3417] | 1423 | set bool $_settings($what) |
---|
| 1424 | SendCmd "heightmap surface $bool" |
---|
[2731] | 1425 | } |
---|
[4399] | 1426 | "-colormapdiscrete" { |
---|
[3462] | 1427 | set bool $_settings($what) |
---|
[4399] | 1428 | set numColors [expr $_settings(-numisolines) + 1] |
---|
[3462] | 1429 | StartBufferingCommands |
---|
| 1430 | if {$bool} { |
---|
| 1431 | SendCmd "colormap res $numColors" |
---|
[3545] | 1432 | # Discrete colormap requires preinterp on |
---|
| 1433 | SendCmd "heightmap preinterp on" |
---|
[3462] | 1434 | } else { |
---|
| 1435 | SendCmd "colormap res default" |
---|
[3545] | 1436 | # FIXME: add setting for preinterp (default on) |
---|
| 1437 | SendCmd "heightmap preinterp on" |
---|
[3462] | 1438 | } |
---|
| 1439 | StopBufferingCommands |
---|
| 1440 | EventuallyRequestLegend |
---|
| 1441 | } |
---|
[4399] | 1442 | "-edges" { |
---|
| 1443 | set bool $_settings($what) |
---|
[3417] | 1444 | SendCmd "heightmap edges $bool" |
---|
[2731] | 1445 | } |
---|
[4399] | 1446 | "-field" { |
---|
[3409] | 1447 | set label [$itk_component(field) value] |
---|
| 1448 | set fname [$itk_component(field) translate $label] |
---|
[4399] | 1449 | set _settings($what) $fname |
---|
[3409] | 1450 | if { [info exists _fields($fname)] } { |
---|
| 1451 | foreach { label units components } $_fields($fname) break |
---|
| 1452 | if { $components > 1 } { |
---|
| 1453 | set _colorMode vmag |
---|
| 1454 | } else { |
---|
| 1455 | set _colorMode scalar |
---|
| 1456 | } |
---|
| 1457 | set _curFldName $fname |
---|
| 1458 | set _curFldLabel $label |
---|
[2744] | 1459 | } else { |
---|
[3409] | 1460 | puts stderr "unknown field \"$fname\"" |
---|
[2744] | 1461 | return |
---|
[2731] | 1462 | } |
---|
[4208] | 1463 | set label [$_first hints label] |
---|
[3421] | 1464 | if { $label == "" } { |
---|
[3445] | 1465 | if { [string match "component*" $_curFldName] } { |
---|
[3421] | 1466 | set label Z |
---|
| 1467 | } else { |
---|
| 1468 | set label $_curFldLabel |
---|
| 1469 | } |
---|
| 1470 | } |
---|
| 1471 | # May be a space in the axis label. |
---|
| 1472 | SendCmd [list axis name z $label] |
---|
| 1473 | |
---|
| 1474 | if { [$_first hints zunits] == "" } { |
---|
| 1475 | set units [lindex $_fields($_curFldName) 1] |
---|
| 1476 | } else { |
---|
| 1477 | set units [$_first hints zunits] |
---|
| 1478 | } |
---|
| 1479 | if { $units != "" } { |
---|
| 1480 | # May be a space in the axis units. |
---|
[3459] | 1481 | SendCmd [list axis units z $units] |
---|
[3421] | 1482 | } |
---|
| 1483 | # Get the new limits because the field changed. |
---|
| 1484 | ResetAxes |
---|
[3433] | 1485 | SendCmd "dataset scalar $_curFldName" |
---|
| 1486 | SendCmd "heightmap colormode scalar $_curFldName" |
---|
[4208] | 1487 | Zoom reset |
---|
[3623] | 1488 | UpdateContourList |
---|
[3421] | 1489 | DrawLegend |
---|
[3330] | 1490 | } |
---|
[4399] | 1491 | "-heightmapscale" { |
---|
| 1492 | if { $_settings(-isheightmap) } { |
---|
[3417] | 1493 | set scale [GetHeightmapScale] |
---|
[3537] | 1494 | # Have to set the datasets individually because we are |
---|
| 1495 | # tracking them in _comp2scale. |
---|
| 1496 | foreach dataset [CurrentDatasets -all] { |
---|
[3417] | 1497 | SendCmd "heightmap heightscale $scale $dataset" |
---|
| 1498 | set _comp2scale($dataset) $scale |
---|
[3330] | 1499 | } |
---|
[3417] | 1500 | ResetAxes |
---|
[3330] | 1501 | } |
---|
[3417] | 1502 | } |
---|
[4399] | 1503 | "-isheightmap" { |
---|
| 1504 | set bool $_settings($what) |
---|
[3417] | 1505 | set c $itk_component(view) |
---|
[3421] | 1506 | StartBufferingCommands |
---|
[3417] | 1507 | # Fix heightmap scale: 0 for contours, 1 for heightmaps. |
---|
| 1508 | if { $bool } { |
---|
[4399] | 1509 | set _settings(-heightmapscale) 50 |
---|
| 1510 | set _settings(-opacity) $_settings(-saveopacity) |
---|
| 1511 | set _settings(-lighting) $_settings(-savelighting) |
---|
| 1512 | set _settings(-outline) 0 |
---|
[3417] | 1513 | } else { |
---|
[4399] | 1514 | set _settings(-heightmapscale) 0 |
---|
| 1515 | set _settings(-lighting) 0 |
---|
[4432] | 1516 | set _settings(-opacity) 100 |
---|
[4399] | 1517 | set _settings(-outline) $_settings(-saveoutline) |
---|
[3417] | 1518 | } |
---|
[4399] | 1519 | InitSettings -lighting -opacity -outline |
---|
[3417] | 1520 | set scale [GetHeightmapScale] |
---|
[3537] | 1521 | # Have to set the datasets individually because we are |
---|
| 1522 | # tracking them in _comp2scale. |
---|
[3417] | 1523 | foreach dataset [CurrentDatasets -all] { |
---|
| 1524 | SendCmd "heightmap heightscale $scale $dataset" |
---|
| 1525 | set _comp2scale($dataset) $scale |
---|
| 1526 | } |
---|
[3330] | 1527 | if { $bool } { |
---|
| 1528 | $itk_component(lighting) configure -state normal |
---|
[3417] | 1529 | $itk_component(opacity) configure -state normal |
---|
| 1530 | $itk_component(scale) configure -state normal |
---|
| 1531 | $itk_component(opacity_l) configure -state normal |
---|
| 1532 | $itk_component(scale_l) configure -state normal |
---|
[3537] | 1533 | $itk_component(outline) configure -state disabled |
---|
[3416] | 1534 | if {$_view(ortho)} { |
---|
| 1535 | SendCmd "camera mode ortho" |
---|
| 1536 | } else { |
---|
| 1537 | SendCmd "camera mode persp" |
---|
| 1538 | } |
---|
[3330] | 1539 | } else { |
---|
| 1540 | $itk_component(lighting) configure -state disabled |
---|
[3417] | 1541 | $itk_component(opacity) configure -state disabled |
---|
| 1542 | $itk_component(scale) configure -state disabled |
---|
| 1543 | $itk_component(opacity_l) configure -state disabled |
---|
| 1544 | $itk_component(scale_l) configure -state disabled |
---|
[3537] | 1545 | $itk_component(outline) configure -state normal |
---|
[3418] | 1546 | SendCmd "camera mode image" |
---|
[3656] | 1547 | } |
---|
[4399] | 1548 | if {$_settings(-stretchtofit)} { |
---|
[3330] | 1549 | if {$scale == 0} { |
---|
| 1550 | SendCmd "camera aspect window" |
---|
| 1551 | } else { |
---|
| 1552 | SendCmd "camera aspect square" |
---|
| 1553 | } |
---|
| 1554 | } |
---|
[3420] | 1555 | ResetAxes |
---|
[3417] | 1556 | if { $bool } { |
---|
| 1557 | set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] |
---|
| 1558 | $_arcball quaternion $q |
---|
| 1559 | SendCmd "camera orient $q" |
---|
| 1560 | } else { |
---|
| 1561 | bind $c <ButtonPress-1> {} |
---|
| 1562 | bind $c <B1-Motion> {} |
---|
| 1563 | bind $c <ButtonRelease-1> {} |
---|
| 1564 | } |
---|
[4208] | 1565 | Zoom reset |
---|
[3330] | 1566 | # Fix the mouse bindings for rotation/panning and the |
---|
| 1567 | # camera mode. Ideally we'd create a bindtag for these. |
---|
| 1568 | if { $bool } { |
---|
| 1569 | # Bindings for rotation via mouse |
---|
| 1570 | bind $c <ButtonPress-1> \ |
---|
| 1571 | [itcl::code $this Rotate click %x %y] |
---|
| 1572 | bind $c <B1-Motion> \ |
---|
| 1573 | [itcl::code $this Rotate drag %x %y] |
---|
| 1574 | bind $c <ButtonRelease-1> \ |
---|
| 1575 | [itcl::code $this Rotate release %x %y] |
---|
| 1576 | } |
---|
[3421] | 1577 | StopBufferingCommands |
---|
[2731] | 1578 | } |
---|
[4399] | 1579 | "-isolinecolor" { |
---|
[3417] | 1580 | set color [$itk_component(isolinecolor) value] |
---|
| 1581 | if { $color == "none" } { |
---|
[4399] | 1582 | if { $_settings(-isolinesvisible) } { |
---|
[3417] | 1583 | SendCmd "heightmap isolines 0" |
---|
[4399] | 1584 | set _settings(-isolinesvisible) 0 |
---|
[3417] | 1585 | } |
---|
| 1586 | } else { |
---|
[4399] | 1587 | if { !$_settings(-isolinesvisible) } { |
---|
[3417] | 1588 | SendCmd "heightmap isolines 1" |
---|
[4399] | 1589 | set _settings(-isolinesvisible) 1 |
---|
[3417] | 1590 | } |
---|
| 1591 | SendCmd "heightmap isolinecolor [Color2RGB $color]" |
---|
| 1592 | } |
---|
[3421] | 1593 | DrawLegend |
---|
[3417] | 1594 | } |
---|
[4399] | 1595 | "-isolinesvisible" { |
---|
[3417] | 1596 | set bool $_settings($what) |
---|
| 1597 | SendCmd "heightmap isolines $bool" |
---|
[3421] | 1598 | DrawLegend |
---|
[3417] | 1599 | } |
---|
[4399] | 1600 | "-legendvisible" { |
---|
[3417] | 1601 | if { !$_settings($what) } { |
---|
[3330] | 1602 | $itk_component(view) delete legend |
---|
| 1603 | } |
---|
[3421] | 1604 | DrawLegend |
---|
[3330] | 1605 | } |
---|
[4399] | 1606 | "-lighting" { |
---|
| 1607 | if { $_settings(-isheightmap) } { |
---|
[4438] | 1608 | set _settings(-savelighting) $_settings($what) |
---|
[3417] | 1609 | set bool $_settings($what) |
---|
| 1610 | SendCmd "heightmap lighting $bool" |
---|
| 1611 | } else { |
---|
| 1612 | SendCmd "heightmap lighting 0" |
---|
| 1613 | } |
---|
| 1614 | } |
---|
[4399] | 1615 | "-numisolines" { |
---|
| 1616 | set _settings($what) [$itk_component(numisolines) value] |
---|
| 1617 | set _currentNumIsolines $_settings($what) |
---|
[3623] | 1618 | UpdateContourList |
---|
[4399] | 1619 | set _changed($what) 1 |
---|
[3623] | 1620 | SendCmd "heightmap contourlist [list $_contourList]" |
---|
[4399] | 1621 | if {$_settings(-colormapdiscrete)} { |
---|
| 1622 | set numColors [expr $_settings($what) + 1] |
---|
[3462] | 1623 | SendCmd "colormap res $numColors" |
---|
| 1624 | EventuallyRequestLegend |
---|
| 1625 | } else { |
---|
| 1626 | DrawLegend |
---|
| 1627 | } |
---|
[3417] | 1628 | } |
---|
[4399] | 1629 | "-opacity" { |
---|
| 1630 | set _changed($what) 1 |
---|
[4432] | 1631 | set val [expr $_settings($what) * 0.01] |
---|
[4399] | 1632 | if { $_settings(-isheightmap) } { |
---|
| 1633 | set _settings(-saveopacity) $_settings($what) |
---|
[4432] | 1634 | SendCmd "heightmap opacity $val" |
---|
[3417] | 1635 | } else { |
---|
[4399] | 1636 | SendCmd "heightmap opacity 1.0" |
---|
[3417] | 1637 | } |
---|
| 1638 | } |
---|
[4399] | 1639 | "-outline" { |
---|
| 1640 | if { $_settings(-isheightmap) } { |
---|
[3544] | 1641 | SendCmd "outline visible 0" |
---|
[3537] | 1642 | } else { |
---|
[4399] | 1643 | set _settings(-saveoutline) $_settings($what) |
---|
| 1644 | set bool $_settings($what) |
---|
[3544] | 1645 | SendCmd "outline visible $bool" |
---|
[3537] | 1646 | } |
---|
[3417] | 1647 | } |
---|
[4399] | 1648 | "-stretchtofit" { |
---|
[3417] | 1649 | set bool $_settings($what) |
---|
| 1650 | if { $bool } { |
---|
| 1651 | set heightScale [GetHeightmapScale] |
---|
| 1652 | if {$heightScale == 0} { |
---|
| 1653 | SendCmd "camera aspect window" |
---|
| 1654 | } else { |
---|
| 1655 | SendCmd "camera aspect square" |
---|
| 1656 | } |
---|
| 1657 | } else { |
---|
| 1658 | SendCmd "camera aspect native" |
---|
| 1659 | } |
---|
[4208] | 1660 | Zoom reset |
---|
[3417] | 1661 | } |
---|
[4399] | 1662 | "-wireframe" { |
---|
[3417] | 1663 | set bool $_settings($what) |
---|
| 1664 | SendCmd "heightmap wireframe $bool" |
---|
| 1665 | } |
---|
[3330] | 1666 | default { |
---|
[2731] | 1667 | error "don't know how to fix $what" |
---|
| 1668 | } |
---|
| 1669 | } |
---|
| 1670 | } |
---|
| 1671 | |
---|
| 1672 | # |
---|
| 1673 | # RequestLegend -- |
---|
| 1674 | # |
---|
[2744] | 1675 | # Request a new legend from the server. The size of the legend |
---|
[3330] | 1676 | # is determined from the height of the canvas. |
---|
[2731] | 1677 | # |
---|
[3330] | 1678 | # This should be called when |
---|
| 1679 | # 1. A new current colormap is set. |
---|
| 1680 | # 2. Window is resized. |
---|
| 1681 | # 3. The limits of the data have changed. (Just need a redraw). |
---|
| 1682 | # 4. Number of isolines have changed. (Just need a redraw). |
---|
| 1683 | # 5. Legend becomes visible (Just need a redraw). |
---|
| 1684 | # |
---|
[2731] | 1685 | itcl::body Rappture::VtkHeightmapViewer::RequestLegend {} { |
---|
[3330] | 1686 | set _legendPending 0 |
---|
[2731] | 1687 | set font "Arial 8" |
---|
[3421] | 1688 | set w 12 |
---|
[2731] | 1689 | set lineht [font metrics $font -linespace] |
---|
[3421] | 1690 | # color ramp height = (canvas height) - (min and max value lines) - 2 |
---|
[3330] | 1691 | set h [expr {$_height - 2 * ($lineht + 2)}] |
---|
[3421] | 1692 | set _legendHeight $h |
---|
| 1693 | |
---|
| 1694 | set fname $_curFldName |
---|
[3445] | 1695 | if { [string match "component*" $fname] } { |
---|
[3421] | 1696 | set title "" |
---|
| 1697 | } else { |
---|
| 1698 | if { [info exists _fields($fname)] } { |
---|
| 1699 | foreach { title units } $_fields($fname) break |
---|
| 1700 | if { $units != "" } { |
---|
| 1701 | set title [format "%s (%s)" $title $units] |
---|
| 1702 | } |
---|
| 1703 | } else { |
---|
| 1704 | set title $fname |
---|
| 1705 | } |
---|
| 1706 | } |
---|
| 1707 | # If there's a title too, substract one more line |
---|
| 1708 | if { $title != "" } { |
---|
| 1709 | incr h -$lineht |
---|
| 1710 | } |
---|
[4208] | 1711 | if { $h < 1 } { |
---|
[2744] | 1712 | return |
---|
[2731] | 1713 | } |
---|
| 1714 | # Set the legend on the first heightmap dataset. |
---|
[3330] | 1715 | if { $_currentColormap != "" } { |
---|
| 1716 | set cmap $_currentColormap |
---|
[3421] | 1717 | SendCmd "legend $cmap scalar $_curFldName {} $w $h 0" |
---|
[2731] | 1718 | } |
---|
| 1719 | } |
---|
| 1720 | |
---|
| 1721 | # |
---|
[3330] | 1722 | # ResetAxes -- |
---|
[2731] | 1723 | # |
---|
[3330] | 1724 | # Set axis z bounds and range |
---|
| 1725 | # |
---|
| 1726 | itcl::body Rappture::VtkHeightmapViewer::ResetAxes {} { |
---|
[3445] | 1727 | if { ![info exists _limits($_curFldName)]} { |
---|
[3330] | 1728 | SendCmd "dataset maprange all" |
---|
| 1729 | SendCmd "axis autorange z on" |
---|
| 1730 | SendCmd "axis autobounds z on" |
---|
| 1731 | return |
---|
[2731] | 1732 | } |
---|
[3330] | 1733 | foreach { xmin xmax } $_limits(x) break |
---|
| 1734 | foreach { ymin ymax } $_limits(y) break |
---|
[3428] | 1735 | foreach { vmin vmax } $_limits($_curFldName) break |
---|
[3434] | 1736 | |
---|
| 1737 | global tcl_precision |
---|
| 1738 | set tcl_precision 17 |
---|
| 1739 | set xr [expr $xmax - $xmin] |
---|
| 1740 | set yr [expr $ymax - $ymin] |
---|
| 1741 | set vr [expr $vmax - $vmin] |
---|
| 1742 | set r [expr ($yr > $xr) ? $yr : $xr] |
---|
| 1743 | if { $vr < 1.0e-17 } { |
---|
[3330] | 1744 | set dataScale 1.0 |
---|
| 1745 | } else { |
---|
[3434] | 1746 | set dataScale [expr $r / $vr] |
---|
[3330] | 1747 | } |
---|
| 1748 | set heightScale [GetHeightmapScale] |
---|
[3434] | 1749 | set bmin [expr $heightScale * $dataScale * $vmin] |
---|
| 1750 | set bmax [expr $heightScale * $dataScale * $vmax] |
---|
[3554] | 1751 | if {$heightScale > 0} { |
---|
| 1752 | set zpos [expr - $bmin] |
---|
| 1753 | SendCmd "heightmap pos 0 0 $zpos" |
---|
| 1754 | } else { |
---|
| 1755 | SendCmd "heightmap pos 0 0 0" |
---|
| 1756 | } |
---|
| 1757 | set bmax [expr $bmax - $bmin] |
---|
| 1758 | set bmin 0 |
---|
[3428] | 1759 | SendCmd "dataset maprange explicit $_limits($_curFldName) $_curFldName" |
---|
[3434] | 1760 | SendCmd "axis bounds z $bmin $bmax" |
---|
[3428] | 1761 | SendCmd "axis range z $_limits($_curFldName)" |
---|
[2731] | 1762 | } |
---|
| 1763 | |
---|
| 1764 | # |
---|
[3330] | 1765 | # SetCurrentColormap -- |
---|
[2731] | 1766 | # |
---|
[3454] | 1767 | itcl::body Rappture::VtkHeightmapViewer::SetCurrentColormap { name } { |
---|
| 1768 | # Keep track of the colormaps that we build. |
---|
[4208] | 1769 | if { $name != "none" && ![info exists _colormaps($name)] } { |
---|
[3454] | 1770 | BuildColormap $name |
---|
| 1771 | set _colormaps($name) 1 |
---|
[2731] | 1772 | } |
---|
[3330] | 1773 | set _currentColormap $name |
---|
[3454] | 1774 | SendCmd "heightmap colormap $_currentColormap" |
---|
[2731] | 1775 | } |
---|
| 1776 | |
---|
| 1777 | |
---|
| 1778 | # |
---|
| 1779 | # BuildColormap -- |
---|
| 1780 | # |
---|
[3454] | 1781 | # Build the designated colormap on the server. |
---|
| 1782 | # |
---|
| 1783 | itcl::body Rappture::VtkHeightmapViewer::BuildColormap { name } { |
---|
| 1784 | set cmap [ColorsToColormap $name] |
---|
[2731] | 1785 | if { [llength $cmap] == 0 } { |
---|
[2744] | 1786 | set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0" |
---|
[2731] | 1787 | } |
---|
| 1788 | set wmap "0.0 1.0 1.0 1.0" |
---|
| 1789 | SendCmd "colormap add $name { $cmap } { $wmap }" |
---|
| 1790 | } |
---|
| 1791 | |
---|
| 1792 | # ---------------------------------------------------------------------- |
---|
[3330] | 1793 | # CONFIGURATION OPTION: -mode |
---|
| 1794 | # ---------------------------------------------------------------------- |
---|
| 1795 | itcl::configbody Rappture::VtkHeightmapViewer::mode { |
---|
| 1796 | switch -- $itk_option(-mode) { |
---|
| 1797 | "heightmap" { |
---|
[4399] | 1798 | set _settings(-isheightmap) 1 |
---|
[3330] | 1799 | } |
---|
| 1800 | "contour" { |
---|
[4399] | 1801 | set _settings(-isheightmap) 0 |
---|
[3330] | 1802 | } |
---|
| 1803 | default { |
---|
| 1804 | error "unknown mode settings \"$itk_option(-mode)\"" |
---|
| 1805 | } |
---|
| 1806 | } |
---|
[3593] | 1807 | if { !$_reset } { |
---|
[4399] | 1808 | AdjustSetting -isheightmap |
---|
[3593] | 1809 | } |
---|
[3330] | 1810 | } |
---|
| 1811 | |
---|
| 1812 | # ---------------------------------------------------------------------- |
---|
[2731] | 1813 | # CONFIGURATION OPTION: -plotbackground |
---|
| 1814 | # ---------------------------------------------------------------------- |
---|
| 1815 | itcl::configbody Rappture::VtkHeightmapViewer::plotbackground { |
---|
| 1816 | if { [isconnected] } { |
---|
[3355] | 1817 | set rgb [Color2RGB $itk_option(-plotbackground)] |
---|
[3593] | 1818 | if { !$_reset } { |
---|
| 1819 | SendCmd "screen bgcolor $rgb" |
---|
| 1820 | } |
---|
[3330] | 1821 | $itk_component(view) configure -background $itk_option(-plotbackground) |
---|
[2731] | 1822 | } |
---|
| 1823 | } |
---|
| 1824 | |
---|
| 1825 | # ---------------------------------------------------------------------- |
---|
| 1826 | # CONFIGURATION OPTION: -plotforeground |
---|
| 1827 | # ---------------------------------------------------------------------- |
---|
| 1828 | itcl::configbody Rappture::VtkHeightmapViewer::plotforeground { |
---|
| 1829 | if { [isconnected] } { |
---|
[3355] | 1830 | set rgb [Color2RGB $itk_option(-plotforeground)] |
---|
[3593] | 1831 | if { !$_reset } { |
---|
| 1832 | SendCmd "outline color $rgb" |
---|
| 1833 | SendCmd "axis color all $rgb" |
---|
| 1834 | } |
---|
[2731] | 1835 | } |
---|
| 1836 | } |
---|
| 1837 | |
---|
[3330] | 1838 | itcl::body Rappture::VtkHeightmapViewer::BuildContourTab {} { |
---|
[2731] | 1839 | |
---|
| 1840 | set fg [option get $itk_component(hull) font Font] |
---|
| 1841 | #set bfg [option get $itk_component(hull) boldFont Font] |
---|
| 1842 | |
---|
| 1843 | set inner [$itk_component(main) insert end \ |
---|
[3417] | 1844 | -title "Contour/Surface Settings" \ |
---|
[3517] | 1845 | -icon [Rappture::icon contour2]] |
---|
[2731] | 1846 | $inner configure -borderwidth 4 |
---|
| 1847 | |
---|
[3330] | 1848 | checkbutton $inner.legend \ |
---|
| 1849 | -text "Legend" \ |
---|
[4399] | 1850 | -variable [itcl::scope _settings(-legendvisible)] \ |
---|
| 1851 | -command [itcl::code $this AdjustSetting -legendvisible] \ |
---|
[2731] | 1852 | -font "Arial 9" |
---|
| 1853 | |
---|
| 1854 | checkbutton $inner.wireframe \ |
---|
[3330] | 1855 | -text "Wireframe" \ |
---|
[4399] | 1856 | -variable [itcl::scope _settings(-wireframe)] \ |
---|
| 1857 | -command [itcl::code $this AdjustSetting -wireframe] \ |
---|
[2731] | 1858 | -font "Arial 9" |
---|
| 1859 | |
---|
[3330] | 1860 | itk_component add lighting { |
---|
| 1861 | checkbutton $inner.lighting \ |
---|
| 1862 | -text "Enable Lighting" \ |
---|
[4399] | 1863 | -variable [itcl::scope _settings(-lighting)] \ |
---|
| 1864 | -command [itcl::code $this AdjustSetting -lighting] \ |
---|
[3330] | 1865 | -font "Arial 9" |
---|
| 1866 | } { |
---|
| 1867 | ignore -font |
---|
| 1868 | } |
---|
[2731] | 1869 | checkbutton $inner.edges \ |
---|
[3330] | 1870 | -text "Edges" \ |
---|
[4399] | 1871 | -variable [itcl::scope _settings(-edges)] \ |
---|
| 1872 | -command [itcl::code $this AdjustSetting -edges] \ |
---|
[2731] | 1873 | -font "Arial 9" |
---|
| 1874 | |
---|
[3537] | 1875 | itk_component add outline { |
---|
| 1876 | checkbutton $inner.outline \ |
---|
| 1877 | -text "Outline" \ |
---|
[4399] | 1878 | -variable [itcl::scope _settings(-outline)] \ |
---|
| 1879 | -command [itcl::code $this AdjustSetting -outline] \ |
---|
[3537] | 1880 | -font "Arial 9" |
---|
| 1881 | } { |
---|
| 1882 | ignore -font |
---|
| 1883 | } |
---|
[3330] | 1884 | checkbutton $inner.stretch \ |
---|
| 1885 | -text "Stretch to fit" \ |
---|
[4399] | 1886 | -variable [itcl::scope _settings(-stretchtofit)] \ |
---|
| 1887 | -command [itcl::code $this AdjustSetting -stretchtofit] \ |
---|
[3330] | 1888 | -font "Arial 9" |
---|
[2731] | 1889 | |
---|
[3421] | 1890 | checkbutton $inner.isolines \ |
---|
| 1891 | -text "Isolines" \ |
---|
[4399] | 1892 | -variable [itcl::scope _settings(-isolinesvisible)] \ |
---|
| 1893 | -command [itcl::code $this AdjustSetting -isolinesvisible] \ |
---|
[3421] | 1894 | -font "Arial 9" |
---|
| 1895 | |
---|
[3462] | 1896 | checkbutton $inner.colormapDiscrete \ |
---|
| 1897 | -text "Discrete Colormap" \ |
---|
[4399] | 1898 | -variable [itcl::scope _settings(-colormapdiscrete)] \ |
---|
| 1899 | -command [itcl::code $this AdjustSetting -colormapdiscrete] \ |
---|
[3462] | 1900 | -font "Arial 9" |
---|
| 1901 | |
---|
[3421] | 1902 | itk_component add field_l { |
---|
| 1903 | label $inner.field_l -text "Field" -font "Arial 9" |
---|
| 1904 | } { |
---|
| 1905 | ignore -font |
---|
| 1906 | } |
---|
[2731] | 1907 | itk_component add field { |
---|
[2744] | 1908 | Rappture::Combobox $inner.field -width 10 -editable no |
---|
[2731] | 1909 | } |
---|
| 1910 | bind $inner.field <<Value>> \ |
---|
[4399] | 1911 | [itcl::code $this AdjustSetting -field] |
---|
[2731] | 1912 | |
---|
[3330] | 1913 | label $inner.colormap_l -text "Colormap" -font "Arial 9" |
---|
| 1914 | itk_component add colormap { |
---|
| 1915 | Rappture::Combobox $inner.colormap -width 10 -editable no |
---|
[2731] | 1916 | } |
---|
[4449] | 1917 | $inner.colormap choices insert end [GetColormapList -includeNone] |
---|
[4438] | 1918 | $itk_component(colormap) value $_settings(-colormap) |
---|
[3330] | 1919 | bind $inner.colormap <<Value>> \ |
---|
[4399] | 1920 | [itcl::code $this AdjustSetting -colormap] |
---|
[2731] | 1921 | |
---|
[3421] | 1922 | label $inner.isolinecolor_l -text "Isolines Color" -font "Arial 9" |
---|
[3330] | 1923 | itk_component add isolinecolor { |
---|
| 1924 | Rappture::Combobox $inner.isolinecolor -width 10 -editable no |
---|
| 1925 | } |
---|
| 1926 | $inner.isolinecolor choices insert end \ |
---|
| 1927 | "black" "black" \ |
---|
| 1928 | "blue" "blue" \ |
---|
| 1929 | "cyan" "cyan" \ |
---|
| 1930 | "green" "green" \ |
---|
| 1931 | "grey" "grey" \ |
---|
| 1932 | "magenta" "magenta" \ |
---|
| 1933 | "orange" "orange" \ |
---|
| 1934 | "red" "red" \ |
---|
| 1935 | "white" "white" \ |
---|
| 1936 | "none" "none" |
---|
| 1937 | |
---|
[4438] | 1938 | $itk_component(isolinecolor) value $_settings(-isolinecolor) |
---|
[3330] | 1939 | bind $inner.isolinecolor <<Value>> \ |
---|
[4399] | 1940 | [itcl::code $this AdjustSetting -isolinecolor] |
---|
[3330] | 1941 | |
---|
[3421] | 1942 | label $inner.background_l -text "Background Color" -font "Arial 9" |
---|
[3330] | 1943 | itk_component add background { |
---|
| 1944 | Rappture::Combobox $inner.background -width 10 -editable no |
---|
| 1945 | } |
---|
| 1946 | $inner.background choices insert end \ |
---|
| 1947 | "black" "black" \ |
---|
| 1948 | "white" "white" \ |
---|
| 1949 | "grey" "grey" |
---|
| 1950 | |
---|
| 1951 | $itk_component(background) value "white" |
---|
[4399] | 1952 | bind $inner.background <<Value>> \ |
---|
| 1953 | [itcl::code $this AdjustSetting -background] |
---|
[3330] | 1954 | |
---|
[3417] | 1955 | itk_component add opacity_l { |
---|
| 1956 | label $inner.opacity_l -text "Opacity" -font "Arial 9" |
---|
| 1957 | } { |
---|
| 1958 | ignore -font |
---|
| 1959 | } |
---|
| 1960 | itk_component add opacity { |
---|
| 1961 | ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ |
---|
[4432] | 1962 | -variable [itcl::scope _settings(-opacity)] \ |
---|
[3417] | 1963 | -showvalue off \ |
---|
[4399] | 1964 | -command [itcl::code $this AdjustSetting -opacity] |
---|
[3417] | 1965 | } |
---|
| 1966 | itk_component add scale_l { |
---|
| 1967 | label $inner.scale_l -text "Scale" -font "Arial 9" |
---|
| 1968 | } { |
---|
| 1969 | ignore -font |
---|
| 1970 | } |
---|
| 1971 | itk_component add scale { |
---|
| 1972 | ::scale $inner.scale -from 0 -to 100 -orient horizontal \ |
---|
[4399] | 1973 | -variable [itcl::scope _settings(-heightmapscale)] \ |
---|
[3417] | 1974 | -showvalue off \ |
---|
[4399] | 1975 | -command [itcl::code $this AdjustSetting -heightmapscale] |
---|
[3417] | 1976 | } |
---|
[3421] | 1977 | label $inner.numisolines_l -text "Number of Isolines" -font "Arial 9" |
---|
[3417] | 1978 | itk_component add numisolines { |
---|
| 1979 | Rappture::Spinint $inner.numisolines \ |
---|
[4208] | 1980 | -min 0 -max 50 -font "arial 9" |
---|
[3417] | 1981 | } |
---|
[4399] | 1982 | $itk_component(numisolines) value $_settings(-numisolines) |
---|
[3417] | 1983 | bind $itk_component(numisolines) <<Value>> \ |
---|
[4399] | 1984 | [itcl::code $this AdjustSetting -numisolines] |
---|
[3330] | 1985 | |
---|
[3537] | 1986 | frame $inner.separator1 -height 2 -relief sunken -bd 1 |
---|
| 1987 | frame $inner.separator2 -height 2 -relief sunken -bd 1 |
---|
| 1988 | |
---|
[2731] | 1989 | blt::table $inner \ |
---|
[3421] | 1990 | 0,0 $inner.field_l -anchor w -pady 2 \ |
---|
| 1991 | 0,1 $inner.field -anchor w -pady 2 -fill x \ |
---|
| 1992 | 1,0 $inner.colormap_l -anchor w -pady 2 \ |
---|
| 1993 | 1,1 $inner.colormap -anchor w -pady 2 -fill x \ |
---|
| 1994 | 2,0 $inner.isolinecolor_l -anchor w -pady 2 \ |
---|
| 1995 | 2,1 $inner.isolinecolor -anchor w -pady 2 -fill x \ |
---|
| 1996 | 3,0 $inner.background_l -anchor w -pady 2 \ |
---|
| 1997 | 3,1 $inner.background -anchor w -pady 2 -fill x \ |
---|
| 1998 | 4,0 $inner.numisolines_l -anchor w -pady 2 \ |
---|
| 1999 | 4,1 $inner.numisolines -anchor w -pady 2 \ |
---|
| 2000 | 5,0 $inner.stretch -anchor w -pady 2 -cspan 2 \ |
---|
| 2001 | 6,0 $inner.edges -anchor w -pady 2 -cspan 2 \ |
---|
| 2002 | 7,0 $inner.legend -anchor w -pady 2 -cspan 2 \ |
---|
[3462] | 2003 | 8,0 $inner.colormapDiscrete -anchor w -pady 2 -cspan 2 \ |
---|
| 2004 | 9,0 $inner.wireframe -anchor w -pady 2 -cspan 2\ |
---|
[3537] | 2005 | 10,0 $inner.isolines -anchor w -pady 2 -cspan 2 \ |
---|
| 2006 | 11,0 $inner.separator1 -padx 2 -fill x -cspan 2 \ |
---|
| 2007 | 12,0 $inner.outline -anchor w -pady 2 -cspan 2 \ |
---|
| 2008 | 13,0 $inner.separator2 -padx 2 -fill x -cspan 2 \ |
---|
| 2009 | 14,0 $inner.lighting -anchor w -pady 2 -cspan 2 \ |
---|
| 2010 | 15,0 $inner.opacity_l -anchor w -pady 2 \ |
---|
| 2011 | 15,1 $inner.opacity -fill x -pady 2 \ |
---|
| 2012 | 16,0 $inner.scale_l -anchor w -pady 2 -cspan 2 \ |
---|
| 2013 | 16,1 $inner.scale -fill x -pady 2 -cspan 2 \ |
---|
[2731] | 2014 | |
---|
| 2015 | blt::table configure $inner r* c* -resize none |
---|
[3537] | 2016 | blt::table configure $inner r17 c1 -resize expand |
---|
[2731] | 2017 | } |
---|
| 2018 | |
---|
| 2019 | itcl::body Rappture::VtkHeightmapViewer::BuildAxisTab {} { |
---|
| 2020 | |
---|
| 2021 | set fg [option get $itk_component(hull) font Font] |
---|
| 2022 | #set bfg [option get $itk_component(hull) boldFont Font] |
---|
| 2023 | |
---|
| 2024 | set inner [$itk_component(main) insert end \ |
---|
| 2025 | -title "Axis Settings" \ |
---|
[3517] | 2026 | -icon [Rappture::icon axis2]] |
---|
[2731] | 2027 | $inner configure -borderwidth 4 |
---|
| 2028 | |
---|
| 2029 | checkbutton $inner.visible \ |
---|
[3330] | 2030 | -text "Axes" \ |
---|
[4399] | 2031 | -variable [itcl::scope _settings(-axisvisible)] \ |
---|
| 2032 | -command [itcl::code $this AdjustSetting -axisvisible] \ |
---|
[2731] | 2033 | -font "Arial 9" |
---|
| 2034 | checkbutton $inner.labels \ |
---|
[3330] | 2035 | -text "Axis Labels" \ |
---|
[4399] | 2036 | -variable [itcl::scope _settings(-axislabels)] \ |
---|
| 2037 | -command [itcl::code $this AdjustSetting -axislabels] \ |
---|
[2731] | 2038 | -font "Arial 9" |
---|
[3330] | 2039 | label $inner.grid_l -text "Grid" -font "Arial 9" |
---|
| 2040 | checkbutton $inner.xgrid \ |
---|
| 2041 | -text "X" \ |
---|
[4399] | 2042 | -variable [itcl::scope _settings(-xgrid)] \ |
---|
| 2043 | -command [itcl::code $this AdjustSetting -xgrid] \ |
---|
[2731] | 2044 | -font "Arial 9" |
---|
[3330] | 2045 | checkbutton $inner.ygrid \ |
---|
| 2046 | -text "Y" \ |
---|
[4399] | 2047 | -variable [itcl::scope _settings(-ygrid)] \ |
---|
| 2048 | -command [itcl::code $this AdjustSetting -ygrid] \ |
---|
[2731] | 2049 | -font "Arial 9" |
---|
[3330] | 2050 | checkbutton $inner.zgrid \ |
---|
| 2051 | -text "Z" \ |
---|
[4399] | 2052 | -variable [itcl::scope _settings(-zgrid)] \ |
---|
| 2053 | -command [itcl::code $this AdjustSetting -zgrid] \ |
---|
[2731] | 2054 | -font "Arial 9" |
---|
[3330] | 2055 | checkbutton $inner.minorticks \ |
---|
| 2056 | -text "Minor Ticks" \ |
---|
[4399] | 2057 | -variable [itcl::scope _settings(-axisminorticks)] \ |
---|
| 2058 | -command [itcl::code $this AdjustSetting -axisminorticks] \ |
---|
[3330] | 2059 | -font "Arial 9" |
---|
[2731] | 2060 | |
---|
| 2061 | label $inner.mode_l -text "Mode" -font "Arial 9" |
---|
| 2062 | |
---|
[3330] | 2063 | itk_component add axisflymode { |
---|
[2744] | 2064 | Rappture::Combobox $inner.mode -width 10 -editable no |
---|
[2731] | 2065 | } |
---|
| 2066 | $inner.mode choices insert end \ |
---|
| 2067 | "static_triad" "static" \ |
---|
| 2068 | "closest_triad" "closest" \ |
---|
[4208] | 2069 | "furthest_triad" "farthest" \ |
---|
[2731] | 2070 | "outer_edges" "outer" |
---|
[4438] | 2071 | $itk_component(axisflymode) value $_settings(-axisflymode) |
---|
[4399] | 2072 | bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode] |
---|
[2731] | 2073 | |
---|
| 2074 | blt::table $inner \ |
---|
[3330] | 2075 | 0,0 $inner.visible -anchor w -cspan 4 \ |
---|
| 2076 | 1,0 $inner.labels -anchor w -cspan 4 \ |
---|
| 2077 | 2,0 $inner.minorticks -anchor w -cspan 4 \ |
---|
| 2078 | 4,0 $inner.grid_l -anchor w \ |
---|
| 2079 | 4,1 $inner.xgrid -anchor w \ |
---|
| 2080 | 4,2 $inner.ygrid -anchor w \ |
---|
| 2081 | 4,3 $inner.zgrid -anchor w \ |
---|
| 2082 | 5,0 $inner.mode_l -anchor w -padx { 2 0 } \ |
---|
| 2083 | 5,1 $inner.mode -fill x -cspan 3 |
---|
[2731] | 2084 | |
---|
| 2085 | blt::table configure $inner r* c* -resize none |
---|
[3330] | 2086 | blt::table configure $inner r7 c6 -resize expand |
---|
| 2087 | blt::table configure $inner r3 -height 0.125i |
---|
[2731] | 2088 | } |
---|
| 2089 | |
---|
| 2090 | |
---|
| 2091 | itcl::body Rappture::VtkHeightmapViewer::BuildCameraTab {} { |
---|
| 2092 | set inner [$itk_component(main) insert end \ |
---|
| 2093 | -title "Camera Settings" \ |
---|
| 2094 | -icon [Rappture::icon camera]] |
---|
| 2095 | $inner configure -borderwidth 4 |
---|
| 2096 | |
---|
[3517] | 2097 | label $inner.view_l -text "view" -font "Arial 9" |
---|
| 2098 | set f [frame $inner.view] |
---|
| 2099 | foreach side { front back left right top bottom } { |
---|
| 2100 | button $f.$side -image [Rappture::icon view$side] \ |
---|
| 2101 | -command [itcl::code $this SetOrientation $side] |
---|
| 2102 | Rappture::Tooltip::for $f.$side "Change the view to $side" |
---|
| 2103 | pack $f.$side -side left |
---|
| 2104 | } |
---|
| 2105 | |
---|
| 2106 | blt::table $inner \ |
---|
[3536] | 2107 | 0,0 $inner.view_l -anchor e -pady 2 \ |
---|
| 2108 | 0,1 $inner.view -anchor w -pady 2 |
---|
[3517] | 2109 | |
---|
[2731] | 2110 | set labels { qx qy qz qw xpan ypan zoom } |
---|
[3517] | 2111 | set row 1 |
---|
[2731] | 2112 | foreach tag $labels { |
---|
| 2113 | label $inner.${tag}label -text $tag -font "Arial 9" |
---|
| 2114 | entry $inner.${tag} -font "Arial 9" -bg white \ |
---|
| 2115 | -textvariable [itcl::scope _view($tag)] |
---|
[3454] | 2116 | bind $inner.${tag} <Return> \ |
---|
[2731] | 2117 | [itcl::code $this camera set ${tag}] |
---|
[3454] | 2118 | bind $inner.${tag} <KP_Enter> \ |
---|
| 2119 | [itcl::code $this camera set ${tag}] |
---|
[2731] | 2120 | blt::table $inner \ |
---|
| 2121 | $row,0 $inner.${tag}label -anchor e -pady 2 \ |
---|
| 2122 | $row,1 $inner.${tag} -anchor w -pady 2 |
---|
| 2123 | blt::table configure $inner r$row -resize none |
---|
| 2124 | incr row |
---|
| 2125 | } |
---|
| 2126 | checkbutton $inner.ortho \ |
---|
| 2127 | -text "Orthographic Projection" \ |
---|
| 2128 | -variable [itcl::scope _view(ortho)] \ |
---|
| 2129 | -command [itcl::code $this camera set ortho] \ |
---|
| 2130 | -font "Arial 9" |
---|
| 2131 | blt::table $inner \ |
---|
[3441] | 2132 | $row,0 $inner.ortho -cspan 2 -anchor w -pady 2 |
---|
[2731] | 2133 | blt::table configure $inner r$row -resize none |
---|
| 2134 | incr row |
---|
| 2135 | |
---|
[3517] | 2136 | blt::table configure $inner c* r* -resize none |
---|
[2731] | 2137 | blt::table configure $inner c2 -resize expand |
---|
| 2138 | blt::table configure $inner r$row -resize expand |
---|
| 2139 | } |
---|
| 2140 | |
---|
| 2141 | # |
---|
| 2142 | # camera -- |
---|
| 2143 | # |
---|
| 2144 | itcl::body Rappture::VtkHeightmapViewer::camera {option args} { |
---|
| 2145 | switch -- $option { |
---|
| 2146 | "show" { |
---|
| 2147 | puts [array get _view] |
---|
| 2148 | } |
---|
| 2149 | "set" { |
---|
| 2150 | set who [lindex $args 0] |
---|
| 2151 | set x $_view($who) |
---|
| 2152 | set code [catch { string is double $x } result] |
---|
| 2153 | if { $code != 0 || !$result } { |
---|
| 2154 | return |
---|
| 2155 | } |
---|
| 2156 | switch -- $who { |
---|
| 2157 | "ortho" { |
---|
| 2158 | if {$_view(ortho)} { |
---|
| 2159 | SendCmd "camera mode ortho" |
---|
| 2160 | } else { |
---|
| 2161 | SendCmd "camera mode persp" |
---|
| 2162 | } |
---|
| 2163 | } |
---|
| 2164 | "xpan" - "ypan" { |
---|
| 2165 | PanCamera |
---|
| 2166 | } |
---|
| 2167 | "qx" - "qy" - "qz" - "qw" { |
---|
| 2168 | set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] |
---|
[2744] | 2169 | $_arcball quaternion $q |
---|
| 2170 | EventuallyRotate $q |
---|
[2731] | 2171 | } |
---|
| 2172 | "zoom" { |
---|
| 2173 | SendCmd "camera zoom $_view(zoom)" |
---|
| 2174 | } |
---|
| 2175 | } |
---|
| 2176 | } |
---|
| 2177 | } |
---|
| 2178 | } |
---|
| 2179 | |
---|
| 2180 | itcl::body Rappture::VtkHeightmapViewer::GetVtkData { args } { |
---|
| 2181 | set bytes "" |
---|
| 2182 | foreach dataobj [get] { |
---|
| 2183 | foreach comp [$dataobj components] { |
---|
| 2184 | set tag $dataobj-$comp |
---|
[3416] | 2185 | set contents [$dataobj vtkdata $comp] |
---|
[3800] | 2186 | append bytes "$contents\n" |
---|
[2731] | 2187 | } |
---|
| 2188 | } |
---|
| 2189 | return [list .vtk $bytes] |
---|
| 2190 | } |
---|
| 2191 | |
---|
| 2192 | itcl::body Rappture::VtkHeightmapViewer::GetImage { args } { |
---|
| 2193 | if { [image width $_image(download)] > 0 && |
---|
[2744] | 2194 | [image height $_image(download)] > 0 } { |
---|
| 2195 | set bytes [$_image(download) data -format "jpeg -quality 100"] |
---|
| 2196 | set bytes [Rappture::encoding::decode -as b64 $bytes] |
---|
| 2197 | return [list .jpg $bytes] |
---|
[2731] | 2198 | } |
---|
| 2199 | return "" |
---|
| 2200 | } |
---|
| 2201 | |
---|
| 2202 | itcl::body Rappture::VtkHeightmapViewer::BuildDownloadPopup { popup command } { |
---|
| 2203 | Rappture::Balloon $popup \ |
---|
| 2204 | -title "[Rappture::filexfer::label downloadWord] as..." |
---|
| 2205 | set inner [$popup component inner] |
---|
| 2206 | label $inner.summary -text "" -anchor w |
---|
| 2207 | radiobutton $inner.vtk_button -text "VTK data file" \ |
---|
| 2208 | -variable [itcl::scope _downloadPopup(format)] \ |
---|
[3330] | 2209 | -font "Arial 9 " \ |
---|
[2731] | 2210 | -value vtk |
---|
| 2211 | Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file." |
---|
| 2212 | radiobutton $inner.image_button -text "Image File" \ |
---|
| 2213 | -variable [itcl::scope _downloadPopup(format)] \ |
---|
[3330] | 2214 | -font "Arial 9 " \ |
---|
[2731] | 2215 | -value image |
---|
| 2216 | Rappture::Tooltip::for $inner.image_button \ |
---|
| 2217 | "Save as digital image." |
---|
| 2218 | |
---|
| 2219 | button $inner.ok -text "Save" \ |
---|
[2744] | 2220 | -highlightthickness 0 -pady 2 -padx 3 \ |
---|
[2731] | 2221 | -command $command \ |
---|
[2744] | 2222 | -compound left \ |
---|
| 2223 | -image [Rappture::icon download] |
---|
[2731] | 2224 | |
---|
| 2225 | button $inner.cancel -text "Cancel" \ |
---|
[2744] | 2226 | -highlightthickness 0 -pady 2 -padx 3 \ |
---|
| 2227 | -command [list $popup deactivate] \ |
---|
| 2228 | -compound left \ |
---|
| 2229 | -image [Rappture::icon cancel] |
---|
[2731] | 2230 | |
---|
| 2231 | blt::table $inner \ |
---|
| 2232 | 0,0 $inner.summary -cspan 2 \ |
---|
| 2233 | 1,0 $inner.vtk_button -anchor w -cspan 2 -padx { 4 0 } \ |
---|
| 2234 | 2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \ |
---|
| 2235 | 4,1 $inner.cancel -width .9i -fill y \ |
---|
| 2236 | 4,0 $inner.ok -padx 2 -width .9i -fill y |
---|
| 2237 | blt::table configure $inner r3 -height 4 |
---|
| 2238 | blt::table configure $inner r4 -pady 4 |
---|
| 2239 | raise $inner.image_button |
---|
| 2240 | $inner.vtk_button invoke |
---|
| 2241 | return $inner |
---|
| 2242 | } |
---|
| 2243 | |
---|
[3454] | 2244 | # |
---|
| 2245 | # SetObjectStyle -- |
---|
| 2246 | # |
---|
| 2247 | # Set the style of the heightmap/contour object. This gets calls |
---|
| 2248 | # for each dataset once as it is loaded. It can overridden by |
---|
| 2249 | # the user controls. |
---|
| 2250 | # |
---|
| 2251 | # |
---|
[2731] | 2252 | itcl::body Rappture::VtkHeightmapViewer::SetObjectStyle { dataobj comp } { |
---|
| 2253 | # Parse style string. |
---|
| 2254 | set tag $dataobj-$comp |
---|
[3330] | 2255 | array set style { |
---|
| 2256 | -color BCGYR |
---|
[4438] | 2257 | -levels 10 |
---|
[4399] | 2258 | -opacity 1.0 |
---|
[2731] | 2259 | } |
---|
[3454] | 2260 | set stylelist [$dataobj style $comp] |
---|
| 2261 | if { $stylelist != "" } { |
---|
| 2262 | array set style $stylelist |
---|
| 2263 | } |
---|
| 2264 | # This is too complicated. We want to set the colormap, number of |
---|
[3469] | 2265 | # isolines and opacity for the dataset. They can be the default values, |
---|
| 2266 | # the style hints loaded with the dataset, or set by user controls. As |
---|
[3454] | 2267 | # datasets get loaded, they first use the defaults that are overidden |
---|
| 2268 | # by the style hints. If the user changes the global controls, then that |
---|
| 2269 | # overrides everything else. I don't know what it means when global |
---|
| 2270 | # controls are specified as style hints by each dataset. It complicates |
---|
| 2271 | # the code to handle aberrant cases. |
---|
| 2272 | |
---|
[4399] | 2273 | if { $_changed(-opacity) } { |
---|
[4432] | 2274 | set style(-opacity) [expr $_settings(-opacity) * 0.01] |
---|
[3454] | 2275 | } |
---|
[4399] | 2276 | if { $_changed(-numisolines) } { |
---|
[4438] | 2277 | set style(-levels) $_settings(-numisolines) |
---|
[3454] | 2278 | } |
---|
[4399] | 2279 | if { $_changed(-colormap) } { |
---|
| 2280 | set style(-color) $_settings(-colormap) |
---|
[3454] | 2281 | } |
---|
[3330] | 2282 | if { $_currentColormap == "" } { |
---|
[3454] | 2283 | $itk_component(colormap) value $style(-color) |
---|
[2731] | 2284 | } |
---|
[4208] | 2285 | if { [info exists style(-stretchtofit)] } { |
---|
[4399] | 2286 | set _settings(-stretchtofit) $style(-stretchtofit) |
---|
| 2287 | AdjustSetting -stretchtofit |
---|
[4208] | 2288 | } |
---|
[3454] | 2289 | if { $_currentNumIsolines != $style(-levels) } { |
---|
| 2290 | set _currentNumIsolines $style(-levels) |
---|
[4399] | 2291 | set _settings(-numisolines) $_currentNumIsolines |
---|
[3469] | 2292 | $itk_component(numisolines) value $_currentNumIsolines |
---|
[3623] | 2293 | UpdateContourList |
---|
[3454] | 2294 | DrawLegend |
---|
| 2295 | } |
---|
[3544] | 2296 | SendCmd "outline add $tag" |
---|
| 2297 | SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag" |
---|
[4399] | 2298 | SendCmd "outline visible $_settings(-outline) $tag" |
---|
[3330] | 2299 | set scale [GetHeightmapScale] |
---|
[3623] | 2300 | SendCmd "[list heightmap add contourlist $_contourList $scale $tag]" |
---|
[4399] | 2301 | set _comp2scale($tag) $_settings(-heightmapscale) |
---|
| 2302 | SendCmd "heightmap edges $_settings(-edges) $tag" |
---|
| 2303 | SendCmd "heightmap wireframe $_settings(-wireframe) $tag" |
---|
[4438] | 2304 | SetCurrentColormap $style(-color) |
---|
[3416] | 2305 | set color [$itk_component(isolinecolor) value] |
---|
| 2306 | SendCmd "heightmap isolinecolor [Color2RGB $color] $tag" |
---|
[4399] | 2307 | SendCmd "heightmap lighting $_settings(-isheightmap) $tag" |
---|
| 2308 | SendCmd "heightmap isolines $_settings(-isolinesvisible) $tag" |
---|
| 2309 | SendCmd "heightmap surface $_settings(-colormapvisible) $tag" |
---|
[4432] | 2310 | SendCmd "heightmap opacity $style(-opacity) $tag" |
---|
| 2311 | set _settings(-opacity) [expr $style(-opacity) * 100.0] |
---|
[2731] | 2312 | } |
---|
| 2313 | |
---|
| 2314 | itcl::body Rappture::VtkHeightmapViewer::IsValidObject { dataobj } { |
---|
| 2315 | if {[catch {$dataobj isa Rappture::Field} valid] != 0 || !$valid} { |
---|
[2744] | 2316 | return 0 |
---|
[2731] | 2317 | } |
---|
| 2318 | return 1 |
---|
| 2319 | } |
---|
| 2320 | |
---|
| 2321 | # ---------------------------------------------------------------------- |
---|
[3330] | 2322 | # USAGE: ReceiveLegend <colormap> <title> <min> <max> <size> |
---|
[2731] | 2323 | # |
---|
| 2324 | # Invoked automatically whenever the "legend" command comes in from |
---|
| 2325 | # the rendering server. Indicates that binary image data with the |
---|
| 2326 | # specified <size> will follow. |
---|
| 2327 | # ---------------------------------------------------------------------- |
---|
[3330] | 2328 | itcl::body Rappture::VtkHeightmapViewer::ReceiveLegend { colormap title min max size } { |
---|
| 2329 | #puts stderr "ReceiveLegend colormap=$colormap title=$title range=$min,$max size=$size" |
---|
| 2330 | if { [isconnected] } { |
---|
[2731] | 2331 | set bytes [ReceiveBytes $size] |
---|
| 2332 | if { ![info exists _image(legend)] } { |
---|
| 2333 | set _image(legend) [image create photo] |
---|
| 2334 | } |
---|
| 2335 | $_image(legend) configure -data $bytes |
---|
| 2336 | #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" |
---|
[3421] | 2337 | if { [catch {DrawLegend} errs] != 0 } { |
---|
[3330] | 2338 | global errorInfo |
---|
| 2339 | puts stderr "errs=$errs errorInfo=$errorInfo" |
---|
[2744] | 2340 | } |
---|
[2731] | 2341 | } |
---|
| 2342 | } |
---|
| 2343 | |
---|
| 2344 | # |
---|
| 2345 | # DrawLegend -- |
---|
| 2346 | # |
---|
[3416] | 2347 | # Draws the legend in the own canvas on the right side of the plot area. |
---|
[2731] | 2348 | # |
---|
[3421] | 2349 | itcl::body Rappture::VtkHeightmapViewer::DrawLegend {} { |
---|
| 2350 | set fname $_curFldName |
---|
[2731] | 2351 | set c $itk_component(view) |
---|
| 2352 | set w [winfo width $c] |
---|
| 2353 | set h [winfo height $c] |
---|
| 2354 | set font "Arial 8" |
---|
| 2355 | set lineht [font metrics $font -linespace] |
---|
| 2356 | |
---|
[3445] | 2357 | if { [string match "component*" $fname] } { |
---|
[3330] | 2358 | set title "" |
---|
| 2359 | } else { |
---|
[3416] | 2360 | if { [info exists _fields($fname)] } { |
---|
| 2361 | foreach { title units } $_fields($fname) break |
---|
[3330] | 2362 | if { $units != "" } { |
---|
| 2363 | set title [format "%s (%s)" $title $units] |
---|
| 2364 | } |
---|
| 2365 | } else { |
---|
[3416] | 2366 | set title $fname |
---|
[3330] | 2367 | } |
---|
| 2368 | } |
---|
| 2369 | set x [expr $w - 2] |
---|
[4399] | 2370 | if { !$_settings(-legendvisible) } { |
---|
[3330] | 2371 | $c delete legend |
---|
| 2372 | return |
---|
| 2373 | } |
---|
| 2374 | if { [$c find withtag "legend"] == "" } { |
---|
| 2375 | set y 2 |
---|
| 2376 | # If there's a legend title, create a text item for the title. |
---|
[3421] | 2377 | $c create text $x $y \ |
---|
[4438] | 2378 | -anchor ne \ |
---|
| 2379 | -fill $itk_option(-plotforeground) -tags "title legend" \ |
---|
| 2380 | -font $font |
---|
| 2381 | if { $title != "" } { |
---|
| 2382 | incr y $lineht |
---|
| 2383 | } |
---|
[3330] | 2384 | $c create text $x $y \ |
---|
[4438] | 2385 | -anchor ne \ |
---|
| 2386 | -fill $itk_option(-plotforeground) -tags "vmax legend" \ |
---|
| 2387 | -font $font |
---|
| 2388 | incr y $lineht |
---|
[3330] | 2389 | $c create image $x $y \ |
---|
| 2390 | -anchor ne \ |
---|
| 2391 | -image $_image(legend) -tags "colormap legend" |
---|
[3439] | 2392 | $c create rectangle $x $y 1 1 \ |
---|
| 2393 | -fill "" -outline "" -tags "sensor legend" |
---|
[3330] | 2394 | $c create text $x [expr {$h-2}] \ |
---|
| 2395 | -anchor se \ |
---|
| 2396 | -fill $itk_option(-plotforeground) -tags "vmin legend" \ |
---|
| 2397 | -font $font |
---|
[3442] | 2398 | $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y] |
---|
[3439] | 2399 | $c bind sensor <Leave> [itcl::code $this LeaveLegend] |
---|
[3442] | 2400 | $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y] |
---|
[3330] | 2401 | } |
---|
| 2402 | $c delete isoline |
---|
| 2403 | set x2 $x |
---|
| 2404 | set iw [image width $_image(legend)] |
---|
| 2405 | set ih [image height $_image(legend)] |
---|
| 2406 | set x1 [expr $x2 - ($iw*12)/10] |
---|
| 2407 | set color [$itk_component(isolinecolor) value] |
---|
[3421] | 2408 | |
---|
[3330] | 2409 | # Draw the isolines on the legend. |
---|
[4208] | 2410 | array unset _isolines |
---|
[3428] | 2411 | if { $color != "none" && [info exists _limits($_curFldName)] && |
---|
[4399] | 2412 | $_settings(-isolinesvisible) && $_currentNumIsolines > 0 } { |
---|
[3421] | 2413 | |
---|
[3623] | 2414 | foreach { vmin vmax } $_limits($_curFldName) break |
---|
| 2415 | set range [expr double($vmax - $vmin)] |
---|
| 2416 | if { $range <= 0.0 } { |
---|
| 2417 | set range 1.0; # Min is greater or equal to max. |
---|
| 2418 | } |
---|
| 2419 | set tags "isoline legend" |
---|
[3330] | 2420 | set offset [expr 2 + $lineht] |
---|
| 2421 | if { $title != "" } { |
---|
| 2422 | incr offset $lineht |
---|
| 2423 | } |
---|
[3623] | 2424 | foreach value $_contourList { |
---|
| 2425 | set norm [expr 1.0 - (($value - $vmin) / $range)] |
---|
| 2426 | set y1 [expr int(round(($norm * $ih) + $offset))] |
---|
[3439] | 2427 | for { set off 0 } { $off < 3 } { incr off } { |
---|
| 2428 | set _isolines([expr $y1 + $off]) $value |
---|
| 2429 | set _isolines([expr $y1 - $off]) $value |
---|
| 2430 | } |
---|
[3623] | 2431 | $c create line $x1 $y1 $x2 $y1 -fill $color -tags $tags |
---|
[3330] | 2432 | } |
---|
| 2433 | } |
---|
| 2434 | |
---|
| 2435 | $c bind title <ButtonPress> [itcl::code $this Combo post] |
---|
| 2436 | $c bind title <Enter> [itcl::code $this Combo activate] |
---|
| 2437 | $c bind title <Leave> [itcl::code $this Combo deactivate] |
---|
| 2438 | # Reset the item coordinates according the current size of the plot. |
---|
[3428] | 2439 | if { [info exists _limits($_curFldName)] } { |
---|
| 2440 | foreach { vmin vmax } $_limits($_curFldName) break |
---|
[3330] | 2441 | $c itemconfigure vmin -text [format %g $vmin] |
---|
| 2442 | $c itemconfigure vmax -text [format %g $vmax] |
---|
| 2443 | } |
---|
| 2444 | set y 2 |
---|
| 2445 | # If there's a legend title, move the title to the correct position |
---|
| 2446 | if { $title != "" } { |
---|
[3421] | 2447 | $c itemconfigure title -text $title |
---|
[3330] | 2448 | $c coords title $x $y |
---|
| 2449 | incr y $lineht |
---|
| 2450 | } |
---|
| 2451 | $c coords vmax $x $y |
---|
| 2452 | incr y $lineht |
---|
| 2453 | $c coords colormap $x $y |
---|
[3439] | 2454 | $c coords sensor [expr $x - $iw] $y $x [expr $y + $ih] |
---|
| 2455 | $c raise sensor |
---|
[3330] | 2456 | $c coords vmin $x [expr {$h - 2}] |
---|
| 2457 | } |
---|
| 2458 | |
---|
| 2459 | # |
---|
[2731] | 2460 | # EnterLegend -- |
---|
| 2461 | # |
---|
| 2462 | itcl::body Rappture::VtkHeightmapViewer::EnterLegend { x y } { |
---|
| 2463 | SetLegendTip $x $y |
---|
| 2464 | } |
---|
| 2465 | |
---|
| 2466 | # |
---|
| 2467 | # MotionLegend -- |
---|
| 2468 | # |
---|
| 2469 | itcl::body Rappture::VtkHeightmapViewer::MotionLegend { x y } { |
---|
| 2470 | Rappture::Tooltip::tooltip cancel |
---|
| 2471 | set c $itk_component(view) |
---|
[3439] | 2472 | set cw [winfo width $c] |
---|
| 2473 | set ch [winfo height $c] |
---|
| 2474 | if { $x >= 0 && $x < $cw && $y >= 0 && $y < $ch } { |
---|
| 2475 | SetLegendTip $x $y |
---|
| 2476 | } |
---|
[2731] | 2477 | } |
---|
| 2478 | |
---|
| 2479 | # |
---|
| 2480 | # LeaveLegend -- |
---|
| 2481 | # |
---|
| 2482 | itcl::body Rappture::VtkHeightmapViewer::LeaveLegend { } { |
---|
| 2483 | Rappture::Tooltip::tooltip cancel |
---|
| 2484 | .rappturetooltip configure -icon "" |
---|
| 2485 | } |
---|
| 2486 | |
---|
| 2487 | # |
---|
| 2488 | # SetLegendTip -- |
---|
| 2489 | # |
---|
| 2490 | itcl::body Rappture::VtkHeightmapViewer::SetLegendTip { x y } { |
---|
[3442] | 2491 | set fname $_curFldName |
---|
[2731] | 2492 | set c $itk_component(view) |
---|
| 2493 | set w [winfo width $c] |
---|
| 2494 | set h [winfo height $c] |
---|
| 2495 | set font "Arial 8" |
---|
| 2496 | set lineht [font metrics $font -linespace] |
---|
| 2497 | |
---|
[3416] | 2498 | set ih [image height $_image(legend)] |
---|
[3442] | 2499 | # Subtract off the offset of the color ramp from the top of the canvas |
---|
[3416] | 2500 | set iy [expr $y - ($lineht + 2)] |
---|
[2731] | 2501 | |
---|
[3445] | 2502 | if { [string match "component*" $fname] } { |
---|
[3442] | 2503 | set title "" |
---|
[2731] | 2504 | } else { |
---|
[3442] | 2505 | if { [info exists _fields($fname)] } { |
---|
| 2506 | foreach { title units } $_fields($fname) break |
---|
| 2507 | if { $units != "" } { |
---|
| 2508 | set title [format "%s (%s)" $title $units] |
---|
| 2509 | } |
---|
| 2510 | } else { |
---|
| 2511 | set title $fname |
---|
| 2512 | } |
---|
[2731] | 2513 | } |
---|
[3416] | 2514 | # If there's a legend title, increase the offset by the line height. |
---|
| 2515 | if { $title != "" } { |
---|
[3439] | 2516 | incr iy -$lineht |
---|
[3416] | 2517 | } |
---|
| 2518 | |
---|
[2731] | 2519 | # Make a swatch of the selected color |
---|
[3416] | 2520 | if { [catch { $_image(legend) get 10 $iy } pixel] != 0 } { |
---|
[2744] | 2521 | return |
---|
[2731] | 2522 | } |
---|
[3416] | 2523 | |
---|
[2731] | 2524 | if { ![info exists _image(swatch)] } { |
---|
[2744] | 2525 | set _image(swatch) [image create photo -width 24 -height 24] |
---|
[2731] | 2526 | } |
---|
| 2527 | set color [eval format "\#%02x%02x%02x" $pixel] |
---|
| 2528 | $_image(swatch) put black -to 0 0 23 23 |
---|
| 2529 | $_image(swatch) put $color -to 1 1 22 22 |
---|
| 2530 | |
---|
| 2531 | # Compute the value of the point |
---|
[3442] | 2532 | if { [info exists _limits($fname)] } { |
---|
| 2533 | foreach { vmin vmax } $_limits($fname) break |
---|
[3416] | 2534 | set t [expr 1.0 - (double($iy) / double($ih-1))] |
---|
[3330] | 2535 | set value [expr $t * ($vmax - $vmin) + $vmin] |
---|
[2731] | 2536 | } else { |
---|
[2744] | 2537 | set value 0.0 |
---|
[2731] | 2538 | } |
---|
| 2539 | set tipx [expr $x + 15] |
---|
| 2540 | set tipy [expr $y - 5] |
---|
[3439] | 2541 | .rappturetooltip configure -icon $_image(swatch) |
---|
[3442] | 2542 | if { [info exists _isolines($y)] } { |
---|
| 2543 | Rappture::Tooltip::text $c [format "$title %g (isoline)" $_isolines($y)] |
---|
[3439] | 2544 | } else { |
---|
| 2545 | Rappture::Tooltip::text $c [format "$title %g" $value] |
---|
| 2546 | } |
---|
[2731] | 2547 | Rappture::Tooltip::tooltip show $c +$tipx,+$tipy |
---|
| 2548 | } |
---|
| 2549 | |
---|
| 2550 | # ---------------------------------------------------------------------- |
---|
| 2551 | # USAGE: _dropdown post |
---|
| 2552 | # USAGE: _dropdown unpost |
---|
| 2553 | # USAGE: _dropdown select |
---|
| 2554 | # |
---|
| 2555 | # Used internally to handle the dropdown list for this combobox. The |
---|
| 2556 | # post/unpost options are invoked when the list is posted or unposted |
---|
| 2557 | # to manage the relief of the controlling button. The select option |
---|
| 2558 | # is invoked whenever there is a selection from the list, to assign |
---|
| 2559 | # the value back to the gauge. |
---|
| 2560 | # ---------------------------------------------------------------------- |
---|
| 2561 | itcl::body Rappture::VtkHeightmapViewer::Combo {option} { |
---|
| 2562 | set c $itk_component(view) |
---|
| 2563 | switch -- $option { |
---|
| 2564 | post { |
---|
[2744] | 2565 | foreach { x1 y1 x2 y2 } [$c bbox title] break |
---|
| 2566 | set x1 [expr [winfo width $itk_component(view)] - [winfo reqwidth $itk_component(fieldmenu)]] |
---|
| 2567 | set x [expr $x1 + [winfo rootx $itk_component(view)]] |
---|
| 2568 | set y [expr $y2 + [winfo rooty $itk_component(view)]] |
---|
| 2569 | tk_popup $itk_component(fieldmenu) $x $y |
---|
[2731] | 2570 | } |
---|
| 2571 | activate { |
---|
[2744] | 2572 | $c itemconfigure title -fill red |
---|
[2731] | 2573 | } |
---|
| 2574 | deactivate { |
---|
[3330] | 2575 | $c itemconfigure title -fill $itk_option(-plotforeground) |
---|
[2731] | 2576 | } |
---|
[2744] | 2577 | invoke { |
---|
[3409] | 2578 | $itk_component(field) value $_curFldLabel |
---|
[4399] | 2579 | AdjustSetting -field |
---|
[2744] | 2580 | } |
---|
[2731] | 2581 | default { |
---|
| 2582 | error "bad option \"$option\": should be post, unpost, select" |
---|
| 2583 | } |
---|
| 2584 | } |
---|
| 2585 | } |
---|
[3330] | 2586 | |
---|
| 2587 | itcl::body Rappture::VtkHeightmapViewer::GetHeightmapScale {} { |
---|
[4399] | 2588 | if { $_settings(-isheightmap) } { |
---|
| 2589 | set val $_settings(-heightmapscale) |
---|
[3330] | 2590 | set sval [expr { $val >= 50 ? double($val)/50.0 : 1.0/(2.0-(double($val)/50.0)) }] |
---|
| 2591 | return $sval |
---|
| 2592 | } |
---|
[4208] | 2593 | return 0 |
---|
[3330] | 2594 | } |
---|
| 2595 | |
---|
[3517] | 2596 | itcl::body Rappture::VtkHeightmapViewer::SetOrientation { side } { |
---|
| 2597 | array set positions { |
---|
[3545] | 2598 | front "0.707107 0.707107 0 0" |
---|
| 2599 | back "0 0 0.707107 0.707107" |
---|
| 2600 | left "0.5 0.5 -0.5 -0.5" |
---|
| 2601 | right "0.5 0.5 0.5 0.5" |
---|
| 2602 | top "1 0 0 0" |
---|
| 2603 | bottom "0 1 0 0" |
---|
[3517] | 2604 | } |
---|
| 2605 | foreach name { qw qx qy qz } value $positions($side) { |
---|
| 2606 | set _view($name) $value |
---|
| 2607 | } |
---|
| 2608 | set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] |
---|
| 2609 | $_arcball quaternion $q |
---|
[3536] | 2610 | SendCmd "camera orient $q" |
---|
| 2611 | SendCmd "camera reset" |
---|
| 2612 | set _view(xpan) 0 |
---|
| 2613 | set _view(ypan) 0 |
---|
| 2614 | set _view(zoom) 1.0 |
---|
[3517] | 2615 | } |
---|
[3623] | 2616 | |
---|
| 2617 | itcl::body Rappture::VtkHeightmapViewer::UpdateContourList {} { |
---|
[4208] | 2618 | if {$_currentNumIsolines == 0} { |
---|
| 2619 | set _contourList "" |
---|
| 2620 | return |
---|
| 2621 | } |
---|
[3623] | 2622 | if { ![info exists _limits($_curFldName)] } { |
---|
| 2623 | return |
---|
| 2624 | } |
---|
| 2625 | foreach { vmin vmax } $_limits($_curFldName) break |
---|
| 2626 | set v [blt::vector create \#auto] |
---|
| 2627 | $v seq $vmin $vmax [expr $_currentNumIsolines+2] |
---|
| 2628 | $v delete end 0 |
---|
| 2629 | set _contourList [$v range 0 end] |
---|
| 2630 | blt::vector destroy $v |
---|
| 2631 | } |
---|