- Timestamp:
- Jul 21, 2015 11:52:08 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/vtkstreamlinesviewer.tcl
r5765 r5770 66 66 private method BuildAxisTab {} 67 67 private method BuildCameraTab {} 68 private method BuildColormap { name colors}68 private method BuildColormap { name } 69 69 private method BuildCutplaneTab {} 70 70 private method BuildDownloadPopup { widget command } … … 102 102 private method RequestLegend {} 103 103 private method Rotate {option x y} 104 private method SetColormap { dataobj comp } 105 private method ChangeColormap { dataobj comp color } 104 private method SetCurrentColormap { color } 106 105 private method SetLegendTip { x y } 107 106 private method SetObjectStyle { dataobj comp } … … 121 120 private variable _colormaps ; # contains all the colormaps 122 121 ; # in the server. 123 private variable _ dataset2style ;# maps dataobj-component to transfunc122 private variable _currentColormap "" 124 123 125 124 private variable _click ; # info used for rotate operations … … 127 126 private variable _view ; # view params for 3D view 128 127 private variable _settings 129 private variable _style; # Array of current component styles.130 private variable _initialStyle; # Array of initial component styles.131 128 private variable _reset 1; # Connection to server has been reset. 132 129 … … 849 846 array unset _colormaps 850 847 array unset _seeds 851 array unset _dataset2style852 848 } 853 849 … … 1444 1440 set colormap [$itk_component(colormap) value] 1445 1441 set _settings($what) $colormap 1446 foreach dataset [CurrentDatasets -visible $_first] { 1447 foreach {dataobj comp} [split $dataset -] break 1448 ChangeColormap $dataobj $comp $colormap 1449 } 1442 SetCurrentColormap $colormap 1450 1443 set _legendPending 1 1451 1444 } … … 1524 1517 } 1525 1518 # Set the legend on the first streamlines dataset. 1526 foreach dataset [CurrentDatasets -visible $_first] { 1527 foreach {dataobj comp} [split $dataset -] break 1528 if { [info exists _dataset2style($dataset)] } { 1529 SendCmd \ 1530 "legend $_dataset2style($dataset) $_colorMode $_curFldName {} $w $h 0" 1531 break; 1532 } 1533 } 1534 } 1535 1536 # 1537 # ChangeColormap -- 1538 # 1539 itcl::body Rappture::VtkStreamlinesViewer::ChangeColormap {dataobj comp color} { 1540 set tag $dataobj-$comp 1541 if { ![info exist _style($tag)] } { 1542 error "no initial colormap" 1543 } 1544 array set style $_style($tag) 1545 set style(-color) $color 1546 set _style($tag) [array get style] 1547 SetColormap $dataobj $comp 1548 } 1549 1550 # 1551 # SetColormap -- 1552 # 1553 itcl::body Rappture::VtkStreamlinesViewer::SetColormap { dataobj comp } { 1554 array set style { 1555 -color BCGYR 1556 } 1557 set tag $dataobj-$comp 1558 if { ![info exists _initialStyle($tag)] } { 1559 # Save the initial component style. 1560 set _initialStyle($tag) [$dataobj style $comp] 1561 } 1562 1563 # Override defaults with initial style defined in xml. 1564 array set style $_initialStyle($tag) 1565 1566 if { ![info exists _style($tag)] } { 1567 set _style($tag) [array get style] 1568 } 1569 # Override initial style with current style. 1570 array set style $_style($tag) 1571 1572 set name "$style(-color)" 1519 if { $_currentColormap != "" } { 1520 set cmap $_currentColormap 1521 if { ![info exists _colormaps($cmap)] } { 1522 BuildColormap $cmap 1523 set _colormaps($cmap) 1 1524 } 1525 #SendCmd "legend $cmap $_colorMode $_curFldName {} $w $h 0" 1526 SendCmd "legend2 $cmap $w $h" 1527 } 1528 } 1529 1530 # 1531 # SetCurrentColormap -- 1532 # 1533 itcl::body Rappture::VtkStreamlinesViewer::SetCurrentColormap { name } { 1534 # Keep track of the colormaps that we build. 1573 1535 if { ![info exists _colormaps($name)] } { 1574 BuildColormap $name [array get style]1536 BuildColormap $name 1575 1537 set _colormaps($name) 1 1576 1538 } 1577 if { ![info exists _dataset2style($tag)] || 1578 $_dataset2style($tag) != $name } { 1579 SendCmd "streamlines colormap $name $tag" 1580 SendCmd "cutplane colormap $name $tag" 1581 set _dataset2style($tag) $name 1582 } 1539 set _currentColormap $name 1540 SendCmd "streamlines colormap $_currentColormap" 1541 SendCmd "cutplane colormap $_currentColormap" 1583 1542 } 1584 1543 … … 1586 1545 # BuildColormap -- 1587 1546 # 1588 itcl::body Rappture::VtkStreamlinesViewer::BuildColormap { name styles } { 1589 array set style $styles 1590 set cmap [ColorsToColormap $style(-color)] 1547 itcl::body Rappture::VtkStreamlinesViewer::BuildColormap { name } { 1548 set cmap [ColorsToColormap $name] 1591 1549 if { [llength $cmap] == 0 } { 1592 1550 set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0" … … 2140 2098 # Parse style string. 2141 2099 set tag $dataobj-$comp 2142 set style [$dataobj style $comp] 2143 array set settings { 2100 array set style { 2144 2101 -color BCGYR 2145 2102 -constcolor white … … 2163 2120 -visible 1 2164 2121 } 2122 array set style [$dataobj style $comp] 2165 2123 if { $dataobj != $_first } { 2166 set settings(-opacity) 1 2167 } 2168 array set settings $style 2124 set style(-opacity) 1.0 2125 } 2169 2126 StartBufferingCommands 2170 2127 SendCmd "streamlines add $tag" 2171 SendCmd "streamlines color [Color2RGB $s ettings(-constcolor)] $tag"2172 SendCmd "streamlines edges $s ettings(-edges) $tag"2173 SendCmd "streamlines linecolor [Color2RGB $s ettings(-edgecolor)] $tag"2174 SendCmd "streamlines linewidth $s ettings(-linewidth) $tag"2175 SendCmd "streamlines lighting $s ettings(-lighting) $tag"2176 SendCmd "streamlines opacity $s ettings(-opacity) $tag"2177 SendCmd "streamlines seed color [Color2RGB $s ettings(-seedcolor)] $tag"2178 SendCmd "streamlines seed visible $s ettings(-seeds) $tag"2179 SendCmd "streamlines visible $s ettings(-visible) $tag"2128 SendCmd "streamlines color [Color2RGB $style(-constcolor)] $tag" 2129 SendCmd "streamlines edges $style(-edges) $tag" 2130 SendCmd "streamlines linecolor [Color2RGB $style(-edgecolor)] $tag" 2131 SendCmd "streamlines linewidth $style(-linewidth) $tag" 2132 SendCmd "streamlines lighting $style(-lighting) $tag" 2133 SendCmd "streamlines opacity $style(-opacity) $tag" 2134 SendCmd "streamlines seed color [Color2RGB $style(-seedcolor)] $tag" 2135 SendCmd "streamlines seed visible $style(-seeds) $tag" 2136 SendCmd "streamlines visible $style(-visible) $tag" 2180 2137 set seeds [$dataobj hints seeds] 2181 2138 if { $seeds != "" && ![info exists _seeds($dataobj)] } { 2182 2139 set length [string length $seeds] 2183 SendCmd "streamlines seed fmesh $s ettings(-numseeds) data follows $length $tag"2140 SendCmd "streamlines seed fmesh $style(-numseeds) data follows $length $tag" 2184 2141 SendData $seeds 2185 2142 set _seeds($dataobj) 1 2186 2143 } 2187 set _settings(-streamlineslighting) $s ettings(-lighting)2188 $itk_component(streammode) value $s ettings(-mode)2144 set _settings(-streamlineslighting) $style(-lighting) 2145 $itk_component(streammode) value $style(-mode) 2189 2146 AdjustSetting -streamlinesmode 2190 set _settings(-streamlinesnumseeds) $s ettings(-numseeds)2191 set _settings(-streamlinesopacity) [expr $s ettings(-opacity) * 100.0]2192 set _settings(-streamlineslength) [expr $s ettings(-streamlineslength) * 100.0]2193 set _settings(-streamlinesseedsvisible) $s ettings(-seeds)2194 set _settings(-streamlinesvisible) $s ettings(-visible)2147 set _settings(-streamlinesnumseeds) $style(-numseeds) 2148 set _settings(-streamlinesopacity) [expr $style(-opacity) * 100.0] 2149 set _settings(-streamlineslength) [expr $style(-streamlineslength) * 100.0] 2150 set _settings(-streamlinesseedsvisible) $style(-seeds) 2151 set _settings(-streamlinesvisible) $style(-visible) 2195 2152 2196 2153 SendCmd "cutplane add $tag" 2197 2154 2198 2155 SendCmd "polydata add $tag" 2199 SendCmd "polydata color [Color2RGB $s ettings(-surfacecolor)] $tag"2156 SendCmd "polydata color [Color2RGB $style(-surfacecolor)] $tag" 2200 2157 SendCmd "polydata colormode constant {} $tag" 2201 SendCmd "polydata edges $s ettings(-surfaceedges) $tag"2202 SendCmd "polydata linecolor [Color2RGB $s ettings(-surfaceedgecolor)] $tag"2203 SendCmd "polydata lighting $s ettings(-surfacelighting) $tag"2204 SendCmd "polydata opacity $s ettings(-surfaceopacity) $tag"2205 SendCmd "polydata wireframe $s ettings(-surfacewireframe) $tag"2206 SendCmd "polydata visible $s ettings(-surfacevisible) $tag"2207 set _settings(-surfaceedges) $s ettings(-surfaceedges)2208 set _settings(-surfacelighting) $s ettings(-surfacelighting)2209 set _settings(-surfaceopacity) [expr $s ettings(-surfaceopacity) * 100.0]2210 set _settings(-surfacewireframe) $s ettings(-surfacewireframe)2211 set _settings(-surfacevisible) $s ettings(-surfacevisible)2158 SendCmd "polydata edges $style(-surfaceedges) $tag" 2159 SendCmd "polydata linecolor [Color2RGB $style(-surfaceedgecolor)] $tag" 2160 SendCmd "polydata lighting $style(-surfacelighting) $tag" 2161 SendCmd "polydata opacity $style(-surfaceopacity) $tag" 2162 SendCmd "polydata wireframe $style(-surfacewireframe) $tag" 2163 SendCmd "polydata visible $style(-surfacevisible) $tag" 2164 set _settings(-surfaceedges) $style(-surfaceedges) 2165 set _settings(-surfacelighting) $style(-surfacelighting) 2166 set _settings(-surfaceopacity) [expr $style(-surfaceopacity) * 100.0] 2167 set _settings(-surfacewireframe) $style(-surfacewireframe) 2168 set _settings(-surfacevisible) $style(-surfacevisible) 2212 2169 StopBufferingCommands 2213 SetC olormap $dataobj $comp2214 $itk_component(colormap) value $s ettings(-color)2170 SetCurrentColormap $style(-color) 2171 $itk_component(colormap) value $style(-color) 2215 2172 } 2216 2173
Note: See TracChangeset
for help on using the changeset viewer.