Changeset 2474 for trunk/gui


Ignore:
Timestamp:
Sep 4, 2011, 7:21:41 PM (13 years ago)
Author:
gah
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/vtkviewer.tcl

    r2473 r2474  
    9797    private method SetStyles { dataobj comp }
    9898    private method RequestLegend {}
     99    private method EnterLegend { x y }
     100    private method MotionLegend { x y }
     101    private method LeaveLegend {}
     102    private method SetLegendMark { x y }
    99103
    100104    private variable _arcball ""
     
    116120    private variable _limits       ;# autoscale min/max for all axes
    117121    private variable _view         ;# view params for 3D view
    118     private common   _settings
     122    private variable _settings
     123    private variable _volume
     124    private variable _axis
     125    private variable _streamlines
    119126    private variable _reset 1      ;# indicates if camera needs to be reset
    120127                                    # to starting position.
     
    124131    private variable _start 0
    125132    private variable _buffering 0
    126    
     133    private variable _title ""
     134
    127135    common _downloadPopup          ;# download options from popup
    128136    private common _hardcopy
     
    185193    set _limits(zmax) 1.0
    186194
     195    array set _axis [subst {
     196        grid-x          0
     197        grid-y          0
     198        grid-z          0
     199        visible         1
     200    }]
     201    array set _volume [subst {
     202        edges           1
     203        lighting        1
     204        opacity         40
     205        visible         1
     206        wireframe       0
     207    }]
     208    array set _streamlines [subst {
     209        seeds           0
     210        visible         1
     211        opacity         100
     212    }]
    187213    array set _settings [subst {
    188         $this-axes              1
    189         $this-legend            1
    190         $this-seeds             1
    191         $this-streamlines       1
    192         $this-edges             1
    193         $this-lighting          1
    194         $this-opacity           100
    195         $this-volume            1
    196         $this-wireframe         0
    197         $this-grid-x            0
    198         $this-grid-y            0
    199         $this-grid-z            0
     214        legend          1
    200215    }]
    201216
     
    264279    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
    265280
     281    if { [catch {
    266282    BuildVolumeTab
     283    BuildStreamsTab
    267284    BuildAxisTab
    268     BuildStreamsTab
    269285    BuildCameraTab
    270 
     286    } errs] != 0 } {
     287        puts stderr errs=$errs
     288    }
    271289    # Legend
    272290
    273291    set _image(legend) [image create photo]
    274292    itk_component add legend {
    275         canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0
     293        canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0 
    276294    } {
    277295        usual
     
    349367
    350368    eval itk_initialize $args
    351 
    352369    Connect
    353370}
     
    362379    image delete $_image(plot)
    363380    image delete $_image(download)
    364     array unset _settings $this-*
    365381    catch { blt::arcball destroy $_arcball }
    366382}
     
    865881    }
    866882
    867     FixSettings opacity grid-x grid-y grid-z volume lighting \
    868         wireframe axes edges seeds streamlines axismode
     883    FixSettings axis-grid-x axis-grid-y axis-grid-z axis-mode axis-visible \
     884        streamlines-seeds streamlines-visible streamlines-opacity \
     885        volume-edges volume-lighting volume-opacity volume-visible \
     886        volume-wireframe
    869887
    870888    if { !$_haveStreams } {
     
    11171135    }
    11181136    switch -- $what {
    1119         "opacity" {
    1120             set val $_settings($this-opacity)
     1137        "volume-opacity" {
     1138            set val $_volume(opacity)
    11211139            set sval [expr { 0.01 * double($val) }]
    11221140            foreach dataset [CurrentDatasets -visible $_first] {
     
    11241142            }
    11251143        }
    1126         "wireframe" {
    1127             set bool $_settings($this-wireframe)
     1144        "volume-wireframe" {
     1145            set bool $_volume(wireframe)
    11281146            foreach dataset [CurrentDatasets -visible $_first] {
    11291147                SendCmd "polydata wireframe $bool $dataset"
    11301148            }
    11311149        }
    1132         "volume" {
    1133             set bool $_settings($this-volume)
     1150        "volume-visible" {
     1151            set bool $_volume(visible)
    11341152            foreach dataset [CurrentDatasets -visible $_first] {
    11351153                SendCmd "polydata visible $bool $dataset"
    11361154            }
    11371155        }
    1138         "lighting" {
    1139             set bool $_settings($this-lighting)
     1156        "volume-lighting" {
     1157            set bool $_volume(lighting)
    11401158            foreach dataset [CurrentDatasets -visible $_first] {
    11411159                SendCmd "polydata lighting $bool $dataset"
    11421160            }
    11431161        }
    1144         "grid-x" {
    1145             set bool $_settings($this-grid-x)
    1146             SendCmd "axis grid x $bool"
    1147         }
    1148         "grid-y" {
    1149             set bool $_settings($this-grid-y)
    1150             SendCmd "axis grid y $bool"
    1151         }
    1152         "grid-z" {
    1153             set bool $_settings($this-grid-z)
    1154             SendCmd "axis grid z $bool"
    1155         }
    1156         "axes" {
    1157             set bool $_settings($this-axes)
    1158             SendCmd "axis visible all $bool"
    1159         }
    1160         "axismode" {
    1161             set mode [$itk_component(axismode) value]
    1162             set mode [$itk_component(axismode) translate $mode]
    1163             SendCmd "axis flymode $mode"
    1164         }
    1165         "edges" {
    1166             set bool $_settings($this-edges)
     1162        "volume-edges" {
     1163            set bool $_volume(edges)
    11671164            foreach dataset [CurrentDatasets -visible $_first] {
    11681165                foreach {dataobj comp} [split $dataset -] break
     
    11721169            }
    11731170        }
    1174         "seeds" {
    1175             set bool $_settings($this-seeds)
     1171        "axis-visible" {
     1172            set bool $_axis(visible)
     1173            SendCmd "axis visible all $bool"
     1174        }
     1175        "axis-grid-x" {
     1176            set bool $_axis(grid-x)
     1177            SendCmd "axis grid x $bool"
     1178        }
     1179        "axis-grid-y" {
     1180            set bool $_axis(grid-y)
     1181            SendCmd "axis grid y $bool"
     1182        }
     1183        "axis-grid-z" {
     1184            set bool $_axis(grid-z)
     1185            SendCmd "axis grid z $bool"
     1186        }
     1187        "axis-mode" {
     1188            set mode [$itk_component(axismode) value]
     1189            set mode [$itk_component(axismode) translate $mode]
     1190            SendCmd "axis flymode $mode"
     1191        }
     1192        "streamlines-seeds" {
     1193            set bool $_streamlines(seeds)
    11761194            foreach dataset [CurrentDatasets -visible $_first] {
    11771195                foreach {dataobj comp} [split $dataset -] break
     
    11811199            }
    11821200        }
    1183         "streamlines" {
    1184             set bool $_settings($this-streamlines)
     1201        "streamlines-visible" {
     1202            set bool $_streamlines(visible)
    11851203            foreach dataset [CurrentDatasets -visible $_first] {
    11861204                foreach {dataobj comp} [split $dataset -] break
    11871205                if { [$dataobj type $comp] == "streamlines" } {
    1188                     if { $bool } {
    1189                         SendCmd "streamlines add $dataset"
    1190                     } else {
    1191                         SendCmd "streamlines delete $dataset"
    1192                     }
     1206                    SendCmd "streamlines visible $bool $dataset"
    11931207                }
    11941208            }
    11951209        }
    1196         "streammode" {
     1210        "streamlines-mode" {
    11971211            set mode [$itk_component(streammode) value]
    11981212            foreach dataset [CurrentDatasets -visible $_first] {
     
    12041218                        }
    12051219                        "ribbons" {
    1206                             SendCmd "streamlines ribbons 3.0 20 $dataset"
     1220                            SendCmd "streamlines ribbons 1 0 $dataset"
    12071221                        }
    12081222                        "tubes" {
    1209                             SendCmd "streamlines tubes 20 10 $dataset"
     1223                            SendCmd "streamlines tubes 5 1 $dataset"
    12101224                        }
    12111225                    }
     
    12131227            }
    12141228        }
     1229        "streamlines-opacity" {
     1230            set val $_streamlines(opacity)
     1231            set sval [expr { 0.01 * double($val) }]
     1232            foreach dataset [CurrentDatasets -visible $_first] {
     1233                SendCmd "streamlines opacity $sval $dataset"
     1234            }
     1235        }
    12151236        default {
    12161237            error "don't know how to fix $what"
     
    12301251    set lineht [font metrics $itk_option(-font) -linespace]
    12311252    set c $itk_component(legend)
    1232     set w [expr {$_height-20}]
    1233     set h 45;                           # Hard coding height of legend
    1234 
    1235     if { $w == 0} {
     1253    set w 20
     1254    set h [expr {$_height - 2 * $lineht}]
     1255    if { $h < 1} {
    12361256        return
    12371257    }
     
    12991319        set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
    13001320    }
    1301     set tag $this-$colormap
    1302     if { ![info exists _settings($tag-opacity)] } {
    1303         set _settings($tag-opacity) $style(-opacity)
    1304     }
    1305     set max $_settings($tag-opacity)
     1321    if { ![info exists _volume(opacity)] } {
     1322        set _volume(opacity) $style(-opacity)
     1323    }
     1324    set max $_volume(opacity)
    13061325
    13071326    set wmap "0.0 1.0 1.0 1.0"
     
    13801399
    13811400    checkbutton $inner.volume \
    1382         -text "Visible" \
    1383         -variable [itcl::scope _settings($this-volume)] \
    1384         -command [itcl::code $this AdjustSetting volume] \
     1401        -text "Show Volume" \
     1402        -variable [itcl::scope _volume(visible)] \
     1403        -command [itcl::code $this AdjustSetting volume-visible] \
    13851404        -font "Arial 9"
    13861405
    13871406    checkbutton $inner.wireframe \
    1388         -text "Wireframe" \
    1389         -variable [itcl::scope _settings($this-wireframe)] \
    1390         -command [itcl::code $this AdjustSetting wireframe] \
     1407        -text "Show Wireframe" \
     1408        -variable [itcl::scope _volume(wireframe)] \
     1409        -command [itcl::code $this AdjustSetting volume-wireframe] \
    13911410        -font "Arial 9"
    13921411
    13931412    checkbutton $inner.lighting \
    1394         -text "Lighting" \
    1395         -variable [itcl::scope _settings($this-lighting)] \
    1396         -command [itcl::code $this AdjustSetting lighting] \
     1413        -text "Enable Lighting" \
     1414        -variable [itcl::scope _volume(lighting)] \
     1415        -command [itcl::code $this AdjustSetting volume-lighting] \
    13971416        -font "Arial 9"
    13981417
    13991418    checkbutton $inner.edges \
    1400         -text "Edges" \
    1401         -variable [itcl::scope _settings($this-edges)] \
    1402         -command [itcl::code $this AdjustSetting edges] \
     1419        -text "Show Edges" \
     1420        -variable [itcl::scope _volume(edges)] \
     1421        -command [itcl::code $this AdjustSetting volume-edges] \
    14031422        -font "Arial 9"
    14041423
    14051424    label $inner.opacity_l -text "Opacity" -font "Arial 9"
    14061425    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1407         -variable [itcl::scope _settings($this-opacity)] \
     1426        -variable [itcl::scope _volume(opacity)] \
    14081427        -width 10 \
    1409         -showvalue off -command [itcl::code $this AdjustSetting opacity]
     1428        -showvalue off \
     1429        -command [itcl::code $this AdjustSetting volume-opacity]
    14101430
    14111431    blt::table $inner \
    1412         0,0 $inner.volume -columnspan 4 -anchor w -pady 2 \
    1413         1,0 $inner.wireframe -columnspan 4 -anchor w -pady 2 \
    1414         2,0 $inner.lighting  -columnspan 4 -anchor w \
    1415         3,0 $inner.edges -columnspan 4 -anchor w -pady 2 \
     1432        0,0 $inner.volume   -anchor w -pady 2 \
     1433        1,0 $inner.wireframe -anchor w -pady 2 \
     1434        2,0 $inner.lighting  -anchor w -pady 2 \
     1435        3,0 $inner.edges     -anchor w -pady 2 \
    14161436        4,0 $inner.opacity_l -anchor w -pady 2 \
    1417         5,0 $inner.opacity -columnspan 2 -pady 2 -fill x
    1418 
    1419     blt::table configure $inner r* -resize none
    1420     blt::table configure $inner r6 -resize expand
     1437        5,0 $inner.opacity   -fill x   -pady 2
     1438
     1439    blt::table configure $inner r* c* -resize none
     1440    blt::table configure $inner r6 c1 -resize expand
    14211441}
    14221442
     
    14331453
    14341454    checkbutton $inner.streamlines \
    1435         -text "Visible" \
    1436         -variable [itcl::scope _settings($this-streamlines)] \
    1437         -command [itcl::code $this AdjustSetting streamlines] \
     1455        -text "Show Streamlines" \
     1456        -variable [itcl::scope _streamlines(visible)] \
     1457        -command [itcl::code $this AdjustSetting streamlines-visible] \
    14381458        -font "Arial 9"
    14391459
    14401460    checkbutton $inner.seeds \
    1441         -text "Show seeds" \
    1442         -variable [itcl::scope _settings($this-seeds)] \
    1443         -command [itcl::code $this AdjustSetting seeds] \
     1461        -text "Show Seeds" \
     1462        -variable [itcl::scope _streamlines(seeds)] \
     1463        -command [itcl::code $this AdjustSetting streamlines-seeds] \
    14441464        -font "Arial 9"
    14451465
    1446     label $inner.streammode -text "Mode" \
    1447         -font "Arial 9"
    1448 
     1466    label $inner.mode_l -text "Mode" -font "Arial 9"
    14491467    itk_component add streammode {
    1450         Rappture::Combobox $inner.streammode_combo -width 10 -editable no
    1451     }
    1452     $inner.streammode_combo choices insert end \
     1468        Rappture::Combobox $inner.mode -width 10 -editable no
     1469    }
     1470    $inner.mode choices insert end \
    14531471        "lines"    "lines" \
    14541472        "ribbons"   "ribbons" \
    14551473        "tubes"     "tubes"
    14561474    $itk_component(streammode) value "lines"
    1457     bind $inner.streammode_combo <<Value>> \
    1458         [itcl::code $this AdjustSetting streammode]
     1475    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting streamlines-mode]
    14591476
    14601477    label $inner.opacity_l -text "Opacity" -font "Arial 9"
    14611478    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1462         -variable [itcl::scope _settings($this-opacity)] \
     1479        -variable [itcl::scope _streamlines(opacity)] \
    14631480        -width 10 \
    1464         -showvalue off -command [itcl::code $this AdjustSetting opacity]
     1481        -showvalue off \
     1482        -command [itcl::code $this AdjustSetting streamlines-opacity]
    14651483
    14661484    blt::table $inner \
    1467         0,0 $inner.streamlines -columnspan 4 -anchor w -pady 2 \
    1468         1,0 $inner.seeds -columnspan 4 -anchor w -pady 2 \
    1469         2,0 $inner.streammode -anchor w -pady 2 \
    1470         2,1 $inner.streammode_combo -cspan 3 -anchor w -pady 2 \
    1471         3,0 $inner.opacity_l -pady 2 -fill x\
    1472         4,0 $inner.opacity -columnspan 2 -pady 2 -fill x
    1473 
    1474     blt::table configure $inner r* -resize none
    1475     blt::table configure $inner r5 -resize expand
     1485        0,0 $inner.streamlines -anchor w -pady 2 -cspan 2 \
     1486        1,0 $inner.seeds       -anchor w -pady 2 -cspan 2 \
     1487        2,0 $inner.mode_l      -anchor w -pady 2 \
     1488        2,1 $inner.mode        -anchor w -pady 2 \
     1489        3,0 $inner.opacity_l   -anchor w -pady 2  \
     1490        4,0 $inner.opacity     -fill x   -pady 2 -cspan 2
     1491
     1492    blt::table configure $inner r* c* -resize none
     1493    blt::table configure $inner r5 c1 c2 -resize expand
    14761494}
    14771495
     
    14861504    $inner configure -borderwidth 4
    14871505
    1488     checkbutton $inner.axes \
    1489         -text "Visible" \
    1490         -variable [itcl::scope _settings($this-axes)] \
    1491         -command [itcl::code $this AdjustSetting axes] \
     1506    checkbutton $inner.visible \
     1507        -text "Show Axes" \
     1508        -variable [itcl::scope _axis(visible)] \
     1509        -command [itcl::code $this AdjustSetting axis-visible] \
    14921510        -font "Arial 9"
    14931511
    1494     label $inner.grid -text "Grid" -font "Arial 9"
    1495     set f [frame $inner.gridf]
    1496     checkbutton $f.x \
    1497         -text "X" \
    1498         -variable [itcl::scope _settings($this-grid-x)] \
    1499         -command [itcl::code $this AdjustSetting grid-x] \
     1512    checkbutton $inner.gridx \
     1513        -text "Show X Grid" \
     1514        -variable [itcl::scope _axis(grid-x)] \
     1515        -command [itcl::code $this AdjustSetting axis-grid-x] \
    15001516        -font "Arial 9"
    1501     checkbutton $f.y \
    1502         -text "Y" \
    1503         -variable [itcl::scope _settings($this-grid-y)] \
    1504         -command [itcl::code $this AdjustSetting grid-y] \
     1517    checkbutton $inner.gridy \
     1518        -text "Show Y Grid" \
     1519        -variable [itcl::scope _axis(grid-y)] \
     1520        -command [itcl::code $this AdjustSetting axis-grid-y] \
    15051521        -font "Arial 9"
    1506     checkbutton $f.z \
    1507         -text "Z" \
    1508         -variable [itcl::scope _settings($this-grid-z)] \
    1509         -command [itcl::code $this AdjustSetting grid-z] \
     1522    checkbutton $inner.gridz \
     1523        -text "Show Z Grid" \
     1524        -variable [itcl::scope _axis(grid-z)] \
     1525        -command [itcl::code $this AdjustSetting axis-grid-z] \
    15101526        -font "Arial 9"
    1511     pack $f.x $f.y $f.z -side left
    1512 
    1513     label $inner.axismode -text "Mode" \
    1514         -font "Arial 9"
     1527
     1528    label $inner.mode_l -text "Mode" -font "Arial 9"
    15151529
    15161530    itk_component add axismode {
    1517         Rappture::Combobox $inner.axismode_combo -width 10 -editable no
    1518     }
    1519     $inner.axismode_combo choices insert end \
     1531        Rappture::Combobox $inner.mode -width 10 -editable no
     1532    }
     1533    $inner.mode choices insert end \
    15201534        "static_triad"    "static" \
    15211535        "closest_triad"   "closest" \
     
    15231537        "outer_edges"     "outer"         
    15241538    $itk_component(axismode) value "outer"
    1525     bind $inner.axismode_combo <<Value>> \
    1526         [itcl::code $this AdjustSetting axismode]
     1539    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axis-mode]
    15271540
    15281541    blt::table $inner \
    1529         0,0 $inner.axes -columnspan 4 -anchor w -pady 2 \
    1530         1,0 $inner.axismode -anchor w -pady 2 \
    1531         1,1 $inner.axismode_combo -cspan 3 -anchor w -pady 2 \
    1532         2,0 $inner.grid -anchor w -pady 2 \
    1533         2,1 $inner.gridf -anchor w -cspan 3 -fill x
    1534 
    1535     blt::table configure $inner r* -resize none
    1536     blt::table configure $inner r3 -resize expand
     1542        0,0 $inner.visible -anchor w -pady 2 -cspan 2 \
     1543        1,0 $inner.gridx   -anchor w -pady 2 -cspan 2 \
     1544        2,0 $inner.gridy   -anchor w -pady 2 -cspan 2 \
     1545        3,0 $inner.gridz   -anchor w -pady 2 -cspan 2 \
     1546        4,0 $inner.mode_l  -anchor w -pady 2 \
     1547        4,1 $inner.mode    -fill x   -pady 2
     1548
     1549    blt::table configure $inner r* c* -resize none
     1550    blt::table configure $inner r5 c2 -resize expand
    15371551}
    15381552
     
    15581572    }
    15591573    checkbutton $inner.ortho \
    1560         -text "Orthogrpahic" \
     1574        -text "Orthographic Projection" \
    15611575        -variable [itcl::scope _view(ortho)] \
    15621576        -command [itcl::code $this camera set ortho] \
     
    17371751    }
    17381752    SendCmd "polydata wireframe $props(-wireframe) $tag"
    1739     set _settings($this-opacity) [expr $props(-opacity) * 100.0]
     1753    set _volume(opacity) [expr $props(-opacity) * 100.0]
    17401754}
    17411755
     
    17561770itcl::body Rappture::VtkViewer::ReceiveLegend { colormap title vmin vmax size } {
    17571771    #puts stderr "ReceiveLegend colormap=$colormap title=$title range=$vmin,$vmax size=$size"
     1772    set _limits(vmin) $vmin
     1773    set _limits(vmax) $vmax
     1774    set _title $title
    17581775    if { [IsConnected] } {
    17591776        set bytes [ReceiveBytes $size]
     
    17621779        }
    17631780        #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
    1764         set src [image create photo -data $bytes]
    1765         blt::winop image rotate $src $_image(legend) 90
    1766         set dst $_image(legend)
     1781        set _image(legend) [image create photo -data $bytes]
    17671782        DrawLegend
    17681783    }
     
    17811796    set lineht [font metrics $itk_option(-font) -linespace]
    17821797   
    1783     if { $_settings($this-legend) } {
    1784         set x 2
     1798    if { $_settings(legend) } {
     1799        set x [expr $w - 2]
    17851800        if { [$c find withtag "legend"] == "" } {
    1786             $c create image $x [expr {$lineht+2}] -anchor nw \
    1787                 -image $_image(legend) -tags "transfunc legend"
    1788             $c create text $x 2 -anchor nw \
    1789                 -fill $itk_option(-plotforeground) -tags "zmax legend" \
     1801            $c create image $x [expr {$lineht+2}] \
     1802                -anchor ne \
     1803                -image $_image(legend) -tags "colormap legend"
     1804            $c create text $x 2 \
     1805                -anchor ne \
     1806                -fill $itk_option(-plotforeground) -tags "vmax legend" \
     1807                -font "Arial 6"
     1808            $c create text $x [expr {$h-2}] \
     1809                -anchor se \
     1810                -fill $itk_option(-plotforeground) -tags "vmin legend" \
    17901811                -font "Arial 6"
    1791             $c create text $x [expr {$h-2}] -anchor sw \
    1792                 -fill $itk_option(-plotforeground) -tags "zmin legend" \
    1793                 -font "Arial 6"
     1812            #$c bind colormap <Enter> [itcl::code $this EnterLegend %x %y]
     1813            $c bind colormap <Leave> [itcl::code $this LeaveLegend]
     1814            $c bind colormap <Motion> [itcl::code $this MotionLegend %x %y]
    17941815        }
    17951816        # Reset the item coordinates according the current size of the plot.
    1796         $c coords transfunc $x [expr {$lineht+2}]
    1797         if { $_limits(zmin) != "" } {
    1798             $c itemconfigure zmin -text [format %g $_limits(zmin)]
    1799         }
    1800         if { $_limits(zmax) != "" } {
    1801             $c itemconfigure zmax -text [format %g $_limits(zmax)]
     1817        $c coords colormap $x [expr {$lineht+2}]
     1818        if { $_limits(vmin) != "" } {
     1819            $c itemconfigure vmin -text [format %g $_limits(vmin)]
     1820        }
     1821        if { $_limits(vmax) != "" } {
     1822            $c itemconfigure vmax -text [format %g $_limits(vmax)]
    18021823        }
    18031824        $c coords zmin $x [expr {$h-2}]
     
    18051826    }
    18061827}
     1828
     1829#
     1830# EnterLegend --
     1831#
     1832itcl::body Rappture::VtkViewer::EnterLegend { x y } {
     1833    SetLegendMark $x $y
     1834}
     1835
     1836#
     1837# MotionLegend --
     1838#
     1839itcl::body Rappture::VtkViewer::MotionLegend { x y } {
     1840    Rappture::Tooltip::tooltip cancel
     1841    set c $itk_component(view)
     1842    $c delete mark
     1843    SetLegendMark $x $y
     1844}
     1845
     1846#
     1847# LeaveLegend --
     1848#
     1849itcl::body Rappture::VtkViewer::LeaveLegend { } {
     1850    Rappture::Tooltip::tooltip cancel
     1851    #set c $itk_component(view)
     1852    #$c delete mark
     1853}
     1854
     1855#
     1856# SetLegendMark --
     1857#
     1858itcl::body Rappture::VtkViewer::SetLegendMark { x y } {
     1859    set c $itk_component(view)
     1860    set w [winfo width $c]
     1861    set h [winfo height $c]
     1862   
     1863    set imgHeight [image height $_image(legend)]
     1864    set coords [$c coords colormap]
     1865    set imgX [expr $w - [image width $_image(legend)] - 2]
     1866    set imgY [expr $y - 2]
     1867
     1868    if 0 {
     1869    # Make a swatch of the selected color
     1870    set pixel [image get 0 $imgY]
     1871    set swatch [image create photo -width 20 -height 20]
     1872    $swatch puts $pixel -to 0 0 19 19
     1873    }
     1874    # Create a line over the spot
     1875    $c create line [expr $w - 27] $y [expr $w - 2] $y -fill black \
     1876        -tags "legend mark"
     1877
     1878    # Compute the value of the point
     1879    set t [expr 1.0 - (double($imgY) / double($imgHeight))]
     1880    #puts stderr "t=$t x=$x y=$y"
     1881    set value [expr $t * ($_limits(vmax) - $_limits(vmin)) + $_limits(vmin)]
     1882    set tipx [expr $x + 15]
     1883    set tipy [expr $y - 5]
     1884    #puts stderr "tipx=$tipx tipy=$tipy x=$x y=$y"
     1885    Rappture::Tooltip::text $c "$_title $value"
     1886    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy   
     1887}
Note: See TracChangeset for help on using the changeset viewer.