Ignore:
Timestamp:
Aug 24, 2010, 8:38:37 PM (14 years ago)
Author:
gah
Message:
 
Location:
branches/blt4/gui/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/blt4/gui/scripts/drawing3d.tcl

    r1879 r1880  
    3131    public method style { elem }
    3232    public method values { elem }
     33    public method data { elem }
    3334    public method hints {{keyword ""}}
    3435    public method components { args }
     
    3839    private variable _actors
    3940    private variable _styles
     41    private variable _data
    4042    private variable _hints
    4143    private variable _units
     
    6870    # determine the overall size of the device
    6971    foreach elem [$_xmlobj children $path] {
    70         puts stderr elem=$elem
    7172        switch -glob -- $elem {
    7273            polygon* {
    7374                set data [$_xmlobj get $path.$elem.vtk]
    74                 puts stderr "data=$data"
    7575                set arr [vtkCharArray $this-xvtkCharArray]
    7676                $arr SetArray $data [string length $data] 1
     
    8585                set _limits($elem) [$actor GetBounds]
    8686                set _styles($elem) [$_xmlobj get $path.$elem.style]
     87                set _data($elem) $mapper
    8788            }
    8889        }
     
    129130
    130131# ----------------------------------------------------------------------
    131 # method mesh
     132# method style
    132133#       Returns a base64 encoded, gzipped Tcl list that represents the
    133134#       Tcl command and data to recreate the uniform rectangular grid
     
    142143
    143144# ----------------------------------------------------------------------
     145# method data
     146#       Returns a base64 encoded, gzipped Tcl list that represents the
     147#       Tcl command and data to recreate the uniform rectangular grid
     148#       on the nanovis server.
     149# ----------------------------------------------------------------------
     150itcl::body Rappture::Drawing3d::data { elem } {
     151    if { [info exists _data($elem)] } {
     152        return $_data($elem)
     153    }
     154    return ""
     155}
     156
     157# ----------------------------------------------------------------------
    144158# method values
    145159#       Returns a base64 encoded, gzipped Tcl list that represents the
     
    155169
    156170itcl::body Rappture::Drawing3d::components { args } {
    157     puts stderr "components=[array names _actors]"
    158171    return [array names _actors]
    159172}
  • branches/blt4/gui/scripts/vtkviewer.tcl

    r1879 r1880  
    3333    inherit itk::Widget
    3434
     35    itk_option define -plotforeground plotForeground Foreground ""
     36    itk_option define -plotbackground plotBackground Background ""
     37
    3538    private variable _dlist ""     ;# list of data objects
    3639    private variable _dims ""      ;# dimensionality of data objects
     
    5154    private variable _interactor "";
    5255    private variable _style "";
     56    private variable _light "";
    5357    private variable _cubeAxesActor ""
    5458    private variable _axesActor ""
    5559    private variable _axesWidget "";
    56 
     60    private variable _settings
    5761    constructor {args} {
    5862        # defined below
     
    8286    protected method SetActorProperties { actor style }
    8387
    84     itk_option define -plotforeground plotForeground Foreground ""
    85     itk_option define -plotbackground plotBackground Background ""
     88    private method BuildCameraTab {}
     89    private method BuildCutplanesTab {}
     90    private method BuildViewTab {}
     91    private method BuildVolumeTab {}
     92    protected method FixSettings {what {value ""}}
    8693
    8794}
     
    109116    set _view(phi) 0
    110117
    111     foreach val {xmin xmax ymin ymax zmin zmax vmin vmax} {
    112         set _limits($val) ""
    113     }
     118    array set _limits {
     119        xmin 0
     120        xmax 1
     121        ymin 0
     122        ymax 1
     123        zmin 0
     124        zmax 1
     125        vmin 0
     126        vmax 1
     127    }
     128
     129    itk_component add main {
     130        Rappture::SidebarFrame $itk_interior.main
     131    }
     132    pack $itk_component(main) -expand yes -fill both
     133    set f [$itk_component(main) component frame]
    114134
    115135    itk_component add controls {
    116         frame $itk_interior.cntls
     136        frame $f.cntls
    117137    } {
    118138        usual
     
    169189
    170190    #
    171     # Create slicer controls...
    172     #
    173     itk_component add slicers {
    174         frame $itk_component(controls).slicers
    175     } {
    176         usual
    177         rename -background -controlbackground controlBackground Background
    178     }
    179     pack $itk_component(slicers) -side bottom -padx 4 -pady 4
    180     grid rowconfigure $itk_component(slicers) 1 -weight 1
    181 
    182     #
    183     # X-value slicer...
    184     #
    185     itk_component add xslice {
    186         label $itk_component(slicers).xslice \
    187             -borderwidth 1 -relief raised -padx 1 -pady 1 \
    188             -bitmap [Rappture::icon x]
    189     } {
    190         usual
    191         ignore -borderwidth
    192         rename -highlightbackground -controlbackground controlBackground Background
    193     }
    194     bind $itk_component(xslice) <ButtonPress> \
    195         [itcl::code $this Slice axis x toggle]
    196     Rappture::Tooltip::for $itk_component(xslice) \
    197         "Toggle the X cut plane on/off"
    198     grid $itk_component(xslice) -row 0 -column 0 -sticky ew -padx 1
    199 
    200     itk_component add xslicer {
    201         ::scale $itk_component(slicers).xval -from 100 -to 0 \
    202             -width 10 -orient vertical -showvalue off -state disabled \
    203             -borderwidth 1 -highlightthickness 0 \
    204             -command [itcl::code $this Slice move x]
    205     } {
    206         usual
    207         ignore -borderwidth
    208         ignore -highlightthickness
    209         rename -highlightbackground -controlbackground controlBackground Background
    210         rename -troughcolor -controldarkbackground controlDarkBackground Background
    211     }
    212     grid $itk_component(xslicer) -row 1 -column 0 -padx 1
    213     Rappture::Tooltip::for $itk_component(xslicer) \
    214         "@[itcl::code $this Slicertip x]"
    215 
    216     #
    217     # Y-value slicer...
    218     #
    219     itk_component add yslice {
    220         label $itk_component(slicers).yslice \
    221             -borderwidth 1 -relief raised -padx 1 -pady 1 \
    222             -bitmap [Rappture::icon y]
    223     } {
    224         usual
    225         ignore -borderwidth
    226         rename -highlightbackground -controlbackground controlBackground Background
    227     }
    228     bind $itk_component(yslice) <ButtonPress> \
    229         [itcl::code $this Slice axis y toggle]
    230     Rappture::Tooltip::for $itk_component(yslice) \
    231         "Toggle the Y cut plane on/off"
    232     grid $itk_component(yslice) -row 0 -column 1 -sticky ew -padx 1
    233 
    234     itk_component add yslicer {
    235         ::scale $itk_component(slicers).yval -from 100 -to 0 \
    236             -width 10 -orient vertical -showvalue off -state disabled \
    237             -borderwidth 1 -highlightthickness 0 \
    238             -command [itcl::code $this Slice move y]
    239     } {
    240         usual
    241         ignore -borderwidth
    242         ignore -highlightthickness
    243         rename -highlightbackground -controlbackground controlBackground Background
    244         rename -troughcolor -controldarkbackground controlDarkBackground Background
    245     }
    246     grid $itk_component(yslicer) -row 1 -column 1 -padx 1
    247     Rappture::Tooltip::for $itk_component(yslicer) \
    248         "@[itcl::code $this Slicertip y]"
    249 
    250     #
    251     # Z-value slicer...
    252     #
    253     itk_component add zslice {
    254         label $itk_component(slicers).zslice \
    255             -borderwidth 1 -relief raised -padx 1 -pady 1 \
    256             -bitmap [Rappture::icon z]
    257     } {
    258         usual
    259         ignore -borderwidth
    260         rename -highlightbackground -controlbackground controlBackground Background
    261     }
    262     grid $itk_component(zslice) -row 0 -column 2 -sticky ew -padx 1
    263     bind $itk_component(zslice) <ButtonPress> \
    264         [itcl::code $this Slice axis z toggle]
    265     Rappture::Tooltip::for $itk_component(zslice) \
    266         "Toggle the Z cut plane on/off"
    267 
    268     itk_component add zslicer {
    269         ::scale $itk_component(slicers).zval -from 100 -to 0 \
    270             -width 10 -orient vertical -showvalue off -state disabled \
    271             -borderwidth 1 -highlightthickness 0 \
    272             -command [itcl::code $this Slice move z]
    273     } {
    274         usual
    275         ignore -borderwidth
    276         ignore -highlightthickness
    277         rename -highlightbackground -controlbackground controlBackground Background
    278         rename -troughcolor -controldarkbackground controlDarkBackground Background
    279     }
    280     grid $itk_component(zslicer) -row 1 -column 2 -padx 1
    281     Rappture::Tooltip::for $itk_component(zslicer) \
    282         "@[itcl::code $this Slicertip z]"
    283 
    284     #
    285191    # RENDERING AREA
    286192    #
    287193    itk_component add area {
    288         frame $itk_interior.area
     194        frame $f.area
    289195    }
    290196    pack $itk_component(area) -expand yes -fill both
     
    321227    $_axesWidget SetViewport 0 0 0.3 0.3
    322228
    323     $_window LineSmoothingOn
    324     $_window PolygonSmoothingOn
    325 
    326229    $_cubeAxesActor SetXTitle "X Axis (units)"
    327230    $_cubeAxesActor SetYTitle "Y Axis (units)"
    328231
    329     if 0 {
    330     vtkRenderer $this-ren2
    331     vtkRenderWindow $this-vtkRenderWindow2
    332     $this-vtkRenderWindow2 AddRenderer $this-vtkRenderer2
    333     vtkRenderWindowInteractor $this-vtkInteractor2
    334     $this-vtkInteractor2 SetRenderWindow $this-vtkRenderWindow2
    335 
    336     itk_component add legend {
    337         vtkTkRenderWidget $itk_component(area).legend \
    338             -rw $this-vtkRenderWindow2 -width 1 -height 40
    339     } {
    340     }
    341     pack $itk_component(legend) -side bottom -fill x
    342     }
     232    BuildViewTab
     233    BuildVolumeTab
     234    BuildCutplanesTab
     235    BuildCameraTab
     236
     237    set v0 0
     238    set v1 1
     239    set _lookup [vtkLookupTable $this-Lookup]
     240    $_lookup SetTableRange $v0 $v1
     241    $_lookup SetHueRange 0.66667 0.0
     242    $_lookup Build
     243
     244
     245    #
     246    # 3D CUT PLANES
     247    #
     248    foreach axis {x y z} norm {{1 0 0} {0 1 0} {0 0 1}} {
     249
     250        set plane [vtkPlane $this-${axis}cutplane]
     251        eval $plane SetNormal $norm
     252        set _slicer(${axis}plane) $plane
     253       
     254        set cutter [vtkCutter $this-${axis}cutter]
     255        $cutter SetCutFunction $plane
     256       
     257        set mapper [vtkPolyDataMapper  $this-${axis}cutmapper]
     258        $mapper SetInput [$cutter GetOutput]
     259        $mapper SetScalarRange $v0 $v1
     260        $mapper SetLookupTable $_lookup
     261       
     262        #lappend _obj2vtk($dataobj) $cutplane $cutter $mapper
     263       
     264        set actor [vtkActor $this-${axis}actor]
     265        $actor VisibilityOn
     266        $actor SetMapper $mapper
     267        $actor SetPosition 0 0 0
     268        [$actor GetProperty] SetColor 0 0 0
     269        set _slicer(${axis}slice) $actor
     270       
     271        $_renderer AddActor $actor
     272        lappend _actors($_renderer) $actor
     273        #lappend _obj2vtk($dataobj) $actor
     274    }
     275   
     276    #
     277    # CUT PLANE READOUT
     278    #
     279    set mapper [vtkTextMapper $this-text]
     280    set props [$mapper GetTextProperty]
     281    #eval $props SetColor [_color2rgb $itk_option(-plotforeground)]
     282    $props SetVerticalJustificationToTop
     283    set _slicer(readout) $mapper
     284           
     285    set actor [vtkActor2D $this-texta]
     286    $actor SetMapper $mapper
     287    set coords [$actor GetPositionCoordinate]
     288    $coords SetCoordinateSystemToNormalizedDisplay
     289    $coords SetValue 0.02 0.98
     290           
     291    $_renderer AddActor $actor
     292    lappend _actors($_renderer) $actor
     293    #lappend _obj2vtk($dataobj) $mapper $actor
     294
     295    # turn off all slicers by default
     296    foreach axis {x y z} {
     297        $itk_component(${axis}CutScale) configure -state normal
     298        $itk_component(${axis}CutScale) set 50
     299        Slice move $axis 50
     300        Slice axis $axis off
     301    }
     302
     303    set _light [vtkLight $this-Light]
     304    $_light SetColor 1 1 1
     305    $_light SetAttenuationValues 0 0 0
     306    $_light SetFocalPoint 0 0 0
     307    $_light SetLightTypeToHeadlight
     308    $_renderer AddLight $_light
     309
    343310    #
    344311    # Create a picture for download snapshots
     
    680647            if {$op == ""} { set op "on" }
    681648
    682             if {[$itk_component(${axis}slice) cget -relief] == "raised"} {
    683                 set current "off"
     649            set current $_settings($this-${axis}cutplane)
     650            if {$op == "toggle"} {
     651                set op [expr $current==0]
     652            }
     653
     654            if {$op} {
     655                $itk_component(${axis}CutScale) configure -state normal
     656                $_slicer(${axis}slice) VisibilityOn
     657                $itk_component(${axis}CutButton) select
    684658            } else {
    685                 set current "on"
    686             }
    687 
    688             if {$op == "toggle"} {
    689                 if {$current == "on"} { set op "off" } else { set op "on" }
    690             }
    691 
    692             if {$op} {
    693                 $itk_component(${axis}slicer) configure -state normal
    694                 $_slicer(${axis}slice) VisibilityOn
    695                 $itk_component(${axis}slice) configure -relief sunken
    696             } else {
    697                 $itk_component(${axis}slicer) configure -state disabled
     659                $itk_component(${axis}CutScale) configure -state disabled
    698660                $_slicer(${axis}slice) VisibilityOff
    699                 $itk_component(${axis}slice) configure -relief raised
     661                $itk_component(${axis}CutButton) deselect
    700662            }
    701663            $_window Render
     
    840802itcl::body Rappture::VtkViewer::SetActorProperties { actor style } {
    841803    array set props {
    842         -color blue
     804        -color \#6666FF
    843805        -edgevisibility yes
    844806        -edgecolor black
     
    855817        $prop EdgeVisibilityOff
    856818    }
     819    set _settings($this-edges) $props(-edgevisibility)
    857820    eval $prop SetEdgeColor [_color2rgb $props(-edgecolor)]
    858821    $prop SetLineWidth $props(-linewidth)
    859822    $prop SetOpacity $props(-opacity)
     823    set _settings($this-opacity) [expr $props(-opacity) * 100.0]
    860824}
    861825
     
    899863
    900864    if 0 {
    901     set lu $this-vtkLookup$id
    902     vtkLookupTable $lu
     865    set lu $this-vtkLookup
     866        vtkLookupTable $lu
    903867    $lu SetTableRange $v0 $v1
    904868    $lu SetHueRange 0.66667 0.0
     
    924888        set zr [expr {$z1-$z0}]
    925889
    926         set light [vtkLight $this-vtkLight$id]
     890        set light [vtkLight $this-vtkLight]
    927891        $light SetColor 1 1 1
    928892        $light SetAttenuationValues 0 0 0
     
    945909            $_cubeAxesActor SetCamera [$_renderer GetActiveCamera]
    946910            eval $_cubeAxesActor SetBounds [$actor GetBounds]
    947             puts stderr "added action $actor to $_renderer"
     911
     912            set mapper [$dataobj data $comp]
     913            $this-xcutter SetInput [$mapper GetInput]
     914
    948915            if 0 {
    949916            #
     
    970937                      vtkPoints {
    971938                        # handle cloud of 3D points
    972                         set pd $this-polydata$id
     939                        set pd $this-polydata
    973940                        vtkPolyData $pd
    974941                        $pd SetPoints $mesh
    975942                        [$pd GetPointData] SetScalars [$dataobj values $comp]
    976943
    977                         set tr $this-triangles$id
     944                        set tr $this-triangles
    978945                        vtkDelaunay3D $tr
    979946                        $tr SetInput $pd
     
    981948                        set source [$tr GetOutput]
    982949
    983                         set mp $this-mapper$id
     950                        set mp $this-mapper
    984951                        vtkPolyDataMapper $mp
    985952
     
    988955                      vtkUnstructuredGrid {
    989956                        # handle 3D grid with connectivity
    990                         set gr $this-grdata$id
     957                        set gr $this-grdata
    991958                        vtkUnstructuredGrid $gr
    992959                        $gr ShallowCopy $mesh
     
    998965                      vtkRectilinearGrid {
    999966                        # handle 3D grid with connectivity
    1000                         set gr $this-grdata$id
     967                        set gr $this-grdata
    1001968                        vtkRectilinearGrid $gr
    1002969                        $gr ShallowCopy $mesh
     
    1014981                    # 3D ISOSURFACES
    1015982                    #
    1016                     set iso $this-iso$id
     983                    set iso $this-iso
    1017984                    vtkContourFilter $iso
    1018985                      $iso SetInput $source
    1019986
    1020                     set mp $this-isomap$id
     987                    set mp $this-isomap
    1021988                    vtkPolyDataMapper $mp
    1022989                      $mp SetInput [$iso GetOutput]
    1023990
    1024                     set ac $this-isoactor$id
     991                    set ac $this-isoactor
    1025992                    vtkActor $ac
    1026993                      $ac SetMapper $mp
     
    13181285}
    13191286
     1287itcl::body Rappture::VtkViewer::BuildViewTab {} {
     1288    foreach { key value } {
     1289        edges           1
     1290        axes            1
     1291        wireframe       0
     1292        volume          1
     1293        legend          1
     1294        particles       1
     1295        lic             1
     1296    } {
     1297        set _settings($this-$key) $value
     1298    }
     1299
     1300    set fg [option get $itk_component(hull) font Font]
     1301    #set bfg [option get $itk_component(hull) boldFont Font]
     1302
     1303    set tab [$itk_component(main) insert end \
     1304        -title "View Settings" \
     1305        -icon [Rappture::icon wrench]]
     1306    blt::scrollset $tab.ss \
     1307        -xscrollbar $tab.ss.xs \
     1308        -yscrollbar $tab.ss.ys \
     1309        -window $tab.ss.frame
     1310    pack $tab.ss -fill both -expand yes
     1311    blt::tk::scrollbar $tab.ss.xs               
     1312    blt::tk::scrollbar $tab.ss.ys               
     1313    set inner [blt::tk::frame $tab.ss.frame]
     1314    $inner configure -borderwidth 4
     1315
     1316    set ::Rappture::VtkViewer::_settings($this-isosurface) 0
     1317    checkbutton $inner.isosurface \
     1318        -text "Isosurface shading" \
     1319        -variable [itcl::scope _settings($this-isosurface)] \
     1320        -command [itcl::code $this FixSettings isosurface] \
     1321        -font "Arial 9"
     1322
     1323    checkbutton $inner.axes \
     1324        -text "Axes" \
     1325        -variable [itcl::scope _settings($this-axes)] \
     1326        -command [itcl::code $this FixSettings axes] \
     1327        -font "Arial 9"
     1328
     1329    checkbutton $inner.edges \
     1330        -text "Edges" \
     1331        -variable [itcl::scope _settings($this-edges)] \
     1332        -command [itcl::code $this FixSettings edges] \
     1333        -font "Arial 9"
     1334
     1335    checkbutton $inner.wireframe \
     1336        -text "Wireframe" \
     1337        -variable [itcl::scope _settings($this-wireframe)] \
     1338        -command [itcl::code $this FixSettings wireframe] \
     1339        -font "Arial 9"
     1340
     1341    checkbutton $inner.legend \
     1342        -text "Legend" \
     1343        -variable [itcl::scope _settings($this-legend)] \
     1344        -command [itcl::code $this FixSettings legend] \
     1345        -font "Arial 9"
     1346
     1347    checkbutton $inner.volume \
     1348        -text "Volume" \
     1349        -variable [itcl::scope _settings($this-volume)] \
     1350        -command [itcl::code $this FixSettings volume] \
     1351        -font "Arial 9"
     1352
     1353    blt::table $inner \
     1354        0,0 $inner.axes  -columnspan 2 -anchor w \
     1355        1,0 $inner.edges  -columnspan 2 -anchor w \
     1356        2,0 $inner.wireframe  -columnspan 2 -anchor w \
     1357        3,0 $inner.volume  -columnspan 2 -anchor w \
     1358        4,0 $inner.legend  -columnspan 2 -anchor w
     1359
     1360    if 0 {
     1361    bind $inner <Map> [itcl::code $this GetVolumeInfo $inner]
     1362    }
     1363    blt::table configure $inner r* -resize none
     1364    blt::table configure $inner r5 -resize expand
     1365}
     1366
     1367itcl::body Rappture::VtkViewer::BuildVolumeTab {} {
     1368    foreach { key value } {
     1369        light           40
     1370        transp          50
     1371        opacity         1000
     1372    } {
     1373        set _settings($this-$key) $value
     1374    }
     1375
     1376    set tab [$itk_component(main) insert end \
     1377        -title "Volume Settings" \
     1378        -icon [Rappture::icon volume-on]]
     1379    blt::scrollset $tab.ss \
     1380        -xscrollbar $tab.ss.xs \
     1381        -yscrollbar $tab.ss.ys \
     1382        -window $tab.ss.frame
     1383    pack $tab.ss -fill both -expand yes
     1384    blt::tk::scrollbar $tab.ss.xs               
     1385    blt::tk::scrollbar $tab.ss.ys               
     1386    set inner [blt::tk::frame $tab.ss.frame]
     1387    $inner configure -borderwidth 4
     1388
     1389    set fg [option get $itk_component(hull) font Font]
     1390    #set bfg [option get $itk_component(hull) boldFont Font]
     1391
     1392    checkbutton $inner.vol -text "Show volume" -font $fg \
     1393        -variable [itcl::scope _settings($this-volume)] \
     1394        -command [itcl::code $this FixSettings volume]
     1395    label $inner.shading -text "Shading:" -font $fg
     1396
     1397    label $inner.dim -text "Dim" -font $fg
     1398    ::scale $inner.light -from 0 -to 100 -orient horizontal \
     1399        -variable [itcl::scope _settings($this-light)] \
     1400        -width 10 \
     1401        -showvalue off -command [itcl::code $this FixSettings light]
     1402    label $inner.bright -text "Bright" -font $fg
     1403
     1404    label $inner.fog -text "Fog" -font $fg
     1405    ::scale $inner.transp -from 0 -to 100 -orient horizontal \
     1406        -variable [itcl::scope _settings($this-transp)] \
     1407        -width 10 \
     1408        -showvalue off -command [itcl::code $this FixSettings transp]
     1409    label $inner.plastic -text "Plastic" -font $fg
     1410
     1411    label $inner.clear -text "Clear" -font $fg
     1412    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
     1413        -variable [itcl::scope _settings($this-opacity)] \
     1414        -width 10 \
     1415        -showvalue off -command [itcl::code $this FixSettings opacity]
     1416    label $inner.opaque -text "Opaque" -font $fg
     1417
     1418    blt::table $inner \
     1419        0,0 $inner.vol -columnspan 4 -anchor w -pady 2 \
     1420        1,0 $inner.shading -columnspan 4 -anchor w -pady {10 2} \
     1421        2,0 $inner.dim -anchor e -pady 2 \
     1422        2,1 $inner.light -columnspan 2 -pady 2 -fill x \
     1423        2,3 $inner.bright -anchor w -pady 2 \
     1424        3,0 $inner.fog -anchor e -pady 2 \
     1425        3,1 $inner.transp -columnspan 2 -pady 2 -fill x \
     1426        3,3 $inner.plastic -anchor w -pady 2 \
     1427        4,0 $inner.clear -anchor e -pady 2 \
     1428        4,1 $inner.opacity -columnspan 2 -pady 2 -fill x\
     1429        4,3 $inner.opaque -anchor w -pady 2
     1430
     1431    blt::table configure $inner c0 c1 c3 r* -resize none
     1432    blt::table configure $inner r6 -resize expand
     1433}
     1434
     1435itcl::body Rappture::VtkViewer::BuildCutplanesTab {} {
     1436
     1437    set tab [$itk_component(main) insert end \
     1438        -title "Cutplane Settings" \
     1439        -icon [Rappture::icon cutbutton]]
     1440    blt::scrollset $tab.ss \
     1441        -xscrollbar $tab.ss.xs \
     1442        -yscrollbar $tab.ss.ys \
     1443        -window $tab.ss.frame
     1444    pack $tab.ss -fill both -expand yes
     1445    blt::tk::scrollbar $tab.ss.xs               
     1446    blt::tk::scrollbar $tab.ss.ys               
     1447    set inner [blt::tk::frame $tab.ss.frame]
     1448    $inner configure -borderwidth 4
     1449
     1450    # X-value slicer...
     1451    itk_component add xCutButton {
     1452        Rappture::PushButton $inner.xbutton \
     1453            -onimage [Rappture::icon x-cutplane] \
     1454            -offimage [Rappture::icon x-cutplane] \
     1455            -command [itcl::code $this FixSettings xcutplane] \
     1456            -variable [itcl::scope _settings($this-xcutplane)]
     1457    }
     1458    Rappture::Tooltip::for $itk_component(xCutButton) \
     1459        "Toggle the X cut plane on/off"
     1460
     1461    itk_component add xCutScale {
     1462        ::scale $inner.xval -from 100 -to 0 \
     1463            -width 10 -orient vertical -showvalue off -state disabled \
     1464            -borderwidth 1 -highlightthickness 0 \
     1465            -command [itcl::code $this Slice move x]
     1466    } {
     1467        usual
     1468        ignore -borderwidth -highlightthickness
     1469    }
     1470    # Set the default cutplane value before disabling the scale.
     1471    $itk_component(xCutScale) set 50
     1472    $itk_component(xCutScale) configure -state disabled
     1473    Rappture::Tooltip::for $itk_component(xCutScale) \
     1474        "@[itcl::code $this SlicerTip x]"
     1475
     1476    # Y-value slicer...
     1477    itk_component add yCutButton {
     1478        Rappture::PushButton $inner.ybutton \
     1479            -onimage [Rappture::icon y-cutplane] \
     1480            -offimage [Rappture::icon y-cutplane] \
     1481            -command [itcl::code $this FixSettings ycutplane] \
     1482            -variable [itcl::scope _settings($this-ycutplane)]
     1483    }
     1484    Rappture::Tooltip::for $itk_component(yCutButton) \
     1485        "Toggle the Y cut plane on/off"
     1486
     1487    itk_component add yCutScale {
     1488        ::scale $inner.yval -from 100 -to 0 \
     1489            -width 10 -orient vertical -showvalue off -state disabled \
     1490            -borderwidth 1 -highlightthickness 0 \
     1491            -command [itcl::code $this Slice move y]
     1492    } {
     1493        usual
     1494        ignore -borderwidth -highlightthickness
     1495    }
     1496    Rappture::Tooltip::for $itk_component(yCutScale) \
     1497        "@[itcl::code $this SlicerTip y]"
     1498    # Set the default cutplane value before disabling the scale.
     1499    $itk_component(yCutScale) set 50
     1500    $itk_component(yCutScale) configure -state disabled
     1501
     1502    # Z-value slicer...
     1503    itk_component add zCutButton {
     1504        Rappture::PushButton $inner.zbutton \
     1505            -onimage [Rappture::icon z-cutplane] \
     1506            -offimage [Rappture::icon z-cutplane] \
     1507            -command [itcl::code $this FixSettings zcutplane] \
     1508            -variable [itcl::scope _settings($this-zcutplane)]
     1509    }
     1510    Rappture::Tooltip::for $itk_component(zCutButton) \
     1511        "Toggle the Z cut plane on/off"
     1512
     1513    itk_component add zCutScale {
     1514        ::scale $inner.zval -from 100 -to 0 \
     1515            -width 10 -orient vertical -showvalue off -state disabled \
     1516            -borderwidth 1 -highlightthickness 0 \
     1517            -command [itcl::code $this Slice move z]
     1518    } {
     1519        usual
     1520        ignore -borderwidth -highlightthickness
     1521    }
     1522    $itk_component(zCutScale) set 50
     1523    $itk_component(zCutScale) configure -state disabled
     1524    #$itk_component(zCutScale) configure -state disabled
     1525    Rappture::Tooltip::for $itk_component(zCutScale) \
     1526        "@[itcl::code $this SlicerTip z]"
     1527
     1528    blt::table $inner \
     1529        1,1 $itk_component(xCutButton) \
     1530        1,2 $itk_component(yCutButton) \
     1531        1,3 $itk_component(zCutButton) \
     1532        0,1 $itk_component(xCutScale) \
     1533        0,2 $itk_component(yCutScale) \
     1534        0,3 $itk_component(zCutScale)
     1535
     1536    blt::table configure $inner r0 r1 c* -resize none
     1537    blt::table configure $inner r2 c4 -resize expand
     1538    blt::table configure $inner c0 -width 2
     1539    blt::table configure $inner c1 c2 c3 -padx 2
     1540}
     1541
     1542itcl::body Rappture::VtkViewer::BuildCameraTab {} {
     1543    set tab [$itk_component(main) insert end \
     1544        -title "Camera Settings" \
     1545        -icon [Rappture::icon camera]]
     1546    blt::scrollset $tab.ss \
     1547        -xscrollbar $tab.ss.xs \
     1548        -yscrollbar $tab.ss.ys \
     1549        -window $tab.ss.frame
     1550    blt::tk::scrollbar $tab.ss.xs               
     1551    blt::tk::scrollbar $tab.ss.ys               
     1552    pack $tab.ss -fill both -expand yes
     1553    set inner [blt::tk::frame $tab.ss.frame]
     1554    $inner configure -borderwidth 4
     1555
     1556    set labels { phi theta psi pan-x pan-y zoom }
     1557    set row 0
     1558    foreach tag $labels {
     1559        label $inner.${tag}label -text $tag -font "Arial 9"
     1560        entry $inner.${tag} -font "Arial 9"  -bg white \
     1561            -textvariable [itcl::scope _settings($this-$tag)]
     1562        bind $inner.${tag} <KeyPress-Return> \
     1563            [itcl::code $this camera set ${tag}]
     1564        blt::table $inner \
     1565            $row,0 $inner.${tag}label -anchor e -pady 2 \
     1566            $row,1 $inner.${tag} -anchor w -pady 2
     1567        blt::table configure $inner r$row -resize none
     1568        incr row
     1569    }
     1570    blt::table configure $inner c0 c1 -resize none
     1571    blt::table configure $inner c2 -resize expand
     1572    blt::table configure $inner r$row -resize expand
     1573}
     1574
     1575# ----------------------------------------------------------------------
     1576# USAGE: FixSettings <what> ?<value>?
     1577#
     1578# Used internally to update rendering settings whenever parameters
     1579# change in the popup settings panel.  Sends the new settings off
     1580# to the back end.
     1581# ----------------------------------------------------------------------
     1582itcl::body Rappture::VtkViewer::FixSettings {what {value ""}} {
     1583    switch -- $what {
     1584        light {
     1585        }
     1586        transp {
     1587        }
     1588        opacity {
     1589            set new [expr $_settings($this-opacity) * 0.01]
     1590            foreach dataobj [get] {
     1591                foreach comp [$dataobj components] {
     1592                    set actor [$dataobj values $comp]
     1593                    set prop [$actor GetProperty]
     1594                    $prop SetOpacity $new
     1595                }
     1596            }
     1597            $_window Render
     1598        }
     1599
     1600        "wireframe" {
     1601            foreach dataobj [get] {
     1602                foreach comp [$dataobj components] {
     1603                    set actor [$dataobj values $comp]
     1604                    set prop [$actor GetProperty]
     1605                    if { $_settings($this-wireframe) } {
     1606                        $prop SetRepresentationToWireframe
     1607                    } else {
     1608                        $prop SetRepresentationToSurface
     1609                    }
     1610                }
     1611            }
     1612            $_window Render
     1613        }
     1614        "isosurface" {
     1615        }
     1616        "edges" {
     1617            foreach dataobj [get] {
     1618                foreach comp [$dataobj components] {
     1619                    set actor [$dataobj values $comp]
     1620                    set prop [$actor GetProperty]
     1621                    if { $_settings($this-edges) } {
     1622                        $prop EdgeVisibilityOn
     1623                    } else {
     1624                        $prop EdgeVisibilityOff
     1625                    }
     1626                }
     1627            }
     1628            $_window Render
     1629        }
     1630        "axes" {
     1631            if { $_settings($this-axes) } {
     1632                $_cubeAxesActor VisibilityOn
     1633            } else {
     1634                $_cubeAxesActor VisibilityOff
     1635            }
     1636            $_window Render
     1637        }
     1638        "legend" {
     1639            if { $_settings($this-legend) } {
     1640                blt::table $itk_component(plotarea) \
     1641                    0,0 $itk_component(3dview) -fill both \
     1642                    1,0 $itk_component(legend) -fill x
     1643                blt::table configure $itk_component(plotarea) r1 -resize none
     1644            } else {
     1645                blt::table forget $itk_component(legend)
     1646            }
     1647        }
     1648        "volume" {
     1649        }
     1650        "xcutplane" - "ycutplane" - "zcutplane" {
     1651            set axis [string range $what 0 0]
     1652            set bool $_settings($this-$what)
     1653            if { $bool } {
     1654                $itk_component(${axis}CutScale) configure -state normal \
     1655                    -troughcolor white
     1656            } else {
     1657                $itk_component(${axis}CutScale) configure -state disabled \
     1658                    -troughcolor grey82
     1659            }
     1660        }
     1661        default {
     1662            error "don't know how to fix $what"
     1663        }
     1664    }
     1665}
     1666
     1667if 0 {
     1668    #
     1669    # Create slicer controls...
     1670    #
     1671    itk_component add slicers {
     1672        frame $itk_component(controls).slicers
     1673    } {
     1674        usual
     1675        rename -background -controlbackground controlBackground Background
     1676    }
     1677    pack $itk_component(slicers) -side bottom -padx 4 -pady 4
     1678    grid rowconfigure $itk_component(slicers) 1 -weight 1
     1679
     1680    #
     1681    # X-value slicer...
     1682    #
     1683    itk_component add xslice {
     1684        label $itk_component(slicers).xslice \
     1685            -borderwidth 1 -relief raised -padx 1 -pady 1 \
     1686            -bitmap [Rappture::icon x]
     1687    } {
     1688        usual
     1689        ignore -borderwidth
     1690        rename -highlightbackground -controlbackground controlBackground Background
     1691    }
     1692    bind $itk_component(xslice) <ButtonPress> \
     1693        [itcl::code $this Slice axis x toggle]
     1694    Rappture::Tooltip::for $itk_component(xslice) \
     1695        "Toggle the X cut plane on/off"
     1696    grid $itk_component(xslice) -row 0 -column 0 -sticky ew -padx 1
     1697
     1698    itk_component add xslicer {
     1699        ::scale $itk_component(slicers).xval -from 100 -to 0 \
     1700            -width 10 -orient vertical -showvalue off -state disabled \
     1701            -borderwidth 1 -highlightthickness 0 \
     1702            -command [itcl::code $this Slice move x]
     1703    } {
     1704        usual
     1705        ignore -borderwidth
     1706        ignore -highlightthickness
     1707        rename -highlightbackground -controlbackground controlBackground Background
     1708        rename -troughcolor -controldarkbackground controlDarkBackground Background
     1709    }
     1710    grid $itk_component(xslicer) -row 1 -column 0 -padx 1
     1711    Rappture::Tooltip::for $itk_component(xslicer) \
     1712        "@[itcl::code $this Slicertip x]"
     1713
     1714    #
     1715    # Y-value slicer...
     1716    #
     1717    itk_component add yslice {
     1718        label $itk_component(slicers).yslice \
     1719            -borderwidth 1 -relief raised -padx 1 -pady 1 \
     1720            -bitmap [Rappture::icon y]
     1721    } {
     1722        usual
     1723        ignore -borderwidth
     1724        rename -highlightbackground -controlbackground controlBackground Background
     1725    }
     1726    bind $itk_component(yslice) <ButtonPress> \
     1727        [itcl::code $this Slice axis y toggle]
     1728    Rappture::Tooltip::for $itk_component(yslice) \
     1729        "Toggle the Y cut plane on/off"
     1730    grid $itk_component(yslice) -row 0 -column 1 -sticky ew -padx 1
     1731
     1732    itk_component add yslicer {
     1733        ::scale $itk_component(slicers).yval -from 100 -to 0 \
     1734            -width 10 -orient vertical -showvalue off -state disabled \
     1735            -borderwidth 1 -highlightthickness 0 \
     1736            -command [itcl::code $this Slice move y]
     1737    } {
     1738        usual
     1739        ignore -borderwidth
     1740        ignore -highlightthickness
     1741        rename -highlightbackground -controlbackground controlBackground Background
     1742        rename -troughcolor -controldarkbackground controlDarkBackground Background
     1743    }
     1744    grid $itk_component(yslicer) -row 1 -column 1 -padx 1
     1745    Rappture::Tooltip::for $itk_component(yslicer) \
     1746        "@[itcl::code $this Slicertip y]"
     1747
     1748    #
     1749    # Z-value slicer...
     1750    #
     1751    itk_component add zslice {
     1752        label $itk_component(slicers).zslice \
     1753            -borderwidth 1 -relief raised -padx 1 -pady 1 \
     1754            -bitmap [Rappture::icon z]
     1755    } {
     1756        usual
     1757        ignore -borderwidth
     1758        rename -highlightbackground -controlbackground controlBackground Background
     1759    }
     1760    grid $itk_component(zslice) -row 0 -column 2 -sticky ew -padx 1
     1761    bind $itk_component(zslice) <ButtonPress> \
     1762        [itcl::code $this Slice axis z toggle]
     1763    Rappture::Tooltip::for $itk_component(zslice) \
     1764        "Toggle the Z cut plane on/off"
     1765
     1766    itk_component add zslicer {
     1767        ::scale $itk_component(slicers).zval -from 100 -to 0 \
     1768            -width 10 -orient vertical -showvalue off -state disabled \
     1769            -borderwidth 1 -highlightthickness 0 \
     1770            -command [itcl::code $this Slice move z]
     1771    } {
     1772        usual
     1773        ignore -borderwidth
     1774        ignore -highlightthickness
     1775        rename -highlightbackground -controlbackground controlBackground Background
     1776        rename -troughcolor -controldarkbackground controlDarkBackground Background
     1777    }
     1778    grid $itk_component(zslicer) -row 1 -column 2 -padx 1
     1779    Rappture::Tooltip::for $itk_component(zslicer) \
     1780        "@[itcl::code $this Slicertip z]"
     1781
     1782}
Note: See TracChangeset for help on using the changeset viewer.