- Timestamp:
- Feb 19, 2009 3:13:35 PM (15 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 6 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/combobox.tcl
r746 r1277 1 1 2 # ---------------------------------------------------------------------- 2 3 # COMPONENT: combobox - entry widget with a drop-down list of values -
trunk/gui/scripts/molvisviewer.tcl
r1228 r1277 65 65 66 66 public method emblems {option} 67 public method projection {option} 67 68 public method rock {option} 68 69 public method representation {option {model "all"} } 70 public method atomscale {option {model "all"} } 69 71 public method ResetView {} 72 public method settings {option args} 70 73 71 74 protected method _send {args} … … 74 77 protected method _zoom {option {factor 10}} 75 78 protected method _pan {option x y} 79 protected method _rotate {option x y} 76 80 protected method _configure {w h} 77 81 protected method _unmap {} … … 79 83 protected method _vmouse2 {option b m x y} 80 84 protected method _vmouse {option b m x y} 81 private method _ receive_image { size cacheid frame rock }82 85 private method _ReceiveImage { size cacheid frame rock } 86 private method _BuildSettingsDrawer {} 83 87 private variable _inrebuild 0 84 88 … … 92 96 93 97 private variable view_ 98 private variable click_ 94 99 95 100 private variable _model … … 102 107 private variable _cacheid "" 103 108 private variable _cacheimage "" 104 private variable _busy 0105 109 106 110 private variable delta1_ 10 … … 108 112 109 113 private common _settings ;# array of settings for all known widgets 114 private variable initialized_ "no"; 110 115 } 111 116 … … 133 138 # Populate the slave interpreter with commands to handle responses from 134 139 # the visualization server. 135 $_parser alias image [itcl::code $this _ receive_image]140 $_parser alias image [itcl::code $this _ReceiveImage] 136 141 137 142 set _rocker(dir) 1 … … 144 149 145 150 array set view_ { 151 theta 45 152 phi 45 153 psi 0 154 vx 0 155 vy 0 156 vz 0 146 157 zoom 0 147 158 mx 0 … … 151 162 y 0 152 163 z 0 153 } 154 164 width 0 165 height 0 166 } 167 168 # Setup default settings for widget. 155 169 array set _settings [subst { 156 $this-model $_mrepresentation 157 $this-modelimg [Rappture::icon ballnstick] 158 $this-emblems 0 159 $this-rock 0 170 $this-model ballnstick 171 $this-modelimg [Rappture::icon ballnstick] 172 $this-emblems no 173 $this-rock no 174 $this-ortho no 175 $this-atomscale 0.25 160 176 }] 161 177 … … 163 179 # Set up the widgets in the main body 164 180 # 165 itk_component add zoom {166 frame $itk_component(controls).zoom167 } {168 usual169 rename -background -controlbackground controlBackground Background170 }171 pack $itk_component(zoom) -side top172 173 181 itk_component add reset { 174 button $itk_component( zoom).reset \182 button $itk_component(controls).reset \ 175 183 -borderwidth 1 -padx 1 -pady 1 \ 176 - bitmap [Rappture::icon reset] \184 -image [Rappture::icon reset-view] \ 177 185 -command [itcl::code $this ResetView] 178 186 } { 179 187 usual 180 188 ignore -borderwidth 181 rename -highlightbackground -controlbackground controlBackground Background 182 } 183 pack $itk_component(reset) -side left -padx {4 1} -pady 4 184 Rappture::Tooltip::for $itk_component(reset) "Reset the view to the default zoom level" 189 rename -highlightbackground -controlbackground controlBackground \ 190 Background 191 } 192 pack $itk_component(reset) -padx 1 -pady 2 193 Rappture::Tooltip::for $itk_component(reset) \ 194 "Reset the view to the default zoom level" 185 195 186 196 itk_component add zoomin { 187 button $itk_component( zoom).zin \197 button $itk_component(controls).zin \ 188 198 -borderwidth 1 -padx 1 -pady 1 \ 189 - bitmap [Rappture::icon zoomin] \199 -image [Rappture::icon zoom-in] \ 190 200 -command [itcl::code $this _zoom in] 191 201 } { 192 202 usual 193 203 ignore -borderwidth 194 rename -highlightbackground -controlbackground controlBackground Background 195 } 196 pack $itk_component(zoomin) -side left -padx 1 -pady 4 204 rename -highlightbackground -controlbackground \ 205 controlBackground Background 206 } 207 pack $itk_component(zoomin) -padx 2 -pady { 0 2 } 197 208 Rappture::Tooltip::for $itk_component(zoomin) "Zoom in" 198 209 199 210 itk_component add zoomout { 200 button $itk_component( zoom).zout \211 button $itk_component(controls).zout \ 201 212 -borderwidth 1 -padx 1 -pady 1 \ 202 - bitmap [Rappture::icon zoomout] \213 -image [Rappture::icon zoom-out] \ 203 214 -command [itcl::code $this _zoom out] 204 215 } { 205 216 usual 206 217 ignore -borderwidth 207 rename -highlightbackground -controlbackground controlBackground Background208 } 209 pack $itk_component(zoomout) -side left -padx {1 4} -pady 4210 218 rename -highlightbackground -controlbackground controlBackground \ 219 Background 220 } 221 pack $itk_component(zoomout) -padx 2 -pady { 0 2 } 211 222 Rappture::Tooltip::for $itk_component(zoomout) "Zoom out" 212 213 # 214 # Settings panel... 215 # 216 itk_component add settings { 217 button $itk_component(controls).settings -text "Settings..." \ 218 -borderwidth 1 -relief flat -overrelief raised \ 219 -padx 2 -pady 1 \ 220 -command [list $itk_component(controls).panel activate $itk_component(controls).settings left] 221 } { 222 usual 223 ignore -borderwidth 224 rename -background -controlbackground controlBackground Background 225 rename -highlightbackground -controlbackground controlBackground Background 226 } 227 pack $itk_component(settings) -side top -pady {8 2} 228 229 Rappture::Balloon $itk_component(controls).panel -title "Rendering Options" 230 set inner [$itk_component(controls).panel component inner] 231 frame $inner.model 232 pack $inner.model -side top -fill x 233 set fg [option get $itk_component(hull) font Font] 234 235 label $inner.model.pict -image $_settings($this-modelimg) 236 pack $inner.model.pict -side left -anchor n 237 label $inner.model.heading -text "Method for drawing atoms:" 238 pack $inner.model.heading -side top -anchor w 239 radiobutton $inner.model.bstick -text "Balls and sticks" \ 240 -command [itcl::code $this representation ballnstick all] \ 241 -variable Rappture::MolvisViewer::_settings($this-model) \ 242 -value ballnstick 243 pack $inner.model.bstick -side top -anchor w 244 radiobutton $inner.model.spheres -text "Spheres" \ 245 -command [itcl::code $this representation spheres all] \ 246 -variable Rappture::MolvisViewer::_settings($this-model) \ 247 -value spheres 248 pack $inner.model.spheres -side top -anchor w 249 radiobutton $inner.model.lines -text "Lines" \ 250 -command [itcl::code $this representation lines all] \ 251 -variable Rappture::MolvisViewer::_settings($this-model) \ 252 -value lines 253 pack $inner.model.lines -side top -anchor w 254 255 checkbutton $inner.labels -text "Show labels on atoms" \ 256 -command [itcl::code $this emblems update] \ 257 -variable Rappture::MolvisViewer::_settings($this-emblems) 258 pack $inner.labels -side top -anchor w -pady {4 1} 259 260 checkbutton $inner.rock -text "Rock model back and forth" \ 261 -command [itcl::code $this rock toggle] \ 262 -variable Rappture::MolvisViewer::_settings($this-rock) 263 pack $inner.rock -side top -anchor w -pady {1 4} 264 223 265 224 # 266 225 # Shortcuts … … 277 236 label $itk_component(shortcuts).labels \ 278 237 -borderwidth 1 -padx 1 -pady 1 \ 279 -relief "raised" - bitmap [Rappture::icon atoms]238 -relief "raised" -image [Rappture::icon atom-label] 280 239 } { 281 240 usual 282 241 ignore -borderwidth 283 rename -highlightbackground -controlbackground controlBackground Background 284 } 285 pack $itk_component(labels) -side left -padx {4 1} -pady 4 -ipadx 1 -ipady 1 286 Rappture::Tooltip::for $itk_component(labels) "Show/hide the labels on atoms" 242 rename -highlightbackground -controlbackground controlBackground \ 243 Background 244 } 245 pack $itk_component(labels) -padx 2 -pady { 0 2} -ipadx 1 -ipady 1 246 Rappture::Tooltip::for $itk_component(labels) \ 247 "Show/hide the labels on atoms" 287 248 bind $itk_component(labels) <ButtonPress> \ 288 249 [itcl::code $this emblems toggle] … … 291 252 label $itk_component(shortcuts).rock \ 292 253 -borderwidth 1 -padx 1 -pady 1 \ 293 -relief "raised" - bitmap [Rappture::icon rocker]254 -relief "raised" -image [Rappture::icon rock-view] 294 255 } { 295 256 usual 296 257 ignore -borderwidth 297 rename -highlightbackground -controlbackground controlBackground Background 298 } 299 pack $itk_component(rock) -side left -padx 1 -pady 4 -ipadx 1 -ipady 1 258 rename -highlightbackground -controlbackground controlBackground \ 259 Background 260 } 261 pack $itk_component(rock) -padx 2 -pady { 0 2 } -ipadx 1 -ipady 1 300 262 Rappture::Tooltip::for $itk_component(rock) "Rock model back and forth" 301 263 302 264 bind $itk_component(rock) <ButtonPress> \ 303 265 [itcl::code $this rock toggle] 266 267 268 itk_component add ortho { 269 label $itk_component(shortcuts).ortho \ 270 -borderwidth 1 -padx 1 -pady 1 \ 271 -relief "raised" -image [Rappture::icon 3dpers] 272 } { 273 usual 274 ignore -borderwidth 275 rename -highlightbackground -controlbackground controlBackground \ 276 Background 277 } 278 pack $itk_component(ortho) -padx 2 -pady { 0 2 } -ipadx 1 -ipady 1 279 Rappture::Tooltip::for $itk_component(ortho) \ 280 "Change to orthoscopic projection" 281 282 bind $itk_component(ortho) <ButtonPress> \ 283 [itcl::code $this projection toggle] 284 $this projection perspective 285 286 itk_component add settings_button { 287 label $itk_component(controls).settingsbutton \ 288 -borderwidth 1 -padx 1 -pady 1 \ 289 -relief "raised" -image [Rappture::icon wrench] 290 } { 291 usual 292 ignore -borderwidth 293 rename -highlightbackground -controlbackground controlBackground \ 294 Background 295 } 296 pack $itk_component(settings_button) -padx 2 -pady { 0 2 } -ipadx 1 -ipady 1 297 Rappture::Tooltip::for $itk_component(settings_button) \ 298 "Configure settings" 299 bind $itk_component(settings_button) <ButtonPress> \ 300 [itcl::code $this settings toggle] 301 pack $itk_component(settings_button) -side bottom \ 302 -padx 2 -pady 2 -anchor e 303 304 _BuildSettingsDrawer 304 305 305 306 # … … 310 311 311 312 # set up bindings for rotation 312 bind $itk_component(3dview) <ButtonPress-1> \ 313 [itcl::code $this _vmouse click %b %s %x %y] 314 bind $itk_component(3dview) <B1-Motion> \ 315 [itcl::code $this _vmouse drag 1 %s %x %y] 316 bind $itk_component(3dview) <ButtonRelease-1> \ 317 [itcl::code $this _vmouse release %b %s %x %y] 313 if 0 { 314 bind $itk_component(3dview) <ButtonPress-1> \ 315 [itcl::code $this _rotate click %x %y] 316 bind $itk_component(3dview) <B1-Motion> \ 317 [itcl::code $this _rotate drag %x %y] 318 bind $itk_component(3dview) <ButtonRelease-1> \ 319 [itcl::code $this _rotate release %x %y] 320 } else { 321 bind $itk_component(3dview) <ButtonPress-1> \ 322 [itcl::code $this _vmouse click %b %s %x %y] 323 bind $itk_component(3dview) <B1-Motion> \ 324 [itcl::code $this _vmouse drag 1 %s %x %y] 325 bind $itk_component(3dview) <ButtonRelease-1> \ 326 [itcl::code $this _vmouse release %b %s %x %y] 327 } 318 328 319 329 bind $itk_component(3dview) <ButtonPress-2> \ … … 333 343 [itcl::code $this _pan set 0 10] 334 344 bind $itk_component(3dview) <Shift-KeyPress-Left> \ 335 [itcl::code $this _pan set - 20]345 [itcl::code $this _pan set -50 0] 336 346 bind $itk_component(3dview) <Shift-KeyPress-Right> \ 337 [itcl::code $this _pan set 20]347 [itcl::code $this _pan set 50 0] 338 348 bind $itk_component(3dview) <Shift-KeyPress-Up> \ 339 [itcl::code $this _pan set 0 - 2]349 [itcl::code $this _pan set 0 -50] 340 350 bind $itk_component(3dview) <Shift-KeyPress-Down> \ 341 [itcl::code $this _pan set 0 2]351 [itcl::code $this _pan set 0 50] 342 352 bind $itk_component(3dview) <KeyPress-Prior> \ 343 353 [itcl::code $this _zoom out 2] … … 378 388 } 379 389 390 itcl::body Rappture::MolvisViewer::_BuildSettingsDrawer {} { 391 392 itk_component add settings { 393 Rappture::Scroller $itk_component(drawer).scrl \ 394 -xscrollmode auto -yscrollmode auto \ 395 -width 200 -height 100 396 } 397 398 itk_component add settings_canvas { 399 canvas $itk_component(settings).canvas 400 } 401 $itk_component(settings) contents $itk_component(settings_canvas) 402 403 itk_component add settings_frame { 404 frame $itk_component(settings_canvas).frame -bg white 405 } 406 $itk_component(settings_canvas) create window 0 0 \ 407 -anchor nw -window $itk_component(settings_frame) 408 bind $itk_component(settings_frame) <Configure> \ 409 [itcl::code $this settings resize] 410 411 set fg [option get $itk_component(hull) font Font] 412 413 set inner $itk_component(settings_frame) 414 label $inner.drawinglabel -text "Drawing Method:" -font "Arial 9 bold" 415 416 label $inner.pict -image $_settings($this-modelimg) 417 radiobutton $inner.bstick -text "Balls and sticks" \ 418 -command [itcl::code $this representation ballnstick all] \ 419 -variable Rappture::MolvisViewer::_settings($this-model) \ 420 -value ballnstick -font "Arial 9" -pady 0 421 radiobutton $inner.spheres -text "Spheres" \ 422 -command [itcl::code $this representation spheres all] \ 423 -variable Rappture::MolvisViewer::_settings($this-model) \ 424 -value spheres -font "Arial 9" -pady 0 425 radiobutton $inner.lines -text "Lines" \ 426 -command [itcl::code $this representation lines all] \ 427 -variable Rappture::MolvisViewer::_settings($this-model) \ 428 -value lines -font "Arial 9" -pady 0 429 430 label $inner.sizelabel -text "Atom Scale:" -font "Arial 9 bold" 431 scale $inner.atomscale \ 432 -from 0.1 -to 2.0 -resolution 0.05 \ 433 -showvalue true -orient horizontal \ 434 -command [itcl::code $this atomscale] \ 435 -variable Rappture::MolvisViewer::_settings($this-atomscale) 436 $inner.atomscale set $_settings($this-atomscale) 437 438 checkbutton $inner.labels -text "Show labels on atoms" \ 439 -command [itcl::code $this emblems update] \ 440 -variable Rappture::MolvisViewer::_settings($this-emblems) \ 441 -font "Arial 9 bold" 442 checkbutton $inner.rock -text "Rock model back and forth" \ 443 -command [itcl::code $this rock toggle] \ 444 -variable Rappture::MolvisViewer::_settings($this-rock) \ 445 -font "Arial 9 bold" 446 checkbutton $inner.ortho -text "Orthoscopic projection" \ 447 -command [itcl::code $this projection update] \ 448 -variable Rappture::MolvisViewer::_settings($this-ortho) \ 449 -font "Arial 9 bold" 450 blt::table $inner \ 451 0,0 $inner.drawinglabel -anchor w -columnspan 4 \ 452 1,1 $inner.pict -anchor w -rowspan 3 \ 453 1,2 $inner.spheres -anchor w -columnspan 2 \ 454 2,2 $inner.lines -anchor w -columnspan 2 \ 455 3,2 $inner.bstick -anchor w -columnspan 2 \ 456 4,0 $inner.sizelabel -columnspan 4 -anchor w \ 457 5,1 $inner.atomscale -anchor w -columnspan 3 \ 458 8,0 $inner.labels -anchor w -columnspan 4 \ 459 9,0 $inner.rock -anchor w -columnspan 4 \ 460 10,0 $inner.ortho -anchor w -columnspan 4 461 462 blt::table configure $inner c0 -resize expand -width 2 463 blt::table configure $inner c1 c2 -resize none 464 blt::table configure $inner c3 -resize expand 465 } 466 467 380 468 # ---------------------------------------------------------------------- 381 469 # DESTRUCTOR … … 427 515 # 428 516 itcl::body Rappture::MolvisViewer::Connect {} { 429 #$_image(plot) blank 517 if { [isconnected] } { 518 return 1 519 } 430 520 set hosts [GetServerList "pymol"] 431 521 if { "" == $hosts } { 432 522 return 0 433 523 } 434 524 set result [VisViewer::Connect $hosts] 435 525 if { $result } { 436 437 438 439 526 set _rocker(server) 0 527 set _cacheid 0 528 _send "raw -defer {set auto_color,0}" 529 _send "raw -defer {set auto_show_lines,0}" 440 530 } 441 531 return $result … … 465 555 466 556 itcl::body Rappture::MolvisViewer::_send { args } { 557 debug "_send $args" 467 558 if { $_state(server) != $_state(client) } { 468 559 if { ![SendBytes "frame -defer $_state(client)"] } { … … 480 571 481 572 # 482 # _ receive_image -bytes <size>573 # _ReceiveImage -bytes <size> 483 574 # 484 575 # Invoked automatically whenever the "image" command comes in from … … 486 577 # specified <size> will follow. 487 578 # 488 itcl::body Rappture::MolvisViewer::_receive_image { size cacheid frame rock } { 579 set count 0 580 itcl::body Rappture::MolvisViewer::_ReceiveImage { size cacheid frame rock } { 489 581 set tag "$frame,$rock" 582 global count 583 incr count 584 debug "$count: cacheid=$cacheid frame=$frame\n" 490 585 if { $cacheid != $_cacheid } { 491 586 array unset _imagecache 492 587 set _cacheid $cacheid 493 588 } 589 # debug "reading $size bytes from proxy\n" 494 590 set _imagecache($tag) [ReceiveBytes $size] 591 # debug "success: reading $size bytes from proxy\n" 495 592 496 # puts stderr"CACHED: $tag,$cacheid"593 #debug "CACHED: $tag,$cacheid" 497 594 $_image(plot) configure -data $_imagecache($tag) 498 595 set _image(id) $tag … … 512 609 return 513 610 } 514 611 debug "in rebuild" 515 612 #set _inrebuild 1 516 613 set changed 0 517 set _busy 1518 614 519 615 $itk_component(3dview) configure -cursor watch 520 616 521 617 # refresh GUI (primarily to make pending cursor changes visible) 522 update idletasks618 #update idletasks 523 619 set dlist [get] 524 620 foreach dev $dlist { … … 543 639 if { ![info exists _dataobjs($model-$state)] } { 544 640 set data1 "" 545 set serial 0641 set serial 0 546 642 547 643 foreach _atom [$dev children -type atom components.molecule] { … … 639 735 set _state(server) 1 640 736 set _state(client) 1 641 _send "frame -push1"737 _send "frame 1" 642 738 } elseif { ![info exists _imagecache($state,$_rocker(client))] } { 643 739 set _state(server) $state 644 740 set _state(client) $state 645 _send "frame -push$state"741 _send "frame $state" 646 742 } else { 647 743 set _state(client) $state 648 744 _update 649 745 } 650 # Reset screen size746 # Reset viewing parameters 651 747 set w [winfo width $itk_component(3dview)] 652 748 set h [winfo height $itk_component(3dview)] 653 _send "screen $w $h" 654 # Reset viewing parameters 655 _send "reset" 656 _send "rotate $view_(mx) $view_(my) $view_(mz)" 657 _send "pan $view_(x) $view_(y)" 658 _send "zoom $view_(zoom)" 749 _send [subst { 750 reset 751 screen $w $h 752 rotate $view_(mx) $view_(my) $view_(mz) 753 pan $view_(x) $view_(y) 754 zoom $view_(zoom) 755 }] 756 debug "rebuild: rotate $view_(mx) $view_(my) $view_(mz)" 757 758 $this projection update 759 $this atomscale update 760 $this emblems update 659 761 660 762 set _inrebuild 0 661 763 $itk_component(3dview) configure -cursor "" 764 debug "exiting rebuild" 662 765 } 663 766 … … 685 788 686 789 itcl::body Rappture::MolvisViewer::_configure { w h } { 790 debug "in _configure $w $h" 687 791 $_image(plot) configure -width $w -height $h 688 792 # immediately invalidate cache, defer update until mapped 689 793 array unset _imagecache 690 if { [isconnected] } { 691 if { [winfo ismapped $itk_component(3dview)] } { 692 _send "screen $w $h" 693 # Why do a reset? 694 #_send "reset -push" 695 } else { 696 _send "screen -defer $w $h" 697 # Why do a reset? 698 #_send "reset -push" 699 } 700 } 794 _send "screen $w $h" 701 795 } 702 796 … … 822 916 } 823 917 918 824 919 itcl::body Rappture::MolvisViewer::_vmouse2 {option b m x y} { 825 920 set now [clock clicks -milliseconds] … … 865 960 if { $option == "drag" || $option == "release" } { 866 961 set diff 0 867 catch { set diff [expr $now - $_mevent(time) ] }868 if {$diff < 75 && $option == "drag" } { # 75ms between motion updates869 set _mevent(afterid) [after [expr 75 - $diff] [itcl::code $this _vmouse drag $b $m $x $y]]870 return871 }962 catch { set diff [expr $now - $_mevent(time) ] } 963 if {$diff < 25 && $option == "drag" } { # 75ms between motion updates 964 set _mevent(afterid) [after [expr 25 - $diff] [itcl::code $this _vmouse drag $b $m $x $y]] 965 return 966 } 872 967 set w [winfo width $itk_component(3dview)] 873 968 set h [winfo height $itk_component(3dview)] … … 875 970 return 876 971 } 877 set x1 [expr $w/ 3]972 set x1 [expr double($w) / 3] 878 973 set x2 [expr $x1 * 2] 879 set y1 [expr $h/ 3]974 set y1 [expr double($h) / 3] 880 975 set y2 [expr $y1 * 2] 881 976 set dx [expr $x - $_mevent(x)] … … 905 1000 set view_(mz) [expr {$view_(mz) + $mz}] 906 1001 _send "rotate $mx $my $mz" 1002 debug "_vmmouse: rotate $view_(mx) $view_(my) $view_(mz)" 907 1003 } 908 1004 set _mevent(x) $x … … 915 1011 916 1012 # ---------------------------------------------------------------------- 1013 # USAGE: _rotate click <x> <y> 1014 # USAGE: _rotate drag <x> <y> 1015 # USAGE: _rotate release <x> <y> 1016 # 1017 # Called automatically when the user clicks/drags/releases in the 1018 # plot area. Moves the plot according to the user's actions. 1019 # ---------------------------------------------------------------------- 1020 itcl::body Rappture::MolvisViewer::_rotate {option x y} { 1021 set now [clock clicks -milliseconds] 1022 update idletasks 1023 # cancel any pending delayed dragging events 1024 if { [info exists _mevent(afterid)] } { 1025 after cancel $_mevent(afterid) 1026 unset _mevent(afterid) 1027 } 1028 switch -- $option { 1029 click { 1030 $itk_component(3dview) configure -cursor fleur 1031 set click_(x) $x 1032 set click_(y) $y 1033 set click_(theta) $view_(theta) 1034 set click_(phi) $view_(phi) 1035 } 1036 drag { 1037 if {[array size click_] == 0} { 1038 _rotate click $x $y 1039 } else { 1040 set w [winfo width $itk_component(3dview)] 1041 set h [winfo height $itk_component(3dview)] 1042 if {$w <= 0 || $h <= 0} { 1043 return 1044 } 1045 # set diff 0 1046 # catch { set diff [expr $now - $_mevent(time) ] } 1047 # if {$diff < 175 && $option == "drag" } { # 75ms between motion updates 1048 # set _mevent(afterid) [after [expr 175 - $diff] [itcl::code $this _rotate drag $x $y]] 1049 # return 1050 # } 1051 1052 if {[catch { 1053 # this fails sometimes for no apparent reason 1054 set dx [expr {double($x-$click_(x))/$w}] 1055 set dy [expr {double($y-$click_(y))/$h}] 1056 }]} { 1057 return 1058 } 1059 1060 # 1061 # Rotate the camera in 3D 1062 # 1063 if {$view_(psi) > 90 || $view_(psi) < -90} { 1064 # when psi is flipped around, theta moves backwards 1065 set dy [expr {-$dy}] 1066 } 1067 set theta [expr {$view_(theta) - $dy*180}] 1068 while {$theta < 0} { set theta [expr {$theta+180}] } 1069 while {$theta > 180} { set theta [expr {$theta-180}] } 1070 1071 if {abs($theta) >= 30 && abs($theta) <= 160} { 1072 set phi [expr {$view_(phi) - $dx*360}] 1073 while {$phi < 0} { set phi [expr {$phi+360}] } 1074 while {$phi > 360} { set phi [expr {$phi-360}] } 1075 set psi $view_(psi) 1076 } else { 1077 set phi $view_(phi) 1078 set psi [expr {$view_(psi) - $dx*360}] 1079 while {$psi < -180} { set psi [expr {$psi+360}] } 1080 while {$psi > 180} { set psi [expr {$psi-360}] } 1081 } 1082 array set view_ [subst { 1083 theta $theta 1084 phi $phi 1085 psi $psi 1086 }] 1087 foreach { vx vy vz } [Euler2XYZ $theta $phi $psi] break 1088 set a [expr $vx - $view_(vx)] 1089 set a [expr -$a] 1090 set b [expr $vy - $view_(vy)] 1091 set c [expr $vz - $view_(vz)] 1092 array set view_ [subst { 1093 vx $vx 1094 vy $vy 1095 vz $vz 1096 }] 1097 _send "rotate $a $b $c" 1098 debug "_rotate $x $y: rotate $view_(vx) $view_(vy) $view_(vz)" 1099 set click_(x) $x 1100 set click_(y) $y 1101 } 1102 } 1103 release { 1104 _rotate drag $x $y 1105 $itk_component(3dview) configure -cursor "" 1106 catch {unset click_} 1107 } 1108 default { 1109 error "bad option \"$option\": should be click, drag, release" 1110 } 1111 } 1112 set _mevent(time) $now 1113 } 1114 1115 # ---------------------------------------------------------------------- 917 1116 # USAGE: representation spheres 918 1117 # USAGE: representation ballnstick … … 927 1126 } 928 1127 set _settings($this-modelimg) [Rappture::icon $option] 929 set inner [$itk_component(controls).panel component inner] 930 $inner.model.pict configure -image $_settings($this-modelimg) 1128 #@set inner [$itk_component(controls).panel component inner] 1129 set inner $itk_component(settings_frame) 1130 $inner.pict configure -image $_settings($this-modelimg) 931 1131 932 1132 # Save the current option to set all radiobuttons -- just in case. … … 940 1140 set models $model 941 1141 } 1142 942 1143 foreach obj $models { 943 1144 if { [info exists _model($obj-representation)] } { … … 950 1151 } 951 1152 if { [isconnected] } { 952 $_dispatcher event -idle !rebuild 1153 _send "$option -model $model" 1154 #$_dispatcher event -idle !rebuild 953 1155 } 954 1156 } … … 997 1199 set _settings($this-emblems) 0 998 1200 _send "label off" 1201 } 1202 } 1203 1204 # ---------------------------------------------------------------------- 1205 # USAGE: projection on|off|toggle 1206 # USAGE: projection update 1207 # 1208 # Used internally to turn labels associated with atoms on/off, and to 1209 # update the positions of the labels so they sit on top of each atom. 1210 # ---------------------------------------------------------------------- 1211 itcl::body Rappture::MolvisViewer::projection {option} { 1212 switch -- $option { 1213 "orthoscopic" { 1214 set ortho 1 1215 } 1216 "perspective" { 1217 set ortho 0 1218 } 1219 "toggle" { 1220 set ortho [expr {$_settings($this-ortho) == 0}] 1221 } 1222 "update" { 1223 set ortho $_settings($this-ortho) 1224 } 1225 default { 1226 error "bad option \"$option\": should be on, off, toggle, or update" 1227 } 1228 } 1229 if { $ortho == $_settings($this-ortho) && $option != "update"} { 1230 # nothing to do 1231 return 1232 } 1233 if { $ortho } { 1234 $itk_component(ortho) configure -image [Rappture::icon 3dorth] 1235 Rappture::Tooltip::for $itk_component(ortho) \ 1236 "Change to perspective projection" 1237 set _settings($this-ortho) 1 1238 _send "orthoscopic on" 1239 } else { 1240 $itk_component(ortho) configure -image [Rappture::icon 3dpers] 1241 Rappture::Tooltip::for $itk_component(ortho) \ 1242 "Change to orthoscopic projection" 1243 set _settings($this-ortho) 0 1244 _send "orthoscopic off" 1245 } 1246 } 1247 1248 # ---------------------------------------------------------------------- 1249 # USAGE: atomscale scale ?model? 1250 # atomscale update 1251 # 1252 # Used internally to change the molecular representation used to render 1253 # our scene. 1254 # ---------------------------------------------------------------------- 1255 1256 itcl::body Rappture::MolvisViewer::atomscale { option {model "all"} } { 1257 if { $option == "update" } { 1258 set scale $_settings($this-atomscale) 1259 } elseif { [string is double $option] } { 1260 set scale $option 1261 if { ($scale < 0.1) || ($scale > 2.0) } { 1262 error "bad atom size \"$scale\"" 1263 } 1264 } else { 1265 error "bad option \"$option\"" 1266 } 1267 set _settings($this-atomscale) $scale 1268 if { [isconnected] } { 1269 _send "atomscale -model $model $scale" 999 1270 } 1000 1271 } … … 1062 1333 itcl::body Rappture::MolvisViewer::ResetView {} { 1063 1334 array set view_ { 1335 theta 45 1336 phi 45 1337 psi 0 1064 1338 mx 0 1065 1339 my 0 … … 1069 1343 z 0 1070 1344 zoom 0 1345 width 0 1346 height 0 1071 1347 } 1072 1348 _send "reset" 1349 _send "rotate $view_(mx) $view_(my) $view_(mz)" 1350 debug "ResetView: rotate $view_(mx) $view_(my) $view_(mz)" 1351 _send "pan $view_(x) $view_(y)" 1352 _send "zoom $view_(zoom)" 1073 1353 } 1074 1354 … … 1148 1428 } 1149 1429 1430 1431 itcl::body Rappture::MolvisViewer::settings { what args } { 1432 switch -- ${what} { 1433 "activate" { 1434 $itk_component(drawer) add $itk_component(settings) -sticky nsew 1435 after idle [list focus $itk_component(settings)] 1436 if { !$initialized_ } { 1437 set w [winfo width $itk_component(drawer)] 1438 set x [expr $w - 100] 1439 $itk_component(drawer) sash place 0 $x 0 1440 set initialized_ 1 1441 } 1442 $itk_component(settings_button) configure -relief sunken 1443 } 1444 "deactivate" { 1445 $itk_component(drawer) forget $itk_component(settings) 1446 $itk_component(settings_button) configure -relief raised 1447 } 1448 "toggle" { 1449 set slaves [$itk_component(drawer) panes] 1450 if { [lsearch $slaves $itk_component(settings)] >= 0 } { 1451 settings deactivate 1452 } else { 1453 settings activate 1454 } 1455 } 1456 "resize" { 1457 set bbox [$itk_component(settings_canvas) bbox all] 1458 set wid [winfo width $itk_component(settings_frame)] 1459 $itk_component(settings_canvas) configure -width $wid \ 1460 -scrollregion $bbox -yscrollincrement 0.1i 1461 } 1462 } 1463 } 1464 1465 1466 -
trunk/gui/scripts/nanovisviewer.tcl
r1254 r1277 189 189 button $itk_component(zoom).reset \ 190 190 -borderwidth 1 -padx 1 -pady 1 \ 191 - bitmap [Rappture::icon reset] \191 -image [Rappture::icon reset-view] \ 192 192 -command [itcl::code $this _zoom reset] 193 193 } { … … 202 202 button $itk_component(zoom).zin \ 203 203 -borderwidth 1 -padx 1 -pady 1 \ 204 - bitmap [Rappture::icon zoomin] \204 -image [Rappture::icon zoom-in] \ 205 205 -command [itcl::code $this _zoom in] 206 206 } { … … 215 215 button $itk_component(zoom).zout \ 216 216 -borderwidth 1 -padx 1 -pady 1 \ 217 - bitmap [Rappture::icon zoomout] \217 -image [Rappture::icon zoom-out] \ 218 218 -command [itcl::code $this _zoom out] 219 219 } { -
trunk/gui/scripts/scroller.tcl
r464 r1277 161 161 set _contents $widget 162 162 163 if {[string equal "x11" [tk windowingsystem]]} { 164 bind ${widget} <4> { %W yview scroll -5 units } 165 bind ${widget} <5> { %W yview scroll 5 units } 166 } else { 167 bind ${widget} <MouseWheel> { 168 %W yview scroll [expr {- (%D / 120) * 4}] units 169 } 170 } 163 171 if {$widget == $_frame} { 164 172 return $_frame.f -
trunk/gui/scripts/visviewer.tcl
r1247 r1277 88 88 } 89 89 90 itk::usual Panedwindow { 91 keep -background -cursor 92 } 93 90 94 # ---------------------------------------------------------------------- 91 95 # CONSTRUCTOR … … 128 132 # RENDERING AREA 129 133 # 134 itk_component add drawer { 135 panedwindow $itk_interior.drawer \ 136 -orient horizontal -opaqueresize 1 -handlepad 0 \ 137 -handlesize 1 -sashwidth 2 138 } 139 pack $itk_component(drawer) -expand yes -fill both 140 130 141 itk_component add area { 131 142 frame $itk_interior.area 132 143 } 133 pack $itk_component(area) -expand yes -fill both144 $itk_component(drawer) add $itk_component(area) -sticky nsew 134 145 135 146 set _image(plot) [image create photo] … … 273 284 itcl::body Rappture::VisViewer::Disconnect {} { 274 285 $_dispatcher cancel !timeout 275 if { [IsConnected] } { 276 catch {close $sid_} 277 set sid_ "" 278 } 286 catch {close $sid_} 287 set sid_ "" 279 288 set buffer_(in) "" 280 289 } … … 450 459 return 0 451 460 } 452 if { [gets $sid_ line] < 0 } { 461 set n [gets $sid_ line] 462 463 if { $n < 0 } { 453 464 Disconnect 465 return 0 454 466 } 455 467 set line [string trim $line] -
trunk/gui/scripts/xyresult.tcl
r1252 r1277 154 154 button $itk_component(controls).reset \ 155 155 -borderwidth 1 -padx 1 -pady 1 \ 156 - bitmap [Rappture::icon reset] \156 -image [Rappture::icon reset-view] \ 157 157 -command [itcl::code $this _zoom reset] 158 158 } { … … 177 177 } 178 178 $itk_component(drawer) add $itk_component(plot) -sticky nsew 179 179 180 $itk_component(plot) pen configure activeLine \ 180 181 -symbol square -pixels 3 -linewidth 2 \ … … 250 251 button $itk_component(controls).legendbutton \ 251 252 -borderwidth 1 -padx 2 -pady 0 -highlightthickness 0 \ 252 - text "L" -font "-*-times new roman-bold-i-*-*-11-*-*-*-*-*-*-*"\253 -image [Rappture::icon wrench] \ 253 254 -command [itcl::code $this legend toggle] 254 255 } { … … 257 258 rename -highlightbackground -controlbackground controlBackground Background 258 259 } 259 pack $itk_component(legendbutton) -padx 4 -pady { 0 2 } -anchor e 260 pack $itk_component(legendbutton) \ 261 -side bottom -padx 4 -pady { 0 2 } -anchor e 260 262 261 263 itk_component add legend {
Note: See TracChangeset
for help on using the changeset viewer.