Changeset 5254
- Timestamp:
- Apr 17, 2015 6:34:56 PM (6 years ago)
- Location:
- branches/1.3/gui/scripts
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3/gui/scripts/flowvisviewer.tcl
r5230 r5254 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: flowvisviewer - 3D flow rendering 4 #5 4 # 6 5 # This widget performs volume and flow rendering on 3D scalar/vector datasets. … … 64 63 public method isconnected {} 65 64 public method limits { tf } 66 public method over marker { m x }65 public method overMarker { m x } 67 66 public method parameters {title args} { 68 67 # do nothing 69 68 } 70 public method r mdupmarker { m x }69 public method removeDuplicateMarker { m x } 71 70 public method scale {args} 72 public method update transferfuncs {}71 public method updateTransferFunctions {} 73 72 74 73 protected method Connect {} … … 1162 1161 unset _recvObjs($tag) 1163 1162 if { [array size _recvObjs] == 0 } { 1164 update transferfuncs1163 updateTransferFunctions 1165 1164 } 1166 1165 } … … 1655 1654 set tf $_activeTf 1656 1655 set _settings($this-$tf-opacity) $opacity 1657 update transferfuncs1656 updateTransferFunctions 1658 1657 } 1659 1658 } … … 1666 1665 set tf $_activeTf 1667 1666 set _settings($this-$tf-thickness) $sval 1668 update transferfuncs1667 updateTransferFunctions 1669 1668 } 1670 1669 } … … 2007 2006 # USAGE: UndateTransferFuncs 2008 2007 # ---------------------------------------------------------------------- 2009 itcl::body Rappture::FlowvisViewer::update transferfuncs {} {2008 itcl::body Rappture::FlowvisViewer::updateTransferFunctions {} { 2010 2009 $_dispatcher event -after 100 !send_transfunc 2011 2010 } … … 2021 2020 $m relval [expr {double($x-10)/($w-20)}] 2022 2021 lappend _isomarkers($tf) $m 2023 update transferfuncs2022 updateTransferFunctions 2024 2023 return 1 2025 2024 } 2026 2025 2027 itcl::body Rappture::FlowvisViewer::r mdupmarker { marker x } {2026 itcl::body Rappture::FlowvisViewer::removeDuplicateMarker { marker x } { 2028 2027 set tf [$marker transferfunc] 2029 2028 set bool 0 … … 2045 2044 } 2046 2045 set _isomarkers($tf) $list 2047 update transferfuncs2046 updateTransferFunctions 2048 2047 } 2049 2048 return $bool 2050 2049 } 2051 2050 2052 itcl::body Rappture::FlowvisViewer::over marker { marker x } {2051 itcl::body Rappture::FlowvisViewer::overMarker { marker x } { 2053 2052 set tf [$marker transferfunc] 2054 2053 if { [info exists _isomarkers($tf)] } { -
branches/1.3/gui/scripts/isomarker.tcl
r5115 r5254 1 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 3 2 # ---------------------------------------------------------------------- 4 3 # COMPONENT: nanovisviewer::isomarker - Marker for 3D volume rendering … … 30 29 private common _normalIcon [Rappture::icon nvlegendmark] 31 30 private common _activeIcon [Rappture::icon nvlegendmark2] 31 private method EnterTick {} 32 private method LeaveTick {} 33 private method StartDrag { x y } 34 private method ContinueDrag { x y } 35 private method StopDrag { x y } 32 36 33 constructor {c obj tf args} { 34 set _canvas $c 35 set _nvobj $obj 36 set _tf $tf 37 set w [winfo width $_canvas] 38 set h [winfo height $_canvas] 39 set _tick [$c create image 0 $h \ 40 -image $_normalIcon -anchor s \ 41 -tags "$this $obj" -state hidden] 42 set _label [$c create text 0 $h \ 43 -anchor n -fill white -font "Helvetica 8" \ 44 -tags "$this $obj" -state hidden] 45 $c bind $_tick <Enter> [itcl::code $this HandleEvent "enter"] 46 $c bind $_tick <Leave> [itcl::code $this HandleEvent "leave"] 47 $c bind $_tick <ButtonPress-1> \ 48 [itcl::code $this HandleEvent "start" %x %y] 49 $c bind $_tick <B1-Motion> \ 50 [itcl::code $this HandleEvent "update" %x %y] 51 $c bind $_tick <ButtonRelease-1> \ 52 [itcl::code $this HandleEvent "end" %x %y] 53 } 54 destructor { 37 constructor {c obj tf args} {} 38 destructor {} 39 public method transferfunc {} 40 public method activate { bool } 41 public method visible { bool } 42 public method screenpos {} 43 public method absval { {x "-get"} } 44 public method relval { {x "-get"} } 45 } 46 47 itcl::body Rappture::IsoMarker::constructor {c obj tf args} { 48 set _canvas $c 49 set _nvobj $obj 50 set _tf $tf 51 set w [winfo width $_canvas] 52 set h [winfo height $_canvas] 53 set _tick [$c create image 0 $h \ 54 -image $_normalIcon -anchor s \ 55 -tags "$this $obj" -state hidden] 56 set _label [$c create text 0 $h \ 57 -anchor n -fill white -font "Helvetica 8" \ 58 -tags "$this $obj" -state hidden] 59 $c bind $_tick <Enter> [itcl::code $this EnterTick] 60 $c bind $_tick <Leave> [itcl::code $this LeaveTick] 61 $c bind $_tick <ButtonPress-1> [itcl::code $this StartDrag %x %y] 62 $c bind $_tick <B1-Motion> [itcl::code $this ContinueDrag %x %y] 63 $c bind $_tick <ButtonRelease-1> [itcl::code $this StopDrag %x %y] 64 } 65 66 itcl::body Rappture::IsoMarker::destructor {} { 67 if { [winfo exists $_canvas] } { 55 68 $_canvas delete $this 56 69 } 57 public method transferfunc {} { 58 return $_tf 70 } 71 72 itcl::body Rappture::IsoMarker::transferfunc {} { 73 return $_tf 74 } 75 76 itcl::body Rappture::IsoMarker::activate { bool } { 77 if { $bool || $_activePress || $_activeMotion } { 78 $_canvas itemconfigure $_label -state normal 79 $_canvas itemconfigure $_tick -image $_activeIcon 80 } else { 81 $_canvas itemconfigure $_label -state hidden 82 $_canvas itemconfigure $_tick -image $_normalIcon 59 83 } 60 public method activate { bool } { 61 if { $bool || $_activePress || $_activeMotion } { 62 $_canvas itemconfigure $_label -state normal 63 $_canvas itemconfigure $_tick -image $_activeIcon 64 } else { 65 $_canvas itemconfigure $_label -state hidden 66 $_canvas itemconfigure $_tick -image $_normalIcon 67 } 84 } 85 86 itcl::body Rappture::IsoMarker::visible { bool } { 87 if { $bool } { 88 absval $_value 89 $_canvas itemconfigure $_tick -state normal 90 $_canvas raise $_tick 91 } else { 92 $_canvas itemconfigure $_tick -state hidden 68 93 } 69 public method visible { bool } { 70 if { $bool } { 71 absval $_value 72 $_canvas itemconfigure $_tick -state normal73 $_canvas raise $_tick74 } else {75 $_canvas itemconfigure $_tick -state hidden76 }94 } 95 96 itcl::body Rappture::IsoMarker::screenpos { } { 97 set x [relval] 98 if { $x < 0.0 } { 99 set x 0.0 100 } elseif { $x > 1.0 } { 101 set x 1.0 77 102 } 78 public method screenpos { } { 79 set x [relval] 80 if { $x < 0.0 } { 81 set x 0.0 82 } elseif { $x > 1.0 } { 83 set x 1.0 84 } 85 set low 10 86 set w [winfo width $_canvas] 87 set high [expr {$w - 10}] 88 set x [expr {round($x*($high - $low) + $low)}] 89 return $x 103 set low 10 104 set w [winfo width $_canvas] 105 set high [expr {$w - 10}] 106 set x [expr {round($x*($high - $low) + $low)}] 107 return $x 108 } 109 110 itcl::body Rappture::IsoMarker::absval { {x "-get"} } { 111 if { $x != "-get" } { 112 set _value $x 113 set y 31 114 $_canvas itemconfigure $_label -text [format %.2g $_value] 115 set x [screenpos] 116 $_canvas coords $_tick $x [expr {$y+3}] 117 $_canvas coords $_label $x [expr {$y+5}] 90 118 } 91 public method absval { {x "-get"} } { 92 if { $x != "-get" } { 93 set _value $x 94 set y 31 95 $_canvas itemconfigure $_label -text [format %.2g $_value] 96 set x [screenpos] 97 $_canvas coords $_tick $x [expr {$y+3}] 98 $_canvas coords $_label $x [expr {$y+5}] 99 } 100 return $_value 101 } 102 public method relval { {x "-get"} } { 103 if { $x == "-get" } { 104 array set limits [$_nvobj limits $_tf] 105 if { $limits(vmax) == $limits(vmin) } { 106 if { $limits(vmax) == 0.0 } { 107 set limits(vmin) 0.0 108 set limits(vmax) 1.0 109 } else { 110 set limits(vmax) [expr $limits(vmin) + 1.0] 111 } 112 } 113 return [expr {($_value-$limits(vmin))/ 114 ($limits(vmax) - $limits(vmin))}] 115 } 116 array set limits [$_nvobj limits $_tf] 117 if { $limits(vmax) == $limits(vmin) } { 118 set limits(vmin) 0.0 119 set limits(vmax) 1.0 120 } 121 if { [catch {expr $limits(vmax) - $limits(vmin)} r] != 0 } { 122 return 0.0 123 } 124 absval [expr {($x * $r) + $limits(vmin)}] 125 } 126 private method HandleEvent { option args } { 127 switch -- $option { 128 enter { 129 set _activeMotion 1 130 activate yes 131 $_canvas raise $_tick 132 } 133 leave { 134 set _activeMotion 0 135 activate no 136 } 137 start { 138 $_canvas raise $_tick 139 set _activePress 1 140 activate yes 141 $_canvas itemconfigure limits -state hidden 142 } 143 update { 144 set w [winfo width $_canvas] 145 set x [lindex $args 0] 146 relval [expr {double($x-10)/($w-20)}] 147 $_nvobj overmarker $this $x 148 $_nvobj updatetransferfuncs 149 } 150 end { 151 set x [lindex $args 0] 152 if { ![$_nvobj rmdupmarker $this $x]} { 153 eval HandleEvent update $args 154 } 155 set _activePress 0 156 activate no 157 $_canvas itemconfigure limits -state normal 158 } 159 default { 160 error "bad option \"$option\": should be start, update, end" 119 return $_value 120 } 121 122 itcl::body Rappture::IsoMarker::relval { {x "-get"} } { 123 array set limits [$_nvobj limits $_tf] 124 set min $limits(vmin) 125 set max $limits(vmax) 126 if { $x == "-get" } { 127 if { $max == $min } { 128 if { $max == 0.0 } { 129 set min 0.0 130 set max 1.0 131 } else { 132 set max [expr $min + 1.0] 161 133 } 162 134 } 135 return [expr {($_value - $min) / ($max - $min)}] 163 136 } 137 if { $max == $min } { 138 set min 0.0 139 set max 1.0 140 } 141 if { [catch {expr $max - $min} r] != 0 } { 142 return 0.0 143 } 144 absval [expr {($x * $r) + $min}] 164 145 } 146 147 itcl::body Rappture::IsoMarker::EnterTick {} { 148 set _activeMotion 1 149 activate yes 150 $_canvas raise $_tick 151 } 152 153 itcl::body Rappture::IsoMarker::LeaveTick {} { 154 set _activeMotion 0 155 activate no 156 } 157 158 itcl::body Rappture::IsoMarker::StartDrag { x y } { 159 $_canvas raise $_tick 160 set _activePress 1 161 activate yes 162 $_canvas itemconfigure limits -state hidden 163 } 164 165 itcl::body Rappture::IsoMarker::StopDrag { x y } { 166 if { ![$_nvobj removeDuplicateMarker $this $x]} { 167 ContinueDrag $x $y 168 } 169 set _activePress 0 170 activate no 171 $_canvas itemconfigure limits -state normal 172 } 173 174 itcl::body Rappture::IsoMarker::ContinueDrag { x y } { 175 set w [winfo width $_canvas] 176 relval [expr {double($x-10)/($w-20)}] 177 $_nvobj overMarker $this $x 178 $_nvobj updateTransferFunctions 179 } -
branches/1.3/gui/scripts/nanovisviewer.tcl
r5230 r5254 1 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 3 2 # ---------------------------------------------------------------------- 4 3 # COMPONENT: nanovisviewer - 3D volume rendering … … 76 75 public method isconnected {} 77 76 public method limits { tf } 78 public method over marker { m x }77 public method overMarker { m x } 79 78 public method parameters {title args} { 80 79 # do nothing 81 80 } 82 public method r mdupmarker { m x }81 public method removeDuplicateMarker { m x } 83 82 public method scale {args} 84 public method update transferfuncs {}83 public method updateTransferFunctions {} 85 84 86 85 protected method Connect {} … … 848 847 # the first data object. This assumes that the data is always 849 848 # successfully transferred. 850 update transferfuncs849 updateTransferFunctions 851 850 } 852 851 } … … 976 975 set cname [lindex [$_first components] 0] 977 976 if { [info exists _serverDatasets($_first-$cname)] } { 978 update transferfuncs977 updateTransferFunctions 979 978 } 980 979 } … … 1225 1224 set _activeTfs($tf) 0 1226 1225 } 1227 update transferfuncs1226 updateTransferFunctions 1228 1227 } 1229 1228 thickness { … … 1236 1235 set _activeTfs($tf) 0 1237 1236 } 1238 update transferfuncs1237 updateTransferFunctions 1239 1238 } 1240 1239 } … … 1549 1548 # USAGE: UndateTransferFuncs 1550 1549 # ---------------------------------------------------------------------- 1551 itcl::body Rappture::NanovisViewer::update transferfuncs {} {1550 itcl::body Rappture::NanovisViewer::updateTransferFunctions {} { 1552 1551 $_dispatcher event -idle !send_transfunc 1553 1552 } … … 1564 1563 $m relval [expr {double($x-10)/($w-20)}] 1565 1564 lappend _isomarkers($tf) $m 1566 update transferfuncs1565 updateTransferFunctions 1567 1566 return 1 1568 1567 } 1569 1568 1570 itcl::body Rappture::NanovisViewer::r mdupmarker { marker x } {1569 itcl::body Rappture::NanovisViewer::removeDuplicateMarker { marker x } { 1571 1570 set tf [$marker transferfunc] 1572 1571 set bool 0 … … 1588 1587 } 1589 1588 set _isomarkers($tf) $list 1590 update transferfuncs1589 updateTransferFunctions 1591 1590 } 1592 1591 return $bool 1593 1592 } 1594 1593 1595 itcl::body Rappture::NanovisViewer::over marker { marker x } {1594 itcl::body Rappture::NanovisViewer::overMarker { marker x } { 1596 1595 set tf [$marker transferfunc] 1597 1596 if { [info exists _isomarkers($tf)] } {
Note: See TracChangeset
for help on using the changeset viewer.