Changeset 6364 for branches/1.7


Ignore:
Timestamp:
May 24, 2016, 8:28:53 AM (8 years ago)
Author:
ldelgass
Message:

Merge fixes from trunk/1.6 branch

Location:
branches/1.7
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • branches/1.7

  • branches/1.7/gui/scripts/flowvisviewer.tcl

    r6306 r6364  
    696696        if { $pos >= 0 } {
    697697            set _dlist [lreplace $_dlist $pos $pos]
    698             array unset _limits $dataobj-*
    699698            array unset _obj2ovride $dataobj-*
    700             array unset _dataset2flow $dataobj-*
    701             array unset _serverDatasets $dataobj-*
    702             array unset _dataset2style $dataobj-*
    703699            set changed 1
    704700        }
     
    706702    # If anything changed, then rebuild the plot
    707703    if {$changed} {
    708         # Repair the reverse lookup
    709         foreach tf [array names _style2datasets] {
    710             set list {}
    711             foreach {dataobj cname} $_style2datasets($tf) {
    712                 if { [info exists _serverDatasets($dataobj-$cname)] } {
    713                     lappend list $dataobj $cname
    714                 }
    715             }
    716             if { $list == "" } {
    717                 array unset _style2datasets $tf
    718             } else {
    719                 set _style2datasets($tf) $list
    720             }
    721         }
    722704        $_dispatcher event -idle !rebuild
    723705    }
     
    11371119        DoResize
    11381120    }
    1139 
     1121    if { $_reset } {
     1122        InitSettings -background -axesvisible -gridvisible
     1123    }
    11401124    set _first ""
    11411125    foreach dataobj [get] {
     
    11831167
    11841168    # Reset the camera and other view parameters
    1185     InitSettings -axesvisible -gridvisible \
    1186         -opacity -light2side -isosurfaceshading \
     1169    InitSettings -opacity -light2side -isosurfaceshading \
    11871170        -light \
    11881171        -volume -outlinevisible -cutplanesvisible \
     
    28552838    radiobutton $inner.image_button -text "Image File" \
    28562839        -variable [itcl::scope _downloadPopup(format)] \
    2857         -font "Arial 9 " \
     2840        -font "Arial 9" \
    28582841        -value image
    28592842    Rappture::Tooltip::for $inner.image_button \
  • branches/1.7/gui/scripts/mesh.tcl

    r5679 r6364  
    211211        set result [ReadUnstructuredGrid $path]
    212212    } elseif {[$_mesh element "node"] != "" && [$_mesh element "element"] != ""} {
     213        puts stderr "WARNING: <node>/<element> mesh is deprecated.  Please use an unstructured mesh instead."
    213214        set result [ReadNodesElements $path]
    214215    }
     
    14381439    array set node2celltype {
    14391440        3 5
    1440         4 10
     1441        4 9
    14411442        8 12
    14421443        6 13
     
    14521453        set numNodes [llength $nodeList]
    14531454        if { ![info exists node2celltype($numNodes)] } {
    1454             puts stderr "WARNING: bad nodes/elements mesh \$path\": unknown number of indices \"$_numNodes\": should be 3, 4, 5, 6, or 8"
     1455            puts stderr "WARNING: bad node/element mesh \$path\": unknown number of nodes \"$numNodes\": should be 3, 4, 5, 6, or 8"
    14551456            return 0
    14561457        }
    14571458        set celltype $node2celltype($numNodes)
     1459        if { $_dim == 3 && $numNodes == 4 } {
     1460            # If mesh is 3D, assume a tetrahedron (default is quad)
     1461            # XXX: Does prophet output tets, and if so what is the node order?
     1462            set celltype 10
     1463        }
    14581464        append celltypes "$celltype\n"
    1459         if { $celltype == 12 } {
    1460             # Formerly used voxels instead of hexahedrons. We're converting
    1461             # it here to be backward compatible and still fault-tolerant of
    1462             # non-axis aligned cells.
     1465        if { $celltype == 9 } {
     1466            # Fix the node order for quad cells
     1467            # (this converts from PROPHET convention to VTK convention)
     1468            set newList {}
     1469            foreach i { 0 1 3 2 } {
     1470                lappend newList [lindex $nodeList $i]
     1471            }
     1472            set nodeList $newList
     1473        } elseif { $celltype == 12 } {
     1474            # Fix the node order for hexahedron cells
     1475            # (this converts from PROPHET convention to VTK convention)
    14631476            set newList {}
    14641477            foreach i { 0 1 3 2 4 5 7 6 } {
  • branches/1.7/gui/scripts/nanovisviewer.tcl

    r6310 r6364  
    502502        if { $pos >= 0 } {
    503503            set _dlist [lreplace $_dlist $pos $pos]
    504             # Don't remove the limits settings because we're not really
    505             # deleting the volume, just hiding it.
    506             #array unset _limits $dataobj*
    507504            array unset _obj2ovride $dataobj-*
    508505            set changed 1
     
    943940        DoResize
    944941    }
    945 
     942    if { $_reset } {
     943        InitSettings -background -axesvisible -gridvisible
     944    }
    946945    foreach dataobj [get] {
    947946        foreach cname [$dataobj components] {
     
    10081007        }
    10091008
    1010         InitSettings -axesvisible -gridvisible \
    1011             -light2side -isosurfaceshading -opacity \
     1009        InitSettings -opacity -light2side -isosurfaceshading \
    10121010            -light \
    10131011            -xcutplanevisible -ycutplanevisible -zcutplanevisible
     
    21342132    radiobutton $inner.image_button -text "Image File" \
    21352133        -variable [itcl::scope _downloadPopup(format)] \
    2136         -font "Arial 9 " \
     2134        -font "Arial 9" \
    21372135        -value image
    21382136    Rappture::Tooltip::for $inner.image_button \
  • branches/1.7/gui/scripts/probdisteditor.tcl

    r5192 r6364  
    1919option add *ProbDistEditor*Entry.width 10 widgetDefault
    2020
    21     itcl::class Rappture::ProbDistEditor {
     21itcl::class Rappture::ProbDistEditor {
    2222    inherit itk::Widget
    2323
    2424    itk_option define -fillcolor fillColor FillColor ""
    2525
    26     constructor {args} { # defined below }
     26    constructor {args} {
     27        # defined below
     28    }
    2729    public method value {{newval ""}}
    2830    public method mode {{newval ""}}
     
    3335    protected method _apply {op {widget ""}}
    3436
    35     protected variable _dispatcher ""   ;# dispatcher for !events
    36     protected variable _mode ""         ;# type of distribution function
    37     protected variable _value           ;# data values for mode-detail
    38     protected variable _uvalue          ;# data values for mode-detail with units
    39     protected variable _umin             ;# minimum allowed value for tool with units
    40     protected variable _umax             ;# maximum allowed value for tool with units
    41     protected variable _units           ;# units for min and max
     37    protected variable _dispatcher ""# dispatcher for !events
     38    protected variable _mode "";        # type of distribution function
     39    protected variable _value;          # data values for mode-detail
     40    protected variable _uvalue;         # data values for mode-detail with units
     41    protected variable _umin;           # minimum allowed value for tool with units
     42    protected variable _umax;           # maximum allowed value for tool with units
     43    protected variable _units;          # units for min and max
    4244}
    4345
  • branches/1.7/gui/scripts/visviewer.tcl

    r6306 r6364  
    2020    itk_option define -receivecommand receiveCommand ReceiveCommand ""
    2121
    22     private common _servers;            # array of visualization server lists
    23     set _servers(nanovis) "localhost:2000"
    24     set _servers(pymol)   "localhost:2020"
    25     set _servers(vmdmds)  "localhost:2018"
    26     set _servers(vtkvis)  "localhost:2010"
    27 
    28     private common _done;               # Used to indicate status of send.
    29     private variable _buffer;           # buffer for incoming/outgoing commands
    30     private variable _outbuf;           # buffer for outgoing commands
    31     private variable _blockOnWrite 0;   # Should writes to socket block?
    32     private variable _initialized
    33     private variable _isOpen 0
    34     private variable _afterId -1
    35     private variable _icon 0
    36     private variable _trace 0;          # Protocol tracing for console
    37     private variable _logging 0;        # Command logging to file
    38     # Number of milliseconds to wait before idle timeout.  If greater than 0,
    39     # automatically disconnect from the visualization server when idle timeout
    40     # is reached.
    41     private variable _idleTimeout 43200000; # 12 hours
    42     #private variable _idleTimeout 5000;# 5 seconds
    43     #private variable _idleTimeout 0;   # No timeout
    44 
    45     protected variable _debug 0
    46     protected variable _serverType "???";# Type of server.
    47     protected variable _sid "";         # socket connection to server
    48     protected variable _maxConnects 100
    49     protected variable _buffering 0
    50     protected variable _cmdSeq 0;       # Command sequence number
    51     protected variable _dispatcher "";  # dispatcher for !events
    52     protected variable _hosts "";       # list of hosts for server
    53     protected variable _parser "";      # interpreter for incoming commands
    54     protected variable _image
    55     protected variable _hostname
    56     protected variable _numConnectTries 0
    57     protected variable _debugConsole 0
    58     protected variable _reportClientInfo 1
    59     # Number of milliscends to wait for server reply before displaying wait
    60     # dialog.  If set to 0, dialog is never displayed.
    61     protected variable _waitTimeout 0
    62 
    6322    constructor { args } {
    6423        # defined below
     
    6726        # defined below
    6827    }
    69     # Used internally only.
    70     private method BuildConsole {}
    71     private method DebugConsole {}
    72     private method HideConsole {}
    73     private method ReceiveHelper {}
    74     private method SendDebugCommand {}
    75     private method SendHelper {}
    76     private method ServerDown {}
    77     private method Shuffle { servers }
    78     private method TraceComm { channel {data {}} }
    79     private method WaitDialog { state }
    80     private method Waiting { option widget }
     28    public proc GetServerList { type } {
     29        return $_servers($type)
     30    }
     31    public proc SetServerList { type namelist } {
     32        # Convert the comma separated list into a Tcl list.  OGRE also adds
     33        # a trailing comma that we want to ignore.
     34        regsub -all "," $namelist " " namelist
     35        CheckNameList $namelist
     36        set _servers($type) $namelist
     37    }
     38    public proc RemoveServerFromList { type server } {
     39        if { ![info exists _servers($type)] } {
     40            error "unknown server type \"$type\""
     41        }
     42        set i [lsearch $_servers($type) $server]
     43        if { $i < 0 } {
     44            return
     45        }
     46        set _servers($type) [lreplace $_servers($type) $i $i]
     47    }
     48    public proc SetPymolServerList { namelist } {
     49        SetServerList "pymol" $namelist
     50    }
     51    public proc SetNanovisServerList { namelist } {
     52        SetServerList "nanovis" $namelist
     53    }
     54    public proc SetVtkServerList { namelist } {
     55        SetServerList "vtk" $namelist
     56    }
    8157
    8258    protected method CheckConnection {}
     
    11692    protected method ToggleConsole {}
    11793
     94    protected variable _debug 0
     95    protected variable _serverType "???";# Type of server.
     96    protected variable _sid "";         # socket connection to server
     97    protected variable _maxConnects 100
     98    protected variable _buffering 0
     99    protected variable _cmdSeq 0;       # Command sequence number
     100    protected variable _dispatcher "";  # dispatcher for !events
     101    protected variable _hosts "";       # list of hosts for server
     102    protected variable _parser "";      # interpreter for incoming commands
     103    protected variable _image
     104    protected variable _hostname
     105    protected variable _numConnectTries 0
     106    protected variable _debugConsole 0
     107    protected variable _reportClientInfo 1
     108    # Number of milliscends to wait for server reply before displaying wait
     109    # dialog.  If set to 0, dialog is never displayed.
     110    protected variable _waitTimeout 0
     111
     112    private method BuildConsole {}
     113    private method DebugConsole {}
     114    private method HideConsole {}
     115    private method ReceiveHelper {}
     116    private method SendDebugCommand {}
     117    private method SendHelper {}
     118    private method ServerDown {}
     119    private method Shuffle { servers }
     120    private method TraceComm { channel {data {}} }
     121    private method WaitDialog { state }
     122    private method Waiting { option widget }
     123
    118124    private proc CheckNameList { namelist }  {
    119125        foreach host $namelist {
     
    124130        }
    125131    }
    126     public proc GetServerList { type } {
    127         return $_servers($type)
    128     }
    129     public proc SetServerList { type namelist } {
    130         # Convert the comma separated list into a Tcl list.  OGRE also adds
    131         # a trailing comma that we want to ignore.
    132         regsub -all "," $namelist " " namelist
    133         CheckNameList $namelist
    134         set _servers($type) $namelist
    135     }
    136     public proc RemoveServerFromList { type server } {
    137         if { ![info exists _servers($type)] } {
    138             error "unknown server type \"$type\""
    139         }
    140         set i [lsearch $_servers($type) $server]
    141         if { $i < 0 } {
    142             return
    143         }
    144         set _servers($type) [lreplace $_servers($type) $i $i]
    145     }
    146     public proc SetPymolServerList { namelist } {
    147         SetServerList "pymol" $namelist
    148     }
    149     public proc SetNanovisServerList { namelist } {
    150         SetServerList "nanovis" $namelist
    151     }
    152     public proc SetVtkServerList { namelist } {
    153         SetServerList "vtk" $namelist
    154     }
     132
     133    private variable _buffer;           # buffer for incoming/outgoing commands
     134    private variable _outbuf;           # buffer for outgoing commands
     135    private variable _blockOnWrite 0;   # Should writes to socket block?
     136    private variable _initialized
     137    private variable _isOpen 0
     138    private variable _afterId -1
     139    private variable _icon 0
     140    private variable _trace 0;          # Protocol tracing for console
     141    private variable _logging 0;        # Command logging to file
     142    # Number of milliseconds to wait before idle timeout.  If greater than 0,
     143    # automatically disconnect from the visualization server when idle timeout
     144    # is reached.
     145    private variable _idleTimeout 43200000; # 12 hours
     146    #private variable _idleTimeout 5000;# 5 seconds
     147    #private variable _idleTimeout 0;   # No timeout
     148
     149    private common _servers;            # array of visualization server lists
     150    set _servers(nanovis) "localhost:2000"
     151    set _servers(pymol)   "localhost:2020"
     152    set _servers(vmdmds)  "localhost:2018"
     153    set _servers(vtkvis)  "localhost:2010"
     154    private common _done;               # Used to indicate status of send.
    155155}
    156156
     
    863863                -xscrollmode auto -yscrollmode auto
    864864            text $inner.scrl.text \
    865                 -font "Arial 9 " -background white -relief sunken -bd 1 \
     865                -font "Arial 9" -background white -relief sunken -bd 1 \
    866866                -height 5 -wrap word -width 60
    867867            $inner.scrl contents $inner.scrl.text
  • branches/1.7/gui/scripts/vtkglyphviewer.tcl

    r6306 r6364  
    102102    private method ReceiveDataset { args }
    103103    private method ReceiveImage { args }
    104     private method ReceiveLegend { colormap title vmin vmax size }
     104    private method ReceiveLegend { colormap title min max size }
    105105    private method RequestLegend {}
    106106    private method Rotate {option x y}
     
    151151    private variable _rotatePending 0
    152152    private variable _cutplanePending 0
    153     private variable _field      ""
    154     private variable _colorMode "vmag"; # Mode of colormap (vmag or scalar)
    155153    private variable _fields
    156154    private variable _curFldName ""
    157155    private variable _curFldLabel ""
    158156    private variable _curFldComp 3
     157    private variable _colorMode "vmag"; # Mode of colormap (vmag or scalar)
    159158    private variable _mouseOver "";     # what called LegendRangeAction:
    160159                                        # vmin or vmax
     
    627626        set _dlist [lreplace $_dlist $pos $pos]
    628627        array unset _obj2ovride $dataobj-*
    629         array unset _settings $dataobj-*
    630628        set changed 1
    631629    }
     
    13201318itcl::body Rappture::VtkGlyphViewer::InitSettings { args } {
    13211319    foreach spec $args {
    1322         if { [info exists _settings($_first${spec})] } {
    1323             # Reset global setting with dataobj specific setting
    1324             set _settings($spec) $_settings($_first${spec})
    1325         }
    13261320        AdjustSetting $spec
    13271321    }
     
    22102204                    SendCmd "camera zoom $_view($what)"
    22112205                }
    2212              }
     2206            }
    22132207        }
    22142208    }
     
    22442238    radiobutton $inner.vtk_button -text "VTK data file" \
    22452239        -variable [itcl::scope _downloadPopup(format)] \
    2246         -font "Arial 9 " \
     2240        -font "Arial 9" \
    22472241        -value vtk
    22482242    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
    22492243    radiobutton $inner.image_button -text "Image File" \
    22502244        -variable [itcl::scope _downloadPopup(format)] \
    2251         -font "Arial 9 " \
     2245        -font "Arial 9" \
    22522246        -value image
    22532247    Rappture::Tooltip::for $inner.image_button \
  • branches/1.7/gui/scripts/vtkheightmapviewer.tcl

    r6306 r6364  
    7171    private method BuildDownloadPopup { widget command }
    7272    private method CameraReset {}
    73     private method Combo { option }
    7473    private method Connect {}
    7574    private method CurrentDatasets {args}
     
    8887    private method IsValidObject { dataobj }
    8988    private method LeaveLegend {}
     89    private method LegendTitleAction { option }
    9090    private method MotionLegend { x y }
    9191    private method Pan {option x y}
     
    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 }
     
    214215
    215216    array set _settings {
    216         -axisflymode            "static"
     217        -axesvisible            1
    217218        -axislabels             1
    218219        -axisminorticks         1
    219         -axisvisible            1
     220        -axismode               "static"
    220221        -colormap               BCGYR
    221222        -colormapdiscrete       0
     
    243244    array set _changed {
    244245        -colormap               0
     246        -colormapdiscrete       0
     247        -colormapvisible        0
     248        -edges                  0
     249        -isolinecolor           0
     250        -isolinesvisible        0
    245251        -numisolines            0
    246252        -opacity                0
     253        -wireframe              0
    247254    }
    248255    itk_component add view {
     
    255262
    256263    itk_component add fieldmenu {
    257         menu $itk_component(plotarea).menu \
    258             -relief flat \
    259             -tearoff 0
     264        menu $itk_component(plotarea).menu -relief flat -tearoff 0
    260265    } {
    261266        usual
     
    286291    }
    287292    pack $itk_component(reset) -side top -padx 2 -pady { 2 0 }
    288     Rappture::Tooltip::for $itk_component(reset) "Reset the view to the default zoom level"
     293    Rappture::Tooltip::for $itk_component(reset) \
     294        "Reset the view to the default zoom level"
    289295
    290296    itk_component add zoomin {
     
    520526        set _dlist [lreplace $_dlist $pos $pos]
    521527        array unset _obj2ovride $dataobj-*
    522         array unset _settings $dataobj-*
    523528        set changed 1
    524529    }
     
    917922        # Reset the camera and other view parameters
    918923        #
    919         InitSettings -isheightmap -background
     924        InitSettings -isheightmap -background \
     925            -xgrid -ygrid -zgrid -axismode \
     926            -axesvisible -axislabels -axisminorticks
    920927
    921928        # Setting a custom exponent and label format for axes is causing
     
    930937        #SendCmd "axis exp 0 0 0 1"
    931938
     939        SendCmd "axis tickpos outside"
    932940        SendCmd "axis lrot z 90"
    933941        $_arcball quaternion [ViewToQuaternion]
     
    954962        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
    955963            set _first $dataobj
     964            SetCurrentFieldName $dataobj
    956965        }
    957966        foreach comp [$dataobj components] {
     
    9951004        }
    9961005    }
    997     if { $_first != "" } {
    998         $itk_component(field) choices delete 0 end
    999         $itk_component(fieldmenu) delete 0 end
    1000         array unset _fields
    1001         set _curFldName ""
    1002         foreach cname [$_first components] {
    1003             foreach fname [$_first fieldnames $cname] {
    1004                 if { [info exists _fields($fname)] } {
    1005                     continue
    1006                 }
    1007                 foreach { label units components } \
    1008                     [$_first fieldinfo $fname] break
    1009                 $itk_component(field) choices insert end "$fname" "$label"
    1010                 $itk_component(fieldmenu) add radiobutton -label "$label" \
    1011                     -value $label -variable [itcl::scope _curFldLabel] \
    1012                     -selectcolor red \
    1013                     -activebackground $itk_option(-plotbackground) \
    1014                     -activeforeground $itk_option(-plotforeground) \
    1015                     -font "Arial 8" \
    1016                     -command [itcl::code $this Combo invoke]
    1017                 set _fields($fname) [list $label $units $components]
    1018                 if { $_curFldName == "" } {
    1019                     set _curFldName $fname
    1020                     set _curFldLabel $label
    1021                 }
    1022             }
    1023         }
    1024         $itk_component(field) value $_curFldLabel
    1025     }
     1006
    10261007    InitSettings -stretchtofit -outline
    1027 
    10281008    if { $_reset } {
    1029         SendCmd "axis tickpos outside"
    1030         #SendCmd "axis lformat all %g"
    1031 
    10321009        foreach axis { x y z } {
    10331010            set label ""
     
    10861063        }
    10871064        PanCamera
    1088         InitSettings -xgrid -ygrid -zgrid \
    1089             -axisvisible -axislabels -heightmapscale -field -isheightmap \
    1090             -numisolines
     1065        InitSettings -heightmapscale -field -isheightmap -numisolines
    10911066        if { [array size _fields] < 2 } {
    10921067            catch {blt::table forget $itk_component(field) $itk_component(field_l)}
     
    13281303itcl::body Rappture::VtkHeightmapViewer::InitSettings { args } {
    13291304    foreach spec $args {
    1330         if { [info exists _settings($_first${spec})] } {
    1331             # Reset global setting with dataobj specific setting
    1332             set _settings($spec) $_settings($_first${spec})
    1333         }
    13341305        AdjustSetting $spec
    13351306    }
     
    13481319    }
    13491320    switch -- $what {
    1350         "-axisflymode" {
    1351             set mode [$itk_component(axisflymode) value]
    1352             set mode [$itk_component(axisflymode) translate $mode]
    1353             set _settings($what) $mode
    1354             SendCmd "axis flymode $mode"
     1321        "-axesvisible" {
     1322            set bool $_settings($what)
     1323            SendCmd "axis visible all $bool"
    13551324        }
    13561325        "-axislabels" {
     
    13621331            SendCmd "axis minticks all $bool"
    13631332        }
    1364         "-axisvisible" {
    1365             set bool $_settings($what)
    1366             SendCmd "axis visible all $bool"
     1333        "-axismode" {
     1334            set mode [$itk_component(axismode) value]
     1335            set mode [$itk_component(axismode) translate $mode]
     1336            set _settings($what) $mode
     1337            SendCmd "axis flymode $mode"
    13671338        }
    13681339        "-background" {
     
    13881359            if { $color == "none" } {
    13891360                if { $_settings(-colormapvisible) } {
     1361                    set _changed(-colormapvisible) 1
    13901362                    SendCmd "heightmap surface 0"
    13911363                    set _settings(-colormapvisible) 0
     
    13931365            } else {
    13941366                if { !$_settings(-colormapvisible) } {
     1367                    set _changed(-colormapvisible) 1
    13951368                    SendCmd "heightmap surface 1"
    13961369                    set _settings(-colormapvisible) 1
     
    14051378            EventuallyRequestLegend
    14061379        }
    1407         "-colormapvisible" {
    1408             set bool $_settings($what)
    1409             SendCmd "heightmap surface $bool"
    1410         }
    14111380        "-colormapdiscrete" {
     1381            set _changed($what) 1
    14121382            set bool $_settings($what)
    14131383            set numColors [expr $_settings(-numisolines) + 1]
     
    14251395            EventuallyRequestLegend
    14261396        }
     1397        "-colormapvisible" {
     1398            set _changed($what) 1
     1399            set bool $_settings($what)
     1400            SendCmd "heightmap surface $bool"
     1401        }
    14271402        "-edges" {
     1403            set _changed($what) 1
    14281404            set bool $_settings($what)
    14291405            SendCmd "heightmap edges $bool"
     
    15711547        }
    15721548        "-isolinecolor" {
     1549            set _changed($what) 1
    15731550            set color [$itk_component(isolinecolor) value]
    15741551            if { $color == "none" } {
    15751552                if { $_settings(-isolinesvisible) } {
     1553                    set _changed(-isolinesvisible) 1
    15761554                    SendCmd "heightmap isolines 0"
    15771555                    set _settings(-isolinesvisible) 0
    15781556                }
    15791557            } else {
     1558                set _settings($what) $color
    15801559                if { !$_settings(-isolinesvisible) } {
     1560                    set _changed(-isolinesvisible) 1
    15811561                    SendCmd "heightmap isolines 1"
    15821562                    set _settings(-isolinesvisible) 1
     
    15871567        }
    15881568        "-isolinesvisible" {
     1569            set _changed($what) 1
    15891570            set bool $_settings($what)
     1571            set color [$itk_component(isolinecolor) value]
     1572            if { $bool && $color != $_settings(-isolinecolor)} {
     1573                $itk_component(isolinecolor) value $_settings(-isolinecolor)
     1574            }
    15901575            SendCmd "heightmap isolines $bool"
    15911576            DrawLegend
     
    16311616        }
    16321617        "-outline" {
     1618            set _changed($what) 1
    16331619            if { $_settings(-isheightmap) } {
    16341620                SendCmd "outline visible 0"
     
    16541640        }
    16551641        "-wireframe" {
     1642            set _changed($what) 1
    16561643            set bool $_settings($what)
    16571644            SendCmd "heightmap wireframe $bool"
     
    17141701        set cmap $_currentColormap
    17151702        if { ![info exists _colormaps($cmap)] } {
    1716            BuildColormap $cmap
    1717            set _colormaps($cmap) 1
     1703            BuildColormap $cmap
     1704            set _colormaps($cmap) 1
    17181705        }
    17191706        #SendCmd "legend $cmap scalar $_curFldName {} $w $h 0"
     
    20312018    checkbutton $inner.visible \
    20322019        -text "Axes" \
    2033         -variable [itcl::scope _settings(-axisvisible)] \
    2034         -command [itcl::code $this AdjustSetting -axisvisible] \
     2020        -variable [itcl::scope _settings(-axesvisible)] \
     2021        -command [itcl::code $this AdjustSetting -axesvisible] \
    20352022        -font "Arial 9"
    20362023    checkbutton $inner.labels \
     
    20632050    label $inner.mode_l -text "Mode" -font "Arial 9"
    20642051
    2065     itk_component add axisflymode {
     2052    itk_component add axismode {
    20662053        Rappture::Combobox $inner.mode -width 10 -editable 0
    20672054    }
     
    20712058        "furthest_triad"  "farthest" \
    20722059        "outer_edges"     "outer"
    2073     $itk_component(axisflymode) value $_settings(-axisflymode)
    2074     bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode]
     2060    $itk_component(axismode) value $_settings(-axismode)
     2061    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
    20752062
    20762063    blt::table $inner \
     
    22092196    radiobutton $inner.vtk_button -text "VTK data file" \
    22102197        -variable [itcl::scope _downloadPopup(format)] \
    2211         -font "Arial 9 " \
     2198        -font "Arial 9" \
    22122199        -value vtk
    22132200    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
    22142201    radiobutton $inner.image_button -text "Image File" \
    22152202        -variable [itcl::scope _downloadPopup(format)] \
    2216         -font "Arial 9 " \
     2203        -font "Arial 9" \
    22172204        -value image
    22182205    Rappture::Tooltip::for $inner.image_button \
     
    22552242    set tag $dataobj-$comp
    22562243    array set style {
    2257         -color BCGYR
    2258         -levels 10
    2259         -opacity 1.0
     2244        -color            BCGYR
     2245        -colormapdiscrete 0
     2246        -colormapvisible  1
     2247        -edgecolor        black
     2248        -edges            0
     2249        -isolinecolor     black
     2250        -isolinesvisible  1
     2251        -isolinewidth     1.0
     2252        -levels           10
     2253        -linewidth        1.0
     2254        -opacity          1.0
     2255        -outline          0
     2256        -wireframe        0
    22602257    }
    22612258    set stylelist [$dataobj style $comp]
     
    22952292        DrawLegend
    22962293    }
     2294    foreach setting {-edges -outline -wireframe -colormapdiscrete \
     2295                     -colormapvisible -isolinecolor -isolinesvisible} {
     2296        if {$_changed($setting)} {
     2297            # User-modified UI setting overrides style
     2298            set style($setting) $_settings($setting)
     2299        } else {
     2300            # Set UI control to style setting (tool provided or default)
     2301            set _settings($setting) $style($setting)
     2302        }
     2303    }
     2304
    22972305    SendCmd "outline add $tag"
    22982306    SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag"
    2299     SendCmd "outline visible $_settings(-outline) $tag"
     2307    SendCmd "outline visible $style(-outline) $tag"
     2308
    23002309    set scale [GetHeightmapScale]
    23012310    SendCmd "[list heightmap add contourlist $_contourList $scale $tag]"
    23022311    set _comp2scale($tag) $_settings(-heightmapscale)
    2303     SendCmd "heightmap edges $_settings(-edges) $tag"
    2304     SendCmd "heightmap wireframe $_settings(-wireframe) $tag"
     2312    SendCmd "heightmap edges $style(-edges) $tag"
     2313    SendCmd "heightmap linecolor [Color2RGB $style(-edgecolor)] $tag"
     2314    SendCmd "heightmap linewidth $style(-linewidth) $tag"
     2315    SendCmd "heightmap wireframe $style(-wireframe) $tag"
    23052316    SetCurrentColormap $style(-color)
    2306     set color [$itk_component(isolinecolor) value]
    2307     SendCmd "heightmap isolinecolor [Color2RGB $color] $tag"
     2317    if {$style(-colormapdiscrete)} {
     2318        SendCmd "heightmap preinterp 1 $tag"
     2319        set numColors [expr $style(-levels) + 1]
     2320        SendCmd "colormap res $numColors $style(-color)"
     2321    }
     2322    SendCmd "heightmap isolinecolor [Color2RGB $style(-isolinecolor)] $tag"
     2323    $itk_component(isolinecolor) value $style(-isolinecolor)
     2324    SendCmd "heightmap isolinewidth $style(-isolinewidth) $tag"
    23082325    SendCmd "heightmap lighting $_settings(-isheightmap) $tag"
    2309     SendCmd "heightmap isolines $_settings(-isolinesvisible) $tag"
    2310     SendCmd "heightmap surface $_settings(-colormapvisible) $tag"
     2326    SendCmd "heightmap isolines $style(-isolinesvisible) $tag"
     2327    SendCmd "heightmap surface $style(-colormapvisible) $tag"
    23112328    SendCmd "heightmap opacity $style(-opacity) $tag"
    23122329    set _settings(-opacity) [expr $style(-opacity) * 100.0]
     
    23462363# DrawLegend --
    23472364#
    2348 # Draws the legend in the own canvas on the right side of the plot area.
     2365# Draws the legend in its own canvas on the right side of the plot area.
    23492366#
    23502367itcl::body Rappture::VtkHeightmapViewer::DrawLegend {} {
     
    24342451    }
    24352452
    2436     $c bind title <ButtonPress> [itcl::code $this Combo post]
    2437     $c bind title <Enter> [itcl::code $this Combo activate]
    2438     $c bind title <Leave> [itcl::code $this Combo deactivate]
     2453    $c bind title <ButtonPress> [itcl::code $this LegendTitleAction post]
     2454    $c bind title <Enter> [itcl::code $this LegendTitleAction enter]
     2455    $c bind title <Leave> [itcl::code $this LegendTitleAction leave]
    24392456    # Reset the item coordinates according the current size of the plot.
    24402457    if { [info exists _limits($_curFldName)] } {
     
    25502567
    25512568# ----------------------------------------------------------------------
    2552 # USAGE: _dropdown post
    2553 # USAGE: _dropdown unpost
    2554 # USAGE: _dropdown select
    2555 #
    2556 # Used internally to handle the dropdown list for this combobox.  The
    2557 # post/unpost options are invoked when the list is posted or unposted
    2558 # to manage the relief of the controlling button.  The select option
    2559 # is invoked whenever there is a selection from the list, to assign
    2560 # the value back to the gauge.
    2561 # ----------------------------------------------------------------------
    2562 itcl::body Rappture::VtkHeightmapViewer::Combo {option} {
     2569# USAGE: LegendTitleAction post
     2570# USAGE: LegendTitleAction enter
     2571# USAGE: LegendTitleAction leave
     2572# USAGE: LegendTitleAction save
     2573#
     2574# Used internally to handle the dropdown list for the fields menu combobox.
     2575# The post option is invoked when the field title is pressed to launch the
     2576# dropdown.  The enter option is invoked when the user mouses over the field
     2577# title. The leave option is invoked when the user moves the mouse away
     2578# from the field title.  The save option is invoked whenever there is a
     2579# selection from the list, to alert the visualization server.
     2580# ----------------------------------------------------------------------
     2581itcl::body Rappture::VtkHeightmapViewer::LegendTitleAction {option} {
    25632582    set c $itk_component(view)
    25642583    switch -- $option {
     
    25702589            tk_popup $itk_component(fieldmenu) $x $y
    25712590        }
    2572         activate {
     2591        enter {
    25732592            $c itemconfigure title -fill red
    25742593        }
    2575         deactivate {
     2594        leave {
    25762595            $c itemconfigure title -fill $itk_option(-plotforeground)
    25772596        }
    2578         invoke {
     2597        save {
    25792598            $itk_component(field) value $_curFldLabel
    25802599            AdjustSetting -field
    25812600        }
    25822601        default {
    2583             error "bad option \"$option\": should be post, unpost, select"
     2602            error "bad option \"$option\": should be post, enter, leave or save"
    25842603        }
    25852604    }
     
    26312650    blt::vector destroy $v
    26322651}
     2652
     2653itcl::body Rappture::VtkHeightmapViewer::SetCurrentFieldName { dataobj } {
     2654    set _first $dataobj
     2655    $itk_component(field) choices delete 0 end
     2656    $itk_component(fieldmenu) delete 0 end
     2657    array unset _fields
     2658    set _curFldName ""
     2659    foreach cname [$_first components] {
     2660        foreach fname [$_first fieldnames $cname] {
     2661            if { [info exists _fields($fname)] } {
     2662                continue
     2663            }
     2664            foreach { label units components } \
     2665                [$_first fieldinfo $fname] break
     2666            $itk_component(field) choices insert end "$fname" "$label"
     2667            $itk_component(fieldmenu) add radiobutton -label "$label" \
     2668                -value $label -variable [itcl::scope _curFldLabel] \
     2669                -selectcolor red \
     2670                -activebackground $itk_option(-plotbackground) \
     2671                -activeforeground $itk_option(-plotforeground) \
     2672                -font "Arial 8" \
     2673                -command [itcl::code $this LegendTitleAction save]
     2674            set _fields($fname) [list $label $units $components]
     2675            if { $_curFldName == "" } {
     2676                set _curFldName $fname
     2677                set _curFldLabel $label
     2678            }
     2679        }
     2680    }
     2681    $itk_component(field) value $_curFldLabel
     2682}
  • branches/1.7/gui/scripts/vtkimageviewer.tcl

    r6306 r6364  
    7070    private method BuildImageTab {}
    7171    private method BuildDownloadPopup { widget command }
    72     private method Combo { option }
    7372    private method Connect {}
    7473    private method CurrentDatasets {args}
     
    8685    private method IsValidObject { dataobj }
    8786    private method LeaveLegend {}
     87    private method LegendTitleAction { option }
    8888    private method MotionLegend { x y }
    8989    private method Pan {option x y}
     
    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 }
     
    209210
    210211    array set _settings {
    211         -axisflymode            "static"
     212        -axesvisible            1
    212213        -axislabels             1
    213214        -axisminorticks         1
    214         -axisvisible            1
     215        -axismode               "static"
    215216        -backingcolor           white
    216217        -backingvisible         1
     
    243244
    244245    itk_component add fieldmenu {
    245         menu $itk_component(plotarea).menu \
    246             -relief flat \
    247             -tearoff 0
     246        menu $itk_component(plotarea).menu -relief flat -tearoff 0
    248247    } {
    249248        usual
     
    274273    }
    275274    pack $itk_component(reset) -side top -padx 2 -pady { 2 0 }
    276     Rappture::Tooltip::for $itk_component(reset) "Reset the view to the default zoom level"
     275    Rappture::Tooltip::for $itk_component(reset) \
     276        "Reset the view to the default zoom level"
    277277
    278278    itk_component add zoomin {
     
    510510        set _dlist [lreplace $_dlist $pos $pos]
    511511        array unset _obj2ovride $dataobj-*
    512         array unset _settings $dataobj-*
    513512        set changed 1
    514513    }
     
    604603        }
    605604        foreach axis { x y } {
     605            set units [$dataobj hints ${axis}units]
     606            set found($units) 1
    606607            set lim [$dataobj limits $axis]
    607608            if { ![info exists _limits($axis)] } {
     
    618619            }
    619620            set _limits($axis) [list $amin $amax]
    620             set units [$dataobj hints ${axis}units]
    621             set found($units) 1
    622621        }
    623622        foreach { fname lim } [$dataobj fieldlimits] {
     
    900899        DoResize
    901900        if { $_settings(-stretchtofit) } {
    902             AdjustSetting -stretchToFit
     901            AdjustSetting -stretchtofit
    903902        }
    904903    }
     
    907906        # Reset the camera and other view parameters
    908907        #
    909         InitSettings -view3d -background
    910 
     908        InitSettings -view3d -background \
     909            -xgrid -ygrid -zgrid -axismode \
     910            -axesvisible -axislabels -axisminorticks
     911
     912        SendCmd "axis tickpos outside"
    911913        SendCmd "axis lrot z 90"
    912914        $_arcball quaternion [ViewToQuaternion]
     
    932934        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
    933935            set _first $dataobj
     936            SetCurrentFieldName $dataobj
    934937        }
    935938        foreach comp [$dataobj components] {
     
    968971        }
    969972    }
    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 Combo invoke]
    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     }
     973
    999974    InitSettings -stretchtofit -outline
    1000 
    1001975    if { $_reset } {
    1002         SendCmd "axis tickpos outside"
    1003         #SendCmd "axis lformat all %g"
    1004 
    1005976        foreach axis { x y z } {
    1006977            set label ""
     
    10431014        }
    10441015        PanCamera
    1045         InitSettings -xgrid -ygrid -zgrid \
    1046             -axisvisible -axislabels -field -view3d
     1016        InitSettings -field -view3d
    10471017        if { [array size _fields] < 2 } {
    10481018            catch {blt::table forget $itk_component(field) $itk_component(field_l)}
     
    12751245itcl::body Rappture::VtkImageViewer::InitSettings { args } {
    12761246    foreach spec $args {
    1277         if { [info exists _settings($_first${spec})] } {
    1278             # Reset global setting with dataobj specific setting
    1279             set _settings($spec) $_settings($_first${spec})
    1280         }
    12811247        AdjustSetting $spec
    12821248    }
     
    12951261    }
    12961262    switch -- $what {
    1297         "-axisflymode" {
    1298             set mode [$itk_component(axisflymode) value]
    1299             set mode [$itk_component(axisflymode) translate $mode]
    1300             set _settings($what) $mode
    1301             SendCmd "axis flymode $mode"
     1263        "-axesvisible" {
     1264            set bool $_settings($what)
     1265            SendCmd "axis visible all $bool"
    13021266        }
    13031267        "-axislabels" {
     
    13091273            SendCmd "axis minticks all $bool"
    13101274        }
    1311         "-axisvisible" {
    1312             set bool $_settings($what)
    1313             SendCmd "axis visible all $bool"
     1275        "-axismode" {
     1276            set mode [$itk_component(axismode) value]
     1277            set mode [$itk_component(axismode) translate $mode]
     1278            set _settings($what) $mode
     1279            SendCmd "axis flymode $mode"
    13141280        }
    13151281        "-background" {
     
    13931359            SendCmd "camera reset"
    13941360            DrawLegend
     1361        }
     1362        "-legendvisible" {
     1363            if { !$_settings($what) } {
     1364                $itk_component(view) delete legend
     1365            }
     1366            DrawLegend
     1367        }
     1368        "-level" {
     1369            set val $_settings($what)
     1370            SendCmd "image level $val"
     1371        }
     1372        "-opacity" {
     1373            set _changed($what) 1
     1374            if { $_settings(-view3d) } {
     1375                set _settings(-saveopacity) $_settings($what)
     1376                set val [expr $_settings($what) * 0.01]
     1377                SendCmd "image opacity $val"
     1378            } else {
     1379                SendCmd "image opacity 1.0"
     1380            }
     1381        }
     1382        "-outline" {
     1383            set bool $_settings($what)
     1384            SendCmd "outline visible $bool"
     1385        }
     1386        "-stretchtofit" {
     1387            set bool $_settings($what)
     1388            if { $bool } {
     1389                if { $_settings(-view3d) } {
     1390                    SendCmd "camera aspect native"
     1391                } else {
     1392                    SendCmd "camera aspect window"
     1393                }
     1394            } else {
     1395                SendCmd "camera aspect native"
     1396            }
    13951397        }
    13961398        "-view3d" {
     
    14481450            set val $_settings($what)
    14491451            SendCmd "image window $val"
    1450         }
    1451         "-level" {
    1452             set val $_settings($what)
    1453             SendCmd "image level $val"
    1454         }
    1455         "-legendvisible" {
    1456             if { !$_settings($what) } {
    1457                 $itk_component(view) delete legend
    1458             }
    1459             DrawLegend
    1460         }
    1461         "-opacity" {
    1462             set _changed($what) 1
    1463             if { $_settings(-view3d) } {
    1464                 set _settings(-saveopacity) $_settings($what)
    1465                 set val [expr $_settings($what) * 0.01]
    1466                 SendCmd "image opacity $val"
    1467             } else {
    1468                 SendCmd "image opacity 1.0"
    1469             }
    1470         }
    1471         "-outline" {
    1472             set bool $_settings($what)
    1473             SendCmd "outline visible $bool"
    1474         }
    1475         "-stretchtofit" {
    1476             set bool $_settings($what)
    1477             if { $bool } {
    1478                 if { $_settings(-view3d) } {
    1479                     SendCmd "camera aspect native"
    1480                 } else {
    1481                     SendCmd "camera aspect window"
    1482                 }
    1483             } else {
    1484                 SendCmd "camera aspect native"
    1485             }
    14861452        }
    14871453        "-xgrid" - "-ygrid" - "-zgrid" {
     
    17951761    checkbutton $inner.visible \
    17961762        -text "Axes" \
    1797         -variable [itcl::scope _settings(-axisvisible)] \
    1798         -command [itcl::code $this AdjustSetting -axisvisible] \
     1763        -variable [itcl::scope _settings(-axesvisible)] \
     1764        -command [itcl::code $this AdjustSetting -axesvisible] \
    17991765        -font "Arial 9"
    18001766    checkbutton $inner.labels \
     
    18271793    label $inner.mode_l -text "Mode" -font "Arial 9"
    18281794
    1829     itk_component add axisflymode {
     1795    itk_component add axismode {
    18301796        Rappture::Combobox $inner.mode -width 10 -editable 0
    18311797    }
     
    18351801        "furthest_triad"  "farthest" \
    18361802        "outer_edges"     "outer"
    1837     $itk_component(axisflymode) value $_settings(-axisflymode)
    1838     bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode]
     1803    $itk_component(axismode) value $_settings(-axismode)
     1804    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
    18391805
    18401806    blt::table $inner \
     
    19731939    radiobutton $inner.vtk_button -text "VTK data file" \
    19741940        -variable [itcl::scope _downloadPopup(format)] \
    1975         -font "Arial 9 " \
     1941        -font "Arial 9" \
    19761942        -value vtk
    19771943    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
    19781944    radiobutton $inner.image_button -text "Image File" \
    19791945        -variable [itcl::scope _downloadPopup(format)] \
    1980         -font "Arial 9 " \
     1946        -font "Arial 9" \
    19811947        -value image
    19821948    Rappture::Tooltip::for $inner.image_button \
     
    20462012    if { [info exists style(-stretchtofit)] } {
    20472013        set _settings(-stretchtofit) $style(-stretchtofit)
    2048         AdjustSetting -stretchToFit
     2014        AdjustSetting -stretchtofit
    20492015    }
    20502016    SendCmd "outline add $tag"
     
    20922058# DrawLegend --
    20932059#
    2094 #       Draws the legend in the own canvas on the right side of the plot area.
     2060# Draws the legend in its own canvas on the right side of the plot area.
    20952061#
    20962062itcl::body Rappture::VtkImageViewer::DrawLegend {} {
     
    21532119    set x1 [expr $x2 - ($iw*12)/10]
    21542120
    2155     $c bind title <ButtonPress> [itcl::code $this Combo post]
    2156     $c bind title <Enter> [itcl::code $this Combo activate]
    2157     $c bind title <Leave> [itcl::code $this Combo deactivate]
     2121    $c bind title <ButtonPress> [itcl::code $this LegendTitleAction post]
     2122    $c bind title <Enter> [itcl::code $this LegendTitleAction enter]
     2123    $c bind title <Leave> [itcl::code $this LegendTitleAction leave]
    21582124    # Reset the item coordinates according the current size of the plot.
    21592125    if { [info exists _limits($_curFldName)] } {
     
    22692235
    22702236# ----------------------------------------------------------------------
    2271 # USAGE: _dropdown post
    2272 # USAGE: _dropdown unpost
    2273 # USAGE: _dropdown select
    2274 #
    2275 # Used internally to handle the dropdown list for this combobox.  The
    2276 # post/unpost options are invoked when the list is posted or unposted
    2277 # to manage the relief of the controlling button.  The select option
    2278 # is invoked whenever there is a selection from the list, to assign
    2279 # the value back to the gauge.
    2280 # ----------------------------------------------------------------------
    2281 itcl::body Rappture::VtkImageViewer::Combo {option} {
     2237# USAGE: LegendTitleAction post
     2238# USAGE: LegendTitleAction enter
     2239# USAGE: LegendTitleAction leave
     2240# USAGE: LegendTitleAction save
     2241#
     2242# Used internally to handle the dropdown list for the fields menu combobox.
     2243# The post option is invoked when the field title is pressed to launch the
     2244# dropdown.  The enter option is invoked when the user mouses over the field
     2245# title. The leave option is invoked when the user moves the mouse away
     2246# from the field title.  The save option is invoked whenever there is a
     2247# selection from the list, to alert the visualization server.
     2248# ----------------------------------------------------------------------
     2249itcl::body Rappture::VtkImageViewer::LegendTitleAction {option} {
    22822250    set c $itk_component(view)
    22832251    switch -- $option {
     
    22892257            tk_popup $itk_component(fieldmenu) $x $y
    22902258        }
    2291         activate {
     2259        enter {
    22922260            $c itemconfigure title -fill red
    22932261        }
    2294         deactivate {
     2262        leave {
    22952263            $c itemconfigure title -fill $itk_option(-plotforeground)
    22962264        }
    2297         invoke {
     2265        save {
    22982266            $itk_component(field) value $_curFldLabel
    22992267            AdjustSetting -field
    23002268        }
    23012269        default {
    2302             error "bad option \"$option\": should be post, unpost, select"
     2270            error "bad option \"$option\": should be post, enter, leave or save"
    23032271        }
    23042272    }
     
    23252293    set _view(-zoom) 1.0
    23262294}
     2295
     2296itcl::body Rappture::VtkImageViewer::SetCurrentFieldName { dataobj } {
     2297    set _first $dataobj
     2298    $itk_component(field) choices delete 0 end
     2299    $itk_component(fieldmenu) delete 0 end
     2300    array unset _fields
     2301    set _curFldName ""
     2302    foreach cname [$_first components] {
     2303        foreach fname [$_first fieldnames $cname] {
     2304            if { [info exists _fields($fname)] } {
     2305                continue
     2306            }
     2307            foreach { label units components } \
     2308                [$_first fieldinfo $fname] break
     2309            $itk_component(field) choices insert end "$fname" "$label"
     2310            $itk_component(fieldmenu) add radiobutton -label "$label" \
     2311                -value $label -variable [itcl::scope _curFldLabel] \
     2312                -selectcolor red \
     2313                -activebackground $itk_option(-plotbackground) \
     2314                -activeforeground $itk_option(-plotforeground) \
     2315                -font "Arial 8" \
     2316                -command [itcl::code $this LegendTitleAction save]
     2317            set _fields($fname) [list $label $units $components]
     2318            if { $_curFldName == "" } {
     2319                set _curFldName $fname
     2320                set _curFldLabel $label
     2321            }
     2322        }
     2323    }
     2324    $itk_component(field) value $_curFldLabel
     2325}
  • branches/1.7/gui/scripts/vtkisosurfaceviewer.tcl

    r6306 r6364  
    107107    private method ReceiveDataset { args }
    108108    private method ReceiveImage { args }
    109     private method ReceiveLegend { colormap title vmin vmax size }
     109    private method ReceiveLegend { colormap title min max size }
    110110    private method RequestLegend {}
    111111    private method Rotate {option x y}
     
    160160    private variable _rotatePending 0
    161161    private variable _cutplanePending 0
    162     private variable _field      ""
    163     private variable _colorMode "scalar"; # Mode of colormap (vmag or scalar)
    164162    private variable _fields
    165163    private variable _curFldName ""
    166164    private variable _curFldLabel ""
     165    private variable _colorMode "scalar"; # Mode of colormap (vmag or scalar)
    167166    private variable _mouseOver "";     # what called LegendRangeAction:
    168167                                        # vmin or vmax
     
    654653        set _dlist [lreplace $_dlist $pos $pos]
    655654        array unset _obj2ovride $dataobj-*
    656         array unset _settings $dataobj-*
    657655        set changed 1
    658656    }
     
    13471345itcl::body Rappture::VtkIsosurfaceViewer::InitSettings { args } {
    13481346    foreach spec $args {
    1349         if { [info exists _settings($_first${spec})] } {
    1350             # Reset global setting with dataobj specific setting
    1351             set _settings($spec) $_settings($_first${spec})
    1352         }
    13531347        AdjustSetting $spec
    13541348    }
     
    15021496        }
    15031497        "-isolinecolor" {
    1504             set color [$itk_component(isolineColor) value]
     1498            set color [$itk_component(isolinecolor) value]
    15051499            set _settings($what) $color
    15061500            DrawLegend
     
    17381732
    17391733    label $inner.linecolor_l -text "Isolines" -font "Arial 9"
    1740     itk_component add isolineColor {
     1734    itk_component add isolinecolor {
    17411735        Rappture::Combobox $inner.linecolor -width 10 -editable 0
    17421736    }
     
    17531747        "none"               "none"
    17541748
    1755     $itk_component(isolineColor) value "white"
     1749    $itk_component(isolinecolor) value $_settings(-isolinecolor)
    17561750    bind $inner.linecolor <<Value>> \
    17571751        [itcl::code $this AdjustSetting -isolinecolor]
     
    21812175                    SendCmd "camera zoom $_view($what)"
    21822176                }
    2183              }
     2177            }
    21842178        }
    21852179    }
     
    22152209    radiobutton $inner.vtk_button -text "VTK data file" \
    22162210        -variable [itcl::scope _downloadPopup(format)] \
    2217         -font "Arial 9 " \
     2211        -font "Arial 9" \
    22182212        -value vtk
    22192213    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
    22202214    radiobutton $inner.image_button -text "Image File" \
    22212215        -variable [itcl::scope _downloadPopup(format)] \
    2222         -font "Arial 9 " \
     2216        -font "Arial 9" \
    22232217        -value image
    22242218    Rappture::Tooltip::for $inner.image_button \
     
    22562250    array set style {
    22572251        -color                  BCGYR
     2252        -constcolor             white
    22582253        -cutplaneedges          0
    22592254        -cutplanelighting       1
     
    22812276        set style(-opacity) 1.0
    22822277    }
     2278    set style(-constcolor) $itk_option(-plotforeground)
    22832279    array set style [$dataobj style $comp]
    22842280    #DebugTrace [array get style]
     
    23122308    }
    23132309    if { $_currentColormap == "" } {
    2314         SetCurrentColormap $style(-color)
    23152310        $itk_component(colormap) value $style(-color)
    23162311    }
     
    23402335
    23412336    SendCmd "cutplane add $tag"
    2342     SendCmd "cutplane color [Color2RGB $itk_option(-plotforeground)] $tag"
     2337    SendCmd "cutplane color [Color2RGB $style(-constcolor)] $tag"
    23432338    foreach axis {x y z} {
    23442339        set pos [expr $style(-${axis}cutplaneposition) * 0.01]
     
    23562351
    23572352    SendCmd "outline add $tag"
    2358     SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag"
     2353    SendCmd "outline color [Color2RGB $style(-constcolor)] $tag"
    23592354    SendCmd "outline visible $style(-outline) $tag"
    23602355
     
    23642359    SendCmd "contour3d edges $style(-edges) $tag"
    23652360    set _settings(-isosurfaceedges) $style(-edges)
    2366     #SendCmd "contour3d color [Color2RGB $style(-color)] $tag"
     2361    #SendCmd "contour3d color [Color2RGB $style(-constcolor)] $tag"
    23672362    SendCmd "contour3d lighting $style(-lighting) $tag"
    23682363    set _settings(-isosurfacelighting) $style(-lighting)
  • branches/1.7/gui/scripts/vtkmeshviewer.tcl

    r6306 r6364  
    14641464    radiobutton $inner.vtk_button -text "VTK data file" \
    14651465        -variable [itcl::scope _downloadPopup(format)] \
    1466         -font "Helvetica 9 " \
     1466        -font "Arial 9" \
    14671467        -value vtk
    14681468    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
  • branches/1.7/gui/scripts/vtkstreamlinesviewer.tcl

    r6306 r6364  
    7272    private method BuildSurfaceTab {}
    7373    private method DrawLegend {}
    74     private method Combo { option }
    7574    private method Connect {}
    7675    private method CurrentDatasets {args}
     
    9190    private method IsValidObject { dataobj }
    9291    private method LeaveLegend {}
     92    private method LegendTitleAction { option }
    9393    private method MotionLegend { x y }
    9494    private method Pan {option x y}
     
    101101    private method ReceiveDataset { args }
    102102    private method ReceiveImage { args }
    103     private method ReceiveLegend { colormap title vmin vmax size }
     103    private method ReceiveLegend { colormap title min max size }
    104104    private method RequestLegend {}
    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 }
     
    145146    private variable _curFldName ""
    146147    private variable _curFldLabel ""
    147     private variable _field ""
     148    private variable _colorMode "vmag"; # Mode of colormap (vmag or scalar)
    148149    private variable _streamlinesLength 0
    149150    private variable _numSeeds 200
    150     private variable _colorMode "vmag"; # Mode of colormap (vmag or scalar)
    151151
    152152    private common _downloadPopup;      # download options from popup
     
    301301    }
    302302    pack $itk_component(reset) -side top -padx 2 -pady 2
    303     Rappture::Tooltip::for $itk_component(reset) "Reset the view to the default zoom level"
     303    Rappture::Tooltip::for $itk_component(reset) \
     304        "Reset the view to the default zoom level"
    304305
    305306    itk_component add zoomin {
     
    589590        set _dlist [lreplace $_dlist $pos $pos]
    590591        array unset _obj2ovride $dataobj-*
    591         array unset _settings $dataobj-*
    592592        set changed 1
    593593    }
     
    979979        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
    980980            set _first $dataobj
     981            SetCurrentFieldName $dataobj
    981982        }
    982983        foreach comp [$dataobj components] {
     
    10241025            }
    10251026        }
    1026         $itk_component(field) choices delete 0 end
    1027         $itk_component(fieldmenu) delete 0 end
    1028         array unset _fields
    1029         set _curFldName ""
    1030         set _curFldLabel ""
    1031         foreach cname [$_first components] {
    1032             foreach fname [$_first fieldnames $cname] {
    1033                 if { [info exists _fields($fname)] } {
    1034                     continue
    1035                 }
    1036                 foreach { label units components } \
    1037                     [$_first fieldinfo $fname] break
    1038                 $itk_component(field) choices insert end "$fname" "$label"
    1039                 $itk_component(fieldmenu) add radiobutton -label "$label" \
    1040                     -value $label -variable [itcl::scope _curFldLabel] \
    1041                     -selectcolor red \
    1042                     -activebackground $itk_option(-plotbackground) \
    1043                     -activeforeground $itk_option(-plotforeground) \
    1044                     -font "Arial 8" \
    1045                     -command [itcl::code $this Combo invoke]
    1046                 set _fields($fname) [list $label $units $components]
    1047                 if { $_curFldName == "" && $components == 3 } {
    1048                     set _curFldName $fname
    1049                     set _curFldLabel $label
    1050                 }
    1051             }
    1052         }
    1053         $itk_component(field) value $_curFldLabel
    10541027    }
    10551028
     
    12961269itcl::body Rappture::VtkStreamlinesViewer::InitSettings { args } {
    12971270    foreach spec $args {
    1298         if { [info exists _settings($_first${spec})] } {
    1299             # Reset global setting with dataobj specific setting
    1300             set _settings($spec) $_settings($_first${spec})
    1301         }
    13021271        AdjustSetting $spec
    13031272    }
     
    20652034    radiobutton $inner.vtk_button -text "VTK data file" \
    20662035        -variable [itcl::scope _downloadPopup(format)] \
    2067         -font "Helvetica 9 " \
     2036        -font "Arial 9" \
    20682037        -value vtk
    20692038    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
     
    21822151
    21832152# ----------------------------------------------------------------------
    2184 # USAGE: ReceiveLegend <colormap> <title> <vmin> <vmax> <size>
     2153# USAGE: ReceiveLegend <colormap> <title> <min> <max> <size>
    21852154#
    21862155# Invoked automatically whenever the "legend" command comes in from
     
    21882157# specified <size> will follow.
    21892158# ----------------------------------------------------------------------
    2190 itcl::body Rappture::VtkStreamlinesViewer::ReceiveLegend { colormap title vmin vmax size } {
     2159itcl::body Rappture::VtkStreamlinesViewer::ReceiveLegend { colormap title min max size } {
    21912160    set _legendPending 0
    21922161    set _title $title
     
    22522221            $c bind colormap <Motion> [itcl::code $this MotionLegend %x %y]
    22532222        }
    2254         $c bind title <ButtonPress> [itcl::code $this Combo post]
    2255         $c bind title <Enter> [itcl::code $this Combo activate]
    2256         $c bind title <Leave> [itcl::code $this Combo deactivate]
     2223        $c bind title <ButtonPress> [itcl::code $this LegendTitleAction post]
     2224        $c bind title <Enter> [itcl::code $this LegendTitleAction enter]
     2225        $c bind title <Leave> [itcl::code $this LegendTitleAction leave]
    22572226        # Reset the item coordinates according the current size of the plot.
    22582227        $c itemconfigure title -text $title
     
    23772346
    23782347# ----------------------------------------------------------------------
    2379 # USAGE: _dropdown post
    2380 # USAGE: _dropdown unpost
    2381 # USAGE: _dropdown select
    2382 #
    2383 # Used internally to handle the dropdown list for this combobox.  The
    2384 # post/unpost options are invoked when the list is posted or unposted
    2385 # to manage the relief of the controlling button.  The select option
    2386 # is invoked whenever there is a selection from the list, to assign
    2387 # the value back to the gauge.
    2388 # ----------------------------------------------------------------------
    2389 itcl::body Rappture::VtkStreamlinesViewer::Combo {option} {
     2348# USAGE: LegendTitleAction post
     2349# USAGE: LegendTitleAction enter
     2350# USAGE: LegendTitleAction leave
     2351# USAGE: LegendTitleAction save
     2352#
     2353# Used internally to handle the dropdown list for the fields menu combobox.
     2354# The post option is invoked when the field title is pressed to launch the
     2355# dropdown.  The enter option is invoked when the user mouses over the field
     2356# title. The leave option is invoked when the user moves the mouse away
     2357# from the field title.  The save option is invoked whenever there is a
     2358# selection from the list, to alert the visualization server.
     2359# ----------------------------------------------------------------------
     2360itcl::body Rappture::VtkStreamlinesViewer::LegendTitleAction {option} {
    23902361    set c $itk_component(view)
    23912362    switch -- $option {
     
    23972368            tk_popup $itk_component(fieldmenu) $x $y
    23982369        }
    2399         activate {
     2370        enter {
    24002371            $c itemconfigure title -fill red
    24012372        }
    2402         deactivate {
     2373        leave {
    24032374            $c itemconfigure title -fill white
    24042375        }
    2405         invoke {
     2376        save {
    24062377            $itk_component(field) value $_curFldLabel
    24072378            AdjustSetting -field
    24082379        }
    24092380        default {
    2410             error "bad option \"$option\": should be post, unpost, select"
     2381            error "bad option \"$option\": should be post, enter, leave or save"
    24112382        }
    24122383    }
     
    24332404    set _view(-zoom) 1.0
    24342405}
     2406
     2407itcl::body Rappture::VtkStreamlinesViewer::SetCurrentFieldName { dataobj } {
     2408    set _first $dataobj
     2409    $itk_component(field) choices delete 0 end
     2410    $itk_component(fieldmenu) delete 0 end
     2411    array unset _fields
     2412    set _curFldName ""
     2413    set _curFldLabel ""
     2414    foreach cname [$_first components] {
     2415        foreach fname [$_first fieldnames $cname] {
     2416            if { [info exists _fields($fname)] } {
     2417                continue
     2418            }
     2419            foreach { label units components } \
     2420                [$_first fieldinfo $fname] break
     2421            $itk_component(field) choices insert end "$fname" "$label"
     2422            $itk_component(fieldmenu) add radiobutton -label "$label" \
     2423                -value $label -variable [itcl::scope _curFldLabel] \
     2424                -selectcolor red \
     2425                -activebackground $itk_option(-plotbackground) \
     2426                -activeforeground $itk_option(-plotforeground) \
     2427                -font "Arial 8" \
     2428                -command [itcl::code $this LegendTitleAction save]
     2429            set _fields($fname) [list $label $units $components]
     2430            if { $_curFldName == "" && $components == 3 } {
     2431                set _curFldName $fname
     2432                set _curFldLabel $label
     2433            }
     2434        }
     2435    }
     2436    $itk_component(field) value $_curFldLabel
     2437}
  • branches/1.7/gui/scripts/vtksurfaceviewer.tcl

    r6306 r6364  
    6969    private method BuildDownloadPopup { widget command }
    7070    private method BuildSurfaceTab {}
    71     private method Combo { option }
    7271    private method Connect {}
    7372    private method CurrentDatasets {args}
     
    8584    private method IsValidObject { dataobj }
    8685    private method LeaveLegend {}
     86    private method LegendTitleAction { option }
    8787    private method MotionLegend { x y }
    8888    private method Pan {option x y}
     
    9595    private method ReceiveDataset { args }
    9696    private method ReceiveImage { args }
    97     private method ReceiveLegend { colormap title vmin vmax size }
     97    private method ReceiveLegend { colormap title min max size }
    9898    private method RequestLegend {}
    9999    private method Rotate {option x y}
     
    139139    private variable _legendPending 0
    140140    private variable _rotatePending 0
    141     private variable _field ""
    142     private variable _colorMode "scalar"; # Mode of colormap (vmag or scalar)
    143141    private variable _fields
    144142    private variable _curFldName ""
    145143    private variable _curFldLabel ""
     144    private variable _colorMode "scalar"; # Mode of colormap (vmag or scalar)
    146145
    147146    private common _downloadPopup;      # download options from popup
     
    510509        set _dlist [lreplace $_dlist $pos $pos]
    511510        array unset _obj2ovride $dataobj-*
    512         array unset _settings $dataobj-*
    513511        set changed 1
    514512    }
     
    11911189itcl::body Rappture::VtkSurfaceViewer::InitSettings { args } {
    11921190    foreach spec $args {
    1193         if { [info exists _settings($_first${spec})] } {
    1194             # Reset global setting with dataobj specific setting
    1195             set _settings($spec) $_settings($_first${spec})
    1196         }
    11971191        AdjustSetting $spec
    11981192    }
     
    13151309        "-isolinecolor" {
    13161310            set _changed($what) 1
    1317             set color [$itk_component(isolineColor) value]
    1318             set _settings($what) $color
    1319             SendCmd "contour2d linecolor [Color2RGB $color]"
     1311            set color [$itk_component(isolinecolor) value]
     1312            if { $color == "none" } {
     1313                if { $_settings(-isolinesvisible) } {
     1314                    set _changed(-isolinesvisible) 1
     1315                    foreach tag [CurrentDatasets -visible] {
     1316                        SendCmd "contour2d visible 0 $tag"
     1317                    }
     1318                    set _settings(-isolinesvisible) 0
     1319                }
     1320            } else {
     1321                set _settings($what) $color
     1322                if { !$_settings(-isolinesvisible) } {
     1323                    set _changed(-isolinesvisible) 1
     1324                    foreach tag [CurrentDatasets -visible] {
     1325                        SendCmd "contour2d visible 1 $tag"
     1326                    }
     1327                    set _settings(-isolinesvisible) 1
     1328                }
     1329                SendCmd "contour2d linecolor [Color2RGB $color]"
     1330            }
    13201331            DrawLegend
    13211332        }
     
    13251336            SendCmd "contour2d visible 0"
    13261337            if { $bool } {
     1338                if { [$itk_component(isolinecolor) value] != $_settings(-isolinecolor)} {
     1339                    $itk_component(isolinecolor) value $_settings(-isolinecolor)
     1340                }
    13271341                foreach tag [CurrentDatasets -visible] {
    13281342                    SendCmd "contour2d visible $bool $tag"
     
    15431557
    15441558    label $inner.linecolor_l -text "Isolines" -font "Arial 9"
    1545     itk_component add isolineColor {
     1559    itk_component add isolinecolor {
    15461560        Rappture::Combobox $inner.linecolor -width 10 -editable 0
    15471561    }
     
    15581572        "none"               "none"
    15591573
    1560     $itk_component(isolineColor) value "white"
     1574    $itk_component(isolinecolor) value $_settings(-isolinecolor)
    15611575    bind $inner.linecolor <<Value>> \
    15621576        [itcl::code $this AdjustSetting -isolinecolor]
     
    17941808                    SendCmd "camera zoom $_view($what)"
    17951809                }
    1796              }
     1810            }
    17971811        }
    17981812    }
     
    18281842    radiobutton $inner.vtk_button -text "VTK data file" \
    18291843        -variable [itcl::scope _downloadPopup(format)] \
    1830         -font "Arial 9 " \
     1844        -font "Arial 9" \
    18311845        -value vtk
    18321846    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
    18331847    radiobutton $inner.image_button -text "Image File" \
    18341848        -variable [itcl::scope _downloadPopup(format)] \
    1835         -font "Arial 9 " \
     1849        -font "Arial 9" \
    18361850        -value image
    18371851    Rappture::Tooltip::for $inner.image_button \
     
    21672181    }
    21682182
    2169     $c bind title <ButtonPress> [itcl::code $this Combo post]
    2170     $c bind title <Enter> [itcl::code $this Combo activate]
    2171     $c bind title <Leave> [itcl::code $this Combo deactivate]
     2183    $c bind title <ButtonPress> [itcl::code $this LegendTitleAction post]
     2184    $c bind title <Enter> [itcl::code $this LegendTitleAction enter]
     2185    $c bind title <Leave> [itcl::code $this LegendTitleAction leave]
    21722186    # Reset the item coordinates according the current size of the plot.
    21732187    $c itemconfigure title -text $title
     
    21942208
    21952209# ----------------------------------------------------------------------
    2196 # USAGE: _dropdown post
    2197 # USAGE: _dropdown unpost
    2198 # USAGE: _dropdown select
    2199 #
    2200 # Used internally to handle the dropdown list for this combobox.  The
    2201 # post/unpost options are invoked when the list is posted or unposted
    2202 # to manage the relief of the controlling button.  The select option
    2203 # is invoked whenever there is a selection from the list, to assign
    2204 # the value back to the gauge.
    2205 # ----------------------------------------------------------------------
    2206 itcl::body Rappture::VtkSurfaceViewer::Combo {option} {
     2210# USAGE: LegendTitleAction post
     2211# USAGE: LegendTitleAction enter
     2212# USAGE: LegendTitleAction leave
     2213# USAGE: LegendTitleAction save
     2214#
     2215# Used internally to handle the dropdown list for the fields menu combobox.
     2216# The post option is invoked when the field title is pressed to launch the
     2217# dropdown.  The enter option is invoked when the user mouses over the field
     2218# title. The leave option is invoked when the user moves the mouse away
     2219# from the field title.  The save option is invoked whenever there is a
     2220# selection from the list, to alert the visualization server.
     2221# ----------------------------------------------------------------------
     2222itcl::body Rappture::VtkSurfaceViewer::LegendTitleAction {option} {
    22072223    set c $itk_component(view)
    22082224    switch -- $option {
     
    22162232            tk_popup $itk_component(fieldmenu) $x $y
    22172233        }
    2218         activate {
     2234        enter {
    22192235            $c itemconfigure title -fill red
    22202236        }
    2221         deactivate {
     2237        leave {
    22222238            $c itemconfigure title -fill $itk_option(-plotforeground)
    22232239        }
    2224         invoke {
     2240        save {
    22252241            $itk_component(field) value $_curFldLabel
    22262242            AdjustSetting -field
    22272243        }
    22282244        default {
    2229             error "bad option \"$option\": should be post, unpost, select"
     2245            error "bad option \"$option\": should be post, enter, leave or save"
    22302246        }
    22312247    }
     
    23172333                -activeforeground $itk_option(-plotforeground) \
    23182334                -font "Arial 8" \
    2319                 -command [itcl::code $this Combo invoke]
     2335                -command [itcl::code $this LegendTitleAction save]
    23202336            set _fields($fname) [list $label $units $components]
    23212337            if { $_curFldName == "" } {
  • branches/1.7/gui/scripts/vtkviewer.tcl

    r6306 r6364  
    104104    private method ReceiveDataset { args }
    105105    private method ReceiveImage { args }
    106     private method ReceiveLegend { colormap title vmin vmax size }
     106    private method ReceiveLegend { colormap title min max size }
    107107    private method RequestLegend {}
    108108    private method Rotate {option x y}
     
    631631        set _dlist [lreplace $_dlist $pos $pos]
    632632        array unset _obj2ovride $dataobj-*
    633         array unset _settings $dataobj-*
    634633        set changed 1
    635634    }
     
    25852584    radiobutton $inner.vtk_button -text "VTK data file" \
    25862585        -variable [itcl::scope _downloadPopup(format)] \
    2587         -font "Helvetica 9 " \
     2586        -font "Arial 9" \
    25882587        -value vtk
    25892588    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
     
    28632862
    28642863# ----------------------------------------------------------------------
    2865 # USAGE: ReceiveLegend <colormap> <title> <vmin> <vmax> <size>
     2864# USAGE: ReceiveLegend <colormap> <title> <min> <max> <size>
    28662865#
    28672866# Invoked automatically whenever the "legend" command comes in from
     
    28692868# specified <size> will follow.
    28702869# ----------------------------------------------------------------------
    2871 itcl::body Rappture::VtkViewer::ReceiveLegend { colormap title vmin vmax size } {
    2872     set _limits(vmin) $vmin
    2873     set _limits(vmax) $vmax
     2870itcl::body Rappture::VtkViewer::ReceiveLegend { colormap title min max size } {
     2871    set _limits(vmin) $min
     2872    set _limits(vmax) $max
    28742873    set _title $title
    28752874    if { [IsConnected] } {
  • branches/1.7/gui/scripts/vtkvolumeviewer.tcl

    r6306 r6364  
    7373    private method BuildVolumeTab {}
    7474    private method ChangeColormap { dataobj comp color }
    75     private method Combo { option }
    7675    private method Connect {}
    7776    private method CurrentDatasets {args}
     
    9190    private method IsValidObject { dataobj }
    9291    private method LeaveLegend {}
     92    private method LegendTitleAction { option }
    9393    private method MotionLegend { x y }
    9494    private method Pan {option x y}
     
    101101    private method ReceiveDataset { args }
    102102    private method ReceiveImage { args }
    103     private method ReceiveLegend { colormap title vmin vmax size }
     103    private method ReceiveLegend { colormap title min max size }
    104104    private method RequestLegend {}
    105105    private method Rotate {option x y}
    106106    private method SetColormap { dataobj comp }
     107    private method SetCurrentFieldName { dataobj }
    107108    private method SetLegendTip { x y }
    108109    private method SetObjectStyle { dataobj cname }
     
    224225    array set _settings {
    225226        -axesvisible            1
    226         -axisflymode            static
    227227        -axislabels             1
    228228        -axisminorticks         1
     229        -axismode               "static"
    229230        -background             black
    230231        -color                  BCGYR
     
    548549        set _dlist [lreplace $_dlist $pos $pos]
    549550        array unset _obj2ovride $dataobj-*
    550         array unset _settings $dataobj-*
    551551        set changed 1
    552552    }
     
    970970        set _first ""
    971971        InitSettings -background \
    972             -xgrid -ygrid -zgrid -axisflymode \
     972            -xgrid -ygrid -zgrid -axismode \
    973973            -axesvisible -axislabels -axisminorticks
    974974        StopBufferingCommands
     
    986986        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
    987987            set _first $dataobj
     988            SetCurrentFieldName $dataobj
    988989        }
    989990        foreach cname [$dataobj components] {
     
    10321033            }
    10331034        }
    1034         $itk_component(field) choices delete 0 end
    1035         $itk_component(fieldmenu) delete 0 end
    1036         array unset _fields
    1037         set _curFldName ""
    1038         foreach cname [$_first components] {
    1039             foreach fname [$_first fieldnames $cname] {
    1040                 if { [info exists _fields($fname)] } {
    1041                     continue
    1042                 }
    1043                 foreach { label units components } \
    1044                     [$_first fieldinfo $fname] break
    1045                 # Only scalar fields are valid
    1046                 if {$_allowMultiComponent || $components == 1} {
    1047                     $itk_component(field) choices insert end "$fname" "$label"
    1048                     $itk_component(fieldmenu) add radiobutton -label "$label" \
    1049                         -value $label -variable [itcl::scope _curFldLabel] \
    1050                         -selectcolor red \
    1051                         -activebackground $itk_option(-plotbackground) \
    1052                         -activeforeground $itk_option(-plotforeground) \
    1053                         -font "Arial 8" \
    1054                         -command [itcl::code $this Combo invoke]
    1055                     set _fields($fname) [list $label $units $components]
    1056                     if { $_curFldName == "" } {
    1057                         set _curFldName $fname
    1058                         set _curFldLabel $label
    1059                     }
    1060                 }
    1061             }
    1062         }
    1063         $itk_component(field) value $_curFldLabel
    10641035    }
    10651036
     
    12961267itcl::body Rappture::VtkVolumeViewer::InitSettings { args } {
    12971268    foreach spec $args {
    1298         if { [info exists _settings($_first${spec})] } {
    1299             # Reset global setting with dataobj specific setting
    1300             set _settings($spec) $_settings($_first${spec})
    1301         }
    13021269        AdjustSetting $spec
    13031270    }
     
    13161283    }
    13171284    switch -- $what {
     1285        "-axesvisible" {
     1286            set bool $_settings($what)
     1287            SendCmd "axis visible all $bool"
     1288        }
     1289        "-axislabels" {
     1290            set bool $_settings($what)
     1291            SendCmd "axis labels all $bool"
     1292        }
     1293        "-axisminorticks" {
     1294            set bool $_settings($what)
     1295            SendCmd "axis minticks all $bool"
     1296        }
     1297        "-axismode" {
     1298            set mode [$itk_component(axismode) value]
     1299            set mode [$itk_component(axismode) translate $mode]
     1300            set _settings($what) $mode
     1301            SendCmd "axis flymode $mode"
     1302        }
    13181303        "-background" {
    13191304            set bgcolor [$itk_component(background) value]
     
    13291314            DrawLegend
    13301315        }
    1331         "-volumeoutline" {
    1332             set bool $_settings($what)
    1333             SendCmd "outline visible 0"
    1334             foreach tag [CurrentDatasets -visible] {
    1335                 SendCmd "outline visible $bool $tag"
    1336             }
    1337         }
    1338         "-legendvisible" {
    1339             DrawLegend
    1340         }
    1341         "-volumevisible" {
    1342             set bool $_settings($what)
    1343             foreach tag [CurrentDatasets -visible] {
    1344                 SendCmd "volume visible $bool $tag"
    1345             }
    1346             if { $bool } {
    1347                 Rappture::Tooltip::for $itk_component(volume) \
    1348                     "Hide the volume"
    1349             } else {
    1350                 Rappture::Tooltip::for $itk_component(volume) \
    1351                     "Show the volume"
    1352             }
    1353         }
    1354         "-volumematerial" {
    1355             set val $_settings($what)
    1356             set diffuse [expr {0.01*$val}]
    1357             set specular [expr {0.01*$val}]
    1358             #set power [expr {sqrt(160*$val+1.0)}]
    1359             set power [expr {$val+1.0}]
    1360             foreach tag [CurrentDatasets -visible] {
    1361                 SendCmd "volume shading diffuse $diffuse $tag"
    1362                 SendCmd "volume shading specular $specular $power $tag"
    1363             }
    1364         }
    1365         "-volumelighting" {
    1366             set bool $_settings($what)
    1367             foreach tag [CurrentDatasets -visible] {
    1368                 SendCmd "volume lighting $bool $tag"
    1369             }
    1370         }
    1371         "-volumeopacity" {
    1372             set val $_settings($what)
    1373             set val [expr {0.01*$val}]
    1374             foreach tag [CurrentDatasets -visible] {
    1375                 SendCmd "volume opacity $val $tag"
    1376             }
    1377         }
    1378         "-volumequality" {
    1379             set val $_settings($what)
    1380             set val [expr {0.01*$val}]
    1381             foreach tag [CurrentDatasets -visible] {
    1382                 SendCmd "volume quality $val $tag"
    1383             }
    1384         }
    1385         "-axesvisible" {
    1386             set bool $_settings($what)
    1387             SendCmd "axis visible all $bool"
    1388         }
    1389         "-axislabels" {
    1390             set bool $_settings($what)
    1391             SendCmd "axis labels all $bool"
    1392         }
    1393         "-axisminorticks" {
    1394             set bool $_settings($what)
    1395             SendCmd "axis minticks all $bool"
    1396         }
    1397         "-xgrid" - "-ygrid" - "-zgrid" {
    1398             set axis [string range $what 1 1]
    1399             set bool $_settings($what)
    1400             SendCmd "axis grid $axis $bool"
    1401         }
    1402         "-axisflymode" {
    1403             set mode [$itk_component(axismode) value]
    1404             set mode [$itk_component(axismode) translate $mode]
    1405             set _settings($what) $mode
    1406             SendCmd "axis flymode $mode"
    1407         }
    1408         "-cutplanesvisible" {
    1409             set bool $_settings($what)
    1410             foreach dataset [CurrentDatasets -visible] {
    1411                 SendCmd "$_cutplaneCmd visible $bool $dataset"
    1412             }
     1316        "-color" {
     1317            set color [$itk_component(colormap) value]
     1318            set _settings($what) $color
     1319            foreach dataset [CurrentDatasets -visible $_first] {
     1320                foreach {dataobj comp} [split $dataset -] break
     1321                ChangeColormap $dataobj $comp $color
     1322            }
     1323            EventuallyRequestLegend
    14131324        }
    14141325        "-cutplanelighting" {
     
    14361347            }
    14371348        }
    1438         "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" {
    1439             set axis [string range $what 1 1]
     1349        "-cutplanesvisible" {
    14401350            set bool $_settings($what)
    1441             if { $bool } {
    1442                 $itk_component(${axis}CutScale) configure -state normal \
    1443                     -troughcolor white
    1444             } else {
    1445                 $itk_component(${axis}CutScale) configure -state disabled \
    1446                     -troughcolor grey82
    1447             }
    14481351            foreach dataset [CurrentDatasets -visible] {
    1449                 SendCmd "$_cutplaneCmd axis $axis $bool $dataset"
    1450             }
    1451         }
    1452         "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" {
    1453             set axis [string range $what 1 1]
    1454             set pos [expr $_settings($what) * 0.01]
    1455             foreach dataset [CurrentDatasets -visible] {
    1456                 SendCmd "$_cutplaneCmd slice ${axis} ${pos} $dataset"
    1457             }
    1458             set _cutplanePending 0
    1459         }
    1460         "-color" {
    1461             set color [$itk_component(colormap) value]
    1462             set _settings($what) $color
    1463             foreach dataset [CurrentDatasets -visible $_first] {
    1464                 foreach {dataobj comp} [split $dataset -] break
    1465                 ChangeColormap $dataobj $comp $color
    1466             }
    1467             EventuallyRequestLegend
     1352                SendCmd "$_cutplaneCmd visible $bool $dataset"
     1353            }
    14681354        }
    14691355        "-field" {
     
    14951381            SendCmd "camera reset"
    14961382            DrawLegend
     1383        }
     1384        "-legendvisible" {
     1385            DrawLegend
     1386        }
     1387        "-volumematerial" {
     1388            set val $_settings($what)
     1389            set diffuse [expr {0.01*$val}]
     1390            set specular [expr {0.01*$val}]
     1391            #set power [expr {sqrt(160*$val+1.0)}]
     1392            set power [expr {$val+1.0}]
     1393            foreach tag [CurrentDatasets -visible] {
     1394                SendCmd "volume shading diffuse $diffuse $tag"
     1395                SendCmd "volume shading specular $specular $power $tag"
     1396            }
     1397        }
     1398        "-volumelighting" {
     1399            set bool $_settings($what)
     1400            foreach tag [CurrentDatasets -visible] {
     1401                SendCmd "volume lighting $bool $tag"
     1402            }
     1403        }
     1404        "-volumeopacity" {
     1405            set val $_settings($what)
     1406            set val [expr {0.01*$val}]
     1407            foreach tag [CurrentDatasets -visible] {
     1408                SendCmd "volume opacity $val $tag"
     1409            }
     1410        }
     1411        "-volumeoutline" {
     1412            set bool $_settings($what)
     1413            SendCmd "outline visible 0"
     1414            foreach tag [CurrentDatasets -visible] {
     1415                SendCmd "outline visible $bool $tag"
     1416            }
     1417        }
     1418        "-volumequality" {
     1419            set val $_settings($what)
     1420            set val [expr {0.01*$val}]
     1421            foreach tag [CurrentDatasets -visible] {
     1422                SendCmd "volume quality $val $tag"
     1423            }
     1424        }
     1425        "-volumevisible" {
     1426            set bool $_settings($what)
     1427            foreach tag [CurrentDatasets -visible] {
     1428                SendCmd "volume visible $bool $tag"
     1429            }
     1430            if { $bool } {
     1431                Rappture::Tooltip::for $itk_component(volume) \
     1432                    "Hide the volume"
     1433            } else {
     1434                Rappture::Tooltip::for $itk_component(volume) \
     1435                    "Show the volume"
     1436            }
     1437        }
     1438        "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" {
     1439            set axis [string range $what 1 1]
     1440            set bool $_settings($what)
     1441            if { $bool } {
     1442                $itk_component(${axis}CutScale) configure -state normal \
     1443                    -troughcolor white
     1444            } else {
     1445                $itk_component(${axis}CutScale) configure -state disabled \
     1446                    -troughcolor grey82
     1447            }
     1448            foreach dataset [CurrentDatasets -visible] {
     1449                SendCmd "$_cutplaneCmd axis $axis $bool $dataset"
     1450            }
     1451        }
     1452        "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" {
     1453            set axis [string range $what 1 1]
     1454            set pos [expr $_settings($what) * 0.01]
     1455            foreach dataset [CurrentDatasets -visible] {
     1456                SendCmd "$_cutplaneCmd slice ${axis} ${pos} $dataset"
     1457            }
     1458            set _cutplanePending 0
     1459        }
     1460        "-xgrid" - "-ygrid" - "-zgrid" {
     1461            set axis [string range $what 1 1]
     1462            set bool $_settings($what)
     1463            SendCmd "axis grid $axis $bool"
    14971464        }
    14981465        default {
     
    18071774        "furthest_triad"  "farthest" \
    18081775        "outer_edges"     "outer"
    1809     $itk_component(axismode) value $_settings(-axisflymode)
    1810     bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode]
     1776    $itk_component(axismode) value $_settings(-axismode)
     1777    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
    18111778
    18121779    blt::table $inner \
     
    20732040    radiobutton $inner.vtk_button -text "VTK data file" \
    20742041        -variable [itcl::scope _downloadPopup(format)] \
    2075         -font "Helvetica 9 " \
     2042        -font "Arial 9" \
    20762043        -value vtk
    20772044    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
     
    21482115
    21492116# ----------------------------------------------------------------------
    2150 # USAGE: ReceiveLegend <colormap> <title> <vmin> <vmax> <size>
     2117# USAGE: ReceiveLegend <colormap> <title> <min> <max> <size>
    21512118#
    21522119# Invoked automatically whenever the "legend" command comes in from
     
    21542121# specified <size> will follow.
    21552122# ----------------------------------------------------------------------
    2156 itcl::body Rappture::VtkVolumeViewer::ReceiveLegend { colormap title vmin vmax size } {
     2123itcl::body Rappture::VtkVolumeViewer::ReceiveLegend { colormap title min max size } {
    21572124    if { [isconnected] } {
    21582125        set bytes [ReceiveBytes $size]
     
    22172184        $c bind colormap <Motion> [itcl::code $this MotionLegend %x %y]
    22182185    }
    2219     $c bind title <ButtonPress> [itcl::code $this Combo post]
    2220     $c bind title <Enter> [itcl::code $this Combo activate]
    2221     $c bind title <Leave> [itcl::code $this Combo deactivate]
     2186    $c bind title <ButtonPress> [itcl::code $this LegendTitleAction post]
     2187    $c bind title <Enter> [itcl::code $this LegendTitleAction enter]
     2188    $c bind title <Leave> [itcl::code $this LegendTitleAction leave]
    22222189    # Reset the item coordinates according the current size of the plot.
    22232190    $c itemconfigure title -text $title
     
    23412308
    23422309# ----------------------------------------------------------------------
    2343 # USAGE: _dropdown post
    2344 # USAGE: _dropdown unpost
    2345 # USAGE: _dropdown select
    2346 #
    2347 # Used internally to handle the dropdown list for this combobox.  The
    2348 # post/unpost options are invoked when the list is posted or unposted
    2349 # to manage the relief of the controlling button.  The select option
    2350 # is invoked whenever there is a selection from the list, to assign
    2351 # the value back to the gauge.
    2352 # ----------------------------------------------------------------------
    2353 itcl::body Rappture::VtkVolumeViewer::Combo {option} {
     2310# USAGE: LegendTitleAction post
     2311# USAGE: LegendTitleAction enter
     2312# USAGE: LegendTitleAction leave
     2313# USAGE: LegendTitleAction save
     2314#
     2315# Used internally to handle the dropdown list for the fields menu combobox.
     2316# The post option is invoked when the field title is pressed to launch the
     2317# dropdown.  The enter option is invoked when the user mouses over the field
     2318# title. The leave option is invoked when the user moves the mouse away
     2319# from the field title.  The save option is invoked whenever there is a
     2320# selection from the list, to alert the visualization server.
     2321# ----------------------------------------------------------------------
     2322itcl::body Rappture::VtkVolumeViewer::LegendTitleAction {option} {
    23542323    set c $itk_component(view)
    23552324    switch -- $option {
     
    23612330            tk_popup $itk_component(fieldmenu) $x $y
    23622331        }
    2363         activate {
     2332        enter {
    23642333            $c itemconfigure title -fill red
    23652334        }
    2366         deactivate {
     2335        leave {
    23672336            $c itemconfigure title -fill $itk_option(-plotforeground)
    23682337        }
    2369         invoke {
     2338        save {
    23702339            $itk_component(field) value $_curFldLabel
    23712340            AdjustSetting -field
    23722341        }
    23732342        default {
    2374             error "bad option \"$option\": should be post, unpost, select"
     2343            error "bad option \"$option\": should be post, enter, leave or save"
    23752344        }
    23762345    }
     
    24122381    return $_volcomponents($cname)
    24132382}
     2383
     2384itcl::body Rappture::VtkVolumeViewer::SetCurrentFieldName { dataobj } {
     2385    set _first $dataobj
     2386    $itk_component(field) choices delete 0 end
     2387    $itk_component(fieldmenu) delete 0 end
     2388    array unset _fields
     2389    set _curFldName ""
     2390    foreach cname [$_first components] {
     2391        foreach fname [$_first fieldnames $cname] {
     2392            if { [info exists _fields($fname)] } {
     2393                continue
     2394            }
     2395            foreach { label units components } \
     2396                [$_first fieldinfo $fname] break
     2397            # Only scalar fields are valid
     2398            if {$_allowMultiComponent || $components == 1} {
     2399                $itk_component(field) choices insert end "$fname" "$label"
     2400                $itk_component(fieldmenu) add radiobutton -label "$label" \
     2401                    -value $label -variable [itcl::scope _curFldLabel] \
     2402                    -selectcolor red \
     2403                    -activebackground $itk_option(-plotbackground) \
     2404                    -activeforeground $itk_option(-plotforeground) \
     2405                    -font "Arial 8" \
     2406                    -command [itcl::code $this LegendTitleAction save]
     2407                set _fields($fname) [list $label $units $components]
     2408                if { $_curFldName == "" } {
     2409                    set _curFldName $fname
     2410                    set _curFldLabel $label
     2411                }
     2412            }
     2413        }
     2414    }
     2415    $itk_component(field) value $_curFldLabel
     2416}
Note: See TracChangeset for help on using the changeset viewer.