Changeset 3175 for branches


Ignore:
Timestamp:
Sep 20, 2012 12:46:32 PM (12 years ago)
Author:
ldelgass
Message:

sync with trunk

Location:
branches/nanovis2
Files:
1 deleted
85 edited
57 copied

Legend:

Unmodified
Added
Removed
  • branches/nanovis2

  • branches/nanovis2/Makefile.in

    r2890 r3175  
    3737  TARGETS += gui builder tester examples
    3838endif
    39 ifeq ($(HAVE_FFMEG),)
     39ifneq ($(HAVE_FFMPEG),)
    4040  TARGETS += video
    4141endif
  • branches/nanovis2/builder/scripts/hierlist.tcl

    r2081 r3175  
    371371# ----------------------------------------------------------------------
    372372itcl::body Rappture::Hierlist::dd_get_source {widget x y} {
     373    # convert from screen coords to canvas coords (for scrollbars)
     374    set x [$widget canvasx $x]
     375    set y [$widget canvasy $y]
     376
    373377    set data ""
    374     foreach id [$itk_component(area) find overlapping $x $y $x $y] {
    375         foreach tag [$itk_component(area) gettags $id] {
     378    foreach id [$widget find overlapping $x $y $x $y] {
     379        foreach tag [$widget gettags $id] {
    376380            # search for a tag like item:NNN and make sure it's selected
    377381            if {[regexp {^item:([0-9]+)$} $tag match node]
  • branches/nanovis2/builder/scripts/main.tcl

    r2253 r3175  
    8787
    8888switch $tcl_platform(platform) {
    89     unix - windows {
     89    unix {
     90        event add <<PopupMenu>> <ButtonPress-3>
     91
     92        # make Ctrl-V binding work:
     93        # not strict Motif, and remove conflicting binding in Tk library
     94        set tk_strictMotif 0
     95        bind Text <Control-v> ""
     96    }
     97    windows {
    9098        event add <<PopupMenu>> <ButtonPress-3>
    9199    }
     
    659667# ----------------------------------------------------------------------
    660668proc main_saveas {{option "start"}} {
    661     global SaveAs ToolXml LastToolXmlFile LastToolXmlLoaded
     669    global tcl_platform SaveAs ToolXml LastToolXmlFile LastToolXmlLoaded
    662670
    663671    switch -- $option {
     
    846854                    set pfile "main$SaveAs(ext)"
    847855                }
     856                set fname [file tail $pfile]
    848857                set mfile [file join [file dirname $pfile] Makefile]
    849858                if {[file exists $mfile]} {
     
    858867                }
    859868
    860                 set fname [file tail $pfile]
    861                 set dir [file dirname [file dirname $::Rappture::installdir]]
     869                # /apps/rappture/current for 32-bit systems
     870                # /apps/share64/rappture/current for 64-bit systems
     871                if {$tcl_platform(wordSize) == 8
     872                      && [file isdirectory /apps/share64/rappture/current]} {
     873                    set dir /apps/share64/rappture/current
     874                } else {
     875                    set dir /apps/rappture/current
     876                }
     877                if {![file isdirectory $dir]} {
     878                    # if all else fails, ask the current Rappture for its install dir
     879                    set dir [file dirname [file dirname $::Rappture::installdir]]
     880                }
     881
    862882                set macros [list @@RAPPTUREDIR@@ $dir]
    863883                lappend macros @@FILENAME@@ $fname
     
    10831103    # turn off download options and clear button
    10841104    $f.analyze component download configure -state disabled
    1085     $f.analyze component resultset component clear configure -state disabled
    1086     # remove the "---" and "Download..." options from the result selector
    1087     $f.analyze component resultselector choices delete end
    1088     $f.analyze component resultselector choices delete end
     1105    $f.analyze component resultselector component clear configure -state disabled
     1106    # remove the "---" and "Download..." options from the view selector
     1107    $f.analyze component viewselector choices delete end
     1108    $f.analyze component viewselector choices delete end
    10891109}
    10901110
     
    15271547set ErrFocusAttr ""
    15281548
    1529 if {"" != $params(-tool)} {
     1549if {$params(-tool) ne ""} {
    15301550    if {![file exists $params(-tool)]} {
    15311551        puts stderr "can't find tool \"$params(-tool)\""
     
    15331553    }
    15341554    main_open $params(-tool)
     1555} elseif {[file exists tool.xml]} {
     1556    main_open tool.xml
    15351557} else {
    15361558    main_open -new
  • branches/nanovis2/cf/rpLangJava.m4

    r2298 r3175  
    3030   ${JAVA_HOME} \
    3131   /apps/java/jdk1.6* \
     32   /usr/lib/jvm/java-6-openjdk \
     33   /usr/lib/jvm/icedtea-6 \
    3234   /usr/lib/jvm/*sun-1.6* \
    3335   /opt/sun-jdk-1.6* \
     36   /usr/lib/jvm/icedtea-7 \
    3437   /opt/icedtea6-* \
    3538   /opt/sun-jdk-1.5* \
    36    /usr/lib/jvm/*sun-1.5*
     39   /usr/lib/jvm/*sun-1.5* 
    3740  do
    3841    if test -r "${d}/include/jni.h" ; then
  • branches/nanovis2/configure

    r2890 r3175  
    11#! /bin/sh
    22# Guess values for system-dependent variables and create Makefiles.
    3 # Generated by GNU Autoconf 2.68 for Rappture 1.1.
     3# Generated by GNU Autoconf 2.69 for Rappture 1.1.
    44#
    55# Report bugs to <rappture@nanohub.org>.
    66#
    77#
    8 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
    9 # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
    10 # Foundation, Inc.
     8# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
    119#
    1210#
     
    137135(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
    138136
     137# Use a proper internal environment variable to ensure we don't fall
     138  # into an infinite loop, continuously re-executing ourselves.
     139  if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
     140    _as_can_reexec=no; export _as_can_reexec;
     141    # We cannot yet assume a decent shell, so we have to provide a
     142# neutralization value for shells without unset; and this also
     143# works around shells that cannot unset nonexistent variables.
     144# Preserve -v and -x to the replacement shell.
     145BASH_ENV=/dev/null
     146ENV=/dev/null
     147(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
     148case $- in # ((((
     149  *v*x* | *x*v* ) as_opts=-vx ;;
     150  *v* ) as_opts=-v ;;
     151  *x* ) as_opts=-x ;;
     152  * ) as_opts= ;;
     153esac
     154exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
     155# Admittedly, this is quite paranoid, since all the known shells bail
     156# out after a failed `exec'.
     157$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
     158as_fn_exit 255
     159  fi
     160  # We don't want this to propagate to other subprocesses.
     161          { _as_can_reexec=; unset _as_can_reexec;}
    139162if test "x$CONFIG_SHELL" = x; then
    140163  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
     
    170193  exitcode=1; echo positional parameters were not saved.
    171194fi
    172 test x\$exitcode = x0 || exit 1"
     195test x\$exitcode = x0 || exit 1
     196test -x / || exit 1"
    173197  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
    174198  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
     
    215239
    216240      if test "x$CONFIG_SHELL" != x; then :
    217   # We cannot yet assume a decent shell, so we have to provide a
    218         # neutralization value for shells without unset; and this also
    219         # works around shells that cannot unset nonexistent variables.
    220         # Preserve -v and -x to the replacement shell.
    221         BASH_ENV=/dev/null
    222         ENV=/dev/null
    223         (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
    224         export CONFIG_SHELL
    225         case $- in # ((((
    226           *v*x* | *x*v* ) as_opts=-vx ;;
    227           *v* ) as_opts=-v ;;
    228           *x* ) as_opts=-x ;;
    229           * ) as_opts= ;;
    230         esac
    231         exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
     241  export CONFIG_SHELL
     242             # We cannot yet assume a decent shell, so we have to provide a
     243# neutralization value for shells without unset; and this also
     244# works around shells that cannot unset nonexistent variables.
     245# Preserve -v and -x to the replacement shell.
     246BASH_ENV=/dev/null
     247ENV=/dev/null
     248(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
     249case $- in # ((((
     250  *v*x* | *x*v* ) as_opts=-vx ;;
     251  *v* ) as_opts=-v ;;
     252  *x* ) as_opts=-x ;;
     253  * ) as_opts= ;;
     254esac
     255exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
     256# Admittedly, this is quite paranoid, since all the known shells bail
     257# out after a failed `exec'.
     258$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
     259exit 255
    232260fi
    233261
     
    332360
    333361} # as_fn_mkdir_p
     362
     363# as_fn_executable_p FILE
     364# -----------------------
     365# Test if FILE is an executable regular file.
     366as_fn_executable_p ()
     367{
     368  test -f "$1" && test -x "$1"
     369} # as_fn_executable_p
    334370# as_fn_append VAR VALUE
    335371# ----------------------
     
    453489    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
    454490
     491  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
     492  # already done that, so ensure we don't try to do so again and fall
     493  # in an infinite loop.  This has already happened in practice.
     494  _as_can_reexec=no; export _as_can_reexec
    455495  # Don't try to exec as it changes $[0], causing all sort of problems
    456496  # (the dirname of $[0] is not the place where we might find the
     
    487527    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
    488528    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
    489     # In both cases, we have to default to `cp -p'.
     529    # In both cases, we have to default to `cp -pR'.
    490530    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
    491       as_ln_s='cp -p'
     531      as_ln_s='cp -pR'
    492532  elif ln conf$$.file conf$$ 2>/dev/null; then
    493533    as_ln_s=ln
    494534  else
    495     as_ln_s='cp -p'
     535    as_ln_s='cp -pR'
    496536  fi
    497537else
    498   as_ln_s='cp -p'
     538  as_ln_s='cp -pR'
    499539fi
    500540rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
     
    508548fi
    509549
    510 if test -x / >/dev/null 2>&1; then
    511   as_test_x='test -x'
    512 else
    513   if ls -dL / >/dev/null 2>&1; then
    514     as_ls_L_option=L
    515   else
    516     as_ls_L_option=
    517   fi
    518   as_test_x='
    519     eval sh -c '\''
    520       if test -d "$1"; then
    521         test -d "$1/.";
    522       else
    523         case $1 in #(
    524         -*)set "./$1";;
    525         esac;
    526         case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
    527         ???[sx]*):;;*)false;;esac;fi
    528     '\'' sh
    529   '
    530 fi
    531 as_executable_p=$as_test_x
     550as_test_x='test -x'
     551as_executable_p=as_fn_executable_p
    532552
    533553# Sed expression to map a string onto a valid CPP name.
     
    12691289  if test "x$build_alias" = x; then
    12701290    cross_compiling=maybe
    1271     $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
    1272     If a cross compiler is detected then cross compile mode will be used" >&2
    12731291  elif test "x$build_alias" != "x$host_alias"; then
    12741292    cross_compiling=yes
     
    15341552  cat <<\_ACEOF
    15351553Rappture configure 1.1
    1536 generated by GNU Autoconf 2.68
    1537 
    1538 Copyright (C) 2010 Free Software Foundation, Inc.
     1554generated by GNU Autoconf 2.69
     1555
     1556Copyright (C) 2012 Free Software Foundation, Inc.
    15391557This configure script is free software; the Free Software Foundation
    15401558gives unlimited permission to copy, distribute and modify it.
     
    17671785       } && test -s conftest$ac_exeext && {
    17681786         test "$cross_compiling" = yes ||
    1769          $as_test_x conftest$ac_exeext
     1787         test -x conftest$ac_exeext
    17701788       }; then :
    17711789  ac_retval=0
     
    18801898       } && test -s conftest$ac_exeext && {
    18811899         test "$cross_compiling" = yes ||
    1882          $as_test_x conftest$ac_exeext
     1900         test -x conftest$ac_exeext
    18831901       }; then :
    18841902  ac_retval=0
     
    21842202{
    21852203static int test_array [1 - 2 * !(($2) >= 0)];
    2186 test_array [0] = 0
     2204test_array [0] = 0;
     2205return test_array [0];
    21872206
    21882207  ;
     
    22002219{
    22012220static int test_array [1 - 2 * !(($2) <= $ac_mid)];
    2202 test_array [0] = 0
     2221test_array [0] = 0;
     2222return test_array [0];
    22032223
    22042224  ;
     
    22262246{
    22272247static int test_array [1 - 2 * !(($2) < 0)];
    2228 test_array [0] = 0
     2248test_array [0] = 0;
     2249return test_array [0];
    22292250
    22302251  ;
     
    22422263{
    22432264static int test_array [1 - 2 * !(($2) >= $ac_mid)];
    2244 test_array [0] = 0
     2265test_array [0] = 0;
     2266return test_array [0];
    22452267
    22462268  ;
     
    22762298{
    22772299static int test_array [1 - 2 * !(($2) <= $ac_mid)];
    2278 test_array [0] = 0
     2300test_array [0] = 0;
     2301return test_array [0];
    22792302
    22802303  ;
     
    23492372
    23502373It was created by Rappture $as_me 1.1, which was
    2351 generated by GNU Autoconf 2.68.  Invocation command line was
     2374generated by GNU Autoconf 2.69.  Invocation command line was
    23522375
    23532376  $ $0 $@
     
    27992822    for ac_prog in ginstall scoinst install; do
    28002823      for ac_exec_ext in '' $ac_executable_extensions; do
    2801         if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
     2824        if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
    28022825          if test $ac_prog = install &&
    28032826            grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
     
    28732896  test -z "$as_dir" && as_dir=.
    28742897    for ac_exec_ext in '' $ac_executable_extensions; do
    2875   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     2898  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    28762899    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
    28772900    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    29132936  test -z "$as_dir" && as_dir=.
    29142937    for ac_exec_ext in '' $ac_executable_extensions; do
    2915   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     2938  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    29162939    ac_cv_prog_ac_ct_RANLIB="ranlib"
    29172940    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    29722995    for ac_prog in mkdir gmkdir; do
    29732996         for ac_exec_ext in '' $ac_executable_extensions; do
    2974            { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
     2997           as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue
    29752998           case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
    29762999             'mkdir (GNU coreutils) '* | \
     
    30563079  test -z "$as_dir" && as_dir=.
    30573080    for ac_exec_ext in '' $ac_executable_extensions; do
    3058   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     3081  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    30593082    ac_cv_prog_CC="${ac_tool_prefix}gcc"
    30603083    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    30963119  test -z "$as_dir" && as_dir=.
    30973120    for ac_exec_ext in '' $ac_executable_extensions; do
    3098   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     3121  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    30993122    ac_cv_prog_ac_ct_CC="gcc"
    31003123    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    31493172  test -z "$as_dir" && as_dir=.
    31503173    for ac_exec_ext in '' $ac_executable_extensions; do
    3151   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     3174  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    31523175    ac_cv_prog_CC="${ac_tool_prefix}cc"
    31533176    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    31903213  test -z "$as_dir" && as_dir=.
    31913214    for ac_exec_ext in '' $ac_executable_extensions; do
    3192   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     3215  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    31933216    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
    31943217       ac_prog_rejected=yes
     
    32483271  test -z "$as_dir" && as_dir=.
    32493272    for ac_exec_ext in '' $ac_executable_extensions; do
    3250   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     3273  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    32513274    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
    32523275    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    32923315  test -z "$as_dir" && as_dir=.
    32933316    for ac_exec_ext in '' $ac_executable_extensions; do
    3294   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     3317  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    32953318    ac_cv_prog_ac_ct_CC="$ac_prog"
    32963319    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    37383761#include <stdarg.h>
    37393762#include <stdio.h>
    3740 #include <sys/types.h>
    3741 #include <sys/stat.h>
     3763struct stat;
    37423764/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
    37433765struct buf { int x; };
     
    38523874  test -z "$as_dir" && as_dir=.
    38533875    for ac_exec_ext in '' $ac_executable_extensions; do
    3854   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     3876  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    38553877    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
    38563878    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    38963918  test -z "$as_dir" && as_dir=.
    38973919    for ac_exec_ext in '' $ac_executable_extensions; do
    3898   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     3920  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    38993921    ac_cv_prog_ac_ct_CXX="$ac_prog"
    39003922    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    41054127  test -z "$as_dir" && as_dir=.
    41064128    for ac_exec_ext in '' $ac_executable_extensions; do
    4107   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     4129  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    41084130    ac_cv_prog_F77="$ac_tool_prefix$ac_prog"
    41094131    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    41494171  test -z "$as_dir" && as_dir=.
    41504172    for ac_exec_ext in '' $ac_executable_extensions; do
    4151   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     4173  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    41524174    ac_cv_prog_ac_ct_F77="$ac_prog"
    41534175    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    44564478    for ac_exec_ext in '' $ac_executable_extensions; do
    44574479      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
    4458       { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
     4480      as_fn_executable_p "$ac_path_GREP" || continue
    44594481# Check for GNU ac_path_GREP and select it if it is found.
    44604482  # Check for GNU $ac_path_GREP
     
    45224544    for ac_exec_ext in '' $ac_executable_extensions; do
    45234545      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
    4524       { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
     4546      as_fn_executable_p "$ac_path_EGREP" || continue
    45254547# Check for GNU ac_path_EGREP and select it if it is found.
    45264548  # Check for GNU $ac_path_EGREP
     
    49594981
    49604982else
    4961   as_fn_error $? "ncursers library missing?" "$LINENO" 5
     4983  as_fn_error $? "ncurses library missing?" "$LINENO" 5
    49624984fi
    49634985
     
    56055627  test -z "$as_dir" && as_dir=.
    56065628    for ac_exec_ext in '' $ac_executable_extensions; do
    5607   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     5629  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    56085630    ac_cv_prog_AR="ar"
    56095631    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    73397361  test -z "$as_dir" && as_dir=.
    73407362    for ac_exec_ext in '' $ac_executable_extensions; do
    7341   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     7363  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    73427364    ac_cv_path_TCLSH="$as_dir/$ac_word$ac_exec_ext"
    73437365    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    73817403  test -z "$as_dir" && as_dir=.
    73827404    for ac_exec_ext in '' $ac_executable_extensions; do
    7383   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     7405  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    73847406    ac_cv_path_TCLSH="$as_dir/$ac_word$ac_exec_ext"
    73857407    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    74827504  test -z "$as_dir" && as_dir=.
    74837505    for ac_exec_ext in '' $ac_executable_extensions; do
    7484   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     7506  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    74857507    ac_cv_path_MATLAB="$as_dir/$ac_word$ac_exec_ext"
    74867508    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    75247546  test -z "$as_dir" && as_dir=.
    75257547    for ac_exec_ext in '' $ac_executable_extensions; do
    7526   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     7548  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    75277549    ac_cv_path_MATLAB="$as_dir/$ac_word$ac_exec_ext"
    75287550    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    75747596  test -z "$as_dir" && as_dir=.
    75757597    for ac_exec_ext in '' $ac_executable_extensions; do
    7576   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     7598  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    75777599    ac_cv_path_MEX="$as_dir/$ac_word$ac_exec_ext"
    75787600    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    76147636  test -z "$as_dir" && as_dir=.
    76157637    for ac_exec_ext in '' $ac_executable_extensions; do
    7616   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     7638  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    76177639    ac_cv_path_MEXEXT="$as_dir/$ac_word$ac_exec_ext"
    76187640    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    76657687  test -z "$as_dir" && as_dir=.
    76667688    for ac_exec_ext in '' $ac_executable_extensions; do
    7667   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     7689  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    76687690    ac_cv_path_MCC="$as_dir/$ac_word$ac_exec_ext"
    76697691    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    77277749  test -z "$as_dir" && as_dir=.
    77287750    for ac_exec_ext in '' $ac_executable_extensions; do
    7729   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     7751  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    77307752    ac_cv_path_OCTAVE="$as_dir/$ac_word$ac_exec_ext"
    77317753    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    77677789  test -z "$as_dir" && as_dir=.
    77687790    for ac_exec_ext in '' $ac_executable_extensions; do
    7769   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     7791  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    77707792    ac_cv_path_MKOCTFILE="$as_dir/$ac_word$ac_exec_ext"
    77717793    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    78547876  test -z "$as_dir" && as_dir=.
    78557877    for ac_exec_ext in '' $ac_executable_extensions; do
    7856   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     7878  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    78577879    ac_cv_path_mkoctfile3="$as_dir/$ac_word$ac_exec_ext"
    78587880    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    79147936  test -z "$as_dir" && as_dir=.
    79157937    for ac_exec_ext in '' $ac_executable_extensions; do
    7916   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     7938  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    79177939    ac_cv_path_mkoctfile2="$as_dir/$ac_word$ac_exec_ext"
    79187940    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    79888010  test -z "$as_dir" && as_dir=.
    79898011    for ac_exec_ext in '' $ac_executable_extensions; do
    7990   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     8012  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    79918013    ac_cv_path_PERL="$as_dir/$ac_word$ac_exec_ext"
    79928014    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    80298051  test -z "$as_dir" && as_dir=.
    80308052    for ac_exec_ext in '' $ac_executable_extensions; do
    8031   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     8053  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    80328054    ac_cv_path_XSUBPP="$as_dir/$ac_word$ac_exec_ext"
    80338055    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    80708092  test -z "$as_dir" && as_dir=.
    80718093    for ac_exec_ext in '' $ac_executable_extensions; do
    8072   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     8094  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    80738095    ac_cv_path_PERL="$as_dir/$ac_word$ac_exec_ext"
    80748096    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    81108132  test -z "$as_dir" && as_dir=.
    81118133    for ac_exec_ext in '' $ac_executable_extensions; do
    8112   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     8134  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    81138135    ac_cv_path_XSUBPP="$as_dir/$ac_word$ac_exec_ext"
    81148136    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    81928214  test -z "$as_dir" && as_dir=.
    81938215    for ac_exec_ext in '' $ac_executable_extensions; do
    8194   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     8216  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    81958217    ac_cv_path_PYTHON="$as_dir/$ac_word$ac_exec_ext"
    81968218    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    82348256  test -z "$as_dir" && as_dir=.
    82358257    for ac_exec_ext in '' $ac_executable_extensions; do
    8236   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     8258  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    82378259    ac_cv_path_PYTHON="$as_dir/$ac_word$ac_exec_ext"
    82388260    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    83558377  test -z "$as_dir" && as_dir=.
    83568378    for ac_exec_ext in '' $ac_executable_extensions; do
    8357   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     8379  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    83588380    ac_cv_path_JAVA="$as_dir/$ac_word$ac_exec_ext"
    83598381    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    83958417  test -z "$as_dir" && as_dir=.
    83968418    for ac_exec_ext in '' $ac_executable_extensions; do
    8397   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     8419  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    83988420    ac_cv_path_JAVAC="$as_dir/$ac_word$ac_exec_ext"
    83998421    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    84358457  test -z "$as_dir" && as_dir=.
    84368458    for ac_exec_ext in '' $ac_executable_extensions; do
    8437   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     8459  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    84388460    ac_cv_path_JAVAH="$as_dir/$ac_word$ac_exec_ext"
    84398461    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    84778499  test -z "$as_dir" && as_dir=.
    84788500    for ac_exec_ext in '' $ac_executable_extensions; do
    8479   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     8501  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    84808502    ac_cv_path_JAVA="$as_dir/$ac_word$ac_exec_ext"
    84818503    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    85188540  test -z "$as_dir" && as_dir=.
    85198541    for ac_exec_ext in '' $ac_executable_extensions; do
    8520   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     8542  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    85218543    ac_cv_path_JAVAC="$as_dir/$ac_word$ac_exec_ext"
    85228544    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    85598581  test -z "$as_dir" && as_dir=.
    85608582    for ac_exec_ext in '' $ac_executable_extensions; do
    8561   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     8583  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    85628584    ac_cv_path_JAVAH="$as_dir/$ac_word$ac_exec_ext"
    85638585    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    85938615   ${JAVA_HOME} \
    85948616   /apps/java/jdk1.6* \
     8617   /usr/lib/jvm/java-6-openjdk \
     8618   /usr/lib/jvm/icedtea-6 \
    85958619   /usr/lib/jvm/*sun-1.6* \
    85968620   /opt/sun-jdk-1.6* \
     8621   /usr/lib/jvm/icedtea-7 \
    85978622   /opt/icedtea6-* \
    85988623   /opt/sun-jdk-1.5* \
     
    86478672  test -z "$as_dir" && as_dir=.
    86488673    for ac_exec_ext in '' $ac_executable_extensions; do
    8649   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     8674  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    86508675    ac_cv_path_R="$as_dir/$ac_word$ac_exec_ext"
    86518676    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    86898714  test -z "$as_dir" && as_dir=.
    86908715    for ac_exec_ext in '' $ac_executable_extensions; do
    8691   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     8716  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    86928717    ac_cv_path_R="$as_dir/$ac_word$ac_exec_ext"
    86938718    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    87488773  test -z "$as_dir" && as_dir=.
    87498774    for ac_exec_ext in '' $ac_executable_extensions; do
    8750   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     8775  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    87518776    ac_cv_path_RUBY="$as_dir/$ac_word$ac_exec_ext"
    87528777    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    87908815  test -z "$as_dir" && as_dir=.
    87918816    for ac_exec_ext in '' $ac_executable_extensions; do
    8792   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     8817  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    87938818    ac_cv_path_RUBY="$as_dir/$ac_word$ac_exec_ext"
    87948819    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    88408865    for ac_exec_ext in '' $ac_executable_extensions; do
    88418866      ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
    8842       { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue
     8867      as_fn_executable_p "$ac_path_SED" || continue
    88438868# Check for GNU ac_path_SED and select it if it is found.
    88448869  # Check for GNU $ac_path_SED
     
    89258950  test -z "$as_dir" && as_dir=.
    89268951    for ac_exec_ext in '' $ac_executable_extensions; do
    8927   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     8952  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    89288953    ac_cv_prog_AWK="$ac_prog"
    89298954    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     
    1002610051fi
    1002710052
     10053  for ac_func in sws_getCachedContext
     10054do :
     10055  ac_fn_cxx_check_func "$LINENO" "sws_getCachedContext" "ac_cv_func_sws_getCachedContext"
     10056if test "x$ac_cv_func_sws_getCachedContext" = xyes; then :
     10057  cat >>confdefs.h <<_ACEOF
     10058#define HAVE_SWS_GETCACHEDCONTEXT 1
     10059_ACEOF
     10060
     10061fi
     10062done
     10063
     10064  for ac_func in img_convert
     10065do :
     10066  ac_fn_cxx_check_func "$LINENO" "img_convert" "ac_cv_func_img_convert"
     10067if test "x$ac_cv_func_img_convert" = xyes; then :
     10068  cat >>confdefs.h <<_ACEOF
     10069#define HAVE_IMG_CONVERT 1
     10070_ACEOF
     10071
     10072fi
     10073done
     10074
     10075  for ac_func in sws_scale
     10076do :
     10077  ac_fn_cxx_check_func "$LINENO" "sws_scale" "ac_cv_func_sws_scale"
     10078if test "x$ac_cv_func_sws_scale" = xyes; then :
     10079  cat >>confdefs.h <<_ACEOF
     10080#define HAVE_SWS_SCALE 1
     10081_ACEOF
     10082
     10083fi
     10084done
    1002810085
    1002910086  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
     
    1015210209
    1015310210
    10154 ac_config_files="$ac_config_files Makefile packages/Makefile src/Makefile src/core/Makefile src/core2/Makefile src/objects/Makefile src/objects/RpHash.h gui/Makefile gui/apps/Makefile gui/apps/about gui/apps/copy_rappture_examples gui/apps/encodedata gui/apps/rappture gui/apps/rappture-csh.env gui/apps/rappture.env gui/apps/rappture.use gui/apps/rerun gui/apps/simsim gui/apps/xmldiff gui/pkgIndex.tcl gui/scripts/Makefile gui/src/Makefile builder/Makefile builder/pkgIndex.tcl builder/scripts/Makefile tester/Makefile tester/pkgIndex.tcl tester/scripts/Makefile lang/Makefile lang/java/Makefile lang/java/rappture/Makefile lang/perl/Makefile lang/perl/Makefile.PL lang/python/Makefile lang/python/setup.py lang/matlab/Makefile lang/octave/Makefile lang/octave/octave2/Makefile lang/octave/octave3/Makefile lang/R/Makefile lang/ruby/Makefile lang/ruby/build.rb lang/tcl/Makefile lang/tcl/pkgIndex.tcl lang/tcl/src/Makefile lang/tcl/scripts/Makefile lang/tcl/tests/Makefile lib/Makefile examples/3D/Makefile examples/Makefile examples/app-fermi/2.0/Makefile examples/app-fermi/Makefile examples/app-fermi/cee/Makefile examples/app-fermi/fortran/Makefile examples/app-fermi/java/Makefile examples/app-fermi/matlab/Makefile examples/app-fermi/matlab/compiled/Makefile examples/app-fermi/matlab/uncompiled/Makefile examples/app-fermi/octave/octave2/Makefile examples/app-fermi/octave/octave3/Makefile examples/app-fermi/octave/Makefile examples/app-fermi/perl/Makefile examples/app-fermi/python/Makefile examples/app-fermi/ruby/Makefile examples/app-fermi/tcl/Makefile examples/app-fermi/wrapper/Makefile examples/app-fermi/wrapper/cee/Makefile examples/app-fermi/wrapper/perl/Makefile examples/app-fermi/wrapper/python/Makefile examples/app-fermi/wrapper/tcl/Makefile examples/app-fermi/R/Makefile examples/c-example/Makefile examples/canvas/Makefile examples/demo.bash examples/flow/Makefile examples/flow/demo1/Makefile examples/flow/demo2/Makefile examples/flow/demo3/Makefile examples/graph/Makefile examples/objects/Makefile examples/objects/axis/Makefile examples/objects/contour/Makefile examples/objects/curve/Makefile examples/objects/dxWriter/Makefile examples/objects/floatBuffer/Makefile examples/objects/histogram/Makefile examples/objects/library/Makefile examples/objects/number/Makefile examples/objects/path/Makefile examples/objects/plot/Makefile examples/objects/scatter/Makefile examples/objects/string/Makefile examples/objects/tree/Makefile examples/objects/xmlparser/Makefile examples/zoo/Makefile examples/zoo/binary/Makefile examples/zoo/boolean/Makefile examples/zoo/choice/Makefile examples/zoo/cloud/Makefile examples/zoo/cloud/matlab/Makefile examples/zoo/curve/Makefile examples/zoo/enable/Makefile examples/zoo/field/Makefile examples/zoo/group/Makefile examples/zoo/histogram/Makefile examples/zoo/image/Makefile examples/zoo/image/docs/Makefile examples/zoo/image/examples/Makefile examples/zoo/integer/Makefile examples/zoo/integer2/Makefile examples/zoo/loader/Makefile examples/zoo/loader/examples/Makefile examples/zoo/loadrun/Makefile examples/zoo/log/Makefile examples/zoo/note/Makefile examples/zoo/note/docs/Makefile examples/zoo/number/Makefile examples/zoo/number2/Makefile examples/zoo/parallelepiped/Makefile examples/zoo/periodicelement/Makefile examples/zoo/phase/Makefile examples/zoo/sequence/Makefile examples/zoo/sequence/examples/Makefile examples/zoo/string/Makefile examples/zoo/structure/Makefile examples/zoo/structure/examples/Makefile examples/zoo/table/Makefile examples/zoo/unirect2d/Makefile video/Makefile video/pkgIndex.tcl oldtest/Makefile oldtest/src/Makefile"
     10211ac_config_files="$ac_config_files Makefile packages/Makefile src/Makefile src/core/Makefile src/core2/Makefile src/objects/Makefile src/objects/RpHash.h gui/Makefile gui/apps/Makefile gui/apps/about gui/apps/copy_rappture_examples gui/apps/encodedata gui/apps/rappture gui/apps/rappture-csh.env gui/apps/rappture.env gui/apps/rappture.use gui/apps/rerun gui/apps/simsim gui/apps/xmldiff gui/pkgIndex.tcl gui/scripts/Makefile gui/src/Makefile builder/Makefile builder/pkgIndex.tcl builder/scripts/Makefile tester/Makefile tester/pkgIndex.tcl tester/scripts/Makefile lang/Makefile lang/java/Makefile lang/java/rappture/Makefile lang/perl/Makefile lang/perl/Makefile.PL lang/python/Makefile lang/python/setup.py lang/matlab/Makefile lang/octave/Makefile lang/octave/octave2/Makefile lang/octave/octave3/Makefile lang/R/Makefile lang/ruby/Makefile lang/ruby/build.rb lang/tcl/Makefile lang/tcl/pkgIndex.tcl lang/tcl/src/Makefile lang/tcl/scripts/Makefile lang/tcl/tests/Makefile lib/Makefile examples/3D/Makefile examples/Makefile examples/app-fermi/2.0/Makefile examples/app-fermi/Makefile examples/app-fermi/cee/Makefile examples/app-fermi/fortran/Makefile examples/app-fermi/java/Makefile examples/app-fermi/matlab/Makefile examples/app-fermi/matlab/compiled/Makefile examples/app-fermi/matlab/uncompiled/Makefile examples/app-fermi/octave/octave2/Makefile examples/app-fermi/octave/octave3/Makefile examples/app-fermi/octave/Makefile examples/app-fermi/perl/Makefile examples/app-fermi/python/Makefile examples/app-fermi/ruby/Makefile examples/app-fermi/tcl/Makefile examples/app-fermi/wrapper/Makefile examples/app-fermi/wrapper/cee/Makefile examples/app-fermi/wrapper/perl/Makefile examples/app-fermi/wrapper/python/Makefile examples/app-fermi/wrapper/tcl/Makefile examples/app-fermi/R/Makefile examples/c-example/Makefile examples/canvas/Makefile examples/demo.bash examples/flow/Makefile examples/flow/demo1/Makefile examples/flow/demo2/Makefile examples/flow/demo3/Makefile examples/graph/Makefile examples/objects/Makefile examples/objects/axis/Makefile examples/objects/contour/Makefile examples/objects/curve/Makefile examples/objects/dxWriter/Makefile examples/objects/floatBuffer/Makefile examples/objects/histogram/Makefile examples/objects/library/Makefile examples/objects/number/Makefile examples/objects/path/Makefile examples/objects/plot/Makefile examples/objects/scatter/Makefile examples/objects/string/Makefile examples/objects/tree/Makefile examples/objects/xmlparser/Makefile examples/zoo/Makefile examples/zoo/binary/Makefile examples/zoo/boolean/Makefile examples/zoo/choice/Makefile examples/zoo/cloud/Makefile examples/zoo/cloud/matlab/Makefile examples/zoo/curve/Makefile examples/zoo/drawing/Makefile examples/zoo/enable/Makefile examples/zoo/field/Makefile examples/zoo/group/Makefile examples/zoo/histogram/Makefile examples/zoo/image/Makefile examples/zoo/image/docs/Makefile examples/zoo/image/examples/Makefile examples/zoo/integer/Makefile examples/zoo/integer2/Makefile examples/zoo/loader/Makefile examples/zoo/loader/examples/Makefile examples/zoo/log/Makefile examples/zoo/note/Makefile examples/zoo/note/docs/Makefile examples/zoo/number/Makefile examples/zoo/number2/Makefile examples/zoo/parallelepiped/Makefile examples/zoo/periodicelement/Makefile examples/zoo/phase/Makefile examples/zoo/sequence/Makefile examples/zoo/sequence/examples/Makefile examples/zoo/string/Makefile examples/zoo/structure/Makefile examples/zoo/structure/examples/Makefile examples/zoo/table/Makefile examples/zoo/unirect2d/Makefile video/Makefile video/pkgIndex.tcl oldtest/Makefile oldtest/src/Makefile"
    1015510212
    1015610213cat >confcache <<\_ACEOF
     
    1056210619    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
    1056310620    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
    10564     # In both cases, we have to default to `cp -p'.
     10621    # In both cases, we have to default to `cp -pR'.
    1056510622    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
    10566       as_ln_s='cp -p'
     10623      as_ln_s='cp -pR'
    1056710624  elif ln conf$$.file conf$$ 2>/dev/null; then
    1056810625    as_ln_s=ln
    1056910626  else
    10570     as_ln_s='cp -p'
     10627    as_ln_s='cp -pR'
    1057110628  fi
    1057210629else
    10573   as_ln_s='cp -p'
     10630  as_ln_s='cp -pR'
    1057410631fi
    1057510632rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
     
    1063110688fi
    1063210689
    10633 if test -x / >/dev/null 2>&1; then
    10634   as_test_x='test -x'
    10635 else
    10636   if ls -dL / >/dev/null 2>&1; then
    10637     as_ls_L_option=L
    10638   else
    10639     as_ls_L_option=
    10640   fi
    10641   as_test_x='
    10642     eval sh -c '\''
    10643       if test -d "$1"; then
    10644         test -d "$1/.";
    10645       else
    10646         case $1 in #(
    10647         -*)set "./$1";;
    10648         esac;
    10649         case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
    10650         ???[sx]*):;;*)false;;esac;fi
    10651     '\'' sh
    10652   '
    10653 fi
    10654 as_executable_p=$as_test_x
     10690
     10691# as_fn_executable_p FILE
     10692# -----------------------
     10693# Test if FILE is an executable regular file.
     10694as_fn_executable_p ()
     10695{
     10696  test -f "$1" && test -x "$1"
     10697} # as_fn_executable_p
     10698as_test_x='test -x'
     10699as_executable_p=as_fn_executable_p
    1065510700
    1065610701# Sed expression to map a string onto a valid CPP name.
     
    1067410719ac_log="
    1067510720This file was extended by Rappture $as_me 1.1, which was
    10676 generated by GNU Autoconf 2.68.  Invocation command line was
     10721generated by GNU Autoconf 2.69.  Invocation command line was
    1067710722
    1067810723  CONFIG_FILES    = $CONFIG_FILES
     
    1073610781ac_cs_version="\\
    1073710782Rappture config.status 1.1
    10738 configured by $0, generated by GNU Autoconf 2.68,
     10783configured by $0, generated by GNU Autoconf 2.69,
    1073910784  with options \\"\$ac_cs_config\\"
    1074010785
    10741 Copyright (C) 2010 Free Software Foundation, Inc.
     10786Copyright (C) 2012 Free Software Foundation, Inc.
    1074210787This config.status script is free software; the Free Software Foundation
    1074310788gives unlimited permission to copy, distribute and modify it."
     
    1083010875cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
    1083110876if \$ac_cs_recheck; then
    10832   set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
     10877  set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
    1083310878  shift
    1083410879  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
     
    1096111006    "examples/zoo/cloud/matlab/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/cloud/matlab/Makefile" ;;
    1096211007    "examples/zoo/curve/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/curve/Makefile" ;;
     11008    "examples/zoo/drawing/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/drawing/Makefile" ;;
    1096311009    "examples/zoo/enable/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/enable/Makefile" ;;
    1096411010    "examples/zoo/field/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/field/Makefile" ;;
     
    1097211018    "examples/zoo/loader/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/loader/Makefile" ;;
    1097311019    "examples/zoo/loader/examples/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/loader/examples/Makefile" ;;
    10974     "examples/zoo/loadrun/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/loadrun/Makefile" ;;
    1097511020    "examples/zoo/log/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/log/Makefile" ;;
    1097611021    "examples/zoo/note/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/note/Makefile" ;;
  • branches/nanovis2/configure.in

    r2959 r3175  
    6161AC_CHECK_LIB(m, main,,AC_MSG_ERROR(librappture requires libm))
    6262
    63 AC_CHECK_LIB(ncurses, clrtoeol,,AC_MSG_ERROR([ncursers library missing?]))
     63AC_CHECK_LIB(ncurses, clrtoeol,,AC_MSG_ERROR([ncurses library missing?]))
    6464AC_CHECK_HEADERS(ncurses.h,,AC_MSG_WARN(ncurses headers missing ?))
    6565
     
    544544    examples/zoo/cloud/matlab/Makefile
    545545    examples/zoo/curve/Makefile
     546    examples/zoo/drawing/Makefile
    546547    examples/zoo/enable/Makefile
    547548    examples/zoo/field/Makefile
     
    555556    examples/zoo/loader/Makefile
    556557    examples/zoo/loader/examples/Makefile
    557     examples/zoo/loadrun/Makefile
    558558    examples/zoo/log/Makefile
    559559    examples/zoo/note/Makefile
  • branches/nanovis2/examples/demo.bash.in

    r1738 r3175  
    1212
    1313ZOO="\
    14  ./zoo/log \
    15  ./zoo/note \
    16  ./zoo/cloud \
    17  ./zoo/cloud \
    18  ./zoo/curve \
    19  ./zoo/field \
    20  ./zoo/group \
    21  ./zoo/image \
    22  ./zoo/phase \
    23  ./zoo/table \
    24  ./zoo/structure \
    25  ./zoo/loadrun \
    26  ./zoo/unirect2d \
    27  ./zoo/binary \
    28  ./zoo/choice \
    29  ./zoo/enable \
    30  ./zoo/loader \
    31  ./zoo/number \
    32  ./zoo/string \
    33  ./zoo/number2 \
    34  ./zoo/sequence \
    35  ./zoo/boolean \
    36  ./zoo/integer \
    37  ./zoo/integer2 \
     14        ./zoo/binary
     15        ./zoo/boolean
     16        ./zoo/choice
     17        ./zoo/cloud/matlab
     18        ./zoo/cloud
     19        ./zoo/curve
     20        ./zoo/drawing
     21        ./zoo/enable
     22        ./zoo/field
     23        ./zoo/group
     24        ./zoo/histogram
     25        ./zoo/image
     26        ./zoo/integer
     27        ./zoo/integer2
     28        ./zoo/loader
     29        ./zoo/log
     30        ./zoo/note
     31        ./zoo/number
     32        ./zoo/number2
     33        ./zoo/parallelepiped
     34        ./zoo/periodicelement
     35        ./zoo/phase
     36        ./zoo/sequence
     37        ./zoo/string
     38        ./zoo/structure
     39        ./zoo/table
     40        ./zoo/unirect2d
    3841"
    3942
    4043FLOW=" \
    41  ./flow/demo1 \
    42  ./flow/demo2 \
    43  ./flow/demo3 \
    44  ./flow"
    45 
     44        ./flow/demo1
     45        ./flow/demo2
     46        ./flow/demo3
     47        ./flow
     48"
    4649FERMI=" \
    47   ./app-fermi/cee \
    48   ./app-fermi/tcl \
    49   ./app-fermi/java \
    50   ./app-fermi/perl \
    51   ./app-fermi/ruby \
    52   ./app-fermi/fortran \
    53   ./app-fermi/matlab \
    54   ./app-fermi/matlab \
    55   ./app-fermi/octave/2 \
    56   ./app-fermi/octave/3 \
    57   ./app-fermi/python \
    58   ./app-fermi/wrapper/cee \
    59   ./app-fermi/wrapper/tcl \
    60   ./app-fermi/wrapper/python \
     50        ./app-fermi/cee
     51        ./app-fermi/fortran
     52        ./app-fermi/tcl
     53        ./app-fermi/perl
     54        ./app-fermi/python
     55        ./app-fermi/ruby
     56        ./app-fermi/java
     57        ./app-fermi/R
     58        ./app-fermi/matlab/uncompiled
     59        ./app-fermi/matlab/compiled
     60        ./app-fermi/octave/octave2
     61        ./app-fermi/octave/octave3
     62        ./app-fermi/wrapper/cee
     63        ./app-fermi/wrapper/tcl
     64        ./app-fermi/wrapper/perl
     65        ./app-fermi/wrapper/python
    6166"
    6267
  • branches/nanovis2/examples/graph/tool.xml

    r555 r3175  
    1313            </about>
    1414            <size>30x5</size>
     15            <default>2*x+1</default>
    1516        </string>
    1617        <number id="min">
  • branches/nanovis2/examples/zoo/Makefile.in

    r2301 r3175  
    2020                cloud \
    2121                curve \
     22                drawing \
    2223                enable \
    2324                field \
     
    2829                integer2 \
    2930                loader \
    30                 loadrun \
    3131                log \
    3232                note \
  • branches/nanovis2/examples/zoo/drawing/Makefile.in

    r2959 r3175  
    2323all:
    2424
    25 install:
     25install: install-files install-images
     26
     27install-files:
    2628        $(MKDIR_P) -m 0755 $(destdir)
    2729        for i in $(FILES) ; do \
    2830          $(INSTALL) -m 0444  $$i $(destdir) ; \
     31        done
     32
     33install-images:
     34        $(MKDIR_P) -m 0755 $(destdir)/images
     35        for i in $(srcdir)/images/* ; do \
     36          $(INSTALL) -m 0444  $$i $(destdir)/images ; \
    2937        done
    3038
  • branches/nanovis2/examples/zoo/drawing/drawing.tcl

    r2959 r3175  
    1313set driver [Rappture::library [lindex $argv 0]]
    1414
    15 set title [$driver get input.(title).current]
    16 set indeck [$driver get input.(indeck).current]
     15set value [$driver get input.choice(analysis).current]
     16append out "Analysis Choice:  $value\n"
     17set value [$driver get input.number(trapezoid_top).current]
     18append out "Trapezoid Top:  $value\n"
     19set value [$driver get input.number(substrate_length).current]
     20append out "Substrate Length:  $value\n"
     21set value [$driver get input.number(feature_length).current]
     22append out "Feature Length:  $value\n"
     23set value [$driver get input.number(feature_height).current]
     24append out "Feature Height:  $value\n"
     25set value [$driver get input.string(indeck).current]
     26append out "String:  $value\n"
    1727
    18 $driver put output.string(outt).about.label "Echo of title"
    19 $driver put output.string(outt).current $title
    20 $driver put output.string(outi).about.label "Echo of input"
    21 $driver put output.string(outi).current $indeck
     28$driver put output.string(out).about.label "Echo of inputs"
     29$driver put output.string(out).current $out
    2230
    2331# save the updated XML describing the run...
  • branches/nanovis2/examples/zoo/drawing/tool.xml

    r2959 r3175  
    11<?xml version="1.0"?>
    22<run>
    3 <tool>
     3 <tool>
    44  <title>drawing</title>
    55  <about>Example of a Rappture &lt;drawing&gt; object.
     
    1313    tclsh @tool/drawing.tcl @driver
    1414  </command>
    15 </tool>
    16 <input>
     15  <layout>wizard</layout>
     16 </tool>
     17 <input>
     18    <boolean id="trapezoid_top">
     19      <about> <label>Enable trapezoid top</label> </about>
     20      <default>off</default>
     21    </boolean>
    1722  <drawing>
    18     <about>
    19       <label>Title</label>
    20       <description>This text will be used as the title for all plots.</description>
    21       <bbox>-.1 0 1.1 1</bbox>
    22     </about>
    23     <components>
    24         <line>
    25           <coords>.25 .75 .75 .75</coords>
    26           <color>black</color>
    27           <linewidth>2</linewidth>
    28           <arrow>both</arrow>
    29         </line>
    30         <text>
    31           <coords>.5 .8</coords>
    32           <color>black</color>
    33           <text>Feature Length = 50 nm</text>
    34           <font>Arial 9</font>
    35           <anchor>c</anchor>
    36         </text>
    37         <line>
    38           <coords>.78 .4 .78 .7</coords>
    39           <color>black</color>
    40           <linewidth>2</linewidth>
    41           <arrow>both</arrow>
    42         </line>
    43         <text>
    44           <coords>.82 .48</coords>
    45           <color>black</color>
    46           <text>Feature
    47 Height = 30 nm</text>
    48           <font>Arial 9</font>
    49           <anchor>nw</anchor>
    50         </text>
    51         <line>
    52           <coords>0 .9 1 .9</coords>
    53           <color>black</color>
    54           <linewidth>2</linewidth>
    55           <arrow>both</arrow>
    56         </line>
    57         <text>
    58           <coords>.5 .91</coords>
    59           <color>black</color>
    60           <text>Substrate Length = 100 nm</text>
    61           <font>Arial 9</font>
    62           <anchor>n</anchor>
    63         </text>
    64         <line>
    65           <coords>.35 .35 .65 .35</coords>
    66           <color>black</color>
    67           <linewidth>2</linewidth>
    68           <arrow>both</arrow>
    69         </line>
    70         <text>
    71           <coords>.5 .30</coords>
    72           <color>black</color>
    73           <text>Length of Trapezoid Top = 30 nm</text>
    74           <font>Arial 9</font>
    75           <anchor>s</anchor>
    76         </text>
    77         <line id="polyline">
    78           <coords>0 .7 .25 .7 .35 .4 .65 .4 .75 .7 1 .7</coords>
    79           <color>red</color>
    80           <linewidth>2</linewidth>
    81         </line>
    82         <grid>
    83           <xcoords>0 .1 .2 .3 .4 .5 .6 .7 .8 .9 1</xcoords>
    84           <ycoords>.2 .3 .4 .5 .6 .7</ycoords>
    85           <color>grey70</color>
    86           <linewidth>1</linewidth>
    87           <dash>4 2</dash>
    88         </grid>
    89         <string>
    90           <about>
    91             <label>String:</label>
    92           </about> 
    93           <coords>.1 1.1</coords>
    94           <color>blue</color>
    95           <font>Arial 9</font>
    96           <anchor>nw</anchor>
    97           <default>value</default>
    98         </string>
    99         <number>
    100           <about>
    101             <label>Number:</label>
    102           </about> 
    103           <coords></coords>
    104           <color>blue</color>
    105           <font>Arial 12</font>
    106           <anchor>n</anchor>
    107           <default></default>
    108           <min></min>
    109           <max></max>
    110         </number>
    111     </components>
     23   <about>
     24    <label>Title</label>
     25    <description>This text will be used as the title for all plots.</description>
     26   </about>
     27   <background>
     28    <color>#FFFCDA</color>
     29    <coordinates>-.1 0 1.1 1</coordinates>
     30    <width>800</width>
     31    <height>500</height>
     32   </background>
     33   <substitutions>
     34    <variable>
     35     <name>string</name>
     36     <path>input.string(indeck)</path>
     37    </variable>
     38    <variable>
     39     <name>feature_height</name>
     40     <path>input.number(feature_height)</path>
     41    </variable>
     42    <variable>
     43     <name>feature_length</name>
     44     <path>input.number(feature_length)</path>
     45    </variable>
     46    <variable>
     47     <name>trapezoid_top</name>
     48     <path>input.number(trapezoid_top)</path>
     49    </variable>
     50    <variable>
     51     <name>substrate_length</name>
     52     <path>input.number(substrate_length)</path>
     53    </variable>
     54    <variable>
     55     <name>analysis</name>
     56     <path>input.choice(analysis)</path>
     57    </variable>
     58   </substitutions>
     59   <components>
     60    <grid>
     61     <xcoords>0 .1 .2 .3 .4 .5 .6 .7 .8 .9 1</xcoords>
     62     <ycoords>.2 .3 .4 .5 .6 .7</ycoords>
     63     <color>grey70</color>
     64     <linewidth>1</linewidth>
     65     <dash>4 2</dash>
     66    </grid>
     67    <line id="feature_length">
     68     <coords>.25 .72 .75 .72</coords>
     69     <color>black</color>
     70     <linewidth>2</linewidth>
     71     <arrow>both</arrow>
     72    </line>
     73    <text id="feature_length">
     74     <coords>.5 .73</coords>
     75     <color>black</color>
     76     <text>Feature Length = ${feature_length}</text>
     77     <font>Arial 11</font>
     78     <anchor>n</anchor>
     79     <hotspot>inline</hotspot>
     80    </text>
     81    <line id="feature_height">
     82     <coords>.76 .4 .76 .7</coords>
     83     <color>black</color>
     84     <linewidth>2</linewidth>
     85     <arrow>both</arrow>
     86    </line>
     87    <text id="feature_height">
     88     <coords>.77 .48</coords>
     89     <color>black</color>
     90     <text>Feature
     91Height = ${feature_height}</text>
     92     <font>Arial 11</font>
     93     <anchor>nw</anchor>
     94    </text>
     95    <hotspot id="feature_height">
     96     <coords>.95 .53</coords>
     97     <controls>input.choice(analysis)</controls>
     98     <controls>input.number(feature_height)</controls>
     99     <controls>input.number(feature_length)</controls>
     100     <controls>input.number(substrate_length)</controls>
     101    </hotspot>
     102    <line id="substrate_length">
     103     <coords>0 .8 1 .8</coords>
     104     <color>black</color>
     105     <linewidth>2</linewidth>
     106     <arrow>both</arrow>
     107    </line>
     108    <text id="substrate_length">
     109     <coords>.5 .81</coords>
     110     <color>black</color>
     111     <text>Substrate Length = ${substrate_length}</text>
     112     <font>Arial 11</font>
     113     <hotspot>inline</hotspot>
     114     <anchor>n</anchor>
     115    </text>
     116    <line id="trapezoid_top">
     117     <coords>.35 .38 .65 .38</coords>
     118     <color>black</color>
     119     <linewidth>2</linewidth>
     120     <arrow>both</arrow>
     121    </line>
     122    <text id="trapezoid_top">
     123     <coords>.5 .35</coords>
     124     <color>black</color>
     125     <text>Length of Trapezoid Top = ${trapezoid_top}</text>
     126     <font>Arial 11</font>
     127     <anchor>s</anchor>
     128     <hotspot>inline</hotspot>
     129    </text>
     130    <line id="polyline">
     131     <coords>0 .7 .25 .7 .35 .4 .65 .4 .75 .7 1 .7</coords>
     132     <color>red</color>
     133     <linewidth>2</linewidth>
     134    </line>
     135    <picture id="analysis">
     136     <coords>-.08 .06 0.17 0.15</coords>
     137     <contents>file:images/${analysis}_F-d.png</contents>
     138     <anchor>nw</anchor>
     139    </picture>
     140    <text id="analysis">
     141     <coords>.05 .4</coords>
     142     <color>black</color>
     143     <text>${analysis}</text>
     144     <font>Arial 11</font>
     145     <anchor>n</anchor>
     146     <hotspot>inline</hotspot>
     147    </text>
     148    <text id="string">
     149     <coords>-.03 .85</coords>
     150     <color>black</color>
     151     <text>${string}</text>
     152     <font>Arial 11</font>
     153     <anchor>nw</anchor>
     154     <hotspot>inline</hotspot>
     155    </text>
     156   </components>
    112157  </drawing>
    113 
    114   <separator/>
    115 
     158  <number id="feature_height">
     159   <about>
     160    <label>Feature Height</label>
     161    <description>Height of feature.</description>
     162   </about>
     163   <units>nm</units>
     164   <min>10</min>
     165   <max>70</max>
     166   <default>30</default>
     167  </number>
     168  <number id="feature_length">
     169   <about>
     170    <label>Feature Length</label>
     171    <description>Length of feature.</description>
     172   </about>
     173   <units>nm</units>
     174   <min>10</min>
     175   <max>100</max>
     176   <default>50</default>
     177  </number>
     178  <number id="substrate_length">
     179   <about>
     180    <label>Substrate Length</label>
     181    <description>Length of substrate.</description>
     182   </about>
     183   <units>nm</units>
     184   <min>10</min>
     185   <max>500</max>
     186   <default>100</default>
     187  </number>
     188  <number id="trapezoid_top">
     189   <about>
     190    <label>Trapezoid Top</label>
     191    <description>Width of the Trapezoid Top.</description>
     192    <enable>input.boolean(trapezoid_top)</enable>
     193   </about>
     194   <units>nm</units>
     195   <min>10</min>
     196   <max>70</max>
     197   <default>30</default>
     198  </number>
     199  <choice id="analysis">
     200   <about>
     201    <label>Type of Analysis</label>
     202    <description>Determines the type of analysis to perform.</description>
     203   </about>
     204   <option>
     205    <about>
     206     <label>Hertz</label>
     207     <description>Hertz analysis</description>
     208    </about>
     209   </option>
     210   <option>
     211    <about>
     212     <label>LinCon</label>
     213     <description>LinCon analysis</description>
     214    </about>
     215   </option>
     216   <option>
     217    <about>
     218     <label>Chadwick</label>
     219     <description>Chadwick analysis</description>
     220    </about>
     221   </option>
     222   <option>
     223    <about>
     224     <label>DMT</label>
     225     <description>DMT analysis</description>
     226    </about>
     227   </option>
     228   <default>Chadwick</default>
     229  </choice>
    116230  <string id="indeck">
    117     <about>
    118       <label>Input</label>
    119       <description>This is the control file for the program.</description>
    120       <hints>EXAMPLE:  .print ac vm(11) mag(i(vcc))</hints>
    121     </about>
    122     <size>40x10</size>
    123     <default>Enter your SPICE commands
     231   <about>
     232    <label>Input</label>
     233    <description>This is the control file for the program.</description>
     234    <hints>EXAMPLE:  .print ac vm(11) mag(i(vcc))</hints>
     235   </about>
     236   <size>40x10</size>
     237   <default>Enter your SPICE commands
    124238in this area.  Right-click
    125239for a menu of editing options.</default>
    126240  </string>
    127 </input>
     241 </input>
    128242</run>
  • branches/nanovis2/examples/zoo/field/field.tcl

    r1587 r3175  
    180180    component "data" value 3}
    181181
    182     set file "/tmp/dx[clock seconds]"
    183     set fid [open $file w]
    184     puts $fid $dx
    185     close $fid
    186 
    187     set fid [open "| gzip -c $file | mimencode" r]
    188     $driver put output.field(f3d).component.dx [read $fid]
    189     close $fid
    190 
    191     file delete -force $file
     182    set data [Rappture::encoding::encode -as zb64 $dx]
     183    $driver put output.field(f3d).component.dx $data
    192184}
    193185
  • branches/nanovis2/gui/apps/rappture.in

    r2789 r3175  
    1616dir=`dirname $0`
    1717. $dir/rappture.env
    18 exec tclsh $dir/launcher.tcl "$@"
     18exec tclsh $dir/launcher.tcl -- "$@"
  • branches/nanovis2/gui/apps/vtkviewer-test

    r2789 r3175  
    102102        return $_type
    103103    }
     104    public method shape {args} {
     105        return "sphere"
     106    }
    104107
    105108    private variable _data ""
     
    116119    global widgets
    117120
    118     set file [tk_getOpenFile -title "Open VTK File"]
     121    set file [tk_getOpenFile -title "Open VTK File as PolyData"]
    119122    if {"" != $file && [catch {
    120123            set fid [open $file r]
     
    123126            close $fid
    124127          }] == 0} {
    125         set obj [visData #auto $info ""]
     128        set obj [visData #auto $info "polydata"]
    126129        $widgets(vtkviewer) add $obj
    127130    }
     
    150153
    151154# ----------------------------------------------------------------------
    152 # USAGE: send_spheres_file
     155# USAGE: send_glyphs_file
    153156#
    154157# Prompts the user for a text file, and then sends the text within
    155158# that file along to the rendering widget.
    156159# ----------------------------------------------------------------------
    157 proc send_spheres_file {} {
    158     global widgets
    159 
    160     set file [tk_getOpenFile -title "Open VTK File as Spheres"]
     160proc send_glyphs_file {} {
     161    global widgets
     162
     163    set file [tk_getOpenFile -title "Open VTK File as Glyphs"]
    161164    if {"" != $file && [catch {
    162165            set fid [open $file r]
     
    165168            close $fid
    166169          }] == 0} {
    167         set obj [visData #auto $info "spheres"]
     170        set obj [visData #auto $info "glyphs"]
     171        $widgets(vtkviewer) add $obj
     172    }
     173}
     174
     175# ----------------------------------------------------------------------
     176# USAGE: send_molecule_file
     177#
     178# Prompts the user for a text file, and then sends the text within
     179# that file along to the rendering widget.
     180# ----------------------------------------------------------------------
     181proc send_molecule_file {} {
     182    global widgets
     183
     184    set file [tk_getOpenFile -title "Open VTK File as Molecule"]
     185    if {"" != $file && [catch {
     186            set fid [open $file r]
     187            fconfigure $fid -translation binary
     188            set info [read $fid]
     189            close $fid
     190          }] == 0} {
     191        set obj [visData #auto $info "molecule"]
    168192        $widgets(vtkviewer) add $obj
    169193    }
     
    367391.mbar.file add command -label "Send VTK File..." -underline 0 -command send_file
    368392.mbar.file add command -label "Send VTK File as Streamlines..." -underline 0 -command send_streamlines_file
    369 .mbar.file add command -label "Send VTK File as Spheres..." -underline 0 -command send_spheres_file
     393.mbar.file add command -label "Send VTK File as Glyphs..." -underline 0 -command send_glyphs_file
     394.mbar.file add command -label "Send VTK File as Molecule..." -underline 0 -command send_molecule_file
    370395.mbar.file add command -label "Load script..." -underline 0 -command load_script
    371396.mbar.file add command -label "Reset" -underline 0 -command reset
  • branches/nanovis2/gui/scripts/Makefile.in

    r2992 r3175  
    3030                $(srcdir)/color.tcl \
    3131                $(srcdir)/combobox.tcl \
     32                $(srcdir)/combochecks.tcl \
    3233                $(srcdir)/contourresult.tcl \
    3334                $(srcdir)/controlOwner.tcl \
     
    4647                $(srcdir)/drawingentry.tcl \
    4748                $(srcdir)/dropdown.tcl \
     49                $(srcdir)/dropdownchecks.tcl \
    4850                $(srcdir)/dropdownlist.tcl \
    4951                $(srcdir)/editor.tcl \
     
    9597                $(srcdir)/resources.tcl \
    9698                $(srcdir)/resultset.tcl \
     99                $(srcdir)/resultselector.tcl \
    97100                $(srcdir)/resultviewer.tcl \
    98101                $(srcdir)/scroller.tcl \
  • branches/nanovis2/gui/scripts/analyzer.tcl

    r2943 r3175  
    5555    public method reset {{when -eventually}}
    5656    public method load {xmlobj}
    57     public method clear {{xmlobj ""}}
     57    public method clear {{xmlobj "all"}}
    5858    public method download {option args}
    5959
     
    6262    protected method _autoLabel {xmlobj path title cntVar}
    6363    protected method _fixResult {}
     64    protected method _fixResultSet {args}
    6465    protected method _fixSize {}
    6566    protected method _fixSimControl {}
     
    7778    private variable _appName ""       ;# Name of application
    7879    private variable _control "manual" ;# start mode
    79     private variable _runs ""          ;# list of XML objects with results
     80    private variable _resultset ""     ;# ResultSet object with all results
    8081    private variable _pages 0          ;# number of pages for result sets
    8182    private variable _label2page       ;# maps output label => result set
     
    9798    set _tool $tool
    9899
     100    # use this to store all simulation results
     101    set _resultset [Rappture::ResultSet ::#auto]
     102    $_resultset notify add $this [itcl::code $this _fixResultSet]
     103
     104    # widget settings...
    99105    itk_option add hull.width hull.height
    100106    pack propagate $itk_component(hull) no
     
    258264    pack $w.top.l -side left
    259265
    260     itk_component add resultselector {
     266    itk_component add viewselector {
    261267        Rappture::Combobox $w.top.sel -width 10 -editable no
    262268    } {
     
    264270        rename -font -textfont textFont Font
    265271    }
    266     pack $itk_component(resultselector) -side left -expand yes -fill x
    267     bind $itk_component(resultselector) <<Value>> [itcl::code $this _fixResult]
    268     bind $itk_component(resultselector) <Enter> \
     272    pack $itk_component(viewselector) -side left -expand yes -fill x
     273    bind $itk_component(viewselector) <<Value>> [itcl::code $this _fixResult]
     274    bind $itk_component(viewselector) <Enter> \
    269275        [itcl::code $this download coming]
    270276
    271     Rappture::Tooltip::for $itk_component(resultselector) \
     277    Rappture::Tooltip::for $itk_component(viewselector) \
    272278        "@[itcl::code $this _resultTooltip]"
    273279
    274     $itk_component(resultselector) choices insert end \
     280    $itk_component(viewselector) choices insert end \
    275281        --- "---"
    276282
     
    284290        [itcl::code $this download coming]
    285291
    286     $itk_component(resultselector) choices insert end \
     292    $itk_component(viewselector) choices insert end \
    287293        @download [Rappture::filexfer::label download]
    288294
     
    307313
    308314    set f [$itk_component(results) insert end -fraction 0.1]
    309     itk_component add resultset {
    310         Rappture::ResultSet $f.rset \
    311             -clearcommand [itcl::code $this clear] \
    312             -settingscommand [itcl::code $this _plot] \
    313             -promptcommand [itcl::code $this _simState]
    314     }
    315     pack $itk_component(resultset) -expand yes -fill both
    316     bind $itk_component(resultset) <<Control>> [itcl::code $this _fixSize]
     315    itk_component add resultselector {
     316        Rappture::ResultSelector $f.rsel -resultset $_resultset \
     317            -settingscommand [itcl::code $this _plot]
     318    }
     319    pack $itk_component(resultselector) -expand yes -fill both
     320    bind $itk_component(resultselector) <<Layout>> [itcl::code $this _fixSize]
    317321    bind $itk_component(results) <Configure> [itcl::code $this _fixSize]
    318322
     
    358362# ----------------------------------------------------------------------
    359363itcl::body Rappture::Analyzer::destructor {} {
    360     foreach obj $_runs {
    361         itcl::delete object $obj
    362     }
    363364    after cancel [itcl::code $this simulate]
     365    $_resultset notify remove $this
     366    itcl::delete object $_resultset
    364367}
    365368
     
    378381        # check to see if simulation is really needed
    379382        $_tool sync
    380         if {[$itk_component(resultset) contains [$_tool xml object]]
     383        if {[$_resultset contains [$_tool xml object]]
    381384              && ![string equal $_control "manual-resim"]} {
    382385            # not needed -- show results and return
     
    466469    # check to see if simulation is really needed
    467470    $_tool sync
    468     if {![$itk_component(resultset) contains [$_tool xml object]]
     471    if {![$_resultset contains [$_tool xml object]]
    469472          || [string equal $_control "manual-resim"]} {
    470473        # if control mode is "auto", then simulate right away
     
    495498    }
    496499
    497     # look for all output.load children and load them first
    498     # each run.xml is loaded as a previous simulation.
    499     foreach item [$xmlobj children -type run output.load] {
    500         set loadfile [$xmlobj get output.load.$item]
    501         set loadobj [Rappture::library $loadfile]
    502         load $loadobj
    503     }
    504 
    505     foreach item [$xmlobj children -type run output.include] {
    506         set id [$xmlobj element -as id output.include.$item]
    507         set inclfile [$xmlobj get output.include.$item]
    508         set inclobj [Rappture::library $inclfile]
    509         foreach c [$inclobj children output] {
    510             switch -glob -- $c {
    511                 # We don't want to include these tags.
    512                 include* - time* - status* - user* {
    513                     continue
    514                 }
    515                 default {
    516                     set oldid [$inclobj element -as id output.$c]
    517                     set oldtype [$inclobj element -as type output.$c]
    518                     set newcomp "$oldtype\($id-$oldid\)"
    519                     $xmlobj copy output.$newcomp from $inclobj output.$c
    520                 }
    521             }
    522         }
    523     }
    524 
    525     lappend _runs $xmlobj
    526 
    527     # Detect molecule elements that contain trajectory data and convert
    528     # to sequences.
    529     _trajToSequence $xmlobj output
    530 
    531     # Go through the analysis and find all result sets.
    532     set haveresults 0
    533     foreach item [_reorder [$xmlobj children output]] {
    534         switch -glob -- $item {
    535             log* {
    536                 _autoLabel $xmlobj output.$item "Output Log" counters
    537             }
    538             number* {
    539                 _autoLabel $xmlobj output.$item "Number" counters
    540             }
    541             integer* {
    542                 _autoLabel $xmlobj output.$item "Integer" counters
    543             }
    544             string* {
    545                 _autoLabel $xmlobj output.$item "String" counters
    546             }
    547             histogram* - curve* - field* {
    548                 _autoLabel $xmlobj output.$item "Plot" counters
    549             }
    550             drawing* {
    551                 _autoLabel $xmlobj output.$item "Drawing" counters
    552             }
    553             structure* {
    554                 _autoLabel $xmlobj output.$item "Structure" counters
    555             }
    556             table* {
    557                 _autoLabel $xmlobj output.$item "Energy Levels" counters
    558             }
    559             sequence* {
    560                 _autoLabel $xmlobj output.$item "Sequence" counters
    561             }
    562             default {
    563                 if 0 {
    564                     puts stderr "unknown output $item"
    565                 }
    566             }
    567         }
    568         set label [$xmlobj get output.$item.about.group]
    569         if {"" == $label} {
    570             set label [$xmlobj get output.$item.about.label]
    571         }
    572 
    573         set hidden [$xmlobj get output.$item.hide]
    574         set hidden [expr {"" != $hidden && $hidden}]
    575 
    576         if {"" != $label && !$hidden} {
    577             set haveresults 1
    578         }
    579     }
    580     # if there are any valid results, add them to the resultset
    581     if {$haveresults} {
    582         set index [$itk_component(resultset) add $xmlobj]
    583 
    584         # add each result to a result viewer
    585         foreach item [_reorder [$xmlobj children output]] {
    586             set label [$xmlobj get output.$item.about.group]
    587             if {"" == $label} {
    588                 set label [$xmlobj get output.$item.about.label]
    589             }
    590             set hidden [$xmlobj get output.$item.hide]
    591             if { $hidden == "" } {
    592                 set hidden 0
    593             }
    594             if {"" != $label && !$hidden} {
    595                 if {![info exists _label2page($label)]} {
    596                     set name "page[incr _pages]"
    597                     set page [$itk_component(resultpages) insert end $name]
    598                     set _label2page($label) $page
    599                     set _label2desc($label) \
    600                         [$xmlobj get output.$item.about.description]
    601                     Rappture::ResultViewer $page.rviewer
    602                     pack $page.rviewer -expand yes -fill both -pady 4
    603 
    604                     set end [$itk_component(resultselector) \
    605                         choices index -value ---]
    606                     if {$end < 0} {
    607                         set end "end"
    608                     }
    609                     $itk_component(resultselector) choices insert $end \
    610                         $name $label
    611                 }
    612 
    613                 # add/replace the latest result into this viewer
    614                 set page $_label2page($label)
    615 
    616                 if {![info exists reset($page)]} {
    617                     $page.rviewer clear $index
    618                     set reset($page) 1
    619                 }
    620                 $page.rviewer add $index $xmlobj output.$item
    621             }
    622         }
    623     }
    624 
    625     # show the first page by default
    626     set max [$itk_component(resultselector) choices size]
    627     for {set i 0} {$i < $max} {incr i} {
    628         set first [$itk_component(resultselector) choices get -label $i]
    629         if {$first != ""} {
    630             set page [$itk_component(resultselector) choices get -value $i]
    631             set char [string index $page 0]
    632             if {$char != "@" && $char != "-"} {
    633                 $itk_component(resultpages) current $page
    634                 $itk_component(resultselector) value $first
    635                 set _lastlabel $first
    636                 break
    637             }
    638         }
    639     }
     500    $_resultset add $xmlobj
     501
     502    # NOTE: Adding will trigger a !change event on the ResultSet
     503    # object, which will trigger calls to _fixResultSet to add
     504    # the results to display.
    640505}
    641506
     
    647512# Otherwise, all results are cleared.
    648513# ----------------------------------------------------------------------
    649 itcl::body Rappture::Analyzer::clear {{xmlobj ""}} {
    650     if {$xmlobj ne ""} {
    651         set i [lsearch -exact $_runs $xmlobj]
    652         if {$i >= 0} {
    653             itcl::delete object $xmlobj
    654             set _runs [lreplace $_runs $i $i]
    655 
    656             # delete this result from all viewers
    657             foreach label [array names _label2page] {
    658                 set page $_label2page($label)
    659                 $page.rviewer clear $xmlobj
    660             }
    661         }
     514itcl::body Rappture::Analyzer::clear {{xmlobj "all"}} {
     515    if {$xmlobj eq "" || $xmlobj eq "all"} {
     516        $_resultset clear
    662517    } else {
    663         # clear everything
    664         foreach obj $_runs {
    665             itcl::delete object $obj
    666         }
    667         set _runs ""
    668     }
    669 
    670     if {[llength $_runs] == 0} {
    671         # reset the size of the controls area
    672         set ht [winfo height $itk_component(results)]
    673         set cntlht [$itk_component(resultset) size -controlarea]
    674         set frac [expr {double($cntlht)/$ht}]
    675         $itk_component(results) fraction end $frac
    676 
    677         foreach label [array names _label2page] {
    678             set page $_label2page($label)
    679             destroy $page.rviewer
    680         }
    681         $itk_component(resultselector) value ""
    682         $itk_component(resultselector) choices delete 0 end
    683         catch {unset _label2page}
    684         catch {unset _label2desc}
    685         set _plotlist ""
    686 
    687         $itk_component(resultselector) choices insert end --- "---"
    688         $itk_component(resultselector) choices insert end \
    689             @download [Rappture::filexfer::label download]
    690         set _lastlabel ""
    691     }
    692 
    693     #
    694     # HACK ALERT!!
    695     # The following statement should be in place, but it causes
    696     # vtk to dump core.  Leave it out until we can fix the core dump.
    697     # In the mean time, we leak memory...
    698     #
    699     #$itk_component(resultpages) delete -all
    700     #set _pages 0
    701 
    702     _simState on
    703     _fixSimControl
    704     reset
     518        $_resultset clear $xmlobj
     519    }
     520
     521    # NOTE: Clearing will trigger a !change event on the ResultSet
     522    # object, which will trigger calls to _fixResultSet to clean up
     523    # the results being displayed.
    705524}
    706525
     
    714533# ----------------------------------------------------------------------
    715534itcl::body Rappture::Analyzer::download {option args} {
    716     set title [$itk_component(resultselector) value]
    717     set page [$itk_component(resultselector) translate $title]
     535    set title [$itk_component(viewselector) value]
     536    set page [$itk_component(viewselector) translate $title]
    718537
    719538    switch -- $option {
     
    775594                set ext ""
    776595                set f [$itk_component(resultpages) page $page]
    777                 set item [$itk_component(resultselector) value]
     596                set item [$itk_component(viewselector) value]
    778597                set result [$f.rviewer download now $widget $_appName $item]
    779598                if { $result == "" } {
     
    811630#
    812631# Used internally to update the plot shown in the current result
    813 # viewer whenever the resultset settings have changed.  Causes the
     632# viewer whenever the resultselector settings have changed.  Causes the
    814633# desired results to show up on screen.
    815634# ----------------------------------------------------------------------
     
    817636    set _plotlist $args
    818637
    819     set page [$itk_component(resultselector) value]
    820     set page [$itk_component(resultselector) translate $page]
     638    set page [$itk_component(viewselector) value]
     639    set page [$itk_component(viewselector) translate $page]
    821640    if {"" != $page} {
    822641        set f [$itk_component(resultpages) page $page]
     
    897716# ----------------------------------------------------------------------
    898717itcl::body Rappture::Analyzer::_fixResult {} {
    899     set name [$itk_component(resultselector) value]
     718    set name [$itk_component(viewselector) value]
    900719    set page ""
    901720    if {"" != $name} {
    902         set page [$itk_component(resultselector) translate $name]
     721        set page [$itk_component(viewselector) translate $name]
    903722    }
    904723    if {$page == "@download"} {
    905724        # put the combobox back to its last value
    906         $itk_component(resultselector) component entry configure -state normal
    907         $itk_component(resultselector) component entry delete 0 end
    908         $itk_component(resultselector) component entry insert end $_lastlabel
    909         $itk_component(resultselector) component entry configure -state disabled
     725        $itk_component(viewselector) component entry configure -state normal
     726        $itk_component(viewselector) component entry delete 0 end
     727        $itk_component(viewselector) component entry insert end $_lastlabel
     728        $itk_component(viewselector) component entry configure -state disabled
    910729        # perform the actual download
    911730        download start $itk_component(download)
    912731    } elseif {$page == "---"} {
    913732        # put the combobox back to its last value
    914         $itk_component(resultselector) component entry configure -state normal
    915         $itk_component(resultselector) component entry delete 0 end
    916         $itk_component(resultselector) component entry insert end $_lastlabel
    917         $itk_component(resultselector) component entry configure -state disabled
     733        $itk_component(viewselector) component entry configure -state normal
     734        $itk_component(viewselector) component entry delete 0 end
     735        $itk_component(viewselector) component entry insert end $_lastlabel
     736        $itk_component(viewselector) component entry configure -state disabled
    918737    } elseif {$page != ""} {
    919738        set _lastlabel $name
     
    930749
    931750# ----------------------------------------------------------------------
     751# USAGE: _fixResultSet ?<eventData>...?
     752#
     753# Used internally to react to changes within the ResultSet.  When a
     754# result is added, a new result viewer is created for the object.
     755# When all results are cleared, the viewers are deleted.
     756# ----------------------------------------------------------------------
     757itcl::body Rappture::Analyzer::_fixResultSet {args} {
     758    array set eventData $args
     759    switch -- $eventData(op) {
     760        add {
     761            set xmlobj $eventData(what)
     762
     763            # Detect molecule elements that contain trajectory data
     764            # and convert to sequences.
     765            _trajToSequence $xmlobj output
     766
     767            # Go through the analysis and find all result sets.
     768            set haveresults 0
     769            foreach item [_reorder [$xmlobj children output]] {
     770                switch -glob -- $item {
     771                    log* {
     772                        _autoLabel $xmlobj output.$item "Output Log" counters
     773                    }
     774                    number* {
     775                        _autoLabel $xmlobj output.$item "Number" counters
     776                    }
     777                    integer* {
     778                        _autoLabel $xmlobj output.$item "Integer" counters
     779                    }
     780                    string* {
     781                        _autoLabel $xmlobj output.$item "String" counters
     782                    }
     783                    histogram* - curve* - field* {
     784                        _autoLabel $xmlobj output.$item "Plot" counters
     785                    }
     786                    drawing* {
     787                        _autoLabel $xmlobj output.$item "Drawing" counters
     788                    }
     789                    structure* {
     790                        _autoLabel $xmlobj output.$item "Structure" counters
     791                    }
     792                    table* {
     793                        _autoLabel $xmlobj output.$item "Energy Levels" counters
     794                    }
     795                    sequence* {
     796                        _autoLabel $xmlobj output.$item "Sequence" counters
     797                    }
     798                }
     799                set label [$xmlobj get output.$item.about.group]
     800                if {"" == $label} {
     801                    set label [$xmlobj get output.$item.about.label]
     802                }
     803
     804                set hidden [$xmlobj get output.$item.hide]
     805                set hidden [expr {"" != $hidden && $hidden}]
     806
     807                if {"" != $label && !$hidden} {
     808                    set haveresults 1
     809                }
     810            }
     811
     812            # if there are any valid results, add them to the resultset
     813            if {$haveresults} {
     814                set index [$_resultset get simnum $xmlobj]
     815
     816                # add each result to a result viewer
     817                foreach item [_reorder [$xmlobj children output]] {
     818                    set label [$xmlobj get output.$item.about.group]
     819                    if {"" == $label} {
     820                        set label [$xmlobj get output.$item.about.label]
     821                    }
     822                    set hidden [$xmlobj get output.$item.hide]
     823                    if { $hidden == "" } {
     824                        set hidden 0
     825                    }
     826                    if {"" != $label && !$hidden} {
     827                        if {![info exists _label2page($label)]} {
     828                            set name "page[incr _pages]"
     829                            set page [$itk_component(resultpages) \
     830                                insert end $name]
     831                            set _label2page($label) $page
     832                            set _label2desc($label) \
     833                                [$xmlobj get output.$item.about.description]
     834                            Rappture::ResultViewer $page.rviewer
     835                            pack $page.rviewer -expand yes -fill both -pady 4
     836
     837                            set end [$itk_component(viewselector) \
     838                                choices index -value ---]
     839                            if {$end < 0} {
     840                                set end "end"
     841                            }
     842                            $itk_component(viewselector) choices insert $end \
     843                                $name $label
     844                        }
     845
     846                        # add/replace the latest result into this viewer
     847                        set page $_label2page($label)
     848
     849                        if {![info exists reset($page)]} {
     850                            $page.rviewer clear $index
     851                            set reset($page) 1
     852                        }
     853                        $page.rviewer add $index $xmlobj output.$item
     854                    }
     855                }
     856            }
     857
     858            # show the first page by default
     859            set max [$itk_component(viewselector) choices size]
     860            for {set i 0} {$i < $max} {incr i} {
     861                set first [$itk_component(viewselector) choices get -label $i]
     862                if {$first != ""} {
     863                    set page [$itk_component(viewselector) choices get -value $i]
     864                    set char [string index $page 0]
     865                    if {$char != "@" && $char != "-"} {
     866                        $itk_component(resultpages) current $page
     867                        $itk_component(viewselector) value $first
     868                        set _lastlabel $first
     869                        break
     870                    }
     871                }
     872            }
     873        }
     874        clear {
     875            if {$eventData(what) ne "all"} {
     876                # delete this result from all viewers
     877                array set params $eventData(what)
     878                foreach label [array names _label2page] {
     879                    set page $_label2page($label)
     880                    $page.rviewer clear $params(simnum)
     881                }
     882            }
     883
     884            if {[$_resultset size] == 0} {
     885                # reset the size of the controls area
     886                set ht [winfo height $itk_component(results)]
     887                set cntlht [$itk_component(resultselector) size -controlarea]
     888                set frac [expr {double($cntlht)/$ht}]
     889                $itk_component(results) fraction end $frac
     890
     891                foreach label [array names _label2page] {
     892                    set page $_label2page($label)
     893                    destroy $page.rviewer
     894                }
     895                $itk_component(resultpages) delete -all
     896                set _pages 0
     897
     898                $itk_component(viewselector) value ""
     899                $itk_component(viewselector) choices delete 0 end
     900                catch {unset _label2page}
     901                catch {unset _label2desc}
     902                set _plotlist ""
     903
     904                $itk_component(viewselector) choices insert end --- "---"
     905                $itk_component(viewselector) choices insert end \
     906                    @download [Rappture::filexfer::label download]
     907                set _lastlabel ""
     908            }
     909
     910            # fix Simulate button state
     911            reset
     912        }
     913        default {
     914            error "don't know how to handle op \"$eventData(op)\""
     915        }
     916    }
     917}
     918
     919# ----------------------------------------------------------------------
    932920# USAGE: _fixSize
    933921#
     
    939927    set ht [winfo height $itk_component(results)]
    940928    if {$ht <= 1} { set ht [winfo reqheight $itk_component(results)] }
    941     set cntlht [$itk_component(resultset) size -controlarea]
     929    set cntlht [$itk_component(resultselector) size -controlarea]
    942930    set frac [expr {double($cntlht)/$ht}]
    943931
     
    11101098itcl::body Rappture::Analyzer::_resultTooltip {} {
    11111099    set tip ""
    1112     set name [$itk_component(resultselector) value]
     1100    set name [$itk_component(viewselector) value]
    11131101    if {[info exists _label2desc($name)] &&
    11141102         [string length $_label2desc($name)] > 0} {
     
    11421130            # with no data, requiring simulation.
    11431131            #
    1144             if {[$itk_component(resultset) size -controls] >= 2} {
     1132            if {[$itk_component(resultselector) size -controls] >= 2} {
    11451133                pack $itk_interior.simol -fill x -before $itk_interior.nb
    11461134            } else {
  • branches/nanovis2/gui/scripts/choiceentry.tcl

    r1929 r3175  
    240240    # Assign the default value to this widget, if there is one.
    241241    #
    242     set defval [$_owner xml get $_path.default]
     242    set defval [string trim [$_owner xml get $_path.default]]
    243243    if {"" != $defval} {
    244244        if {[info exists _str2val($defval)]} {
  • branches/nanovis2/gui/scripts/controlOwner.tcl

    r2977 r3175  
    5959    # in coordination with loaders inside the load function
    6060    array set _type2curpath {
    61         drawing components
     61        drawing all
    6262        choice current
    6363        boolean current
     
    260260        error "\"$newobj\" is not a Rappture::library"
    261261    }
    262 
    263262    foreach path [array names _path2widget] {
    264263        # the following elements do not accept "current" tags, skip them
     
    270269        set type [[tool] xml element -as type $path]
    271270        if {[info exists _type2curpath($type)]} {
    272             set currentpath $path.$_type2curpath($type)
     271            if { $_type2curpath($type) == "all" } {
     272                set currentpath $path
     273            } else {
     274                set currentpath $path.$_type2curpath($type)
     275            }
    273276        } else {
    274277            # default incase i forgot an input type in _type2curpath
  • branches/nanovis2/gui/scripts/controls.tcl

    r2992 r3175  
    216216                foreach {s0 s1} $match break
    217217
    218                 if {[string index $rest [expr {$s0-1}]] == "\""
    219                       && [string index $rest [expr {$s1+1}]] == "\""} {
     218                if {[string index $rest [expr {$s0-1}]] == "\""} {
    220219                    # string in ""'s? then leave it alone
    221                     append enable [string range $rest 0 $s1]
    222                     set rest [string range $rest [expr {$s1+1}] end]
     220                    append enable [string range $rest 0 [expr {$s0-1}]]
     221                    set rest [string range $rest $s0 end]
     222                    if {[regexp -indices {[^\"]+\"} $rest match]} {
     223                        foreach {s0 s1} $match break
     224                        append enable [string range $rest $s0 $s1]
     225                        set rest [string range $rest [expr {$s1+1}] end]
     226                    } else {
     227                        puts stderr "WARNING: mismatched quote in enable condition for $path"
     228                        puts stderr "   expr: [string trim [$_owner xml get $path.about.enable]]"
     229                        set rest ""
     230                    }
    223231                } else {
    224232                    #
     
    511519            }
    512520            set _name2info($name-label) $label
    513 
    514             $_tabs insert end $label \
     521            $_tabs insert end $name -text $label \
    515522                -activebackground $itk_option(-background)
    516523
  • branches/nanovis2/gui/scripts/drawing.tcl

    r2792 r3175  
    2727    public method type { elem }
    2828    public method style { elem }
     29    public method shape { elem }
    2930    public method values { elem }
    3031    public method data { elem }
     
    3637    private variable _actors
    3738    private variable _styles
     39    private variable _shapes
    3840    private variable _labels
    3941    private variable _types
     
    7375            polygon* {
    7476                set _data($elem) [$_xmlobj get $path.$elem.vtk]
     77                set _data($elem) [string trim $_data($elem)]
    7578                set _styles($elem) [$_xmlobj get $path.$elem.about.style]
    7679                set _labels($elem) [$_xmlobj get $path.$elem.about.label]
     
    7982            streamlines* {
    8083                set _data($elem) [$_xmlobj get $path.$elem.vtk]
     84                set _data($elem) [string trim $_data($elem)]
    8185                set _styles($elem) [$_xmlobj get $path.$elem.about.style]
    8286                set _labels($elem) [$_xmlobj get $path.$elem.about.label]
    8387                set _types($elem) streamlines
    8488            }
    85             spheres* {
     89            glyphs* {
    8690                set _data($elem) [$_xmlobj get $path.$elem.vtk]
     91                set _data($elem) [string trim $_data($elem)]
    8792                set _styles($elem) [$_xmlobj get $path.$elem.about.style]
    8893                set _labels($elem) [$_xmlobj get $path.$elem.about.label]
    89                 set _types($elem) spheres
     94                set _shapes($elem) [$_xmlobj get $path.$elem.about.shape]
     95                set _types($elem) glyphs
     96            }
     97            molecule* {
     98                set _data($elem) [$_xmlobj get $path.$elem.vtk]
     99                set _data($elem) [string trim $_data($elem)]
     100                set _styles($elem) [$_xmlobj get $path.$elem.about.style]
     101                set _labels($elem) [$_xmlobj get $path.$elem.about.label]
     102                set _types($elem) molecule
    90103            }
    91104        }
     
    173186
    174187#
     188# shape --
     189#
     190#       Returns the shape of the glyphs in the drawing element.
     191#
     192itcl::body Rappture::Drawing::shape { elem } {
     193    set shape ""
     194    if { [info exists _shapes($elem)] } {
     195        return $_shapes($elem)
     196    }
     197    switch -- $shape {
     198        arrow - cone - cube - cylinder - dodecahedron -
     199        icosahedron - line - octahedron - sphere - tetrahedron  {
     200            return $shape
     201        }
     202        default {
     203            puts stderr "unknown glyph shape \"$shape\""
     204        }
     205    }
     206    return ""
     207}
     208
     209#
    175210# data --
    176211#
  • branches/nanovis2/gui/scripts/drawingcontrols.tcl

    r2992 r3175  
    3939    private method FormatLabel {str}
    4040    private method Monitor {name state}
    41 
    4241    private variable _dispatcher ""
    4342    private variable _controls ""
     
    4645    private variable _owner ""
    4746    private variable _frame ""
     47    private variable _closeOnChange 0
    4848}
    4949
     
    180180        set _name2info($name-disablestyle) $disablestyle
    181181    }
     182
     183    if 0 {
    182184    #
    183185    # If this element has an <enable> expression, then register
     
    231233            }
    232234        }
    233 
    234235        foreach cpath $deps {
    235236            $_owner dependenciesfor $cpath $path
    236237        }
    237238    }
    238     set _name2info($name-enable) $enable
     239    }
     240    set _name2info($name-enable) yes
    239241
    240242    #set wid [$_owner widgetfor $path]
     
    292294        $_owner changed $path
    293295    }
     296    if { [winfo class $wid] == "TextEntry" } {
     297        return
     298    }
     299    eval $deactivatecommand
    294300}
    295301
     
    459465        grid rowconfigure $_frame 99 -weight 0
    460466    }
     467    set _closeOnChange 0
     468    set slaves [grid slaves $_frame]
     469    if { [llength $slaves] == 1 } {
     470        set slave [lindex $slaves 0]
     471        set _closeOnChange 1
     472    }
    461473}
    462474
     
    526538    $_dispatcher event -idle !layout
    527539}
     540
  • branches/nanovis2/gui/scripts/drawingentry.tcl

    r2999 r3175  
    2828    private variable _drawingWidth 0
    2929    private variable _owner
    30     private variable _parser ""
     30    private variable _xmlobj ""
     31    private variable _parser "";        # Slave interpreter where all
     32                                        # substituted variables are stored.
    3133    private variable _path
    3234    private variable _showing ""
     
    4143    private variable _cursor ""
    4244
    43     constructor {owner path args} { # defined below }
    44 
     45    constructor {owner path args} {
     46        # defined below
     47    }
     48    destructor {
     49        # defined below
     50    }
    4551    public method value { args }
    4652    public method label {}
     
    4955    private method Activate { tag }
    5056    private method AdjustDrawingArea { xAspect yAspect }
     57    private method ControlValue {path {units ""}}
    5158    private method Deactivate { tag }
    5259    private method Highlight { tag }
     
    7077    private method ScreenY { y }
    7178    private method XmlGet { path }
    72     private method Withdraw {}
     79    private method XmlGetSubst { path }
     80    private method Withdraw { cname }
     81    private method Hotspot { option cname item args }
     82    private method IsEnabled { path }
     83    private method NumControlsEnabled { cname }
    7384}
    7485
     
    89100    set _path $path
    90101    set _owner $owner
     102    set _xmlobj [$_owner xml object]
    91103    #
    92104    # Display the current drawing.
     
    100112    pack $itk_component(drawing) -expand yes -fill both
    101113    bind $itk_component(drawing) <Configure> [itcl::code $this Redraw]
     114    set _parser [interp create -safe]
    102115    Redraw
    103116    eval itk_initialize $args
    104117}
    105118
     119itcl::body Rappture::DrawingEntry::destructor {} {
     120    if { $_parser != "" } {
     121        $_parser delete
     122    }
     123}
    106124# ----------------------------------------------------------------------
    107125# USAGE: label
     
    112130itcl::body Rappture::DrawingEntry::label {} {
    113131return ""
    114     set label [$_owner xml get $_path.about.label]
     132    set label [$_xmlobj get $_path.about.label]
    115133    if {"" == $label} {
    116134        set label "Drawing"
     
    129147itcl::body Rappture::DrawingEntry::tooltip {} {
    130148return ""
    131     set str [$_owner xml get $_path.about.description]
     149    set str [$_xmlobj get $_path.about.description]
    132150    return [string trim $str]
    133151}
     
    178196    ParseBackground
    179197    ParseSubstitutions
    180     foreach cname [$_owner xml children $_path.components] {
     198    foreach cname [$_xmlobj children $_path.components] {
    181199        switch -glob -- $cname {
    182200            "line*" {
     
    227245    }
    228246    # Coords
    229     set xcoords [XmlGet $cpath.xcoords]
     247    set xcoords [XmlGetSubst $cpath.xcoords]
    230248    set xcoords [string trim $xcoords]
    231     set ycoords [XmlGet $cpath.ycoords]
     249    set ycoords [XmlGetSubst $cpath.ycoords]
    232250    set ycoords [string trim $ycoords]
    233251    if { $ycoords == "" } {
     
    273291    #puts stderr "ParseGrid owner=$_owner cpath=$cpath xcoords=$xcoords ycoords=$ycoords"
    274292    set list {}
    275     foreach attr [$_owner xml children $cpath] {
     293    foreach attr [$_xmlobj children $cpath] {
    276294        if { [info exists attr2option($attr)] } {
    277295            set option $attr2option($attr)
    278             set value [XmlGet $cpath.$attr]
     296            set value [XmlGetSubst $cpath.$attr]
    279297            set options($option) $value
    280298        }
     
    309327    }
    310328    array unset _cname2controls $cname
    311     foreach attr [$_owner xml children $cpath] {
     329    foreach attr [$_xmlobj children $cpath] {
    312330        if { [info exists attr2option($attr)] } {
    313331            set option $attr2option($attr)
    314             set value [XmlGet $cpath.$attr]
     332            set value [XmlGetSubst $cpath.$attr]
    315333            set options($option) $value
    316334        } elseif { [string match "controls*" $attr] } {
    317             set value [XmlGet $cpath.$attr]
     335            set value [XmlGetSubst $cpath.$attr]
    318336            lappend _cname2controls($cname) $value
    319             $_owner xml put $value.hide 1
     337            $_xmlobj put $value.hide 1
    320338        }
    321339    }
    322340    # Coordinates
    323     set coords [XmlGet $cpath.coords]
     341    set coords [XmlGetSubst $cpath.coords]
    324342    set coords [ScreenCoords $coords]
    325343    if { $coords == "" } {
     
    327345    }
    328346    set c $itk_component(drawing)
    329     set img [Rappture::icon question_mark12]
     347    set img [Rappture::icon hotspot_normal]
    330348    foreach { x1 y1 } $coords break
    331349    set id [$itk_component(drawing) create image $x1 $y1]
     
    338356    $c bind $id <Leave> [itcl::code $this Deactivate $cname]
    339357    #$c bind $id <ButtonPress-1> [itcl::code $this Depress $cname]
    340     $c bind $id <ButtonRelease-1> [itcl::code $this Invoke $cname $x1 $y1]
     358    set bbox [$c bbox $id]
     359    set y1 [lindex $bbox 1]
     360    $c bind $id <ButtonPress-1> [itcl::code $this Invoke $cname $x1 $y1]
    341361}
    342362
     
    360380    # Coords
    361381    set coords {}
    362     set coords [XmlGet $cpath.coords]
     382    set coords [XmlGetSubst $cpath.coords]
    363383    set coords [string trim $coords]
    364384    if { $coords == "" } {
     
    369389    #puts stderr "ParseLine owner=$_owner cpath=$cpath coords=$coords"
    370390    set list {}
    371     foreach attr [$_owner xml children $cpath] {
     391    foreach attr [$_xmlobj children $cpath] {
    372392        if { [info exists attr2option($attr)] } {
    373393            set option $attr2option($attr)
    374             set value [XmlGet $cpath.$attr]
     394            set value [XmlGetSubst $cpath.$attr]
    375395            set options($option) $value
    376396        }
     
    389409        "outline"       "-outline"
    390410        "fill"          "-fill"
    391         "linewidth"     "-linewidth"
     411        "linewidth"     "-width"
    392412    }
    393413    #puts stderr "ParseOval owner=$_owner cpath=$cpath"
     
    396416    array set options {
    397417        -fill blue
    398         -linewidth 1
     418        -width 1
    399419        -outline black
    400420    }
    401     foreach attr [$_owner xml children $cpath] {
     421    foreach attr [$_xmlobj children $cpath] {
    402422        if { [info exists attr2option($attr)] } {
    403423            set option $attr2option($attr)
    404             set value [XmlGet $cpath.$attr]
     424            set value [XmlGetSubst $cpath.$attr]
    405425            set options($option) $value
    406426        }
     
    408428    # Coordinates
    409429    set coords {}
    410     set coords [XmlGet $cpath.coords]
     430    set coords [XmlGetSubst $cpath.coords]
    411431    set coords [string trim $coords]
    412432    if { $coords == "" } {
     
    414434    }
    415435    foreach { x1 y1 x2 y2 } [ScreenCoords $coords] break
    416     set id [eval $itk_component(drawing) create oval $coords]
     436    set id [$itk_component(drawing) create oval $x1 $y1 $x2 $y2]
    417437    set _cname2id($cname) $id
     438    eval $itk_component(drawing) itemconfigure $id [array get options]
    418439}
    419440
     
    430451        -anchor nw
    431452    }
    432     foreach attr [$_owner xml children $cpath] {
     453    foreach attr [$_xmlobj children $cpath] {
    433454        if { [info exists attr2option($attr)] } {
    434455            set option $attr2option($attr)
    435             set value [XmlGet $cpath.$attr]
     456            set value [XmlGetSubst $cpath.$attr]
    436457            set options($option) $value
    437458        }
    438459    }
    439     set contents [XmlGet $cpath.contents]
     460    set contents [XmlGetSubst $cpath.contents]
    440461    set img ""
    441462    if { [string compare -length 5 $contents "file:"] == 0 } {
     
    454475    }
    455476    # Coordinates
    456     set coords [XmlGet $cpath.coords]
     477    set coords [XmlGetSubst $cpath.coords]
    457478    set coords [ScreenCoords $coords]
    458479    if { [llength $coords] == 2 } {
    459480        foreach { x1 y1 } $coords break
    460         set w [XmlGet $cpath.width]
     481        set w [XmlGetSubst $cpath.width]
    461482        if { $w == "" || ![string is number $w] || $w <= 0.0 } {
    462483            set width [expr [image width $img] / 4]
     
    464485            set width [expr [ScreenX $w] - [ScreenX 0]]
    465486        }
    466         set h [XmlGet $cpath.height]
     487        set h [XmlGetSubst $cpath.height]
    467488        if { $h == "" || ![string is number $h] || $h <= 0.0 } {
    468489            set height [expr [image height $img] / 4]
     
    499520        set width [expr [image width $img] / 4]
    500521        set height [expr [image height $img] / 4]
    501         set dst [image create photo -width $width -height $height]
     522        set dst [image create photo -width $width -height $height]
    502523        blt::winop resample $img $dst
    503524        image delete $img
     
    518539    array set attr2option {
    519540        "linewidth"     "-width"
    520         "arrow"         "-arrow"
    521541        "color"         "-fill"
    522542    }
    523543    # Set default options first and then let tool.xml override them.
    524544    array set options {
    525         -arrow          none
    526         -width          0
    527         -fill           black
     545        -width          1
     546        -fill           blue
     547        -outline        black
    528548    }
    529549    # Coords
    530     set coords [XmlGet $cpath.coords]
     550    set coords [XmlGetSubst $cpath.coords]
    531551    set coords [string trim $coords]
    532552    if { $coords == "" } {
     
    540560    #puts stderr "ParsePolygon owner=$_owner cpath=$cpath coords=$coords"
    541561    set list {}
    542     foreach attr [$_owner xml children $cpath] {
     562    foreach attr [$_xmlobj children $cpath] {
    543563        if { [info exists attr2option($attr)] } {
    544564            set option $attr2option($attr)
    545             set value [XmlGet $cpath.$attr]
     565            set value [XmlGetSubst $cpath.$attr]
    546566            set options($option) $value
    547567        }
     
    560580        "outline"       "-outline"
    561581        "fill"          "-fill"
    562         "linewidth"     "-linewidth"
     582        "linewidth"     "-width"
    563583    }
    564584    #puts stderr "ParseRectangle owner=$_owner cpath=$cpath"
     
    567587    array set options {
    568588        -fill blue
    569         -linewidth 1
     589        -width 1
    570590        -outline black
    571591    }
    572     foreach attr [$_owner xml children $cpath] {
     592    foreach attr [$_xmlobj children $cpath] {
    573593        if { [info exists attr2option($attr)] } {
    574594            set option $attr2option($attr)
    575             set value [XmlGet $cpath.$attr]
     595            set value [XmlGetSubst $cpath.$attr]
    576596            set options($option) $value
    577597        }
    578598    }
    579599    # Coordinates
    580     set coords [XmlGet $cpath.coords]
     600    set coords [XmlGetSubst $cpath.coords]
    581601    set coords [string trim $coords]
    582602    if { $coords == "" } {
    583603        set coords "0 0 1 1"
    584604    }
    585     foreach { x1 y1 x2 y2 } [ScreenCoords $coords] break
    586     set id [eval $itk_component(drawing) create rectangle $coords]
     605    foreach { x1 y1 x2 y2 } [ScreenCoords $coords] break 
     606   set id [$itk_component(drawing) create rectangle $x1 $y1 $x2 $y2]
    587607    set _cname2id($cname) $id
     608    eval $itk_component(drawing) itemconfigure $id [array get options]
    588609}
    589610
     
    594615    array set attr2option {
    595616        "font"          "-font"
    596         "color"         "-fill"
     617        "color"         "-foreground"
     618        "valuecolor"    "-valueforeground"
    597619        "text"          "-text"
    598620        "anchor"        "-anchor"
     
    602624    # Set default options first and then let tool.xml override them.
    603625    array set options {
    604         -font {Arial 8}
     626        -font {Arial 12}
     627        -valuefont {Arial 12}
     628        -valueforeground blue3
    605629        -text {}
    606         -fill black
     630        -fill {}
    607631        -anchor c
    608632    }
    609     foreach attr [$_owner xml children $cpath] {
     633    foreach attr [$_xmlobj children $cpath] {
    610634        if { [info exists attr2option($attr)] } {
    611635            set option $attr2option($attr)
    612             set value [XmlGet $cpath.$attr]
     636            if { $attr == "text" } {
     637                set value [XmlGet $cpath.$attr]
     638            } else {
     639                set value [XmlGetSubst $cpath.$attr]
     640            }
    613641            set options($option) $value
    614642        }
    615643    }
    616644    # Coords
    617     set coords [XmlGet $cpath.coords]
     645    set coords [XmlGetSubst $cpath.coords]
    618646    set coords [string trim $coords]
    619647    if { $coords == "" } {
     
    622650        set coords [ScreenCoords $coords]
    623651    }
     652    set hotspot [XmlGetSubst $cpath.hotspot]
     653    if { $hotspot == "inline" } {
     654        set options(-showicons) 1
     655    }
     656    set c $itk_component(drawing)
    624657    set options(-tags) $cname
    625     set id [eval $itk_component(drawing) create text $coords]
     658    set img [Rappture::icon hotspot_normal]
     659    set options(-image) $img
     660    set img [Rappture::icon hotspot_active]
     661    set options(-activeimage) $img
     662    set id [eval $c create hotspot $coords]
    626663    set _cname2id($cname) $id
    627     eval $itk_component(drawing) itemconfigure $id [array get options]
     664    set options(-interp) $_parser
     665    eval $c itemconfigure $id [array get options]
     666    if { $hotspot == "inline" } {
     667        array unset _cname2controls $cname
     668        foreach varName [Rappture::hotspot variables $c $id] {
     669            if { [info exists _name2path($varName)] } {
     670                set path $_name2path($varName)
     671                $_xmlobj put $path.hide 1
     672                lappend _cname2controls($cname) $path
     673            } else {
     674                puts stderr "unknown varName=$varName"
     675            }
     676        }
     677        $c bind $id <Motion> \
     678            [itcl::code $this Hotspot watch $cname $id %x %y]
     679        $c bind $id <Leave> \
     680            [itcl::code $this Hotspot deactivate $cname $id]
     681        $c bind $id <Enter> \
     682            [itcl::code $this Hotspot activate $cname $id %x %y]
     683        $c bind $id <ButtonRelease-1> \
     684            [itcl::code $this Hotspot invoke $cname $id %x %y]
     685    }
     686}
     687
     688
     689itcl::body Rappture::DrawingEntry::Hotspot { option cname item args } {
     690    if { [NumControlsEnabled $cname] == 0 } {
     691        return
     692    }
     693    set c $itk_component(drawing)
     694    switch -- $option {
     695        "activate" {
     696            foreach { x y } $args break
     697            set varName  [Rappture::hotspot identify $c $item $x $y]
     698            $c itemconfigure $item -activevalue $varName
     699        }
     700        "deactivate" {
     701            $c itemconfigure $item -activevalue ""
     702        }
     703        "watch" {
     704            foreach { x y } $args break
     705            set active [$c itemcget $item -activevalue]
     706            set varName  [Rappture::hotspot identify $c $item $x $y]
     707            if { $varName != $active  } {
     708                $c itemconfigure $item -activevalue $varName
     709            }
     710        }
     711        "invoke" {
     712            foreach { x y } $args break
     713            set active [$c itemcget $item -activevalue]
     714            set varName  [Rappture::hotspot identify $c $item $x $y]
     715            if { $varName != "" } {
     716                set bbox [$c bbox $item]
     717                Invoke $cname $x [lindex $bbox 1]
     718            }
     719        }
     720    }
    628721}
    629722
     
    738831
    739832itcl::body Rappture::DrawingEntry::ParseBackground {} {
    740     foreach elem [$_owner xml children $_path.background] {
     833    foreach elem [$_xmlobj children $_path.background] {
    741834        switch -glob -- $elem {
    742835            "color*" {
     
    767860
    768861itcl::body Rappture::DrawingEntry::ParseSubstitutions {} {
    769     foreach var [$_owner xml children $_path.substitutions] {
     862    foreach var [$_xmlobj children $_path.substitutions] {
    770863        if { ![string match "variable*" $var] } {
    771864            continue
     
    775868        set name ""
    776869        set path ""
    777         foreach elem [$_owner xml children $varPath] {
     870        foreach elem [$_xmlobj children $varPath] {
    778871            switch -glob -- $elem {
    779872                "name*" {
     
    826919    set popup .drawingentrypopup
    827920    if { ![winfo exists $popup] } {
    828         # Create a popup for the print dialog
     921        # Create a popup for the controls dialog
    829922        Rappture::Balloon $popup -title "Change values..." \
    830             -deactivatecommand [itcl::code $this Withdraw]
     923            -deactivatecommand [itcl::code $this Withdraw $cname]
    831924        set inner [$popup component inner]
    832925        Rappture::DrawingControls $inner.controls $_owner \
     
    837930        $inner.controls delete all
    838931    }
     932    set count 0
    839933    foreach path $controls {
    840         $inner.controls add $path
     934        if { [IsEnabled $path] } {
     935            $inner.controls add $path
     936            incr count
     937        }
     938    }
     939    if { $count == 0 } {
     940        return
    841941    }
    842942    update
     
    844944    incr x [winfo rootx $itk_component(drawing)]
    845945    incr y [winfo rooty $itk_component(drawing)]
    846    
    847946    $popup activate @$x,$y above
    848947}
     
    852951#
    853952itcl::body Rappture::DrawingEntry::Activate { cname } {
    854     $itk_component(drawing) configure -cursor center_ptr
     953    $itk_component(drawing) configure -cursor center_ptr
     954    $itk_component(drawing) itemconfigure $_cname2id($cname) \
     955        -image [Rappture::icon hotspot_active]
    855956}
    856957
     
    859960#
    860961itcl::body Rappture::DrawingEntry::Deactivate { cname } {
    861     $itk_component(drawing) configure -cursor left_ptr
    862 }
    863 
    864 #
    865 # Invoke --
    866 #
    867 itcl::body Rappture::DrawingEntry::Withdraw {} {
     962    $itk_component(drawing) configure -cursor left_ptr
     963    $itk_component(drawing) itemconfigure $_cname2id($cname) \
     964        -image [Rappture::icon hotspot_normal]
     965}
     966
     967#
     968# Withdraw --
     969#
     970itcl::body Rappture::DrawingEntry::Withdraw { cname } {
    868971    Redraw
    869972}
     
    879982# ----------------------------------------------------------------------
    880983itcl::body Rappture::DrawingEntry::value {args} {
    881     # drawing entries have no value
     984    # Redraw if there's a new library object.
     985    if { [llength $args] > 0 } {
     986        set libobj [lindex $args 0]
     987        if { $libobj != "" } {
     988            Redraw
     989        }
     990    }
    882991    return ""
    883992}
     
    889998itcl::body Rappture::DrawingEntry::InitSubstitutions {} {
    890999    # Load a new parser with the variables representing the substitution
    891     set _parser [interp create -safe]
    8921000    foreach name [array names _name2path] {
    8931001        set path $_name2path($name)
     
    9031011
    9041012itcl::body Rappture::DrawingEntry::XmlGet { path } {
    905     set value [$_owner xml get $path]
     1013    set value [$_xmlobj get $path]
     1014    return [string trim $value]
     1015}
     1016
     1017itcl::body Rappture::DrawingEntry::XmlGetSubst { path } {
     1018    set value [$_xmlobj get $path]
    9061019    if { $_parser == "" } {
    9071020        return $value
    9081021    }
    909     return [$_parser eval [list subst -nocommands $value]]
    910 }
    911 
     1022    return [string trim [$_parser eval [list subst -nocommands $value]]]
     1023}
     1024
     1025itcl::body Rappture::DrawingEntry::IsEnabled { path } {
     1026    set enable [string trim [$_xmlobj get $path.about.enable]]
     1027    if {"" == $enable} {
     1028        return 1
     1029    }
     1030    if {![string is boolean $enable]} {
     1031        set re {([a-zA-Z_]+[0-9]*|\([^\(\)]+\)|[a-zA-Z_]+[0-9]*\([^\(\)]+\))(\.([a-zA-Z_]+[0-9]*|\([^\(\)]+\)|[a-zA-Z_]+[0-9]*\([^\(\)]+\)))*(:[-a-zA-Z0-9/]+)?}
     1032        set rest $enable
     1033        set enable ""
     1034        set deps ""
     1035        while {1} {
     1036            if {[regexp -indices $re $rest match]} {
     1037                foreach {s0 s1} $match break
     1038
     1039                if {[string index $rest [expr {$s0-1}]] == "\""
     1040                      && [string index $rest [expr {$s1+1}]] == "\""} {
     1041                    # string in ""'s? then leave it alone
     1042                    append enable [string range $rest 0 $s1]
     1043                    set rest [string range $rest [expr {$s1+1}] end]
     1044                } else {
     1045                    #
     1046                    # This is a symbol which should be substituted
     1047                    # it can be either:
     1048                    #   input.foo.bar
     1049                    #   input.foo.bar:units
     1050                    #
     1051                    set cpath [string range $rest $s0 $s1]
     1052                    set parts [split $cpath :]
     1053                    set ccpath [lindex $parts 0]
     1054                    set units [lindex $parts 1]
     1055
     1056                    # make sure we have the standard path notation
     1057                    set stdpath [$_owner regularize $ccpath]
     1058                    if {"" == $stdpath} {
     1059                        puts stderr "WARNING: don't recognize parameter $cpath in <enable> expression for $path.  This may be buried in a structure that is not yet loaded."
     1060                        set stdpath $ccpath
     1061                    }
     1062                    # substitute [_controlValue ...] call in place of path
     1063                    append enable [string range $rest 0 [expr {$s0-1}]]
     1064                    append enable [format {[ControlValue %s %s]} $stdpath $units]
     1065                    lappend deps $stdpath
     1066                    set rest [string range $rest [expr {$s1+1}] end]
     1067                }
     1068            } else {
     1069                append enable $rest
     1070                break
     1071            }
     1072        }
     1073    }
     1074    return [expr $enable]
     1075}
     1076
     1077# ----------------------------------------------------------------------
     1078# USAGE: ControlValue <path> ?<units>?
     1079#
     1080# Used internally to get the value of a control with the specified
     1081# <path>.  Returns the current value for the control.
     1082# ----------------------------------------------------------------------
     1083itcl::body Rappture::DrawingEntry::ControlValue {path {units ""}} {
     1084    if {"" != $_owner} {
     1085        set val [$_owner valuefor $path]
     1086         if {"" != $units} {
     1087            set val [Rappture::Units::convert $val -to $units -units off]
     1088        }
     1089        return $val
     1090    }
     1091    return ""
     1092}
     1093
     1094itcl::body Rappture::DrawingEntry::NumControlsEnabled { cname } {
     1095    set controls $_cname2controls($cname)
     1096    set count 0
     1097    foreach path $controls {
     1098        if { [IsEnabled $path] } {
     1099            incr count
     1100        }
     1101    }
     1102    return $count
     1103}
  • branches/nanovis2/gui/scripts/field.tcl

    r2744 r3175  
    5151    private variable _comp2vtk   ;# maps component name => vtkFloatArray
    5252    private variable _comp2vtkstreamlines   ;# maps component name => vtkFloatArray
     53    private variable _comp2vtkcontour   ;# maps component name => vtkFloatArray
    5354    private variable _comp2vtkvolume   ;# maps component name => vtkFloatArray
    5455    private variable _comp2volume   ;# maps component name => vtkFloatArray
     
    5960    private variable _comp2cntls ;# maps component name => x,y control points
    6061    private variable _comp2extents
     62    private variable _comp2limits
    6163    private variable _type ""
    6264    private variable _comp2flowhints
    6365    private common _counter 0    ;# counter for unique vector names
     66
     67    private method ConvertToVtkData { cname }
     68    private method ReadVtkDataSet { cname contents }
     69    private variable _fields {}
     70    private variable _isVtk
    6471}
    6572
     
    197204        return [$mobj mesh]
    198205    }
     206    if { [info exists _comp2vtkcontour($what)] } {
     207        error "method \"mesh\" is not implemented for vtkcontour"
     208    }
    199209    if { [info exists _comp2vtk($what)] } {
    200210        set mobj [lindex $_comp2vtk($what) 0]
     
    232242        return [lindex $_comp2xy($what) 1]  ;# return yv
    233243    }
     244    if { [info exists _comp2vtkcontour($what)] } {
     245        error "method \"values\" is not implemented for vtkcontour"
     246    }
    234247    if { [info exists _comp2vtkstreamlines($what)] } {
    235248        # FIXME: Need to process the vtk file data to pull out the field's
    236249        # values.
    237         error "vtkstreamlines: values not implements"
     250        error "vtkstreamlines: values not implemented"
    238251        return [lindex $_comp2vtkstreamlines($what) 1]
    239252    }
     
    270283    if { [info exists _comp2vtkvolume($what)] } {
    271284        return $_comp2vtkvolume($what)
     285    }
     286    if { [info exists _comp2vtkcontour($what)] } {
     287        return $_comp2vtkcontour($what)
    272288    }
    273289    if { [info exists _comp2vtkstreamlines($what)] } {
     
    589605    array unset _comp2volume
    590606    array unset _comp2vtkstreamlines
     607    array unset _comp2vtkcontour
    591608    array unset _comp2unirect2d
    592609    array unset _comp2unirect3d
     
    607624            set type "points-on-mesh"
    608625        } elseif {[$_field element $cname.vtk] != ""} {
     626            set _isVtkData($cname) 1
    609627            if { [$_field get "about.view"] == "streamlines" } {
    610628                set type "vtkstreamlines"
     629            } elseif { [$_field get "about.view"] == "contour" } {
     630                set type "vtkcontour"
    611631            } else {
    612632                set type "vtk"
     
    800820            # Allow redirects to another element.
    801821            set vtkdata [$_field get $cname.vtk]
    802             if { ![string match "!*" $vtkdata] } {
    803                 set _comp2vtkstreamlines($cname) $vtkdata
    804             } else {
    805                 set path [string range $vtkdata 1 end]
    806                 if { [$_xmlobj element $path] == "" } {
    807                     error "bad redirection path \"$path\""
    808                 }
    809                 puts stderr path=$path
    810                 set element [$_xmlobj element -as type $path]
    811                 if { $element != "vtk" } {
    812                     error "bad path \"$path\": must redirect to a vtk element"
    813                 }
    814                 set _comp2vtkstreamlines($cname) [$_xmlobj get $path]
    815             }
     822            set _comp2vtkstreamlines($cname) $vtkdata
     823            set _comp2style($cname) [$_field get $cname.style]
     824            incr _counter
     825        } elseif {$type == "vtkcontour"} {
     826            set _comp2dims($cname) "2D"
     827            # Allow redirects to another element.
     828
     829            set data [$_field get $cname.vtk]
     830            ReadVtkDataSet $cname $data
     831            set _comp2vtkcontour($cname) $data
    816832            set _comp2style($cname) [$_field get $cname.style]
    817833            incr _counter
     
    10241040        return ""
    10251041    }
     1042    if { [info exists _comp2vtkcontour($what)] } {
     1043        return $_comp2contour($what)
     1044    }
    10261045    if { [info exists _comp2vtkstreamlines($what)] } {
    1027         # Return the contents of the vtk file.
    10281046        return $_comp2vtkstreamlines($what)
    10291047    }
    10301048    if { [info exists _comp2vtkvolume($what)] } {
    1031         # Return the contents of the vtk file.
    10321049        return $_comp2vtkvolume($what)
    10331050    }
     
    10431060    error "bad option \"$what\": should be [join [lsort [array names _comp2dims]] {, }]"
    10441061}
     1062
     1063itcl::body Rappture::Field::ConvertToVtkData { comp } {
     1064    set ds ""
     1065    switch -- [typeof $comp] {
     1066        "unirect2d" {
     1067            foreach { x1 x2 xN y1 y2 yN } [$dataobj mesh $comp] break
     1068            set spacingX [expr {double($x2 - $x1)/double($xN - 1)}]
     1069            set spacingY [expr {double($y2 - $y1)/double($yN - 1)}]
     1070           
     1071            set ds [vtkImageData $this-grdataTemp]
     1072            $ds SetDimensions $xN $yN 1
     1073            $ds SetOrigin $x1 $y1 0
     1074            $ds SetSpacing $spacingX $spacingY 0
     1075            set arr [vtkDoubleArray $this-arrTemp]
     1076            foreach {val} [$dataobj values $comp] {
     1077                $arr InsertNextValue $val
     1078            }
     1079            [$ds GetPointData] SetScalars $arr
     1080        }
     1081        "unirect3d" {
     1082            foreach { x1 x2 xN y1 y2 yN z1 z2 zN } [$dataobj mesh $comp] break
     1083            set spacingX [expr {double($x2 - $x1)/double($xN - 1)}]
     1084            set spacingY [expr {double($y2 - $y1)/double($yN - 1)}]
     1085            set spacingZ [expr {double($z2 - $z1)/double($zN - 1)}]
     1086           
     1087            set ds [vtkImageData $this-grdataTemp]
     1088            $ds SetDimensions $xN $yN $zN
     1089            $ds SetOrigin $x1 $y1 $z1
     1090            $ds SetSpacing $spacingX $spacingY $spacingZ
     1091            set arr [vtkDoubleArray $this-arrTemp]
     1092            foreach {val} [$dataobj values $comp] {
     1093                $arr InsertNextValue $val
     1094            }
     1095            [$ds GetPointData] SetScalars $val
     1096        }
     1097        "vtkcontour" {
     1098            return [$dataobj blob $comp]
     1099        }
     1100        "dx" {
     1101            return [Rappture::ConvertDxToVtk $_comp2dx($what)]
     1102        }
     1103        default {
     1104            set mesh [$dataobj mesh $comp]
     1105            switch -- [$mesh GetClassName] {
     1106                vtkPoints {
     1107                    # handle cloud of points
     1108                    set ds [vtkPolyData $this-polydataTemp]
     1109                    $ds SetPoints $mesh
     1110                    [$ds GetPointData] SetScalars [$dataobj values $comp]
     1111                }
     1112                vtkPolyData {
     1113                    set ds [vtkPolyData $this-polydataTemp]
     1114                    $ds ShallowCopy $mesh
     1115                    [$ds GetPointData] SetScalars [$dataobj values $comp]
     1116                }
     1117                vtkUnstructuredGrid {
     1118                    # handle 3D grid with connectivity
     1119                    set ds [vtkUnstructuredGrid $this-grdataTemp]
     1120                    $ds ShallowCopy $mesh
     1121                    [$ds GetPointData] SetScalars [$dataobj values $comp]
     1122                }
     1123                vtkRectilinearGrid {
     1124                    # handle 3D grid with connectivity
     1125                    set ds [vtkRectilinearGrid $this-grdataTemp]
     1126                    $ds ShallowCopy $mesh
     1127                    [$ds GetPointData] SetScalars [$dataobj values $comp]
     1128                }
     1129                default {
     1130                    error "don't know how to handle [$mesh GetClassName] data"
     1131                }
     1132            }
     1133        }
     1134    }
     1135
     1136    if {"" != $ds} {
     1137        set writer [vtkDataSetWriter $this-dsWriterTmp]
     1138        $writer SetInput $ds
     1139        $writer SetFileTypeToASCII
     1140        $writer WriteToOutputStringOn
     1141        $writer Write
     1142        set out [$writer GetOutputString]
     1143        $ds Delete
     1144        $writer Delete
     1145    } else {
     1146        set out ""
     1147        error "No DataSet to write"
     1148    }
     1149
     1150    append out "\n"
     1151    return $out
     1152}
     1153
     1154itcl::body Rappture::Field::ReadVtkDataSet { comp contents } {
     1155    package require vtk
     1156
     1157    set reader $this-datasetreader
     1158    vtkDataSetReader $reader
     1159
     1160    # Write the contents to a file just in case it's binary.
     1161    set tmpfile file[pid].vtk
     1162    set f [open "$tmpfile" "w"]
     1163    fconfigure $f -translation binary -encoding binary
     1164    puts $f $contents
     1165    close $f
     1166    $reader SetFileName $tmpfile
     1167    $reader ReadAllScalarsOn
     1168    $reader ReadAllVectorsOn
     1169    $reader ReadAllFieldsOn
     1170    $reader Update
     1171    set dataset [$reader GetOutput]
     1172    set limits {}
     1173    foreach {xmin xmax ymin ymax zmin zmax} [$dataset GetBounds] break
     1174    lappend limits xmin $xmin xmax $xmax ymin $ymin ymax $ymax 
     1175    set dataAttrs [$dataset GetPointData]
     1176    if { $dataAttrs == ""} {
     1177        puts stderr "No point data"
     1178    }
     1179    for {set i 0} {$i < [$dataAttrs GetNumberOfArrays] } {incr i} {
     1180        set array [$dataAttrs GetArray $i]
     1181        set name  [$dataAttrs GetArrayName $i]
     1182        foreach {min max} [$array GetRange] break
     1183        lappend limits $name-min $min $name-max $max
     1184        lappend _fields $name
     1185    }
     1186    set _comp2limits($comp) $limits
     1187    puts stderr limits=$limits
     1188    $reader Delete
     1189    file delete $tmpfile
     1190}
     1191
  • branches/nanovis2/gui/scripts/field2dresult.tcl

    r2977 r3175  
    6161            set servers [Rappture::VisViewer::GetServerList "nanovis"]
    6262        }
    63         "vtkcontour" - "vtkheightmap" {
     63        "vtkcontour" - "vtkheightmap" - "vtkstreamlines" - "vtkviewer" {
    6464            set servers [Rappture::VisViewer::GetServerList "vtkvis"]
    6565        }
     
    7878                }
    7979            }
    80             "vtkheightmap" {
     80            "flowvis" {
    8181                itk_component add renderer {
    82                     Rappture::VtkHeightmapViewer $itk_interior.ren $servers
     82                    Rappture::FlowvisViewer $itk_interior.ren $servers
    8383                }
    8484            }
     
    8888                }
    8989            }
    90             "flowvis" {
     90            "vtkheightmap" {
    9191                itk_component add renderer {
    92                     Rappture::FlowvisViewer $itk_interior.ren $servers
     92                    Rappture::VtkHeightmapViewer $itk_interior.ren $servers
     93                }
     94            }
     95            "vtkstreamlines" {
     96                itk_component add renderer {
     97                    Rappture::VtkStreamlinesViewer $itk_interior.ren $servers
     98                }
     99            }
     100            "vtkviewer" {
     101                itk_component add renderer {
     102                    Rappture::VtkViewer $itk_interior.ren $servers
    93103                }
    94104            }
  • branches/nanovis2/gui/scripts/field3dresult.tcl

    r2977 r3175  
    5959            set servers [Rappture::VisViewer::GetServerList "nanovis"]
    6060        }
    61         "vtkcontour" - "vtkstreamlines" - "vtkvolume" - "vtkviewer" {
     61        "vtkcontour" - "vtkheightmap" - "vtkstreamlines" - "vtkviewer" - "vtkvolume" {
    6262            set servers [Rappture::VisViewer::GetServerList "vtkvis"]
    6363        }
     
    6969            puts stderr "unknown render mode \"$flags(-mode)\""
    7070        }
    71     }           
     71    }
    7272    if {"" != $servers && $flags(-mode) != "vtk"} {
    7373        switch -- $flags(-mode) {
     
    8282                }
    8383            }
    84             "vtkvolume" {
    85                 catch {
     84            "vtkcontour" {
    8685                itk_component add renderer {
    87                     Rappture::VtkVolumeViewer $itk_interior.ren $servers
     86                    Rappture::VtkContourViewer $itk_interior.ren $servers
    8887                }
    89                 } errs
    90                 puts stderr errs=$errs
     88            }
     89            "vtkheightmap" {
     90                itk_component add renderer {
     91                    Rappture::VtkHeightmapViewer $itk_interior.ren $servers
     92                }
    9193            }
    9294            "vtkstreamlines" {
    9395                itk_component add renderer {
    9496                    Rappture::VtkStreamlinesViewer $itk_interior.ren $servers
     97                }
     98            }
     99            "vtkviewer" {
     100                itk_component add renderer {
     101                    Rappture::VtkViewer $itk_interior.ren $servers
     102                }
     103            }
     104            "vtkvolume" {
     105                itk_component add renderer {
     106                    Rappture::VtkVolumeViewer $itk_interior.ren $servers
    95107                }
    96108            }
  • branches/nanovis2/gui/scripts/gauge.tcl

    r1850 r3175  
    239239            }
    240240            real {
    241                 if {[string length $nv] <= 0
    242                       || ![string is double $nv]
    243                       || [regexp -nocase {^(inf|nan)$} $nv]} {
     241                # "scan" will reject the number if the string is "NaN" or
     242                # "Inf" or the empty string.  It also is accepts large numbers
     243                # (e.g. 111111111111111111111) that "string is double"
     244                # rejects.  The problem with "scan" is that it doesn't care if
     245                # there are extra characters trailing the number (eg. "123a").
     246                # The extra %s substitution is used to detect this case.
     247                if { [scan $nv "%g%s" dummy1 dummy2] != 1 } {
    244248                    error "bad value \"$nv\": should be a real number"
    245249                }
  • branches/nanovis2/gui/scripts/histogram.tcl

    r2778 r3175  
    354354        set count 0
    355355        foreach line [split $xydata \n] {
    356             foreach {name value} $line break
    357             $_yvalues($comp) append $value
    358             $_xvalues($comp) append $count
    359             lappend _xlabels($comp) $name
    360             incr count
     356            if {[llength $line] == 2} {
     357                foreach {name value} $line break
     358                $_yvalues($comp) append $value
     359                $_xvalues($comp) append $count
     360                lappend _xlabels($comp) $name
     361                incr count
     362            }
    361363        }           
    362364        set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)]
     
    368370        foreach line [split $xhwdata \n] {
    369371            set n [scan $line {%s %s %s} name h w]
    370             lappend _xlabels($comp) $name
    371             $_xvalues($comp) append $count
    372             $_yvalues($comp) append $h
    373             if { $n == 3 } {
    374                 $_widths($comp) append $w
     372            if {$n >= 2} {
     373                lappend _xlabels($comp) $name
     374                $_xvalues($comp) append $count
     375                $_yvalues($comp) append $h
     376                if { $n == 3 } {
     377                    $_widths($comp) append $w
     378                }
     379                incr count
    375380            }
    376             incr count
    377381        }           
    378382        set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)]
  • branches/nanovis2/gui/scripts/histogramresult.tcl

    r2778 r3175  
    545545                            set xv [$dataobj mesh $comp]
    546546                            set yv [$dataobj values $comp]
    547                             foreach x [$xv range 0 end] y [$yv range 0 end] {
    548                                 append csvdata \
    549                                     [format "%20.15g, %20.15g\n" $x $y]
    550                             }
     547                            if { [$xv length] > 0 && [$yv length] > 0 } {
     548                                foreach x [$xv range 0 end] y [$yv range 0 end] {
     549                                    append csvdata \
     550                                        [format "%20.15g, %20.15g\n" $x $y]
     551                                }
     552                            }
    551553                            set first 0
    552554                        }
     
    717719            # Compute default bar width for histogram elements.
    718720            if { [$zv length] == [$xv length] } {
    719                 foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
    720                     set elem "elem[incr count]"
    721                     set _elem2dataobj($elem) $dataobj
    722                     $g element create $elem -x $x -y $y -barwidth $z \
    723                         -label $label -foreground $color \
    724                         -mapx $mapx -mapy $mapy
    725                 }
     721                if { [$xv length] > 0 && [$yv length] > 0 } {
     722                    set xvalues [$xv range 0 end]
     723                    set yvalues [$yv range 0 end]
     724                    set zvalues [$zv range 0 end]
     725                    foreach x $xvalues y $yvalues z $zvalues {
     726                        set elem "elem[incr count]"
     727                        set _elem2dataobj($elem) $dataobj
     728                        $g element create $elem -x $x -y $y -barwidth $z \
     729                            -label $label -foreground $color \
     730                            -mapx $mapx -mapy $mapy
     731                    }
     732                }
    726733            } else {
    727734                set r [blt::vector expr {max($xv) - min($xv)}]
    728                 set z [expr {$r / ([$xv length]-1) * 0.8}]
     735                set length [$xv length]
     736                if { $length > 1 } {
     737                    set z [expr {$r / ([$xv length]-1) * 0.8}]
     738                } else {
     739                    set z 1
     740                }
    729741                set elem "elem[incr count]"
    730742                set _elem2dataobj($elem) $dataobj
     
    15711583    # Determine the element name from the value
    15721584    set index [expr round($value)]
    1573     if { [info exists _xlabels($index)] } {
    1574         return $_xlabels($index)
    1575     }
     1585    set d [expr abs($value - $index)]
     1586    # Ignore values that aren't close to the integer value
     1587    if { $d < 0.00000001 } {
     1588        if { [info exists _xlabels($index)] } {
     1589            return $_xlabels($index)
     1590        }
     1591    }
    15761592    return " "
    15771593}
  • branches/nanovis2/gui/scripts/htmlviewer.tcl

    r2981 r3175  
    304304        if {"" != $node} {
    305305            set bbox [$itk_component(html) bbox $node]
    306             set realht [expr {[lindex $bbox 3]-[lindex $bbox 1]}]
     306            if { [llength $bbox] == 4 } {
     307                set realht [expr {[lindex $bbox 3]-[lindex $bbox 1]}]
     308            }
    307309        }
    308310        if {$itk_option(-maxlines) > 0} {
  • branches/nanovis2/gui/scripts/main.tcl

    r2977 r3175  
    5555option add *Balloon*Radiobutton.font -*-helvetica-medium-r-normal-*-12-*
    5656option add *Balloon*Checkbutton.font -*-helvetica-medium-r-normal-*-12-*
    57 option add *ResultSet.controlbarBackground #6666cc
    58 option add *ResultSet.controlbarForeground white
    59 option add *ResultSet.activeControlBackground #ccccff
    60 option add *ResultSet.activeControlForeground black
     57option add *ResultSelector.controlbarBackground #6666cc
     58option add *ResultSelector.controlbarForeground white
     59option add *ResultSelector.activeControlBackground #ccccff
     60option add *ResultSelector.activeControlForeground black
    6161option add *Radiodial.length 3i
    6262option add *BugReport*banner*foreground white
     
    146146set xmlobj [Rappture::library $params(-tool)]
    147147
    148 set installdir [file dirname $params(-tool)]
    149 if {"." == $installdir} {
    150     set installdir [pwd]
    151 }
     148set installdir [file normalize [file dirname $params(-tool)]]
     149$xmlobj put tool.version.application.directory(tool) $installdir
    152150
    153151set tool [Rappture::Tool ::#auto $xmlobj $installdir]
  • branches/nanovis2/gui/scripts/mesh.tcl

    r2792 r3175  
    366366    if {![info exists _pts2elem($npts)]} {
    367367        switch -- $npts {
     368            3 {
     369                set _pts2elem($npts) $this-elem3
     370                vtkTriangle $_pts2elem($npts)
     371            }
    368372            4 {
    369373                set _pts2elem($npts) $this-elem4
  • branches/nanovis2/gui/scripts/nanovisviewer.tcl

    r3023 r3175  
    117117    private method volume { tag name }
    118118    private method GetVolumeInfo { w }
     119    private method SetOrientation {}
    119120
    120121    private variable _arcball ""
     
    19531954        incr row
    19541955    }
     1956
     1957    itk_component add orientation {
     1958        Rappture::Combobox $inner.orientation -width 10 -editable no
     1959    }
     1960    $inner.orientation choices insert end \
     1961        "front"    "0 90 0" \
     1962        "back"   "180 90 0" \
     1963        "top"     "0 0 0"  \
     1964        "bottom"     "0 180 0"  \
     1965        "left"     "270 90 0 "  \
     1966        "right"     "90 90 0"  \
     1967        "default"  "45 45 0"
     1968    $itk_component(orientation) value "default"
     1969    bind $inner.orientation <<Value>> [itcl::code $this SetOrientation]
     1970
    19551971    blt::table configure $inner c0 c1 -resize none
    19561972    blt::table configure $inner c2 -resize expand
     
    21322148}
    21332149
     2150
     2151itcl::body Rappture::NanovisViewer::SetOrientation {} {
     2152    set angles [$itk_component(orientation) value]
     2153    foreach name { theta phi psi } angle $angles {
     2154        set _view($name) $angle
     2155    }
     2156    set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
     2157    SendCmd "camera angle $xyz"
     2158}
  • branches/nanovis2/gui/scripts/note.tcl

    r1641 r3175  
     1
    12# ----------------------------------------------------------------------
    23#  COMPONENT: Note - widget for displaying HTML notes
     
    6869
    6970    _setContents [$_owner xml get $_path.contents]
    70 }
     71    set w [$_owner xml get $_path.width]
     72    if { $w != "" } {
     73        $itk_component(html) configure -width $w
     74    }
     75    set h [$_owner xml get $_path.height]
     76    if { $h != "" } {
     77        $itk_component(html) configure -height $h
     78    }   
     79}
     80
    7181
    7282# ----------------------------------------------------------------------
  • branches/nanovis2/gui/scripts/numberresult.tcl

    r2744 r3175  
    957957        # - multiple axes? dim other axes
    958958        # - pop up tooltip about data
    959 
    960         $g element deactivate $_hilite(elem)
     959        if {$_hilite(elem) ne ""} {
     960            $g element deactivate $_hilite(elem)
     961        }
    961962        $g crosshairs configure -hide yes
    962963        Rappture::Tooltip::tooltip cancel
     
    10411042        # - take down tooltip
    10421043        #
    1043         $g element deactivate $_hilite(elem)
     1044        if {$_hilite(elem) ne ""} {
     1045            $g element deactivate $_hilite(elem)
     1046        }
    10441047
    10451048        set allx [$g x2axis use]
  • branches/nanovis2/gui/scripts/periodictable.tcl

    r2977 r3175  
    1 
    21# ----------------------------------------------------------------------
    32#  COMPONENT: periodictable - drop-down list of items
     
    76#
    87# ======================================================================
    9 #  AUTHOR:  Michael McLennan, Purdue University
    10 #  Copyright (c) 2004-2005  Purdue Research Foundation
     8#  AUTHOR:  George Howlett, Purdue University
     9#  Copyright (c) 2004-2012  Purdue Research Foundation
    1110#
    1211#  See the file "license.terms" for information on usage and
     
    3231    public method value { {name ""} }
    3332
    34     private variable _table
     33    public proc FindElement { string }
     34    public proc ElementIsType { string args }
     35
    3536    private variable _dispatcher ""
    3637    private variable _current ""
     
    4344    protected method Activate { widget id x y }
    4445    protected method Deactivate { widget id }
    45     protected method FindElement { string }
    4646    private common _colors
    4747    array set _colors {
     
    242242        Lawrencium      103 Lr [262.110] 9 17   actinoid
    243243    }
     244
     245    private common _table
     246    foreach { name number symbol weight row column type } $_tableData {
     247        set _table($name) [list name $name number $number symbol $symbol \
     248                weight $weight row $row column $column type $type]
     249    }
     250
    244251    private common _types
    245252    array set _types {
     
    302309    $_dispatcher register !rebuild
    303310    $_dispatcher dispatch $this !rebuild "[itcl::code $this Redraw]; list"
    304     foreach { name number symbol weight row column type } $_tableData {
    305         set _table($name) [list name $name number $number symbol $symbol \
    306                 weight $weight row $row column $column type $type]
     311
     312    foreach name [array names _table] {
    307313        set _state($name) "normal"
    308314    }
     315
    309316    itk_component add scroller {
    310317        Rappture::Scroller $itk_interior.sc \
     
    494501    set _current $elem
    495502    $_dispatcher event -idle !rebuild
     503}
     504
     505# ----------------------------------------------------------------------
     506# USAGE: FindElement <what>
     507#
     508# Checks to see if the given string <what> is recognized as an element
     509# name, symbol, or number.  Returns the corresponding element name
     510# or "" if the element is not recognized.
     511# ----------------------------------------------------------------------
     512itcl::body Rappture::PeriodicTable::FindElement { what } {
     513    foreach name [array names _table] {
     514        array unset info
     515        array set info $_table($name)
     516        if { $what eq $info(name) || $what eq $info(number) ||
     517             $what eq $info(symbol) } {
     518            return $info(name)
     519        }
     520    }
     521    return ""
     522}
     523
     524# ----------------------------------------------------------------------
     525# USAGE: ElementIsType <name> <type> <type>...
     526#
     527# Checks to see if the given element <name> is one of the specified
     528# <type> values.  Returns true if the element is one of the types
     529# (logical or), or false if it is not.
     530# ----------------------------------------------------------------------
     531itcl::body Rappture::PeriodicTable::ElementIsType { name args } {
     532    foreach type $args {
     533        if {[info exists _types($type)]} {
     534            if {[lsearch -exact $_types($type) $name] >= 0} {
     535                return 1
     536            }
     537        }
     538    }
     539    return 0
    496540}
    497541
     
    608652    $c configure -height $height -width $width -background white
    609653}
    610 
    611 # ----------------------------------------------------------------------
    612 # USAGE: FindElement
    613 #
    614 # Used to manipulate the selection in the table.
    615 #
    616 # ----------------------------------------------------------------------
    617 itcl::body Rappture::PeriodicTable::FindElement { what } {
    618     foreach name [array names _table] {
    619         array unset info
    620         array set info $_table($name)
    621         if { $what == $info(name) || $what == $info(number) ||
    622              $what == $info(symbol) } {
    623             return $info(name)
    624         }
    625     }
    626     return ""
    627 }
    628                                                                
  • branches/nanovis2/gui/scripts/radiodial.tcl

    r1929 r3175  
    565565        }
    566566    }
    567     error "bad value \"$str\": should be something matching the raw values \"[join $_values ,]\""
     567
     568    # didn't match -- build a return string of possible values
     569    set labels ""
     570    foreach vlist $_values {
     571        foreach v $vlist {
     572            lappend labels "\"$_val2label($v)\""
     573        }
     574    }
     575    error "bad value \"$str\": should be one of [join $labels ,]"
    568576}
    569577
  • branches/nanovis2/gui/scripts/resultset.tcl

    r2977 r3175  
    1 
    2 # ----------------------------------------------------------------------
    3 #  COMPONENT: ResultSet - controls for a collection of related results
    4 #
    5 #  This widget stores a collection of results that all represent
    6 #  the same quantity, but for various ranges of input values.
    7 #  It also manages the controls to select and visualize the data.
     1# ----------------------------------------------------------------------
     2#  COMPONENT: ResultSet - set of XML objects for simulated results
     3#
     4#  This data structure collects all of the simulated results
     5#  produced by a series of tool runs.  It is used by the Analyzer,
     6#  ResultSelector, and other widgets to keep track of all known runs
     7#  and visualize the result that is currently selected.  Each run
     8#  has an index number ("#1", "#2", "#3", etc.) that can be used to
     9#  label the run and refer to it later.
    810# ======================================================================
    911#  AUTHOR:  Michael McLennan, Purdue University
    10 #  Copyright (c) 2004-2005  Purdue Research Foundation
     12#  Copyright (c) 2004-2012  Purdue Research Foundation
    1113#
    1214#  See the file "license.terms" for information on usage and
    1315#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    1416# ======================================================================
    15 package require Itk
    16 
    17 option add *ResultSet.width 4i widgetDefault
    18 option add *ResultSet.height 4i widgetDefault
    19 option add *ResultSet.missingData skip widgetDefault
    20 option add *ResultSet.controlbarBackground gray widgetDefault
    21 option add *ResultSet.controlbarForeground white widgetDefault
    22 option add *ResultSet.activeControlBackground #ffffcc widgetDefault
    23 option add *ResultSet.activeControlForeground black widgetDefault
    24 option add *ResultSet.controlActiveForeground blue widgetDefault
    25 option add *ResultSet.toggleBackground gray widgetDefault
    26 option add *ResultSet.toggleForeground white widgetDefault
    27 option add *ResultSet.textFont \
    28     -*-helvetica-medium-r-normal-*-12-* widgetDefault
    29 option add *ResultSet.boldFont \
    30     -*-helvetica-bold-r-normal-*-12-* widgetDefault
     17package require Itcl
    3118
    3219itcl::class Rappture::ResultSet {
    33     inherit itk::Widget
    34 
    35     itk_option define -activecontrolbackground activeControlBackground Background ""
    36     itk_option define -activecontrolforeground activeControlForeground Foreground ""
    37     itk_option define -controlactiveforeground controlActiveForeground Foreground ""
    38     itk_option define -togglebackground toggleBackground Background ""
    39     itk_option define -toggleforeground toggleForeground Foreground ""
    40     itk_option define -textfont textFont Font ""
    41     itk_option define -boldfont boldFont Font ""
    42     itk_option define -foreground foreground Foreground ""
    43     itk_option define -clearcommand clearCommand ClearCommand ""
    44     itk_option define -settingscommand settingsCommand SettingsCommand ""
    45     itk_option define -promptcommand promptCommand PromptCommand ""
    46 
    4720    constructor {args} { # defined below }
    4821    destructor { # defined below }
     
    5023    public method add {xmlobj}
    5124    public method clear {{xmlobj ""}}
    52     public method activate {column}
     25    public method diff {option args}
     26    public method find {collist vallist}
     27    public method get {collist xmlobj}
    5328    public method contains {xmlobj}
    54     public method size {{what -results}}
    55 
    56     protected method _doClear {what}
    57     protected method _doSettings {{cmd ""}}
    58     protected method _control {option args}
    59     protected method _fixControls {args}
    60     protected method _fixLayout {args}
    61     protected method _fixNumResults {}
    62     protected method _fixSettings {args}
    63     protected method _fixValue {column why}
    64     protected method _drawValue {column widget wmax}
    65     protected method _toggleAll {{column "current"}}
    66     protected method _getValues {column {which ""}}
    67     protected method _getTooltip {role column}
    68     protected method _getParamDesc {which {index "current"}}
     29    public method size {}
     30
     31    public method notify {option args}
     32    protected method _notifyHandler {args}
     33
    6934    protected method _addOneResult {tuples xmlobj {simnum ""}}
    7035
     
    7237    private variable _results ""     ;# tuple of known results
    7338    private variable _resultnum 0    ;# counter for result #1, #2, etc.
    74     private variable _recent ""      ;# most recent result in _results
    75     private variable _active ""      ;# column with active control
    76     private variable _plotall 0      ;# non-zero => plot all active results
    77     private variable _layout         ;# info used in _fixLayout
    78     private variable _counter 0      ;# counter for unique control names
    79     private variable _settings 0     ;# non-zero => _fixSettings in progress
    80 
    81     private common _cntlInfo         ;# maps column name => control info
     39    private variable _notify         ;# info used for notify command
    8240}
    8341                                                                               
    84 itk::usual ResultSet {
    85     keep -background -foreground -cursor -font
    86 }
    87 
    8842# ----------------------------------------------------------------------
    8943# CONSTRUCTOR
    9044# ----------------------------------------------------------------------
    9145itcl::body Rappture::ResultSet::constructor {args} {
    92     option add hull.width hull.height
    93     pack propagate $itk_component(hull) no
    94 
    9546    # create a dispatcher for events
    9647    Rappture::dispatcher _dispatcher
    97     $_dispatcher register !fixcntls
    98     $_dispatcher dispatch $this !fixcntls \
    99         [itcl::code $this _fixControls]
    100     $_dispatcher register !layout
    101     $_dispatcher dispatch $this !layout \
    102         [itcl::code $this _fixLayout]
    103     $_dispatcher register !settings
    104     $_dispatcher dispatch $this !settings \
    105         [itcl::code $this _fixSettings]
    106 
    107     # initialize controls info
    108     set _cntlInfo($this-all) ""
    109 
    110     # initialize layout info
    111     set _layout(mode) "usual"
    112     set _layout(active) ""
     48    $_dispatcher register !change
     49    $_dispatcher dispatch $this !change \
     50        [itcl::code $this _notifyHandler]
    11351
    11452    # create a list of tuples for data
     
    11755    $_results column insert end -name simnum -label "simulation number"
    11856
    119 
    120     itk_component add cntls {
    121         frame $itk_interior.cntls
    122     } {
    123         usual
    124         rename -background -controlbarbackground controlbarBackground Background
    125         rename -highlightbackground -controlbarbackground controlbarBackground Background
    126     }
    127     pack $itk_component(cntls) -fill x -pady {0 2}
    128 
    129     itk_component add clearall {
    130         button $itk_component(cntls).clearall -text "Clear" -state disabled \
    131             -padx 1 -pady 1 \
    132             -relief flat -overrelief raised \
    133             -command [itcl::code $this _doClear all]
    134     } {
    135         usual
    136         rename -background -controlbarbackground controlbarBackground Background
    137         rename -foreground -controlbarforeground controlbarForeground Foreground
    138         rename -highlightbackground -controlbarbackground controlbarBackground Background
    139     }
    140     pack $itk_component(clearall) -side right -padx 2 -pady 1
    141     Rappture::Tooltip::for $itk_component(clearall) \
    142         "Clears all results collected so far."
    143 
    144     itk_component add clear {
    145         button $itk_component(cntls).clear -text "Clear One" -state disabled \
    146             -padx 1 -pady 1 \
    147             -relief flat -overrelief raised \
    148             -command [itcl::code $this _doClear current]
    149     } {
    150         usual
    151         rename -background -controlbarbackground controlbarBackground Background
    152         rename -foreground -controlbarforeground controlbarForeground Foreground
    153         rename -highlightbackground -controlbarbackground controlbarBackground Background
    154     }
    155     pack $itk_component(clear) -side right -padx 2 -pady 1
    156     Rappture::Tooltip::for $itk_component(clear) \
    157         "Clears the result that is currently selected."
    158 
    159     itk_component add status {
    160         label $itk_component(cntls).status -anchor w \
    161             -text "No results" -padx 0 -pady 0
    162     } {
    163         usual
    164         rename -background -controlbarbackground controlbarBackground Background
    165         rename -foreground -controlbarforeground controlbarForeground Foreground
    166         rename -highlightbackground -controlbarbackground controlbarBackground Background
    167     }
    168     pack $itk_component(status) -side left -padx 2 -pady {2 0}
    169 
    170     itk_component add dials {
    171         frame $itk_interior.dials
    172     }
    173     pack $itk_component(dials) -expand yes -fill both
    174     bind $itk_component(dials) <Configure> \
    175         [list $_dispatcher event -after 10 !layout why resize]
    176 
    177     # create the permanent controls in the "short list" area
    178     set dials $itk_component(dials)
    179     frame $dials.bg
    180     Rappture::Radiodial $dials.dial -valuewidth 0
    181     Rappture::Tooltip::for $dials.dial \
    182         "@[itcl::code $this _getTooltip dial active]"
    183 
    184     set fn [option get $itk_component(hull) textFont Font]
    185     label $dials.all -text "All" -padx 8 \
    186         -borderwidth 1 -relief raised -font $fn
    187     Rappture::Tooltip::for $dials.all \
    188         "@[itcl::code $this _getTooltip all active]"
    189     bind $dials.all <ButtonRelease> [itcl::code $this _toggleAll]
    190 
    191     frame $dials.labelmore
    192     label $dials.labelmore.arrow -bitmap [Rappture::icon empty] -borderwidth 0
    193     pack $dials.labelmore.arrow -side left -fill y
    194     label $dials.labelmore.name -text "more parameters..." -font $fn \
    195         -borderwidth 0 -padx 0 -pady 1
    196     pack $dials.labelmore.name -side left
    197     label $dials.labelmore.value
    198     pack $dials.labelmore.value -side left
    199 
    200     eval itk_initialize $args
     57    # clear notification info
     58    set _notify(ALL) ""
     59
     60    eval configure $args
    20161}
    20262
     
    20565# ----------------------------------------------------------------------
    20666itcl::body Rappture::ResultSet::destructor {} {
     67    clear
    20768    itcl::delete object $_results
    20869}
     
    21879# ----------------------------------------------------------------------
    21980itcl::body Rappture::ResultSet::add {xmlobj} {
    220     # make sure we fix up controls at some point
    221     $_dispatcher event -idle !fixcntls
    222 
    223     #
    224     # If this is the first result, then there are no diffs.
    225     # Add it right in.
    226     #
    22781    set xmlobj0 [$_results get -format xmlobj end]
    228     if {"" == $xmlobj0} {
    229         # first element -- always add
     82    if {$xmlobj0 eq ""} {
     83        #
     84        # If this is the first result, then there are no diffs.
     85        # Add it right in.
     86        #
    23087        set simnum "#[incr _resultnum]"
    23188        $_results insert end [list $xmlobj $simnum]
    232         _fixNumResults
    233         set _recent $xmlobj
    234         return $simnum
    235     }
    236 
    237     #
    238     # For all later results, find the diffs and add any new columns
    239     # into the results tuple.  The latest result is the most recent.
    240     #
    241     set simnum [_addOneResult $_results $xmlobj]
    242     set _recent $xmlobj
    243     _fixNumResults
     89    } else {
     90        #
     91        # For all later results, find the diffs and add any new columns
     92        # into the results tuple.  The latest result is the most recent.
     93        #
     94        set simnum [_addOneResult $_results $xmlobj]
     95    }
     96
     97    # make sure we fix up associated controls
     98    $_dispatcher event -now !change op add what $xmlobj
    24499
    245100    return $simnum
     
    253108# ----------------------------------------------------------------------
    254109itcl::body Rappture::ResultSet::clear {{xmlobj ""}} {
    255     set shortlist $itk_component(dials)
    256     set controlsChanged 0
    257 
    258     # clear any currently highlighted result
    259     _doSettings
    260 
    261110    if {$xmlobj ne ""} {
    262111        #
     
    269118        set irun [$_results find -format xmlobj $xmlobj]
    270119        if {[llength $irun] == 1} {
    271             # figure out where we are in the active control, and
    272             # what value we should display after this one is deleted
    273             set vlist ""
    274             foreach {label val} [_getValues $_active all] {
    275                 lappend vlist $label
    276             }
    277             set ipos [lsearch $vlist $_cntlInfo($this-$_active-value)]
    278 
    279             set vcurr ""
    280             set vnext ""
    281             if {$ipos >= 0} {
    282                 # try to stay at this value, if we can
    283                 set vcurr [lindex $vlist $ipos]
    284 
    285                 # fall back to this value, if we have to
    286                 if {$ipos > 0} { incr ipos -1 } else { incr ipos }
    287                 set vnext [lindex $vlist $ipos]
    288             }
    289 
    290             # delete the value from the tuples of all results
     120            # grab a description of what we're about to delete
     121            set dlist [list simnum [$_results get -format simnum $irun]]
     122            foreach col [lrange [$_results column names] 2 end] {
     123                set raw [lindex [Rappture::LibraryObj::value $xmlobj $col] 0]
     124                lappend dlist $col $raw  ;# use "raw" (user-readable) label
     125            }
     126
     127            # delete this from the tuples of all results
     128            itcl::delete object $xmlobj
    291129            $_results delete $irun
    292130
     
    309147            set _results $new
    310148
    311             # delete any adjuster controls that disappeared
    312             foreach col $_cntlInfo($this-all) {
    313                 if {[$_results column names $col] eq ""} {
    314                     set id $_cntlInfo($this-$col-id)
    315                     destroy $shortlist.label$id
    316                     array unset _cntlInfo $this-$col*
    317 
    318                     set i [lsearch -exact $_cntlInfo($this-all) $col]
    319                     if {$i >= 0} {
    320                         set _cntlInfo($this-all) [lreplace $_cntlInfo($this-all) $i $i]
     149            # make sure we fix up associated controls at some point
     150            $_dispatcher event -now !change op clear what $dlist
     151        }
     152    } else {
     153        #
     154        # Delete all results.
     155        #
     156        for {set irun 0} {$irun < [$_results size]} {incr irun} {
     157            set xo [$_results get -format xmlobj $irun]
     158            itcl::delete object $xo
     159        }
     160        $_results delete 0 end
     161
     162        # make sure we fix up associated controls at some point
     163        $_dispatcher event -now !change op clear what all
     164    }
     165
     166    if {[$_results size] == 0} {
     167        # no results left?  then reset to a clean state
     168        eval $_results column delete [lrange [$_results column names] 2 end]
     169        set _resultnum 0
     170    }
     171}
     172
     173# ----------------------------------------------------------------------
     174# USAGE: diff names
     175# USAGE: diff values <column> ?<which>?
     176#
     177# Returns information about the diffs in the current set of known
     178# results.  The "diff names" returns a list of column names for
     179# parameters that have diffs.  (These are the columns in the tuples.)
     180#
     181# The "diff values" returns the various values associated with a
     182# particular <column> name.  If the optional <which> is specified,
     183# then it is treated as an index into the list of values--0 for the
     184# first value, 1 for the second, etc.  Each value is returned as
     185# a list with two words.  The first is the the label associated with
     186# the value.  The second is the normalized (numeric) value, which can
     187# be sorted to get a particular ordering.
     188# ----------------------------------------------------------------------
     189itcl::body Rappture::ResultSet::diff {option args} {
     190    switch -- $option {
     191        names {
     192            return [$_results column names]
     193        }
     194        values {
     195            if {[llength $args] < 1} {
     196                error "wrong # args: should be \"diff values col ?which?\""
     197            }
     198            set col [lindex $args 0]
     199
     200            set which "all"
     201            if {[llength $args] > 1} {
     202                set which [lindex $args 1]
     203            }
     204
     205            set rlist ""
     206            # build an array of normalized values and their labels
     207            if {$col == "simnum"} {
     208                set nruns [$_results size]
     209                for {set n 0} {$n < $nruns} {incr n} {
     210                    set simnum [$_results get -format simnum $n]
     211                    lappend rlist $simnum $n
     212                }
     213            } else {
     214                set havenums 1
     215                foreach rec [$_results get -format [list xmlobj $col]] {
     216                    set xo [lindex $rec 0]
     217                    set v [lindex $rec 1]
     218                    foreach {raw norm} \
     219                        [Rappture::LibraryObj::value $xo $col] break
     220
     221                    if {![info exists unique($v)]} {
     222                        # keep only unique label strings
     223                        set unique($v) $norm
    321224                    }
    322 
    323                     if {$col == $_active} {
    324                         # control is going away -- switch to sim # control
    325                         set simnum0 [$_results get -format simnum 0]
    326                         set _cntlInfo($this-simnum-value) $simnum0
    327                         activate simnum
     225                    if {$havenums && ![string is double $norm]} {
     226                        set havenums 0
    328227                    }
    329                     set controlsChanged 1
    330                 }
    331             }
    332 
    333             # can we find a tuple with the desired value for the active col?
    334             if {$_active ne "" && $vcurr ne ""} {
    335                 set found ""
    336                 if {[$_results find -format $_active $vcurr] ne ""} {
    337                     set found $vcurr
    338                 } elseif {$vnext ne "" && [$_results find -format $_active $vnext] ne ""} {
    339                     set found $vnext
    340                 }
    341 
    342                 if {$found ne ""} {
    343                     # set the control to a value we were able to find
    344                     # this will trigger !settings and other adjustments
    345                     set _cntlInfo($this-$_active-value) $found
     228                }
     229
     230                if {!$havenums} {
     231                    # don't have normalized nums? then sort and create nums
     232                    set rlist ""
     233                    set n 0
     234                    foreach val [lsort -dictionary [array names unique]] {
     235                        lappend rlist $val [incr n]
     236                    }
    346237                } else {
    347                     # if all else fails, show solution #1
    348                     set simnum0 [$_results get -format simnum 0]
    349                     set _cntlInfo($this-simnum-value) $simnum0
    350                     activate simnum
    351                 }
    352             }
    353         }
    354     } else {
    355         #
    356         # Delete all results.
    357         #
    358         $_results delete 0 end
    359 
    360         # delete all adjuster controls
    361         foreach col $_cntlInfo($this-all) {
    362             set id $_cntlInfo($this-$col-id)
    363             destroy $shortlist.label$id
    364         }
    365         set controlsChanged 1
    366     }
    367 
    368     if {[$_results size] == 0} {
    369         #
    370         # No results left?  Then clean everything up.
    371         #
    372 
    373         array unset _cntlInfo $this-*
    374         # clean up control info
    375         foreach key [array names _cntlInfo $this-*] {
    376             catch {unset _cntlInfo($key)}
    377         }
    378         set _cntlInfo($this-all) ""
    379         set _counter 0
    380         set _resultnum 0
    381 
    382         # clear out all results
    383         eval $_results column delete [lrange [$_results column names] 2 end]
    384         set _recent ""
    385         set _active ""
    386 
    387         set _plotall 0
    388         $itk_component(dials).all configure -relief raised \
    389             -background $itk_option(-background) \
    390             -foreground $itk_option(-foreground)
    391     }
    392 
    393     # update status and Clear button
    394     _fixNumResults
    395     $_dispatcher event -idle !fixcntls
    396 
    397     # let clients know that the number of controls has changed
    398     if {$controlsChanged} {
    399         event generate $itk_component(hull) <<Control>>
    400     }
    401 
    402     # if there's a callback for clearing, invoke it now...
    403     if {[string length $itk_option(-clearcommand)] > 0} {
    404         uplevel #0 $itk_option(-clearcommand) $xmlobj
    405     }
    406 }
    407 
    408 # ----------------------------------------------------------------------
    409 # USAGE: activate <column>
    410 #
    411 # Clients use this to activate a particular column in the set of
    412 # controls.  When a column is active, its label is bold and its
    413 # value has a radiodial in the "short list" area.
    414 # ----------------------------------------------------------------------
    415 itcl::body Rappture::ResultSet::activate {column} {
    416     set allowed [$_results column names]
    417     if {[lsearch $allowed $column] < 0} {
    418         error "bad value \"$column\": should be one of [join $allowed {, }]"
    419     }
    420 
    421     # column is now active
    422     set _active $column
    423 
    424     # keep track of usage, so we know which controls are popular
    425     incr _cntlInfo($this-$column-usage)
    426 
    427     # fix controls at next idle point
    428     $_dispatcher event -idle !layout why data
    429     $_dispatcher event -idle !settings column $_active
     238                    set rlist [array get unique]
     239                }
     240            }
     241
     242            if {$which eq "all"} {
     243                return $rlist
     244            }
     245
     246            # treat the "which" parameter as an XML object
     247            set irun [lindex [$_results find -format xmlobj $which] 0]
     248            if {$irun ne ""} {
     249                set val [$_results get -format $col $irun]
     250                array set val2norm $rlist
     251                if {[info exists val2norm($val)]} {
     252                    return [list $val $val2norm($val)]
     253                }
     254            }
     255        }
     256        default {
     257            error "bad option \"$option\": should be names or values"
     258        }
     259    }
     260}
     261
     262# ----------------------------------------------------------------------
     263# USAGE: find <columnList> <valueList>
     264#
     265# Searches through the results for a set of tuple values that match
     266# the <valueList> for the given <columnList>.  Returns a list of
     267# matching xml objects or "" if there is no match.  If the <valueList>
     268# is *, then it returns a list of all xml objects.
     269# ----------------------------------------------------------------------
     270itcl::body Rappture::ResultSet::find {collist vallist} {
     271    if {$vallist eq "*"} {
     272        return [$_results get -format xmlobj]
     273    }
     274
     275    set rlist ""
     276    foreach irun [$_results find -format $collist -- $vallist] {
     277        lappend rlist [$_results get -format xmlobj $irun]
     278    }
     279    return $rlist
     280}
     281
     282# ----------------------------------------------------------------------
     283# USAGE: get <columnList> <xmlobj>
     284#
     285# Returns values for the specified <columnList> for the given <xmlobj>.
     286# This is a way of querying associated data for the given object.
     287# ----------------------------------------------------------------------
     288itcl::body Rappture::ResultSet::get {collist xmlobj} {
     289    set irun [lindex [$_results find -format xmlobj $xmlobj] 0]
     290    if {$irun ne ""} {
     291        return [lindex [$_results get -format $collist $irun] 0]
     292    }
     293    return ""
    430294}
    431295
     
    499363
    500364# ----------------------------------------------------------------------
    501 # USAGE: size ?-results|-controls|-controlarea?
    502 #
    503 # Returns various measures for the size of this area:
    504 #   -results ....... number of results loaded
    505 #   -controls ...... number of distinct control parameters
    506 #   -controlarea ... minimum size of usable control area, in pixels
    507 # ----------------------------------------------------------------------
    508 itcl::body Rappture::ResultSet::size {{what -results}} {
    509     switch -- $what {
    510         -results {
    511             return [$_results size]
    512         }
    513         -controls {
    514             return [llength $_cntlInfo($this-all)]
    515         }
    516         -controlarea {
    517             set ht [winfo reqheight $itk_component(cntls)]
    518             incr ht 2  ;# padding below controls
    519 
    520             set normalLine [font metrics $itk_option(-textfont) -linespace]
    521             incr normalLine 2  ;# padding
    522             set boldLine [font metrics $itk_option(-boldfont) -linespace]
    523             incr boldLine 2  ;# padding
    524 
    525             set numcntls [llength $_cntlInfo($this-all)]
    526             switch -- $numcntls {
    527                 0 - 1 {
    528                     # 0 = no controls (no data at all)
    529                     # 1 = run control, but only 1 run so far
    530                     # add nothing
     365# USAGE: size
     366#
     367# Returns the number of results currently stored in the set.
     368# ----------------------------------------------------------------------
     369itcl::body Rappture::ResultSet::size {} {
     370    return [$_results size]
     371}
     372
     373# ----------------------------------------------------------------------
     374# USAGE: notify add <client> ?!event !event ...? <command>
     375# USAGE: notify get ?<client>? ?!event?
     376# USAGE: notify remove <client> ?!event !event ...?
     377#
     378# Clients use this to add/remove requests for notifications about
     379# various events that signal changes to the data in each ResultSet.
     380#
     381# The "notify add" operation takes a <client> name (any unique string
     382# identifying the client), an optional list of events, and the <command>
     383# that should be called for the callback.
     384#
     385# The "notify get" command returns information about clients and their
     386# registered callbacks.  With no args, it returns a list of <client>
     387# names.  If the <client> is specified, it returns a list of !events.
     388# If the <client> and !event is specified, it returns the <command>.
     389#
     390# The "notify remove" command removes any callback associated with
     391# a given <client>.  If no particular !events are specified, then it
     392# removes callbacks for all events.
     393# ----------------------------------------------------------------------
     394itcl::body Rappture::ResultSet::notify {option args} {
     395    set allEvents {!change}
     396    switch -- $option {
     397        add {
     398            if {[llength $args] < 2} {
     399                error "wrong # args: should be \"notify add caller ?!event !event ...? command"
     400            }
     401            set caller [lindex $args 0]
     402            set command [lindex $args end]
     403            if {[llength $args] > 2} {
     404                set events [lrange $args 1 end-1]
     405            } else {
     406                set events $allEvents
     407            }
     408
     409            foreach name $events {
     410                if {[lsearch -exact $allEvents $name] < 0} {
     411                    error "bad event \"$name\": should be [join $allEvents ,]"
     412                }
     413                if {[lsearch $_notify(ALL) $caller] < 0} {
     414                    lappend _notify(ALL) $caller
     415                }
     416                set _notify($caller-$name) $command
     417            }
     418        }
     419        get {
     420            switch -- [llength $args] {
     421                0 {
     422                    return $_notify(ALL)
     423                }
     424                1 {
     425                    set caller [lindex $args 0]
     426                    set rlist ""
     427                    foreach key [array names _notify $caller-*] {
     428                        lappend rlist [lindex [split $key -] end]
     429                    }
     430                    return $rlist
     431                }
     432                2 {
     433                    set caller [lindex $args 0]
     434                    set name [lindex $args 1]
     435                    if {[info exists _notify($caller-$name)]} {
     436                        return $_notify($caller-$name)
     437                    }
     438                    return ""
    531439                }
    532440                default {
    533                     # non-active controls
    534                     incr ht [expr {($numcntls-1)*$normalLine}]
    535                     # active control
    536                     incr ht $boldLine
    537                     # dial for active control
    538                     incr ht [winfo reqheight $itk_component(dials).dial]
    539                     # padding around active control
    540                     incr ht 4
    541                 }
    542             }
    543             return $ht
     441                    error "wrong # args: should be \"notify get ?caller? ?!event?\""
     442                }
     443            }
     444        }
     445        remove {
     446            if {[llength $args] < 1} {
     447                error "wrong # args: should be \"notify remove caller ?!event !event ...?"
     448            }
     449            set caller [lindex $args 0]
     450            if {[llength $args] > 1} {
     451                set events [lrange $args 1 end]
     452            } else {
     453                set events $allEvents
     454            }
     455
     456            foreach name $events {
     457                catch {unset _notify($caller-$name)}
     458            }
     459            if {[llength [array names _notify $caller-*]] == 0} {
     460                set i [lsearch $_notify(ALL) $caller]
     461                if {$i >= 0} {
     462                    set _notify(ALL) [lreplace $_notify(ALL) $i $i]
     463                }
     464            }
    544465        }
    545466        default {
    546             error "bad option \"$what\": should be -results, -controls, or -controlarea"
    547         }
    548     }
    549 }
    550 
    551 # ----------------------------------------------------------------------
    552 # USAGE: _doClear all|current
    553 #
    554 # Invoked automatically when the user presses the "Clear One" or
    555 # "Clear All" buttons.  Invokes the -clearcommand to clear all data
    556 # from this resultset and all other resultsets in an Analyzer.
    557 # ----------------------------------------------------------------------
    558 itcl::body Rappture::ResultSet::_doClear {what} {
    559     switch -- $what {
    560         current {
    561             set xmlobj ""
    562             # value of xmlobj control is something like "#1" or "#2"
    563             set irun [$_results find -format simnum $_cntlInfo($this-simnum-value)]
    564             if {$irun ne ""} {
    565                 # convert index to a real xmlobj object
    566                 set xmlobj [$_results get -format xmlobj $irun]
    567             }
    568             clear $xmlobj
    569         }
    570         all {
    571             clear
    572         }
    573         default { error "bad option \"$what\": should be current or all" }
    574     }
    575 }
    576 
    577 # ----------------------------------------------------------------------
    578 # USAGE: _doSettings ?<command>?
    579 #
    580 # Used internally whenever the result selection changes to invoke
    581 # the -settingscommand.  This will notify some external widget, which
    582 # with perform the plotting action specified in the <command>.
    583 # ----------------------------------------------------------------------
    584 itcl::body Rappture::ResultSet::_doSettings {{cmd ""}} {
    585     if {[string length $itk_option(-settingscommand)] > 0} {
    586         uplevel #0 $itk_option(-settingscommand) $cmd
    587     }
    588 }
    589 
    590 # ----------------------------------------------------------------------
    591 # USAGE: _control bind <widget> <column>
    592 # USAGE: _control hilite <state> <column> <panel>
    593 # USAGE: _control load <widget> <column>
    594 #
    595 # Used internally to manage the interactivity of controls.  The "bind"
    596 # operation sets up bindings on the label/value for each control, so
    597 # you can mouse over and click on a control to activate it.  The
    598 # "hilite" operation controls highlighting of the control.  The "load"
    599 # operation loads data into the specified radiodial <widget>.
    600 # ----------------------------------------------------------------------
    601 itcl::body Rappture::ResultSet::_control {option args} {
    602     switch -- $option {
    603         bind {
    604             if {[llength $args] != 2} {
    605                 error "wrong # args: should be _control bind widget column"
    606             }
    607             set widget [lindex $args 0]
    608             set col [lindex $args 1]
    609 
    610             set panel [winfo parent $widget]
    611             if {[string match label* [winfo name $panel]]} {
    612                 set panel [winfo parent $panel]
    613             }
    614 
    615             bind $widget <Enter> \
    616                 [itcl::code $this _control hilite on $col $panel]
    617             bind $widget <Leave> \
    618                 [itcl::code $this _control hilite off $col $panel]
    619             bind $widget <ButtonRelease> [itcl::code $this activate $col]
    620         }
    621         hilite {
    622             if {[llength $args] != 3} {
    623                 error "wrong # args: should be _control hilite state column panel"
    624             }
    625             if {$_layout(mode) != "usual"} {
    626                 # abbreviated controls? then skip highlighting
    627                 return
    628             }
    629             set state [lindex $args 0]
    630             set col [lindex $args 1]
    631             set panel [lindex $args 2]
    632 
    633             if {[string index $col 0] == "@"} {
    634                 # handle artificial names like "@more"
    635                 set id [string range $col 1 end]
    636             } else {
    637                 # get id for ordinary columns
    638                 set id $_cntlInfo($this-$col-id)
    639             }
    640 
    641             # highlight any non-active entries
    642             if {$col != $_active} {
    643                 if {$state} {
    644                     set fg $itk_option(-controlactiveforeground)
    645                     $panel.label$id.name configure -fg $fg
    646                     $panel.label$id.value configure -fg $fg
    647                     $panel.label$id.arrow configure -fg $fg \
    648                         -bitmap [Rappture::icon rarrow2]
    649                 } else {
    650                     set fg $itk_option(-foreground)
    651                     $panel.label$id.name configure -fg $fg
    652                     $panel.label$id.value configure -fg $fg
    653                     $panel.label$id.arrow configure -fg $fg \
    654                         -bitmap [Rappture::icon empty]
    655                 }
    656             }
    657         }
    658         load {
    659             if {[llength $args] != 2} {
    660                 error "wrong # args: should be _control load widget column"
    661             }
    662             set dial [lindex $args 0]
    663             set col [lindex $args 1]
    664 
    665             $dial clear
    666             foreach {label val} [_getValues $col all] {
    667                 $dial add $label $val
    668             }
    669         }
    670         default {
    671             error "bad option \"$option\": should be bind, hilite, or load"
    672         }
    673     }
    674 }
    675 
    676 # ----------------------------------------------------------------------
    677 # USAGE: _fixControls ?<eventArgs...>?
    678 #
    679 # Called automatically at the idle point after one or more results
    680 # have been added to this result set.  Scans through all existing
    681 # data and updates controls used to select the data.
    682 # ----------------------------------------------------------------------
    683 itcl::body Rappture::ResultSet::_fixControls {args} {
    684     if {[$_results size] == 0} {
    685         return
    686     }
    687 
    688     set shortlist $itk_component(dials)
    689     grid columnconfigure $shortlist 1 -weight 1
    690 
    691     #
    692     # Scan through all columns in the data and create any
    693     # controls that just appeared.
    694     #
    695     $shortlist.dial configure -variable ""
    696 
    697     set nadded 0
    698     foreach col [$_results column names] {
    699         set xmlobj [$_results get -format xmlobj 0]
    700 
    701         #
    702         # If this column doesn't have a control yet, then
    703         # create one.
    704         #
    705         if {![info exists _cntlInfo($this-$col-id)]} {
    706             set tip ""
    707             if {$col eq "xmlobj"} {
    708                 continue
    709             } elseif {$col eq "simnum"} {
    710                 set quantity "Simulation"
    711                 set tip "List of all simulations that you have performed so far."
    712             } else {
    713                 # search for the first XML object with this element defined
    714                 foreach xmlobj [$_results get -format xmlobj] {
    715                     set quantity [$xmlobj get $col.about.label]
    716                     set tip [$xmlobj get $col.about.description]
    717                     if {"" != $quantity} {
    718                         break
    719                     }
    720                 }
    721                 if {"" == $quantity && "" != $xmlobj} {
    722                     set quantity [$xmlobj element -as id $col]
    723                 }
    724             }
    725 
    726             # Create the controls for the "short list" area.
    727             set fn $itk_option(-textfont)
    728             set w $shortlist.label$_counter
    729             set row [lindex [grid size $shortlist] 1]
    730             frame $w
    731             grid $w -row $row -column 1 -sticky ew
    732             label $w.arrow -bitmap [Rappture::icon empty] -borderwidth 0
    733             pack $w.arrow -side left -fill y
    734             _control bind $w.arrow $col
    735 
    736             label $w.name -text $quantity -anchor w \
    737                 -borderwidth 0 -padx 0 -pady 1 -font $fn
    738             pack $w.name -side left
    739             bind $w.name <Configure> [itcl::code $this _fixValue $col resize]
    740             _control bind $w.name $col
    741 
    742             label $w.value -anchor w \
    743                 -borderwidth 0 -padx 0 -pady 1 -font $fn
    744             pack $w.value -side left
    745             bind $w.value <Configure> [itcl::code $this _fixValue $col resize]
    746             _control bind $w.value $col
    747 
    748             Rappture::Tooltip::for $w \
    749                 "@[itcl::code $this _getTooltip label $col]"
    750 
    751             # create a record for this control
    752             lappend _cntlInfo($this-all) $col
    753             set _cntlInfo($this-$col-id) $_counter
    754             set _cntlInfo($this-$col-label) $quantity
    755             set _cntlInfo($this-$col-tip) $tip
    756             set _cntlInfo($this-$col-value) ""
    757             set _cntlInfo($this-$col-usage) 0
    758             set _cntlInfo($this-$col) ""
    759 
    760             trace add variable _cntlInfo($this-$col-value) write \
    761                 "[itcl::code $this _fixValue $col value]; list"
    762 
    763             incr _counter
    764 
    765             # fix the shortlist layout to show as many controls as we can
    766             $_dispatcher event -now !layout why data
    767 
    768             # let clients know that a new control appeared
    769             # so they can fix the overall size accordingly
    770             event generate $itk_component(hull) <<Control>>
    771 
    772             incr nadded
    773         }
    774 
    775         #
    776         # Determine the unique values for this column and load
    777         # them into the control.
    778         #
    779         set id $_cntlInfo($this-$col-id)
    780 
    781         if {$col == $_layout(active)} {
    782             _control load $shortlist.dial $col
    783             $shortlist.dial configure -variable \
    784                 "::Rappture::ResultSet::_cntlInfo($this-$col-value)"
    785         }
    786     }
    787 
    788     #
    789     # Activate the most recent control.  If a bunch of controls
    790     # were just added, then activate the "Simulation" control,
    791     # since that's the easiest way to page through results.
    792     #
    793     if {$nadded > 0} {
    794         if {[$_results column names] == 3 || $nadded == 1} {
    795             activate [lindex $_cntlInfo($this-all) end]
    796         } else {
    797             activate simnum
    798         }
    799     }
    800 
    801     #
    802     # Set all controls to the settings of the most recent addition.
    803     # Setting the value slot will trigger the !settings event, which
    804     # will then fix all other controls to match the one that changed.
    805     #
    806     set irun [lindex [$_results find -format xmlobj $_recent] 0]
    807     if {$irun ne ""} {
    808         set simnum [$_results get -format simnum $irun]
    809         set _cntlInfo($this-simnum-value) $simnum
    810     }
    811 }
    812 
    813 # ----------------------------------------------------------------------
    814 # USAGE: _fixLayout ?<eventArgs...>?
    815 #
    816 # Called automatically at the idle point after the controls have
    817 # changed, or the size of the window has changed.  Fixes the layout
    818 # so that the active control is displayed, and other recent controls
    819 # are shown above and/or below.  At the very least, we must show the
    820 # "more options..." control.
    821 # ----------------------------------------------------------------------
    822 itcl::body Rappture::ResultSet::_fixLayout {args} {
    823     array set eventdata $args
    824 
    825     set shortlist $itk_component(dials)
    826 
    827     # clear out the short list area
    828     foreach w [grid slaves $shortlist] {
    829         grid forget $w
    830     }
    831 
    832     # reset all labels back to an ordinary font/background
    833     set fn $itk_option(-textfont)
    834     set bg $itk_option(-background)
    835     set fg $itk_option(-foreground)
    836     foreach col $_cntlInfo($this-all) {
    837         set id $_cntlInfo($this-$col-id)
    838         $shortlist.label$id configure -background $bg
    839         $shortlist.label$id.arrow configure -background $bg \
    840             -bitmap [Rappture::icon empty]
    841         $shortlist.label$id.name configure -font $fn -background $bg
    842         $shortlist.label$id.value configure -background $bg
    843     }
    844 
    845     # only 1 result? then we don't need any controls
    846     if {[$_results size] < 2} {
    847         return
    848     }
    849 
    850     # compute the number of controls that will fit in the shortlist area
    851     set dials $itk_component(dials)
    852     set h [winfo height $dials]
    853     set normalLine [font metrics $itk_option(-textfont) -linespace]
    854     set boldLine [font metrics $itk_option(-boldfont) -linespace]
    855     set active [expr {$boldLine+[winfo reqheight $dials.dial]+4}]
    856 
    857     if {$h < $active+$normalLine} {
    858         # active control kinda big? then show parameter values only
    859         set _layout(mode) abbreviated
    860         set ncntls [expr {int(floor(double($h)/$normalLine))}]
    861     } else {
    862         set _layout(mode) usual
    863         set ncntls [expr {int(floor(double($h-$active)/$normalLine))+1}]
    864     }
    865 
    866     # find the controls with the most usage
    867     set order ""
    868     foreach col $_cntlInfo($this-all) {
    869         lappend order [list $col $_cntlInfo($this-$col-usage)]
    870     }
    871     set order [lsort -integer -decreasing -index 1 $order]
    872 
    873     set mostUsed ""
    874     if {[llength $order] <= $ncntls} {
    875         # plenty of space? then show all controls
    876         foreach item $order {
    877             lappend mostUsed [lindex $item 0]
    878         }
    879     } else {
    880         # otherwise, limit to the most-used controls
    881         foreach item [lrange $order 0 [expr {$ncntls-1}]] {
    882             lappend mostUsed [lindex $item 0]
    883         }
    884 
    885         # make sure the active control is included
    886         if {"" != $_active && [lsearch -exact $mostUsed $_active] < 0} {
    887             set mostUsed [lreplace [linsert $mostUsed 0 $_active] end end]
    888         }
    889 
    890         # if there are more controls, add the "more parameters..." entry
    891         if {$ncntls > 2} {
    892             set mostUsed [lreplace $mostUsed end end @more]
    893             set rest [expr {[llength $order]-($ncntls-1)}]
    894             if {$rest == 1} {
    895                 $dials.labelmore.name configure -text "1 more parameter..."
    896             } else {
    897                 $dials.labelmore.name configure -text "$rest more parameters..."
    898             }
    899         }
    900     }
    901 
    902     # draw the active control
    903     set row 0
    904     foreach col [concat $_cntlInfo($this-all) @more] {
    905         # this control not on the short list? then ignore it
    906         if {[lsearch $mostUsed $col] < 0} {
    907             continue
    908         }
    909 
    910         if {[string index $col 0] == "@"} {
    911             set id [string range $col 1 end]
    912         } else {
    913             set id $_cntlInfo($this-$col-id)
    914         }
    915         grid $shortlist.label$id -row $row -column 1 -sticky ew -padx 4
    916 
    917         if {$col == $_active} {
    918             if {$_layout(mode) == "usual"} {
    919                 # put the background behind the active control in the shortlist
    920                 grid $shortlist.bg -row $row -rowspan 2 \
    921                     -column 0 -columnspan 2 -sticky nsew
    922                 lower $shortlist.bg
    923 
    924                 # place the All and dial in the shortlist area
    925                 grid $shortlist.all -row $row -rowspan 2 -column 0 \
    926                     -sticky nsew -padx 2 -pady 2
    927                 grid $shortlist.dial -row [expr {$row+1}] -column 1 \
    928                     -sticky ew -padx 4
    929                 incr row
    930 
    931                 if {$_layout(active) != $_active} {
    932                     $shortlist.dial configure -variable ""
    933                     _control load $shortlist.dial $col
    934                     $shortlist.dial configure -variable \
    935                         "::Rappture::ResultSet::_cntlInfo($this-$col-value)"
    936                     set _layout(active) $_active
    937                 }
    938             }
    939         }
    940         incr row
    941     }
    942 
    943     # highlight the active control
    944     if {[info exists _cntlInfo($this-$_active-id)]} {
    945         set id $_cntlInfo($this-$_active-id)
    946         set bf $itk_option(-boldfont)
    947         set fg $itk_option(-activecontrolforeground)
    948         set bg $itk_option(-activecontrolbackground)
    949 
    950         if {$_layout(mode) == "usual"} {
    951             $shortlist.label$id configure -background $bg
    952             $shortlist.label$id.arrow configure -foreground $fg \
    953                 -background $bg -bitmap [Rappture::icon rarrow]
    954             $shortlist.label$id.name configure -foreground $fg \
    955                 -background $bg -font $bf
    956             $shortlist.label$id.value configure -foreground $fg \
    957                 -background $bg
    958             $shortlist.dial configure -background $bg
    959             $shortlist.bg configure -background $bg
    960 
    961             if {[$shortlist.all cget -relief] == "raised"} {
    962                 $shortlist.all configure -foreground $fg -background $bg
    963             }
    964         }
    965     }
    966 }
    967 
    968 # ----------------------------------------------------------------------
    969 # USAGE: _fixNumResults
    970 #
    971 # Used internally to update the number of results displayed near the
    972 # top of this widget.  If there is only 1 result, then there is also
    973 # a single "Clear" button.  If there are no results, the clear button
    974 # is diabled.
    975 # ----------------------------------------------------------------------
    976 itcl::body Rappture::ResultSet::_fixNumResults {} {
    977     switch [$_results size] {
    978         0 {
    979             $itk_component(status) configure -text "No results"
    980             $itk_component(clearall) configure -state disabled -text "Clear"
    981             pack forget $itk_component(clear)
    982         }
    983         1 {
    984             $itk_component(status) configure -text "1 result"
    985             $itk_component(clearall) configure -state normal -text "Clear"
    986             pack forget $itk_component(clear)
    987         }
    988         default {
    989             $itk_component(status) configure -text "[$_results size] results"
    990             $itk_component(clearall) configure -state normal -text "Clear All"
    991             $itk_component(clear) configure -state normal
    992             pack $itk_component(clear) -side right \
    993                 -after $itk_component(clearall) -padx {0 6}
    994         }
    995     }
    996 }
    997 
    998 # ----------------------------------------------------------------------
    999 # USAGE: _fixSettings ?<eventArgs...>?
    1000 #
    1001 # Called automatically at the idle point after a control has changed
    1002 # to load new data into the plotting area at the top of this result
    1003 # set.  Extracts the current tuple of control values from the control
    1004 # area, then finds the corresponding data values.  Loads the data
    1005 # by invoking a -settingscommand callback with parameters that
    1006 # describe what data should be plotted.
    1007 # ----------------------------------------------------------------------
    1008 itcl::body Rappture::ResultSet::_fixSettings {args} {
    1009     array set eventdata $args
    1010     if {[info exists eventdata(column)]} {
    1011         set changed $eventdata(column)
    1012     } else {
    1013         set changed ""
    1014     }
    1015 
    1016     if {[info exists _cntlInfo($this-$_active-label)]} {
    1017         lappend params $_cntlInfo($this-$_active-label)
    1018     } else {
    1019         lappend params "???"
    1020     }
    1021     if { $_active == "" } {
    1022         return;                         # Nothing active. Don't do anything.
    1023     }
    1024     eval lappend params [_getValues $_active all]
    1025 
    1026     switch -- [$_results size] {
    1027         0 {
    1028             # no data? then do nothing
    1029             return
    1030         }
    1031         1 {
    1032             # only one data set? then plot it
    1033             set simnum [$_results get -format simnum 0]
    1034             _doSettings [list \
    1035                 $simnum [list -width 2 \
    1036                         -param [_getValues $_active current] \
    1037                         -description [_getParamDesc all] \
    1038                   ] \
    1039                 params $params \
    1040             ]
    1041             return
    1042         }
    1043     }
    1044 
    1045     #
    1046     # Find the selected run.  If the run setting changed, then
    1047     # look at its current value.  Otherwise, search the results
    1048     # for a tuple that matches the current settings.
    1049     #
    1050     if {$changed == "xmlobj" || $changed == "simnum"} {
    1051         set irun [$_results find -format simnum $_cntlInfo($this-simnum-value)]
    1052     } else {
    1053         set format ""
    1054         set tuple ""
    1055         foreach col [lrange [$_results column names] 2 end] {
    1056             lappend format $col
    1057             lappend tuple $_cntlInfo($this-$col-value)
    1058         }
    1059         set irun [lindex [$_results find -format $format -- $tuple] 0]
    1060 
    1061         if {"" == $irun && "" != $changed} {
    1062             #
    1063             # No data for these settings.  Try leaving the next
    1064             # column open, then the next, and so forth, until
    1065             # we find some data.
    1066             #
    1067             # allcols:  foo bar baz qux
    1068             #               ^^^changed
    1069             #
    1070             # search:   baz qux foo
    1071             #
    1072             set val $_cntlInfo($this-$changed-value)
    1073             set allcols [lrange [$_results column names] 2 end]
    1074             set i [lsearch -exact $allcols $changed]
    1075             set search [concat \
    1076                 [lrange $allcols [expr {$i+1}] end] \
    1077                 [lrange $allcols 0 [expr {$i-1}]] \
    1078             ]
    1079             set nsearch [llength $search]
    1080 
    1081             for {set i 0} {$i < $nsearch} {incr i} {
    1082                 set format $changed
    1083                 set tuple [list $val]
    1084                 for {set j [expr {$i+1}]} {$j < $nsearch} {incr j} {
    1085                     set col [lindex $search $j]
    1086                     lappend format $col
    1087                     lappend tuple $_cntlInfo($this-$col-value)
    1088                 }
    1089                 set irun [lindex [$_results find -format $format -- $tuple] 0]
    1090                 if {"" != $irun} {
    1091                     break
    1092                 }
    1093             }
    1094         }
    1095     }
    1096 
    1097     #
    1098     # If we found a particular run, then load its values into all
    1099     # controls.
    1100     #
    1101     if {"" != $irun} {
    1102         # stop reacting to value changes
    1103         set _settings 1
    1104 
    1105         set format [lrange [$_results column names] 2 end]
    1106         if {[llength $format] == 1} {
    1107             set data [$_results get -format $format $irun]
    1108         } else {
    1109             set data [lindex [$_results get -format $format $irun] 0]
    1110         }
    1111 
    1112         foreach col $format val $data {
    1113             set _cntlInfo($this-$col-value) $val
    1114         }
    1115         set simnum [$_results get -format simnum $irun]
    1116         set _cntlInfo($this-simnum-value) $simnum
    1117 
    1118         # okay, react to value changes again
    1119         set _settings 0
    1120     }
    1121 
    1122     #
    1123     # Search for tuples matching the current setting and
    1124     # plot them.
    1125     #
    1126     if {$_plotall && $_active == "simnum"} {
    1127         set format ""
    1128     } else {
    1129         set format ""
    1130         set tuple ""
    1131         foreach col [lrange [$_results column names] 2 end] {
    1132             if {!$_plotall || $col != $_active} {
    1133                 lappend format $col
    1134                 lappend tuple $_cntlInfo($this-$col-value)
    1135             }
    1136         }
    1137     }
    1138 
    1139     if {"" != $format} {
    1140         set ilist [$_results find -format $format -- $tuple]
    1141     } else {
    1142         set ilist [$_results find]
    1143     }
    1144 
    1145     if {[llength $ilist] > 0} {
    1146         # search for the result for these settings
    1147         set format ""
    1148         set tuple ""
    1149         foreach col [lrange [$_results column names] 2 end] {
    1150             lappend format $col
    1151             lappend tuple $_cntlInfo($this-$col-value)
    1152         }
    1153         set icurr [$_results find -format $format -- $tuple]
    1154 
    1155         if {[llength $ilist] == 1} {
    1156             # single result -- always use active color
    1157             set i [lindex $ilist 0]
    1158             set simnum [$_results get -format simnum $i]
    1159             set plist [list \
    1160                 $simnum [list -width 2 \
    1161                          -param [_getValues $_active $i] \
    1162                          -description [_getParamDesc all $i] \
    1163                    ] \
    1164                 params $params \
    1165             ]
    1166         } else {
    1167             #
    1168             # Get the color for all points according to
    1169             # the color spectrum.
    1170             #
    1171             set plist [list params $params]
    1172             foreach i $ilist {
    1173                 set simnum [$_results get -format simnum $i]
    1174                 if {$i == $icurr} {
    1175                     lappend plist $simnum [list -width 3 -raise 1 \
    1176                         -param [_getValues $_active $i] \
    1177                         -description [_getParamDesc all $i]]
    1178                 } else {
    1179                     lappend plist $simnum [list -brightness 0.7 -width 1 \
    1180                         -param [_getValues $_active $i] \
    1181                         -description [_getParamDesc all $i]]
    1182                 }
    1183             }
    1184         }
    1185 
    1186         #
    1187         # Load up the matching plots
    1188         #
    1189         _doSettings $plist
    1190     }
    1191 }
    1192 
    1193 # ----------------------------------------------------------------------
    1194 # USAGE: _fixValue <columnName> <why>
    1195 #
    1196 # Called automatically whenver a value for a parameter dial changes.
    1197 # Updates the interface to display the new value.  The <why> is a
    1198 # reason for the change, which may be "resize" (draw old value in
    1199 # new size) or "value" (value changed).
    1200 # ----------------------------------------------------------------------
    1201 itcl::body Rappture::ResultSet::_fixValue {col why} {
    1202     if {[info exists _cntlInfo($this-$col-id)]} {
    1203         set id $_cntlInfo($this-$col-id)
    1204 
    1205         set widget $itk_component(dials).label$id
    1206         set wmax [winfo width $itk_component(dials).dial]
    1207         if {$wmax <= 1} {
    1208             set wmax [expr {round(0.9*[winfo width $itk_component(cntls)])}]
    1209         }
    1210         _drawValue $col $widget $wmax
    1211 
    1212         if {$why == "value" && !$_settings} {
    1213             # keep track of usage, so we know which controls are popular
    1214             incr _cntlInfo($this-$col-usage)
    1215 
    1216             # adjust the settings according to the value in the column
    1217             $_dispatcher event -idle !settings column $col
    1218         }
    1219     }
    1220 }
    1221 
    1222 # ----------------------------------------------------------------------
    1223 # USAGE: _drawValue <columnName> <widget> <widthMax>
    1224 #
    1225 # Used internally to fix the rendering of a "quantity = value" display.
    1226 # If the name/value in <widget> are smaller than <widthMax>, then the
    1227 # full "quantity = value" string is displayed.  Otherwise, an
    1228 # abbreviated form is displayed.
    1229 # ----------------------------------------------------------------------
    1230 itcl::body Rappture::ResultSet::_drawValue {col widget wmax} {
    1231     set quantity $_cntlInfo($this-$col-label)
    1232     regsub -all {\n} $quantity " " quantity  ;# take out newlines
    1233 
    1234     set newval $_cntlInfo($this-$col-value)
    1235     regsub -all {\n} $newval " " newval  ;# take out newlines
    1236 
    1237     set lfont [$widget.name cget -font]
    1238     set vfont [$widget.value cget -font]
    1239 
    1240     set wn [font measure $lfont $quantity]
    1241     set wv [font measure $lfont " = $newval"]
    1242     set w [expr {$wn + $wv}]
    1243 
    1244     if {$w <= $wmax} {
    1245         # if the text fits, then shown "quantity = value"
    1246         $widget.name configure -text $quantity
    1247         $widget.value configure -text " = $newval"
    1248     } else {
    1249         # Otherwise, we'll have to appreviate.
    1250         # If the value is really long, then just show a little bit
    1251         # of it.  Otherwise, show as much of the value as we can.
    1252         if {[string length $newval] > 30} {
    1253             set frac 0.8
    1254         } else {
    1255             set frac 0.2
    1256         }
    1257         set wNameSpace [expr {round($frac*$wmax)}]
    1258         set wValueSpace [expr {$wmax-$wNameSpace}]
    1259 
    1260         # fit as much of the "quantity" label in the space available
    1261         if {$wn < $wNameSpace} {
    1262             $widget.name configure -text $quantity
    1263             set wValueSpace [expr {$wmax-$wn}]
    1264         } else {
    1265             set wDots [font measure $lfont "..."]
    1266             set wchar [expr {double($wn)/[string length $quantity]}]
    1267             while {1} {
    1268                 # figure out a good size for the abbreviated string
    1269                 set cmax [expr {round(($wNameSpace-$wDots)/$wchar)}]
    1270                 if {$cmax < 0} {set cmax 0}
    1271                 set str "[string range $quantity 0 $cmax]..."
    1272                 if {[font measure $lfont $str] <= $wNameSpace
    1273                       || $wDots >= $wNameSpace} {
    1274                     break
    1275                 }
    1276                 # we're measuring with average chars, so we may have
    1277                 # to shave a little off and do this again
    1278                 set wDots [expr {$wDots+2*$wchar}]
    1279             }
    1280             $widget.name configure -text $str
    1281             set wValueSpace [expr {$wmax-[font measure $lfont $str]}]
    1282         }
    1283 
    1284         if {$wv < $wValueSpace} {
    1285             $widget.value configure -text " = $newval"
    1286         } else {
    1287             set wDots [font measure $vfont "..."]
    1288             set wEq [font measure $vfont " = "]
    1289             set wchar [expr {double($wv)/[string length " = $newval"]}]
    1290             while {1} {
    1291                 # figure out a good size for the abbreviated string
    1292                 set cmax [expr {round(($wValueSpace-$wDots-$wEq)/$wchar)}]
    1293                 if {$cmax < 0} {set cmax 0}
    1294                 set str " = [string range $newval 0 $cmax]..."
    1295                 if {[font measure $vfont $str] <= $wValueSpace
    1296                       || $wDots >= $wValueSpace} {
    1297                     break
    1298                 }
    1299                 # we're measuring with average chars, so we may have
    1300                 # to shave a little off and do this again
    1301                 set wDots [expr {$wDots+2*$wchar}]
    1302             }
    1303             $widget.value configure -text $str
    1304         }
    1305     }
    1306 }
    1307 
    1308 # ----------------------------------------------------------------------
    1309 # USAGE: _toggleAll ?<columnName>?
    1310 #
    1311 # Called automatically whenever the user clicks on an "All" button.
    1312 # Toggles the button between its on/off states.  In the "on" state,
    1313 # all results associated with the current control are sent to the
    1314 # result viewer.
    1315 # ----------------------------------------------------------------------
    1316 itcl::body Rappture::ResultSet::_toggleAll {{col "current"}} {
    1317     if {$col == "current"} {
    1318         set col $_active
    1319     }
    1320     if {![info exists _cntlInfo($this-$col-id)]} {
    1321         return
    1322     }
    1323     set id $_cntlInfo($this-$col-id)
    1324     set sbutton $itk_component(dials).all
    1325     set current [$sbutton cget -relief]
    1326 
    1327     if {$current == "sunken"} {
    1328         $sbutton configure -relief raised \
    1329             -background $itk_option(-activecontrolbackground) \
    1330             -foreground $itk_option(-activecontrolforeground)
    1331         set _plotall 0
    1332     } else {
    1333         $sbutton configure -relief sunken \
    1334             -background $itk_option(-togglebackground) \
    1335             -foreground $itk_option(-toggleforeground)
    1336         set _plotall 1
    1337 
    1338         if {$col != $_active} {
    1339             # clicked on an inactive "All" button? then activate that column
    1340             activate $col
    1341         }
    1342     }
    1343     $_dispatcher event -idle !settings
    1344 }
    1345 
    1346 # ----------------------------------------------------------------------
    1347 # USAGE: _getValues <column> ?<which>?
    1348 #
    1349 # Called automatically whenever the user hovers a control within
    1350 # this widget.  Returns the tooltip associated with the control.
    1351 # ----------------------------------------------------------------------
    1352 itcl::body Rappture::ResultSet::_getValues {col {which ""}} {
    1353     if {$col == "simnum"} {
    1354         # load the Simulation # control
    1355         set nruns [$_results size]
    1356         for {set n 0} {$n < $nruns} {incr n} {
    1357             set v [$_results get -format simnum $n]
    1358             set label2val($v) $n
    1359         }
    1360     } else {
    1361         set havenums 1
    1362         set vlist ""
    1363         foreach rec [$_results get -format [list xmlobj $col]] {
    1364             set xo [lindex $rec 0]
    1365             set v [lindex $rec 1]
    1366 
    1367             if {![info exists label2val($v)]} {
    1368                 lappend vlist $v
    1369                 foreach {raw norm} [Rappture::LibraryObj::value $xo $col] break
    1370                 set label2val($v) $norm
    1371 
    1372                 if {$havenums && ![string is double $norm]} {
    1373                     set havenums 0
    1374                 }
    1375             }
    1376         }
    1377 
    1378         if {!$havenums} {
    1379             # don't have normalized nums? then sort and create nums
    1380             catch {unset label2val}
    1381 
    1382             set n 0
    1383             foreach v [lsort $vlist] {
    1384                 incr n
    1385                 set label2val($v) $n
    1386             }
    1387         }
    1388     }
    1389 
    1390     switch -- $which {
    1391         current {
    1392             set curr $_cntlInfo($this-$col-value)
    1393             if {[info exists label2val($curr)]} {
    1394                 return [list $curr $label2val($curr)]
    1395             }
    1396             return ""
    1397         }
    1398         all {
    1399             return [array get label2val]
    1400         }
    1401         default {
    1402             if {[string is integer $which]} {
    1403                 if {$col == "simnum"} {
    1404                     set val [$_results get -format simnum $which]
    1405                 } else {
    1406                     # Be careful giving singleton elements as the "columns"
    1407                     # argument to "Tuples::get". It is expecting a list.
    1408                     set val [lindex [$_results get -format [list $col] $which] 0]
    1409                 }
    1410                 if {[info exists label2val($val)]} {
    1411                     return [list $val $label2val($val)]
    1412                 }
    1413                 return ""
    1414             }
    1415             error "bad option \"$which\": should be all, current, or an integer index"
    1416         }
    1417     }
    1418 }
    1419 
    1420 # ----------------------------------------------------------------------
    1421 # USAGE: _getTooltip <role> <column>
    1422 #
    1423 # Called automatically whenever the user hovers a control within
    1424 # this widget.  Returns the tooltip associated with the control.
    1425 # ----------------------------------------------------------------------
    1426 itcl::body Rappture::ResultSet::_getTooltip {role column} {
    1427     set label ""
    1428     set tip ""
    1429     if {$column == "active"} {
    1430         set column $_active
    1431     }
    1432     if {[info exists _cntlInfo($this-$column-label)]} {
    1433         set label $_cntlInfo($this-$column-label)
    1434     }
    1435     if {[info exists _cntlInfo($this-$column-tip)]} {
    1436         set tip $_cntlInfo($this-$column-tip)
    1437     }
    1438 
    1439     switch -- $role {
    1440         label {
    1441             if {$column != $_active} {
    1442                 append tip "\n\nClick to activate this control."
    1443             }
    1444         }
    1445         dial {
    1446             append tip "\n\nClick to change the value of this parameter."
    1447         }
    1448         all {
    1449             if {$label == ""} {
    1450                 set tip "Plot all values for this quantity."
    1451             } else {
    1452                 set tip "Plot all values for $label."
    1453             }
    1454             if {$_plotall} {
    1455                 set what "all values"
    1456             } else {
    1457                 set what "one value"
    1458             }
    1459             append tip "\n\nCurrently, plotting $what.  Click to toggle."
    1460         }
    1461     }
    1462     return [string trim $tip]
    1463 }
    1464 
    1465 # ----------------------------------------------------------------------
    1466 # USAGE: _getParamDesc <which> ?<index>?
    1467 #
    1468 # Used internally to build a descripton of parameters for the data
    1469 # tuple at the specified <index>.  This is passed on to the underlying
    1470 # results viewer, so it will know what data is being viewed.
    1471 # ----------------------------------------------------------------------
    1472 itcl::body Rappture::ResultSet::_getParamDesc {which {index "current"}} {
    1473     if {$index == "current"} {
    1474         # search for the result for these settings
    1475         set format ""
    1476         set tuple ""
    1477         foreach col [lrange [$_results column names] 2 end] {
    1478             lappend format $col
    1479             lappend tuple $_cntlInfo($this-$col-value)
    1480         }
    1481         set index [$_results find -format $format -- $tuple]
    1482         if {"" == $index} {
    1483             return ""  ;# somethings wrong -- bail out!
    1484         }
    1485     }
    1486 
    1487     switch -- $which {
    1488         active {
    1489             if {"" == $_active} {
    1490                 return ""
    1491             }
    1492         }
    1493         all {
    1494             set desc ""
    1495             foreach col $_cntlInfo($this-all) {
    1496                 set quantity $_cntlInfo($this-$col-label)
    1497                 # Be careful giving singleton elements as the "columns"
    1498                 # argument to "Tuples::get". It is expecting a list.
    1499                 set val [lindex [$_results get -format [list $col] $index] 0]
    1500                 if {$col == "simnum"} {
    1501                     set irun [lindex [$_results find -format xmlobj $val] 0]
    1502                     set val [$_results get -format simnum $irun]
    1503                 }
    1504                 append desc "$quantity = $val\n"
    1505             }
    1506             return [string trim $desc]
    1507         }
    1508         default {
    1509             error "bad value \"$which\": should be active or all"
     467            error "wrong # args: should be add, get, remove"
     468        }
     469    }
     470}
     471
     472# ----------------------------------------------------------------------
     473# USAGE: _notifyHandler ?<eventArgs>...?
     474#
     475# Called automatically whenever a !change event is triggered in this
     476# object.  Scans through the list of clients that want to receive this
     477# event and executes each of their callbacks.
     478# ----------------------------------------------------------------------
     479itcl::body Rappture::ResultSet::_notifyHandler {args} {
     480    array set data $args
     481    set event $data(event)
     482
     483    foreach caller $_notify(ALL) {
     484        if {[info exists _notify($caller-$event)]} {
     485            if {[catch {uplevel #0 $_notify($caller-$event) $args} result]} {
     486                # anything go wrong? then throw a background error
     487                bgerror "$result\n(while dispatching $event to $caller)"
     488            }
    1510489        }
    1511490    }
     
    1575554
    1576555        # overwrite the first matching entry
     556        # start by freeing the old result
    1577557        set index [lindex $ilist 0]
     558        set xo [$tuples get -format xmlobj $index]
     559        itcl::delete object $xo
     560
     561        # put this new result in its place
    1578562        $tuples put -format $cols $index $tuple
     563        set simnum [$tuples get -format simnum $index]
    1579564    } else {
    1580565        if {$simnum eq ""} {
     
    1586571    return $simnum
    1587572}
    1588 
    1589 # ----------------------------------------------------------------------
    1590 # OPTION: -activecontrolbackground
    1591 # ----------------------------------------------------------------------
    1592 itcl::configbody Rappture::ResultSet::activecontrolbackground {
    1593     $_dispatcher event -idle !layout
    1594 }
    1595 
    1596 # ----------------------------------------------------------------------
    1597 # OPTION: -activecontrolforeground
    1598 # ----------------------------------------------------------------------
    1599 itcl::configbody Rappture::ResultSet::activecontrolforeground {
    1600     $_dispatcher event -idle !layout
    1601 }
    1602 
  • branches/nanovis2/gui/scripts/sequenceresult.tcl

    r2939 r3175  
    444444        }
    445445        switch -- $type {
     446            ::Rappture::Drawing {
     447                Rappture::VtkViewer $viewer
     448                pack $viewer -expand yes -fill both
     449            }
    446450            ::Rappture::Curve {
    447451                Rappture::XyResult $viewer
     452                pack $viewer -expand yes -fill both
     453            }
     454            ::Rappture::Histogram {
     455                Rappture::HistogramResult $viewer
    448456                pack $viewer -expand yes -fill both
    449457            }
     
    476484                switch -- $dimensions {
    477485                    2D {
     486                        global env
    478487                        if { [$dataobj isunirect2d] } {
    479                             global env
    480488                            if { [$dataobj hints type] == "contour" } {
    481489                                set mode "vtkcontour"
     
    485493                                set mode "heightmap"
    486494                            }
     495                        } elseif { [info exists env(VTKCONTOUR)] } {
     496                            set mode "vtkcontour"
    487497                        } else {
    488498                            set mode "vtk"
     499                        }
     500                        set extents [$dataobj extents]
     501                        if { $extents > 1 } {
     502                            set mode "flowvis"
    489503                        }
    490504                        Rappture::Field2DResult $viewer -mode $mode
     
    508522                                }
    509523                            }
     524                            "vtkvolume" {
     525                                set fmt "vtkvolume"
     526                            }
     527                            "vtkstreamlines" {
     528                                set fmt "vtkstreamlines"
     529                            }
    510530                            "" {
    511531                                set fmt "auto"
  • branches/nanovis2/gui/scripts/sidebarframe.tcl

    r2744 r3175  
    3838    itk_option define -sashcursor sashCursor Cursor ""
    3939
     40    public variable resizeframe 1
    4041    constructor {args} { # defined below }
    4142
     
    569570    set x1 [expr {$w - $sbarw - $sashw}]
    570571    set x2 [expr {$w - $sbarw}]
    571     place $itk_component(frame) -x 0 -y 0 -anchor nw -width $x1 -height $h
     572    if { $resizeframe } {
     573        set framew $x1
     574    } else {
     575        set framew [expr $w - $ctrlw]
     576    }
     577    place $itk_component(frame) -x 0 -y 0 -anchor nw -width $framew -height $h
    572578    place $itk_component(sashbg) -x $x1 -y 0 -anchor nw -width $sashw -height $h
    573579    place $itk_component(sidebar) -x $x2 -y 0 -anchor nw -width $sbarw -height $h
  • branches/nanovis2/gui/scripts/textentry.tcl

    r2744 r3175  
    3737    itk_option define -height height Height 0
    3838
    39     constructor {owner path args} { # defined below }
     39    constructor {owner path args} {
     40        # defined below
     41    }
    4042
    4143    public method value {args}
     
    254256                    -foreground $itk_option(-textforeground)
    255257
    256                 bind $itk_component(entry) <KeyPress> \
     258                # Make sure these event bindings occur after the class bindings.
     259                # Otherwise you'll always get the entry value before the edit.
     260                bind textentry <KeyPress> \
    257261                    [itcl::code $this _newValue]
    258                 bind $itk_component(entry) <Control-KeyPress-a> \
     262                bind textentry <Control-KeyPress-a> \
    259263                    "[list $itk_component(entry) selection range 0 end]; break"
     264                set bindtags [bindtags $itk_component(entry)]
     265                lappend bindtags textentry
     266                bindtags $itk_component(entry) $bindtags
    260267
    261268                itk_component add emenu {
     
    309316                $itk_component(scrollbars) contents $itk_component(text)
    310317
    311                 bind $itk_component(text) <KeyPress> \
     318                # Make sure these event bindings occur after the class bindings.
     319                # Otherwise you'll always get the text value before the edit.
     320                bind textentry <KeyPress> \
    312321                    [itcl::code $this _newValue]
    313                 bind $itk_component(text) <Control-KeyPress-a> \
     322                bind textentry <Control-KeyPress-a> \
    314323                    "[list $itk_component(text) tag add sel 1.0 end]; break"
     324                set bindtags [bindtags $itk_component(text)]
     325                lappend bindtags textentry
     326                bindtags $itk_component(text) $bindtags
    315327
    316328                itk_component add tmenu {
  • branches/nanovis2/gui/scripts/tool.tcl

    r2977 r3175  
    212212
    213213            if { $status != 0 } {
     214                # We're here because the exec-ed program failed
    214215                if { $::Rappture::Tool::job(control) != "" } {
    215                     set code [lindex $::Rappture::Tool::job(control) 0]
    216                     set mesg [lindex $::Rappture::Tool::job(control) 2]
    217                     if { $code == "EXITED" } {
    218                         set result "Program returned exit code $status:\n\n"
     216                    foreach { token pid code mesg } \
     217                        $::Rappture::Tool::job(control) break
     218                    if { $token == "EXITED" } {
     219                        # This means that the program exited normally but
     220                        # returned a non-zero exitcode.  Consider this an
     221                        # invalid result from the program.  Append the stderr
     222                        # from the program to the message.
     223                        set result \
     224                            "Program finished: exit code is $code\n\n"
    219225                        append result $::Rappture::Tool::job(error)
    220                     } else  {
    221                         set result \
    222                             "Abnormal program termination \"$code\": $mesg"
     226                    } elseif { $token == "abort" }  {
     227                        # The user pressed the abort button.
     228                        set result "Program terminated by user.\n\n"
     229                        append result $::Rappture::Tool::job(output)
     230                    } else {
     231                        # Abnormal termination
     232                        set result "Abnormal program termination: $mesg\n\n"
     233                        append result $::Rappture::Tool::job(output)
    223234                    }
    224235                }
  • branches/nanovis2/gui/scripts/unirect2d.tcl

    r2830 r3175  
    5252    }
    5353    set path [$field get $cname.mesh]
     54
    5455    set m [$xmlobj element -as object $path]
    5556    GetValue $m "xaxis.min" _xMin
     
    101102    set n [expr $_xNum * $_yNum * $_compNum]
    102103    if { [$_values length] != $n } {
    103         error "wrong \# of values in \"$cname.values\": expected $n values"
     104        error "wrong \# of values in \"$cname.values\": expected $n values, got [$_values length]"
    104105    }
    105106}
  • branches/nanovis2/gui/scripts/unirect3d.tcl

    r2830 r3175  
    105105    set n [expr $_xNum * $_yNum * $_zNum * $_compNum]
    106106    if { [$_values length] != $n } {
    107         error "wrong \# of values in \"$cname.values\": expected $n values"
     107        error "wrong \# of values in \"$cname.values\": expected $n values, got [$_values length]"
    108108    }
    109109}
  • branches/nanovis2/gui/scripts/visviewer.tcl

    r2977 r3175  
    152152
    153153    itk_component add main {
    154         Rappture::SidebarFrame $itk_interior.main
     154        Rappture::SidebarFrame $itk_interior.main -resizeframe 0
    155155    }
    156156    pack $itk_component(main) -expand yes -fill both
     
    168168    if { [info exists env(VISRECORDER)] } {
    169169        set _logging 1
     170        if { [file exists /tmp/recording.log] } {
     171            file delete /tmp/recording.log
     172        }
    170173    }
    171174    eval itk_initialize $args
  • branches/nanovis2/gui/scripts/vtkheightmapviewer.tcl

    r2792 r3175  
    1 
    21# ----------------------------------------------------------------------
    32#  COMPONENT: vtkheightmapviewer - Vtk heightmap viewer
  • branches/nanovis2/gui/scripts/vtkviewer.tcl

    r2848 r3175  
    8484    private method BuildAxisTab {}
    8585    private method BuildCameraTab {}
    86     private method BuildColormap { colormap dataobj comp }
     86    private method BuildColormap { name styles }
    8787    private method BuildCutawayTab {}
    8888    private method BuildDownloadPopup { widget command }
    89     private method BuildVolumeTab {}
     89    private method BuildMeshTab {}
     90    private method BuildMoleculeTab {}
    9091    private method ConvertToVtkData { dataobj comp }
    9192    private method DrawLegend {}
     
    101102    private method RequestLegend {}
    102103    private method SetColormap { dataobj comp }
     104    private method ChangeColormap { dataobj comp color }
     105    private method ColorsToColormap { color }
    103106    private method SetLegendTip { x y }
    104107    private method SetObjectStyle { dataobj comp }
     
    106109
    107110    private variable _arcball ""
    108     private variable _outbuf       ;# buffer for outgoing commands
    109 
    110     private variable _dlist ""     ;# list of data objects
     111    private variable _outbuf;           # buffer for outgoing commands
     112
     113    private variable _dlist "";         # list of data objects
    111114    private variable _allDataObjs
    112115    private variable _obj2datasets
    113     private variable _obj2ovride   ;# maps dataobj => style override
    114     private variable _datasets     ;# contains all the dataobj-component
    115                                    ;# datasets in the server
    116     private variable _colormaps    ;# contains all the colormaps
    117                                    ;# in the server.
    118     private variable _dataset2style    ;# maps dataobj-component to transfunc
    119     private variable _style2datasets   ;# maps tf back to list of
    120                                     # dataobj-components using the tf.
    121 
    122     private variable _click        ;# info used for rotate operations
    123     private variable _limits       ;# autoscale min/max for all axes
    124     private variable _view         ;# view params for 3D view
     116    private variable _obj2ovride;       # maps dataobj => style override
     117    private variable _datasets;         # contains all the dataobj-component
     118                                        # datasets in the server
     119    private variable _colormaps;        # contains all the colormaps
     120                                        # in the server.
     121    private variable _dataset2style;    # maps dataobj-component to transfunc
     122    private variable _style2datasets;   # maps tf back to list of
     123                                        # dataobj-components using the tf.
     124    private variable _click        ;    # info used for rotate operations
     125    private variable _limits       ;    # autoscale min/max for all axes
     126    private variable _view         ;    # view params for 3D view
    125127    private variable _settings
    126     private variable _volume
     128    private variable _style;            # Array of current component styles.
     129    private variable _initialStyle;     # Array of initial component styles.
    127130    private variable _axis
    128131    private variable _reset 1      ;# indicates if camera needs to be reset
    129132                                    # to starting position.
    130     private variable _haveSpheres 0
     133    private variable _haveGlyphs 0
     134    private variable _haveMolecules 0
    131135
    132136    private variable _first ""     ;# This is the topmost dataset.
     
    141145    private variable _resizePending 0
    142146    private variable _rotatePending 0
     147    private variable _updatePending 0;
    143148    private variable _outline
    144149}
     
    163168    $_dispatcher register !resize
    164169    $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list"
     170
     171    # Update state event
     172    $_dispatcher register !update
     173    $_dispatcher dispatch $this !update "[itcl::code $this DoUpdate]; list"
    165174
    166175    # Rotate event
     
    187196    # Initialize the view to some default parameters.
    188197    array set _view {
    189         qw              1
    190         qx              0
    191         qy              0
    192         qz              0
     198        qw              0.853553
     199        qx              -0.353553
     200        qy              0.353553
     201        qz              0.146447
    193202        zoom            1.0
    194203        xpan            0
     
    219228        labels          1
    220229    }]
    221     array set _volume [subst {
    222         edges           1
    223         lighting        1
    224         opacity         40
    225         visible         1
    226         wireframe       0
    227     }]
    228230    array set _settings [subst {
    229231        legend          1
     232        molecule-representation  "Ball and Stick"
     233        molecule-edges           0
     234        molecule-labels          0
     235        molecule-lighting        1
     236        molecule-opacity         100
     237        molecule-visible         1
     238        molecule-wireframe       0
     239        molecule-palette         elementDefault
     240        mesh-edges           0
     241        mesh-lighting        1
     242        mesh-opacity         40
     243        mesh-visible         1
     244        mesh-wireframe       0
     245        mesh-palette         rainbow
    230246    }]
    231247
     
    268284    }
    269285    pack $itk_component(reset) -side top -padx 2 -pady 2
    270     Rappture::Tooltip::for $itk_component(reset) "Reset the view to the default zoom level"
     286    Rappture::Tooltip::for $itk_component(reset) \
     287        "Reset the view to the default zoom level"
    271288
    272289    itk_component add zoomin {
     
    294311    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
    295312
    296     if { [catch {
    297     BuildVolumeTab
     313    puts stderr "BuildMeshTab"
     314    if { [catch { BuildMeshTab } errs ]  != 0 } {
     315        puts stderr "errs=$errs"
     316    }
     317    puts stderr "BuildMoleculeTab"
     318    if { [catch { BuildMoleculeTab } errs ]  != 0 } {
     319        global errorInfo
     320        puts stderr "errs=$errs\nerrorInfo=$errorInfo"
     321    }
    298322    BuildAxisTab
    299     BuildCutawayTab
     323    #BuildCutawayTab
    300324    BuildCameraTab
    301     } errs] != 0 } {
    302         puts stderr errs=$errs
    303     }
     325
    304326    # Legend
    305327
     
    405427        set _height 500
    406428    }
    407     #puts stderr "DoResize screen size $_width $_height"
    408429    set _start [clock clicks -milliseconds]
    409     #puts stderr "screen size request width=$_width height=$_height"
    410430    SendCmd "screen size $_width $_height"
    411431    #SendCmd "imgflush"
     
    424444
    425445itcl::body Rappture::VtkViewer::EventuallyResize { w h } {
    426     #puts stderr "EventuallyResize $w $h"
    427446    set _width $w
    428447    set _height $h
     
    437456
    438457itcl::body Rappture::VtkViewer::EventuallyRotate { q } {
    439     #puts stderr "EventuallyRotate $w $h"
    440458    foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
    441459    if { !$_rotatePending } {
     
    695713# ----------------------------------------------------------------------
    696714itcl::body Rappture::VtkViewer::Connect {} {
    697     #puts stderr "Enter Connect: [info level -1]"
    698715    set _hosts [GetServerList "vtkvis"]
    699716    if { "" == $_hosts } {
     
    702719    set result [VisViewer::Connect $_hosts]
    703720    if { $result } {
    704         #puts stderr "Connected to $_hostname sid=$_sid"
    705721        set w [winfo width $itk_component(view)]
    706722        set h [winfo height $itk_component(view)]
     
    789805        set time [clock seconds]
    790806        set date [clock format $time]
    791         #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"       
    792807        if { $_start > 0 } {
    793808            set finish [clock clicks -milliseconds]
    794             #puts stderr "round trip time [expr $finish -$_start] milliseconds"
    795809            set _start 0
    796810        }
     
    878892        SendCmd "camera mode persp"
    879893    }
     894
    880895    DoRotate
    881896    PanCamera
     
    887902    FixSettings axis-xgrid axis-ygrid axis-zgrid axis-mode \
    888903        axis-visible axis-labels \
    889         volume-edges volume-lighting volume-opacity volume-visible \
    890         volume-wireframe
     904        mesh-edges mesh-lighting mesh-opacity mesh-visible \
     905        mesh-wireframe
    891906
    892907    #SendCmd "imgflush"
     
    904919            if { ![info exists _datasets($tag)] } {
    905920                set bytes [$dataobj data $comp]
     921                if { $bytes == "" } {
     922                    continue
     923                }
    906924                set length [string length $bytes]
    907925                append _outbuf "dataset add $tag data follows $length\n"
    908926                append _outbuf $bytes
    909                 if { [$dataobj type $comp] != "spheres" } {
    910                 }
    911927                set _datasets($tag) 1
    912928            }
     
    937953        }
    938954    }
     955    FixSettings molecule-representation
     956
     957    SendCmd "dataset maprange visible"
    939958       
    940959    set _buffering 0;                        # Turn off buffering.
     
    10131032        "reset" {
    10141033            array set _view {
    1015                 qw      1
    1016                 qx      0
    1017                 qy      0
    1018                 qz      0
     1034                qw      0.853553
     1035                qx      -0.353553
     1036                qy      0.353553
     1037                qz      0.146447
    10191038                zoom    1.0
    10201039                xpan   0
     
    11771196    }
    11781197    switch -- $what {
    1179         "volume-opacity" {
    1180             set val $_volume(opacity)
     1198        "mesh-opacity" {
     1199            set val $_settings(mesh-opacity)
    11811200            set sval [expr { 0.01 * double($val) }]
    11821201            foreach dataset [CurrentDatasets -visible $_first] {
    1183                 SendCmd "polydata opacity $sval $dataset"
    1184             }
    1185         }
    1186         "volume-wireframe" {
    1187             set bool $_volume(wireframe)
     1202                foreach { dataobj comp } [split $dataset -] break
     1203                set type [$dataobj type $comp]
     1204                if { $type == "polydata" } {
     1205                    SendCmd "$type opacity $sval $dataset"
     1206                }
     1207            }
     1208        }
     1209        "mesh-wireframe" {
     1210            set bool $_settings(mesh-wireframe)
    11881211            foreach dataset [CurrentDatasets -visible $_first] {
    1189                 SendCmd "polydata wireframe $bool $dataset"
    1190             }
    1191         }
    1192         "volume-visible" {
    1193             set bool $_volume(visible)
     1212                foreach { dataobj comp } [split $dataset -] break
     1213                set type [$dataobj type $comp]
     1214                if { $type == "polydata" } {
     1215                    SendCmd "$type wireframe $bool $dataset"
     1216                }
     1217            }
     1218        }
     1219        "mesh-visible" {
     1220            set bool $_settings(mesh-visible)
    11941221            foreach dataset [CurrentDatasets -visible $_first] {
    1195                 SendCmd "polydata visible $bool $dataset"
    1196             }
    1197         }
    1198         "volume-lighting" {
    1199             set bool $_volume(lighting)
     1222                foreach { dataobj comp } [split $dataset -] break
     1223                set type [$dataobj type $comp]
     1224                if { $type == "polydata" } {
     1225                    SendCmd "$type visible $bool $dataset"
     1226                }
     1227            }
     1228        }
     1229        "mesh-lighting" {
     1230            set bool $_settings(mesh-lighting)
    12001231            foreach dataset [CurrentDatasets -visible $_first] {
    1201                 SendCmd "polydata lighting $bool $dataset"
    1202             }
    1203         }
    1204         "volume-edges" {
    1205             set bool $_volume(edges)
     1232                foreach { dataobj comp } [split $dataset -] break
     1233                set type [$dataobj type $comp]
     1234                if { $type == "polydata" } {
     1235                    SendCmd "$type lighting $bool $dataset"
     1236                }
     1237            }
     1238        }
     1239        "mesh-edges" {
     1240            set bool $_settings(mesh-edges)
    12061241            foreach dataset [CurrentDatasets -visible $_first] {
    1207                 SendCmd "polydata edges $bool $dataset"
     1242                foreach { dataobj comp } [split $dataset -] break
     1243                set type [$dataobj type $comp]
     1244                if { $type == "polydata" } {
     1245                    SendCmd "$type edges $bool $dataset"
     1246                }
     1247            }
     1248        }
     1249        "mesh-palette" {
     1250            set palette [$itk_component(meshpalette) value]
     1251            set _settings(mesh-palette) $palette
     1252            foreach dataset [CurrentDatasets -visible $_first] {
     1253                foreach {dataobj comp} [split $dataset -] break
     1254                set type [$dataobj type $comp]
     1255                if { $type == "polydata" } {
     1256                    ChangeColormap $dataobj $comp $palette
     1257                }
     1258            }
     1259            set _legendPending 1
     1260        }
     1261        "molecule-opacity" {
     1262            set val $_settings(molecule-opacity)
     1263            set sval [expr { 0.01 * double($val) }]
     1264            foreach dataset [CurrentDatasets -visible $_first] {
     1265                foreach { dataobj comp } [split $dataset -] break
     1266                set type [$dataobj type $comp]
     1267                if { $type == "molecule" } {
     1268                    SendCmd "molecule opacity $sval $dataset"
     1269                }
     1270            }
     1271        }
     1272        "molecule-wireframe" {
     1273            set bool $_settings(molecule-wireframe)
     1274            foreach dataset [CurrentDatasets -visible $_first] {
     1275                foreach { dataobj comp } [split $dataset -] break
     1276                set type [$dataobj type $comp]
     1277                if { $type == "molecule" } {
     1278                    SendCmd "molecule wireframe $bool $dataset"
     1279                }
     1280            }
     1281        }
     1282        "molecule-visible" {
     1283            set bool $_settings(molecule-visible)
     1284            foreach dataset [CurrentDatasets -visible $_first] {
     1285                foreach { dataobj comp } [split $dataset -] break
     1286                set type [$dataobj type $comp]
     1287                if { $type == "molecule" } {
     1288                    SendCmd "molecule visible $bool $dataset"
     1289                }
     1290            }
     1291        }
     1292        "molecule-lighting" {
     1293            set bool $_settings(molecule-lighting)
     1294            foreach dataset [CurrentDatasets -visible $_first] {
     1295                foreach { dataobj comp } [split $dataset -] break
     1296                set type [$dataobj type $comp]
     1297                if { $type == "molecule" } {
     1298                    SendCmd "molecule lighting $bool $dataset"
     1299                }
     1300            }
     1301        }
     1302        "molecule-edges" {
     1303            set bool $_settings(molecule-edges)
     1304            foreach dataset [CurrentDatasets -visible $_first] {
     1305                foreach { dataobj comp } [split $dataset -] break
     1306                set type [$dataobj type $comp]
     1307                if { $type == "molecule" } {
     1308                    SendCmd "molecule edges $bool $dataset"
     1309                }
     1310            }
     1311        }
     1312        "molecule-palette" {
     1313            set palette [$itk_component(moleculepalette) value]
     1314            set _settings(molecule-palette) $palette
     1315            foreach dataset [CurrentDatasets -visible $_first] {
     1316                foreach {dataobj comp} [split $dataset -] break
     1317                set type [$dataobj type $comp]
     1318                if { $type == "molecule" } {
     1319                    ChangeColormap $dataobj $comp $palette
     1320                    if { $palette == "elementDefault" } {
     1321                        SendCmd "molecule colormode by_elements element $dataset"
     1322                    } else {
     1323                        # FIXME: Set the chosen scalar field name here
     1324                        SendCmd "molecule colormode scalar {} $dataset"
     1325                    }
     1326                }
     1327            }
     1328            set _legendPending 1
     1329        }
     1330        "molecule-representation" {
     1331            set value [$itk_component(representation) value]
     1332            set value [$itk_component(representation) translate $value]
     1333            switch -- $value {
     1334                "ballandstick" {
     1335                    set rscale covalent
     1336                    set ashow 1
     1337                    set bshow 1
     1338                    set bstyle cylinder
     1339                    set ascale 0.3
     1340                    set bscale 0.075
     1341                }
     1342                "balls" - "spheres" {
     1343                    set rscale covalent
     1344                    set ashow 1
     1345                    set bshow 0
     1346                    set bstyle cylinder
     1347                    set ascale 0.3
     1348                    set bscale 0.075
     1349                }
     1350                "sticks" {
     1351                    set rscale none
     1352                    set ashow 1
     1353                    set bshow 1
     1354                    set bstyle cylinder
     1355                    set ascale 0.075
     1356                    set bscale 0.075
     1357                }
     1358                "spacefilling" {
     1359                    set rscale van_der_waals
     1360                    set ashow 1
     1361                    set bshow 0
     1362                    set bstyle cylinder
     1363                    set ascale 1.0
     1364                    set bscale 0.075
     1365                }
     1366                "rods"  {
     1367                    set rscale none
     1368                    set ashow 1
     1369                    set bshow 1
     1370                    set bstyle cylinder
     1371                    set ascale 0.1
     1372                    set bscale 0.1
     1373                }
     1374                "wireframe" - "lines" {
     1375                    set rscale none
     1376                    set ashow 0
     1377                    set bshow 1
     1378                    set bstyle line
     1379                    set ascale 1.0
     1380                    set bscale 1.0
     1381                }
     1382                default {
     1383                    error "unknown representation $value"
     1384                }
     1385            }
     1386            foreach dataset [CurrentDatasets -visible $_first] {
     1387                foreach {dataobj comp} [split $dataset -] break
     1388                set type [$dataobj type $comp]
     1389                if { $type == "molecule" } {
     1390                    SendCmd [subst {molecule rscale $rscale $dataset
     1391molecule atoms $ashow $dataset
     1392molecule bonds $bshow $dataset
     1393molecule bstyle $bstyle $dataset
     1394molecule ascale $ascale $dataset
     1395molecule bscale $bscale $dataset}]
     1396                }
     1397            }
     1398        }
     1399        "molecule-labels" {
     1400            set bool $_settings(molecule-labels)
     1401            foreach dataset [CurrentDatasets -visible $_first] {
     1402               foreach { dataobj comp } [split $dataset -] break
     1403               set type [$dataobj type $comp]
     1404               if { $type == "molecule" } {
     1405                   SendCmd "molecule labels $bool $dataset"
     1406               }
    12081407            }
    12091408        }
     
    12691468#
    12701469itcl::body Rappture::VtkViewer::RequestLegend {} {
    1271     #puts stderr "RequestLegend _first=$_first"
    1272     #puts stderr "RequestLegend width=$_width height=$_height"
    12731470    set font "Arial 8"
    12741471    set lineht [font metrics $font -linespace]
     
    12831480        foreach {dataobj comp} [split $dataset -] break
    12841481        if { [info exists _dataset2style($dataset)] } {
    1285             #puts stderr "RequestLegend w=$w h=$h"
    12861482            SendCmd "legend $_dataset2style($dataset) vmag {} {} $w $h 0"
    12871483            break;
     
    12911487
    12921488#
     1489# ChangeColormap --
     1490#
     1491itcl::body Rappture::VtkViewer::ChangeColormap {dataobj comp color} {
     1492    set tag $dataobj-$comp
     1493    if { ![info exist _style($tag)] } {
     1494        error "no initial colormap"
     1495    }
     1496    array set style $_style($tag)
     1497    set style(-color) $color
     1498    set _style($tag) [array get style]
     1499    SetColormap $dataobj $comp
     1500}
     1501
     1502#
    12931503# SetColormap --
    12941504#
    12951505itcl::body Rappture::VtkViewer::SetColormap { dataobj comp } {
    12961506    array set style {
    1297         -color rainbow
     1507        -color BCGYR
    12981508        -levels 6
    12991509        -opacity 1.0
    13001510    }
     1511    if {[$dataobj type $comp] == "molecule"} {
     1512        set style(-color) elementDefault
     1513    }
    13011514    set tag $dataobj-$comp
    1302     array set style [$dataobj style $comp]
    1303     set colormap "$style(-color):$style(-levels):$style(-opacity)"
    1304     if { [info exists _colormaps($colormap)] } {
    1305         puts stderr "Colormap $colormap already built"
    1306         return $colormap
    1307     }
    1308     if { ![info exists _dataset2style($tag)] } {
    1309         set _dataset2style($tag) $colormap
    1310         lappend _style2datasets($colormap) $tag
    1311     }
    1312     if { ![info exists _colormaps($colormap)] } {
    1313         # Build the pseudo colormap if it doesn't exist.
    1314         BuildColormap $colormap $dataobj $comp
    1315         set _colormaps($colormap) 1
    1316     }
    1317     switch -- [$dataobj type $comp] {
    1318         "polygon" {
    1319             SendCmd "pseudocolor colormap $colormap $tag"
    1320         }
    1321         "spheres" {
    1322             #SendCmd "glyphs colormap $colormap $tag"
    1323         }
    1324     }
    1325     return $colormap
    1326 }
    1327 
    1328 #
    1329 # BuildColormap --
    1330 #
    1331 itcl::body Rappture::VtkViewer::BuildColormap { colormap dataobj comp } {
    1332     array set style {
    1333         -color rainbow
    1334         -levels 6
    1335         -opacity 1.0
    1336     }
    1337     array set style [$dataobj style $comp]
    1338     if {$style(-color) == "rainbow"} {
    1339         set style(-color) "white:yellow:green:cyan:blue:magenta"
    1340     }
    1341     set clist [split $style(-color) :]
     1515    if { ![info exists _initialStyle($tag)] } {
     1516        # Save the initial component style.
     1517        set _initialStyle($tag) [$dataobj style $comp]
     1518    }
     1519
     1520    # Override defaults with initial style defined in xml.
     1521    array set style $_initialStyle($tag)
     1522
     1523    if { ![info exists _style($tag)] } {
     1524        set _style($tag) [array get style]
     1525    }
     1526    # Override initial style with current style.
     1527    array set style $_style($tag)
     1528
     1529    if { $style(-color) == "elementDefault" } {
     1530        set name "$style(-color)"
     1531    } else {
     1532        set name "$style(-color):$style(-levels):$style(-opacity)"
     1533    }
     1534    if { ![info exists _colormaps($name)] } {
     1535        BuildColormap $name [array get style]
     1536        set _colormaps($name) 1
     1537    }
     1538    if { ![info exists _dataset2style($tag)] ||
     1539         $_dataset2style($tag) != $name } {
     1540        set _dataset2style($tag) $name
     1541        switch -- [$dataobj type $comp] {
     1542            "polygon" {
     1543                SendCmd "pseudocolor colormap $name $tag"
     1544            }
     1545            "glyphs" {
     1546                SendCmd "glyphs colormap $name $tag"
     1547            }
     1548            "molecule" {
     1549                SendCmd "molecule colormap $name $tag"
     1550            }
     1551        }
     1552    }
     1553}
     1554
     1555itcl::body Rappture::VtkViewer::ColorsToColormap { colors } {
     1556    switch -- $colors {
     1557        "grey-to-blue" {
     1558            return {
     1559                0.0                      0.200 0.200 0.200
     1560                0.14285714285714285      0.400 0.400 0.400
     1561                0.2857142857142857       0.600 0.600 0.600
     1562                0.42857142857142855      0.900 0.900 0.900
     1563                0.5714285714285714       0.800 1.000 1.000
     1564                0.7142857142857143       0.600 1.000 1.000
     1565                0.8571428571428571       0.400 0.900 1.000
     1566                1.0                      0.000 0.600 0.800
     1567            }
     1568        }
     1569        "blue-to-grey" {
     1570            return {
     1571                0.0                     0.000 0.600 0.800
     1572                0.14285714285714285     0.400 0.900 1.000
     1573                0.2857142857142857      0.600 1.000 1.000
     1574                0.42857142857142855     0.800 1.000 1.000
     1575                0.5714285714285714      0.900 0.900 0.900
     1576                0.7142857142857143      0.600 0.600 0.600
     1577                0.8571428571428571      0.400 0.400 0.400
     1578                1.0                     0.200 0.200 0.200
     1579            }
     1580        }
     1581        "blue" {
     1582            return {
     1583                0.0                     0.900 1.000 1.000
     1584                0.1111111111111111      0.800 0.983 1.000
     1585                0.2222222222222222      0.700 0.950 1.000
     1586                0.3333333333333333      0.600 0.900 1.000
     1587                0.4444444444444444      0.500 0.833 1.000
     1588                0.5555555555555556      0.400 0.750 1.000
     1589                0.6666666666666666      0.300 0.650 1.000
     1590                0.7777777777777778      0.200 0.533 1.000
     1591                0.8888888888888888      0.100 0.400 1.000
     1592                1.0                     0.000 0.250 1.000
     1593            }
     1594        }
     1595        "brown-to-blue" {
     1596            return {
     1597                0.0                             0.200   0.100   0.000
     1598                0.09090909090909091             0.400   0.187   0.000
     1599                0.18181818181818182             0.600   0.379   0.210
     1600                0.2727272727272727              0.800   0.608   0.480
     1601                0.36363636363636365             0.850   0.688   0.595
     1602                0.45454545454545453             0.950   0.855   0.808
     1603                0.5454545454545454              0.800   0.993   1.000
     1604                0.6363636363636364              0.600   0.973   1.000
     1605                0.7272727272727273              0.400   0.940   1.000
     1606                0.8181818181818182              0.200   0.893   1.000
     1607                0.9090909090909091              0.000   0.667   0.800
     1608                1.0                             0.000   0.480   0.600
     1609            }
     1610        }
     1611        "blue-to-brown" {
     1612            return {
     1613                0.0                             0.000   0.480   0.600
     1614                0.09090909090909091             0.000   0.667   0.800
     1615                0.18181818181818182             0.200   0.893   1.000
     1616                0.2727272727272727              0.400   0.940   1.000
     1617                0.36363636363636365             0.600   0.973   1.000
     1618                0.45454545454545453             0.800   0.993   1.000
     1619                0.5454545454545454              0.950   0.855   0.808
     1620                0.6363636363636364              0.850   0.688   0.595
     1621                0.7272727272727273              0.800   0.608   0.480
     1622                0.8181818181818182              0.600   0.379   0.210
     1623                0.9090909090909091              0.400   0.187   0.000
     1624                1.0                             0.200   0.100   0.000
     1625            }
     1626        }
     1627        "blue-to-orange" {
     1628            return {
     1629                0.0                             0.000   0.167   1.000
     1630                0.09090909090909091             0.100   0.400   1.000
     1631                0.18181818181818182             0.200   0.600   1.000
     1632                0.2727272727272727              0.400   0.800   1.000
     1633                0.36363636363636365             0.600   0.933   1.000
     1634                0.45454545454545453             0.800   1.000   1.000
     1635                0.5454545454545454              1.000   1.000   0.800
     1636                0.6363636363636364              1.000   0.933   0.600
     1637                0.7272727272727273              1.000   0.800   0.400
     1638                0.8181818181818182              1.000   0.600   0.200
     1639                0.9090909090909091              1.000   0.400   0.100
     1640                1.0                             1.000   0.167   0.000
     1641            }
     1642        }
     1643        "orange-to-blue" {
     1644            return {
     1645                0.0                             1.000   0.167   0.000
     1646                0.09090909090909091             1.000   0.400   0.100
     1647                0.18181818181818182             1.000   0.600   0.200
     1648                0.2727272727272727              1.000   0.800   0.400
     1649                0.36363636363636365             1.000   0.933   0.600
     1650                0.45454545454545453             1.000   1.000   0.800
     1651                0.5454545454545454              0.800   1.000   1.000
     1652                0.6363636363636364              0.600   0.933   1.000
     1653                0.7272727272727273              0.400   0.800   1.000
     1654                0.8181818181818182              0.200   0.600   1.000
     1655                0.9090909090909091              0.100   0.400   1.000
     1656                1.0                             0.000   0.167   1.000
     1657            }
     1658        }
     1659        "rainbow" {
     1660            set clist {
     1661                "#EE82EE"
     1662                "#4B0082"
     1663                "blue"
     1664                "#008000"
     1665                "yellow"
     1666                "#FFA500"
     1667                "red"
     1668            }
     1669        }
     1670        "BGYOR" {
     1671            set clist {
     1672                "blue"
     1673                "#008000"
     1674                "yellow"
     1675                "#FFA500"
     1676                "red"
     1677            }
     1678        }
     1679        "ROYGB" {
     1680            set clist {
     1681                "red"
     1682                "#FFA500"
     1683                "yellow"
     1684                "#008000"
     1685                "blue"
     1686            }
     1687        }
     1688        "RYGCB" {
     1689            set clist {
     1690                "red"
     1691                "yellow"
     1692                "green"
     1693                "cyan"
     1694                "blue"
     1695            }
     1696        }
     1697        "BCGYR" {
     1698            set clist {
     1699                "blue"
     1700                "cyan"
     1701                "green"
     1702                "yellow"
     1703                "red"
     1704            }
     1705        }
     1706        "spectral" {
     1707            return {
     1708                0.0 0.150 0.300 1.000
     1709                0.1 0.250 0.630 1.000
     1710                0.2 0.450 0.850 1.000
     1711                0.3 0.670 0.970 1.000
     1712                0.4 0.880 1.000 1.000
     1713                0.5 1.000 1.000 0.750
     1714                0.6 1.000 0.880 0.600
     1715                0.7 1.000 0.680 0.450
     1716                0.8 0.970 0.430 0.370
     1717                0.9 0.850 0.150 0.196
     1718                1.0 0.650 0.000 0.130
     1719            }
     1720        }
     1721        "green-to-magenta" {
     1722            return {
     1723                0.0 0.000 0.316 0.000
     1724                0.06666666666666667 0.000 0.526 0.000
     1725                0.13333333333333333 0.000 0.737 0.000
     1726                0.2 0.000 0.947 0.000
     1727                0.26666666666666666 0.316 1.000 0.316
     1728                0.3333333333333333 0.526 1.000 0.526
     1729                0.4 0.737 1.000 0.737
     1730                0.4666666666666667 1.000 1.000 1.000
     1731                0.5333333333333333 1.000 0.947 1.000
     1732                0.6 1.000 0.737 1.000
     1733                0.6666666666666666 1.000 0.526 1.000
     1734                0.7333333333333333 1.000 0.316 1.000
     1735                0.8 0.947 0.000 0.947
     1736                0.8666666666666667 0.737 0.000 0.737
     1737                0.9333333333333333 0.526 0.000 0.526
     1738                1.0 0.316 0.000 0.316
     1739            }
     1740        }
     1741        "greyscale" {
     1742            return {
     1743                0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0
     1744            }
     1745        }
     1746        "nanohub" {
     1747            set clist "white yellow green cyan blue magenta"
     1748        }
     1749        default {
     1750            set clist $colors
     1751        }
     1752    }
    13421753    set cmap {}
    1343     for {set i 0} {$i < [llength $clist]} {incr i} {
    1344         set x [expr {double($i)/([llength $clist]-1)}]
     1754    set numColors [llength $clist]
     1755    for {set i 0} {$i < $numColors} {incr i} {
     1756        if { $numColors > 1 } {
     1757            set x [expr {double($i)/($numColors-1)}]
     1758        } else {
     1759            set x [expr double($i)]
     1760        }
    13451761        set color [lindex $clist $i]
    13461762        append cmap "$x [Color2RGB $color] "
    13471763    }
     1764    return $cmap
     1765}
     1766
     1767#
     1768# BuildColormap --
     1769#
     1770itcl::body Rappture::VtkViewer::BuildColormap { name styles } {
     1771    puts stderr name=$name
     1772    if { $name ==  "elementDefault" } {
     1773        return
     1774    }
     1775    array set style $styles
     1776    set cmap [ColorsToColormap $style(-color)]
    13481777    if { [llength $cmap] == 0 } {
    13491778        set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
    13501779    }
    1351     if { ![info exists _volume(opacity)] } {
    1352         set _volume(opacity) $style(-opacity)
    1353     }
    1354     set max $_volume(opacity)
     1780    if { ![info exists _settings(mesh-opacity)] } {
     1781        set _settings(mesh-opacity) $style(-opacity)
     1782    }
     1783    set max $_settings(mesh-opacity)
    13551784
    13561785    set wmap "0.0 1.0 1.0 1.0"
    1357     SendCmd "colormap add $colormap { $cmap } { $wmap }"
    1358 }
     1786    SendCmd "colormap add $name { $cmap } { $wmap }"
     1787}
     1788
    13591789
    13601790# ----------------------------------------------------------------------
     
    13861816        if { ![info exists _limits($tag)] } {
    13871817            set data [$dataobj data $comp]
     1818            if { $data == "" } {
     1819                continue
     1820            }
    13881821            set tmpfile file[pid].vtk
    13891822            set f [open "$tmpfile" "w"]
     
    14011834            set _limits($tag) [$output GetBounds]
    14021835            set pointData [$output GetPointData]
    1403             puts stderr "\#scalars=[$reader GetNumberOfScalarsInFile]"
    1404             puts stderr "\#vectors=[$reader GetNumberOfVectorsInFile]"
    1405             puts stderr "\#tensors=[$reader GetNumberOfTensorsInFile]"
    1406             puts stderr "\#normals=[$reader GetNumberOfNormalsInFile]"
    1407             puts stderr "\#fielddata=[$reader GetNumberOfFieldDataInFile]"
    1408             puts stderr "fielddataname=[$reader GetFieldDataNameInFile 0]"
    14091836            set fieldData [$output GetFieldData]
    1410             set pointData [$output GetPointData]
    1411             puts stderr "field \#arrays=[$fieldData GetNumberOfArrays]"
    1412             puts stderr "point \#arrays=[$pointData GetNumberOfArrays]"
    1413             puts stderr "field \#components=[$fieldData GetNumberOfComponents]"
    1414             puts stderr "point \#components=[$pointData GetNumberOfComponents]"
    1415             puts stderr "field \#tuples=[$fieldData GetNumberOfTuples]"
    1416             puts stderr "point \#tuples=[$pointData GetNumberOfTuples]"
    1417             puts stderr "point \#scalars=[$pointData GetScalars]"
    1418             puts stderr vectors=[$pointData GetVectors]
     1837            if 0 {
     1838                puts stderr "\#scalars=[$reader GetNumberOfScalarsInFile]"
     1839                puts stderr "\#vectors=[$reader GetNumberOfVectorsInFile]"
     1840                puts stderr "\#tensors=[$reader GetNumberOfTensorsInFile]"
     1841                puts stderr "\#normals=[$reader GetNumberOfNormalsInFile]"
     1842                puts stderr "\#fielddata=[$reader GetNumberOfFieldDataInFile]"
     1843                puts stderr "fielddataname=[$reader GetFieldDataNameInFile 0]"
     1844                puts stderr "field \#arrays=[$fieldData GetNumberOfArrays]"
     1845                puts stderr "point \#arrays=[$pointData GetNumberOfArrays]"
     1846                puts stderr "field \#components=[$fieldData GetNumberOfComponents]"
     1847                puts stderr "point \#components=[$pointData GetNumberOfComponents]"
     1848                puts stderr "field \#tuples=[$fieldData GetNumberOfTuples]"
     1849                puts stderr "point \#tuples=[$pointData GetNumberOfTuples]"
     1850                puts stderr "point \#scalars=[$pointData GetScalars]"
     1851                puts stderr vectors=[$pointData GetVectors]
     1852            }
    14191853            rename $output ""
    14201854            rename $reader ""
     
    14441878}
    14451879
    1446 itcl::body Rappture::VtkViewer::BuildVolumeTab {} {
     1880itcl::body Rappture::VtkViewer::BuildMeshTab {} {
    14471881
    14481882    set fg [option get $itk_component(hull) font Font]
     
    14501884
    14511885    set inner [$itk_component(main) insert end \
    1452         -title "Volume Settings" \
    1453         -icon [Rappture::icon volume-on]]
     1886        -title "Mesh Settings" \
     1887        -icon [Rappture::icon mesh]]
    14541888    $inner configure -borderwidth 4
    14551889
    1456     checkbutton $inner.volume \
    1457         -text "Show Volume" \
    1458         -variable [itcl::scope _volume(visible)] \
    1459         -command [itcl::code $this AdjustSetting volume-visible] \
     1890    checkbutton $inner.mesh \
     1891        -text "Show Mesh" \
     1892        -variable [itcl::scope _settings(mesh-visible)] \
     1893        -command [itcl::code $this AdjustSetting mesh-visible] \
    14601894        -font "Arial 9"
    14611895
    14621896    checkbutton $inner.wireframe \
    14631897        -text "Show Wireframe" \
    1464         -variable [itcl::scope _volume(wireframe)] \
    1465         -command [itcl::code $this AdjustSetting volume-wireframe] \
     1898        -variable [itcl::scope _settings(mesh-wireframe)] \
     1899        -command [itcl::code $this AdjustSetting mesh-wireframe] \
    14661900        -font "Arial 9"
    14671901
    14681902    checkbutton $inner.lighting \
    14691903        -text "Enable Lighting" \
    1470         -variable [itcl::scope _volume(lighting)] \
    1471         -command [itcl::code $this AdjustSetting volume-lighting] \
     1904        -variable [itcl::scope _settings(mesh-lighting)] \
     1905        -command [itcl::code $this AdjustSetting mesh-lighting] \
    14721906        -font "Arial 9"
    14731907
    14741908    checkbutton $inner.edges \
    14751909        -text "Show Edges" \
    1476         -variable [itcl::scope _volume(edges)] \
    1477         -command [itcl::code $this AdjustSetting volume-edges] \
     1910        -variable [itcl::scope _settings(mesh-edges)] \
     1911        -command [itcl::code $this AdjustSetting mesh-edges] \
    14781912        -font "Arial 9"
     1913
     1914    label $inner.palette_l -text "Palette" -font "Arial 9"
     1915    itk_component add meshpalette {
     1916        Rappture::Combobox $inner.palette -width 10 -editable no
     1917    }
     1918    $inner.palette choices insert end \
     1919        "BCGYR"              "BCGYR"            \
     1920        "BGYOR"              "BGYOR"            \
     1921        "blue"               "blue"             \
     1922        "blue-to-brown"      "blue-to-brown"    \
     1923        "blue-to-orange"     "blue-to-orange"   \
     1924        "blue-to-grey"       "blue-to-grey"     \
     1925        "green-to-magenta"   "green-to-magenta" \
     1926        "greyscale"          "greyscale"        \
     1927        "nanohub"            "nanohub"          \
     1928        "rainbow"            "rainbow"          \
     1929        "spectral"           "spectral"         \
     1930        "ROYGB"              "ROYGB"            \
     1931        "RYGCB"              "RYGCB"            \
     1932        "brown-to-blue"      "brown-to-blue"    \
     1933        "grey-to-blue"       "grey-to-blue"     \
     1934        "orange-to-blue"     "orange-to-blue"   
     1935
     1936    $itk_component(meshpalette) value "BCGYR"
     1937    bind $inner.palette <<Value>> \
     1938        [itcl::code $this AdjustSetting mesh-palette]
    14791939
    14801940    label $inner.opacity_l -text "Opacity" -font "Arial 9"
    14811941    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    1482         -variable [itcl::scope _volume(opacity)] \
     1942        -variable [itcl::scope _settings(mesh-opacity)] \
    14831943        -width 10 \
    14841944        -showvalue off \
    1485         -command [itcl::code $this AdjustSetting volume-opacity]
     1945        -command [itcl::code $this AdjustSetting mesh-opacity]
    14861946
    14871947    blt::table $inner \
    1488         0,0 $inner.volume    -anchor w -pady 2 \
    1489         1,0 $inner.wireframe -anchor w -pady 2 \
    1490         2,0 $inner.lighting  -anchor w -pady 2 \
    1491         3,0 $inner.edges     -anchor w -pady 2 \
     1948        0,0 $inner.mesh    -cspan 2 -anchor w -pady 2 \
     1949        1,0 $inner.wireframe -cspan 2 -anchor w -pady 2 \
     1950        2,0 $inner.lighting  -cspan 2 -anchor w -pady 2 \
     1951        3,0 $inner.edges     -cspan 2 -anchor w -pady 2 \
    14921952        4,0 $inner.opacity_l -anchor w -pady 2 \
    1493         5,0 $inner.opacity   -fill x   -pady 2
     1953        4,1 $inner.opacity   -fill x   -pady 2 \
     1954        5,0 $inner.palette_l -anchor w -pady 2 \
     1955        5,1 $inner.palette   -fill x   -pady 2 
    14941956
    14951957    blt::table configure $inner r* c* -resize none
    1496     blt::table configure $inner r6 c1 -resize expand
     1958    blt::table configure $inner r7 c1 -resize expand
    14971959}
    14981960
     
    17392201}
    17402202
    1741 
     2203itcl::body Rappture::VtkViewer::BuildMoleculeTab {} {
     2204    set fg [option get $itk_component(hull) font Font]
     2205
     2206    set inner [$itk_component(main) insert end \
     2207        -title "Molecule Settings" \
     2208        -icon [Rappture::icon molecule]]
     2209    $inner configure -borderwidth 4
     2210
     2211    checkbutton $inner.molecule \
     2212        -text "Show Molecule" \
     2213        -variable [itcl::scope _settings(molecule-visible)] \
     2214        -command [itcl::code $this AdjustSetting molecule-visible] \
     2215        -font "Arial 9"
     2216
     2217    checkbutton $inner.label \
     2218        -text "Show Atom Labels" \
     2219        -variable [itcl::scope _settings(molecule-labels)] \
     2220        -command [itcl::code $this AdjustSetting molecule-labels] \
     2221        -font "Arial 9"
     2222
     2223    checkbutton $inner.wireframe \
     2224        -text "Show Wireframe" \
     2225        -variable [itcl::scope _settings(molecule-wireframe)] \
     2226        -command [itcl::code $this AdjustSetting molecule-wireframe] \
     2227        -font "Arial 9"
     2228
     2229    checkbutton $inner.lighting \
     2230        -text "Enable Lighting" \
     2231        -variable [itcl::scope _settings(molecule-lighting)] \
     2232        -command [itcl::code $this AdjustSetting molecule-lighting] \
     2233        -font "Arial 9"
     2234
     2235    checkbutton $inner.edges \
     2236        -text "Show Edges" \
     2237        -variable [itcl::scope _settings(molecule-edges)] \
     2238        -command [itcl::code $this AdjustSetting molecule-edges] \
     2239        -font "Arial 9"
     2240
     2241    label $inner.rep_l -text "Molecule Representation" \
     2242        -font "Arial 9"
     2243
     2244    itk_component add representation {
     2245        Rappture::Combobox $inner.rep -width 20 -editable no
     2246    }
     2247    $inner.rep choices insert end \
     2248        "ballandstick"  "Ball and Stick" \
     2249        "spheres"       "Spheres"       \
     2250        "sticks"        "Sticks"        \
     2251        "rods"          "Rods"          \
     2252        "wireframe"     "Wireframe"     \
     2253        "spacefilling"  "Space Filling"
     2254
     2255    bind $inner.rep <<Value>> \
     2256        [itcl::code $this AdjustSetting molecule-representation]
     2257    $inner.rep value "Ball and Stick"
     2258
     2259    label $inner.palette_l -text "Palette" -font "Arial 9"
     2260    itk_component add moleculepalette {
     2261        Rappture::Combobox $inner.palette -width 10 -editable no
     2262    }
     2263    $inner.palette choices insert end \
     2264        "elementDefault"             "elementDefault" \
     2265        "BCGYR"              "BCGYR"            \
     2266        "BGYOR"              "BGYOR"            \
     2267        "blue"               "blue"             \
     2268        "blue-to-brown"      "blue-to-brown"    \
     2269        "blue-to-orange"     "blue-to-orange"   \
     2270        "blue-to-grey"       "blue-to-grey"     \
     2271        "green-to-magenta"   "green-to-magenta" \
     2272        "greyscale"          "greyscale"        \
     2273        "nanohub"            "nanohub"          \
     2274        "rainbow"            "rainbow"          \
     2275        "spectral"           "spectral"         \
     2276        "ROYGB"              "ROYGB"            \
     2277        "RYGCB"              "RYGCB"            \
     2278        "brown-to-blue"      "brown-to-blue"    \
     2279        "grey-to-blue"       "grey-to-blue"     \
     2280        "orange-to-blue"     "orange-to-blue"   
     2281
     2282    $itk_component(moleculepalette) value "elementDefault"
     2283    bind $inner.palette <<Value>> \
     2284        [itcl::code $this AdjustSetting molecule-palette]
     2285
     2286    checkbutton $inner.labels -text "Show labels on atoms" \
     2287        -command [itcl::code $this labels update] \
     2288        -variable [itcl::scope _settings(molecule-labels)] \
     2289        -font "Arial 9"
     2290    Rappture::Tooltip::for $inner.labels \
     2291        "Display atom symbol and serial number."
     2292
     2293    checkbutton $inner.rock -text "Rock molecule back and forth" \
     2294        -variable [itcl::scope _settings(molecule-rock)] \
     2295        -font "Arial 9"
     2296    Rappture::Tooltip::for $inner.rock \
     2297        "Rotate the object back and forth around the y-axis."
     2298
     2299    checkbutton $inner.cell -text "Parallelepiped" \
     2300        -font "Arial 9"
     2301    $inner.cell select
     2302
     2303    label $inner.opacity_l -text "Opacity" -font "Arial 9"
     2304    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
     2305        -variable [itcl::scope _settings(molecule-opacity)] \
     2306        -width 10 \
     2307        -showvalue off \
     2308        -command [itcl::code $this AdjustSetting molecule-opacity]
     2309
     2310    blt::table $inner \
     2311        0,0 $inner.molecule -anchor w -pady {1 0} \
     2312        1,0 $inner.label -anchor w -pady {1 0} \
     2313        2,0 $inner.edges -anchor w -pady {1 0} \
     2314        3,0 $inner.rep_l -anchor w -pady { 2 0 } \
     2315        4,0 $inner.rep -anchor w  \
     2316        5,0 $inner.palette_l -anchor w -pady 2 \
     2317        6,0 $inner.palette   -fill x   -pady 2  \
     2318        7,0 $inner.opacity_l -anchor w -pady 2 \
     2319        8,0 $inner.opacity   -fill x   -pady 2
     2320   
     2321    blt::table configure $inner r* -resize none
     2322    blt::table configure $inner r9 -resize expand
     2323}
    17422324
    17432325#
     
    18042386        foreach comp [$dataobj components] {
    18052387            set tag $dataobj-$comp
    1806             set contents [ConvertToVtkData $dataobj $comp]
    1807             append bytes "$contents\n\n"
     2388            set contents [$dataobj data $comp]
     2389            append bytes "$contents\n"
     2390            append bytes "\# End of VTK file\n\n"
    18082391        }
    18092392    }
     
    18702453        set settings(-wireframe) 1
    18712454    }
    1872     if { $type == "spheres" } {
     2455    if { $type == "glyphs" } {
    18732456        array set settings {
    18742457            -color \#808080
     
    18822465            -visible 1
    18832466        }
     2467        set shape [$dataobj shape $comp]
    18842468        array set settings $style
    1885         SendCmd "glyphs add sphere $tag"
     2469        SendCmd "glyphs add $shape $tag"
    18862470        SendCmd "glyphs normscale 0 $tag"
    18872471        SendCmd "glyphs gscale $settings(-gscale) $tag"
     
    18892473        #SendCmd "glyphs ccolor [Color2RGB $settings(-color)] $tag"
    18902474        #SendCmd "glyphs colormode ccolor {} $tag"
     2475        SendCmd "glyphs gorient 0 {} $tag"
    18912476        SendCmd "glyphs smode vcomp {} $tag"
    18922477        SendCmd "glyphs opacity $settings(-opacity) $tag"
    18932478        SendCmd "glyphs visible $settings(-visible) $tag"
    1894         set _haveSpheres 1
     2479        set _settings(glyphs-wireframe) $settings(-wireframe)
     2480        set _haveGlyphs 1
     2481    } elseif { $type == "molecule" } {
     2482        array set settings {
     2483            -color \#808080
     2484            -gscale 1
     2485            -edges 0
     2486            -edgecolor black
     2487            -linewidth 1.0
     2488            -opacity 1.0
     2489            -wireframe 0
     2490            -lighting 1
     2491            -visible 1
     2492        }
     2493        array set settings $style
     2494        SendCmd "molecule add $tag"
     2495        SendCmd "molecule opacity $settings(-opacity) $tag"
     2496        SendCmd "molecule visible $settings(-visible) $tag"
     2497        SendCmd "molecule rscale van_der_waals $tag"
     2498        set _settings(molecule-wireframe) $settings(-wireframe)
     2499        set _haveMolecules 1
    18952500    } else {
    18962501        array set settings {
     
    19072512        SendCmd "polydata add $tag"
    19082513        SendCmd "polydata visible $settings(-visible) $tag"
    1909         set _volume(visible) $settings(-visible)
    1910     }
    1911     if { $type != "spheres" } {
     2514        set _settings(mesh-visible) $settings(-visible)
    19122515        SendCmd "polydata edges $settings(-edges) $tag"
    1913         set _volume(edges) $settings(-edges)
     2516        set _settings(mesh-edges) $settings(-edges)
    19142517        SendCmd "polydata color [Color2RGB $settings(-color)] $tag"
    19152518        SendCmd "polydata lighting $settings(-lighting) $tag"
    1916         set _volume(lighting) $settings(-lighting)
     2519        set _settings(mesh-lighting) $settings(-lighting)
    19172520        SendCmd "polydata linecolor [Color2RGB $settings(-edgecolor)] $tag"
    19182521        SendCmd "polydata linewidth $settings(-linewidth) $tag"
    19192522        SendCmd "polydata opacity $settings(-opacity) $tag"
    1920         set _volume(opacity) $settings(-opacity)
     2523        set _settings(mesh-opacity) $settings(-opacity)
    19212524        SendCmd "polydata wireframe $settings(-wireframe) $tag"
    1922         set _volume(wireframe) $settings(-wireframe)
    1923     }
    1924     set _volume(opacity) [expr $settings(-opacity) * 100.0]
     2525        set _settings(mesh-wireframe) $settings(-wireframe)
     2526    }
     2527    set _settings(mesh-opacity) [expr $settings(-opacity) * 100.0]
    19252528    SetColormap $dataobj $comp
    19262529}
     
    19412544# ----------------------------------------------------------------------
    19422545itcl::body Rappture::VtkViewer::ReceiveLegend { colormap title vmin vmax size } {
    1943     #puts stderr "ReceiveLegend colormap=$colormap title=$title range=$vmin,$vmax size=$size"
    19442546    set _limits(vmin) $vmin
    19452547    set _limits(vmax) $vmax
     
    19512553        }
    19522554        $_image(legend) configure -data $bytes
    1953         #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
    19542555        DrawLegend
    19552556    }
     
    20412642    # Make a swatch of the selected color
    20422643    if { [catch { $_image(legend) get 10 $imgY } pixel] != 0 } {
    2043         #puts stderr "out of range: $imgY"
    20442644        return
    20452645    }
     
    20542654    # Compute the value of the point
    20552655    set t [expr 1.0 - (double($imgY) / double($imgHeight-1))]
    2056     #puts stderr "t=$t x=$x y=$y imgY=$imgY"
    20572656    set value [expr $t * ($_limits(vmax) - $_limits(vmin)) + $_limits(vmin)]
    20582657    set tipx [expr $x + 15]
    20592658    set tipy [expr $y - 5]
    2060     #puts stderr "tipx=$tipx tipy=$tipy x=$x y=$y"
    20612659    Rappture::Tooltip::text $c "$_title $value"
    20622660    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy   
     
    20942692    }
    20952693}
     2694
  • branches/nanovis2/gui/scripts/vtkvolumeviewer.tcl

    r2792 r3175  
    222222    # Initialize the view to some default parameters.
    223223    array set _view {
    224         qw              1
    225         qx              0
    226         qy              0
    227         qz              0
     224        qw              0.853553
     225        qx              -0.353553
     226        qy              0.353553
     227        qz              0.146447
    228228        zoom            1.0
    229229        xpan            0
     
    11851185        "reset" {
    11861186            array set _view {
    1187                 qw      1
    1188                 qx      0
    1189                 qy      0
    1190                 qz      0
     1187                qw      0.853553
     1188                qx      -0.353553
     1189                qy      0.353553
     1190                qz      0.146447
    11911191                zoom    1.0
    11921192                xpan   0
  • branches/nanovis2/gui/scripts/xyresult.tcl

    r2811 r3175  
    283283        -param ""
    284284    }
     285    # Override the defaults with first the <style> specified and then the
     286    # settings list passed into this routoue.
     287    array set params [$dataobj hints style]
    285288    foreach {opt val} $settings {
    286289        if {![info exists params($opt)]} {
     
    299302            set _autoColorI 0
    300303        }
    301         set color [lindex $itk_option(-autocolors) $_autoColorI]
     304        set color [lindex $itk_option(-autocolors) $_autoColorI]
    302305        if { "" == $color} {
    303306            set color black
     
    694697                set color $_dataobj2color($dataobj)
    695698            } else {
    696                 set color [$dataobj hints color]
    697                 if {"" == $color} {
    698                     set color black
    699                 }
     699                set color black
    700700            }
    701701            if {[info exists _dataobj2width($dataobj)]} {
     
    704704                set lwidth 2
    705705            }
    706 
    707706            if {[info exists _dataobj2dashes($dataobj)]} {
    708707                set dashes $_dataobj2dashes($dataobj)
     
    710709                set dashes ""
    711710            }
    712 
    713711            if {([$xv length] <= 1) || ($lwidth == 0)} {
    714712                set sym square
  • branches/nanovis2/gui/src/Makefile.in

    r2743 r3175  
    5151OBJS            = \
    5252                RapptureGUI_Init.o \
     53                RpCanvHotspot.o \
    5354                RpCanvPlacard.o \
    5455                RpDiffview.o \
  • branches/nanovis2/gui/src/RapptureGUI_Init.c

    r2717 r3175  
    2323
    2424extern Tcl_AppInitProc Rappturegui_Init;
     25extern Tcl_AppInitProc RpCanvHotspot_Init;
    2526extern Tcl_AppInitProc RpCanvPlacard_Init;
     27extern Tcl_AppInitProc RpConvertDxToVtk_Init;
    2628extern Tcl_AppInitProc RpDiffview_Init;
    2729
     
    4850        return TCL_ERROR;
    4951    }
     52    if (RpCanvHotspot_Init(interp) != TCL_OK) {
     53        return TCL_ERROR;
     54    }
    5055    return TCL_OK;
    5156}
  • branches/nanovis2/gui/src/RpDiffview.c

    r2310 r3175  
    27742774        layoutPtr->lines = (DiffviewLayoutLine*)ckalloc(
    27752775            (unsigned)(layoutPtr->numLines * sizeof(DiffviewLayoutLine)));
     2776        layoutPtr->maxLines = layoutPtr->numLines;
    27762777    }
    27772778    layoutPtr->numLines = 0;
  • branches/nanovis2/lang/Makefile.in

    r2709 r3175  
    2121MEX             = @MEX@
    2222OCTAVE          = @OCTAVE_VERSION@
    23 JAVAC           = @JAVAC@
     23JAVA_INC_DIR    = @JAVA_INC_DIR@
    2424R               = @R@
    2525
     
    4242  LANGS += octave
    4343endif
    44 ifneq ($(JAVAC),)
     44ifneq ($(JAVA_INC_DIR),)
    4545  LANGS += java
    4646endif
  • branches/nanovis2/lang/python/Makefile.in

    r2061 r3175  
    4242        $(LN_S) $(srcdir2)/Rappture/*.cc build/tmp
    4343
    44 install:
     44install: all
    4545        $(MKDIR_P) -m 0755 $(pythonlib)
    4646        $(PYTHON) setup.py install --install-lib=$(pythonlib)
  • branches/nanovis2/lang/python/Rappture/PyRpLibrary.cc

    r1527 r3175  
    1111#include <Python.h>
    1212#include <RpLibrary.h>
     13#include <ctype.h>
     14
     15#define TRUE 1
     16#define FALSE 0
     17
     18#define RP_OK   0
     19#define RP_ERROR 1
    1320
    1421#ifndef Py_RETURN_NONE
     
    2835
    2936static PyObject *ErrorObject;
    30 RpLibrary * RpLibraryObject_AsLibrary(PyObject *lib);
     37static RpLibrary * RpLibraryObject_AsLibrary(PyObject *lib);
    3138static PyObject * RpLibraryObject_FromLibrary(RpLibrary *lib);
    32 int boolAsInt(const char *inVal, int *outVal);
    33 int boolIntFromPyObject ( PyObject *inPyObj, const char *defaultVal,
    34                             const char *argName, int *boolVal);
    35 int getArgCount ( PyObject *args, PyObject *keywds, int *argc);
     39static int StringToBoolean(const char *inVal, int *resultPtr);
     40static int PyObjectToBoolean(PyObject *objPtr, const char *defaultVal,
     41        const char *argName, int *resultPtr);
     42static int getArgCount(PyObject *args, PyObject *keywds, int *argc);
    3643
    3744typedef struct {
     
    3946    RpLibrary *lib;
    4047} RpLibraryObject;
     48
     49
     50static int
     51getArgCount(PyObject *args, PyObject *keywds, int *argc)
     52{
     53    int args_cnt = 0;
     54    int keywds_cnt = 0;
     55
     56    if (argc == NULL) {
     57        // incorrect use of function
     58        // argc cannot be null
     59        PyErr_Format(PyExc_ValueError,"getArgCount(): argc is NULL");
     60        return RP_ERROR;
     61    }
     62    if (args != NULL) {
     63        if (!PyTuple_Check(args)) {
     64            PyErr_Format(PyExc_TypeError,
     65                "getArgCount(): \'args\' should be a PyTuple");
     66            return RP_ERROR;
     67        }
     68        args_cnt = PyTuple_Size(args);
     69    }
     70    if (keywds != NULL) {
     71        if (!PyDict_Check(keywds)) {
     72            PyErr_Format(PyExc_TypeError,
     73                "getArgCount(): \'keywds\' should be a PyDict");
     74            return RP_ERROR;
     75        }
     76        keywds_cnt = PyDict_Size(keywds);
     77    }
     78    *argc = args_cnt + keywds_cnt;
     79    return RP_OK;
     80}
     81
     82/*
     83 *  StringToBoolean --
     84 *
     85 *  represent a boolean string as an integer.
     86 *
     87 *  outVal set to 1 if the boolean value inVal could
     88 *  be associated with any of the following strings:
     89 *  "yes", "on", "true", "1".
     90 *
     91 *  outVal set to 0 if the boolean value inVal could
     92 *  be associated with any of the following strings:
     93 *  "no", "off", "false", "0".
     94 *
     95 *  returns a status integer to tell if the operation
     96 *  was successful (0) of if there was an error (!0)
     97 *
     98 *  note: string comparisons are case insensitive.
     99 */
     100
     101static int
     102StringToBoolean(const char *string, int *resultPtr)
     103{
     104    char c;
     105
     106    if ((string == NULL) || (resultPtr == NULL) ) {
     107        PyErr_Format(PyExc_TypeError,
     108                     "incorrect use of StringToBoolean(inVal,outVal)");
     109        return RP_ERROR;
     110    }
     111    c = tolower(string[0]);
     112    if (((c == 'y') && (strcasecmp(string, "yes") == 0)) ||
     113        ((c == 'o') && (strcasecmp(string, "on") == 0)) ||
     114        ((c == 't') && (strcasecmp(string, "true") == 0)) ||
     115        ((c == '1') && (strcasecmp(string, "1") == 0))) {
     116        *resultPtr = TRUE;
     117    } else if (((c == 'n') && (strcasecmp(string, "no") == 0)) ||
     118               ((c == 'o') && (strcasecmp(string, "off") == 0)) ||
     119               ((c == 'f') && (strcasecmp(string, "false") == 0)) ||
     120               ((c == '0') && (strcasecmp(string, "0") == 0))) {
     121        *resultPtr = FALSE;
     122    } else {
     123        PyErr_Format(PyExc_ValueError,
     124            "unrecognized input: %s: should be one of: \'yes\',\'true\',\'on\',\'1\',1,True,\'no\',\'false\',\'off\',\'0\',0,False", string);
     125        return RP_ERROR;
     126    }
     127    return RP_OK;
     128}
     129
     130static int
     131PyObjectToBoolean(PyObject *objPtr, const char *defValue, const char *argName,
     132                  int *resultPtr)
     133{
     134    int value;
     135
     136    value = FALSE;                      // Suppress compiler warning.
     137    if ((defValue == NULL) || (argName == NULL) || (resultPtr == NULL)) {
     138        // incorrect use of function
     139        PyErr_Format(PyExc_ValueError,
     140            "PyObjectToBoolean: defValue or argName or resultPtr is NULL");
     141        return RP_ERROR;
     142    }
     143    if (objPtr == NULL) {
     144        return StringToBoolean(defValue, resultPtr);
     145    }
     146    if (PyBool_Check(objPtr)) {
     147        value = PyObject_IsTrue(objPtr);
     148        if (value < 0) {
     149             PyErr_Format(PyExc_ValueError,
     150                "PyObjectToBoolean: bad boolean object");
     151            return RP_ERROR;
     152        }
     153    } else if (PyLong_Check(objPtr)) {
     154        long l;
     155
     156        l = PyLong_AsLong(objPtr);
     157        value = (l == 0) ? FALSE : TRUE;
     158    } else if (PyInt_Check(objPtr)) {
     159        long l;
     160
     161        l = PyInt_AsLong(objPtr);
     162        value = (l == 0) ? FALSE : TRUE;
     163    } else if (PyFloat_Check(objPtr)) {
     164        double d;
     165
     166        d = PyFloat_AS_DOUBLE(objPtr);
     167        value = (d == 0.0) ? FALSE : TRUE;
     168    } else if (PyString_Check(objPtr)) {
     169        const char *string;
     170       
     171        string = PyString_AsString(objPtr);
     172        if (string == NULL) {
     173            PyErr_Format(PyExc_TypeError,
     174                "bad value: %s: cannot convert to string",argName);
     175            return RP_ERROR;
     176        }
     177        return StringToBoolean(string, resultPtr);
     178    } else {
     179        PyErr_Format(PyExc_TypeError,
     180                "unknown python type for %s", argName);
     181        return RP_ERROR;
     182    }
     183    *resultPtr = value;
     184    return RP_OK;
     185}
    41186
    42187/*
     
    46191 * correct initialization, use RpLibraryObject_IsValid.
    47192 */
    48 
    49 int
    50 RpLibraryObject_Check(PyObject *o)
    51 {
    52     int retval = 0;
    53 
    54     if (o != NULL) {
    55         if (    (*(o->ob_type->tp_name) == 'R')
    56              && (strcmp(o->ob_type->tp_name,"Rappture.library") == 0) ) {
    57             retval = 1;
    58         }
    59     }
    60 
    61     return retval;
     193static int
     194RpLibraryObject_Check(PyObject *objPtr)
     195{
     196    if (objPtr == NULL) {
     197        return FALSE;
     198    }
     199    if (strcmp(objPtr->ob_type->tp_name, "Rappture.library") != 0) {
     200        return FALSE;
     201    }
     202    return TRUE;
    62203}
    63204
     
    70211 * in by the user is a valid Rappture.library object
    71212 */
    72 
    73 int
    74 RpLibraryObject_IsValid(PyObject *o)
    75 {
    76     int retval = 0;
    77 
    78     if (o != NULL) {
    79         if (RpLibraryObject_Check(o)) {
    80             if ( ((RpLibraryObject *)o)->lib != NULL ) {
    81                 retval = 1;
    82             }
    83         }
    84     }
    85 
    86     return retval;
     213static int
     214RpLibraryObject_IsValid(PyObject *objPtr)
     215{
     216    if (objPtr == NULL) {
     217        return FALSE;                   // Passed a NULL pointer. Should
     218                                        // probably segfault.
     219    }
     220    if (!RpLibraryObject_Check(objPtr)) {
     221        return FALSE;                   // Not a rappture library object type.
     222    }
     223    if (((RpLibraryObject *)objPtr)->lib == NULL) {
     224        return FALSE;                   // Is a rappture library object, but
     225                                        // doesn't contain a valid library.
     226    }
     227    return TRUE;
    87228}
    88229
    89230static PyObject *
    90 RpLibraryObject_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
     231NewProc(PyTypeObject *type, PyObject *args, PyObject *kwds)
    91232{
    92233    RpLibraryObject *self = NULL;
     
    95236    if (self != NULL) {
    96237        self->lib = NULL;
    97     }
    98     else {
    99         PyErr_SetString(PyExc_RuntimeError,"trouble creating new RpLibraryObject");
    100     }
    101 
     238    } else {
     239        PyErr_SetString(PyExc_RuntimeError,
     240                "trouble creating new RpLibraryObject");
     241    }
    102242    return (PyObject *)self;
    103243}
    104244
    105245static int
    106 RpLibraryObject_init(RpLibraryObject *self, PyObject *args, PyObject *kwds)
    107 {
    108     PyObject *inObj = NULL;
    109     char *filename = NULL;
    110     int retVal = 1;
    111 
    112     if (!PyArg_ParseTuple(args, "|O", &inObj)) {
     246InitProc(RpLibraryObject *self, PyObject *args, PyObject *kwds)
     247{
     248    PyObject *objPtr;
     249
     250    objPtr = NULL;
     251    if (!PyArg_ParseTuple(args, "|O", &objPtr)) {
    113252        PyErr_Format(PyExc_TypeError,
    114253            "library() takes at most 1 argument, a file name or a Rappture Library Object");
     
    116255    }
    117256
    118     if (inObj != NULL) {
    119         if (PyString_Check(inObj)) {
    120             filename = PyString_AsString(inObj);
     257    if (objPtr != NULL) {
     258        if (PyString_Check(objPtr)) {
     259            char *filename;
     260
     261            filename = PyString_AsString(objPtr);
    121262            if (filename == NULL) {
    122263                PyErr_Format(PyExc_ValueError,"a file name is required");
    123264            }
    124265            self->lib = new RpLibrary(std::string(filename));
    125         }
    126         else if (RpLibraryObject_IsValid(inObj)) {
    127             self->lib = new RpLibrary( *(RpLibraryObject_AsLibrary(inObj)) );
    128         }
    129         else if (RpLibraryObject_Check(inObj)) {
     266        } else if (RpLibraryObject_IsValid(objPtr)) {
     267            self->lib = new RpLibrary( *(RpLibraryObject_AsLibrary(objPtr)) );
     268        } else if (RpLibraryObject_Check(objPtr)) {
    130269            self->lib = new RpLibrary();
    131         }
    132         else {
     270        } else {
    133271            PyErr_Format(PyExc_TypeError,"unrecognized object type");
    134272            return -1;
    135273        }
    136     }
    137     else {
     274    } else {
    138275        self->lib = new RpLibrary();
    139276    }
    140277
    141     return retVal;
     278    return 1;
    142279}
    143280
    144281static void
    145 RpLibraryObject_dealloc(RpLibraryObject *self)
     282FreeProc(RpLibraryObject *self)
    146283{
    147284    if (self) {
     
    153290}
    154291
    155 PyDoc_STRVAR(RpLibraryObject_copy_doc,
     292PyDoc_STRVAR(CopyProcDoc,
    156293"copy (topath, frompath [, fromobj=$self]) -> None, copies data\n\
    157294\n\
     
    170307
    171308static PyObject *
    172 RpLibraryObject_copy(RpLibraryObject *self, PyObject *args, PyObject *keywds)
     309CopyProc(RpLibraryObject *self, PyObject *args, PyObject *keywds)
    173310{
    174311    char *topath = (char *)"";
    175312    char *frompath = (char *)"";
    176313    int argc = 0;
    177     int status = 0;
    178314    PyObject *fromobj = (PyObject *) self;
    179315
     
    191327    }
    192328
    193     status = getArgCount(args,keywds,&argc);
    194     if (status != 0) {
     329    if (getArgCount(args,keywds,&argc) != RP_OK) {
    195330        // trouble ensues
    196331        // error message was set in getArgCount()
     
    234369}
    235370
    236 PyDoc_STRVAR(RpLibraryObject_element_doc,
     371PyDoc_STRVAR(ElementProcDoc,
    237372"element ([path=\'\'][, as=\'object\']) -> returns string or Rappture Library Object\n\
    238373\n\
     
    253388
    254389static PyObject *
    255 RpLibraryObject_element(RpLibraryObject *self, PyObject *args, PyObject *keywds)
     390ElementProc(RpLibraryObject *self, PyObject *args, PyObject *keywds)
    256391{
    257392    char* path = (char *)"";
     
    260395    PyObject* retVal = NULL;
    261396    int argc = 0;
    262     int status = 0;
    263397
    264398    static char *kwlist[] = {
     
    274408    }
    275409
    276     status = getArgCount(args,keywds,&argc);
    277     if (status != 0) {
     410    if (getArgCount(args,keywds,&argc) != RP_OK) {
    278411        // trouble ensues
    279412        // error message was set in getArgCount()
     
    299432
    300433    if (retlib != NULL) {
    301         if (   (as == NULL)
    302             || ((*as == 'o') && (strcmp("object",as) == 0)) ) {
     434        if ((as == NULL) || ((*as == 'o') && (strcmp("object",as) == 0)) ) {
    303435            // tested with ElementTests.testArguments_PathArg()
    304436            retVal = RpLibraryObject_FromLibrary(retlib);
    305         }
    306         else if ((*as == 'c') && (strcmp("component",as) == 0)) {
     437        } else if ((*as == 'c') && (strcmp("component",as) == 0)) {
    307438            // tested with ElementTests.testArguments_TwoArgs()
    308439            retVal = PyString_FromString(retlib->nodeComp().c_str());
    309         }
    310         else if ((*as == 'i') && (strcmp("id",as) == 0)) {
     440        } else if ((*as == 'i') && (strcmp("id",as) == 0)) {
    311441            // tested with ElementTests.testArguments_AsId()
    312442            retVal = PyString_FromString(retlib->nodeId().c_str());
    313         }
    314         else if ((*as == 't') && (strcmp("type",as) == 0)) {
     443        } else if ((*as == 't') && (strcmp("type",as) == 0)) {
    315444            // tested with ElementTests.testArguments_AsKeywordArgs()
    316445            retVal = PyString_FromString(retlib->nodeType().c_str());
    317         }
    318         else if ((*as == 'p') && (strcmp("path",as) == 0)) {
     446        } else if ((*as == 'p') && (strcmp("path",as) == 0)) {
    319447            // tested with ElementTests.testArguments_TwoKeywordArgs()
    320448            retVal = PyString_FromString(retlib->nodePath().c_str());
    321         }
    322         else {
     449        } else {
    323450            // tested with ElementTests.testArguments_UnrecognizedAs()
    324451            PyErr_Format(PyExc_ValueError,
     
    331458
    332459
    333 PyDoc_STRVAR(RpLibraryObject_get_doc,
     460PyDoc_STRVAR(GetProcDoc,
    334461"get ([path=\'\'][, decode=\'True\']) -> returns data at \'path\' as string\n\
    335462\n\
     
    341468
    342469static PyObject *
    343 RpLibraryObject_get(RpLibraryObject *self, PyObject *args, PyObject *keywds)
     470GetProc(RpLibraryObject *self, PyObject *args, PyObject *keywds)
    344471{
    345472    char* path = (char *)"";
    346473
    347474    PyObject* decode = NULL;
    348     int decodeVal = 0;
     475    int decodeFlag;
    349476
    350477    PyObject* retVal = NULL;
     
    353480
    354481    int argc = 0;
    355     int status = 0;
    356482
    357483    static char *kwlist[] = {
     
    367493    }
    368494
    369     status = getArgCount(args,keywds,&argc);
    370     if (status != 0) {
     495    if (getArgCount(args,keywds,&argc) != RP_OK) {
    371496        // trouble ensues
    372497        // error message was set in getArgCount()
     
    387512        return NULL;
    388513    }
    389 
    390     status = boolIntFromPyObject(decode,"yes","decode",&decodeVal);
    391     if (status != 0) {
     514    if (PyObjectToBoolean(decode,"yes", "decode", &decodeFlag) != RP_OK) {
    392515        // tested with GetTests.testArgumentsDecodeError()
    393516        return NULL;
    394517    }
    395 
    396     if (decodeVal == 1) {
    397         // tested with GetTests.testArgumentsDecode()
    398         // tested with GetTests.testArgumentsDecodeYes()
    399         // tested with GetTests.testArgumentsDecodeTrue)
    400         // tested with GetTests.testArgumentsDecodeOn()
    401         // tested with GetTests.testArgumentsDecode1Str()
    402         // tested with GetTests.testArgumentsDecode1Int()
     518    if (decodeFlag) {
    403519        retValStr = self->lib->get(std::string(path));
    404520        retVal = PyString_FromStringAndSize(retValStr.c_str(),retValStr.size());
    405     }
    406     else {
    407         // tested with GetTests.testArgumentsNoDecodeNo()
    408         // tested with GetTests.testArgumentsNoDecodeFalse()
    409         // tested with GetTests.testArgumentsNoDecodeOff()
    410         // tested with GetTests.testArgumentsNoDecode0Str()
    411         // tested with GetTests.testArgumentsNoDecode0Int()
     521    } else {
    412522        retValBuf = self->lib->getData(std::string(path));
    413523        retVal = PyString_FromStringAndSize(retValBuf.bytes(),retValBuf.size());
    414524    }
    415 
    416525    return (PyObject *)retVal;
    417526}
    418527
    419 PyDoc_STRVAR(RpLibraryObject_parent_doc,
     528#ifdef notdef
     529PyDoc_STRVAR(ParentProcDoc,
    420530"parent ([path=\'\'][, as=\'object\']) -> returns string or Rappture Library Object\n\
    421531\n\
     
    433543
    434544static PyObject *
    435 RpLibraryObject_parent(RpLibraryObject *self, PyObject *args, PyObject *keywds)
     545ParentProc(RpLibraryObject *self, PyObject *args, PyObject *keywds)
    436546{
    437547    char* path = (char *)"";
     
    440550    PyObject* retVal = NULL;
    441551    int argc = 0;
    442     int status = 0;
    443552
    444553    static char *kwlist[] = {
     
    448557    };
    449558
    450     status = getArgCount(args,keywds,&argc);
    451     if (status != 0) {
     559    if (getArgCount(args,keywds,&argc) != RP_OK) {
    452560        // trouble ensues
    453561        // error message was set in getArgCount()
     
    459567        return NULL;
    460568    }
    461 
    462569    if (!PyArg_ParseTupleAndKeywords(args, keywds, "|ss",
    463570            kwlist, &path, &as)) {
    464571        /* incorrect input values */
    465         PyErr_SetString(PyExc_TypeError,"parent ([path=\'\'][, as=\'object\'])");
    466         return NULL;
    467     }
    468 
     572        PyErr_SetString(PyExc_TypeError,
     573                        "parent ([path=\'\'][, as=\'object\'])");
     574        return NULL;
     575    }
    469576    if (self->lib) {
    470577        retlib = self->lib->parent(std::string(path));
    471     }
    472     else {
     578    } else {
    473579        PyErr_SetString(PyExc_RuntimeError,
    474580            "incorrectly initialized Rappture Library Object");
     
    477583
    478584    if (retlib != NULL) {
    479         if (   (as == NULL)
    480             || ((*as == 'o') && (strcmp("object",as) == 0))
    481            ) {
     585        if ((as == NULL) || ((*as == 'o') && (strcmp("object",as) == 0))) {
    482586            retVal = RpLibraryObject_FromLibrary(retlib);
    483         }
    484         else if ((*as == 'c') && (strcmp("component",as) == 0)) {
     587        } else if ((*as == 'c') && (strcmp("component",as) == 0)) {
    485588            retVal = PyString_FromString(retlib->nodeComp().c_str());
    486         }
    487         else if ((*as == 'i') && (strcmp("id",as) == 0)) {
     589        } else if ((*as == 'i') && (strcmp("id",as) == 0)) {
    488590            retVal = PyString_FromString(retlib->nodeId().c_str());
    489         }
    490         else if ((*as == 't') && (strcmp("type",as) == 0)) {
     591        } else if ((*as == 't') && (strcmp("type",as) == 0)) {
    491592            retVal = PyString_FromString(retlib->nodeType().c_str());
    492         }
    493         else if ((*as == 'p') && (strcmp("path",as) == 0)) {
     593        } else if ((*as == 'p') && (strcmp("path",as) == 0)) {
    494594            retVal = PyString_FromString(retlib->nodePath().c_str());
    495         }
    496         else {
     595        } else {
    497596            PyErr_Format(PyExc_ValueError,
    498597                "parent() \'as\' arg must be \'object\' or \'component\' or \'id\' or \'type\' or \'path\'");
    499598        }
    500599    }
    501 
    502600    return (PyObject *)retVal;
    503601}
    504 
    505 PyDoc_STRVAR(RpLibraryObject_put_doc,
     602#endif
     603
     604PyDoc_STRVAR(PutProcDoc,
    506605"put (path=\'\', value=\'\'[,id=None][,append=False][,type=\'string\'][,compress=False]) -> None\n\
    507606\n\
     
    532631
    533632static PyObject *
    534 RpLibraryObject_put(RpLibraryObject *self, PyObject *args, PyObject *keywds)
     633PutProc(RpLibraryObject *self, PyObject *args, PyObject *keywds)
    535634{
    536635    char *path = (char *)"";
    537636
    538     PyObject *value = NULL;
    539     PyObject *valueStrObj = NULL;
    540     char *value_char = NULL;
    541     Py_ssize_t value_len = 0;
    542 
     637    PyObject *valueObjPtr, *compressObjPtr, *appendObjPtr, *strObjPtr;
    543638    char *id = NULL;
    544 
    545     PyObject* append = NULL;
    546     int appendInt = 0;
    547 
     639    int appendFlag, compressFlag;
    548640    char *type = (char *)"string";
    549 
    550     PyObject* compress = NULL;
    551     int compressInt = 0;
    552 
    553641    int argc = 0;
    554     int status = 0;
    555642
    556643    static char *kwlist[] = {
     
    563650        NULL
    564651    };
    565 
     652    appendFlag = compressFlag = FALSE;
     653    strObjPtr = appendObjPtr = valueObjPtr = compressObjPtr = NULL;
    566654    if (self->lib == NULL) {
    567655        PyErr_Format(PyExc_RuntimeError,
     
    570658    }
    571659
    572     status = getArgCount(args,keywds,&argc);
    573     if (status != 0) {
    574         // trouble ensues
    575         // error message was set in getArgCount()
    576         return NULL;
    577     }
    578 
     660    if (getArgCount(args,keywds,&argc) != RP_OK) {
     661        return NULL;
     662    }
    579663    if (argc > 6) {
    580         // tested with PutTests.testArguments_TooManyArgs()
    581664        PyErr_Format(PyExc_TypeError,
    582665            "put() takes at most 6 arguments (%i given)",argc);
    583666        return NULL;
    584667    }
    585 
    586668    if (argc < 2) {
    587         // tested with PutTests.testArguments_NotEnoughArgs()
    588669        PyErr_Format(PyExc_TypeError,
    589670            "put() takes at least 2 arguments (%i given)",argc);
    590671        return NULL;
    591672    }
    592 
    593     if (!PyArg_ParseTupleAndKeywords(args, keywds, "sO|sOsO",
    594             kwlist, &path, &value, &id, &append, &type, &compress)) {
    595         // tested with PutTests.testArguments_ArgsWrongType2()
    596         PyErr_Format(PyExc_TypeError, "incorrect arguments: put(path=\'\',value=\'\'[,id=None][,append=False][,type=\'string\'][,compress=False])");
    597         return NULL;
    598     }
    599 
    600     if (value == NULL) {
     673    if (!PyArg_ParseTupleAndKeywords(args, keywds, "sO|sOsO", kwlist, &path,
     674        &valueObjPtr, &id, &appendObjPtr, &type, &compressObjPtr)) {
     675        return NULL;
     676    }
     677
     678    if (valueObjPtr == NULL) {
    601679        PyErr_Format(PyExc_ValueError, "put()'s \'value\' arg is required");
    602680        return NULL;
    603681    }
    604682
    605     valueStrObj = PyObject_Str(value);
    606 
    607     status = boolIntFromPyObject(append,"no","append",&appendInt);
    608     if (status != 0) {
    609         // error message set inside of boolIntFromPyObject
    610         // tested with PutTests.testArguments_AppendValError()
    611         return NULL;
    612     }
    613     status = boolIntFromPyObject(compress,"no","compress",&compressInt);
    614     if (status != 0) {
    615         // error message set inside of boolIntFromPyObject
    616         // tested with PutTests.testArguments_CompressValError()
    617         return NULL;
    618     }
    619 
    620     if (RpLibraryObject_IsValid(value)) {
    621         // tested with PutTests.testPutObject()
    622         self->lib->put( std::string(path),
    623                         RpLibraryObject_AsLibrary(value), "", appendInt);
    624     }
    625     else if (valueStrObj != NULL) {
    626 
    627         if (PyString_AsStringAndSize(valueStrObj, &value_char, &value_len) == -1) {
    628             // user passed in an improper string
    629             // exception raised within fxn
     683    if (PyObjectToBoolean(appendObjPtr, "no"," append", &appendFlag) != RP_OK){
     684        return NULL;
     685    }
     686    if (PyObjectToBoolean(compressObjPtr, "no", "compress", &compressFlag)
     687        != RP_OK) {
     688        return NULL;
     689    }
     690
     691    strObjPtr = PyObject_Str(valueObjPtr);
     692    if (RpLibraryObject_IsValid(valueObjPtr)) {
     693        self->lib->put( std::string(path),
     694                RpLibraryObject_AsLibrary(valueObjPtr), "", appendFlag);
     695    } else if (strObjPtr != NULL) {
     696        char *string;
     697        Py_ssize_t length;
     698
     699        if (PyString_AsStringAndSize(strObjPtr, &string, &length) == -1) {
    630700            return NULL;
    631701        }
    632 
    633         if (   ( type == NULL )
    634             || ( (*type == 's') && (strcmp("string", type) == 0) ) ) {
    635             if (compress == 0) {
    636                 // tested with PutTests.testArgumentsCheckAppend()
    637                 // tested with PutTests.testArgumentsCheckAppendYes()
     702        if ((type == NULL) || ((*type=='s') && (strcmp("string", type) == 0))){
     703            if (compressFlag == 0) {
    638704                self->lib->put( std::string(path),
    639                                 std::string(value_char), "", appendInt);
     705                                std::string(string), "", appendFlag);
     706            } else {
     707                self->lib->putData( std::string(path), string, length,
     708                        appendFlag);
    640709            }
    641             else {
    642                 // tested with PutTests.testArgumentsCheckTypeStringCompressYes()
    643                 self->lib->putData( std::string(path),
    644                                     value_char, value_len, appendInt);
    645             }
    646         }
    647         else if ( (*type == 'f') && (strcmp("file",type) == 0) ) {
    648             // tested with PutTests.testArgumentsCheckTypeFile()
    649             // tested with PutTests.testArgumentsCheckTypeFileCompressTrue()
    650             // tested with PutTests.testArgumentsCheckTypeFileCompressTrueNoDecode()
     710        } else if ((*type == 'f') && (strcmp("file",type) == 0)) {
    651711            self->lib->putFile( std::string(path),
    652                                 std::string(PyString_AsString(valueStrObj)),
    653                                 compressInt,appendInt);
    654         }
    655         else {
    656             // tested with PutTests.testArgumentsCheckTypeError()
     712                                std::string(PyString_AsString(strObjPtr)),
     713                                compressFlag, appendFlag);
     714        } else {
    657715            PyErr_Format(PyExc_ValueError,
    658716                "\'type\' arg must be \'string\' or \'file\'");
    659717            return NULL;
    660718        }
    661     }
    662     else {
     719    } else {
    663720        PyErr_Format(PyExc_TypeError,
    664721            "put()'s \'value\' arg must be a string or Rappture Library Object");
    665722        return NULL;
    666723    }
    667 
    668724    Py_RETURN_NONE;
    669725}
    670726
    671 PyDoc_STRVAR(RpLibraryObject_xml_doc,
     727PyDoc_STRVAR(XmlProcDoc,
    672728"xml () -> returns xml string\n\
    673729\n\
     
    677733
    678734static PyObject*
    679 RpLibraryObject_xml(RpLibraryObject *self)
    680 {
    681     PyObject *retStr = NULL;
    682 
     735XmlProc(RpLibraryObject *self)
     736{
    683737    if (self->lib == NULL) {
    684738        PyErr_Format(PyExc_RuntimeError,
    685739            "self uninitialized Rappture Library Object");
    686740    }
    687 
    688     retStr = PyString_FromString(self->lib->xml().c_str());
    689 
    690     return (PyObject *)retStr;
    691 }
    692 
    693 PyDoc_STRVAR(RpLibraryObject_result_doc,
     741    return PyString_FromString(self->lib->xml().c_str());
     742}
     743
     744PyDoc_STRVAR(ResultProcDoc,
    694745"result ([status=0]) -> None, send results back to graphical user interface\n\
    695746\n\
     
    699750
    700751static PyObject*
    701 RpLibraryObject_result(RpLibraryObject *self, PyObject *args, PyObject *keywds)
     752ResultProc(RpLibraryObject *self, PyObject *args, PyObject *keywds)
    702753{
    703754    int argc = 0;
     
    715766    }
    716767
    717     status = getArgCount(args,keywds,&argc);
    718     if (status != 0) {
     768    if (getArgCount(args,keywds,&argc) != RP_OK) {
    719769        // trouble ensues
    720770        // error message was set in getArgCount()
     
    742792static PyMethodDef RpLibraryObject_methods[] = {
    743793
    744     {"copy", (PyCFunction)RpLibraryObject_copy, METH_VARARGS|METH_KEYWORDS,
    745         RpLibraryObject_copy_doc},
    746 
    747 /*
    748     {"children", (PyCFunction)RpLibraryObject_children, METH_VARARGS|METH_KEYWORDS,
    749         RpLibraryObject_children_doc},
    750 */
    751 
    752     {"element", (PyCFunction)RpLibraryObject_element, METH_VARARGS|METH_KEYWORDS,
    753         RpLibraryObject_element_doc},
    754 
    755     {"get", (PyCFunction)RpLibraryObject_get, METH_VARARGS|METH_KEYWORDS,
    756         RpLibraryObject_get_doc},
    757 
    758 /*
    759     {"parent", (PyCFunction)RpLibraryObject_parent, METH_VARARGS|METH_KEYWORDS,
    760         RpLibraryObject_put_doc},
    761 */
    762 
    763     {"put", (PyCFunction)RpLibraryObject_put, METH_VARARGS|METH_KEYWORDS,
    764         RpLibraryObject_put_doc},
    765 
    766 /*
    767     {"remove", (PyCFunction)RpLibraryObject_remove, METH_VARARGS|METH_KEYWORDS,
    768         RpLibraryObject_remove_doc},
    769 */
    770 
    771     {"xml", (PyCFunction)RpLibraryObject_xml, METH_NOARGS,
    772         RpLibraryObject_xml_doc},
    773 
    774     {"result", (PyCFunction)RpLibraryObject_result, METH_VARARGS|METH_KEYWORDS,
    775         RpLibraryObject_result_doc},
     794    {"copy", (PyCFunction)CopyProc, METH_VARARGS|METH_KEYWORDS, CopyProcDoc},
     795
     796#ifdef notdef
     797    {"children", (PyCFunction)ChildrenProc, METH_VARARGS|METH_KEYWORDS,
     798        ChildrenProcDoc},
     799#endif
     800
     801    {"element", (PyCFunction)ElementProc, METH_VARARGS|METH_KEYWORDS,
     802        ElementProcDoc},
     803
     804    {"get", (PyCFunction)GetProc, METH_VARARGS|METH_KEYWORDS,
     805        GetProcDoc},
     806
     807#ifdef notdef
     808    {"parent", (PyCFunction)ParentProc, METH_VARARGS|METH_KEYWORDS,
     809                ParentProcDoc},
     810#endif
     811
     812    {"put", (PyCFunction)PutProc, METH_VARARGS|METH_KEYWORDS, PutProcDoc},
     813
     814#ifdef notdef
     815    {"remove", (PyCFunction)RemoveProc, METH_VARARGS|METH_KEYWORDS,
     816        RemoveProcDoc},
     817#endif
     818
     819    {"xml", (PyCFunction)XmlProc, METH_NOARGS, XmlProcDoc},
     820
     821    {"result", (PyCFunction)ResultProc, METH_VARARGS|METH_KEYWORDS,
     822        ResultProcDoc},
    776823
    777824    {NULL,        NULL}        /* sentinel */
     
    787834    0,                                    /*tp_itemsize*/
    788835    /* methods */
    789     (destructor)RpLibraryObject_dealloc,  /*tp_dealloc*/
     836    (destructor)FreeProc,               /*tp_dealloc*/
    790837    0,                                    /*tp_print*/
    791838    0,                                    /*tp_getattr*/
     
    818865    0,                                    /*tp_descr_set*/
    819866    0,                                    /*tp_dictoffset*/
    820     (initproc)RpLibraryObject_init,       /*tp_init*/
     867    (initproc)InitProc,                 /*tp_init*/
    821868    0,                                    /*tp_alloc*/
    822     RpLibraryObject_new,                  /*tp_new*/
     869    NewProc,                            /*tp_new*/
    823870    0,                                    /*tp_new*/
    824871};
     
    827874 * used to create a RpLibrary object from a PyObject
    828875 */
    829 RpLibrary *
     876static RpLibrary *
    830877RpLibraryObject_AsLibrary(PyObject *lib)
    831878{
     
    852899        if (self != NULL) {
    853900            self->lib = lib;
    854         }
    855         else {
     901        } else {
    856902            // raise error
    857903            PyErr_SetString(PyExc_RuntimeError,
    858                             "trouble creating new RpLibraryObject");
    859         }
    860     }
    861 
     904                "trouble creating new RpLibraryObject");
     905        }
     906    }
    862907    return (PyObject *)self;
    863 }
    864 
    865 /*
    866  *  int boolAsInt (inVal, outVal)
    867  *
    868  *  represent a boolean string as an integer.
    869  *
    870  *  outVal set to 1 if the boolean value inVal could
    871  *  be associated with any of the following strings:
    872  *  "yes", "on", "true", "1".
    873  *
    874  *  outVal set to 0 if the boolean value inVal could
    875  *  be associated with any of the following strings:
    876  *  "no", "off", "false", "0".
    877  *
    878  *  returns a status integer to tell if the operation
    879  *  was successful (0) of if there was an error (!0)
    880  *
    881  *  note: string comparisons are case insensitive.
    882  */
    883 
    884 int
    885 boolAsInt(const char *inVal, int *outVal)
    886 {
    887     int len = 0;
    888     int lcv = 0;
    889     int status = 1;
    890     char boolVal[7] = "\0\0\0\0\0\0";
    891 
    892     if ( (inVal == NULL) || (outVal == NULL) ) {
    893         PyErr_Format(PyExc_TypeError,"incorrect use of boolAsInt(inVal,outVal)");
    894         return status;
    895     }
    896 
    897     len = strlen(inVal);
    898 
    899     if (len > 5) {
    900         PyErr_Format(PyExc_ValueError,
    901             "unrecognized input: %s: should be one of: \'yes\',\'true\',\'on\',\'1\',1,True,\'no\',\'false\',\'off\',\'0\',0,False",boolVal);
    902         return status;
    903     }
    904 
    905     for (lcv = 0; lcv < len; lcv++) {
    906         boolVal[lcv] = tolower(inVal[lcv]);
    907     }
    908 
    909     if (
    910         ((*boolVal == 'y') && (strcmp("yes",boolVal) == 0))  ||
    911         ((*boolVal == 't') && (strcmp("true",boolVal) == 0)) ||
    912         ((*boolVal == 'o') && (strcmp("on",boolVal) == 0)) ||
    913         ((*boolVal == '1') && (strcmp("1",boolVal) == 0)) ) {
    914 
    915         status = 0;
    916         *outVal = 1;
    917     }
    918     else if (
    919         ((*boolVal == 'n') && (strcmp("no",boolVal) == 0))  ||
    920         ((*boolVal == 'f') && (strcmp("false",boolVal) == 0)) ||
    921         ((*boolVal == 'o') && (strcmp("off",boolVal) == 0)) ||
    922         ((*boolVal == '0') && (strcmp("0",boolVal) == 0)) ) {
    923 
    924         status = 0;
    925         *outVal = 0;
    926     }
    927     else {
    928         PyErr_Format(PyExc_ValueError,
    929             "unrecognized input: %s: should be one of: \'yes\',\'true\',\'on\',\'1\',1,True,\'no\',\'false\',\'off\',\'0\',0,False",boolVal);
    930         status = 1;
    931     }
    932 
    933     return status;
    934 }
    935 
    936 int
    937 boolIntFromPyObject (
    938     PyObject *inPyObj,
    939     const char *defaultVal,
    940     const char *argName,
    941     int *boolVal
    942     )
    943 {
    944     int status = -1;
    945     PyObject *inStrObj = NULL;
    946     char *inStr = NULL;
    947 
    948     if (    (defaultVal == NULL) ||
    949             (argName == NULL) ||
    950             (boolVal == NULL)
    951         ) {
    952         // incorrect use of function
    953         PyErr_Format(PyExc_ValueError,
    954             "boolIntFromPyObject(): defaultVal or argName or boolVal is NULL");
    955         return status;
    956     }
    957 
    958     if (inPyObj != NULL) {
    959         inStrObj = PyObject_Str(inPyObj);
    960         if (inStrObj == NULL) {
    961             PyErr_Format(PyExc_TypeError,
    962                 "bad value: %s: no string representation",argName);
    963             return status;
    964         }
    965 
    966         inStr = PyString_AsString(inStrObj);
    967         if (inStr == NULL) {
    968             PyErr_Format(PyExc_TypeError,
    969                 "bad value: %s: cannot convert to string",argName);
    970             return status;
    971         }
    972     }
    973 
    974     if (inStr != NULL) {
    975         status = boolAsInt(inStr,boolVal);
    976     }
    977     else {
    978         status = boolAsInt(defaultVal,boolVal);
    979     }
    980 
    981     return status;
    982 }
    983 
    984 int getArgCount (
    985     PyObject *args,
    986     PyObject *keywds,
    987     int *argc
    988     )
    989 {
    990     int status = 1;
    991     int args_cnt = 0;
    992     int keywds_cnt = 0;
    993 
    994     if (argc == NULL) {
    995         // incorrect use of function
    996         // argc cannot be null
    997         PyErr_Format(PyExc_ValueError,"getArgCount(): argc is NULL");
    998         return status;
    999     }
    1000 
    1001     if (args != NULL) {
    1002         if (!PyTuple_Check(args)) {
    1003             PyErr_Format(PyExc_TypeError,
    1004                 "getArgCount(): \'args\' should be a PyTuple");
    1005             return status;
    1006         }
    1007         args_cnt = PyTuple_Size(args);
    1008     }
    1009 
    1010     if (keywds != NULL) {
    1011         if (!PyDict_Check(keywds)) {
    1012             PyErr_Format(PyExc_TypeError,
    1013                 "getArgCount(): \'keywds\' should be a PyDict");
    1014             return status;
    1015         }
    1016         keywds_cnt = PyDict_Size(keywds);
    1017     }
    1018 
    1019     *argc = args_cnt + keywds_cnt;
    1020     status = 0;
    1021 
    1022     return status;
    1023908}
    1024909
  • branches/nanovis2/lang/python/Rappture/PyRpUtils.cc

    r1326 r3175  
    2525RpUtils_progress(PyObject *self, PyObject *args, PyObject *keywds)
    2626{
    27     int percent = 0;
    28     char* message = NULL;
    29     int result = -1;
    30 
    31     static char *kwlist[] = {
    32         (char *)"percent",
    33         (char *)"message",
    34         NULL
     27    double pct;
     28    char *msg;
     29    static char *kwlist[] = {
     30        (char *)"percent", (char *)"message", NULL
    3531    };
    3632    if (PyTuple_Size(args) != 2) {
    37         PyErr_SetString(PyExc_TypeError,"progress() takes exactly 2 arguments");
     33        PyErr_Format(PyExc_ValueError,
     34                "progress() takes exactly 2 arguments, got %ld",
     35                PyTuple_Size(args));
    3836        return NULL;
    3937    }
    40 
    41     if (!PyArg_ParseTupleAndKeywords(args, keywds, "is",
    42             kwlist, &percent, &message)) {
    43         PyErr_SetString(PyExc_TypeError,"progress() takes exactly 2 arguments");
     38    if (!PyArg_ParseTupleAndKeywords(args, keywds, "ds", kwlist,
     39                &pct, &msg)) {
    4440        return NULL;
    4541    }
    46 
    47     result = Rappture::Utils::progress(percent,message);
    48     if (result != 0) {
    49         PyErr_SetString(PyExc_RuntimeError,"Error while writing to stdout");
     42    if (Rappture::Utils::progress((int)pct, msg) != 0) {
     43        PyErr_SetString(PyExc_RuntimeError, "Error while writing to stdout");
     44        return NULL;
    5045    }
    51 
    5246    Py_INCREF(Py_None);
    5347    return Py_None;
  • branches/nanovis2/lang/python/Rappture/tools.py

    r2926 r3175  
    44#  AUTHOR:  Derrick S. Kearney, Purdue University
    55#  AUTHOR:  Steve Clark, Purdue University
    6 #  Copyright (c) 2005-2007  Purdue Research Foundation, West Lafayette, IN
     6#  Copyright (c) 2005-2012  Purdue Research Foundation, West Lafayette, IN
    77# ======================================================================
    88
    9 import sys, os, re, subprocess, select
     9import sys
     10import os
     11import re
     12import subprocess
     13import select
     14import signal
    1015
    11 # getCommandOutput function written by Steve Clark
     16commandPid = 0
     17
     18def sig_handler(signalType, frame):
     19    global commandPid
     20    if commandPid:
     21        os.kill(commandPid,signal.SIGTERM)
     22
    1223
    1324def getCommandOutput(command,
     
    1526    global commandPid
    1627
     28    sig_INT_handler = signal.signal(signal.SIGINT,sig_handler)
     29    sig_HUP_handler = signal.signal(signal.SIGHUP,sig_handler)
     30    sig_TERM_handler = signal.signal(signal.SIGTERM,sig_handler)
     31
    1732    BUFSIZ = 4096
    18     child      = subprocess.Popen(command,shell=True,bufsize=BUFSIZ, \
    19                                   stdout=subprocess.PIPE, \
    20                                   stderr=subprocess.PIPE, \
    21                                   close_fds=True)
     33    if isinstance(command,list):
     34       child = subprocess.Popen(command,bufsize=BUFSIZ, \
     35                                stdout=subprocess.PIPE, \
     36                                stderr=subprocess.PIPE, \
     37                                close_fds=True)
     38    else:
     39       child = subprocess.Popen(command,shell=True,bufsize=BUFSIZ, \
     40                                stdout=subprocess.PIPE, \
     41                                stderr=subprocess.PIPE, \
     42                                close_fds=True)
    2243    commandPid = child.pid
    2344    childout   = child.stdout
     
    2647    childerrFd = childerr.fileno()
    2748
    28     outEOF = errEOF = 0
     49    outEOF = False
     50    errEOF = False
    2951
    3052    outData = []
    3153    errData = []
    3254
    33     while 1:
     55    while True:
    3456        toCheck = []
    3557        if not outEOF:
     
    3759        if not errEOF:
    3860            toCheck.append(childerrFd)
    39         ready = select.select(toCheck,[],[]) # wait for input
    40         if childoutFd in ready[0]:
     61        try:
     62            readyRead,readyWrite,readyException = select.select(toCheck,[],[]) # wait for input
     63        except select.error,err:
     64            readyRead = []
     65            readyWrite = []
     66            readyException = []
     67        if childoutFd in readyRead:
    4168            outChunk = os.read(childoutFd,BUFSIZ)
    4269            if outChunk == '':
    43                 outEOF = 1
     70                outEOF = True
    4471            outData.append(outChunk)
    4572            if streamOutput:
     
    4774                sys.stdout.flush()
    4875
    49         if childerrFd in ready[0]:
     76        if childerrFd in readyRead:
    5077            errChunk = os.read(childerrFd,BUFSIZ)
    5178            if errChunk == '':
    52                 errEOF = 1
     79                errEOF = True
    5380            errData.append(errChunk)
    5481            if streamOutput:
     
    5986            break
    6087
    61     err = child.wait()
     88    pid,err = os.waitpid(commandPid,0)
    6289    commandPid = 0
     90
     91    signal.signal(signal.SIGINT,sig_INT_handler)
     92    signal.signal(signal.SIGHUP,sig_HUP_handler)
     93    signal.signal(signal.SIGTERM,sig_TERM_handler)
     94
    6395    if err != 0:
    64         sys.stderr.write("%s failed w/ exit code %d\n" % (command,err))
     96        if   os.WIFSIGNALED(err):
     97           sys.stderr.write("%s failed w/ signal %d\n" % (command,os.WTERMSIG(err)))
     98        else:
     99           if os.WIFEXITED(err):
     100               err = os.WEXITSTATUS(err)
     101           sys.stderr.write("%s failed w/ exit code %d\n" % (command,err))
    65102        if not streamOutput:
    66             sys.stderr.write("%s\n" % ("".join(errData)))
     103           sys.stderr.write("%s\n" % ("".join(errData)))
    67104
    68105    return err,"".join(outData),"".join(errData)
  • branches/nanovis2/lang/tcl/scripts/Makefile.in

    r2698 r3175  
    6161
    6262TYPEFILES       = \
     63                $(srcdir)/types/atomactive.tcl \
     64                $(srcdir)/types/atomelem.tcl \
     65                $(srcdir)/types/atomprops.tcl \
    6366                $(srcdir)/types/boolean.tcl \
    6467                $(srcdir)/types/choices.tcl \
  • branches/nanovis2/lang/tcl/scripts/objects/periodicelement/periodicelement.rp

    r2638 r3175  
    1818    help http://rappture.org/wiki/rp_xml_ele_periodicelement
    1919
    20     attr active -title "Active Elements" \
    21         -type string -path default -only input \
    22         -tooltip "Specifies the set of elements that can be selected.\n\nCan be a list of element symbols or groups: actinoid, alkali-metal, alkaline-earth-metal, halogen, lanthanoid, metalloid, noble-gas, other-non-metal, post-transition-metal, transition-metal, or unknown."
    23     attr inactive -title "Inactive Elements" \
    24         -type string -path default -only input \
    25         -tooltip "Specifies the set of elements that can't be selected.\n\nCan be a list of element symbols or groups: actinoid, alkali-metal, alkaline-earth-metal, halogen, lanthanoid, metalloid, noble-gas, other-non-metal, post-transition-metal, transition-metal, or unknown."
     20    attr default -title "Default Value" -type atomelem -path default -only input -tooltip "Sets the value that this input has when the program first starts.  This value is used by default unless the user explicitly changes it."
    2621
    27     attr returnvalue -title "Return value" -type string -path default -only input -tooltip "Specifies the return value: name, symbol, number, or weight."
     22    attr returnvalue -title "Return value" -type atomprops -path returnvalue -only input -tooltip "Specifies how the selected element is reported to your program: name, symbol, number, or weight."
    2823
    29     attr default -title "Default Value" -type string -path default -only input -tooltip "Sets the value that this input has when the program first starts.  This value is used by default unless the user explicitly changes it."
     24    attr active -title "Allowed Elements" \
     25        -type atomactive -path active -only input -tooltip "Specifies the set of elements that can be selected.\n\nCan allow or disallow one or more groups of elements on the periodic table: actinoid, alkali-metal, alkaline-earth-metal, halogen, lanthanoid, metalloid, noble-gas, other-non-metal, post-transition-metal, transition-metal, or unknown."
    3026
    3127    check default {
    32         if {[llength $attr(options)] > 0} {
    33             if {[string length [string trim $attr(default)]] == 0} {
    34                 return [list error "Must have a default value for this periodicelement."]
     28        set defval [string trim $attr(default)]
     29        if {[string length $defval] == 0} {
     30            return [list error "Must have a default value for this periodicelement."]
     31        }
     32
     33        # make sure that the given value is a valid element type
     34        if {[Rappture::PeriodicTable::FindElement $defval] eq ""} {
     35            return [list error "Bad value \"$defval\": must be a known element in the periodic table."]
     36        }
     37
     38        # make sure that the given value isn't in conflict with allowed values
     39        if {$attr(active) ne "" && [regexp {^(active|inactive): (.+)} $attr(active) match polarity vlist]} {
     40            set found [eval Rappture::PeriodicTable::ElementIsType $attr(default) [split $vlist ,]]
     41            if { (!$found && $polarity eq "active")
     42                  || ($found && $polarity eq "inactive") } {
     43                return [list error "Default value \"$attr(default)\" is not one of the allowed values"]
    3544            }
     45        }
     46    }
    3647
    37             # make sure that the default is really a choice
    38             set defval [string trim $attr(default)]
    39             set found 0
    40             foreach rec $attr(options) {
    41                 set label [string trim [lindex $rec 0]]
    42                 set value [string trim [lindex $rec 1]]
    43                 if {$defval eq $label || $defval eq $value} {
    44                     set found 1
    45                     break
    46                 }
    47             }
    48             if {!$found} {
    49                 return [list error "Default value must be a label or value for one of the current periodicelements."]
    50             }
     48    check returnvalue {
     49        if {[string length [string trim $attr(returnvalue)]] == 0} {
     50            return [list error "Must choose at least one return value to report the selected element to your program."]
    5151        }
    5252    }
  • branches/nanovis2/packages/vizservers/vtkvis/Makefile.in

    r2864 r3175  
    8383                PPMWriter.cpp \
    8484                ReadBuffer.cpp \
     85                RpArc.cpp \
     86                RpArrow.cpp \
     87                RpBox.cpp \
     88                RpCone.cpp \
    8589                RpContour2D.cpp \
    8690                RpContour3D.cpp \
    8791                RpCutplane.cpp \
     92                RpCylinder.cpp \
     93                RpDisk.cpp \
    8894                RpGlyphs.cpp \
     95                RpGroup.cpp \
    8996                RpHeightMap.cpp \
     97                RpLine.cpp \
    9098                RpLIC.cpp \
    9199                RpMolecule.cpp \
    92100                RpPolyData.cpp \
     101                RpPolygon.cpp \
    93102                RpPseudoColor.cpp \
     103                RpShape.cpp \
     104                RpSphere.cpp \
    94105                RpStreamlines.cpp \
    95106                RpVolume.cpp \
     
    100111                RpVtkRendererGraphicsObjs.cpp \
    101112                RpVtkRenderServer.cpp \
     113                RpWarp.cpp \
    102114                TGAWriter.cpp \
    103115                Trace.cpp
     
    149161ReadBuffer.o: ReadBuffer.h Trace.h
    150162ResponseQueue.o: ResponseQueue.h Trace.h
     163RpArc.o: RpArc.h RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h
     164RpArrow.o: RpArrow.h RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h
     165RpBox.o: RpBox.h RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h
     166RpCone.o: RpCone.h RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h
    151167RpContour2D.o: RpContour2D.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h
    152168RpContour3D.o: RpContour3D.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h
    153169RpCutplane.o: RpCutplane.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h
     170RpCylinder.o: RpCylinder.h RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h
     171RpDisk.o: RpDisk.h RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h
    154172RpGlyphs.o: RpGlyphs.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h
     173RpGroup.o: RpGroup.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h
    155174RpHeightMap.o: RpHeightMap.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h
     175RpLine.o: RpLine.h RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h
    156176RpLIC.o: RpLIC.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h RpVtkRenderServer.h
    157177RpMolecule.o: RpMolecule.h RpMoleculeData.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h
     178RpMolecule2.o: RpMolecule2.h RpMoleculeData.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h
    158179RpPolyData.o: RpPolyData.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h
     180RpPolygon.o: RpPolygon.h RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h
    159181RpPseudoColor.o: RpPseudoColor.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h
     182RpShape.o: RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h
     183RpSphere.o: RpSphere.h RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h
    160184RpStreamlines.o: RpStreamlines.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h
    161185RpVolume.o: RpVolume.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h
    162186RpVtkDataSet.o: RpVtkDataSet.h Trace.h
    163 RpVtkGraphicsObject.o: RpVtkGraphicsObject.h RpVtkRenderer.h RpVtkDataSet.h RpContour2D.h RpContour3D.h RpCutplane.h RpGlyphs.h RpHeightMap.h RpLIC.h RpMolecule.h RpPolyData.h RpPseudoColor.h RpStreamlines.h RpVolume.h ColorMap.h Trace.h
    164 RpVtkRenderer.o: RpVtkRenderer.h RpMath.h vtkRpCubeAxesActor2D.h RpVtkDataSet.h RpContour2D.h RpContour3D.h RpCutplane.h RpGlyphs.h RpHeightMap.h RpLIC.h RpMolecule.h RpPolyData.h RpPseudoColor.h RpStreamlines.h RpVolume.h ColorMap.h Trace.h
    165 RpVtkRendererCmd.o: RpVtkRenderer.h RpVtkRendererGraphicsObjs.h vtkRpCubeAxesActor2D.h RpVtkDataSet.h RpContour2D.h RpContour3D.h RpCutplane.h RpGlyphs.h RpHeightMap.h RpLIC.h RpMolecule.h RpPolyData.h RpPseudoColor.h RpStreamlines.h RpVolume.h ColorMap.h ReadBuffer.h ResponseQueue.h Trace.h CmdProc.h PPMWriter.h TGAWriter.h
    166 RpVtkRendererGraphicsObjs.o: RpVtkRenderer.h RpVtkRendererGraphicsObjs.h RpVtkDataSet.h RpContour2D.h RpContour3D.h RpCutplane.h RpGlyphs.h RpHeightMap.h RpLIC.h RpMolecule.h RpPolyData.h RpPseudoColor.h RpStreamlines.h RpVolume.h ColorMap.h Trace.h
     187RpVtkGraphicsObject.o: RpVtkGraphicsObject.h RpVtkRenderer.h RpVtkDataSet.h ColorMap.h Trace.h
     188RpVtkRenderer.o: RpVtkRenderer.h RpVtkRendererGraphicsObjs.h RpMath.h vtkRpCubeAxesActor2D.h RpVtkDataSet.h RpArc.h RpArrow.h RpBox.h RpCone.h RpContour2D.h RpContour3D.h RpCutplane.h RpCylinder.h RpDisk.h RpGlyphs.h RpGroup.h RpHeightMap.h RpLIC.h RpLine.h RpMolecule.h RpPolyData.h RpPolygon.h RpPseudoColor.h RpSphere.h RpStreamlines.h RpVolume.h ColorMap.h Trace.h
     189RpVtkRendererCmd.o: RpVtkRenderer.h RpVtkRendererGraphicsObjs.h vtkRpCubeAxesActor2D.h RpVtkDataSet.h RpArc.h RpArrow.h RpBox.h RpCone.h RpContour2D.h RpContour3D.h RpCutplane.h RpCylinder.h RpDisk.h RpGlyphs.h RpGroup.h RpHeightMap.h RpLIC.h RpLine.h RpMolecule.h RpPolyData.h RpPolygon.h RpPseudoColor.h RpSphere.h RpStreamlines.h RpVolume.h ColorMap.h ReadBuffer.h ResponseQueue.h Trace.h CmdProc.h PPMWriter.h TGAWriter.h
     190RpVtkRendererGraphicsObjs.o: RpVtkRenderer.h RpVtkRendererGraphicsObjs.h RpVtkDataSet.h RpArc.h RpArrow.h RpBox.h RpCone.h RpContour2D.h RpContour3D.h RpCutplane.h RpCylinder.h RpDisk.h RpGlyphs.h RpGroup.h RpHeightMap.h RpLIC.h RpLine.h RpMolecule.h RpPolyData.h RpPolygon.h RpPseudoColor.h RpSphere.h RpStreamlines.h RpVolume.h ColorMap.h Trace.h
    167191RpVtkRenderServer.o: RpVtkRenderServer.h RpVtkRendererCmd.h RpVtkRenderer.h vtkRpAxisActor.h vtkRpCubeAxesActor.h vtkRpAxisActor2D.h vtkRpCubeAxesActor2D.h ReadBuffer.h ResponseQueue.h Trace.h PPMWriter.h TGAWriter.h
     192RpWarp.o: RpWarp.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h
    168193Trace.o: Trace.h
    169194TGAWriter.o: TGAWriter.h ResponseQueue.h Trace.h
  • branches/nanovis2/packages/vizservers/vtkvis/ResponseQueue.cpp

    r2578 r3175  
    7272    Response *response = NULL;
    7373
    74     if (sem_wait(&_ready) < 0) {
     74    int ret;
     75    while ((ret = sem_wait(&_ready)) < 0 && errno == EINTR)
     76        continue;
     77    if (ret < 0) {
    7578        ERROR("can't wait on semaphore: %s", strerror(errno));
    7679    }
  • branches/nanovis2/packages/vizservers/vtkvis/RpContour2D.cpp

    r2612 r3175  
    66 */
    77
    8 #include <cassert>
     8#include <cfloat>
    99
    1010#include <vtkDataSet.h>
     
    2323
    2424#include "RpContour2D.h"
     25#include "RpVtkRenderer.h"
    2526#include "Trace.h"
    2627
     
    2930Contour2D::Contour2D(int numContours) :
    3031    VtkGraphicsObject(),
    31     _numContours(numContours)
     32    _numContours(numContours),
     33    _colorMap(NULL),
     34    _colorMode(COLOR_CONSTANT),
     35    _colorFieldType(DataSet::POINT_DATA),
     36    _renderer(NULL)
    3237{
    3338    _edgeColor[0] = _color[0];
    3439    _edgeColor[1] = _color[0];
    3540    _edgeColor[2] = _color[0];
     41    _colorFieldRange[0] = DBL_MAX;
     42    _colorFieldRange[1] = -DBL_MAX;
    3643    _lighting = false;
    3744}
     
    4047    VtkGraphicsObject(),
    4148    _numContours(contours.size()),
    42     _contours(contours)
     49    _contours(contours),
     50    _colorMap(NULL),
     51    _colorMode(COLOR_CONSTANT),
     52    _colorFieldType(DataSet::POINT_DATA),
     53    _renderer(NULL)
    4354{
    4455    _edgeColor[0] = _color[0];
    4556    _edgeColor[1] = _color[0];
    4657    _edgeColor[2] = _color[0];
     58    _colorFieldRange[0] = DBL_MAX;
     59    _colorFieldRange[1] = -DBL_MAX;
    4760    _lighting = false;
    4861}
     
    5871}
    5972
     73void Contour2D::setDataSet(DataSet *dataSet,
     74                           Renderer *renderer)
     75{
     76    if (_dataSet != dataSet) {
     77        _dataSet = dataSet;
     78
     79        _renderer = renderer;
     80
     81        if (renderer->getUseCumulativeRange()) {
     82            renderer->getCumulativeDataRange(_dataRange,
     83                                             _dataSet->getActiveScalarsName(),
     84                                             1);
     85            renderer->getCumulativeDataRange(_vectorMagnitudeRange,
     86                                             _dataSet->getActiveVectorsName(),
     87                                             3);
     88            for (int i = 0; i < 3; i++) {
     89                renderer->getCumulativeDataRange(_vectorComponentRange[i],
     90                                                 _dataSet->getActiveVectorsName(),
     91                                                 3, i);
     92            }
     93        } else {
     94            _dataSet->getScalarRange(_dataRange);
     95            _dataSet->getVectorRange(_vectorMagnitudeRange);
     96            for (int i = 0; i < 3; i++) {
     97                _dataSet->getVectorRange(_vectorComponentRange[i], i);
     98            }
     99        }
     100
     101        update();
     102    }
     103}
     104
    60105/**
    61106 * \brief Internal method to re-compute contours after a state change
     
    67112    }
    68113    vtkDataSet *ds = _dataSet->getVtkDataSet();
    69 
    70     initProp();
    71114
    72115    // Contour filter to generate isolines
     
    166209        }
    167210    }
    168     if (_contourMapper == NULL) {
    169         _contourMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
    170         _contourMapper->SetResolveCoincidentTopologyToPolygonOffset();
    171         _contourMapper->ScalarVisibilityOff();
     211
     212    initProp();
     213
     214    if (_dsMapper == NULL) {
     215        _dsMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
     216        _dsMapper->SetResolveCoincidentTopologyToPolygonOffset();
     217        _dsMapper->ScalarVisibilityOff();
    172218        vtkSmartPointer<vtkStripper> stripper = vtkSmartPointer<vtkStripper>::New();
    173219        stripper->SetInputConnection(_contourFilter->GetOutputPort());
    174         _contourMapper->SetInputConnection(stripper->GetOutputPort());
    175         getActor()->SetMapper(_contourMapper);
    176     }
    177 
    178     _contourMapper->Update();
     220        _dsMapper->SetInputConnection(stripper->GetOutputPort());
     221        getActor()->SetMapper(_dsMapper);
     222    }
     223
     224    if (_lut == NULL) {
     225        setColorMap(ColorMap::getDefault());
     226    }
     227
     228    setColorMode(_colorMode);
     229
     230    _dsMapper->Update();
    179231}
    180232
    181233void Contour2D::updateRanges(Renderer *renderer)
    182234{
    183     VtkGraphicsObject::updateRanges(renderer);
     235    if (_dataSet == NULL) {
     236        ERROR("called before setDataSet");
     237        return;
     238    }
     239
     240    if (renderer->getUseCumulativeRange()) {
     241        renderer->getCumulativeDataRange(_dataRange,
     242                                         _dataSet->getActiveScalarsName(),
     243                                         1);
     244        renderer->getCumulativeDataRange(_vectorMagnitudeRange,
     245                                         _dataSet->getActiveVectorsName(),
     246                                         3);
     247        for (int i = 0; i < 3; i++) {
     248            renderer->getCumulativeDataRange(_vectorComponentRange[i],
     249                                             _dataSet->getActiveVectorsName(),
     250                                             3, i);
     251        }
     252    } else {
     253        _dataSet->getScalarRange(_dataRange);
     254        _dataSet->getVectorRange(_vectorMagnitudeRange);
     255        for (int i = 0; i < 3; i++) {
     256            _dataSet->getVectorRange(_vectorComponentRange[i], i);
     257        }
     258    }
    184259 
     260    // Need to update color map ranges
     261    double *rangePtr = _colorFieldRange;
     262    if (_colorFieldRange[0] > _colorFieldRange[1]) {
     263        rangePtr = NULL;
     264    }
     265    setColorMode(_colorMode, _colorFieldType, _colorFieldName.c_str(), rangePtr);
     266
    185267    if (_contours.empty() && _numContours > 0) {
    186268        // Contour isovalues need to be recomputed
     
    189271}
    190272
     273void Contour2D::setColorMode(ColorMode mode)
     274{
     275    _colorMode = mode;
     276    if (_dataSet == NULL)
     277        return;
     278
     279    switch (mode) {
     280    case COLOR_BY_SCALAR:
     281        setColorMode(mode,
     282                     _dataSet->getActiveScalarsType(),
     283                     _dataSet->getActiveScalarsName(),
     284                     _dataRange);
     285        break;
     286    case COLOR_BY_VECTOR_MAGNITUDE:
     287        setColorMode(mode,
     288                     _dataSet->getActiveVectorsType(),
     289                     _dataSet->getActiveVectorsName(),
     290                     _vectorMagnitudeRange);
     291        break;
     292    case COLOR_BY_VECTOR_X:
     293        setColorMode(mode,
     294                     _dataSet->getActiveVectorsType(),
     295                     _dataSet->getActiveVectorsName(),
     296                     _vectorComponentRange[0]);
     297        break;
     298    case COLOR_BY_VECTOR_Y:
     299        setColorMode(mode,
     300                     _dataSet->getActiveVectorsType(),
     301                     _dataSet->getActiveVectorsName(),
     302                     _vectorComponentRange[1]);
     303        break;
     304    case COLOR_BY_VECTOR_Z:
     305        setColorMode(mode,
     306                     _dataSet->getActiveVectorsType(),
     307                     _dataSet->getActiveVectorsName(),
     308                     _vectorComponentRange[2]);
     309        break;
     310    case COLOR_CONSTANT:
     311    default:
     312        setColorMode(mode, DataSet::POINT_DATA, NULL, NULL);
     313        break;
     314    }
     315}
     316
     317void Contour2D::setColorMode(ColorMode mode,
     318                             const char *name, double range[2])
     319{
     320    if (_dataSet == NULL)
     321        return;
     322    DataSet::DataAttributeType type = DataSet::POINT_DATA;
     323    int numComponents = 1;
     324    if (name != NULL && strlen(name) > 0 &&
     325        !_dataSet->getFieldInfo(name, &type, &numComponents)) {
     326        ERROR("Field not found: %s", name);
     327        return;
     328    }
     329    setColorMode(mode, type, name, range);
     330}
     331
     332void Contour2D::setColorMode(ColorMode mode, DataSet::DataAttributeType type,
     333                             const char *name, double range[2])
     334{
     335    _colorMode = mode;
     336    _colorFieldType = type;
     337    if (name == NULL)
     338        _colorFieldName.clear();
     339    else
     340        _colorFieldName = name;
     341    if (range == NULL) {
     342        _colorFieldRange[0] = DBL_MAX;
     343        _colorFieldRange[1] = -DBL_MAX;
     344    } else {
     345        memcpy(_colorFieldRange, range, sizeof(double)*2);
     346    }
     347
     348    if (_dataSet == NULL || _dsMapper == NULL)
     349        return;
     350
     351    switch (type) {
     352    case DataSet::POINT_DATA:
     353        _dsMapper->SetScalarModeToUsePointFieldData();
     354        break;
     355    case DataSet::CELL_DATA:
     356        _dsMapper->SetScalarModeToUseCellFieldData();
     357        break;
     358    default:
     359        ERROR("Unsupported DataAttributeType: %d", type);
     360        return;
     361    }
     362
     363    if (name != NULL && strlen(name) > 0) {
     364        _dsMapper->SelectColorArray(name);
     365    } else {
     366        _dsMapper->SetScalarModeToDefault();
     367    }
     368
     369    if (_lut != NULL) {
     370        if (range != NULL) {
     371            _lut->SetRange(range);
     372        } else if (name != NULL && strlen(name) > 0) {
     373            double r[2];
     374            int comp = -1;
     375            if (mode == COLOR_BY_VECTOR_X)
     376                comp = 0;
     377            else if (mode == COLOR_BY_VECTOR_Y)
     378                comp = 1;
     379            else if (mode == COLOR_BY_VECTOR_Z)
     380                comp = 2;
     381
     382            if (_renderer->getUseCumulativeRange()) {
     383                int numComponents;
     384                if  (!_dataSet->getFieldInfo(name, type, &numComponents)) {
     385                    ERROR("Field not found: %s, type: %d", name, type);
     386                    return;
     387                } else if (numComponents < comp+1) {
     388                    ERROR("Request for component %d in field with %d components",
     389                          comp, numComponents);
     390                    return;
     391                }
     392                _renderer->getCumulativeDataRange(r, name, type, numComponents, comp);
     393            } else {
     394                _dataSet->getDataRange(r, name, type, comp);
     395            }
     396            _lut->SetRange(r);
     397        }
     398    }
     399
     400    switch (mode) {
     401    case COLOR_BY_SCALAR:
     402        _dsMapper->ScalarVisibilityOn();
     403        break;
     404    case COLOR_BY_VECTOR_MAGNITUDE:
     405        _dsMapper->ScalarVisibilityOn();
     406        if (_lut != NULL) {
     407            _lut->SetVectorModeToMagnitude();
     408        }
     409        break;
     410    case COLOR_BY_VECTOR_X:
     411        _dsMapper->ScalarVisibilityOn();
     412        if (_lut != NULL) {
     413            _lut->SetVectorModeToComponent();
     414            _lut->SetVectorComponent(0);
     415        }
     416        break;
     417    case COLOR_BY_VECTOR_Y:
     418        _dsMapper->ScalarVisibilityOn();
     419        if (_lut != NULL) {
     420            _lut->SetVectorModeToComponent();
     421            _lut->SetVectorComponent(1);
     422        }
     423        break;
     424    case COLOR_BY_VECTOR_Z:
     425        _dsMapper->ScalarVisibilityOn();
     426        if (_lut != NULL) {
     427            _lut->SetVectorModeToComponent();
     428            _lut->SetVectorComponent(2);
     429        }
     430        break;
     431    case COLOR_CONSTANT:
     432    default:
     433        _dsMapper->ScalarVisibilityOff();
     434        break;
     435    }
     436}
     437
     438/**
     439 * \brief Called when the color map has been edited
     440 */
     441void Contour2D::updateColorMap()
     442{
     443    setColorMap(_colorMap);
     444}
     445
     446/**
     447 * \brief Associate a colormap lookup table with the DataSet
     448 */
     449void Contour2D::setColorMap(ColorMap *cmap)
     450{
     451    if (cmap == NULL)
     452        return;
     453
     454    _colorMap = cmap;
     455 
     456    if (_lut == NULL) {
     457        _lut = vtkSmartPointer<vtkLookupTable>::New();
     458        if (_dsMapper != NULL) {
     459            _dsMapper->UseLookupTableScalarRangeOn();
     460            _dsMapper->SetLookupTable(_lut);
     461        }
     462        _lut->DeepCopy(cmap->getLookupTable());
     463        switch (_colorMode) {
     464        case COLOR_CONSTANT:
     465        case COLOR_BY_SCALAR:
     466            _lut->SetRange(_dataRange);
     467            break;
     468        case COLOR_BY_VECTOR_MAGNITUDE:
     469            _lut->SetRange(_vectorMagnitudeRange);
     470            break;
     471        case COLOR_BY_VECTOR_X:
     472            _lut->SetRange(_vectorComponentRange[0]);
     473            break;
     474        case COLOR_BY_VECTOR_Y:
     475            _lut->SetRange(_vectorComponentRange[1]);
     476            break;
     477        case COLOR_BY_VECTOR_Z:
     478            _lut->SetRange(_vectorComponentRange[2]);
     479            break;
     480        default:
     481            break;
     482        }
     483    } else {
     484        double range[2];
     485        _lut->GetTableRange(range);
     486        _lut->DeepCopy(cmap->getLookupTable());
     487        _lut->SetRange(range);
     488    }
     489
     490    switch (_colorMode) {
     491    case COLOR_BY_VECTOR_MAGNITUDE:
     492        _lut->SetVectorModeToMagnitude();
     493        break;
     494    case COLOR_BY_VECTOR_X:
     495        _lut->SetVectorModeToComponent();
     496        _lut->SetVectorComponent(0);
     497        break;
     498    case COLOR_BY_VECTOR_Y:
     499        _lut->SetVectorModeToComponent();
     500        _lut->SetVectorComponent(1);
     501        break;
     502    case COLOR_BY_VECTOR_Z:
     503        _lut->SetVectorModeToComponent();
     504        _lut->SetVectorComponent(2);
     505        break;
     506    default:
     507         break;
     508    }
     509}
     510
    191511/**
    192512 * \brief Specify number of evenly spaced contour lines to render
     
    239559void Contour2D::setClippingPlanes(vtkPlaneCollection *planes)
    240560{
    241     if (_contourMapper != NULL) {
    242         _contourMapper->SetClippingPlanes(planes);
    243     }
    244 }
     561    if (_dsMapper != NULL) {
     562        _dsMapper->SetClippingPlanes(planes);
     563    }
     564}
  • branches/nanovis2/packages/vizservers/vtkvis/RpContour2D.h

    r2612 r3175  
    1414#include <vtkActor.h>
    1515#include <vtkPlaneCollection.h>
     16#include <vtkLookupTable.h>
    1617
    1718#include <vector>
    1819
     20#include "ColorMap.h"
    1921#include "RpVtkGraphicsObject.h"
    2022
     
    2729class Contour2D : public VtkGraphicsObject {
    2830public:
     31    enum ColorMode {
     32        COLOR_BY_SCALAR,
     33        COLOR_BY_VECTOR_MAGNITUDE,
     34        COLOR_BY_VECTOR_X,
     35        COLOR_BY_VECTOR_Y,
     36        COLOR_BY_VECTOR_Z,
     37        COLOR_CONSTANT
     38    };
     39
    2940    Contour2D(int numContours);
    3041
     
    3849    }
    3950
     51    virtual void setDataSet(DataSet *dataSet,
     52                            Renderer *renderer);
     53
    4054    virtual void setClippingPlanes(vtkPlaneCollection *planes);
    4155
     
    4761
    4862    const std::vector<double>& getContourList() const;
     63
     64    void setColorMode(ColorMode mode, DataSet::DataAttributeType type,
     65                      const char *name, double range[2] = NULL);
     66
     67    void setColorMode(ColorMode mode,
     68                      const char *name, double range[2] = NULL);
     69
     70    void setColorMode(ColorMode mode);
     71
     72    void setColorMap(ColorMap *colorMap);
     73
     74    /**
     75     * \brief Return the ColorMap in use
     76     */
     77    ColorMap *getColorMap()
     78    {
     79        return _colorMap;
     80    }
     81
     82    void updateColorMap();
    4983
    5084    virtual void updateRanges(Renderer *renderer);
     
    69103    std::vector<double> _contours;
    70104
     105    ColorMap *_colorMap;
     106    ColorMode _colorMode;
     107    std::string _colorFieldName;
     108    DataSet::DataAttributeType _colorFieldType;
     109    double _colorFieldRange[2];
     110    double _vectorMagnitudeRange[2];
     111    double _vectorComponentRange[3][2];
     112    Renderer *_renderer;
     113
     114    vtkSmartPointer<vtkLookupTable> _lut;
    71115    vtkSmartPointer<vtkContourFilter> _contourFilter;
    72     vtkSmartPointer<vtkPolyDataMapper> _contourMapper;
     116    vtkSmartPointer<vtkPolyDataMapper> _dsMapper;
    73117};
    74118
  • branches/nanovis2/packages/vizservers/vtkvis/RpGlyphs.cpp

    r2641 r3175  
    107107        _glyphSource = vtkSmartPointer<vtkLineSource>::New();
    108108        break;
    109     case ARROW:
     109    case ARROW: {
    110110        _glyphSource = vtkSmartPointer<vtkArrowSource>::New();
    111         break;
    112     case CONE:
     111        vtkSmartPointer<vtkArrowSource> arrow = vtkArrowSource::SafeDownCast(_glyphSource);
     112        arrow->SetTipResolution(8);
     113        arrow->SetShaftResolution(8);
     114    }
     115        break;
     116    case CONE: {
    113117        _glyphSource = vtkSmartPointer<vtkConeSource>::New();
     118        vtkSmartPointer<vtkConeSource> cone = vtkConeSource::SafeDownCast(_glyphSource);
     119        cone->SetResolution(8);
     120    }
    114121        break;
    115122    case CUBE:
     
    119126    case CYLINDER: {
    120127        vtkSmartPointer<vtkCylinderSource> csource = vtkSmartPointer<vtkCylinderSource>::New();
    121         vtkCylinderSource::SafeDownCast(csource)->SetResolution(6);
     128        csource->SetResolution(8);
    122129        _glyphSource = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
    123130        _glyphSource->SetInputConnection(csource->GetOutputPort());
     
    139146        vtkPlatonicSolidSource::SafeDownCast(_glyphSource)->SetSolidTypeToOctahedron();
    140147        break;
    141     case SPHERE:
     148    case SPHERE: {
    142149        _glyphSource = vtkSmartPointer<vtkSphereSource>::New();
     150        vtkSmartPointer<vtkSphereSource> sphere = vtkSphereSource::SafeDownCast(_glyphSource);
     151        sphere->SetThetaResolution(14);
     152        sphere->SetPhiResolution(14);
     153    }
    143154        break;
    144155    case TETRAHEDRON:
     
    169180    }
    170181#endif
     182
     183    //setQuality(0.8);
     184}
     185
     186void Glyphs::setQuality(double quality)
     187{
     188    switch (_glyphShape) {
     189    case ARROW: {
     190        vtkSmartPointer<vtkArrowSource> arrow = vtkArrowSource::SafeDownCast(_glyphSource);
     191        int res = (int)(quality * 25);
     192        if (res < 5) res = 5;
     193        arrow->SetTipResolution(res);
     194        arrow->SetShaftResolution(res);
     195    }
     196        break;
     197    case CONE: {
     198        vtkSmartPointer<vtkConeSource> cone = vtkConeSource::SafeDownCast(_glyphSource);
     199        int res = (int)(quality * 25);
     200        if (res < 5) res = 5;
     201        cone->SetResolution(res);
     202    }
     203        break;
     204    case SPHERE: {
     205        vtkSmartPointer<vtkSphereSource> sphere = vtkSphereSource::SafeDownCast(_glyphSource);
     206        int res = (int)(quality * 50);
     207        if (res < 5) res = 5;
     208        sphere->SetThetaResolution(res);
     209        sphere->SetPhiResolution(res);
     210    }
     211        break;
     212    case CYLINDER: {
     213        assert (vtkTransformPolyDataFilter::SafeDownCast(_glyphSource) != NULL);
     214        assert (vtkTransformPolyDataFilter::SafeDownCast(_glyphSource)->GetInput() != NULL);
     215        TRACE("gsource input: %s", vtkTransformPolyDataFilter::SafeDownCast(_glyphSource)->GetInput()->GetClassName());
     216        vtkSmartPointer<vtkCylinderSource> csource = vtkCylinderSource::SafeDownCast(vtkTransformPolyDataFilter::SafeDownCast(_glyphSource)->GetInput()->GetProducerPort());
     217        int res = (int)(quality * 25);
     218        if (res < 5) res = 5;
     219        csource->SetResolution(res);
     220    }
     221        break;
     222    default:
     223        break;
     224    }
    171225}
    172226
     
    208262    if (ds->GetPointData() == NULL ||
    209263        ds->GetPointData()->GetScalars() == NULL) {
    210         WARN("No scalar point data in dataset %s", _dataSet->getName().c_str());
    211264        if (ds->GetCellData() != NULL &&
    212265            ds->GetCellData()->GetScalars() != NULL) {
     266            TRACE("Generating point data scalars from cell data for: %s", _dataSet->getName().c_str());
    213267            cellToPtData =
    214268                vtkSmartPointer<vtkCellDataToPointData>::New();
     
    218272            ds = cellToPtData->GetOutput();
    219273        } else {
    220             ERROR("No scalar cell data in dataset %s", _dataSet->getName().c_str());
     274            TRACE("No scalar data in dataset %s", _dataSet->getName().c_str());
    221275        }
    222276    }
     
    298352
    299353#ifdef HAVE_GLYPH3D_MAPPER
     354/**
     355 * \brief Turn on/off orienting glyphs from a vector field
     356 */
     357void Glyphs::setOrientMode(bool mode, const char *name)
     358{
     359    if (_glyphMapper != NULL) {
     360        _glyphMapper->SetOrient(mode ? 1 : 0);
     361        if (name != NULL && strlen(name) > 0) {
     362            _glyphMapper->SetOrientationArray(name);
     363        } else {
     364            _glyphMapper->SetOrientationArray(vtkDataSetAttributes::VECTORS);
     365        }
     366    }
     367}
     368
    300369/**
    301370 * \brief Control how glyphs are scaled
     
    638707
    639708/**
     709 * \brief Turn on/off orienting glyphs from a vector field
     710 */
     711void Glyphs::setOrient(bool state)
     712{
     713#ifdef HAVE_GLYPH3D_MAPPER
     714    if (_glyphMapper != NULL) {
     715        _glyphMapper->SetOrient(state ? 1 : 0);
     716    }
     717#else
     718    if (_glyphGenerator != NULL) {
     719        _glyphGenerator->SetOrient(state ? 1 : 0);
     720    }
     721#endif
     722}
     723
     724/**
    640725 * \brief Controls relative scaling of glyphs
    641726 */
  • branches/nanovis2/packages/vizservers/vtkvis/RpGlyphs.h

    r2641 r3175  
    7777    virtual void setClippingPlanes(vtkPlaneCollection *planes);
    7878
     79    void setQuality(double quality);
     80
     81    void setOrient(bool state);
     82
    7983#ifdef HAVE_GLYPH3D_MAPPER
     84    void setOrientMode(bool mode, const char *name);
     85
    8086    void setScalingMode(ScalingMode mode, const char *name, double range[2]);
    8187
  • branches/nanovis2/packages/vizservers/vtkvis/RpMolecule.cpp

    r2641 r3175  
    66 */
    77
     8#include <cstdio>
     9#include <cfloat>
    810#include <cassert>
    911
    1012#include <vtkDataSet.h>
     13#include <vtkCellArray.h>
    1114#include <vtkPointData.h>
    1215#include <vtkFloatArray.h>
     16#include <vtkDoubleArray.h>
     17#include <vtkIntArray.h>
     18#include <vtkStringArray.h>
    1319#include <vtkPolyData.h>
    1420#include <vtkPolyDataMapper.h>
     
    1723#include <vtkTubeFilter.h>
    1824#include <vtkSphereSource.h>
     25#include <vtkCylinderSource.h>
     26#include <vtkTransform.h>
     27#include <vtkTransformPolyDataFilter.h>
    1928#include <vtkGlyph3D.h>
     29#include <vtkPointSetToLabelHierarchy.h>
     30#include <vtkLabelPlacementMapper.h>
     31#include <vtkTextProperty.h>
    2032
    2133#include "RpMolecule.h"
    2234#include "RpMoleculeData.h"
     35#include "RpVtkRenderer.h"
    2336#include "Trace.h"
    2437
     
    2740Molecule::Molecule() :
    2841    VtkGraphicsObject(),
    29     _atomScaling(NO_ATOM_SCALING),
    30     _colorMap(NULL)
    31 {
     42    _radiusScale(0.3),
     43    _atomScaling(COVALENT_RADIUS),
     44    _labelsOn(false),
     45    _colorMap(NULL),
     46    _colorMode(COLOR_BY_ELEMENTS),
     47    _colorFieldType(DataSet::POINT_DATA)
     48{
     49    _bondColor[0] = _bondColor[1] = _bondColor[2] = 1.0f;
     50    _colorFieldRange[0] = DBL_MAX;
     51    _colorFieldRange[1] = -DBL_MAX;
    3252    _faceCulling = true;
    3353}
     
    4161        TRACE("Deleting Molecule with NULL DataSet");
    4262#endif
     63}
     64
     65void Molecule::setDataSet(DataSet *dataSet,
     66                          Renderer *renderer)
     67{
     68    if (_dataSet != dataSet) {
     69        _dataSet = dataSet;
     70
     71        _renderer = renderer;
     72
     73        if (renderer->getUseCumulativeRange()) {
     74            renderer->getCumulativeDataRange(_dataRange,
     75                                             _dataSet->getActiveScalarsName(),
     76                                             1);
     77            renderer->getCumulativeDataRange(_vectorMagnitudeRange,
     78                                             _dataSet->getActiveVectorsName(),
     79                                             3);
     80            for (int i = 0; i < 3; i++) {
     81                renderer->getCumulativeDataRange(_vectorComponentRange[i],
     82                                                 _dataSet->getActiveVectorsName(),
     83                                                 3, i);
     84            }
     85        } else {
     86            _dataSet->getScalarRange(_dataRange);
     87            _dataSet->getVectorRange(_vectorMagnitudeRange);
     88            for (int i = 0; i < 3; i++) {
     89                _dataSet->getVectorRange(_vectorComponentRange[i], i);
     90            }
     91        }
     92
     93        update();
     94    }
    4395}
    4496
     
    65117            setCulling(_bondProp->GetProperty(), true);
    66118        _bondProp->GetProperty()->EdgeVisibilityOff();
     119        _bondProp->GetProperty()->SetColor(_bondColor[0], _bondColor[1], _bondColor[2]);
    67120        _bondProp->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);
    68121        _bondProp->GetProperty()->SetLineWidth(_edgeWidth);
     
    72125            _bondProp->GetProperty()->LightingOff();
    73126    }
     127    if (_labelProp == NULL) {
     128        _labelProp = vtkSmartPointer<vtkActor2D>::New();
     129    }
    74130    if (_prop == NULL) {
    75131        _prop = vtkSmartPointer<vtkAssembly>::New();
     
    87143    vtkDataSet *ds = _dataSet->getVtkDataSet();
    88144
     145#ifndef MOLECULE_USE_GLYPH3D_MAPPER
    89146    if (_atomMapper == NULL) {
    90147        _atomMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
     
    96153        _bondMapper->SetResolveCoincidentTopologyToPolygonOffset();
    97154        _bondMapper->ScalarVisibilityOn();
     155    }
     156#else
     157    if (_atomMapper == NULL) {
     158        _atomMapper = vtkSmartPointer<vtkGlyph3DMapper>::New();
     159        _atomMapper->SetResolveCoincidentTopologyToPolygonOffset();
     160        _atomMapper->ScalarVisibilityOn();
     161    }
     162    if (_bondMapper == NULL) {
     163        _bondMapper = vtkSmartPointer<vtkGlyph3DMapper>::New();
     164        _bondMapper->SetResolveCoincidentTopologyToPolygonOffset();
     165        _bondMapper->ScalarVisibilityOn();
     166    }
     167#endif
     168    if (_labelMapper == NULL) {
     169        _labelMapper = vtkSmartPointer<vtkLabelPlacementMapper>::New();
     170        _labelMapper->SetShapeToRoundedRect();
     171        _labelMapper->SetBackgroundColor(1.0, 1.0, 0.7);
     172        _labelMapper->SetBackgroundOpacity(0.8);
     173        _labelMapper->SetMargin(3);
    98174    }
    99175
     
    104180            WARN("No element array in dataset %s", _dataSet->getName().c_str());
    105181            setColorMap(ColorMap::getDefault());
     182            if (_atomScaling != NO_ATOM_SCALING)
     183                _atomScaling = NO_ATOM_SCALING;
    106184        } else {
    107185            TRACE("Using element default colormap");
     
    112190    initProp();
    113191
    114     addRadiusArray(ds, _atomScaling);
     192    addLabelArray(ds);
     193    addRadiusArray(ds, _atomScaling, _radiusScale);
    115194
    116195    vtkPolyData *pd = vtkPolyData::SafeDownCast(ds);
     
    124203        if (pd->GetNumberOfLines() > 0) {
    125204            // Bonds
    126             vtkSmartPointer<vtkTubeFilter> tuber = vtkSmartPointer<vtkTubeFilter>::New();
    127             tuber->SetInput(pd);
    128             tuber->SetNumberOfSides(6);
    129             tuber->CappingOff();
    130             tuber->SetRadius(.03);
    131             tuber->SetVaryRadiusToVaryRadiusOff();
    132             _bondMapper->SetInputConnection(tuber->GetOutputPort());
     205#ifndef MOLECULE_USE_GLYPH3D_MAPPER
     206            if (_tuber == NULL)
     207                _tuber = vtkSmartPointer<vtkTubeFilter>::New();
     208            _tuber->SetInput(pd);
     209            _tuber->SetNumberOfSides(12);
     210            _tuber->CappingOff();
     211            _tuber->SetRadius(0.075);
     212            _tuber->SetVaryRadiusToVaryRadiusOff();
     213            _bondMapper->SetInputConnection(_tuber->GetOutputPort());
     214#else
     215            setupBondPolyData();
     216
     217            if (_cylinderSource == NULL) {
     218                _cylinderSource = vtkSmartPointer<vtkCylinderSource>::New();
     219                _cylinderSource->SetRadius(0.075);
     220                _cylinderSource->SetHeight(1.0);
     221                _cylinderSource->SetResolution(12);
     222                _cylinderSource->CappingOff();
     223                _cylinderTrans = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
     224                _cylinderTrans->SetInputConnection(_cylinderSource->GetOutputPort());
     225                vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New();
     226                trans->RotateZ(-90.0);
     227                _cylinderTrans->SetTransform(trans);
     228            }
     229            if (_lineSource == NULL) {
     230                _lineSource = vtkSmartPointer<vtkLineSource>::New();
     231                _lineSource->SetPoint1(-0.5, 0, 0);
     232                _lineSource->SetPoint2(0.5, 0, 0);
     233            }
     234
     235            _bondMapper->SetSourceConnection(_cylinderTrans->GetOutputPort());
     236            _bondMapper->SetInputConnection(_bondPD->GetProducerPort());
     237            _bondMapper->SetOrientationArray("bond_orientations");
     238            _bondMapper->SetOrientationModeToDirection();
     239            _bondMapper->OrientOn();
     240            _bondMapper->SetScaleArray("bond_scales");
     241            _bondMapper->SetScaleModeToScaleByVectorComponents();
     242            _bondMapper->ScalingOn();
     243            _bondMapper->ClampingOff();
     244#endif
    133245            _bondProp->SetMapper(_bondMapper);
    134246            getAssembly()->AddPart(_bondProp);
    135247        }
    136248        if (pd->GetNumberOfVerts() > 0) {
     249            vtkSmartPointer<vtkPointSetToLabelHierarchy> hier = vtkSmartPointer<vtkPointSetToLabelHierarchy>::New();
     250            hier->SetInput(pd);
     251            hier->SetLabelArrayName("labels");
     252            hier->GetTextProperty()->SetColor(0, 0, 0);
     253            _labelMapper->SetInputConnection(hier->GetOutputPort());
     254            _labelProp->SetMapper(_labelMapper);
     255
    137256            // Atoms
    138257            vtkSmartPointer<vtkSphereSource> sphereSource = vtkSmartPointer<vtkSphereSource>::New();
    139             sphereSource->SetRadius(.08);
     258            sphereSource->SetRadius(1.0);
     259            sphereSource->SetThetaResolution(14);
     260            sphereSource->SetPhiResolution(14);
     261#ifndef MOLECULE_USE_GLYPH3D_MAPPER
    140262            if (_glypher == NULL)
    141263                _glypher = vtkSmartPointer<vtkGlyph3D>::New();
    142264            _glypher->SetSourceConnection(sphereSource->GetOutputPort());
    143265            _glypher->SetInput(pd);
    144             if (_atomScaling != NO_ATOM_SCALING &&
    145                 ds->GetPointData() != NULL &&
     266            if (ds->GetPointData() != NULL &&
    146267                ds->GetPointData()->GetVectors() != NULL) {
    147268                _glypher->SetScaleModeToScaleByVector();
     
    154275            _glypher->OrientOff();
    155276            _atomMapper->SetInputConnection(_glypher->GetOutputPort());
     277#else
     278            _atomMapper->SetSourceConnection(sphereSource->GetOutputPort());
     279            _atomMapper->SetInputConnection(pd->GetProducerPort());
     280            if (ds->GetPointData() != NULL &&
     281                ds->GetPointData()->GetVectors() != NULL) {
     282                _atomMapper->SetScaleArray(vtkDataSetAttributes::VECTORS);
     283                _atomMapper->SetScaleModeToScaleByMagnitude();
     284                _atomMapper->ScalingOn();
     285            } else {
     286                _atomMapper->SetScaleModeToNoDataScaling();
     287                _atomMapper->ScalingOff();
     288            }
     289            _atomMapper->OrientOff();
     290#endif
    156291            _atomProp->SetMapper(_atomMapper);
    157292            getAssembly()->AddPart(_atomProp);
     
    163298    }
    164299
     300    setAtomLabelVisibility(_labelsOn);
     301
    165302    _atomMapper->Update();
    166303    _bondMapper->Update();
     304    _labelMapper->Update();
    167305}
    168306
    169307void Molecule::updateRanges(Renderer *renderer)
    170308{
    171     VtkGraphicsObject::updateRanges(renderer);
    172 
    173     if (_lut != NULL && _dataSet != NULL) {
    174         vtkDataSet *ds = _dataSet->getVtkDataSet();
    175         if (ds == NULL)
    176             return;
    177         if (ds->GetPointData() == NULL ||
    178             ds->GetPointData()->GetScalars() == NULL ||
    179             strcmp(ds->GetPointData()->GetScalars()->GetName(), "element") != 0) {
    180             _lut->SetRange(_dataRange);
    181         }
     309    if (_dataSet == NULL) {
     310        ERROR("called before setDataSet");
     311        return;
     312    }
     313
     314    if (renderer->getUseCumulativeRange()) {
     315        renderer->getCumulativeDataRange(_dataRange,
     316                                         _dataSet->getActiveScalarsName(),
     317                                         1);
     318        renderer->getCumulativeDataRange(_vectorMagnitudeRange,
     319                                         _dataSet->getActiveVectorsName(),
     320                                         3);
     321        for (int i = 0; i < 3; i++) {
     322            renderer->getCumulativeDataRange(_vectorComponentRange[i],
     323                                             _dataSet->getActiveVectorsName(),
     324                                             3, i);
     325        }
     326    } else {
     327        _dataSet->getScalarRange(_dataRange);
     328        _dataSet->getVectorRange(_vectorMagnitudeRange);
     329        for (int i = 0; i < 3; i++) {
     330            _dataSet->getVectorRange(_vectorComponentRange[i], i);
     331        }
     332    }
     333
     334    // Need to update color map ranges
     335    double *rangePtr = _colorFieldRange;
     336    if (_colorFieldRange[0] > _colorFieldRange[1]) {
     337        rangePtr = NULL;
     338    }
     339    setColorMode(_colorMode, _colorFieldType, _colorFieldName.c_str(), rangePtr);
     340}
     341
     342void Molecule::setColorMode(ColorMode mode)
     343{
     344    _colorMode = mode;
     345    if (_dataSet == NULL)
     346        return;
     347
     348    switch (mode) {
     349    case COLOR_BY_ELEMENTS: // Assume default scalar is "element" array
     350        setColorMode(mode,
     351                     DataSet::POINT_DATA,
     352                     "element");
     353        break;
     354    case COLOR_BY_SCALAR:
     355        setColorMode(mode,
     356                     _dataSet->getActiveScalarsType(),
     357                     _dataSet->getActiveScalarsName(),
     358                     _dataRange);
     359        break;
     360    case COLOR_BY_VECTOR_MAGNITUDE:
     361        setColorMode(mode,
     362                     _dataSet->getActiveVectorsType(),
     363                     _dataSet->getActiveVectorsName(),
     364                     _vectorMagnitudeRange);
     365        break;
     366    case COLOR_BY_VECTOR_X:
     367        setColorMode(mode,
     368                     _dataSet->getActiveVectorsType(),
     369                     _dataSet->getActiveVectorsName(),
     370                     _vectorComponentRange[0]);
     371        break;
     372    case COLOR_BY_VECTOR_Y:
     373        setColorMode(mode,
     374                     _dataSet->getActiveVectorsType(),
     375                     _dataSet->getActiveVectorsName(),
     376                     _vectorComponentRange[1]);
     377        break;
     378    case COLOR_BY_VECTOR_Z:
     379        setColorMode(mode,
     380                     _dataSet->getActiveVectorsType(),
     381                     _dataSet->getActiveVectorsName(),
     382                     _vectorComponentRange[2]);
     383        break;
     384    case COLOR_CONSTANT:
     385    default:
     386        setColorMode(mode, DataSet::POINT_DATA, NULL, NULL);
     387        break;
     388    }
     389}
     390
     391void Molecule::setColorMode(ColorMode mode,
     392                            const char *name, double range[2])
     393{
     394    if (_dataSet == NULL)
     395        return;
     396    DataSet::DataAttributeType type = DataSet::POINT_DATA;
     397    int numComponents = 1;
     398    if (name != NULL && strlen(name) > 0 &&
     399        !_dataSet->getFieldInfo(name, &type, &numComponents)) {
     400        ERROR("Field not found: %s", name);
     401        return;
     402    }
     403    setColorMode(mode, type, name, range);
     404}
     405
     406void Molecule::setColorMode(ColorMode mode, DataSet::DataAttributeType type,
     407                            const char *name, double range[2])
     408{
     409    _colorMode = mode;
     410    _colorFieldType = type;
     411    if (name == NULL)
     412        _colorFieldName.clear();
     413    else
     414        _colorFieldName = name;
     415    if (range == NULL) {
     416        _colorFieldRange[0] = DBL_MAX;
     417        _colorFieldRange[1] = -DBL_MAX;
     418    } else {
     419        memcpy(_colorFieldRange, range, sizeof(double)*2);
     420    }
     421
     422    if (_dataSet == NULL || (_atomMapper == NULL && _bondMapper == NULL))
     423        return;
     424
     425    switch (type) {
     426    case DataSet::POINT_DATA:
     427        if (_atomMapper != NULL)
     428            _atomMapper->SetScalarModeToUsePointFieldData();
     429        if (_bondMapper != NULL)
     430            _bondMapper->SetScalarModeToUsePointFieldData();
     431        break;
     432    case DataSet::CELL_DATA:
     433        if (_atomMapper != NULL)
     434            _atomMapper->SetScalarModeToUseCellFieldData();
     435        if (_bondMapper != NULL)
     436            _bondMapper->SetScalarModeToUseCellFieldData();
     437        break;
     438    default:
     439        ERROR("Unsupported DataAttributeType: %d", type);
     440        return;
     441    }
     442
     443    if (name != NULL && strlen(name) > 0) {
     444        if (_atomMapper != NULL)
     445            _atomMapper->SelectColorArray(name);
     446        if (_bondMapper != NULL)
     447            _bondMapper->SelectColorArray(name);
     448    } else {
     449        if (_atomMapper != NULL)
     450            _atomMapper->SetScalarModeToDefault();
     451        if (_bondMapper != NULL)
     452            _bondMapper->SetScalarModeToDefault();
     453    }
     454
     455    if (_lut != NULL) {
     456        if (range != NULL) {
     457            _lut->SetRange(range);
     458        } else if (mode == COLOR_BY_ELEMENTS) {
     459            double range[2];
     460            range[0] = 0;
     461            range[1] = NUM_ELEMENTS;
     462            _lut->SetRange(range);
     463        } else if (name != NULL && strlen(name) > 0) {
     464            double r[2];
     465            int comp = -1;
     466            if (mode == COLOR_BY_VECTOR_X)
     467                comp = 0;
     468            else if (mode == COLOR_BY_VECTOR_Y)
     469                comp = 1;
     470            else if (mode == COLOR_BY_VECTOR_Z)
     471                comp = 2;
     472
     473            if (_renderer->getUseCumulativeRange()) {
     474                int numComponents;
     475                if  (!_dataSet->getFieldInfo(name, type, &numComponents)) {
     476                    ERROR("Field not found: %s, type: %d", name, type);
     477                    return;
     478                } else if (numComponents < comp+1) {
     479                    ERROR("Request for component %d in field with %d components",
     480                          comp, numComponents);
     481                    return;
     482                }
     483                _renderer->getCumulativeDataRange(r, name, type, numComponents, comp);
     484            } else {
     485                _dataSet->getDataRange(r, name, type, comp);
     486            }
     487            _lut->SetRange(r);
     488        }
     489    }
     490
     491    switch (mode) {
     492    case COLOR_BY_ELEMENTS:
     493        if (_atomMapper != NULL)
     494            _atomMapper->ScalarVisibilityOn();
     495        if (_bondMapper != NULL)
     496            _bondMapper->ScalarVisibilityOn();
     497        break;
     498    case COLOR_BY_SCALAR:
     499        if (_atomMapper != NULL)
     500            _atomMapper->ScalarVisibilityOn();
     501        if (_bondMapper != NULL)
     502            _bondMapper->ScalarVisibilityOn();
     503        break;
     504    case COLOR_BY_VECTOR_MAGNITUDE:
     505        if (_atomMapper != NULL)
     506            _atomMapper->ScalarVisibilityOn();
     507        if (_bondMapper != NULL)
     508            _bondMapper->ScalarVisibilityOn();
     509        if (_lut != NULL) {
     510            _lut->SetVectorModeToMagnitude();
     511        }
     512        break;
     513    case COLOR_BY_VECTOR_X:
     514        if (_atomMapper != NULL)
     515            _atomMapper->ScalarVisibilityOn();
     516        if (_bondMapper != NULL)
     517            _bondMapper->ScalarVisibilityOn();
     518        if (_lut != NULL) {
     519            _lut->SetVectorModeToComponent();
     520            _lut->SetVectorComponent(0);
     521        }
     522        break;
     523    case COLOR_BY_VECTOR_Y:
     524        if (_atomMapper != NULL)
     525            _atomMapper->ScalarVisibilityOn();
     526        if (_bondMapper != NULL)
     527            _bondMapper->ScalarVisibilityOn();
     528        if (_lut != NULL) {
     529            _lut->SetVectorModeToComponent();
     530            _lut->SetVectorComponent(1);
     531        }
     532        break;
     533    case COLOR_BY_VECTOR_Z:
     534        if (_atomMapper != NULL)
     535            _atomMapper->ScalarVisibilityOn();
     536        if (_bondMapper != NULL)
     537            _bondMapper->ScalarVisibilityOn();
     538        if (_lut != NULL) {
     539            _lut->SetVectorModeToComponent();
     540            _lut->SetVectorComponent(2);
     541        }
     542        break;
     543    case COLOR_CONSTANT:
     544    default:
     545        if (_atomMapper != NULL)
     546            _atomMapper->ScalarVisibilityOff();
     547        if (_bondMapper != NULL)
     548            _bondMapper->ScalarVisibilityOff();
     549        break;
    182550    }
    183551}
     
    211579            _bondMapper->SetLookupTable(_lut);
    212580        }
    213     }
    214 
    215     _lut->DeepCopy(cmap->getLookupTable());
    216     _lut->Modified();
    217 
    218     // Element color maps need to retain their range
    219     // Only set LUT range if we are not coloring by element
    220     vtkDataSet *ds = _dataSet->getVtkDataSet();
    221     if (ds == NULL)
    222         return;
    223     if (ds->GetPointData() == NULL ||
    224         ds->GetPointData()->GetScalars() == NULL ||
    225         strcmp(ds->GetPointData()->GetScalars()->GetName(), "element") != 0) {
    226         _lut->SetRange(_dataRange);
     581        _lut->DeepCopy(cmap->getLookupTable());
     582        switch (_colorMode) {
     583        case COLOR_BY_ELEMENTS: {
     584            double range[2];
     585            range[0] = 0;
     586            range[1] = NUM_ELEMENTS;
     587            _lut->SetRange(range);
     588        }
     589            break;
     590        case COLOR_CONSTANT:
     591        case COLOR_BY_SCALAR:
     592            _lut->SetRange(_dataRange);
     593            break;
     594        case COLOR_BY_VECTOR_MAGNITUDE:
     595            _lut->SetRange(_vectorMagnitudeRange);
     596            break;
     597        case COLOR_BY_VECTOR_X:
     598            _lut->SetRange(_vectorComponentRange[0]);
     599            break;
     600        case COLOR_BY_VECTOR_Y:
     601            _lut->SetRange(_vectorComponentRange[1]);
     602            break;
     603        case COLOR_BY_VECTOR_Z:
     604            _lut->SetRange(_vectorComponentRange[2]);
     605            break;
     606        default:
     607            break;
     608        }
     609    } else {
     610        double range[2];
     611        _lut->GetTableRange(range);
     612        _lut->DeepCopy(cmap->getLookupTable());
     613        _lut->SetRange(range);
     614    }
     615}
     616
     617/**
     618 * \brief Turn on/off rendering of atom labels
     619 */
     620void Molecule::setAtomLabelVisibility(bool state)
     621{
     622    _labelsOn = state;
     623    if (_labelProp != NULL) {
     624        _labelProp->SetVisibility((state ? 1 : 0));
    227625    }
    228626}
     
    245643    if (_bondProp != NULL) {
    246644        _bondProp->SetVisibility((state ? 1 : 0));
     645    }
     646}
     647
     648/**
     649 * \brief Toggle visibility of the prop
     650 */
     651void Molecule::setVisibility(bool state)
     652{
     653    VtkGraphicsObject::setVisibility(state);
     654    if (_labelProp != NULL) {
     655        if (!state)
     656            _labelProp->SetVisibility(0);
     657        else
     658            setAtomLabelVisibility(_labelsOn);
     659    }
     660}
     661
     662/**
     663 * \brief Set opacity of molecule
     664 */
     665void Molecule::setOpacity(double opacity)
     666{
     667    VtkGraphicsObject::setOpacity(opacity);
     668    if (_labelMapper != NULL) {
     669        _labelMapper->SetBackgroundOpacity(opacity);
     670    }
     671}
     672
     673void Molecule::setBondStyle(BondStyle style)
     674{
     675#ifdef MOLECULE_USE_GLYPH3D_MAPPER
     676    switch (style) {
     677    case BOND_STYLE_CYLINDER:
     678        if (_bondProp != NULL) {
     679            _bondProp->GetProperty()->SetLineWidth(_edgeWidth);
     680            _bondProp->GetProperty()->SetLighting(_lighting ? 1 : 0);
     681        }
     682        if (_bondMapper != NULL && _cylinderTrans != NULL) {
     683            _cylinderTrans->Modified();
     684            _bondMapper->SetSourceConnection(_cylinderTrans->GetOutputPort());
     685            _bondMapper->Modified();
     686        }
     687        break;
     688    case BOND_STYLE_LINE:
     689        if (_bondProp != NULL) {
     690            _bondProp->GetProperty()->LightingOff();
     691        }
     692        if (_bondMapper != NULL && _lineSource != NULL) {
     693            _lineSource->Modified();
     694            _bondMapper->SetSourceConnection(_lineSource->GetOutputPort());
     695            _bondMapper->Modified();
     696        }
     697         break;
     698    default:
     699        WARN("Unknown bond style");   
     700    }
     701#endif
     702}
     703
     704/**
     705 * \brief Set constant bond color
     706 */
     707void Molecule::setBondColor(float color[3])
     708{
     709    _bondColor[0] = color[0];
     710    _bondColor[1] = color[1];
     711    _bondColor[2] = color[2];
     712    if (_bondProp != NULL) {
     713        _bondProp->GetProperty()->SetColor(_bondColor[0], _bondColor[1], _bondColor[2]);
     714    }
     715}
     716
     717/**
     718 * \brief Set mode to determine how bonds are colored
     719 */
     720void Molecule::setBondColorMode(BondColorMode mode)
     721{
     722    if (_bondMapper == NULL) return;
     723
     724    switch (mode) {
     725    case BOND_COLOR_BY_ELEMENTS:
     726        _bondMapper->ScalarVisibilityOn();
     727        break;
     728    case BOND_COLOR_CONSTANT:
     729        _bondMapper->ScalarVisibilityOff();
     730        break;
     731    default:
     732        WARN("Unknown bond color mode");
    247733    }
    248734}
     
    271757    if (_dataSet != NULL) {
    272758        vtkDataSet *ds = _dataSet->getVtkDataSet();
    273         addRadiusArray(ds, _atomScaling);
     759        addRadiusArray(ds, _atomScaling, _radiusScale);
     760#ifndef MOLECULE_USE_GLYPH3D_MAPPER
    274761        if (_glypher != NULL) {
    275             if (_atomScaling != NO_ATOM_SCALING &&
    276                 ds->GetPointData() != NULL &&
    277                 ds->GetPointData()->GetVectors() != NULL) {
    278                 _glypher->SetScaleModeToScaleByVector();
    279                 _glypher->ScalingOn();
    280             } else {
    281                 _glypher->SetScaleModeToDataScalingOff();
    282                 _glypher->ScalingOff();
    283             }
    284         }
    285     }
     762            assert(ds->GetPointData() != NULL &&
     763                   ds->GetPointData()->GetVectors() != NULL);
     764            _glypher->SetScaleModeToScaleByVector();
     765            _glypher->ScalingOn();
     766        }
     767#else
     768        if (_atomMapper != NULL) {
     769             assert(ds->GetPointData() != NULL &&
     770                    ds->GetPointData()->GetVectors() != NULL);
     771            _atomMapper->SetScaleModeToScaleByMagnitude();
     772            _atomMapper->SetScaleArray(vtkDataSetAttributes::VECTORS);
     773            _atomMapper->ScalingOn();
     774        }
     775#endif
     776    }
     777}
     778
     779/**
     780 * \brief Set the constant radius scaling factor for atoms.  This
     781 * can be used to convert from Angstroms to atom coordinates units.
     782 */
     783void Molecule::setAtomRadiusScale(double scale)
     784{
     785    _radiusScale = scale;
     786    if (_dataSet != NULL) {
     787        vtkDataSet *ds = _dataSet->getVtkDataSet();
     788        addRadiusArray(ds, _atomScaling, _radiusScale);
     789    }
     790}
     791
     792/**
     793 * \brief Set the constant radius scaling factor for bonds.
     794 */
     795void Molecule::setBondRadiusScale(double scale)
     796{
     797#ifndef MOLECULE_USE_GLYPH3D_MAPPER
     798    if (_tuber != NULL) {
     799        _tuber->SetRadius(scale);
     800    }
     801#else
     802    if (_cylinderSource != NULL) {
     803        _cylinderSource->SetRadius(scale);
     804        // Workaround bug with source modification not causing
     805        // mapper to be updated
     806        if (_bondMapper != NULL) {
     807            _bondMapper->Modified();
     808        }
     809    }
     810#endif
     811}
     812
     813#ifdef MOLECULE_USE_GLYPH3D_MAPPER
     814void Molecule::setupBondPolyData()
     815{
     816    if (_dataSet == NULL)
     817        return;
     818    if (_bondPD == NULL) {
     819        _bondPD = vtkSmartPointer<vtkPolyData>::New();
     820    } else {
     821        _bondPD->Initialize();
     822    }
     823    vtkPolyData *pd = vtkPolyData::SafeDownCast(_dataSet->getVtkDataSet());
     824    if (pd == NULL)
     825        return;
     826    vtkCellArray *lines = pd->GetLines();
     827    lines->InitTraversal();
     828    vtkIdType npts, *pts;
     829    vtkSmartPointer<vtkPoints> bondPoints = vtkSmartPointer<vtkPoints>::New();
     830    vtkSmartPointer<vtkIntArray> bondElements = vtkSmartPointer<vtkIntArray>::New();
     831    vtkSmartPointer<vtkDoubleArray> bondVectors = vtkSmartPointer<vtkDoubleArray>::New();
     832    vtkSmartPointer<vtkDoubleArray> bondScales = vtkSmartPointer<vtkDoubleArray>::New();
     833    bondElements->SetName("element");
     834    bondVectors->SetName("bond_orientations");
     835    bondVectors->SetNumberOfComponents(3);
     836    bondScales->SetName("bond_scales");
     837    bondScales->SetNumberOfComponents(3);
     838    vtkDataArray *elements = NULL;
     839    if (pd->GetPointData() != NULL &&
     840        pd->GetPointData()->GetScalars() != NULL &&
     841        strcmp(pd->GetPointData()->GetScalars()->GetName(), "element") == 0) {
     842        elements = pd->GetPointData()->GetScalars();
     843    }
     844    for (int i = 0; lines->GetNextCell(npts, pts); i++) {
     845        assert(npts == 2);
     846        double pt0[3], pt1[3];
     847        double newPt0[3], newPt1[3];
     848        //double *pt0 = pd->GetPoint(pts[0]);
     849        //double *pt1 = pd->GetPoint(pts[1]);
     850        pd->GetPoint(pts[0], pt0);
     851        pd->GetPoint(pts[1], pt1);
     852        double center[3];
     853
     854        for (int j = 0; j < 3; j++)
     855            center[j] = pt0[j] + (pt1[j] - pt0[j]) * 0.5;
     856        for (int j = 0; j < 3; j++)
     857            newPt0[j] = pt0[j] + (pt1[j] - pt0[j]) * 0.25;
     858        for (int j = 0; j < 3; j++)
     859            newPt1[j] = pt0[j] + (pt1[j] - pt0[j]) * 0.75;
     860
     861        bondPoints->InsertNextPoint(newPt0);
     862        bondPoints->InsertNextPoint(newPt1);
     863
     864        TRACE("Bond %d: (%g,%g,%g)-(%g,%g,%g)-(%g,%g,%g)", i,
     865              pt0[0], pt0[1], pt0[2],
     866              center[0], center[1], center[2],
     867              pt1[0], pt1[1], pt1[2]);
     868
     869        double vec[3];
     870        for (int j = 0; j < 3; j++)
     871            vec[j] = center[j] - pt0[j];
     872
     873        bondVectors->InsertNextTupleValue(vec);
     874        bondVectors->InsertNextTupleValue(vec);
     875        TRACE("Bond %d, vec: %g,%g,%g", i, vec[0], vec[1], vec[2]);
     876
     877        double scale[3];
     878        scale[0] = sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]);
     879        scale[1] = 1.0;
     880        scale[2] = 1.0;
     881
     882        bondScales->InsertNextTupleValue(scale);
     883        bondScales->InsertNextTupleValue(scale);
     884
     885        if (elements != NULL) {
     886            int element = (int)elements->GetComponent(pts[0], 0);
     887            TRACE("Bond %d, elt 0: %d", i, element);
     888            bondElements->InsertNextValue(element);
     889            element = (int)elements->GetComponent(pts[1], 0);
     890            TRACE("Bond %d, elt 1: %d", i, element);
     891            bondElements->InsertNextValue(element);
     892        }
     893    }
     894    _bondPD->SetPoints(bondPoints);
     895    if (elements != NULL)
     896        _bondPD->GetPointData()->SetScalars(bondElements);
     897    _bondPD->GetPointData()->AddArray(bondVectors);
     898    _bondPD->GetPointData()->AddArray(bondScales);
     899}
     900#endif
     901
     902void Molecule::addLabelArray(vtkDataSet *dataSet)
     903{
     904    vtkDataArray *elements = NULL;
     905    if (dataSet->GetPointData() != NULL &&
     906        dataSet->GetPointData()->GetScalars() != NULL &&
     907        strcmp(dataSet->GetPointData()->GetScalars()->GetName(), "element") == 0) {
     908        elements = dataSet->GetPointData()->GetScalars();
     909    } else {
     910        WARN("Can't label atoms without an element array");
     911    }
     912
     913    vtkSmartPointer<vtkStringArray> labelArray = vtkSmartPointer<vtkStringArray>::New();
     914    labelArray->SetName("labels");
     915    vtkPolyData *pd = vtkPolyData::SafeDownCast(dataSet);
     916    if (pd == NULL) {
     917        ERROR("DataSet not a PolyData");
     918        return;
     919    }
     920    for (int i = 0; i < pd->GetNumberOfVerts(); i++) {
     921        char buf[32];
     922        if (elements != NULL) {
     923            int elt = (int)elements->GetComponent(i, 0);
     924            sprintf(buf, "%s%d", g_elementNames[elt], i);
     925        } else {
     926            sprintf(buf, "%d", i);
     927        }
     928        labelArray->InsertNextValue(buf);
     929    }
     930    dataSet->GetPointData()->AddArray(labelArray);
    286931}
    287932
     
    290935 * specified in the "element" scalar array
    291936 */
    292 void Molecule::addRadiusArray(vtkDataSet *dataSet, AtomScaling scaling)
    293 {
    294     if (dataSet->GetPointData() == NULL ||
    295         dataSet->GetPointData()->GetScalars() == NULL) {
    296         return;
    297     }
    298     vtkDataArray *elements = dataSet->GetPointData()->GetScalars();
    299     if (strcmp(elements->GetName(), "element") != 0) {
    300         return;
     937void Molecule::addRadiusArray(vtkDataSet *dataSet, AtomScaling scaling, double scaleFactor)
     938{
     939    vtkDataArray *elements = NULL;
     940    if (dataSet->GetPointData() != NULL &&
     941        dataSet->GetPointData()->GetScalars() != NULL &&
     942        strcmp(dataSet->GetPointData()->GetScalars()->GetName(), "element") == 0) {
     943        elements = dataSet->GetPointData()->GetScalars();
     944    } else if (scaling != NO_ATOM_SCALING) {
     945        WARN("Can't use non-constant scaling without an element array");
    301946    }
    302947    const float *radiusSource = NULL;
     
    313958    case NO_ATOM_SCALING:
    314959    default:
    315         return;
     960        ;
    316961    }
    317962    vtkSmartPointer<vtkFloatArray> radii = vtkSmartPointer<vtkFloatArray>::New();
    318963    radii->SetName("radius");
    319964    radii->SetNumberOfComponents(3);
    320     for (int i = 0; i < elements->GetNumberOfTuples(); i++) {
    321         int elt = (int)elements->GetComponent(i, 0);
     965    vtkPolyData *pd = vtkPolyData::SafeDownCast(dataSet);
     966    if (pd == NULL) {
     967        ERROR("DataSet not a PolyData");
     968        return;
     969    }
     970    for (int i = 0; i < pd->GetNumberOfVerts(); i++) {
    322971        float tuple[3];
    323         tuple[0] = radiusSource[elt];
    324         tuple[1] = 0;
    325         tuple[2] = 0;
     972        tuple[1] = tuple[2] = 0;
     973        if (elements != NULL && radiusSource != NULL) {
     974            int elt = (int)elements->GetComponent(i, 0);
     975            tuple[0] = radiusSource[elt] * scaleFactor;
     976        } else {
     977            tuple[0] = scaleFactor;
     978        }
    326979        radii->InsertNextTupleValue(tuple);
    327980    }
     
    339992    elementCmap->setNumberOfTableEntries(NUM_ELEMENTS+1);
    340993    for (int i = 0; i <= NUM_ELEMENTS; i++) {
    341         cp[i].value = i/((double)(NUM_ELEMENTS+1));
     994        cp[i].value = i/((double)NUM_ELEMENTS);
    342995        for (int c = 0; c < 3; c++) {
    343996            cp[i].color[c] = ((double)g_elementColors[i][c])/255.;
     
    3551008    double range[2];
    3561009    range[0] = 0;
    357     range[1] = NUM_ELEMENTS+1;
     1010    range[1] = NUM_ELEMENTS;
    3581011    elementCmap->getLookupTable()->SetRange(range);
    3591012
  • branches/nanovis2/packages/vizservers/vtkvis/RpMolecule.h

    r2612 r3175  
    1313#include <vtkPolyDataMapper.h>
    1414#include <vtkActor.h>
     15#include <vtkActor2D.h>
    1516#include <vtkAssembly.h>
     17#if ((VTK_MAJOR_VERSION > 5) || (VTK_MAJOR_VERSION == 5 && VTK_MINOR_VERSION >= 8))
     18#define MOLECULE_USE_GLYPH3D_MAPPER
     19#include <vtkGlyph3DMapper.h>
     20#include <vtkTransformPolyDataFilter.h>
     21#include <vtkCylinderSource.h>
     22#include <vtkLineSource.h>
     23#else
    1624#include <vtkGlyph3D.h>
     25#include <vtkTubeFilter.h>
     26#endif
     27#include <vtkLabelPlacementMapper.h>
    1728
    1829#include "ColorMap.h"
     
    4152        ATOMIC_RADIUS
    4253    };
     54    enum BondStyle {
     55        BOND_STYLE_CYLINDER,
     56        BOND_STYLE_LINE
     57    };
     58    enum ColorMode {
     59        COLOR_BY_ELEMENTS,
     60        COLOR_BY_SCALAR,
     61        COLOR_BY_VECTOR_MAGNITUDE,
     62        COLOR_BY_VECTOR_X,
     63        COLOR_BY_VECTOR_Y,
     64        COLOR_BY_VECTOR_Z,
     65        COLOR_CONSTANT
     66    };
     67    enum BondColorMode {
     68        BOND_COLOR_BY_ELEMENTS,
     69        BOND_COLOR_CONSTANT
     70    };
    4371
    4472    Molecule();
     
    5078    }
    5179
     80    virtual vtkProp *getOverlayProp()
     81    {
     82        return _labelProp;
     83    }
     84
     85    virtual void setDataSet(DataSet *dataSet,
     86                            Renderer *renderer);
     87
    5288    virtual void setClippingPlanes(vtkPlaneCollection *planes);
     89
     90    void setColorMode(ColorMode mode, DataSet::DataAttributeType type,
     91                      const char *name, double range[2] = NULL);
     92
     93    void setColorMode(ColorMode mode,
     94                      const char *name, double range[2] = NULL);
     95
     96    void setColorMode(ColorMode mode);
    5397
    5498    void setColorMap(ColorMap *colorMap);
     
    68112    void setAtomScaling(AtomScaling state);
    69113
     114    void setAtomRadiusScale(double scale);
     115
     116    void setBondRadiusScale(double scale);
     117
     118    virtual void setVisibility(bool state);
     119
     120    virtual void setOpacity(double opacity);
     121
    70122    void setAtomVisibility(bool state);
    71123
     124    void setAtomLabelVisibility(bool state);
     125
    72126    void setBondVisibility(bool state);
     127
     128    void setBondStyle(BondStyle style);
     129
     130    void setBondColor(float color[3]);
     131
     132    void setBondColorMode(BondColorMode mode);
    73133
    74134    static ColorMap *createElementColorMap();
     
    78138    virtual void update();
    79139
    80     static void addRadiusArray(vtkDataSet *dataSet, AtomScaling scaling);
     140#ifdef MOLECULE_USE_GLYPH3D_MAPPER
     141    void setupBondPolyData();
     142#endif
    81143
     144    static void addLabelArray(vtkDataSet *dataSet);
     145
     146    static void addRadiusArray(vtkDataSet *dataSet, AtomScaling scaling, double scaleFactor);
     147
     148    float _bondColor[3];
     149    double _radiusScale;
    82150    AtomScaling _atomScaling;
     151    bool _labelsOn;
    83152    ColorMap *_colorMap;
     153    ColorMode _colorMode;
     154    std::string _colorFieldName;
     155    DataSet::DataAttributeType _colorFieldType;
     156    double _colorFieldRange[2];
     157    double _vectorMagnitudeRange[2];
     158    double _vectorComponentRange[3][2];
     159    Renderer *_renderer;
    84160
    85161    vtkSmartPointer<vtkLookupTable> _lut;
    86162    vtkSmartPointer<vtkActor> _atomProp;
    87163    vtkSmartPointer<vtkActor> _bondProp;
     164    vtkSmartPointer<vtkActor2D> _labelProp;
     165#ifndef MOLECULE_USE_GLYPH3D_MAPPER
    88166    vtkSmartPointer<vtkGlyph3D> _glypher;
     167    vtkSmartPointer<vtkTubeFilter> _tuber;
    89168    vtkSmartPointer<vtkPolyDataMapper> _atomMapper;
    90169    vtkSmartPointer<vtkPolyDataMapper> _bondMapper;
     170#else
     171    vtkSmartPointer<vtkPolyData> _bondPD;
     172    vtkSmartPointer<vtkCylinderSource> _cylinderSource;
     173    vtkSmartPointer<vtkTransformPolyDataFilter>_cylinderTrans;
     174    vtkSmartPointer<vtkLineSource> _lineSource;
     175    vtkSmartPointer<vtkGlyph3DMapper> _atomMapper;
     176    vtkSmartPointer<vtkGlyph3DMapper> _bondMapper;
     177#endif
     178    vtkSmartPointer<vtkLabelPlacementMapper> _labelMapper;
    91179};
    92180
  • branches/nanovis2/packages/vizservers/vtkvis/RpMoleculeData.h

    r2321 r3175  
    464464    1.700f, // 109  Mt
    465465};
     466
     467const char * g_elementNames[NUM_ELEMENTS+1] = {
     468    "?",    //   0  ?
     469    "H",    //   1  H
     470    "He",   //   2  He
     471    "Li",   //   3  Li
     472    "Be",   //   4  Be
     473    "B",    //   5  B
     474    "C",    //   6  C
     475    "N",    //   7  N
     476    "O",    //   8  O
     477    "F",    //   9  F
     478    "Ne",   //  10  Ne
     479    "Na",   //  11  Na
     480    "Mg",   //  12  Mg
     481    "Al",   //  13  Al
     482    "Si",   //  14  Si
     483    "P",    //  15  P
     484    "S",    //  16  S
     485    "Cl",   //  17  Cl
     486    "Ar",   //  18  Ar
     487    "K",    //  19  K
     488    "Ca",   //  20  Ca
     489    "Sc",   //  21  Sc
     490    "Ti",   //  22  Ti
     491    "V",    //  23  V
     492    "Cr",   //  24  Cr
     493    "Mn",   //  25  Mn
     494    "Fe",   //  26  Fe
     495    "Co",   //  27  Co
     496    "Ni",   //  28  Ni
     497    "Cu",   //  29  Cu
     498    "Zn",   //  30  Zn
     499    "Ga",   //  31  Ga
     500    "Ge",   //  32  Ge
     501    "As",   //  33  As
     502    "Se",   //  34  Se
     503    "Br",   //  35  Br
     504    "Kr",   //  36  Kr
     505    "Rb",   //  37  Rb
     506    "Sr",   //  38  Sr
     507    "Y",    //  39  Y
     508    "Zr",   //  40  Zr
     509    "Nb",   //  41  Nb
     510    "Mo",   //  42  Mo
     511    "Tc",   //  43  Tc
     512    "Ru",   //  44  Ru
     513    "Rh",   //  45  Rh
     514    "Pd",   //  46  Pd
     515    "Ag",   //  47  Ag
     516    "Cd",   //  48  Cd
     517    "In",   //  49  In
     518    "Sn",   //  50  Sn
     519    "Sb",   //  51  Sb
     520    "Te",   //  52  Te
     521    "I",    //  53  I
     522    "Xe",   //  54  Xe
     523    "Cs",   //  55  Cs
     524    "Ba",   //  56  Ba
     525    "La",   //  57  La
     526    "Ce",   //  58  Ce
     527    "Pr",   //  59  Pr
     528    "Nd",   //  60  Nd
     529    "Pm",   //  61  Pm
     530    "Sm",   //  62  Sm
     531    "Eu",   //  63  Eu
     532    "Gd",   //  64  Gd
     533    "Tb",   //  65  Tb
     534    "Dy",   //  66  Dy
     535    "Ho",   //  67  Ho
     536    "Er",   //  68  Er
     537    "Tm",   //  69  Tm
     538    "Yb",   //  70  Yb
     539    "Lu",   //  71  Lu
     540    "Hf",   //  72  Hf
     541    "Ta",   //  73  Ta
     542    "W",    //  74  W
     543    "Re",   //  75  Re
     544    "Os",   //  76  Os
     545    "Ir",   //  77  Ir
     546    "Pt",   //  78  Pt
     547    "Au",   //  79  Au
     548    "Hg",   //  80  Hg
     549    "Tl",   //  81  Tl
     550    "Pb",   //  82  Pb
     551    "Bi",   //  83  Bi
     552    "Po",   //  84  Po
     553    "At",   //  85  At
     554    "Rn",   //  86  Rn
     555    "Fr",   //  87  Fr
     556    "Ra",   //  88  Ra
     557    "Ac",   //  89  Ac
     558    "Th",   //  90  Th
     559    "Pa",   //  91  Pa
     560    "U",    //  92  U
     561    "Np",   //  93  Np
     562    "Pu",   //  94  Pu
     563    "Am",   //  95  Am
     564    "Cm",   //  96  Cm
     565    "Bk",   //  97  Bk
     566    "Cf",   //  98  Cf
     567    "Es",   //  99  Es
     568    "Fm",   // 100  Fm
     569    "Md",   // 101  Md
     570    "No",   // 102  No
     571    "Lr",   // 103  Lr
     572    "Rf",   // 104  Rf
     573    "Db",   // 105  Db
     574    "Sg",   // 106  Sg
     575    "Bh",   // 107  Bh
     576    "Hs",   // 108  Hs
     577    "Mt",   // 109  Mt
     578};
  • branches/nanovis2/packages/vizservers/vtkvis/RpPolyData.cpp

    r2641 r3175  
    2727    VtkGraphicsObject()
    2828{
    29     _color[0] = 0.0f;
    30     _color[1] = 0.0f;
    31     _color[2] = 1.0f;
    3229}
    3330
  • branches/nanovis2/packages/vizservers/vtkvis/RpVtkDataSet.cpp

    r2639 r3175  
    1313#include <vtkCharArray.h>
    1414#include <vtkDataSetReader.h>
     15#include <vtkDataSetWriter.h>
    1516#include <vtkPolyData.h>
    1617#include <vtkStructuredPoints.h>
     
    140141}
    141142
     143void DataSet::writeDataFile(const char *filename)
     144{
     145    if (_dataSet == NULL)
     146        return;
     147   
     148    vtkSmartPointer<vtkDataSetWriter> writer = vtkSmartPointer<vtkDataSetWriter>::New();
     149
     150    writer->SetFileName(filename);
     151    writer->SetInput(_dataSet);
     152    writer->Write();
     153}
     154
    142155/**
    143156 * \brief Read a VTK data file
     
    192205void DataSet::print() const
    193206{
    194     TRACE("DataSet class: %s", _dataSet->GetClassName());
    195 
    196     TRACE("DataSet memory: %g MiB", _dataSet->GetActualMemorySize()/1024.);
     207    print(_dataSet);
     208}
     209
     210void DataSet::print(vtkDataSet *ds)
     211{
     212    if (ds == NULL)
     213        return;
     214
     215    TRACE("DataSet class: %s", ds->GetClassName());
     216
     217    TRACE("DataSet memory: %g MiB", ds->GetActualMemorySize()/1024.);
    197218
    198219    double bounds[6];
    199     getBounds(bounds);
     220    ds->GetBounds(bounds);
    200221
    201222    // Topology
     
    204225          bounds[2], bounds[3],
    205226          bounds[4], bounds[5]);
    206     TRACE("Points: %d Cells: %d", _dataSet->GetNumberOfPoints(), _dataSet->GetNumberOfCells());
     227    TRACE("Points: %d Cells: %d", ds->GetNumberOfPoints(), ds->GetNumberOfCells());
    207228
    208229    double dataRange[2];
    209     if (_dataSet->GetPointData() != NULL) {
    210         TRACE("PointData arrays: %d", _dataSet->GetPointData()->GetNumberOfArrays());
    211         for (int i = 0; i < _dataSet->GetPointData()->GetNumberOfArrays(); i++) {
    212             _dataSet->GetPointData()->GetArray(i)->GetRange(dataRange, -1);
    213             TRACE("PointData[%d]: '%s' comp:%d, (%g,%g)", i,
    214                   _dataSet->GetPointData()->GetArrayName(i),
    215                   _dataSet->GetPointData()->GetArray(i)->GetNumberOfComponents(),
    216                   dataRange[0], dataRange[1]);
    217         }
    218     }
    219     if (_dataSet->GetCellData() != NULL) {
    220         TRACE("CellData arrays: %d", _dataSet->GetCellData()->GetNumberOfArrays());
    221         for (int i = 0; i < _dataSet->GetCellData()->GetNumberOfArrays(); i++) {
    222             _dataSet->GetCellData()->GetArray(i)->GetRange(dataRange, -1);
    223             TRACE("CellData[%d]: '%s' comp:%d, (%g,%g)", i,
    224                   _dataSet->GetCellData()->GetArrayName(i),
    225                   _dataSet->GetCellData()->GetArray(i)->GetNumberOfComponents(),
    226                   dataRange[0], dataRange[1]);
    227         }
    228     }
    229     if (_dataSet->GetFieldData() != NULL) {
    230         TRACE("FieldData arrays: %d", _dataSet->GetFieldData()->GetNumberOfArrays());
    231         for (int i = 0; i < _dataSet->GetFieldData()->GetNumberOfArrays(); i++) {
    232             _dataSet->GetFieldData()->GetArray(i)->GetRange(dataRange, -1);
    233             TRACE("FieldData[%d]: '%s' comp:%d, tuples:%d (%g,%g)", i,
    234                   _dataSet->GetFieldData()->GetArrayName(i),
    235                   _dataSet->GetFieldData()->GetArray(i)->GetNumberOfComponents(),
    236                   _dataSet->GetFieldData()->GetArray(i)->GetNumberOfTuples(),
    237                   dataRange[0], dataRange[1]);
     230    if (ds->GetPointData() != NULL) {
     231        TRACE("PointData arrays: %d", ds->GetPointData()->GetNumberOfArrays());
     232        for (int i = 0; i < ds->GetPointData()->GetNumberOfArrays(); i++) {
     233            if (ds->GetPointData()->GetArray(i) != NULL) {
     234                ds->GetPointData()->GetArray(i)->GetRange(dataRange, -1);
     235                TRACE("PointData[%d]: '%s' comp:%d, (%g,%g)", i,
     236                      ds->GetPointData()->GetArrayName(i),
     237                      ds->GetPointData()->GetAbstractArray(i)->GetNumberOfComponents(),
     238                      dataRange[0], dataRange[1]);
     239            } else {
     240                TRACE("PointData[%d]: '%s' comp:%d", i,
     241                      ds->GetPointData()->GetArrayName(i),
     242                      ds->GetPointData()->GetAbstractArray(i)->GetNumberOfComponents());
     243            }
     244        }
     245    }
     246    if (ds->GetCellData() != NULL) {
     247        TRACE("CellData arrays: %d", ds->GetCellData()->GetNumberOfArrays());
     248        for (int i = 0; i < ds->GetCellData()->GetNumberOfArrays(); i++) {
     249            if (ds->GetCellData()->GetArray(i) != NULL) {
     250                ds->GetCellData()->GetArray(i)->GetRange(dataRange, -1);
     251                TRACE("CellData[%d]: '%s' comp:%d, (%g,%g)", i,
     252                      ds->GetCellData()->GetArrayName(i),
     253                      ds->GetCellData()->GetAbstractArray(i)->GetNumberOfComponents(),
     254                      dataRange[0], dataRange[1]);
     255            } else {
     256                TRACE("CellData[%d]: '%s' comp:%d", i,
     257                      ds->GetCellData()->GetArrayName(i),
     258                      ds->GetCellData()->GetAbstractArray(i)->GetNumberOfComponents());
     259            }
     260        }
     261    }
     262    if (ds->GetFieldData() != NULL) {
     263        TRACE("FieldData arrays: %d", ds->GetFieldData()->GetNumberOfArrays());
     264        for (int i = 0; i < ds->GetFieldData()->GetNumberOfArrays(); i++) {
     265            if (ds->GetFieldData()->GetArray(i) != NULL) {
     266                ds->GetFieldData()->GetArray(i)->GetRange(dataRange, -1);
     267                TRACE("FieldData[%d]: '%s' comp:%d, tuples:%d (%g,%g)", i,
     268                      ds->GetFieldData()->GetArrayName(i),
     269                      ds->GetFieldData()->GetAbstractArray(i)->GetNumberOfComponents(),
     270                      ds->GetFieldData()->GetAbstractArray(i)->GetNumberOfTuples(),
     271                      dataRange[0], dataRange[1]);
     272            } else {
     273                TRACE("FieldData[%d]: '%s' comp:%d, tuples:%d", i,
     274                      ds->GetFieldData()->GetArrayName(i),
     275                      ds->GetFieldData()->GetAbstractArray(i)->GetNumberOfComponents(),
     276                      ds->GetFieldData()->GetAbstractArray(i)->GetNumberOfTuples());
     277            }
    238278        }
    239279    }
     
    246286        _dataSet->GetPointData()->GetNumberOfArrays() > 0) {
    247287        for (int i = 0; i < _dataSet->GetPointData()->GetNumberOfArrays(); i++) {
    248             if (_dataSet->GetPointData()->GetArray(i)->GetNumberOfComponents() == 1) {
     288            if (_dataSet->GetPointData()->GetArray(i) != NULL &&
     289                _dataSet->GetPointData()->GetArray(i)->GetNumberOfComponents() == 1) {
    249290                TRACE("Setting point scalars to '%s'", _dataSet->GetPointData()->GetArrayName(i));
    250291                _dataSet->GetPointData()->SetActiveScalars(_dataSet->GetPointData()->GetArrayName(i));
     
    257298        _dataSet->GetPointData()->GetNumberOfArrays() > 0) {
    258299        for (int i = 0; i < _dataSet->GetPointData()->GetNumberOfArrays(); i++) {
    259             if (_dataSet->GetPointData()->GetArray(i)->GetNumberOfComponents() == 3) {
     300            if (_dataSet->GetPointData()->GetArray(i) != NULL &&
     301                _dataSet->GetPointData()->GetArray(i)->GetNumberOfComponents() == 3) {
    260302                TRACE("Setting point vectors to '%s'", _dataSet->GetPointData()->GetArrayName(i));
    261303                _dataSet->GetPointData()->SetActiveVectors(_dataSet->GetPointData()->GetArrayName(i));
     
    268310        _dataSet->GetCellData()->GetNumberOfArrays() > 0) {
    269311        for (int i = 0; i < _dataSet->GetCellData()->GetNumberOfArrays(); i++) {
    270             if (_dataSet->GetCellData()->GetArray(i)->GetNumberOfComponents() == 1) {
     312            if (_dataSet->GetCellData()->GetArray(i) != NULL &&
     313                _dataSet->GetCellData()->GetArray(i)->GetNumberOfComponents() == 1) {
    271314                TRACE("Setting cell scalars to '%s'", _dataSet->GetCellData()->GetArrayName(i));
    272315                _dataSet->GetCellData()->SetActiveScalars(_dataSet->GetCellData()->GetArrayName(i));
     
    279322        _dataSet->GetCellData()->GetNumberOfArrays() > 0) {
    280323        for (int i = 0; i < _dataSet->GetCellData()->GetNumberOfArrays(); i++) {
    281             if (_dataSet->GetCellData()->GetArray(i)->GetNumberOfComponents() == 3) {
     324            if (_dataSet->GetCellData()->GetArray(i) != NULL &&
     325                _dataSet->GetCellData()->GetArray(i)->GetNumberOfComponents() == 3) {
    282326                TRACE("Setting cell vectors to '%s'", _dataSet->GetCellData()->GetArrayName(i));
    283327                _dataSet->GetCellData()->SetActiveVectors(_dataSet->GetCellData()->GetArrayName(i));
     
    635679{
    636680    if (_dataSet->GetPointData() != NULL &&
    637         _dataSet->GetPointData()->GetArray(fieldName) != NULL) {
     681        _dataSet->GetPointData()->GetAbstractArray(fieldName) != NULL) {
    638682        if (type != NULL)
    639683            *type = POINT_DATA;
    640684        if (numComponents != NULL)
    641             *numComponents = _dataSet->GetPointData()->GetArray(fieldName)->GetNumberOfComponents();
     685            *numComponents = _dataSet->GetPointData()->GetAbstractArray(fieldName)->GetNumberOfComponents();
    642686        return true;
    643687    } else if (_dataSet->GetCellData() != NULL &&
    644                _dataSet->GetCellData()->GetArray(fieldName) != NULL) {
     688               _dataSet->GetCellData()->GetAbstractArray(fieldName) != NULL) {
    645689        if (type != NULL)
    646690            *type = CELL_DATA;
    647691        if (numComponents != NULL)
    648             *numComponents = _dataSet->GetCellData()->GetArray(fieldName)->GetNumberOfComponents();
     692            *numComponents = _dataSet->GetCellData()->GetAbstractArray(fieldName)->GetNumberOfComponents();
    649693        return true;
    650694    } else if (_dataSet->GetFieldData() != NULL &&
    651                _dataSet->GetFieldData()->GetArray(fieldName) != NULL) {
     695               _dataSet->GetFieldData()->GetAbstractArray(fieldName) != NULL) {
    652696        if (type != NULL)
    653697            *type = FIELD_DATA;
    654698        if (numComponents != NULL)
    655             *numComponents = _dataSet->GetFieldData()->GetArray(fieldName)->GetNumberOfComponents();
     699            *numComponents = _dataSet->GetFieldData()->GetAbstractArray(fieldName)->GetNumberOfComponents();
    656700        return true;
    657701    }
     
    666710    case POINT_DATA:
    667711        if (_dataSet->GetPointData() != NULL &&
    668             _dataSet->GetPointData()->GetArray(fieldName) != NULL) {
     712            _dataSet->GetPointData()->GetAbstractArray(fieldName) != NULL) {
    669713            if (numComponents != NULL)
    670                 *numComponents = _dataSet->GetPointData()->GetArray(fieldName)->GetNumberOfComponents();
     714                *numComponents = _dataSet->GetPointData()->GetAbstractArray(fieldName)->GetNumberOfComponents();
    671715            return true;
    672716        } else
     
    675719    case CELL_DATA:
    676720        if (_dataSet->GetCellData() != NULL &&
    677             _dataSet->GetCellData()->GetArray(fieldName) != NULL) {
     721            _dataSet->GetCellData()->GetAbstractArray(fieldName) != NULL) {
    678722            if (numComponents != NULL)
    679                 *numComponents = _dataSet->GetCellData()->GetArray(fieldName)->GetNumberOfComponents();
     723                *numComponents = _dataSet->GetCellData()->GetAbstractArray(fieldName)->GetNumberOfComponents();
    680724            return true;
    681725        } else
     
    684728    case FIELD_DATA:
    685729        if (_dataSet->GetFieldData() != NULL &&
    686             _dataSet->GetFieldData()->GetArray(fieldName) != NULL) {
     730            _dataSet->GetFieldData()->GetAbstractArray(fieldName) != NULL) {
    687731            if (numComponents != NULL)
    688                 *numComponents = _dataSet->GetFieldData()->GetArray(fieldName)->GetNumberOfComponents();
     732                *numComponents = _dataSet->GetFieldData()->GetAbstractArray(fieldName)->GetNumberOfComponents();
    689733            return true;
    690734        } else
     
    715759            for (int i = 0; i < _dataSet->GetPointData()->GetNumberOfArrays(); i++) {
    716760                if (numComponents == -1 ||
    717                     _dataSet->GetPointData()->GetArray(i)->GetNumberOfComponents() == numComponents) {
     761                    (_dataSet->GetPointData()->GetAbstractArray(i) != NULL &&
     762                     _dataSet->GetPointData()->GetAbstractArray(i)->GetNumberOfComponents() == numComponents)) {
    718763                    names.push_back(_dataSet->GetPointData()->GetArrayName(i));
    719764                }
     
    725770            for (int i = 0; i < _dataSet->GetCellData()->GetNumberOfArrays(); i++) {
    726771                if (numComponents == -1 ||
    727                     _dataSet->GetCellData()->GetArray(i)->GetNumberOfComponents() == numComponents) {
     772                    (_dataSet->GetCellData()->GetAbstractArray(i) != NULL &&
     773                     _dataSet->GetCellData()->GetAbstractArray(i)->GetNumberOfComponents() == numComponents)) {
    728774                    names.push_back(_dataSet->GetCellData()->GetArrayName(i));
    729775                }
     
    735781            for (int i = 0; i < _dataSet->GetFieldData()->GetNumberOfArrays(); i++) {
    736782                if (numComponents == -1 ||
    737                     _dataSet->GetFieldData()->GetArray(i)->GetNumberOfComponents() == numComponents) {
     783                    (_dataSet->GetFieldData()->GetAbstractArray(i) != NULL &&
     784                     _dataSet->GetFieldData()->GetAbstractArray(i)->GetNumberOfComponents() == numComponents)) {
    738785                    names.push_back(_dataSet->GetFieldData()->GetArrayName(i));
    739786                }
  • branches/nanovis2/packages/vizservers/vtkvis/RpVtkDataSet.h

    r2640 r3175  
    3737    DataSet(const std::string& name);
    3838    virtual ~DataSet();
     39
     40    void writeDataFile(const char *filename);
    3941
    4042    bool setDataFile(const char *filename);
     
    135137    }
    136138
     139    static void print(vtkDataSet *ds);
     140
    137141private:
    138142    DataSet();
  • branches/nanovis2/packages/vizservers/vtkvis/RpVtkGraphicsObject.cpp

    r2641 r3175  
    1818        _dataSet = dataSet;
    1919
    20         if (renderer->getUseCumulativeRange()) {
     20        if (renderer != NULL &&
     21            dataSet != NULL &&
     22            renderer->getUseCumulativeRange()) {
    2123            renderer->getCumulativeDataRange(_dataRange,
    2224                                             _dataSet->getActiveScalarsName(),
    2325                                             1);
    24         } else {
     26        } else if (_dataSet != NULL) {
    2527            _dataSet->getScalarRange(_dataRange);
    2628        }
     
    3638        return;
    3739    }
     40    if (renderer == NULL) {
     41        ERROR("NULL renderer");
     42        return;
     43    }
    3844
    3945    if (renderer->getUseCumulativeRange()) {
     
    4147                                         _dataSet->getActiveScalarsName(),
    4248                                         1);
    43     } else  {
     49    } else {
    4450        _dataSet->getScalarRange(_dataRange);
    4551    }
  • branches/nanovis2/packages/vizservers/vtkvis/RpVtkGraphicsObject.h

    r2771 r3175  
    7272
    7373    /**
    74      * \brief Specify input DataSet
    75      *
    76      * Default implementation calls update()
    77      *
    78      * \param[in] dataSet DataSet to use in rendering
    79      */
    80     virtual void setDataSet(DataSet *dataSet)
    81     {
    82         if (_dataSet != dataSet) {
    83             _dataSet = dataSet;
    84 
    85             update();
    86         }
    87     }
    88 
    89     /**
    9074     * \brief Specify input DataSet and information on cumulative data ranges
    9175     *
     
    163147    {
    164148        return vtkAssembly::SafeDownCast(_prop);
     149    }
     150
     151    virtual vtkProp *getOverlayProp()
     152    {
     153        return NULL;
    165154    }
    166155
     
    242231
    243232    /**
     233     * \brief Set 2D aspect ratio scaling
     234     *
     235     * \param aspect 0=no scaling, otherwise aspect
     236     * is horiz/vertical ratio
     237     */
     238    virtual void setAspect(double aspect)
     239    {
     240        ;
     241    }
     242
     243    /**
    244244     * \brief Set the prop scaling
    245245     *
     
    251251            getProp3D()->SetScale(scale);
    252252        }
     253    }
     254
     255    /**
     256     * \brief Get the physical bounds of the prop
     257     *
     258     * If the prop is scaled, these bounds will be
     259     * scaled as well
     260     */
     261    virtual double *getBounds()
     262    {
     263        if (getProp() != NULL)
     264            return getProp()->GetBounds();
     265        else
     266            return NULL;
     267    }
     268
     269    /**
     270     * \brief Get the data bounds of the prop
     271     *
     272     * If the prop is scaled, these bounds will NOT
     273     * be scaled, they will reflect the unscaled data
     274     * bounds.
     275     */
     276    virtual double *getUnscaledBounds()
     277    {
     278        if (getProp3D() != NULL) {
     279            double scale[3];
     280            getProp3D()->GetScale(scale);
     281            if (scale[0] == scale[1] && scale[1] == scale[2] &&
     282                scale[0] == 1.0) {
     283                return getBounds();
     284            } else if (getBounds() != NULL) {
     285                _unscaledBounds[0] = getBounds()[0] / scale[0];
     286                _unscaledBounds[1] = getBounds()[1] / scale[0];
     287                _unscaledBounds[2] = getBounds()[2] / scale[1];
     288                _unscaledBounds[3] = getBounds()[3] / scale[1];
     289                _unscaledBounds[4] = getBounds()[4] / scale[2];
     290                _unscaledBounds[5] = getBounds()[5] / scale[2];
     291                return _unscaledBounds;
     292            }
     293        }
     294        return getBounds();
    253295    }
    254296
     
    658700        if (getActor() != NULL) {
    659701            setCulling(getActor()->GetProperty(), state);
    660          } else if (getAssembly() != NULL) {
     702        } else if (getAssembly() != NULL) {
    661703            vtkProp3DCollection *props = getAssembly()->GetParts();
    662704            vtkProp3D *prop;
     
    743785    DataSet *_dataSet;
    744786    double _dataRange[2];
     787    double _unscaledBounds[6];
    745788    double _opacity;
    746789    float _color[3];
  • branches/nanovis2/packages/vizservers/vtkvis/RpVtkRenderer.cpp

    r2865 r3175  
    2424#include <vtkCharArray.h>
    2525#include <vtkAxisActor2D.h>
    26 #include <vtkCubeAxesActor.h>
    2726#ifdef USE_CUSTOM_AXES
     27#include "vtkRpCubeAxesActor.h"
    2828#include "vtkRpCubeAxesActor2D.h"
    2929#else
     30#include <vtkCubeAxesActor.h>
    3031#include <vtkCubeAxesActor2D.h>
    3132#endif
     
    5859    _windowWidth(500),
    5960    _windowHeight(500),
     61    _cameraMode(PERSPECTIVE),
    6062    _imgCameraPlane(PLANE_XY),
    6163    _imgCameraOffset(0),
    6264    _cameraZoomRatio(1),
    6365    _useCumulativeRange(true),
    64     _cumulativeRangeOnlyVisible(false),
    65     _cameraMode(PERSPECTIVE)
     66    _cumulativeRangeOnlyVisible(false)
    6667{
    6768    _bgColor[0] = 0;
     
    141142{
    142143    TRACE("Enter");
    143     TRACE("Deleting Contour2Ds");
    144     for (Contour2DHashmap::iterator itr = _contour2Ds.begin();
    145          itr != _contour2Ds.end(); ++itr) {
    146         delete itr->second;
    147     }
    148     _contour2Ds.clear();
    149     TRACE("Deleting Contour3Ds");
    150     for (Contour3DHashmap::iterator itr = _contour3Ds.begin();
    151          itr != _contour3Ds.end(); ++itr) {
    152         delete itr->second;
    153     }
    154     _contour3Ds.clear();
    155     TRACE("Deleting Cutplanes");
    156     for (CutplaneHashmap::iterator itr = _cutplanes.begin();
    157          itr != _cutplanes.end(); ++itr) {
    158         delete itr->second;
    159     }
    160     _cutplanes.clear();
    161     TRACE("Deleting Glyphs");
    162     for (GlyphsHashmap::iterator itr = _glyphs.begin();
    163          itr != _glyphs.end(); ++itr) {
    164         delete itr->second;
    165     }
    166     _glyphs.clear();
    167     TRACE("Deleting HeightMaps");
    168     for (HeightMapHashmap::iterator itr = _heightMaps.begin();
    169          itr != _heightMaps.end(); ++itr) {
    170         delete itr->second;
    171     }
    172     _heightMaps.clear();
    173     TRACE("Deleting LICs");
    174     for (LICHashmap::iterator itr = _lics.begin();
    175          itr != _lics.end(); ++itr) {
    176         delete itr->second;
    177     }
    178     _lics.clear();
    179     TRACE("Deleting Molecules");
    180     for (MoleculeHashmap::iterator itr = _molecules.begin();
    181          itr != _molecules.end(); ++itr) {
    182         delete itr->second;
    183     }
    184     _molecules.clear();
    185     TRACE("Deleting PolyDatas");
    186     for (PolyDataHashmap::iterator itr = _polyDatas.begin();
    187          itr != _polyDatas.end(); ++itr) {
    188         delete itr->second;
    189     }
    190     _polyDatas.clear();
    191     TRACE("Deleting PseudoColors");
    192     for (PseudoColorHashmap::iterator itr = _pseudoColors.begin();
    193          itr != _pseudoColors.end(); ++itr) {
    194         delete itr->second;
    195     }
    196     _pseudoColors.clear();
    197     TRACE("Deleting Streamlines");
    198     for (StreamlinesHashmap::iterator itr = _streamlines.begin();
    199          itr != _streamlines.end(); ++itr) {
    200         delete itr->second;
    201     }
    202     _streamlines.clear();
    203     TRACE("Deleting Volumes");
    204     for (VolumeHashmap::iterator itr = _volumes.begin();
    205          itr != _volumes.end(); ++itr) {
    206         delete itr->second;
    207     }
    208     _volumes.clear();
     144
     145    deleteAllGraphicsObjects<Arc>();
     146    deleteAllGraphicsObjects<Arrow>();
     147    deleteAllGraphicsObjects<Box>();
     148    deleteAllGraphicsObjects<Cone>();
     149    deleteAllGraphicsObjects<Contour2D>();
     150    deleteAllGraphicsObjects<Contour3D>();
     151    deleteAllGraphicsObjects<Cutplane>();
     152    deleteAllGraphicsObjects<Cylinder>();
     153    deleteAllGraphicsObjects<Disk>();
     154    deleteAllGraphicsObjects<Glyphs>();
     155    deleteAllGraphicsObjects<Group>();
     156    deleteAllGraphicsObjects<HeightMap>();
     157    deleteAllGraphicsObjects<LIC>();
     158    deleteAllGraphicsObjects<Line>();
     159    deleteAllGraphicsObjects<Molecule>();
     160    deleteAllGraphicsObjects<PolyData>();
     161    deleteAllGraphicsObjects<Polygon>();
     162    deleteAllGraphicsObjects<PseudoColor>();
     163    deleteAllGraphicsObjects<Sphere>();
     164    deleteAllGraphicsObjects<Streamlines>();
     165    deleteAllGraphicsObjects<Volume>();
     166    deleteAllGraphicsObjects<Warp>();
     167
    209168    TRACE("Deleting ColorMaps");
    210169    // Delete color maps and data sets last in case references still
     
    280239        deleteGraphicsObject<Streamlines>(itr->second->getName());
    281240        deleteGraphicsObject<Volume>(itr->second->getName());
     241        deleteGraphicsObject<Warp>(itr->second->getName());
    282242 
    283243        if (itr->second->getProp() != NULL) {
     
    546506
    547507    _cubeAxesActor2D->ScalingOff();
    548     //_cubeAxesActor2D->SetShowActualBounds(0);
     508    _cubeAxesActor2D->SetShowActualBounds(1);
    549509    _cubeAxesActor2D->SetFontFactor(1.25);
    550510    // Use "nice" range and number of ticks/labels
     
    878838void Renderer::updateColorMap(ColorMap *cmap)
    879839{
    880     for (Contour3DHashmap::iterator itr = _contour3Ds.begin();
    881          itr != _contour3Ds.end(); ++itr) {
    882         if (itr->second->getColorMap() == cmap) {
    883             itr->second->updateColorMap();
    884             _needsRedraw = true;
    885         }
    886     }
    887     for (CutplaneHashmap::iterator itr = _cutplanes.begin();
    888          itr != _cutplanes.end(); ++itr) {
    889         if (itr->second->getColorMap() == cmap) {
    890             itr->second->updateColorMap();
    891             _needsRedraw = true;
    892         }
    893     }
    894     for (GlyphsHashmap::iterator itr = _glyphs.begin();
    895          itr != _glyphs.end(); ++itr) {
    896         if (itr->second->getColorMap() == cmap) {
    897             itr->second->updateColorMap();
    898             _needsRedraw = true;
    899         }
    900     }
    901     for (HeightMapHashmap::iterator itr = _heightMaps.begin();
    902          itr != _heightMaps.end(); ++itr) {
    903         if (itr->second->getColorMap() == cmap) {
    904             itr->second->updateColorMap();
    905             _needsRedraw = true;
    906         }
    907     }
    908     for (LICHashmap::iterator itr = _lics.begin();
    909          itr != _lics.end(); ++itr) {
    910         if (itr->second->getColorMap() == cmap) {
    911             itr->second->updateColorMap();
    912             _needsRedraw = true;
    913         }
    914     }
    915     for (MoleculeHashmap::iterator itr = _molecules.begin();
    916          itr != _molecules.end(); ++itr) {
    917         if (itr->second->getColorMap() == cmap) {
    918             itr->second->updateColorMap();
    919             _needsRedraw = true;
    920         }
    921     }
    922     for (PseudoColorHashmap::iterator itr = _pseudoColors.begin();
    923          itr != _pseudoColors.end(); ++itr) {
    924         if (itr->second->getColorMap() == cmap) {
    925             itr->second->updateColorMap();
    926             _needsRedraw = true;
    927         }
    928     }
    929     for (StreamlinesHashmap::iterator itr = _streamlines.begin();
    930          itr != _streamlines.end(); ++itr) {
    931         if (itr->second->getColorMap() == cmap) {
    932             itr->second->updateColorMap();
    933             _needsRedraw = true;
    934         }
    935     }
    936     for (VolumeHashmap::iterator itr = _volumes.begin();
    937          itr != _volumes.end(); ++itr) {
    938         if (itr->second->getColorMap() == cmap) {
    939             itr->second->updateColorMap();
    940             _needsRedraw = true;
    941         }
    942     }
     840    updateGraphicsObjectColorMap<Contour2D>(cmap);
     841    updateGraphicsObjectColorMap<Contour3D>(cmap);
     842    updateGraphicsObjectColorMap<Cutplane>(cmap);
     843    updateGraphicsObjectColorMap<Glyphs>(cmap);
     844    updateGraphicsObjectColorMap<HeightMap>(cmap);
     845    updateGraphicsObjectColorMap<LIC>(cmap);
     846    updateGraphicsObjectColorMap<Molecule>(cmap);
     847    updateGraphicsObjectColorMap<PseudoColor>(cmap);
     848    updateGraphicsObjectColorMap<Streamlines>(cmap);
     849    updateGraphicsObjectColorMap<Volume>(cmap);
     850    updateGraphicsObjectColorMap<Warp>(cmap);
    943851}
    944852
     
    948856bool Renderer::colorMapUsed(ColorMap *cmap)
    949857{
    950     for (Contour3DHashmap::iterator itr = _contour3Ds.begin();
    951          itr != _contour3Ds.end(); ++itr) {
    952         if (itr->second->getColorMap() == cmap)
    953             return true;
    954     }
    955     for (CutplaneHashmap::iterator itr = _cutplanes.begin();
    956          itr != _cutplanes.end(); ++itr) {
    957         if (itr->second->getColorMap() == cmap)
    958             return true;
    959     }
    960     for (GlyphsHashmap::iterator itr = _glyphs.begin();
    961          itr != _glyphs.end(); ++itr) {
    962         if (itr->second->getColorMap() == cmap)
    963             return true;
    964     }
    965     for (HeightMapHashmap::iterator itr = _heightMaps.begin();
    966          itr != _heightMaps.end(); ++itr) {
    967         if (itr->second->getColorMap() == cmap)
    968             return true;
    969     }
    970     for (LICHashmap::iterator itr = _lics.begin();
    971          itr != _lics.end(); ++itr) {
    972         if (itr->second->getColorMap() == cmap)
    973             return true;
    974     }
    975     for (MoleculeHashmap::iterator itr = _molecules.begin();
    976          itr != _molecules.end(); ++itr) {
    977         if (itr->second->getColorMap() == cmap)
    978             return true;
    979     }
    980     for (PseudoColorHashmap::iterator itr = _pseudoColors.begin();
    981          itr != _pseudoColors.end(); ++itr) {
    982         if (itr->second->getColorMap() == cmap)
    983             return true;
    984     }
    985     for (StreamlinesHashmap::iterator itr = _streamlines.begin();
    986          itr != _streamlines.end(); ++itr) {
    987         if (itr->second->getColorMap() == cmap)
    988             return true;
    989     }
    990     for (VolumeHashmap::iterator itr = _volumes.begin();
    991          itr != _volumes.end(); ++itr) {
    992         if (itr->second->getColorMap() == cmap)
    993             return true;
    994     }
     858    if (graphicsObjectColorMapUsed<Contour2D>(cmap))
     859        return true;
     860    if (graphicsObjectColorMapUsed<Contour3D>(cmap))
     861        return true;
     862    if (graphicsObjectColorMapUsed<Cutplane>(cmap))
     863        return true;
     864    if (graphicsObjectColorMapUsed<Glyphs>(cmap))
     865        return true;
     866    if (graphicsObjectColorMapUsed<HeightMap>(cmap))
     867        return true;
     868    if (graphicsObjectColorMapUsed<LIC>(cmap))
     869        return true;
     870    if (graphicsObjectColorMapUsed<Molecule>(cmap))
     871        return true;
     872    if (graphicsObjectColorMapUsed<PseudoColor>(cmap))
     873        return true;
     874    if (graphicsObjectColorMapUsed<Streamlines>(cmap))
     875        return true;
     876    if (graphicsObjectColorMapUsed<Volume>(cmap))
     877        return true;
     878    if (graphicsObjectColorMapUsed<Warp>(cmap))
     879        return true;
     880
    995881    return false;
    996882}
     
    15421428    }
    15431429    _needsRedraw = true;
     1430}
     1431
     1432void Renderer::setObjectAspects(double aspectRatio)
     1433{
     1434    setGraphicsObjectAspect<Arc>(aspectRatio);
     1435    setGraphicsObjectAspect<Arrow>(aspectRatio);
     1436    setGraphicsObjectAspect<Box>(aspectRatio);
     1437    setGraphicsObjectAspect<Cone>(aspectRatio);
     1438    setGraphicsObjectAspect<Contour2D>(aspectRatio);
     1439    setGraphicsObjectAspect<Contour3D>(aspectRatio);
     1440    setGraphicsObjectAspect<Cutplane>(aspectRatio);
     1441    setGraphicsObjectAspect<Cylinder>(aspectRatio);
     1442    setGraphicsObjectAspect<Disk>(aspectRatio);
     1443    setGraphicsObjectAspect<Glyphs>(aspectRatio);
     1444    setGraphicsObjectAspect<HeightMap>(aspectRatio);
     1445    setGraphicsObjectAspect<LIC>(aspectRatio);
     1446    setGraphicsObjectAspect<Line>(aspectRatio);
     1447    setGraphicsObjectAspect<Molecule>(aspectRatio);
     1448    setGraphicsObjectAspect<PolyData>(aspectRatio);
     1449    setGraphicsObjectAspect<Polygon>(aspectRatio);
     1450    setGraphicsObjectAspect<PseudoColor>(aspectRatio);
     1451    setGraphicsObjectAspect<Sphere>(aspectRatio);
     1452    setGraphicsObjectAspect<Streamlines>(aspectRatio);
     1453    setGraphicsObjectAspect<Volume>(aspectRatio);
     1454    setGraphicsObjectAspect<Warp>(aspectRatio);
    15441455}
    15451456
     
    20051916    double offsetX = pxOffsetX * pxToWorld;
    20061917    double offsetY = pxOffsetY * pxToWorld;
     1918    double plotWidthWorld = imgWidthPx * pxToWorld;
     1919    double plotHeightWorld = imgHeightPx * pxToWorld;
    20071920
    20081921    TRACE("Window: %d %d", _windowWidth, _windowHeight);
     
    20391952        _cameraClipPlanes[1]->SetNormal(1, 0, 0);
    20401953        // top
    2041         _cameraClipPlanes[2]->SetOrigin(0, _imgWorldOrigin[1] + _imgWorldDims[1], 0);
     1954        _cameraClipPlanes[2]->SetOrigin(0, _imgWorldOrigin[1] + plotHeightWorld, 0);
    20421955        _cameraClipPlanes[2]->SetNormal(0, -1, 0);
    20431956        // right
    2044         _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + _imgWorldDims[0], 0, 0);
     1957        _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + plotWidthWorld, 0, 0);
    20451958        _cameraClipPlanes[3]->SetNormal(-1, 0, 0);
    2046         _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + _imgWorldDims[0],
    2047                                     _imgWorldOrigin[1], _imgWorldOrigin[1] + _imgWorldDims[1],
     1959        _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + plotWidthWorld,
     1960                                    _imgWorldOrigin[1], _imgWorldOrigin[1] + plotHeightWorld,
    20481961                                    _imgCameraOffset, _imgCameraOffset);
    20491962        _cubeAxesActor2D->XAxisVisibilityOn();
     
    20621975        _cameraClipPlanes[1]->SetNormal(0, 0, 1);
    20631976        // top
    2064         _cameraClipPlanes[2]->SetOrigin(0, _imgWorldOrigin[1] + _imgWorldDims[1], 0);
     1977        _cameraClipPlanes[2]->SetOrigin(0, _imgWorldOrigin[1] + plotHeightWorld, 0);
    20651978        _cameraClipPlanes[2]->SetNormal(0, -1, 0);
    20661979        // right
    2067         _cameraClipPlanes[3]->SetOrigin(0, 0, _imgWorldOrigin[0] + _imgWorldDims[0]);
     1980        _cameraClipPlanes[3]->SetOrigin(0, 0, _imgWorldOrigin[0] + plotWidthWorld);
    20681981        _cameraClipPlanes[3]->SetNormal(0, 0, -1);
    20691982        _cubeAxesActor2D->SetBounds(_imgCameraOffset, _imgCameraOffset,
    2070                                     _imgWorldOrigin[1], _imgWorldOrigin[1] + _imgWorldDims[1],
    2071                                     _imgWorldOrigin[0], _imgWorldOrigin[0] + _imgWorldDims[0]);
     1983                                    _imgWorldOrigin[1], _imgWorldOrigin[1] + plotHeightWorld,
     1984                                    _imgWorldOrigin[0], _imgWorldOrigin[0] + plotWidthWorld);
    20721985        _cubeAxesActor2D->XAxisVisibilityOff();
    20731986        _cubeAxesActor2D->YAxisVisibilityOn();
     
    20851998        _cameraClipPlanes[1]->SetNormal(1, 0, 0);
    20861999        // top
    2087         _cameraClipPlanes[2]->SetOrigin(0, 0, _imgWorldOrigin[1] + _imgWorldDims[1]);
     2000        _cameraClipPlanes[2]->SetOrigin(0, 0, _imgWorldOrigin[1] + plotHeightWorld);
    20882001        _cameraClipPlanes[2]->SetNormal(0, 0, -1);
    20892002        // right
    2090         _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + _imgWorldDims[0], 0, 0);
     2003        _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + plotWidthWorld, 0, 0);
    20912004        _cameraClipPlanes[3]->SetNormal(-1, 0, 0);
    2092         _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + _imgWorldDims[0],
     2005        _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + plotWidthWorld,
    20932006                                    _imgCameraOffset, _imgCameraOffset,
    2094                                     _imgWorldOrigin[1], _imgWorldOrigin[1] + _imgWorldDims[1]);
     2007                                    _imgWorldOrigin[1], _imgWorldOrigin[1] + plotHeightWorld);
    20952008        _cubeAxesActor2D->XAxisVisibilityOn();
    20962009        _cubeAxesActor2D->YAxisVisibilityOff();
     
    22752188            mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds());
    22762189    }
    2277     for (Contour2DHashmap::iterator itr = _contour2Ds.begin();
    2278              itr != _contour2Ds.end(); ++itr) {
    2279         if ((!onlyVisible || itr->second->getVisibility()) &&
    2280             itr->second->getProp() != NULL)
    2281             mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds());
    2282     }
    2283     for (Contour3DHashmap::iterator itr = _contour3Ds.begin();
    2284              itr != _contour3Ds.end(); ++itr) {
    2285         if ((!onlyVisible || itr->second->getVisibility()) &&
    2286             itr->second->getProp() != NULL)
    2287             mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds());
    2288     }
    2289     for (CutplaneHashmap::iterator itr = _cutplanes.begin();
    2290              itr != _cutplanes.end(); ++itr) {
    2291         if ((!onlyVisible || itr->second->getVisibility()) &&
    2292             itr->second->getProp() != NULL)
    2293             mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds());
    2294     }
    2295     for (GlyphsHashmap::iterator itr = _glyphs.begin();
    2296              itr != _glyphs.end(); ++itr) {
    2297         if ((!onlyVisible || itr->second->getVisibility()) &&
    2298             itr->second->getProp() != NULL)
    2299             mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds());
    2300     }
    2301     for (HeightMapHashmap::iterator itr = _heightMaps.begin();
    2302              itr != _heightMaps.end(); ++itr) {
    2303         if ((!onlyVisible || itr->second->getVisibility()) &&
    2304             itr->second->getProp() != NULL)
    2305             mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds());
    2306     }
    2307     for (LICHashmap::iterator itr = _lics.begin();
    2308              itr != _lics.end(); ++itr) {
    2309         if ((!onlyVisible || itr->second->getVisibility()) &&
    2310             itr->second->getProp() != NULL)
    2311             mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds());
    2312     }
    2313     for (MoleculeHashmap::iterator itr = _molecules.begin();
    2314              itr != _molecules.end(); ++itr) {
    2315         if ((!onlyVisible || itr->second->getVisibility()) &&
    2316             itr->second->getProp() != NULL)
    2317             mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds());
    2318     }
    2319     for (PolyDataHashmap::iterator itr = _polyDatas.begin();
    2320              itr != _polyDatas.end(); ++itr) {
    2321         if ((!onlyVisible || itr->second->getVisibility()) &&
    2322             itr->second->getProp() != NULL)
    2323             mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds());
    2324     }
    2325     for (PseudoColorHashmap::iterator itr = _pseudoColors.begin();
    2326              itr != _pseudoColors.end(); ++itr) {
    2327         if ((!onlyVisible || itr->second->getVisibility()) &&
    2328             itr->second->getProp() != NULL)
    2329             mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds());
    2330     }
    2331     for (StreamlinesHashmap::iterator itr = _streamlines.begin();
    2332              itr != _streamlines.end(); ++itr) {
    2333         if ((!onlyVisible || itr->second->getVisibility()) &&
    2334             itr->second->getProp() != NULL)
    2335             mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds());
    2336     }
    2337     for (VolumeHashmap::iterator itr = _volumes.begin();
    2338              itr != _volumes.end(); ++itr) {
    2339         if ((!onlyVisible || itr->second->getVisibility()) &&
    2340             itr->second->getProp() != NULL)
    2341             mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds());
    2342     }
     2190
     2191    mergeGraphicsObjectBounds<Arc>(bounds, onlyVisible);
     2192    mergeGraphicsObjectBounds<Arrow>(bounds, onlyVisible);
     2193    mergeGraphicsObjectBounds<Box>(bounds, onlyVisible);
     2194    mergeGraphicsObjectBounds<Cone>(bounds, onlyVisible);
     2195    mergeGraphicsObjectBounds<Contour2D>(bounds, onlyVisible);
     2196    mergeGraphicsObjectBounds<Contour3D>(bounds, onlyVisible);
     2197    mergeGraphicsObjectBounds<Cutplane>(bounds, onlyVisible);
     2198    mergeGraphicsObjectBounds<Cylinder>(bounds, onlyVisible);
     2199    mergeGraphicsObjectBounds<Disk>(bounds, onlyVisible);
     2200    mergeGraphicsObjectBounds<Glyphs>(bounds, onlyVisible);
     2201    mergeGraphicsObjectBounds<HeightMap>(bounds, onlyVisible);
     2202    mergeGraphicsObjectBounds<LIC>(bounds, onlyVisible);
     2203    mergeGraphicsObjectBounds<Line>(bounds, onlyVisible);
     2204    mergeGraphicsObjectBounds<Molecule>(bounds, onlyVisible);
     2205    mergeGraphicsObjectBounds<PolyData>(bounds, onlyVisible);
     2206    mergeGraphicsObjectBounds<Polygon>(bounds, onlyVisible);
     2207    mergeGraphicsObjectBounds<PseudoColor>(bounds, onlyVisible);
     2208    mergeGraphicsObjectBounds<Sphere>(bounds, onlyVisible);
     2209    mergeGraphicsObjectBounds<Streamlines>(bounds, onlyVisible);
     2210    mergeGraphicsObjectBounds<Volume>(bounds, onlyVisible);
     2211    mergeGraphicsObjectBounds<Warp>(bounds, onlyVisible);
    23432212
    23442213    for (int i = 0; i < 6; i += 2) {
     
    23742243
    23752244/**
     2245 * \brief Collect bounds of all graphics objects
     2246 *
     2247 * \param[out] bounds Bounds of all scene objects
     2248 * \param[in] onlyVisible Only collect bounds of visible objects
     2249 */
     2250void Renderer::collectUnscaledBounds(double *bounds, bool onlyVisible)
     2251{
     2252    bounds[0] = DBL_MAX;
     2253    bounds[1] = -DBL_MAX;
     2254    bounds[2] = DBL_MAX;
     2255    bounds[3] = -DBL_MAX;
     2256    bounds[4] = DBL_MAX;
     2257    bounds[5] = -DBL_MAX;
     2258
     2259    for (DataSetHashmap::iterator itr = _dataSets.begin();
     2260             itr != _dataSets.end(); ++itr) {
     2261        if ((!onlyVisible || itr->second->getVisibility()) &&
     2262            itr->second->getProp() != NULL)
     2263            mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds());
     2264    }
     2265
     2266    mergeGraphicsObjectUnscaledBounds<Arc>(bounds, onlyVisible);
     2267    mergeGraphicsObjectUnscaledBounds<Arrow>(bounds, onlyVisible);
     2268    mergeGraphicsObjectUnscaledBounds<Box>(bounds, onlyVisible);
     2269    mergeGraphicsObjectUnscaledBounds<Cone>(bounds, onlyVisible);
     2270    mergeGraphicsObjectUnscaledBounds<Contour2D>(bounds, onlyVisible);
     2271    mergeGraphicsObjectUnscaledBounds<Contour3D>(bounds, onlyVisible);
     2272    mergeGraphicsObjectUnscaledBounds<Cutplane>(bounds, onlyVisible);
     2273    mergeGraphicsObjectUnscaledBounds<Cylinder>(bounds, onlyVisible);
     2274    mergeGraphicsObjectUnscaledBounds<Disk>(bounds, onlyVisible);
     2275    mergeGraphicsObjectUnscaledBounds<Glyphs>(bounds, onlyVisible);
     2276    mergeGraphicsObjectUnscaledBounds<HeightMap>(bounds, onlyVisible);
     2277    mergeGraphicsObjectUnscaledBounds<LIC>(bounds, onlyVisible);
     2278    mergeGraphicsObjectUnscaledBounds<Line>(bounds, onlyVisible);
     2279    mergeGraphicsObjectUnscaledBounds<Molecule>(bounds, onlyVisible);
     2280    mergeGraphicsObjectUnscaledBounds<PolyData>(bounds, onlyVisible);
     2281    mergeGraphicsObjectUnscaledBounds<Polygon>(bounds, onlyVisible);
     2282    mergeGraphicsObjectUnscaledBounds<PseudoColor>(bounds, onlyVisible);
     2283    mergeGraphicsObjectUnscaledBounds<Sphere>(bounds, onlyVisible);
     2284    mergeGraphicsObjectUnscaledBounds<Streamlines>(bounds, onlyVisible);
     2285    mergeGraphicsObjectUnscaledBounds<Volume>(bounds, onlyVisible);
     2286    mergeGraphicsObjectUnscaledBounds<Warp>(bounds, onlyVisible);
     2287
     2288    for (int i = 0; i < 6; i += 2) {
     2289        if (bounds[i+1] < bounds[i]) {
     2290            bounds[i] = -0.5;
     2291            bounds[i+1] = 0.5;
     2292        }
     2293    }
     2294
     2295    int numDims = 0;
     2296    if (bounds[0] != bounds[1])
     2297        numDims++;
     2298    if (bounds[2] != bounds[3])
     2299        numDims++;
     2300    if (bounds[4] != bounds[5])
     2301        numDims++;
     2302
     2303    if (numDims == 0) {
     2304        bounds[0] -= .5;
     2305        bounds[1] += .5;
     2306        bounds[2] -= .5;
     2307        bounds[3] += .5;
     2308    }
     2309
     2310    TRACE("Bounds: %g %g %g %g %g %g",
     2311          bounds[0],
     2312          bounds[1],
     2313          bounds[2],
     2314          bounds[3],
     2315          bounds[4],
     2316          bounds[5]);
     2317}
     2318
     2319/**
    23762320 * \brief Update data ranges for color-mapping and contours
    23772321 */
     
    23802324    collectDataRanges();
    23812325
    2382     for (Contour2DHashmap::iterator itr = _contour2Ds.begin();
    2383          itr != _contour2Ds.end(); ++itr) {
    2384         itr->second->updateRanges(this);
    2385     }
    2386     for (Contour3DHashmap::iterator itr = _contour3Ds.begin();
    2387          itr != _contour3Ds.end(); ++itr) {
    2388         itr->second->updateRanges(this);
    2389     }
    2390     for (CutplaneHashmap::iterator itr = _cutplanes.begin();
    2391          itr != _cutplanes.end(); ++itr) {
    2392         itr->second->updateRanges(this);
    2393     }
    2394     for (GlyphsHashmap::iterator itr = _glyphs.begin();
    2395          itr != _glyphs.end(); ++itr) {
    2396         itr->second->updateRanges(this);
    2397     }
    2398     for (HeightMapHashmap::iterator itr = _heightMaps.begin();
    2399          itr != _heightMaps.end(); ++itr) {
    2400         itr->second->updateRanges(this);
    2401     }
    2402     for (LICHashmap::iterator itr = _lics.begin();
    2403          itr != _lics.end(); ++itr) {
    2404         itr->second->updateRanges(this);
    2405     }
    2406     for (MoleculeHashmap::iterator itr = _molecules.begin();
    2407          itr != _molecules.end(); ++itr) {
    2408         itr->second->updateRanges(this);
    2409     }
    2410     for (PseudoColorHashmap::iterator itr = _pseudoColors.begin();
    2411          itr != _pseudoColors.end(); ++itr) {
    2412         itr->second->updateRanges(this);
    2413     }
    2414     for (StreamlinesHashmap::iterator itr = _streamlines.begin();
    2415          itr != _streamlines.end(); ++itr) {
    2416         itr->second->updateRanges(this);
    2417     }
    2418     for (VolumeHashmap::iterator itr = _volumes.begin();
    2419          itr != _volumes.end(); ++itr) {
    2420         itr->second->updateRanges(this);
    2421     }
     2326    updateGraphicsObjectFieldRanges<Contour2D>();
     2327    updateGraphicsObjectFieldRanges<Contour3D>();
     2328    updateGraphicsObjectFieldRanges<Cutplane>();
     2329    updateGraphicsObjectFieldRanges<Glyphs>();
     2330    updateGraphicsObjectFieldRanges<HeightMap>();
     2331    updateGraphicsObjectFieldRanges<LIC>();
     2332    updateGraphicsObjectFieldRanges<Molecule>();
     2333    updateGraphicsObjectFieldRanges<PseudoColor>();
     2334    updateGraphicsObjectFieldRanges<Streamlines>();
     2335    updateGraphicsObjectFieldRanges<Volume>();
     2336    updateGraphicsObjectFieldRanges<Warp>();
    24222337}
    24232338
     
    24422357        if (!onlyVisible || itr->second->getVisibility()) {
    24432358            double r[2];
     2359            r[0] = DBL_MAX;
     2360            r[1] = -DBL_MAX;
    24442361            itr->second->getDataRange(r, name, type, component);
    24452362            range[0] = min2(range[0], r[0]);
     
    27712688 * \brief Initialize the camera zoom region to include the bounding volume given
    27722689 */
    2773 void Renderer::initCamera()
     2690void Renderer::initCamera(bool initCameraMode)
    27742691{
    27752692#ifdef WANT_TRACE
     
    27922709    bool twod = is2D(bounds, &_imgCameraPlane, &_imgCameraOffset);
    27932710    if (twod) {
    2794         _cameraMode = IMAGE;
     2711        if (initCameraMode) {
     2712            TRACE("Changing camera mode to image");
     2713            _cameraMode = IMAGE;
     2714        }
    27952715        if (_imgCameraPlane == PLANE_ZY) {
    27962716            _imgWorldOrigin[0] = bounds[4];
     
    29282848    if (id.compare("all") == 0 || getGraphicsObject<Volume>(id) != NULL)
    29292849        setGraphicsObjectOpacity<Volume>(id, opacity);
     2850    if (id.compare("all") == 0 || getGraphicsObject<Warp>(id) != NULL)
     2851        setGraphicsObjectOpacity<Warp>(id, opacity);
    29302852
    29312853    _needsRedraw = true;
     
    29782900    if (id.compare("all") == 0 || getGraphicsObject<Volume>(id) != NULL)
    29792901        setGraphicsObjectVisibility<Volume>(id, state);
     2902    if (id.compare("all") == 0 || getGraphicsObject<Warp>(id) != NULL)
     2903        setGraphicsObjectVisibility<Warp>(id, state);
    29802904
    29812905    _needsRedraw = true;
     
    31623086     * Mappers already using the PlaneCollection
    31633087     */
    3164     for (Contour2DHashmap::iterator itr = _contour2Ds.begin();
    3165          itr != _contour2Ds.end(); ++itr) {
    3166         itr->second->setClippingPlanes(_activeClipPlanes);
    3167     }
    3168     for (Contour3DHashmap::iterator itr = _contour3Ds.begin();
    3169          itr != _contour3Ds.end(); ++itr) {
    3170         itr->second->setClippingPlanes(_activeClipPlanes);
    3171     }
    3172     for (CutplaneHashmap::iterator itr = _cutplanes.begin();
    3173          itr != _cutplanes.end(); ++itr) {
    3174         itr->second->setClippingPlanes(_activeClipPlanes);
    3175     }
    3176     for (GlyphsHashmap::iterator itr = _glyphs.begin();
    3177          itr != _glyphs.end(); ++itr) {
    3178         itr->second->setClippingPlanes(_activeClipPlanes);
    3179     }
    3180     for (HeightMapHashmap::iterator itr = _heightMaps.begin();
    3181          itr != _heightMaps.end(); ++itr) {
    3182         itr->second->setClippingPlanes(_activeClipPlanes);
    3183     }
    3184     for (LICHashmap::iterator itr = _lics.begin();
    3185          itr != _lics.end(); ++itr) {
    3186         itr->second->setClippingPlanes(_activeClipPlanes);
    3187     }
    3188     for (MoleculeHashmap::iterator itr = _molecules.begin();
    3189          itr != _molecules.end(); ++itr) {
    3190         itr->second->setClippingPlanes(_activeClipPlanes);
    3191     }
    3192     for (PolyDataHashmap::iterator itr = _polyDatas.begin();
    3193          itr != _polyDatas.end(); ++itr) {
    3194         itr->second->setClippingPlanes(_activeClipPlanes);
    3195     }
    3196     for (PseudoColorHashmap::iterator itr = _pseudoColors.begin();
    3197          itr != _pseudoColors.end(); ++itr) {
    3198         itr->second->setClippingPlanes(_activeClipPlanes);
    3199     }
    3200     for (StreamlinesHashmap::iterator itr = _streamlines.begin();
    3201          itr != _streamlines.end(); ++itr) {
    3202         itr->second->setClippingPlanes(_activeClipPlanes);
    3203     }
    3204     for (VolumeHashmap::iterator itr = _volumes.begin();
    3205          itr != _volumes.end(); ++itr) {
    3206         itr->second->setClippingPlanes(_activeClipPlanes);
    3207     }
     3088    setGraphicsObjectClippingPlanes<Arc>(_activeClipPlanes);
     3089    setGraphicsObjectClippingPlanes<Arrow>(_activeClipPlanes);
     3090    setGraphicsObjectClippingPlanes<Box>(_activeClipPlanes);
     3091    setGraphicsObjectClippingPlanes<Cone>(_activeClipPlanes);
     3092    setGraphicsObjectClippingPlanes<Contour2D>(_activeClipPlanes);
     3093    setGraphicsObjectClippingPlanes<Contour3D>(_activeClipPlanes);
     3094    setGraphicsObjectClippingPlanes<Cutplane>(_activeClipPlanes);
     3095    setGraphicsObjectClippingPlanes<Cylinder>(_activeClipPlanes);
     3096    setGraphicsObjectClippingPlanes<Disk>(_activeClipPlanes);
     3097    setGraphicsObjectClippingPlanes<Glyphs>(_activeClipPlanes);
     3098    setGraphicsObjectClippingPlanes<Group>(_activeClipPlanes);
     3099    setGraphicsObjectClippingPlanes<HeightMap>(_activeClipPlanes);
     3100    setGraphicsObjectClippingPlanes<LIC>(_activeClipPlanes);
     3101    setGraphicsObjectClippingPlanes<Line>(_activeClipPlanes);
     3102    setGraphicsObjectClippingPlanes<Molecule>(_activeClipPlanes);
     3103    setGraphicsObjectClippingPlanes<PolyData>(_activeClipPlanes);
     3104    setGraphicsObjectClippingPlanes<Polygon>(_activeClipPlanes);
     3105    setGraphicsObjectClippingPlanes<PseudoColor>(_activeClipPlanes);
     3106    setGraphicsObjectClippingPlanes<Sphere>(_activeClipPlanes);
     3107    setGraphicsObjectClippingPlanes<Streamlines>(_activeClipPlanes);
     3108    setGraphicsObjectClippingPlanes<Volume>(_activeClipPlanes);
     3109    setGraphicsObjectClippingPlanes<Warp>(_activeClipPlanes);
    32083110}
    32093111
  • branches/nanovis2/packages/vizservers/vtkvis/RpVtkRenderer.h

    r2866 r3175  
    3030#include "RpTypes.h"
    3131#include "RpVtkDataSet.h"
     32#include "RpArc.h"
     33#include "RpArrow.h"
     34#include "RpBox.h"
     35#include "RpCone.h"
    3236#include "RpContour2D.h"
    3337#include "RpContour3D.h"
    3438#include "RpCutplane.h"
     39#include "RpCylinder.h"
     40#include "RpDisk.h"
    3541#include "RpGlyphs.h"
     42#include "RpGroup.h"
    3643#include "RpHeightMap.h"
    3744#include "RpLIC.h"
     45#include "RpLine.h"
    3846#include "RpMolecule.h"
    3947#include "RpPolyData.h"
     48#include "RpPolygon.h"
    4049#include "RpPseudoColor.h"
     50#include "RpSphere.h"
    4151#include "RpStreamlines.h"
    4252#include "RpVolume.h"
     53#include "RpWarp.h"
    4354#include "Trace.h"
    4455
     
    293304
    294305    template<class GraphicsObject>
     306    void deleteAllGraphicsObjects();
     307
     308    template<class GraphicsObject>
     309    void mergeGraphicsObjectBounds(double *bounds, bool onlyVisible);
     310
     311    template<class GraphicsObject>
     312    void mergeGraphicsObjectUnscaledBounds(double *bounds, bool onlyVisible);
     313
     314    template<class GraphicsObject>
     315    void updateGraphicsObjectFieldRanges();
     316
     317    template<class GraphicsObject>
     318    void setGraphicsObjectClippingPlanes(vtkPlaneCollection *planes);
     319
     320    template<class GraphicsObject>
     321    void setGraphicsObjectAspect(double aspectRatio);
     322
     323    template<class GraphicsObject>
    295324    void setGraphicsObjectColorMap(const DataSetId& id, const ColorMapId& colorMapId);
    296325
    297326    template<class GraphicsObject>
     327    void updateGraphicsObjectColorMap(ColorMap *cmap);
     328
     329    template<class GraphicsObject>
     330    bool graphicsObjectColorMapUsed(ColorMap *cmap);
     331
     332    template<class GraphicsObject>
    298333    void setGraphicsObjectVolumeSlice(const DataSetId& id, Axis axis, double ratio);
    299334
     
    310345
    311346    template<class GraphicsObject>
     347    void setGraphicsObjectAspect(const DataSetId& id, double aspect);
     348
     349    template<class GraphicsObject>
    312350    void setGraphicsObjectScale(const DataSetId& id, double scale[3]);
    313351
     
    353391    void setGraphicsObjectWireframe(const DataSetId& id, bool state);
    354392
     393    // Arcs
     394
     395    bool addArc(const DataSetId& id, double pt1[3], double pt2[3]);
     396
     397    void setArcResolution(const DataSetId& id, int res);
     398
     399    // Arrows
     400
     401    bool addArrow(const DataSetId& id, double tipRadius, double shaftRadius, double tipLength);
     402
     403    void setArrowResolution(const DataSetId& id, int resTip, int resShaft);
     404
     405    // Cones
     406
     407    bool addCone(const DataSetId& id, double radius, double height, bool cap);
     408
     409    void setConeResolution(const DataSetId& id, int res);
     410
    355411    // 2D Contour plots
    356412
     
    362418
    363419    void setContour2DContourList(const DataSetId& id, const std::vector<double>& contours);
     420
     421    void setContour2DColorMode(const DataSetId& id,
     422                               Contour2D::ColorMode mode,
     423                               const char *name, double range[2] = NULL);
     424
     425    void setContour2DColorMode(const DataSetId& id,
     426                               Contour2D::ColorMode mode,
     427                               DataSet::DataAttributeType type,
     428                               const char *name, double range[2] = NULL);
    364429
    365430    // 3D Contour (isosurface) plots
     
    388453                              const char *name, double range[2] = NULL);
    389454
     455    // Cylinders
     456
     457    bool addCylinder(const DataSetId& id, double radius, double height, bool cap);
     458
     459    void setCylinderResolution(const DataSetId& id, int res);
     460
     461    // Disks
     462
     463    bool addDisk(const DataSetId& id, double innerRadius, double outerRadius);
     464
     465    void setDiskResolution(const DataSetId& id, int resRadial, int resCircum);
     466
    390467    // Glyphs
    391468
     
    393470
    394471    void setGlyphsShape(const DataSetId& id, Glyphs::GlyphShape shape);
     472
     473    void setGlyphsOrientMode(const DataSetId& id, bool state, const char *name);
    395474
    396475    void setGlyphsColorMode(const DataSetId& id,
     
    428507    void setHeightMapContourEdgeWidth(const DataSetId& id, float edgeWidth);
    429508
     509    // Lines
     510
     511    bool addLine(const DataSetId& id, double pt1[3], double pt2[3]);
     512
    430513    // Molecules
    431514
     515    void setMoleculeAtomRadiusScale(const DataSetId& id, double scale);
     516
     517    void setMoleculeBondRadiusScale(const DataSetId& id, double scale);
     518
    432519    void setMoleculeAtomScaling(const DataSetId& id, Molecule::AtomScaling scaling);
    433520
    434521    void setMoleculeAtomVisibility(const DataSetId& id, bool state);
    435522
     523    void setMoleculeAtomLabelVisibility(const DataSetId& id, bool state);
     524
    436525    void setMoleculeBondVisibility(const DataSetId& id, bool state);
     526
     527    void setMoleculeBondStyle(const DataSetId& id, Molecule::BondStyle style);
     528
     529    void setMoleculeBondColorMode(const DataSetId& id, Molecule::BondColorMode mode);
     530
     531    void setMoleculeBondColor(const DataSetId& id, float color[3]);
     532
     533    void setMoleculeColorMode(const DataSetId& id,
     534                              Molecule::ColorMode mode,
     535                              const char *name, double range[2] = NULL);
     536
     537    void setMoleculeColorMode(const DataSetId& id,
     538                              Molecule::ColorMode mode,
     539                              DataSet::DataAttributeType type,
     540                              const char *name, double range[2] = NULL);
     541
     542    // N-sided Regular Polygons
     543
     544    bool addPolygon(const DataSetId& id, int numSides);
    437545
    438546    // Color-mapped surfaces
     
    447555                                 const char *name, double range[2] = NULL);
    448556
     557    // Spheres
     558
     559    void setSphereSection(const DataSetId& id, double thetaStart, double thetaEnd,
     560                          double phiStart, double phiEnd);
     561
     562    void setSphereResolution(const DataSetId& id, int thetaRes, int phiRes);
     563
    449564    // Streamlines
    450565
     
    506621    void setVolumeSampleDistance(const DataSetId& id, double distance);
    507622
     623    // Warps
     624
     625    void setWarpWarpScale(const DataSetId& id, double scale);
     626
    508627private:
    509628    typedef std::tr1::unordered_map<DataSetId, DataSet *> DataSetHashmap;
    510629    typedef std::tr1::unordered_map<FieldId, double *> FieldRangeHashmap;
    511630    typedef std::tr1::unordered_map<ColorMapId, ColorMap *> ColorMapHashmap;
     631
     632    typedef std::tr1::unordered_map<DataSetId, Arc *> ArcHashmap;
     633    typedef std::tr1::unordered_map<DataSetId, Arrow *> ArrowHashmap;
     634    typedef std::tr1::unordered_map<DataSetId, Box *> BoxHashmap;
     635    typedef std::tr1::unordered_map<DataSetId, Cone *> ConeHashmap;
    512636    typedef std::tr1::unordered_map<DataSetId, Contour2D *> Contour2DHashmap;
    513637    typedef std::tr1::unordered_map<DataSetId, Contour3D *> Contour3DHashmap;
    514638    typedef std::tr1::unordered_map<DataSetId, Cutplane *> CutplaneHashmap;
     639    typedef std::tr1::unordered_map<DataSetId, Cylinder *> CylinderHashmap;
     640    typedef std::tr1::unordered_map<DataSetId, Disk *> DiskHashmap;
    515641    typedef std::tr1::unordered_map<DataSetId, Glyphs *> GlyphsHashmap;
     642    typedef std::tr1::unordered_map<DataSetId, Group *> GroupHashmap;
    516643    typedef std::tr1::unordered_map<DataSetId, HeightMap *> HeightMapHashmap;
    517644    typedef std::tr1::unordered_map<DataSetId, LIC *> LICHashmap;
     645    typedef std::tr1::unordered_map<DataSetId, Line *> LineHashmap;
    518646    typedef std::tr1::unordered_map<DataSetId, Molecule *> MoleculeHashmap;
    519647    typedef std::tr1::unordered_map<DataSetId, PolyData *> PolyDataHashmap;
     648    typedef std::tr1::unordered_map<DataSetId, Polygon *> PolygonHashmap;
    520649    typedef std::tr1::unordered_map<DataSetId, PseudoColor *> PseudoColorHashmap;
     650    typedef std::tr1::unordered_map<DataSetId, Sphere *> SphereHashmap;
    521651    typedef std::tr1::unordered_map<DataSetId, Streamlines *> StreamlinesHashmap;
    522652    typedef std::tr1::unordered_map<DataSetId, Volume *> VolumeHashmap;
     653    typedef std::tr1::unordered_map<DataSetId, Warp *> WarpHashmap;
    523654
    524655    static void printCameraInfo(vtkCamera *camera);
     
    531662    std::tr1::unordered_map<DataSetId, GraphicsObject *>&getGraphicsObjectHashmap();
    532663
     664    void setObjectAspects(double aspectRatio);
     665
    533666    void collectBounds(double *bounds, bool onlyVisible);
     667
     668    void collectUnscaledBounds(double *bounds, bool onlyVisible);
    534669
    535670    void collectDataRanges();
     
    558693              PrincipalPlane *plane,
    559694              double *offset) const;
    560     void initCamera();
     695    void initCamera(bool initCameraMode = false);
    561696    void initAxes();
    562697    void resetAxes(double bounds[6] = NULL);
     
    565700    bool _needsRedraw;
    566701    int _windowWidth, _windowHeight;
     702    CameraMode _cameraMode;
    567703    double _imgWorldOrigin[2];
    568704    double _imgWorldDims[2];
     
    586722    ColorMapHashmap _colorMaps;
    587723    DataSetHashmap _dataSets;
     724    ArcHashmap _arcs;
     725    ArrowHashmap _arrows;
     726    BoxHashmap _boxes;
     727    ConeHashmap _cones;
    588728    Contour2DHashmap _contour2Ds;
    589729    Contour3DHashmap _contour3Ds;
    590730    CutplaneHashmap _cutplanes;
     731    CylinderHashmap _cylinders;
     732    DiskHashmap _disks;
    591733    GlyphsHashmap _glyphs;
     734    GroupHashmap _groups;
    592735    HeightMapHashmap _heightMaps;
    593736    LICHashmap _lics;
     737    LineHashmap _lines;
    594738    MoleculeHashmap _molecules;
    595739    PolyDataHashmap _polyDatas;
     740    PolygonHashmap _polygons;
    596741    PseudoColorHashmap _pseudoColors;
     742    SphereHashmap _spheres;
    597743    StreamlinesHashmap _streamlines;
    598744    VolumeHashmap _volumes;
    599 
    600     CameraMode _cameraMode;
     745    WarpHashmap _warps;
    601746
    602747    vtkSmartPointer<vtkPlane> _cameraClipPlanes[4];
  • branches/nanovis2/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp

    r2757 r3175  
    121121
    122122static int
     123ArcAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
     124         Tcl_Obj *const *objv)
     125{
     126    double pt1[3];
     127    double pt2[3];
     128    if (Tcl_GetDoubleFromObj(interp, objv[2], &pt1[0]) != TCL_OK ||
     129        Tcl_GetDoubleFromObj(interp, objv[3], &pt1[1]) != TCL_OK ||
     130        Tcl_GetDoubleFromObj(interp, objv[4], &pt1[2]) != TCL_OK ||
     131        Tcl_GetDoubleFromObj(interp, objv[5], &pt2[0]) != TCL_OK ||
     132        Tcl_GetDoubleFromObj(interp, objv[6], &pt2[1]) != TCL_OK ||
     133        Tcl_GetDoubleFromObj(interp, objv[7], &pt2[2]) != TCL_OK) {
     134        return TCL_ERROR;
     135    }
     136    const char *name = Tcl_GetString(objv[8]);
     137    if (!g_renderer->addArc(name, pt1, pt2)) {
     138        Tcl_AppendResult(interp, "Failed to create arc", (char*)NULL);
     139        return TCL_ERROR;
     140    }
     141    return TCL_OK;
     142}
     143
     144static int
     145ArcDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
     146             Tcl_Obj *const *objv)
     147{
     148    if (objc == 3) {
     149        const char *name = Tcl_GetString(objv[2]);
     150        g_renderer->deleteGraphicsObject<Arc>(name);
     151    } else {
     152        g_renderer->deleteGraphicsObject<Arc>("all");
     153    }
     154    return TCL_OK;
     155}
     156
     157static int
     158ArcColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     159           Tcl_Obj *const *objv)
     160{
     161    float color[3];
     162    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     163        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     164        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     165        return TCL_ERROR;
     166    }
     167    if (objc == 6) {
     168        const char *name = Tcl_GetString(objv[5]);
     169        g_renderer->setGraphicsObjectColor<Arc>(name, color);
     170    } else {
     171        g_renderer->setGraphicsObjectColor<Arc>("all", color);
     172    }
     173    return TCL_OK;
     174}
     175
     176static int
     177ArcLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc,
     178               Tcl_Obj *const *objv)
     179{
     180    float width;
     181    if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) {
     182        return TCL_ERROR;
     183    }
     184    if (objc == 4) {
     185        const char *name = Tcl_GetString(objv[3]);
     186        g_renderer->setGraphicsObjectEdgeWidth<Arc>(name, width);
     187    } else {
     188        g_renderer->setGraphicsObjectEdgeWidth<Arc>("all", width);
     189    }
     190    return TCL_OK;
     191}
     192
     193static int
     194ArcOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     195             Tcl_Obj *const *objv)
     196{
     197    double opacity;
     198    if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) {
     199        return TCL_ERROR;
     200    }
     201    if (objc == 4) {
     202        const char *name = Tcl_GetString(objv[3]);
     203        g_renderer->setGraphicsObjectOpacity<Arc>(name, opacity);
     204    } else {
     205        g_renderer->setGraphicsObjectOpacity<Arc>("all", opacity);
     206    }
     207    return TCL_OK;
     208}
     209
     210static int
     211ArcOrientOp(ClientData clientData, Tcl_Interp *interp, int objc,
     212            Tcl_Obj *const *objv)
     213{
     214    double quat[4];
     215    if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK ||
     216        Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK ||
     217        Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK ||
     218        Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) {
     219        return TCL_ERROR;
     220    }
     221    if (objc == 7) {
     222        const char *name = Tcl_GetString(objv[6]);
     223        g_renderer->setGraphicsObjectOrientation<Arc>(name, quat);
     224    } else {
     225        g_renderer->setGraphicsObjectOrientation<Arc>("all", quat);
     226    }
     227    return TCL_OK;
     228}
     229
     230static int
     231ArcPositionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     232              Tcl_Obj *const *objv)
     233{
     234    double pos[3];
     235    if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK ||
     236        Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK ||
     237        Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) {
     238        return TCL_ERROR;
     239    }
     240    if (objc == 6) {
     241        const char *name = Tcl_GetString(objv[5]);
     242        g_renderer->setGraphicsObjectPosition<Arc>(name, pos);
     243    } else {
     244        g_renderer->setGraphicsObjectPosition<Arc>("all", pos);
     245    }
     246    return TCL_OK;
     247}
     248
     249static int
     250ArcResolutionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     251                Tcl_Obj *const *objv)
     252{
     253    int res;
     254    if (Tcl_GetIntFromObj(interp, objv[2], &res) != TCL_OK) {
     255        return TCL_ERROR;
     256    }
     257    if (objc == 4) {
     258        const char *name = Tcl_GetString(objv[3]);
     259        g_renderer->setArcResolution(name, res);
     260    } else {
     261        g_renderer->setArcResolution("all", res);
     262    }
     263    return TCL_OK;
     264}
     265
     266static int
     267ArcScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     268            Tcl_Obj *const *objv)
     269{
     270    double scale[3];
     271    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK ||
     272        Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK ||
     273        Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) {
     274        return TCL_ERROR;
     275    }
     276    if (objc == 6) {
     277        const char *name = Tcl_GetString(objv[5]);
     278        g_renderer->setGraphicsObjectScale<Arc>(name, scale);
     279    } else {
     280        g_renderer->setGraphicsObjectScale<Arc>("all", scale);
     281    }
     282    return TCL_OK;
     283}
     284
     285static int
     286ArcVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     287             Tcl_Obj *const *objv)
     288{
     289    bool state;
     290    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     291        return TCL_ERROR;
     292    }
     293    if (objc == 4) {
     294        const char *name = Tcl_GetString(objv[3]);
     295        g_renderer->setGraphicsObjectVisibility<Arc>(name, state);
     296    } else {
     297        g_renderer->setGraphicsObjectVisibility<Arc>("all", state);
     298    }
     299    return TCL_OK;
     300}
     301
     302static Rappture::CmdSpec arcOps[] = {
     303    {"add",       1, ArcAddOp, 9, 9, "x1 y1 z1 x2 y2 z2 name"},
     304    {"color",     1, ArcColorOp, 5, 6, "r g b ?name?"},
     305    {"delete",    1, ArcDeleteOp, 2, 3, "?name?"},
     306    {"linecolor", 5, ArcColorOp, 5, 6, "r g b ?name?"},
     307    {"linewidth", 5, ArcLineWidthOp, 3, 4, "width ?name?"},
     308    {"opacity",   2, ArcOpacityOp, 3, 4, "value ?name?"},
     309    {"orient",    2, ArcOrientOp, 6, 7, "qw qx qy qz ?name?"},
     310    {"pos",       2, ArcPositionOp, 5, 6, "x y z ?name?"},
     311    {"resolution",1, ArcResolutionOp, 3, 4, "res ?name?"},
     312    {"scale",     2, ArcScaleOp, 5, 6, "sx sy sz ?name?"},
     313    {"visible",   1, ArcVisibleOp, 3, 4, "bool ?name?"}
     314};
     315static int nArcOps = NumCmdSpecs(arcOps);
     316
     317static int
     318ArcCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     319       Tcl_Obj *const *objv)
     320{
     321    Tcl_ObjCmdProc *proc;
     322
     323    proc = Rappture::GetOpFromObj(interp, nArcOps, arcOps,
     324                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
     325    if (proc == NULL) {
     326        return TCL_ERROR;
     327    }
     328    return (*proc) (clientData, interp, objc, objv);
     329}
     330
     331static int
     332ArrowAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
     333           Tcl_Obj *const *objv)
     334{
     335    double tipRadius, shaftRadius, tipLength;
     336    if (Tcl_GetDoubleFromObj(interp, objv[2], &tipRadius) != TCL_OK ||
     337        Tcl_GetDoubleFromObj(interp, objv[3], &shaftRadius) != TCL_OK ||
     338        Tcl_GetDoubleFromObj(interp, objv[4], &tipLength) != TCL_OK) {
     339        return TCL_ERROR;
     340    }
     341    const char *name = Tcl_GetString(objv[5]);
     342    if (!g_renderer->addArrow(name, tipRadius, shaftRadius, tipLength)) {
     343        Tcl_AppendResult(interp, "Failed to create arrow", (char*)NULL);
     344        return TCL_ERROR;
     345    }
     346    return TCL_OK;
     347}
     348
     349static int
     350ArrowDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
     351              Tcl_Obj *const *objv)
     352{
     353    if (objc == 3) {
     354        const char *name = Tcl_GetString(objv[2]);
     355        g_renderer->deleteGraphicsObject<Arrow>(name);
     356    } else {
     357        g_renderer->deleteGraphicsObject<Arrow>("all");
     358    }
     359    return TCL_OK;
     360}
     361
     362static int
     363ArrowColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     364             Tcl_Obj *const *objv)
     365{
     366    float color[3];
     367    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     368        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     369        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     370        return TCL_ERROR;
     371    }
     372    if (objc == 6) {
     373        const char *name = Tcl_GetString(objv[5]);
     374        g_renderer->setGraphicsObjectColor<Arrow>(name, color);
     375    } else {
     376        g_renderer->setGraphicsObjectColor<Arrow>("all", color);
     377    }
     378    return TCL_OK;
     379}
     380
     381static int
     382ArrowEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     383                      Tcl_Obj *const *objv)
     384{
     385    bool state;
     386    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     387        return TCL_ERROR;
     388    }
     389    if (objc == 4) {
     390        const char *name = Tcl_GetString(objv[3]);
     391        g_renderer->setGraphicsObjectEdgeVisibility<Arrow>(name, state);
     392    } else {
     393        g_renderer->setGraphicsObjectEdgeVisibility<Arrow>("all", state);
     394    }
     395    return TCL_OK;
     396}
     397
     398static int
     399ArrowLightingOp(ClientData clientData, Tcl_Interp *interp, int objc,
     400                Tcl_Obj *const *objv)
     401{
     402    bool state;
     403    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     404        return TCL_ERROR;
     405    }
     406    if (objc == 4) {
     407        const char *name = Tcl_GetString(objv[3]);
     408        g_renderer->setGraphicsObjectLighting<Arrow>(name, state);
     409    } else {
     410        g_renderer->setGraphicsObjectLighting<Arrow>("all", state);
     411    }
     412    return TCL_OK;
     413}
     414
     415static int
     416ArrowLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     417                 Tcl_Obj *const *objv)
     418{
     419    float color[3];
     420    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     421        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     422        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     423        return TCL_ERROR;
     424    }
     425    if (objc == 6) {
     426        const char *name = Tcl_GetString(objv[5]);
     427        g_renderer->setGraphicsObjectEdgeColor<Arrow>(name, color);
     428    } else {
     429        g_renderer->setGraphicsObjectEdgeColor<Arrow>("all", color);
     430    }
     431    return TCL_OK;
     432}
     433
     434static int
     435ArrowLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc,
     436                 Tcl_Obj *const *objv)
     437{
     438    float width;
     439    if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) {
     440        return TCL_ERROR;
     441    }
     442    if (objc == 4) {
     443        const char *name = Tcl_GetString(objv[3]);
     444        g_renderer->setGraphicsObjectEdgeWidth<Arrow>(name, width);
     445    } else {
     446        g_renderer->setGraphicsObjectEdgeWidth<Arrow>("all", width);
     447    }
     448    return TCL_OK;
     449}
     450
     451static int
     452ArrowMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc,
     453                Tcl_Obj *const *objv)
     454{
     455    double ambient, diffuse, specCoeff, specPower;
     456    if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK ||
     457        Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK ||
     458        Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK ||
     459        Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) {
     460        return TCL_ERROR;
     461    }
     462
     463    if (objc == 7) {
     464        const char *name = Tcl_GetString(objv[6]);
     465        g_renderer->setGraphicsObjectAmbient<Arrow>(name, ambient);
     466        g_renderer->setGraphicsObjectDiffuse<Arrow>(name, diffuse);
     467        g_renderer->setGraphicsObjectSpecular<Arrow>(name, specCoeff, specPower);
     468    } else {
     469        g_renderer->setGraphicsObjectAmbient<Arrow>("all", ambient);
     470        g_renderer->setGraphicsObjectDiffuse<Arrow>("all", diffuse);
     471        g_renderer->setGraphicsObjectSpecular<Arrow>("all", specCoeff, specPower);
     472    }
     473    return TCL_OK;
     474}
     475
     476static int
     477ArrowOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     478               Tcl_Obj *const *objv)
     479{
     480    double opacity;
     481    if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) {
     482        return TCL_ERROR;
     483    }
     484    if (objc == 4) {
     485        const char *name = Tcl_GetString(objv[3]);
     486        g_renderer->setGraphicsObjectOpacity<Arrow>(name, opacity);
     487    } else {
     488        g_renderer->setGraphicsObjectOpacity<Arrow>("all", opacity);
     489    }
     490    return TCL_OK;
     491}
     492
     493static int
     494ArrowOrientOp(ClientData clientData, Tcl_Interp *interp, int objc,
     495              Tcl_Obj *const *objv)
     496{
     497    double quat[4];
     498    if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK ||
     499        Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK ||
     500        Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK ||
     501        Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) {
     502        return TCL_ERROR;
     503    }
     504    if (objc == 7) {
     505        const char *name = Tcl_GetString(objv[6]);
     506        g_renderer->setGraphicsObjectOrientation<Arrow>(name, quat);
     507    } else {
     508        g_renderer->setGraphicsObjectOrientation<Arrow>("all", quat);
     509    }
     510    return TCL_OK;
     511}
     512
     513static int
     514ArrowPositionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     515                Tcl_Obj *const *objv)
     516{
     517    double pos[3];
     518    if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK ||
     519        Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK ||
     520        Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) {
     521        return TCL_ERROR;
     522    }
     523    if (objc == 6) {
     524        const char *name = Tcl_GetString(objv[5]);
     525        g_renderer->setGraphicsObjectPosition<Arrow>(name, pos);
     526    } else {
     527        g_renderer->setGraphicsObjectPosition<Arrow>("all", pos);
     528    }
     529    return TCL_OK;
     530}
     531
     532static int
     533ArrowResolutionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     534                  Tcl_Obj *const *objv)
     535{
     536    int tipRes, shaftRes;
     537    if (Tcl_GetIntFromObj(interp, objv[2], &tipRes) != TCL_OK ||
     538        Tcl_GetIntFromObj(interp, objv[3], &shaftRes) != TCL_OK) {
     539        return TCL_ERROR;
     540    }
     541    if (objc == 4) {
     542        const char *name = Tcl_GetString(objv[4]);
     543        g_renderer->setArrowResolution(name, tipRes, shaftRes);
     544    } else {
     545        g_renderer->setArrowResolution("all", tipRes, shaftRes);
     546    }
     547    return TCL_OK;
     548}
     549
     550static int
     551ArrowScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     552             Tcl_Obj *const *objv)
     553{
     554    double scale[3];
     555    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK ||
     556        Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK ||
     557        Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) {
     558        return TCL_ERROR;
     559    }
     560    if (objc == 6) {
     561        const char *name = Tcl_GetString(objv[5]);
     562        g_renderer->setGraphicsObjectScale<Arrow>(name, scale);
     563    } else {
     564        g_renderer->setGraphicsObjectScale<Arrow>("all", scale);
     565    }
     566    return TCL_OK;
     567}
     568
     569static int
     570ArrowVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     571               Tcl_Obj *const *objv)
     572{
     573    bool state;
     574    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     575        return TCL_ERROR;
     576    }
     577    if (objc == 4) {
     578        const char *name = Tcl_GetString(objv[3]);
     579        g_renderer->setGraphicsObjectVisibility<Arrow>(name, state);
     580    } else {
     581        g_renderer->setGraphicsObjectVisibility<Arrow>("all", state);
     582    }
     583    return TCL_OK;
     584}
     585
     586static int
     587ArrowWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     588                 Tcl_Obj *const *objv)
     589{
     590    bool state;
     591    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     592        return TCL_ERROR;
     593    }
     594    if (objc == 4) {
     595        const char *name = Tcl_GetString(objv[3]);
     596        g_renderer->setGraphicsObjectWireframe<Arrow>(name, state);
     597    } else {
     598        g_renderer->setGraphicsObjectWireframe<Arrow>("all", state);
     599    }
     600    return TCL_OK;
     601}
     602
     603static Rappture::CmdSpec arrowOps[] = {
     604    {"add",       1, ArrowAddOp, 6, 6, "tipRadius shaftRadius tipLength name"},
     605    {"color",     1, ArrowColorOp, 5, 6, "r g b ?name?"},
     606    {"delete",    1, ArrowDeleteOp, 2, 3, "?name?"},
     607    {"edges",     1, ArrowEdgeVisibilityOp, 3, 4, "bool ?name?"},
     608    {"lighting",  3, ArrowLightingOp, 3, 4, "bool ?name?"},
     609    {"linecolor", 5, ArrowLineColorOp, 5, 6, "r g b ?name?"},
     610    {"linewidth", 5, ArrowLineWidthOp, 3, 4, "width ?name?"},
     611    {"material",  1, ArrowMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"},
     612    {"opacity",   2, ArrowOpacityOp, 3, 4, "value ?name?"},
     613    {"orient",    2, ArrowOrientOp, 6, 7, "qw qx qy qz ?name?"},
     614    {"pos",       2, ArrowPositionOp, 5, 6, "x y z ?name?"},
     615    {"resolution",1, ArrowResolutionOp, 4, 5, "tipRes shaftRes ?name?"},
     616    {"scale",     1, ArrowScaleOp, 5, 6, "sx sy sz ?name?"},
     617    {"visible",   1, ArrowVisibleOp, 3, 4, "bool ?name?"},
     618    {"wireframe", 1, ArrowWireframeOp, 3, 4, "bool ?name?"}
     619};
     620static int nArrowOps = NumCmdSpecs(arrowOps);
     621
     622static int
     623ArrowCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     624       Tcl_Obj *const *objv)
     625{
     626    Tcl_ObjCmdProc *proc;
     627
     628    proc = Rappture::GetOpFromObj(interp, nArrowOps, arrowOps,
     629                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
     630    if (proc == NULL) {
     631        return TCL_ERROR;
     632    }
     633    return (*proc) (clientData, interp, objc, objv);
     634}
     635
     636static int
    123637AxisColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
    124638            Tcl_Obj *const *objv)
     
    360874
    361875    proc = Rappture::GetOpFromObj(interp, nAxisOps, axisOps,
     876                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
     877    if (proc == NULL) {
     878        return TCL_ERROR;
     879    }
     880    return (*proc) (clientData, interp, objc, objv);
     881}
     882
     883static int
     884BoxAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
     885         Tcl_Obj *const *objv)
     886{
     887    const char *name = Tcl_GetString(objv[2]);
     888    if (!g_renderer->addGraphicsObject<Box>(name)) {
     889        Tcl_AppendResult(interp, "Failed to create box", (char*)NULL);
     890        return TCL_ERROR;
     891    }
     892    return TCL_OK;
     893}
     894
     895static int
     896BoxDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
     897            Tcl_Obj *const *objv)
     898{
     899    if (objc == 3) {
     900        const char *name = Tcl_GetString(objv[2]);
     901        g_renderer->deleteGraphicsObject<Box>(name);
     902    } else {
     903        g_renderer->deleteGraphicsObject<Box>("all");
     904    }
     905    return TCL_OK;
     906}
     907
     908static int
     909BoxColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     910           Tcl_Obj *const *objv)
     911{
     912    float color[3];
     913    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     914        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     915        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     916        return TCL_ERROR;
     917    }
     918    if (objc == 6) {
     919        const char *name = Tcl_GetString(objv[5]);
     920        g_renderer->setGraphicsObjectColor<Box>(name, color);
     921    } else {
     922        g_renderer->setGraphicsObjectColor<Box>("all", color);
     923    }
     924    return TCL_OK;
     925}
     926
     927static int
     928BoxEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     929                    Tcl_Obj *const *objv)
     930{
     931    bool state;
     932    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     933        return TCL_ERROR;
     934    }
     935    if (objc == 4) {
     936        const char *name = Tcl_GetString(objv[3]);
     937        g_renderer->setGraphicsObjectEdgeVisibility<Box>(name, state);
     938    } else {
     939        g_renderer->setGraphicsObjectEdgeVisibility<Box>("all", state);
     940    }
     941    return TCL_OK;
     942}
     943
     944static int
     945BoxLightingOp(ClientData clientData, Tcl_Interp *interp, int objc,
     946              Tcl_Obj *const *objv)
     947{
     948    bool state;
     949    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     950        return TCL_ERROR;
     951    }
     952    if (objc == 4) {
     953        const char *name = Tcl_GetString(objv[3]);
     954        g_renderer->setGraphicsObjectLighting<Box>(name, state);
     955    } else {
     956        g_renderer->setGraphicsObjectLighting<Box>("all", state);
     957    }
     958    return TCL_OK;
     959}
     960
     961static int
     962BoxLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     963               Tcl_Obj *const *objv)
     964{
     965    float color[3];
     966    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     967        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     968        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     969        return TCL_ERROR;
     970    }
     971    if (objc == 6) {
     972        const char *name = Tcl_GetString(objv[5]);
     973        g_renderer->setGraphicsObjectEdgeColor<Box>(name, color);
     974    } else {
     975        g_renderer->setGraphicsObjectEdgeColor<Box>("all", color);
     976    }
     977    return TCL_OK;
     978}
     979
     980static int
     981BoxLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc,
     982               Tcl_Obj *const *objv)
     983{
     984    float width;
     985    if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) {
     986        return TCL_ERROR;
     987    }
     988    if (objc == 4) {
     989        const char *name = Tcl_GetString(objv[3]);
     990        g_renderer->setGraphicsObjectEdgeWidth<Box>(name, width);
     991    } else {
     992        g_renderer->setGraphicsObjectEdgeWidth<Box>("all", width);
     993    }
     994    return TCL_OK;
     995}
     996
     997static int
     998BoxMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc,
     999              Tcl_Obj *const *objv)
     1000{
     1001    double ambient, diffuse, specCoeff, specPower;
     1002    if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK ||
     1003        Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK ||
     1004        Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK ||
     1005        Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) {
     1006        return TCL_ERROR;
     1007    }
     1008
     1009    if (objc == 7) {
     1010        const char *name = Tcl_GetString(objv[6]);
     1011        g_renderer->setGraphicsObjectAmbient<Box>(name, ambient);
     1012        g_renderer->setGraphicsObjectDiffuse<Box>(name, diffuse);
     1013        g_renderer->setGraphicsObjectSpecular<Box>(name, specCoeff, specPower);
     1014    } else {
     1015        g_renderer->setGraphicsObjectAmbient<Box>("all", ambient);
     1016        g_renderer->setGraphicsObjectDiffuse<Box>("all", diffuse);
     1017        g_renderer->setGraphicsObjectSpecular<Box>("all", specCoeff, specPower);
     1018    }
     1019    return TCL_OK;
     1020}
     1021
     1022static int
     1023BoxOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1024             Tcl_Obj *const *objv)
     1025{
     1026    double opacity;
     1027    if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) {
     1028        return TCL_ERROR;
     1029    }
     1030    if (objc == 4) {
     1031        const char *name = Tcl_GetString(objv[3]);
     1032        g_renderer->setGraphicsObjectOpacity<Box>(name, opacity);
     1033    } else {
     1034        g_renderer->setGraphicsObjectOpacity<Box>("all", opacity);
     1035    }
     1036    return TCL_OK;
     1037}
     1038
     1039static int
     1040BoxOrientOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1041            Tcl_Obj *const *objv)
     1042{
     1043    double quat[4];
     1044    if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK ||
     1045        Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK ||
     1046        Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK ||
     1047        Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) {
     1048        return TCL_ERROR;
     1049    }
     1050    if (objc == 7) {
     1051        const char *name = Tcl_GetString(objv[6]);
     1052        g_renderer->setGraphicsObjectOrientation<Box>(name, quat);
     1053    } else {
     1054        g_renderer->setGraphicsObjectOrientation<Box>("all", quat);
     1055    }
     1056    return TCL_OK;
     1057}
     1058
     1059static int
     1060BoxPositionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1061              Tcl_Obj *const *objv)
     1062{
     1063    double pos[3];
     1064    if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK ||
     1065        Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK ||
     1066        Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) {
     1067        return TCL_ERROR;
     1068    }
     1069    if (objc == 6) {
     1070        const char *name = Tcl_GetString(objv[5]);
     1071        g_renderer->setGraphicsObjectPosition<Box>(name, pos);
     1072    } else {
     1073        g_renderer->setGraphicsObjectPosition<Box>("all", pos);
     1074    }
     1075    return TCL_OK;
     1076}
     1077
     1078static int
     1079BoxScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1080           Tcl_Obj *const *objv)
     1081{
     1082    double scale[3];
     1083    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK ||
     1084        Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK ||
     1085        Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) {
     1086        return TCL_ERROR;
     1087    }
     1088    if (objc == 6) {
     1089        const char *name = Tcl_GetString(objv[5]);
     1090        g_renderer->setGraphicsObjectScale<Box>(name, scale);
     1091    } else {
     1092        g_renderer->setGraphicsObjectScale<Box>("all", scale);
     1093    }
     1094    return TCL_OK;
     1095}
     1096
     1097static int
     1098BoxVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1099             Tcl_Obj *const *objv)
     1100{
     1101    bool state;
     1102    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     1103        return TCL_ERROR;
     1104    }
     1105    if (objc == 4) {
     1106        const char *name = Tcl_GetString(objv[3]);
     1107        g_renderer->setGraphicsObjectVisibility<Box>(name, state);
     1108    } else {
     1109        g_renderer->setGraphicsObjectVisibility<Box>("all", state);
     1110    }
     1111    return TCL_OK;
     1112}
     1113
     1114static int
     1115BoxWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1116               Tcl_Obj *const *objv)
     1117{
     1118    bool state;
     1119    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     1120        return TCL_ERROR;
     1121    }
     1122    if (objc == 4) {
     1123        const char *name = Tcl_GetString(objv[3]);
     1124        g_renderer->setGraphicsObjectWireframe<Box>(name, state);
     1125    } else {
     1126        g_renderer->setGraphicsObjectWireframe<Box>("all", state);
     1127    }
     1128    return TCL_OK;
     1129}
     1130
     1131static Rappture::CmdSpec boxOps[] = {
     1132    {"add",       1, BoxAddOp, 3, 3, "name"},
     1133    {"color",     1, BoxColorOp, 5, 6, "r g b ?name?"},
     1134    {"delete",    1, BoxDeleteOp, 2, 3, "?name?"},
     1135    {"edges",     1, BoxEdgeVisibilityOp, 3, 4, "bool ?name?"},
     1136    {"lighting",  3, BoxLightingOp, 3, 4, "bool ?name?"},
     1137    {"linecolor", 5, BoxLineColorOp, 5, 6, "r g b ?name?"},
     1138    {"linewidth", 5, BoxLineWidthOp, 3, 4, "width ?name?"},
     1139    {"material",  1, BoxMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"},
     1140    {"opacity",   2, BoxOpacityOp, 3, 4, "value ?name?"},
     1141    {"orient",    2, BoxOrientOp, 6, 7, "qw qx qy qz ?name?"},
     1142    {"pos",       2, BoxPositionOp, 5, 6, "x y z ?name?"},
     1143    {"scale",     1, BoxScaleOp, 5, 6, "sx sy sz ?name?"},
     1144    {"visible",   1, BoxVisibleOp, 3, 4, "bool ?name?"},
     1145    {"wireframe", 1, BoxWireframeOp, 3, 4, "bool ?name?"}
     1146};
     1147static int nBoxOps = NumCmdSpecs(boxOps);
     1148
     1149static int
     1150BoxCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     1151       Tcl_Obj *const *objv)
     1152{
     1153    Tcl_ObjCmdProc *proc;
     1154
     1155    proc = Rappture::GetOpFromObj(interp, nBoxOps, boxOps,
    3621156                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
    3631157    if (proc == NULL) {
     
    5521346
    5531347static Rappture::CmdSpec cameraOps[] = {
    554     {"get", 1, CameraGetOp, 2, 2, ""},
    555     {"mode", 1, CameraModeOp, 3, 3, "mode"},
     1348    {"get",    1, CameraGetOp, 2, 2, ""},
     1349    {"mode",   1, CameraModeOp, 3, 3, "mode"},
    5561350    {"orient", 3, CameraOrientOp, 6, 6, "qw qx qy qz"},
    557     {"ortho", 1, CameraOrthoOp, 7, 7, "coordMode x y width height"},
    558     {"pan", 1, CameraPanOp, 4, 4, "panX panY"},
    559     {"reset", 2, CameraResetOp, 2, 3, "?all?"},
     1351    {"ortho",  1, CameraOrthoOp, 7, 7, "coordMode x y width height"},
     1352    {"pan",    1, CameraPanOp, 4, 4, "panX panY"},
     1353    {"reset",  2, CameraResetOp, 2, 3, "?all?"},
    5601354    {"rotate", 2, CameraRotateOp, 5, 5, "angle angle angle"},
    561     {"set", 1, CameraSetOp, 11, 11, "posX posY posZ focalPtX focalPtY focalPtZ viewUpX viewUpY viewUpZ"},
    562     {"zoom", 1, CameraZoomOp, 3, 3, "zoomAmount"}
     1355    {"set",    1, CameraSetOp, 11, 11, "posX posY posZ focalPtX focalPtY focalPtZ viewUpX viewUpY viewUpZ"},
     1356    {"zoom",   1, CameraZoomOp, 3, 3, "zoomAmount"}
    5631357};
    5641358static int nCameraOps = NumCmdSpecs(cameraOps);
     
    6921486
    6931487static int
     1488ConeAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1489          Tcl_Obj *const *objv)
     1490{
     1491    double radius, height;
     1492    bool cap;
     1493    if (Tcl_GetDoubleFromObj(interp, objv[2], &radius) != TCL_OK ||
     1494        Tcl_GetDoubleFromObj(interp, objv[3], &height) != TCL_OK ||
     1495        GetBooleanFromObj(interp, objv[4], &cap) != TCL_OK) {
     1496        return TCL_ERROR;
     1497    }
     1498    const char *name = Tcl_GetString(objv[5]);
     1499    if (!g_renderer->addCone(name, radius, height, cap)) {
     1500        Tcl_AppendResult(interp, "Failed to create cone", (char*)NULL);
     1501        return TCL_ERROR;
     1502    }
     1503    return TCL_OK;
     1504}
     1505
     1506static int
     1507ConeDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1508             Tcl_Obj *const *objv)
     1509{
     1510    if (objc == 3) {
     1511        const char *name = Tcl_GetString(objv[2]);
     1512        g_renderer->deleteGraphicsObject<Cone>(name);
     1513    } else {
     1514        g_renderer->deleteGraphicsObject<Cone>("all");
     1515    }
     1516    return TCL_OK;
     1517}
     1518
     1519static int
     1520ConeColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1521            Tcl_Obj *const *objv)
     1522{
     1523    float color[3];
     1524    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     1525        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     1526        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     1527        return TCL_ERROR;
     1528    }
     1529    if (objc == 6) {
     1530        const char *name = Tcl_GetString(objv[5]);
     1531        g_renderer->setGraphicsObjectColor<Cone>(name, color);
     1532    } else {
     1533        g_renderer->setGraphicsObjectColor<Cone>("all", color);
     1534    }
     1535    return TCL_OK;
     1536}
     1537
     1538static int
     1539ConeEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1540                     Tcl_Obj *const *objv)
     1541{
     1542    bool state;
     1543    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     1544        return TCL_ERROR;
     1545    }
     1546    if (objc == 4) {
     1547        const char *name = Tcl_GetString(objv[3]);
     1548        g_renderer->setGraphicsObjectEdgeVisibility<Cone>(name, state);
     1549    } else {
     1550        g_renderer->setGraphicsObjectEdgeVisibility<Cone>("all", state);
     1551    }
     1552    return TCL_OK;
     1553}
     1554
     1555static int
     1556ConeLightingOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1557               Tcl_Obj *const *objv)
     1558{
     1559    bool state;
     1560    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     1561        return TCL_ERROR;
     1562    }
     1563    if (objc == 4) {
     1564        const char *name = Tcl_GetString(objv[3]);
     1565        g_renderer->setGraphicsObjectLighting<Cone>(name, state);
     1566    } else {
     1567        g_renderer->setGraphicsObjectLighting<Cone>("all", state);
     1568    }
     1569    return TCL_OK;
     1570}
     1571
     1572static int
     1573ConeLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1574                Tcl_Obj *const *objv)
     1575{
     1576    float color[3];
     1577    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     1578        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     1579        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     1580        return TCL_ERROR;
     1581    }
     1582    if (objc == 6) {
     1583        const char *name = Tcl_GetString(objv[5]);
     1584        g_renderer->setGraphicsObjectEdgeColor<Cone>(name, color);
     1585    } else {
     1586        g_renderer->setGraphicsObjectEdgeColor<Cone>("all", color);
     1587    }
     1588    return TCL_OK;
     1589}
     1590
     1591static int
     1592ConeLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1593                Tcl_Obj *const *objv)
     1594{
     1595    float width;
     1596    if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) {
     1597        return TCL_ERROR;
     1598    }
     1599    if (objc == 4) {
     1600        const char *name = Tcl_GetString(objv[3]);
     1601        g_renderer->setGraphicsObjectEdgeWidth<Cone>(name, width);
     1602    } else {
     1603        g_renderer->setGraphicsObjectEdgeWidth<Cone>("all", width);
     1604    }
     1605    return TCL_OK;
     1606}
     1607
     1608static int
     1609ConeMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1610               Tcl_Obj *const *objv)
     1611{
     1612    double ambient, diffuse, specCoeff, specPower;
     1613    if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK ||
     1614        Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK ||
     1615        Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK ||
     1616        Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) {
     1617        return TCL_ERROR;
     1618    }
     1619
     1620    if (objc == 7) {
     1621        const char *name = Tcl_GetString(objv[6]);
     1622        g_renderer->setGraphicsObjectAmbient<Cone>(name, ambient);
     1623        g_renderer->setGraphicsObjectDiffuse<Cone>(name, diffuse);
     1624        g_renderer->setGraphicsObjectSpecular<Cone>(name, specCoeff, specPower);
     1625    } else {
     1626        g_renderer->setGraphicsObjectAmbient<Cone>("all", ambient);
     1627        g_renderer->setGraphicsObjectDiffuse<Cone>("all", diffuse);
     1628        g_renderer->setGraphicsObjectSpecular<Cone>("all", specCoeff, specPower);
     1629    }
     1630    return TCL_OK;
     1631}
     1632
     1633static int
     1634ConeOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1635              Tcl_Obj *const *objv)
     1636{
     1637    double opacity;
     1638    if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) {
     1639        return TCL_ERROR;
     1640    }
     1641    if (objc == 4) {
     1642        const char *name = Tcl_GetString(objv[3]);
     1643        g_renderer->setGraphicsObjectOpacity<Cone>(name, opacity);
     1644    } else {
     1645        g_renderer->setGraphicsObjectOpacity<Cone>("all", opacity);
     1646    }
     1647    return TCL_OK;
     1648}
     1649
     1650static int
     1651ConeOrientOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1652             Tcl_Obj *const *objv)
     1653{
     1654    double quat[4];
     1655    if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK ||
     1656        Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK ||
     1657        Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK ||
     1658        Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) {
     1659        return TCL_ERROR;
     1660    }
     1661    if (objc == 7) {
     1662        const char *name = Tcl_GetString(objv[6]);
     1663        g_renderer->setGraphicsObjectOrientation<Cone>(name, quat);
     1664    } else {
     1665        g_renderer->setGraphicsObjectOrientation<Cone>("all", quat);
     1666    }
     1667    return TCL_OK;
     1668}
     1669
     1670static int
     1671ConePositionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1672               Tcl_Obj *const *objv)
     1673{
     1674    double pos[3];
     1675    if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK ||
     1676        Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK ||
     1677        Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) {
     1678        return TCL_ERROR;
     1679    }
     1680    if (objc == 6) {
     1681        const char *name = Tcl_GetString(objv[5]);
     1682        g_renderer->setGraphicsObjectPosition<Cone>(name, pos);
     1683    } else {
     1684        g_renderer->setGraphicsObjectPosition<Cone>("all", pos);
     1685    }
     1686    return TCL_OK;
     1687}
     1688
     1689static int
     1690ConeResolutionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1691                 Tcl_Obj *const *objv)
     1692{
     1693    int res;
     1694    if (Tcl_GetIntFromObj(interp, objv[2], &res) != TCL_OK) {
     1695        return TCL_ERROR;
     1696    }
     1697    if (objc == 4) {
     1698        const char *name = Tcl_GetString(objv[3]);
     1699        g_renderer->setConeResolution(name, res);
     1700    } else {
     1701        g_renderer->setConeResolution("all", res);
     1702    }
     1703    return TCL_OK;
     1704}
     1705
     1706static int
     1707ConeScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1708            Tcl_Obj *const *objv)
     1709{
     1710    double scale[3];
     1711    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK ||
     1712        Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK ||
     1713        Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) {
     1714        return TCL_ERROR;
     1715    }
     1716    if (objc == 6) {
     1717        const char *name = Tcl_GetString(objv[5]);
     1718        g_renderer->setGraphicsObjectScale<Cone>(name, scale);
     1719    } else {
     1720        g_renderer->setGraphicsObjectScale<Cone>("all", scale);
     1721    }
     1722    return TCL_OK;
     1723}
     1724
     1725static int
     1726ConeVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1727              Tcl_Obj *const *objv)
     1728{
     1729    bool state;
     1730    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     1731        return TCL_ERROR;
     1732    }
     1733    if (objc == 4) {
     1734        const char *name = Tcl_GetString(objv[3]);
     1735        g_renderer->setGraphicsObjectVisibility<Cone>(name, state);
     1736    } else {
     1737        g_renderer->setGraphicsObjectVisibility<Cone>("all", state);
     1738    }
     1739    return TCL_OK;
     1740}
     1741
     1742static int
     1743ConeWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1744                Tcl_Obj *const *objv)
     1745{
     1746    bool state;
     1747    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     1748        return TCL_ERROR;
     1749    }
     1750    if (objc == 4) {
     1751        const char *name = Tcl_GetString(objv[3]);
     1752        g_renderer->setGraphicsObjectWireframe<Cone>(name, state);
     1753    } else {
     1754        g_renderer->setGraphicsObjectWireframe<Cone>("all", state);
     1755    }
     1756    return TCL_OK;
     1757}
     1758
     1759static Rappture::CmdSpec coneOps[] = {
     1760    {"add",       1, ConeAddOp, 6, 6, "radius height cap name"},
     1761    {"color",     1, ConeColorOp, 5, 6, "r g b ?name?"},
     1762    {"delete",    1, ConeDeleteOp, 2, 3, "?name?"},
     1763    {"edges",     1, ConeEdgeVisibilityOp, 3, 4, "bool ?name?"},
     1764    {"lighting",  3, ConeLightingOp, 3, 4, "bool ?name?"},
     1765    {"linecolor", 5, ConeLineColorOp, 5, 6, "r g b ?name?"},
     1766    {"linewidth", 5, ConeLineWidthOp, 3, 4, "width ?name?"},
     1767    {"material",  1, ConeMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"},
     1768    {"opacity",   2, ConeOpacityOp, 3, 4, "value ?name?"},
     1769    {"orient",    2, ConeOrientOp, 6, 7, "qw qx qy qz ?name?"},
     1770    {"pos",       2, ConePositionOp, 5, 6, "x y z ?name?"},
     1771    {"resolution",1, ConeResolutionOp, 3, 4, "res ?name?"},
     1772    {"scale",     1, ConeScaleOp, 5, 6, "sx sy sz ?name?"},
     1773    {"visible",   1, ConeVisibleOp, 3, 4, "bool ?name?"},
     1774    {"wireframe", 1, ConeWireframeOp, 3, 4, "bool ?name?"}
     1775};
     1776static int nConeOps = NumCmdSpecs(coneOps);
     1777
     1778static int
     1779ConeCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     1780       Tcl_Obj *const *objv)
     1781{
     1782    Tcl_ObjCmdProc *proc;
     1783
     1784    proc = Rappture::GetOpFromObj(interp, nConeOps, coneOps,
     1785                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
     1786    if (proc == NULL) {
     1787        return TCL_ERROR;
     1788    }
     1789    return (*proc) (clientData, interp, objc, objv);
     1790}
     1791
     1792static int
    6941793Contour2DAddContourListOp(ClientData clientData, Tcl_Interp *interp, int objc,
    6951794                          Tcl_Obj *const *objv)
     
    7841883
    7851884static int
     1885Contour2DColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1886                    Tcl_Obj *const *objv)
     1887{
     1888    const char *colorMapName = Tcl_GetString(objv[2]);
     1889    if (objc == 4) {
     1890        const char *dataSetName = Tcl_GetString(objv[3]);
     1891        g_renderer->setGraphicsObjectColorMap<Contour2D>(dataSetName, colorMapName);
     1892    } else {
     1893        g_renderer->setGraphicsObjectColorMap<Contour2D>("all", colorMapName);
     1894    }
     1895    return TCL_OK;
     1896}
     1897
     1898static int
     1899Contour2DColorModeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1900                     Tcl_Obj *const *objv)
     1901{
     1902    Contour2D::ColorMode mode;
     1903    const char *str = Tcl_GetString(objv[2]);
     1904    if (str[0] == 'c' && strcmp(str, "ccolor") == 0) {
     1905        mode = Contour2D::COLOR_CONSTANT;
     1906    } else if (str[0] == 's' && strcmp(str, "scalar") == 0) {
     1907        mode = Contour2D::COLOR_BY_SCALAR;
     1908    } else if (str[0] == 'v' && strcmp(str, "vmag") == 0) {
     1909        mode = Contour2D::COLOR_BY_VECTOR_MAGNITUDE;
     1910    } else if (str[0] == 'v' && strcmp(str, "vx") == 0) {
     1911        mode = Contour2D::COLOR_BY_VECTOR_X;
     1912    } else if (str[0] == 'v' && strcmp(str, "vy") == 0) {
     1913        mode = Contour2D::COLOR_BY_VECTOR_Y;
     1914    } else if (str[0] == 'v' && strcmp(str, "vz") == 0) {
     1915        mode = Contour2D::COLOR_BY_VECTOR_Z;
     1916    } else {
     1917        Tcl_AppendResult(interp, "bad color mode option \"", str,
     1918                         "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor'", (char*)NULL);
     1919        return TCL_ERROR;
     1920    }
     1921    const char *fieldName = Tcl_GetString(objv[3]);
     1922    if (mode == Contour2D::COLOR_CONSTANT) {
     1923        fieldName = NULL;
     1924    }
     1925    if (objc == 5) {
     1926        const char *name = Tcl_GetString(objv[4]);
     1927        g_renderer->setContour2DColorMode(name, mode, fieldName);
     1928    } else {
     1929        g_renderer->setContour2DColorMode("all", mode, fieldName);
     1930    }
     1931    return TCL_OK;
     1932}
     1933
     1934static int
    7861935Contour2DLightingOp(ClientData clientData, Tcl_Interp *interp, int objc,
    7871936                    Tcl_Obj *const *objv)
     
    9302079static Rappture::CmdSpec contour2dOps[] = {
    9312080    {"add",       1, Contour2DAddOp, 4, 5, "oper value ?dataSetName?"},
    932     {"color",     1, Contour2DLineColorOp, 5, 6, "r g b ?dataSetName?"},
     2081    {"ccolor",    2, Contour2DLineColorOp, 5, 6, "r g b ?dataSetName?"},
     2082    {"colormap",  7, Contour2DColorMapOp, 3, 4, "colorMapName ?dataSetName?"},
     2083    {"colormode", 7, Contour2DColorModeOp, 4, 5, "mode fieldName ?dataSetName?"},
    9332084    {"delete",    1, Contour2DDeleteOp, 2, 3, "?dataSetName?"},
    9342085    {"lighting",  3, Contour2DLightingOp, 3, 4, "bool ?dataSetName?"},
     
    16842835
    16852836static int
     2837CylinderAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2838              Tcl_Obj *const *objv)
     2839{
     2840    double radius, height;
     2841    bool cap = true;
     2842    if (Tcl_GetDoubleFromObj(interp, objv[2], &radius) != TCL_OK ||
     2843        Tcl_GetDoubleFromObj(interp, objv[3], &height) != TCL_OK ||
     2844        GetBooleanFromObj(interp, objv[4], &cap) != TCL_OK) {
     2845        return TCL_ERROR;
     2846    }
     2847    const char *name = Tcl_GetString(objv[5]);
     2848    if (!g_renderer->addCylinder(name, radius, height, cap)) {
     2849        Tcl_AppendResult(interp, "Failed to create cylinder", (char*)NULL);
     2850        return TCL_ERROR;
     2851    }
     2852    return TCL_OK;
     2853}
     2854
     2855static int
     2856CylinderDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2857                 Tcl_Obj *const *objv)
     2858{
     2859    if (objc == 3) {
     2860        const char *name = Tcl_GetString(objv[2]);
     2861        g_renderer->deleteGraphicsObject<Cylinder>(name);
     2862    } else {
     2863        g_renderer->deleteGraphicsObject<Cylinder>("all");
     2864    }
     2865    return TCL_OK;
     2866}
     2867
     2868static int
     2869CylinderColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2870                Tcl_Obj *const *objv)
     2871{
     2872    float color[3];
     2873    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     2874        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     2875        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     2876        return TCL_ERROR;
     2877    }
     2878    if (objc == 6) {
     2879        const char *name = Tcl_GetString(objv[5]);
     2880        g_renderer->setGraphicsObjectColor<Cylinder>(name, color);
     2881    } else {
     2882        g_renderer->setGraphicsObjectColor<Cylinder>("all", color);
     2883    }
     2884    return TCL_OK;
     2885}
     2886
     2887static int
     2888CylinderEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2889                         Tcl_Obj *const *objv)
     2890{
     2891    bool state;
     2892    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     2893        return TCL_ERROR;
     2894    }
     2895    if (objc == 4) {
     2896        const char *name = Tcl_GetString(objv[3]);
     2897        g_renderer->setGraphicsObjectEdgeVisibility<Cylinder>(name, state);
     2898    } else {
     2899        g_renderer->setGraphicsObjectEdgeVisibility<Cylinder>("all", state);
     2900    }
     2901    return TCL_OK;
     2902}
     2903
     2904static int
     2905CylinderLightingOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2906                   Tcl_Obj *const *objv)
     2907{
     2908    bool state;
     2909    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     2910        return TCL_ERROR;
     2911    }
     2912    if (objc == 4) {
     2913        const char *name = Tcl_GetString(objv[3]);
     2914        g_renderer->setGraphicsObjectLighting<Cylinder>(name, state);
     2915    } else {
     2916        g_renderer->setGraphicsObjectLighting<Cylinder>("all", state);
     2917    }
     2918    return TCL_OK;
     2919}
     2920
     2921static int
     2922CylinderLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2923                    Tcl_Obj *const *objv)
     2924{
     2925    float color[3];
     2926    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     2927        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     2928        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     2929        return TCL_ERROR;
     2930    }
     2931    if (objc == 6) {
     2932        const char *name = Tcl_GetString(objv[5]);
     2933        g_renderer->setGraphicsObjectEdgeColor<Cylinder>(name, color);
     2934    } else {
     2935        g_renderer->setGraphicsObjectEdgeColor<Cylinder>("all", color);
     2936    }
     2937    return TCL_OK;
     2938}
     2939
     2940static int
     2941CylinderLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2942                    Tcl_Obj *const *objv)
     2943{
     2944    float width;
     2945    if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) {
     2946        return TCL_ERROR;
     2947    }
     2948    if (objc == 4) {
     2949        const char *name = Tcl_GetString(objv[3]);
     2950        g_renderer->setGraphicsObjectEdgeWidth<Cylinder>(name, width);
     2951    } else {
     2952        g_renderer->setGraphicsObjectEdgeWidth<Cylinder>("all", width);
     2953    }
     2954    return TCL_OK;
     2955}
     2956
     2957static int
     2958CylinderMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2959                   Tcl_Obj *const *objv)
     2960{
     2961    double ambient, diffuse, specCoeff, specPower;
     2962    if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK ||
     2963        Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK ||
     2964        Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK ||
     2965        Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) {
     2966        return TCL_ERROR;
     2967    }
     2968
     2969    if (objc == 7) {
     2970        const char *name = Tcl_GetString(objv[6]);
     2971        g_renderer->setGraphicsObjectAmbient<Cylinder>(name, ambient);
     2972        g_renderer->setGraphicsObjectDiffuse<Cylinder>(name, diffuse);
     2973        g_renderer->setGraphicsObjectSpecular<Cylinder>(name, specCoeff, specPower);
     2974    } else {
     2975        g_renderer->setGraphicsObjectAmbient<Cylinder>("all", ambient);
     2976        g_renderer->setGraphicsObjectDiffuse<Cylinder>("all", diffuse);
     2977        g_renderer->setGraphicsObjectSpecular<Cylinder>("all", specCoeff, specPower);
     2978    }
     2979    return TCL_OK;
     2980}
     2981
     2982static int
     2983CylinderOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2984                  Tcl_Obj *const *objv)
     2985{
     2986    double opacity;
     2987    if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) {
     2988        return TCL_ERROR;
     2989    }
     2990    if (objc == 4) {
     2991        const char *name = Tcl_GetString(objv[3]);
     2992        g_renderer->setGraphicsObjectOpacity<Cylinder>(name, opacity);
     2993    } else {
     2994        g_renderer->setGraphicsObjectOpacity<Cylinder>("all", opacity);
     2995    }
     2996    return TCL_OK;
     2997}
     2998
     2999static int
     3000CylinderOrientOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3001                 Tcl_Obj *const *objv)
     3002{
     3003    double quat[4];
     3004    if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK ||
     3005        Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK ||
     3006        Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK ||
     3007        Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) {
     3008        return TCL_ERROR;
     3009    }
     3010    if (objc == 7) {
     3011        const char *name = Tcl_GetString(objv[6]);
     3012        g_renderer->setGraphicsObjectOrientation<Cylinder>(name, quat);
     3013    } else {
     3014        g_renderer->setGraphicsObjectOrientation<Cylinder>("all", quat);
     3015    }
     3016    return TCL_OK;
     3017}
     3018
     3019static int
     3020CylinderPositionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3021                   Tcl_Obj *const *objv)
     3022{
     3023    double pos[3];
     3024    if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK ||
     3025        Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK ||
     3026        Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) {
     3027        return TCL_ERROR;
     3028    }
     3029    if (objc == 6) {
     3030        const char *name = Tcl_GetString(objv[5]);
     3031        g_renderer->setGraphicsObjectPosition<Cylinder>(name, pos);
     3032    } else {
     3033        g_renderer->setGraphicsObjectPosition<Cylinder>("all", pos);
     3034    }
     3035    return TCL_OK;
     3036}
     3037
     3038static int
     3039CylinderResolutionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3040                     Tcl_Obj *const *objv)
     3041{
     3042    int res;
     3043    if (Tcl_GetIntFromObj(interp, objv[2], &res) != TCL_OK) {
     3044        return TCL_ERROR;
     3045    }
     3046    if (objc == 4) {
     3047        const char *name = Tcl_GetString(objv[3]);
     3048        g_renderer->setCylinderResolution(name, res);
     3049    } else {
     3050        g_renderer->setCylinderResolution("all", res);
     3051    }
     3052    return TCL_OK;
     3053}
     3054
     3055static int
     3056CylinderScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3057                Tcl_Obj *const *objv)
     3058{
     3059    double scale[3];
     3060    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK ||
     3061        Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK ||
     3062        Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) {
     3063        return TCL_ERROR;
     3064    }
     3065    if (objc == 6) {
     3066        const char *name = Tcl_GetString(objv[5]);
     3067        g_renderer->setGraphicsObjectScale<Cylinder>(name, scale);
     3068    } else {
     3069        g_renderer->setGraphicsObjectScale<Cylinder>("all", scale);
     3070    }
     3071    return TCL_OK;
     3072}
     3073
     3074static int
     3075CylinderVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3076                  Tcl_Obj *const *objv)
     3077{
     3078    bool state;
     3079    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     3080        return TCL_ERROR;
     3081    }
     3082    if (objc == 4) {
     3083        const char *name = Tcl_GetString(objv[3]);
     3084        g_renderer->setGraphicsObjectVisibility<Cylinder>(name, state);
     3085    } else {
     3086        g_renderer->setGraphicsObjectVisibility<Cylinder>("all", state);
     3087    }
     3088    return TCL_OK;
     3089}
     3090
     3091static int
     3092CylinderWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3093                    Tcl_Obj *const *objv)
     3094{
     3095    bool state;
     3096    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     3097        return TCL_ERROR;
     3098    }
     3099    if (objc == 4) {
     3100        const char *name = Tcl_GetString(objv[3]);
     3101        g_renderer->setGraphicsObjectWireframe<Cylinder>(name, state);
     3102    } else {
     3103        g_renderer->setGraphicsObjectWireframe<Cylinder>("all", state);
     3104    }
     3105    return TCL_OK;
     3106}
     3107
     3108static Rappture::CmdSpec cylinderOps[] = {
     3109    {"add",       1, CylinderAddOp, 6, 6, " radius height cap name"},
     3110    {"color",     1, CylinderColorOp, 5, 6, "r g b ?name?"},
     3111    {"delete",    1, CylinderDeleteOp, 2, 3, "?name?"},
     3112    {"edges",     1, CylinderEdgeVisibilityOp, 3, 4, "bool ?name?"},
     3113    {"lighting",  3, CylinderLightingOp, 3, 4, "bool ?name?"},
     3114    {"linecolor", 5, CylinderLineColorOp, 5, 6, "r g b ?name?"},
     3115    {"linewidth", 5, CylinderLineWidthOp, 3, 4, "width ?name?"},
     3116    {"material",  1, CylinderMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"},
     3117    {"opacity",   2, CylinderOpacityOp, 3, 4, "value ?name?"},
     3118    {"orient",    2, CylinderOrientOp, 6, 7, "qw qx qy qz ?name?"},
     3119    {"pos",       2, CylinderPositionOp, 5, 6, "x y z ?name?"},
     3120    {"resolution",1, CylinderResolutionOp, 3, 4, "res ?name?"},
     3121    {"scale",     1, CylinderScaleOp, 5, 6, "sx sy sz ?name?"},
     3122    {"visible",   1, CylinderVisibleOp, 3, 4, "bool ?name?"},
     3123    {"wireframe", 1, CylinderWireframeOp, 3, 4, "bool ?name?"}
     3124};
     3125static int nCylinderOps = NumCmdSpecs(cylinderOps);
     3126
     3127static int
     3128CylinderCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     3129       Tcl_Obj *const *objv)
     3130{
     3131    Tcl_ObjCmdProc *proc;
     3132
     3133    proc = Rappture::GetOpFromObj(interp, nCylinderOps, cylinderOps,
     3134                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
     3135    if (proc == NULL) {
     3136        return TCL_ERROR;
     3137    }
     3138    return (*proc) (clientData, interp, objc, objv);
     3139}
     3140
     3141static int
    16863142DataSetActiveScalarsOp(ClientData clientData, Tcl_Interp *interp, int objc,
    16873143                       Tcl_Obj *const *objv)
     
    20993555
    21003556    proc = Rappture::GetOpFromObj(interp, nDataSetOps, dataSetOps,
     3557                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
     3558    if (proc == NULL) {
     3559        return TCL_ERROR;
     3560    }
     3561    return (*proc) (clientData, interp, objc, objv);
     3562}
     3563
     3564static int
     3565DiskAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3566          Tcl_Obj *const *objv)
     3567{
     3568    double innerRadius, outerRadius;
     3569    if (Tcl_GetDoubleFromObj(interp, objv[2], &innerRadius) != TCL_OK ||
     3570        Tcl_GetDoubleFromObj(interp, objv[3], &outerRadius) != TCL_OK) {
     3571        return TCL_ERROR;
     3572    }
     3573    const char *name = Tcl_GetString(objv[4]);
     3574    if (!g_renderer->addDisk(name, innerRadius, outerRadius)) {
     3575        Tcl_AppendResult(interp, "Failed to create disk", (char*)NULL);
     3576        return TCL_ERROR;
     3577    }
     3578    return TCL_OK;
     3579}
     3580
     3581static int
     3582DiskDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3583             Tcl_Obj *const *objv)
     3584{
     3585    if (objc == 3) {
     3586        const char *name = Tcl_GetString(objv[2]);
     3587        g_renderer->deleteGraphicsObject<Disk>(name);
     3588    } else {
     3589        g_renderer->deleteGraphicsObject<Disk>("all");
     3590    }
     3591    return TCL_OK;
     3592}
     3593
     3594static int
     3595DiskColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3596            Tcl_Obj *const *objv)
     3597{
     3598    float color[3];
     3599    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     3600        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     3601        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     3602        return TCL_ERROR;
     3603    }
     3604    if (objc == 6) {
     3605        const char *name = Tcl_GetString(objv[5]);
     3606        g_renderer->setGraphicsObjectColor<Disk>(name, color);
     3607    } else {
     3608        g_renderer->setGraphicsObjectColor<Disk>("all", color);
     3609    }
     3610    return TCL_OK;
     3611}
     3612
     3613static int
     3614DiskEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3615                     Tcl_Obj *const *objv)
     3616{
     3617    bool state;
     3618    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     3619        return TCL_ERROR;
     3620    }
     3621    if (objc == 4) {
     3622        const char *name = Tcl_GetString(objv[3]);
     3623        g_renderer->setGraphicsObjectEdgeVisibility<Disk>(name, state);
     3624    } else {
     3625        g_renderer->setGraphicsObjectEdgeVisibility<Disk>("all", state);
     3626    }
     3627    return TCL_OK;
     3628}
     3629
     3630static int
     3631DiskLightingOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3632               Tcl_Obj *const *objv)
     3633{
     3634    bool state;
     3635    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     3636        return TCL_ERROR;
     3637    }
     3638    if (objc == 4) {
     3639        const char *name = Tcl_GetString(objv[3]);
     3640        g_renderer->setGraphicsObjectLighting<Disk>(name, state);
     3641    } else {
     3642        g_renderer->setGraphicsObjectLighting<Disk>("all", state);
     3643    }
     3644    return TCL_OK;
     3645}
     3646
     3647static int
     3648DiskLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3649                Tcl_Obj *const *objv)
     3650{
     3651    float color[3];
     3652    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     3653        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     3654        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     3655        return TCL_ERROR;
     3656    }
     3657    if (objc == 6) {
     3658        const char *name = Tcl_GetString(objv[5]);
     3659        g_renderer->setGraphicsObjectEdgeColor<Disk>(name, color);
     3660    } else {
     3661        g_renderer->setGraphicsObjectEdgeColor<Disk>("all", color);
     3662    }
     3663    return TCL_OK;
     3664}
     3665
     3666static int
     3667DiskLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3668                Tcl_Obj *const *objv)
     3669{
     3670    float width;
     3671    if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) {
     3672        return TCL_ERROR;
     3673    }
     3674    if (objc == 4) {
     3675        const char *name = Tcl_GetString(objv[3]);
     3676        g_renderer->setGraphicsObjectEdgeWidth<Disk>(name, width);
     3677    } else {
     3678        g_renderer->setGraphicsObjectEdgeWidth<Disk>("all", width);
     3679    }
     3680    return TCL_OK;
     3681}
     3682
     3683static int
     3684DiskMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3685               Tcl_Obj *const *objv)
     3686{
     3687    double ambient, diffuse, specCoeff, specPower;
     3688    if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK ||
     3689        Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK ||
     3690        Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK ||
     3691        Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) {
     3692        return TCL_ERROR;
     3693    }
     3694
     3695    if (objc == 7) {
     3696        const char *name = Tcl_GetString(objv[6]);
     3697        g_renderer->setGraphicsObjectAmbient<Disk>(name, ambient);
     3698        g_renderer->setGraphicsObjectDiffuse<Disk>(name, diffuse);
     3699        g_renderer->setGraphicsObjectSpecular<Disk>(name, specCoeff, specPower);
     3700    } else {
     3701        g_renderer->setGraphicsObjectAmbient<Disk>("all", ambient);
     3702        g_renderer->setGraphicsObjectDiffuse<Disk>("all", diffuse);
     3703        g_renderer->setGraphicsObjectSpecular<Disk>("all", specCoeff, specPower);
     3704    }
     3705    return TCL_OK;
     3706}
     3707
     3708static int
     3709DiskOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3710              Tcl_Obj *const *objv)
     3711{
     3712    double opacity;
     3713    if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) {
     3714        return TCL_ERROR;
     3715    }
     3716    if (objc == 4) {
     3717        const char *name = Tcl_GetString(objv[3]);
     3718        g_renderer->setGraphicsObjectOpacity<Disk>(name, opacity);
     3719    } else {
     3720        g_renderer->setGraphicsObjectOpacity<Disk>("all", opacity);
     3721    }
     3722    return TCL_OK;
     3723}
     3724
     3725static int
     3726DiskOrientOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3727             Tcl_Obj *const *objv)
     3728{
     3729    double quat[4];
     3730    if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK ||
     3731        Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK ||
     3732        Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK ||
     3733        Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) {
     3734        return TCL_ERROR;
     3735    }
     3736    if (objc == 7) {
     3737        const char *name = Tcl_GetString(objv[6]);
     3738        g_renderer->setGraphicsObjectOrientation<Disk>(name, quat);
     3739    } else {
     3740        g_renderer->setGraphicsObjectOrientation<Disk>("all", quat);
     3741    }
     3742    return TCL_OK;
     3743}
     3744
     3745static int
     3746DiskPositionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3747               Tcl_Obj *const *objv)
     3748{
     3749    double pos[3];
     3750    if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK ||
     3751        Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK ||
     3752        Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) {
     3753        return TCL_ERROR;
     3754    }
     3755    if (objc == 6) {
     3756        const char *name = Tcl_GetString(objv[5]);
     3757        g_renderer->setGraphicsObjectPosition<Disk>(name, pos);
     3758    } else {
     3759        g_renderer->setGraphicsObjectPosition<Disk>("all", pos);
     3760    }
     3761    return TCL_OK;
     3762}
     3763
     3764static int
     3765DiskResolutionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3766                 Tcl_Obj *const *objv)
     3767{
     3768    int radial, circum;
     3769    if (Tcl_GetIntFromObj(interp, objv[2], &radial) != TCL_OK ||
     3770        Tcl_GetIntFromObj(interp, objv[3], &circum) != TCL_OK) {
     3771        return TCL_ERROR;
     3772    }
     3773    if (objc == 5) {
     3774        const char *name = Tcl_GetString(objv[4]);
     3775        g_renderer->setDiskResolution(name, radial, circum);
     3776    } else {
     3777        g_renderer->setDiskResolution("all", radial, circum);
     3778    }
     3779    return TCL_OK;
     3780}
     3781
     3782static int
     3783DiskScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3784            Tcl_Obj *const *objv)
     3785{
     3786    double scale[3];
     3787    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK ||
     3788        Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK ||
     3789        Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) {
     3790        return TCL_ERROR;
     3791    }
     3792    if (objc == 6) {
     3793        const char *name = Tcl_GetString(objv[5]);
     3794        g_renderer->setGraphicsObjectScale<Disk>(name, scale);
     3795    } else {
     3796        g_renderer->setGraphicsObjectScale<Disk>("all", scale);
     3797    }
     3798    return TCL_OK;
     3799}
     3800
     3801static int
     3802DiskVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3803              Tcl_Obj *const *objv)
     3804{
     3805    bool state;
     3806    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     3807        return TCL_ERROR;
     3808    }
     3809    if (objc == 4) {
     3810        const char *name = Tcl_GetString(objv[3]);
     3811        g_renderer->setGraphicsObjectVisibility<Disk>(name, state);
     3812    } else {
     3813        g_renderer->setGraphicsObjectVisibility<Disk>("all", state);
     3814    }
     3815    return TCL_OK;
     3816}
     3817
     3818static int
     3819DiskWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3820                Tcl_Obj *const *objv)
     3821{
     3822    bool state;
     3823    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     3824        return TCL_ERROR;
     3825    }
     3826    if (objc == 4) {
     3827        const char *name = Tcl_GetString(objv[3]);
     3828        g_renderer->setGraphicsObjectWireframe<Disk>(name, state);
     3829    } else {
     3830        g_renderer->setGraphicsObjectWireframe<Disk>("all", state);
     3831    }
     3832    return TCL_OK;
     3833}
     3834
     3835static Rappture::CmdSpec diskOps[] = {
     3836    {"add",       1, DiskAddOp, 5, 5, "innerRadius outerRadius name"},
     3837    {"color",     1, DiskColorOp, 5, 6, "r g b ?name?"},
     3838    {"delete",    1, DiskDeleteOp, 2, 3, "?name?"},
     3839    {"edges",     1, DiskEdgeVisibilityOp, 3, 4, "bool ?name?"},
     3840    {"lighting",  3, DiskLightingOp, 3, 4, "bool ?name?"},
     3841    {"linecolor", 5, DiskLineColorOp, 5, 6, "r g b ?name?"},
     3842    {"linewidth", 5, DiskLineWidthOp, 3, 4, "width ?name?"},
     3843    {"material",  1, DiskMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"},
     3844    {"opacity",   2, DiskOpacityOp, 3, 4, "value ?name?"},
     3845    {"orient",    2, DiskOrientOp, 6, 7, "qw qx qy qz ?name?"},
     3846    {"pos",       2, DiskPositionOp, 5, 6, "x y z ?name?"},
     3847    {"resolution",1, DiskResolutionOp, 4, 5, "resRadial resCircum ?name?"},
     3848    {"scale",     1, DiskScaleOp, 5, 6, "sx sy sz ?name?"},
     3849    {"visible",   1, DiskVisibleOp, 3, 4, "bool ?name?"},
     3850    {"wireframe", 1, DiskWireframeOp, 3, 4, "bool ?name?"}
     3851};
     3852static int nDiskOps = NumCmdSpecs(diskOps);
     3853
     3854static int
     3855DiskCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     3856        Tcl_Obj *const *objv)
     3857{
     3858    Tcl_ObjCmdProc *proc;
     3859
     3860    proc = Rappture::GetOpFromObj(interp, nDiskOps, diskOps,
    21013861                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
    21023862    if (proc == NULL) {
     
    23614121
    23624122static int
     4123GlyphsOrientGlyphsOp(ClientData clientData, Tcl_Interp *interp, int objc,
     4124                     Tcl_Obj *const *objv)
     4125{
     4126    bool state;
     4127    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     4128        return TCL_ERROR;
     4129    }
     4130    const char *fieldName = Tcl_GetString(objv[3]);
     4131    if (objc == 5) {
     4132        const char *name = Tcl_GetString(objv[4]);
     4133        g_renderer->setGlyphsOrientMode(name, state, fieldName);
     4134    } else {
     4135        g_renderer->setGlyphsOrientMode("all", state, fieldName);
     4136    }
     4137    return TCL_OK;
     4138}
     4139
     4140static int
    23634141GlyphsPositionOp(ClientData clientData, Tcl_Interp *interp, int objc,
    23644142                 Tcl_Obj *const *objv)
     
    25274305    {"delete",    1, GlyphsDeleteOp, 2, 3, "?dataSetName?"},
    25284306    {"edges",     1, GlyphsEdgeVisibilityOp, 3, 4, "bool ?dataSetName?"},
    2529     {"gscale",    1, GlyphsScaleFactorOp, 3, 4, "scaleFactor ?dataSetName?"},
     4307    {"gorient",   2, GlyphsOrientGlyphsOp, 4, 5, "bool fieldName ?dataSetName?"},
     4308    {"gscale",    2, GlyphsScaleFactorOp, 3, 4, "scaleFactor ?dataSetName?"},
    25304309    {"lighting",  3, GlyphsLightingOp, 3, 4, "bool ?dataSetName?"},
    25314310    {"linecolor", 5, GlyphsLineColorOp, 5, 6, "r g b ?dataSetName?"},
     
    34335212
    34345213static int
     5214LineAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5215          Tcl_Obj *const *objv)
     5216{
     5217    double pt1[3];
     5218    double pt2[3];
     5219    if (Tcl_GetDoubleFromObj(interp, objv[2], &pt1[0]) != TCL_OK ||
     5220        Tcl_GetDoubleFromObj(interp, objv[3], &pt1[1]) != TCL_OK ||
     5221        Tcl_GetDoubleFromObj(interp, objv[4], &pt1[2]) != TCL_OK ||
     5222        Tcl_GetDoubleFromObj(interp, objv[5], &pt2[0]) != TCL_OK ||
     5223        Tcl_GetDoubleFromObj(interp, objv[6], &pt2[1]) != TCL_OK ||
     5224        Tcl_GetDoubleFromObj(interp, objv[7], &pt2[2]) != TCL_OK) {
     5225        return TCL_ERROR;
     5226    }
     5227    const char *name = Tcl_GetString(objv[8]);
     5228    if (!g_renderer->addLine(name, pt1, pt2)) {
     5229        Tcl_AppendResult(interp, "Failed to create line", (char*)NULL);
     5230        return TCL_ERROR;
     5231    }
     5232    return TCL_OK;
     5233}
     5234
     5235static int
     5236LineDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5237             Tcl_Obj *const *objv)
     5238{
     5239    if (objc == 3) {
     5240        const char *name = Tcl_GetString(objv[2]);
     5241        g_renderer->deleteGraphicsObject<Line>(name);
     5242    } else {
     5243        g_renderer->deleteGraphicsObject<Line>("all");
     5244    }
     5245    return TCL_OK;
     5246}
     5247
     5248static int
     5249LineColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5250            Tcl_Obj *const *objv)
     5251{
     5252    float color[3];
     5253    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     5254        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     5255        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     5256        return TCL_ERROR;
     5257    }
     5258    if (objc == 6) {
     5259        const char *name = Tcl_GetString(objv[5]);
     5260        g_renderer->setGraphicsObjectColor<Line>(name, color);
     5261    } else {
     5262        g_renderer->setGraphicsObjectColor<Line>("all", color);
     5263    }
     5264    return TCL_OK;
     5265}
     5266
     5267static int
     5268LineLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5269                Tcl_Obj *const *objv)
     5270{
     5271    float width;
     5272    if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) {
     5273        return TCL_ERROR;
     5274    }
     5275    if (objc == 4) {
     5276        const char *name = Tcl_GetString(objv[3]);
     5277        g_renderer->setGraphicsObjectEdgeWidth<Line>(name, width);
     5278    } else {
     5279        g_renderer->setGraphicsObjectEdgeWidth<Line>("all", width);
     5280    }
     5281    return TCL_OK;
     5282}
     5283
     5284static int
     5285LineOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5286              Tcl_Obj *const *objv)
     5287{
     5288    double opacity;
     5289    if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) {
     5290        return TCL_ERROR;
     5291    }
     5292    if (objc == 4) {
     5293        const char *name = Tcl_GetString(objv[3]);
     5294        g_renderer->setGraphicsObjectOpacity<Line>(name, opacity);
     5295    } else {
     5296        g_renderer->setGraphicsObjectOpacity<Line>("all", opacity);
     5297    }
     5298    return TCL_OK;
     5299}
     5300
     5301static int
     5302LineOrientOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5303             Tcl_Obj *const *objv)
     5304{
     5305    double quat[4];
     5306    if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK ||
     5307        Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK ||
     5308        Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK ||
     5309        Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) {
     5310        return TCL_ERROR;
     5311    }
     5312    if (objc == 7) {
     5313        const char *name = Tcl_GetString(objv[6]);
     5314        g_renderer->setGraphicsObjectOrientation<Line>(name, quat);
     5315    } else {
     5316        g_renderer->setGraphicsObjectOrientation<Line>("all", quat);
     5317    }
     5318    return TCL_OK;
     5319}
     5320
     5321static int
     5322LinePositionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5323               Tcl_Obj *const *objv)
     5324{
     5325    double pos[3];
     5326    if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK ||
     5327        Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK ||
     5328        Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) {
     5329        return TCL_ERROR;
     5330    }
     5331    if (objc == 6) {
     5332        const char *name = Tcl_GetString(objv[5]);
     5333        g_renderer->setGraphicsObjectPosition<Line>(name, pos);
     5334    } else {
     5335        g_renderer->setGraphicsObjectPosition<Line>("all", pos);
     5336    }
     5337    return TCL_OK;
     5338}
     5339
     5340static int
     5341LineScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5342            Tcl_Obj *const *objv)
     5343{
     5344    double scale[3];
     5345    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK ||
     5346        Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK ||
     5347        Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) {
     5348        return TCL_ERROR;
     5349    }
     5350    if (objc == 6) {
     5351        const char *name = Tcl_GetString(objv[5]);
     5352        g_renderer->setGraphicsObjectScale<Line>(name, scale);
     5353    } else {
     5354        g_renderer->setGraphicsObjectScale<Line>("all", scale);
     5355    }
     5356    return TCL_OK;
     5357}
     5358
     5359static int
     5360LineVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5361              Tcl_Obj *const *objv)
     5362{
     5363    bool state;
     5364    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     5365        return TCL_ERROR;
     5366    }
     5367    if (objc == 4) {
     5368        const char *name = Tcl_GetString(objv[3]);
     5369        g_renderer->setGraphicsObjectVisibility<Line>(name, state);
     5370    } else {
     5371        g_renderer->setGraphicsObjectVisibility<Line>("all", state);
     5372    }
     5373    return TCL_OK;
     5374}
     5375
     5376static Rappture::CmdSpec lineOps[] = {
     5377    {"add",       1, LineAddOp, 9, 9, "x1 y1 z1 x2 y2 z2 name"},
     5378    {"color",     1, LineColorOp, 5, 6, "r g b ?name?"},
     5379    {"delete",    1, LineDeleteOp, 2, 3, "?name?"},
     5380    {"linecolor", 5, LineColorOp, 5, 6, "r g b ?name?"},
     5381    {"linewidth", 5, LineLineWidthOp, 3, 4, "width ?name?"},
     5382    {"opacity",   2, LineOpacityOp, 3, 4, "value ?name?"},
     5383    {"orient",    2, LineOrientOp, 6, 7, "qw qx qy qz ?name?"},
     5384    {"pos",       2, LinePositionOp, 5, 6, "x y z ?name?"},
     5385    {"scale",     2, LineScaleOp, 5, 6, "sx sy sz ?name?"},
     5386    {"visible",   1, LineVisibleOp, 3, 4, "bool ?name?"}
     5387};
     5388static int nLineOps = NumCmdSpecs(lineOps);
     5389
     5390static int
     5391LineCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     5392       Tcl_Obj *const *objv)
     5393{
     5394    Tcl_ObjCmdProc *proc;
     5395
     5396    proc = Rappture::GetOpFromObj(interp, nLineOps, lineOps,
     5397                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
     5398    if (proc == NULL) {
     5399        return TCL_ERROR;
     5400    }
     5401    return (*proc) (clientData, interp, objc, objv);
     5402}
     5403
     5404static int
    34355405MoleculeAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
    34365406              Tcl_Obj *const *objv)
     
    34645434    } else {
    34655435        g_renderer->setMoleculeAtomVisibility("all", state);
     5436    }
     5437    return TCL_OK;
     5438}
     5439
     5440static int
     5441MoleculeAtomLabelVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5442                              Tcl_Obj *const *objv)
     5443{
     5444    bool state;
     5445    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     5446        return TCL_ERROR;
     5447    }
     5448    if (objc == 4) {
     5449        const char *name = Tcl_GetString(objv[3]);
     5450        g_renderer->setMoleculeAtomLabelVisibility(name, state);
     5451    } else {
     5452        g_renderer->setMoleculeAtomLabelVisibility("all", state);
     5453    }
     5454    return TCL_OK;
     5455}
     5456
     5457static int
     5458MoleculeAtomScaleFactorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5459                          Tcl_Obj *const *objv)
     5460{
     5461    double scale;
     5462    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale) != TCL_OK) {
     5463        return TCL_ERROR;
     5464    }
     5465    if (objc == 4) {
     5466        const char *name = Tcl_GetString(objv[3]);
     5467        g_renderer->setMoleculeAtomRadiusScale(name, scale);
     5468    } else {
     5469        g_renderer->setMoleculeAtomRadiusScale("all", scale);
    34665470    }
    34675471    return TCL_OK;
     
    34975501
    34985502static int
     5503MoleculeBondColorModeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5504                        Tcl_Obj *const *objv)
     5505{
     5506    Molecule::BondColorMode mode;
     5507    const char *colorMode = Tcl_GetString(objv[2]);
     5508    if (colorMode[0] == 'c' && strcmp(colorMode, "constant") == 0) {
     5509        mode = Molecule::BOND_COLOR_CONSTANT;
     5510    } else if (colorMode[0] == 'b' && strcmp(colorMode, "by_elements") == 0) {
     5511        mode = Molecule::BOND_COLOR_BY_ELEMENTS;
     5512    } else {
     5513        Tcl_AppendResult(interp, "bad bcmode option \"", colorMode,
     5514                         "\": should be constant or by_elements", (char*)NULL);
     5515        return TCL_ERROR;
     5516    }
     5517    if (objc == 4) {
     5518        const char *name = Tcl_GetString(objv[3]);
     5519        g_renderer->setMoleculeBondColorMode(name, mode);
     5520    } else {
     5521        g_renderer->setMoleculeBondColorMode("all", mode);
     5522    }
     5523    return TCL_OK;
     5524}
     5525
     5526static int
     5527MoleculeBondColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5528                    Tcl_Obj *const *objv)
     5529{
     5530    float color[3];
     5531    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     5532        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     5533        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     5534        return TCL_ERROR;
     5535    }
     5536    if (objc == 6) {
     5537        const char *name = Tcl_GetString(objv[5]);
     5538        g_renderer->setMoleculeBondColor(name, color);
     5539    } else {
     5540        g_renderer->setMoleculeBondColor("all", color);
     5541    }
     5542    return TCL_OK;
     5543}
     5544
     5545static int
     5546MoleculeBondScaleFactorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5547                          Tcl_Obj *const *objv)
     5548{
     5549    double scale;
     5550    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale) != TCL_OK) {
     5551        return TCL_ERROR;
     5552    }
     5553    if (objc == 4) {
     5554        const char *name = Tcl_GetString(objv[3]);
     5555        g_renderer->setMoleculeBondRadiusScale(name, scale);
     5556    } else {
     5557        g_renderer->setMoleculeBondRadiusScale("all", scale);
     5558    }
     5559    return TCL_OK;
     5560}
     5561
     5562static int
     5563MoleculeBondStyleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5564                    Tcl_Obj *const *objv)
     5565{
     5566    Molecule::BondStyle style;
     5567    const char *styleStr = Tcl_GetString(objv[2]);
     5568    if (styleStr[0] == 'c' && strcmp(styleStr, "cylinder") == 0) {
     5569        style = Molecule::BOND_STYLE_CYLINDER;
     5570    } else if (styleStr[0] == 'l' && strcmp(styleStr, "line") == 0) {
     5571        style = Molecule::BOND_STYLE_LINE;
     5572    } else {
     5573        Tcl_AppendResult(interp, "bad bstyle option \"", styleStr,
     5574                         "\": should be cylinder or line", (char*)NULL);
     5575        return TCL_ERROR;
     5576    }
     5577    if (objc == 4) {
     5578        const char *name = Tcl_GetString(objv[3]);
     5579        g_renderer->setMoleculeBondStyle(name, style);
     5580    } else {
     5581        g_renderer->setMoleculeBondStyle("all", style);
     5582    }
     5583    return TCL_OK;
     5584}
     5585
     5586static int
    34995587MoleculeBondVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc,
    35005588                         Tcl_Obj *const *objv)
     
    35145602
    35155603static int
     5604MoleculeColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5605                Tcl_Obj *const *objv)
     5606{
     5607    float color[3];
     5608    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     5609        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     5610        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     5611        return TCL_ERROR;
     5612    }
     5613    if (objc == 6) {
     5614        const char *name = Tcl_GetString(objv[5]);
     5615        g_renderer->setGraphicsObjectColor<Molecule>(name, color);
     5616    } else {
     5617        g_renderer->setGraphicsObjectColor<Molecule>("all", color);
     5618    }
     5619    return TCL_OK;
     5620}
     5621
     5622static int
    35165623MoleculeColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc,
    35175624                   Tcl_Obj *const *objv)
     
    35235630    } else {
    35245631        g_renderer->setGraphicsObjectColorMap<Molecule>("all", colorMapName);
     5632    }
     5633    return TCL_OK;
     5634}
     5635
     5636static int
     5637MoleculeColorModeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5638                    Tcl_Obj *const *objv)
     5639{
     5640    Molecule::ColorMode mode;
     5641    const char *str = Tcl_GetString(objv[2]);
     5642    if (str[0] == 'b' && strcmp(str, "by_elements") == 0) {
     5643        mode = Molecule::COLOR_BY_ELEMENTS;
     5644    } else if (str[0] == 'c' && strcmp(str, "ccolor") == 0) {
     5645        mode = Molecule::COLOR_CONSTANT;
     5646    } else if (str[0] == 's' && strcmp(str, "scalar") == 0) {
     5647        mode = Molecule::COLOR_BY_SCALAR;
     5648    } else if (str[0] == 'v' && strcmp(str, "vmag") == 0) {
     5649        mode = Molecule::COLOR_BY_VECTOR_MAGNITUDE;
     5650    } else if (str[0] == 'v' && strcmp(str, "vx") == 0) {
     5651        mode = Molecule::COLOR_BY_VECTOR_X;
     5652    } else if (str[0] == 'v' && strcmp(str, "vy") == 0) {
     5653        mode = Molecule::COLOR_BY_VECTOR_Y;
     5654    } else if (str[0] == 'v' && strcmp(str, "vz") == 0) {
     5655        mode = Molecule::COLOR_BY_VECTOR_Z;
     5656    } else {
     5657        Tcl_AppendResult(interp, "bad color mode option \"", str,
     5658                         "\": should be one of: 'by_elements', 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor'", (char*)NULL);
     5659        return TCL_ERROR;
     5660    }
     5661    const char *fieldName = Tcl_GetString(objv[3]);
     5662    if (mode == Molecule::COLOR_CONSTANT) {
     5663        fieldName = NULL;
     5664    }
     5665#if 0
     5666    else if (mode == Molecule::COLOR_BY_ELEMENTS) {
     5667        fieldName = "element";
     5668    }
     5669#endif
     5670    if (objc == 5) {
     5671        const char *name = Tcl_GetString(objv[4]);
     5672        g_renderer->setMoleculeColorMode(name, mode, fieldName);
     5673    } else {
     5674        g_renderer->setMoleculeColorMode("all", mode, fieldName);
    35255675    }
    35265676    return TCL_OK;
     
    37215871static Rappture::CmdSpec moleculeOps[] = {
    37225872    {"add",        2, MoleculeAddOp, 2, 3, "?dataSetName?"},
     5873    {"ascale",     2, MoleculeAtomScaleFactorOp, 3, 4, "value ?dataSetName?"},
    37235874    {"atoms",      2, MoleculeAtomVisibilityOp, 3, 4, "bool ?dataSetName?"},
     5875    {"bcmode",     3, MoleculeBondColorModeOp, 3, 4, "mode ?dataSetName?"},
     5876    {"bcolor",     3, MoleculeBondColorOp, 5, 6, "r g b ?dataSetName?"},
    37245877    {"bonds",      2, MoleculeBondVisibilityOp, 3, 4, "bool ?dataSetName?"},
    3725     {"colormap",   1, MoleculeColorMapOp, 3, 4, "colorMapName ?dataSetName?"},
     5878    {"bscale",     3, MoleculeBondScaleFactorOp, 3, 4, "value ?dataSetName?"},
     5879    {"bstyle",     3, MoleculeBondStyleOp, 3, 4, "value ?dataSetName?"},
     5880    {"ccolor",     2, MoleculeColorOp, 5, 6, "r g b ?dataSetName?"},
     5881    {"colormap",   7, MoleculeColorMapOp, 3, 4, "colorMapName ?dataSetName?"},
     5882    {"colormode",  7, MoleculeColorModeOp, 4, 5, "mode fieldName ?dataSetName?"},
    37265883    {"delete",     1, MoleculeDeleteOp, 2, 3, "?dataSetName?"},
    37275884    {"edges",      1, MoleculeEdgeVisibilityOp, 3, 4, "bool ?dataSetName?"},
     5885    {"labels",     2, MoleculeAtomLabelVisibilityOp, 3, 4, "bool ?dataSetName?"},
    37285886    {"lighting",   3, MoleculeLightingOp, 3, 4, "bool ?dataSetName?"},
    37295887    {"linecolor",  5, MoleculeLineColorOp, 5, 6, "r g b ?dataSetName?"},
     
    38756033
    38766034static int
     6035PolyDataMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc,
     6036                   Tcl_Obj *const *objv)
     6037{
     6038    double ambient, diffuse, specCoeff, specPower;
     6039    if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK ||
     6040        Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK ||
     6041        Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK ||
     6042        Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) {
     6043        return TCL_ERROR;
     6044    }
     6045
     6046    if (objc == 7) {
     6047        const char *name = Tcl_GetString(objv[6]);
     6048        g_renderer->setGraphicsObjectAmbient<PolyData>(name, ambient);
     6049        g_renderer->setGraphicsObjectDiffuse<PolyData>(name, diffuse);
     6050        g_renderer->setGraphicsObjectSpecular<PolyData>(name, specCoeff, specPower);
     6051    } else {
     6052        g_renderer->setGraphicsObjectAmbient<PolyData>("all", ambient);
     6053        g_renderer->setGraphicsObjectDiffuse<PolyData>("all", diffuse);
     6054        g_renderer->setGraphicsObjectSpecular<PolyData>("all", specCoeff, specPower);
     6055    }
     6056    return TCL_OK;
     6057}
     6058
     6059static int
    38776060PolyDataOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc,
    38786061                  Tcl_Obj *const *objv)
     
    40086191    {"linecolor", 5, PolyDataLineColorOp, 5, 6, "r g b ?dataSetName?"},
    40096192    {"linewidth", 5, PolyDataLineWidthOp, 3, 4, "width ?dataSetName?"},
     6193    {"material",  1, PolyDataMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?dataSetName?"},
    40106194    {"opacity",   2, PolyDataOpacityOp, 3, 4, "value ?dataSetName?"},
    40116195    {"orient",    2, PolyDataOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"},
     
    40256209
    40266210    proc = Rappture::GetOpFromObj(interp, nPolyDataOps, polyDataOps,
     6211                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
     6212    if (proc == NULL) {
     6213        return TCL_ERROR;
     6214    }
     6215    return (*proc) (clientData, interp, objc, objv);
     6216}
     6217
     6218static int
     6219PolygonAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
     6220             Tcl_Obj *const *objv)
     6221{
     6222    int numSides;
     6223    if (Tcl_GetIntFromObj(interp, objv[2], &numSides) != TCL_OK) {
     6224        return TCL_ERROR;
     6225    }
     6226    const char *name = Tcl_GetString(objv[3]);
     6227    if (!g_renderer->addPolygon(name, numSides)) {
     6228        Tcl_AppendResult(interp, "Failed to create polygon", (char*)NULL);
     6229        return TCL_ERROR;
     6230    }
     6231    return TCL_OK;
     6232}
     6233
     6234static int
     6235PolygonDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
     6236                Tcl_Obj *const *objv)
     6237{
     6238    if (objc == 3) {
     6239        const char *name = Tcl_GetString(objv[2]);
     6240        g_renderer->deleteGraphicsObject<Polygon>(name);
     6241    } else {
     6242        g_renderer->deleteGraphicsObject<Polygon>("all");
     6243    }
     6244    return TCL_OK;
     6245}
     6246
     6247static int
     6248PolygonColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     6249               Tcl_Obj *const *objv)
     6250{
     6251    float color[3];
     6252    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     6253        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     6254        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     6255        return TCL_ERROR;
     6256    }
     6257    if (objc == 6) {
     6258        const char *name = Tcl_GetString(objv[5]);
     6259        g_renderer->setGraphicsObjectColor<Polygon>(name, color);
     6260    } else {
     6261        g_renderer->setGraphicsObjectColor<Polygon>("all", color);
     6262    }
     6263    return TCL_OK;
     6264}
     6265
     6266static int
     6267PolygonEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     6268                        Tcl_Obj *const *objv)
     6269{
     6270    bool state;
     6271    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     6272        return TCL_ERROR;
     6273    }
     6274    if (objc == 4) {
     6275        const char *name = Tcl_GetString(objv[3]);
     6276        g_renderer->setGraphicsObjectEdgeVisibility<Polygon>(name, state);
     6277    } else {
     6278        g_renderer->setGraphicsObjectEdgeVisibility<Polygon>("all", state);
     6279    }
     6280    return TCL_OK;
     6281}
     6282
     6283static int
     6284PolygonLightingOp(ClientData clientData, Tcl_Interp *interp, int objc,
     6285                  Tcl_Obj *const *objv)
     6286{
     6287    bool state;
     6288    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     6289        return TCL_ERROR;
     6290    }
     6291    if (objc == 4) {
     6292        const char *name = Tcl_GetString(objv[3]);
     6293        g_renderer->setGraphicsObjectLighting<Polygon>(name, state);
     6294    } else {
     6295        g_renderer->setGraphicsObjectLighting<Polygon>("all", state);
     6296    }
     6297    return TCL_OK;
     6298}
     6299
     6300static int
     6301PolygonLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     6302                   Tcl_Obj *const *objv)
     6303{
     6304    float color[3];
     6305    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     6306        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     6307        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     6308        return TCL_ERROR;
     6309    }
     6310    if (objc == 6) {
     6311        const char *name = Tcl_GetString(objv[5]);
     6312        g_renderer->setGraphicsObjectEdgeColor<Polygon>(name, color);
     6313    } else {
     6314        g_renderer->setGraphicsObjectEdgeColor<Polygon>("all", color);
     6315    }
     6316    return TCL_OK;
     6317}
     6318
     6319static int
     6320PolygonLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc,
     6321                   Tcl_Obj *const *objv)
     6322{
     6323    float width;
     6324    if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) {
     6325        return TCL_ERROR;
     6326    }
     6327    if (objc == 4) {
     6328        const char *name = Tcl_GetString(objv[3]);
     6329        g_renderer->setGraphicsObjectEdgeWidth<Polygon>(name, width);
     6330    } else {
     6331        g_renderer->setGraphicsObjectEdgeWidth<Polygon>("all", width);
     6332    }
     6333    return TCL_OK;
     6334}
     6335
     6336static int
     6337PolygonMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc,
     6338                  Tcl_Obj *const *objv)
     6339{
     6340    double ambient, diffuse, specCoeff, specPower;
     6341    if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK ||
     6342        Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK ||
     6343        Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK ||
     6344        Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) {
     6345        return TCL_ERROR;
     6346    }
     6347
     6348    if (objc == 7) {
     6349        const char *name = Tcl_GetString(objv[6]);
     6350        g_renderer->setGraphicsObjectAmbient<Polygon>(name, ambient);
     6351        g_renderer->setGraphicsObjectDiffuse<Polygon>(name, diffuse);
     6352        g_renderer->setGraphicsObjectSpecular<Polygon>(name, specCoeff, specPower);
     6353    } else {
     6354        g_renderer->setGraphicsObjectAmbient<Polygon>("all", ambient);
     6355        g_renderer->setGraphicsObjectDiffuse<Polygon>("all", diffuse);
     6356        g_renderer->setGraphicsObjectSpecular<Polygon>("all", specCoeff, specPower);
     6357    }
     6358    return TCL_OK;
     6359}
     6360
     6361static int
     6362PolygonOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     6363                 Tcl_Obj *const *objv)
     6364{
     6365    double opacity;
     6366    if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) {
     6367        return TCL_ERROR;
     6368    }
     6369    if (objc == 4) {
     6370        const char *name = Tcl_GetString(objv[3]);
     6371        g_renderer->setGraphicsObjectOpacity<Polygon>(name, opacity);
     6372    } else {
     6373        g_renderer->setGraphicsObjectOpacity<Polygon>("all", opacity);
     6374    }
     6375    return TCL_OK;
     6376}
     6377
     6378static int
     6379PolygonOrientOp(ClientData clientData, Tcl_Interp *interp, int objc,
     6380                Tcl_Obj *const *objv)
     6381{
     6382    double quat[4];
     6383    if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK ||
     6384        Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK ||
     6385        Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK ||
     6386        Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) {
     6387        return TCL_ERROR;
     6388    }
     6389    if (objc == 7) {
     6390        const char *name = Tcl_GetString(objv[6]);
     6391        g_renderer->setGraphicsObjectOrientation<Polygon>(name, quat);
     6392    } else {
     6393        g_renderer->setGraphicsObjectOrientation<Polygon>("all", quat);
     6394    }
     6395    return TCL_OK;
     6396}
     6397
     6398static int
     6399PolygonPositionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     6400                  Tcl_Obj *const *objv)
     6401{
     6402    double pos[3];
     6403    if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK ||
     6404        Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK ||
     6405        Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) {
     6406        return TCL_ERROR;
     6407    }
     6408    if (objc == 6) {
     6409        const char *name = Tcl_GetString(objv[5]);
     6410        g_renderer->setGraphicsObjectPosition<Polygon>(name, pos);
     6411    } else {
     6412        g_renderer->setGraphicsObjectPosition<Polygon>("all", pos);
     6413    }
     6414    return TCL_OK;
     6415}
     6416
     6417static int
     6418PolygonScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     6419               Tcl_Obj *const *objv)
     6420{
     6421    double scale[3];
     6422    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK ||
     6423        Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK ||
     6424        Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) {
     6425        return TCL_ERROR;
     6426    }
     6427    if (objc == 6) {
     6428        const char *name = Tcl_GetString(objv[5]);
     6429        g_renderer->setGraphicsObjectScale<Polygon>(name, scale);
     6430    } else {
     6431        g_renderer->setGraphicsObjectScale<Polygon>("all", scale);
     6432    }
     6433    return TCL_OK;
     6434}
     6435
     6436static int
     6437PolygonVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     6438                 Tcl_Obj *const *objv)
     6439{
     6440    bool state;
     6441    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     6442        return TCL_ERROR;
     6443    }
     6444    if (objc == 4) {
     6445        const char *name = Tcl_GetString(objv[3]);
     6446        g_renderer->setGraphicsObjectVisibility<Polygon>(name, state);
     6447    } else {
     6448        g_renderer->setGraphicsObjectVisibility<Polygon>("all", state);
     6449    }
     6450    return TCL_OK;
     6451}
     6452
     6453static int
     6454PolygonWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     6455                   Tcl_Obj *const *objv)
     6456{
     6457    bool state;
     6458    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     6459        return TCL_ERROR;
     6460    }
     6461    if (objc == 4) {
     6462        const char *name = Tcl_GetString(objv[3]);
     6463        g_renderer->setGraphicsObjectWireframe<Polygon>(name, state);
     6464    } else {
     6465        g_renderer->setGraphicsObjectWireframe<Polygon>("all", state);
     6466    }
     6467    return TCL_OK;
     6468}
     6469
     6470static Rappture::CmdSpec polygonOps[] = {
     6471    {"add",       1, PolygonAddOp, 4, 4, "numSides name"},
     6472    {"color",     1, PolygonColorOp, 5, 6, "r g b ?name?"},
     6473    {"delete",    1, PolygonDeleteOp, 2, 3, "?name?"},
     6474    {"edges",     1, PolygonEdgeVisibilityOp, 3, 4, "bool ?name?"},
     6475    {"lighting",  3, PolygonLightingOp, 3, 4, "bool ?name?"},
     6476    {"linecolor", 5, PolygonLineColorOp, 5, 6, "r g b ?name?"},
     6477    {"linewidth", 5, PolygonLineWidthOp, 3, 4, "width ?name?"},
     6478    {"material",  1, PolygonMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"},
     6479    {"opacity",   2, PolygonOpacityOp, 3, 4, "value ?name?"},
     6480    {"orient",    2, PolygonOrientOp, 6, 7, "qw qx qy qz ?name?"},
     6481    {"pos",       2, PolygonPositionOp, 5, 6, "x y z ?name?"},
     6482    {"scale",     1, PolygonScaleOp, 5, 6, "sx sy sz ?name?"},
     6483    {"visible",   1, PolygonVisibleOp, 3, 4, "bool ?name?"},
     6484    {"wireframe", 1, PolygonWireframeOp, 3, 4, "bool ?name?"}
     6485};
     6486static int nPolygonOps = NumCmdSpecs(polygonOps);
     6487
     6488static int
     6489PolygonCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     6490           Tcl_Obj *const *objv)
     6491{
     6492    Tcl_ObjCmdProc *proc;
     6493
     6494    proc = Rappture::GetOpFromObj(interp, nPolygonOps, polygonOps,
    40276495                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
    40286496    if (proc == NULL) {
     
    44736941
    44746942    proc = Rappture::GetOpFromObj(interp, nScreenOps, screenOps,
     6943                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
     6944    if (proc == NULL) {
     6945        return TCL_ERROR;
     6946    }
     6947    return (*proc) (clientData, interp, objc, objv);
     6948}
     6949
     6950static int
     6951SphereAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
     6952            Tcl_Obj *const *objv)
     6953{
     6954    const char *name = Tcl_GetString(objv[2]);
     6955    if (!g_renderer->addGraphicsObject<Sphere>(name)) {
     6956        Tcl_AppendResult(interp, "Failed to create sphere", (char*)NULL);
     6957        return TCL_ERROR;
     6958    }
     6959    return TCL_OK;
     6960}
     6961
     6962static int
     6963SphereDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
     6964               Tcl_Obj *const *objv)
     6965{
     6966    if (objc == 3) {
     6967        const char *name = Tcl_GetString(objv[2]);
     6968        g_renderer->deleteGraphicsObject<Sphere>(name);
     6969    } else {
     6970        g_renderer->deleteGraphicsObject<Sphere>("all");
     6971    }
     6972    return TCL_OK;
     6973}
     6974
     6975static int
     6976SphereColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     6977              Tcl_Obj *const *objv)
     6978{
     6979    float color[3];
     6980    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     6981        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     6982        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     6983        return TCL_ERROR;
     6984    }
     6985    if (objc == 6) {
     6986        const char *name = Tcl_GetString(objv[5]);
     6987        g_renderer->setGraphicsObjectColor<Sphere>(name, color);
     6988    } else {
     6989        g_renderer->setGraphicsObjectColor<Sphere>("all", color);
     6990    }
     6991    return TCL_OK;
     6992}
     6993
     6994static int
     6995SphereEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     6996                       Tcl_Obj *const *objv)
     6997{
     6998    bool state;
     6999    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     7000        return TCL_ERROR;
     7001    }
     7002    if (objc == 4) {
     7003        const char *name = Tcl_GetString(objv[3]);
     7004        g_renderer->setGraphicsObjectEdgeVisibility<Sphere>(name, state);
     7005    } else {
     7006        g_renderer->setGraphicsObjectEdgeVisibility<Sphere>("all", state);
     7007    }
     7008    return TCL_OK;
     7009}
     7010
     7011static int
     7012SphereLightingOp(ClientData clientData, Tcl_Interp *interp, int objc,
     7013                 Tcl_Obj *const *objv)
     7014{
     7015    bool state;
     7016    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     7017        return TCL_ERROR;
     7018    }
     7019    if (objc == 4) {
     7020        const char *name = Tcl_GetString(objv[3]);
     7021        g_renderer->setGraphicsObjectLighting<Sphere>(name, state);
     7022    } else {
     7023        g_renderer->setGraphicsObjectLighting<Sphere>("all", state);
     7024    }
     7025    return TCL_OK;
     7026}
     7027
     7028static int
     7029SphereLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     7030                  Tcl_Obj *const *objv)
     7031{
     7032    float color[3];
     7033    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     7034        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     7035        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     7036        return TCL_ERROR;
     7037    }
     7038    if (objc == 6) {
     7039        const char *name = Tcl_GetString(objv[5]);
     7040        g_renderer->setGraphicsObjectEdgeColor<Sphere>(name, color);
     7041    } else {
     7042        g_renderer->setGraphicsObjectEdgeColor<Sphere>("all", color);
     7043    }
     7044    return TCL_OK;
     7045}
     7046
     7047static int
     7048SphereLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc,
     7049                  Tcl_Obj *const *objv)
     7050{
     7051    float width;
     7052    if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) {
     7053        return TCL_ERROR;
     7054    }
     7055    if (objc == 4) {
     7056        const char *name = Tcl_GetString(objv[3]);
     7057        g_renderer->setGraphicsObjectEdgeWidth<Sphere>(name, width);
     7058    } else {
     7059        g_renderer->setGraphicsObjectEdgeWidth<Sphere>("all", width);
     7060    }
     7061    return TCL_OK;
     7062}
     7063
     7064static int
     7065SphereMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc,
     7066                 Tcl_Obj *const *objv)
     7067{
     7068    double ambient, diffuse, specCoeff, specPower;
     7069    if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK ||
     7070        Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK ||
     7071        Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK ||
     7072        Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) {
     7073        return TCL_ERROR;
     7074    }
     7075
     7076    if (objc == 7) {
     7077        const char *name = Tcl_GetString(objv[6]);
     7078        g_renderer->setGraphicsObjectAmbient<Sphere>(name, ambient);
     7079        g_renderer->setGraphicsObjectDiffuse<Sphere>(name, diffuse);
     7080        g_renderer->setGraphicsObjectSpecular<Sphere>(name, specCoeff, specPower);
     7081    } else {
     7082        g_renderer->setGraphicsObjectAmbient<Sphere>("all", ambient);
     7083        g_renderer->setGraphicsObjectDiffuse<Sphere>("all", diffuse);
     7084        g_renderer->setGraphicsObjectSpecular<Sphere>("all", specCoeff, specPower);
     7085    }
     7086    return TCL_OK;
     7087}
     7088
     7089static int
     7090SphereOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     7091                Tcl_Obj *const *objv)
     7092{
     7093    double opacity;
     7094    if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) {
     7095        return TCL_ERROR;
     7096    }
     7097    if (objc == 4) {
     7098        const char *name = Tcl_GetString(objv[3]);
     7099        g_renderer->setGraphicsObjectOpacity<Sphere>(name, opacity);
     7100    } else {
     7101        g_renderer->setGraphicsObjectOpacity<Sphere>("all", opacity);
     7102    }
     7103    return TCL_OK;
     7104}
     7105
     7106static int
     7107SphereOrientOp(ClientData clientData, Tcl_Interp *interp, int objc,
     7108               Tcl_Obj *const *objv)
     7109{
     7110    double quat[4];
     7111    if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK ||
     7112        Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK ||
     7113        Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK ||
     7114        Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) {
     7115        return TCL_ERROR;
     7116    }
     7117    if (objc == 7) {
     7118        const char *name = Tcl_GetString(objv[6]);
     7119        g_renderer->setGraphicsObjectOrientation<Sphere>(name, quat);
     7120    } else {
     7121        g_renderer->setGraphicsObjectOrientation<Sphere>("all", quat);
     7122    }
     7123    return TCL_OK;
     7124}
     7125
     7126static int
     7127SpherePositionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     7128                 Tcl_Obj *const *objv)
     7129{
     7130    double pos[3];
     7131    if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK ||
     7132        Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK ||
     7133        Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) {
     7134        return TCL_ERROR;
     7135    }
     7136    if (objc == 6) {
     7137        const char *name = Tcl_GetString(objv[5]);
     7138        g_renderer->setGraphicsObjectPosition<Sphere>(name, pos);
     7139    } else {
     7140        g_renderer->setGraphicsObjectPosition<Sphere>("all", pos);
     7141    }
     7142    return TCL_OK;
     7143}
     7144
     7145static int
     7146SphereResolutionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     7147                   Tcl_Obj *const *objv)
     7148{
     7149    int theta, phi;
     7150    if (Tcl_GetIntFromObj(interp, objv[2], &theta) != TCL_OK ||
     7151        Tcl_GetIntFromObj(interp, objv[3], &phi) != TCL_OK) {
     7152        return TCL_ERROR;
     7153    }
     7154    if (objc == 5) {
     7155        const char *name = Tcl_GetString(objv[4]);
     7156        g_renderer->setSphereResolution(name, theta, phi);
     7157    } else {
     7158        g_renderer->setSphereResolution("all", theta, phi);
     7159    }
     7160    return TCL_OK;
     7161}
     7162
     7163static int
     7164SphereScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     7165              Tcl_Obj *const *objv)
     7166{
     7167    double scale[3];
     7168    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK ||
     7169        Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK ||
     7170        Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) {
     7171        return TCL_ERROR;
     7172    }
     7173    if (objc == 6) {
     7174        const char *name = Tcl_GetString(objv[5]);
     7175        g_renderer->setGraphicsObjectScale<Sphere>(name, scale);
     7176    } else {
     7177        g_renderer->setGraphicsObjectScale<Sphere>("all", scale);
     7178    }
     7179    return TCL_OK;
     7180}
     7181
     7182static int
     7183SphereSectionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     7184                Tcl_Obj *const *objv)
     7185{
     7186    double thetaStart, thetaEnd, phiStart, phiEnd;
     7187    if (Tcl_GetDoubleFromObj(interp, objv[2], &thetaStart) != TCL_OK ||
     7188        Tcl_GetDoubleFromObj(interp, objv[3], &thetaEnd) != TCL_OK ||
     7189        Tcl_GetDoubleFromObj(interp, objv[4], &phiStart) != TCL_OK ||
     7190        Tcl_GetDoubleFromObj(interp, objv[5], &phiEnd) != TCL_OK) {
     7191        return TCL_ERROR;
     7192    }
     7193    if (objc == 7) {
     7194        const char *name = Tcl_GetString(objv[6]);
     7195        g_renderer->setSphereSection(name, thetaStart, thetaEnd, phiStart, phiEnd);
     7196    } else {
     7197        g_renderer->setSphereSection("all", thetaStart, thetaEnd, phiStart, phiEnd);
     7198    }
     7199    return TCL_OK;
     7200}
     7201
     7202static int
     7203SphereVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     7204                Tcl_Obj *const *objv)
     7205{
     7206    bool state;
     7207    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     7208        return TCL_ERROR;
     7209    }
     7210    if (objc == 4) {
     7211        const char *name = Tcl_GetString(objv[3]);
     7212        g_renderer->setGraphicsObjectVisibility<Sphere>(name, state);
     7213    } else {
     7214        g_renderer->setGraphicsObjectVisibility<Sphere>("all", state);
     7215    }
     7216    return TCL_OK;
     7217}
     7218
     7219static int
     7220SphereWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     7221                  Tcl_Obj *const *objv)
     7222{
     7223    bool state;
     7224    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     7225        return TCL_ERROR;
     7226    }
     7227    if (objc == 4) {
     7228        const char *name = Tcl_GetString(objv[3]);
     7229        g_renderer->setGraphicsObjectWireframe<Sphere>(name, state);
     7230    } else {
     7231        g_renderer->setGraphicsObjectWireframe<Sphere>("all", state);
     7232    }
     7233    return TCL_OK;
     7234}
     7235
     7236static Rappture::CmdSpec sphereOps[] = {
     7237    {"add",       1, SphereAddOp, 3, 3, "name"},
     7238    {"color",     1, SphereColorOp, 5, 6, "r g b ?name?"},
     7239    {"delete",    1, SphereDeleteOp, 2, 3, "?name?"},
     7240    {"edges",     1, SphereEdgeVisibilityOp, 3, 4, "bool ?name?"},
     7241    {"lighting",  3, SphereLightingOp, 3, 4, "bool ?name?"},
     7242    {"linecolor", 5, SphereLineColorOp, 5, 6, "r g b ?name?"},
     7243    {"linewidth", 5, SphereLineWidthOp, 3, 4, "width ?name?"},
     7244    {"material",  1, SphereMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"},
     7245    {"opacity",   2, SphereOpacityOp, 3, 4, "value ?name?"},
     7246    {"orient",    2, SphereOrientOp, 6, 7, "qw qx qy qz ?name?"},
     7247    {"pos",       2, SpherePositionOp, 5, 6, "x y z ?name?"},
     7248    {"resolution",1, SphereResolutionOp, 4, 5, "thetaRes phiRes ?name?"},
     7249    {"scale",     2, SphereScaleOp, 5, 6, "sx sy sz ?name?"},
     7250    {"section",   2, SphereSectionOp, 6, 7, "thetaStart thetaEnd phiStart phiEnd ?name?"},
     7251    {"visible",   1, SphereVisibleOp, 3, 4, "bool ?name?"},
     7252    {"wireframe", 1, SphereWireframeOp, 3, 4, "bool ?name?"}
     7253};
     7254static int nSphereOps = NumCmdSpecs(sphereOps);
     7255
     7256static int
     7257SphereCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     7258       Tcl_Obj *const *objv)
     7259{
     7260    Tcl_ObjCmdProc *proc;
     7261
     7262    proc = Rappture::GetOpFromObj(interp, nSphereOps, sphereOps,
    44757263                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
    44767264    if (proc == NULL) {
     
    54808268
    54818269    proc = Rappture::GetOpFromObj(interp, nVolumeOps, volumeOps,
     8270                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
     8271    if (proc == NULL) {
     8272        return TCL_ERROR;
     8273    }
     8274    return (*proc) (clientData, interp, objc, objv);
     8275}
     8276
     8277static int
     8278WarpAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8279          Tcl_Obj *const *objv)
     8280{
     8281    if (objc == 3) {
     8282        const char *name = Tcl_GetString(objv[2]);
     8283        if (!g_renderer->addGraphicsObject<Warp>(name)) {
     8284            Tcl_AppendResult(interp, "Failed to create warp", (char*)NULL);
     8285            return TCL_ERROR;
     8286        }
     8287    } else {
     8288        if (!g_renderer->addGraphicsObject<Warp>("all")) {
     8289            Tcl_AppendResult(interp, "Failed to create warp for one or more data sets", (char*)NULL);
     8290            return TCL_ERROR;
     8291        }
     8292    }
     8293    return TCL_OK;
     8294}
     8295
     8296static int
     8297WarpColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8298               Tcl_Obj *const *objv)
     8299{
     8300    const char *colorMapName = Tcl_GetString(objv[2]);
     8301    if (objc == 4) {
     8302        const char *dataSetName = Tcl_GetString(objv[3]);
     8303        g_renderer->setGraphicsObjectColorMap<Warp>(dataSetName, colorMapName);
     8304    } else {
     8305        g_renderer->setGraphicsObjectColorMap<Warp>("all", colorMapName);
     8306    }
     8307    return TCL_OK;
     8308}
     8309
     8310static int
     8311WarpDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8312             Tcl_Obj *const *objv)
     8313{
     8314    if (objc == 3) {
     8315        const char *name = Tcl_GetString(objv[2]);
     8316        g_renderer->deleteGraphicsObject<Warp>(name);
     8317    } else {
     8318        g_renderer->deleteGraphicsObject<Warp>("all");
     8319    }
     8320    return TCL_OK;
     8321}
     8322
     8323static int
     8324WarpEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8325                     Tcl_Obj *const *objv)
     8326{
     8327    bool state;
     8328    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     8329        return TCL_ERROR;
     8330    }
     8331    if (objc == 4) {
     8332        const char *name = Tcl_GetString(objv[3]);
     8333        g_renderer->setGraphicsObjectEdgeVisibility<Warp>(name, state);
     8334    } else {
     8335        g_renderer->setGraphicsObjectEdgeVisibility<Warp>("all", state);
     8336    }
     8337    return TCL_OK;
     8338}
     8339
     8340static int
     8341WarpLightingOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8342               Tcl_Obj *const *objv)
     8343{
     8344    bool state;
     8345    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     8346        return TCL_ERROR;
     8347    }
     8348    if (objc == 4) {
     8349        const char *name = Tcl_GetString(objv[3]);
     8350        g_renderer->setGraphicsObjectLighting<Warp>(name, state);
     8351    } else {
     8352        g_renderer->setGraphicsObjectLighting<Warp>("all", state);
     8353    }
     8354    return TCL_OK;
     8355}
     8356
     8357static int
     8358WarpLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8359                Tcl_Obj *const *objv)
     8360{
     8361    float color[3];
     8362    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     8363        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     8364        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     8365        return TCL_ERROR;
     8366    }
     8367    if (objc == 6) {
     8368        const char *name = Tcl_GetString(objv[5]);
     8369        g_renderer->setGraphicsObjectEdgeColor<Warp>(name, color);
     8370    } else {
     8371        g_renderer->setGraphicsObjectEdgeColor<Warp>("all", color);
     8372    }
     8373    return TCL_OK;
     8374}
     8375
     8376static int
     8377WarpLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8378                Tcl_Obj *const *objv)
     8379{
     8380    float width;
     8381    if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) {
     8382        return TCL_ERROR;
     8383    }
     8384    if (objc == 4) {
     8385        const char *name = Tcl_GetString(objv[3]);
     8386        g_renderer->setGraphicsObjectEdgeWidth<Warp>(name, width);
     8387    } else {
     8388        g_renderer->setGraphicsObjectEdgeWidth<Warp>("all", width);
     8389    }
     8390    return TCL_OK;
     8391}
     8392
     8393static int
     8394WarpOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8395                   Tcl_Obj *const *objv)
     8396{
     8397    double opacity;
     8398    if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) {
     8399        return TCL_ERROR;
     8400    }
     8401    if (objc == 4) {
     8402        const char *name = Tcl_GetString(objv[3]);
     8403        g_renderer->setGraphicsObjectOpacity<Warp>(name, opacity);
     8404    } else {
     8405        g_renderer->setGraphicsObjectOpacity<Warp>("all", opacity);
     8406    }
     8407    return TCL_OK;
     8408}
     8409
     8410static int
     8411WarpOrientOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8412             Tcl_Obj *const *objv)
     8413{
     8414    double quat[4];
     8415    if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK ||
     8416        Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK ||
     8417        Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK ||
     8418        Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) {
     8419        return TCL_ERROR;
     8420    }
     8421    if (objc == 7) {
     8422        const char *name = Tcl_GetString(objv[6]);
     8423        g_renderer->setGraphicsObjectOrientation<Warp>(name, quat);
     8424    } else {
     8425        g_renderer->setGraphicsObjectOrientation<Warp>("all", quat);
     8426    }
     8427    return TCL_OK;
     8428}
     8429
     8430static int
     8431WarpPositionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8432               Tcl_Obj *const *objv)
     8433{
     8434    double pos[3];
     8435    if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK ||
     8436        Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK ||
     8437        Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) {
     8438        return TCL_ERROR;
     8439    }
     8440    if (objc == 6) {
     8441        const char *name = Tcl_GetString(objv[5]);
     8442        g_renderer->setGraphicsObjectPosition<Warp>(name, pos);
     8443    } else {
     8444        g_renderer->setGraphicsObjectPosition<Warp>("all", pos);
     8445    }
     8446    return TCL_OK;
     8447}
     8448
     8449static int
     8450WarpScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8451            Tcl_Obj *const *objv)
     8452{
     8453    double scale[3];
     8454    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK ||
     8455        Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK ||
     8456        Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) {
     8457        return TCL_ERROR;
     8458    }
     8459    if (objc == 6) {
     8460        const char *name = Tcl_GetString(objv[5]);
     8461        g_renderer->setGraphicsObjectScale<Warp>(name, scale);
     8462    } else {
     8463        g_renderer->setGraphicsObjectScale<Warp>("all", scale);
     8464    }
     8465    return TCL_OK;
     8466}
     8467
     8468static int
     8469WarpVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8470              Tcl_Obj *const *objv)
     8471{
     8472    bool state;
     8473    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     8474        return TCL_ERROR;
     8475    }
     8476    if (objc == 4) {
     8477        const char *name = Tcl_GetString(objv[3]);
     8478        g_renderer->setGraphicsObjectVisibility<Warp>(name, state);
     8479    } else {
     8480        g_renderer->setGraphicsObjectVisibility<Warp>("all", state);
     8481    }
     8482    return TCL_OK;
     8483}
     8484
     8485static int
     8486WarpWarpScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8487                Tcl_Obj *const *objv)
     8488{
     8489    double scale;
     8490    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale) != TCL_OK) {
     8491        return TCL_ERROR;
     8492    }
     8493    if (objc == 4) {
     8494        const char *name = Tcl_GetString(objv[3]);
     8495        g_renderer->setWarpWarpScale(name, scale);
     8496    } else {
     8497        g_renderer->setWarpWarpScale("all", scale);
     8498    }
     8499    return TCL_OK;
     8500}
     8501
     8502static int
     8503WarpWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     8504                Tcl_Obj *const *objv)
     8505{
     8506    bool state;
     8507    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     8508        return TCL_ERROR;
     8509    }
     8510    if (objc == 4) {
     8511        const char *name = Tcl_GetString(objv[3]);
     8512        g_renderer->setGraphicsObjectWireframe<Warp>(name, state);
     8513    } else {
     8514        g_renderer->setGraphicsObjectWireframe<Warp>("all", state);
     8515    }
     8516    return TCL_OK;
     8517}
     8518
     8519static Rappture::CmdSpec warpOps[] = {
     8520    {"add",          1, WarpAddOp, 2, 3, "?dataSetName?"},
     8521    {"colormap",     1, WarpColorMapOp, 3, 4, "colorMapName ?dataSetName?"},
     8522    {"delete",       1, WarpDeleteOp, 2, 3, "?dataSetName?"},
     8523    {"edges",        1, WarpEdgeVisibilityOp, 3, 4, "bool ?dataSetName?"},
     8524    {"lighting",     3, WarpLightingOp, 3, 4, "bool ?dataSetName?"},
     8525    {"linecolor",    5, WarpLineColorOp, 5, 6, "r g b ?dataSetName?"},
     8526    {"linewidth",    5, WarpLineWidthOp, 3, 4, "width ?dataSetName?"},
     8527    {"opacity",      2, WarpOpacityOp, 3, 4, "value ?dataSetName?"},
     8528    {"orient",       2, WarpOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"},
     8529    {"pos",          1, WarpPositionOp, 5, 6, "x y z ?dataSetName?"},
     8530    {"scale",        2, WarpScaleOp, 5, 6, "sx sy sz ?dataSetName?"},
     8531    {"visible",      1, WarpVisibleOp, 3, 4, "bool ?dataSetName?"},
     8532    {"warpscale",    2, WarpWarpScaleOp, 3, 4, "value ?dataSetName?"},
     8533    {"wireframe",    2, WarpWireframeOp, 3, 4, "bool ?dataSetName?"}
     8534};
     8535static int nWarpOps = NumCmdSpecs(warpOps);
     8536
     8537static int
     8538WarpCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     8539             Tcl_Obj *const *objv)
     8540{
     8541    Tcl_ObjCmdProc *proc;
     8542
     8543    proc = Rappture::GetOpFromObj(interp, nWarpOps, warpOps,
    54828544                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
    54838545    if (proc == NULL) {
     
    55848646{
    55858647    Tcl_MakeSafe(interp);
     8648    Tcl_CreateObjCommand(interp, "arc",         ArcCmd,         clientData, NULL);
     8649    Tcl_CreateObjCommand(interp, "arrow",       ArrowCmd,       clientData, NULL);
    55868650    Tcl_CreateObjCommand(interp, "axis",        AxisCmd,        clientData, NULL);
     8651    Tcl_CreateObjCommand(interp, "box",         BoxCmd,         clientData, NULL);
    55878652    Tcl_CreateObjCommand(interp, "camera",      CameraCmd,      clientData, NULL);
    55888653    Tcl_CreateObjCommand(interp, "colormap",    ColorMapCmd,    clientData, NULL);
     8654    Tcl_CreateObjCommand(interp, "cone",        ConeCmd,        clientData, NULL);
    55898655    Tcl_CreateObjCommand(interp, "contour2d",   Contour2DCmd,   clientData, NULL);
    55908656    Tcl_CreateObjCommand(interp, "contour3d",   Contour3DCmd,   clientData, NULL);
    55918657    Tcl_CreateObjCommand(interp, "cutplane",    CutplaneCmd,    clientData, NULL);
     8658    Tcl_CreateObjCommand(interp, "cylinder",    CylinderCmd,    clientData, NULL);
    55928659    Tcl_CreateObjCommand(interp, "dataset",     DataSetCmd,     clientData, NULL);
     8660    Tcl_CreateObjCommand(interp, "disk",        DiskCmd,        clientData, NULL);
    55938661    Tcl_CreateObjCommand(interp, "glyphs",      GlyphsCmd,      clientData, NULL);
    55948662    Tcl_CreateObjCommand(interp, "heightmap",   HeightMapCmd,   clientData, NULL);
     
    55968664    Tcl_CreateObjCommand(interp, "legend",      LegendCmd,      clientData, NULL);
    55978665    Tcl_CreateObjCommand(interp, "lic",         LICCmd,         clientData, NULL);
     8666    Tcl_CreateObjCommand(interp, "line",        LineCmd,        clientData, NULL);
    55988667    Tcl_CreateObjCommand(interp, "molecule",    MoleculeCmd,    clientData, NULL);
    55998668    Tcl_CreateObjCommand(interp, "polydata",    PolyDataCmd,    clientData, NULL);
     8669    Tcl_CreateObjCommand(interp, "polygon",     PolygonCmd,     clientData, NULL);
    56008670    Tcl_CreateObjCommand(interp, "pseudocolor", PseudoColorCmd, clientData, NULL);
    56018671    Tcl_CreateObjCommand(interp, "renderer",    RendererCmd,    clientData, NULL);
    56028672    Tcl_CreateObjCommand(interp, "screen",      ScreenCmd,      clientData, NULL);
     8673    Tcl_CreateObjCommand(interp, "sphere",      SphereCmd,      clientData, NULL);
    56038674    Tcl_CreateObjCommand(interp, "streamlines", StreamlinesCmd, clientData, NULL);
    56048675    Tcl_CreateObjCommand(interp, "volume",      VolumeCmd,      clientData, NULL);
     8676    Tcl_CreateObjCommand(interp, "warp",        WarpCmd,        clientData, NULL);
    56058677}
    56068678
     
    56108682void Rappture::VtkVis::exitTcl(Tcl_Interp *interp)
    56118683{
    5612 
     8684    Tcl_DeleteCommand(interp, "arc");
     8685    Tcl_DeleteCommand(interp, "arrow");
    56138686    Tcl_DeleteCommand(interp, "axis");
     8687    Tcl_DeleteCommand(interp, "box");
    56148688    Tcl_DeleteCommand(interp, "camera");
    56158689    Tcl_DeleteCommand(interp, "colormap");
     8690    Tcl_DeleteCommand(interp, "cone");
    56168691    Tcl_DeleteCommand(interp, "contour2d");
    56178692    Tcl_DeleteCommand(interp, "contour3d");
    56188693    Tcl_DeleteCommand(interp, "cutplane");
     8694    Tcl_DeleteCommand(interp, "cylinder");
    56198695    Tcl_DeleteCommand(interp, "dataset");
     8696    Tcl_DeleteCommand(interp, "disk");
    56208697    Tcl_DeleteCommand(interp, "glyphs");
    56218698    Tcl_DeleteCommand(interp, "heightmap");
     
    56238700    Tcl_DeleteCommand(interp, "legend");
    56248701    Tcl_DeleteCommand(interp, "lic");
     8702    Tcl_DeleteCommand(interp, "line");
    56258703    Tcl_DeleteCommand(interp, "molecule");
    56268704    Tcl_DeleteCommand(interp, "polydata");
     8705    Tcl_DeleteCommand(interp, "polygon");
    56278706    Tcl_DeleteCommand(interp, "pseudocolor");
    56288707    Tcl_DeleteCommand(interp, "renderer");
    56298708    Tcl_DeleteCommand(interp, "screen");
     8709    Tcl_DeleteCommand(interp, "sphere");
    56308710    Tcl_DeleteCommand(interp, "streamlines");
    56318711    Tcl_DeleteCommand(interp, "volume");
     8712    Tcl_DeleteCommand(interp, "warp");
    56328713
    56338714    Tcl_DeleteInterp(interp);
  • branches/nanovis2/packages/vizservers/vtkvis/RpVtkRendererGraphicsObjs.cpp

    r2757 r3175  
    1414#include <vtkDataSetReader.h>
    1515
     16#include "RpVtkRendererGraphicsObjs.h"
    1617#include "RpVtkRenderer.h"
    1718#include "RpVtkDataSet.h"
     19#include "RpBox.h"
    1820#include "RpContour2D.h"
    1921#include "RpContour3D.h"
     
    2224#include "RpHeightMap.h"
    2325#include "RpLIC.h"
     26#include "RpLine.h"
    2427#include "RpMolecule.h"
    2528#include "RpPolyData.h"
    2629#include "RpPseudoColor.h"
     30#include "RpSphere.h"
    2731#include "RpStreamlines.h"
    2832#include "RpVolume.h"
     
    3539
    3640template<>
     41Renderer::ArcHashmap &
     42Renderer::getGraphicsObjectHashmap<Arc>()
     43{ return _arcs; }
     44
     45template<>
     46Renderer::ArrowHashmap &
     47Renderer::getGraphicsObjectHashmap<Arrow>()
     48{ return _arrows; }
     49
     50template<>
     51Renderer::BoxHashmap &
     52Renderer::getGraphicsObjectHashmap<Box>()
     53{ return _boxes; }
     54
     55template<>
     56Renderer::ConeHashmap &
     57Renderer::getGraphicsObjectHashmap<Cone>()
     58{ return _cones; }
     59
     60template<>
    3761Renderer::Contour2DHashmap &
    3862Renderer::getGraphicsObjectHashmap<Contour2D>()
     
    5074
    5175template<>
     76Renderer::CylinderHashmap &
     77Renderer::getGraphicsObjectHashmap<Cylinder>()
     78{ return _cylinders; }
     79
     80template<>
     81Renderer::DiskHashmap &
     82Renderer::getGraphicsObjectHashmap<Disk>()
     83{ return _disks; }
     84
     85template<>
    5286Renderer::GlyphsHashmap &
    5387Renderer::getGraphicsObjectHashmap<Glyphs>()
    5488{ return _glyphs; }
     89
     90template<>
     91Renderer::GroupHashmap &
     92Renderer::getGraphicsObjectHashmap<Group>()
     93{ return _groups; }
    5594
    5695template<>
     
    65104
    66105template<>
     106Renderer::LineHashmap &
     107Renderer::getGraphicsObjectHashmap<Line>()
     108{ return _lines; }
     109
     110template<>
    67111Renderer::MoleculeHashmap &
    68112Renderer::getGraphicsObjectHashmap<Molecule>()
     
    75119
    76120template<>
     121Renderer::PolygonHashmap &
     122Renderer::getGraphicsObjectHashmap<Polygon>()
     123{ return _polygons; }
     124
     125template<>
    77126Renderer::PseudoColorHashmap &
    78127Renderer::getGraphicsObjectHashmap<PseudoColor>()
    79128{ return _pseudoColors; }
     129
     130template<>
     131Renderer::SphereHashmap &
     132Renderer::getGraphicsObjectHashmap<Sphere>()
     133{ return _spheres; }
    80134
    81135template<>
     
    89143{ return _volumes; }
    90144
     145template<>
     146Renderer::WarpHashmap &
     147Renderer::getGraphicsObjectHashmap<Warp>()
     148{ return _warps; }
     149
     150template Arc *Renderer::getGraphicsObject(const DataSetId&);
     151template Arrow *Renderer::getGraphicsObject(const DataSetId&);
     152template Box *Renderer::getGraphicsObject(const DataSetId&);
     153template Cone *Renderer::getGraphicsObject(const DataSetId&);
     154template Cylinder *Renderer::getGraphicsObject(const DataSetId&);
     155template Disk *Renderer::getGraphicsObject(const DataSetId&);
     156template Group *Renderer::getGraphicsObject(const DataSetId&);
     157template Line *Renderer::getGraphicsObject(const DataSetId&);
     158template Polygon *Renderer::getGraphicsObject(const DataSetId&);
     159template Sphere *Renderer::getGraphicsObject(const DataSetId&);
     160
     161template <>
     162bool Renderer::addGraphicsObject<Box>(const DataSetId& id)
     163{
     164    Box *gobj;
     165    if ((gobj = getGraphicsObject<Box>(id)) != NULL) {
     166        WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str());
     167        deleteGraphicsObject<Box>(id);
     168    }
     169
     170    gobj = new Box();
     171 
     172    gobj->setDataSet(NULL, this);
     173
     174    if (gobj->getProp() == NULL &&
     175        gobj->getOverlayProp() == NULL) {
     176        delete gobj;
     177        return false;
     178    } else {
     179        if (gobj->getProp())
     180            _renderer->AddViewProp(gobj->getProp());
     181        if (gobj->getOverlayProp())
     182            _renderer->AddViewProp(gobj->getOverlayProp());
     183    }
     184
     185    getGraphicsObjectHashmap<Box>()[id] = gobj;
     186
     187    initCamera();
     188    _needsRedraw = true;
     189    return true;
     190}
     191
     192template <>
     193bool Renderer::addGraphicsObject<Sphere>(const DataSetId& id)
     194{
     195    Sphere *gobj;
     196    if ((gobj = getGraphicsObject<Sphere>(id)) != NULL) {
     197        WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str());
     198        deleteGraphicsObject<Sphere>(id);
     199    }
     200
     201    gobj = new Sphere();
     202 
     203    gobj->setDataSet(NULL, this);
     204
     205    if (gobj->getProp() == NULL &&
     206        gobj->getOverlayProp() == NULL) {
     207        delete gobj;
     208        return false;
     209    } else {
     210        if (gobj->getProp())
     211            _renderer->AddViewProp(gobj->getProp());
     212        if (gobj->getOverlayProp())
     213            _renderer->AddViewProp(gobj->getOverlayProp());
     214    }
     215
     216    getGraphicsObjectHashmap<Sphere>()[id] = gobj;
     217
     218    initCamera();
     219    _needsRedraw = true;
     220    return true;
     221}
     222
    91223/**
    92224 * \brief Set the volume slice used for mapping volumetric data
     
    129261
    130262using namespace Rappture::VtkVis;
     263
     264/**
     265 * \brief Create a new Arc and associate it with an ID
     266 */
     267bool Renderer::addArc(const DataSetId& id, double pt1[3], double pt2[3])
     268{
     269    Arc *gobj;
     270    if ((gobj = getGraphicsObject<Arc>(id)) != NULL) {
     271        WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str());
     272        deleteGraphicsObject<Arc>(id);
     273    }
     274
     275    gobj = new Arc();
     276 
     277    gobj->setDataSet(NULL, this);
     278
     279    if (gobj->getProp() == NULL &&
     280        gobj->getOverlayProp() == NULL) {
     281        delete gobj;
     282        return false;
     283    } else {
     284        if (gobj->getProp())
     285            _renderer->AddViewProp(gobj->getProp());
     286        if (gobj->getOverlayProp())
     287            _renderer->AddViewProp(gobj->getOverlayProp());
     288    }
     289
     290    gobj->setEndPoints(pt1, pt2);
     291
     292    getGraphicsObjectHashmap<Arc>()[id] = gobj;
     293
     294    initCamera();
     295    _needsRedraw = true;
     296    return true;
     297}
     298
     299/**
     300 * \brief Set Arc resolution
     301 */
     302void Renderer::setArcResolution(const DataSetId& id, int res)
     303{
     304    ArcHashmap::iterator itr;
     305
     306    bool doAll = false;
     307
     308    if (id.compare("all") == 0) {
     309        itr = _arcs.begin();
     310        doAll = true;
     311    } else {
     312        itr = _arcs.find(id);
     313    }
     314    if (itr == _arcs.end()) {
     315        ERROR("Arc not found: %s", id.c_str());
     316        return;
     317    }
     318
     319    do {
     320        itr->second->setResolution(res);
     321    } while (doAll && ++itr != _arcs.end());
     322
     323    _needsRedraw = true;
     324}
     325
     326/**
     327 * \brief Create a new Arrow and associate it with an ID
     328 */
     329bool Renderer::addArrow(const DataSetId& id, double tipRadius, double shaftRadius, double tipLength)
     330{
     331    Arrow *gobj;
     332    if ((gobj = getGraphicsObject<Arrow>(id)) != NULL) {
     333        WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str());
     334        deleteGraphicsObject<Arrow>(id);
     335    }
     336
     337    gobj = new Arrow();
     338 
     339    gobj->setDataSet(NULL, this);
     340
     341    if (gobj->getProp() == NULL &&
     342        gobj->getOverlayProp() == NULL) {
     343        delete gobj;
     344        return false;
     345    } else {
     346        if (gobj->getProp())
     347            _renderer->AddViewProp(gobj->getProp());
     348        if (gobj->getOverlayProp())
     349            _renderer->AddViewProp(gobj->getOverlayProp());
     350    }
     351
     352    gobj->setRadii(tipRadius, shaftRadius);
     353    gobj->setTipLength(tipLength);
     354
     355    getGraphicsObjectHashmap<Arrow>()[id] = gobj;
     356
     357    initCamera();
     358    _needsRedraw = true;
     359    return true;
     360}
     361
     362/**
     363 * \brief Set Arrow resolution
     364 */
     365void Renderer::setArrowResolution(const DataSetId& id, int tipRes, int shaftRes)
     366{
     367    ArrowHashmap::iterator itr;
     368
     369    bool doAll = false;
     370
     371    if (id.compare("all") == 0) {
     372        itr = _arrows.begin();
     373        doAll = true;
     374    } else {
     375        itr = _arrows.find(id);
     376    }
     377    if (itr == _arrows.end()) {
     378        ERROR("Arrow not found: %s", id.c_str());
     379        return;
     380    }
     381
     382    do {
     383        itr->second->setResolution(tipRes, shaftRes);
     384    } while (doAll && ++itr != _arrows.end());
     385
     386    _needsRedraw = true;
     387}
     388
     389/**
     390 * \brief Create a new Cone and associate it with an ID
     391 */
     392bool Renderer::addCone(const DataSetId& id, double radius, double height, bool cap)
     393{
     394    Cone *gobj;
     395    if ((gobj = getGraphicsObject<Cone>(id)) != NULL) {
     396        WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str());
     397        deleteGraphicsObject<Cone>(id);
     398    }
     399
     400    gobj = new Cone();
     401 
     402    gobj->setDataSet(NULL, this);
     403
     404    if (gobj->getProp() == NULL &&
     405        gobj->getOverlayProp() == NULL) {
     406        delete gobj;
     407        return false;
     408    } else {
     409        if (gobj->getProp())
     410            _renderer->AddViewProp(gobj->getProp());
     411        if (gobj->getOverlayProp())
     412            _renderer->AddViewProp(gobj->getOverlayProp());
     413    }
     414
     415    gobj->setRadius(radius);
     416    gobj->setHeight(height);
     417    gobj->setCapping(cap);
     418
     419    getGraphicsObjectHashmap<Cone>()[id] = gobj;
     420
     421    initCamera();
     422    _needsRedraw = true;
     423    return true;
     424}
     425
     426/**
     427 * \brief Set Cone resolution
     428 */
     429void Renderer::setConeResolution(const DataSetId& id, int res)
     430{
     431    ConeHashmap::iterator itr;
     432
     433    bool doAll = false;
     434
     435    if (id.compare("all") == 0) {
     436        itr = _cones.begin();
     437        doAll = true;
     438    } else {
     439        itr = _cones.find(id);
     440    }
     441    if (itr == _cones.end()) {
     442        ERROR("Cone not found: %s", id.c_str());
     443        return;
     444    }
     445
     446    do {
     447        itr->second->setResolution(res);
     448    } while (doAll && ++itr != _cones.end());
     449
     450    _needsRedraw = true;
     451}
    131452
    132453/**
     
    278599}
    279600
     601
     602/**
     603 * \brief Set the color mode for the specified DataSet
     604 */
     605void Renderer::setContour2DColorMode(const DataSetId& id,
     606                                     Contour2D::ColorMode mode,
     607                                     DataSet::DataAttributeType type,
     608                                     const char *name, double range[2])
     609{
     610    Contour2DHashmap::iterator itr;
     611
     612    bool doAll = false;
     613
     614    if (id.compare("all") == 0) {
     615        itr = _contour2Ds.begin();
     616        doAll = true;
     617    } else {
     618        itr = _contour2Ds.find(id);
     619    }
     620    if (itr == _contour2Ds.end()) {
     621        ERROR("Contour2D not found: %s", id.c_str());
     622        return;
     623    }
     624
     625    do {
     626        itr->second->setColorMode(mode, type, name, range);
     627    } while (doAll && ++itr != _contour2Ds.end());
     628
     629    _needsRedraw = true;
     630}
     631
     632/**
     633 * \brief Set the color mode for the specified DataSet
     634 */
     635void Renderer::setContour2DColorMode(const DataSetId& id,
     636                                     Contour2D::ColorMode mode,
     637                                     const char *name, double range[2])
     638{
     639    Contour2DHashmap::iterator itr;
     640
     641    bool doAll = false;
     642
     643    if (id.compare("all") == 0) {
     644        itr = _contour2Ds.begin();
     645        doAll = true;
     646    } else {
     647        itr = _contour2Ds.find(id);
     648    }
     649    if (itr == _contour2Ds.end()) {
     650        ERROR("Contour2D not found: %s", id.c_str());
     651        return;
     652    }
     653
     654    do {
     655        itr->second->setColorMode(mode, name, range);
     656    } while (doAll && ++itr != _contour2Ds.end());
     657
     658    _needsRedraw = true;
     659}
     660
    280661/**
    281662 * \brief Create a new Contour3D and associate it with the named DataSet
     
    543924        itr->second->setColorMode(mode, name, range);
    544925    } while (doAll && ++itr != _cutplanes.end());
     926
     927    _needsRedraw = true;
     928}
     929
     930/**
     931 * \brief Create a new Cylinder and associate it with an ID
     932 */
     933bool Renderer::addCylinder(const DataSetId& id, double radius, double height, bool cap)
     934{
     935    Cylinder *gobj;
     936    if ((gobj = getGraphicsObject<Cylinder>(id)) != NULL) {
     937        WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str());
     938        deleteGraphicsObject<Cylinder>(id);
     939    }
     940
     941    gobj = new Cylinder();
     942 
     943    gobj->setDataSet(NULL, this);
     944
     945    if (gobj->getProp() == NULL &&
     946        gobj->getOverlayProp() == NULL) {
     947        delete gobj;
     948        return false;
     949    } else {
     950        if (gobj->getProp())
     951            _renderer->AddViewProp(gobj->getProp());
     952        if (gobj->getOverlayProp())
     953            _renderer->AddViewProp(gobj->getOverlayProp());
     954    }
     955
     956    gobj->setRadius(radius);
     957    gobj->setHeight(height);
     958    gobj->setCapping(cap);
     959
     960    getGraphicsObjectHashmap<Cylinder>()[id] = gobj;
     961
     962    initCamera();
     963    _needsRedraw = true;
     964    return true;
     965}
     966
     967/**
     968 * \brief Set Cylinder resolution
     969 */
     970void Renderer::setCylinderResolution(const DataSetId& id, int res)
     971{
     972    CylinderHashmap::iterator itr;
     973
     974    bool doAll = false;
     975
     976    if (id.compare("all") == 0) {
     977        itr = _cylinders.begin();
     978        doAll = true;
     979    } else {
     980        itr = _cylinders.find(id);
     981    }
     982    if (itr == _cylinders.end()) {
     983        ERROR("Cylinder not found: %s", id.c_str());
     984        return;
     985    }
     986
     987    do {
     988        itr->second->setResolution(res);
     989    } while (doAll && ++itr != _cylinders.end());
     990
     991    _needsRedraw = true;
     992}
     993
     994/**
     995 * \brief Create a new Disk and associate it with an ID
     996 */
     997bool Renderer::addDisk(const DataSetId& id, double innerRadius, double outerRadius)
     998{
     999    Disk *gobj;
     1000    if ((gobj = getGraphicsObject<Disk>(id)) != NULL) {
     1001        WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str());
     1002        deleteGraphicsObject<Disk>(id);
     1003    }
     1004
     1005    gobj = new Disk();
     1006 
     1007    gobj->setDataSet(NULL, this);
     1008
     1009    if (gobj->getProp() == NULL &&
     1010        gobj->getOverlayProp() == NULL) {
     1011        delete gobj;
     1012        return false;
     1013    } else {
     1014        if (gobj->getProp())
     1015            _renderer->AddViewProp(gobj->getProp());
     1016        if (gobj->getOverlayProp())
     1017            _renderer->AddViewProp(gobj->getOverlayProp());
     1018    }
     1019
     1020    gobj->setRadii(innerRadius, outerRadius);
     1021
     1022    getGraphicsObjectHashmap<Disk>()[id] = gobj;
     1023
     1024    initCamera();
     1025    _needsRedraw = true;
     1026    return true;
     1027}
     1028
     1029/**
     1030 * \brief Set Disk resolution
     1031 */
     1032void Renderer::setDiskResolution(const DataSetId& id, int resRadial, int resCircum)
     1033{
     1034    DiskHashmap::iterator itr;
     1035
     1036    bool doAll = false;
     1037
     1038    if (id.compare("all") == 0) {
     1039        itr = _disks.begin();
     1040        doAll = true;
     1041    } else {
     1042        itr = _disks.find(id);
     1043    }
     1044    if (itr == _disks.end()) {
     1045        ERROR("Disk not found: %s", id.c_str());
     1046        return;
     1047    }
     1048
     1049    do {
     1050        itr->second->setResolution(resRadial, resCircum);
     1051    } while (doAll && ++itr != _disks.end());
    5451052
    5461053    _needsRedraw = true;
     
    6981205
    6991206/**
     1207 * \brief Controls if glyphs are oriented from a vector field for the
     1208 * given DataSet
     1209 */
     1210void Renderer::setGlyphsOrientMode(const DataSetId& id, bool state,
     1211                                   const char *name)
     1212{
     1213    GlyphsHashmap::iterator itr;
     1214
     1215    bool doAll = false;
     1216
     1217    if (id.compare("all") == 0) {
     1218        itr = _glyphs.begin();
     1219        doAll = true;
     1220    } else {
     1221        itr = _glyphs.find(id);
     1222    }
     1223    if (itr == _glyphs.end()) {
     1224        ERROR("Glyphs not found: %s", id.c_str());
     1225        return;
     1226    }
     1227
     1228    do {
     1229#ifdef HAVE_GLYPH3D_MAPPER
     1230        itr->second->setOrientMode(state, name);
     1231#else
     1232        if (name != NULL && strlen(name) > 0) {
     1233            WARN("Glyphs orient mode doesn't support named fields for VTK < 5.8.0");
     1234        }
     1235        itr->second->setOrient(state);
     1236#endif
     1237    } while (doAll && ++itr != _glyphs.end());
     1238
     1239    _renderer->ResetCameraClippingRange();
     1240    _needsRedraw = true;
     1241}
     1242
     1243/**
    7001244 * \brief Set the shape of Glyphs for the given DataSet
    7011245 */
     
    8751419     } while (doAll && ++itr != _heightMaps.end());
    8761420
    877     initCamera();
     1421    _renderer->ResetCameraClippingRange();
     1422    resetAxes();
    8781423    _needsRedraw = true;
    8791424}
     
    10451590
    10461591/**
    1047  * \brief Set radius standard for scaling atoms
    1048  */
    1049 void Renderer::setMoleculeAtomScaling(const DataSetId& id, Molecule::AtomScaling scaling)
     1592 * \brief Create a new Line and associate it with an ID
     1593 */
     1594bool Renderer::addLine(const DataSetId& id, double pt1[3], double pt2[3])
     1595{
     1596    Line *gobj;
     1597    if ((gobj = getGraphicsObject<Line>(id)) != NULL) {
     1598        WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str());
     1599        deleteGraphicsObject<Line>(id);
     1600    }
     1601
     1602    gobj = new Line();
     1603 
     1604    gobj->setDataSet(NULL, this);
     1605
     1606    if (gobj->getProp() == NULL &&
     1607        gobj->getOverlayProp() == NULL) {
     1608        delete gobj;
     1609        return false;
     1610    } else {
     1611        if (gobj->getProp())
     1612            _renderer->AddViewProp(gobj->getProp());
     1613        if (gobj->getOverlayProp())
     1614            _renderer->AddViewProp(gobj->getOverlayProp());
     1615    }
     1616
     1617    gobj->setEndPoints(pt1, pt2);
     1618
     1619    getGraphicsObjectHashmap<Line>()[id] = gobj;
     1620
     1621    initCamera();
     1622    _needsRedraw = true;
     1623    return true;
     1624}
     1625
     1626/**
     1627 * \brief Set radius scale factor for atoms
     1628 */
     1629void Renderer::setMoleculeAtomRadiusScale(const DataSetId& id, double scale)
    10501630{
    10511631    MoleculeHashmap::iterator itr;
     
    10651645
    10661646    do {
     1647        itr->second->setAtomRadiusScale(scale);
     1648    } while (doAll && ++itr != _molecules.end());
     1649
     1650    _renderer->ResetCameraClippingRange();
     1651    resetAxes();
     1652    _needsRedraw = true;
     1653}
     1654
     1655/**
     1656 * \brief Set radius standard for scaling atoms
     1657 */
     1658void Renderer::setMoleculeAtomScaling(const DataSetId& id, Molecule::AtomScaling scaling)
     1659{
     1660    MoleculeHashmap::iterator itr;
     1661
     1662    bool doAll = false;
     1663
     1664    if (id.compare("all") == 0) {
     1665        itr = _molecules.begin();
     1666        doAll = true;
     1667    } else {
     1668        itr = _molecules.find(id);
     1669    }
     1670    if (itr == _molecules.end()) {
     1671        ERROR("Molecule not found: %s", id.c_str());
     1672        return;
     1673    }
     1674
     1675    do {
    10671676        itr->second->setAtomScaling(scaling);
    10681677    } while (doAll && ++itr != _molecules.end());
    10691678
     1679    _renderer->ResetCameraClippingRange();
     1680    resetAxes();
    10701681    _needsRedraw = true;
    10711682}
     
    10991710
    11001711/**
    1101  * \brief Turn on/off rendering of the Molecule bonds for the given DataSet
    1102  */
    1103 void Renderer::setMoleculeBondVisibility(const DataSetId& id, bool state)
     1712 * \brief Turn on/off rendering of the Molecule atom labels for the given DataSet
     1713 */
     1714void Renderer::setMoleculeAtomLabelVisibility(const DataSetId& id, bool state)
    11041715{
    11051716    MoleculeHashmap::iterator itr;
     
    11191730
    11201731    do {
     1732        itr->second->setAtomLabelVisibility(state);
     1733    } while (doAll && ++itr != _molecules.end());
     1734
     1735    _needsRedraw = true;
     1736}
     1737
     1738/**
     1739 * \brief Set radius scale factor for atoms
     1740 */
     1741void Renderer::setMoleculeBondRadiusScale(const DataSetId& id, double scale)
     1742{
     1743    MoleculeHashmap::iterator itr;
     1744
     1745    bool doAll = false;
     1746
     1747    if (id.compare("all") == 0) {
     1748        itr = _molecules.begin();
     1749        doAll = true;
     1750    } else {
     1751        itr = _molecules.find(id);
     1752    }
     1753    if (itr == _molecules.end()) {
     1754        ERROR("Molecule not found: %s", id.c_str());
     1755        return;
     1756    }
     1757
     1758    do {
     1759        itr->second->setBondRadiusScale(scale);
     1760    } while (doAll && ++itr != _molecules.end());
     1761
     1762    _renderer->ResetCameraClippingRange();
     1763    resetAxes();
     1764    _needsRedraw = true;
     1765}
     1766
     1767/**
     1768 * \brief Turn on/off rendering of the Molecule bonds for the given DataSet
     1769 */
     1770void Renderer::setMoleculeBondVisibility(const DataSetId& id, bool state)
     1771{
     1772    MoleculeHashmap::iterator itr;
     1773
     1774    bool doAll = false;
     1775
     1776    if (id.compare("all") == 0) {
     1777        itr = _molecules.begin();
     1778        doAll = true;
     1779    } else {
     1780        itr = _molecules.find(id);
     1781    }
     1782    if (itr == _molecules.end()) {
     1783        ERROR("Molecule not found: %s", id.c_str());
     1784        return;
     1785    }
     1786
     1787    do {
    11211788        itr->second->setBondVisibility(state);
    11221789    } while (doAll && ++itr != _molecules.end());
    11231790
    11241791    _needsRedraw = true;
     1792}
     1793
     1794void Renderer::setMoleculeBondStyle(const DataSetId& id, Molecule::BondStyle style)
     1795{
     1796    MoleculeHashmap::iterator itr;
     1797
     1798    bool doAll = false;
     1799
     1800    if (id.compare("all") == 0) {
     1801        itr = _molecules.begin();
     1802        doAll = true;
     1803    } else {
     1804        itr = _molecules.find(id);
     1805    }
     1806    if (itr == _molecules.end()) {
     1807        ERROR("Molecule not found: %s", id.c_str());
     1808        return;
     1809    }
     1810
     1811    do {
     1812        itr->second->setBondStyle(style);
     1813    } while (doAll && ++itr != _molecules.end());
     1814
     1815    _needsRedraw = true;
     1816}
     1817
     1818void Renderer::setMoleculeBondColorMode(const DataSetId& id, Molecule::BondColorMode mode)
     1819{
     1820    MoleculeHashmap::iterator itr;
     1821
     1822    bool doAll = false;
     1823
     1824    if (id.compare("all") == 0) {
     1825        itr = _molecules.begin();
     1826        doAll = true;
     1827    } else {
     1828        itr = _molecules.find(id);
     1829    }
     1830    if (itr == _molecules.end()) {
     1831        ERROR("Molecule not found: %s", id.c_str());
     1832        return;
     1833    }
     1834
     1835    do {
     1836        itr->second->setBondColorMode(mode);
     1837    } while (doAll && ++itr != _molecules.end());
     1838
     1839    _needsRedraw = true;
     1840}
     1841
     1842void Renderer::setMoleculeBondColor(const DataSetId& id, float color[3])
     1843{
     1844    MoleculeHashmap::iterator itr;
     1845
     1846    bool doAll = false;
     1847
     1848    if (id.compare("all") == 0) {
     1849        itr = _molecules.begin();
     1850        doAll = true;
     1851    } else {
     1852        itr = _molecules.find(id);
     1853    }
     1854    if (itr == _molecules.end()) {
     1855        ERROR("Molecule not found: %s", id.c_str());
     1856        return;
     1857    }
     1858
     1859    do {
     1860        itr->second->setBondColor(color);
     1861    } while (doAll && ++itr != _molecules.end());
     1862
     1863    _needsRedraw = true;
     1864}
     1865
     1866
     1867/**
     1868 * \brief Set the color mode for the specified DataSet
     1869 */
     1870void Renderer::setMoleculeColorMode(const DataSetId& id,
     1871                                    Molecule::ColorMode mode,
     1872                                    DataSet::DataAttributeType type,
     1873                                    const char *name, double range[2])
     1874{
     1875    MoleculeHashmap::iterator itr;
     1876
     1877    bool doAll = false;
     1878
     1879    if (id.compare("all") == 0) {
     1880        itr = _molecules.begin();
     1881        doAll = true;
     1882    } else {
     1883        itr = _molecules.find(id);
     1884    }
     1885    if (itr == _molecules.end()) {
     1886        ERROR("Molecule not found: %s", id.c_str());
     1887        return;
     1888    }
     1889
     1890    do {
     1891        itr->second->setColorMode(mode, type, name, range);
     1892    } while (doAll && ++itr != _molecules.end());
     1893
     1894    _needsRedraw = true;
     1895}
     1896
     1897/**
     1898 * \brief Set the color mode for the specified DataSet
     1899 */
     1900void Renderer::setMoleculeColorMode(const DataSetId& id,
     1901                                    Molecule::ColorMode mode,
     1902                                    const char *name, double range[2])
     1903{
     1904    MoleculeHashmap::iterator itr;
     1905
     1906    bool doAll = false;
     1907
     1908    if (id.compare("all") == 0) {
     1909        itr = _molecules.begin();
     1910        doAll = true;
     1911    } else {
     1912        itr = _molecules.find(id);
     1913    }
     1914    if (itr == _molecules.end()) {
     1915        ERROR("Molecule not found: %s", id.c_str());
     1916        return;
     1917    }
     1918
     1919    do {
     1920        itr->second->setColorMode(mode, name, range);
     1921    } while (doAll && ++itr != _molecules.end());
     1922
     1923    _needsRedraw = true;
     1924}
     1925
     1926/**
     1927 * \brief Create a new n-sided regular Polygon and associate it with an ID
     1928 */
     1929bool Renderer::addPolygon(const DataSetId& id, int numSides)
     1930{
     1931    Polygon *gobj;
     1932    if ((gobj = getGraphicsObject<Polygon>(id)) != NULL) {
     1933        WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str());
     1934        deleteGraphicsObject<Polygon>(id);
     1935    }
     1936
     1937    gobj = new Polygon();
     1938 
     1939    gobj->setDataSet(NULL, this);
     1940
     1941    if (gobj->getProp() == NULL &&
     1942        gobj->getOverlayProp() == NULL) {
     1943        delete gobj;
     1944        return false;
     1945    } else {
     1946        if (gobj->getProp())
     1947            _renderer->AddViewProp(gobj->getProp());
     1948        if (gobj->getOverlayProp())
     1949            _renderer->AddViewProp(gobj->getOverlayProp());
     1950    }
     1951
     1952    gobj->setNumberOfSides(numSides);
     1953
     1954    getGraphicsObjectHashmap<Polygon>()[id] = gobj;
     1955
     1956    initCamera();
     1957    _needsRedraw = true;
     1958    return true;
    11251959}
    11261960
     
    11802014        itr->second->setColorMode(mode, name, range);
    11812015    } while (doAll && ++itr != _pseudoColors.end());
     2016
     2017    _needsRedraw = true;
     2018}
     2019
     2020/**
     2021 * \brief Set Sphere resolution
     2022 */
     2023void Renderer::setSphereResolution(const DataSetId& id, int thetaRes, int phiRes)
     2024{
     2025    SphereHashmap::iterator itr;
     2026
     2027    bool doAll = false;
     2028
     2029    if (id.compare("all") == 0) {
     2030        itr = _spheres.begin();
     2031        doAll = true;
     2032    } else {
     2033        itr = _spheres.find(id);
     2034    }
     2035    if (itr == _spheres.end()) {
     2036        ERROR("Sphere not found: %s", id.c_str());
     2037        return;
     2038    }
     2039
     2040    do {
     2041        itr->second->setThetaResolution(thetaRes);
     2042        itr->second->setPhiResolution(phiRes);
     2043    } while (doAll && ++itr != _spheres.end());
     2044
     2045    _needsRedraw = true;
     2046}
     2047
     2048/**
     2049 * \brief Set Sphere section
     2050 */
     2051void Renderer::setSphereSection(const DataSetId& id, double thetaStart, double thetaEnd,
     2052                                double phiStart, double phiEnd)
     2053{
     2054    SphereHashmap::iterator itr;
     2055
     2056    bool doAll = false;
     2057
     2058    if (id.compare("all") == 0) {
     2059        itr = _spheres.begin();
     2060        doAll = true;
     2061    } else {
     2062        itr = _spheres.find(id);
     2063    }
     2064    if (itr == _spheres.end()) {
     2065        ERROR("Sphere not found: %s", id.c_str());
     2066        return;
     2067    }
     2068
     2069    do {
     2070        itr->second->setStartTheta(thetaStart);
     2071        itr->second->setEndTheta(thetaEnd);
     2072        itr->second->setStartPhi(phiStart);
     2073        itr->second->setEndPhi(phiEnd);
     2074    } while (doAll && ++itr != _spheres.end());
    11822075
    11832076    _needsRedraw = true;
     
    17402633    _needsRedraw = true;
    17412634}
     2635
     2636/**
     2637 * \brief Set amount to scale vector magnitudes when warping
     2638 * a mesh
     2639 */
     2640void Renderer::setWarpWarpScale(const DataSetId& id, double scale)
     2641{
     2642    WarpHashmap::iterator itr;
     2643
     2644    bool doAll = false;
     2645
     2646    if (id.compare("all") == 0) {
     2647        itr = _warps.begin();
     2648        doAll = true;
     2649    } else {
     2650        itr = _warps.find(id);
     2651    }
     2652
     2653    if (itr == _warps.end()) {
     2654        ERROR("Warp not found: %s", id.c_str());
     2655        return;
     2656    }
     2657
     2658    do {
     2659        itr->second->setWarpScale(scale);
     2660     } while (doAll && ++itr != _warps.end());
     2661
     2662    _renderer->ResetCameraClippingRange();
     2663    resetAxes();
     2664    _needsRedraw = true;
     2665}
  • branches/nanovis2/packages/vizservers/vtkvis/RpVtkRendererGraphicsObjs.h

    r2612 r3175  
    6060        if (gobj->getProp())
    6161            _renderer->RemoveViewProp(gobj->getProp());
     62        if (gobj->getOverlayProp())
     63            _renderer->RemoveViewProp(gobj->getOverlayProp());
    6264        delete gobj;
    6365
     
    6769    initCamera();
    6870    _needsRedraw = true;
     71}
     72
     73template<class GraphicsObject>
     74void Renderer::deleteAllGraphicsObjects()
     75{
     76    std::tr1::unordered_map<DataSetId, GraphicsObject *>& hashmap =
     77        getGraphicsObjectHashmap<GraphicsObject>();
     78    typename std::tr1::unordered_map<DataSetId, GraphicsObject *>::iterator itr;
     79
     80    itr = hashmap.begin();
     81    if (itr == hashmap.end())
     82        return;
     83
     84    TRACE("Deleting all %s objects", itr->second->getClassName());
     85
     86    for (; itr != hashmap.end(); ++itr) {
     87        delete itr->second;
     88    }
     89    hashmap.clear();
    6990}
    7091
     
    100121        gobj->setDataSet(ds, this);
    101122
    102         if (gobj->getProp() == NULL) {
     123        if (gobj->getProp() == NULL &&
     124            gobj->getOverlayProp() == NULL) {
    103125            delete gobj;
    104126            return false;
    105127        } else {
    106             _renderer->AddViewProp(gobj->getProp());
     128            if (gobj->getProp())
     129                _renderer->AddViewProp(gobj->getProp());
     130            if (gobj->getOverlayProp())
     131                _renderer->AddViewProp(gobj->getOverlayProp());
    107132        }
    108133
     
    233258    do {
    234259        itr->second->setPosition(pos);
     260    } while (doAll && ++itr != hashmap.end());
     261
     262    resetAxes();
     263    _needsRedraw = true;
     264}
     265
     266/**
     267 * \brief Set the prop scaling by 2D aspect ratio
     268 */
     269template<class GraphicsObject>
     270void Renderer::setGraphicsObjectAspect(const DataSetId& id, double aspect)
     271{
     272    std::tr1::unordered_map<DataSetId, GraphicsObject *>& hashmap =
     273        getGraphicsObjectHashmap<GraphicsObject>();
     274    typename std::tr1::unordered_map<DataSetId, GraphicsObject *>::iterator itr;
     275
     276    bool doAll = false;
     277
     278    if (id.compare("all") == 0) {
     279        itr = hashmap.begin();
     280        doAll = true;
     281    } else {
     282        itr = hashmap.find(id);
     283    }
     284    if (itr == hashmap.end()) {
     285        ERROR("%s not found: %s", typeid(GraphicsObject).name(), id.c_str());
     286        return;
     287    }
     288
     289    do {
     290        itr->second->setAspect(aspect);
    235291    } while (doAll && ++itr != hashmap.end());
    236292
     
    709765}
    710766
     767template<class GraphicsObject>
     768void Renderer::updateGraphicsObjectColorMap(ColorMap *cmap)
     769{
     770    std::tr1::unordered_map<DataSetId, GraphicsObject *>& hashmap =
     771        getGraphicsObjectHashmap<GraphicsObject>();
     772    typename std::tr1::unordered_map<DataSetId, GraphicsObject *>::iterator itr;
     773
     774    for (itr = hashmap.begin(); itr != hashmap.end(); ++itr) {
     775        if (itr->second->getColorMap() == cmap) {
     776            itr->second->updateColorMap();
     777            _needsRedraw = true;
     778        }
     779    }
     780}
     781
     782template<class GraphicsObject>
     783bool Renderer::graphicsObjectColorMapUsed(ColorMap *cmap)
     784{
     785    std::tr1::unordered_map<DataSetId, GraphicsObject *>& hashmap =
     786        getGraphicsObjectHashmap<GraphicsObject>();
     787    typename std::tr1::unordered_map<DataSetId, GraphicsObject *>::iterator itr;
     788
     789    for (itr = hashmap.begin(); itr != hashmap.end(); ++itr) {
     790        if (itr->second->getColorMap() == cmap)
     791            return true;
     792    }
     793    return false;
     794}
     795
     796template<class GraphicsObject>
     797void Renderer::mergeGraphicsObjectBounds(double *bounds, bool onlyVisible)
     798{
     799    std::tr1::unordered_map<DataSetId, GraphicsObject *>& hashmap =
     800        getGraphicsObjectHashmap<GraphicsObject>();
     801    typename std::tr1::unordered_map<DataSetId, GraphicsObject *>::iterator itr;
     802
     803    for (itr = hashmap.begin(); itr != hashmap.end(); ++itr) {
     804        if ((!onlyVisible || itr->second->getVisibility()) &&
     805            itr->second->getProp() != NULL)
     806            mergeBounds(bounds, bounds, itr->second->getBounds());
     807    }
     808}
     809
     810template<class GraphicsObject>
     811void Renderer::mergeGraphicsObjectUnscaledBounds(double *bounds, bool onlyVisible)
     812{
     813    std::tr1::unordered_map<DataSetId, GraphicsObject *>& hashmap =
     814        getGraphicsObjectHashmap<GraphicsObject>();
     815    typename std::tr1::unordered_map<DataSetId, GraphicsObject *>::iterator itr;
     816
     817    for (itr = hashmap.begin(); itr != hashmap.end(); ++itr) {
     818        if ((!onlyVisible || itr->second->getVisibility()) &&
     819            itr->second->getProp() != NULL)
     820            mergeBounds(bounds, bounds, itr->second->getUnscaledBounds());
     821    }
     822}
     823
     824template<class GraphicsObject>
     825void Renderer::updateGraphicsObjectFieldRanges()
     826{
     827    std::tr1::unordered_map<DataSetId, GraphicsObject *>& hashmap =
     828        getGraphicsObjectHashmap<GraphicsObject>();
     829    typename std::tr1::unordered_map<DataSetId, GraphicsObject *>::iterator itr;
     830
     831    for (itr = hashmap.begin(); itr != hashmap.end(); ++itr) {
     832        itr->second->updateRanges(this);
     833    }
     834}
     835
     836template<class GraphicsObject>
     837void Renderer::setGraphicsObjectClippingPlanes(vtkPlaneCollection *planes)
     838{
     839    std::tr1::unordered_map<DataSetId, GraphicsObject *>& hashmap =
     840        getGraphicsObjectHashmap<GraphicsObject>();
     841    typename std::tr1::unordered_map<DataSetId, GraphicsObject *>::iterator itr;
     842
     843    for (itr = hashmap.begin(); itr != hashmap.end(); ++itr) {
     844        itr->second->setClippingPlanes(planes);
     845    }
     846}
     847
     848template<class GraphicsObject>
     849void Renderer::setGraphicsObjectAspect(double aspectRatio)
     850{
     851    std::tr1::unordered_map<DataSetId, GraphicsObject *>& hashmap =
     852        getGraphicsObjectHashmap<GraphicsObject>();
     853    typename std::tr1::unordered_map<DataSetId, GraphicsObject *>::iterator itr;
     854
     855    for (itr = hashmap.begin(); itr != hashmap.end(); ++itr) {
     856        itr->second->setAspect(aspectRatio);
     857    }
     858}
     859
    711860}
    712861}
  • branches/nanovis2/packages/vizservers/vtkvis/protocol.txt

    r2892 r3175  
    129129dataset visible <bool> <?datasetName?>
    130130
     131arc add <pt1X> <pt1Y> <pt1Z> <pt2X> <pt2Y> <pt2Z> <name>
     132arc color <r> <g> <b> <?name?>
     133arc delete <?name?>
     134arc linecolor <r> <g> <b> <?name?>
     135arc linewidth <val> <?name?>
     136arc opacity <val> <?name?>
     137arc orient <qw> <qx> <qy> <qz> <?name?>
     138arc pos <x> <y> <z> <?name?>
     139arc resolution <res> <?name?>
     140arc scale <sx> <sy> <sz> <?name?>
     141arc visible <bool> <?name?>
     142
     143arrow add <tipRadius> <shaftRadius> <tipLength> <name>
     144      Arrow will have base at 0,0,0 and tip at 1, 0, 0
     145arrow color <r> <g> <b> <?name?>
     146arrow delete <?name?>
     147arrow edges <bool> <?name?>
     148arrow lighting <bool> <?name?>
     149arrow linecolor <r> <g> <b> <?name?>
     150arrow linewidth <val> <?name?>
     151arrow material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp> <?name?>
     152arrow opacity <val> <?name?>
     153arrow orient <qw> <qx> <qy> <qz> <?name?>
     154arrow pos <x> <y> <z> <?name?>
     155arrow resolution <tipRes> <shaftRes> <?name?>
     156arrow scale <sx> <sy> <sz> <?name?>
     157arrow visible <bool> <?name?>
     158arrow wireframe <bool> <?name?>
     159
     160box add <name>
     161box color <r> <g> <b> <?name?>
     162box delete <?name?>
     163box edges <bool> <?name?>
     164box lighting <bool> <?name?>
     165box linecolor <r> <g> <b> <?name?>
     166box linewidth <val> <?name?>
     167box material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp> <?name?>
     168box opacity <val> <?name?>
     169box orient <qw> <qx> <qy> <qz> <?name?>
     170box pos <x> <y> <z> <?name?>
     171box scale <sx> <sy> <sz> <?name?>
     172box visible <bool> <?name?>
     173box wireframe <bool> <?name?>
     174
     175cone add <radius> <height> <cap> <name>
     176     <cap> = boolean flag for cap disks
     177cone color <r> <g> <b> <?name?>
     178cone delete <?name?>
     179cone edges <bool> <?name?>
     180cone lighting <bool> <?name?>
     181cone linecolor <r> <g> <b> <?name?>
     182cone linewidth <val> <?name?>
     183cone material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp> <?name?>
     184cone opacity <val> <?name?>
     185cone orient <qw> <qx> <qy> <qz> <?name?>
     186cone pos <x> <y> <z> <?name?>
     187cone resolution <res> <?name?>
     188cone scale <sx> <sy> <sz> <?name?>
     189cone visible <bool> <?name?>
     190cone wireframe <bool> <?name?>
     191
    131192contour2d add numcontours <n> <?datasetName?>
    132193          Generate evenly spaced contours including range endpoints.  See also
     
    134195contour2d add contourlist <list> <?datasetName?>
    135196          list = {isoval1 isoval2 isoval3...}
    136 contour2d color <r> <g> <b> <?datasetName?>
     197contour2d ccolor <r> <g> <b> <?datasetName?>
    137198          synonym for linecolor
     199contour2d colormap <colormapName> <?datasetName?>
     200contour2d colormode <scalar|vmag|vx|vy|vz|ccolor> <fieldName> <?datasetName?>
     201          Set the field used to color the object.  'ccolor' means to use
     202          the constant color defined by the ccolor subcommand.  'scalar' uses
     203          the active scalar field.  'vmag' uses the magnitude of the current
     204          vector field, and 'vx','vy','vz' use the corresponding component of
     205          the active vector field.
    138206contour2d delete <?datasetName?>
    139207contour2d lighting <bool> <?datasetName?>
     
    194262cutplane wireframe <bool> <?datasetName?>
    195263
     264cylinder add <radius> <height> <cap> <name>
     265         <cap> = boolean flag for cap disks
     266cylinder color <r> <g> <b> <?name?>
     267cylinder delete <?name?>
     268cylinder edges <bool> <?name?>
     269cylinder lighting <bool> <?name?>
     270cylinder linecolor <r> <g> <b> <?name?>
     271cylinder linewidth <val> <?name?>
     272cylinder material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp> <?name?>
     273cylinder opacity <val> <?name?>
     274cylinder orient <qw> <qx> <qy> <qz> <?name?>
     275cylinder pos <x> <y> <z> <?name?>
     276cylinder resolution <res> <?name?>
     277cylinder scale <sx> <sy> <sz> <?name?>
     278cylinder visible <bool> <?name?>
     279cylinder wireframe <bool> <?name?>
     280
     281disk add <innerRadius> <outerRadius> <name>
     282disk color <r> <g> <b> <?name?>
     283disk delete <?name?>
     284disk edges <bool> <?name?>
     285disk lighting <bool> <?name?>
     286disk linecolor <r> <g> <b> <?name?>
     287disk linewidth <val> <?name?>
     288disk material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp> <?name?>
     289disk opacity <val> <?name?>
     290disk orient <qw> <qx> <qy> <qz> <?name?>
     291disk pos <x> <y> <z> <?name?>
     292disk resolution <resRadial> <resCircum> <?name?>
     293disk scale <sx> <sy> <sz> <?name?>
     294disk visible <bool> <?name?>
     295disk wireframe <bool> <?name?>
     296
    196297glyphs add <shape> <?dataSetName?>
    197298       See 'glyphs shape' for list of shapes
     
    204305glyphs delete <?dataSetName?>
    205306glyphs edges <bool> <?datasetName?>
     307glyphs gorient <bool> <fieldName> <?datasetName?>
     308       Set the glyph orientation mode: orient glyphs by
     309       a named vector field, or set to default orientation (off)
    206310glyphs gscale <scaleFactor> <?datasetName?>
    207311       Set glyph scaling factor
     
    268372lic visible <bool> <?datasetName?>
    269373
     374line add <pt1X> <pt1Y> <pt1Z> <pt2X> <pt2Y> <pt2Z> <name>
     375line color <r> <g> <b> <?name?>
     376line delete <?name?>
     377line linecolor <r> <g> <b> <?name?>
     378line linewidth <val> <?name?>
     379line opacity <val> <?name?>
     380line orient <qw> <qx> <qy> <qz> <?name?>
     381line pos <x> <y> <z> <?name?>
     382line scale <sx> <sy> <sz> <?name?>
     383line visible <bool> <?name?>
     384
    270385molecule add <?datasetName?>
    271386molecule atoms <bool> <?datasetName?>
    272387         Toggle rendering of atoms
     388molecule ascale <val> <?datasetName?>
     389         Set atom scale factor
     390molecule bcmode <by_elements|constant> <?datasetName?>
     391         Set bond color mode
     392molecule bcolor <r> <g> <b> <?datasetName?>
     393         Set constant bond color
    273394molecule bonds <bool> <?datasetName?>
    274395         Toggle rendering of bonds
     396molecule bscale <val> <?datasetName?>
     397         Set bond scale factor
     398molecule bstyle <cylinder|line> <?datasetName?>
     399         Set bond render style
     400molecule ccolor r g b <?datasetName?>
    275401molecule colormap <colormapName> <?datasetName?>
     402molecule colormode <by_elements|scalar|vmag|vx|vy|vz|ccolor> <fieldName> <?datasetName?>
     403         Set the field used to color the object.  'ccolor' means to use
     404         the constant color defined by the ccolor subcommand.  'scalar' uses
     405         the active scalar field.  'vmag' uses the magnitude of the current
     406         vector field, and 'vx','vy','vz' use the corresponding component of
     407         the active vector field.
    276408molecule delete <?datasetName?>
    277409molecule edges <bool> <?datasetName?>
     410molecule labels <bool> <?datasetName?>
    278411molecule lighting <bool> <?datasetName?>
    279412molecule linecolor <r> <g> <b> <?datasetName?>
     
    284417molecule rscale <val> <?dataSetName?>
    285418         Atom radius scaling
    286          val = van_der_walls|covalent|atomic|none
     419         val = van_der_waals|covalent|atomic|none
    287420molecule scale <sx> <sy> <sz> <?dataSetName?>
    288421molecule visible <bool> <?datasetName?>
     
    296429polydata linecolor <r> <g> <b> <?datasetName?>
    297430polydata linewidth <val> <?datasetName?>
     431polydata material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp>
    298432polydata opacity <val> <?datasetName?>
    299433polydata orient <qw> <qx> <qy> <qz> <?dataSetName?>
     
    304438polydata wireframe <bool> <?datasetName?>
    305439
     440polygon add <numSides> <name>
     441polygon color <r> <g> <b> <?name?>
     442polygon delete <?name?>
     443polygon edges <bool> <?name?>
     444polygon lighting <bool> <?name?>
     445polygon linecolor <r> <g> <b> <?name?>
     446polygon linewidth <val> <?name?>
     447polygon material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp> <?name?>
     448polygon opacity <val> <?name?>
     449polygon orient <qw> <qx> <qy> <qz> <?name?>
     450polygon pos <x> <y> <z> <?name?>
     451polygon scale <sx> <sy> <sz> <?name?>
     452polygon visible <bool> <?name?>
     453polygon wireframe <bool> <?name?>
     454
    306455pseudocolor add <?datasetName?>
    307 pseudocolor ccolor r g b <?datasetName?>
     456pseudocolor ccolor <r> <g> <b> <?datasetName?>
    308457pseudocolor colormap <colormapName> <?datasetName?>
    309458pseudocolor colormode <scalar|vmag|vx|vy|vz|ccolor> <fieldName> <?datasetName?>
     
    324473pseudocolor visible <bool> <?datasetName?>
    325474pseudocolor wireframe <bool> <?datasetName?>
     475
     476sphere add <name>
     477sphere color <r> <g> <b> <?name?>
     478sphere delete <?name?>
     479sphere edges <bool> <?name?>
     480sphere lighting <bool> <?name?>
     481sphere linecolor <r> <g> <b> <?name?>
     482sphere linewidth <val> <?name?>
     483sphere material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp> <?name?>
     484sphere opacity <val> <?name?>
     485sphere orient <qw> <qx> <qy> <qz> <?name?>
     486sphere pos <x> <y> <z> <?name?>
     487sphere resolution <thetaRes> <phiRes> <?name?>
     488sphere scale <sx> <sy> <sz> <?name?>
     489sphere section <thetaStart> <thetaEnd> <phiStart> <phiEnd> <?name?>
     490       Angles are in degrees
     491sphere visible <bool> <?name?>
     492sphere wireframe <bool> <?name?>
    326493
    327494streamlines add <?datasetName?>
     
    396563volume visible <bool> <?datasetName?>
    397564
     565warp add <?dataSetName?>
     566warp colormap <colorMapName> <?dataSetName?>
     567warp delete <?dataSetName?>
     568warp edges <bool> <?dataSetName?>
     569warp lighting <bool> <?dataSetName?>
     570warp linecolor <r> <g> <b> <?dataSetName?>
     571warp linewidth <width> <?dataSetName?>
     572warp opacity <value> <?dataSetName?>
     573warp orient <qw> <qx> <qy> <qz> <?dataSetName?>
     574warp pos <x> <y> <z> <?dataSetName?>
     575warp scale <sx> <sy> <sz> <?dataSetName?>
     576warp visible <bool> <?dataSetName?>
     577warp warpscale <value> <?dataSetName?>
     578     Specify amount to scale vector magnitudes when warping
     579warp wireframe <bool> <?datasetName?>
     580
    398581================================================================================
    399582Replies:
  • branches/nanovis2/packages/vizservers/vtkvis/vtkRpAxisActor.cpp

    r2864 r3175  
    22
    33  Program:   Visualization Toolkit
    4   Module:    vtkRpAxisActor.cxx
     4  Module:    vtkRpAxisActor.cpp
    55  Thanks:    Kathleen Bonnell, B Division, Lawrence Livermore Nat'l Laboratory
    66
  • branches/nanovis2/packages/vizservers/vtkvis/vtkRpAxisActor2D.cpp

    r2864 r3175  
    22
    33  Program:   Visualization Toolkit
    4   Module:    vtkRpAxisActor2D.cxx
     4  Module:    vtkRpAxisActor2D.cpp
    55
    66  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  • branches/nanovis2/src/core/RpLibrary.cc

    r2408 r3175  
    6363        parser = scew_parser_create();
    6464
    65         scew_parser_ignore_whitespaces(parser, 1);
     65        // Don't ignore whitespaces!
     66        // Things like string inputs may have trailing newlines that
     67        // matter to the underlying application.
     68        scew_parser_ignore_whitespaces(parser, 0);
    6669
    6770        /* Loads an XML file */
  • branches/nanovis2/tester/scripts/statuslist.tcl

    r2139 r3175  
    289289    set c $itk_component(listview)
    290290
     291    # translate the screen y to the canvas y (may be scrolled down)
     292    set y [$c canvasy $y]
     293
    291294    set index ""
    292295    foreach id [$c find overlapping 10 $y 10 $y] {
  • branches/nanovis2/tester/scripts/stringdiffs.tcl

    r2139 r3175  
    3232
    3333    protected method _yview {args}
     34    protected method _ysbar {args}
    3435}
    3536
     
    128129    $itk_component(body1) configure \
    129130        -xscrollcommand [list $itk_component(xsbar1) set] \
    130         -yscrollcommand [list $itk_component(ysbar) set]
     131        -yscrollcommand [itcl::code $this _ysbar body1]
    131132    $itk_component(body2) configure \
    132         -xscrollcommand [list $itk_component(xsbar2) set]
     133        -xscrollcommand [list $itk_component(xsbar2) set] \
     134        -yscrollcommand [itcl::code $this _ysbar body2]
    133135
    134136    grid $itk_component(title1) -row 0 -column 0 -sticky nsew
     
    205207# USAGE: _yview <arg> <arg>...
    206208#
    207 # Loads two values into the viewer and shows their differences.
    208 # If the strings are short, the diffs are shown inline.  Otherwise,
    209 # they are show with side-by-side viewers.
     209# Called whenever the scrollbar changes the y-view of the diffs.
     210# Sends the new command along to both views so they are aligned.
    210211# ----------------------------------------------------------------------
    211212itcl::body Rappture::Tester::StringDiffs::_yview {args} {
    212213    eval $itk_component(body1) yview $args
    213214    eval $itk_component(body2) yview $args
     215}
     216
     217# ----------------------------------------------------------------------
     218# USAGE: _ysbar <whichChanged> <arg> <arg>...
     219#
     220# Called whenever the y-view of one widget changes.  Copies the
     221# current view from the <whichChanged> widget to the other side,
     222# and updates the bubble to display the correct view.
     223# ----------------------------------------------------------------------
     224itcl::body Rappture::Tester::StringDiffs::_ysbar {which args} {
     225    switch -- $which {
     226        body1 {
     227            set pos [lindex [$itk_component(body1) yview] 0]
     228            $itk_component(body2) yview moveto $pos
     229        }
     230        body2 {
     231            set pos [lindex [$itk_component(body2) yview] 0]
     232            $itk_component(body1) yview moveto $pos
     233        }
     234    }
     235    eval $itk_component(ysbar) set $args
    214236}
    215237
Note: See TracChangeset for help on using the changeset viewer.