Changeset 3330


Ignore:
Timestamp:
Feb 24, 2013 1:11:18 PM (9 years ago)
Author:
gah
Message:

merge (by hand) with Rappture1.2 branch

Location:
trunk
Files:
14 added
5 deleted
168 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure

    r3282 r3330  
    645645SIZEOF_INT
    646646SHLIB_LDFLAGS
     647RUBY_VERSION_RV
     648RUBY_PLATFORM
    647649RP_BASE
    648650PYTHON_VERSION
     
    678680JAVA_HOME
    679681INSTALL_PREFIX
     682HAVE_RUBY_DEVEL
    680683HAVE_INTTYPES_H
    681684HAVE_FFMPEG_LIBS
     
    683686LDFLAGS_DEFAULT
    684687CFLAGS_DEFAULT
    685 host_os
    686 host_vendor
    687 host_cpu
    688 host
    689 build_os
    690 build_vendor
    691 build_cpu
    692 build
    693 HAVE_RUBY_H
    694 RUBY_SITELIBDIR
    695 RUBY_LIBRUBYARG_STATIC
    696 RUBY_LIBRUBYARG
    697 RUBY_LIBS
     688RUBY_EXTRA_LIBS
     689RUBY_SITE_PKG
    698690RUBY_LDFLAGS
    699 RUBY_CXXFLAGS
    700 RUBY_CFLAGS
    701691RUBY_CPPFLAGS
    702 RUBY_VERSION_CODE
     692AWK
     693RUBY_VERSION
     694SED
    703695RUBY
    704696R
     
    824816with_R
    825817with_ruby
    826 with_ruby_sitelibdir
    827818enable_shared
    828819enable_symbols
     
    14391430
    14401431  cat <<\_ACEOF
    1441 
    1442 System types:
    1443   --build=BUILD     configure for building on BUILD [guessed]
    1444   --host=HOST       cross-compile to build programs to run on HOST [BUILD]
    14451432_ACEOF
    14461433fi
     
    14811468  --with-java=DIR         location of java [default=yes]
    14821469  --with-R=DIR            location of R interpreter [default=yes]
    1483   --with-ruby=PATH        path to the ruby interpreter [[ruby]]
    1484   --with-ruby-sitelibdir=PATH
    1485                           path to install ruby scripts [[auto-detect]]
     1470  --with-ruby=DIR         location of ruby [default=yes]
    14861471
    14871472Some influential environment variables:
     
    74667451    for path in \
    74677452     $libdir \
     7453     $prefix/lib/tcltk \
    74687454     $prefix/lib \
    74697455     $exec_prefix/lib \
     
    86308616   ${JAVA_HOME} \
    86318617   /apps/java/jdk1.6* \
     8618   /usr/lib/jvm/java-6-openjdk \
     8619   /usr/lib/jvm/icedtea-6 \
     8620   /usr/lib/jvm/*sun-1.6* \
    86328621   /opt/sun-jdk-1.6* \
     8622   /usr/lib/jvm/icedtea-7 \
    86338623   /opt/icedtea6-* \
    86348624   /opt/sun-jdk-1.5* \
    8635    /usr/lib/jvm/*sun* \
    8636    /usr/lib/jvm/*icedtea* \
    8637    /usr/lib/jvm/*openjdk*
     8625   /usr/lib/jvm/*sun-1.5*
    86388626  do
    86398627    if test -r "${d}/include/jni.h" ; then
     
    87538741
    87548742
    8755 # Make sure we can run config.sub.
    8756 $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
    8757   as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
    8758 
    8759 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
    8760 $as_echo_n "checking build system type... " >&6; }
    8761 if ${ac_cv_build+:} false; then :
    8762   $as_echo_n "(cached) " >&6
    8763 else
    8764   ac_build_alias=$build_alias
    8765 test "x$ac_build_alias" = x &&
    8766   ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
    8767 test "x$ac_build_alias" = x &&
    8768   as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
    8769 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
    8770   as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
    8771 
    8772 fi
    8773 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
    8774 $as_echo "$ac_cv_build" >&6; }
    8775 case $ac_cv_build in
    8776 *-*-*) ;;
    8777 *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
    8778 esac
    8779 build=$ac_cv_build
    8780 ac_save_IFS=$IFS; IFS='-'
    8781 set x $ac_cv_build
    8782 shift
    8783 build_cpu=$1
    8784 build_vendor=$2
    8785 shift; shift
    8786 # Remember, the first character of IFS is used to create $*,
    8787 # except with old shells:
    8788 build_os=$*
    8789 IFS=$ac_save_IFS
    8790 case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
    8791 
    8792 
    8793 { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
    8794 $as_echo_n "checking host system type... " >&6; }
    8795 if ${ac_cv_host+:} false; then :
    8796   $as_echo_n "(cached) " >&6
    8797 else
    8798   if test "x$host_alias" = x; then
    8799   ac_cv_host=$ac_cv_build
    8800 else
    8801   ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
    8802     as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
    8803 fi
    8804 
    8805 fi
    8806 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
    8807 $as_echo "$ac_cv_host" >&6; }
    8808 case $ac_cv_host in
    8809 *-*-*) ;;
    8810 *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
    8811 esac
    8812 host=$ac_cv_host
    8813 ac_save_IFS=$IFS; IFS='-'
    8814 set x $ac_cv_host
    8815 shift
    8816 host_cpu=$1
    8817 host_vendor=$2
    8818 shift; shift
    8819 # Remember, the first character of IFS is used to create $*,
    8820 # except with old shells:
    8821 host_os=$*
    8822 IFS=$ac_save_IFS
    8823 case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
    8824 
    8825 
    8826 
     8743
     8744RUBY=""
     8745RUBY_DEV_PKG="no"
    88278746
    88288747
    88298748# Check whether --with-ruby was given.
    88308749if test "${with_ruby+set}" = set; then :
    8831   withval=$with_ruby;  RUBY=$withval
    8832 else
    8833    RUBY=ruby
    8834 fi
    8835 
    8836 
    8837 # Check whether --with-ruby_sitelibdir was given.
    8838 if test "${with_ruby_sitelibdir+set}" = set; then :
    8839   withval=$with_ruby_sitelibdir;  ruby_sitelibdir=$withval
    8840 else
    8841    ruby_sitelibdir=NONE
    8842 fi
    8843 
    8844 
    8845 
    8846 
    8847 RUBY_VERSION_CODE=`$RUBY -e "puts RUBY_VERSION.gsub(/\./, '')"`
    8848 
    8849 
    8850 RUBY_CONFIG_SO_NAME=`
    8851           $RUBY -rrbconfig -e "puts(Config::CONFIG['RUBY_SO_NAME'] || '')"`
    8852 RUBY_CONFIG_ARCHDIR=`
    8853           $RUBY -rrbconfig -e "puts(Config::CONFIG['archdir'] || '')"`
    8854 RUBY_CONFIG_ARCH=`
    8855           $RUBY -rrbconfig -e "puts(Config::CONFIG['arch'] || '')"`
    8856 RUBY_CONFIG_LIBDIR=`
    8857           $RUBY -rrbconfig -e "puts(Config::CONFIG['libdir'] || '')"`
    8858 RUBY_CONFIG_BINDIR=`
    8859           $RUBY -rrbconfig -e "puts(Config::CONFIG['bindir'] || '')"`
    8860 RUBY_CONFIG_RUBYHDRDIR=`
    8861           $RUBY -rrbconfig -e "puts(Config::CONFIG['rubyhdrdir'] || '')"`
    8862 RUBY_CONFIG_CFLAGS=`
    8863           $RUBY -rrbconfig -e "puts(Config::CONFIG['CFLAGS'] || '')"`
    8864 RUBY_CONFIG_LIBS=`
    8865           $RUBY -rrbconfig -e "puts(Config::CONFIG['LIBS'] || '')"`
    8866 RUBY_CONFIG_DLDLIBS=`
    8867           $RUBY -rrbconfig -e "puts(Config::CONFIG['DLDLIBS'] || '')"`
    8868 RUBY_CONFIG_LDFLAGS=`
    8869           $RUBY -rrbconfig -e "puts(Config::CONFIG['LDFLAGS'] || '')"`
    8870 RUBY_CONFIG_LIBRUBYARG=`
    8871           $RUBY -rrbconfig -e "puts(Config::CONFIG['LIBRUBYARG'] || '')"`
    8872 RUBY_CONFIG_LIBRUBYARG_STATIC=`
    8873           $RUBY -rrbconfig -e "puts(Config::CONFIG['LIBRUBYARG_STATIC'] || '')"`
    8874 RUBY_CONFIG_CCDLFLAGS=`
    8875           $RUBY -rrbconfig -e "puts(Config::CONFIG['CCDLFLAGS'] || '')"`
    8876 
    8877 if test "x${RUBY_CONFIG_RUBYHDRDIR}x" != "xx"; then
    8878   # 1.9
    8879   RUBY_CPPFLAGS="-I${RUBY_CONFIG_RUBYHDRDIR}"
    8880   RUBY_CPPFLAGS="${RUBY_CPPFLAGS} -I${RUBY_CONFIG_RUBYHDRDIR}/${RUBY_CONFIG_ARCH}"
    8881 else
    8882   # 1.8
    8883   RUBY_CPPFLAGS="-I${RUBY_CONFIG_ARCHDIR}"
    8884 fi
    8885 
    8886 
    8887 RUBY_CFLAGS="${RUBY_CONFIG_CFLAGS} ${RUBY_CONFIG_CCDLFLAGS}"
    8888 
    8889 
    8890 RUBY_CXXFLAGS="${RUBY_CONFIG_CFLAGS} ${RUBY_CONFIG_CCDLFLAGS}"
    8891 
    8892 
    8893 RUBY_LDFLAGS="-L${RUBY_CONFIG_ARCHDIR} -L${RUBY_CONFIG_LIBDIR} ${RUBY_CONFIG_LDFLAGS}"
    8894 
    8895 
    8896 RUBY_LIBS="${RUBY_CONFIG_LIBS} ${RUBY_CONFIG_DLDLIBS}"
    8897 
    8898 
    8899 RUBY_LIBRUBYARG="${RUBY_CONFIG_LIBRUBYARG}"
    8900 
    8901 
    8902 RUBY_LIBRUBYARG_STATIC="${RUBY_CONFIG_LIBRUBYARG_STATIC}"
    8903 
    8904 
    8905 if test "x${ruby_sitelibdir}x" != "xNONEx"
    8906 then
    8907   RUBY_SITELIBDIR="${ruby_sitelibdir}"
    8908 else
    8909   if test "x${prefix}x" = "xNONEx"
    8910   then
    8911     RUBY_SITELIBDIR=`
    8912           $RUBY -rrbconfig -e "puts(Config::CONFIG['sitelibdir'] || '')"`
     8750  withval=$with_ruby;
     8751else
     8752  with_ruby="yes"
     8753fi
     8754
     8755
     8756if test "${with_ruby}" != "no" ; then
     8757  if test "${with_ruby}" = "yes" ; then
     8758    # Extract the first word of "ruby", so it can be a program name with args.
     8759set dummy ruby; ac_word=$2
     8760{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
     8761$as_echo_n "checking for $ac_word... " >&6; }
     8762if ${ac_cv_path_RUBY+:} false; then :
     8763  $as_echo_n "(cached) " >&6
     8764else
     8765  case $RUBY in
     8766  [\\/]* | ?:[\\/]*)
     8767  ac_cv_path_RUBY="$RUBY" # Let the user override the test with a path.
     8768  ;;
     8769  *)
     8770  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
     8771for as_dir in $PATH
     8772do
     8773  IFS=$as_save_IFS
     8774  test -z "$as_dir" && as_dir=.
     8775    for ac_exec_ext in '' $ac_executable_extensions; do
     8776  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     8777    ac_cv_path_RUBY="$as_dir/$ac_word$ac_exec_ext"
     8778    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     8779    break 2
     8780  fi
     8781done
     8782  done
     8783IFS=$as_save_IFS
     8784
     8785  ;;
     8786esac
     8787fi
     8788RUBY=$ac_cv_path_RUBY
     8789if test -n "$RUBY"; then
     8790  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RUBY" >&5
     8791$as_echo "$RUBY" >&6; }
     8792else
     8793  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
     8794$as_echo "no" >&6; }
     8795fi
     8796
     8797
    89138798  else
    8914     sitelibdir_no_prefix=`$RUBY -rrbconfig \
    8915     -e "include Config; \
    8916     puts CONFIG['sitelibdir'].sub(CONFIG['prefix'], '')"`
    8917     RUBY_SITELIBDIR="${prefix}/${sitelibdir_no_prefix}"
     8799    # Extract the first word of "ruby", so it can be a program name with args.
     8800set dummy ruby; ac_word=$2
     8801{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
     8802$as_echo_n "checking for $ac_word... " >&6; }
     8803if ${ac_cv_path_RUBY+:} false; then :
     8804  $as_echo_n "(cached) " >&6
     8805else
     8806  case $RUBY in
     8807  [\\/]* | ?:[\\/]*)
     8808  ac_cv_path_RUBY="$RUBY" # Let the user override the test with a path.
     8809  ;;
     8810  *)
     8811  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
     8812as_dummy="${with_ruby}/bin:${with_ruby}"
     8813for as_dir in $as_dummy
     8814do
     8815  IFS=$as_save_IFS
     8816  test -z "$as_dir" && as_dir=.
     8817    for ac_exec_ext in '' $ac_executable_extensions; do
     8818  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     8819    ac_cv_path_RUBY="$as_dir/$ac_word$ac_exec_ext"
     8820    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     8821    break 2
    89188822  fi
    8919 fi
    8920 
    8921 
    8922 CPPFLAGS_save="${CPPFLAGS}"
    8923 CPPFLAGS="${CPPFLAGS} ${RUBY_CPPFLAGS}"
    8924 CXXFLAGS="${CPPFLAGS}"
    8925 for ac_header in ruby.h
    8926 do :
    8927   ac_fn_cxx_check_header_mongrel "$LINENO" "ruby.h" "ac_cv_header_ruby_h" "$ac_includes_default"
    8928 if test "x$ac_cv_header_ruby_h" = xyes; then :
    8929   cat >>confdefs.h <<_ACEOF
    8930 #define HAVE_RUBY_H 1
    8931 _ACEOF
    8932 
    8933 fi
    8934 
    8935 done
    8936 
    8937 HAVE_RUBY_H=${ac_cv_header_ruby_h}
    8938 
    8939 
    8940 for ac_header in node.h
    8941 do :
    8942   ac_fn_cxx_check_header_compile "$LINENO" "node.h" "ac_cv_header_node_h" "
    8943 #include <ruby.h>
    8944 
    8945 "
    8946 if test "x$ac_cv_header_node_h" = xyes; then :
    8947   cat >>confdefs.h <<_ACEOF
    8948 #define HAVE_NODE_H 1
    8949 _ACEOF
    8950 
    8951 fi
    8952 
    8953 done
    8954 
    8955 for ac_header in ruby/node.h
    8956 do :
    8957   ac_fn_cxx_check_header_compile "$LINENO" "ruby/node.h" "ac_cv_header_ruby_node_h" "
    8958                              #include <ruby.h>
    8959 
    8960 "
    8961 if test "x$ac_cv_header_ruby_node_h" = xyes; then :
    8962   cat >>confdefs.h <<_ACEOF
    8963 #define HAVE_RUBY_NODE_H 1
    8964 _ACEOF
    8965 
    8966 $as_echo "#define REALLY_HAVE_RUBY_NODE_H /**/" >>confdefs.h
    8967 
    8968 fi
    8969 
    8970 done
    8971 
    8972 for ac_header in version.h
    8973 do :
    8974   ac_fn_cxx_check_header_compile "$LINENO" "version.h" "ac_cv_header_version_h" "
    8975 #include <ruby.h>
    8976 
    8977 "
    8978 if test "x$ac_cv_header_version_h" = xyes; then :
    8979   cat >>confdefs.h <<_ACEOF
    8980 #define HAVE_VERSION_H 1
    8981 _ACEOF
    8982 
    8983 fi
    8984 
    8985 done
    8986 
    8987 for ac_header in env.h
    8988 do :
    8989   ac_fn_cxx_check_header_compile "$LINENO" "env.h" "ac_cv_header_env_h" "
    8990 #include <ruby.h>
    8991 
    8992 "
    8993 if test "x$ac_cv_header_env_h" = xyes; then :
    8994   cat >>confdefs.h <<_ACEOF
    8995 #define HAVE_ENV_H 1
    8996 _ACEOF
    8997 
    8998 fi
    8999 
    9000 done
    9001 
    9002 
    9003 CPPFLAGS="${CPPFLAGS_save}"
    9004 
    9005 
    9006 case $host_os in
    9007   *mingw32* ) MINGW32=yes;;
    9008           * ) MINGW32=no;;
     8823done
     8824  done
     8825IFS=$as_save_IFS
     8826
     8827  ;;
    90098828esac
    9010 
    9011 
    9012 if test x"${MINGW32}"x = xyesx; then
    9013 
    9014 RUBY_LIBS=`echo ${RUBY_LIBS} | sed -e "s%oldnames.lib%-lmoldname%"`
    9015 RUBY_LIBS=`echo ${RUBY_LIBS} | sed -e "s%user32.lib%-luser32%"`
    9016 RUBY_LIBS=`echo ${RUBY_LIBS} | sed -e "s%advapi32.lib%-ladvapi32%"`
    9017 RUBY_LIBS=`echo ${RUBY_LIBS} | sed -e "s%ws2_32.lib%-lws2_32%"`
    9018 RUBY_LIBRUBYARG=`echo ${RUBY_LIBRUBYARG} | sed -e "s%\(msvcrt-ruby.*\).lib%${RUBY_CONFIG_BINDIR}/\1.dll%"`
    9019 RUBY_LIBRUBYARG_STATIC=`echo ${RUBY_LIBRUBYARG_STATIC} | sed -e "s%\(msvcrt-ruby.*\).lib%${RUBY_CONFIG_LIBDIR}/\1.lib%"`
    9020 
    9021 fi
    9022 
     8829fi
     8830RUBY=$ac_cv_path_RUBY
     8831if test -n "$RUBY"; then
     8832  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RUBY" >&5
     8833$as_echo "$RUBY" >&6; }
     8834else
     8835  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
     8836$as_echo "no" >&6; }
     8837fi
     8838
     8839
     8840  fi
     8841fi
     8842
     8843RUBY_VERSION_RV=
     8844RUBY_PLATFORM=
     8845if test "x${RUBY}" != "x" ; then
     8846  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
     8847$as_echo_n "checking for a sed that does not truncate output... " >&6; }
     8848if ${ac_cv_path_SED+:} false; then :
     8849  $as_echo_n "(cached) " >&6
     8850else
     8851            ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
     8852     for ac_i in 1 2 3 4 5 6 7; do
     8853       ac_script="$ac_script$as_nl$ac_script"
     8854     done
     8855     echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
     8856     { ac_script=; unset ac_script;}
     8857     if test -z "$SED"; then
     8858  ac_path_SED_found=false
     8859  # Loop through the user's path and test for each of PROGNAME-LIST
     8860  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
     8861for as_dir in $PATH
     8862do
     8863  IFS=$as_save_IFS
     8864  test -z "$as_dir" && as_dir=.
     8865    for ac_prog in sed gsed; do
     8866    for ac_exec_ext in '' $ac_executable_extensions; do
     8867      ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
     8868      as_fn_executable_p "$ac_path_SED" || continue
     8869# Check for GNU ac_path_SED and select it if it is found.
     8870  # Check for GNU $ac_path_SED
     8871case `"$ac_path_SED" --version 2>&1` in
     8872*GNU*)
     8873  ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
     8874*)
     8875  ac_count=0
     8876  $as_echo_n 0123456789 >"conftest.in"
     8877  while :
     8878  do
     8879    cat "conftest.in" "conftest.in" >"conftest.tmp"
     8880    mv "conftest.tmp" "conftest.in"
     8881    cp "conftest.in" "conftest.nl"
     8882    $as_echo '' >> "conftest.nl"
     8883    "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
     8884    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
     8885    as_fn_arith $ac_count + 1 && ac_count=$as_val
     8886    if test $ac_count -gt ${ac_path_SED_max-0}; then
     8887      # Best one so far, save it but keep looking for a better one
     8888      ac_cv_path_SED="$ac_path_SED"
     8889      ac_path_SED_max=$ac_count
     8890    fi
     8891    # 10*(2^10) chars as input seems more than enough
     8892    test $ac_count -gt 10 && break
     8893  done
     8894  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
     8895esac
     8896
     8897      $ac_path_SED_found && break 3
     8898    done
     8899  done
     8900  done
     8901IFS=$as_save_IFS
     8902  if test -z "$ac_cv_path_SED"; then
     8903    as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5
     8904  fi
     8905else
     8906  ac_cv_path_SED=$SED
     8907fi
     8908
     8909fi
     8910{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
     8911$as_echo "$ac_cv_path_SED" >&6; }
     8912 SED="$ac_cv_path_SED"
     8913  rm -f conftest.sed
     8914
     8915
     8916
     8917
     8918
     8919    if test -n "$RUBY"; then :
     8920
     8921        ax_ruby_version=""
     8922
     8923        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ruby version" >&5
     8924$as_echo_n "checking for ruby version... " >&6; }
     8925
     8926        ruby_version=`$RUBY --version 2>&1 | $GREP "^ruby " | $SED -e 's/^.* \([0-9]*\.[0-9]*\.[0-9]*\) .*/\1/'`
     8927
     8928        { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ruby_version" >&5
     8929$as_echo "$ruby_version" >&6; }
     8930
     8931        RUBY_VERSION=$ruby_version
     8932
     8933
     8934
     8935  for ac_prog in gawk mawk nawk awk
     8936do
     8937  # Extract the first word of "$ac_prog", so it can be a program name with args.
     8938set dummy $ac_prog; ac_word=$2
     8939{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
     8940$as_echo_n "checking for $ac_word... " >&6; }
     8941if ${ac_cv_prog_AWK+:} false; then :
     8942  $as_echo_n "(cached) " >&6
     8943else
     8944  if test -n "$AWK"; then
     8945  ac_cv_prog_AWK="$AWK" # Let the user override the test.
     8946else
     8947as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
     8948for as_dir in $PATH
     8949do
     8950  IFS=$as_save_IFS
     8951  test -z "$as_dir" && as_dir=.
     8952    for ac_exec_ext in '' $ac_executable_extensions; do
     8953  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     8954    ac_cv_prog_AWK="$ac_prog"
     8955    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     8956    break 2
     8957  fi
     8958done
     8959  done
     8960IFS=$as_save_IFS
     8961
     8962fi
     8963fi
     8964AWK=$ac_cv_prog_AWK
     8965if test -n "$AWK"; then
     8966  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
     8967$as_echo "$AWK" >&6; }
     8968else
     8969  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
     8970$as_echo "no" >&6; }
     8971fi
     8972
     8973
     8974  test -n "$AWK" && break
     8975done
     8976
     8977
     8978  # Used to indicate true or false condition
     8979  ax_compare_version=false
     8980
     8981  # Convert the two version strings to be compared into a format that
     8982  # allows a simple string comparison.  The end result is that a version
     8983  # string of the form 1.12.5-r617 will be converted to the form
     8984  # 0001001200050617.  In other words, each number is zero padded to four
     8985  # digits, and non digits are removed.
     8986
     8987  ax_compare_version_A=`echo "$ax_ruby_version" | sed -e 's/\([0-9]*\)/Z\1Z/g' \
     8988                     -e 's/Z\([0-9]\)Z/Z0\1Z/g' \
     8989                     -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \
     8990                     -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \
     8991                     -e 's/[^0-9]//g'`
     8992
     8993
     8994  ax_compare_version_B=`echo "$ruby_version" | sed -e 's/\([0-9]*\)/Z\1Z/g' \
     8995                     -e 's/Z\([0-9]\)Z/Z0\1Z/g' \
     8996                     -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \
     8997                     -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \
     8998                     -e 's/[^0-9]//g'`
     8999
     9000
     9001    ax_compare_version=`echo "x$ax_compare_version_A
     9002x$ax_compare_version_B" | sed 's/^ *//' | sort | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"`
     9003
     9004
     9005
     9006    if test "$ax_compare_version" = "true" ; then
     9007
     9008            :
     9009
     9010
     9011    else
     9012            :
     9013
     9014
     9015  fi
     9016
     9017
     9018else
     9019
     9020        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find the ruby interpreter" >&5
     9021$as_echo "$as_me: WARNING: could not find the ruby interpreter" >&2;}
     9022
     9023
     9024fi
     9025
     9026  RUBY_VERSION_RV=`echo ${RUBY_VERSION} | cut -d'.' -f1-2`
     9027  RUBY_PLATFORM=`ruby -e 'puts RUBY_PLATFORM'`
     9028  ac_mkmf_result=`${RUBY} -r mkmf -e ";" 2>&1`
     9029  if test -z "$ac_mkmf_result"; then
     9030    HAVE_RUBY_DEVEL="yes"
     9031
     9032    #
     9033    # Check for Ruby include path
     9034    #
     9035    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Ruby include path" >&5
     9036$as_echo_n "checking for Ruby include path... " >&6; }
     9037    if test -z "$RUBY_CPPFLAGS"; then
     9038        ruby_path=`$RUBY -rmkmf -e 'print Config::CONFIG["archdir"]'`
     9039        if test -n "${ruby_path}"; then
     9040                ruby_path="-I$ruby_path"
     9041        fi
     9042        RUBY_CPPFLAGS=$ruby_path
     9043    fi
     9044    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RUBY_CPPFLAGS" >&5
     9045$as_echo "$RUBY_CPPFLAGS" >&6; }
     9046
     9047
     9048    #
     9049    # Check for Ruby library path
     9050    #
     9051    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Ruby library path" >&5
     9052$as_echo_n "checking for Ruby library path... " >&6; }
     9053    if test -z "$RUBY_LDFLAGS"; then
     9054        RUBY_LDFLAGS=`$RUBY -rmkmf -e 'print Config::CONFIG["LIBRUBYARG_SHARED"]'`
     9055    fi
     9056    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RUBY_LDFLAGS" >&5
     9057$as_echo "$RUBY_LDFLAGS" >&6; }
     9058
     9059
     9060    #
     9061    # Check for site packages
     9062    #
     9063    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Ruby site-packages path" >&5
     9064$as_echo_n "checking for Ruby site-packages path... " >&6; }
     9065    if test -z "$RUBY_SITE_PKG"; then
     9066        RUBY_SITE_PKG=`$RUBY -rmkmf -e 'print Config::CONFIG["sitearchdir"]'`
     9067    fi
     9068    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RUBY_SITE_PKG" >&5
     9069$as_echo "$RUBY_SITE_PKG" >&6; }
     9070
     9071
     9072    #
     9073    # libraries which must be linked in when embedding
     9074    #
     9075    { $as_echo "$as_me:${as_lineno-$LINENO}: checking ruby extra libraries" >&5
     9076$as_echo_n "checking ruby extra libraries... " >&6; }
     9077    if test -z "$RUBY_EXTRA_LIBS"; then
     9078       RUBY_EXTRA_LIBS=`$RUBY -rmkmf -e 'print Config::CONFIG["SOLIBS"]'`
     9079    fi
     9080    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RUBY_EXTRA_LIBS" >&5
     9081$as_echo "$RUBY_EXTRA_LIBS" >&6; }
     9082
     9083
     9084    #
     9085    # linking flags needed when embedding
     9086    # (is it even needed for Ruby?)
     9087    #
     9088    # AC_MSG_CHECKING(ruby extra linking flags)
     9089    # if test -z "$RUBY_EXTRA_LDFLAGS"; then
     9090    # RUBY_EXTRA_LDFLAGS=`$RUBY -rmkmf -e 'print Config::CONFIG[["LINKFORSHARED"]]'`
     9091    # fi
     9092    # AC_MSG_RESULT([$RUBY_EXTRA_LDFLAGS])
     9093    # AC_SUBST(RUBY_EXTRA_LDFLAGS)
     9094
     9095    # this flags breaks ruby.h, and is sometimes defined by KDE m4 macros
     9096    CFLAGS="`echo "$CFLAGS" | sed -e 's/-std=iso9899:1990//g;'`"
     9097    #
     9098    # final check to see if everything compiles alright
     9099    #
     9100    { $as_echo "$as_me:${as_lineno-$LINENO}: checking consistency of all components of ruby development environment" >&5
     9101$as_echo_n "checking consistency of all components of ruby development environment... " >&6; }
     9102    ac_ext=c
     9103ac_cpp='$CPP $CPPFLAGS'
     9104ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
     9105ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
     9106ac_compiler_gnu=$ac_cv_c_compiler_gnu
     9107
     9108    # save current global flags
     9109    ac_save_LIBS="$LIBS"
     9110    LIBS="$ac_save_LIBS $RUBY_LDFLAGS"
     9111    ac_save_CPPFLAGS="$CPPFLAGS"
     9112    CPPFLAGS="$ac_save_CPPFLAGS $RUBY_CPPFLAGS"
     9113    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
     9114/* end confdefs.h.  */
     9115
     9116        #include <ruby.h>
     9117
     9118int
     9119main ()
     9120{
     9121
     9122        ruby_init();
     9123
     9124  ;
     9125  return 0;
     9126}
     9127_ACEOF
     9128if ac_fn_c_try_link "$LINENO"; then :
     9129  rubyexists=yes
     9130else
     9131  rubyexists=no
     9132fi
     9133rm -f core conftest.err conftest.$ac_objext \
     9134    conftest$ac_exeext conftest.$ac_ext
     9135
     9136    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $rubyexists" >&5
     9137$as_echo "$rubyexists" >&6; }
     9138
     9139    if test "$rubyexists" = "no"; then
     9140      HAVE_RUBY_DEVEL="no"
     9141    fi
     9142    ac_ext=cpp
     9143ac_cpp='$CXXCPP $CPPFLAGS'
     9144ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
     9145ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
     9146ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
     9147
     9148    # turn back to default flags
     9149    CPPFLAGS="$ac_save_CPPFLAGS"
     9150    LIBS="$ac_save_LIBS"
     9151
     9152    #
     9153    # all done!
     9154    #
     9155
     9156  fi
     9157fi
    90239158
    90249159
     
    999710132
    999810133
     10134
    999910135MAKE=${make_command}
     10136
     10137
     10138
    1000010139
    1000110140
     
    1065410793INSTALL='$INSTALL'
    1065510794MKDIR_P='$MKDIR_P'
     10795AWK='$AWK'
    1065610796test -n "\$AWK" || AWK=awk
    1065710797_ACEOF
  • trunk/configure.in

    r3277 r3330  
    183183    for path in \
    184184     $libdir \
     185     $prefix/lib/tcltk \
    185186     $prefix/lib \
    186187     $exec_prefix/lib \
     
    206207RP_LANG_JAVA
    207208RP_LANG_R
    208 RP_LANG_RUBY
     209
     210RUBY=""
     211RUBY_DEV_PKG="no"
     212
     213AC_ARG_WITH(
     214    [ruby],
     215    [AS_HELP_STRING([--with-ruby=DIR], [location of ruby @<:@default=yes@:>@])],
     216    [],
     217    [with_ruby="yes"])
     218
     219if test "${with_ruby}" != "no" ; then
     220  if test "${with_ruby}" = "yes" ; then
     221    AC_PATH_PROG(RUBY, ruby)
     222  else
     223    AC_PATH_PROG(RUBY, ruby, [], [${with_ruby}/bin:${with_ruby}])
     224  fi
     225fi
     226
     227RUBY_VERSION_RV=
     228RUBY_PLATFORM=
     229if test "x${RUBY}" != "x" ; then
     230  AX_PROG_RUBY_VERSION
     231  RUBY_VERSION_RV=`echo ${RUBY_VERSION} | cut -d'.' -f1-2`
     232  RUBY_PLATFORM=`ruby -e 'puts RUBY_PLATFORM'`
     233  ac_mkmf_result=`${RUBY} -r mkmf -e ";" 2>&1`
     234  if test -z "$ac_mkmf_result"; then
     235    HAVE_RUBY_DEVEL="yes"
     236    AX_RUBY_DEV_FLAGS([${RUBY}])
     237  fi
     238fi
     239
    209240
    210241RP_BASE=`pwd`
     
    329360AC_SUBST(HAVE_FFMPEG_LIBS)
    330361AC_SUBST(HAVE_INTTYPES_H)
     362AC_SUBST(HAVE_RUBY_DEVEL)
    331363AC_SUBST(INSTALL_PREFIX)
    332364AC_SUBST(JAVA)
     
    372404AC_SUBST(R)
    373405AC_SUBST(RP_BASE)
     406AC_SUBST(RUBY)
     407AC_SUBST(RUBY_PLATFORM)
     408AC_SUBST(RUBY_VERSION_RV)
    374409AC_SUBST(SHLIB_CFLAGS)
    375410AC_SUBST(SHLIB_LD)
  • trunk/gui/apps/rappture.env.in

    r3177 r3330  
    2828PATH=${bindir}:$PATH
    2929
    30 LD_LIBRARY_PATH=${libdir}:${vtkdir}:$LD_LIBRARY_PATH
     30LD_LIBRARY_PATH=${libdir}:$LD_LIBRARY_PATH
    3131
    3232# For MacOS X
    33 DYLD_LIBRARY_PATH=${libdir}:${vtkdir}:$DYLD_LIBRARY_PATH
     33DYLD_LIBRARY_PATH=${libdir}:$DYLD_LIBRARY_PATH
    3434
    3535export PATH LD_LIBRARY_PATH DYLD_LIBRARY_PATH
  • trunk/gui/apps/rappture.use.in

    r2709 r3330  
    1818prepend PATH ${bindir}
    1919
    20 prepend LD_LIBRARY_PATH ${vtkdir}
    2120prepend LD_LIBRARY_PATH ${libdir}
    22 prepend DYLD_LIBRARY_PATH ${vtkdir}
    2321prepend DYLD_LIBRARY_PATH ${libdir}
    2422
  • trunk/gui/scripts/Makefile.in

    r3186 r3330  
    6363                $(srcdir)/grab.tcl \
    6464                $(srcdir)/groupentry.tcl \
    65                 $(srcdir)/heightmapviewer.tcl \
    6665                $(srcdir)/histogram.tcl \
    6766                $(srcdir)/histogramresult.tcl \
     
    102101                $(srcdir)/scroller.tcl \
    103102                $(srcdir)/sequence.tcl \
     103                $(srcdir)/sequencedial.tcl \
    104104                $(srcdir)/sequenceresult.tcl \
    105105                $(srcdir)/service.tcl \
     
    132132                $(srcdir)/visviewer.tcl \
    133133                $(srcdir)/vtkviewer.tcl \
    134                 $(srcdir)/vtkcontourviewer.tcl \
     134                $(srcdir)/vtkisosurfaceviewer.tcl \
    135135                $(srcdir)/vtkstreamlinesviewer.tcl \
    136136                $(srcdir)/vtkvolumeviewer.tcl \
  • trunk/gui/scripts/analyzer.tcl

    r3187 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: analyzer - output area for Rappture
     
    11851186# ----------------------------------------------------------------------
    11861187itcl::body Rappture::Analyzer::_isPdbTrajectory {data} {
    1187     if { [llength $data]  == 0 } {
     1188    if { [llength $data] == 0 } {
    11881189        return 0
    11891190    }
     
    12091210# ----------------------------------------------------------------------
    12101211itcl::body Rappture::Analyzer::_isLammpsTrajectory { data } {
    1211     if { [llength $data]  == 0 } {
     1212    if { [llength $data] == 0 } {
    12121213        return 0
    12131214    }
  • trunk/gui/scripts/animicon.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: animicon - an animated icon
  • trunk/gui/scripts/animover.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: animover - animated move
  • trunk/gui/scripts/balloon.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: Balloon - toplevel popup window, like a cartoon balloon
  • trunk/gui/scripts/barchartresult.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
  • trunk/gui/scripts/booleanentry.tcl

    r3186 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: BooleanEntry - widget for entering boolean values
  • trunk/gui/scripts/bugreport.tcl

    r3188 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  UTILITY: bugreport
  • trunk/gui/scripts/choiceentry.tcl

    r3186 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: ChoiceEntry - widget for entering a choice of strings
  • trunk/gui/scripts/cloud.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: cloud - represents the mesh for a cloud of points
     
    2223    public method points {}
    2324    public method mesh {}
     25    public method vtkdata {}
    2426    public method size {}
    2527    public method dimensions {}
    2628    public method limits {which}
    2729    public method hints {{key ""}}
    28 
     30    public method numpoints {} {
     31        return $_numPoints
     32    }
    2933    public proc fetch {xmlobj path}
    3034    public proc release {obj}
     
    3842    private common _xp2obj       ;# used for fetch/release ref counting
    3943    private common _obj2ref      ;# used for fetch/release ref counting
     44    private variable _numPoints 0
     45    private variable _vtkdata ""
     46    private variable _vtkpoints ""
     47    private variable _points ""
     48    private variable _dim 0
    4049}
    4150
     
    106115    }
    107116
    108     # create the vtk object containing points
    109     vtkPoints $this-points
     117    set data [$xmlobj get $path.points]
     118    Rappture::ReadPoints $data _dim values
    110119
    111120    foreach lim {xmin xmax ymin ymax zmin zmax} {
    112121        set _limits($lim) ""
    113122    }
    114 
     123    set _numPoints 0
     124    set _points {}
    115125    foreach line [split [$xmlobj get $path.points] \n] {
    116126        if {"" == [string trim $line]} {
     
    139149            }
    140150        }
    141         $this-points InsertNextPoint $x $y $z
    142     }
     151        append _points "$x $y $z\n"
     152        incr _numPoints
     153    }
     154    if { $_dim == 3 } {
     155        set _vtkpoints [vtkPoints $this-vtkpoints]
     156        foreach { x y z } $_points {
     157            $_vtkpoints InsertNextPoint $x $y $z
     158        }
     159    }
     160    append out "DATASET POLYDATA\n"
     161    append out "POINTS $_numPoints float\n"
     162    append out $_points
     163    set _vtkdata $out
    143164}
    144165
     
    149170    # don't destroy the _xmlobj! we don't own it!
    150171    itcl::delete object $_cloud
    151     rename $this-points ""
    152172}
    153173
     
    158178# ----------------------------------------------------------------------
    159179itcl::body Rappture::Cloud::points {} {
    160     return $this-points
     180    return $_points
    161181}
    162182
     
    167187# ----------------------------------------------------------------------
    168188itcl::body Rappture::Cloud::mesh {} {
    169     return $this-points
     189    if { $_dim == 3 } {
     190        return $_vtkpoints
     191    }
     192    return $_points
    170193}
    171194
     
    176199# ----------------------------------------------------------------------
    177200itcl::body Rappture::Cloud::size {} {
    178     return [$this-points GetNumberOfPoints]
     201    return $_numPOints
    179202}
    180203
     
    185208# ----------------------------------------------------------------------
    186209itcl::body Rappture::Cloud::dimensions {} {
     210    return $_dim
    187211    # count the dimensions with real limits
    188212    set dims 0
     
    230254    return [array get hints]
    231255}
     256
     257itcl::body Rappture::Cloud::vtkdata {} {
     258    return $_vtkdata
     259}
  • trunk/gui/scripts/color.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  UTILITY: color
  • trunk/gui/scripts/combobox.tcl

    r3186 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
  • trunk/gui/scripts/combochecks.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: combochecks - like a combobox, but items with checkboxes
  • trunk/gui/scripts/contourresult.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: contourresult - contour plot in a ResultSet
     
    590591                        return
    591592                    }
     593puts stderr "ContourResult: dataobj=$dataobj mesh=$mesh "
    592594                    switch -- [$mesh GetClassName] {
    593595                      vtkPoints {
  • trunk/gui/scripts/controlOwner.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: owner - manages Rappture controls
  • trunk/gui/scripts/controls.tcl

    r3186 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: controls - a container for various Rappture controls
  • trunk/gui/scripts/curve.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
  • trunk/gui/scripts/datatable.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12 
    23# ----------------------------------------------------------------------
  • trunk/gui/scripts/datatableresult.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
  • trunk/gui/scripts/deviceEditor.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: deviceEditor - general-purpose device editor
  • trunk/gui/scripts/deviceLayout1D.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: deviceLayout1D - visualizer for 1D device geometries
  • trunk/gui/scripts/deviceViewer1D.tcl

    r3186 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: deviceViewer1D - visualizer for 1D device geometries
  • trunk/gui/scripts/deviceresult.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: DeviceResult - output for <structure>
  • trunk/gui/scripts/diffview.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  WIDGET: diffview - view differences between two strings
  • trunk/gui/scripts/dispatcher.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: dispatcher - central notification mechanism
  • trunk/gui/scripts/drawing-obsolete.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: drawingobsolete - 2D drawing of data
  • trunk/gui/scripts/drawing.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
  • trunk/gui/scripts/drawingcontrols.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
  • trunk/gui/scripts/drawingentry.tcl

    r3182 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
  • trunk/gui/scripts/dropdown.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: dropdown - base class for drop-down panels
  • trunk/gui/scripts/dropdownchecks.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: dropdownchecks - drop-down list of checkbox items
  • trunk/gui/scripts/dropdownlist.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: dropdownlist - drop-down list of items
  • trunk/gui/scripts/editor.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: editor - pop-up editor for little bits of text
  • trunk/gui/scripts/energyLevels.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: EnergyLevels - visualizer for discrete energy levels
  • trunk/gui/scripts/field.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
     
    1617package require BLT
    1718
    18 namespace eval Rappture { # forward declaration }
    19 
     19namespace eval Rappture {
     20    # forward declaration
     21}
     22
     23#
     24# Possible field dataset types:
     25#
     26# 2D Datasets
     27#       vtk             (range of z-axis is zero).
     28#       unirect2d       (deprecated except where extents > 1)
     29#       cloud           (x,y point coordinates) (deprecated)
     30#       mesh
     31# 3D Datasets
     32#       vtk
     33#       unirect3d
     34#       cloud           (x,y,z coordinates) (deprecated)
     35#       mesh
     36#       dx              (FIXME: make dx-to-vtk converter work)
     37#       ucd avs
     38#
     39# Viewers:
     40#       Format     Dim  Description                     Viewer          Server
     41#       vtk         2   vtk file data.                  contour         vtkvis
     42#       vtk         3   vtk file data.                  isosurface      vtkvis
     43#       mesh        2   points-on-mesh                  heightmap       vtkvis
     44#       mesh        3   points-on-mesh                  isosurface      vtkvis
     45#       dx          3   DX                              volume          nanovis
     46#       unirect2d   2   unirect3d + extents > 1 flow    flow            nanovis
     47#       unirect3d   3   unirect2d + extents > 1 flow    flow            nanovis
     48#       
     49# The goal should be any 3D dataset can view a isosurface, volume,
     50# streamlines, or flow (if extents > 1).  Any 2D dataset can view a
     51# contour, heightmap, streamlines, or flow (if extents > 1). 
     52#
     53#
    2054itcl::class Rappture::Field {
    21     constructor {xmlobj path} { # defined below }
    22     destructor { # defined below }
    23 
     55    private variable _dim       0;      # Dimension of the mesh
     56    private variable _xmlobj ""  ;      # ref to XML obj with field data
     57    private variable _limits     ;      # maps box name => {z0 z1} limits
     58    private variable _field ""
     59    private variable _fieldNames ""   ; # list of field names.
     60    private variable _fieldUnits ""   ; # list of units of each field name.
     61    private variable _fieldLabels ""  ; # list of labels of each field name.
     62    private variable _viewer            ""
     63    private variable _hints
     64
     65    constructor {xmlobj path} {
     66        # defined below
     67    }
     68    destructor {
     69        # defined below
     70    }
    2471    public method components {args}
    25     public method mesh {{what -overall}}
    26     public method values {{what -overall}}
    27     public method blob {{what -overall}}
     72    public method mesh {{cname -overall}}
     73    public method values {{cname -overall}}
     74    public method blob {{cname -overall}}
    2875    public method limits {axis}
    2976    public method controls {option args}
     
    3279    public method isunirect2d {}
    3380    public method isunirect3d {}
    34     public method extents {{what -overall}}
     81    public method extents {{cname -overall}}
    3582    public method flowhints { cname }
    3683    public method type {}
    37     public method vtkdata {{what -overall}}
    38 
    39     protected method _build {}
     84    public method viewer {} {
     85        return $_viewer
     86    }
     87    public method vtkdata {cname}
     88   
     89    protected method Build {}
    4090    protected method _getValue {expr}
    4191
    42     private variable _xmlobj ""  ;      # ref to XML obj with device data
    4392    private variable _path "";          # Path of this object in the XML
    4493    private variable _units ""   ;      # system of units for this field
    45     private variable _limits     ;# maps box name => {z0 z1} limits
    4694    private variable _zmax 0     ;# length of the device
    4795
    48     private variable _field ""   ;# lib obj representing this field
    4996    private variable _comp2dims  ;# maps component name => dimensionality
    5097    private variable _comp2xy    ;# maps component name => x,y vectors
    51     private variable _comp2vtk   ;# maps component name => vtkFloatArray
    52     private variable _comp2vtkstreamlines   ;# maps component name => vtkFloatArray
    53     private variable _comp2vtkcontour   ;# maps component name => vtkFloatArray
    54     private variable _comp2vtkvolume   ;# maps component name => vtkFloatArray
    55     private variable _comp2volume   ;# maps component name => vtkFloatArray
     98    private variable _comp2vtk   ;# maps component name => vtk file data
    5699    private variable _comp2dx    ;# maps component name => OpenDX data
    57100    private variable _comp2unirect2d ;# maps component name => unirect2d obj
     
    60103    private variable _comp2cntls ;# maps component name => x,y control points
    61104    private variable _comp2extents
    62     private variable _comp2limits 
     105    private variable _comp2limits;      #  Array of limits per component
    63106    private variable _type ""
    64107    private variable _comp2flowhints
     108    private variable _comp2mesh
    65109    private common _counter 0    ;# counter for unique vector names
    66110
     111    private method BuildPointsOnMesh { cname }
    67112    private method ConvertToVtkData { cname }
    68113    private method ReadVtkDataSet { cname contents }
    69     private variable _fields {}
    70     private variable _isVtk
     114    private method AvsToVtk { cname contents }
     115    private variable _values ""
    71116}
    72117
     
    111156
    112157    # build up vectors for various components of the field
    113     _build
     158    Build
    114159}
    115160
     
    124169        eval blt::vector destroy $_comp2xy($name)
    125170    }
    126     foreach name [array names _comp2vtk] {
    127         set mobj [lindex $_comp2vtk($name) 0]
    128         set class [$mobj info class]
    129         ${class}::release $mobj
    130 
    131         set fobj [lindex $_comp2vtk($name) 1]
    132         rename $fobj ""
    133     }
    134171    foreach name [array names _comp2unirect2d] {
    135172        itcl::delete object $_comp2unirect2d($name)
     
    140177    foreach name [array names _comp2flowhints] {
    141178        itcl::delete object $_comp2flowhints($name)
     179    }
     180    foreach name [array names _comp2mesh] {
     181        # Data is in the form of a mesh and a vector.
     182        foreach { mesh vector } $_comp2mesh($name) break
     183        # Release the mesh (may be shared)
     184        set class [$mesh info class]
     185        ${class}::release $mesh
     186        # Destroy the vector
     187        blt::vector destroy $vector
    142188    }
    143189}
     
    193239# overall field (sum of all components).
    194240# ----------------------------------------------------------------------
    195 itcl::body Rappture::Field::mesh {{what -overall}} {
    196     if {$what == "-overall" || $what == "component0"} {
    197         set what [lindex [components -name] 0]
    198     }
    199     if {[info exists _comp2xy($what)]} {
    200         return [lindex $_comp2xy($what) 0]  ;# return xv
    201     }
    202     if { [info exists _comp2vtkstreamlines($what)] } {
    203         error "mesh: not implemented for streamlines"
     241itcl::body Rappture::Field::mesh {{cname -overall}} {
     242    if {$cname == "-overall" || $cname == "component0"} {
     243        set cname [lindex [components -name] 0]
     244    }
     245    if {[info exists _comp2xy($cname)]} {
     246        return [lindex $_comp2xy($cname) 0]  ;# return xv
     247    }
     248    if { [info exists _comp2vtk($cname)] } {
     249        # FIXME: extract mesh from VTK file data.
     250        error "method \"mesh\" is not implemented for VTK file data"
     251    }
     252    if {[info exists _comp2dx($cname)]} {
     253        return ""  ;# no mesh -- it's embedded in the value data
     254    }
     255    if {[info exists _comp2mesh($cname)]} {
     256        return ""  ;# no mesh -- it's embedded in the value data
     257    }
     258    if {[info exists _comp2unirect2d($cname)]} {
     259        set mobj [lindex $_comp2unirect2d($cname) 0]
    204260        return [$mobj mesh]
    205261    }
    206     if { [info exists _comp2vtkcontour($what)] } {
    207         error "method \"mesh\" is not implemented for vtkcontour"
    208     }
    209     if { [info exists _comp2vtk($what)] } {
    210         set mobj [lindex $_comp2vtk($what) 0]
     262    if {[info exists _comp2unirect3d($cname)]} {
     263        set mobj [lindex $_comp2unirect3d($cname) 0]
    211264        return [$mobj mesh]
    212265    }
    213     if {[info exists _comp2dx($what)]} {
    214         return ""  ;# no mesh -- it's embedded in the value data
    215     }
    216     if {[info exists _comp2vtkvolume($what)]} {
    217         return ""  ;# no mesh -- it's embedded in the value data
    218     }
    219     if {[info exists _comp2unirect2d($what)]} {
    220         set mobj [lindex $_comp2unirect2d($what) 0]
    221         return [$mobj mesh]
    222     }
    223     if {[info exists _comp2unirect3d($what)]} {
    224         set mobj [lindex $_comp2unirect3d($what) 0]
    225         return [$mobj mesh]
    226     }
    227     error "bad option \"$what\": should be [join [lsort [array names _comp2dims]] {, }]"
     266    error "bad option \"$cname\": should be [join [lsort [array names _comp2dims]] {, }]"
    228267}
    229268
     
    235274# overall field (sum of all components).
    236275# ----------------------------------------------------------------------
    237 itcl::body Rappture::Field::values {{what -overall}} {
    238     if {$what == "component0"} {
    239         set what "component"
    240     }
    241     if {[info exists _comp2xy($what)]} {
    242         return [lindex $_comp2xy($what) 1]  ;# return yv
    243     }
    244     if { [info exists _comp2vtkcontour($what)] } {
    245         error "method \"values\" is not implemented for vtkcontour"
    246     }
    247     if { [info exists _comp2vtkstreamlines($what)] } {
    248         # FIXME: Need to process the vtk file data to pull out the field's
    249         # values.
    250         error "vtkstreamlines: values not implemented"
    251         return [lindex $_comp2vtkstreamlines($what) 1]
    252     }
    253     if { [info exists _comp2vtk($what)] } {
    254         return [lindex $_comp2vtk($what) 1]  ;# return vtkFloatArray
    255     }
    256     if {[info exists _comp2dx($what)]} {
    257         return $_comp2dx($what)  ;# return gzipped, base64-encoded DX data
    258     }
    259     if {[info exists _comp2unirect2d($what)]} {
    260         return [$_comp2unirect2d($what) values]
    261     }
    262     if {[info exists _comp2unirect3d($what)]} {
    263         return [$_comp2unirect3d($what) blob]
    264     }
    265     error "bad option \"$what\": should be [join [lsort [array names _comp2dims]] {, }]"
     276itcl::body Rappture::Field::values {{cname -overall}} {
     277    if {$cname == "component0"} {
     278        set cname "component"
     279    }
     280    if {[info exists _comp2xy($cname)]} {
     281        return [lindex $_comp2xy($cname) 1]  ;# return yv
     282    }
     283    # VTK file data
     284    if { [info exists _comp2vtk($cname)] } {
     285        # FIXME: extract the values from the VTK file data
     286        error "method \"values\" is not implemented for vtk file data"
     287    }
     288    # Points-on-mesh
     289    if { [info exists _comp2mesh($cname)] } {
     290        set vector [lindex $_comp2mesh($cname) 1]
     291        return [$vector range 0 end]
     292    }
     293    if {[info exists _comp2dx($cname)]} {
     294        return $_comp2dx($cname)  ;# return gzipped, base64-encoded DX data
     295    }
     296    if {[info exists _comp2unirect2d($cname)]} {
     297        return [$_comp2unirect2d($cname) values]
     298    }
     299    if {[info exists _comp2unirect3d($cname)]} {
     300        return [$_comp2unirect3d($cname) blob]
     301    }
     302    error "bad option \"$cname\": should be [join [lsort [array names _comp2dims]] {, }]"
    266303}
    267304
     
    271308# Returns a string representing the blob of data for the mesh and values.
    272309# ----------------------------------------------------------------------
    273 itcl::body Rappture::Field::blob {{what -overall}} {
    274     if {$what == "component0"} {
    275         set what "component"
    276     }
    277     if {[info exists _comp2xy($what)]} {
     310itcl::body Rappture::Field::blob {{cname -overall}} {
     311    if {$cname == "component0"} {
     312        set cname "component"
     313    }
     314    if {[info exists _comp2xy($cname)]} {
    278315        return ""
    279316    }
    280     if { [info exists _comp2vtk($what)] } {
    281         return ""
    282     }
    283     if { [info exists _comp2vtkvolume($what)] } {
    284         return $_comp2vtkvolume($what)
    285     }
    286     if { [info exists _comp2vtkcontour($what)] } {
    287         return $_comp2vtkcontour($what)
    288     }
    289     if { [info exists _comp2vtkstreamlines($what)] } {
    290         # Return the contents of the vtk file.
    291         return $_comp2vtkstreamlines($what)
    292     }
    293     if {[info exists _comp2dx($what)]} {
    294         return $_comp2dx($what)  ;# return gzipped, base64-encoded DX data
    295     }
    296     if {[info exists _comp2unirect2d($what)]} {
    297         return [$_comp2unirect2d($what) blob]
    298     }
    299     if {[info exists _comp2unirect3d($what)]} {
    300         return [$_comp2unirect3d($what) blob]
    301     }
    302     error "bad option \"$what\": should be [join [lsort [array names _comp2dims]] {, }]"
     317    if { [info exists _comp2vtk($cname)] } {
     318        error "blob not implemented for VTK file data"
     319    }
     320    if {[info exists _comp2dx($cname)]} {
     321        return $_comp2dx($cname)  ;# return gzipped, base64-encoded DX data
     322    }
     323    if {[info exists _comp2unirect2d($cname)]} {
     324        return [$_comp2unirect2d($cname) blob]
     325    }
     326    if {[info exists _comp2unirect3d($cname)]} {
     327        return [$_comp2unirect3d($cname) blob]
     328    }
     329    error "bad option \"$cname\": should be [join [lsort [array names _comp2dims]] {, }]"
    303330}
    304331
     
    312339    set min ""
    313340    set max ""
    314 
    315341    blt::vector tmp zero
    316     foreach comp [array names _comp2dims] {
    317         switch -- $_comp2dims($comp) {
     342
     343    foreach cname [array names _comp2dims] {
     344        switch -- $_comp2dims($cname) {
    318345            1D {
    319346                switch -- $which {
    320                     x - xlin { set pos 0; set log 0; set axis xaxis }
    321                     xlog { set pos 0; set log 1; set axis xaxis }
    322                     y - ylin - v - vlin { set pos 1; set log 0; set axis yaxis }
    323                     ylog - vlog { set pos 1; set log 1; set axis yaxis }
     347                    x - xlin {
     348                        set pos 0; set log 0; set axis x
     349                    }
     350                    xlog {
     351                        set pos 0; set log 1; set axis x
     352                    }
     353                    y - ylin - v - vlin {
     354                        set pos 1; set log 0; set axis y
     355                    }
     356                    ylog - vlog {
     357                        set pos 1; set log 1; set axis y
     358                    }
    324359                    default {
    325360                        error "bad option \"$which\": should be x, xlin, xlog, y, ylin, ylog, v, vlin, vlog"
     
    327362                }
    328363
    329                 set vname [lindex $_comp2xy($comp) $pos]
     364                set vname [lindex $_comp2xy($cname) $pos]
    330365                $vname variable vec
    331366
     
    337372                    tmp expr {abs(tmp)}             ;# get the abs value
    338373                    tmp expr {tmp + zero*max(tmp)}  ;# replace 0's with abs max
    339                     set vmin [blt::vector expr min(tmp)]
    340                     set vmax [blt::vector expr max(tmp)]
     374                    set axisMin [blt::vector expr min(tmp)]
     375                    set axisMax [blt::vector expr max(tmp)]
    341376                } else {
    342                     set vmin $vec(min)
    343                     set vmax $vec(max)
     377                    set axisMin $vec(min)
     378                    set axisMax $vec(max)
    344379                }
    345380
    346381                if {"" == $min} {
    347                     set min $vmin
    348                 } elseif {$vmin < $min} {
    349                     set min $vmin
     382                    set min $axisMin
     383                } elseif {$axisMin < $min} {
     384                    set min $axisMin
    350385                }
    351386                if {"" == $max} {
    352                     set max $vmax
    353                 } elseif {$vmax > $max} {
    354                     set max $vmax
     387                    set max $axisMax
     388                } elseif {$axisMax > $max} {
     389                    set max $axisMax
    355390                }
    356391            }
    357392            2D - 3D {
    358                 if {[info exists _comp2unirect2d($comp)]} {
    359                     set limits [$_comp2unirect2d($comp) limits $which]
    360                     foreach {vmin vmax} $limits break
    361                     set axis vaxis
    362                 } elseif {[info exists _comp2unirect3d($comp)]} {
    363                     set limits [$_comp2unirect3d($comp) limits $which]
    364                     foreach {vmin vmax} $limits break
    365                     set axis vaxis
    366                 } elseif {[info exists _comp2vtk($comp)]} {
    367                     foreach {xv yv} $_comp2vtk($comp) break
    368                     switch -- $which {
     393                if {[info exists _comp2unirect2d($cname)]} {
     394                    set limits [$_comp2unirect2d($cname) limits $which]
     395                    foreach {axisMin axisMax} $limits break
     396                    set axis v
     397                } elseif {[info exists _comp2unirect3d($cname)]} {
     398                    set limits [$_comp2unirect3d($cname) limits $which]
     399                    foreach {axisMin axisMax} $limits break
     400                    set axis v
     401                } elseif {[info exists _comp2limits($cname)]} {
     402                    array set limits $_comp2limits($cname)
     403                    switch -- $which {
    369404                        x - xlin - xlog {
    370                             foreach {vmin vmax} [$xv limits x] break
    371                             set axis xaxis
     405                            set axis x
     406                            foreach {axisMin axisMax} $limits(x) break
    372407                        }
    373408                        y - ylin - ylog {
    374                             foreach {vmin vmax} [$xv limits y] break
    375                             set axis yaxis
     409                            set axis y
     410                            foreach {axisMin axisMax} $limits(y) break
    376411                        }
    377412                        z - zlin - zlog {
    378                             foreach {vmin vmax} [$xv limits z] break
    379                             set axis zaxis
     413                            set axis y
     414                            foreach {axisMin axisMax} $limits(z) break
    380415                        }
    381416                        v - vlin - vlog {
    382                             catch {unset style}
    383                             array set style $_comp2style($comp)
    384                             if {[info exists style(-min)] && [info exists style(-max)]} {
    385                                 # This component has its own hard-coded
    386                                 # min/max range.  Ignore it for overall limits.
    387                                 set vmin $min
    388                                 set vmax $max
    389                             } else {
    390                                 foreach {vmin vmax} [$yv GetRange] break
    391                             }
    392                             set axis vaxis
    393                         }
    394                         default {
    395                             error "bad option \"$which\": should be x, xlin, xlog, y, ylin, ylog, v, vlin, vlog"
    396                         }
    397                     }
     417                            set axis v
     418                            foreach {axisMin axisMax} $limits(v) break
     419                        }
     420                        default {
     421                            if { ![info exists limits($which)] } {
     422                                error "limits: unknown axis \"$which\""
     423                            }
     424                            set axis v
     425                            foreach {axisMin axisMax} $limits($which) break
     426                        }
     427                    }
    398428                } else {
    399                     set vmin 0  ;# HACK ALERT! must be OpenDX data
    400                     set vmax 1
    401                     set axis vaxis
     429                    set axisMin 0  ;# HACK ALERT! must be OpenDX data
     430                    set axisMax 1
     431                    set axis v
    402432                }
    403433            }
    404434        }
    405         if {"" == $min} {
    406             set min $vmin
    407         } elseif {$vmin < $min} {
    408             set min $vmin
    409         }
    410         if {"" == $max} {
    411             set max $vmax
    412         } elseif {$vmax > $max} {
    413             set max $vmax
     435        if { "" == $min || $axisMin < $min } {
     436            set min $axisMin
     437        }
     438        if { "" == $max || $axisMax > $max } {
     439            set max $axisMax
    414440        }
    415441    }
    416442    blt::vector destroy tmp zero
    417 
    418     set val [$_field get $axis.min]
     443    set val [$_field get "${axis}axis.min"]
    419444    if {"" != $val && "" != $min} {
    420445        if {$val > $min} {
     
    423448        }
    424449    }
    425 
    426     set val [$_field get $axis.max]
     450    set val [$_field get "${axis}axis.max"]
    427451    if {"" != $val && "" != $max} {
    428452        if {$val < $max} {
     
    445469    switch -- $option {
    446470        get {
    447             set what [lindex $args 0]
    448             if {[info exists _comp2cntls($what)]} {
    449                 return $_comp2cntls($what)
     471            set cname [lindex $args 0]
     472            if {[info exists _comp2cntls($cname)]} {
     473                return $_comp2cntls($cname)
    450474            }
    451475            return ""
     
    511535            set value [lindex $args 1]
    512536            $_xmlobj put $path.current $value
    513             _build
     537            Build
    514538        }
    515539        default {
     
    527551# ----------------------------------------------------------------------
    528552itcl::body Rappture::Field::hints {{keyword ""}} {
    529     foreach {key path} {
    530         camera          camera.position
    531         color           about.color
    532         default         about.default
    533         group           about.group
    534         label           about.label
    535         scalars         about.scalars
    536         scale           about.scale
    537         seeds           about.seeds
    538         style           about.style
    539         toolId          tool.id
    540         toolName        tool.name
    541         toolRevision    tool.version.application.revision
    542         type            about.type
    543         units           units
    544         updir           updir
    545         vectors         about.vectors
    546     } {
    547         set str [$_field get $path]
    548         if {"" != $str} {
    549             set hints($key) $str
    550         }
    551     }
    552     # Set tool and path hints
    553     set hints(tool) [$_xmlobj get tool.name]
    554     set hints(path) $_path
    555     if 0 {
    556         # to be compatible with curve objects
    557         set hints(xlabel) "Position"
    558     }
    559     if {[info exists hints(group)] && [info exists hints(label)]} {
    560         # pop-up help for each curve
    561         set hints(tooltip) $hints(label)
    562     }
    563 
    564     if {$keyword != ""} {
    565         if {[info exists hints($keyword)]} {
    566             return $hints($keyword)
     553    if { ![info exists _hints] } {
     554        set _hints(fieldnames)  $_fieldNames
     555        set _hints(fieldunits)  $_fieldUnits
     556        set _hints(fieldlabels) $_fieldLabels
     557        foreach {key path} {
     558            camera          camera.position
     559            color           about.color
     560            default         about.default
     561            group           about.group
     562            label           about.label
     563            fieldnames      about.fieldnames
     564            fieldunits      about.fieldunits
     565            fieldlabels     about.fieldlabels
     566            scale           about.scale
     567            seeds           about.seeds
     568            style           about.style
     569            type            about.type
     570            xlabel          about.xaxis.label
     571            ylabel          about.yaxis.label
     572            zlabel          about.zaxis.label
     573            xunits          about.xaxis.units
     574            yunits          about.yaxis.units
     575            zunits          about.zaxis.units
     576            units           units
     577            updir           updir
     578            vectors         about.vectors
     579        } {
     580            set str [$_field get $path]
     581            if { "" != $str } {
     582                set _hints($key) $str
     583            }
     584        }
     585        foreach {key path} {
     586            toolid          tool.id
     587            toolname        tool.name
     588            toolcommand     tool.execute
     589            tooltitle       tool.title
     590            toolrevision    tool.version.application.revision
     591        } {
     592            set str [$_xmlobj get $path]
     593            if { "" != $str } {
     594                set _hints($key) $str
     595            }
     596        }
     597        # Set toolip and path hints
     598        set _hints(path) $_path
     599        if { [info exists _hints(group)] && [info exists _hints(label)] } {
     600            # pop-up help for each curve
     601            set _hints(tooltip) $_hints(label)
     602        }
     603    }
     604    if { $keyword != "" } {
     605        if {[info exists _hints($keyword)]} {
     606            return $_hints($keyword)
    567607        }
    568608        return ""
    569609    }
    570     return [array get hints]
    571 }
    572 
    573 # ----------------------------------------------------------------------
    574 # USAGE: _build
     610    return [array get _hints]
     611}
     612
     613# ----------------------------------------------------------------------
     614# USAGE: Build
    575615#
    576616# Used internally to build up the vector representation for the
     
    579619# from scratch.
    580620# ----------------------------------------------------------------------
    581 itcl::body Rappture::Field::_build {} {
    582     # discard any existing data
     621itcl::body Rappture::Field::Build {} {
     622
     623    # Discard any existing data
    583624    foreach name [array names _comp2xy] {
    584625        eval blt::vector destroy $_comp2xy($name)
    585626    }
    586     foreach name [array names _comp2vtk] {
    587         set mobj [lindex $_comp2vtk($name) 0]
    588         set class [$mobj info class]
    589         ${class}::release $mobj
    590 
    591         set fobj [lindex $_comp2vtk($name) 1]
    592         rename $fobj ""
    593     }
     627    array unset _comp2vtk
    594628    foreach name [array names _comp2unirect2d] {
    595629        eval itcl::delete object $_comp2unirect2d($name)
     
    599633    }
    600634    catch {unset _comp2xy}
    601     catch {unset _comp2vtk}
    602635    catch {unset _comp2dx}
    603636    catch {unset _comp2dims}
    604637    catch {unset _comp2style}
    605     array unset _comp2volume
    606     array unset _comp2vtkstreamlines
    607     array unset _comp2vtkcontour
    608638    array unset _comp2unirect2d
    609639    array unset _comp2unirect3d
     
    617647        set type ""
    618648        if { ([$_field element $cname.constant] != "" &&
    619             [$_field element $cname.domain] != "") ||
    620             [$_field element $cname.xy] != ""} {
     649              [$_field element $cname.domain] != "") ||
     650              [$_field element $cname.xy] != "" } {
    621651            set type "1D"
    622         } elseif {[$_field element $cname.mesh] != "" &&
    623             [$_field element $cname.values] != ""} {
     652        } elseif { [$_field element $cname.mesh] != "" &&
     653                   [$_field element $cname.values] != ""} {
    624654            set type "points-on-mesh"
    625         } elseif {[$_field element $cname.vtk] != ""} {
    626             set _isVtkData($cname) 1
    627             if { [$_field get "about.view"] == "streamlines" } {
    628                 set type "vtkstreamlines"
    629             } elseif { [$_field get "about.view"] == "contour" } {
    630                 set type "vtkcontour"
    631             } else {
    632                 set type "vtk"
    633             }
     655        } elseif { [$_field element $cname.vtk] != ""} {
     656            set viewer [$_field get "about.view"]
     657            set type "vtk"
     658            if { $viewer != "" } {
     659                set _viewer $viewer
     660            }
    634661        } elseif {[$_field element $cname.opendx] != ""} {
    635662            global env
     
    646673                set type "dx"
    647674            }
    648         }
     675        }
    649676        set _comp2style($cname) ""
    650677       
     
    701728                # sort x-coords in increasing order
    702729                $xv sort $yv
    703 
    704730                set _comp2dims($cname) "1D"
    705731                set _comp2xy($cname) [list $xv $yv]
     
    707733            }
    708734        } elseif {$type == "points-on-mesh"} {
    709             #
    710             # More complex 2D/3D data is represented by a mesh
    711             # object and an associated vtkFloatArray for field
    712             # values.
    713             #
    714             set path [$_field get $cname.mesh]
    715             if {[$_xmlobj element $path] != ""} {
    716                 set element [$_xmlobj element -as type $path]
    717                 if { $element == "unirect2d" } {
    718                     set _comp2dims($cname) "2D"
    719                     set _comp2unirect2d($cname) \
    720                         [Rappture::Unirect2d \#auto $_xmlobj $_field $cname \
    721                              $extents]
    722                     set _comp2style($cname) [$_field get $cname.style]
    723                     if {[$_field element $cname.flow] != ""} {
    724                         set _comp2flowhints($cname) \
    725                             [Rappture::FlowHints ::\#auto $_field $cname $_units]
    726                     }
    727                     incr _counter
    728                 } elseif { $element == "unirect3d" } {
    729                     set _comp2dims($cname) "3D"
    730                     set _comp2unirect3d($cname) \
    731                         [Rappture::Unirect3d \#auto $_xmlobj $_field $cname \
    732                             $extents]
    733                     set _comp2style($cname) [$_field get $cname.style]
    734                     if {[$_field element $cname.flow] != ""} {
    735                         set _comp2flowhints($cname) \
    736                             [Rappture::FlowHints ::\#auto $_field $cname $_units]
    737                     }
    738                     incr _counter
    739                 } elseif { $element == "cloud" || $element == "mesh" } {
    740                     switch -- $element {
    741                         cloud {
    742                             set mobj [Rappture::Cloud::fetch $_xmlobj $path]
    743                         }
    744                         mesh {
    745                             set mobj [Rappture::Mesh::fetch $_xmlobj $path]
    746                         }
    747                     }
    748                     if {[$mobj dimensions] > 1} {
    749                         #
    750                         # 2D/3D data
    751                         # Store cloud/field as components
    752                         #
    753                         set values [$_field get $cname.values]
    754                         set farray [vtkFloatArray ::vals$_counter]
    755 
    756                         foreach v $values {
    757                             if {"" != $_units} {
    758                                 set v [Rappture::Units::convert $v \
    759                                    -context $_units -to $_units -units off]
    760                             }
    761                             $farray InsertNextValue $v
    762                         }
    763 
    764                         set _comp2dims($cname) "[$mobj dimensions]D"
    765                         set _comp2vtk($cname) [list $mobj $farray]
    766                         set _comp2style($cname) [$_field get $cname.style]
    767                         incr _counter
    768                     } else {
    769                         #
    770                         # OOPS!  This is 1D data
    771                         # Forget the cloud/field -- store BLT vectors
    772                         #
    773                         set xv [blt::vector create x$_counter]
    774                         set yv [blt::vector create y$_counter]
    775 
    776                         set vtkpts [$mobj points]
    777                         set max [$vtkpts GetNumberOfPoints]
    778                         for {set i 0} {$i < $max} {incr i} {
    779                             set xval [lindex [$vtkpts GetPoint $i] 0]
    780                             $xv append $xval
    781                         }
    782                         set class [$mobj info class]
    783                         ${class}::release $mobj
    784 
    785                         set values [$_field get $cname.values]
    786                         foreach yval $values {
    787                             if {"" != $_units} {
    788                                 set yval [Rappture::Units::convert $yval \
    789                                       -context $_units -to $_units -units off]
    790                             }
    791                             $yv append $yval
    792                         }
    793 
    794                         # sort x-coords in increasing order
    795                         $xv sort $yv
    796 
    797                         set _comp2dims($cname) "1D"
    798                         set _comp2xy($cname) [list $xv $yv]
    799                         incr _counter
    800                     }
    801                 }
    802             } else {
    803                 puts "WARNING: can't find mesh $path for field component"
    804             }
     735            BuildPointsOnMesh $cname
    805736        } elseif {$type == "vtk"} {
    806             #
    807             # Extract native vtk data from the XML and use a reader
    808             # to load it.
    809             #
    810             vtkRectilinearGridReader $this-gr
    811             $this-gr SetInputString [$_field get $cname.vtk]
    812 
    813 
    814             set _comp2dims($cname) "[$mobj dimensions]D"
    815             set _comp2vtk($cname) [list $mobj $farray]
    816             set _comp2style($cname) [$_field get $cname.style]
    817             incr _counter
    818         } elseif {$type == "vtkstreamlines"} {
    819             set _comp2dims($cname) "3D"
    820             # Allow redirects to another element.
    821737            set vtkdata [$_field get $cname.vtk]
    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
    832             set _comp2style($cname) [$_field get $cname.style]
    833             incr _counter
    834         } elseif {$type == "vtkvolume"} {
    835             set _comp2dims($cname) "3D"
    836             # Allow redirects to another element.
    837             set data [$_field get -decode no $cname.dx]
    838             set data [Rappture::encoding::decode -as zb64 $data]
    839             if 1 {
    840             set file "/tmp/$cname.dx"
    841             set f [open $file "w"]
    842             puts $f $data
    843             close $f
    844             }
    845             set data [Rappture::ConvertDxToVtk $data]
    846             if 1 {
    847             set file "/tmp/$cname.vtk"
    848             set f [open $file "w"]
    849             puts $f $data
    850             close $f
    851             }
    852             set _comp2vtkvolume($cname) $data
    853             set _comp2style($cname) [$_field get $cname.style]
    854             incr _counter
    855         } elseif {$type == "vtkstreamlines2"} {
    856             set _comp2dims($cname) "3D"
    857             set _comp2vtkstreamlines($cname) [$_field get $cname.vtk]
     738            ReadVtkDataSet $cname $vtkdata
     739            set _comp2vtk($cname) $vtkdata
    858740            set _comp2style($cname) [$_field get $cname.style]
    859741            incr _counter
     
    864746            # off to the NanoVis visualizer.
    865747            #
     748            set _viewer "nanovis"
    866749            set _comp2dims($cname) "3D"
    867750            set _comp2dx($cname)  [$_field get -decode no $cname.dx]
     
    890773            # off to the NanoVis visualizer.
    891774            #
     775            set _viewer "nanovis"
    892776            set _comp2dims($cname) "3D"
    893777            set data [$_field get -decode yes $cname.opendx]
     
    901785            }
    902786            incr _counter
     787        } elseif {[$_field element $cname.ucd] != ""} {
     788            set _viewer "isosurface"
     789            set _comp2dims($cname) "3D"
     790            set contents [$_field get $cname.ucd]
     791            set vtkdata [AvsToVtk $cname $contents]
     792            ReadVtkDataSet $cname $vtkdata
     793            set _comp2vtk($cname) $vtkdata
     794            set _comp2style($cname) [$_field get $cname.style]
     795            incr _counter
     796        }
     797    }
     798    # Sanity check.  Verify that all components of the field have the same
     799    # dimension.
     800    set dim ""
     801    foreach cname [array names _comp2dims] {
     802        if { $dim == "" } {
     803            set dim $_comp2dims($cname)
     804            continue
     805        }
     806        if { $dim != $_comp2dims($cname) } {
     807            error "field can't have components of different dimensions: [join [array get _comp2dims] ,]"
    903808        }
    904809    }
     
    1004909# Returns if the field is a unirect2d object. 
    1005910#
    1006 itcl::body Rappture::Field::extents {{what -overall}} {
    1007     if {$what == "-overall" } {
     911itcl::body Rappture::Field::extents {{cname -overall}} {
     912    if {$cname == "-overall" } {
    1008913        set max 0
    1009914        foreach cname [$_field children -type component] {
     
    1019924        return $max
    1020925    }
    1021     if { $what == "component0"} {
    1022         set what [lindex [components -name] 0]
    1023     }
    1024     return $_comp2extents($what)
    1025 }
    1026 
    1027 # ----------------------------------------------------------------------
    1028 # USAGE: blob ?<name>?
    1029 #
    1030 # Returns a string representing the blob of data for the mesh and values.
    1031 # ----------------------------------------------------------------------
    1032 itcl::body Rappture::Field::vtkdata {{what -overall}} {
    1033     if {$what == "component0"} {
    1034         set what "component"
    1035     }
    1036     if {[info exists _comp2xy($what)]} {
    1037         return ""
    1038     }
    1039     if { [info exists _comp2vtk($what)] } {
    1040         return ""
    1041     }
    1042     if { [info exists _comp2vtkcontour($what)] } {
    1043         return $_comp2contour($what)
    1044     }
    1045     if { [info exists _comp2vtkstreamlines($what)] } {
    1046         return $_comp2vtkstreamlines($what)
    1047     }
    1048     if { [info exists _comp2vtkvolume($what)] } {
    1049         return $_comp2vtkvolume($what)
    1050     }
    1051     if {[info exists _comp2dx($what)]} {
    1052         return $_comp2dx($what)
    1053     }
    1054     if {[info exists _comp2unirect2d($what)]} {
    1055         return [$_comp2unirect2d($what) blob]
    1056     }
    1057     if {[info exists _comp2unirect3d($what)]} {
    1058         return [$_comp2unirect3d($what) blob]
    1059     }
    1060     error "bad option \"$what\": should be [join [lsort [array names _comp2dims]] {, }]"
    1061 }
    1062 
    1063 itcl::body Rappture::Field::ConvertToVtkData { comp } {
     926    if { $cname == "component0"} {
     927        set cname [lindex [components -name] 0]
     928    }
     929    return $_comp2extents($cname)
     930}
     931
     932itcl::body Rappture::Field::ConvertToVtkData { cname } {
    1064933    set ds ""
    1065     switch -- [typeof $comp] {
     934    switch -- [typeof $cname] {
    1066935        "unirect2d" {
    1067             foreach { x1 x2 xN y1 y2 yN } [$dataobj mesh $comp] break
     936            foreach { x1 x2 xN y1 y2 yN } [$dataobj mesh $cname] break
    1068937            set spacingX [expr {double($x2 - $x1)/double($xN - 1)}]
    1069938            set spacingY [expr {double($y2 - $y1)/double($yN - 1)}]
     
    1074943            $ds SetSpacing $spacingX $spacingY 0
    1075944            set arr [vtkDoubleArray $this-arrTemp]
    1076             foreach {val} [$dataobj values $comp] {
     945            foreach {val} [$dataobj values $cname] {
    1077946                $arr InsertNextValue $val
    1078947            }
     
    1080949        }
    1081950        "unirect3d" {
    1082             foreach { x1 x2 xN y1 y2 yN z1 z2 zN } [$dataobj mesh $comp] break
     951            foreach { x1 x2 xN y1 y2 yN z1 z2 zN } [$dataobj mesh $cname] break
    1083952            set spacingX [expr {double($x2 - $x1)/double($xN - 1)}]
    1084953            set spacingY [expr {double($y2 - $y1)/double($yN - 1)}]
     
    1090959            $ds SetSpacing $spacingX $spacingY $spacingZ
    1091960            set arr [vtkDoubleArray $this-arrTemp]
    1092             foreach {val} [$dataobj values $comp] {
     961            foreach {val} [$dataobj values $cname] {
    1093962                $arr InsertNextValue $val
    1094963            }
    1095964            [$ds GetPointData] SetScalars $val
    1096965        }
    1097         "vtkcontour" {
    1098             return [$dataobj blob $comp]
     966        "contour" {
     967            return [$dataobj blob $cname]
    1099968        }
    1100969        "dx" {
    1101             return [Rappture::ConvertDxToVtk $_comp2dx($what)]
     970            return [Rappture::ConvertDxToVtk $_comp2dx($cname)]
    1102971        }
    1103972        default {
    1104             set mesh [$dataobj mesh $comp]
     973            set mesh [$dataobj mesh $cname]
    1105974            switch -- [$mesh GetClassName] {
    1106975                vtkPoints {
     
    1108977                    set ds [vtkPolyData $this-polydataTemp]
    1109978                    $ds SetPoints $mesh
    1110                     [$ds GetPointData] SetScalars [$dataobj values $comp]
     979                    [$ds GetPointData] SetScalars [$dataobj values $cname]
    1111980                }
    1112981                vtkPolyData {
    1113982                    set ds [vtkPolyData $this-polydataTemp]
    1114983                    $ds ShallowCopy $mesh
    1115                     [$ds GetPointData] SetScalars [$dataobj values $comp]
     984                    [$ds GetPointData] SetScalars [$dataobj values $cname]
    1116985                }
    1117986                vtkUnstructuredGrid {
     
    1119988                    set ds [vtkUnstructuredGrid $this-grdataTemp]
    1120989                    $ds ShallowCopy $mesh
    1121                     [$ds GetPointData] SetScalars [$dataobj values $comp]
     990                    [$ds GetPointData] SetScalars [$dataobj values $cname]
    1122991                }
    1123992                vtkRectilinearGrid {
     
    1125994                    set ds [vtkRectilinearGrid $this-grdataTemp]
    1126995                    $ds ShallowCopy $mesh
    1127                     [$ds GetPointData] SetScalars [$dataobj values $comp]
     996                    [$ds GetPointData] SetScalars [$dataobj values $cname]
    1128997                }
    1129998                default {
     
    11521021}
    11531022
    1154 itcl::body Rappture::Field::ReadVtkDataSet { comp contents } {
     1023itcl::body Rappture::Field::ReadVtkDataSet { cname contents } {
    11551024    package require vtk
    11561025
     
    11721041    set limits {}
    11731042    foreach {xmin xmax ymin ymax zmin zmax} [$dataset GetBounds] break
    1174     lappend limits xmin $xmin xmax $xmax ymin $ymin ymax $ymax 
     1043    # Figure out the dimension of the mesh from the bounds.
     1044    set _dim 0
     1045    if { $xmax > $xmin } {
     1046        incr _dim
     1047    }
     1048    if { $ymax > $ymin } {
     1049        incr _dim
     1050    }
     1051    if { $zmax > $zmin } {
     1052        incr _dim
     1053    }
     1054    if { $_viewer == "" } {
     1055        if { $_dim == 2 } {
     1056            set _viewer contour
     1057        } else {
     1058            set _viewer isosurface
     1059        }
     1060    }
     1061    set _comp2dims($cname) ${_dim}D
     1062    lappend limits x [list $xmin $xmax]
     1063    lappend limits y [list $ymin $ymax]
     1064    lappend limits z [list $zmin $zmax]
    11751065    set dataAttrs [$dataset GetPointData]
    11761066    if { $dataAttrs == ""} {
    11771067        puts stderr "No point data"
    11781068    }
    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
     1069    set vmin 0
     1070    set vmax 1
     1071    set numArrays [$dataAttrs GetNumberOfArrays]
     1072    if { $numArrays > 0 } {
     1073        set array [$dataAttrs GetArray 0]
     1074        foreach {vmin vmax} [$array GetRange] break
     1075
     1076        for {set i 0} {$i < [$dataAttrs GetNumberOfArrays] } {incr i} {
     1077            set array [$dataAttrs GetArray $i]
     1078            set name  [$dataAttrs GetArrayName $i]
     1079            foreach {min max} [$array GetRange] break
     1080            lappend limits $name [list $min $max]
     1081            lappend _fieldNames $name
     1082            lappend _fieldUnits ""
     1083            lappend _fieldLabels $name
     1084        }
     1085    }
     1086    lappend limits v [list $vmin $vmax]
     1087    set _comp2limits($cname) $limits
    11881088    $reader Delete
    11891089    file delete $tmpfile
    11901090}
    11911091
     1092#
     1093# vtkdata --
     1094#
     1095#       Returns a string representing the mesh and field data for a specific
     1096#       component in the legacy VTK file format.
     1097#
     1098itcl::body Rappture::Field::vtkdata {cname} {
     1099    if {$cname == "component0"} {
     1100        set cname "component"
     1101    }
     1102    # DX: Convert DX to VTK
     1103    if {[info exists _comp2dx($cname)]} {
     1104        return [Rappture::ConvertDxToVtk $_comp2dx($cname)]
     1105    }
     1106    # Unirect3d: isosurface
     1107    if {[info exists _comp2unirect3d($cname)]} {
     1108        return [$_comp2unirect3d($cname) vtkdata]
     1109    }
     1110    # VTK file data:
     1111    if { [info exists _comp2vtk($cname)] } {
     1112        return $_comp2vtk($cname)
     1113    }
     1114    # Points on mesh:  Construct VTK file output.
     1115    if { [info exists _comp2mesh($cname)] } {
     1116        # Data is in the form mesh and vector
     1117        foreach {mesh vector} $_comp2mesh($cname) break
     1118        set label [hints zlabel]
     1119        if { $label == "" } {
     1120            set label $cname
     1121        } else {
     1122            regsub -all { } $label {_} label
     1123        }
     1124        append out "# vtk DataFile Version 3.0\n"
     1125        append out "[hints label]\n"
     1126        append out "ASCII\n"
     1127        append out [$mesh vtkdata]
     1128        append out "POINT_DATA [$vector length]\n"
     1129        append out "SCALARS $label float\n"
     1130        append out "LOOKUP_TABLE default\n"
     1131        append out "[$vector range 0 end]\n"
     1132        return $out
     1133    }
     1134    error "can't find vtkdata for $cname. This method should only be called by the vtkheightmap widget"
     1135}
     1136
     1137#
     1138# BuildPointsOnMesh --
     1139#
     1140#       Parses the field XML description to build a mesh and values vector
     1141#       representing the field.  Right now we handle the deprecated types
     1142#       of "cloud", "unirect2d", and "unirect3d" (mostly for flows).
     1143#
     1144itcl::body Rappture::Field::BuildPointsOnMesh {cname} {
     1145    #
     1146    # More complex 2D/3D data is represented by a mesh
     1147    # object and an associated vector for field values.
     1148    #
     1149    set path [$_field get $cname.mesh]
     1150    if {[$_xmlobj element $path] == ""} {
     1151        # Unknown mesh designated.
     1152        return
     1153    }
     1154    set element [$_xmlobj element -as type $path]
     1155    lappend _fieldNames $cname
     1156    lappend _fieldLabels $cname
     1157    lappend _fieldUnits ""
     1158
     1159    # Handle bizarre cases that hopefully will be deprecated.
     1160    if { $element == "unirect3d" } {
     1161        # Special case: unirect3d (should be deprecated) + flow.
     1162        if { [$_field element $cname.extents] != "" } {
     1163            set extents [$_field get $cname.extents]
     1164        } else {
     1165            set extents 1
     1166        }
     1167        set _dim 3
     1168        set _viewer flowvis
     1169        set _comp2dims($cname) "3D"
     1170        set _comp2unirect3d($cname) \
     1171            [Rappture::Unirect3d \#auto $_xmlobj $_field $cname $extents]
     1172        set _comp2style($cname) [$_field get $cname.style]
     1173        if {[$_field element $cname.flow] != ""} {
     1174            set _comp2flowhints($cname) \
     1175                [Rappture::FlowHints ::\#auto $_field $cname $_units]
     1176        }
     1177        incr _counter
     1178        return
     1179    }
     1180    if { $element == "unirect2d" && [$_field element $cname.flow] != "" } {
     1181        # Special case: unirect2d (normally deprecated) + flow.
     1182        if { [$_field element $cname.extents] != "" } {
     1183            set extents [$_field get $cname.extents]
     1184        } else {
     1185            set extents 1
     1186        }
     1187        set _dim 2
     1188        set _viewer "flowvis"
     1189        set _comp2dims($cname) "2D"
     1190        set _comp2unirect2d($cname) \
     1191            [Rappture::Unirect2d \#auto $_xmlobj $path]
     1192        set _comp2style($cname) [$_field get $cname.style]
     1193        set _comp2flowhints($cname) \
     1194            [Rappture::FlowHints ::\#auto $_field $cname $_units]
     1195        set _values [$_field element $cname.values]
     1196        incr _counter
     1197        return
     1198    }
     1199    set _viewer "contour"
     1200    switch -- $element {
     1201        "cloud" {
     1202            set mesh [Rappture::Cloud::fetch $_xmlobj $path]
     1203        }
     1204        "mesh" {
     1205            set mesh [Rappture::Mesh::fetch $_xmlobj $path]
     1206        }           
     1207        "unirect2d" {
     1208            set mesh [Rappture::Unirect2d::fetch $_xmlobj $path]
     1209            set _viewer "heightmap"
     1210        }
     1211    }
     1212    set _dim [$mesh dimensions]
     1213    if {$_dim == 1} {
     1214        # Is this used anywhere?
     1215        #
     1216        # OOPS!  This is 1D data
     1217        # Forget the cloud/field -- store BLT vectors
     1218        #
     1219        # Is there a natural growth path in generating output from 1D to
     1220        # higher dimensions?  If there isn't, let's kill this in favor
     1221        # or explicitly using a <curve> instead.  Otherwise, the features
     1222        # (methods such as xmarkers) or the <curve> need to be added
     1223        # to the <field>.
     1224        #
     1225        set xv [blt::vector create x$_counter]
     1226        set yv [blt::vector create y$_counter]
     1227       
     1228        $yv set [$mesh points]
     1229        $xv seq 0 1 [$yv length]
     1230        # sort x-coords in increasing order
     1231        $xv sort $yv
     1232       
     1233        set _comp2dims($cname) "1D"
     1234        set _comp2xy($cname) [list $xv $yv]
     1235        incr _counter
     1236        return
     1237    } elseif {$_dim == 2} {
     1238        set _type "heightmap"
     1239        set vector [blt::vector create \#auto]
     1240        $vector set [$_field get $cname.values]
     1241        set _comp2dims($cname) "[$mesh dimensions]D"
     1242        set _comp2mesh($cname) [list $mesh $vector]
     1243        set _comp2style($cname) [$_field get $cname.style]
     1244        incr _counter
     1245        set label [hints zlabel]
     1246        if { $label != "" } {
     1247            set _fieldLabels $label
     1248            set _fieldNames $label
     1249            regsub -all { } $_fieldNames {_} _fieldNames
     1250        }
     1251        set units [hints zunits]
     1252        if { $units != "" } {
     1253            set _fieldUnits $units
     1254        }
     1255        array unset _comp2limits $cname
     1256        lappend _comp2limits($cname) x [$mesh limits x]
     1257        lappend _comp2limits($cname) y [$mesh limits y]
     1258        lappend _comp2limits($cname) $label [$vector limits]
     1259        lappend _comp2limits($cname) v [$vector limits]
     1260        return
     1261    } elseif {$_dim == 3} {
     1262        #
     1263        # 3D data: Store cloud/field as components
     1264        #
     1265        set values [$_field get $cname.values]
     1266        set farray [vtkFloatArray ::vals$_counter]
     1267        foreach v $values {
     1268            if {"" != $_units} {
     1269                set v [Rappture::Units::convert $v \
     1270                           -context $_units -to $_units -units off]
     1271            }
     1272            $farray InsertNextValue $v
     1273        }
     1274        set _viewer "isosurface"
     1275        set _type "isosurface"
     1276        set vector [blt::vector create \#auto]
     1277        $vector set [$_field get $cname.values]
     1278        set _comp2dims($cname) "[$mesh dimensions]D"
     1279        set _comp2mesh($cname) [list $mesh $vector]
     1280        set _comp2style($cname) [$_field get $cname.style]
     1281        incr _counter
     1282        set label [hints zlabel]
     1283        if { $label != "" } {
     1284            set _fieldNames $label
     1285            regsub -all { } $_fieldNames {_} _fieldNames
     1286            set _fieldLabels $label
     1287        }
     1288        set units [hints zunits]
     1289        if { $units != "" } {
     1290            set _fieldUnits $units
     1291        }
     1292        lappend _comp2limits($cname) x [$mesh limits x]
     1293        lappend _comp2limits($cname) y [$mesh limits y]
     1294        lappend _comp2limits($cname) z [$mesh limits z]
     1295        lappend _comp2limits($cname) $label [$vector limits]
     1296        lappend _comp2limits($cname) v [$vector limits]
     1297        return
     1298    }
     1299    error "unhandled case in field"
     1300}
     1301
     1302itcl::body Rappture::Field::AvsToVtk { comp contents } {
     1303    package require vtk
     1304
     1305    set reader $this-datasetreader
     1306    vtkAVSucdReader $reader
     1307
     1308    # Write the contents to a file just in case it's binary.
     1309    set tmpfile file[pid].vtk
     1310    set f [open "$tmpfile" "w"]
     1311    fconfigure $f -translation binary -encoding binary
     1312    puts $f $contents
     1313    close $f
     1314    $reader SetFileName $tmpfile
     1315    $reader Update
     1316    file delete $tmpfile
     1317
     1318    set output [$reader GetOutput]
     1319    set pointData [$output GetPointData]
     1320    set _scalars {}
     1321    for { set i 0 } { $i < [$pointData GetNumberOfArrays] } { incr i } {
     1322        set name [$pointData GetArrayName $i]
     1323        lappend _scalars $name $name "???"
     1324    }
     1325    set writer $this-datasetwriter
     1326    vtkDataSetWriter $writer
     1327    $writer SetInputConnection [$reader GetOutputPort]
     1328    $writer SetFileName $tmpfile
     1329    $writer Write
     1330    rename $reader ""
     1331    rename $writer ""
     1332    set f [open "$tmpfile" "r"]
     1333    fconfigure $f -translation binary -encoding binary
     1334    set vtkdata [read $f]
     1335    close $f
     1336    file delete $tmpfile
     1337    return $vtkdata
     1338}
  • trunk/gui/scripts/field2dresult.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: field2dresult - plot a field in a ResultSet
     
    2122option add *Field2DResult.controlBackground gray widgetDefault
    2223option add *Field2DResult.controlDarkBackground #999999 widgetDefault
    23 option add *Field2DResult.plotBackground black widgetDefault
    24 option add *Field2DResult.plotForeground white widgetDefault
     24option add *Field2DResult.plotBackground white widgetDefault
     25option add *Field2DResult.plotForeground black widgetDefault
    2526option add *Field2DResult.font \
    2627    -*-helvetica-medium-r-normal-*-12-* widgetDefault
     
    3132    itk_option define -mode mode Mode "auto"
    3233
    33     constructor {args} { # defined below }
    34     destructor { # defined below }
     34    constructor {args} {
     35        # defined below
     36    }
     37    destructor {
     38        # defined below
     39    }
    3540
    3641    public method add {dataobj {settings ""}}
     
    3944    public method scale {args}
    4045    public method snap {w h}
    41     public method parameters {title args} { # do nothing }
     46    public method parameters {title args} {
     47        # do nothing
     48    }
    4249    public method download {option args}
    4350}
     
    5865    set servers ""
    5966    switch -- $flags(-mode) {
    60         "auto" - "heightmap" - "flowvis" {
     67        "flowvis" {
    6168            set servers [Rappture::VisViewer::GetServerList "nanovis"]
    6269        }
    63         "vtkcontour" - "vtkheightmap" - "vtkstreamlines" - "vtkviewer" {
     70        "auto" - "contour" - "heightmap" - "streamlines" - "vtkviewer" {
    6471            set servers [Rappture::VisViewer::GetServerList "vtkvis"]
    6572        }
     
    7380    if {"" != $servers && $flags(-mode) != "vtk"} {
    7481        switch -- $flags(-mode) {
    75             "auto" - "heightmap" {
     82            "contour" - "heightmap" {
    7683                itk_component add renderer {
    77                     Rappture::HeightmapViewer $itk_interior.ren $servers
     84                    Rappture::VtkHeightmapViewer $itk_interior.heightmap \
     85                        $servers -mode $flags(-mode)
    7886                }
    7987            }
    8088            "flowvis" {
    8189                itk_component add renderer {
    82                     Rappture::FlowvisViewer $itk_interior.ren $servers
     90                    Rappture::FlowvisViewer $itk_interior.flow $servers
    8391                }
    8492            }
    85             "vtkcontour" {
     93            "streamlines" {
    8694                itk_component add renderer {
    87                     Rappture::VtkContourViewer $itk_interior.ren $servers
    88                 }
    89             }
    90             "vtkheightmap" {
    91                 itk_component add renderer {
    92                     Rappture::VtkHeightmapViewer $itk_interior.ren $servers
    93                 }
    94             }
    95             "vtkstreamlines" {
    96                 itk_component add renderer {
    97                     Rappture::VtkStreamlinesViewer $itk_interior.ren $servers
     95                    Rappture::VtkStreamlinesViewer $itk_interior.streamlines \
     96                        $servers
    9897                }
    9998            }
    10099            "vtkviewer" {
    101100                itk_component add renderer {
    102                     Rappture::VtkViewer $itk_interior.ren $servers
     101                    Rappture::VtkViewer $itk_interior.viewer $servers
    103102                }
    104103            }
     
    113112        }
    114113    }
    115 
    116114    if {![info exists itk_component(renderer)]} {
    117115        itk_component add renderer {
    118             Rappture::ContourResult $itk_interior.ren
     116            Rappture::ContourResult $itk_interior.oldcontour
    119117        }
    120118        pack $itk_component(renderer) -expand yes -fill both
    121119    }
    122120    eval itk_initialize $args
     121    update
    123122}
    124123
  • trunk/gui/scripts/field3dresult.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: field3dresult - plot a field in a ResultSet
     
    5455        -mode auto
    5556    }
    56     array set flags $args
    57     switch -- $flags(-mode) {
     57    array set flags $args 
     58   switch -- $flags(-mode) {
    5859        "auto" - "nanovis" - "flowvis" {
    5960            set servers [Rappture::VisViewer::GetServerList "nanovis"]
    6061        }
    61         "vtkcontour" - "vtkheightmap" - "vtkstreamlines" - "vtkviewer" - "vtkvolume" {
     62        "isosurface" - "heightmap" - "streamlines" - "vtkviewer" - "vtkvolume" {
    6263            set servers [Rappture::VisViewer::GetServerList "vtkvis"]
    6364        }
     
    8283                }
    8384            }
    84             "vtkcontour" {
    85                 itk_component add renderer {
    86                     Rappture::VtkContourViewer $itk_interior.ren $servers
    87                 }
    88             }
    89             "vtkheightmap" {
     85            "contour" - "heightmap" {
    9086                itk_component add renderer {
    9187                    Rappture::VtkHeightmapViewer $itk_interior.ren $servers
    9288                }
    9389            }
    94             "vtkstreamlines" {
     90            "isosurface" {
     91                itk_component add renderer {
     92                    Rappture::VtkIsosurfaceViewer $itk_interior.ren $servers
     93                }
     94            }
     95            "streamlines" {
    9596                itk_component add renderer {
    9697                    Rappture::VtkStreamlinesViewer $itk_interior.ren $servers
     
    125126        pack $itk_component(renderer) -expand yes -fill both
    126127    }
    127 
    128128    eval itk_initialize $args
    129129}
  • trunk/gui/scripts/filexfer.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: filexfer - support for file transfer with user's desktop
  • trunk/gui/scripts/flowdial.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: Flowdial - selector, like the dial on a flow
  • trunk/gui/scripts/flowhints.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
  • trunk/gui/scripts/flowspeed.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
  • trunk/gui/scripts/flowvisviewer.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: flowvisviewer - 3D flow rendering
  • trunk/gui/scripts/gauge.tcl

    r3186 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: gauge - compact readout for real values
  • trunk/gui/scripts/getopts.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
  • trunk/gui/scripts/grab.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: grab - improved version of the Tk grab command
  • trunk/gui/scripts/groupentry.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: GroupEntry - widget containing a group of controls
  • trunk/gui/scripts/histogram.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12 
    23# ----------------------------------------------------------------------
  • trunk/gui/scripts/histogramresult.tcl

    r3186 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
  • trunk/gui/scripts/htmlviewer.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: htmlviewer - easy way to display HTML text
  • trunk/gui/scripts/icons.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: icons - utility for loading icons from a library
  • trunk/gui/scripts/image.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: image - represents a picture image
  • trunk/gui/scripts/imageentry.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: ImageEntry - widget for displaying images
  • trunk/gui/scripts/imageresult.tcl

    r3186 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: imageresult - picture image in a ResultSet
  • trunk/gui/scripts/integerentry.tcl

    r3186 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: IntegerEntry - widget for entering integer values
  • trunk/gui/scripts/isomarker.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
  • trunk/gui/scripts/loader.tcl

    r3186 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: loader - widget for loading examples and old runs
  • trunk/gui/scripts/logger.tcl

    r3187 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: logger - log user activities within the Rappture program
  • trunk/gui/scripts/main.tcl

    r3187 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12#!/bin/sh
    23# ----------------------------------------------------------------------
  • trunk/gui/scripts/mainwin.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: mainwin - main application window for Rappture
  • trunk/gui/scripts/mesh.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
     2
    13# ----------------------------------------------------------------------
    24#  COMPONENT: mesh - represents a structured mesh for a device
     
    1618package require Itcl
    1719
    18 namespace eval Rappture { # forward declaration }
     20namespace eval Rappture {
     21    # forward declaration
     22}
    1923
    2024itcl::class Rappture::Mesh {
    21     constructor {xmlobj path} { # defined below }
    22     destructor { # defined below }
    23 
     25    private variable _xmlobj ""  ;      # Ref to XML obj with device data
     26    private variable _mesh ""    ;      # Lib obj representing this mesh
     27    private variable _dim       0;      # Dimension of mesh (1, 2, or 3)
     28    private variable _type "";          # Indicates the type of mesh.
     29    private variable _units "m m m" ;   # System of units for x, y, z
     30    private variable _limits        ;   # Array of mesh limits. Keys are
     31                                        # xmin, xmax, ymin, ymax, ...
     32    private variable _numPoints 0   ;   # # of points in mesh
     33    private variable _numCells 0   ;    # # of cells in mesh
     34    private variable _vtkdata "";       # Mesh in vtk file format.
     35    constructor {xmlobj path} {
     36        # defined below
     37    }
     38    destructor {
     39        # defined below
     40    }
    2441    public method points {}
    2542    public method elements {}
    26     public method mesh {}
     43    public method mesh {{-type "vtk"}}
    2744    public method size {{what -points}}
    2845    public method dimensions {}
     
    3249    public proc fetch {xmlobj path}
    3350    public proc release {obj}
    34 
    35     private method _buildNodesElements {xmlobj path}
    36     private method _buildRectMesh {xmlobj path}
    37     private method _getVtkElement {npts}
    38 
    39     private variable _xmlobj ""  ;# ref to XML obj with device data
    40     private variable _mesh ""    ;# lib obj representing this mesh
    41     private variable _pts2elem   ;# maps # points => vtk element
    42 
    43     private variable _units "m m m" ;# system of units for x, y, z
    44     private variable _limits        ;# limits xmin, xmax, ymin, ymax, ...
    45     private variable _pdata ""      ;# name of vtkPointData object
    46     private variable _gdata ""      ;# name of vtkDataSet object
    47 
    48     private common _xp2obj       ;# used for fetch/release ref counting
    49     private common _obj2ref      ;# used for fetch/release ref counting
     51    public method vtkdata {}
     52    public method type {} {
     53        return $_type
     54    }
     55    public method numpoints {} {
     56        return $_numPoints
     57    }
     58
     59    private method ReadNodesElements {xmlobj path}
     60
     61    private variable _points ""      ;  # name of vtkPointData object
     62
     63    private common _xp2obj       ;      # used for fetch/release ref counting
     64    private common _obj2ref      ;      # used for fetch/release ref counting
     65    private variable _isValid 0
     66    private variable _vtkoutput ""
     67    private variable _vtkreader ""
     68    private variable _vtkpoints ""
     69    private variable _vtkgrid   ""
     70    private variable _xv        ""
     71    private variable _yv        ""
     72    private variable _zv        ""
     73    private variable _xCoords   "";     # For the blt contour only
     74    private variable _yCoords   "";     # For the blt contour only
     75   
     76    private method GetDimension {}
     77    private method GetDouble { path }
     78    private method GetInt { path }
     79    private method ReadCells { xmlobj path }
     80    private method ReadCloud { xmlobj path }
     81    private method ReadGrid { xmlobj path }
     82    private method ReadTriangles { xmlobj path }
     83    private method ReadVtk { xmlobj path }
     84    private method ReadUnstructuredGrid { xmlobj path }
    5085}
    5186
     
    65100        return $obj
    66101    }
    67 
    68102    set obj [Rappture::Mesh ::#auto $xmlobj $path]
    69103    set _xp2obj($handle) $obj
     
    108142    set _mesh [$xmlobj element -as object $path]
    109143
     144    # Initialize mesh bounds to empty
     145    foreach axis {x y z} {
     146        set _limits($axis) ""
     147    }
     148    GetDimension
    110149    set u [$_mesh get units]
    111150    if {"" != $u} {
     
    116155    }
    117156
    118     foreach lim {xmin xmax ymin ymax zmin zmax} {
    119         set _limits($lim) ""
    120     }
    121 
    122     if {[$_mesh element vtk] != ""} {
    123         _buildRectMesh $xmlobj $path
    124     } elseif {[$_mesh element node] != "" && [$_mesh element element] != ""} {
    125         _buildNodesElements $xmlobj $path
    126     } else {
    127         error "can't find mesh data in $path"
     157    # Meshes comes in a variety of flavors
     158    #
     159    # Dimensionality is determined from the <dimension> tag. 
     160    #
     161    # <vtk> described mesh
     162    # <element> +  <node> definitions
     163    # <cloud>           x,y coordinates or x,y,z coordinates
     164    # <grid>            rectangular mesh
     165    # <triangles>       triangular mesh
     166    # <cells>           homogeneous cell type mesh.
     167    # <unstructured_grid> homogeneous cell type mesh.
     168    #
     169
     170    # Check that only one mesh type was defined.
     171    set subcount 0
     172    foreach cname [$_mesh children] {
     173        foreach type { vtk cloud grid triangles cells unstructured_grid} {
     174            if { $cname == $type } {
     175                incr subcount
     176                break
     177            }
     178        }
     179    }
     180    set elemcount 0
     181    foreach cname [$_mesh children] {
     182        foreach type { node element } {
     183            if { $cname == $type } {
     184                incr elemcount
     185                break
     186            }
     187        }
     188    }
     189    if { $elemcount > 0 } {
     190        incr $subcount
     191    }
     192    if { $subcount > 1 } {
     193        puts stderr "too many mesh types specified: picking first found."
     194    }
     195    if { [$_mesh element "vtk"] != ""} {
     196        ReadVtk $xmlobj $path
     197    } elseif { [$_mesh element "cloud"] != "" } {
     198        ReadCloud $xmlobj $path
     199    } elseif {[$_mesh element "grid"] != "" } {
     200        ReadGrid $xmlobj $path
     201    } elseif {[$_mesh element "triangles"] != "" } {
     202        ReadTriangles $xmlobj $path
     203    } elseif {[$_mesh element "cells"] != "" } {
     204        ReadCells $xmlobj $path
     205    } elseif {[$_mesh element "unstructured_grid"] != "" } {
     206        ReadUnstructuredGrid $xmlobj $path
     207    } elseif {[$_mesh element "node"] != "" && [$_mesh element "element"]!=""} {
     208        ReadNodesElements $xmlobj $path
    128209    }
    129210}
     
    136217    itcl::delete object $_mesh
    137218
    138     catch {rename $this-points ""}
    139     catch {rename $this-grid ""}
    140     catch {rename $this-dset ""}
    141 
    142     foreach type [array names _pts2elem] {
    143         rename $_pts2elem($type) ""
    144     }
     219    if { $_xCoords != "" } {
     220        blt::vector destroy $_xCoords
     221    }
     222    if { $_yCoords != "" } {
     223        blt::vector destroy $_yCoords
     224    }
     225    if { $_vtkoutput != "" } {
     226        rename $_vtkoutput ""
     227    }
     228    if { $_vtkreader != "" } {
     229        rename $_vtkreader ""
     230    }
     231    if { $_points != "" } {
     232        rename $_points ""
     233    }
     234}
     235
     236#
     237# vtkdata --
     238#
     239#       This is called by the field object to generate a VTK file to send to
     240#       the remote render server.  Returns the vtkDataSet object containing
     241#       (at this point) just the mesh.  The field object doesn't know (or
     242#       care) what type of mesh is used.  The field object will add field
     243#       arrays before generating output to send to the remote render server.
     244#
     245itcl::body Rappture::Mesh::vtkdata {} {
     246    return $_vtkdata
    145247}
    146248
     
    151253# ----------------------------------------------------------------------
    152254itcl::body Rappture::Mesh::points {} {
    153     return $_pdata
     255    return $_points
    154256}
    155257
     
    200302# Returns the vtk object representing the mesh.
    201303# ----------------------------------------------------------------------
    202 itcl::body Rappture::Mesh::mesh {} {
    203     return $_gdata
     304itcl::body Rappture::Mesh::mesh { {type "vtk"} } {
     305    switch $type {
     306        "vtk" {
     307            return $_vtkgrid
     308        }
     309        default {
     310            error "Requested mesh type \"$type\" is unknown."
     311        }
     312    }
    204313}
    205314
     
    212321    switch -- $what {
    213322        -points {
    214             return [$_pdata GetNumberOfPoints]
     323            return $_numPoints
    215324        }
    216325        -elements {
    217             return [$_gdata GetNumberOfCells]
     326            return $_numCells
    218327        }
    219328        default {
     
    229338# ----------------------------------------------------------------------
    230339itcl::body Rappture::Mesh::dimensions {} {
    231     # count the dimensions with real limits
    232     set dims 0
    233     foreach d {x y z} {
    234         if {$_limits(${d}min) != $_limits(${d}max)} {
    235             incr dims
    236         }
    237     }
    238     return $dims
     340    return $_dim
    239341}
    240342
     
    242344# USAGE: limits x|y|z
    243345#
    244 # Returns the {min max} values for the limits of the specified axis.
    245 # ----------------------------------------------------------------------
    246 itcl::body Rappture::Mesh::limits {which} {
    247     if {![info exists _limits(${which}min)]} {
     346# Returns the {min max} coords for the limits of the specified axis.
     347# ----------------------------------------------------------------------
     348itcl::body Rappture::Mesh::limits {axis} {
     349    if {![info exists _limits($axis)]} {
    248350        error "bad axis \"$which\": should be x, y, z"
    249351    }
    250     return [list $_limits(${which}min) $_limits(${which}max)]
     352    return $_limits($axis)
    251353}
    252354
     
    275377}
    276378
    277 # ----------------------------------------------------------------------
    278 # USAGE: _buildNodesElements <xmlobj> <path>
     379itcl::body Rappture::Mesh::GetDimension {} {
     380    set string [$_xmlobj get dimension]
     381    if { [scan $string "%d" _dim] != 1 } {
     382        set _dim -1
     383        return
     384    }
     385    if { $_dim < 1 || $_dim > 4 } {
     386        error "bad dimension in mesh"
     387    } 
     388}
     389
     390itcl::body Rappture::Mesh::GetDouble { path } {
     391    set string [$_xmlobj get $path]
     392    if { [scan $string "%g" value] != 1 } {
     393        puts stderr "can't get double value \"$string\" of \"$path\""
     394        return 0.0
     395    }
     396    return $value
     397}
     398
     399itcl::body Rappture::Mesh::GetInt { path } {
     400    set string [$_xmlobj get $path]
     401    if { [scan $string "%d" value] != 1 } {
     402        puts stderr "can't get integer value \"$string\" of \"$path\""
     403        return 0.0
     404    }
     405    return $value
     406}
     407
     408itcl::body Rappture::Mesh::ReadCloud { xmlobj path } {
     409    set _type "cloud"
     410    set data [$xmlobj get $path.cloud.points]
     411    Rappture::ReadPoints $data _dim coords
     412       
     413    set all [blt::vector create \#auto]
     414    $all set $coords
     415    set xv [blt::vector create \#auto]
     416    set yv [blt::vector create \#auto]
     417    set zv [blt::vector create \#auto]
     418    if { $_dim == 2 } {
     419        $all split $xv $yv
     420        $zv seq 0 0 [$xv length]
     421    } elseif { $_dim == 3 } {
     422        $all split $xv $yv $zv
     423    } else {
     424        error "invalid dimension \"$_dim\" of cloud mesh"
     425    }
     426    set _numPoints [$xv length]
     427    if { $_dim == 2 } {
     428        append out "DATASET POLYDATA\n"
     429        append out "POINTS $_numPoints float\n"
     430        foreach x [$xv range 0 end] y [$yv range 0 end]  {
     431            append out "$x $y 0\n"
     432        }
     433        set _vtkdata $out
     434        foreach axis {x y} {
     435            set vector [set ${axis}v]
     436            set _limits($axis) [$vector limits]
     437        }
     438    } elseif { $_dim == 3 } {
     439        append out "DATASET POLYDATA\n"
     440        append out "POINTS $_numPoints float\n"
     441        foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
     442            append out "$x $y $z\n"
     443        }
     444        set _vtkdata $out
     445        foreach axis {x y z} {
     446            set vector [set ${axis}v]
     447            set _limits($axis) [$vector limits]
     448        }
     449    }
     450    blt::vector destroy $xv $yv $zv $all
     451}
     452
     453itcl::body Rappture::Mesh::ReadVtk { xmlobj path } {
     454    set _type "vtk"
     455
     456    # Create a VTK file with the mesh in it. 
     457    set _vtkdata [$xmlobj get $path.vtk]
     458    append out "# vtk DataFile Version 3.0\n"
     459    append out "mesh\n"
     460    append out "ASCII\n"
     461    append out "$_vtkdata\n"
     462
     463    # Write the contents to a file just in case it's binary.
     464    set tmpfile file[pid].vtk
     465    set f [open "$tmpfile" "w"]
     466    fconfigure $f -translation binary -encoding binary
     467    puts $f $out
     468    close $f
     469
     470    # Read the data back into a vtk dataset and query the bounds.
     471    set reader $this-datasetreader
     472    vtkDataSetReader $reader
     473    $reader SetFileName $tmpfile
     474    $reader Update
     475    set output [$reader GetOutput]
     476    foreach { xmin xmax ymin ymax zmin zmax } [$output GetBounds] break
     477    set _dim 3;                         # Hard coding all vtk meshes to 3D?
     478    set _limits(x) [list $xmin $xmax]
     479    set _limits(y) [list $ymin $ymax]
     480    set _limits(z) [list $zmin $zmax]
     481    if { $zmin >= $zmax } {
     482        set _dim 2
     483    }
     484    file delete $tmpfile
     485    rename $output ""
     486    rename $reader ""
     487    set _isValid 1
     488}
     489
     490itcl::body Rappture::Mesh::ReadGrid { xmlobj path } {
     491    set _type "grid"
     492    set numUniform 0
     493    set numRectilinear 0
     494    set numCurvilinear 0
     495    foreach axis { x y z } {
     496        set min    [$xmlobj get "$path.grid.${axis}axis.min"]
     497        set max    [$xmlobj get "$path.grid.${axis}axis.max"]
     498        set num    [$xmlobj get "$path.grid.${axis}axis.numpoints"]
     499        set coords [$xmlobj get "$path.grid.${axis}coords"]
     500        set dim    [$xmlobj get "$path.grid.${axis}dim"]
     501        if { $min != "" && $max != "" && $num != "" && $num > 0 } {
     502            set ${axis}Min $min
     503            set ${axis}Max $max
     504            set ${axis}Num $num
     505            incr numUniform
     506        } elseif { $coords != "" } {
     507            incr numRectilinear
     508            set ${axis}Coords $coords
     509        } elseif { $dim != "" } {
     510            set ${axis}Num $dim
     511            incr numCurvilinear
     512        }
     513    }
     514    set _dim [expr $numRectilinear + $numUniform + $numCurvilinear]
     515    if { $_dim == 0 } {
     516        # No data found.
     517        return 0
     518    }
     519    if { $numCurvilinear > 0 } {
     520        # This is the 2D/3D curilinear case. We found <xdim>, <ydim>, or <zdim>
     521        if { $numRectilinear > 0 || $numUniform > 0 } {
     522            error "can't mix curvilinear and rectilinear grids."
     523        }
     524        if { $numCurvilinear < 2 } {
     525            error "curvilinear grid must be 2D or 3D."
     526        }
     527        set points [$xmlobj get $path.grid.points]
     528        if { $points == "" } {
     529            error "missing <points> from grid description."
     530        }
     531        if { ![info exists xNum] || ![info exists yNum] } {
     532            error "invalid dimensions for curvilinear grid: missing <xdim> or <ydim> from grid description."
     533        }
     534        set all [blt::vector create \#auto]
     535        set xv [blt::vector create \#auto]
     536        set yv [blt::vector create \#auto]
     537        set zv [blt::vector create \#auto]
     538        $all set $points
     539        set numCoords [$all length]
     540        if { [info exists zNum] } {
     541            set _dim 3
     542            set _numPoints [expr $xNum * $yNum * $zNum]
     543            $all set $points
     544            if { ($_numPoints*3) != $numCoords } {
     545                error "invalid grid: \# of points does not match dimensions <xdim> * <ydim>"
     546            }
     547            if { ($numCoords % 3) != 0 } {
     548                error "wrong \# of coordinates for 3D grid"
     549            }
     550            $all split $xv $yv $zv
     551            foreach axis {x y z} {
     552                set vector [set ${axis}v]
     553                set _limits($axis) [$vector limits]
     554            }
     555            append out "DATASET STRUCTURED_GRID\n"
     556            append out "DIMENSIONS $xNum $yNum $zNum\n"
     557            append out "POINTS $_numPoints double\n"
     558            append out [$all range 0 end]
     559            append out "\n"
     560            set _vtkdata $out
     561        } else {
     562            set _dim 2
     563            set _numPoints [expr $xNum * $yNum]
     564            if { ($_numPoints*2) != $numCoords } {
     565                error "invalid grid: \# of points does not match dimensions <xdim> * <ydim> * <zdim>"
     566            }
     567            if { ($numCoords % 2) != 0 } {
     568                error "wrong \# of coordinates for 2D grid"
     569            }
     570            foreach axis {x y} {
     571                set vector [set ${axis}v]
     572                set _limits($axis) [$vector limits]
     573            }
     574            $zv seq 0 0 [$xv length]
     575            $all merge $xv $yv $zv
     576            append out "DATASET STRUCTURED_GRID\n"
     577            append out "DIMENSIONS $xNum $yNum 1\n"
     578            append out "POINTS $_numPoints double\n"
     579            append out [$all range 0 end]
     580            append out "\n"
     581            set _vtkdata $out
     582        }
     583        blt::vector destroy $all $xv $yv $zv
     584        set _isValid 1
     585        return 1
     586    }
     587    if { $numRectilinear == 0 && $numUniform > 0} {
     588        # This is the special case where all axes 2D/3D are uniform. 
     589        # This results in a STRUCTURE_POINTS
     590        if { $_dim == 2 } {
     591            set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
     592            set ySpace [expr ($yMax - $yMin) / double($yNum - 1)]
     593            set _numPoints [expr $xNum * $yNum]
     594            append out "DATASET STRUCTURED_POINTS\n"
     595            append out "DIMENSIONS $xNum $yNum 1\n"
     596            append out "SPACING $xSpace $ySpace 0\n"
     597            append out "ORIGIN 0 0 0\n"
     598            set _vtkdata $out
     599            foreach axis {x y} {
     600                set _limits($axis) [list [set ${axis}Min] [set ${axis}Max]]
     601            }
     602        } elseif { $_dim == 3 } {
     603            set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
     604            set ySpace [expr ($yMax - $yMin) / double($yNum - 1)]
     605            set zSpace [expr ($zMax - $zMin) / double($zNum - 1)]
     606            set _numPoints [expr $xNum * $yNum * zNum]
     607            append out "DATASET STRUCTURED_POINTS\n"
     608            append out "DIMENSIONS $xNum $yNum $zNum\n"
     609            append out "SPACING $xSpace $ySpace $zSpace\n"
     610            append out "ORIGIN 0 0 0\n"
     611            set _vtkdata $out
     612            foreach axis {x y z} {
     613                set _limits($axis) [list [set ${axis}Min] [set ${axis}Max]]
     614            }
     615        } else {
     616            error "bad dimension of mesh \"$_dim\""
     617        }
     618        set _isValid 1
     619        return 1
     620    }
     621    # This is the hybrid case.  Some axes are uniform, others are nonuniform.
     622    set xv [blt::vector create \#auto]
     623    if { [info exists xMin] } {
     624        $xv seq $xMin $xMax $xNum
     625    } else {
     626        $xv set [$xmlobj get $path.grid.xcoords]
     627        set xMin [$xv min]
     628        set xMax [$xv max]
     629        set xNum [$xv length]
     630    }
     631    set yv [blt::vector create \#auto]
     632    if { [info exists yMin] } {
     633        $yv seq $yMin $yMax $yNum
     634    } else {
     635        $yv set [$xmlobj get $path.grid.ycoords]
     636        set yMin [$yv min]
     637        set yMax [$yv max]
     638        set yNum [$yv length]
     639    }
     640    set zv [blt::vector create \#auto]
     641    if { $_dim == 3 } {
     642        if { [info exists zMin] } {
     643            $zv seq $zMin $zMax $zNum
     644        }  else {
     645            $zv set [$xmlobj get $path.grid.zcoords]
     646            set zMin [$zv min]
     647            set zMax [$zv max]
     648            set zNum [$zv length]
     649        }
     650    } else {
     651        set zNum 1
     652    }
     653    if { $_dim == 3 } {
     654        set _numPoints [expr $xNum * $yNum * $zNum]
     655        append out "DATASET RECTILINEAR_GRID\n"
     656        append out "DIMENSIONS $xNum $yNum $zNum\n"
     657        append out "X_COORDINATES $xNum double\n"
     658        append out [$xv range 0 end]
     659        append out "\n"
     660        append out "Y_COORDINATES $yNum double\n"
     661        append out [$yv range 0 end]
     662        append out "\n"
     663        append out "Z_COORDINATES $zNum double\n"
     664        append out [$zv range 0 end]
     665        append out "\n"
     666        set _vtkdata $out
     667        foreach axis {x y z} {
     668            if { [info exists ${axis}Min] } {
     669                set _limits($axis) [list [set ${axis}Min] [set ${axis}Max]]
     670            }
     671        }
     672    } elseif { $_dim == 2 } {
     673        set _numPoints [expr $xNum * $yNum]
     674        append out "DATASET RECTILINEAR_GRID\n"
     675        append out "DIMENSIONS $xNum $yNum 1\n"
     676        append out "X_COORDINATES $xNum double\n"
     677        append out [$xv range 0 end]
     678        append out "\n"
     679        append out "Y_COORDINATES $yNum double\n"
     680        append out [$yv range 0 end]
     681        append out "\n"
     682        append out "Z_COORDINATES 1 double\n"
     683        append out "0\n"
     684        foreach axis {x y} {
     685            if { [info exists ${axis}Min] } {
     686                set _limits($axis) [list [set ${axis}Min] [set ${axis}Max]]
     687            }
     688        }
     689        set _vtkdata $out
     690    } else {
     691        error "invalid dimension of grid \"$_dim\""
     692    }
     693    blt::vector destroy $xv $yv $zv
     694    set _isValid 1
     695    return 1
     696}
     697
     698itcl::body Rappture::Mesh::ReadCells { xmlobj path } {
     699    set _type "cells"
     700
     701    set data [$xmlobj get $path.cells.points]
     702    Rappture::ReadPoints $data _dim points
     703    if { $points == "" } {
     704        puts stderr "no <points> found for <cells> mesh"
     705        return 0
     706    }
     707    array set celltype2vertices {
     708        triangles 3
     709        quads    4
     710        tetraheadrons 4
     711        voxels 8
     712        hexaheadrons 8
     713        wedges 6
     714        pyramids 5
     715    }
     716    array set celltype2vtkid {
     717        triangles 5
     718        quads    9
     719        tetraheadrons 10
     720        voxels 11
     721        hexaheadrons 12
     722        wedges 13
     723        pyramids 14
     724    }
     725    set count 0
     726
     727    # Try to detect the celltype used.  There should be a single XML tag
     728    # containing all the cells defined.  It's an error if there's more than
     729    # one of these, or if there isn't one. 
     730    foreach type {
     731        triangles quads tetraheadrons voxels hexaheadrons wedges pyramids }  {
     732        if { [$xmlobj get $path.cells.$type] != "" } {
     733            set celltype $type
     734            incr count
     735        }
     736    }
     737    if { $count == 0 } {
     738        puts stderr "no cell types found"
     739        return 0
     740    }
     741    if { $count > 1 } {
     742        puts stderr "too many cell types tags found"
     743        return 0
     744    }
     745    set cells [$xmlobj get $path.cells.$celltype]
     746    if { $cells == "" } {
     747        puts stderr "no data for celltype \"$celltype\""
     748        return 0
     749    }
     750    # Get the number of vertices for each cell and the corresponding VTK id.
     751    set numVertices $celltype2vertices($celltype)
     752    set vtkid       $celltype2vtkid($celltype)
     753   
     754    if { $_dim == 2 } {
     755        # Load the points into one big vector, then split out the x and y
     756        # coordinates.
     757        set all [blt::vector create \#auto]
     758        $all set $points
     759        set xv [blt::vector create \#auto]
     760        set yv [blt::vector create \#auto]
     761        $all split $xv $yv
     762        set _numPoints [$xv length]
     763
     764        set data {}
     765        set _numCells 0
     766        set celltypes {}
     767        # Build cell information.  Look line by line.  Most cell types
     768        # have a specific number of vertices, but there are a few that
     769        # have a variable number of vertices.
     770        foreach line [split $cells \n] {
     771            set numVerticies [llength $line]
     772            if { $numVerticies == 0 } {
     773                continue;               # Skip blank lines
     774            }
     775            append data "    $numVertices $line\n"
     776            append celltypes "$vtkid\n"
     777            incr _numCells
     778        }
     779        append out "DATASET UNSTRUCTURED_GRID\n"
     780        append out "POINTS $_numPoints float\n"
     781        foreach x [$xv range 0 end] y [$yv range 0 end] {
     782            append out "    $x $y 0\n"
     783        }
     784        append out "CELLS $_numCells [expr $_numCells * ($numVertices + 1)]\n"
     785        append out $data
     786        append out "CELL_TYPES $_numCells\n"
     787        append out $celltypes
     788        set _limits(x) [$xv limits]
     789        set _limits(y) [$yv limits]
     790        blt::vector destroy $xv $yv $all
     791    } else {
     792        # Load the points into one big vector, then split out the x, y, and z
     793        # coordinates.
     794        set all [blt::vector create \#auto]
     795        $all set $points
     796        set xv [blt::vector create \#auto]
     797        set yv [blt::vector create \#auto]
     798        set zv [blt::vector create \#auto]
     799        $all split $xv $yv $zv
     800        set _numPoints [$xv length]
     801
     802        set data {}
     803        set _numCells 0
     804        set celltypes {}
     805        # Build cell information.  Look line by line.  Most cell types
     806        # have a specific number of vertices, but there are a few that
     807        # have a variable number of vertices.
     808        foreach line [split $cells \n] {
     809            set numVerticies [llength $line]
     810            if { $numVerticies == 0 } {
     811                continue;               # Skip blank lines
     812            }
     813            append data "    $numVertices $line\n"
     814            append celltypes "$vtkid\n"
     815            incr _numCells
     816        }
     817        append out "DATASET UNSTRUCTURED_GRID\n"
     818        append out "POINTS $_numPoints float\n"
     819        foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
     820            append out "    $x $y $z\n"
     821        }
     822        append out "CELLS $_numCells [expr $_numCells * ($numVerticies + 1)]\n"
     823        append out $data
     824        append out "CELL_TYPES $_numCells\n"
     825        append out $celltypes
     826        set _limits(x) [$xv limits]
     827        set _limits(y) [$yv limits]
     828        set _limits(z) [$zv limits]
     829        blt::vector destroy $xv $yv $zv $all
     830    }
     831    set _vtkdata $out
     832    set _isValid 1
     833}
     834
     835
     836itcl::body Rappture::Mesh::ReadTriangles { xmlobj path } {
     837    set _type "triangles"
     838    set _dim 2
     839    set triangles [$xmlobj get $path.triangles.indices]
     840    if { $triangles == "" } {
     841        puts stderr "no triangle indices specified in mesh"
     842        return 0
     843    }
     844    set xcoords [$xmlobj get $path.triangles.xcoords]
     845    set ycoords [$xmlobj get $path.triangles.ycoords]
     846    set points [$xmlobj get $path.triangles.points]
     847    set xv [blt::vector create \#auto]
     848    set yv [blt::vector create \#auto]
     849    if { $xcoords != "" && $ycoords != "" } {
     850        $xv set $xcoords
     851        $yx set $ycoords
     852    } elseif { $points != "" } {
     853        set all [blt::vector create \#auto]
     854        $all set $points
     855        $all split $xv $yv
     856    } else {
     857        puts stderr "missing either <xcoords>, <ycoords>, or <points> for triangular mesh"
     858        return 0
     859    }
     860    set _numPoints [$xv length]
     861    set count 0
     862    set data {}
     863    foreach { a b c } $triangles {
     864        append data "    3 $a $b $c\n"
     865        incr count
     866    }
     867    set celltypes {}
     868    for { set i 0 } { $i < $count } { incr i } {
     869        append celltypes "5\n"
     870    }
     871    append out "DATASET UNSTRUCTURED_GRID\n"
     872    append out "POINTS $_numPoints float\n"
     873    foreach x [$xv range 0 end] y [$yv range 0 end] {
     874        append out "    $x $y 0\n"
     875    }
     876    append out "CELLS $count [expr $count * 4]\n"
     877    append out $data
     878    append out "CELL_TYPES $count\n"
     879    append out $celltypes
     880    set _limits(x) [$xv limits]
     881    set _limits(y) [$yv limits]
     882    set _vtkdata $out
     883    set _isValid 1
     884}
     885
     886itcl::body Rappture::Mesh::ReadUnstructuredGrid { xmlobj path } {
     887    set _type "unstructured_grid"
     888
     889    set data [$xmlobj get $path.unstructured_grid.points]
     890    Rappture::ReadPoints $data _dim points
     891    if { $points == "" } {
     892        puts stderr "no <points> found for <cells> mesh"
     893        return 0
     894    }
     895    set cells [$xmlobj get $path.unstructured_grid.cells]
     896    if { $cells == "" } {
     897        puts stderr "no <cells> description found unstructured_grid"
     898        return 0
     899    }
     900    set celltypes [$xmlobj get $path.unstructured_grid.celltypes]
     901    if { $cells == "" } {
     902        puts stderr "no <cells> description found unstructured_grid."
     903        return 0
     904    }
     905    set lines [split $cells \n]
     906   
     907    set all [blt::vector create \#auto]
     908    set xv [blt::vector create \#auto]
     909    set yv [blt::vector create \#auto]
     910    set zv [blt::vector create \#auto]
     911    $all set $points
     912    if { $_dim == 2 } {
     913        # Load the points into one big vector, then split out the x and y
     914        # coordinates.
     915        $all split $xv $yv
     916        set _numPoints [$xv length]
     917
     918        set data {}
     919        set count 0
     920        set _numCells 0
     921        foreach line $lines {
     922            set length [llength $line]
     923            if { $length == 0 } {
     924                continue
     925            }
     926            set celltype [lindex $celltypes $_numCells]
     927            if { $celltype == "" } {
     928                puts stderr "can't find celltype for line \"$line\""
     929                return 0
     930            }
     931            append data " $line\n"
     932            incr count $length
     933            incr _numCells
     934        }
     935        append out "DATASET UNSTRUCTURED_GRID\n"
     936        append out "POINTS $_numPoints float\n"
     937        $zv seq 0 0 [$xv length];       # Make an all zeroes vector.
     938        $all merge $xv $yv $zv
     939        append out [$all range 0 end]
     940        append out "CELLS $_numCells $count\n"
     941        append out $data
     942        append out "CELL_TYPES $_numCells\n"
     943        append out $celltypes
     944        set _limits(x) [$xv limits]
     945        set _limits(y) [$yv limits]
     946    } else {
     947        # Load the points into one big vector, then split out the x, y, and z
     948        # coordinates.
     949        $all split $xv $yv $zv
     950        set _numPoints [$xv length]
     951
     952        set data {}
     953        set count 0
     954        set _numCells 0
     955        foreach line $lines {
     956            set length [llength $line]
     957            if { $length == 0 } {
     958                continue
     959            }
     960            set celltype [lindex $celltypes $_numCells]
     961            if { $celltype == "" } {
     962                puts stderr "can't find celltype for line \"$line\""
     963                return 0
     964            }
     965            append data " $line\n"
     966            incr count $length
     967            incr _numCells
     968        }
     969        append out "DATASET UNSTRUCTURED_GRID\n"
     970        append out "POINTS $_numPoints float\n"
     971        $all merge $xv $yv $zv
     972        append out [$all range 0 end]
     973        append out "\n"
     974        append out "CELLS $_numCells $count\n"
     975        append out $data
     976        append out "CELL_TYPES $_numCells\n"
     977        append out $celltypes
     978        set _limits(x) [$xv limits]
     979        set _limits(y) [$yv limits]
     980        set _limits(z) [$zv limits]
     981    }
     982    blt::vector destroy $xv $yv $zv $all
     983    set _vtkdata $out
     984    set _isValid 1
     985}
     986
     987# ----------------------------------------------------------------------
     988# USAGE: ReadNodesElements <xmlobj> <path>
    279989#
    280990# Used internally to build a mesh representation based on nodes and
    281991# elements stored in the XML.
    282992# ----------------------------------------------------------------------
    283 itcl::body Rappture::Mesh::_buildNodesElements {xmlobj path} {
    284     # create the vtk objects containing points and connectivity
    285     vtkPoints $this-points
    286     set _pdata $this-points
    287     vtkUnstructuredGrid $this-grid
    288     set _gdata $this-grid
    289 
    290     #
    291     # Extract each node and add it to the points list.
    292     #
    293     foreach comp [$xmlobj children -type node $path] {
    294         set xyz [$xmlobj get $path.$comp]
    295 
    296         # make sure we have x,y,z
    297         while {[llength $xyz] < 3} {
    298             lappend xyz "0"
    299         }
    300 
    301         # extract each point and add it to the points list
    302         foreach {x y z} $xyz break
    303         foreach dim {x y z} units $_units {
    304             set v [Rappture::Units::convert [set $dim] \
    305                 -context $units -to $units -units off]
    306 
    307             set $dim $v  ;# save back to real x/y/z variable
    308 
    309             if {"" == $_limits(${dim}min)} {
    310                 set _limits(${dim}min) $v
    311                 set _limits(${dim}max) $v
    312             } else {
    313                 if {$v < $_limits(${dim}min)} { set _limits(${dim}min) $v }
    314                 if {$v > $_limits(${dim}max)} { set _limits(${dim}max) $v }
    315             }
    316         }
    317         $this-points InsertNextPoint $x $y $z
    318     }
    319     $this-grid SetPoints $this-points
    320 
    321     #
    322     # Extract each element and add it to the mesh.
    323     #
    324     foreach comp [$xmlobj children -type element $path] {
    325         set nlist [$_mesh get $comp.nodes]
    326         set elem [_getVtkElement [llength $nlist]]
    327 
    328         set i 0
    329         foreach n $nlist {
    330             [$elem GetPointIds] SetId $i $n
    331             incr i
    332         }
    333         $this-grid InsertNextCell [$elem GetCellType] [$elem GetPointIds]
    334     }
    335 }
    336 
    337 # ----------------------------------------------------------------------
    338 # USAGE: _buildRectMesh <xmlobj> <path>
    339 #
    340 # Used internally to build a mesh representation based on a native
    341 # VTK file for a rectangular mesh.
    342 # ----------------------------------------------------------------------
    343 itcl::body Rappture::Mesh::_buildRectMesh {xmlobj path} {
    344     vtkRectilinearGridReader $this-gr
    345     $this-gr ReadFromInputStringOn
    346     $this-gr SetInputString [$xmlobj get $path.vtk]
    347 
    348     set _gdata [$this-gr GetOutput]
    349     set _pdata [$_gdata GetPointData]
    350 
    351     $_gdata Update
    352     foreach name {xmin xmax ymin ymax zmin zmax} val [$_gdata GetBounds] {
    353         set _limits($name) $val
    354     }
    355 }
    356 
    357 # ----------------------------------------------------------------------
    358 # USAGE: _getVtkElement <npts>
    359 #
    360 # Used internally to find (or allocate, if necessary) a vtk element
    361 # that can be used to build up a mesh.  The element depends on the
    362 # number of points passed in.  4 points is a tetrahedron, 5 points
    363 # is a pyramid, etc.
    364 # ----------------------------------------------------------------------
    365 itcl::body Rappture::Mesh::_getVtkElement {npts} {
    366     if {![info exists _pts2elem($npts)]} {
    367         switch -- $npts {
    368             3 {
    369                 set _pts2elem($npts) $this-elem3
    370                 vtkTriangle $_pts2elem($npts)
    371             }
    372             4 {
    373                 set _pts2elem($npts) $this-elem4
    374                 vtkTetra $_pts2elem($npts)
    375             }
    376             5 {
    377                 set _pts2elem($npts) $this-elem5
    378                 vtkPyramid $_pts2elem($npts)
    379             }
    380             6 {
    381                 set _pts2elem($npts) $this-elem6
    382                 vtkWedge $_pts2elem($npts)
    383             }
    384             8 {
    385                 set _pts2elem($npts) $this-elem8
    386                 vtkVoxel $_pts2elem($npts)
    387             }
    388         }
    389     }
    390     return $_pts2elem($npts)
    391 }
     993itcl::body Rappture::Mesh::ReadNodesElements {xmlobj path} {
     994    set type "nodeselements"
     995    set count 0
     996
     997    # Scan for nodes.  Each node represents a vertex.
     998    set data {}
     999    foreach cname [$xmlobj children -type node $path] {
     1000        append data "[$xmlobj get $path.$cname]\n"
     1001    }   
     1002    Rappture::ReadPoints $data _dim points
     1003    if { $_dim == 2 } {
     1004        set all [blt::vector create \#auto]
     1005        set xv [blt::vector create \#auto]
     1006        set yv [blt::vector create \#auto]
     1007        set zv [blt::vector create \#auto]
     1008        $all set $points
     1009        $all split $xv $yv
     1010        set _numPoints [$xv length]
     1011        foreach axis {x y} {
     1012            set vector [set ${axis}v]
     1013            set _limits($axis) [${vector} limits]
     1014        }
     1015        # 2D Dataset. All Z coordinates are 0
     1016        $zv seq 0.0 0.0 $_numPoints
     1017        $all merge $xv $yv $zv
     1018        set points [$all range 0 end]
     1019        blt::vector destroy $all $xv $yv $zv
     1020    } elseif { $_dim == 3 } {
     1021        set all [blt::vector create \#auto]
     1022        set xv [blt::vector create \#auto]
     1023        set yv [blt::vector create \#auto]
     1024        set zv [blt::vector create \#auto]
     1025        $all set $points
     1026        $all split $xv $yv $zv
     1027        set _numPoints [$xv length]
     1028        foreach axis {x y z} {
     1029            set vector [set ${axis}v]
     1030            set _limits($axis) [${vector} limits]
     1031        }
     1032        set points [$all range 0 end]
     1033        blt::vector destroy $all $xv $yv $zv
     1034    } else {
     1035        error "bad dimension \"$_dim\" for nodes mesh"
     1036    }
     1037    array set node2celltype {
     1038        3 5
     1039        4 10
     1040        8 11
     1041        6 13
     1042        5 14
     1043    }
     1044    set count 0
     1045    set _numCells 0
     1046    set celltypes {}
     1047    set data {}
     1048    # Next scan for elements.  Each element represents a cell.
     1049    foreach cname [$xmlobj children -type element $path] {
     1050        set nodeList [$_mesh get $cname.nodes]
     1051        set numNodes [llength $nodeList]
     1052        if { ![info exists node2celltype($numNodes)] } {
     1053            puts stderr "unknown number of indices \"$_numNodes\": should be 3, 4, 5, 6, or 8"
     1054            return 0
     1055        }
     1056        set celltype $node2celltype($numNodes)
     1057        append celltypes "  $celltype\n"
     1058        append data "  $numNodes $nodeList\n"
     1059        incr _numCells
     1060        incr count $numNodes
     1061        incr count;                     # One extra for the VTK celltype id.
     1062    }
     1063
     1064    append out "DATASET UNSTRUCTURED_GRID\n"
     1065    append out "POINTS $_numPoints float\n"
     1066    append out $points
     1067    append out "CELLS $_numCells $count\n"
     1068    append out $data
     1069    append out "CELL_TYPES $_numCells\n"
     1070    append out $celltypes
     1071    append out "\n"
     1072    set _vtkdata $out
     1073    set _isValid 1
     1074}
  • trunk/gui/scripts/meshresult.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: meshresult - mesh plot in a ResultSet
  • trunk/gui/scripts/moleculeViewer.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: MoleculeViewer - view a molecule in 3D
  • trunk/gui/scripts/molvisviewer.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
     
    6566    private variable _cacheid ""
    6667    private variable _cacheimage ""
     68    private variable _first     ""
    6769
    6870    private common _settings  ;         # Array of settings for all known
     
    8183    private variable _width
    8284    private variable _height
    83     private variable _reset 1;  # Restore camera settings
     85    private variable _reset 1;          # Restore camera settings
    8486    private variable _cell 0;           # Restore camera settings
    85     private variable _flush 1
    86 
    87     constructor { hostlist args } {
    88         Rappture::VisViewer::constructor $hostlist
     87
     88    constructor { servers args } {
     89        Rappture::VisViewer::constructor $servers
    8990    } {
    9091        # defined below
     
    158159# CONSTRUCTOR
    159160# ----------------------------------------------------------------------
    160 itcl::body Rappture::MolvisViewer::constructor {hostlist args} {
     161itcl::body Rappture::MolvisViewer::constructor {servers args} {
    161162    set _serverType "pymol"
    162163
     
    196197    # the visualization server.
    197198    $_parser alias image [itcl::code $this ReceiveImage]
     199    $_parser alias viserror [itcl::code $this ReceiveError]
    198200
    199201    set _rocker(dir) 1
     
    203205    set _state(server) 1
    204206    set _state(client) 1
    205     set _hostlist $hostlist
    206207    set _reset 1
    207208
     
    246247        ignore -highlightthickness -borderwidth  -background
    247248    }
     249    bind $itk_component(3dview) <Control-F1> [itcl::code $this ToggleConsole]
    248250
    249251    set f [$itk_component(main) component controls]
     
    501503    # delete all specified dataobjs
    502504    set changed 0
    503     set _flush 1
    504505    foreach dataobj $args {
    505506        set pos [lsearch -exact $_dlist $dataobj]
     
    712713    global readyForNextFrame
    713714    set readyForNextFrame 1
     715    set _reset 1
    714716}
    715717
     
    893895        SendCmd "raw -defer {set auto_show_lines,0}"
    894896    }
     897    set _first ""
    895898    set dlist [get]
    896899    foreach dataobj $dlist {
     900        if { $_first == "" } {
     901            set _first $dataobj
     902        }
    897903        set model [$dataobj get components.molecule.model]
    898904        if {"" == $model } {
     
    10961102    }
    10971103    if { $_reset } {
     1104        if 1 {
     1105            # Tell the server the name of the tool, the version, and dataset
     1106            # that we are rendering.  Have to do it here because we don't know
     1107            # what data objects are using the renderer until be get here.
     1108            global env
     1109            lappend out "hub" [exec hostname]
     1110            lappend out "viewer" "molvisviewer"
     1111            if { [info exists env(USER)] } {
     1112                lappend out "user" $env(USER)
     1113            }
     1114            if { [info exists env(SESSION)] } {
     1115                lappend out "session" $env(SESSION)
     1116            }
     1117            set parent [$_first parent -as object]
     1118            while { $parent != "" } {
     1119                set xmlobj $parent
     1120                set parent [$parent parent -as object]
     1121            }
     1122            lappend out "tool_id" [$xmlobj get tool.id]
     1123            lappend out "tool_name" [$xmlobj get tool.name]
     1124            lappend out "tool_title" [$xmlobj get tool.title]
     1125            lappend out "tool_command" [$xmlobj get tool.execute]
     1126            lappend out "tool_revision" \
     1127                [$xmlobj get tool.version.application.revision]
     1128            SendCmd "clientinfo $out"
     1129        }
     1130
    10981131        # Set or restore viewing parameters.  We do this for the first
    10991132        # model and assume this works for everything else.
     
    11341167                                        # until we get an image.
    11351168        #SendCmd "ppm";                 # Flush the results.
    1136         set _flush 0
    11371169    }
    11381170    set _buffering 0;                   # Turn off buffering.
  • trunk/gui/scripts/nanovisviewer.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
     
    133134                                    # dataobj-components using the tf.
    134135
     136    private variable _reset 1;          # Connection to server has been reset
    135137    private variable _click        ;# info used for rotate operations
    136138    private variable _limits       ;# autoscale min/max for all axes
     
    193195    $_parser alias legend [itcl::code $this ReceiveLegend]
    194196    $_parser alias data [itcl::code $this ReceiveData]
     197    $_parser alias viserror [itcl::code $this ReceiveError]
    195198
    196199    # Initialize the view to some default parameters.
     
    205208    set _limits(vmin) 0.0
    206209    set _limits(vmax) 1.0
     210    set _reset 1
    207211
    208212    array set _settings [subst {
     
    229233        ignore -highlightthickness -borderwidth  -background
    230234    }
     235    bind $itk_component(3dview) <Control-F1> [itcl::code $this ToggleConsole]
    231236
    232237    set f [$itk_component(main) component controls]
     
    586591        return 0
    587592    }
     593    set _reset 1
    588594    set result [VisViewer::Connect $_hosts]
    589595    if { $result } {
     
    883889        }
    884890    }
    885     #
    886     # Reset the camera and other view parameters
    887     #
    888 
    889     set _settings($this-theta) $_view(theta)
    890     set _settings($this-phi)   $_view(phi)
    891     set _settings($this-psi)   $_view(psi)
    892     set _settings($this-pan-x) $_view(pan-x)
    893     set _settings($this-pan-y) $_view(pan-y)
    894     set _settings($this-zoom)  $_view(zoom)
    895 
    896     set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
    897     SendCmd "camera angle $xyz"
    898     PanCamera
    899     SendCmd "camera zoom $_view(zoom)"
    900     FixSettings light
    901     FixSettings transp
    902     FixSettings isosurface
    903     FixSettings grid
    904     FixSettings axes
    905     FixSettings outline
    906 
    907     # nothing to send -- activate the proper ivol
    908     SendCmd "volume state 0"
    909     set _first [lindex [get] 0]
    910     if {"" != $_first} {
    911         set axis [$_first hints updir]
    912         if { "" != $axis } {
    913             SendCmd "up $axis"
    914         }
    915         set location [$_first hints camera]
    916         if { $location != "" } {
    917             array set _view $location
    918         }
    919         set vols [array names _serverVols $_first-*]
    920         if { $vols != "" } {
    921             SendCmd "volume state 1 $vols"
    922         }
    923     }
    924     # If the first volume already exists on the server, then make sure we
    925     # display the proper transfer function in the legend.
    926     set comp [lindex [$_first components] 0]
    927     if { [info exists _serverVols($_first-$comp)] } {
    928         updatetransferfuncs
    929     }
    930     foreach axis {x y z} {
    931         # Turn off cutplanes for all volumes
    932         SendCmd "cutplane state 0 $axis"
     891    if { $_reset } {
     892        #
     893        # Reset the camera and other view parameters
     894        #
     895       
     896        set _settings($this-theta) $_view(theta)
     897        set _settings($this-phi)   $_view(phi)
     898        set _settings($this-psi)   $_view(psi)
     899        set _settings($this-pan-x) $_view(pan-x)
     900        set _settings($this-pan-y) $_view(pan-y)
     901        set _settings($this-zoom)  $_view(zoom)
     902       
     903        set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
     904        SendCmd "camera angle $xyz"
     905        PanCamera
     906        SendCmd "camera zoom $_view(zoom)"
     907        FixSettings light
     908        FixSettings transp
     909        FixSettings isosurface
     910        FixSettings grid
     911        FixSettings axes
     912        FixSettings outline
     913       
     914        # nothing to send -- activate the proper ivol
     915        SendCmd "volume state 0"
     916        set _first [lindex [get] 0]
     917        if {"" != $_first} {
     918            set axis [$_first hints updir]
     919            if { "" != $axis } {
     920                SendCmd "up $axis"
     921            }
     922            set location [$_first hints camera]
     923            if { $location != "" } {
     924                array set _view $location
     925            }
     926            set vols [array names _serverVols $_first-*]
     927            if { $vols != "" } {
     928                SendCmd "volume state 1 $vols"
     929            }
     930            if 1 {
     931                # Tell the server the name of the tool, the version, and dataset
     932                # that we are rendering.  Have to do it here because we don't know
     933                # what data objects are using the renderer until be get here.
     934                global env
     935
     936                lappend out "hub" [exec hostname]
     937                lappend out "viewer" "nanovisviewer"
     938                if { [info exists env(USER)] } {
     939                    lappend out "user" $env(USER)
     940                }
     941                if { [info exists env(SESSION)] } {
     942                    lappend out "session" $env(SESSION)
     943                }
     944                lappend out "tool_id"      [$_first hints toolId]
     945                lappend out "tool_name"    [$_first hints toolName]
     946                lappend out "tool_version" [$_first hints toolRevision]
     947                lappend out "tool_title"   [$_first hints toolTitle]
     948                lappend out "tool_dataset" [$_first hints label]
     949                SendCmd "clientinfo [list $out]"
     950            }
     951
     952            foreach axis {x y z} {
     953                # Turn off cutplanes for all volumes
     954                SendCmd "cutplane state 0 $axis"
     955            }
     956           
     957            # If the first volume already exists on the server, then make sure
     958            # we display the proper transfer function in the legend.
     959            set comp [lindex [$_first components] 0]
     960            if { [info exists _serverVols($_first-$comp)] } {
     961                updatetransferfuncs
     962            }
     963        }
    933964    }
    934965    set _buffering 0;                        # Turn off buffering.
     
    938969    SendBytes $_outbuf;                       
    939970    blt::busy release $itk_component(hull)
     971    set _reset 0
    940972    set _outbuf "";                        # Clear the buffer.               
    941973}
  • trunk/gui/scripts/note.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
  • trunk/gui/scripts/notebook.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: notebook - series of pages, but only one packed at a time
  • trunk/gui/scripts/numberentry.tcl

    r3186 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: NumberEntry - widget for entering numeric values
  • trunk/gui/scripts/numberresult.tcl

    r3186 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
  • trunk/gui/scripts/page.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: page - single page of widgets
  • trunk/gui/scripts/pager.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: pager - notebook for displaying pages of widgets
  • trunk/gui/scripts/panes.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
  • trunk/gui/scripts/periodicelement.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
  • trunk/gui/scripts/periodicelemententry.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: PeriodicElementEntry - widget for entering a choice of strings
  • trunk/gui/scripts/periodictable.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: periodictable - drop-down list of items
  • trunk/gui/scripts/postern.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: postern - a back door for debugging
  • trunk/gui/scripts/progress.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: progress - progress meter for long-running apps
  • trunk/gui/scripts/pushbutton.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
     
    2829    itk_option define -onvalue onValue OnValue "normal"
    2930    itk_option define -offvalue offValue OffValue "normal"
     31    itk_option define -onbackground onBackground OnBackground "white"
     32    itk_option define -offbackground offBackground OffBackground "grey85"
    3033
    3134    constructor {args} {
     
    5457    public variable onvalue "1";        # Value set when selected.
    5558    public variable offvalue "0";       # Value set when deselected.
     59    public variable onbackground "white"
     60    public variable offbackground "grey85"
    5661}
    5762
     
    133138        set _state 1
    134139        $itk_component(button) configure -relief sunken \
    135             -image $onimage -bg white
     140            -image $onimage -bg $onbackground
    136141    } else {
    137142        set _state 0
    138143        $itk_component(button) configure -relief raise \
    139             -image $offimage -bg grey85
     144            -image $offimage -bg $offbackground
    140145    }
    141146}
  • trunk/gui/scripts/radiodial.tcl

    r3186 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: Radiodial - selector, like the dial on a car radio
  • trunk/gui/scripts/resources.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: resources
  • trunk/gui/scripts/resultselector.tcl

    r3186 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: ResultSelector - controls for a ResultSet
  • trunk/gui/scripts/resultset.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: ResultSet - set of XML objects for simulated results
  • trunk/gui/scripts/resultviewer.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: ResultViewer - plots a collection of related results
     
    2425    itk_option define -simulatecommand simulateCommand SimulateCommand ""
    2526
    26     constructor {args} { # defined below }
    27     destructor { # defined below }
    28 
     27    constructor {args} {
     28        # defined below
     29    }
     30    destructor {
     31        # defined below
     32    }
    2933    public method add {index xmlobj path}
    3034    public method clear {{index ""}}
     
    294298                }
    295299                2D {
    296                     set mode "contour"
    297                     if {![info exists _mode2widget($mode)]} {
    298                         global env
    299                         if { [$dataobj isunirect2d] } {
    300                             if { [$dataobj hints type] == "contour" } {
    301                                 set resultMode "vtkcontour"
    302                             } elseif { [info exists env(VTKHEIGHTMAP)] } {
    303                                 set resultMode "vtkheightmap"
    304                             } else {
    305                                 set resultMode "heightmap"
    306                             }
    307                         } elseif { [info exists env(VTKCONTOUR)] } {
    308                             set resultMode "vtkcontour"
    309                         } else {
    310                             set resultMode "vtk"
    311                         }
    312                         set extents [$dataobj extents]
    313                         if { $extents > 1 } {
    314                             set resultMode "flowvis"
    315                         }
    316                         set w $itk_interior.contour
     300                    set mode "field2d"
     301                    set viewer [$dataobj viewer]
     302                    set extents [$dataobj extents]
     303                    if { $extents > 1 } {
     304                        set mode "flowvis"
     305                    }
     306                    if {![info exists _mode2widget($mode)]} {
     307                        set w $itk_interior.$mode
    317308                        if { ![winfo exists $w] } {
    318                             Rappture::Field2DResult $w -mode $resultMode
    319                         }
    320                         set _mode2widget($mode) $w
     309                            Rappture::Field2DResult $w -mode $viewer
     310                            set _mode2widget($mode) $w
     311                        }
    321312                    }
    322313                }
    323314                3D {
    324                     set mode "field3D"
    325                     if {![info exists _mode2widget($mode)]} {
    326                         switch -- [$dataobj type] {
    327                             "vtk" {
    328                                 set fmt "vtk"
    329                             }
    330                             "points-on-mesh" {
    331                                 set mesh [$dataobj mesh]
    332                                 set fmt [expr {("" != $mesh) ? "vtk" : "nanovis"}]
    333                                 set extents [$dataobj extents]
    334                                 if { $extents > 1 } {
    335                                     set fmt "flowvis"
    336                                 }
    337                             }
    338                             "opendx" - "dx" {
    339                                 set fmt "nanovis"
    340                                 set extents [$dataobj extents]
    341                                 if { $extents > 1 } {
    342                                     set fmt "flowvis"
    343                                 }
    344                             }
    345                             "vtkvolume" {
    346                                 set fmt "vtkvolume"
    347                             }
    348                             "vtkstreamlines" {
    349                                 set fmt "vtkstreamlines"
    350                             }
    351                         }
    352                         set w $itk_interior.field3D
    353                         Rappture::Field3DResult $w -mode $fmt
     315                    set mode [$dataobj viewer]
     316                    set extents [$dataobj extents]
     317                    if { $extents > 1 } {
     318                        set mode "flowvis"
     319                    }
     320                    if {![info exists _mode2widget($mode)]} {
     321                        set w $itk_interior.$mode
     322                        Rappture::Field3DResult $w -mode $mode
    354323                        set _mode2widget($mode) $w
    355324                    }
  • trunk/gui/scripts/scroller.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: scroller - adds scrollbars to any standard Tk widget
  • trunk/gui/scripts/sequence.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
     2
    13# ----------------------------------------------------------------------
    24#  COMPONENT: sequence - represents a sequence of output results
     
    7173                }
    7274                curve {
    73                     set obj [Rappture::Curve ::#auto $xmlobj $path.$name.$cname]
     75                    set obj [Rappture::Curve ::\#auto $xmlobj $path.$name.$cname]
    7476                }
    7577                datatable {
    76                     set obj [Rappture::DataTable ::#auto $xmlobj $path.$name.$cname]
     78                    set obj [Rappture::DataTable ::\#auto $xmlobj $path.$name.$cname]
    7779                }
    7880                histogram {
    79                     set obj [Rappture::Histogram ::#auto $xmlobj $path.$name.$cname]
     81                    set obj [Rappture::Histogram ::\#auto $xmlobj $path.$name.$cname]
    8082                }
    8183                field {
    82                     set obj [Rappture::Field ::#auto $xmlobj $path.$name.$cname]
     84                    set obj [Rappture::Field ::\#auto $xmlobj $path.$name.$cname]
    8385                }
    8486                image {
    85                     set obj [Rappture::Image ::#auto $xmlobj $path.$name.$cname]
     87                    set obj [Rappture::Image ::\#auto $xmlobj $path.$name.$cname]
    8688                }
    8789                structure {
     
    119121        }
    120122    }
    121 
    122123    #
    123124    # Generate a list of sorted index values.
     
    134135        # sort according to raw values; store both values
    135136        set _indices [lsort -real -index 1 $vals]
    136 
    137137    } else {
    138138        # are the indices integers, reals, or strings?
     
    182182itcl::body Rappture::Sequence::value {pos} {
    183183    set i [lindex [lindex $_indices $pos] 0]
     184
     185    # FIXME:  This is a bandaid on what appears to be a timing problem.
     186    # This "dataobjs" method is now called before any sequence frames
     187    # have been added.
     188    if { ![info exists _dataobjs($i)] } {
     189        return ""
     190    }
     191
    184192    return $_dataobjs($i)
    185193}
     
    193201itcl::body Rappture::Sequence::label {pos} {
    194202    set i [lindex [lindex $_indices $pos] 0]
     203
     204    # FIXME:  This is a bandaid on what appears to be a timing problem.
     205    # This "label" method is now called before any sequence frames
     206    # have been added.
     207    if { ![info exists _labels($i)] } {
     208        return ""
     209    }
     210
    195211    return $_labels($i)
    196212}
  • trunk/gui/scripts/sequenceresult.tcl

    r3186 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
     
    9394
    9495    itk_component add dial {
    95         Rappture::Radiodial $itk_component(player).dial \
     96        Rappture::SequenceDial $itk_component(player).dial \
    9697            -length 10 -valuewidth 0 -valuepadding 0 -padding 6 \
    9798            -linecolor "" -activelinecolor "" \
     
    436437    # Otherwise, hide it.
    437438    #
    438     set viewer $itk_component(area).viewer
    439     if {[winfo exists $viewer]} {
     439    set w $itk_component(area).viewer
     440    if {[winfo exists $w]} {
    440441        if {"" == $_topmost} {
    441             pack forget $viewer
     442            pack forget $w
    442443            pack forget $itk_component(player)
    443444            return
    444445        } else {
    445             pack $viewer -expand yes -fill both
     446            pack $w -expand yes -fill both
    446447            pack $itk_component(player) -side bottom -fill x
    447448        }
     
    458459        switch -- $type {
    459460            ::Rappture::Drawing {
    460                 Rappture::VtkViewer $viewer
    461                 pack $viewer -expand yes -fill both
     461                Rappture::VtkViewer $w
     462                pack $w -expand yes -fill both
    462463            }
    463464            ::Rappture::Curve {
    464                 Rappture::XyResult $viewer
    465                 pack $viewer -expand yes -fill both
     465                Rappture::XyResult $w
     466                pack $w -expand yes -fill both
    466467            }
    467468            ::Rappture::Histogram {
    468                 Rappture::HistogramResult $viewer
    469                 pack $viewer -expand yes -fill both
     469                Rappture::HistogramResult $w
     470                pack $w -expand yes -fill both
    470471            }
    471472            ::Rappture::DataTable {
    472                 Rappture::DataTable $viewer
    473                 pack $viewer -expand yes -fill both
     473                Rappture::DataTable $w
     474                pack $w -expand yes -fill both
    474475            }
    475476            ::Rappture::Image {
    476                 Rappture::ImageResult $viewer
    477                 pack $viewer -expand yes -fill both
     477                Rappture::ImageResult $w
     478                pack $w -expand yes -fill both
    478479            }
    479480            ::Rappture::Field {
     
    495496                    }
    496497                }
     498                set mode [$dataobj viewer]
    497499                switch -- $dimensions {
    498500                    2D {
    499                         global env
    500                         if { [$dataobj isunirect2d] } {
    501                             if { [$dataobj hints type] == "contour" } {
    502                                 set mode "vtkcontour"
    503                             } elseif { [info exists env(VTKHEIGHTMAP)] } {
    504                                 set mode "vtkheightmap"
    505                             } else {
    506                                 set mode "heightmap"
    507                             }
    508                         } elseif { [info exists env(VTKCONTOUR)] } {
    509                             set mode "vtkcontour"
    510                         } else {
    511                             set mode "vtk"
    512                         }
    513                         set extents [$dataobj extents]
    514                         if { $extents > 1 } {
    515                             set mode "flowvis"
    516                         }
    517                         Rappture::Field2DResult $viewer -mode $mode
     501                        Rappture::Field2DResult $w -mode $mode
    518502                    }
    519503                    3D {
    520                         set fmt [$dataobj type]
    521                         switch -- $fmt {
    522                             "points-on-mesh" {
    523                                 set mesh [$dataobj mesh]
    524                                 set fmt [expr {("" != $mesh) ? "vtk" : "nanovis"}]
    525                                 set extents [$dataobj extents]
    526                                 if { $extents > 1 } {
    527                                     set fmt "flowvis"
    528                                 }
    529                             }
    530                             "opendx" - "dx" {
    531                                 set fmt "nanovis"
    532                                 set extents [$dataobj extents]
    533                                 if { $extents > 1 } {
    534                                     set fmt "flowvis"
    535                                 }
    536                             }
    537                             "vtkvolume" {
    538                                 set fmt "vtkvolume"
    539                             }
    540                             "vtkstreamlines" {
    541                                 set fmt "vtkstreamlines"
    542                             }
    543                             "" {
    544                                 set fmt "auto"
    545                             }
    546                         }
    547                         Rappture::Field3DResult $viewer -mode $fmt
     504                        Rappture::Field3DResult $w -mode $mode
    548505                    }
    549506                    default {
    550507                        error "don't know how to view sequences of $type\
    551                             with $dimensions dimensions"
     508                            with \"$dimensions\" dimensions dim=[$dataobj components -dimensions]"
    552509                    }
    553510                }
    554                 pack $viewer -expand yes -fill both
     511                pack $w -expand yes -fill both
    555512            }
    556513            ::Rappture::LibraryObj {
    557514                switch -- [$dataobj element -as type] {
    558515                    structure {
    559                         Rappture::DeviceResult $viewer
    560                         pack $viewer -expand yes -fill both
     516                        Rappture::DeviceResult $w
     517                        pack $w -expand yes -fill both
    561518                    }
    562519                    default {
     
    572529        }
    573530    }
    574 
    575531    #
    576532    # Load the current sequence info the viewer.
    577533    #
    578534    $itk_component(indexLabel) configure -text [$_topmost hints indexlabel]
    579 
    580     $viewer delete
     535   
     536    $w delete
    581537    $itk_component(dial) clear
    582538
     
    586542        eval lappend all [$_topmost value $i]
    587543    }
    588     eval $viewer scale $all
     544    eval $w scale $all
    589545
    590546    set _indices ""
     
    634590# ----------------------------------------------------------------------
    635591itcl::body Rappture::SequenceResult::_fixValue {} {
    636     set viewer $itk_component(area).viewer
    637     if {![winfo exists $viewer]} {
     592    set w $itk_component(area).viewer
     593    if {![winfo exists $w]} {
    638594        return
    639595    }
    640     $viewer delete
     596    $w delete
    641597    if { $_topmost == "" } {
    642598        return
     
    644600    set val [$itk_component(dial) get -format label current]
    645601    set _pos [lsearch -glob $_indices $val*]
     602
    646603    # populate the label for this element
    647604    if { "" != [$_topmost hints indexlabel] } {
     
    659616            }
    660617        }
    661         $viewer add $dataobj $settings
    662     }
    663 }
     618        $w add $dataobj $settings
     619    }
     620}
  • trunk/gui/scripts/service.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: service - represents a tool embedded within another tool
  • trunk/gui/scripts/sidebarframe.tcl

    r3287 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: SidebarFrame - pop-out controls for visualization widgets
     
    5152    public method disable { which }
    5253
    53     protected method _toggleTab { which }
     54    protected method _toggleTab {which}
    5455    protected method _sash {op x}
    5556    protected method _fixLayout {args}
     
    214215            Background
    215216    }
    216     pack $itk_component(tabs) -side top -expand yes -anchor e -padx {4 0} \
    217         -fill y
     217    pack $itk_component(tabs) -side top -expand yes -anchor e -padx {4 0} -fill y
    218218
    219219    eval itk_initialize $args
  • trunk/gui/scripts/spectrum.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: spectrum - maps a range of real values onto a color
  • trunk/gui/scripts/spinint.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
  • trunk/gui/scripts/switch.tcl

    r3186 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: switch - on/off switch
  • trunk/gui/scripts/table.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: table - extracts data from an XML description of a table
  • trunk/gui/scripts/tempgauge.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: tempgauge - gauge for temperature values
  • trunk/gui/scripts/textentry.tcl

    r3186 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: textentry - general-purpose text entry widget
  • trunk/gui/scripts/textresult.tcl

    r3186 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: TextResult - Log output for ResultSet
  • trunk/gui/scripts/tool.tcl

    r3275 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: tool - represents an entire tool
     
    192193            set cmd [linsert $cmd 0 submit --local]
    193194        }
     195        $_xmlobj put tool.execute $cmd
    194196
    195197        # starting job...
  • trunk/gui/scripts/tooltip.tcl

    r3186 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: tooltip - help information that pops up beneath a widget
  • trunk/gui/scripts/tuples.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12# ----------------------------------------------------------------------
    23#  COMPONENT: tuples - represents a series of tuples for arbitrary data
  • trunk/gui/scripts/unirect2d.tcl

    r3177 r3330  
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    12
    23# ----------------------------------------------------------------------
     
    1920
    2021itcl::class Rappture::Unirect2d {
    21     constructor {xmlobj field cname {extents 1}} { # defined below }
     22    constructor {xmlobj path} {
     23        # defined below
     24    }
    2225    destructor { # defined below }
    2326
     27    public proc fetch {xmlobj path}
     28    public proc release {obj}
    2429    public method limits {axis}
    2530    public method blob {}
    26     public method mesh.old {}
    2731    public method mesh {}
    28     public method values {}
     32    public method dimensions {} {
     33        return 2
     34    }
     35    public method numpoints {} {
     36        return $_numPoints
     37    }
     38    public method vtkdata {} {
     39        return $_vtkdata
     40    }
    2941    public method hints {{keyword ""}}
    3042    private method GetString { obj path varName }
    3143    private method GetValue { obj path varName }
    3244    private method GetSize { obj path varName }
    33 
     45   
    3446    private variable _axisOrder "x y"
    3547    private variable _xMax      0
     
    3951    private variable _yMin      0
    4052    private variable _yNum      0
    41     private variable _compNum   1
    42     private variable _values    "";     # BLT vector containing the z-values
    4353    private variable _hints
     54    private variable _vtkdata ""
     55    private variable _numPoints 0
     56
     57    private common _xp2obj       ;      # used for fetch/release ref counting
     58    private common _obj2ref      ;      # used for fetch/release ref counting
     59}
     60
     61#
     62# fetch <xmlobj> <path>
     63#
     64#    Clients use this instead of a constructor to fetch the Mesh for a
     65#    particular <path> in the <xmlobj>.  When the client is done with the mesh,
     66#    he calls "release" to decrement the reference count.  When the mesh is no
     67#    longer needed, it is cleaned up automatically.
     68#
     69itcl::body Rappture::Unirect2d::fetch {xmlobj path} {
     70    set handle "$xmlobj|$path"
     71    if {[info exists _xp2obj($handle)]} {
     72        set obj $_xp2obj($handle)
     73        incr _obj2ref($obj)
     74        return $obj
     75    }
     76    set obj [Rappture::Unirect2d ::#auto $xmlobj $path]
     77    set _xp2obj($handle) $obj
     78    set _obj2ref($obj) 1
     79    return $obj
     80}
     81
     82# ----------------------------------------------------------------------
     83# USAGE: Rappture::Mesh::release <obj>
     84#
     85# Clients call this when they're no longer using a Mesh fetched
     86# previously by the "fetch" proc.  This decrements the reference
     87# count for the mesh and destroys the object when it is no longer
     88# in use.
     89# ----------------------------------------------------------------------
     90itcl::body Rappture::Unirect2d::release { obj } {
     91    if { ![info exists _obj2ref($obj)] } {
     92        error "can't find reference count for $obj"
     93    }
     94    incr _obj2ref($obj) -1
     95    if {$_obj2ref($obj) <= 0} {
     96        unset _obj2ref($obj)
     97        foreach handle [array names _xp2obj] {
     98            if {$_xp2obj($handle) == $obj} {
     99                unset _xp2obj($handle)
     100            }
     101        }
     102        itcl::delete object $obj
     103    }
    44104}
    45105
     
    47107# Constructor
    48108# ----------------------------------------------------------------------
    49 itcl::body Rappture::Unirect2d::constructor {xmlobj field cname {extents 1}} {
     109itcl::body Rappture::Unirect2d::constructor {xmlobj path} {
    50110    if {![Rappture::library isvalid $xmlobj]} {
    51111        error "bad value \"$xmlobj\": should be Rappture::library"
    52112    }
    53     set path [$field get $cname.mesh]
    54 
    55113    set m [$xmlobj element -as object $path]
    56114    GetValue $m "xaxis.min" _xMin
     
    60118    GetValue $m "yaxis.max" _yMax
    61119    GetSize $m "yaxis.numpoints" _yNum
    62     set _compNum $extents
    63120    foreach {key path} {
    64121        group   about.group
     
    86143        }
    87144    }
    88     foreach {key} { axisorder } {
    89         set str [$field get $cname.$key]
    90         if {"" != $str} {
    91             set _hints($key) $str
    92         }
    93     }
    94145    itcl::delete object $m
    95    
    96     set _values [blt::vector create \#auto]
    97     set values [$field get "$cname.values"]
    98     if { $values == "" } {
    99         set values [$field get "$cname.zvalues"]
    100     }
    101     $_values set $values
    102     set n [expr $_xNum * $_yNum * $_compNum]
    103     if { [$_values length] != $n } {
    104         error "wrong \# of values in \"$cname.values\": expected $n values, got [$_values length]"
    105     }
     146    set _numPoints [expr $_xNum * $_yNum]
     147    if { $_numPoints == 0 } {
     148        set _vtkdata ""
     149        return
     150    }
     151    append out "DATASET STRUCTURED_POINTS\n"
     152    append out "DIMENSIONS $_xNum $_yNum 1"
     153    set xSpace [expr ($_xMax - $_xMin) / double($_xNum - 1)]
     154    set ySpace [expr ($_yMax - $_yMin) / double($_yNum - 1)]
     155    append out "SPACING $xSpace $ySpace 0\n"
     156    append out "ORIGIN 0 0 0\n"
     157    set _vtkdata $out
    106158}
    107159
     
    110162# ----------------------------------------------------------------------
    111163itcl::body Rappture::Unirect2d::destructor {} {
    112     if { $_values != "" } {
    113         blt::vector destroy $_values