[3330] | 1 | # -*- mode: tcl; indent-tabs-mode: nil -*- |
---|
[1295] | 2 | # ---------------------------------------------------------------------- |
---|
[1349] | 3 | # COMPONENT: flowvisviewer - 3D flow rendering |
---|
[1295] | 4 | # |
---|
[1349] | 5 | # |
---|
| 6 | # This widget performs volume and flow rendering on 3D scalar/vector datasets. |
---|
| 7 | # It connects to the Flowvis server running on a rendering farm, transmits |
---|
| 8 | # data, and displays the results. |
---|
| 9 | # |
---|
[1295] | 10 | # ====================================================================== |
---|
[1349] | 11 | # AUTHOR: Michael McLennan, Purdue University |
---|
[3177] | 12 | # Copyright (c) 2004-2012 HUBzero Foundation, LLC |
---|
[1295] | 13 | # |
---|
[1349] | 14 | # See the file "license.terms" for information on usage and redistribution of |
---|
| 15 | # this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
[1295] | 16 | # ====================================================================== |
---|
| 17 | package require Itk |
---|
| 18 | package require BLT |
---|
| 19 | package require Img |
---|
| 20 | |
---|
[1448] | 21 | option add *FlowvisViewer.width 5i widgetDefault |
---|
[1349] | 22 | option add *FlowvisViewer*cursor crosshair widgetDefault |
---|
[1295] | 23 | option add *FlowvisViewer.height 4i widgetDefault |
---|
| 24 | option add *FlowvisViewer.foreground black widgetDefault |
---|
[1442] | 25 | option add *FlowvisViewer.controlBackground gray widgetDefault |
---|
| 26 | option add *FlowvisViewer.controlDarkBackground #999999 widgetDefault |
---|
[1295] | 27 | option add *FlowvisViewer.plotBackground black widgetDefault |
---|
| 28 | option add *FlowvisViewer.plotForeground white widgetDefault |
---|
[1349] | 29 | option add *FlowvisViewer.plotOutline gray widgetDefault |
---|
[1295] | 30 | option add *FlowvisViewer.font \ |
---|
| 31 | -*-helvetica-medium-r-normal-*-12-* widgetDefault |
---|
| 32 | |
---|
| 33 | # must use this name -- plugs into Rappture::resources::load |
---|
| 34 | proc FlowvisViewer_init_resources {} { |
---|
| 35 | Rappture::resources::register \ |
---|
[1349] | 36 | nanovis_server Rappture::FlowvisViewer::SetServerList |
---|
[1295] | 37 | } |
---|
| 38 | |
---|
| 39 | itcl::class Rappture::FlowvisViewer { |
---|
| 40 | inherit Rappture::VisViewer |
---|
| 41 | |
---|
| 42 | itk_option define -plotforeground plotForeground Foreground "" |
---|
| 43 | itk_option define -plotbackground plotBackground Background "" |
---|
| 44 | itk_option define -plotoutline plotOutline PlotOutline "" |
---|
| 45 | |
---|
[3940] | 46 | private variable _volcomponents ; # Array of components found |
---|
| 47 | private variable _componentsList ; # Array of components found |
---|
| 48 | private method BuildVolumeComponents {} |
---|
| 49 | private method GetDatasetsWithComponent { cname } |
---|
| 50 | |
---|
[1295] | 51 | constructor { hostlist args } { |
---|
[1349] | 52 | Rappture::VisViewer::constructor $hostlist |
---|
[1295] | 53 | } { |
---|
[1349] | 54 | # defined below |
---|
[1295] | 55 | } |
---|
| 56 | destructor { |
---|
[1349] | 57 | # defined below |
---|
[1295] | 58 | } |
---|
| 59 | public proc SetServerList { namelist } { |
---|
[1349] | 60 | Rappture::VisViewer::SetServerList "nanovis" $namelist |
---|
[1295] | 61 | } |
---|
| 62 | public method add {dataobj {settings ""}} |
---|
[1442] | 63 | public method camera {option args} |
---|
[1295] | 64 | public method delete {args} |
---|
[1491] | 65 | public method disconnect {} |
---|
[1295] | 66 | public method download {option args} |
---|
[1442] | 67 | public method flow {option} |
---|
| 68 | public method get {args} |
---|
[1295] | 69 | public method isconnected {} |
---|
[3940] | 70 | public method limits { cname } |
---|
[4166] | 71 | public method overMarker { m x } |
---|
[1442] | 72 | public method parameters {title args} { |
---|
[1694] | 73 | # do nothing |
---|
[1442] | 74 | } |
---|
[4166] | 75 | public method removeDuplicateMarker { m x } |
---|
[1442] | 76 | public method scale {args} |
---|
[4166] | 77 | public method updateTransferFunctions {} |
---|
[1349] | 78 | |
---|
[1295] | 79 | protected method Connect {} |
---|
[1442] | 80 | protected method CurrentVolumeIds {{what -all}} |
---|
[1295] | 81 | protected method Disconnect {} |
---|
[1491] | 82 | protected method Resize {} |
---|
[1448] | 83 | protected method ResizeLegend {} |
---|
[3396] | 84 | protected method AdjustSetting {what {value ""}} |
---|
| 85 | protected method InitSettings { args } |
---|
[1442] | 86 | protected method Pan {option x y} |
---|
| 87 | protected method Rebuild {} |
---|
| 88 | protected method ReceiveData { args } |
---|
| 89 | protected method ReceiveImage { args } |
---|
| 90 | protected method ReceiveLegend { tf vmin vmax size } |
---|
| 91 | protected method Rotate {option x y} |
---|
[1377] | 92 | protected method SendTransferFuncs {} |
---|
[1349] | 93 | protected method Slice {option args} |
---|
| 94 | protected method SlicerTip {axis} |
---|
[1442] | 95 | protected method Zoom {option} |
---|
[1295] | 96 | |
---|
[1442] | 97 | # soon to be removed. |
---|
[1349] | 98 | protected method Flow {option args} |
---|
| 99 | protected method Play {} |
---|
| 100 | protected method Pause {} |
---|
[1295] | 101 | |
---|
| 102 | |
---|
[1349] | 103 | # The following methods are only used by this class. |
---|
[1442] | 104 | |
---|
[1349] | 105 | private method AddIsoMarker { x y } |
---|
[1442] | 106 | private method BuildCameraTab {} |
---|
[1373] | 107 | private method BuildCutplanesTab {} |
---|
| 108 | private method BuildViewTab {} |
---|
| 109 | private method BuildVolumeTab {} |
---|
[1442] | 110 | private method ComputeTransferFunc { tf } |
---|
| 111 | private method EventuallyResize { w h } |
---|
[1471] | 112 | private method EventuallyGoto { nSteps } |
---|
[1442] | 113 | private method EventuallyResizeLegend { } |
---|
| 114 | private method FlowCmd { dataobj comp nbytes extents } |
---|
| 115 | private method GetMovie { widget width height } |
---|
[1506] | 116 | private method GetPngImage { widget width height } |
---|
[1442] | 117 | private method NameTransferFunc { dataobj comp } |
---|
[1349] | 118 | private method PanCamera {} |
---|
[1442] | 119 | private method ParseLevelsOption { tf levels } |
---|
| 120 | private method ParseMarkersOption { tf markers } |
---|
[1355] | 121 | private method WaitIcon { option widget } |
---|
[1471] | 122 | private method str2millisecs { value } |
---|
| 123 | private method millisecs2str { value } |
---|
[1442] | 124 | private method GetFlowInfo { widget } |
---|
| 125 | private method particles { tag name } |
---|
| 126 | private method box { tag name } |
---|
| 127 | private method streams { tag name } |
---|
[1491] | 128 | private method arrows { tag name } |
---|
[3533] | 129 | private method SetOrientation { side } |
---|
[1295] | 130 | |
---|
[3362] | 131 | private variable _arcball "" |
---|
[1442] | 132 | private variable _dlist "" ;# list of data objects |
---|
| 133 | private variable _allDataObjs |
---|
| 134 | private variable _obj2ovride ;# maps dataobj => style override |
---|
[1479] | 135 | private variable _serverObjs ;# maps dataobj-component to volume ID |
---|
[1694] | 136 | # in the server |
---|
[1448] | 137 | private variable _recvObjs ;# list of data objs to send to server |
---|
[1442] | 138 | private variable _obj2style ;# maps dataobj-component to transfunc |
---|
| 139 | private variable _style2objs ;# maps tf back to list of |
---|
[1694] | 140 | # dataobj-components using the tf. |
---|
[2744] | 141 | private variable _obj2flow; # Maps dataobj-component to a flow. |
---|
[1442] | 142 | |
---|
[3396] | 143 | private variable _reset 1; # Connection to server has been reset |
---|
[1442] | 144 | private variable _click ;# info used for rotate operations |
---|
| 145 | private variable _limits ;# autoscale min/max for all axes |
---|
| 146 | private variable _view ;# view params for 3D view |
---|
| 147 | private variable _isomarkers ;# array of isosurface level values 0..1 |
---|
| 148 | private common _settings |
---|
| 149 | private variable _activeTf "" ;# The currently active transfer function. |
---|
| 150 | private variable _first "" ;# This is the topmost volume. |
---|
[1506] | 151 | private variable _nextToken 0 |
---|
| 152 | private variable _icon 0 |
---|
[1442] | 153 | private variable _flow |
---|
[1349] | 154 | # This |
---|
| 155 | # indicates which isomarkers and transfer |
---|
| 156 | # function to use when changing markers, |
---|
| 157 | # opacity, or thickness. |
---|
[1506] | 158 | private common _downloadPopup ;# download options from popup |
---|
[1295] | 159 | |
---|
[1442] | 160 | private common _hardcopy |
---|
| 161 | private variable _width 0 |
---|
| 162 | private variable _height 0 |
---|
[1448] | 163 | private variable _resizePending 0 |
---|
| 164 | private variable _resizeLegendPending 0 |
---|
[1471] | 165 | private variable _gotoPending 0 |
---|
[1295] | 166 | } |
---|
| 167 | |
---|
| 168 | itk::usual FlowvisViewer { |
---|
| 169 | keep -background -foreground -cursor -font |
---|
| 170 | keep -plotbackground -plotforeground |
---|
| 171 | } |
---|
| 172 | |
---|
| 173 | # ---------------------------------------------------------------------- |
---|
| 174 | # CONSTRUCTOR |
---|
| 175 | # ---------------------------------------------------------------------- |
---|
[1349] | 176 | itcl::body Rappture::FlowvisViewer::constructor { hostlist args } { |
---|
[2671] | 177 | set _serverType "nanovis" |
---|
[1349] | 178 | |
---|
| 179 | # Draw legend event |
---|
| 180 | $_dispatcher register !legend |
---|
[1448] | 181 | $_dispatcher dispatch $this !legend "[itcl::code $this ResizeLegend]; list" |
---|
[1442] | 182 | |
---|
| 183 | # Send transferfunctions event |
---|
[1349] | 184 | $_dispatcher register !send_transfunc |
---|
| 185 | $_dispatcher dispatch $this !send_transfunc \ |
---|
[1377] | 186 | "[itcl::code $this SendTransferFuncs]; list" |
---|
[1442] | 187 | |
---|
| 188 | # Rebuild event. |
---|
[1295] | 189 | $_dispatcher register !rebuild |
---|
[1349] | 190 | $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list" |
---|
[1295] | 191 | |
---|
[1442] | 192 | # Resize event. |
---|
[1377] | 193 | $_dispatcher register !resize |
---|
[1491] | 194 | $_dispatcher dispatch $this !resize "[itcl::code $this Resize]; list" |
---|
[1377] | 195 | |
---|
[1349] | 196 | $_dispatcher register !play |
---|
| 197 | $_dispatcher dispatch $this !play "[itcl::code $this flow next]; list" |
---|
| 198 | |
---|
[1471] | 199 | # Draw legend event |
---|
| 200 | $_dispatcher register !goto |
---|
| 201 | $_dispatcher dispatch $this !goto "[itcl::code $this flow goto2]; list" |
---|
| 202 | |
---|
[1506] | 203 | $_dispatcher register !movietimeout |
---|
| 204 | $_dispatcher register !waiticon |
---|
| 205 | |
---|
[1442] | 206 | set _flow(state) 0 |
---|
| 207 | |
---|
| 208 | array set _downloadPopup { |
---|
[1355] | 209 | format draft |
---|
[1295] | 210 | } |
---|
| 211 | # |
---|
| 212 | # Populate parser with commands handle incoming requests |
---|
| 213 | # |
---|
| 214 | $_parser alias image [itcl::code $this ReceiveImage] |
---|
[1349] | 215 | $_parser alias legend [itcl::code $this ReceiveLegend] |
---|
| 216 | $_parser alias data [itcl::code $this ReceiveData] |
---|
[1295] | 217 | |
---|
| 218 | # Initialize the view to some default parameters. |
---|
[1442] | 219 | array set _view { |
---|
[3362] | 220 | qw 0.853553 |
---|
| 221 | qx -0.353553 |
---|
| 222 | qy 0.353553 |
---|
| 223 | qz 0.146447 |
---|
[1694] | 224 | zoom 1.0 |
---|
[3533] | 225 | xpan 0 |
---|
| 226 | ypan 0 |
---|
[1295] | 227 | } |
---|
[3362] | 228 | set _arcball [blt::arcball create 100 100] |
---|
| 229 | set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] |
---|
| 230 | $_arcball quaternion $q |
---|
| 231 | |
---|
[3940] | 232 | set _limits(v) [list 0.0 1.0] |
---|
[3396] | 233 | set _reset 1 |
---|
[1295] | 234 | |
---|
[1442] | 235 | array set _settings [subst { |
---|
[3362] | 236 | $this-qw $_view(qw) |
---|
| 237 | $this-qx $_view(qx) |
---|
| 238 | $this-qy $_view(qy) |
---|
| 239 | $this-qz $_view(qz) |
---|
| 240 | $this-zoom $_view(zoom) |
---|
[3533] | 241 | $this-xpan $_view(xpan) |
---|
| 242 | $this-ypan $_view(ypan) |
---|
[2744] | 243 | $this-arrows 0 |
---|
| 244 | $this-currenttime 0 |
---|
| 245 | $this-duration 1:00 |
---|
| 246 | $this-loop 0 |
---|
| 247 | $this-play 0 |
---|
| 248 | $this-speed 500 |
---|
| 249 | $this-step 0 |
---|
| 250 | $this-streams 0 |
---|
| 251 | $this-volume 1 |
---|
[3946] | 252 | $this-ambient 60 |
---|
| 253 | $this-diffuse 40 |
---|
[3915] | 254 | $this-light2side 1 |
---|
| 255 | $this-opacity 100 |
---|
| 256 | $this-specularLevel 30 |
---|
| 257 | $this-specularExponent 90 |
---|
| 258 | $this-thickness 350 |
---|
| 259 | $this-transp 50 |
---|
[3899] | 260 | $this-cutplaneVisible 0 |
---|
| 261 | $this-xcutplane 1 |
---|
[2744] | 262 | $this-xcutposition 0 |
---|
[3899] | 263 | $this-ycutplane 1 |
---|
[2744] | 264 | $this-ycutposition 0 |
---|
[3899] | 265 | $this-zcutplane 1 |
---|
[2744] | 266 | $this-zcutposition 0 |
---|
[1442] | 267 | }] |
---|
| 268 | |
---|
[1545] | 269 | itk_component add 3dview { |
---|
[2584] | 270 | label $itk_component(plotarea).view -image $_image(plot) \ |
---|
[1694] | 271 | -highlightthickness 0 -borderwidth 0 |
---|
[1545] | 272 | } { |
---|
[1694] | 273 | usual |
---|
| 274 | ignore -highlightthickness -borderwidth -background |
---|
[1545] | 275 | } |
---|
[3477] | 276 | bind $itk_component(3dview) <Control-F1> [itcl::code $this ToggleConsole] |
---|
| 277 | |
---|
[1375] | 278 | set f [$itk_component(main) component controls] |
---|
[1295] | 279 | itk_component add reset { |
---|
[1375] | 280 | button $f.reset -borderwidth 1 -padx 1 -pady 1 \ |
---|
[1391] | 281 | -highlightthickness 0 \ |
---|
[1349] | 282 | -image [Rappture::icon reset-view] \ |
---|
| 283 | -command [itcl::code $this Zoom reset] |
---|
[1391] | 284 | } { |
---|
| 285 | usual |
---|
| 286 | ignore -highlightthickness |
---|
[1295] | 287 | } |
---|
[1373] | 288 | pack $itk_component(reset) -side top -padx 2 -pady 2 |
---|
[1295] | 289 | Rappture::Tooltip::for $itk_component(reset) "Reset the view to the default zoom level" |
---|
| 290 | |
---|
| 291 | itk_component add zoomin { |
---|
[1375] | 292 | button $f.zin -borderwidth 1 -padx 1 -pady 1 \ |
---|
[1391] | 293 | -highlightthickness 0 \ |
---|
[1349] | 294 | -image [Rappture::icon zoom-in] \ |
---|
| 295 | -command [itcl::code $this Zoom in] |
---|
[1391] | 296 | } { |
---|
| 297 | usual |
---|
| 298 | ignore -highlightthickness |
---|
[1295] | 299 | } |
---|
[1373] | 300 | pack $itk_component(zoomin) -side top -padx 2 -pady 2 |
---|
[1295] | 301 | Rappture::Tooltip::for $itk_component(zoomin) "Zoom in" |
---|
| 302 | |
---|
| 303 | itk_component add zoomout { |
---|
[1375] | 304 | button $f.zout -borderwidth 1 -padx 1 -pady 1 \ |
---|
[1391] | 305 | -highlightthickness 0 \ |
---|
[1349] | 306 | -image [Rappture::icon zoom-out] \ |
---|
| 307 | -command [itcl::code $this Zoom out] |
---|
[1391] | 308 | } { |
---|
| 309 | usual |
---|
| 310 | ignore -highlightthickness |
---|
[1295] | 311 | } |
---|
[1373] | 312 | pack $itk_component(zoomout) -side top -padx 2 -pady 2 |
---|
[1295] | 313 | Rappture::Tooltip::for $itk_component(zoomout) "Zoom out" |
---|
| 314 | |
---|
| 315 | itk_component add volume { |
---|
[1442] | 316 | Rappture::PushButton $f.volume \ |
---|
[1694] | 317 | -onimage [Rappture::icon volume-on] \ |
---|
| 318 | -offimage [Rappture::icon volume-off] \ |
---|
[3396] | 319 | -command [itcl::code $this AdjustSetting volume] \ |
---|
[1694] | 320 | -variable [itcl::scope _settings($this-volume)] |
---|
[1295] | 321 | } |
---|
[1442] | 322 | $itk_component(volume) select |
---|
[1295] | 323 | Rappture::Tooltip::for $itk_component(volume) \ |
---|
[1349] | 324 | "Toggle the volume cloud on/off" |
---|
[1373] | 325 | pack $itk_component(volume) -padx 2 -pady 2 |
---|
[1295] | 326 | |
---|
[3899] | 327 | itk_component add cutplane { |
---|
| 328 | Rappture::PushButton $f.cutplane \ |
---|
| 329 | -onimage [Rappture::icon cutbutton] \ |
---|
| 330 | -offimage [Rappture::icon cutbutton] \ |
---|
| 331 | -variable [itcl::scope _settings($this-cutplaneVisible)] \ |
---|
| 332 | -command [itcl::code $this AdjustSetting cutplaneVisible] |
---|
| 333 | } |
---|
| 334 | Rappture::Tooltip::for $itk_component(cutplane) \ |
---|
| 335 | "Show/Hide cutplanes" |
---|
| 336 | pack $itk_component(cutplane) -padx 2 -pady 2 |
---|
| 337 | |
---|
[3492] | 338 | if { [catch { |
---|
| 339 | BuildViewTab |
---|
| 340 | BuildVolumeTab |
---|
| 341 | BuildCutplanesTab |
---|
| 342 | BuildCameraTab |
---|
| 343 | } errs] != 0 } { |
---|
| 344 | global errorInfo |
---|
| 345 | puts stderr "errs=$errs errorInfo=$errorInfo" |
---|
| 346 | } |
---|
[1373] | 347 | |
---|
[1448] | 348 | bind $itk_component(3dview) <Configure> \ |
---|
[1694] | 349 | [itcl::code $this EventuallyResize %w %h] |
---|
[1448] | 350 | |
---|
[1349] | 351 | # Legend |
---|
| 352 | set _image(legend) [image create photo] |
---|
| 353 | itk_component add legend { |
---|
[4165] | 354 | canvas $itk_component(plotarea).legend -height 50 -highlightthickness 0 |
---|
[1295] | 355 | } { |
---|
[1349] | 356 | usual |
---|
| 357 | ignore -highlightthickness |
---|
| 358 | rename -background -plotbackground plotBackground Background |
---|
[1295] | 359 | } |
---|
[1349] | 360 | bind $itk_component(legend) <Configure> \ |
---|
[1694] | 361 | [itcl::code $this EventuallyResizeLegend] |
---|
[1295] | 362 | |
---|
[1373] | 363 | # Hack around the Tk panewindow. The problem is that the requested |
---|
| 364 | # size of the 3d view isn't set until an image is retrieved from |
---|
| 365 | # the server. So the panewindow uses the tiny size. |
---|
[1442] | 366 | set w 10000 |
---|
| 367 | pack forget $itk_component(3dview) |
---|
[1373] | 368 | blt::table $itk_component(plotarea) \ |
---|
[1694] | 369 | 0,0 $itk_component(3dview) -fill both -reqwidth $w \ |
---|
| 370 | 1,0 $itk_component(legend) -fill x |
---|
[1442] | 371 | blt::table configure $itk_component(plotarea) r1 -resize none |
---|
[1349] | 372 | # Create flow controls... |
---|
[1295] | 373 | |
---|
[1448] | 374 | itk_component add flowcontrols { |
---|
| 375 | frame $itk_interior.flowcontrols |
---|
[1295] | 376 | } { |
---|
[1694] | 377 | usual |
---|
[1349] | 378 | rename -background -controlbackground controlBackground Background |
---|
[1295] | 379 | } |
---|
[1442] | 380 | pack forget $itk_component(main) |
---|
| 381 | blt::table $itk_interior \ |
---|
[1694] | 382 | 0,0 $itk_component(main) -fill both \ |
---|
| 383 | 1,0 $itk_component(flowcontrols) -fill x |
---|
[1442] | 384 | blt::table configure $itk_interior r1 -resize none |
---|
[1295] | 385 | |
---|
[1448] | 386 | # Rewind |
---|
[1349] | 387 | itk_component add rewind { |
---|
[1448] | 388 | button $itk_component(flowcontrols).reset \ |
---|
[1349] | 389 | -borderwidth 1 -padx 1 -pady 1 \ |
---|
| 390 | -image [Rappture::icon flow-rewind] \ |
---|
[1694] | 391 | -command [itcl::code $this flow reset] |
---|
[1295] | 392 | } { |
---|
[1349] | 393 | usual |
---|
| 394 | ignore -borderwidth |
---|
[1448] | 395 | rename -highlightbackground -controlbackground controlBackground \ |
---|
[1694] | 396 | Background |
---|
[1295] | 397 | } |
---|
[1349] | 398 | Rappture::Tooltip::for $itk_component(rewind) \ |
---|
[1442] | 399 | "Rewind flow" |
---|
[1295] | 400 | |
---|
[1448] | 401 | # Stop |
---|
[1295] | 402 | itk_component add stop { |
---|
[1448] | 403 | button $itk_component(flowcontrols).stop \ |
---|
[1349] | 404 | -borderwidth 1 -padx 1 -pady 1 \ |
---|
| 405 | -image [Rappture::icon flow-stop] \ |
---|
[1694] | 406 | -command [itcl::code $this flow stop] |
---|
[1295] | 407 | } { |
---|
[1349] | 408 | usual |
---|
| 409 | ignore -borderwidth |
---|
[1448] | 410 | rename -highlightbackground -controlbackground controlBackground \ |
---|
[1694] | 411 | Background |
---|
[1295] | 412 | } |
---|
| 413 | Rappture::Tooltip::for $itk_component(stop) \ |
---|
[1442] | 414 | "Stop flow" |
---|
[1295] | 415 | |
---|
[1448] | 416 | # Play |
---|
[1295] | 417 | itk_component add play { |
---|
[1448] | 418 | Rappture::PushButton $itk_component(flowcontrols).play \ |
---|
[1694] | 419 | -onimage [Rappture::icon flow-pause] \ |
---|
| 420 | -offimage [Rappture::icon flow-play] \ |
---|
| 421 | -variable [itcl::scope _settings($this-play)] \ |
---|
| 422 | -command [itcl::code $this flow toggle] |
---|
[1295] | 423 | } |
---|
[1349] | 424 | set fg [option get $itk_component(hull) font Font] |
---|
[1295] | 425 | Rappture::Tooltip::for $itk_component(play) \ |
---|
[1442] | 426 | "Play/Pause flow" |
---|
[1295] | 427 | |
---|
[1448] | 428 | # Loop |
---|
[1442] | 429 | itk_component add loop { |
---|
[1448] | 430 | Rappture::PushButton $itk_component(flowcontrols).loop \ |
---|
[1694] | 431 | -onimage [Rappture::icon flow-loop] \ |
---|
| 432 | -offimage [Rappture::icon flow-loop] \ |
---|
| 433 | -variable [itcl::scope _settings($this-loop)] |
---|
[1442] | 434 | } |
---|
| 435 | Rappture::Tooltip::for $itk_component(loop) \ |
---|
| 436 | "Play continuously" |
---|
| 437 | |
---|
[1449] | 438 | itk_component add dial { |
---|
[1471] | 439 | Rappture::Flowdial $itk_component(flowcontrols).dial \ |
---|
[1449] | 440 | -length 10 -valuewidth 0 -valuepadding 0 -padding 6 \ |
---|
| 441 | -linecolor "" -activelinecolor "" \ |
---|
[1694] | 442 | -min 0.0 -max 1.0 \ |
---|
| 443 | -variable [itcl::scope _settings($this-currenttime)] \ |
---|
[1449] | 444 | -knobimage [Rappture::icon knob2] -knobposition center@middle |
---|
[1442] | 445 | } { |
---|
| 446 | usual |
---|
[1471] | 447 | ignore -dialprogresscolor |
---|
[1442] | 448 | rename -background -controlbackground controlBackground Background |
---|
| 449 | } |
---|
[1471] | 450 | $itk_component(dial) current 0.0 |
---|
| 451 | bind $itk_component(dial) <<Value>> [itcl::code $this flow goto] |
---|
[1449] | 452 | # Duration |
---|
| 453 | itk_component add duration { |
---|
[1694] | 454 | entry $itk_component(flowcontrols).duration \ |
---|
| 455 | -textvariable [itcl::scope _settings($this-duration)] \ |
---|
| 456 | -bg white -width 6 -font "arial 9" |
---|
[1449] | 457 | } { |
---|
| 458 | usual |
---|
[1694] | 459 | ignore -highlightthickness -background |
---|
[1449] | 460 | } |
---|
| 461 | bind $itk_component(duration) <Return> [itcl::code $this flow duration] |
---|
[3454] | 462 | bind $itk_component(duration) <KP_Enter> [itcl::code $this flow duration] |
---|
[1511] | 463 | bind $itk_component(duration) <Tab> [itcl::code $this flow duration] |
---|
[1473] | 464 | Rappture::Tooltip::for $itk_component(duration) \ |
---|
| 465 | "Set duration of flow (format is min:sec)" |
---|
[1449] | 466 | |
---|
[1473] | 467 | |
---|
[1449] | 468 | itk_component add durationlabel { |
---|
[1694] | 469 | label $itk_component(flowcontrols).durationl \ |
---|
| 470 | -text "Duration:" -font $fg \ |
---|
| 471 | -highlightthickness 0 |
---|
[1442] | 472 | } { |
---|
| 473 | usual |
---|
[1694] | 474 | ignore -highlightthickness |
---|
[1442] | 475 | rename -background -controlbackground controlBackground Background |
---|
| 476 | } |
---|
| 477 | |
---|
[1349] | 478 | itk_component add speedlabel { |
---|
[1694] | 479 | label $itk_component(flowcontrols).speedl -text "Speed:" -font $fg \ |
---|
| 480 | -highlightthickness 0 |
---|
[1349] | 481 | } { |
---|
| 482 | usual |
---|
[1694] | 483 | ignore -highlightthickness |
---|
[1349] | 484 | rename -background -controlbackground controlBackground Background |
---|
| 485 | } |
---|
| 486 | |
---|
[1448] | 487 | # Speed |
---|
[1442] | 488 | itk_component add speed { |
---|
[1694] | 489 | Rappture::Flowspeed $itk_component(flowcontrols).speed \ |
---|
| 490 | -min 1 -max 10 -width 3 -font "arial 9" |
---|
[1442] | 491 | } { |
---|
[1448] | 492 | usual |
---|
[1694] | 493 | ignore -highlightthickness |
---|
[1442] | 494 | rename -background -controlbackground controlBackground Background |
---|
| 495 | } |
---|
[1473] | 496 | Rappture::Tooltip::for $itk_component(speed) \ |
---|
| 497 | "Change speed of flow" |
---|
| 498 | |
---|
[1448] | 499 | $itk_component(speed) value 1 |
---|
| 500 | bind $itk_component(speed) <<Value>> [itcl::code $this flow speed] |
---|
[1349] | 501 | |
---|
[1448] | 502 | |
---|
| 503 | blt::table $itk_component(flowcontrols) \ |
---|
[1694] | 504 | 0,0 $itk_component(rewind) -padx {3 0} \ |
---|
| 505 | 0,1 $itk_component(stop) -padx {2 0} \ |
---|
| 506 | 0,2 $itk_component(play) -padx {2 0} \ |
---|
| 507 | 0,3 $itk_component(loop) -padx {2 0} \ |
---|
| 508 | 0,4 $itk_component(dial) -fill x -padx {2 0 } \ |
---|
| 509 | 0,5 $itk_component(duration) -padx { 0 0} \ |
---|
| 510 | 0,7 $itk_component(speed) -padx {2 3} |
---|
[1448] | 511 | |
---|
[1694] | 512 | # 0,6 $itk_component(speedlabel) -padx {2 0} |
---|
[1448] | 513 | blt::table configure $itk_component(flowcontrols) c* -resize none |
---|
| 514 | blt::table configure $itk_component(flowcontrols) c4 -resize both |
---|
| 515 | blt::table configure $itk_component(flowcontrols) r0 -pady 1 |
---|
[1295] | 516 | # Bindings for rotation via mouse |
---|
| 517 | bind $itk_component(3dview) <ButtonPress-1> \ |
---|
[1349] | 518 | [itcl::code $this Rotate click %x %y] |
---|
[1295] | 519 | bind $itk_component(3dview) <B1-Motion> \ |
---|
[1349] | 520 | [itcl::code $this Rotate drag %x %y] |
---|
[1295] | 521 | bind $itk_component(3dview) <ButtonRelease-1> \ |
---|
[1349] | 522 | [itcl::code $this Rotate release %x %y] |
---|
[1448] | 523 | |
---|
[1295] | 524 | bind $itk_component(3dview) <Configure> \ |
---|
[1694] | 525 | [itcl::code $this EventuallyResize %w %h] |
---|
[1295] | 526 | |
---|
| 527 | # Bindings for panning via mouse |
---|
| 528 | bind $itk_component(3dview) <ButtonPress-2> \ |
---|
[1349] | 529 | [itcl::code $this Pan click %x %y] |
---|
[1295] | 530 | bind $itk_component(3dview) <B2-Motion> \ |
---|
[1349] | 531 | [itcl::code $this Pan drag %x %y] |
---|
[1295] | 532 | bind $itk_component(3dview) <ButtonRelease-2> \ |
---|
[1349] | 533 | [itcl::code $this Pan release %x %y] |
---|
[1295] | 534 | |
---|
| 535 | # Bindings for panning via keyboard |
---|
| 536 | bind $itk_component(3dview) <KeyPress-Left> \ |
---|
[1349] | 537 | [itcl::code $this Pan set -10 0] |
---|
[1295] | 538 | bind $itk_component(3dview) <KeyPress-Right> \ |
---|
[1349] | 539 | [itcl::code $this Pan set 10 0] |
---|
[1295] | 540 | bind $itk_component(3dview) <KeyPress-Up> \ |
---|
[1349] | 541 | [itcl::code $this Pan set 0 -10] |
---|
[1295] | 542 | bind $itk_component(3dview) <KeyPress-Down> \ |
---|
[1349] | 543 | [itcl::code $this Pan set 0 10] |
---|
[1295] | 544 | bind $itk_component(3dview) <Shift-KeyPress-Left> \ |
---|
[1349] | 545 | [itcl::code $this Pan set -2 0] |
---|
[1295] | 546 | bind $itk_component(3dview) <Shift-KeyPress-Right> \ |
---|
[1349] | 547 | [itcl::code $this Pan set 2 0] |
---|
[1295] | 548 | bind $itk_component(3dview) <Shift-KeyPress-Up> \ |
---|
[1349] | 549 | [itcl::code $this Pan set 0 -2] |
---|
[1295] | 550 | bind $itk_component(3dview) <Shift-KeyPress-Down> \ |
---|
[1349] | 551 | [itcl::code $this Pan set 0 2] |
---|
[1295] | 552 | |
---|
| 553 | # Bindings for zoom via keyboard |
---|
| 554 | bind $itk_component(3dview) <KeyPress-Prior> \ |
---|
[1349] | 555 | [itcl::code $this Zoom out] |
---|
[1295] | 556 | bind $itk_component(3dview) <KeyPress-Next> \ |
---|
[1349] | 557 | [itcl::code $this Zoom in] |
---|
[1295] | 558 | |
---|
| 559 | bind $itk_component(3dview) <Enter> "focus $itk_component(3dview)" |
---|
| 560 | |
---|
| 561 | if {[string equal "x11" [tk windowingsystem]]} { |
---|
[1349] | 562 | # Bindings for zoom via mouse |
---|
| 563 | bind $itk_component(3dview) <4> [itcl::code $this Zoom out] |
---|
| 564 | bind $itk_component(3dview) <5> [itcl::code $this Zoom in] |
---|
[1295] | 565 | } |
---|
| 566 | |
---|
| 567 | set _image(download) [image create photo] |
---|
| 568 | |
---|
| 569 | eval itk_initialize $args |
---|
| 570 | |
---|
| 571 | Connect |
---|
| 572 | } |
---|
| 573 | |
---|
| 574 | # ---------------------------------------------------------------------- |
---|
| 575 | # DESTRUCTOR |
---|
| 576 | # ---------------------------------------------------------------------- |
---|
| 577 | itcl::body Rappture::FlowvisViewer::destructor {} { |
---|
| 578 | $_dispatcher cancel !rebuild |
---|
[1349] | 579 | $_dispatcher cancel !send_transfunc |
---|
[1295] | 580 | image delete $_image(plot) |
---|
[1349] | 581 | image delete $_image(legend) |
---|
[1295] | 582 | image delete $_image(download) |
---|
[3362] | 583 | catch { blt::arcball destroy $_arcball } |
---|
[1442] | 584 | array unset _settings $this-* |
---|
[1295] | 585 | } |
---|
| 586 | |
---|
| 587 | # ---------------------------------------------------------------------- |
---|
| 588 | # USAGE: add <dataobj> ?<settings>? |
---|
| 589 | # |
---|
| 590 | # Clients use this to add a data object to the plot. The optional |
---|
| 591 | # <settings> are used to configure the plot. Allowed settings are |
---|
| 592 | # -color, -brightness, -width, -linestyle, and -raise. |
---|
| 593 | # ---------------------------------------------------------------------- |
---|
| 594 | itcl::body Rappture::FlowvisViewer::add {dataobj {settings ""}} { |
---|
| 595 | array set params { |
---|
[1349] | 596 | -color auto |
---|
| 597 | -width 1 |
---|
| 598 | -linestyle solid |
---|
| 599 | -brightness 0 |
---|
| 600 | -raise 0 |
---|
| 601 | -description "" |
---|
| 602 | -param "" |
---|
[1295] | 603 | } |
---|
[3799] | 604 | array set params $settings |
---|
[1295] | 605 | if {$params(-color) == "auto" || $params(-color) == "autoreset"} { |
---|
[1349] | 606 | # can't handle -autocolors yet |
---|
| 607 | set params(-color) black |
---|
[1295] | 608 | } |
---|
[1442] | 609 | foreach comp [$dataobj components] { |
---|
[1694] | 610 | set flowobj [$dataobj flowhints $comp] |
---|
| 611 | if { $flowobj == "" } { |
---|
| 612 | puts stderr "no flowhints $dataobj-$comp" |
---|
| 613 | continue |
---|
| 614 | } |
---|
| 615 | set _obj2flow($dataobj-$comp) $flowobj |
---|
[1442] | 616 | } |
---|
[3813] | 617 | set pos [lsearch -exact $_dlist $dataobj] |
---|
[1295] | 618 | if {$pos < 0} { |
---|
[1442] | 619 | lappend _dlist $dataobj |
---|
| 620 | set _allDataObjs($dataobj) 1 |
---|
| 621 | set _obj2ovride($dataobj-color) $params(-color) |
---|
| 622 | set _obj2ovride($dataobj-width) $params(-width) |
---|
| 623 | set _obj2ovride($dataobj-raise) $params(-raise) |
---|
[1349] | 624 | $_dispatcher event -idle !rebuild |
---|
[1295] | 625 | } |
---|
| 626 | } |
---|
| 627 | |
---|
| 628 | # ---------------------------------------------------------------------- |
---|
| 629 | # USAGE: get ?-objects? |
---|
| 630 | # USAGE: get ?-image 3dview|legend? |
---|
| 631 | # |
---|
| 632 | # Clients use this to query the list of objects being plotted, in |
---|
| 633 | # order from bottom to top of this result. The optional "-image" |
---|
| 634 | # flag can also request the internal images being shown. |
---|
| 635 | # ---------------------------------------------------------------------- |
---|
| 636 | itcl::body Rappture::FlowvisViewer::get {args} { |
---|
| 637 | if {[llength $args] == 0} { |
---|
[1349] | 638 | set args "-objects" |
---|
[1295] | 639 | } |
---|
| 640 | |
---|
| 641 | set op [lindex $args 0] |
---|
| 642 | switch -- $op { |
---|
| 643 | -objects { |
---|
[1349] | 644 | # put the dataobj list in order according to -raise options |
---|
[1442] | 645 | set dlist $_dlist |
---|
[1349] | 646 | foreach obj $dlist { |
---|
[1442] | 647 | if {[info exists _obj2ovride($obj-raise)] && $_obj2ovride($obj-raise)} { |
---|
[1349] | 648 | set i [lsearch -exact $dlist $obj] |
---|
| 649 | if {$i >= 0} { |
---|
| 650 | set dlist [lreplace $dlist $i $i] |
---|
| 651 | lappend dlist $obj |
---|
| 652 | } |
---|
| 653 | } |
---|
| 654 | } |
---|
| 655 | return $dlist |
---|
[1295] | 656 | } |
---|
| 657 | -image { |
---|
[1349] | 658 | if {[llength $args] != 2} { |
---|
| 659 | error "wrong # args: should be \"get -image 3dview|legend\"" |
---|
| 660 | } |
---|
| 661 | switch -- [lindex $args end] { |
---|
| 662 | 3dview { |
---|
| 663 | return $_image(plot) |
---|
| 664 | } |
---|
| 665 | legend { |
---|
| 666 | return $_image(legend) |
---|
| 667 | } |
---|
| 668 | default { |
---|
| 669 | error "bad image name \"[lindex $args end]\": should be 3dview or legend" |
---|
| 670 | } |
---|
| 671 | } |
---|
[1295] | 672 | } |
---|
| 673 | default { |
---|
[1349] | 674 | error "bad option \"$op\": should be -objects or -image" |
---|
[1295] | 675 | } |
---|
| 676 | } |
---|
| 677 | } |
---|
| 678 | |
---|
| 679 | # ---------------------------------------------------------------------- |
---|
| 680 | # USAGE: delete ?<dataobj1> <dataobj2> ...? |
---|
| 681 | # |
---|
[1349] | 682 | # Clients use this to delete a dataobj from the plot. If no dataobjs |
---|
| 683 | # are specified, then all dataobjs are deleted. No data objects are |
---|
| 684 | # deleted. They are only removed from the display list. |
---|
| 685 | # |
---|
[1295] | 686 | # ---------------------------------------------------------------------- |
---|
| 687 | itcl::body Rappture::FlowvisViewer::delete {args} { |
---|
[3940] | 688 | flow stop |
---|
[1295] | 689 | if {[llength $args] == 0} { |
---|
[1442] | 690 | set args $_dlist |
---|
[1295] | 691 | } |
---|
[1442] | 692 | |
---|
[1349] | 693 | # Delete all specified dataobjs |
---|
[1295] | 694 | set changed 0 |
---|
| 695 | foreach dataobj $args { |
---|
[1442] | 696 | set pos [lsearch -exact $_dlist $dataobj] |
---|
[1349] | 697 | if { $pos >= 0 } { |
---|
[1694] | 698 | foreach comp [$dataobj components] { |
---|
| 699 | array unset _limits $dataobj-$comp-* |
---|
| 700 | } |
---|
| 701 | set _dlist [lreplace $_dlist $pos $pos] |
---|
| 702 | array unset _obj2ovride $dataobj-* |
---|
| 703 | array unset _obj2flow $dataobj-* |
---|
| 704 | array unset _serverObjs $dataobj-* |
---|
| 705 | array unset _obj2style $dataobj-* |
---|
[1349] | 706 | set changed 1 |
---|
| 707 | } |
---|
[1295] | 708 | } |
---|
[1349] | 709 | # If anything changed, then rebuild the plot |
---|
[1295] | 710 | if {$changed} { |
---|
[1694] | 711 | # Repair the reverse lookup |
---|
| 712 | foreach tf [array names _style2objs] { |
---|
| 713 | set list {} |
---|
| 714 | foreach {dataobj comp} $_style2objs($tf) break |
---|
| 715 | if { [info exists _serverObjs($dataobj-$comp)] } { |
---|
| 716 | lappend list $dataobj $comp |
---|
| 717 | } |
---|
| 718 | if { $list == "" } { |
---|
| 719 | array unset _style2objs $tf |
---|
| 720 | } else { |
---|
| 721 | set _style2objs($tf) $list |
---|
| 722 | } |
---|
| 723 | } |
---|
[1349] | 724 | $_dispatcher event -idle !rebuild |
---|
[1295] | 725 | } |
---|
| 726 | } |
---|
| 727 | |
---|
| 728 | # ---------------------------------------------------------------------- |
---|
| 729 | # USAGE: scale ?<data1> <data2> ...? |
---|
| 730 | # |
---|
| 731 | # Sets the default limits for the overall plot according to the |
---|
| 732 | # limits of the data for all of the given <data> objects. This |
---|
| 733 | # accounts for all objects--even those not showing on the screen. |
---|
| 734 | # Because of this, the limits are appropriate for all objects as |
---|
| 735 | # the user scans through data in the ResultSet viewer. |
---|
| 736 | # ---------------------------------------------------------------------- |
---|
| 737 | itcl::body Rappture::FlowvisViewer::scale {args} { |
---|
[3940] | 738 | array set style { |
---|
| 739 | -color BCGYR |
---|
| 740 | -levels 6 |
---|
| 741 | -opacity 1.0 |
---|
| 742 | -markers "" |
---|
[1295] | 743 | } |
---|
[3940] | 744 | array unset _limits |
---|
| 745 | array unset _volcomponents |
---|
| 746 | foreach dataobj $args { |
---|
| 747 | if { ![$dataobj isvalid] } { |
---|
| 748 | continue; # Object doesn't contain valid data. |
---|
| 749 | } |
---|
| 750 | foreach cname [$dataobj components] { |
---|
| 751 | if { ![info exists _volcomponents($cname)] } { |
---|
| 752 | lappend _componentsList $cname |
---|
| 753 | array set style [lindex [$dataobj components -style $cname] 0] |
---|
| 754 | set cmap [ColorsToColormap $style(-color)] |
---|
| 755 | set _cname2defaultcolormap($cname) $cmap |
---|
| 756 | set _settings($cname-colormap) $style(-color) |
---|
| 757 | } |
---|
| 758 | lappend _volcomponents($cname) $dataobj-$cname |
---|
| 759 | array unset limits |
---|
| 760 | array set limits [$dataobj valueLimits $cname] |
---|
| 761 | set _limits($cname) $limits(v) |
---|
| 762 | } |
---|
| 763 | foreach axis {x y z v} { |
---|
| 764 | foreach { min max } [$dataobj limits $axis] break |
---|
[1349] | 765 | if {"" != $min && "" != $max} { |
---|
[3940] | 766 | if { ![info exists _limits($axis)] } { |
---|
| 767 | set _limits($axis) [list $min $max] |
---|
[1349] | 768 | } else { |
---|
[3940] | 769 | foreach {amin amax} $_limits($axis) break |
---|
| 770 | if {$min < $amin} { |
---|
| 771 | set amin $min |
---|
[1349] | 772 | } |
---|
[3940] | 773 | if {$max > $amax} { |
---|
| 774 | set amax $max |
---|
[1349] | 775 | } |
---|
[3940] | 776 | set _limits($axis) [list $amin $amax] |
---|
[1349] | 777 | } |
---|
| 778 | } |
---|
| 779 | } |
---|
[1295] | 780 | } |
---|
[3940] | 781 | #BuildVolumeComponents |
---|
[1295] | 782 | } |
---|
| 783 | |
---|
| 784 | # ---------------------------------------------------------------------- |
---|
| 785 | # USAGE: download coming |
---|
| 786 | # USAGE: download controls <downloadCommand> |
---|
| 787 | # USAGE: download now |
---|
| 788 | # |
---|
| 789 | # Clients use this method to create a downloadable representation |
---|
| 790 | # of the plot. Returns a list of the form {ext string}, where |
---|
| 791 | # "ext" is the file extension (indicating the type of data) and |
---|
| 792 | # "string" is the data itself. |
---|
| 793 | # ---------------------------------------------------------------------- |
---|
| 794 | itcl::body Rappture::FlowvisViewer::download {option args} { |
---|
[1506] | 795 | set popup .flowvisviewerdownload |
---|
[1295] | 796 | switch $option { |
---|
[1349] | 797 | coming { |
---|
[1442] | 798 | if {[catch { |
---|
[1694] | 799 | blt::winop snap $itk_component(plotarea) $_image(download) |
---|
| 800 | }]} { |
---|
[1349] | 801 | $_image(download) configure -width 1 -height 1 |
---|
| 802 | $_image(download) put #000000 |
---|
| 803 | } |
---|
| 804 | } |
---|
| 805 | controls { |
---|
[1694] | 806 | if {![winfo exists $popup]} { |
---|
| 807 | # if we haven't created the popup yet, do it now |
---|
| 808 | Rappture::Balloon $popup \ |
---|
| 809 | -title "[Rappture::filexfer::label downloadWord] as..." |
---|
| 810 | set inner [$popup component inner] |
---|
| 811 | label $inner.summary -text "" -anchor w |
---|
| 812 | pack $inner.summary -side top |
---|
| 813 | set img $_image(plot) |
---|
| 814 | set res "[image width $img]x[image height $img]" |
---|
| 815 | radiobutton $inner.draft -text "Image (draft $res)" \ |
---|
| 816 | -variable Rappture::FlowvisViewer::_downloadPopup(format) \ |
---|
| 817 | -value draft |
---|
| 818 | pack $inner.draft -anchor w |
---|
[1355] | 819 | |
---|
[1694] | 820 | set res "640x480" |
---|
| 821 | radiobutton $inner.medium -text "Movie (standard $res)" \ |
---|
| 822 | -variable Rappture::FlowvisViewer::_downloadPopup(format) \ |
---|
| 823 | -value $res |
---|
| 824 | pack $inner.medium -anchor w |
---|
[1355] | 825 | |
---|
[1694] | 826 | set res "1024x768" |
---|
| 827 | radiobutton $inner.high -text "Movie (high quality $res)" \ |
---|
| 828 | -variable Rappture::FlowvisViewer::_downloadPopup(format) \ |
---|
| 829 | -value $res |
---|
| 830 | pack $inner.high -anchor w |
---|
| 831 | button $inner.go -text [Rappture::filexfer::label download] \ |
---|
| 832 | -command [lindex $args 0] |
---|
| 833 | pack $inner.go -pady 4 |
---|
| 834 | $inner.draft select |
---|
| 835 | } else { |
---|
| 836 | set inner [$popup component inner] |
---|
| 837 | } |
---|
| 838 | set num [llength [get]] |
---|
| 839 | set num [expr {($num == 1) ? "1 result" : "$num results"}] |
---|
| 840 | set word [Rappture::filexfer::label downloadWord] |
---|
| 841 | $inner.summary configure -text "$word $num in the following format:" |
---|
| 842 | update idletasks ;# fix initial sizes |
---|
[3555] | 843 | update |
---|
[1694] | 844 | return $popup |
---|
| 845 | } |
---|
[1349] | 846 | now { |
---|
[1694] | 847 | if { [winfo exists $popup] } { |
---|
| 848 | $popup deactivate |
---|
| 849 | } |
---|
| 850 | switch -- $_downloadPopup(format) { |
---|
| 851 | draft { |
---|
| 852 | # Get the image data (as base64) and decode it back to |
---|
| 853 | # binary. This is better than writing to temporary |
---|
| 854 | # files. When we switch to the BLT picture image it |
---|
| 855 | # won't be necessary to decode the image data. |
---|
| 856 | set bytes [$_image(plot) data -format "jpeg -quality 100"] |
---|
| 857 | set bytes [Rappture::encoding::decode -as b64 $bytes] |
---|
| 858 | return [list .jpg $bytes] |
---|
| 859 | } |
---|
| 860 | "640x480" { |
---|
| 861 | return [$this GetMovie [lindex $args 0] 640 480] |
---|
| 862 | } |
---|
| 863 | "1024x768" { |
---|
| 864 | return [$this GetMovie [lindex $args 0] 1024 768] |
---|
| 865 | } |
---|
| 866 | default { |
---|
| 867 | error "bad download format $_downloadPopup(format)" |
---|
| 868 | } |
---|
| 869 | } |
---|
| 870 | } |
---|
[1349] | 871 | default { |
---|
| 872 | error "bad option \"$option\": should be coming, controls, now" |
---|
| 873 | } |
---|
[1295] | 874 | } |
---|
| 875 | } |
---|
| 876 | |
---|
| 877 | # ---------------------------------------------------------------------- |
---|
| 878 | # USAGE: Connect ?<host:port>,<host:port>...? |
---|
| 879 | # |
---|
| 880 | # Clients use this method to establish a connection to a new |
---|
| 881 | # server, or to reestablish a connection to the previous server. |
---|
| 882 | # Any existing connection is automatically closed. |
---|
| 883 | # ---------------------------------------------------------------------- |
---|
| 884 | itcl::body Rappture::FlowvisViewer::Connect {} { |
---|
| 885 | set _hosts [GetServerList "nanovis"] |
---|
| 886 | if { "" == $_hosts } { |
---|
[1349] | 887 | return 0 |
---|
[1295] | 888 | } |
---|
[3396] | 889 | set _reset 1 |
---|
[1295] | 890 | set result [VisViewer::Connect $_hosts] |
---|
[1349] | 891 | if { $result } { |
---|
[3592] | 892 | if { $_reportClientInfo } { |
---|
| 893 | # Tell the server the viewer, hub, user and session. |
---|
[4075] | 894 | # Do this immediately on connect before buffering any commands |
---|
[3592] | 895 | global env |
---|
| 896 | |
---|
| 897 | set info {} |
---|
| 898 | set user "???" |
---|
| 899 | if { [info exists env(USER)] } { |
---|
| 900 | set user $env(USER) |
---|
| 901 | } |
---|
| 902 | set session "???" |
---|
| 903 | if { [info exists env(SESSION)] } { |
---|
| 904 | set session $env(SESSION) |
---|
| 905 | } |
---|
| 906 | lappend info "hub" [exec hostname] |
---|
| 907 | lappend info "client" "flowvisviewer" |
---|
| 908 | lappend info "user" $user |
---|
| 909 | lappend info "session" $session |
---|
| 910 | SendCmd "clientinfo [list $info]" |
---|
| 911 | } |
---|
| 912 | |
---|
[1349] | 913 | set w [winfo width $itk_component(3dview)] |
---|
| 914 | set h [winfo height $itk_component(3dview)] |
---|
[1442] | 915 | EventuallyResize $w $h |
---|
[1349] | 916 | } |
---|
[1295] | 917 | return $result |
---|
| 918 | } |
---|
| 919 | |
---|
| 920 | # |
---|
| 921 | # isconnected -- |
---|
| 922 | # |
---|
| 923 | # Indicates if we are currently connected to the visualization server. |
---|
| 924 | # |
---|
| 925 | itcl::body Rappture::FlowvisViewer::isconnected {} { |
---|
| 926 | return [VisViewer::IsConnected] |
---|
| 927 | } |
---|
| 928 | |
---|
| 929 | # |
---|
[1491] | 930 | # disconnect -- |
---|
| 931 | # |
---|
| 932 | itcl::body Rappture::FlowvisViewer::disconnect {} { |
---|
| 933 | Disconnect |
---|
| 934 | } |
---|
| 935 | |
---|
| 936 | # |
---|
[1349] | 937 | # Disconnect -- |
---|
| 938 | # |
---|
| 939 | # Clients use this method to disconnect from the current rendering |
---|
| 940 | # server. |
---|
| 941 | # |
---|
[1295] | 942 | itcl::body Rappture::FlowvisViewer::Disconnect {} { |
---|
| 943 | VisViewer::Disconnect |
---|
| 944 | |
---|
[1349] | 945 | # disconnected -- no more data sitting on server |
---|
[1479] | 946 | array unset _serverObjs |
---|
[1295] | 947 | } |
---|
| 948 | |
---|
| 949 | # ---------------------------------------------------------------------- |
---|
[1377] | 950 | # USAGE: SendTransferFuncs |
---|
[1349] | 951 | # ---------------------------------------------------------------------- |
---|
[1377] | 952 | itcl::body Rappture::FlowvisViewer::SendTransferFuncs {} { |
---|
[1442] | 953 | if { $_activeTf == "" } { |
---|
[1694] | 954 | puts stderr "no active tf" |
---|
| 955 | return |
---|
[1349] | 956 | } |
---|
[1442] | 957 | set tf $_activeTf |
---|
| 958 | if { $_first == "" } { |
---|
[1694] | 959 | puts stderr "no first" |
---|
| 960 | return |
---|
[1442] | 961 | } |
---|
[1349] | 962 | |
---|
[3362] | 963 | # Ensure that the global opacity and thickness settings (in the slider |
---|
[1349] | 964 | # settings widgets) are used for the active transfer-function. Update the |
---|
[1442] | 965 | # values in the _settings varible. |
---|
| 966 | set value $_settings($this-opacity) |
---|
[1349] | 967 | set opacity [expr { double($value) * 0.01 }] |
---|
[1442] | 968 | set _settings($this-$tf-opacity) $opacity |
---|
| 969 | set value $_settings($this-thickness) |
---|
[1349] | 970 | # Scale values between 0.00001 and 0.01000 |
---|
| 971 | set thickness [expr {double($value) * 0.0001}] |
---|
[1442] | 972 | set _settings($this-$tf-thickness) $thickness |
---|
[1349] | 973 | |
---|
[1442] | 974 | foreach key [array names _obj2style $_first-*] { |
---|
[1694] | 975 | if { [info exists _obj2style($key)] } { |
---|
| 976 | foreach tf $_obj2style($key) { |
---|
| 977 | ComputeTransferFunc $tf |
---|
| 978 | } |
---|
| 979 | } |
---|
[1349] | 980 | } |
---|
[1479] | 981 | EventuallyResizeLegend |
---|
[1349] | 982 | } |
---|
| 983 | |
---|
| 984 | # ---------------------------------------------------------------------- |
---|
[1442] | 985 | # USAGE: ReceiveImage -bytes $size -type $type -token $token |
---|
[1295] | 986 | # |
---|
| 987 | # Invoked automatically whenever the "image" command comes in from |
---|
| 988 | # the rendering server. Indicates that binary image data with the |
---|
| 989 | # specified <size> will follow. |
---|
| 990 | # ---------------------------------------------------------------------- |
---|
[1349] | 991 | itcl::body Rappture::FlowvisViewer::ReceiveImage { args } { |
---|
| 992 | array set info { |
---|
[1694] | 993 | -token "???" |
---|
| 994 | -bytes 0 |
---|
| 995 | -type image |
---|
[1349] | 996 | } |
---|
| 997 | array set info $args |
---|
| 998 | set bytes [ReceiveBytes $info(-bytes)] |
---|
| 999 | ReceiveEcho <<line "<read $info(-bytes) bytes" |
---|
[1506] | 1000 | switch -- $info(-type) { |
---|
[1694] | 1001 | "image" { |
---|
| 1002 | $_image(plot) configure -data $bytes |
---|
| 1003 | #puts stderr "image received [image width $_image(plot)] by [image height $_image(plot)]" |
---|
| 1004 | } |
---|
| 1005 | "print" { |
---|
| 1006 | set tag $this-$info(-token) |
---|
| 1007 | set _hardcopy($tag) $bytes |
---|
| 1008 | } |
---|
| 1009 | "movie" { |
---|
| 1010 | set tag $this-$info(-token) |
---|
| 1011 | set _hardcopy($tag) $bytes |
---|
| 1012 | } |
---|
| 1013 | default { |
---|
| 1014 | puts stderr "unknown download type $info(-type)" |
---|
| 1015 | } |
---|
[1295] | 1016 | } |
---|
| 1017 | } |
---|
| 1018 | |
---|
| 1019 | # |
---|
[1349] | 1020 | # ReceiveLegend -- |
---|
| 1021 | # |
---|
| 1022 | # The procedure is the response from the render server to each "legend" |
---|
| 1023 | # command. The server sends back a "legend" command invoked our |
---|
| 1024 | # the slave interpreter. The purpose is to collect data of the image |
---|
| 1025 | # representing the legend in the canvas. In addition, the isomarkers |
---|
| 1026 | # of the active transfer function are displayed. |
---|
| 1027 | # |
---|
| 1028 | # I don't know is this is the right place to display the isomarkers. |
---|
| 1029 | # I don't know all the different paths used to draw the plot. There's |
---|
| 1030 | # "Rebuild", "add", etc. |
---|
| 1031 | # |
---|
[1479] | 1032 | itcl::body Rappture::FlowvisViewer::ReceiveLegend { tag vmin vmax size } { |
---|
[1349] | 1033 | if { ![isconnected] } { |
---|
| 1034 | return |
---|
| 1035 | } |
---|
[1491] | 1036 | #puts stderr "receive legend $tag $vmin $vmax $size" |
---|
[1349] | 1037 | set bytes [ReceiveBytes $size] |
---|
| 1038 | $_image(legend) configure -data $bytes |
---|
| 1039 | ReceiveEcho <<line "<read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" |
---|
[1295] | 1040 | |
---|
[1349] | 1041 | set c $itk_component(legend) |
---|
| 1042 | set w [winfo width $c] |
---|
| 1043 | set h [winfo height $c] |
---|
| 1044 | set lx 10 |
---|
| 1045 | set ly [expr {$h - 1}] |
---|
[4165] | 1046 | if {"" == [$c find withtag colorbar]} { |
---|
[1349] | 1047 | $c create image 10 10 -anchor nw \ |
---|
[4165] | 1048 | -image $_image(legend) -tags colorbar |
---|
[1349] | 1049 | $c create text $lx $ly -anchor sw \ |
---|
| 1050 | -fill $itk_option(-plotforeground) -tags "limits vmin" |
---|
| 1051 | $c create text [expr {$w-$lx}] $ly -anchor se \ |
---|
| 1052 | -fill $itk_option(-plotforeground) -tags "limits vmax" |
---|
[4165] | 1053 | $c lower colorbar |
---|
| 1054 | $c bind colorbar <ButtonRelease-1> [itcl::code $this AddIsoMarker %x %y] |
---|
[1349] | 1055 | } |
---|
| 1056 | # Display the markers used by the active transfer function. |
---|
[1479] | 1057 | set tf $_obj2style($tag) |
---|
[3940] | 1058 | foreach {vmin vmax} [limits $tf] break |
---|
| 1059 | $c itemconfigure vmin -text [format %.2g $vmin] |
---|
[1349] | 1060 | $c coords vmin $lx $ly |
---|
| 1061 | |
---|
[3940] | 1062 | $c itemconfigure vmax -text [format %.2g $vmax] |
---|
[1349] | 1063 | $c coords vmax [expr {$w-$lx}] $ly |
---|
| 1064 | |
---|
[1442] | 1065 | if { [info exists _isomarkers($tf)] } { |
---|
| 1066 | foreach m $_isomarkers($tf) { |
---|
| 1067 | $m visible yes |
---|
[1349] | 1068 | } |
---|
[1295] | 1069 | } |
---|
| 1070 | } |
---|
| 1071 | |
---|
| 1072 | # |
---|
[1349] | 1073 | # ReceiveData -- |
---|
| 1074 | # |
---|
[2744] | 1075 | # The procedure is the response from the render server to each "data |
---|
| 1076 | # follows" command. The server sends back a "data" command invoked our |
---|
| 1077 | # the slave interpreter. The purpose is to collect the min/max of the |
---|
| 1078 | # volume sent to the render server. Since the client (flowvisviewer) |
---|
| 1079 | # doesn't parse 3D data formats, we rely on the server (flowvis) to |
---|
| 1080 | # tell us what the limits are. Once we've received the limits to all |
---|
| 1081 | # the data we've sent (tracked by _recvObjs) we can then determine |
---|
| 1082 | # what the transfer functions are for these # volumes. |
---|
[1349] | 1083 | # |
---|
| 1084 | # Note: There is a considerable tradeoff in having the server report |
---|
| 1085 | # back what the data limits are. It means that much of the code |
---|
| 1086 | # having to do with transfer-functions has to wait for the data |
---|
| 1087 | # to come back, since the isomarkers are calculated based upon |
---|
| 1088 | # the data limits. The client code is much messier because of |
---|
| 1089 | # this. The alternative is to parse any of the 3D formats on the |
---|
| 1090 | # client side. |
---|
| 1091 | # |
---|
| 1092 | itcl::body Rappture::FlowvisViewer::ReceiveData { args } { |
---|
| 1093 | if { ![isconnected] } { |
---|
| 1094 | return |
---|
| 1095 | } |
---|
| 1096 | # Arguments from server are name value pairs. Stuff them in an array. |
---|
[1479] | 1097 | array set values $args |
---|
| 1098 | set tag $values(tag) |
---|
[1442] | 1099 | set parts [split $tag -] |
---|
| 1100 | set dataobj [lindex $parts 0] |
---|
[1479] | 1101 | set _serverObjs($tag) 0 |
---|
[3940] | 1102 | set _limits($tag) [list $values(min) $values(max)] |
---|
[1448] | 1103 | unset _recvObjs($tag) |
---|
| 1104 | if { [array size _recvObjs] == 0 } { |
---|
[4166] | 1105 | updateTransferFunctions |
---|
[1349] | 1106 | } |
---|
| 1107 | } |
---|
| 1108 | |
---|
| 1109 | # |
---|
| 1110 | # Rebuild -- |
---|
| 1111 | # |
---|
| 1112 | # Called automatically whenever something changes that affects the data |
---|
| 1113 | # in the widget. Clears any existing data and rebuilds the widget to |
---|
| 1114 | # display new data. |
---|
| 1115 | # |
---|
| 1116 | itcl::body Rappture::FlowvisViewer::Rebuild {} { |
---|
[3498] | 1117 | set w [winfo width $itk_component(3dview)] |
---|
| 1118 | set h [winfo height $itk_component(3dview)] |
---|
| 1119 | if { $w < 2 || $h < 2 } { |
---|
| 1120 | $_dispatcher event -idle !rebuild |
---|
| 1121 | return |
---|
| 1122 | } |
---|
[1543] | 1123 | |
---|
[3498] | 1124 | # Turn on buffering of commands to the server. We don't want to |
---|
| 1125 | # be preempted by a server disconnect/reconnect (which automatically |
---|
| 1126 | # generates a new call to Rebuild). |
---|
| 1127 | StartBufferingCommands |
---|
| 1128 | |
---|
[1349] | 1129 | # Hide all the isomarkers. Can't remove them. Have to remember the |
---|
| 1130 | # settings since the user may have created/deleted/moved markers. |
---|
| 1131 | |
---|
[1442] | 1132 | foreach tf [array names _isomarkers] { |
---|
| 1133 | foreach m $_isomarkers($tf) { |
---|
| 1134 | $m visible no |
---|
[1349] | 1135 | } |
---|
| 1136 | } |
---|
| 1137 | |
---|
[3498] | 1138 | if { $_width != $w || $_height != $h || $_reset } { |
---|
| 1139 | set _width $w |
---|
| 1140 | set _height $h |
---|
| 1141 | $_arcball resize $w $h |
---|
| 1142 | Resize |
---|
| 1143 | } |
---|
| 1144 | |
---|
[1509] | 1145 | set _first "" |
---|
[1295] | 1146 | foreach dataobj [get] { |
---|
[1479] | 1147 | foreach comp [$dataobj components] { |
---|
[3394] | 1148 | set tag $dataobj-$comp |
---|
[3947] | 1149 | set isvtk 0 |
---|
| 1150 | # FIXME: Would like to use the type method of the dataobj |
---|
| 1151 | # but the returned value isn't well defined now |
---|
| 1152 | if {[catch { |
---|
| 1153 | # Send the data as one huge base64-encoded mess -- yuck! |
---|
| 1154 | set data [$dataobj blob $comp] |
---|
| 1155 | }]} { |
---|
| 1156 | set data [$dataobj vtkdata $comp] |
---|
| 1157 | set isvtk 1 |
---|
| 1158 | } |
---|
[1694] | 1159 | set nbytes [string length $data] |
---|
[3421] | 1160 | if { $_reportClientInfo } { |
---|
[3392] | 1161 | set info {} |
---|
| 1162 | lappend info "tool_id" [$dataobj hints toolId] |
---|
| 1163 | lappend info "tool_name" [$dataobj hints toolName] |
---|
| 1164 | lappend info "tool_version" [$dataobj hints toolRevision] |
---|
| 1165 | lappend info "tool_title" [$dataobj hints toolTitle] |
---|
| 1166 | lappend info "dataset_label" [$dataobj hints label] |
---|
| 1167 | lappend info "dataset_size" $nbytes |
---|
[3394] | 1168 | lappend info "dataset_tag" $tag |
---|
[3392] | 1169 | SendCmd "clientinfo [list $info]" |
---|
| 1170 | } |
---|
[1694] | 1171 | set extents [$dataobj extents $comp] |
---|
| 1172 | # I have a field. Is a vector field or a volume field? |
---|
[3947] | 1173 | if { !$isvtk && $extents == 1 } { |
---|
[3394] | 1174 | set cmd "volume data follows $nbytes $tag\n" |
---|
[1694] | 1175 | } else { |
---|
| 1176 | set cmd [FlowCmd $dataobj $comp $nbytes $extents] |
---|
| 1177 | if { $cmd == "" } { |
---|
| 1178 | puts stderr "no command" |
---|
| 1179 | continue |
---|
| 1180 | } |
---|
| 1181 | } |
---|
| 1182 | append _outbuf $cmd |
---|
[1479] | 1183 | append _outbuf $data |
---|
| 1184 | NameTransferFunc $dataobj $comp |
---|
[3394] | 1185 | set _recvObjs($tag) 1 |
---|
[1349] | 1186 | } |
---|
[1295] | 1187 | } |
---|
| 1188 | |
---|
[1509] | 1189 | set _first [lindex [get] 0] |
---|
| 1190 | |
---|
[3899] | 1191 | foreach axis {x y z} { |
---|
| 1192 | # Turn off cutplanes for all volumes |
---|
| 1193 | SendCmd "cutplane state 0 $axis" |
---|
| 1194 | } |
---|
| 1195 | |
---|
[1295] | 1196 | # Reset the camera and other view parameters |
---|
[3915] | 1197 | InitSettings light2side ambient diffuse specularLevel specularExponent \ |
---|
| 1198 | transp isosurface grid axes volume outline \ |
---|
[3899] | 1199 | cutplaneVisible xcutplane ycutplane zcutplane |
---|
[3915] | 1200 | |
---|
[1496] | 1201 | # nothing to send -- activate the proper volume |
---|
[1448] | 1202 | if {"" != $_first} { |
---|
| 1203 | set axis [$_first hints updir] |
---|
| 1204 | if {"" != $axis} { |
---|
| 1205 | SendCmd "up $axis" |
---|
| 1206 | } |
---|
[1694] | 1207 | set location [$_first hints camera] |
---|
| 1208 | if { $location != "" } { |
---|
| 1209 | array set _view $location |
---|
| 1210 | } |
---|
[3362] | 1211 | |
---|
[1448] | 1212 | } |
---|
[3362] | 1213 | set _settings($this-qw) $_view(qw) |
---|
| 1214 | set _settings($this-qx) $_view(qx) |
---|
| 1215 | set _settings($this-qy) $_view(qy) |
---|
| 1216 | set _settings($this-qz) $_view(qz) |
---|
[3533] | 1217 | set _settings($this-xpan) $_view(xpan) |
---|
| 1218 | set _settings($this-ypan) $_view(ypan) |
---|
[1442] | 1219 | set _settings($this-zoom) $_view(zoom) |
---|
[1349] | 1220 | |
---|
[3485] | 1221 | set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] |
---|
| 1222 | $_arcball quaternion $q |
---|
| 1223 | SendCmd "camera orient $q" |
---|
[3492] | 1224 | SendCmd "camera reset" |
---|
[1448] | 1225 | PanCamera |
---|
| 1226 | SendCmd "camera zoom $_view(zoom)" |
---|
[1349] | 1227 | |
---|
[1479] | 1228 | foreach dataobj [get] { |
---|
| 1229 | foreach comp [$dataobj components] { |
---|
[1694] | 1230 | NameTransferFunc $dataobj $comp |
---|
[1479] | 1231 | } |
---|
| 1232 | } |
---|
| 1233 | |
---|
[1349] | 1234 | # nothing to send -- activate the proper ivol |
---|
[1442] | 1235 | set _first [lindex [get] 0] |
---|
| 1236 | if {"" != $_first} { |
---|
| 1237 | set axis [$_first hints updir] |
---|
[1349] | 1238 | if {"" != $axis} { |
---|
| 1239 | SendCmd "up $axis" |
---|
| 1240 | } |
---|
[1694] | 1241 | set location [$_first hints camera] |
---|
| 1242 | if { $location != "" } { |
---|
| 1243 | array set _view $location |
---|
| 1244 | } |
---|
[1442] | 1245 | set comp [lindex [$_first components] 0] |
---|
[1479] | 1246 | set _activeTf [lindex $_obj2style($_first-$comp) 0] |
---|
[1442] | 1247 | } |
---|
[1349] | 1248 | |
---|
[1479] | 1249 | |
---|
[1349] | 1250 | # sync the state of slicers |
---|
| 1251 | set vols [CurrentVolumeIds -cutplanes] |
---|
| 1252 | foreach axis {x y z} { |
---|
[1694] | 1253 | set pos [expr {0.01*$_settings($this-${axis}cutposition)}] |
---|
| 1254 | SendCmd "cutplane position $pos $axis $vols" |
---|
[1349] | 1255 | } |
---|
[1442] | 1256 | SendCmd "volume data state $_settings($this-volume)" |
---|
[1479] | 1257 | EventuallyResizeLegend |
---|
[1442] | 1258 | |
---|
| 1259 | # Actually write the commands to the server socket. If it fails, we don't |
---|
| 1260 | # care. We're finished here. |
---|
[1543] | 1261 | blt::busy hold $itk_component(hull) |
---|
[3421] | 1262 | StopBufferingCommands |
---|
[1479] | 1263 | blt::busy release $itk_component(hull) |
---|
[3396] | 1264 | set _reset 0 |
---|
[1295] | 1265 | } |
---|
| 1266 | |
---|
| 1267 | # ---------------------------------------------------------------------- |
---|
[1349] | 1268 | # USAGE: CurrentVolumeIds ?-cutplanes? |
---|
[1295] | 1269 | # |
---|
| 1270 | # Returns a list of volume server IDs for the current volume being |
---|
| 1271 | # displayed. This is normally a single ID, but it might be a list |
---|
| 1272 | # of IDs if the current data object has multiple components. |
---|
| 1273 | # ---------------------------------------------------------------------- |
---|
[1349] | 1274 | itcl::body Rappture::FlowvisViewer::CurrentVolumeIds {{what -all}} { |
---|
[1479] | 1275 | return "" |
---|
[1442] | 1276 | if { $_first == "" } { |
---|
[1694] | 1277 | return |
---|
[1442] | 1278 | } |
---|
[1479] | 1279 | foreach key [array names _serverObjs *-*] { |
---|
[1442] | 1280 | if {[string match $_first-* $key]} { |
---|
[1349] | 1281 | array set style { |
---|
| 1282 | -cutplanes 1 |
---|
| 1283 | } |
---|
| 1284 | foreach {dataobj comp} [split $key -] break |
---|
| 1285 | array set style [lindex [$dataobj components -style $comp] 0] |
---|
| 1286 | if {$what != "-cutplanes" || $style(-cutplanes)} { |
---|
[1479] | 1287 | lappend rlist $_serverObjs($key) |
---|
[1349] | 1288 | } |
---|
| 1289 | } |
---|
[1295] | 1290 | } |
---|
| 1291 | return $rlist |
---|
| 1292 | } |
---|
| 1293 | |
---|
| 1294 | # ---------------------------------------------------------------------- |
---|
[1349] | 1295 | # USAGE: Zoom in |
---|
| 1296 | # USAGE: Zoom out |
---|
| 1297 | # USAGE: Zoom reset |
---|
[1295] | 1298 | # |
---|
| 1299 | # Called automatically when the user clicks on one of the zoom |
---|
| 1300 | # controls for this widget. Changes the zoom for the current view. |
---|
| 1301 | # ---------------------------------------------------------------------- |
---|
[1349] | 1302 | itcl::body Rappture::FlowvisViewer::Zoom {option} { |
---|
[1295] | 1303 | switch -- $option { |
---|
[1694] | 1304 | "in" { |
---|
| 1305 | set _view(zoom) [expr {$_view(zoom)*1.25}] |
---|
| 1306 | set _settings($this-zoom) $_view(zoom) |
---|
[3485] | 1307 | SendCmd "camera zoom $_view(zoom)" |
---|
[1694] | 1308 | } |
---|
| 1309 | "out" { |
---|
| 1310 | set _view(zoom) [expr {$_view(zoom)*0.8}] |
---|
| 1311 | set _settings($this-zoom) $_view(zoom) |
---|
[3485] | 1312 | SendCmd "camera zoom $_view(zoom)" |
---|
[1694] | 1313 | } |
---|
[1349] | 1314 | "reset" { |
---|
[1694] | 1315 | array set _view { |
---|
[3362] | 1316 | qw 0.853553 |
---|
| 1317 | qx -0.353553 |
---|
| 1318 | qy 0.353553 |
---|
| 1319 | qz 0.146447 |
---|
[2744] | 1320 | zoom 1.0 |
---|
[3533] | 1321 | xpan 0 |
---|
| 1322 | ypan 0 |
---|
[1694] | 1323 | } |
---|
| 1324 | if { $_first != "" } { |
---|
| 1325 | set location [$_first hints camera] |
---|
| 1326 | if { $location != "" } { |
---|
| 1327 | array set _view $location |
---|
| 1328 | } |
---|
| 1329 | } |
---|
[3485] | 1330 | set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] |
---|
| 1331 | $_arcball quaternion $q |
---|
| 1332 | SendCmd "camera orient $q" |
---|
[3492] | 1333 | SendCmd "camera reset" |
---|
[3362] | 1334 | set _settings($this-qw) $_view(qw) |
---|
| 1335 | set _settings($this-qx) $_view(qx) |
---|
| 1336 | set _settings($this-qy) $_view(qy) |
---|
| 1337 | set _settings($this-qz) $_view(qz) |
---|
[3533] | 1338 | set _settings($this-xpan) $_view(xpan) |
---|
| 1339 | set _settings($this-ypan) $_view(ypan) |
---|
[1694] | 1340 | set _settings($this-zoom) $_view(zoom) |
---|
[1349] | 1341 | } |
---|
[1295] | 1342 | } |
---|
| 1343 | } |
---|
| 1344 | |
---|
[1349] | 1345 | itcl::body Rappture::FlowvisViewer::PanCamera {} { |
---|
[3533] | 1346 | set x $_view(xpan) |
---|
| 1347 | set y $_view(ypan) |
---|
[1349] | 1348 | SendCmd "camera pan $x $y" |
---|
| 1349 | } |
---|
| 1350 | |
---|
[1295] | 1351 | # ---------------------------------------------------------------------- |
---|
[1349] | 1352 | # USAGE: Rotate click <x> <y> |
---|
| 1353 | # USAGE: Rotate drag <x> <y> |
---|
| 1354 | # USAGE: Rotate release <x> <y> |
---|
[1295] | 1355 | # |
---|
[1349] | 1356 | # Called automatically when the user clicks/drags/releases in the |
---|
| 1357 | # plot area. Moves the plot according to the user's actions. |
---|
| 1358 | # ---------------------------------------------------------------------- |
---|
| 1359 | itcl::body Rappture::FlowvisViewer::Rotate {option x y} { |
---|
| 1360 | switch -- $option { |
---|
| 1361 | click { |
---|
| 1362 | $itk_component(3dview) configure -cursor fleur |
---|
[1442] | 1363 | set _click(x) $x |
---|
| 1364 | set _click(y) $y |
---|
[1349] | 1365 | } |
---|
| 1366 | drag { |
---|
[1442] | 1367 | if {[array size _click] == 0} { |
---|
[1349] | 1368 | Rotate click $x $y |
---|
| 1369 | } else { |
---|
| 1370 | set w [winfo width $itk_component(3dview)] |
---|
| 1371 | set h [winfo height $itk_component(3dview)] |
---|
| 1372 | if {$w <= 0 || $h <= 0} { |
---|
| 1373 | return |
---|
| 1374 | } |
---|
| 1375 | |
---|
| 1376 | if {[catch { |
---|
| 1377 | # this fails sometimes for no apparent reason |
---|
[1442] | 1378 | set dx [expr {double($x-$_click(x))/$w}] |
---|
| 1379 | set dy [expr {double($y-$_click(y))/$h}] |
---|
[1349] | 1380 | }]} { |
---|
| 1381 | return |
---|
| 1382 | } |
---|
| 1383 | |
---|
[3485] | 1384 | set q [$_arcball rotate $x $y $_click(x) $_click(y)] |
---|
| 1385 | foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break |
---|
| 1386 | set _settings($this-qw) $_view(qw) |
---|
| 1387 | set _settings($this-qx) $_view(qx) |
---|
| 1388 | set _settings($this-qy) $_view(qy) |
---|
| 1389 | set _settings($this-qz) $_view(qz) |
---|
| 1390 | SendCmd "camera orient $q" |
---|
[1349] | 1391 | |
---|
[1442] | 1392 | set _click(x) $x |
---|
| 1393 | set _click(y) $y |
---|
[1349] | 1394 | } |
---|
| 1395 | } |
---|
| 1396 | release { |
---|
| 1397 | Rotate drag $x $y |
---|
| 1398 | $itk_component(3dview) configure -cursor "" |
---|
[1442] | 1399 | catch {unset _click} |
---|
[1349] | 1400 | } |
---|
| 1401 | default { |
---|
| 1402 | error "bad option \"$option\": should be click, drag, release" |
---|
| 1403 | } |
---|
| 1404 | } |
---|
| 1405 | } |
---|
| 1406 | |
---|
| 1407 | # ---------------------------------------------------------------------- |
---|
| 1408 | # USAGE: $this Pan click x y |
---|
| 1409 | # $this Pan drag x y |
---|
| 1410 | # $this Pan release x y |
---|
| 1411 | # |
---|
[1295] | 1412 | # Called automatically when the user clicks on one of the zoom |
---|
| 1413 | # controls for this widget. Changes the zoom for the current view. |
---|
| 1414 | # ---------------------------------------------------------------------- |
---|
[1349] | 1415 | itcl::body Rappture::FlowvisViewer::Pan {option x y} { |
---|
[1295] | 1416 | # Experimental stuff |
---|
| 1417 | set w [winfo width $itk_component(3dview)] |
---|
| 1418 | set h [winfo height $itk_component(3dview)] |
---|
| 1419 | if { $option == "set" } { |
---|
[1349] | 1420 | set x [expr $x / double($w)] |
---|
| 1421 | set y [expr $y / double($h)] |
---|
[3533] | 1422 | set _view(xpan) [expr $_view(xpan) + $x] |
---|
| 1423 | set _view(ypan) [expr $_view(ypan) + $y] |
---|
[1349] | 1424 | PanCamera |
---|
[3533] | 1425 | set _settings($this-xpan) $_view(xpan) |
---|
| 1426 | set _settings($this-ypan) $_view(ypan) |
---|
[1349] | 1427 | return |
---|
[1295] | 1428 | } |
---|
| 1429 | if { $option == "click" } { |
---|
[1442] | 1430 | set _click(x) $x |
---|
| 1431 | set _click(y) $y |
---|
[1349] | 1432 | $itk_component(3dview) configure -cursor hand1 |
---|
[1295] | 1433 | } |
---|
| 1434 | if { $option == "drag" || $option == "release" } { |
---|
[1442] | 1435 | set dx [expr ($_click(x) - $x)/double($w)] |
---|
| 1436 | set dy [expr ($_click(y) - $y)/double($h)] |
---|
| 1437 | set _click(x) $x |
---|
| 1438 | set _click(y) $y |
---|
[3533] | 1439 | set _view(xpan) [expr $_view(xpan) - $dx] |
---|
| 1440 | set _view(ypan) [expr $_view(ypan) - $dy] |
---|
[1349] | 1441 | PanCamera |
---|
[3533] | 1442 | set _settings($this-xpan) $_view(xpan) |
---|
| 1443 | set _settings($this-ypan) $_view(ypan) |
---|
[1295] | 1444 | } |
---|
| 1445 | if { $option == "release" } { |
---|
[1349] | 1446 | $itk_component(3dview) configure -cursor "" |
---|
[1295] | 1447 | } |
---|
| 1448 | } |
---|
| 1449 | |
---|
| 1450 | |
---|
| 1451 | # ---------------------------------------------------------------------- |
---|
[1349] | 1452 | # USAGE: Flow movie record|stop|play ?on|off|toggle? |
---|
[1295] | 1453 | # |
---|
| 1454 | # Called when the user clicks on the record, stop or play buttons |
---|
| 1455 | # for flow visualization. |
---|
| 1456 | # ---------------------------------------------------------------------- |
---|
[1349] | 1457 | itcl::body Rappture::FlowvisViewer::Flow {option args} { |
---|
[1295] | 1458 | switch -- $option { |
---|
[1349] | 1459 | movie { |
---|
| 1460 | if {[llength $args] < 1 || [llength $args] > 2} { |
---|
| 1461 | error "wrong # args: should be \"Flow movie record|stop|play ?on|off|toggle?\"" |
---|
| 1462 | } |
---|
| 1463 | set action [lindex $args 0] |
---|
| 1464 | set op [lindex $args 1] |
---|
| 1465 | if {$op == ""} { set op "on" } |
---|
[1295] | 1466 | |
---|
[1349] | 1467 | set current [State $action] |
---|
| 1468 | if {$op == "toggle"} { |
---|
| 1469 | if {$current == "on"} { |
---|
| 1470 | set op "off" |
---|
| 1471 | } else { |
---|
| 1472 | set op "on" |
---|
| 1473 | } |
---|
| 1474 | } |
---|
| 1475 | set cmds "" |
---|
| 1476 | switch -- $action { |
---|
| 1477 | record { |
---|
[1694] | 1478 | if { [$itk_component(rewind) cget -relief] != "sunken" } { |
---|
| 1479 | $itk_component(rewind) configure -relief sunken |
---|
| 1480 | $itk_component(stop) configure -relief raised |
---|
| 1481 | $itk_component(play) configure -relief raised |
---|
| 1482 | set inner $itk_component(settingsFrame) |
---|
| 1483 | set frames [$inner.framecnt value] |
---|
| 1484 | set _settings(nsteps) $frames |
---|
| 1485 | set cmds "flow capture $frames" |
---|
| 1486 | SendCmd $cmds |
---|
| 1487 | } |
---|
[1349] | 1488 | } |
---|
| 1489 | stop { |
---|
[1694] | 1490 | if { [$itk_component(stop) cget -relief] != "sunken" } { |
---|
| 1491 | $itk_component(rewind) configure -relief raised |
---|
| 1492 | $itk_component(stop) configure -relief sunken |
---|
| 1493 | $itk_component(play) configure -relief raised |
---|
| 1494 | _pause |
---|
| 1495 | set cmds "flow reset" |
---|
| 1496 | SendCmd $cmds |
---|
| 1497 | } |
---|
[1349] | 1498 | } |
---|
| 1499 | play { |
---|
[1694] | 1500 | if { [$itk_component(play) cget -relief] != "sunken" } { |
---|
| 1501 | $itk_component(rewind) configure -relief raised |
---|
| 1502 | $itk_component(stop) configure -relief raised |
---|
| 1503 | $itk_component(play) configure \ |
---|
| 1504 | -image [Rappture::icon flow-pause] \ |
---|
| 1505 | -relief sunken |
---|
| 1506 | bind $itk_component(play) <ButtonPress> \ |
---|
| 1507 | [itcl::code $this _pause] |
---|
| 1508 | flow next |
---|
| 1509 | } |
---|
[1349] | 1510 | } |
---|
| 1511 | default { |
---|
| 1512 | error "bad option \"$option\": should be one of record|stop|play" |
---|
| 1513 | } |
---|
[1295] | 1514 | |
---|
[1349] | 1515 | } |
---|
| 1516 | } |
---|
| 1517 | default { |
---|
| 1518 | error "bad option \"$option\": should be movie" |
---|
| 1519 | } |
---|
[1295] | 1520 | } |
---|
| 1521 | } |
---|
| 1522 | |
---|
| 1523 | # ---------------------------------------------------------------------- |
---|
[1349] | 1524 | # USAGE: Play |
---|
[1295] | 1525 | # |
---|
| 1526 | # ---------------------------------------------------------------------- |
---|
[1349] | 1527 | itcl::body Rappture::FlowvisViewer::Play {} { |
---|
[1354] | 1528 | SendCmd "flow next" |
---|
[1442] | 1529 | set delay [expr {int(ceil(pow($_settings(speed)/10.0+2,2.0)*15))}] |
---|
[1349] | 1530 | $_dispatcher event -after $delay !play |
---|
[1295] | 1531 | } |
---|
| 1532 | |
---|
| 1533 | # ---------------------------------------------------------------------- |
---|
[1349] | 1534 | # USAGE: Pause |
---|
[1295] | 1535 | # |
---|
| 1536 | # Invoked when the user hits the "pause" button to stop playing the |
---|
| 1537 | # current sequence of frames as a movie. |
---|
| 1538 | # ---------------------------------------------------------------------- |
---|
[1349] | 1539 | itcl::body Rappture::FlowvisViewer::Pause {} { |
---|
| 1540 | $_dispatcher cancel !play |
---|
[1295] | 1541 | |
---|
[1349] | 1542 | # Toggle the button to "play" mode |
---|
[1295] | 1543 | $itk_component(play) configure \ |
---|
[1349] | 1544 | -image [Rappture::icon flow-start] \ |
---|
| 1545 | -relief raised |
---|
[1295] | 1546 | bind $itk_component(play) <ButtonPress> \ |
---|
[1349] | 1547 | [itcl::code $this Flow movie play toggle] |
---|
[1295] | 1548 | } |
---|
| 1549 | |
---|
| 1550 | # ---------------------------------------------------------------------- |
---|
[3396] | 1551 | # USAGE: InitSettings <what> ?<value>? |
---|
[1295] | 1552 | # |
---|
| 1553 | # Used internally to update rendering settings whenever parameters |
---|
| 1554 | # change in the popup settings panel. Sends the new settings off |
---|
| 1555 | # to the back end. |
---|
| 1556 | # ---------------------------------------------------------------------- |
---|
[3396] | 1557 | itcl::body Rappture::FlowvisViewer::InitSettings { args } { |
---|
| 1558 | foreach arg $args { |
---|
| 1559 | AdjustSetting $arg |
---|
| 1560 | } |
---|
| 1561 | } |
---|
| 1562 | |
---|
| 1563 | # ---------------------------------------------------------------------- |
---|
| 1564 | # USAGE: AdjustSetting <what> ?<value>? |
---|
| 1565 | # |
---|
| 1566 | # Used internally to update rendering settings whenever parameters |
---|
| 1567 | # change in the popup settings panel. Sends the new settings off |
---|
| 1568 | # to the back end. |
---|
| 1569 | # ---------------------------------------------------------------------- |
---|
| 1570 | itcl::body Rappture::FlowvisViewer::AdjustSetting {what {value ""}} { |
---|
[1295] | 1571 | switch -- $what { |
---|
[3396] | 1572 | colormap { |
---|
| 1573 | set color [$itk_component(colormap) value] |
---|
| 1574 | set _settings(colormap) $color |
---|
| 1575 | #ResetColormap $color |
---|
| 1576 | } |
---|
[3915] | 1577 | ambient { |
---|
[1491] | 1578 | if { $_first != "" } { |
---|
[1694] | 1579 | set comp [lindex [$_first components] 0] |
---|
| 1580 | set tag $_first-$comp |
---|
[3915] | 1581 | set val $_settings($this-ambient) |
---|
| 1582 | set val [expr {0.01*$val}] |
---|
| 1583 | SendCmd "$tag configure -ambient $val" |
---|
[1349] | 1584 | } |
---|
| 1585 | } |
---|
[3915] | 1586 | diffuse { |
---|
| 1587 | if { $_first != "" } { |
---|
| 1588 | set comp [lindex [$_first components] 0] |
---|
| 1589 | set tag $_first-$comp |
---|
| 1590 | set val $_settings($this-diffuse) |
---|
| 1591 | set val [expr {0.01*$val}] |
---|
| 1592 | SendCmd "$tag configure -diffuse $val" |
---|
| 1593 | } |
---|
| 1594 | } |
---|
| 1595 | specularLevel { |
---|
| 1596 | if { $_first != "" } { |
---|
| 1597 | set comp [lindex [$_first components] 0] |
---|
| 1598 | set tag $_first-$comp |
---|
| 1599 | set val $_settings($this-specularLevel) |
---|
| 1600 | set val [expr {0.01*$val}] |
---|
| 1601 | SendCmd "$tag configure -specularLevel $val" |
---|
| 1602 | } |
---|
| 1603 | } |
---|
| 1604 | specularExponent { |
---|
| 1605 | if { $_first != "" } { |
---|
| 1606 | set comp [lindex [$_first components] 0] |
---|
| 1607 | set tag $_first-$comp |
---|
| 1608 | set val $_settings($this-specularExponent) |
---|
| 1609 | SendCmd "$tag configure -specularExp $val" |
---|
| 1610 | } |
---|
| 1611 | } |
---|
[3396] | 1612 | light2side { |
---|
| 1613 | if { $_first != "" } { |
---|
| 1614 | set comp [lindex [$_first components] 0] |
---|
| 1615 | set tag $_first-$comp |
---|
| 1616 | set val $_settings($this-light2side) |
---|
[3398] | 1617 | SendCmd "$tag configure -light2side $val" |
---|
[3396] | 1618 | } |
---|
| 1619 | } |
---|
[1349] | 1620 | transp { |
---|
[1491] | 1621 | if { $_first != "" } { |
---|
[1694] | 1622 | set comp [lindex [$_first components] 0] |
---|
| 1623 | set tag $_first-$comp |
---|
[3362] | 1624 | set opacity [expr { 0.01 * double($_settings($this-transp)) }] |
---|
[1479] | 1625 | SendCmd "$tag configure -opacity $opacity" |
---|
[1349] | 1626 | } |
---|
| 1627 | } |
---|
| 1628 | opacity { |
---|
[1494] | 1629 | if { $_first != "" && $_activeTf != "" } { |
---|
[1479] | 1630 | set opacity [expr { 0.01 * double($_settings($this-opacity)) }] |
---|
[1442] | 1631 | set tf $_activeTf |
---|
[1479] | 1632 | set _settings($this-$tf-opacity) $opacity |
---|
[4166] | 1633 | updateTransferFunctions |
---|
[1349] | 1634 | } |
---|
| 1635 | } |
---|
[1295] | 1636 | |
---|
[1349] | 1637 | thickness { |
---|
[1494] | 1638 | if { $_first != "" && $_activeTf != "" } { |
---|
[1442] | 1639 | set val $_settings($this-thickness) |
---|
[1349] | 1640 | # Scale values between 0.00001 and 0.01000 |
---|
| 1641 | set sval [expr {0.0001*double($val)}] |
---|
[1442] | 1642 | set tf $_activeTf |
---|
| 1643 | set _settings($this-$tf-thickness) $sval |
---|
[4166] | 1644 | updateTransferFunctions |
---|
[1349] | 1645 | } |
---|
| 1646 | } |
---|
| 1647 | "outline" { |
---|
[1491] | 1648 | if { $_first != "" } { |
---|
[1694] | 1649 | set comp [lindex [$_first components] 0] |
---|
| 1650 | set tag $_first-$comp |
---|
[1479] | 1651 | SendCmd "$tag configure -outline $_settings($this-outline)" |
---|
[1349] | 1652 | } |
---|
| 1653 | } |
---|
| 1654 | "isosurface" { |
---|
[1491] | 1655 | if { [isconnected] } { |
---|
[1694] | 1656 | SendCmd "volume shading isosurface $_settings($this-isosurface)" |
---|
| 1657 | } |
---|
[1349] | 1658 | } |
---|
| 1659 | "grid" { |
---|
| 1660 | if { [isconnected] } { |
---|
[1442] | 1661 | SendCmd "grid visible $_settings($this-grid)" |
---|
[1349] | 1662 | } |
---|
| 1663 | } |
---|
| 1664 | "axes" { |
---|
| 1665 | if { [isconnected] } { |
---|
[1442] | 1666 | SendCmd "axis visible $_settings($this-axes)" |
---|
[1349] | 1667 | } |
---|
| 1668 | } |
---|
[1694] | 1669 | "legend" { |
---|
| 1670 | if { $_settings($this-legend) } { |
---|
| 1671 | blt::table $itk_component(plotarea) \ |
---|
| 1672 | 0,0 $itk_component(3dview) -fill both \ |
---|
| 1673 | 1,0 $itk_component(legend) -fill x |
---|
| 1674 | blt::table configure $itk_component(plotarea) r1 -resize none |
---|
| 1675 | } else { |
---|
| 1676 | blt::table forget $itk_component(legend) |
---|
| 1677 | } |
---|
| 1678 | } |
---|
[1349] | 1679 | "volume" { |
---|
[1491] | 1680 | if { $_first != "" } { |
---|
[1694] | 1681 | set comp [lindex [$_first components] 0] |
---|
| 1682 | set tag $_first-$comp |
---|
[1479] | 1683 | SendCmd "$tag configure -volume $_settings($this-volume)" |
---|
[1694] | 1684 | } |
---|
[1349] | 1685 | } |
---|
[3899] | 1686 | "cutplaneVisible" { |
---|
| 1687 | set bool $_settings($this-$what) |
---|
| 1688 | set datasets [CurrentVolumeIds -cutplanes] |
---|
| 1689 | set tag [lindex $datasets 0] |
---|
| 1690 | SendCmd "cutplane visible $bool $tag" |
---|
| 1691 | } |
---|
[1442] | 1692 | "xcutplane" - "ycutplane" - "zcutplane" { |
---|
[1694] | 1693 | set axis [string range $what 0 0] |
---|
| 1694 | set bool $_settings($this-$what) |
---|
[1442] | 1695 | if { [isconnected] } { |
---|
[1694] | 1696 | set vols [CurrentVolumeIds -cutplanes] |
---|
| 1697 | SendCmd "cutplane state $bool $axis $vols" |
---|
| 1698 | } |
---|
| 1699 | if { $bool } { |
---|
| 1700 | $itk_component(${axis}CutScale) configure -state normal \ |
---|
| 1701 | -troughcolor white |
---|
[1442] | 1702 | } else { |
---|
[1694] | 1703 | $itk_component(${axis}CutScale) configure -state disabled \ |
---|
| 1704 | -troughcolor grey82 |
---|
[1442] | 1705 | } |
---|
[1349] | 1706 | } |
---|
| 1707 | default { |
---|
| 1708 | error "don't know how to fix $what" |
---|
| 1709 | } |
---|
[1295] | 1710 | } |
---|
| 1711 | } |
---|
| 1712 | |
---|
| 1713 | # ---------------------------------------------------------------------- |
---|
[1448] | 1714 | # USAGE: ResizeLegend |
---|
[1295] | 1715 | # |
---|
[1349] | 1716 | # Used internally to update the legend area whenever it changes size |
---|
| 1717 | # or when the field changes. Asks the server to send a new legend |
---|
| 1718 | # for the current field. |
---|
[1295] | 1719 | # ---------------------------------------------------------------------- |
---|
[1448] | 1720 | itcl::body Rappture::FlowvisViewer::ResizeLegend {} { |
---|
| 1721 | set _resizeLegendPending 0 |
---|
[1349] | 1722 | set lineht [font metrics $itk_option(-font) -linespace] |
---|
[1442] | 1723 | set w [expr {$_width-20}] |
---|
[1349] | 1724 | set h [expr {[winfo height $itk_component(legend)]-20-$lineht}] |
---|
[1479] | 1725 | |
---|
| 1726 | if { $_first == "" } { |
---|
[1694] | 1727 | return |
---|
[1479] | 1728 | } |
---|
| 1729 | set comp [lindex [$_first components] 0] |
---|
| 1730 | set tag $_first-$comp |
---|
| 1731 | #set _activeTf [lindex $_obj2style($tag) 0] |
---|
[1442] | 1732 | if {$w > 0 && $h > 0 && "" != $_activeTf} { |
---|
[1479] | 1733 | #SendCmd "legend $_activeTf $w $h" |
---|
[1694] | 1734 | SendCmd "$tag legend $w $h" |
---|
[1349] | 1735 | } else { |
---|
| 1736 | # Can't do this as this will remove the items associated with the |
---|
| 1737 | # isomarkers. |
---|
| 1738 | |
---|
| 1739 | #$itk_component(legend) delete all |
---|
| 1740 | } |
---|
| 1741 | } |
---|
| 1742 | |
---|
| 1743 | # |
---|
[1377] | 1744 | # NameTransferFunc -- |
---|
[1349] | 1745 | # |
---|
| 1746 | # Creates a transfer function name based on the <style> settings in the |
---|
| 1747 | # library run.xml file. This placeholder will be used later to create |
---|
| 1748 | # and send the actual transfer function once the data info has been sent |
---|
| 1749 | # to us by the render server. [We won't know the volume limits until the |
---|
| 1750 | # server parses the 3D data and sends back the limits via ReceiveData.] |
---|
| 1751 | # |
---|
| 1752 | # FIXME: The current way we generate transfer-function names completely |
---|
| 1753 | # ignores the -markers option. The problem is that we are forced |
---|
| 1754 | # to compute the name from an increasing complex set of values: |
---|
| 1755 | # color, levels, marker, opacity. I think we're stuck doing it |
---|
| 1756 | # now. |
---|
| 1757 | # |
---|
[3940] | 1758 | itcl::body Rappture::FlowvisViewer::NameTransferFunc { dataobj cname } { |
---|
[1295] | 1759 | array set style { |
---|
[3396] | 1760 | -color BCGYR |
---|
[1349] | 1761 | -levels 6 |
---|
| 1762 | -opacity 1.0 |
---|
[1694] | 1763 | -light 40 |
---|
| 1764 | -transp 50 |
---|
[1295] | 1765 | } |
---|
[3940] | 1766 | array set style [lindex [$dataobj components -style $cname] 0] |
---|
[1496] | 1767 | set _settings($this-light) $style(-light) |
---|
| 1768 | set _settings($this-transp) $style(-transp) |
---|
| 1769 | set _settings($this-opacity) [expr $style(-opacity) * 100] |
---|
[3940] | 1770 | set _obj2style($dataobj-$cname) $cname |
---|
| 1771 | lappend _style2objs($cname) $dataobj $cname |
---|
| 1772 | return $cname |
---|
[1349] | 1773 | } |
---|
| 1774 | |
---|
| 1775 | # |
---|
[1377] | 1776 | # ComputeTransferFunc -- |
---|
[1349] | 1777 | # |
---|
| 1778 | # Computes and sends the transfer function to the render server. It's |
---|
| 1779 | # assumed that the volume data limits are known and that the global |
---|
| 1780 | # transfer-functions slider values have be setup. Both parts are |
---|
| 1781 | # needed to compute the relative value (location) of the marker, and |
---|
| 1782 | # the alpha map of the transfer function. |
---|
| 1783 | # |
---|
[1377] | 1784 | itcl::body Rappture::FlowvisViewer::ComputeTransferFunc { tf } { |
---|
[1349] | 1785 | array set style { |
---|
[3396] | 1786 | -color BCGYR |
---|
[1349] | 1787 | -levels 6 |
---|
| 1788 | -opacity 1.0 |
---|
[1694] | 1789 | -light 40 |
---|
| 1790 | -transp 50 |
---|
[1349] | 1791 | } |
---|
| 1792 | set dataobj ""; set comp "" |
---|
[1442] | 1793 | foreach {dataobj comp} $_style2objs($tf) break |
---|
[1349] | 1794 | if { $dataobj == "" } { |
---|
| 1795 | return 0 |
---|
| 1796 | } |
---|
| 1797 | array set style [lindex [$dataobj components -style $comp] 0] |
---|
| 1798 | |
---|
| 1799 | |
---|
| 1800 | # We have to parse the style attributes for a volume using this |
---|
| 1801 | # transfer-function *once*. This sets up the initial isomarkers for the |
---|
| 1802 | # transfer function. The user may add/delete markers, so we have to |
---|
| 1803 | # maintain a list of markers for each transfer-function. We use the one |
---|
| 1804 | # of the volumes (the first in the list) using the transfer-function as a |
---|
| 1805 | # reference. |
---|
| 1806 | # |
---|
| 1807 | # FIXME: The current way we generate transfer-function names completely |
---|
| 1808 | # ignores the -markers option. The problem is that we are forced |
---|
| 1809 | # to compute the name from an increasing complex set of values: |
---|
| 1810 | # color, levels, marker, opacity. I think the cow's out of the |
---|
| 1811 | # barn on this one. |
---|
| 1812 | |
---|
[1442] | 1813 | if { ![info exists _isomarkers($tf)] } { |
---|
[1349] | 1814 | # Have to defer creation of isomarkers until we have data limits |
---|
[3396] | 1815 | if { [info exists style(-markers)] && |
---|
| 1816 | [llength $style(-markers)] > 0 } { |
---|
[1442] | 1817 | ParseMarkersOption $tf $style(-markers) |
---|
[1349] | 1818 | } else { |
---|
[1442] | 1819 | ParseLevelsOption $tf $style(-levels) |
---|
[1349] | 1820 | } |
---|
| 1821 | } |
---|
[1479] | 1822 | if { [info exists style(-nonuniformcolors)] } { |
---|
[1694] | 1823 | foreach { value color } $style(-nonuniformcolors) { |
---|
| 1824 | append cmap "$value [Color2RGB $color] " |
---|
| 1825 | } |
---|
[1479] | 1826 | } else { |
---|
[3396] | 1827 | set cmap [ColorsToColormap $style(-color)] |
---|
[1295] | 1828 | } |
---|
[1349] | 1829 | set tag $this-$tf |
---|
[1442] | 1830 | if { ![info exists _settings($tag-opacity)] } { |
---|
| 1831 | set _settings($tag-opacity) $style(-opacity) |
---|
[1295] | 1832 | } |
---|
[3396] | 1833 | set max 1.0 ;#$_settings($tag-opacity) |
---|
[1496] | 1834 | |
---|
[1349] | 1835 | set isovalues {} |
---|
[1442] | 1836 | foreach m $_isomarkers($tf) { |
---|
[1377] | 1837 | lappend isovalues [$m relval] |
---|
[1349] | 1838 | } |
---|
| 1839 | # Sort the isovalues |
---|
| 1840 | set isovalues [lsort -real $isovalues] |
---|
| 1841 | |
---|
[1442] | 1842 | if { ![info exists _settings($tag-thickness)]} { |
---|
[3396] | 1843 | set _settings($tag-thickness) 0.005 |
---|
[1349] | 1844 | } |
---|
[1442] | 1845 | set delta $_settings($tag-thickness) |
---|
[1349] | 1846 | |
---|
| 1847 | set first [lindex $isovalues 0] |
---|
| 1848 | set last [lindex $isovalues end] |
---|
| 1849 | set wmap "" |
---|
| 1850 | if { $first == "" || $first != 0.0 } { |
---|
| 1851 | lappend wmap 0.0 0.0 |
---|
| 1852 | } |
---|
| 1853 | foreach x $isovalues { |
---|
| 1854 | set x1 [expr {$x-$delta-0.00001}] |
---|
| 1855 | set x2 [expr {$x-$delta}] |
---|
| 1856 | set x3 [expr {$x+$delta}] |
---|
| 1857 | set x4 [expr {$x+$delta+0.00001}] |
---|
| 1858 | if { $x1 < 0.0 } { |
---|
| 1859 | set x1 0.0 |
---|
| 1860 | } elseif { $x1 > 1.0 } { |
---|
| 1861 | set x1 1.0 |
---|
| 1862 | } |
---|
| 1863 | if { $x2 < 0.0 } { |
---|
| 1864 | set x2 0.0 |
---|
| 1865 | } elseif { $x2 > 1.0 } { |
---|
| 1866 | set x2 1.0 |
---|
| 1867 | } |
---|
| 1868 | if { $x3 < 0.0 } { |
---|
| 1869 | set x3 0.0 |
---|
| 1870 | } elseif { $x3 > 1.0 } { |
---|
| 1871 | set x3 1.0 |
---|
| 1872 | } |
---|
| 1873 | if { $x4 < 0.0 } { |
---|
| 1874 | set x4 0.0 |
---|
| 1875 | } elseif { $x4 > 1.0 } { |
---|
| 1876 | set x4 1.0 |
---|
| 1877 | } |
---|
| 1878 | # add spikes in the middle |
---|
| 1879 | lappend wmap $x1 0.0 |
---|
| 1880 | lappend wmap $x2 $max |
---|
| 1881 | lappend wmap $x3 $max |
---|
| 1882 | lappend wmap $x4 0.0 |
---|
| 1883 | } |
---|
| 1884 | if { $last == "" || $last != 1.0 } { |
---|
| 1885 | lappend wmap 1.0 0.0 |
---|
| 1886 | } |
---|
[3396] | 1887 | SendCmd "transfunc define $tf { $cmap } { $wmap }" |
---|
| 1888 | return [SendCmd "$dataobj-$comp configure -transferfunction $tf"] |
---|
[1295] | 1889 | } |
---|
| 1890 | |
---|
| 1891 | # ---------------------------------------------------------------------- |
---|
| 1892 | # CONFIGURATION OPTION: -plotbackground |
---|
| 1893 | # ---------------------------------------------------------------------- |
---|
| 1894 | itcl::configbody Rappture::FlowvisViewer::plotbackground { |
---|
[1349] | 1895 | if { [isconnected] } { |
---|
[4163] | 1896 | set color $itk_option(-plotbackground) |
---|
| 1897 | set rgb [Color2RGB $color] |
---|
| 1898 | SendCmd "screen bgcolor $rgb" |
---|
| 1899 | $itk_component(legend) configure -background $color |
---|
[1349] | 1900 | } |
---|
[1295] | 1901 | } |
---|
| 1902 | |
---|
| 1903 | # ---------------------------------------------------------------------- |
---|
| 1904 | # CONFIGURATION OPTION: -plotforeground |
---|
| 1905 | # ---------------------------------------------------------------------- |
---|
| 1906 | itcl::configbody Rappture::FlowvisViewer::plotforeground { |
---|
[1349] | 1907 | if { [isconnected] } { |
---|
[4163] | 1908 | set color $itk_option(-plotforeground) |
---|
| 1909 | set rgb [Color2RGB $color] |
---|
| 1910 | SendCmd "volume outline color $rgb" |
---|
| 1911 | SendCmd "grid axiscolor $rgb" |
---|
| 1912 | SendCmd "grid linecolor $rgb" |
---|
[4166] | 1913 | $itk_component(legend) itemconfigure labels -fill $color |
---|
| 1914 | $itk_component(legend) itemconfigure limits -fill $color |
---|
[1349] | 1915 | } |
---|
[1295] | 1916 | } |
---|
| 1917 | |
---|
| 1918 | # ---------------------------------------------------------------------- |
---|
| 1919 | # CONFIGURATION OPTION: -plotoutline |
---|
| 1920 | # ---------------------------------------------------------------------- |
---|
| 1921 | itcl::configbody Rappture::FlowvisViewer::plotoutline { |
---|
[1349] | 1922 | # Must check if we are connected because this routine is called from the |
---|
| 1923 | # class body when the -plotoutline itk_option is defined. At that point |
---|
| 1924 | # the FlowvisViewer class constructor hasn't been called, so we can't |
---|
| 1925 | # start sending commands to visualization server. |
---|
| 1926 | if { [isconnected] } { |
---|
| 1927 | if {"" == $itk_option(-plotoutline)} { |
---|
| 1928 | SendCmd "volume outline state off" |
---|
| 1929 | } else { |
---|
| 1930 | SendCmd "volume outline state on" |
---|
| 1931 | SendCmd "volume outline color [Color2RGB $itk_option(-plotoutline)]" |
---|
| 1932 | } |
---|
[1295] | 1933 | } |
---|
| 1934 | } |
---|
[1349] | 1935 | |
---|
| 1936 | # |
---|
| 1937 | # The -levels option takes a single value that represents the number |
---|
| 1938 | # of evenly distributed markers based on the current data range. Each |
---|
| 1939 | # marker is a relative value from 0.0 to 1.0. |
---|
| 1940 | # |
---|
[1442] | 1941 | itcl::body Rappture::FlowvisViewer::ParseLevelsOption { tf levels } { |
---|
[1349] | 1942 | set c $itk_component(legend) |
---|
| 1943 | regsub -all "," $levels " " levels |
---|
| 1944 | if {[string is int $levels]} { |
---|
| 1945 | for {set i 1} { $i <= $levels } {incr i} { |
---|
| 1946 | set x [expr {double($i)/($levels+1)}] |
---|
[1442] | 1947 | set m [Rappture::IsoMarker \#auto $c $this $tf] |
---|
[4166] | 1948 | $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground) |
---|
[1377] | 1949 | $m relval $x |
---|
[1442] | 1950 | lappend _isomarkers($tf) $m |
---|
[1349] | 1951 | } |
---|
| 1952 | } else { |
---|
| 1953 | foreach x $levels { |
---|
[1442] | 1954 | set m [Rappture::IsoMarker \#auto $c $this $tf] |
---|
[4166] | 1955 | $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground) |
---|
[1377] | 1956 | $m relval $x |
---|
[1442] | 1957 | lappend _isomarkers($tf) $m |
---|
[1349] | 1958 | } |
---|
| 1959 | } |
---|
| 1960 | } |
---|
| 1961 | |
---|
| 1962 | # |
---|
| 1963 | # The -markers option takes a list of zero or more values (the values |
---|
| 1964 | # may be separated either by spaces or commas) that have the following |
---|
| 1965 | # format: |
---|
| 1966 | # |
---|
| 1967 | # N% Percent of current total data range. Converted to |
---|
| 1968 | # to a relative value between 0.0 and 1.0. |
---|
| 1969 | # N Absolute value of marker. If the marker is outside of |
---|
| 1970 | # the current range, it will be displayed on the outer |
---|
| 1971 | # edge of the legends, but it range it represents will |
---|
| 1972 | # not be seen. |
---|
| 1973 | # |
---|
[1442] | 1974 | itcl::body Rappture::FlowvisViewer::ParseMarkersOption { tf markers } { |
---|
[1349] | 1975 | set c $itk_component(legend) |
---|
| 1976 | regsub -all "," $markers " " markers |
---|
| 1977 | foreach marker $markers { |
---|
| 1978 | set n [scan $marker "%g%s" value suffix] |
---|
| 1979 | if { $n == 2 && $suffix == "%" } { |
---|
| 1980 | # ${n}% : Set relative value. |
---|
| 1981 | set value [expr {$value * 0.01}] |
---|
[1442] | 1982 | set m [Rappture::IsoMarker \#auto $c $this $tf] |
---|
[4166] | 1983 | $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground) |
---|
[1377] | 1984 | $m relval $value |
---|
[1442] | 1985 | lappend _isomarkers($tf) $m |
---|
[1349] | 1986 | } else { |
---|
| 1987 | # ${n} : Set absolute value. |
---|
[1442] | 1988 | set m [Rappture::IsoMarker \#auto $c $this $tf] |
---|
[4166] | 1989 | $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground) |
---|
[1377] | 1990 | $m absval $value |
---|
[1442] | 1991 | lappend _isomarkers($tf) $m |
---|
[1349] | 1992 | } |
---|
| 1993 | } |
---|
| 1994 | } |
---|
| 1995 | |
---|
| 1996 | # ---------------------------------------------------------------------- |
---|
[1377] | 1997 | # USAGE: UndateTransferFuncs |
---|
[1349] | 1998 | # ---------------------------------------------------------------------- |
---|
[4166] | 1999 | itcl::body Rappture::FlowvisViewer::updateTransferFunctions {} { |
---|
[1479] | 2000 | $_dispatcher event -after 100 !send_transfunc |
---|
[1349] | 2001 | } |
---|
| 2002 | |
---|
| 2003 | itcl::body Rappture::FlowvisViewer::AddIsoMarker { x y } { |
---|
[1442] | 2004 | if { $_activeTf == "" } { |
---|
[1349] | 2005 | error "active transfer function isn't set" |
---|
| 2006 | } |
---|
[1442] | 2007 | set tf $_activeTf |
---|
[1349] | 2008 | set c $itk_component(legend) |
---|
[1442] | 2009 | set m [Rappture::IsoMarker \#auto $c $this $tf] |
---|
[4166] | 2010 | $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground) |
---|
[1349] | 2011 | set w [winfo width $c] |
---|
[1377] | 2012 | $m relval [expr {double($x-10)/($w-20)}] |
---|
[1442] | 2013 | lappend _isomarkers($tf) $m |
---|
[4166] | 2014 | updateTransferFunctions |
---|
[1349] | 2015 | return 1 |
---|
| 2016 | } |
---|
| 2017 | |
---|
[4166] | 2018 | itcl::body Rappture::FlowvisViewer::removeDuplicateMarker { marker x } { |
---|
[1377] | 2019 | set tf [$marker transferfunc] |
---|
[1349] | 2020 | set bool 0 |
---|
[1442] | 2021 | if { [info exists _isomarkers($tf)] } { |
---|
[1349] | 2022 | set list {} |
---|
| 2023 | set marker [namespace tail $marker] |
---|
[1442] | 2024 | foreach m $_isomarkers($tf) { |
---|
[1377] | 2025 | set sx [$m screenpos] |
---|
[1349] | 2026 | if { $m != $marker } { |
---|
| 2027 | if { $x >= ($sx-3) && $x <= ($sx+3) } { |
---|
[1377] | 2028 | $marker relval [$m relval] |
---|
[1349] | 2029 | itcl::delete object $m |
---|
| 2030 | bell |
---|
| 2031 | set bool 1 |
---|
| 2032 | continue |
---|
| 2033 | } |
---|
| 2034 | } |
---|
| 2035 | lappend list $m |
---|
| 2036 | } |
---|
[1442] | 2037 | set _isomarkers($tf) $list |
---|
[4166] | 2038 | updateTransferFunctions |
---|
[1349] | 2039 | } |
---|
| 2040 | return $bool |
---|
| 2041 | } |
---|
| 2042 | |
---|
[4166] | 2043 | itcl::body Rappture::FlowvisViewer::overMarker { marker x } { |
---|
[1377] | 2044 | set tf [$marker transferfunc] |
---|
[1442] | 2045 | if { [info exists _isomarkers($tf)] } { |
---|
[1349] | 2046 | set marker [namespace tail $marker] |
---|
[1442] | 2047 | foreach m $_isomarkers($tf) { |
---|
[1377] | 2048 | set sx [$m screenpos] |
---|
[1349] | 2049 | if { $m != $marker } { |
---|
| 2050 | set bool [expr { $x >= ($sx-3) && $x <= ($sx+3) }] |
---|
[1376] | 2051 | $m activate $bool |
---|
[1349] | 2052 | } |
---|
| 2053 | } |
---|
| 2054 | } |
---|
| 2055 | return "" |
---|
| 2056 | } |
---|
| 2057 | |
---|
[3940] | 2058 | itcl::body Rappture::FlowvisViewer::limits { cname } { |
---|
| 2059 | set _limits(v) [list 0.0 1.0] |
---|
| 2060 | if { ![info exists _style2objs($cname)] } { |
---|
| 2061 | puts stderr "no style2objs for $cname cname=($cname)" |
---|
[1694] | 2062 | return [array get _limits] |
---|
[1349] | 2063 | } |
---|
[1442] | 2064 | set min ""; set max "" |
---|
[3940] | 2065 | foreach tag [GetDatasetsWithComponent $cname] { |
---|
[1694] | 2066 | if { ![info exists _serverObjs($tag)] } { |
---|
| 2067 | puts stderr "$tag not in serverObjs?" |
---|
| 2068 | continue |
---|
| 2069 | } |
---|
[3940] | 2070 | if { ![info exists _limits($tag)] } { |
---|
[1694] | 2071 | puts stderr "$tag no min?" |
---|
| 2072 | continue |
---|
| 2073 | } |
---|
[3940] | 2074 | foreach {vmin vmax} $_limits($tag) break |
---|
| 2075 | if { $min == "" || $min > $vmin } { |
---|
| 2076 | set min $vmin |
---|
[1694] | 2077 | } |
---|
[3940] | 2078 | if { $max == "" || $max < $vmax } { |
---|
| 2079 | set max $vmax |
---|
[1694] | 2080 | } |
---|
[1349] | 2081 | } |
---|
[3940] | 2082 | if { $min != "" && $max != "" } { |
---|
| 2083 | set _limits(v) [list $min $max] |
---|
| 2084 | set _limits($cname) [list $min $max] |
---|
[1442] | 2085 | } |
---|
[3940] | 2086 | return $_limits($cname) |
---|
[1349] | 2087 | } |
---|
| 2088 | |
---|
[1373] | 2089 | itcl::body Rappture::FlowvisViewer::BuildViewTab {} { |
---|
[1349] | 2090 | foreach { key value } { |
---|
[2744] | 2091 | grid 0 |
---|
| 2092 | axes 0 |
---|
| 2093 | outline 1 |
---|
| 2094 | volume 1 |
---|
| 2095 | legend 1 |
---|
| 2096 | particles 1 |
---|
| 2097 | lic 1 |
---|
[1349] | 2098 | } { |
---|
[1694] | 2099 | set _settings($this-$key) $value |
---|
[1349] | 2100 | } |
---|
| 2101 | |
---|
| 2102 | set fg [option get $itk_component(hull) font Font] |
---|
| 2103 | #set bfg [option get $itk_component(hull) boldFont Font] |
---|
| 2104 | |
---|
[1375] | 2105 | set inner [$itk_component(main) insert end \ |
---|
| 2106 | -title "View Settings" \ |
---|
| 2107 | -icon [Rappture::icon wrench]] |
---|
| 2108 | $inner configure -borderwidth 4 |
---|
| 2109 | |
---|
[1442] | 2110 | set ::Rappture::FlowvisViewer::_settings($this-isosurface) 0 |
---|
[1349] | 2111 | checkbutton $inner.isosurface \ |
---|
| 2112 | -text "Isosurface shading" \ |
---|
[1442] | 2113 | -variable [itcl::scope _settings($this-isosurface)] \ |
---|
[3396] | 2114 | -command [itcl::code $this AdjustSetting isosurface] \ |
---|
[1694] | 2115 | -font "Arial 9" |
---|
[1349] | 2116 | |
---|
| 2117 | checkbutton $inner.axes \ |
---|
| 2118 | -text "Axes" \ |
---|
[1442] | 2119 | -variable [itcl::scope _settings($this-axes)] \ |
---|
[3396] | 2120 | -command [itcl::code $this AdjustSetting axes] \ |
---|
[1694] | 2121 | -font "Arial 9" |
---|
[1349] | 2122 | |
---|
| 2123 | checkbutton $inner.grid \ |
---|
| 2124 | -text "Grid" \ |
---|
[1442] | 2125 | -variable [itcl::scope _settings($this-grid)] \ |
---|
[3396] | 2126 | -command [itcl::code $this AdjustSetting grid] \ |
---|
[1694] | 2127 | -font "Arial 9" |
---|
[1349] | 2128 | |
---|
| 2129 | checkbutton $inner.outline \ |
---|
| 2130 | -text "Outline" \ |
---|
[1442] | 2131 | -variable [itcl::scope _settings($this-outline)] \ |
---|
[3396] | 2132 | -command [itcl::code $this AdjustSetting outline] \ |
---|
[1694] | 2133 | -font "Arial 9" |
---|
[1349] | 2134 | |
---|
| 2135 | checkbutton $inner.legend \ |
---|
| 2136 | -text "Legend" \ |
---|
[1442] | 2137 | -variable [itcl::scope _settings($this-legend)] \ |
---|
[3396] | 2138 | -command [itcl::code $this AdjustSetting legend] \ |
---|
[1694] | 2139 | -font "Arial 9" |
---|
[1349] | 2140 | |
---|
| 2141 | checkbutton $inner.volume \ |
---|
| 2142 | -text "Volume" \ |
---|
[1442] | 2143 | -variable [itcl::scope _settings($this-volume)] \ |
---|
[3396] | 2144 | -command [itcl::code $this AdjustSetting volume] \ |
---|
[1694] | 2145 | -font "Arial 9" |
---|
[1349] | 2146 | |
---|
| 2147 | checkbutton $inner.particles \ |
---|
| 2148 | -text "Particles" \ |
---|
[1442] | 2149 | -variable [itcl::scope _settings($this-particles)] \ |
---|
[3396] | 2150 | -command [itcl::code $this AdjustSetting particles] \ |
---|
[1694] | 2151 | -font "Arial 9" |
---|
[1349] | 2152 | |
---|
| 2153 | checkbutton $inner.lic \ |
---|
| 2154 | -text "Lic" \ |
---|
[1442] | 2155 | -variable [itcl::scope _settings($this-lic)] \ |
---|
[3396] | 2156 | -command [itcl::code $this AdjustSetting lic] \ |
---|
[1694] | 2157 | -font "Arial 9" |
---|
[1349] | 2158 | |
---|
[1442] | 2159 | frame $inner.frame |
---|
| 2160 | |
---|
[1349] | 2161 | blt::table $inner \ |
---|
[3441] | 2162 | 0,0 $inner.axes -cspan 2 -anchor w \ |
---|
| 2163 | 1,0 $inner.grid -cspan 2 -anchor w \ |
---|
| 2164 | 2,0 $inner.outline -cspan 2 -anchor w \ |
---|
| 2165 | 3,0 $inner.volume -cspan 2 -anchor w \ |
---|
| 2166 | 4,0 $inner.legend -cspan 2 -anchor w |
---|
[1349] | 2167 | |
---|
[1442] | 2168 | bind $inner <Map> [itcl::code $this GetFlowInfo $inner] |
---|
| 2169 | |
---|
| 2170 | blt::table configure $inner r* -resize none |
---|
| 2171 | blt::table configure $inner r5 -resize expand |
---|
[1349] | 2172 | } |
---|
| 2173 | |
---|
[1373] | 2174 | itcl::body Rappture::FlowvisViewer::BuildVolumeTab {} { |
---|
[1375] | 2175 | set inner [$itk_component(main) insert end \ |
---|
| 2176 | -title "Volume Settings" \ |
---|
[1442] | 2177 | -icon [Rappture::icon volume-on]] |
---|
[1375] | 2178 | $inner configure -borderwidth 4 |
---|
[1349] | 2179 | |
---|
[1373] | 2180 | set fg [option get $itk_component(hull) font Font] |
---|
| 2181 | #set bfg [option get $itk_component(hull) boldFont Font] |
---|
| 2182 | |
---|
[1491] | 2183 | checkbutton $inner.vol -text "Show volume" -font $fg \ |
---|
| 2184 | -text "Volume" \ |
---|
| 2185 | -variable [itcl::scope _settings($this-volume)] \ |
---|
[3396] | 2186 | -command [itcl::code $this AdjustSetting volume] \ |
---|
[1694] | 2187 | -font "Arial 9" |
---|
[1491] | 2188 | |
---|
| 2189 | label $inner.shading -text "Shading:" -font $fg |
---|
| 2190 | |
---|
[3396] | 2191 | checkbutton $inner.light2side -text "Two-sided lighting" -font $fg \ |
---|
| 2192 | -variable [itcl::scope _settings($this-light2side)] \ |
---|
| 2193 | -command [itcl::code $this AdjustSetting light2side] |
---|
| 2194 | |
---|
[3915] | 2195 | label $inner.ambient_l -text "Ambient" -font $fg |
---|
| 2196 | ::scale $inner.ambient -from 0 -to 100 -orient horizontal \ |
---|
| 2197 | -variable [itcl::scope _settings($this-ambient)] \ |
---|
[1694] | 2198 | -width 10 \ |
---|
[3915] | 2199 | -showvalue off -command [itcl::code $this AdjustSetting ambient] |
---|
[1373] | 2200 | |
---|
[3915] | 2201 | label $inner.diffuse_l -text "Diffuse" -font $fg |
---|
| 2202 | ::scale $inner.diffuse -from 0 -to 100 -orient horizontal \ |
---|
| 2203 | -variable [itcl::scope _settings($this-diffuse)] \ |
---|
| 2204 | -width 10 \ |
---|
| 2205 | -showvalue off -command [itcl::code $this AdjustSetting diffuse] |
---|
| 2206 | |
---|
| 2207 | label $inner.specularLevel_l -text "Specular" -font $fg |
---|
| 2208 | ::scale $inner.specularLevel -from 0 -to 100 -orient horizontal \ |
---|
| 2209 | -variable [itcl::scope _settings($this-specularLevel)] \ |
---|
| 2210 | -width 10 \ |
---|
| 2211 | -showvalue off -command [itcl::code $this AdjustSetting specularLevel] |
---|
| 2212 | |
---|
| 2213 | label $inner.specularExponent_l -text "Shininess" -font $fg |
---|
| 2214 | ::scale $inner.specularExponent -from 10 -to 128 -orient horizontal \ |
---|
| 2215 | -variable [itcl::scope _settings($this-specularExponent)] \ |
---|
| 2216 | -width 10 \ |
---|
| 2217 | -showvalue off -command [itcl::code $this AdjustSetting specularExponent] |
---|
| 2218 | |
---|
| 2219 | label $inner.clear -text "Clear" -font $fg |
---|
[1373] | 2220 | ::scale $inner.transp -from 0 -to 100 -orient horizontal \ |
---|
[1442] | 2221 | -variable [itcl::scope _settings($this-transp)] \ |
---|
[1694] | 2222 | -width 10 \ |
---|
[3396] | 2223 | -showvalue off -command [itcl::code $this AdjustSetting transp] |
---|
[1373] | 2224 | label $inner.opaque -text "Opaque" -font $fg |
---|
| 2225 | |
---|
| 2226 | label $inner.thin -text "Thin" -font $fg |
---|
| 2227 | ::scale $inner.thickness -from 0 -to 1000 -orient horizontal \ |
---|
[1442] | 2228 | -variable [itcl::scope _settings($this-thickness)] \ |
---|
[1694] | 2229 | -width 10 \ |
---|
[3396] | 2230 | -showvalue off -command [itcl::code $this AdjustSetting thickness] |
---|
[1373] | 2231 | label $inner.thick -text "Thick" -font $fg |
---|
| 2232 | |
---|
[3396] | 2233 | label $inner.colormap_l -text "Colormap" -font "Arial 9" |
---|
| 2234 | itk_component add colormap { |
---|
| 2235 | Rappture::Combobox $inner.colormap -width 10 -editable no |
---|
| 2236 | } |
---|
| 2237 | |
---|
| 2238 | $inner.colormap choices insert end \ |
---|
| 2239 | "BCGYR" "BCGYR" \ |
---|
| 2240 | "BGYOR" "BGYOR" \ |
---|
| 2241 | "blue" "blue" \ |
---|
| 2242 | "blue-to-brown" "blue-to-brown" \ |
---|
| 2243 | "blue-to-orange" "blue-to-orange" \ |
---|
| 2244 | "blue-to-grey" "blue-to-grey" \ |
---|
| 2245 | "green-to-magenta" "green-to-magenta" \ |
---|
| 2246 | "greyscale" "greyscale" \ |
---|
| 2247 | "nanohub" "nanohub" \ |
---|
| 2248 | "rainbow" "rainbow" \ |
---|
| 2249 | "spectral" "spectral" \ |
---|
| 2250 | "ROYGB" "ROYGB" \ |
---|
| 2251 | "RYGCB" "RYGCB" \ |
---|
| 2252 | "brown-to-blue" "brown-to-blue" \ |
---|
| 2253 | "grey-to-blue" "grey-to-blue" \ |
---|
| 2254 | "orange-to-blue" "orange-to-blue" \ |
---|
| 2255 | "none" "none" |
---|
| 2256 | |
---|
| 2257 | $itk_component(colormap) value "BCGYR" |
---|
| 2258 | bind $inner.colormap <<Value>> \ |
---|
| 2259 | [itcl::code $this AdjustSetting colormap] |
---|
| 2260 | |
---|
[1373] | 2261 | blt::table $inner \ |
---|
[3396] | 2262 | 0,0 $inner.vol -cspan 4 -anchor w -pady 2 \ |
---|
[3441] | 2263 | 1,0 $inner.shading -cspan 4 -anchor w -pady {10 2} \ |
---|
| 2264 | 2,0 $inner.light2side -cspan 4 -anchor w -pady 2 \ |
---|
[3915] | 2265 | 3,0 $inner.ambient_l -anchor e -pady 2 \ |
---|
| 2266 | 3,1 $inner.ambient -cspan 3 -pady 2 -fill x \ |
---|
| 2267 | 4,0 $inner.diffuse_l -anchor e -pady 2 \ |
---|
| 2268 | 4,1 $inner.diffuse -cspan 3 -pady 2 -fill x \ |
---|
| 2269 | 5,0 $inner.specularLevel_l -anchor e -pady 2 \ |
---|
| 2270 | 5,1 $inner.specularLevel -cspan 3 -pady 2 -fill x \ |
---|
| 2271 | 6,0 $inner.specularExponent_l -anchor e -pady 2 \ |
---|
| 2272 | 6,1 $inner.specularExponent -cspan 3 -pady 2 -fill x \ |
---|
| 2273 | 7,0 $inner.clear -anchor e -pady 2 \ |
---|
| 2274 | 7,1 $inner.transp -cspan 2 -pady 2 -fill x \ |
---|
| 2275 | 7,3 $inner.opaque -anchor w -pady 2 \ |
---|
| 2276 | 8,0 $inner.thin -anchor e -pady 2 \ |
---|
| 2277 | 8,1 $inner.thickness -cspan 2 -pady 2 -fill x \ |
---|
| 2278 | 8,3 $inner.thick -anchor w -pady 2 |
---|
[1491] | 2279 | |
---|
[1442] | 2280 | blt::table configure $inner c0 c1 c3 r* -resize none |
---|
[3915] | 2281 | blt::table configure $inner r9 -resize expand |
---|
[1373] | 2282 | } |
---|
| 2283 | |
---|
| 2284 | itcl::body Rappture::FlowvisViewer::BuildCutplanesTab {} { |
---|
[1375] | 2285 | set inner [$itk_component(main) insert end \ |
---|
| 2286 | -title "Cutplane Settings" \ |
---|
| 2287 | -icon [Rappture::icon cutbutton]] |
---|
| 2288 | $inner configure -borderwidth 4 |
---|
[1373] | 2289 | |
---|
[1349] | 2290 | # X-value slicer... |
---|
| 2291 | itk_component add xCutButton { |
---|
[1442] | 2292 | Rappture::PushButton $inner.xbutton \ |
---|
[1694] | 2293 | -onimage [Rappture::icon x-cutplane] \ |
---|
| 2294 | -offimage [Rappture::icon x-cutplane] \ |
---|
[3396] | 2295 | -command [itcl::code $this AdjustSetting xcutplane] \ |
---|
[1694] | 2296 | -variable [itcl::scope _settings($this-xcutplane)] |
---|
[1349] | 2297 | } |
---|
| 2298 | Rappture::Tooltip::for $itk_component(xCutButton) \ |
---|
| 2299 | "Toggle the X cut plane on/off" |
---|
[3899] | 2300 | $itk_component(xCutButton) select |
---|
[1349] | 2301 | |
---|
| 2302 | itk_component add xCutScale { |
---|
[1375] | 2303 | ::scale $inner.xval -from 100 -to 0 \ |
---|
[1349] | 2304 | -width 10 -orient vertical -showvalue off \ |
---|
[1376] | 2305 | -borderwidth 1 -highlightthickness 0 \ |
---|
[1442] | 2306 | -command [itcl::code $this Slice move x] \ |
---|
[1694] | 2307 | -variable [itcl::scope _settings($this-xcutposition)] |
---|
[1349] | 2308 | } { |
---|
| 2309 | usual |
---|
[1375] | 2310 | ignore -borderwidth -highlightthickness |
---|
[1349] | 2311 | } |
---|
[1376] | 2312 | # Set the default cutplane value before disabling the scale. |
---|
[1349] | 2313 | $itk_component(xCutScale) set 50 |
---|
[1376] | 2314 | $itk_component(xCutScale) configure -state disabled |
---|
[1349] | 2315 | Rappture::Tooltip::for $itk_component(xCutScale) \ |
---|
| 2316 | "@[itcl::code $this SlicerTip x]" |
---|
| 2317 | |
---|
| 2318 | # Y-value slicer... |
---|
| 2319 | itk_component add yCutButton { |
---|
[1442] | 2320 | Rappture::PushButton $inner.ybutton \ |
---|
[1694] | 2321 | -onimage [Rappture::icon y-cutplane] \ |
---|
| 2322 | -offimage [Rappture::icon y-cutplane] \ |
---|
[3396] | 2323 | -command [itcl::code $this AdjustSetting ycutplane] \ |
---|
[1694] | 2324 | -variable [itcl::scope _settings($this-ycutplane)] |
---|
[1349] | 2325 | } |
---|
| 2326 | Rappture::Tooltip::for $itk_component(yCutButton) \ |
---|
| 2327 | "Toggle the Y cut plane on/off" |
---|
[3899] | 2328 | $itk_component(yCutButton) select |
---|
[1349] | 2329 | |
---|
| 2330 | itk_component add yCutScale { |
---|
[1375] | 2331 | ::scale $inner.yval -from 100 -to 0 \ |
---|
[1349] | 2332 | -width 10 -orient vertical -showvalue off \ |
---|
[1376] | 2333 | -borderwidth 1 -highlightthickness 0 \ |
---|
[1442] | 2334 | -command [itcl::code $this Slice move y] \ |
---|
[1694] | 2335 | -variable [itcl::scope _settings($this-ycutposition)] |
---|
[1349] | 2336 | } { |
---|
| 2337 | usual |
---|
[1375] | 2338 | ignore -borderwidth -highlightthickness |
---|
[1349] | 2339 | } |
---|
| 2340 | Rappture::Tooltip::for $itk_component(yCutScale) \ |
---|
| 2341 | "@[itcl::code $this SlicerTip y]" |
---|
[1376] | 2342 | # Set the default cutplane value before disabling the scale. |
---|
[1373] | 2343 | $itk_component(yCutScale) set 50 |
---|
[1376] | 2344 | $itk_component(yCutScale) configure -state disabled |
---|
[1349] | 2345 | |
---|
| 2346 | # Z-value slicer... |
---|
| 2347 | itk_component add zCutButton { |
---|
[1442] | 2348 | Rappture::PushButton $inner.zbutton \ |
---|
[1694] | 2349 | -onimage [Rappture::icon z-cutplane] \ |
---|
| 2350 | -offimage [Rappture::icon z-cutplane] \ |
---|
[3396] | 2351 | -command [itcl::code $this AdjustSetting zcutplane] \ |
---|
[1694] | 2352 | -variable [itcl::scope _settings($this-zcutplane)] |
---|
[1349] | 2353 | } |
---|
| 2354 | Rappture::Tooltip::for $itk_component(zCutButton) \ |
---|
| 2355 | "Toggle the Z cut plane on/off" |
---|
[3899] | 2356 | $itk_component(zCutButton) select |
---|
[1349] | 2357 | |
---|
| 2358 | itk_component add zCutScale { |
---|
[1375] | 2359 | ::scale $inner.zval -from 100 -to 0 \ |
---|
[1349] | 2360 | -width 10 -orient vertical -showvalue off \ |
---|
[1376] | 2361 | -borderwidth 1 -highlightthickness 0 \ |
---|
[1442] | 2362 | -command [itcl::code $this Slice move z] \ |
---|
[1694] | 2363 | -variable [itcl::scope _settings($this-zcutposition)] |
---|
[1349] | 2364 | } { |
---|
| 2365 | usual |
---|
[1375] | 2366 | ignore -borderwidth -highlightthickness |
---|
[1349] | 2367 | } |
---|
| 2368 | $itk_component(zCutScale) set 50 |
---|
[1376] | 2369 | $itk_component(zCutScale) configure -state disabled |
---|
[1349] | 2370 | #$itk_component(zCutScale) configure -state disabled |
---|
| 2371 | Rappture::Tooltip::for $itk_component(zCutScale) \ |
---|
| 2372 | "@[itcl::code $this SlicerTip z]" |
---|
| 2373 | |
---|
| 2374 | blt::table $inner \ |
---|
[1694] | 2375 | 1,1 $itk_component(xCutButton) \ |
---|
| 2376 | 1,2 $itk_component(yCutButton) \ |
---|
| 2377 | 1,3 $itk_component(zCutButton) \ |
---|
| 2378 | 0,1 $itk_component(xCutScale) \ |
---|
| 2379 | 0,2 $itk_component(yCutScale) \ |
---|
| 2380 | 0,3 $itk_component(zCutScale) \ |
---|
[1375] | 2381 | |
---|
[1376] | 2382 | blt::table configure $inner r0 r1 c* -resize none |
---|
| 2383 | blt::table configure $inner r2 c4 -resize expand |
---|
| 2384 | blt::table configure $inner c0 -width 2 |
---|
| 2385 | blt::table configure $inner c1 c2 c3 -padx 2 |
---|
[1349] | 2386 | } |
---|
| 2387 | |
---|
[1373] | 2388 | itcl::body Rappture::FlowvisViewer::BuildCameraTab {} { |
---|
[1375] | 2389 | set inner [$itk_component(main) insert end \ |
---|
| 2390 | -title "Camera Settings" \ |
---|
| 2391 | -icon [Rappture::icon camera]] |
---|
| 2392 | $inner configure -borderwidth 4 |
---|
[1349] | 2393 | |
---|
[3533] | 2394 | label $inner.view_l -text "view" -font "Arial 9" |
---|
| 2395 | set f [frame $inner.view] |
---|
| 2396 | foreach side { front back left right top bottom } { |
---|
| 2397 | button $f.$side -image [Rappture::icon view$side] \ |
---|
| 2398 | -command [itcl::code $this SetOrientation $side] |
---|
| 2399 | Rappture::Tooltip::for $f.$side "Change the view to $side" |
---|
| 2400 | pack $f.$side -side left |
---|
[3492] | 2401 | } |
---|
[3533] | 2402 | |
---|
[3492] | 2403 | blt::table $inner \ |
---|
[3533] | 2404 | 0,0 $inner.view_l -anchor e -pady 2 \ |
---|
| 2405 | 0,1 $inner.view -anchor w -pady 2 |
---|
[3492] | 2406 | |
---|
[3533] | 2407 | set row 1 |
---|
| 2408 | set labels { qw qx qy qz xpan ypan zoom } |
---|
[1349] | 2409 | foreach tag $labels { |
---|
[1694] | 2410 | label $inner.${tag}label -text $tag -font "Arial 9" |
---|
| 2411 | entry $inner.${tag} -font "Arial 9" -bg white \ |
---|
| 2412 | -textvariable [itcl::scope _settings($this-$tag)] |
---|
| 2413 | bind $inner.${tag} <KeyPress-Return> \ |
---|
| 2414 | [itcl::code $this camera set ${tag}] |
---|
| 2415 | blt::table $inner \ |
---|
| 2416 | $row,0 $inner.${tag}label -anchor e -pady 2 \ |
---|
| 2417 | $row,1 $inner.${tag} -anchor w -pady 2 |
---|
[1375] | 2418 | blt::table configure $inner r$row -resize none |
---|
[1694] | 2419 | incr row |
---|
[1349] | 2420 | } |
---|
[3533] | 2421 | |
---|
| 2422 | blt::table configure $inner c* r* -resize none |
---|
[1373] | 2423 | blt::table configure $inner c2 -resize expand |
---|
[1375] | 2424 | blt::table configure $inner r$row -resize expand |
---|
[1349] | 2425 | } |
---|
| 2426 | |
---|
[1442] | 2427 | itcl::body Rappture::FlowvisViewer::GetFlowInfo { w } { |
---|
[1444] | 2428 | set flowobj "" |
---|
[1442] | 2429 | foreach key [array names _obj2flow] { |
---|
[1694] | 2430 | set flowobj $_obj2flow($key) |
---|
| 2431 | break |
---|
[1442] | 2432 | } |
---|
[1444] | 2433 | if { $flowobj == "" } { |
---|
[1694] | 2434 | return |
---|
[1444] | 2435 | } |
---|
[1442] | 2436 | if { [winfo exists $w.frame] } { |
---|
[1694] | 2437 | destroy $w.frame |
---|
[1442] | 2438 | } |
---|
| 2439 | set inner [frame $w.frame] |
---|
| 2440 | blt::table $w \ |
---|
[3441] | 2441 | 5,0 $inner -fill both -cspan 2 -anchor nw |
---|
[1442] | 2442 | array set hints [$flowobj hints] |
---|
| 2443 | checkbutton $inner.showstreams -text "Streams Plane" \ |
---|
[1694] | 2444 | -variable [itcl::scope _settings($this-streams)] \ |
---|
| 2445 | -command [itcl::code $this streams $key $hints(name)] \ |
---|
| 2446 | -font "Arial 9" |
---|
[1449] | 2447 | Rappture::Tooltip::for $inner.showstreams $hints(description) |
---|
[1491] | 2448 | |
---|
| 2449 | checkbutton $inner.showarrows -text "Arrows" \ |
---|
[1694] | 2450 | -variable [itcl::scope _settings($this-arrows)] \ |
---|
| 2451 | -command [itcl::code $this arrows $key $hints(name)] \ |
---|
| 2452 | -font "Arial 9" |
---|
[1491] | 2453 | |
---|
[1694] | 2454 | label $inner.particles -text "Particles" -font "Arial 9 bold" |
---|
| 2455 | label $inner.boxes -text "Boxes" -font "Arial 9 bold" |
---|
[1442] | 2456 | |
---|
| 2457 | blt::table $inner \ |
---|
[1694] | 2458 | 1,0 $inner.showstreams -anchor w \ |
---|
| 2459 | 2,0 $inner.showarrows -anchor w |
---|
[1491] | 2460 | blt::table configure $inner c0 c1 -resize none |
---|
| 2461 | blt::table configure $inner c2 -resize expand |
---|
[1442] | 2462 | |
---|
[1491] | 2463 | set row 3 |
---|
[1442] | 2464 | set particles [$flowobj particles] |
---|
| 2465 | if { [llength $particles] > 0 } { |
---|
[1694] | 2466 | blt::table $inner $row,0 $inner.particles -anchor w |
---|
| 2467 | incr row |
---|
[1442] | 2468 | } |
---|
| 2469 | foreach part $particles { |
---|
[1694] | 2470 | array unset info |
---|
| 2471 | array set info $part |
---|
| 2472 | set name $info(name) |
---|
| 2473 | if { ![info exists _settings($this-particles-$name)] } { |
---|
| 2474 | set _settings($this-particles-$name) $info(hide) |
---|
| 2475 | } |
---|
| 2476 | checkbutton $inner.part$row -text $info(label) \ |
---|
| 2477 | -variable [itcl::scope _settings($this-particles-$name)] \ |
---|
| 2478 | -onvalue 0 -offvalue 1 \ |
---|
| 2479 | -command [itcl::code $this particles $key $name] \ |
---|
| 2480 | -font "Arial 9" |
---|
| 2481 | Rappture::Tooltip::for $inner.part$row $info(description) |
---|
| 2482 | blt::table $inner $row,0 $inner.part$row -anchor w |
---|
| 2483 | if { !$_settings($this-particles-$name) } { |
---|
| 2484 | $inner.part$row select |
---|
| 2485 | } |
---|
| 2486 | incr row |
---|
[1442] | 2487 | } |
---|
| 2488 | set boxes [$flowobj boxes] |
---|
| 2489 | if { [llength $boxes] > 0 } { |
---|
[1694] | 2490 | blt::table $inner $row,0 $inner.boxes -anchor w |
---|
| 2491 | incr row |
---|
[1442] | 2492 | } |
---|
| 2493 | foreach box $boxes { |
---|
[1694] | 2494 | array unset info |
---|
| 2495 | array set info $box |
---|
| 2496 | set name $info(name) |
---|
| 2497 | if { ![info exists _settings($this-box-$name)] } { |
---|
| 2498 | set _settings($this-box-$name) $info(hide) |
---|
| 2499 | } |
---|
| 2500 | checkbutton $inner.box$row -text $info(label) \ |
---|
| 2501 | -variable [itcl::scope _settings($this-box-$name)] \ |
---|
| 2502 | -onvalue 0 -offvalue 1 \ |
---|
| 2503 | -command [itcl::code $this box $key $name] \ |
---|
| 2504 | -font "Arial 9" |
---|
| 2505 | Rappture::Tooltip::for $inner.box$row $info(description) |
---|
| 2506 | blt::table $inner $row,0 $inner.box$row -anchor w |
---|
| 2507 | if { !$_settings($this-box-$name) } { |
---|
| 2508 | $inner.box$row select |
---|
| 2509 | } |
---|
| 2510 | incr row |
---|
[1442] | 2511 | } |
---|
| 2512 | blt::table configure $inner r* -resize none |
---|
| 2513 | blt::table configure $inner r$row -resize expand |
---|
| 2514 | blt::table configure $inner c3 -resize expand |
---|
| 2515 | event generate [winfo parent [winfo parent $w]] <Configure> |
---|
| 2516 | } |
---|
| 2517 | |
---|
| 2518 | itcl::body Rappture::FlowvisViewer::particles { tag name } { |
---|
| 2519 | set bool $_settings($this-particles-$name) |
---|
[1448] | 2520 | SendCmd "$tag particles configure {$name} -hide $bool" |
---|
[1442] | 2521 | } |
---|
| 2522 | |
---|
| 2523 | itcl::body Rappture::FlowvisViewer::box { tag name } { |
---|
| 2524 | set bool $_settings($this-box-$name) |
---|
[1448] | 2525 | SendCmd "$tag box configure {$name} -hide $bool" |
---|
[1442] | 2526 | } |
---|
| 2527 | |
---|
| 2528 | itcl::body Rappture::FlowvisViewer::streams { tag name } { |
---|
| 2529 | set bool $_settings($this-streams) |
---|
| 2530 | SendCmd "$tag configure -slice $bool" |
---|
| 2531 | } |
---|
| 2532 | |
---|
[1491] | 2533 | itcl::body Rappture::FlowvisViewer::arrows { tag name } { |
---|
| 2534 | set bool $_settings($this-arrows) |
---|
[2965] | 2535 | SendCmd "$tag configure -arrows $bool" |
---|
[1491] | 2536 | } |
---|
| 2537 | |
---|
[1442] | 2538 | # ---------------------------------------------------------------------- |
---|
| 2539 | # USAGE: Slice move x|y|z <newval> |
---|
| 2540 | # |
---|
| 2541 | # Called automatically when the user drags the slider to move the |
---|
| 2542 | # cut plane that slices 3D data. Gets the current value from the |
---|
| 2543 | # slider and moves the cut plane to the appropriate point in the |
---|
| 2544 | # data set. |
---|
| 2545 | # ---------------------------------------------------------------------- |
---|
| 2546 | itcl::body Rappture::FlowvisViewer::Slice {option args} { |
---|
| 2547 | switch -- $option { |
---|
| 2548 | move { |
---|
| 2549 | if {[llength $args] != 2} { |
---|
| 2550 | error "wrong # args: should be \"Slice move x|y|z newval\"" |
---|
| 2551 | } |
---|
| 2552 | set axis [lindex $args 0] |
---|
| 2553 | set newval [lindex $args 1] |
---|
| 2554 | set newpos [expr {0.01*$newval}] |
---|
| 2555 | |
---|
| 2556 | # show the current value in the readout |
---|
| 2557 | |
---|
| 2558 | set ids [CurrentVolumeIds -cutplanes] |
---|
| 2559 | SendCmd "cutplane position $newpos $axis $ids" |
---|
| 2560 | } |
---|
| 2561 | default { |
---|
| 2562 | error "bad option \"$option\": should be axis, move, or volume" |
---|
| 2563 | } |
---|
| 2564 | } |
---|
| 2565 | } |
---|
| 2566 | |
---|
| 2567 | # ---------------------------------------------------------------------- |
---|
| 2568 | # USAGE: SlicerTip <axis> |
---|
| 2569 | # |
---|
| 2570 | # Used internally to generate a tooltip for the x/y/z slicer controls. |
---|
| 2571 | # Returns a message that includes the current slicer value. |
---|
| 2572 | # ---------------------------------------------------------------------- |
---|
| 2573 | itcl::body Rappture::FlowvisViewer::SlicerTip {axis} { |
---|
| 2574 | set val [$itk_component(${axis}CutScale) get] |
---|
| 2575 | return "Move the [string toupper $axis] cut plane.\nCurrently: $axis = $val%" |
---|
| 2576 | } |
---|
| 2577 | |
---|
[1491] | 2578 | itcl::body Rappture::FlowvisViewer::Resize {} { |
---|
[3396] | 2579 | $_arcball resize $_width $_height |
---|
[3478] | 2580 | SendCmd "screen size $_width $_height" |
---|
[1448] | 2581 | set _resizePending 0 |
---|
[1442] | 2582 | } |
---|
| 2583 | |
---|
| 2584 | itcl::body Rappture::FlowvisViewer::EventuallyResize { w h } { |
---|
[1448] | 2585 | set _width $w |
---|
| 2586 | set _height $h |
---|
[3362] | 2587 | $_arcball resize $w $h |
---|
[1448] | 2588 | if { !$_resizePending } { |
---|
[1694] | 2589 | $_dispatcher event -after 200 !resize |
---|
| 2590 | set _resizePending 1 |
---|
[1442] | 2591 | } |
---|
| 2592 | } |
---|
| 2593 | |
---|
| 2594 | itcl::body Rappture::FlowvisViewer::EventuallyResizeLegend {} { |
---|
[1448] | 2595 | if { !$_resizeLegendPending } { |
---|
[1694] | 2596 | $_dispatcher event -after 100 !legend |
---|
| 2597 | set _resizeLegendPending 1 |
---|
[1448] | 2598 | } |
---|
[1442] | 2599 | } |
---|
| 2600 | |
---|
[1471] | 2601 | itcl::body Rappture::FlowvisViewer::EventuallyGoto { nSteps } { |
---|
| 2602 | set _flow(goto) $nSteps |
---|
| 2603 | if { !$_gotoPending } { |
---|
[1694] | 2604 | $_dispatcher event -after 1000 !goto |
---|
| 2605 | set _gotoPending 1 |
---|
[1471] | 2606 | } |
---|
| 2607 | } |
---|
| 2608 | |
---|
[1349] | 2609 | # camera -- |
---|
| 2610 | itcl::body Rappture::FlowvisViewer::camera {option args} { |
---|
| 2611 | switch -- $option { |
---|
[1694] | 2612 | "show" { |
---|
| 2613 | puts [array get _view] |
---|
| 2614 | } |
---|
| 2615 | "set" { |
---|
| 2616 | set who [lindex $args 0] |
---|
| 2617 | set x $_settings($this-$who) |
---|
| 2618 | set code [catch { string is double $x } result] |
---|
| 2619 | if { $code != 0 || !$result } { |
---|
| 2620 | set _settings($this-$who) $_view($who) |
---|
| 2621 | return |
---|
| 2622 | } |
---|
| 2623 | switch -- $who { |
---|
[3533] | 2624 | "xpan" - "ypan" { |
---|
[1694] | 2625 | set _view($who) $_settings($this-$who) |
---|
| 2626 | PanCamera |
---|
| 2627 | } |
---|
[3362] | 2628 | "qx" - "qy" - "qz" - "qw" { |
---|
[3492] | 2629 | set _view($who) $_settings($this-$who) |
---|
[3362] | 2630 | set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] |
---|
| 2631 | $_arcball quaternion $q |
---|
| 2632 | SendCmd "camera orient $q" |
---|
| 2633 | } |
---|
[1694] | 2634 | "zoom" { |
---|
| 2635 | set _view($who) $_settings($this-$who) |
---|
| 2636 | SendCmd "camera zoom $_view(zoom)" |
---|
| 2637 | } |
---|
| 2638 | } |
---|
| 2639 | } |
---|
[1349] | 2640 | } |
---|
| 2641 | } |
---|
[1355] | 2642 | |
---|
[1442] | 2643 | itcl::body Rappture::FlowvisViewer::FlowCmd { dataobj comp nbytes extents } { |
---|
| 2644 | set tag "$dataobj-$comp" |
---|
| 2645 | if { ![info exists _obj2flow($tag)] } { |
---|
[1694] | 2646 | append cmd "flow add $tag\n" |
---|
| 2647 | append cmd "$tag data follows $nbytes $extents\n" |
---|
| 2648 | return $cmd |
---|
[1442] | 2649 | } |
---|
| 2650 | set flowobj $_obj2flow($tag) |
---|
| 2651 | if { $flowobj == "" } { |
---|
[1694] | 2652 | puts stderr "no flowobj" |
---|
| 2653 | return "" |
---|
[1442] | 2654 | } |
---|
| 2655 | set cmd {} |
---|
| 2656 | append cmd "if {\[flow exists $tag\]} {flow delete $tag}\n" |
---|
| 2657 | array set info [$flowobj hints] |
---|
[1496] | 2658 | set _settings($this-volume) $info(volume) |
---|
| 2659 | set _settings($this-outline) $info(outline) |
---|
| 2660 | set _settings($this-arrows) $info(arrows) |
---|
| 2661 | set _settings($this-duration) $info(duration) |
---|
| 2662 | $itk_component(speed) value $info(speed) |
---|
[1514] | 2663 | append cmd "flow add $tag" |
---|
| 2664 | append cmd " -position $info(position)" |
---|
| 2665 | append cmd " -axis $info(axis)" |
---|
| 2666 | append cmd " -volume $info(volume)" |
---|
| 2667 | append cmd " -outline $info(outline)" |
---|
| 2668 | append cmd " -slice $info(streams)" |
---|
| 2669 | append cmd " -arrows $info(arrows)\n" |
---|
[1442] | 2670 | foreach part [$flowobj particles] { |
---|
[1694] | 2671 | array unset info |
---|
| 2672 | array set info $part |
---|
| 2673 | set color [Color2RGB $info(color)] |
---|
| 2674 | append cmd "$tag particles add $info(name)" |
---|
| 2675 | append cmd " -position $info(position)" |
---|
| 2676 | append cmd " -hide $info(hide)" |
---|
| 2677 | append cmd " -axis $info(axis)" |
---|
| 2678 | append cmd " -color {$color}" |
---|
| 2679 | append cmd " -size $info(size)\n" |
---|
[1442] | 2680 | } |
---|
| 2681 | foreach box [$flowobj boxes] { |
---|
[1694] | 2682 | array unset info |
---|
| 2683 | set info(corner1) "" |
---|
| 2684 | set info(corner2) "" |
---|
| 2685 | array set info $box |
---|
| 2686 | if { $info(corner1) == "" || $info(corner2) == "" } { |
---|
| 2687 | continue |
---|
| 2688 | } |
---|
| 2689 | set color [Color2RGB $info(color)] |
---|
| 2690 | append cmd "$tag box add $info(name)" |
---|
[1514] | 2691 | append cmd " -color {$color}" |
---|
[1694] | 2692 | append cmd " -hide $info(hide)" |
---|
[1514] | 2693 | append cmd " -linewidth $info(linewidth) " |
---|
[1694] | 2694 | append cmd " -corner1 {$info(corner1)} " |
---|
[2547] | 2695 | append cmd " -corner2 {$info(corner2)}\n" |
---|
[1442] | 2696 | } |
---|
| 2697 | append cmd "$tag data follows $nbytes $extents\n" |
---|
| 2698 | return $cmd |
---|
| 2699 | } |
---|
| 2700 | |
---|
| 2701 | |
---|
| 2702 | # |
---|
| 2703 | # flow -- |
---|
| 2704 | # |
---|
| 2705 | # Called when the user clicks on the stop or play buttons |
---|
| 2706 | # for flow visualization. |
---|
| 2707 | # |
---|
[1694] | 2708 | # $this flow play |
---|
| 2709 | # $this flow stop |
---|
| 2710 | # $this flow toggle |
---|
| 2711 | # $this flow reset |
---|
| 2712 | # $this flow pause |
---|
| 2713 | # $this flow next |
---|
[1442] | 2714 | # |
---|
[1448] | 2715 | itcl::body Rappture::FlowvisViewer::flow { args } { |
---|
| 2716 | set option [lindex $args 0] |
---|
[1442] | 2717 | switch -- $option { |
---|
[1694] | 2718 | "goto2" { |
---|
| 2719 | puts stderr "actually sending \"flow goto $_flow(goto)\"" |
---|
| 2720 | SendCmd "flow goto $_flow(goto)" |
---|
| 2721 | set _gotoPending 0 |
---|
| 2722 | } |
---|
| 2723 | "goto" { |
---|
| 2724 | puts stderr "flow goto to $_settings($this-currenttime)" |
---|
| 2725 | # Figure out how many steps to the current time based upon |
---|
| 2726 | # the speed and duration. |
---|
| 2727 | set current $_settings($this-currenttime) |
---|
| 2728 | set speed [$itk_component(speed) value] |
---|
| 2729 | set time [str2millisecs $_settings($this-duration)] |
---|
| 2730 | $itk_component(dial) configure -max $time |
---|
| 2731 | set delay [expr int(round(500.0/$speed))] |
---|
| 2732 | set timePerStep [expr {double($time) / $delay}] |
---|
| 2733 | set nSteps [expr {int(ceil($current/$timePerStep))}] |
---|
| 2734 | EventuallyGoto $nSteps |
---|
| 2735 | } |
---|
| 2736 | "speed" { |
---|
| 2737 | set speed [$itk_component(speed) value] |
---|
| 2738 | set _flow(delay) [expr int(round(500.0/$speed))] |
---|
| 2739 | } |
---|
| 2740 | "duration" { |
---|
| 2741 | set max [str2millisecs $_settings($this-duration)] |
---|
| 2742 | if { $max < 0 } { |
---|
| 2743 | bell |
---|
| 2744 | return |
---|
| 2745 | } |
---|
| 2746 | set _flow(duration) $max |
---|
| 2747 | set _settings($this-duration) [millisecs2str $max] |
---|
| 2748 | $itk_component(dial) configure -max $max |
---|
| 2749 | } |
---|
| 2750 | "off" { |
---|
| 2751 | set _flow(state) 0 |
---|
| 2752 | $_dispatcher cancel !play |
---|
| 2753 | $itk_component(play) deselect |
---|
| 2754 | } |
---|
| 2755 | "on" { |
---|
| 2756 | flow speed |
---|
| 2757 | flow duration |
---|
| 2758 | set _flow(state) 1 |
---|
| 2759 | set _settings($this-currenttime) 0 |
---|
| 2760 | $itk_component(play) select |
---|
| 2761 | } |
---|
| 2762 | "stop" { |
---|
| 2763 | if { $_flow(state) } { |
---|
| 2764 | flow off |
---|
| 2765 | flow reset |
---|
| 2766 | } |
---|
| 2767 | } |
---|
| 2768 | "pause" { |
---|
| 2769 | if { $_flow(state) } { |
---|
| 2770 | flow off |
---|
| 2771 | } |
---|
| 2772 | } |
---|
| 2773 | "play" { |
---|
| 2774 | # If the flow is currently off, then restart it. |
---|
| 2775 | if { !$_flow(state) } { |
---|
| 2776 | flow on |
---|
| 2777 | # If we're at the end of the flow, reset the flow. |
---|
| 2778 | set _settings($this-currenttime) \ |
---|
| 2779 | [expr {$_settings($this-currenttime) + $_flow(delay)}] |
---|
| 2780 | if { $_settings($this-currenttime) >= $_flow(duration) } { |
---|
| 2781 | set _settings($this-step) 1 |
---|
| 2782 | SendCmd "flow reset" |
---|
| 2783 | } |
---|
| 2784 | flow next |
---|
| 2785 | } |
---|
| 2786 | } |
---|
| 2787 | "toggle" { |
---|
| 2788 | if { $_settings($this-play) } { |
---|
| 2789 | flow play |
---|
| 2790 | } else { |
---|
| 2791 | flow pause |
---|
| 2792 | } |
---|
| 2793 | } |
---|
| 2794 | "reset" { |
---|
| 2795 | set _settings($this-currenttime) 0 |
---|
| 2796 | SendCmd "flow reset" |
---|
| 2797 | } |
---|
| 2798 | "next" { |
---|
[1929] | 2799 | if { ![winfo viewable $itk_component(3dview)] } { |
---|
[1694] | 2800 | flow stop |
---|
| 2801 | return |
---|
| 2802 | } |
---|
| 2803 | set _settings($this-currenttime) \ |
---|
| 2804 | [expr {$_settings($this-currenttime) + $_flow(delay)}] |
---|
| 2805 | if { $_settings($this-currenttime) >= $_flow(duration) } { |
---|
| 2806 | if { !$_settings($this-loop) } { |
---|
| 2807 | flow off |
---|
| 2808 | return |
---|
| 2809 | } |
---|
| 2810 | flow reset |
---|
| 2811 | } else { |
---|
| 2812 | SendCmd "flow next" |
---|
| 2813 | } |
---|
| 2814 | $_dispatcher event -after $_flow(delay) !play |
---|
| 2815 | } |
---|
| 2816 | default { |
---|
| 2817 | error "bad option \"$option\": should be play, stop, toggle, or reset." |
---|
| 2818 | } |
---|
[1442] | 2819 | } |
---|
| 2820 | } |
---|
| 2821 | |
---|
[1355] | 2822 | itcl::body Rappture::FlowvisViewer::WaitIcon { option widget } { |
---|
| 2823 | switch -- $option { |
---|
[1694] | 2824 | "start" { |
---|
| 2825 | $_dispatcher dispatch $this !waiticon \ |
---|
| 2826 | "[itcl::code $this WaitIcon "next" $widget] ; list" |
---|
| 2827 | set _icon 0 |
---|
| 2828 | $widget configure -image [Rappture::icon bigroller${_icon}] |
---|
| 2829 | $_dispatcher event -after 100 !waiticon |
---|
| 2830 | } |
---|
| 2831 | "next" { |
---|
| 2832 | incr _icon |
---|
| 2833 | if { $_icon >= 8 } { |
---|
| 2834 | set _icon 0 |
---|
| 2835 | } |
---|
| 2836 | $widget configure -image [Rappture::icon bigroller${_icon}] |
---|
| 2837 | $_dispatcher event -after 100 !waiticon |
---|
| 2838 | } |
---|
| 2839 | "stop" { |
---|
| 2840 | $_dispatcher cancel !waiticon |
---|
| 2841 | } |
---|
[1355] | 2842 | } |
---|
| 2843 | } |
---|
| 2844 | |
---|
[1506] | 2845 | itcl::body Rappture::FlowvisViewer::GetPngImage { widget width height } { |
---|
[1498] | 2846 | set token "print[incr _nextToken]" |
---|
[1506] | 2847 | set var ::Rappture::FlowvisViewer::_hardcopy($this-$token) |
---|
[1498] | 2848 | set $var "" |
---|
| 2849 | |
---|
| 2850 | # Setup an automatic timeout procedure. |
---|
| 2851 | $_dispatcher dispatch $this !pngtimeout "set $var {} ; list" |
---|
| 2852 | |
---|
[1506] | 2853 | set popup .flowvisviewerprint |
---|
[1498] | 2854 | if {![winfo exists $popup]} { |
---|
[1694] | 2855 | Rappture::Balloon $popup -title "Generating file..." |
---|
| 2856 | set inner [$popup component inner] |
---|
| 2857 | label $inner.title -text "Generating hardcopy." -font "Arial 10 bold" |
---|
| 2858 | label $inner.please -text "This may take a minute." -font "Arial 10" |
---|
| 2859 | label $inner.icon -image [Rappture::icon bigroller0] |
---|
| 2860 | button $inner.cancel -text "Cancel" -font "Arial 10 bold" \ |
---|
| 2861 | -command [list set $var ""] |
---|
| 2862 | blt::table $inner \ |
---|
[3441] | 2863 | 0,0 $inner.title -cspan 2 \ |
---|
[1694] | 2864 | 1,0 $inner.please -anchor w \ |
---|
| 2865 | 1,1 $inner.icon -anchor e \ |
---|
[3441] | 2866 | 2,0 $inner.cancel -cspan 2 |
---|
[1694] | 2867 | blt::table configure $inner r0 -pady 4 |
---|
| 2868 | blt::table configure $inner r2 -pady 4 |
---|
| 2869 | bind $inner.cancel <KeyPress-Return> [list $inner.cancel invoke] |
---|
[1498] | 2870 | } else { |
---|
[1694] | 2871 | set inner [$popup component inner] |
---|
[1498] | 2872 | } |
---|
| 2873 | |
---|
| 2874 | $_dispatcher event -after 60000 !pngtimeout |
---|
| 2875 | WaitIcon start $inner.icon |
---|
[2606] | 2876 | grab set $inner |
---|
[1498] | 2877 | focus $inner.cancel |
---|
| 2878 | |
---|
| 2879 | SendCmd "print $token $width $height" |
---|
| 2880 | |
---|
| 2881 | $popup activate $widget below |
---|
[3555] | 2882 | update idletasks |
---|
[1498] | 2883 | update |
---|
| 2884 | # We wait here for either |
---|
| 2885 | # 1) the png to be delivered or |
---|
| 2886 | # 2) timeout or |
---|
| 2887 | # 3) user cancels the operation. |
---|
| 2888 | tkwait variable $var |
---|
| 2889 | |
---|
| 2890 | # Clean up. |
---|
| 2891 | $_dispatcher cancel !pngtimeout |
---|
| 2892 | WaitIcon stop $inner.icon |
---|
| 2893 | grab release $inner |
---|
| 2894 | $popup deactivate |
---|
| 2895 | update |
---|
| 2896 | |
---|
| 2897 | if { $_hardcopy($this-$token) != "" } { |
---|
[1694] | 2898 | return [list .png $_hardcopy($this-$token)] |
---|
[1498] | 2899 | } |
---|
| 2900 | return "" |
---|
| 2901 | } |
---|
| 2902 | |
---|
[1514] | 2903 | itcl::body Rappture::FlowvisViewer::GetMovie { widget w h } { |
---|
[1442] | 2904 | set token "movie[incr _nextToken]" |
---|
[1506] | 2905 | set var ::Rappture::FlowvisViewer::_hardcopy($this-$token) |
---|
[1355] | 2906 | set $var "" |
---|
| 2907 | |
---|
| 2908 | # Setup an automatic timeout procedure. |
---|
| 2909 | $_dispatcher dispatch $this !movietimeout "set $var {} ; list" |
---|
[1498] | 2910 | set popup .flowvisviewermovie |
---|
| 2911 | if {![winfo exists $popup]} { |
---|
[1694] | 2912 | Rappture::Balloon $popup -title "Generating movie..." |
---|
| 2913 | set inner [$popup component inner] |
---|
| 2914 | label $inner.title -text "Generating movie for download" \ |
---|
| 2915 | -font "Arial 10 bold" |
---|
| 2916 | label $inner.please -text "This may take a few minutes." \ |
---|
| 2917 | -font "Arial 10" |
---|
| 2918 | label $inner.icon -image [Rappture::icon bigroller0] |
---|
| 2919 | button $inner.cancel -text "Cancel" -font "Arial 10 bold" \ |
---|
| 2920 | -command [list set $var ""] |
---|
| 2921 | blt::table $inner \ |
---|
[3441] | 2922 | 0,0 $inner.title -cspan 2 \ |
---|
[1694] | 2923 | 1,0 $inner.please -anchor w \ |
---|
| 2924 | 1,1 $inner.icon -anchor e \ |
---|
[3441] | 2925 | 2,0 $inner.cancel -cspan 2 |
---|
[1694] | 2926 | blt::table configure $inner r0 -pady 4 |
---|
| 2927 | blt::table configure $inner r2 -pady 4 |
---|
| 2928 | bind $inner.cancel <KeyPress-Return> [list $inner.cancel invoke] |
---|
[1498] | 2929 | } else { |
---|
[1694] | 2930 | set inner [$popup component inner] |
---|
[1498] | 2931 | } |
---|
[3555] | 2932 | update |
---|
[1514] | 2933 | # Timeout is set to 10 minutes. |
---|
| 2934 | $_dispatcher event -after 600000 !movietimeout |
---|
[1355] | 2935 | WaitIcon start $inner.icon |
---|
[2606] | 2936 | grab set $inner |
---|
[1355] | 2937 | focus $inner.cancel |
---|
[1449] | 2938 | |
---|
| 2939 | flow duration |
---|
| 2940 | flow speed |
---|
[1506] | 2941 | set nframes [expr round($_flow(duration) / $_flow(delay))] |
---|
[1449] | 2942 | set framerate [expr 1000.0 / $_flow(delay)] |
---|
[1514] | 2943 | |
---|
| 2944 | # These are specific to MPEG1 video generation |
---|
[1506] | 2945 | set framerate 25.0 |
---|
[1514] | 2946 | set bitrate 6.0e+6 |
---|
[1355] | 2947 | |
---|
[1506] | 2948 | set start [clock seconds] |
---|
[1514] | 2949 | SendCmd "flow video $token -width $w -height $h -numframes $nframes " |
---|
[1355] | 2950 | |
---|
| 2951 | $popup activate $widget below |
---|
[3555] | 2952 | update idletasks |
---|
[1355] | 2953 | update |
---|
[1514] | 2954 | # We wait here until |
---|
| 2955 | # 1. the movie is delivered or |
---|
| 2956 | # 2. we've timed out or |
---|
| 2957 | # 3. the user has canceled the operation.b |
---|
[1355] | 2958 | tkwait variable $var |
---|
| 2959 | |
---|
[1514] | 2960 | puts stderr "Video generated in [expr [clock seconds] - $start] seconds." |
---|
| 2961 | |
---|
[1355] | 2962 | # Clean up. |
---|
[1506] | 2963 | $_dispatcher cancel !movietimeout |
---|
[1355] | 2964 | WaitIcon stop $inner.icon |
---|
| 2965 | grab release $inner |
---|
| 2966 | $popup deactivate |
---|
| 2967 | destroy $popup |
---|
| 2968 | update |
---|
| 2969 | |
---|
[1514] | 2970 | # This will both cancel the movie generation (if it hasn't already |
---|
| 2971 | # completed) and reset the flow. |
---|
| 2972 | SendCmd "flow reset" |
---|
[1442] | 2973 | if { $_hardcopy($this-$token) != "" } { |
---|
[1694] | 2974 | return [list .mpg $_hardcopy($this-$token)] |
---|
[1355] | 2975 | } |
---|
| 2976 | return "" |
---|
[1357] | 2977 | } |
---|
[1377] | 2978 | |
---|
[1471] | 2979 | itcl::body Rappture::FlowvisViewer::str2millisecs { value } { |
---|
[1473] | 2980 | set parts [split $value :] |
---|
| 2981 | set secs 0 |
---|
| 2982 | set mins 0 |
---|
| 2983 | if { [llength $parts] == 1 } { |
---|
[1694] | 2984 | scan [lindex $parts 0] "%d" secs |
---|
[1471] | 2985 | } else { |
---|
[1694] | 2986 | scan [lindex $parts 1] "%d" secs |
---|
| 2987 | scan [lindex $parts 0] "%d" mins |
---|
[1471] | 2988 | } |
---|
[1473] | 2989 | set ms [expr {(($mins * 60) + $secs) * 1000.0}] |
---|
| 2990 | if { $ms > 600000.0 } { |
---|
[1694] | 2991 | set ms 600000.0 |
---|
[1473] | 2992 | } |
---|
| 2993 | if { $ms == 0.0 } { |
---|
[1694] | 2994 | set ms 60000.0 |
---|
[1473] | 2995 | } |
---|
| 2996 | return $ms |
---|
[1471] | 2997 | } |
---|
| 2998 | |
---|
| 2999 | itcl::body Rappture::FlowvisViewer::millisecs2str { value } { |
---|
| 3000 | set min [expr floor($value / 60000.0)] |
---|
| 3001 | set sec [expr ($value - ($min*60000.0)) / 1000.0] |
---|
| 3002 | return [format %02d:%02d [expr round($min)] [expr round($sec)]] |
---|
| 3003 | } |
---|
| 3004 | |
---|
[3533] | 3005 | itcl::body Rappture::FlowvisViewer::SetOrientation { side } { |
---|
| 3006 | array set positions { |
---|
| 3007 | front "1 0 0 0" |
---|
| 3008 | back "0 0 1 0" |
---|
| 3009 | left "0.707107 0 -0.707107 0" |
---|
| 3010 | right "0.707107 0 0.707107 0" |
---|
| 3011 | top "0.707107 -0.707107 0 0" |
---|
| 3012 | bottom "0.707107 0.707107 0 0" |
---|
[3492] | 3013 | } |
---|
[3533] | 3014 | foreach name { qw qx qy qz } value $positions($side) { |
---|
| 3015 | set _view($name) $value |
---|
| 3016 | } |
---|
[3492] | 3017 | set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] |
---|
| 3018 | $_arcball quaternion $q |
---|
| 3019 | SendCmd "camera orient $q" |
---|
| 3020 | SendCmd "camera reset" |
---|
[3533] | 3021 | set _view(xpan) 0.0 |
---|
| 3022 | set _view(ypan) 0.0 |
---|
| 3023 | set _view(zoom) 1.0 |
---|
| 3024 | set _settings($this-xpan) $_view(xpan) |
---|
| 3025 | set _settings($this-ypan) $_view(ypan) |
---|
| 3026 | set _settings($this-zoom) $_view(zoom) |
---|
[3492] | 3027 | } |
---|
[3940] | 3028 | |
---|
| 3029 | # Reset global settings from dataset's settings. |
---|
| 3030 | itcl::body Rappture::FlowvisViewer::BuildVolumeComponents {} { |
---|
| 3031 | $itk_component(volcomponents) choices delete 0 end |
---|
| 3032 | foreach name $_componentsList { |
---|
| 3033 | $itk_component(volcomponents) choices insert end $name $name |
---|
| 3034 | } |
---|
| 3035 | set _current [lindex $_componentsList 0] |
---|
| 3036 | $itk_component(volcomponents) value $_current |
---|
| 3037 | } |
---|
| 3038 | |
---|
| 3039 | # Reset global settings from dataset's settings. |
---|
| 3040 | itcl::body Rappture::FlowvisViewer::GetDatasetsWithComponent { cname } { |
---|
| 3041 | if { ![info exists _volcomponents($cname)] } { |
---|
| 3042 | return "" |
---|
| 3043 | } |
---|
| 3044 | set list "" |
---|
| 3045 | foreach tag $_volcomponents($cname) { |
---|
| 3046 | if { ![info exists _serverObjs($tag)] } { |
---|
| 3047 | continue |
---|
| 3048 | } |
---|
| 3049 | lappend list $tag |
---|
| 3050 | } |
---|
| 3051 | return $list |
---|
| 3052 | } |
---|