Changeset 3416 for trunk/gui


Ignore:
Timestamp:
Mar 2, 2013 9:11:34 PM (11 years ago)
Author:
gah
Message:

fix switching between heightmap/contour modes

Location:
trunk/gui/scripts
Files:
3 edited

Legend:

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

    r3406 r3416  
    10781078    puts $f $contents
    10791079    close $f
     1080
    10801081    $reader SetFileName $tmpfile
    10811082    $reader ReadAllScalarsOn
     
    11321133    lappend limits v [list $vmin $vmax]
    11331134    set _comp2limits($cname) $limits
    1134     $reader Delete
    11351135    file delete $tmpfile
     1136    rename $reader ""
    11361137}
    11371138
  • trunk/gui/scripts/vtkheightmapviewer.tcl

    r3413 r3416  
    941941        $_arcball quaternion $q
    942942        if {$_settings(isHeightmap) } {
    943             SendCmd "camera reset"
    944943            if { $_view(ortho)} {
    945944                SendCmd "camera mode ortho"
     
    947946                SendCmd "camera mode persp"
    948947            }
     948            SendCmd "camera reset"
     949            DoRotate
    949950        }           
    950         DoRotate
    951951        PanCamera
    952952    }
     
    10701070        $_arcball quaternion $q
    10711071        if {$_settings(isHeightmap) } {
    1072             SendCmd "camera reset"
    10731072            if { $_view(ortho)} {
    10741073                SendCmd "camera mode ortho"
     
    10761075                SendCmd "camera mode persp"
    10771076            }
     1077            SendCmd "camera reset"
     1078            DoRotate
    10781079        }
    1079         DoRotate
    10801080        PanCamera
    10811081        InitSettings axisXGrid axisYGrid axisZGrid \
     
    11721172                ypan    0
    11731173            }
    1174             SendCmd "camera reset all"
    11751174            if { $_first != "" } {
    11761175                set location [$_first hints camera]
     
    11811180            set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    11821181            $_arcball quaternion $q
    1183             DoRotate
     1182            SendCmd "camera reset"
     1183            if {$_settings(isHeightmap) } {
     1184                DoRotate
     1185            }
    11841186        }
    11851187    }
     
    15231525        "isHeightmap" {
    15241526            set bool $_settings(isHeightmap)
     1527            incr _buffering
     1528            if { $_buffering == 1 } {
     1529                set _outbuf ""
     1530            }
    15251531            if { $bool } {
    15261532                $itk_component(lighting) configure -state normal
     1533                if {$_view(ortho)} {
     1534                    SendCmd "camera mode ortho"
     1535                } else {
     1536                    SendCmd "camera mode persp"
     1537                }
    15271538            } else {
    15281539                $itk_component(lighting) configure -state disabled
     
    15621573                set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    15631574                $_arcball quaternion $q
    1564                 if {$_view(ortho)} {
    1565                     SendCmd "camera mode ortho"
    1566                 } else {
    1567                     SendCmd "camera mode persp"
    1568                 }
    15691575                SendCmd "camera orient $q"
    15701576            } else {
     
    15741580                bind $c <ButtonRelease-1> {}
    15751581                SendCmd "camera mode image"
     1582            }
     1583            incr _buffering -1
     1584            if { $_buffering == 0 } {
     1585                sendto $_outbuf
     1586                set _outbuf ""
    15761587            }
    15771588        }
     
    20502061        foreach comp [$dataobj components] {
    20512062            set tag $dataobj-$comp
    2052             set contents [ConvertToVtkData $dataobj $comp]
    2053             #set contents [$dataobj vtkdata $comp]
     2063            #set contents [ConvertToVtkData $dataobj $comp]
     2064            set contents [$dataobj vtkdata $comp]
    20542065            append bytes "$contents\n\n"
    20552066        }
     
    21382149    SendCmd "heightmap wireframe $_settings(wireframe) $tag"
    21392150    SendCmd "heightmap colormap $_currentColormap $tag"
     2151    set color [$itk_component(isolinecolor) value]
     2152    SendCmd "heightmap isolinecolor [Color2RGB $color] $tag"
    21402153}
    21412154
     
    21752188# DrawLegend --
    21762189#
    2177 #       Draws the legend in it's own canvas which resides to the right
    2178 #       of the contour plot area.
    2179 #
    2180 itcl::body Rappture::VtkHeightmapViewer::DrawLegend { name } {
     2190#       Draws the legend in the own canvas on the right side of the plot area.
     2191#
     2192itcl::body Rappture::VtkHeightmapViewer::DrawLegend { fname } {
    21812193    set c $itk_component(view)
    21822194    set w [winfo width $c]
     
    21852197    set lineht [font metrics $font -linespace]
    21862198   
    2187     if { $name == "component" } {
     2199    if { $fname == "component" } {
    21882200        set title ""
    21892201    } else {
    2190         if { [info exists _fields($name)] } {
    2191             foreach { title units } $_fields($name) break
     2202        if { [info exists _fields($fname)] } {
     2203            foreach { title units } $_fields($fname) break
    21922204            if { $units != "" } {
    21932205                set title [format "%s (%s)" $title $units]
    21942206            }
    21952207        } else {
    2196             set title $name
     2208            set title $fname
    21972209        }
    21982210    }
     
    23022314itcl::body Rappture::VtkHeightmapViewer::SetIsolineTip { x y value } {
    23032315    set c $itk_component(view)
    2304     set w [winfo width $c]
    2305     set h [winfo height $c]
    2306     set font "Arial 8"
    2307     set lineht [font metrics $font -linespace]
    2308    
    2309     if { [info exists _fields($_title)] } {
    2310         foreach { title units } $_fields($_title) break
    2311         if { $units != "" } {
    2312             set title [format "%s (%s)" $title $units]
    2313         }
    2314     } else {
    2315         set title $_title
    2316     }
    2317     set imgHeight [image height $_image(legend)]
    2318     set coords [$c coords colormap]
    2319     set imgX [expr $w - [image width $_image(legend)] - 2]
    2320     set imgY [expr $y - 2 * ($lineht + 2)]
    2321 
    23222316    .rappturetooltip configure -icon ""
    23232317
    2324     # Compute the value of the point
    2325     set tipx [expr $x + 15]
    2326     set tipy [expr $y - 5]
     2318    # Compute the position of the tip
     2319    set tx [expr $x + 15]
     2320    set ty [expr $y - 5]
    23272321    Rappture::Tooltip::text $c "Isoline $value"
    2328     Rappture::Tooltip::tooltip show $c +$tipx,+$tipy   
     2322    Rappture::Tooltip::tooltip show $c +$tx,+$ty   
    23292323}
    23302324
     
    23642358    set lineht [font metrics $font -linespace]
    23652359   
    2366     set imgHeight [image height $_image(legend)]
    2367     set coords [$c coords colormap]
    2368     set imgX [expr $w - [image width $_image(legend)] - 2]
    2369     set imgY [expr $y - 2 * ($lineht + 2)]
     2360    set ih [image height $_image(legend)]
     2361    set iy [expr $y - ($lineht + 2)]
    23702362
    23712363    if { [info exists _fields($_title)] } {
     
    23772369        set title $_title
    23782370    }
     2371    # If there's a legend title, increase the offset by the line height.
     2372    if { $title != "" } {
     2373        incr iy $lineht
     2374    }
     2375
    23792376    # Make a swatch of the selected color
    2380     if { [catch { $_image(legend) get 10 $imgY } pixel] != 0 } {
    2381         #puts stderr "out of range: $imgY"
     2377    if { [catch { $_image(legend) get 10 $iy } pixel] != 0 } {
     2378        #puts stderr "out of range: $iy"
    23822379        return
    23832380    }
     2381
    23842382    if { ![info exists _image(swatch)] } {
    23852383        set _image(swatch) [image create photo -width 24 -height 24]
     
    23932391    if { [info exists _limits(v)] } {
    23942392        foreach { vmin vmax } $_limits(v) break
    2395         set t [expr 1.0 - (double($imgY) / double($imgHeight-1))]
     2393        set t [expr 1.0 - (double($iy) / double($ih-1))]
    23962394        set value [expr $t * ($vmax - $vmin) + $vmin]
    23972395    } else {
  • trunk/gui/scripts/vtkisosurfaceviewer.tcl

    r3409 r3416  
    11821182                ypan   0
    11831183            }
    1184             SendCmd "camera reset all"
    11851184            if { $_first != "" } {
    11861185                set location [$_first hints camera]
     
    11911190            set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    11921191            $_arcball quaternion $q
     1192            SendCmd "camera reset"
    11931193            DoRotate
    11941194        }
     
    22172217    set w [winfo width $c]
    22182218    set h [winfo height $c]
     2219
    22192220    set font "Arial 8"
    22202221    set lineht [font metrics $font -linespace]
    22212222   
    2222     set imgHeight [image height $_image(legend)]
    2223     set coords [$c coords colormap]
    2224     set imgX [expr $w - [image width $_image(legend)] - 2]
    2225     set imgY [expr $y - 2 * ($lineht + 2)]
     2223    set ih [image height $_image(legend)]
     2224    set iy [expr $y - ($lineht + 2)]
    22262225
    22272226    set title ""
     
    22402239        }
    22412240    }
     2241    # If there's a legend title, increase the offset by the line height.
     2242    if { $title != "" } {
     2243        incr iy $lineht
     2244    }
     2245
    22422246    # Make a swatch of the selected color
    2243     if { [catch { $_image(legend) get 10 $imgY } pixel] != 0 } {
     2247    if { [catch { $_image(legend) get 10 $iy } pixel] != 0 } {
    22442248        return
    22452249    }
     
    22522256    .rappturetooltip configure -icon $_image(swatch)
    22532257
    2254     .rappturetooltip configure -icon $_image(swatch)
    2255 
    22562258    # Compute the value of the point
    22572259    if { [info exists _limits(vmax)] && [info exists _limits(vmin)] } {
    2258         set t [expr 1.0 - (double($imgY) / double($imgHeight-1))]
     2260        set t [expr 1.0 - (double($iy) / double($ih-1))]
    22592261        set value [expr $t * ($_limits(vmax) - $_limits(vmin)) + $_limits(vmin)]
    22602262    } else {
    22612263        set value 0.0
    22622264    }
    2263     set tipx [expr $x + 15]
    2264     set tipy [expr $y - 5]
     2265    set tx [expr $x + 15]
     2266    set ty [expr $y - 5]
    22652267    Rappture::Tooltip::text $c "$title $value"
    2266     Rappture::Tooltip::tooltip show $c +$tipx,+$tipy   
     2268    Rappture::Tooltip::tooltip show $c +$tx,+$ty   
    22672269}
    22682270
     
    23282330# DrawLegend --
    23292331#
    2330 #       Draws the legend in it's own canvas which resides to the right
    2331 #       of the contour plot area.
     2332#       Draws the legend in the own canvas on the right side of the plot area.
    23322333#
    23332334itcl::body Rappture::VtkIsosurfaceViewer::DrawLegend { name } {
     
    24552456itcl::body Rappture::VtkIsosurfaceViewer::SetIsolineTip { x y value } {
    24562457    set c $itk_component(view)
    2457     set w [winfo width $c]
    2458     set h [winfo height $c]
    2459     set font "Arial 8"
    2460     set lineht [font metrics $font -linespace]
    2461    
    2462     if { [info exists _fields($_title)] } {
    2463         foreach { title units } $_fields($_title) break
    2464         if { $title == "component" } {
    2465             set title ""
    2466         }
    2467         if { $units != "" } {
    2468             set title [format "%s (%s)" $title $units]
    2469         }
    2470     } else {
    2471         set title $_title
    2472     }
    2473     # Make a swatch of the selected color
    2474     set imgHeight [image height $_image(legend)]
    2475     set coords [$c coords colormap]
    2476     set imgX [expr $w - [image width $_image(legend)] - 2]
    2477     set imgY [expr $y - 2 * ($lineht + 2)]
    2478 
    2479     if { [catch { $_image(legend) get 10 $imgY } pixel] != 0 } {
    2480         return
    2481     }
    2482     if { ![info exists _image(swatch)] } {
    2483         set _image(swatch) [image create photo -width 24 -height 24]
    2484     }
    2485     set color [eval format "\#%02x%02x%02x" $pixel]
    2486     $_image(swatch) put black  -to 0 0 23 23
    2487     $_image(swatch) put $color -to 1 1 22 22
    2488     .rappturetooltip configure -icon $_image(swatch)
    2489 
    2490      # Compute the value of the point
    2491     set tipx [expr $x + 15]
    2492     set tipy [expr $y - 5]
     2458    .rappturetooltip configure -icon ""
     2459
     2460    # Compute the position of the tip
     2461    set tx [expr $x + 15]
     2462    set ty [expr $y - 5]
    24932463    Rappture::Tooltip::text $c "Isosurface $value"
    2494     Rappture::Tooltip::tooltip show $c +$tipx,+$tipy   
     2464    Rappture::Tooltip::tooltip show $c +$tx,+$ty   
    24952465}
    24962466
Note: See TracChangeset for help on using the changeset viewer.