Ignore:
Timestamp:
Nov 26, 2014, 7:28:23 PM (10 years ago)
Author:
gah
Message:

sync with former 1.3 branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/uq/gui/scripts/vtkmeshviewer.tcl

    r4797 r4798  
    5757    public method get {args}
    5858    public method isconnected {}
    59     public method limits { dataobj }
     59    public method limits { colormap }
    6060    public method parameters {title args} {
    6161        # do nothing
     
    8181    private method BuildAxisTab {}
    8282    private method BuildCameraTab {}
     83    private method BuildCutawayTab {}
    8384    private method BuildDownloadPopup { widget command }
    8485    private method BuildPolydataTab {}
     
    9394    private method SetOrientation { side }
    9495    private method SetPolydataOpacity {}
     96    private method Slice {option args}
    9597
    9698    private variable _arcball ""
     
    100102    private variable _datasets;         # contains all the dataobj-component
    101103                                        # datasets in the server
     104    private variable _colormaps;        # contains all the colormaps
     105                                        # in the server.
    102106    private variable _dataset2style;    # maps dataobj-component to transfunc
    103107    private variable _style2datasets;   # maps tf back to list of
     
    183187        -axesvisible            1
    184188        -axislabels             1
    185         -axisminorticks         1
    186189        -outline                0
    187190        -polydataedges          0
     
    190193        -polydatavisible        1
    191194        -polydatawireframe      0
     195        -xcutaway               0
     196        -xdirection             -1
    192197        -xgrid                  0
     198        -xposition              0
     199        -ycutaway               0
     200        -ydirection             -1
    193201        -ygrid                  0
     202        -yposition              0
     203        -zcutaway               0
     204        -zdirection             -1
    194205        -zgrid                  0
     206        -zposition              0
    195207    }
    196208    array set _widget {
     
    273285    BuildPolydataTab
    274286    BuildAxisTab
     287    #BuildCutawayTab
    275288    BuildCameraTab
    276289
     
    710723
    711724    # disconnected -- no more data sitting on server
    712     array unset _datasets
    713     array unset _data
     725    array unset _datasets
     726    array unset _data
     727    array unset _colormaps
    714728    global readyForNextFrame
    715729    set readyForNextFrame 1
     
    821835        $_arcball resize $w $h
    822836        DoResize
    823         InitSettings -xgrid -ygrid -zgrid -axismode \
    824             -axesvisible -axislabels -axisminorticks
     837        InitSettings -xgrid -ygrid -zgrid -axismode -axesvisible -axislabels
    825838        StopBufferingCommands
    826839        SendCmd "imgflush"
     
    890903            -polydatavisible -polydatawireframe
    891904 
    892         #SendCmd "axis lformat all %g"
     905        SendCmd "axis lformat all %g"
     906        # Too many major ticks, so turn off minor ticks
     907        SendCmd "axis minticks all 0"
    893908
    894909        set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     
    12011216            set mode [$itk_component(axismode) translate $mode]
    12021217            SendCmd "axis flymode $mode"
     1218        }
     1219        "-xcutaway" - "-ycutaway" - "-zcutaway" {
     1220            set axis [string range $what 1 1]
     1221            set bool $_settings($what)
     1222            if { $bool } {
     1223                set pos [expr $_settings(-${axis}position) * 0.01]
     1224                set dir $_settings(-${axis}direction)
     1225                $itk_component(${axis}CutScale) configure -state normal \
     1226                    -troughcolor white
     1227                SendCmd "renderer clipplane $axis $pos $dir"
     1228            } else {
     1229                $itk_component(${axis}CutScale) configure -state disabled \
     1230                    -troughcolor grey82
     1231                SendCmd "renderer clipplane $axis 1 -1"
     1232            }
     1233        }
     1234        "-xposition" - "-yposition" - "-zposition" {
     1235            set axis [string range $what 1 1]
     1236            set pos [expr $_settings($what) * 0.01]
     1237            SendCmd "renderer clipplane ${axis} $pos -1"
     1238        }
     1239        "-xdirection" - "-ydirection" - "-zdirection" {
     1240            set axis [string range $what 1 1]
     1241            puts stderr "direction not implemented"
    12031242        }
    12041243        default {
     
    13521391    set inner [$itk_component(main) insert end \
    13531392        -title "Axis Settings" \
    1354         -icon [Rappture::icon axis2]]
     1393        -icon [Rappture::icon axis1]]
    13551394    $inner configure -borderwidth 4
    13561395
    13571396    checkbutton $inner.visible \
    1358         -text "Axes" \
     1397        -text "Show Axes" \
    13591398        -variable [itcl::scope _settings(-axesvisible)] \
    13601399        -command [itcl::code $this AdjustSetting -axesvisible] \
     
    13621401
    13631402    checkbutton $inner.labels \
    1364         -text "Axis Labels" \
     1403        -text "Show Axis Labels" \
    13651404        -variable [itcl::scope _settings(-axislabels)] \
    13661405        -command [itcl::code $this AdjustSetting -axislabels] \
    13671406        -font "Arial 9"
    1368     label $inner.grid_l -text "Grid" -font "Arial 9"
    1369     checkbutton $inner.xgrid \
    1370         -text "X" \
     1407
     1408    checkbutton $inner.gridx \
     1409        -text "Show X Grid" \
    13711410        -variable [itcl::scope _settings(-xgrid)] \
    13721411        -command [itcl::code $this AdjustSetting -xgrid] \
    13731412        -font "Arial 9"
    1374     checkbutton $inner.ygrid \
    1375         -text "Y" \
     1413    checkbutton $inner.gridy \
     1414        -text "Show Y Grid" \
    13761415        -variable [itcl::scope _settings(-ygrid)] \
    13771416        -command [itcl::code $this AdjustSetting -ygrid] \
    13781417        -font "Arial 9"
    1379     checkbutton $inner.zgrid \
    1380         -text "Z" \
     1418    checkbutton $inner.gridz \
     1419        -text "Show Z Grid" \
    13811420        -variable [itcl::scope _settings(-zgrid)] \
    13821421        -command [itcl::code $this AdjustSetting -zgrid] \
    1383         -font "Arial 9"
    1384     checkbutton $inner.minorticks \
    1385         -text "Minor Ticks" \
    1386         -variable [itcl::scope _settings(-axisminorticks)] \
    1387         -command [itcl::code $this AdjustSetting -axisminorticks] \
    13881422        -font "Arial 9"
    13891423
     
    14021436
    14031437    blt::table $inner \
    1404         0,0 $inner.visible -anchor w -cspan 4 \
    1405         1,0 $inner.labels  -anchor w -cspan 4 \
    1406         2,0 $inner.minorticks  -anchor w -cspan 4 \
    1407         4,0 $inner.grid_l  -anchor w \
    1408         4,1 $inner.xgrid   -anchor w \
    1409         4,2 $inner.ygrid   -anchor w \
    1410         4,3 $inner.zgrid   -anchor w \
    1411         5,0 $inner.mode_l  -anchor w -padx { 2 0 } \
    1412         5,1 $inner.mode    -fill x   -cspan 3
     1438        0,0 $inner.visible -anchor w -cspan 2 \
     1439        1,0 $inner.labels  -anchor w -cspan 2 \
     1440        2,0 $inner.gridx   -anchor w -cspan 2 \
     1441        3,0 $inner.gridy   -anchor w -cspan 2 \
     1442        4,0 $inner.gridz   -anchor w -cspan 2 \
     1443        5,0 $inner.mode_l  -anchor w -cspan 2 -padx { 2 0 } \
     1444        6,0 $inner.mode    -fill x   -cspan 2
    14131445
    14141446    blt::table configure $inner r* c* -resize none
    1415     blt::table configure $inner r7 c6 -resize expand
    1416     blt::table configure $inner r3 -height 0.125i
     1447    blt::table configure $inner r7 c1 -resize expand
    14171448}
    14181449
     
    14631494    blt::table configure $inner c2 -resize expand
    14641495    blt::table configure $inner r$row -resize expand
     1496}
     1497
     1498itcl::body Rappture::VtkMeshViewer::BuildCutawayTab {} {
     1499
     1500    set fg [option get $itk_component(hull) font Font]
     1501   
     1502    set inner [$itk_component(main) insert end \
     1503        -title "Cutaway Along Axis" \
     1504        -icon [Rappture::icon cutbutton]]
     1505
     1506    $inner configure -borderwidth 4
     1507
     1508    # X-value slicer...
     1509    itk_component add xCutButton {
     1510        Rappture::PushButton $inner.xbutton \
     1511            -onimage [Rappture::icon x-cutplane] \
     1512            -offimage [Rappture::icon x-cutplane] \
     1513            -command [itcl::code $this AdjustSetting -xcutaway] \
     1514            -variable [itcl::scope _settings(-xcutaway)]
     1515    }
     1516    Rappture::Tooltip::for $itk_component(xCutButton) \
     1517        "Toggle the X-axis cutaway on/off"
     1518
     1519    itk_component add xCutScale {
     1520        ::scale $inner.xval -from 100 -to 0 \
     1521            -width 10 -orient vertical -showvalue yes \
     1522            -borderwidth 1 -highlightthickness 0 \
     1523            -command [itcl::code $this Slice move x] \
     1524            -variable [itcl::scope _settings(-xposition)]
     1525    } {
     1526        usual
     1527        ignore -borderwidth -highlightthickness
     1528    }
     1529    # Set the default cutaway value before disabling the scale.
     1530    $itk_component(xCutScale) set 100
     1531    $itk_component(xCutScale) configure -state disabled
     1532    Rappture::Tooltip::for $itk_component(xCutScale) \
     1533        "@[itcl::code $this Slice tooltip x]"
     1534
     1535    itk_component add xDirButton {
     1536        Rappture::PushButton $inner.xdir \
     1537            -onimage [Rappture::icon arrow-down] \
     1538            -onvalue -1 \
     1539            -offimage [Rappture::icon arrow-up] \
     1540            -offvalue 1 \
     1541            -command [itcl::code $this AdjustSetting -xdirection] \
     1542            -variable [itcl::scope _settings(-xdirection)]
     1543    }
     1544    set _settings(-xdirection) -1
     1545    Rappture::Tooltip::for $itk_component(xDirButton) \
     1546        "Toggle the direction of the X-axis cutaway"
     1547
     1548    # Y-value slicer...
     1549    itk_component add yCutButton {
     1550        Rappture::PushButton $inner.ybutton \
     1551            -onimage [Rappture::icon y-cutplane] \
     1552            -offimage [Rappture::icon y-cutplane] \
     1553            -command [itcl::code $this AdjustSetting -ycutaway] \
     1554            -variable [itcl::scope _settings(-ycutaway)]
     1555    }
     1556    Rappture::Tooltip::for $itk_component(yCutButton) \
     1557        "Toggle the Y-axis cutaway on/off"
     1558
     1559    itk_component add yCutScale {
     1560        ::scale $inner.yval -from 100 -to 0 \
     1561            -width 10 -orient vertical -showvalue yes \
     1562            -borderwidth 1 -highlightthickness 0 \
     1563            -command [itcl::code $this Slice move y] \
     1564            -variable [itcl::scope _settings(-yposition)]
     1565    } {
     1566        usual
     1567        ignore -borderwidth -highlightthickness
     1568    }
     1569    Rappture::Tooltip::for $itk_component(yCutScale) \
     1570        "@[itcl::code $this Slice tooltip y]"
     1571    # Set the default cutaway value before disabling the scale.
     1572    $itk_component(yCutScale) set 100
     1573    $itk_component(yCutScale) configure -state disabled
     1574
     1575    itk_component add yDirButton {
     1576        Rappture::PushButton $inner.ydir \
     1577            -onimage [Rappture::icon arrow-down] \
     1578            -onvalue -1 \
     1579            -offimage [Rappture::icon arrow-up] \
     1580            -offvalue 1 \
     1581            -command [itcl::code $this AdjustSetting -ydirection] \
     1582            -variable [itcl::scope _settings(-ydirection)]
     1583    }
     1584    Rappture::Tooltip::for $itk_component(yDirButton) \
     1585        "Toggle the direction of the Y-axis cutaway"
     1586    set _settings(-ydirection) -1
     1587
     1588    # Z-value slicer...
     1589    itk_component add zCutButton {
     1590        Rappture::PushButton $inner.zbutton \
     1591            -onimage [Rappture::icon z-cutplane] \
     1592            -offimage [Rappture::icon z-cutplane] \
     1593            -command [itcl::code $this AdjustSetting -zcutaway] \
     1594            -variable [itcl::scope _settings(-zcutaway)]
     1595    }
     1596    Rappture::Tooltip::for $itk_component(zCutButton) \
     1597        "Toggle the Z-axis cutaway on/off"
     1598
     1599    itk_component add zCutScale {
     1600        ::scale $inner.zval -from 100 -to 0 \
     1601            -width 10 -orient vertical -showvalue yes \
     1602            -borderwidth 1 -highlightthickness 0 \
     1603            -command [itcl::code $this Slice move z] \
     1604            -variable [itcl::scope _settings(-zposition)]
     1605    } {
     1606        usual
     1607        ignore -borderwidth -highlightthickness
     1608    }
     1609    $itk_component(zCutScale) set 100
     1610    $itk_component(zCutScale) configure -state disabled
     1611    Rappture::Tooltip::for $itk_component(zCutScale) \
     1612        "@[itcl::code $this Slice tooltip z]"
     1613
     1614    itk_component add zDirButton {
     1615        Rappture::PushButton $inner.zdir \
     1616            -onimage [Rappture::icon arrow-down] \
     1617            -onvalue -1 \
     1618            -offimage [Rappture::icon arrow-up] \
     1619            -offvalue 1 \
     1620            -command [itcl::code $this AdjustSetting -zdirection] \
     1621            -variable [itcl::scope _settings(-zdirection)]
     1622    }
     1623    set _settings(-zdirection) -1
     1624    Rappture::Tooltip::for $itk_component(zDirButton) \
     1625        "Toggle the direction of the Z-axis cutaway"
     1626
     1627    blt::table $inner \
     1628        0,0 $itk_component(xCutButton)  -anchor e -padx 2 -pady 2 \
     1629        1,0 $itk_component(xCutScale)   -fill y \
     1630        0,1 $itk_component(yCutButton)  -anchor e -padx 2 -pady 2 \
     1631        1,1 $itk_component(yCutScale)   -fill y \
     1632        0,2 $itk_component(zCutButton)  -anchor e -padx 2 -pady 2 \
     1633        1,2 $itk_component(zCutScale)   -fill y \
     1634
     1635    blt::table configure $inner r* c* -resize none
     1636    blt::table configure $inner r1 c3 -resize expand
    14651637}
    14661638
     
    16251797}
    16261798
     1799# ----------------------------------------------------------------------
     1800# USAGE: Slice move x|y|z <newval>
     1801#
     1802# Called automatically when the user drags the slider to move the
     1803# cut plane that slices 3D data.  Gets the current value from the
     1804# slider and moves the cut plane to the appropriate point in the
     1805# data set.
     1806# ----------------------------------------------------------------------
     1807itcl::body Rappture::VtkMeshViewer::Slice {option args} {
     1808    switch -- $option {
     1809        "move" {
     1810            set axis [lindex $args 0]
     1811            set newval [lindex $args 1]
     1812            if {[llength $args] != 2} {
     1813                error "wrong # args: should be \"Slice move x|y|z newval\""
     1814            }
     1815            set newpos [expr {0.01*$newval}]
     1816            SendCmd "renderer clipplane $axis $newpos -1"
     1817        }
     1818        "tooltip" {
     1819            set axis [lindex $args 0]
     1820            set val [$itk_component(${axis}CutScale) get]
     1821            return "Move the [string toupper $axis] cut plane.\nCurrently:  $axis = $val%"
     1822        }
     1823        default {
     1824            error "bad option \"$option\": should be axis, move, or tooltip"
     1825        }
     1826    }
     1827}
     1828
    16271829itcl::body Rappture::VtkMeshViewer::SetOrientation { side } {
    16281830    array set positions {
     
    16451847    set _view(zoom) 1.0
    16461848}
     1849
Note: See TracChangeset for help on using the changeset viewer.