Changeset 54 for trunk/gui/scripts
- Timestamp:
- Sep 9, 2005, 9:03:56 AM (19 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/curve.tcl
r25 r54 108 108 109 109 # ---------------------------------------------------------------------- 110 # USAGE: limits x| y110 # USAGE: limits x|xlog|y|ylog 111 111 # 112 112 # Returns the {min max} limits for the specified axis. … … 116 116 set max "" 117 117 switch -- $which { 118 x { set pos 0 } 119 y - v { set pos 1 } 118 x { set pos 0; set log 0 } 119 xlog { set pos 0; set log 1 } 120 y - v { set pos 1; set log 0 } 121 ylog - vlog { set pos 1; set log 1 } 120 122 default { 121 error "bad option \"$which\": should be x or y" 122 } 123 } 123 error "bad option \"$which\": should be x, xlog, y, ylog, v, vlog" 124 } 125 } 126 127 blt::vector create tmp zero 124 128 foreach comp [array names _comp2xy] { 125 129 set vname [lindex $_comp2xy($comp) $pos] 126 130 $vname variable vec 131 132 if {$log} { 133 # on a log scale, use abs value and ignore 0's 134 $vname dup tmp 135 $vname dup zero 136 zero expr {tmp == 0} ;# find the 0's 137 tmp expr {abs(tmp)} ;# get the abs value 138 tmp expr {tmp + zero*max(tmp)} ;# replace 0's with abs max 139 set vmin [blt::vector expr min(tmp)] 140 set vmax [blt::vector expr max(tmp)] 141 } else { 142 set vmin $vec(min) 143 set vmax $vec(max) 144 } 145 127 146 if {"" == $min} { 128 set min $v ec(min)129 } elseif {$v ec(min)< $min} {130 set min $v ec(min)147 set min $vmin 148 } elseif {$vmin < $min} { 149 set min $vmin 131 150 } 132 151 if {"" == $max} { 133 set max $vec(max) 134 } elseif {$vec(max) > $max} { 135 set max $vec(max) 136 } 137 } 152 set max $vmax 153 } elseif {$vmax > $max} { 154 set max $vmax 155 } 156 } 157 blt::vector destroy tmp zero 158 138 159 return [list $min $max] 139 160 } -
trunk/gui/scripts/moleculeViewer.tcl
r52 r54 63 63 64 64 protected method _clear {} 65 protected method _re nder{}65 protected method _redraw {} 66 66 protected method _zoom {option} 67 67 protected method _move {option x y} 68 68 protected method _3dView {theta phi} 69 69 protected method _color2rgb {color} 70 71 private variable _dispatcher "" ;# dispatcher for !events 70 72 71 73 private variable _tool "" ;# tool containing this viewer … … 85 87 itcl::body Rappture::MoleculeViewer::constructor {tool args} { 86 88 set _tool $tool 89 90 Rappture::dispatcher _dispatcher 91 $_dispatcher register !redraw 92 $_dispatcher dispatch $this !redraw "[itcl::code $this _redraw]; list" 93 $_dispatcher register !render 94 $_dispatcher dispatch $this !render "$this-renWin Render; list" 95 $_dispatcher register !fixsize 96 $_dispatcher dispatch $this !fixsize \ 97 "[itcl::code $this emblems fixPosition]; list" 87 98 88 99 itk_option add hull.width hull.height … … 179 190 pack $itk_component(area) -expand yes -fill both 180 191 bind $itk_component(area) <Configure> \ 181 [ itcl::code $this emblems fixPosition]192 [list $_dispatcher event -idle !fixsize] 182 193 183 194 itk_component add renderer { … … 205 216 # ---------------------------------------------------------------------- 206 217 itcl::body Rappture::MoleculeViewer::destructor {} { 207 after cancel [itcl::code $this _render]208 209 218 rename $this-renWin "" 210 219 rename $this-ren "" … … 233 242 234 243 $this-ren ResetCamera 235 $ this-renWin Render236 } 237 238 # ---------------------------------------------------------------------- 239 # USAGE: _re nder244 $_dispatcher event -now !render 245 } 246 247 # ---------------------------------------------------------------------- 248 # USAGE: _redraw 240 249 # 241 250 # Used internally to rebuild the scene whenever options within this 242 251 # widget change. Destroys all actors and rebuilds them from scratch. 243 252 # ---------------------------------------------------------------------- 244 itcl::body Rappture::MoleculeViewer::_render {} { 253 itcl::body Rappture::MoleculeViewer::_redraw {} { 254 blt::busy hold $itk_component(hull); update 255 245 256 _clear 246 257 … … 307 318 emblems on 308 319 } 309 after cancel [list catch [itcl::code $this _zoom reset]] 310 after 200 [list catch [itcl::code $this _zoom reset]] 320 _zoom reset 311 321 } 312 322 $this-ren ResetCamera 313 $this-renWin Render 323 $_dispatcher event -idle !render 324 325 blt::busy release $itk_component(hull) 314 326 } 315 327 … … 326 338 in { 327 339 [$this-ren GetActiveCamera] Zoom 1.25 328 emblems fixPosition329 $this-renWin Render330 340 } 331 341 out { 332 342 [$this-ren GetActiveCamera] Zoom 0.8 333 emblems fixPosition334 $this-renWin Render335 343 } 336 344 reset { 337 [$this-ren GetActiveCamera] SetViewAngle 30338 345 $this-ren ResetCamera 339 [$this-ren GetActiveCamera] Zoom 1.25340 346 _3dView 45 45 341 $this-renWin Render 342 343 after cancel [list catch [itcl::code $this emblems fixPosition]] 344 after 2000 [list catch [itcl::code $this emblems fixPosition]] 345 } 346 } 347 } 348 } 349 $_dispatcher event -later !fixsize 350 $_dispatcher event -idle !render 347 351 } 348 352 … … 370 374 set w [winfo width $itk_component(renderer)] 371 375 set h [winfo height $itk_component(renderer)] 376 if {$w <= 0 || $h <= 0} { 377 return 378 } 372 379 set dx [expr {double($x-$_click(x))/$w}] 373 380 set dy [expr {double($y-$_click(y))/$h}] … … 383 390 _3dView $theta $phi 384 391 emblems fixPosition 385 $ this-renWin Render392 $_dispatcher event -idle !render 386 393 387 394 set _click(x) $x … … 488 495 } 489 496 } 490 $ this-renWin Render497 $_dispatcher event -idle !render 491 498 } 492 499 … … 510 517 itcl::configbody Rappture::MoleculeViewer::backdrop { 511 518 eval $this-ren SetBackground [_color2rgb $itk_option(-backdrop)] 512 $ this-renWin Render519 $_dispatcher event -idle !render 513 520 } 514 521 … … 531 538 } 532 539 } 533 after idle [itcl::code $this _render]534 } 540 $_dispatcher event -idle !redraw 541 } -
trunk/gui/scripts/xyresult.tcl
r52 r54 68 68 private variable _elem2curve ;# maps graph element => curve 69 69 private variable _xmin "" ;# autoscale min for x-axis 70 private variable _xlogmin "" ;# autoscale min for x-axis (log scale) 70 71 private variable _xmax "" ;# autoscale max for x-axis 72 private variable _xlogmax "" ;# autoscale max for x-axis (log scale) 71 73 private variable _vmin "" ;# autoscale min for y-axis 74 private variable _vlogmin "" ;# autoscale min for y-axis (log scale) 72 75 private variable _vmax "" ;# autoscale max for y-axis 76 private variable _vlogmax "" ;# autoscale max for y-axis (log scale) 73 77 private variable _hilite ;# info from last _hilite operation 74 78 private variable _axis ;# info for axis being edited … … 334 338 itcl::body Rappture::XyResult::scale {args} { 335 339 set _xmin "" 340 set _xlogmin "" 336 341 set _xmax "" 342 set _xlogmax "" 337 343 set _vmin "" 344 set _vlogmin "" 338 345 set _vmax "" 346 set _vlogmax "" 339 347 foreach obj $args { 340 foreach axis {x v} {348 foreach axis {x xlog v vlog} { 341 349 foreach {min max} [$obj limits $axis] break 342 350 if {"" != $min && "" != $max} { … … 526 534 # 527 535 if {$_xmin != $_xmax} { 528 $g axis configure x -min $_xmin -max $_xmax 529 } else { 530 $g axis configure x -min "" -max "" 531 } 532 533 if {"" != $_vmin && "" != $_vmax} { 534 set min $_vmin 535 set max $_vmax 536 set log [$g axis cget y -logscale] 536 set log [$g axis cget x -logscale] 537 537 if {$log} { 538 set min $_xlogmin 539 set max $_xlogmax 538 540 if {$min == $max} { 539 541 set min [expr {0.9*$min}] 540 542 set max [expr {1.1*$max}] 541 543 } 542 set min [expr {pow(10.0,floor(log10($min)))}] 543 set max [expr {pow(10.0,ceil(log10($max)))}] 544 set v [expr {floor(log10($min))}] 545 if {$v > 0} { 546 set min [expr {pow(10.0,$v)}] 547 } 548 set v [expr {floor(log10($max))}] 549 if {$v > 0} { 550 set max [expr {pow(10.0,$v)}] 551 } 544 552 } else { 553 set min $_xmin 554 set max $_xmax 555 if {$min > 0} { 556 set min [expr {0.95*$min}] 557 } else { 558 set min [expr {1.05*$min}] 559 } 560 if {$max > 0} { 561 set max [expr {1.05*$max}] 562 } else { 563 set max [expr {0.95*$max}] 564 } 565 } 566 if {$min != $max} { 567 $g axis configure x -min $min -max $max 568 } else { 569 $g axis configure x -min "" -max "" 570 } 571 } else { 572 $g axis configure x -min "" -max "" 573 } 574 575 if {"" != $_vmin && "" != $_vmax} { 576 set log [$g axis cget y -logscale] 577 if {$log} { 578 set min $_vlogmin 579 set max $_vlogmax 580 if {$min == $max} { 581 set min [expr {0.9*$min}] 582 set max [expr {1.1*$max}] 583 } 584 set v [expr {floor(log10($min))}] 585 if {$v > 0} { 586 set min [expr {pow(10.0,$v)}] 587 } 588 set v [expr {floor(log10($max))}] 589 if {$v > 0} { 590 set max [expr {pow(10.0,$v)}] 591 } 592 } else { 593 set min $_vmin 594 set max $_vmax 545 595 if {$min > 0} { 546 596 set min [expr {0.95*$min}]
Note: See TracChangeset
for help on using the changeset viewer.