Ignore:
Timestamp:
Feb 28, 2013 3:28:53 PM (11 years ago)
Author:
gah
Message:

fix to streamlines to display initial plot at proper scale

File:
1 edited

Legend:

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

    r3394 r3400  
    614614        # Remove it from the dataobj list.
    615615        set _dlist [lreplace $_dlist $pos $pos]
    616         SendCmd "dataset visible 0"
    617616        array unset _obj2ovride $dataobj-*
    618617        array unset _settings $dataobj-*
     
    10291028        DoResize
    10301029        InitSettings axisXGrid axisYGrid axisZGrid axis-mode \
    1031             axesVisible axisLabelsVisible \
    1032     }
    1033     #SendCmd "imgflush"
     1030            axesVisible axisLabelsVisible
     1031        # This "imgflush" is to force an image returned before vtkvis starts
     1032        # reading a (big) dataset.  This will display an empty plot with axes
     1033        # at the correct image size.
     1034        SendCmd "imgflush"
     1035    }
    10341036
    10351037    set _limits(zmin) ""
    10361038    set _limits(zmax) ""
    10371039    set _first ""
     1040    SendCmd "dataset visible 0"
    10381041    foreach dataobj [get -objects] {
    10391042        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
     
    10651068            if { [info exists _obj2ovride($dataobj-raise)] } {
    10661069                SendCmd "dataset visible 1 $tag"
    1067             } else {
    1068                 SendCmd "dataset visible 0 $tag"
    10691070            }
    10701071        }
     
    11181119    }
    11191120
    1120     InitSettings streamlinesVisible streamlines-palette volumeVisible
    1121 
    11221121    if { $_reset } {
    11231122        InitSettings streamlinesSeedsVisible streamlinesOpacity \
    1124             streamlinesNumSeeds streamlinesLighting \
    1125             streamlines-palette streamlines-field \
    1126             volumeEdges volumeLighting volumeOpacity volumeWireframe \
     1123            streamlinesVisible streamlinesPalette \
     1124            streamlinesLighting \
     1125            streamlinesPalette streamlinesField \
     1126            volumeVisible volumeEdges volumeLighting volumeOpacity \
     1127            volumeWireframe \
    11271128            cutplaneVisible \
    11281129            cutplaneXPosition cutplaneYPosition cutplaneZPosition \
    11291130            cutplaneXVisible cutplaneYVisible cutplaneZVisible
    1130         #
     1131
     1132        # FIXME: Don't know exactly why this "imgflush" is needed.
     1133        #        But this makes the "camera reset" below to work correctly
     1134        SendCmd "imgflush"
     1135
    11311136        # Reset the camera and other view parameters
    1132         #
    11331137        set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    11341138        $_arcball quaternion $q
     
    13901394            set val $_settings(volumeOpacity)
    13911395            set sval [expr { 0.01 * double($val) }]
    1392             foreach dataset [CurrentDatasets -visible] {
    1393                 SendCmd "polydata opacity $sval $dataset"
    1394             }
     1396            SendCmd "polydata opacity $sval"
    13951397        }
    13961398        "volumeWireframe" {
    13971399            set bool $_settings(volumeWireframe)
    1398             foreach dataset [CurrentDatasets -visible] {
    1399                 SendCmd "polydata wireframe $bool $dataset"
    1400             }
     1400            SendCmd "polydata wireframe $bool"
    14011401        }
    14021402        "volumeVisible" {
    14031403            set bool $_settings(volumeVisible)
    1404             foreach dataset [CurrentDatasets -visible] {
    1405                 SendCmd "polydata visible $bool $dataset"
    1406             }
     1404            SendCmd "polydata visible $bool"
    14071405            if { $bool } {
    14081406                Rappture::Tooltip::for $itk_component(volume) \
     
    14151413        "volumeLighting" {
    14161414            set bool $_settings(volumeLighting)
    1417             foreach dataset [CurrentDatasets -visible] {
    1418                 SendCmd "polydata lighting $bool $dataset"
    1419             }
     1415            SendCmd "polydata lighting $bool"
    14201416        }
    14211417        "volumeEdges" {
    14221418            set bool $_settings(volumeEdges)
    1423             foreach dataset [CurrentDatasets -visible] {
    1424                 SendCmd "polydata edges $bool $dataset"
    1425             }
     1419            SendCmd "polydata edges $bool"
    14261420        }
    14271421        "axesVisible" {
     
    14461440        "cutplaneEdges" {
    14471441            set bool $_settings($what)
    1448             foreach dataset [CurrentDatasets -visible] {
    1449                 SendCmd "cutplane edges $bool $dataset"
    1450             }
     1442            SendCmd "cutplane edges $bool"
    14511443        }
    14521444        "cutplaneVisible" {
    14531445            set bool $_settings($what)
    1454             foreach dataset [CurrentDatasets -visible] {
    1455                 SendCmd "cutplane visible $bool $dataset"
    1456             }
     1446            SendCmd "cutplane visible $bool"
    14571447        }
    14581448        "cutplaneWireframe" {
    14591449            set bool $_settings($what)
    1460             foreach dataset [CurrentDatasets -visible] {
    1461                 SendCmd "cutplane wireframe $bool $dataset"
    1462             }
     1450            SendCmd "cutplane wireframe $bool"
    14631451        }
    14641452        "cutplaneLighting" {
    14651453            set bool $_settings($what)
    1466             foreach dataset [CurrentDatasets -visible] {
    1467                 SendCmd "cutplane lighting $bool $dataset"
    1468             }
     1454            SendCmd "cutplane lighting $bool"
    14691455        }
    14701456        "cutplaneOpacity" {
    14711457            set val $_settings($what)
    14721458            set sval [expr { 0.01 * double($val) }]
    1473             foreach dataset [CurrentDatasets -visible] {
    1474                 SendCmd "cutplane opacity $sval $dataset"
    1475             }
     1459            SendCmd "cutplane opacity $sval"
    14761460        }
    14771461        "cutplaneXVisible" - "cutplaneYVisible" - "cutplaneZVisible" {
     
    14851469                    -troughcolor grey82
    14861470            }
    1487             foreach dataset [CurrentDatasets -visible] {
    1488                 SendCmd "cutplane axis $axis $bool $dataset"
    1489             }
     1471            SendCmd "cutplane axis $axis $bool"
    14901472        }
    14911473        "cutplaneXPosition" - "cutplaneYPosition" - "cutplaneZPosition" {
    14921474            set axis [string tolower [string range $what 8 8]]
    14931475            set pos [expr $_settings($what) * 0.01]
    1494             foreach dataset [CurrentDatasets -visible] {
    1495                 SendCmd "cutplane slice ${axis} ${pos} $dataset"
    1496             }
     1476            SendCmd "cutplane slice ${axis} ${pos}"
    14971477            set _cutplanePending 0
    14981478        }
    14991479        "streamlinesSeedsVisible" {
    15001480            set bool $_settings($what)
    1501             foreach dataset [CurrentDatasets -visible] {
    1502                 SendCmd "streamlines seed visible $bool $dataset"
    1503             }
     1481            SendCmd "streamlines seed visible $bool"
    15041482        }
    15051483        "streamlinesNumSeeds" {
     
    15091487        "streamlinesVisible" {
    15101488            set bool $_settings($what)
    1511             foreach dataset [CurrentDatasets -visible] {
    1512                 SendCmd "streamlines visible $bool $dataset"
    1513             }
     1489            SendCmd "streamlines visible $bool"
    15141490            if { $bool } {
    15151491                Rappture::Tooltip::for $itk_component(streamlines) \
     
    15231499            set mode [$itk_component(streammode) value]
    15241500            set _settings(streamlinesMode) $mode
    1525             foreach dataset [CurrentDatasets -visible] {
    1526                 switch -- $mode {
    1527                     "lines" {
    1528                         SendCmd "streamlines lines $dataset"
    1529                     }
    1530                     "ribbons" {
    1531                         SendCmd "streamlines ribbons 3 0 $dataset"
    1532                     }
    1533                     "tubes" {
    1534                         SendCmd "streamlines tubes 5 3 $dataset"
    1535                     }
    1536                 }
    1537             }
    1538         }
    1539         "streamlines-palette" {
     1501            switch -- $mode {
     1502                "lines" {
     1503                    SendCmd "streamlines lines"
     1504                }
     1505                "ribbons" {
     1506                    SendCmd "streamlines ribbons 3 0"
     1507                }
     1508                "tubes" {
     1509                    SendCmd "streamlines tubes 5 3"
     1510                }
     1511            }
     1512        }
     1513        "streamlinesPalette" {
    15401514            set palette [$itk_component(palette) value]
    1541             set _settings(streamlines-palette) $palette
     1515            set _settings(streamlinesPalette) $palette
    15421516            foreach dataset [CurrentDatasets -visible $_first] {
    15431517                foreach {dataobj comp} [split $dataset -] break
     
    15491523            set val $_settings(streamlinesOpacity)
    15501524            set sval [expr { 0.01 * double($val) }]
    1551             foreach dataset [CurrentDatasets -visible $_first] {
    1552                 SendCmd "streamlines opacity $sval $dataset"
    1553             }
     1525            SendCmd "streamlines opacity $sval"
    15541526        }
    15551527        "streamlinesScale" {
    15561528            set val $_settings(streamlinesScale)
    15571529            set sval [expr { 0.01 * double($val) }]
    1558             foreach dataset [CurrentDatasets -visible $_first] {
    1559                 SendCmd "streamlines scale $sval $sval $sval $dataset"
    1560             }
     1530            SendCmd "streamlines scale $sval $sval $sval"
    15611531        }
    15621532        "streamlinesLighting" {
    15631533            set bool $_settings(streamlinesLighting)
    1564             foreach dataset [CurrentDatasets -visible $_first] {
    1565                 SendCmd "streamlines lighting $bool $dataset"
    1566             }
    1567         }
    1568         "streamlines-field" {
     1534            SendCmd "streamlines lighting $bool"
     1535        }
     1536        "streamlinesField" {
    15691537            set new [$itk_component(field) value]
    15701538            set value [$itk_component(field) translate $new]
    1571             set _settings(streamlines-field) $value
     1539            set _settings(streamlinesField) $value
    15721540            if { [info exists _scalarFields($new)] } {
    15731541                set name $_scalarFields($new)
     
    15821550                return
    15831551            }
    1584             foreach dataset [CurrentDatasets -visible] {
    1585                 SendCmd "streamlines colormode $_colorMode ${name} $dataset"
    1586                 SendCmd "cutplane colormode $_colorMode ${name} $dataset"
    1587             }
     1552            SendCmd "streamlines colormode $_colorMode ${name}"
     1553            SendCmd "cutplane colormode $_colorMode ${name}"
    15881554            set _legendPending 1
    15891555        }
     
    19071873    }
    19081874    bind $inner.field <<Value>> \
    1909         [itcl::code $this AdjustSetting streamlines-field]
     1875        [itcl::code $this AdjustSetting streamlinesField]
    19101876
    19111877    label $inner.palette_l -text "Palette" -font "Arial 9"
     
    19331899    $itk_component(palette) value "BCGYR"
    19341900    bind $inner.palette <<Value>> \
    1935         [itcl::code $this AdjustSetting streamlines-palette]
     1901        [itcl::code $this AdjustSetting streamlinesPalette]
    19361902
    19371903    blt::table $inner \
     
    23532319    }
    23542320    SendCmd "cutplane add $tag"
    2355     SendCmd "cutplane edges 0 $tag"
    2356     SendCmd "cutplane wireframe 0 $tag"
    2357     SendCmd "cutplane lighting 1 $tag"
    2358     SendCmd "cutplane linewidth 1 $tag"
    2359     #SendCmd "cutplane linecolor 1 1 1 $tag"
    2360     #SendCmd "cutplane visible $tag"
    2361     foreach axis { x y z } {
    2362         SendCmd "cutplane slice $axis 0.5 $tag"
    2363         SendCmd "cutplane axis $axis 0 $tag"
    2364     }
    2365 
    23662321    SendCmd "polydata add $tag"
    2367     SendCmd "polydata edges $settings(-edges) $tag"
    23682322    set _settings(volumeEdges) $settings(-edges)
    2369     SendCmd "polydata color [Color2RGB $settings(-color)] $tag"
    2370     SendCmd "polydata lighting $settings(-lighting) $tag"
    23712323    set _settings(volumeLighting) $settings(-lighting)
    2372     SendCmd "polydata linecolor [Color2RGB $settings(-edgecolor)] $tag"
    2373     SendCmd "polydata linewidth $settings(-linewidth) $tag"
    2374     SendCmd "polydata opacity $settings(-opacity) $tag"
    23752324    set _settings(volumeOpacity) $settings(-opacity)
    2376     SendCmd "polydata wireframe $settings(-wireframe) $tag"
    23772325    set _settings(volumeWireframe) $settings(-wireframe)
    23782326    set _settings(volumeOpacity) [expr $settings(-opacity) * 100.0]
     
    26152563        invoke {
    26162564            $itk_component(field) value $_currentField
    2617             AdjustSetting streamlines-field
     2565            AdjustSetting streamlinesField
    26182566        }
    26192567        default {
Note: See TracChangeset for help on using the changeset viewer.