Ignore:
Timestamp:
Jul 16, 2014, 4:24:32 PM (10 years ago)
Author:
gah
Message:

test and fixes for meshviewer, add rappture (non-viewer) bug fixes and features

File:
1 edited

Legend:

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

    r4504 r4512  
    6363    public method scale {args}
    6464
    65     protected method Connect {}
    66     protected method CurrentDatasets {args}
    67     protected method Disconnect {}
    68     protected method DoResize {}
    69     protected method DoRotate {}
    70     protected method DoChangeContourLevels {}
    71     protected method AdjustSetting {what {value ""}}
    72     protected method InitSettings { args  }
    73     protected method Pan {option x y}
    74     protected method Pick {x y}
    75     protected method Rebuild {}
    76     protected method ReceiveDataset { args }
    77     protected method ReceiveImage { args }
    78     protected method ReceiveLegend { colormap title vmin vmax size }
    79     protected method Rotate {option x y}
    80     protected method Zoom {option}
    81 
    8265    # The following methods are only used by this class.
     66
     67    private method AdjustSetting {what {value ""}}
    8368    private method BuildAxisTab {}
    8469    private method BuildCameraTab {}
     
    8873    private method BuildIsosurfaceTab {}
    8974    private method Combo { option }
     75    private method Connect {}
     76    private method CurrentDatasets {args}
     77    private method Disconnect {}
     78    private method DoChangeContourLevels {}
     79    private method DoResize {}
     80    private method DoRotate {}
    9081    private method DrawLegend {}
    9182    private method EnterLegend { x y }
     83    private method EventuallyChangeContourLevels {}
     84    private method EventuallyRequestLegend {}
    9285    private method EventuallyResize { w h }
    93     private method EventuallyChangeContourLevels {}
    9486    private method EventuallyRotate { q }
    95     private method EventuallyRequestLegend {}
    9687    private method EventuallySetCutplane { axis args }
     88    private method GenerateContourList {}
    9789    private method GetImage { args }
    9890    private method GetVtkData { args }
     91    private method InitSettings { args  }
    9992    private method IsValidObject { dataobj }
    10093    private method LeaveLegend {}
    10194    private method MotionLegend { x y }
     95    private method Pan {option x y}
    10296    private method PanCamera {}
     97    private method Pick {x y}
     98    private method Rebuild {}
     99    private method ReceiveDataset { args }
     100    private method ReceiveImage { args }
     101    private method ReceiveLegend { colormap title vmin vmax size }
    103102    private method RequestLegend {}
     103    private method Rotate {option x y}
     104    private method SetCurrentColormap { color }
    104105    private method SetLegendTip { x y }
    105106    private method SetObjectStyle { dataobj comp }
     107    private method SetOrientation { side }
    106108    private method Slice {option args}
    107     private method SetCurrentColormap { color }
    108     private method SetOrientation { side }
    109     private method GenerateContourList {}
     109    private method Zoom {option}
     110    private method ViewToQuaternion {} {
     111        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
     112    }
    110113
    111114    private variable _arcball ""
     
    216219    # Initialize the view to some default parameters.
    217220    array set _view {
    218         qw              0.853553
    219         qx              -0.353553
    220         qy              0.353553
    221         qz              0.146447
    222         zoom            1.0
    223         xpan            0
    224         ypan            0
    225         ortho           0
     221        -ortho           0
     222        -qw              0.853553
     223        -qx              -0.353553
     224        -qy              0.353553
     225        -qz              0.146447
     226        -xpan            0
     227        -ypan            0
     228        -zoom            1.0
    226229    }
    227230    set _arcball [blt::arcball create 100 100]
    228     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    229     $_arcball quaternion $q
     231    $_arcball quaternion [ViewToQuaternion]
    230232
    231233    array set _contourList {
     
    275277    }
    276278    array set _widget {
    277         -isosurfaceopacity       0
    278         -cutplaneopacity         0
     279        -isosurfaceopacity       60
     280        -cutplaneopacity         100
    279281    }
    280282
     
    496498
    497499itcl::body Rappture::VtkIsosurfaceViewer::DoRotate {} {
    498     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    499     SendCmd "camera orient $q"
     500    SendCmd "camera orient [ViewToQuaternion]"
    500501    set _rotatePending 0
    501502}
     
    521522
    522523itcl::body Rappture::VtkIsosurfaceViewer::EventuallyRotate { q } {
    523     foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
     524    foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
    524525    if { !$_rotatePending } {
    525526        set _rotatePending 1
     
    982983        $_arcball resize $w $h
    983984        DoResize
    984         #
     985
    985986        # Reset the camera and other view parameters
    986         #
    987         set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    988         $_arcball quaternion $q
    989         if {$_view(ortho)} {
    990             SendCmd "camera mode ortho"
    991         } else {
    992             SendCmd "camera mode persp"
    993         }
     987        $_arcball quaternion [ViewToQuaternion]
    994988        DoRotate
    995989        PanCamera
    996990        set _first ""
    997991        InitSettings -xgrid -ygrid -zgrid -axismode \
    998             -axesvisible -axislabelsvisible
     992            -axesvisible -axislabelsvisible -ortho
    999993        SendCmd "axis lformat all %g"
    1000994        # Too many major ticks, so turn off minor ticks
     
    11811175    switch -- $option {
    11821176        "in" {
    1183             set _view(zoom) [expr {$_view(zoom)*1.25}]
    1184             SendCmd "camera zoom $_view(zoom)"
     1177            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
     1178            SendCmd "camera zoom $_view(-zoom)"
    11851179        }
    11861180        "out" {
    1187             set _view(zoom) [expr {$_view(zoom)*0.8}]
    1188             SendCmd "camera zoom $_view(zoom)"
     1181            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
     1182            SendCmd "camera zoom $_view(-zoom)"
    11891183        }
    11901184        "reset" {
    11911185            array set _view {
    1192                 qw     0.853553
    1193                 qx     -0.353553
    1194                 qy     0.353553
    1195                 qz     0.146447
    1196                 zoom   1.0
    1197                 xpan   0
    1198                 ypan   0
     1186                -qw     0.853553
     1187                -qx     -0.353553
     1188                -qy     0.353553
     1189                -qz     0.146447
     1190                -xpan   0
     1191                -ypan   0
     1192                -zoom   1.0
    11991193            }
    12001194            if { $_first != "" } {
     
    12041198                }
    12051199            }
    1206             set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    1207             $_arcball quaternion $q
     1200            $_arcball quaternion [ViewToQuaternion]
    12081201            DoRotate
    12091202            SendCmd "camera reset"
     
    12131206
    12141207itcl::body Rappture::VtkIsosurfaceViewer::PanCamera {} {
    1215     set x $_view(xpan)
    1216     set y $_view(ypan)
     1208    set x $_view(-xpan)
     1209    set y $_view(-ypan)
    12171210    SendCmd "camera pan $x $y"
    12181211}
     
    12921285            set x [expr $x / double($w)]
    12931286            set y [expr $y / double($h)]
    1294             set _view(xpan) [expr $_view(xpan) + $x]
    1295             set _view(ypan) [expr $_view(ypan) + $y]
     1287            set _view(-xpan) [expr $_view(-xpan) + $x]
     1288            set _view(-ypan) [expr $_view(-ypan) + $y]
    12961289            PanCamera
    12971290            return
     
    13151308            set _click(x) $x
    13161309            set _click(y) $y
    1317             set _view(xpan) [expr $_view(xpan) - $dx]
    1318             set _view(ypan) [expr $_view(ypan) - $dy]
     1310            set _view(-xpan) [expr $_view(-xpan) - $dx]
     1311            set _view(-ypan) [expr $_view(-ypan) - $dy]
    13191312            PanCamera
    13201313        }
     
    13581351    }
    13591352    switch -- $what {
     1353        "-axesvisible" {
     1354            set bool $_settings($what)
     1355            SendCmd "axis visible all $bool"
     1356        }
     1357        "-axislabelsvisible" {
     1358            set bool $_settings($what)
     1359            SendCmd "axis labels all $bool"
     1360        }
     1361        "-xgrid" - "-ygrid" - "-zgrid" {
     1362            set axis [string tolower [string range $what 1 1]]
     1363            set bool $_settings($what)
     1364            SendCmd "axis grid $axis $bool"
     1365        }
     1366        "-axismode" {
     1367            set mode [$itk_component(axisMode) value]
     1368            set mode [$itk_component(axisMode) translate $mode]
     1369            set _settings($what) $mode
     1370            SendCmd "axis flymode $mode"
     1371        }
    13601372        "-background" {
    13611373            set bgcolor [$itk_component(background) value]
     
    13701382            DrawLegend
    13711383        }
    1372         "-axesvisible" {
    1373             set bool $_settings(-axesvisible)
    1374             SendCmd "axis visible all $bool"
    1375         }
    1376         "-axislabelsvisible" {
    1377             set bool $_settings(-axislabelsvisible)
    1378             SendCmd "axis labels all $bool"
    1379         }
    1380         "-xgrid" - "-ygrid" - "-zgrid" {
    1381             set axis [string tolower [string range $what 1 1]]
    1382             set bool $_settings($what)
    1383             SendCmd "axis grid $axis $bool"
    1384         }
    1385         "-axismode" {
    1386             set mode [$itk_component(axisMode) value]
    1387             set mode [$itk_component(axisMode) translate $mode]
    1388             set _settings($what) $mode
    1389             SendCmd "axis flymode $mode"
    1390         }
    13911384        "-cutplaneedges" {
    13921385            set bool $_settings($what)
    13931386            SendCmd "cutplane edges $bool"
     1387        }
     1388        "-cutplanelighting" {
     1389            set bool $_settings($what)
     1390            SendCmd "cutplane lighting $bool"
     1391        }
     1392        "-cutplaneopacity" {
     1393            set _settings($what) [expr $_widget($what) * 0.01]
     1394            SendCmd "cutplane opacity $_settings($what)"
     1395        }
     1396        "-cutplanepreinterp" {
     1397            set bool $_settings($what)
     1398            SendCmd "cutplane preinterp $bool"
    13941399        }
    13951400        "-cutplanesvisible" {
     
    14131418            SendCmd "cutplane wireframe $bool"
    14141419        }
    1415         "-cutplanelighting" {
    1416             set bool $_settings($what)
    1417             SendCmd "cutplane lighting $bool"
    1418         }
    1419         "-cutplaneopacity" {
    1420             set _settings($what) [$_widget(-cutplaneopacity) * 0.01]
    1421             SendCmd "cutplane opacity $_settings($what)"
    1422         }
    1423         "-cutplanepreinterp" {
    1424             set bool $_settings($what)
    1425             SendCmd "cutplane preinterp $bool"
    1426         }
    1427         "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" {
    1428             set axis [string tolower [string range $what 1 1]]
    1429             set bool $_settings($what)
    1430             if { $bool } {
    1431                 $itk_component(${axis}position) configure -state normal \
    1432                     -troughcolor white
    1433             } else {
    1434                 $itk_component(${axis}position) configure -state disabled \
    1435                     -troughcolor grey82
    1436             }
    1437             SendCmd "cutplane axis $axis $bool"
    1438         }
    1439         "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" {
    1440             set axis [string tolower [string range $what 1 1]]
    1441             set pos [expr $_settings($what) * 0.01]
    1442             SendCmd "cutplane slice ${axis} ${pos}"
    1443             set _cutplanePending 0
    1444         }
    14451420        "-colormap" {
    14461421            set _changed($what) 1
    14471422            StartBufferingCommands
    14481423            set color [$itk_component(colormap) value]
    1449             set _settings(-colormap) $color
     1424            set _settings($what) $color
    14501425            if { $color == "none" } {
    14511426                if { $_settings(-colormapvisible) } {
     
    14631438            EventuallyRequestLegend
    14641439        }
    1465         "-numcontours" {
    1466             set _settings($what) [$itk_component(numcontours) value]
    1467             if { $_contourList(numLevels) != $_settings($what) } {
    1468                 set _contourList(numLevels) $_settings($what)
    1469                 EventuallyChangeContourLevels
    1470             }
    1471         }
    1472         "-isosurfacewireframe" {
    1473             set bool $_settings($what)
    1474             SendCmd "contour3d wireframe $bool"
    1475         }
    1476         "-isosurfacevisible" {
    1477             set bool $_settings($what)
    1478             SendCmd "contour3d visible 0"
    1479             if { $bool } {
    1480                 foreach tag [CurrentDatasets -visible] {
    1481                     SendCmd "contour3d visible $bool $tag"
    1482                 }
    1483             }
    1484             if { $bool } {
    1485                 Rappture::Tooltip::for $itk_component(contour) \
    1486                     "Hide the isosurface"
    1487             } else {
    1488                 Rappture::Tooltip::for $itk_component(contour) \
    1489                     "Show the isosurface"
    1490             }
    1491         }
    1492         "-isosurfacelighting" {
    1493             set bool $_settings($what)
    1494             SendCmd "contour3d lighting $bool"
    1495         }
    1496         "-isosurfaceedges" {
    1497             set bool $_settings($what)
    1498             SendCmd "contour3d edges $bool"
    1499         }
    1500         "-outline" {
    1501             set bool $_settings($what)
    1502             SendCmd "outline visible 0"
    1503             if { $bool } {
    1504                 foreach tag [CurrentDatasets -visible] {
    1505                     SendCmd "outline visible $bool $tag"
    1506                 }
    1507             }
    1508         }
    1509         "-isolinecolor" {
    1510             set color [$itk_component(isolineColor) value]
    1511             set _settings($what) $color
    1512             DrawLegend
    1513         }
    1514         "-isosurfaceopacity" {
    1515             set _settings($what) [$_widget(-isosurfaceopacity) * 0.01]
    1516             SendCmd "contour3d opacity $_settings($what)"
    1517         }
    15181440        "-field" {
    15191441            set label [$itk_component(field) value]
     
    15421464            SendCmd "contour3d colormode $_colorMode $_curFldName"
    15431465            SendCmd "camera reset"
    1544             UpdateContourList
     1466            GenerateContourList
    15451467            DrawLegend
     1468        }
     1469        "-isolinecolor" {
     1470            set color [$itk_component(isolineColor) value]
     1471            set _settings(-isolinecolor) $color
     1472            set _settings($what) $color
     1473            DrawLegend
     1474        }
     1475        "-isosurfaceedges" {
     1476            set bool $_settings($what)
     1477            SendCmd "contour3d edges $bool"
     1478        }
     1479        "-isosurfacelighting" {
     1480            set bool $_settings($what)
     1481            SendCmd "contour3d lighting $bool"
     1482        }
     1483        "-isosurfaceopacity" {
     1484            set _settings($what) [expr $_widget($what) * 0.01]
     1485            SendCmd "contour3d opacity $_settings($what)"
     1486        }
     1487        "-isosurfacevisible" {
     1488            set bool $_settings($what)
     1489            SendCmd "contour3d visible 0"
     1490            if { $bool } {
     1491                foreach tag [CurrentDatasets -visible] {
     1492                    SendCmd "contour3d visible $bool $tag"
     1493                }
     1494            }
     1495            if { $bool } {
     1496                Rappture::Tooltip::for $itk_component(contour) \
     1497                    "Hide the isosurface"
     1498            } else {
     1499                Rappture::Tooltip::for $itk_component(contour) \
     1500                    "Show the isosurface"
     1501            }
     1502        }
     1503        "-isosurfacewireframe" {
     1504            set bool $_settings($what)
     1505            SendCmd "contour3d wireframe $bool"
    15461506        }
    15471507        "-legendvisible" {
     
    15501510            }
    15511511            DrawLegend
     1512        }
     1513        "-numcontours" {
     1514            set _settings($what) [$itk_component(numcontours) value]
     1515            if { $_contourList(numLevels) != $_settings($what) } {
     1516                set _contourList(numLevels) $_settings($what)
     1517                EventuallyChangeContourLevels
     1518            }
     1519        }
     1520        "-ortho" {
     1521            set bool $_view($what)
     1522            if { $bool } {
     1523                SendCmd "camera mode ortho"
     1524            } else {
     1525                SendCmd "camera mode persp"
     1526            }
     1527        }
     1528        "-outline" {
     1529            set bool $_settings($what)
     1530            SendCmd "outline visible 0"
     1531            if { $bool } {
     1532                foreach tag [CurrentDatasets -visible] {
     1533                    SendCmd "outline visible $bool $tag"
     1534                }
     1535            }
     1536        }
     1537        "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" {
     1538            set axis [string tolower [string range $what 1 1]]
     1539            set bool $_settings($what)
     1540            if { $bool } {
     1541                $itk_component(${axis}position) configure -state normal \
     1542                    -troughcolor white
     1543            } else {
     1544                $itk_component(${axis}position) configure -state disabled \
     1545                    -troughcolor grey82
     1546            }
     1547            SendCmd "cutplane axis $axis $bool"
     1548        }
     1549        "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" {
     1550            set axis [string tolower [string range $what 1 1]]
     1551            set pos [expr $_settings($what) * 0.01]
     1552            SendCmd "cutplane slice ${axis} ${pos}"
     1553            set _cutplanePending 0
    15521554        }
    15531555        default {
     
    17221724        -showvalue off \
    17231725        -command [itcl::code $this AdjustSetting -isosurfaceopacity]
    1724     $inner.opacity set [expr $_settings(-isosurfaceeopacity) * 100.0]
     1726    set _widget(-isosurfaceopacity) \
     1727        [expr $_settings(-isosurfaceopacity) * 100.0]
    17251728
    17261729    itk_component add field_l {
     
    18661869        label $inner.${tag}label -text $tag -font "Arial 9"
    18671870        entry $inner.${tag} -font "Arial 9"  -bg white \
    1868             -textvariable [itcl::scope _view($tag)]
     1871            -textvariable [itcl::scope _view(-$tag)]
    18691872        bind $inner.${tag} <KeyPress-Return> \
    18701873            [itcl::code $this camera set ${tag}]
     
    18771880    checkbutton $inner.ortho \
    18781881        -text "Orthographic Projection" \
    1879         -variable [itcl::scope _view(ortho)] \
    1880         -command [itcl::code $this camera set ortho] \
     1882        -variable [itcl::scope _view(-ortho)] \
     1883        -command [itcl::code $this AdjustSetting -ortho] \
    18811884        -font "Arial 9"
    18821885    blt::table $inner \
     
    19361939        -showvalue off \
    19371940        -command [itcl::code $this AdjustSetting -cutplaneopacity]
    1938     $inner.opacity set [expr $_settings(-cutplaneopacity) * 100.0]
     1941    set _widget(-cutplaneopacity) [expr $_settings(-cutplaneopacity) * 100.0]
    19391942
    19401943    # X-value slicer...
     
    20572060        }
    20582061        "set" {
    2059             set who [lindex $args 0]
    2060             set x $_view($who)
     2062            set what [lindex $args 0]
     2063            set x $_view($what)
    20612064            set code [catch { string is double $x } result]
    20622065            if { $code != 0 || !$result } {
    20632066                return
    20642067            }
    2065             switch -- $who {
    2066                 "ortho" {
    2067                     if {$_view(ortho)} {
     2068            switch -- $what {
     2069                "-ortho" {
     2070                    if {$_view($what)} {
    20682071                        SendCmd "camera mode ortho"
    20692072                    } else {
     
    20712074                    }
    20722075                }
    2073                 "xpan" - "ypan" {
     2076                "-xpan" - "-ypan" {
    20742077                    PanCamera
    20752078                }
    2076                 "qx" - "qy" - "qz" - "qw" {
    2077                     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2079                "-qx" - "-qy" - "-qz" - "-qw" {
     2080                    set q [ViewToQuaternion]
    20782081                    $_arcball quaternion $q
    20792082                    EventuallyRotate $q
    20802083                }
    2081                 "zoom" {
    2082                     SendCmd "camera zoom $_view(zoom)"
     2084                "-zoom" {
     2085                    SendCmd "camera zoom $_view(-zoom)"
    20832086                }
    20842087             }
     
    25882591        bottom "0.707107 0.707107 0 0"
    25892592    }
    2590     foreach name { qw qx qy qz } value $positions($side) {
     2593    foreach name { -qw -qx -qy -qz } value $positions($side) {
    25912594        set _view($name) $value
    25922595    }
    2593     set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2596    set q [ViewToQuaternion]
    25942597    $_arcball quaternion $q
    25952598    SendCmd "camera orient $q"
    25962599    SendCmd "camera reset"
    2597     set _view(xpan) 0
    2598     set _view(ypan) 0
    2599     set _view(zoom) 1.0
     2600    set _view(-xpan) 0
     2601    set _view(-ypan) 0
     2602    set _view(-zoom) 1.0
    26002603}
    26012604
Note: See TracChangeset for help on using the changeset viewer.