Changeset 4507 for branches/1.3/gui


Ignore:
Timestamp:
Jul 16, 2014 1:54:18 PM (10 years ago)
Author:
gah
Message:

update nanoscale from trunk, update meshviewer (needs tests in bat)

File:
1 edited

Legend:

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

    r4474 r4507  
    9292    private method PanCamera {}
    9393    private method SetObjectStyle { dataobj }
    94     private method SetOpacity { dataset }
    9594    private method SetOrientation { side }
    9695    private method SetPolydataOpacity {}
     
    114113    private variable _style;            # Array of current component styles.
    115114    private variable _initialStyle;     # Array of initial component styles.
    116     private variable _axis
    117115    private variable _reset 1;          # Indicates that server was reset and
    118116                                        # needs to be reinitialized.
    119117
    120     private variable _first ""     ;# This is the topmost dataset.
     118    private variable _first "";         # This is the topmost dataset.
    121119    private variable _start 0
    122120    private variable _title ""
    123121
    124     common _downloadPopup          ;# download options from popup
     122    common _downloadPopup;              # download options from popup
    125123    private common _hardcopy
    126124    private variable _width 0
     
    184182    set _limits(zmax) 1.0
    185183
    186     array set _axis [subst {
    187         xgrid           0
    188         ygrid           0
    189         zgrid           0
    190         xcutaway        0
    191         ycutaway        0
    192         zcutaway        0
    193         xposition       0
    194         yposition       0
    195         zposition       0
    196         xdirection      -1
    197         ydirection      -1
    198         zdirection      -1
    199         visible         1
    200         labels          1
    201     }]
    202     array set _settings [subst {
    203         outline                 0
    204         polydata-edges          0
    205         polydata-lighting       1
    206         polydata-opacity        100
    207         polydata-visible        1
    208         polydata-wireframe      0
    209     }]
     184    array set _settings {
     185        -axesvisible            1
     186        -axislabels             1
     187        -outline                0
     188        -polydataedges          0
     189        -polydatalighting       1
     190        -polydataopacity        100
     191        -polydatavisible        1
     192        -polydatawireframe      0
     193        -xcutaway               0
     194        -xdirection             -1
     195        -xgrid                  0
     196        -xposition              0
     197        -ycutaway               0
     198        -ydirection             -1
     199        -ygrid                  0
     200        -yposition              0
     201        -zcutaway               0
     202        -zdirection             -1
     203        -zgrid                  0
     204        -zposition              0
     205    }
    210206    itk_component add view {
    211207        canvas $itk_component(plotarea).view \
     
    407403itcl::body Rappture::VtkMeshViewer::SetPolydataOpacity {} {
    408404    set _polydataOpacityPending 0
    409     foreach dataset [CurrentDatasets -visible $_first] {
    410         SetOpacity $dataset
    411     }
    412 }
    413 
    414 itcl::body Rappture::VtkMeshViewer::EventuallySetPolydataOpacity { args } {
     405    set val $_settings(-polydataopacity)
     406    set sval [expr { 0.01 * double($val) }]
     407    SendCmd "polydata opacity $sval"
     408}
     409
     410itcl::body Rappture::VtkMeshViewer::EventuallySetPolydataOpacity { val } {
     411    set _settings(-polydataopacity) $val
    415412    if { !$_polydataOpacityPending } {
    416413        set _polydataOpacityPending 1
     
    478475        set _dlist [lreplace $_dlist $pos $pos]
    479476        array unset _obj2ovride $dataobj-*
    480         array unset _settings $dataobj-*
    481477        set changed 1
    482478    }
     
    832828        $_arcball resize $w $h
    833829        DoResize
    834         InitSettings axis-xgrid axis-ygrid axis-zgrid axis-mode \
    835             axis-visible axis-labels
    836  
     830        InitSettings -xgrid -ygrid -zgrid -axismode -axesvisible -axislabels
    837831        StopBufferingCommands
    838832        SendCmd "imgflush"
     
    874868        }
    875869        lappend _obj2datasets($dataobj) $tag
    876         if { [info exists _obj2ovride($dataobj-raise)] } {
     870        if { [info exists _obj2ovride($dataobj-raise)] &&
     871             $_obj2ovride($dataobj-raise) } {
    877872            SendCmd "dataset visible 1 $tag"
    878873            SetOpacity $tag
     
    896891        }
    897892    }
    898     InitSettings outline
     893    InitSettings -outline
    899894    if { $_reset } {
    900895        # These are settings that rely on a dataset being loaded.
    901         InitSettings polydata-edges polydata-lighting polydata-opacity \
    902             polydata-visible polydata-wireframe
     896        InitSettings -polydataedges -polydatalighting -polydataopacity \
     897            -polydatavisible -polydatawireframe
    903898 
    904899        set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     
    11521147    }
    11531148    switch -- $what {
    1154         "outline" {
    1155             set bool $_settings(outline)
    1156             foreach dataset [CurrentDatasets -visible $_first] {
     1149        "-outline" {
     1150            set bool $_settings($what)
     1151            # Only display a outline for the currently visible sets.
     1152            SendCmd "outline visible 0"
     1153            foreach dataset [CurrentDatasets -visible] {
    11571154                SendCmd "outline visible $bool $dataset"
    11581155            }
    11591156        }
    1160         "polydata-opacity" {
    1161             foreach dataset [CurrentDatasets -visible $_first] {
    1162                 SetOpacity $dataset
    1163             }
    1164         }
    1165         "polydata-wireframe" {
    1166             set bool $_settings(polydata-wireframe)
    1167             foreach dataset [CurrentDatasets -visible $_first] {
    1168                 SendCmd "polydata wireframe $bool $dataset"
    1169             }
    1170         }
    1171         "polydata-visible" {
    1172             set bool $_settings(polydata-visible)
    1173             foreach dataset [CurrentDatasets -visible $_first] {
     1157        "-polydataopacity" {
     1158            EventuallySetPolydataOpacity
     1159        }
     1160        "-polydatawireframe" {
     1161            set bool $_settings($what)
     1162            SendCmd "polydata wireframe $bool"
     1163        }
     1164        "-polydatavisible" {
     1165            set bool $_settings($what)
     1166            # Only change visibility of data sets marked "visible".
     1167            foreach dataset [CurrentDatasets -visible] {
    11741168                SendCmd "polydata visible $bool $dataset"
    11751169            }
    11761170        }
    1177         "polydata-lighting" {
    1178             set bool $_settings(polydata-lighting)
    1179             foreach dataset [CurrentDatasets -visible $_first] {
    1180                 SendCmd "polydata lighting $bool $dataset"
    1181             }
    1182         }
    1183         "polydata-edges" {
    1184             set bool $_settings(polydata-edges)
    1185             foreach dataset [CurrentDatasets -visible $_first] {
    1186                 SendCmd "polydata edges $bool $dataset"
    1187             }
    1188         }
    1189         "axis-visible" {
    1190             set bool $_axis(visible)
     1171        "-polydatalighting" {
     1172            set bool $_settings($what)
     1173            SendCmd "polydata lighting $bool"
     1174        }
     1175        "-polydataedges" {
     1176            set bool $_settings($what)
     1177            SendCmd "polydata edges $bool"
     1178        }
     1179        "-axesvisible" {
     1180            set bool $_settings($what)
    11911181            SendCmd "axis visible all $bool"
    11921182        }
    1193         "axis-labels" {
    1194             set bool $_axis(labels)
     1183        "-axislabels" {
     1184            set bool $_settings($what)
    11951185            SendCmd "axis labels all $bool"
    11961186        }
    1197         "axis-xgrid" {
    1198             set bool $_axis(xgrid)
     1187        "-xgrid" {
     1188            set bool $_settings($what)
    11991189            SendCmd "axis grid x $bool"
    12001190        }
    1201         "axis-ygrid" {
    1202             set bool $_axis(ygrid)
     1191        "-ygrid" {
     1192            set bool $_settings($what)
    12031193            SendCmd "axis grid y $bool"
    12041194        }
    1205         "axis-zgrid" {
    1206             set bool $_axis(zgrid)
     1195        "-zgrid" {
     1196            set bool $_settings($what)
    12071197            SendCmd "axis grid z $bool"
    12081198        }
    1209         "axis-mode" {
     1199        "-axismode" {
    12101200            set mode [$itk_component(axismode) value]
    12111201            set mode [$itk_component(axismode) translate $mode]
    12121202            SendCmd "axis flymode $mode"
    12131203        }
    1214         "axis-xcutaway" - "axis-ycutaway" - "axis-zcutaway" {
    1215             set axis [string range $what 5 5]
    1216             set bool $_axis(${axis}cutaway)
     1204        "-xcutaway" - "-ycutaway" - "-zcutaway" {
     1205            set axis [string range $what 1 1]
     1206            set bool $_settings($what)
    12171207            if { $bool } {
    1218                 set pos [expr $_axis(${axis}position) * 0.01]
    1219                 set dir $_axis(${axis}direction)
     1208                set pos [expr $_settings(-${axis}position) * 0.01]
     1209                set dir $_settings(-${axis}direction)
    12201210                $itk_component(${axis}CutScale) configure -state normal \
    12211211                    -troughcolor white
     
    12271217            }
    12281218        }
    1229         "axis-xposition" - "axis-yposition" - "axis-zposition" -
    1230         "axis-xdirection" - "axis-ydirection" - "axis-zdirection" {
    1231             set axis [string range $what 5 5]
    1232             #set dir $_axis(${axis}direction)
    1233             set pos [expr $_axis(${axis}position) * 0.01]
     1219        "-xposition" - "-yposition" - "-zposition" {
     1220            set axis [string range $what 1 1]
     1221            set pos [expr $_settings($what) * 0.01]
    12341222            SendCmd "renderer clipplane ${axis} $pos -1"
     1223        }
     1224        "-xdirection" - "-ydirection" - "-zdirection" {
     1225            set axis [string range $what 1 1]
     1226            puts stderr "direction not implemented"
    12351227        }
    12361228        default {
     
    13171309    checkbutton $inner.mesh \
    13181310        -text "Show Mesh" \
    1319         -variable [itcl::scope _settings(polydata-visible)] \
    1320         -command [itcl::code $this AdjustSetting polydata-visible] \
     1311        -variable [itcl::scope _settings(-polydatavisible)] \
     1312        -command [itcl::code $this AdjustSetting -polydatavisible] \
    13211313        -font "Arial 9" -anchor w
    13221314
    13231315    checkbutton $inner.outline \
    13241316        -text "Show Outline" \
    1325         -variable [itcl::scope _settings(outline)] \
    1326         -command [itcl::code $this AdjustSetting outline] \
     1317        -variable [itcl::scope _settings(-outline)] \
     1318        -command [itcl::code $this AdjustSetting -outline] \
    13271319        -font "Arial 9" -anchor w
    13281320
    13291321    checkbutton $inner.wireframe \
    13301322        -text "Show Wireframe" \
    1331         -variable [itcl::scope _settings(polydata-wireframe)] \
    1332         -command [itcl::code $this AdjustSetting polydata-wireframe] \
     1323        -variable [itcl::scope _settings(-polydatawireframe)] \
     1324        -command [itcl::code $this AdjustSetting -polydatawireframe] \
    13331325        -font "Arial 9" -anchor w
    13341326
    13351327    checkbutton $inner.lighting \
    13361328        -text "Enable Lighting" \
    1337         -variable [itcl::scope _settings(polydata-lighting)] \
    1338         -command [itcl::code $this AdjustSetting polydata-lighting] \
     1329        -variable [itcl::scope _settings(-polydatalighting)] \
     1330        -command [itcl::code $this AdjustSetting -polydatalighting] \
    13391331        -font "Arial 9" -anchor w
    13401332
    13411333    checkbutton $inner.edges \
    13421334        -text "Show Edges" \
    1343         -variable [itcl::scope _settings(polydata-edges)] \
    1344         -command [itcl::code $this AdjustSetting polydata-edges] \
     1335        -variable [itcl::scope _settings(-polydataedges)] \
     1336        -command [itcl::code $this AdjustSetting -polydataedges] \
    13451337        -font "Arial 9" -anchor w
    13461338
     
    13541346    }
    13551347    bind $inner.field <<Value>> \
    1356         [itcl::code $this AdjustSetting field]
     1348        [itcl::code $this AdjustSetting -field]
    13571349
    13581350    label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w
    13591351    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1360         -variable [itcl::scope _settings(polydata-opacity)] \
     1352        -variable [itcl::scope _settings(-polydataopacity)] \
    13611353        -width 10 \
    13621354        -showvalue off \
    1363         -command [itcl::code $this AdjustSetting polydata-opacity]
    1364     $inner.opacity set $_settings(polydata-opacity)
     1355        -command [itcl::code $this AdjustSetting -polydataopacity]
     1356    $inner.opacity set $_settings(-polydataopacity)
    13651357
    13661358    blt::table $inner \
     
    13891381    checkbutton $inner.visible \
    13901382        -text "Show Axes" \
    1391         -variable [itcl::scope _axis(visible)] \
    1392         -command [itcl::code $this AdjustSetting axis-visible] \
     1383        -variable [itcl::scope _settings(-axesvisible)] \
     1384        -command [itcl::code $this AdjustSetting -axesvisible] \
    13931385        -font "Arial 9"
    13941386
    13951387    checkbutton $inner.labels \
    13961388        -text "Show Axis Labels" \
    1397         -variable [itcl::scope _axis(labels)] \
    1398         -command [itcl::code $this AdjustSetting axis-labels] \
     1389        -variable [itcl::scope _settings(-axislabels)] \
     1390        -command [itcl::code $this AdjustSetting -axislabels] \
    13991391        -font "Arial 9"
    14001392
    14011393    checkbutton $inner.gridx \
    14021394        -text "Show X Grid" \
    1403         -variable [itcl::scope _axis(xgrid)] \
    1404         -command [itcl::code $this AdjustSetting axis-xgrid] \
     1395        -variable [itcl::scope _settings(-xgrid)] \
     1396        -command [itcl::code $this AdjustSetting -xgrid] \
    14051397        -font "Arial 9"
    14061398    checkbutton $inner.gridy \
    14071399        -text "Show Y Grid" \
    1408         -variable [itcl::scope _axis(ygrid)] \
    1409         -command [itcl::code $this AdjustSetting axis-ygrid] \
     1400        -variable [itcl::scope _settings(-ygrid)] \
     1401        -command [itcl::code $this AdjustSetting -ygrid] \
    14101402        -font "Arial 9"
    14111403    checkbutton $inner.gridz \
    14121404        -text "Show Z Grid" \
    1413         -variable [itcl::scope _axis(zgrid)] \
    1414         -command [itcl::code $this AdjustSetting axis-zgrid] \
     1405        -variable [itcl::scope _settings(-zgrid)] \
     1406        -command [itcl::code $this AdjustSetting -zgrid] \
    14151407        -font "Arial 9"
    14161408
     
    14261418        "outer_edges"     "outer"         
    14271419    $itk_component(axismode) value "static"
    1428     bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axis-mode]
     1420    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
    14291421
    14301422    blt::table $inner \
     
    15041496            -onimage [Rappture::icon x-cutplane] \
    15051497            -offimage [Rappture::icon x-cutplane] \
    1506             -command [itcl::code $this AdjustSetting axis-xcutaway] \
    1507             -variable [itcl::scope _axis(xcutaway)]
     1498            -command [itcl::code $this AdjustSetting -xcutaway] \
     1499            -variable [itcl::scope _settings(-xcutaway)]
    15081500    }
    15091501    Rappture::Tooltip::for $itk_component(xCutButton) \
     
    15151507            -borderwidth 1 -highlightthickness 0 \
    15161508            -command [itcl::code $this Slice move x] \
    1517             -variable [itcl::scope _axis(xposition)]
     1509            -variable [itcl::scope _settings(-xposition)]
    15181510    } {
    15191511        usual
     
    15321524            -offimage [Rappture::icon arrow-up] \
    15331525            -offvalue 1 \
    1534             -command [itcl::code $this AdjustSetting axis-xdirection] \
    1535             -variable [itcl::scope _axis(xdirection)]
    1536     }
    1537     set _axis(xdirection) -1
     1526            -command [itcl::code $this AdjustSetting -xdirection] \
     1527            -variable [itcl::scope _settings(-xdirection)]
     1528    }
     1529    set _settings(-xdirection) -1
    15381530    Rappture::Tooltip::for $itk_component(xDirButton) \
    15391531        "Toggle the direction of the X-axis cutaway"
     
    15441536            -onimage [Rappture::icon y-cutplane] \
    15451537            -offimage [Rappture::icon y-cutplane] \
    1546             -command [itcl::code $this AdjustSetting axis-ycutaway] \
    1547             -variable [itcl::scope _axis(ycutaway)]
     1538            -command [itcl::code $this AdjustSetting -ycutaway] \
     1539            -variable [itcl::scope _settings(-ycutaway)]
    15481540    }
    15491541    Rappture::Tooltip::for $itk_component(yCutButton) \
     
    15551547            -borderwidth 1 -highlightthickness 0 \
    15561548            -command [itcl::code $this Slice move y] \
    1557             -variable [itcl::scope _axis(yposition)]
     1549            -variable [itcl::scope _settings(-yposition)]
    15581550    } {
    15591551        usual
     
    15721564            -offimage [Rappture::icon arrow-up] \
    15731565            -offvalue 1 \
    1574             -command [itcl::code $this AdjustSetting axis-ydirection] \
    1575             -variable [itcl::scope _axis(ydirection)]
     1566            -command [itcl::code $this AdjustSetting -ydirection] \
     1567            -variable [itcl::scope _settings(-ydirection)]
    15761568    }
    15771569    Rappture::Tooltip::for $itk_component(yDirButton) \
    15781570        "Toggle the direction of the Y-axis cutaway"
    1579     set _axis(ydirection) -1
     1571    set _settings(-ydirection) -1
    15801572
    15811573    # Z-value slicer...
     
    15841576            -onimage [Rappture::icon z-cutplane] \
    15851577            -offimage [Rappture::icon z-cutplane] \
    1586             -command [itcl::code $this AdjustSetting axis-zcutaway] \
    1587             -variable [itcl::scope _axis(zcutaway)]
     1578            -command [itcl::code $this AdjustSetting -zcutaway] \
     1579            -variable [itcl::scope _settings(-zcutaway)]
    15881580    }
    15891581    Rappture::Tooltip::for $itk_component(zCutButton) \
     
    15951587            -borderwidth 1 -highlightthickness 0 \
    15961588            -command [itcl::code $this Slice move z] \
    1597             -variable [itcl::scope _axis(zposition)]
     1589            -variable [itcl::scope _settings(-zposition)]
    15981590    } {
    15991591        usual
     
    16111603            -offimage [Rappture::icon arrow-up] \
    16121604            -offvalue 1 \
    1613             -command [itcl::code $this AdjustSetting axis-zdirection] \
    1614             -variable [itcl::scope _axis(zdirection)]
    1615     }
    1616     set _axis(zdirection) -1
     1605            -command [itcl::code $this AdjustSetting -zdirection] \
     1606            -variable [itcl::scope _settings(-zdirection)]
     1607    }
     1608    set _settings(-zdirection) -1
    16171609    Rappture::Tooltip::for $itk_component(zDirButton) \
    16181610        "Toggle the direction of the Z-axis cutaway"
     
    17361728    set style [$dataobj hints style]
    17371729    if { $dataobj != $_first } {
    1738         set settings(-wireframe) 1
     1730        set settings(-polydatawireframe) 1
    17391731    }
    17401732
     
    17431735        -color white
    17441736        -edgecolor black
    1745         -edges 1
    17461737        -lighting 1
    17471738        -linewidth 1.0
    1748         -opacity 1.0
    17491739        -outline 0
    1750         -visible 1
    1751         -wireframe 0
     1740        -polydataedges 1
     1741        -polydataopacity 1.0
     1742        -polydatavisible 1
     1743        -polydatawireframe 0
    17521744    }
    17531745    if {$type == "cloud"} {
    17541746        set settings(-cloudstyle) points
    1755         set settings(-edges) 0
     1747        set settings(-polydataedges) 0
    17561748        set settings(-edgecolor) white
    17571749    }
     
    17631755    SendCmd "outline color [Color2RGB $settings(-color)] $tag"
    17641756    SendCmd "outline visible $settings(-outline) $tag"
    1765     set _settings(outline) $settings(-outline)
     1757    set _settings(-outline) $settings(-outline)
    17661758
    17671759    SendCmd "polydata add $tag"
    1768     SendCmd "polydata visible $settings(-visible) $tag"
     1760    SendCmd "polydata visible $settings(-polydatavisible) $tag"
    17691761    SendCmd "polydata cloudstyle $settings(-cloudstyle) $tag"
    1770     set _settings(polydata-visible) $settings(-visible)
    1771     SendCmd "polydata edges $settings(-edges) $tag"
    1772     set _settings(polydata-edges) $settings(-edges)
     1762    set _settings(-polydatavisible) $settings(-polydatavisible)
     1763    SendCmd "polydata edges $settings(-polydataedges) $tag"
     1764    set _settings(-polydataedges) $settings(-polydataedges)
    17731765    SendCmd "polydata color [Color2RGB $settings(-color)] $tag"
    1774     #SendCmd "polydata colormode constant {} $tag"
    1775     SendCmd "polydata lighting $settings(-lighting) $tag"
    1776     set _settings(polydata-lighting) $settings(-lighting)
     1766
     1767    SendCmd "polydata lighting $settings(-polydatalighting) $tag"
     1768    set _settings(-polydatalighting) $settings(-polydatalighting)
    17771769    SendCmd "polydata linecolor [Color2RGB $settings(-edgecolor)] $tag"
    17781770    SendCmd "polydata linewidth $settings(-linewidth) $tag"
    1779     SendCmd "polydata opacity $settings(-opacity) $tag"
    1780     set _settings(polydata-opacity) [expr 100.0 * $settings(-opacity)]
    1781     SendCmd "polydata wireframe $settings(-wireframe) $tag"
    1782     set _settings(polydata-wireframe) $settings(-wireframe)
     1771    SendCmd "polydata opacity $settings(-polydataopacity) $tag"
     1772    set _settings(-polydataopacity) [expr 100.0 * $settings(-polydataopacity)]
     1773    SendCmd "polydata wireframe $settings(-polydatawireframe) $tag"
     1774    set _settings(-polydatawireframe) $settings(-polydatawireframe)
    17831775    set havePolyData 1
    17841776}
     
    18421834}
    18431835
    1844 itcl::body Rappture::VtkMeshViewer::SetOpacity { dataset } {
    1845     set val $_settings(polydata-opacity)
    1846     set sval [expr { 0.01 * double($val) }]
    1847     if { !$_obj2ovride($dataset-raise) } {
    1848         # This is wrong.  Need to figure out why raise isn't set with 1
    1849         #set sval [expr $sval * .6]
    1850     }
    1851     SendCmd "polydata opacity $sval $dataset"
    1852 }
Note: See TracChangeset for help on using the changeset viewer.