Changeset 5016 for branches/1.4
- Timestamp:
- Feb 12, 2015, 10:53:31 PM (10 years ago)
- Location:
- branches/1.4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.4
-
branches/1.4/gui/scripts/isomarker.tcl
r4546 r5016 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 3 3 # ---------------------------------------------------------------------- … … 24 24 private variable _canvas "" 25 25 private variable _nvobj ""; # Parent nanovis object. 26 private variable _tf ""; # Transfer function that this marker is 26 private variable _tf ""; # Transfer function that this marker is 27 27 # associated with. 28 28 private variable _activeMotion 0 … … 30 30 private common _normalIcon [Rappture::icon nvlegendmark] 31 31 private common _activeIcon [Rappture::icon nvlegendmark2] 32 private method EnterTick {} 33 private method LeaveTick {} 34 private method StartDrag { x y } 35 private method ContinueDrag { x y } 36 private method StopDrag { x y } 32 private method EnterTick {} 33 private method LeaveTick {} 34 private method StartDrag { x y } 35 private method ContinueDrag { x y } 36 private method StopDrag { x y } 37 37 38 38 constructor {c obj tf args} {} 39 destructor {} 40 public method transferfunc {} 41 public method activate { bool } 42 public method visible { bool } 43 public method screenpos {} 44 public method absval { {x "-get"} } 39 destructor {} 40 public method transferfunc {} 41 public method activate { bool } 42 public method visible { bool } 43 public method screenpos {} 44 public method absval { {x "-get"} } 45 45 public method relval { {x "-get"} } 46 46 } 47 47 48 itcl::body Rappture::IsoMarker::constructor {c obj tf args} { 48 itcl::body Rappture::IsoMarker::constructor {c obj tf args} { 49 49 set _canvas $c 50 50 set _nvobj $obj … … 95 95 } 96 96 97 itcl::body Rappture::IsoMarker::screenpos { } { 97 itcl::body Rappture::IsoMarker::screenpos { } { 98 98 set x [relval] 99 99 if { $x < 0.0 } { 100 100 set x 0.0 101 101 } elseif { $x > 1.0 } { 102 set x 1.0 102 set x 1.0 103 103 } 104 set low 10 104 set low 10 105 105 set w [winfo width $_canvas] 106 106 set high [expr {$w - 10}] … … 133 133 } 134 134 return [expr {($_value - $min) / ($max - $min)}] 135 } 135 } 136 136 if { $max == $min } { 137 137 set min 0.0 … … 140 140 if { [catch {expr $max - $min} r] != 0 } { 141 141 return 0.0 142 } 142 } 143 143 absval [expr {($x * $r) + $min}] 144 144 } … … 156 156 157 157 itcl::body Rappture::IsoMarker::StartDrag { x y } { 158 $_canvas raise $_tick 158 $_canvas raise $_tick 159 159 set _activePress 1 160 160 activate yes … … 165 165 itcl::body Rappture::IsoMarker::StopDrag { x y } { 166 166 if { ![$_nvobj removeDuplicateMarker $this $x]} { 167 ContinueDrag $x $y 167 ContinueDrag $x $y 168 168 } 169 169 set _activePress 0 … … 178 178 $_nvobj overMarker $this $x 179 179 $_nvobj updateTransferFunctions 180 $_canvas raise $_tick 180 $_canvas raise $_tick 181 181 set _activePress 1 182 182 activate yes -
branches/1.4/gui/scripts/moleculeViewer.tcl
r3844 r5016 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: MoleculeViewer - view a molecule in 3D … … 27 27 itk_option define -device device Device "" 28 28 29 constructor {tool args} { 30 # defined below 31 } 32 destructor { 33 # defined below 29 constructor {tool args} { 30 # defined below 31 } 32 destructor { 33 # defined below 34 34 } 35 35 … … 38 38 public method delete {args} 39 39 public method snap {w h} 40 public method parameters {title args} { 41 # do nothing 40 public method parameters {title args} { 41 # do nothing 42 42 } 43 43 public method emblems {option} … … 63 63 private variable _download "";# snapshot for download 64 64 } 65 65 66 66 itk::usual MoleculeViewer { 67 67 } … … 236 236 } 237 237 array set params $settings 238 238 239 239 set pos [lsearch -exact $_dlist $dataobj] 240 240 … … 243 243 error "bad value \"$dataobj\": should be Rappture::library object" 244 244 } 245 245 246 246 set emblem [$dataobj get components.molecule.about.emblems] 247 247 if {$emblem == "" || ![string is boolean $emblem] || !$emblem} { -
branches/1.4/gui/scripts/molvisviewer.tcl
r4670 r5016 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 3 3 # ---------------------------------------------------------------------- … … 52 52 53 53 private variable _active; # array of active models. 54 private variable _obj2models; # array containing list of models 54 private variable _obj2models; # array containing list of models 55 55 # for each data object. 56 56 private variable _view … … 63 63 private variable _imagecache 64 64 private variable _state 65 private variable _labels 65 private variable _labels "default" 66 66 private variable _cacheid "" 67 67 private variable _cacheimage "" 68 private variable _first 69 70 private common _settings ; # Array of settings for all known 68 private variable _first "" 69 70 private common _settings ; # Array of settings for all known 71 71 # widgets 72 72 private variable _initialized … … 81 81 private variable _width 82 82 private variable _height 83 private variable _reset 1; 83 private variable _reset 1; # Restore camera settings 84 84 private variable _cell 0; # Restore camera settings 85 85 … … 96 96 } 97 97 private method BuildSettingsTab {} 98 private method DoResize {} 99 private method DoRotate {} 100 private method DoUpdate {} 101 private method EventuallyResize { w h } 102 private method EventuallyRotate { a b c } 103 private method EventuallyChangeSettings { args } 98 private method DoResize {} 99 private method DoRotate {} 100 private method DoUpdate {} 101 private method EventuallyResize { w h } 102 private method EventuallyRotate { a b c } 103 private method EventuallyChangeSettings { args } 104 104 private method GetImage { widget } 105 105 private method ReceiveImage { size cacheid frame rock } … … 107 107 private method AddImageControls { frame widget } 108 108 private method SetWaitVariable { value } { 109 set _getimage $value 109 set _getimage $value 110 110 } 111 111 private method WaitForResponse {} { … … 125 125 public method Connect {} 126 126 public method Disconnect {} 127 public method ResetView {} 127 public method ResetView {} 128 128 public method add {dataobj {options ""}} 129 129 public method delete {args} … … 132 132 public method isconnected {} 133 133 public method labels {option {model "all"}} 134 public method parameters {title args} { 135 # do nothing 134 public method parameters {title args} { 135 # do nothing 136 136 } 137 137 … … 236 236 $this-showlabels-initialized no 237 237 }] 238 238 239 239 itk_component add 3dview { 240 240 label $itk_component(plotarea).view -image $_image(plot) \ … … 294 294 Rappture::Tooltip::for $itk_component(labels) \ 295 295 "Show/hide the labels on atoms" 296 pack $itk_component(labels) -padx 2 -pady {6 2} 296 pack $itk_component(labels) -padx 2 -pady {6 2} 297 297 298 298 itk_component add rock { … … 303 303 -variable [itcl::scope _settings($this-rock)] 304 304 } 305 pack $itk_component(rock) -padx 2 -pady 2 305 pack $itk_component(rock) -padx 2 -pady 2 306 306 Rappture::Tooltip::for $itk_component(rock) "Rock model back and forth" 307 307 … … 319 319 BuildSettingsTab 320 320 321 # HACK ALERT. Initially force a requested width of the 3dview label. 321 # HACK ALERT. Initially force a requested width of the 3dview label. 322 322 323 323 # It's a chicken-and-the-egg problem. The size of the 3dview label is set … … 463 463 if { $showlabels != "" && [string is boolean $showlabels] } { 464 464 set _settings($this-showlabels) $showlabels 465 } 465 } 466 466 } 467 467 … … 567 567 -variable [itcl::scope _downloadPopup(format)] \ 568 568 -font "Arial 10 " \ 569 -value pdb 569 -value pdb 570 570 Rappture::Tooltip::for $inner.pdb \ 571 571 "Save as PDB Protein Data Bank format file." … … 573 573 -variable [itcl::scope _downloadPopup(format)] \ 574 574 -font "Arial 10 " \ 575 -value image 575 -value image 576 576 Rappture::Tooltip::for $inner.image \ 577 577 "Save as image." … … 589 589 blt::table $f \ 590 590 0,0 $f.ok \ 591 0,1 $f.cancel 591 0,1 $f.cancel 592 592 blt::table $inner \ 593 593 0,0 $inner.summary -anchor w \ … … 628 628 } else { 629 629 set inner [$popup component inner] 630 } 630 } 631 631 update 632 632 # Activate the popup and call for the output. … … 635 635 $popup activate $widget left 636 636 set bool [WaitForResponse] 637 $popup deactivate 637 $popup deactivate 638 638 if { $bool } { 639 639 return [GetImage $widget] … … 674 674 return 0 675 675 } 676 set _reset 1 676 set _reset 1 677 677 set result [VisViewer::Connect $hosts] 678 678 if { $result } { … … 684 684 set info {} 685 685 set user "???" 686 686 if { [info exists env(USER)] } { 687 687 set user $env(USER) 688 688 } 689 689 set session "???" 690 690 if { [info exists env(SESSION)] } { 691 691 set session $env(SESSION) 692 692 } 693 693 lappend info "version" "$Rappture::version" 694 694 lappend info "build" "$Rappture::build" … … 760 760 incr count 761 761 if { $cacheid != $_cacheid } { 762 array unset _imagecache 762 array unset _imagecache 763 763 set _cacheid $cacheid 764 764 } … … 798 798 "sticks" "sticks" \ 799 799 "lines" "lines" \ 800 "cartoon" "cartoon" 800 "cartoon" "cartoon" 801 801 802 802 bind $inner.rep <<Value>> [itcl::code $this Representation] … … 883 883 # Turn on buffering of commands to the server. We don't want to 884 884 # be preempted by a server disconnect/reconnect (that automatically 885 # generates a new call to Rebuild). 885 # generates a new call to Rebuild). 886 886 StartBufferingCommands 887 887 set _cell 0 … … 897 897 set dlist [get] 898 898 foreach dataobj $dlist { 899 900 901 899 if { $_first == "" } { 900 set _first $dataobj 901 } 902 902 set model [$dataobj get components.molecule.model] 903 903 if {"" == $model } { … … 906 906 set model $model$suffix 907 907 } 908 lappend _obj2models($dataobj) $model 908 lappend _obj2models($dataobj) $model 909 909 set state [$dataobj get components.molecule.state] 910 if {"" == $state} { 911 set state $_state(server) 910 if {"" == $state} { 911 set state $_state(server) 912 912 } 913 913 if { ![info exists _mlist($model)] } { # new, turn on 914 914 set _mlist($model) 2 915 915 } elseif { $_mlist($model) == 1 } { # on, leave on 916 set _mlist($model) 3 916 set _mlist($model) 3 917 917 } elseif { $_mlist($model) == 0 } { # off, turn on 918 918 set _mlist($model) 2 … … 1002 1002 set charge "" 1003 1003 if { "" == $lammpstypemap} { 1004 set atom $type 1004 set atom $type 1005 1005 } else { 1006 1006 set atom [lindex $lammpstypemap [expr {$type - 1}]] … … 1012 1012 append data3 $pdbline 1013 1013 } 1014 # only read first model 1014 # only read first model 1015 1015 if {[regexp "^ITEM: ATOMS" $lammpsline]} { 1016 1016 incr modelcount … … 1025 1025 set numBytes [string length $data3] 1026 1026 1027 # We know we're buffered here, so append the "loadpdb" 1027 # We know we're buffered here, so append the "loadpdb" 1028 1028 # command with the data payload immediately afterwards. 1029 1029 ServerCmd "loadpdb -defer follows $model $state $numBytes" … … 1057 1057 } 1058 1058 } 1059 1059 1060 1060 # enable/disable models as required (0=off->off, 1=on->off, 2=off->on, 1061 1061 # 3=on->on) … … 1074 1074 } 1075 1075 if { $_mlist($model) == 1 } { 1076 if { [info exists _model($model-newtransparency)] || 1076 if { [info exists _model($model-newtransparency)] || 1077 1077 [info exists _model($model-newrep)] } { 1078 1078 if { ![info exists _model($model-newrep)] } { … … 1118 1118 # Set or restore viewing parameters. We do this for the first 1119 1119 # model and assume this works for everything else. 1120 set w [winfo width $itk_component(3dview)] 1121 set h [winfo height $itk_component(3dview)] 1122 ServerCmd [subst { 1120 set w [winfo width $itk_component(3dview)] 1121 set h [winfo height $itk_component(3dview)] 1122 ServerCmd [subst { 1123 1123 reset 1124 1124 screen $w $h … … 1134 1134 if { $changed } { 1135 1135 # Default settings for all models. 1136 SphereScale update 1136 SphereScale update 1137 1137 StickRadius update 1138 labels update 1139 Opacity update 1140 CartoonTrace update 1138 labels update 1139 Opacity update 1140 CartoonTrace update 1141 1141 Cell update 1142 OrthoProjection update 1142 OrthoProjection update 1143 1143 Representation update 1144 1144 } … … 1188 1188 $_image(plot) configure -width $_width -height $_height 1189 1189 # Immediately invalidate cache, defer update until mapped 1190 array unset _imagecache 1190 array unset _imagecache 1191 1191 set _resizePending 0 1192 1192 } 1193 1193 1194 1194 itcl::body Rappture::MolvisViewer::EventuallyResize { w h } { 1195 1195 set _width $w … … 1203 1203 itcl::body Rappture::MolvisViewer::DoRotate {} { 1204 1204 ServerCmd "rotate $_view(a) $_view(b) $_view(c)" 1205 array unset _imagecache 1205 array unset _imagecache 1206 1206 set _rotatePending 0 1207 1207 } 1208 1208 1209 1209 itcl::body Rappture::MolvisViewer::EventuallyRotate { a b c } { 1210 set _view(a) $a 1210 set _view(a) $a 1211 1211 set _view(b) $b 1212 set _view(c) $c 1212 set _view(c) $c 1213 1213 if { !$_rotatePending } { 1214 1214 $_dispatcher event -after 100 !rotate … … 1246 1246 set _view(x) [expr $_view(x) + $dx] 1247 1247 set _view(y) [expr $_view(y) + $dy] 1248 array unset _imagecache 1248 array unset _imagecache 1249 1249 ServerCmd "pan $dx $dy" 1250 1250 return … … 1253 1253 set option "click" 1254 1254 } 1255 if { $option == "click" } { 1255 if { $option == "click" } { 1256 1256 $itk_component(3dview) configure -cursor hand1 1257 1257 } … … 1261 1261 set _view(x) [expr $_view(x) + $dx] 1262 1262 set _view(y) [expr $_view(y) + $dy] 1263 array unset _imagecache 1263 array unset _imagecache 1264 1264 ServerCmd "pan $dx $dy" 1265 1265 } … … 1294 1294 } 1295 1295 } 1296 array unset _imagecache 1296 array unset _imagecache 1297 1297 } 1298 1298 … … 1324 1324 return 1325 1325 } 1326 set _rocker(on) $_settings($this-rock) 1326 set _rocker(on) $_settings($this-rock) 1327 1327 if { $option == "step"} { 1328 1328 if { $_rocker(client) >= 10 } { … … 1554 1554 } 1555 1555 if { $option == $_mrep } { 1556 return 1556 return 1557 1557 } 1558 1558 if { $option == "update" } { 1559 1559 set option $_settings($this-model) 1560 1560 } 1561 array unset _imagecache 1561 array unset _imagecache 1562 1562 if { $option == "sticks" } { 1563 1563 set _settings($this-modelimg) [Rappture::icon lines] … … 1659 1659 return 1660 1660 } 1661 array unset _imagecache 1661 array unset _imagecache 1662 1662 if { $cell } { 1663 1663 Rappture::Tooltip::for $itk_component(ortho) \ … … 1723 1723 } 1724 1724 } 1725 1725 1726 1726 itcl::body Rappture::MolvisViewer::GetImage { widget } { 1727 1727 set token "print[incr _nextToken]" … … 1729 1729 set $var "" 1730 1730 1731 set controls $_downloadPopup(image_controls) 1731 set controls $_downloadPopup(image_controls) 1732 1732 set combo $controls.size 1733 1733 set size [$combo translate [$combo value]] … … 1751 1751 # Setup an automatic timeout procedure. 1752 1752 $_dispatcher dispatch $this !pngtimeout "set $var {} ; list" 1753 1753 1754 1754 set popup .molvisviewerimagedownload 1755 1755 if { ![winfo exists $popup] } { … … 1765 1765 1,0 $inner.please -anchor w \ 1766 1766 1,1 $inner.icon -anchor e \ 1767 2,0 $inner.cancel -cspan 2 1768 blt::table configure $inner r0 -pady 4 1769 blt::table configure $inner r2 -pady 4 1767 2,0 $inner.cancel -cspan 2 1768 blt::table configure $inner r0 -pady 4 1769 blt::table configure $inner r2 -pady 4 1770 1770 bind $inner.cancel <Return> [list $inner.cancel invoke] 1771 1771 bind $inner.cancel <KP_Enter> [list $inner.cancel invoke] … … 1775 1775 set combo $controls.bgcolor 1776 1776 set bgcolor [$combo translate [$combo value]] 1777 1777 1778 1778 $_dispatcher event -after 60000 !pngtimeout 1779 1779 WaitIcon start $inner.icon 1780 1780 grab set $inner 1781 1781 focus $inner.cancel 1782 1782 1783 1783 ServerCmd "print $token $width $height $bgcolor" 1784 1784 1785 1785 $popup activate $widget below 1786 # We wait here for either 1787 # 1) the png to be delivered or 1788 # 2) timeout or 1786 # We wait here for either 1787 # 1) the png to be delivered or 1788 # 2) timeout or 1789 1789 # 3) user cancels the operation. 1790 1790 tkwait variable $var … … 1826 1826 # 1827 1827 # Used internally to change the molecular atom scale used to render 1828 # our scene. 1829 # 1830 # Note: Only sets the specified radius for active models. If the model 1828 # our scene. 1829 # 1830 # Note: Only sets the specified radius for active models. If the model 1831 1831 # is inactive, then it overridden with the value "0.1". 1832 1832 # ---------------------------------------------------------------------- … … 1864 1864 # our scene. 1865 1865 # 1866 # Note: Only sets the specified radius for active models. If the model 1866 # Note: Only sets the specified radius for active models. If the model 1867 1867 # is inactive, then it overridden with the value "0.25". 1868 1868 # ---------------------------------------------------------------------- … … 1900 1900 # our scene. 1901 1901 # 1902 # Note: Only sets the specified transparency for active models. If the model 1902 # Note: Only sets the specified transparency for active models. If the model 1903 1903 # is inactive, then it overridden with the value "0.75". 1904 1904 # ---------------------------------------------------------------------- … … 1971 1971 # ---------------------------------------------------------------------- 1972 1972 itcl::body Rappture::MolvisViewer::CartoonTrace {option {models "all"}} { 1973 array unset _imagecache 1973 array unset _imagecache 1974 1974 set trace $_settings($this-cartoontrace) 1975 1975 if { $option == "update" } { … … 1996 1996 1997 1997 itcl::body Rappture::MolvisViewer::AddImageControls { inner widget } { 1998 label $inner.size_l -text "Size:" -font "Arial 9" 1998 label $inner.size_l -text "Size:" -font "Arial 9" 1999 1999 set _downloadPopup(image_controls) $inner 2000 2000 set img $_image(plot) … … 2006 2006 "highquality" "High Quality (2400x2400)" 2007 2007 2008 label $inner.bgcolor_l -text "Background:" -font "Arial 9" 2008 label $inner.bgcolor_l -text "Background:" -font "Arial 9" 2009 2009 Rappture::Combobox $inner.bgcolor -width 30 -editable no 2010 2010 $inner.bgcolor choices insert end \ 2011 2011 "black" "Black" \ 2012 2012 "white" "White" \ 2013 "none" "Transparent (PNG only)" 2014 2015 label $inner.format_l -text "Format:" -font "Arial 9" 2013 "none" "Transparent (PNG only)" 2014 2015 label $inner.format_l -text "Format:" -font "Arial 9" 2016 2016 Rappture::Combobox $inner.format -width 30 -editable no 2017 2017 $inner.format choices insert end \ … … 2034 2034 blt::table $f \ 2035 2035 0,0 $f.ok \ 2036 0,1 $f.cancel 2036 0,1 $f.cancel 2037 2037 2038 2038 blt::table $inner \ … … 2048 2048 $inner.bgcolor value "Black" 2049 2049 $inner.size value "Draft (400x400)" 2050 $inner.format value "PNG (Portable Network Graphics format)" 2050 $inner.format value "PNG (Portable Network Graphics format)" 2051 2051 } 2052 2052 … … 2055 2055 set w [image width $_image(plot)] 2056 2056 set h [image height $_image(plot)] 2057 } 2057 } 2058 2058 set tag "$_state(client),$_rocker(client)" 2059 2059 if { $_image(id) != "$tag" } { … … 2122 2122 } 2123 2123 2124 # Scale and translate points 2124 # Scale and translate points 2125 2125 for { set i 0 } { $i < 8 } { incr i } { 2126 2126 point${i} expr "(point${i} * scale) + origin"
Note: See TracChangeset
for help on using the changeset viewer.