Changeset 6355


Ignore:
Timestamp:
May 23, 2016, 12:07:34 PM (8 years ago)
Author:
ldelgass
Message:

Add SetCurrentFieldName? method to more vtk viewers

Location:
trunk/gui/scripts
Files:
4 edited

Legend:

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

    r6345 r6355  
    103103    private method Rotate {option x y}
    104104    private method SetCurrentColormap { color }
     105    private method SetCurrentFieldName { dataobj }
    105106    private method SetLegendTip { x y }
    106107    private method SetObjectStyle { dataobj comp }
     
    960961        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
    961962            set _first $dataobj
     963            SetCurrentFieldName $dataobj
    962964        }
    963965        foreach comp [$dataobj components] {
     
    10011003        }
    10021004    }
    1003     if { $_first != "" } {
    1004         $itk_component(field) choices delete 0 end
    1005         $itk_component(fieldmenu) delete 0 end
    1006         array unset _fields
    1007         set _curFldName ""
    1008         foreach cname [$_first components] {
    1009             foreach fname [$_first fieldnames $cname] {
    1010                 if { [info exists _fields($fname)] } {
    1011                     continue
    1012                 }
    1013                 foreach { label units components } \
    1014                     [$_first fieldinfo $fname] break
    1015                 $itk_component(field) choices insert end "$fname" "$label"
    1016                 $itk_component(fieldmenu) add radiobutton -label "$label" \
    1017                     -value $label -variable [itcl::scope _curFldLabel] \
    1018                     -selectcolor red \
    1019                     -activebackground $itk_option(-plotbackground) \
    1020                     -activeforeground $itk_option(-plotforeground) \
    1021                     -font "Arial 8" \
    1022                     -command [itcl::code $this LegendTitleAction save]
    1023                 set _fields($fname) [list $label $units $components]
    1024                 if { $_curFldName == "" } {
    1025                     set _curFldName $fname
    1026                     set _curFldLabel $label
    1027                 }
    1028             }
    1029         }
    1030         $itk_component(field) value $_curFldLabel
    1031     }
     1005
    10321006    InitSettings -stretchtofit -outline
    1033 
    10341007    if { $_reset } {
    10351008        SendCmd "axis tickpos outside"
     
    26792652    blt::vector destroy $v
    26802653}
     2654
     2655itcl::body Rappture::VtkHeightmapViewer::SetCurrentFieldName { dataobj } {
     2656    set _first $dataobj
     2657    $itk_component(field) choices delete 0 end
     2658    $itk_component(fieldmenu) delete 0 end
     2659    array unset _fields
     2660    set _curFldName ""
     2661    foreach cname [$_first components] {
     2662        foreach fname [$_first fieldnames $cname] {
     2663            if { [info exists _fields($fname)] } {
     2664                continue
     2665            }
     2666            foreach { label units components } \
     2667                [$_first fieldinfo $fname] break
     2668            $itk_component(field) choices insert end "$fname" "$label"
     2669            $itk_component(fieldmenu) add radiobutton -label "$label" \
     2670                -value $label -variable [itcl::scope _curFldLabel] \
     2671                -selectcolor red \
     2672                -activebackground $itk_option(-plotbackground) \
     2673                -activeforeground $itk_option(-plotforeground) \
     2674                -font "Arial 8" \
     2675                -command [itcl::code $this LegendTitleAction save]
     2676            set _fields($fname) [list $label $units $components]
     2677            if { $_curFldName == "" } {
     2678                set _curFldName $fname
     2679                set _curFldLabel $label
     2680            }
     2681        }
     2682    }
     2683    $itk_component(field) value $_curFldLabel
     2684}
  • trunk/gui/scripts/vtkimageviewer.tcl

    r6346 r6355  
    100100    private method Rotate {option x y}
    101101    private method SetCurrentColormap { color }
     102    private method SetCurrentFieldName { dataobj }
    102103    private method SetLegendTip { x y }
    103104    private method SetObjectStyle { dataobj comp }
     
    932933        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
    933934            set _first $dataobj
     935            SetCurrentFieldName $dataobj
    934936        }
    935937        foreach comp [$dataobj components] {
     
    968970        }
    969971    }
    970     if { $_first != ""  } {
    971         $itk_component(field) choices delete 0 end
    972         $itk_component(fieldmenu) delete 0 end
    973         array unset _fields
    974         set _curFldName ""
    975         foreach cname [$_first components] {
    976             foreach fname [$_first fieldnames $cname] {
    977                 if { [info exists _fields($fname)] } {
    978                     continue
    979                 }
    980                 foreach { label units components } \
    981                     [$_first fieldinfo $fname] break
    982                 $itk_component(field) choices insert end "$fname" "$label"
    983                 $itk_component(fieldmenu) add radiobutton -label "$label" \
    984                     -value $label -variable [itcl::scope _curFldLabel] \
    985                     -selectcolor red \
    986                     -activebackground $itk_option(-plotbackground) \
    987                     -activeforeground $itk_option(-plotforeground) \
    988                     -font "Arial 8" \
    989                     -command [itcl::code $this LegendTitleAction save]
    990                 set _fields($fname) [list $label $units $components]
    991                 if { $_curFldName == "" } {
    992                     set _curFldName $fname
    993                     set _curFldLabel $label
    994                 }
    995             }
    996         }
    997         $itk_component(field) value $_curFldLabel
    998     }
     972
    999973    InitSettings -stretchtofit -outline
    1000 
    1001974    if { $_reset } {
    1002975        SendCmd "axis tickpos outside"
     
    23272300    set _view(-zoom) 1.0
    23282301}
     2302
     2303itcl::body Rappture::VtkImageViewer::SetCurrentFieldName { dataobj } {
     2304    set _first $dataobj
     2305    $itk_component(field) choices delete 0 end
     2306    $itk_component(fieldmenu) delete 0 end
     2307    array unset _fields
     2308    set _curFldName ""
     2309    foreach cname [$_first components] {
     2310        foreach fname [$_first fieldnames $cname] {
     2311            if { [info exists _fields($fname)] } {
     2312                continue
     2313            }
     2314            foreach { label units components } \
     2315                [$_first fieldinfo $fname] break
     2316            $itk_component(field) choices insert end "$fname" "$label"
     2317            $itk_component(fieldmenu) add radiobutton -label "$label" \
     2318                -value $label -variable [itcl::scope _curFldLabel] \
     2319                -selectcolor red \
     2320                -activebackground $itk_option(-plotbackground) \
     2321                -activeforeground $itk_option(-plotforeground) \
     2322                -font "Arial 8" \
     2323                -command [itcl::code $this LegendTitleAction save]
     2324            set _fields($fname) [list $label $units $components]
     2325            if { $_curFldName == "" } {
     2326                set _curFldName $fname
     2327                set _curFldLabel $label
     2328            }
     2329        }
     2330    }
     2331    $itk_component(field) value $_curFldLabel
     2332}
  • trunk/gui/scripts/vtkstreamlinesviewer.tcl

    r6338 r6355  
    105105    private method Rotate {option x y}
    106106    private method SetCurrentColormap { color }
     107    private method SetCurrentFieldName { dataobj }
    107108    private method SetLegendTip { x y }
    108109    private method SetObjectStyle { dataobj comp }
     
    978979        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
    979980            set _first $dataobj
     981            SetCurrentFieldName $dataobj
    980982        }
    981983        foreach comp [$dataobj components] {
     
    10231025            }
    10241026        }
    1025         $itk_component(field) choices delete 0 end
    1026         $itk_component(fieldmenu) delete 0 end
    1027         array unset _fields
    1028         set _curFldName ""
    1029         set _curFldLabel ""
    1030         foreach cname [$_first components] {
    1031             foreach fname [$_first fieldnames $cname] {
    1032                 if { [info exists _fields($fname)] } {
    1033                     continue
    1034                 }
    1035                 foreach { label units components } \
    1036                     [$_first fieldinfo $fname] break
    1037                 $itk_component(field) choices insert end "$fname" "$label"
    1038                 $itk_component(fieldmenu) add radiobutton -label "$label" \
    1039                     -value $label -variable [itcl::scope _curFldLabel] \
    1040                     -selectcolor red \
    1041                     -activebackground $itk_option(-plotbackground) \
    1042                     -activeforeground $itk_option(-plotforeground) \
    1043                     -font "Arial 8" \
    1044                     -command [itcl::code $this LegendTitleAction save]
    1045                 set _fields($fname) [list $label $units $components]
    1046                 if { $_curFldName == "" && $components == 3 } {
    1047                     set _curFldName $fname
    1048                     set _curFldLabel $label
    1049                 }
    1050             }
    1051         }
    1052         $itk_component(field) value $_curFldLabel
    10531027    }
    10541028
     
    24342408    set _view(-zoom) 1.0
    24352409}
     2410
     2411itcl::body Rappture::VtkStreamlinesViewer::SetCurrentFieldName { dataobj } {
     2412    set _first $dataobj
     2413    $itk_component(field) choices delete 0 end
     2414    $itk_component(fieldmenu) delete 0 end
     2415    array unset _fields
     2416    set _curFldName ""
     2417    set _curFldLabel ""
     2418    foreach cname [$_first components] {
     2419        foreach fname [$_first fieldnames $cname] {
     2420            if { [info exists _fields($fname)] } {
     2421                continue
     2422            }
     2423            foreach { label units components } \
     2424                [$_first fieldinfo $fname] break
     2425            $itk_component(field) choices insert end "$fname" "$label"
     2426            $itk_component(fieldmenu) add radiobutton -label "$label" \
     2427                -value $label -variable [itcl::scope _curFldLabel] \
     2428                -selectcolor red \
     2429                -activebackground $itk_option(-plotbackground) \
     2430                -activeforeground $itk_option(-plotforeground) \
     2431                -font "Arial 8" \
     2432                -command [itcl::code $this LegendTitleAction save]
     2433            set _fields($fname) [list $label $units $components]
     2434            if { $_curFldName == "" && $components == 3 } {
     2435                set _curFldName $fname
     2436                set _curFldLabel $label
     2437            }
     2438        }
     2439    }
     2440    $itk_component(field) value $_curFldLabel
     2441}
  • trunk/gui/scripts/vtkvolumeviewer.tcl

    r6338 r6355  
    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 }
     
    10171018        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
    10181019            set _first $dataobj
     1020            SetCurrentFieldName $dataobj
    10191021        }
    10201022        foreach cname [$dataobj components] {
     
    10631065            }
    10641066        }
    1065         $itk_component(field) choices delete 0 end
    1066         $itk_component(fieldmenu) delete 0 end
    1067         array unset _fields
    1068         set _curFldName ""
    1069         foreach cname [$_first components] {
    1070             foreach fname [$_first fieldnames $cname] {
    1071                 if { [info exists _fields($fname)] } {
    1072                     continue
    1073                 }
    1074                 foreach { label units components } \
    1075                     [$_first fieldinfo $fname] break
    1076                 # Only scalar fields are valid
    1077                 if {$_allowMultiComponent || $components == 1} {
    1078                     $itk_component(field) choices insert end "$fname" "$label"
    1079                     $itk_component(fieldmenu) add radiobutton -label "$label" \
    1080                         -value $label -variable [itcl::scope _curFldLabel] \
    1081                         -selectcolor red \
    1082                         -activebackground $itk_option(-plotbackground) \
    1083                         -activeforeground $itk_option(-plotforeground) \
    1084                         -font "Arial 8" \
    1085                         -command [itcl::code $this LegendTitleAction save]
    1086                     set _fields($fname) [list $label $units $components]
    1087                     if { $_curFldName == "" } {
    1088                         set _curFldName $fname
    1089                         set _curFldLabel $label
    1090                     }
    1091                 }
    1092             }
    1093         }
    1094         $itk_component(field) value $_curFldLabel
    10951067    }
    10961068
     
    28642836    return [ColorsToColormap $color]
    28652837}
     2838
     2839itcl::body Rappture::VtkVolumeViewer::SetCurrentFieldName { dataobj } {
     2840    set _first $dataobj
     2841    $itk_component(field) choices delete 0 end
     2842    $itk_component(fieldmenu) delete 0 end
     2843    array unset _fields
     2844    set _curFldName ""
     2845    foreach cname [$_first components] {
     2846        foreach fname [$_first fieldnames $cname] {
     2847            if { [info exists _fields($fname)] } {
     2848                continue
     2849            }
     2850            foreach { label units components } \
     2851                [$_first fieldinfo $fname] break
     2852            # Only scalar fields are valid
     2853            if {$_allowMultiComponent || $components == 1} {
     2854                $itk_component(field) choices insert end "$fname" "$label"
     2855                $itk_component(fieldmenu) add radiobutton -label "$label" \
     2856                    -value $label -variable [itcl::scope _curFldLabel] \
     2857                    -selectcolor red \
     2858                    -activebackground $itk_option(-plotbackground) \
     2859                    -activeforeground $itk_option(-plotforeground) \
     2860                    -font "Arial 8" \
     2861                    -command [itcl::code $this LegendTitleAction save]
     2862                set _fields($fname) [list $label $units $components]
     2863                if { $_curFldName == "" } {
     2864                    set _curFldName $fname
     2865                    set _curFldLabel $label
     2866                }
     2867            }
     2868        }
     2869    }
     2870    $itk_component(field) value $_curFldLabel
     2871}
Note: See TracChangeset for help on using the changeset viewer.