Ignore:
Timestamp:
Oct 26, 2011, 8:44:43 AM (13 years ago)
Author:
gah
Message:

add menu for additional fields in streamlines widget

File:
1 edited

Legend:

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

    r2632 r2649  
    9393    private method ConvertToVtkData { dataobj comp }
    9494    private method DrawLegend { title }
     95    private method Combo { option }
    9596    private method EnterLegend { x y }
    9697    private method EventuallyResize { w h }
     
    152153    private variable _fields
    153154    private variable _currentField ""
     155    private variable _field      ""
    154156    private variable _numSeeds 200
    155157    private variable _colorMode "vmag";#  Mode of colormap (vmag or scalar)
     
    273275    }
    274276
     277    itk_component add fieldmenu {
     278        menu $itk_component(plotarea).menu -bg black -fg white -relief flat \
     279            -tearoff no
     280    } {
     281        usual
     282        ignore -background -foreground -relief -tearoff
     283    }
    275284    set c $itk_component(view)
    276285    bind $c <Configure> [itcl::code $this EventuallyResize %w %h]
     
    10371046        set _currentField [$_first hints default]
    10381047        $itk_component(field) choices delete 0 end
     1048        $itk_component(fieldmenu) delete 0 end
    10391049        array unset _fields
    10401050        foreach { name title units } [$_first hints vectors] {
    10411051            set _vectorFields($title) $name
    10421052            $itk_component(field) choices insert end "$name" "$title"
     1053            $itk_component(fieldmenu) add radiobutton -label "$title" \
     1054                -value $title -variable [itcl::scope _currentField] \
     1055                -selectcolor red \
     1056                -activebackground black \
     1057                -activeforeground white \
     1058                -font "Arial 8" \
     1059                -command [itcl::code $this Combo invoke]
    10431060            set _fields($name) [list $title $units]
    10441061        }
     
    10461063            set _scalarFields($title) $name
    10471064            $itk_component(field) choices insert end "$name" "$title"
     1065            $itk_component(fieldmenu) add radiobutton -label "$title" \
     1066                -value $title -variable [itcl::scope _currentField] \
     1067                -selectcolor red \
     1068                -activebackground black \
     1069                -activeforeground white \
     1070                -font "Arial 8" \
     1071                -command [itcl::code $this Combo invoke]
    10481072            set _fields($name) [list $title $units]
    10491073        }
     
    14971521            }
    14981522            foreach dataset [CurrentDatasets -visible] {
     1523                puts stderr "streamlines colormode $_colorMode ${name} $dataset"
     1524                puts stderr "cutplane colormode $_colorMode ${name} $dataset"
    14991525                SendCmd "streamlines colormode $_colorMode ${name} $dataset"
    15001526                SendCmd "cutplane colormode $_colorMode ${name} $dataset"
     
    25132539# ----------------------------------------------------------------------
    25142540itcl::body Rappture::VtkStreamlinesViewer::ReceiveLegend { colormap title vmin vmax size } {
    2515     #puts stderr "ReceiveLegend colormap=$colormap title=$title range=$vmin,$vmax size=$size"
     2541    puts stderr "ReceiveLegend colormap=$colormap title=$title range=$vmin,$vmax size=$size"
    25162542    set _limits(vmin) $vmin
    25172543    set _limits(vmax) $vmax
     
    25252551        $_image(legend) configure -data $bytes
    25262552        #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
    2527         DrawLegend $_title
     2553        if { [catch {DrawLegend $_title} errs] != 0 } {
     2554            puts stderr errs=$errs
     2555        }
    25282556    }
    25292557}
     
    25752603            $c bind colormap <Motion> [itcl::code $this MotionLegend %x %y]
    25762604        }
     2605        $c bind title <ButtonPress> [itcl::code $this Combo post]
     2606        $c bind title <Enter> [itcl::code $this Combo activate]
     2607        $c bind title <Leave> [itcl::code $this Combo deactivate]
    25772608        # Reset the item coordinates according the current size of the plot.
    25782609        $c itemconfigure title -text $title
     
    26972728    }
    26982729}
     2730
     2731
     2732# ----------------------------------------------------------------------
     2733# USAGE: _dropdown post
     2734# USAGE: _dropdown unpost
     2735# USAGE: _dropdown select
     2736#
     2737# Used internally to handle the dropdown list for this combobox.  The
     2738# post/unpost options are invoked when the list is posted or unposted
     2739# to manage the relief of the controlling button.  The select option
     2740# is invoked whenever there is a selection from the list, to assign
     2741# the value back to the gauge.
     2742# ----------------------------------------------------------------------
     2743itcl::body Rappture::VtkStreamlinesViewer::Combo {option} {
     2744    set c $itk_component(view)
     2745    switch -- $option {
     2746        post {
     2747            foreach { x1 y1 x2 y2 } [$c bbox title] break
     2748            set x1 [expr [winfo width $itk_component(view)] - [winfo reqwidth $itk_component(fieldmenu)]]
     2749            set x [expr $x1 + [winfo rootx $itk_component(view)]]
     2750            set y [expr $y2 + [winfo rooty $itk_component(view)]]
     2751            puts stderr "combo x=$x y=$y"
     2752            $itk_component(fieldmenu) post $x $y
     2753        }
     2754        activate {
     2755            $c itemconfigure title -fill red
     2756        }
     2757        deactivate {
     2758            $c itemconfigure title -fill white
     2759        }
     2760        invoke {
     2761            $itk_component(field) value $_currentField
     2762            AdjustSetting streamlines-field
     2763        }
     2764        default {
     2765            error "bad option \"$option\": should be post, unpost, select"
     2766        }
     2767    }
     2768}
     2769
     2770
     2771
     2772
     2773
     2774
     2775
     2776
     2777
     2778
     2779
     2780
     2781
     2782
Note: See TracChangeset for help on using the changeset viewer.