Changeset 3362 for trunk/gui/scripts


Ignore:
Timestamp:
Feb 26, 2013, 1:34:35 PM (12 years ago)
Author:
ldelgass
Message:

Merge nanovis2 branch to trunk

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/gui/scripts/flowvisviewer.tcl

    r3330 r3362  
    125125    private method arrows { tag name }
    126126
     127    private variable _arcball ""
     128    private variable _useArcball 1
    127129    private variable _outbuf       ;# buffer for outgoing commands
    128130
     
    220222    $_parser alias legend [itcl::code $this ReceiveLegend]
    221223    $_parser alias data [itcl::code $this ReceiveData]
     224    $_parser alias viserror [itcl::code $this ReceiveError]
    222225
    223226    # Initialize the view to some default parameters.
    224227    array set _view {
     228        qw      0.853553
     229        qx      -0.353553
     230        qy      0.353553
     231        qz      0.146447
    225232        theta   45
    226233        phi     45
     
    230237        pan-y   0
    231238    }
     239    set _arcball [blt::arcball create 100 100]
     240    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     241    $_arcball quaternion $q
     242
    232243    set _limits(vmin) 0.0
    233244    set _limits(vmax) 1.0
    234245
    235246    array set _settings [subst {
     247        $this-qw                $_view(qw)
     248        $this-qx                $_view(qx)
     249        $this-qy                $_view(qy)
     250        $this-qz                $_view(qz)
     251        $this-theta             $_view(theta)
     252        $this-phi               $_view(phi)
     253        $this-psi               $_view(psi)
     254        $this-zoom              $_view(zoom)   
     255        $this-pan-x             $_view(pan-x)
     256        $this-pan-y             $_view(pan-y)
    236257        $this-arrows            0
    237258        $this-currenttime       0
    238259        $this-duration          1:00
    239260        $this-loop              0
    240         $this-pan-x             $_view(pan-x)
    241         $this-pan-y             $_view(pan-y)
    242         $this-phi               $_view(phi)
    243261        $this-play              0
    244         $this-psi               $_view(psi)
    245262        $this-speed             500
    246263        $this-step              0
    247264        $this-streams           0
    248         $this-theta             $_view(theta)
    249265        $this-volume            1
    250266        $this-xcutplane         0
     
    254270        $this-zcutplane         0
    255271        $this-zcutposition      0
    256         $this-zoom              $_view(zoom)
    257272    }]
    258273
     
    554569    image delete $_image(legend)
    555570    image delete $_image(download)
     571    catch { blt::arcball destroy $_arcball }
    556572    array unset _settings $this-*
    557573}
     
    10071023    }
    10081024
    1009     # Insure that the global opacity and thickness settings (in the slider
     1025    # Ensure that the global opacity and thickness settings (in the slider
    10101026    # settings widgets) are used for the active transfer-function.  Update the
    10111027    # values in the _settings varible.
     
    11811197    set w [winfo width $itk_component(3dview)]
    11821198    set h [winfo height $itk_component(3dview)]
     1199    $_arcball resize $w $h
    11831200    EventuallyResize $w $h
    11841201
     
    12291246            array set _view $location
    12301247        }
    1231     }
     1248
     1249        if 1 {
     1250            # Tell the server the name of the tool, the version, and
     1251            # dataset that we are rendering.  Have to do it here because
     1252            # we don't know what data objects are using the renderer until
     1253            # be get here.
     1254            global env
     1255
     1256            lappend out "hub" [exec hostname]
     1257            lappend out "viewer" "flowvisviewer"
     1258            if { [info exists env(USER)] } {
     1259                lappend out "user" $env(USER)
     1260            }
     1261            if { [info exists env(SESSION)] } {
     1262                lappend out "session" $env(SESSION)
     1263            }
     1264            lappend out "tool_id"      [$_first hints toolId]
     1265            lappend out "tool_name"    [$_first hints toolName]
     1266            lappend out "tool_version" [$_first hints toolRevision]
     1267            lappend out "tool_title"   [$_first hints toolTitle]
     1268            lappend out "tool_dataset" [$_first hints label]
     1269            SendCmd "clientinfo [list $out]"
     1270        }
     1271    }
     1272    set _settings($this-qw)    $_view(qw)
     1273    set _settings($this-qx)    $_view(qx)
     1274    set _settings($this-qy)    $_view(qy)
     1275    set _settings($this-qz)    $_view(qz)
    12321276    set _settings($this-theta) $_view(theta)
    12331277    set _settings($this-phi)   $_view(phi)
     
    12371281    set _settings($this-zoom)  $_view(zoom)
    12381282
    1239     set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
    1240     SendCmd "camera angle $xyz"
     1283    if {$_useArcball} {
     1284        set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1285        $_arcball quaternion $q
     1286        SendCmd "camera orient $q"
     1287    } else {
     1288        set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
     1289        SendCmd "camera angle $xyz"
     1290    }
    12411291    PanCamera
    12421292    SendCmd "camera zoom $_view(zoom)"
     
    13301380        "reset" {
    13311381            array set _view {
     1382                qw      0.853553
     1383                qx      -0.353553
     1384                qy      0.353553
     1385                qz      0.146447
    13321386                theta   45
    13331387                phi     45
     
    13431397                }
    13441398            }
    1345             set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
    1346             SendCmd "camera angle $xyz"
     1399            if {$_useArcball} {
     1400                set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1401                $_arcball quaternion $q
     1402                SendCmd "camera orient $q"
     1403            } else {
     1404                set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
     1405                SendCmd "camera angle $xyz"
     1406            }
    13471407            PanCamera
     1408            set _settings($this-qw)    $_view(qw)
     1409            set _settings($this-qx)    $_view(qx)
     1410            set _settings($this-qy)    $_view(qy)
     1411            set _settings($this-qz)    $_view(qz)
    13481412            set _settings($this-theta) $_view(theta)
    13491413            set _settings($this-phi)   $_view(phi)
     
    14001464                }
    14011465
    1402                 #
    1403                 # Rotate the camera in 3D
    1404                 #
    1405                 if {$_view(psi) > 90 || $_view(psi) < -90} {
    1406                     # when psi is flipped around, theta moves backwards
    1407                     set dy [expr {-$dy}]
     1466                if {$_useArcball} {
     1467                    set q [$_arcball rotate $x $y $_click(x) $_click(y)]
     1468                    foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
     1469                    set _settings($this-qw) $_view(qw)
     1470                    set _settings($this-qx) $_view(qx)
     1471                    set _settings($this-qy) $_view(qy)
     1472                    set _settings($this-qz) $_view(qz)
     1473                    SendCmd "camera orient $q"
     1474                } else {
     1475                    #
     1476                    # Rotate the camera in 3D
     1477                    #
     1478                    if {$_view(psi) > 90 || $_view(psi) < -90} {
     1479                        # when psi is flipped around, theta moves backwards
     1480                        set dy [expr {-$dy}]
     1481                    }
     1482                    set theta [expr {$_view(theta) - $dy*180}]
     1483                    while {$theta < 0} { set theta [expr {$theta+180}] }
     1484                    while {$theta > 180} { set theta [expr {$theta-180}] }
     1485
     1486                    if {abs($theta) >= 30 && abs($theta) <= 160} {
     1487                        set phi [expr {$_view(phi) - $dx*360}]
     1488                        while {$phi < 0} { set phi [expr {$phi+360}] }
     1489                        while {$phi > 360} { set phi [expr {$phi-360}] }
     1490                        set psi $_view(psi)
     1491                    } else {
     1492                        set phi $_view(phi)
     1493                        set psi [expr {$_view(psi) - $dx*360}]
     1494                        while {$psi < -180} { set psi [expr {$psi+360}] }
     1495                        while {$psi > 180} { set psi [expr {$psi-360}] }
     1496                    }
     1497
     1498                    set _view(theta)        $theta
     1499                    set _view(phi)          $phi
     1500                    set _view(psi)          $psi
     1501                    set xyz [Euler2XYZ $theta $phi $psi]
     1502                    set _settings($this-theta) $_view(theta)
     1503                    set _settings($this-phi)   $_view(phi)
     1504                    set _settings($this-psi)   $_view(psi)
     1505                    SendCmd "camera angle $xyz"
    14081506                }
    1409                 set theta [expr {$_view(theta) - $dy*180}]
    1410                 while {$theta < 0} { set theta [expr {$theta+180}] }
    1411                 while {$theta > 180} { set theta [expr {$theta-180}] }
    1412 
    1413                 if {abs($theta) >= 30 && abs($theta) <= 160} {
    1414                     set phi [expr {$_view(phi) - $dx*360}]
    1415                     while {$phi < 0} { set phi [expr {$phi+360}] }
    1416                     while {$phi > 360} { set phi [expr {$phi-360}] }
    1417                     set psi $_view(psi)
    1418                 } else {
    1419                     set phi $_view(phi)
    1420                     set psi [expr {$_view(psi) - $dx*360}]
    1421                     while {$psi < -180} { set psi [expr {$psi+360}] }
    1422                     while {$psi > 180} { set psi [expr {$psi-360}] }
    1423                 }
    1424 
    1425                 set _view(theta)        $theta
    1426                 set _view(phi)          $phi
    1427                 set _view(psi)          $psi
    1428                 set xyz [Euler2XYZ $theta $phi $psi]
    1429                 set _settings($this-theta) $_view(theta)
    1430                 set _settings($this-phi)   $_view(phi)
    1431                 set _settings($this-psi)   $_view(psi)
    1432                 SendCmd "camera angle $xyz"
     1507
    14331508                set _click(x) $x
    14341509                set _click(y) $y
     
    16031678                set tag $_first-$comp
    16041679                set diffuse [expr {0.01*$_settings($this-light)}]
    1605                 set specular [expr {sqrt($_settings($this-light)+1.0)}]
    1606                 SendCmd "$tag configure -diffuse $diffuse -specular $specular"
     1680                set ambient [expr {1.0 - $diffuse}]
     1681                set specularLevel 0.3
     1682                set specularExp 90.0
     1683                SendCmd "$tag configure -ambient $ambient -diffuse $diffuse -specularLevel $specularLevel -specularExp $specularExp"
    16071684            }
    16081685        }
     
    16111688                set comp [lindex [$_first components] 0]
    16121689                set tag $_first-$comp
    1613                 set opacity [expr {0.2*$_settings($this-transp)+1}]
     1690                set opacity [expr { 0.01 * double($_settings($this-transp)) }]
    16141691                SendCmd "$tag configure -opacity $opacity"
    16151692            }
     
    20732150}
    20742151
    2075 
    2076 
    20772152itcl::body Rappture::FlowvisViewer::BuildViewTab {} {
    20782153    foreach { key value } {
     
    21862261    label $inner.shading -text "Shading:" -font $fg
    21872262
    2188     label $inner.dim -text "Dim" -font $fg
     2263    label $inner.dim -text "Glow" -font $fg
    21892264    ::scale $inner.light -from 0 -to 100 -orient horizontal \
    21902265        -variable [itcl::scope _settings($this-light)] \
    21912266        -width 10 \
    21922267        -showvalue off -command [itcl::code $this FixSettings light]
    2193     label $inner.bright -text "Bright" -font $fg
    2194 
    2195     label $inner.fog -text "Fog" -font $fg
     2268    label $inner.bright -text "Surface" -font $fg
     2269
     2270    label $inner.fog -text "Clear" -font $fg
    21962271    ::scale $inner.transp -from 0 -to 100 -orient horizontal \
    21972272        -variable [itcl::scope _settings($this-transp)] \
    21982273        -width 10 \
    21992274        -showvalue off -command [itcl::code $this FixSettings transp]
    2200     label $inner.plastic -text "Plastic" -font $fg
     2275    label $inner.plastic -text "Opaque" -font $fg
    22012276
    22022277    label $inner.clear -text "Clear" -font $fg
     
    22232298        3,1 $inner.transp -columnspan 2 -pady 2 -fill x \
    22242299        3,3 $inner.plastic -anchor w -pady 2 \
    2225         4,0 $inner.clear -anchor e -pady 2 \
    2226         4,1 $inner.opacity -columnspan 2 -pady 2 -fill x\
    2227         4,3 $inner.opaque -anchor w -pady 2 \
    2228         5,0 $inner.thin -anchor e -pady 2 \
    2229         5,1 $inner.thickness -columnspan 2 -pady 2 -fill x\
    2230         5,3 $inner.thick -anchor w -pady 2
     2300        4,0 $inner.thin -anchor e -pady 2 \
     2301        4,1 $inner.thickness -columnspan 2 -pady 2 -fill x\
     2302        4,3 $inner.thick -anchor w -pady 2
    22312303
    22322304    if 0 {
     
    22452317    }
    22462318    blt::table configure $inner c0 c1 c3 r* -resize none
    2247     blt::table configure $inner r6 -resize expand
     2319    blt::table configure $inner r5 -resize expand
    22482320}
    22492321
     
    23552427    $inner configure -borderwidth 4
    23562428
    2357     set labels { phi theta psi pan-x pan-y zoom }
     2429    if {$_useArcball} {
     2430        set labels { qw qx qy qz pan-x pan-y zoom }
     2431    } else {
     2432        set labels { phi theta psi pan-x pan-y zoom }
     2433    }
    23582434    set row 0
    23592435    foreach tag $labels {
     
    25372613    set _width $w
    25382614    set _height $h
     2615    $_arcball resize $w $h
    25392616    if { !$_resizePending } {
    25402617        $_dispatcher event -after 200 !resize
     
    25812658                    set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
    25822659                    SendCmd "camera angle $xyz"
     2660                    if {$_useArcball} {
     2661                        $_arcball euler [list [expr {-[lindex $xyz 2]}] [expr {-[lindex $xyz 1]}] [expr {-[lindex $xyz 0]}]]
     2662                        set q [$_arcball quaternion]
     2663                        foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
     2664                        set _settings($this-qw) $_view(qw)
     2665                        set _settings($this-qx) $_view(qx)
     2666                        set _settings($this-qy) $_view(qy)
     2667                        set _settings($this-qz) $_view(qz)
     2668                    }
     2669                }
     2670                "qx" - "qy" - "qz" - "qw" {
     2671                    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2672                    $_arcball quaternion $q
     2673                    SendCmd "camera orient $q"
    25832674                }
    25842675                "zoom" {
  • trunk/gui/scripts/isomarker.tcl

    r3330 r3362  
    116116        array set limits [$_nvobj limits $_tf]
    117117        if { $limits(vmax) == $limits(vmin) } {
    118             set limits(min) 0.0
    119             set limits(max) 1.0
     118            set limits(vmin) 0.0
     119            set limits(vmax) 1.0
    120120        }
    121121        if { [catch {expr $limits(vmax) - $limits(vmin)} r] != 0 } {
  • trunk/gui/scripts/nanovisviewer.tcl

    r3339 r3362  
    120120    private method SetOrientation {}
    121121
     122    private variable _arcball ""
     123    private variable _useArcball 1
    122124    private variable _outbuf       ;# buffer for outgoing commands
    123125
     
    130132                                   ;# in the server.
    131133    private variable _recvdDatasets    ;# list of data objs to send to server
    132     private variable _vol2style    ;# maps dataobj-component to transfunc
     134    private variable _dataset2style    ;# maps dataobj-component to transfunc
    133135    private variable _style2datasets   ;# maps tf back to list of
    134136                                    # dataobj-components using the tf.
     
    199201    # Initialize the view to some default parameters.
    200202    array set _view {
     203        qw      0.853553
     204        qx      -0.353553
     205        qy      0.353553
     206        qz      0.146447
    201207        theta   45
    202208        phi     45
     
    206212        pan-y   0
    207213    }
     214    set _arcball [blt::arcball create 100 100]
     215    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     216    $_arcball quaternion $q
     217
    208218    set _limits(vmin) 0.0
    209219    set _limits(vmax) 1.0
     
    211221
    212222    array set _settings [subst {
     223        $this-qw                $_view(qw)
     224        $this-qx                $_view(qx)
     225        $this-qy                $_view(qy)
     226        $this-qz                $_view(qz)
     227        $this-theta             $_view(theta)
     228        $this-phi               $_view(phi)
     229        $this-psi               $_view(psi)
     230        $this-zoom              $_view(zoom)   
    213231        $this-pan-x             $_view(pan-x)
    214232        $this-pan-y             $_view(pan-y)
    215         $this-phi               $_view(phi)
    216         $this-psi               $_view(psi)
    217         $this-theta             $_view(theta)
    218233        $this-volume            1
    219234        $this-xcutplane         0
     
    223238        $this-zcutplane         0
    224239        $this-zcutposition      0
    225         $this-zoom              $_view(zoom)
    226240    }]
    227241
     
    379393    image delete $_image(legend)
    380394    image delete $_image(download)
     395    catch { blt::arcball destroy $_arcball }
    381396    array unset _settings $this-*
    382397}
     
    491506            array unset _limits $dataobj*
    492507            array unset _obj2ovride $dataobj-*
    493             array unset _vol2style $dataobj-*
     508            array unset _dataset2style $dataobj-*
    494509            set changed 1
    495510        }
     
    676691            # The volume hasn't reached the server yet.  How did we get
    677692            # here?
     693            puts stderr "Don't have $vol in _serverVols"
    678694            continue
    679695        }
    680         if { ![info exists _vol2style($tag)] } {
    681             puts stderr "unknown volume $tag"
     696        if { ![info exists _dataset2style($tag)] } {
     697            puts stderr "Don't have style for volume $tag"
    682698            continue;                        # How does this happen?
    683699        }
    684         set tf $_vol2style($tag)
     700        set tf $_dataset2style($tag)
    685701        set _settings($this-$tf-opacity) $opacity
    686702        set _settings($this-$tf-thickness) $thickness
     
    819835        return
    820836    }
     837
     838    puts stderr "Received volume info: '$args'"
     839
    821840    # Arguments from server are name value pairs. Stuff them in an array.
    822841    array set info $args
     
    872891    set w [winfo width $itk_component(3dview)]
    873892    set h [winfo height $itk_component(3dview)]
     893    $_arcball resize $w $h
    874894    EventuallyResize $w $h
    875895
     
    894914        # Reset the camera and other view parameters
    895915        #
    896        
     916        set _settings($this-qw)    $_view(qw)
     917        set _settings($this-qx)    $_view(qx)
     918        set _settings($this-qy)    $_view(qy)
     919        set _settings($this-qz)    $_view(qz)
    897920        set _settings($this-theta) $_view(theta)
    898921        set _settings($this-phi)   $_view(phi)
     
    901924        set _settings($this-pan-y) $_view(pan-y)
    902925        set _settings($this-zoom)  $_view(zoom)
    903        
    904         set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
    905         SendCmd "camera angle $xyz"
     926
     927        if {$_useArcball} {
     928            set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     929            $_arcball quaternion $q
     930            SendCmd "camera orient $q"
     931        } else {
     932            set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
     933            SendCmd "camera angle $xyz"
     934        }
     935
    906936        PanCamera
    907937        SendCmd "camera zoom $_view(zoom)"
     938        FixSettings light2side
    908939        FixSettings light
    909940        FixSettings transp
     
    10211052        "reset" {
    10221053            array set _view {
     1054                qw      0.853553
     1055                qx      -0.353553
     1056                qy      0.353553
     1057                qz      0.146447
    10231058                theta   45
    10241059                phi     45
     
    10341069                }
    10351070            }
    1036             set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
    1037             SendCmd "camera angle $xyz"
     1071            if {$_useArcball} {
     1072                set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1073                $_arcball quaternion $q
     1074                SendCmd "camera orient $q"
     1075            } else {
     1076                set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
     1077                SendCmd "camera angle $xyz"
     1078            }
     1079
    10381080            PanCamera
     1081            set _settings($this-qw)    $_view(qw)
     1082            set _settings($this-qx)    $_view(qx)
     1083            set _settings($this-qy)    $_view(qy)
     1084            set _settings($this-qz)    $_view(qz)
    10391085            set _settings($this-theta) $_view(theta)
    10401086            set _settings($this-phi)   $_view(phi)
     
    10921138                }
    10931139
    1094                 #
    1095                 # Rotate the camera in 3D
    1096                 #
    1097                 if {$_view(psi) > 90 || $_view(psi) < -90} {
    1098                     # when psi is flipped around, theta moves backwards
    1099                     set dy [expr {-$dy}]
     1140                if {$_useArcball} {
     1141                    set q [$_arcball rotate $x $y $_click(x) $_click(y)]
     1142                    foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
     1143                    set _settings($this-qw) $_view(qw)
     1144                    set _settings($this-qx) $_view(qx)
     1145                    set _settings($this-qy) $_view(qy)
     1146                    set _settings($this-qz) $_view(qz)
     1147                    SendCmd "camera orient $q"
     1148                } else {
     1149                    #
     1150                    # Rotate the camera in 3D
     1151                    #
     1152                    if {$_view(psi) > 90 || $_view(psi) < -90} {
     1153                        # when psi is flipped around, theta moves backwards
     1154                        set dy [expr {-$dy}]
     1155                    }
     1156                    set theta [expr {$_view(theta) - $dy*180}]
     1157                    while {$theta < 0} { set theta [expr {$theta+180}] }
     1158                    while {$theta > 180} { set theta [expr {$theta-180}] }
     1159
     1160                    if {abs($theta) >= 30 && abs($theta) <= 160} {
     1161                        set phi [expr {$_view(phi) - $dx*360}]
     1162                        while {$phi < 0} { set phi [expr {$phi+360}] }
     1163                        while {$phi > 360} { set phi [expr {$phi-360}] }
     1164                        set psi $_view(psi)
     1165                    } else {
     1166                        set phi $_view(phi)
     1167                        set psi [expr {$_view(psi) - $dx*360}]
     1168                        while {$psi < -180} { set psi [expr {$psi+360}] }
     1169                        while {$psi > 180} { set psi [expr {$psi-360}] }
     1170                    }
     1171
     1172                    set _view(theta)        $theta
     1173                    set _view(phi)          $phi
     1174                    set _view(psi)          $psi
     1175                    set xyz [Euler2XYZ $theta $phi $psi]
     1176                    set _settings($this-theta) $_view(theta)
     1177                    set _settings($this-phi)   $_view(phi)
     1178                    set _settings($this-psi)   $_view(psi)
     1179                    SendCmd "camera angle $xyz"
    11001180                }
    1101                 set theta [expr {$_view(theta) - $dy*180}]
    1102                 while {$theta < 0} { set theta [expr {$theta+180}] }
    1103                 while {$theta > 180} { set theta [expr {$theta-180}] }
    1104 
    1105                 if {abs($theta) >= 30 && abs($theta) <= 160} {
    1106                     set phi [expr {$_view(phi) - $dx*360}]
    1107                     while {$phi < 0} { set phi [expr {$phi+360}] }
    1108                     while {$phi > 360} { set phi [expr {$phi-360}] }
    1109                     set psi $_view(psi)
    1110                 } else {
    1111                     set phi $_view(phi)
    1112                     set psi [expr {$_view(psi) - $dx*360}]
    1113                     while {$psi < -180} { set psi [expr {$psi+360}] }
    1114                     while {$psi > 180} { set psi [expr {$psi-360}] }
    1115                 }
    1116 
    1117                 set _view(theta)        $theta
    1118                 set _view(phi)          $phi
    1119                 set _view(psi)          $psi
    1120                 set xyz [Euler2XYZ $theta $phi $psi]
    1121                 set _settings($this-theta) $_view(theta)
    1122                 set _settings($this-phi)   $_view(phi)
    1123                 set _settings($this-psi)   $_view(psi)
    1124                 SendCmd "camera angle $xyz"
     1181
    11251182                set _click(x) $x
    11261183                set _click(y) $y
     
    11931250            if {[isconnected]} {
    11941251                set val $_settings($this-light)
    1195                 set sval [expr {0.01*$val}]
    1196                 SendCmd "volume shading diffuse $sval"
    1197                 set sval [expr {sqrt($val+1.0)}]
    1198                 SendCmd "volume shading specular $sval"
     1252                set diffuse [expr {0.01*$val}]
     1253                set ambient [expr {1.0-$diffuse}]
     1254                set specularLevel 0.3
     1255                set specularExp 90.0
     1256                SendCmd "volume shading ambient $ambient"
     1257                SendCmd "volume shading diffuse $diffuse"
     1258                SendCmd "volume shading specularLevel $specularLevel"
     1259                SendCmd "volume shading specularExp $specularExp"
     1260            }
     1261        }
     1262        light2side {
     1263            if {[isconnected]} {
     1264                set val $_settings($this-light2side)
     1265                SendCmd "volume shading light2side $val"
    11991266            }
    12001267        }
     
    12021269            if {[isconnected]} {
    12031270                set val $_settings($this-transp)
    1204                 set sval [expr {0.2*$val+1}]
     1271                set sval [expr { 0.01 * double($val) }]
    12051272                SendCmd "volume shading opacity $sval"
    12061273            }
     
    12171284            }
    12181285        }
    1219 
    12201286        thickness {
    12211287            if {[isconnected] && [array names _activeTfs] > 0 } {
     
    13021368    if {$w > 0 && $h > 0 && [array names _activeTfs] > 0 && $_first != "" } {
    13031369        set tag [lindex [CurrentDatasets] 0]
    1304         if { [info exists _vol2style($tag)] } {
    1305             SendCmd "legend $_vol2style($tag) $w $h"
     1370        if { [info exists _dataset2style($tag)] } {
     1371            SendCmd "legend $_dataset2style($tag) $w $h"
    13061372        }
    13071373    } else {
     
    13331399        -levels 6
    13341400        -opacity 1.0
     1401        -markers ""
    13351402    }
    13361403    set tag $dataobj-$cname
    13371404    array set style [lindex [$dataobj components -style $cname] 0]
    13381405    set tf "$style(-color):$style(-levels):$style(-opacity)"
    1339     set _vol2style($tag) $tf
     1406    set _dataset2style($tag) $tf
    13401407    lappend _style2datasets($tf) $tag
    13411408    return $tf
     
    13561423        -levels 6
    13571424        -opacity 1.0
     1425        -markers ""
    13581426    }
    13591427    foreach {dataobj cname} [split [lindex $_style2datasets($tf) 0] -] break
    13601428    array set style [lindex [$dataobj components -style $cname] 0]
    13611429
     1430    puts stderr "$tf: $style(-color), $style(-levels), $style(-opacity), $style(-markers)"
    13621431
    13631432    # We have to parse the style attributes for a volume using this
     
    13761445    if { ![info exists _isomarkers($tf)] } {
    13771446        # Have to defer creation of isomarkers until we have data limits
    1378         if { [info exists style(-markers)] } {
     1447        if { [info exists style(-markers)] &&
     1448             [llength $style(-markers)] > 0 } {
    13791449            ParseMarkersOption $tf $style(-markers)
     1450            puts stderr "Found markers option"
    13801451        } else {
    13811452            ParseLevelsOption $tf $style(-levels)
     
    13861457    }
    13871458    set clist [split $style(-color) :]
    1388     set cmap "0.0 [Color2RGB white] "
     1459    if {[llength $clist] == 1} {
     1460        lappend clist [lindex $clist 0]
     1461    }
    13891462    for {set i 0} {$i < [llength $clist]} {incr i} {
    1390         set x [expr {double($i+1)/([llength $clist]+1)}]
     1463        set x [expr {double($i)/([llength $clist]-1)}]
    13911464        set color [lindex $clist $i]
    13921465        append cmap "$x [Color2RGB $color] "
    13931466    }
    1394     append cmap "1.0 [Color2RGB $color]"
    13951467
    13961468    set tag $this-$tf
     
    13981470        set _settings($tag-opacity) $style(-opacity)
    13991471    }
    1400     set max $_settings($tag-opacity)
     1472    set max 1.0 ;#$_settings($tag-opacity)
    14011473
    14021474    set isovalues {}
     
    14081480
    14091481    if { ![info exists _settings($tag-thickness)]} {
    1410         set _settings($tag-thickness) 0.05
     1482        set _settings($tag-thickness) 0.005
    14111483    }
    14121484    set delta $_settings($tag-thickness)
     
    15631635    }
    15641636    set tag [lindex [CurrentDatasets] 0]
    1565     set tf $_vol2style($tag)
     1637    set tf $_dataset2style($tag)
    15661638    set c $itk_component(legend)
    15671639    set m [Rappture::IsoMarker \#auto $c $this $tf]
     
    17181790itcl::body Rappture::NanovisViewer::BuildVolumeTab {} {
    17191791    foreach { key value } {
     1792        light2side      0
    17201793        light           40
    17211794        transp          50
     
    17391812    label $inner.shading -text "Shading:" -font $fg
    17401813
    1741     label $inner.dim -text "Dim" -font $fg
     1814    checkbutton $inner.light2side -text "Two-sided lighting" -font $fg \
     1815        -variable [itcl::scope _settings($this-light2side)] \
     1816        -command [itcl::code $this FixSettings light2side]
     1817
     1818    label $inner.dim -text "Glow" -font $fg
    17421819    ::scale $inner.light -from 0 -to 100 -orient horizontal \
    17431820        -variable [itcl::scope _settings($this-light)] \
    17441821        -width 10 \
    17451822        -showvalue off -command [itcl::code $this FixSettings light]
    1746     label $inner.bright -text "Bright" -font $fg
    1747 
    1748     label $inner.fog -text "Fog" -font $fg
     1823    label $inner.bright -text "Surface" -font $fg
     1824
     1825    label $inner.fog -text "Clear" -font $fg
    17491826    ::scale $inner.transp -from 0 -to 100 -orient horizontal \
    17501827        -variable [itcl::scope _settings($this-transp)] \
    17511828        -width 10 \
    17521829        -showvalue off -command [itcl::code $this FixSettings transp]
    1753     label $inner.plastic -text "Plastic" -font $fg
     1830    label $inner.plastic -text "Opaque" -font $fg
    17541831
    17551832    label $inner.clear -text "Clear" -font $fg
     
    17701847        0,0 $inner.vol -columnspan 4 -anchor w -pady 2 \
    17711848        1,0 $inner.shading -columnspan 4 -anchor w -pady {10 2} \
    1772         2,0 $inner.dim -anchor e -pady 2 \
    1773         2,1 $inner.light -columnspan 2 -pady 2 -fill x \
    1774         2,3 $inner.bright -anchor w -pady 2 \
    1775         3,0 $inner.fog -anchor e -pady 2 \
    1776         3,1 $inner.transp -columnspan 2 -pady 2 -fill x \
    1777         3,3 $inner.plastic -anchor w -pady 2 \
    1778         4,0 $inner.clear -anchor e -pady 2 \
    1779         4,1 $inner.opacity -columnspan 2 -pady 2 -fill x\
    1780         4,3 $inner.opaque -anchor w -pady 2 \
     1849        2,0 $inner.light2side -columnspan 4 -anchor w -pady 2 \
     1850        3,0 $inner.dim -anchor e -pady 2 \
     1851        3,1 $inner.light -columnspan 2 -pady 2 -fill x \
     1852        3,3 $inner.bright -anchor w -pady 2 \
     1853        4,0 $inner.fog -anchor e -pady 2 \
     1854        4,1 $inner.transp -columnspan 2 -pady 2 -fill x \
     1855        4,3 $inner.plastic -anchor w -pady 2 \
    17811856        5,0 $inner.thin -anchor e -pady 2 \
    17821857        5,1 $inner.thickness -columnspan 2 -pady 2 -fill x\
    17831858        5,3 $inner.thick -anchor w -pady 2
     1859
     1860#        4,0 $inner.clear -anchor e -pady 2 \
     1861#        4,1 $inner.opacity -columnspan 2 -pady 2 -fill x\
     1862#        4,3 $inner.opaque -anchor w -pady 2 \
     1863
    17841864
    17851865    blt::table configure $inner c0 c1 c3 r* -resize none
     
    18941974    $inner configure -borderwidth 4
    18951975
    1896     set labels { phi theta psi pan-x pan-y zoom }
     1976    if {$_useArcball} {
     1977        set labels { qw qx qy qz pan-x pan-y zoom }
     1978    } else {
     1979        set labels { phi theta psi pan-x pan-y zoom }
     1980    }
    18971981    set row 0
    18981982    foreach tag $labels {
     
    19802064    set _width $w
    19812065    set _height $h
     2066    $_arcball resize $w $h
    19822067    if { !$_resizePending } {
    19832068        $_dispatcher event -idle !resize
     
    20182103                    set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
    20192104                    SendCmd "camera angle $xyz"
     2105                    if {$_useArcball} {
     2106                        $_arcball euler [list [expr {-[lindex $xyz 2]}] [expr {-[lindex $xyz 1]}] [expr {-[lindex $xyz 0]}]]
     2107                        set q [$_arcball quaternion]
     2108                        foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
     2109                        set _settings($this-qw) $_view(qw)
     2110                        set _settings($this-qx) $_view(qx)
     2111                        set _settings($this-qy) $_view(qy)
     2112                        set _settings($this-qz) $_view(qz)
     2113                    }
     2114                }
     2115                "qx" - "qy" - "qz" - "qw" {
     2116                    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     2117                    $_arcball quaternion $q
     2118                    SendCmd "camera orient $q"
    20202119                }
    20212120                "zoom" {
Note: See TracChangeset for help on using the changeset viewer.