Ignore:
Timestamp:
Jun 2, 2016, 8:19:06 AM (8 years ago)
Author:
dkearney
Message:

merging changes from trunk into multichoice branch

Location:
branches/multichoice
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/multichoice

  • branches/multichoice/gui/scripts/vtkvolumeviewer.tcl

    r6235 r6371  
    7474    private method BuildVolumeComponents {}
    7575    private method BuildVolumeTab {}
    76     private method Combo { option }
    7776    private method ComputeAlphamap { cname }
    7877    private method ComputeTransferFunction { cname }
     
    9796    private method IsValidObject { dataobj }
    9897    private method LeaveLegend {}
     98    private method LegendTitleAction { option }
    9999    private method MotionLegend { x y }
    100100    private method Pan {option x y}
     
    109109    private method ReceiveDataset { args }
    110110    private method ReceiveImage { args }
    111     private method ReceiveLegend { colormap title vmin vmax size }
     111    private method ReceiveLegend { colormap title min max size }
    112112    private method RemoveMarker { x y }
    113113    private method RequestLegend {}
     
    115115    private method Rotate {option x y}
    116116    private method SendTransferFunctions {}
     117    private method SetCurrentFieldName { dataobj }
    117118    private method SetInitialTransferFunction { dataobj cname }
    118119    private method SetLegendTip { x y }
     
    240241    array set _settings {
    241242        -axesvisible            1
    242         -axisflymode            static
    243243        -axislabels             1
    244244        -axisminorticks         1
     245        -axismode               "static"
    245246        -background             black
    246247        -color                  "default"
     
    536537    }
    537538    array set params $settings
    538     set params(-description) ""
    539     set params(-param) ""
    540     array set params $settings
    541539
    542540    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
     
    577575        set _dlist [lreplace $_dlist $pos $pos]
    578576        array unset _obj2ovride $dataobj-*
    579         array unset _settings $dataobj-*
    580577        set changed 1
    581578    }
     
    638635            return $dlist
    639636        }
    640         -image {
     637        "-image" {
    641638            if {[llength $args] != 2} {
    642639                error "wrong # args: should be \"get -image view\""
     
    652649        }
    653650        default {
    654             error "bad option \"$op\": should be -objects or -image"
     651            error "bad option \"$op\": should be -objects, -visible or -image"
    655652        }
    656653    }
     
    10041001        set _first ""
    10051002        InitSettings -background \
    1006             -xgrid -ygrid -zgrid -axisflymode \
     1003            -xgrid -ygrid -zgrid -axismode \
    10071004            -axesvisible -axislabels -axisminorticks
    10081005        StopBufferingCommands
     
    10201017        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
    10211018            set _first $dataobj
     1019            SetCurrentFieldName $dataobj
    10221020        }
    10231021        foreach cname [$dataobj components] {
     
    10661064            }
    10671065        }
    1068         $itk_component(field) choices delete 0 end
    1069         $itk_component(fieldmenu) delete 0 end
    1070         array unset _fields
    1071         set _curFldName ""
    1072         foreach cname [$_first components] {
    1073             foreach fname [$_first fieldnames $cname] {
    1074                 if { [info exists _fields($fname)] } {
    1075                     continue
    1076                 }
    1077                 foreach { label units components } \
    1078                     [$_first fieldinfo $fname] break
    1079                 # Only scalar fields are valid
    1080                 if {$_allowMultiComponent || $components == 1} {
    1081                     $itk_component(field) choices insert end "$fname" "$label"
    1082                     $itk_component(fieldmenu) add radiobutton -label "$label" \
    1083                         -value $label -variable [itcl::scope _curFldLabel] \
    1084                         -selectcolor red \
    1085                         -activebackground $itk_option(-plotbackground) \
    1086                         -activeforeground $itk_option(-plotforeground) \
    1087                         -font "Arial 8" \
    1088                         -command [itcl::code $this Combo invoke]
    1089                     set _fields($fname) [list $label $units $components]
    1090                     if { $_curFldName == "" } {
    1091                         set _curFldName $fname
    1092                         set _curFldLabel $label
    1093                     }
    1094                 }
    1095             }
    1096         }
    1097         $itk_component(field) value $_curFldLabel
    10981066    }
    10991067
     
    13311299itcl::body Rappture::VtkVolumeViewer::InitSettings { args } {
    13321300    foreach spec $args {
    1333         if { [info exists _settings($_first${spec})] } {
    1334             # Reset global setting with dataobj specific setting
    1335             set _settings($spec) $_settings($_first${spec})
    1336         }
    13371301        AdjustSetting $spec
    13381302    }
     
    13511315    }
    13521316    switch -- $what {
    1353         "-current" {
    1354             set cname [$itk_component(volcomponents) value]
    1355             SwitchComponent $cname
     1317        "-axesvisible" {
     1318            set bool $_settings($what)
     1319            SendCmd "axis visible all $bool"
     1320        }
     1321        "-axislabels" {
     1322            set bool $_settings($what)
     1323            SendCmd "axis labels all $bool"
     1324        }
     1325        "-axisminorticks" {
     1326            set bool $_settings($what)
     1327            SendCmd "axis minticks all $bool"
     1328        }
     1329        "-axismode" {
     1330            set mode [$itk_component(axismode) value]
     1331            set mode [$itk_component(axismode) translate $mode]
     1332            set _settings($what) $mode
     1333            SendCmd "axis flymode $mode"
    13561334        }
    13571335        "-background" {
     
    13681346            DrawLegend
    13691347        }
    1370         "-volumeoutline" {
    1371             set bool $_settings($what)
    1372             SendCmd "outline visible 0"
    1373             foreach tag [GetDatasetsWithComponent $_current] {
    1374                 SendCmd "outline visible $bool $tag"
    1375             }
    1376         }
    1377         "-legendvisible" {
    1378             set bool $_settings($what)
    1379             if { $bool } {
    1380                 blt::table $itk_component(plotarea) \
    1381                     1,0 $itk_component(legend) -fill x
    1382             } else {
    1383                 blt::table forget $itk_component(legend)
    1384             }
    1385         }
    1386         "-volumevisible" {
    1387             set bool $_settings($what)
    1388             set _settings($_current${what}) $bool
    1389             # Only the data objects in the array _obj2ovride(*-raise) are
    1390             # in the working set and can be displayed on screen. The global
    1391             # volume control determines whether they are visible.
    1392             #
    1393             # Note: The use of the current component is a hold over from
    1394             #       nanovis.  If we can't display more than one volume,
    1395             #       we don't have to limit the effects to a specific
    1396             #       component.
    1397             foreach tag [GetDatasetsWithComponent $_current] {
    1398                 foreach {dataobj cname} [split $tag -] break
    1399                 if { [info exists _obj2ovride($dataobj-raise)] } {
    1400                     SendCmd "volume visible $bool $tag"
    1401                 }
    1402             }
    1403             if { $bool } {
    1404                 Rappture::Tooltip::for $itk_component(volume) \
    1405                     "Hide the volume"
    1406             } else {
    1407                 Rappture::Tooltip::for $itk_component(volume) \
    1408                     "Show the volume"
    1409             }
    1410         }
    1411         "-volumeblendmode" {
    1412             set val [$itk_component(blendmode) value]
    1413             set mode [$itk_component(blendmode) translate $val]
    1414             set _settings($what) $mode
    1415             set _settings($_current${what}) $mode
    1416             foreach tag [GetDatasetsWithComponent $_current] {
    1417                 SendCmd "volume blendmode $mode $tag"
    1418             }
    1419         }
    1420         "-volumeambient" {
    1421             # Other parts of the code use the -volumeambient setting to
    1422             # tell if the component settings have been initialized
    1423             if { ![info exists _settings($_current${what})] } {
    1424                 InitComponentSettings $_current
    1425             }
    1426             set val $_settings($what)
    1427             set _settings($_current${what}) $val
    1428             set ambient [expr {0.01*$val}]
    1429             foreach tag [GetDatasetsWithComponent $_current] {
    1430                 SendCmd "volume shading ambient $ambient $tag"
    1431             }
    1432         }
    1433         "-volumediffuse" {
    1434             set val $_settings($what)
    1435             set _settings($_current${what}) $val
    1436             set diffuse [expr {0.01*$val}]
    1437             foreach tag [GetDatasetsWithComponent $_current] {
    1438                 SendCmd "volume shading diffuse $diffuse $tag"
    1439             }
    1440         }
    1441         "-volumespecularlevel" - "-volumespecularexponent" {
    1442             set val $_settings($what)
    1443             set _settings($_current${what}) $val
    1444             set level [expr {0.01*$val}]
    1445             set exp $_settings($what)
    1446             foreach tag [GetDatasetsWithComponent $_current] {
    1447                 SendCmd "volume shading specular $level $exp $tag"
    1448             }
    1449         }
    1450         "-volumelighting" {
    1451             set bool $_settings($what)
    1452             set _settings($_current${what}) $bool
    1453             foreach tag [GetDatasetsWithComponent $_current] {
    1454                 SendCmd "volume lighting $bool $tag"
    1455             }
    1456         }
    1457         "-volumeopacity" {
    1458             set val $_settings($what)
    1459             set _settings($_current${what}) $val
    1460             set val [expr {0.01*$val}]
    1461             foreach tag [GetDatasetsWithComponent $_current] {
    1462                 SendCmd "volume opacity $val $tag"
    1463             }
    1464         }
    1465         "-volumequality" {
    1466             set val $_settings($what)
    1467             set _settings($_current${what}) $val
    1468             set val [expr {0.01*$val}]
    1469             foreach tag [GetDatasetsWithComponent $_current] {
    1470                 SendCmd "volume quality $val $tag"
    1471             }
    1472         }
    1473         "-axesvisible" {
    1474             set bool $_settings($what)
    1475             SendCmd "axis visible all $bool"
    1476         }
    1477         "-axislabels" {
    1478             set bool $_settings($what)
    1479             SendCmd "axis labels all $bool"
    1480         }
    1481         "-axisminorticks" {
    1482             set bool $_settings($what)
    1483             SendCmd "axis minticks all $bool"
    1484         }
    1485         "-xgrid" - "-ygrid" - "-zgrid" {
    1486             set axis [string range $what 1 1]
    1487             set bool $_settings($what)
    1488             SendCmd "axis grid $axis $bool"
    1489         }
    1490         "-axisflymode" {
    1491             set mode [$itk_component(axismode) value]
    1492             set mode [$itk_component(axismode) translate $mode]
    1493             set _settings($what) $mode
    1494             SendCmd "axis flymode $mode"
    1495         }
    1496         "-cutplanesvisible" {
    1497             set bool $_settings($what)
    1498             foreach dataset [CurrentDatasets -visible] {
    1499                 SendCmd "$_cutplaneCmd visible $bool $dataset"
    1500             }
     1348        "-color" {
     1349            set color [$itk_component(colormap) value]
     1350            set _settings($what) $color
     1351            set _settings($_current${what}) $color
     1352            ResetColormap $_current $color
     1353        }
     1354        "-current" {
     1355            set cname [$itk_component(volcomponents) value]
     1356            SwitchComponent $cname
    15011357        }
    15021358        "-cutplanelighting" {
     
    15241380            }
    15251381        }
    1526         "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" {
    1527             set axis [string range $what 1 1]
     1382        "-cutplanesvisible" {
    15281383            set bool $_settings($what)
    1529             if { $bool } {
    1530                 $itk_component(${axis}CutScale) configure -state normal \
    1531                     -troughcolor white
    1532             } else {
    1533                 $itk_component(${axis}CutScale) configure -state disabled \
    1534                     -troughcolor grey82
    1535             }
    15361384            foreach dataset [CurrentDatasets -visible] {
    1537                 SendCmd "$_cutplaneCmd axis $axis $bool $dataset"
    1538             }
    1539         }
    1540         "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" {
    1541             set axis [string range $what 1 1]
    1542             set pos [expr $_settings($what) * 0.01]
    1543             foreach dataset [CurrentDatasets -visible] {
    1544                 SendCmd "$_cutplaneCmd slice ${axis} ${pos} $dataset"
    1545             }
    1546             set _cutplanePending 0
    1547         }
    1548         "-volumethickness" {
    1549             set _settings($_current${what}) $_settings($what)
    1550             updateTransferFunctions
    1551         }
    1552         "-color" {
    1553             set color [$itk_component(colormap) value]
    1554             set _settings($what) $color
    1555             set _settings($_current${what}) $color
    1556             ResetColormap $_current $color
     1385                SendCmd "$_cutplaneCmd visible $bool $dataset"
     1386            }
    15571387        }
    15581388        "-field" {
     
    15841414            SendCmd "camera reset"
    15851415            DrawLegend
     1416        }
     1417        "-legendvisible" {
     1418            set bool $_settings($what)
     1419            if { $bool } {
     1420                blt::table $itk_component(plotarea) \
     1421                    1,0 $itk_component(legend) -fill x
     1422            } else {
     1423                blt::table forget $itk_component(legend)
     1424            }
     1425        }
     1426        "-volumeambient" {
     1427            # Other parts of the code use the -volumeambient setting to
     1428            # tell if the component settings have been initialized
     1429            if { ![info exists _settings($_current${what})] } {
     1430                InitComponentSettings $_current
     1431            }
     1432            set val $_settings($what)
     1433            set _settings($_current${what}) $val
     1434            set ambient [expr {0.01*$val}]
     1435            foreach tag [GetDatasetsWithComponent $_current] {
     1436                SendCmd "volume shading ambient $ambient $tag"
     1437            }
     1438        }
     1439        "-volumeblendmode" {
     1440            set val [$itk_component(blendmode) value]
     1441            set mode [$itk_component(blendmode) translate $val]
     1442            set _settings($what) $mode
     1443            set _settings($_current${what}) $mode
     1444            foreach tag [GetDatasetsWithComponent $_current] {
     1445                SendCmd "volume blendmode $mode $tag"
     1446            }
     1447        }
     1448        "-volumediffuse" {
     1449            set val $_settings($what)
     1450            set _settings($_current${what}) $val
     1451            set diffuse [expr {0.01*$val}]
     1452            foreach tag [GetDatasetsWithComponent $_current] {
     1453                SendCmd "volume shading diffuse $diffuse $tag"
     1454            }
     1455        }
     1456        "-volumelighting" {
     1457            set bool $_settings($what)
     1458            set _settings($_current${what}) $bool
     1459            foreach tag [GetDatasetsWithComponent $_current] {
     1460                SendCmd "volume lighting $bool $tag"
     1461            }
     1462        }
     1463        "-volumeopacity" {
     1464            set val $_settings($what)
     1465            set _settings($_current${what}) $val
     1466            set val [expr {0.01*$val}]
     1467            foreach tag [GetDatasetsWithComponent $_current] {
     1468                SendCmd "volume opacity $val $tag"
     1469            }
     1470        }
     1471        "-volumeoutline" {
     1472            set bool $_settings($what)
     1473            SendCmd "outline visible 0"
     1474            foreach tag [GetDatasetsWithComponent $_current] {
     1475                SendCmd "outline visible $bool $tag"
     1476            }
     1477        }
     1478        "-volumequality" {
     1479            set val $_settings($what)
     1480            set _settings($_current${what}) $val
     1481            set val [expr {0.01*$val}]
     1482            foreach tag [GetDatasetsWithComponent $_current] {
     1483                SendCmd "volume quality $val $tag"
     1484            }
     1485        }
     1486        "-volumespecularlevel" - "-volumespecularexponent" {
     1487            set val $_settings($what)
     1488            set _settings($_current${what}) $val
     1489            set level [expr {0.01*$val}]
     1490            set exp $_settings($what)
     1491            foreach tag [GetDatasetsWithComponent $_current] {
     1492                SendCmd "volume shading specular $level $exp $tag"
     1493            }
     1494        }
     1495        "-volumethickness" {
     1496            set _settings($_current${what}) $_settings($what)
     1497            updateTransferFunctions
     1498        }
     1499        "-volumevisible" {
     1500            set bool $_settings($what)
     1501            set _settings($_current${what}) $bool
     1502            # Only the data objects in the array _obj2ovride(*-raise) are
     1503            # in the working set and can be displayed on screen. The global
     1504            # volume control determines whether they are visible.
     1505            #
     1506            # Note: The use of the current component is a hold over from
     1507            #       nanovis.  If we can't display more than one volume,
     1508            #       we don't have to limit the effects to a specific
     1509            #       component.
     1510            foreach tag [GetDatasetsWithComponent $_current] {
     1511                foreach {dataobj cname} [split $tag -] break
     1512                if { [info exists _obj2ovride($dataobj-raise)] } {
     1513                    SendCmd "volume visible $bool $tag"
     1514                }
     1515            }
     1516            if { $bool } {
     1517                Rappture::Tooltip::for $itk_component(volume) \
     1518                    "Hide the volume"
     1519            } else {
     1520                Rappture::Tooltip::for $itk_component(volume) \
     1521                    "Show the volume"
     1522            }
     1523        }
     1524        "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" {
     1525            set axis [string range $what 1 1]
     1526            set bool $_settings($what)
     1527            if { $bool } {
     1528                $itk_component(${axis}CutScale) configure -state normal \
     1529                    -troughcolor white
     1530            } else {
     1531                $itk_component(${axis}CutScale) configure -state disabled \
     1532                    -troughcolor grey82
     1533            }
     1534            foreach dataset [CurrentDatasets -visible] {
     1535                SendCmd "$_cutplaneCmd axis $axis $bool $dataset"
     1536            }
     1537        }
     1538        "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" {
     1539            set axis [string range $what 1 1]
     1540            set pos [expr $_settings($what) * 0.01]
     1541            foreach dataset [CurrentDatasets -visible] {
     1542                SendCmd "$_cutplaneCmd slice ${axis} ${pos} $dataset"
     1543            }
     1544            set _cutplanePending 0
     1545        }
     1546        "-xgrid" - "-ygrid" - "-zgrid" {
     1547            set axis [string range $what 1 1]
     1548            set bool $_settings($what)
     1549            SendCmd "axis grid $axis $bool"
    15861550        }
    15871551        default {
     
    19081872        "furthest_triad"  "farthest" \
    19091873        "outer_edges"     "outer"
    1910     $itk_component(axismode) value $_settings(-axisflymode)
    1911     bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode]
     1874    $itk_component(axismode) value $_settings(-axismode)
     1875    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
    19121876
    19131877    blt::table $inner \
     
    21742138    radiobutton $inner.vtk_button -text "VTK data file" \
    21752139        -variable [itcl::scope _downloadPopup(format)] \
    2176         -font "Helvetica 9 " \
     2140        -font "Arial 9" \
    21772141        -value vtk
    21782142    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
     
    22522216
    22532217# ----------------------------------------------------------------------
    2254 # USAGE: ReceiveLegend <colormap> <title> <vmin> <vmax> <size>
     2218# USAGE: ReceiveLegend <colormap> <title> <min> <max> <size>
    22552219#
    22562220# Invoked automatically whenever the "legend" command comes in from
     
    22582222# specified <size> will follow.
    22592223# ----------------------------------------------------------------------
    2260 itcl::body Rappture::VtkVolumeViewer::ReceiveLegend { colormap title vmin vmax size } {
     2224itcl::body Rappture::VtkVolumeViewer::ReceiveLegend { colormap title min max size } {
    22612225    if { [isconnected] } {
    22622226        set bytes [ReceiveBytes $size]
     
    24282392
    24292393# ----------------------------------------------------------------------
    2430 # USAGE: _dropdown post
    2431 # USAGE: _dropdown unpost
    2432 # USAGE: _dropdown select
    2433 #
    2434 # Used internally to handle the dropdown list for this combobox.  The
    2435 # post/unpost options are invoked when the list is posted or unposted
    2436 # to manage the relief of the controlling button.  The select option
    2437 # is invoked whenever there is a selection from the list, to assign
    2438 # the value back to the gauge.
    2439 # ----------------------------------------------------------------------
    2440 itcl::body Rappture::VtkVolumeViewer::Combo {option} {
     2394# USAGE: LegendTitleAction post
     2395# USAGE: LegendTitleAction enter
     2396# USAGE: LegendTitleAction leave
     2397# USAGE: LegendTitleAction save
     2398#
     2399# Used internally to handle the dropdown list for the fields menu combobox.
     2400# The post option is invoked when the field title is pressed to launch the
     2401# dropdown.  The enter option is invoked when the user mouses over the field
     2402# title. The leave option is invoked when the user moves the mouse away
     2403# from the field title.  The save option is invoked whenever there is a
     2404# selection from the list, to alert the visualization server.
     2405# ----------------------------------------------------------------------
     2406itcl::body Rappture::VtkVolumeViewer::LegendTitleAction {option} {
    24412407    set c $itk_component(view)
    24422408    switch -- $option {
     
    24482414            tk_popup $itk_component(fieldmenu) $x $y
    24492415        }
    2450         activate {
     2416        enter {
    24512417            $c itemconfigure title -fill red
    24522418        }
    2453         deactivate {
     2419        leave {
    24542420            $c itemconfigure title -fill $itk_option(-plotforeground)
    24552421        }
    2456         invoke {
     2422        save {
    24572423            $itk_component(field) value $_curFldLabel
    24582424            AdjustSetting -field
    24592425        }
    24602426        default {
    2461             error "bad option \"$option\": should be post, unpost, select"
     2427            error "bad option \"$option\": should be post, enter, leave or save"
    24622428        }
    24632429    }
     
    25102476        } else {
    25112477            # $n : absolute value, compute relative
    2512             lappend list  [expr {(double($value)-$min)/($max-$min)]}
     2478            lappend list [expr {(double($value)-$min)/($max-$min)}]
    25132479        }
    25142480    }
     
    28652831    return [ColorsToColormap $color]
    28662832}
     2833
     2834itcl::body Rappture::VtkVolumeViewer::SetCurrentFieldName { dataobj } {
     2835    set _first $dataobj
     2836    $itk_component(field) choices delete 0 end
     2837    $itk_component(fieldmenu) delete 0 end
     2838    array unset _fields
     2839    set _curFldName ""
     2840    foreach cname [$_first components] {
     2841        foreach fname [$_first fieldnames $cname] {
     2842            if { [info exists _fields($fname)] } {
     2843                continue
     2844            }
     2845            foreach { label units components } \
     2846                [$_first fieldinfo $fname] break
     2847            # Only scalar fields are valid
     2848            if {$_allowMultiComponent || $components == 1} {
     2849                $itk_component(field) choices insert end "$fname" "$label"
     2850                $itk_component(fieldmenu) add radiobutton -label "$label" \
     2851                    -value $label -variable [itcl::scope _curFldLabel] \
     2852                    -selectcolor red \
     2853                    -activebackground $itk_option(-plotbackground) \
     2854                    -activeforeground $itk_option(-plotforeground) \
     2855                    -font "Arial 8" \
     2856                    -command [itcl::code $this LegendTitleAction save]
     2857                set _fields($fname) [list $label $units $components]
     2858                if { $_curFldName == "" } {
     2859                    set _curFldName $fname
     2860                    set _curFldLabel $label
     2861                }
     2862            }
     2863        }
     2864    }
     2865    $itk_component(field) value $_curFldLabel
     2866}
Note: See TracChangeset for help on using the changeset viewer.