Changeset 5770 for trunk/gui


Ignore:
Timestamp:
Jul 21, 2015 11:52:08 AM (9 years ago)
Author:
ldelgass
Message:

Fix colormap handling in streamlines viewer to bring in line with other viewers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/vtkstreamlinesviewer.tcl

    r5765 r5770  
    6666    private method BuildAxisTab {}
    6767    private method BuildCameraTab {}
    68     private method BuildColormap { name colors }
     68    private method BuildColormap { name }
    6969    private method BuildCutplaneTab {}
    7070    private method BuildDownloadPopup { widget command }
     
    102102    private method RequestLegend {}
    103103    private method Rotate {option x y}
    104     private method SetColormap { dataobj comp }
    105     private method ChangeColormap { dataobj comp color }
     104    private method SetCurrentColormap { color }
    106105    private method SetLegendTip { x y }
    107106    private method SetObjectStyle { dataobj comp }
     
    121120    private variable _colormaps    ;    # contains all the colormaps
    122121                                   ;    # in the server.
    123     private variable _dataset2style    ;# maps dataobj-component to transfunc
     122    private variable _currentColormap ""
    124123
    125124    private variable _click        ;    # info used for rotate operations
     
    127126    private variable _view         ;    # view params for 3D view
    128127    private variable _settings
    129     private variable _style;            # Array of current component styles.
    130     private variable _initialStyle;     # Array of initial component styles.
    131128    private variable _reset 1;          # Connection to server has been reset.
    132129
     
    849846    array unset _colormaps
    850847    array unset _seeds
    851     array unset _dataset2style
    852848}
    853849
     
    14441440            set colormap [$itk_component(colormap) value]
    14451441            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
    14501443            set _legendPending 1
    14511444        }
     
    15241517    }
    15251518    # 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#
     1533itcl::body Rappture::VtkStreamlinesViewer::SetCurrentColormap { name } {
     1534    # Keep track of the colormaps that we build.
    15731535    if { ![info exists _colormaps($name)] } {
    1574         BuildColormap $name [array get style]
     1536        BuildColormap $name
    15751537        set _colormaps($name) 1
    15761538    }
    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"
    15831542}
    15841543
     
    15861545# BuildColormap --
    15871546#
    1588 itcl::body Rappture::VtkStreamlinesViewer::BuildColormap { name styles } {
    1589     array set style $styles
    1590     set cmap [ColorsToColormap $style(-color)]
     1547itcl::body Rappture::VtkStreamlinesViewer::BuildColormap { name } {
     1548    set cmap [ColorsToColormap $name]
    15911549    if { [llength $cmap] == 0 } {
    15921550        set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
     
    21402098    # Parse style string.
    21412099    set tag $dataobj-$comp
    2142     set style [$dataobj style $comp]
    2143     array set settings {
     2100    array set style {
    21442101        -color BCGYR
    21452102        -constcolor white
     
    21632120        -visible 1
    21642121    }
     2122    array set style [$dataobj style $comp]
    21652123    if { $dataobj != $_first } {
    2166         set settings(-opacity) 1
    2167     }
    2168     array set settings $style
     2124        set style(-opacity) 1.0
     2125    }
    21692126    StartBufferingCommands
    21702127    SendCmd "streamlines add $tag"
    2171     SendCmd "streamlines color [Color2RGB $settings(-constcolor)] $tag"
    2172     SendCmd "streamlines edges $settings(-edges) $tag"
    2173     SendCmd "streamlines linecolor [Color2RGB $settings(-edgecolor)] $tag"
    2174     SendCmd "streamlines linewidth $settings(-linewidth) $tag"
    2175     SendCmd "streamlines lighting $settings(-lighting) $tag"
    2176     SendCmd "streamlines opacity $settings(-opacity) $tag"
    2177     SendCmd "streamlines seed color [Color2RGB $settings(-seedcolor)] $tag"
    2178     SendCmd "streamlines seed visible $settings(-seeds) $tag"
    2179     SendCmd "streamlines visible $settings(-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"
    21802137    set seeds [$dataobj hints seeds]
    21812138    if { $seeds != "" && ![info exists _seeds($dataobj)] } {
    21822139        set length [string length $seeds]
    2183         SendCmd "streamlines seed fmesh $settings(-numseeds) data follows $length $tag"
     2140        SendCmd "streamlines seed fmesh $style(-numseeds) data follows $length $tag"
    21842141        SendData $seeds
    21852142        set _seeds($dataobj) 1
    21862143    }
    2187     set _settings(-streamlineslighting) $settings(-lighting)
    2188     $itk_component(streammode) value $settings(-mode)
     2144    set _settings(-streamlineslighting) $style(-lighting)
     2145    $itk_component(streammode) value $style(-mode)
    21892146    AdjustSetting -streamlinesmode
    2190     set _settings(-streamlinesnumseeds) $settings(-numseeds)
    2191     set _settings(-streamlinesopacity) [expr $settings(-opacity) * 100.0]
    2192     set _settings(-streamlineslength) [expr $settings(-streamlineslength) * 100.0]
    2193     set _settings(-streamlinesseedsvisible) $settings(-seeds)
    2194     set _settings(-streamlinesvisible) $settings(-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)
    21952152
    21962153    SendCmd "cutplane add $tag"
    21972154
    21982155    SendCmd "polydata add $tag"
    2199     SendCmd "polydata color [Color2RGB $settings(-surfacecolor)] $tag"
     2156    SendCmd "polydata color [Color2RGB $style(-surfacecolor)] $tag"
    22002157    SendCmd "polydata colormode constant {} $tag"
    2201     SendCmd "polydata edges $settings(-surfaceedges) $tag"
    2202     SendCmd "polydata linecolor [Color2RGB $settings(-surfaceedgecolor)] $tag"
    2203     SendCmd "polydata lighting $settings(-surfacelighting) $tag"
    2204     SendCmd "polydata opacity $settings(-surfaceopacity) $tag"
    2205     SendCmd "polydata wireframe $settings(-surfacewireframe) $tag"
    2206     SendCmd "polydata visible $settings(-surfacevisible) $tag"
    2207     set _settings(-surfaceedges) $settings(-surfaceedges)
    2208     set _settings(-surfacelighting) $settings(-surfacelighting)
    2209     set _settings(-surfaceopacity) [expr $settings(-surfaceopacity) * 100.0]
    2210     set _settings(-surfacewireframe) $settings(-surfacewireframe)
    2211     set _settings(-surfacevisible) $settings(-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)
    22122169    StopBufferingCommands
    2213     SetColormap $dataobj $comp
    2214     $itk_component(colormap) value $settings(-color)
     2170    SetCurrentColormap $style(-color)
     2171    $itk_component(colormap) value $style(-color)
    22152172}
    22162173
Note: See TracChangeset for help on using the changeset viewer.