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

Merge r5758:r5765 from trunk

Location:
branches/1.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.4

  • branches/1.4/gui/scripts/vtkstreamlinesviewer.tcl

    r5388 r5766  
    7070    private method BuildDownloadPopup { widget command }
    7171    private method BuildStreamsTab {}
    72     private method BuildVolumeTab {}
     72    private method BuildSurfaceTab {}
    7373    private method DrawLegend {}
    7474    private method Combo { option }
     
    135135    private variable _title ""
    136136    private variable _seeds
    137 
    138     private common _downloadPopup;      # download options from popup
    139     private common _hardcopy
    140137    private variable _width 0
    141138    private variable _height 0
     
    145142    private variable _cutplanePending 0
    146143    private variable _legendPending 0
    147     private variable _vectorFields
    148     private variable _scalarFields
    149144    private variable _fields
    150145    private variable _curFldName ""
     
    153148    private variable _numSeeds 200
    154149    private variable _colorMode "vmag";#  Mode of colormap (vmag or scalar)
     150
     151    private common _downloadPopup;      # download options from popup
     152    private common _hardcopy
    155153}
    156154
     
    245243        -streamlinesnumseeds        200
    246244        -streamlinesopacity         100
    247         -streamlinesscale           1
     245        -streamlineslength          70
    248246        -streamlinesseedsvisible    0
    249247        -streamlinesvisible         1
    250         -volumeedges                0
    251         -volumelighting             1
    252         -volumeopacity              40
    253         -volumevisible              1
    254         -volumewireframe            0
     248        -surfaceedges               0
     249        -surfacelighting            1
     250        -surfaceopacity             40
     251        -surfacevisible             1
     252        -surfacewireframe           0
    255253        -xgrid                      0
    256254        -ygrid                      0
     
    330328    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
    331329
    332     itk_component add volume {
    333         Rappture::PushButton $f.volume \
     330    itk_component add surface {
     331        Rappture::PushButton $f.surface \
    334332            -onimage [Rappture::icon volume-on] \
    335333            -offimage [Rappture::icon volume-off] \
    336             -variable [itcl::scope _settings(-volumevisible)] \
    337             -command [itcl::code $this AdjustSetting -volumevisible]
    338     }
    339     $itk_component(volume) select
    340     Rappture::Tooltip::for $itk_component(volume) \
    341         "Don't display the volume"
    342     pack $itk_component(volume) -padx 2 -pady 2
     334            -variable [itcl::scope _settings(-surfacevisible)] \
     335            -command [itcl::code $this AdjustSetting -surfacevisible]
     336    }
     337    $itk_component(surface) select
     338    Rappture::Tooltip::for $itk_component(surface) \
     339        "Show/Hide the boundary surface"
     340    pack $itk_component(surface) -padx 2 -pady 2
    343341
    344342    itk_component add streamlines {
     
    351349    $itk_component(streamlines) select
    352350    Rappture::Tooltip::for $itk_component(streamlines) \
    353         "Toggle the streamlines on/off"
     351        "Show/Hide the streamlines"
    354352    pack $itk_component(streamlines) -padx 2 -pady 2
    355353
     
    362360    }
    363361    Rappture::Tooltip::for $itk_component(cutplane) \
    364         "Show/Hide cutplanes"
     362        "Show/Hide the cutplanes"
    365363    pack $itk_component(cutplane) -padx 2 -pady 2
    366364
    367 
    368365    if { [catch {
    369         BuildVolumeTab
     366        BuildSurfaceTab
    370367        BuildStreamsTab
    371368        BuildCutplaneTab
     
    10311028        array unset _fields
    10321029        set _curFldName ""
     1030        set _curFldLabel ""
    10331031        foreach cname [$_first components] {
    10341032            foreach fname [$_first fieldnames $cname] {
     
    10471045                    -command [itcl::code $this Combo invoke]
    10481046                set _fields($fname) [list $label $units $components]
    1049                 if { $_curFldName == "" } {
     1047                if { $_curFldName == "" && $components == 3 } {
    10501048                    set _curFldName $fname
    10511049                    set _curFldLabel $label
     
    10611059            -streamlineslighting \
    10621060            -streamlinescolormap -field \
    1063             -volumevisible -volumeedges -volumelighting -volumeopacity \
    1064             -volumewireframe \
     1061            -surfacevisible -surfaceedges -surfacelighting -surfaceopacity \
     1062            -surfacewireframe \
    10651063            -cutplanevisible \
    10661064            -cutplanexposition -cutplaneyposition -cutplanezposition \
     
    13431341            set bool $_settings($what)
    13441342            SendCmd "cutplane visible $bool"
     1343            if { $bool } {
     1344                Rappture::Tooltip::for $itk_component(cutplane) \
     1345                    "Hide the cutplanes"
     1346            } else {
     1347                Rappture::Tooltip::for $itk_component(cutplane) \
     1348                    "Show the cutplanes"
     1349            }
    13451350        }
    13461351        "-cutplanewireframe" {
     
    14501455            SendCmd "streamlines opacity $sval"
    14511456        }
    1452         "-streamlinesscale" {
     1457        "-streamlineslength" {
    14531458            set val $_settings($what)
    1454             set sval [expr { 0.01 * double($val) }]
    1455             SendCmd "streamlines scale $sval $sval $sval"
     1459            set sval [expr { (0.01 * double($val)) / 0.7 }]
     1460            foreach axis {x y z} {
     1461                foreach {min max} $_limits($axis) break
     1462                set ${axis}len [expr double($max) - double($min)]
     1463            }
     1464            set length [expr { $sval * ($xlen + $ylen + $zlen) } ]
     1465            SendCmd "streamlines length $length"
    14561466        }
    14571467        "-streamlineslighting" {
     
    14591469            SendCmd "streamlines lighting $bool"
    14601470        }
    1461         "-volumeopacity" {
     1471        "-surfaceopacity" {
    14621472            set val $_settings($what)
    14631473            set sval [expr { 0.01 * double($val) }]
    14641474            SendCmd "polydata opacity $sval"
    14651475        }
    1466         "-volumewireframe" {
     1476        "-surfacewireframe" {
    14671477            set bool $_settings($what)
    14681478            SendCmd "polydata wireframe $bool"
    14691479        }
    1470         "-volumevisible" {
     1480        "-surfacevisible" {
    14711481            set bool $_settings($what)
    14721482            SendCmd "polydata visible $bool"
    14731483            if { $bool } {
    1474                 Rappture::Tooltip::for $itk_component(volume) \
    1475                     "Hide the volume"
     1484                Rappture::Tooltip::for $itk_component(surface) \
     1485                    "Hide the boundary surface"
    14761486            } else {
    1477                 Rappture::Tooltip::for $itk_component(volume) \
    1478                     "Show the volume"
    1479             }
    1480         }
    1481         "-volumelighting" {
     1487                Rappture::Tooltip::for $itk_component(surface) \
     1488                    "Show the boundary surface"
     1489            }
     1490        }
     1491        "-surfacelighting" {
    14821492            set bool $_settings($what)
    14831493            SendCmd "polydata lighting $bool"
    14841494        }
    1485         "-volumeedges" {
     1495        "-surfaceedges" {
    14861496            set bool $_settings($what)
    14871497            SendCmd "polydata edges $bool"
     
    15441554    array set style {
    15451555        -color BCGYR
    1546         -levels 6
    1547         -opacity 1.0
    15481556    }
    15491557    set tag $dataobj-$comp
     
    15621570    array set style $_style($tag)
    15631571
    1564     set name "$style(-color):$style(-levels):$style(-opacity)"
     1572    set name "$style(-color)"
    15651573    if { ![info exists _colormaps($name)] } {
    15661574        BuildColormap $name [array get style]
     
    15841592        set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
    15851593    }
    1586     if { ![info exists _settings(-volumeopacity)] } {
    1587         set _settings(-volumeopacity) $style(-opacity)
    1588     }
    1589     set max $_settings(-volumeopacity)
    1590 
    15911594    set amap "0.0 1.0 1.0 1.0"
    15921595    SendCmd "colormap add $name { $cmap } { $amap }"
     
    16151618}
    16161619
    1617 itcl::body Rappture::VtkStreamlinesViewer::BuildVolumeTab {} {
     1620itcl::body Rappture::VtkStreamlinesViewer::BuildSurfaceTab {} {
    16181621
    16191622    set fg [option get $itk_component(hull) font Font]
     
    16211624
    16221625    set inner [$itk_component(main) insert end \
    1623         -title "Volume Settings" \
     1626        -title "Boundary Surface Settings" \
    16241627        -icon [Rappture::icon volume-on]]
    16251628    $inner configure -borderwidth 4
    16261629
    1627     checkbutton $inner.volume \
    1628         -text "Show Volume" \
    1629         -variable [itcl::scope _settings(-volumevisible)] \
    1630         -command [itcl::code $this AdjustSetting -volumevisible] \
     1630    checkbutton $inner.surface \
     1631        -text "Show Surface" \
     1632        -variable [itcl::scope _settings(-surfacevisible)] \
     1633        -command [itcl::code $this AdjustSetting -surfacevisible] \
    16311634        -font "Arial 9"
    16321635
    16331636    checkbutton $inner.wireframe \
    16341637        -text "Show Wireframe" \
    1635         -variable [itcl::scope _settings(-volumewireframe)] \
    1636         -command [itcl::code $this AdjustSetting -volumewireframe] \
     1638        -variable [itcl::scope _settings(-surfacewireframe)] \
     1639        -command [itcl::code $this AdjustSetting -surfacewireframe] \
    16371640        -font "Arial 9"
    16381641
    16391642    checkbutton $inner.lighting \
    16401643        -text "Enable Lighting" \
    1641         -variable [itcl::scope _settings(-volumelighting)] \
    1642         -command [itcl::code $this AdjustSetting -volumelighting] \
     1644        -variable [itcl::scope _settings(-surfacelighting)] \
     1645        -command [itcl::code $this AdjustSetting -surfacelighting] \
    16431646        -font "Arial 9"
    16441647
    16451648    checkbutton $inner.edges \
    16461649        -text "Show Edges" \
    1647         -variable [itcl::scope _settings(-volumeedges)] \
    1648         -command [itcl::code $this AdjustSetting -volumeedges] \
     1650        -variable [itcl::scope _settings(-surfaceedges)] \
     1651        -command [itcl::code $this AdjustSetting -surfaceedges] \
    16491652        -font "Arial 9"
    16501653
    16511654    label $inner.opacity_l -text "Opacity" -font "Arial 9"
    16521655    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1653         -variable [itcl::scope _settings(-volumeopacity)] \
     1656        -variable [itcl::scope _settings(-surfaceopacity)] \
    16541657        -width 10 \
    16551658        -showvalue off \
    1656         -command [itcl::code $this AdjustSetting -volumeopacity]
     1659        -command [itcl::code $this AdjustSetting -surfaceopacity]
    16571660
    16581661    blt::table $inner \
     
    17201723        -command [itcl::code $this AdjustSetting -streamlinesnumseeds]
    17211724
    1722     label $inner.scale_l -text "Scale" -font "Arial 9"
     1725    label $inner.scale_l -text "Length" -font "Arial 9"
    17231726    ::scale $inner.scale -from 1 -to 100 -orient horizontal \
    1724         -variable [itcl::scope _settings(-streamlinesscale)] \
     1727        -variable [itcl::scope _settings(-streamlineslength)] \
    17251728        -width 10 \
    17261729        -showvalue off \
    1727         -command [itcl::code $this AdjustSetting -streamlinesscale]
     1730        -command [itcl::code $this AdjustSetting -streamlineslength]
    17281731
    17291732    label $inner.field_l -text "Color by" -font "Arial 9"
     
    17511754        2,0 $inner.mode_l      -anchor w -pady 2  \
    17521755        2,1 $inner.mode        -fill x   -pady 2  \
    1753         3,0 $inner.opacity_l   -anchor w -pady 2  \
    1754         3,1 $inner.opacity     -fill x -pady 2 \
     1756        3,0 $inner.scale_l     -anchor w -pady 2  \
     1757        3,1 $inner.scale       -fill x   -pady 2  \
     1758        4,0 $inner.opacity_l   -anchor w -pady 2  \
     1759        4,1 $inner.opacity     -fill x -pady 2 \
    17551760        5,0 $inner.lighting    -anchor w -pady 2 -cspan 2 \
    17561761        6,0 $inner.seeds       -anchor w -pady 2 -cspan 2 \
     
    21372142    set style [$dataobj style $comp]
    21382143    array set settings {
    2139         -color \#808080
     2144        -color BCGYR
     2145        -constcolor white
     2146        -edgecolor black
    21402147        -edges 0
    2141         -edgecolor black
     2148        -lighting 1
    21422149        -linewidth 1.0
    2143         -opacity 0.4
    2144         -wireframe 0
    2145         -lighting 1
     2150        -mode lines
     2151        -numseeds 200
     2152        -opacity 1.0
    21462153        -seeds 1
    21472154        -seedcolor white
     2155        -streamlineslength 0.7
     2156        -surfacecolor white
     2157        -surfaceedgecolor black
     2158        -surfaceedges 0
     2159        -surfacelighting 1
     2160        -surfaceopacity 0.4
     2161        -surfacevisible 1
     2162        -surfacewireframe 0
    21482163        -visible 1
    21492164    }
     
    21542169    StartBufferingCommands
    21552170    SendCmd "streamlines add $tag"
    2156     SendCmd "streamlines seed visible off $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"
    21572180    set seeds [$dataobj hints seeds]
    21582181    if { $seeds != "" && ![info exists _seeds($dataobj)] } {
    21592182        set length [string length $seeds]
    2160         SendCmd "streamlines seed fmesh 200 data follows $length $tag"
     2183        SendCmd "streamlines seed fmesh $settings(-numseeds) data follows $length $tag"
    21612184        SendData $seeds
    21622185        set _seeds($dataobj) 1
    21632186    }
     2187    set _settings(-streamlineslighting) $settings(-lighting)
     2188    $itk_component(streammode) value $settings(-mode)
     2189    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)
     2195
    21642196    SendCmd "cutplane add $tag"
     2197
    21652198    SendCmd "polydata add $tag"
     2199    SendCmd "polydata color [Color2RGB $settings(-surfacecolor)] $tag"
    21662200    SendCmd "polydata colormode constant {} $tag"
    2167     set _settings(-volumeedges) $settings(-edges)
    2168     set _settings(-volumelighting) $settings(-lighting)
    2169     set _settings(-volumeopacity) $settings(-opacity)
    2170     set _settings(-volumewireframe) $settings(-wireframe)
    2171     set _settings(-volumeopacity) [expr $settings(-opacity) * 100.0]
     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)
    21722212    StopBufferingCommands
    21732213    SetColormap $dataobj $comp
     2214    $itk_component(colormap) value $settings(-color)
    21742215}
    21752216
Note: See TracChangeset for help on using the changeset viewer.