- Timestamp:
- Sep 20, 2012 12:46:32 PM (12 years ago)
- Location:
- branches/nanovis2
- Files:
-
- 1 deleted
- 85 edited
- 57 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/nanovis2
-
branches/nanovis2/Makefile.in
r2890 r3175 37 37 TARGETS += gui builder tester examples 38 38 endif 39 if eq ($(HAVE_FFMEG),)39 ifneq ($(HAVE_FFMPEG),) 40 40 TARGETS += video 41 41 endif -
branches/nanovis2/builder/scripts/hierlist.tcl
r2081 r3175 371 371 # ---------------------------------------------------------------------- 372 372 itcl::body Rappture::Hierlist::dd_get_source {widget x y} { 373 # convert from screen coords to canvas coords (for scrollbars) 374 set x [$widget canvasx $x] 375 set y [$widget canvasy $y] 376 373 377 set data "" 374 foreach id [$ itk_component(area)find overlapping $x $y $x $y] {375 foreach tag [$ itk_component(area)gettags $id] {378 foreach id [$widget find overlapping $x $y $x $y] { 379 foreach tag [$widget gettags $id] { 376 380 # search for a tag like item:NNN and make sure it's selected 377 381 if {[regexp {^item:([0-9]+)$} $tag match node] -
branches/nanovis2/builder/scripts/main.tcl
r2253 r3175 87 87 88 88 switch $tcl_platform(platform) { 89 unix - windows { 89 unix { 90 event add <<PopupMenu>> <ButtonPress-3> 91 92 # make Ctrl-V binding work: 93 # not strict Motif, and remove conflicting binding in Tk library 94 set tk_strictMotif 0 95 bind Text <Control-v> "" 96 } 97 windows { 90 98 event add <<PopupMenu>> <ButtonPress-3> 91 99 } … … 659 667 # ---------------------------------------------------------------------- 660 668 proc main_saveas {{option "start"}} { 661 global SaveAs ToolXml LastToolXmlFile LastToolXmlLoaded669 global tcl_platform SaveAs ToolXml LastToolXmlFile LastToolXmlLoaded 662 670 663 671 switch -- $option { … … 846 854 set pfile "main$SaveAs(ext)" 847 855 } 856 set fname [file tail $pfile] 848 857 set mfile [file join [file dirname $pfile] Makefile] 849 858 if {[file exists $mfile]} { … … 858 867 } 859 868 860 set fname [file tail $pfile] 861 set dir [file dirname [file dirname $::Rappture::installdir]] 869 # /apps/rappture/current for 32-bit systems 870 # /apps/share64/rappture/current for 64-bit systems 871 if {$tcl_platform(wordSize) == 8 872 && [file isdirectory /apps/share64/rappture/current]} { 873 set dir /apps/share64/rappture/current 874 } else { 875 set dir /apps/rappture/current 876 } 877 if {![file isdirectory $dir]} { 878 # if all else fails, ask the current Rappture for its install dir 879 set dir [file dirname [file dirname $::Rappture::installdir]] 880 } 881 862 882 set macros [list @@RAPPTUREDIR@@ $dir] 863 883 lappend macros @@FILENAME@@ $fname … … 1083 1103 # turn off download options and clear button 1084 1104 $f.analyze component download configure -state disabled 1085 $f.analyze component resultse tcomponent clear configure -state disabled1086 # remove the "---" and "Download..." options from the resultselector1087 $f.analyze component resultselector choices delete end1088 $f.analyze component resultselector choices delete end1105 $f.analyze component resultselector component clear configure -state disabled 1106 # remove the "---" and "Download..." options from the view selector 1107 $f.analyze component viewselector choices delete end 1108 $f.analyze component viewselector choices delete end 1089 1109 } 1090 1110 … … 1527 1547 set ErrFocusAttr "" 1528 1548 1529 if { "" != $params(-tool)} {1549 if {$params(-tool) ne ""} { 1530 1550 if {![file exists $params(-tool)]} { 1531 1551 puts stderr "can't find tool \"$params(-tool)\"" … … 1533 1553 } 1534 1554 main_open $params(-tool) 1555 } elseif {[file exists tool.xml]} { 1556 main_open tool.xml 1535 1557 } else { 1536 1558 main_open -new -
branches/nanovis2/cf/rpLangJava.m4
r2298 r3175 30 30 ${JAVA_HOME} \ 31 31 /apps/java/jdk1.6* \ 32 /usr/lib/jvm/java-6-openjdk \ 33 /usr/lib/jvm/icedtea-6 \ 32 34 /usr/lib/jvm/*sun-1.6* \ 33 35 /opt/sun-jdk-1.6* \ 36 /usr/lib/jvm/icedtea-7 \ 34 37 /opt/icedtea6-* \ 35 38 /opt/sun-jdk-1.5* \ 36 /usr/lib/jvm/*sun-1.5* 39 /usr/lib/jvm/*sun-1.5* 37 40 do 38 41 if test -r "${d}/include/jni.h" ; then -
branches/nanovis2/configure
r2890 r3175 1 1 #! /bin/sh 2 2 # Guess values for system-dependent variables and create Makefiles. 3 # Generated by GNU Autoconf 2.6 8for Rappture 1.1.3 # Generated by GNU Autoconf 2.69 for Rappture 1.1. 4 4 # 5 5 # Report bugs to <rappture@nanohub.org>. 6 6 # 7 7 # 8 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 9 # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software 10 # Foundation, Inc. 8 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. 11 9 # 12 10 # … … 137 135 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH 138 136 137 # Use a proper internal environment variable to ensure we don't fall 138 # into an infinite loop, continuously re-executing ourselves. 139 if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then 140 _as_can_reexec=no; export _as_can_reexec; 141 # We cannot yet assume a decent shell, so we have to provide a 142 # neutralization value for shells without unset; and this also 143 # works around shells that cannot unset nonexistent variables. 144 # Preserve -v and -x to the replacement shell. 145 BASH_ENV=/dev/null 146 ENV=/dev/null 147 (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV 148 case $- in # (((( 149 *v*x* | *x*v* ) as_opts=-vx ;; 150 *v* ) as_opts=-v ;; 151 *x* ) as_opts=-x ;; 152 * ) as_opts= ;; 153 esac 154 exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} 155 # Admittedly, this is quite paranoid, since all the known shells bail 156 # out after a failed `exec'. 157 $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 158 as_fn_exit 255 159 fi 160 # We don't want this to propagate to other subprocesses. 161 { _as_can_reexec=; unset _as_can_reexec;} 139 162 if test "x$CONFIG_SHELL" = x; then 140 163 as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : … … 170 193 exitcode=1; echo positional parameters were not saved. 171 194 fi 172 test x\$exitcode = x0 || exit 1" 195 test x\$exitcode = x0 || exit 1 196 test -x / || exit 1" 173 197 as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO 174 198 as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO … … 215 239 216 240 if test "x$CONFIG_SHELL" != x; then : 217 # We cannot yet assume a decent shell, so we have to provide a 218 # neutralization value for shells without unset; and this also 219 # works around shells that cannot unset nonexistent variables. 220 # Preserve -v and -x to the replacement shell. 221 BASH_ENV=/dev/null 222 ENV=/dev/null 223 (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV 224 export CONFIG_SHELL 225 case $- in # (((( 226 *v*x* | *x*v* ) as_opts=-vx ;; 227 *v* ) as_opts=-v ;; 228 *x* ) as_opts=-x ;; 229 * ) as_opts= ;; 230 esac 231 exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} 241 export CONFIG_SHELL 242 # We cannot yet assume a decent shell, so we have to provide a 243 # neutralization value for shells without unset; and this also 244 # works around shells that cannot unset nonexistent variables. 245 # Preserve -v and -x to the replacement shell. 246 BASH_ENV=/dev/null 247 ENV=/dev/null 248 (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV 249 case $- in # (((( 250 *v*x* | *x*v* ) as_opts=-vx ;; 251 *v* ) as_opts=-v ;; 252 *x* ) as_opts=-x ;; 253 * ) as_opts= ;; 254 esac 255 exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} 256 # Admittedly, this is quite paranoid, since all the known shells bail 257 # out after a failed `exec'. 258 $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 259 exit 255 232 260 fi 233 261 … … 332 360 333 361 } # as_fn_mkdir_p 362 363 # as_fn_executable_p FILE 364 # ----------------------- 365 # Test if FILE is an executable regular file. 366 as_fn_executable_p () 367 { 368 test -f "$1" && test -x "$1" 369 } # as_fn_executable_p 334 370 # as_fn_append VAR VALUE 335 371 # ---------------------- … … 453 489 { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } 454 490 491 # If we had to re-execute with $CONFIG_SHELL, we're ensured to have 492 # already done that, so ensure we don't try to do so again and fall 493 # in an infinite loop. This has already happened in practice. 494 _as_can_reexec=no; export _as_can_reexec 455 495 # Don't try to exec as it changes $[0], causing all sort of problems 456 496 # (the dirname of $[0] is not the place where we might find the … … 487 527 # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. 488 528 # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. 489 # In both cases, we have to default to `cp -p '.529 # In both cases, we have to default to `cp -pR'. 490 530 ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || 491 as_ln_s='cp -p '531 as_ln_s='cp -pR' 492 532 elif ln conf$$.file conf$$ 2>/dev/null; then 493 533 as_ln_s=ln 494 534 else 495 as_ln_s='cp -p '535 as_ln_s='cp -pR' 496 536 fi 497 537 else 498 as_ln_s='cp -p '538 as_ln_s='cp -pR' 499 539 fi 500 540 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file … … 508 548 fi 509 549 510 if test -x / >/dev/null 2>&1; then 511 as_test_x='test -x' 512 else 513 if ls -dL / >/dev/null 2>&1; then 514 as_ls_L_option=L 515 else 516 as_ls_L_option= 517 fi 518 as_test_x=' 519 eval sh -c '\'' 520 if test -d "$1"; then 521 test -d "$1/."; 522 else 523 case $1 in #( 524 -*)set "./$1";; 525 esac; 526 case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( 527 ???[sx]*):;;*)false;;esac;fi 528 '\'' sh 529 ' 530 fi 531 as_executable_p=$as_test_x 550 as_test_x='test -x' 551 as_executable_p=as_fn_executable_p 532 552 533 553 # Sed expression to map a string onto a valid CPP name. … … 1269 1289 if test "x$build_alias" = x; then 1270 1290 cross_compiling=maybe 1271 $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.1272 If a cross compiler is detected then cross compile mode will be used" >&21273 1291 elif test "x$build_alias" != "x$host_alias"; then 1274 1292 cross_compiling=yes … … 1534 1552 cat <<\_ACEOF 1535 1553 Rappture configure 1.1 1536 generated by GNU Autoconf 2.6 81537 1538 Copyright (C) 201 0Free Software Foundation, Inc.1554 generated by GNU Autoconf 2.69 1555 1556 Copyright (C) 2012 Free Software Foundation, Inc. 1539 1557 This configure script is free software; the Free Software Foundation 1540 1558 gives unlimited permission to copy, distribute and modify it. … … 1767 1785 } && test -s conftest$ac_exeext && { 1768 1786 test "$cross_compiling" = yes || 1769 $as_test_x conftest$ac_exeext1787 test -x conftest$ac_exeext 1770 1788 }; then : 1771 1789 ac_retval=0 … … 1880 1898 } && test -s conftest$ac_exeext && { 1881 1899 test "$cross_compiling" = yes || 1882 $as_test_x conftest$ac_exeext1900 test -x conftest$ac_exeext 1883 1901 }; then : 1884 1902 ac_retval=0 … … 2184 2202 { 2185 2203 static int test_array [1 - 2 * !(($2) >= 0)]; 2186 test_array [0] = 0 2204 test_array [0] = 0; 2205 return test_array [0]; 2187 2206 2188 2207 ; … … 2200 2219 { 2201 2220 static int test_array [1 - 2 * !(($2) <= $ac_mid)]; 2202 test_array [0] = 0 2221 test_array [0] = 0; 2222 return test_array [0]; 2203 2223 2204 2224 ; … … 2226 2246 { 2227 2247 static int test_array [1 - 2 * !(($2) < 0)]; 2228 test_array [0] = 0 2248 test_array [0] = 0; 2249 return test_array [0]; 2229 2250 2230 2251 ; … … 2242 2263 { 2243 2264 static int test_array [1 - 2 * !(($2) >= $ac_mid)]; 2244 test_array [0] = 0 2265 test_array [0] = 0; 2266 return test_array [0]; 2245 2267 2246 2268 ; … … 2276 2298 { 2277 2299 static int test_array [1 - 2 * !(($2) <= $ac_mid)]; 2278 test_array [0] = 0 2300 test_array [0] = 0; 2301 return test_array [0]; 2279 2302 2280 2303 ; … … 2349 2372 2350 2373 It was created by Rappture $as_me 1.1, which was 2351 generated by GNU Autoconf 2.6 8. Invocation command line was2374 generated by GNU Autoconf 2.69. Invocation command line was 2352 2375 2353 2376 $ $0 $@ … … 2799 2822 for ac_prog in ginstall scoinst install; do 2800 2823 for ac_exec_ext in '' $ac_executable_extensions; do 2801 if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then2824 if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then 2802 2825 if test $ac_prog = install && 2803 2826 grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then … … 2873 2896 test -z "$as_dir" && as_dir=. 2874 2897 for ac_exec_ext in '' $ac_executable_extensions; do 2875 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then2898 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 2876 2899 ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" 2877 2900 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 2913 2936 test -z "$as_dir" && as_dir=. 2914 2937 for ac_exec_ext in '' $ac_executable_extensions; do 2915 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then2938 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 2916 2939 ac_cv_prog_ac_ct_RANLIB="ranlib" 2917 2940 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 2972 2995 for ac_prog in mkdir gmkdir; do 2973 2996 for ac_exec_ext in '' $ac_executable_extensions; do 2974 { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }|| continue2997 as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue 2975 2998 case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 2976 2999 'mkdir (GNU coreutils) '* | \ … … 3056 3079 test -z "$as_dir" && as_dir=. 3057 3080 for ac_exec_ext in '' $ac_executable_extensions; do 3058 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then3081 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 3059 3082 ac_cv_prog_CC="${ac_tool_prefix}gcc" 3060 3083 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 3096 3119 test -z "$as_dir" && as_dir=. 3097 3120 for ac_exec_ext in '' $ac_executable_extensions; do 3098 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then3121 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 3099 3122 ac_cv_prog_ac_ct_CC="gcc" 3100 3123 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 3149 3172 test -z "$as_dir" && as_dir=. 3150 3173 for ac_exec_ext in '' $ac_executable_extensions; do 3151 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then3174 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 3152 3175 ac_cv_prog_CC="${ac_tool_prefix}cc" 3153 3176 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 3190 3213 test -z "$as_dir" && as_dir=. 3191 3214 for ac_exec_ext in '' $ac_executable_extensions; do 3192 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then3215 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 3193 3216 if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then 3194 3217 ac_prog_rejected=yes … … 3248 3271 test -z "$as_dir" && as_dir=. 3249 3272 for ac_exec_ext in '' $ac_executable_extensions; do 3250 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then3273 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 3251 3274 ac_cv_prog_CC="$ac_tool_prefix$ac_prog" 3252 3275 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 3292 3315 test -z "$as_dir" && as_dir=. 3293 3316 for ac_exec_ext in '' $ac_executable_extensions; do 3294 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then3317 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 3295 3318 ac_cv_prog_ac_ct_CC="$ac_prog" 3296 3319 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 3738 3761 #include <stdarg.h> 3739 3762 #include <stdio.h> 3740 #include <sys/types.h> 3741 #include <sys/stat.h> 3763 struct stat; 3742 3764 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ 3743 3765 struct buf { int x; }; … … 3852 3874 test -z "$as_dir" && as_dir=. 3853 3875 for ac_exec_ext in '' $ac_executable_extensions; do 3854 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then3876 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 3855 3877 ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" 3856 3878 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 3896 3918 test -z "$as_dir" && as_dir=. 3897 3919 for ac_exec_ext in '' $ac_executable_extensions; do 3898 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then3920 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 3899 3921 ac_cv_prog_ac_ct_CXX="$ac_prog" 3900 3922 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 4105 4127 test -z "$as_dir" && as_dir=. 4106 4128 for ac_exec_ext in '' $ac_executable_extensions; do 4107 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then4129 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 4108 4130 ac_cv_prog_F77="$ac_tool_prefix$ac_prog" 4109 4131 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 4149 4171 test -z "$as_dir" && as_dir=. 4150 4172 for ac_exec_ext in '' $ac_executable_extensions; do 4151 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then4173 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 4152 4174 ac_cv_prog_ac_ct_F77="$ac_prog" 4153 4175 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 4456 4478 for ac_exec_ext in '' $ac_executable_extensions; do 4457 4479 ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" 4458 { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; }|| continue4480 as_fn_executable_p "$ac_path_GREP" || continue 4459 4481 # Check for GNU ac_path_GREP and select it if it is found. 4460 4482 # Check for GNU $ac_path_GREP … … 4522 4544 for ac_exec_ext in '' $ac_executable_extensions; do 4523 4545 ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" 4524 { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; }|| continue4546 as_fn_executable_p "$ac_path_EGREP" || continue 4525 4547 # Check for GNU ac_path_EGREP and select it if it is found. 4526 4548 # Check for GNU $ac_path_EGREP … … 4959 4981 4960 4982 else 4961 as_fn_error $? "ncurse rs library missing?" "$LINENO" 54983 as_fn_error $? "ncurses library missing?" "$LINENO" 5 4962 4984 fi 4963 4985 … … 5605 5627 test -z "$as_dir" && as_dir=. 5606 5628 for ac_exec_ext in '' $ac_executable_extensions; do 5607 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then5629 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 5608 5630 ac_cv_prog_AR="ar" 5609 5631 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 7339 7361 test -z "$as_dir" && as_dir=. 7340 7362 for ac_exec_ext in '' $ac_executable_extensions; do 7341 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then7363 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 7342 7364 ac_cv_path_TCLSH="$as_dir/$ac_word$ac_exec_ext" 7343 7365 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 7381 7403 test -z "$as_dir" && as_dir=. 7382 7404 for ac_exec_ext in '' $ac_executable_extensions; do 7383 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then7405 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 7384 7406 ac_cv_path_TCLSH="$as_dir/$ac_word$ac_exec_ext" 7385 7407 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 7482 7504 test -z "$as_dir" && as_dir=. 7483 7505 for ac_exec_ext in '' $ac_executable_extensions; do 7484 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then7506 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 7485 7507 ac_cv_path_MATLAB="$as_dir/$ac_word$ac_exec_ext" 7486 7508 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 7524 7546 test -z "$as_dir" && as_dir=. 7525 7547 for ac_exec_ext in '' $ac_executable_extensions; do 7526 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then7548 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 7527 7549 ac_cv_path_MATLAB="$as_dir/$ac_word$ac_exec_ext" 7528 7550 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 7574 7596 test -z "$as_dir" && as_dir=. 7575 7597 for ac_exec_ext in '' $ac_executable_extensions; do 7576 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then7598 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 7577 7599 ac_cv_path_MEX="$as_dir/$ac_word$ac_exec_ext" 7578 7600 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 7614 7636 test -z "$as_dir" && as_dir=. 7615 7637 for ac_exec_ext in '' $ac_executable_extensions; do 7616 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then7638 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 7617 7639 ac_cv_path_MEXEXT="$as_dir/$ac_word$ac_exec_ext" 7618 7640 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 7665 7687 test -z "$as_dir" && as_dir=. 7666 7688 for ac_exec_ext in '' $ac_executable_extensions; do 7667 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then7689 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 7668 7690 ac_cv_path_MCC="$as_dir/$ac_word$ac_exec_ext" 7669 7691 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 7727 7749 test -z "$as_dir" && as_dir=. 7728 7750 for ac_exec_ext in '' $ac_executable_extensions; do 7729 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then7751 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 7730 7752 ac_cv_path_OCTAVE="$as_dir/$ac_word$ac_exec_ext" 7731 7753 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 7767 7789 test -z "$as_dir" && as_dir=. 7768 7790 for ac_exec_ext in '' $ac_executable_extensions; do 7769 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then7791 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 7770 7792 ac_cv_path_MKOCTFILE="$as_dir/$ac_word$ac_exec_ext" 7771 7793 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 7854 7876 test -z "$as_dir" && as_dir=. 7855 7877 for ac_exec_ext in '' $ac_executable_extensions; do 7856 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then7878 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 7857 7879 ac_cv_path_mkoctfile3="$as_dir/$ac_word$ac_exec_ext" 7858 7880 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 7914 7936 test -z "$as_dir" && as_dir=. 7915 7937 for ac_exec_ext in '' $ac_executable_extensions; do 7916 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then7938 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 7917 7939 ac_cv_path_mkoctfile2="$as_dir/$ac_word$ac_exec_ext" 7918 7940 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 7988 8010 test -z "$as_dir" && as_dir=. 7989 8011 for ac_exec_ext in '' $ac_executable_extensions; do 7990 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then8012 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 7991 8013 ac_cv_path_PERL="$as_dir/$ac_word$ac_exec_ext" 7992 8014 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 8029 8051 test -z "$as_dir" && as_dir=. 8030 8052 for ac_exec_ext in '' $ac_executable_extensions; do 8031 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then8053 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 8032 8054 ac_cv_path_XSUBPP="$as_dir/$ac_word$ac_exec_ext" 8033 8055 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 8070 8092 test -z "$as_dir" && as_dir=. 8071 8093 for ac_exec_ext in '' $ac_executable_extensions; do 8072 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then8094 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 8073 8095 ac_cv_path_PERL="$as_dir/$ac_word$ac_exec_ext" 8074 8096 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 8110 8132 test -z "$as_dir" && as_dir=. 8111 8133 for ac_exec_ext in '' $ac_executable_extensions; do 8112 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then8134 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 8113 8135 ac_cv_path_XSUBPP="$as_dir/$ac_word$ac_exec_ext" 8114 8136 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 8192 8214 test -z "$as_dir" && as_dir=. 8193 8215 for ac_exec_ext in '' $ac_executable_extensions; do 8194 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then8216 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 8195 8217 ac_cv_path_PYTHON="$as_dir/$ac_word$ac_exec_ext" 8196 8218 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 8234 8256 test -z "$as_dir" && as_dir=. 8235 8257 for ac_exec_ext in '' $ac_executable_extensions; do 8236 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then8258 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 8237 8259 ac_cv_path_PYTHON="$as_dir/$ac_word$ac_exec_ext" 8238 8260 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 8355 8377 test -z "$as_dir" && as_dir=. 8356 8378 for ac_exec_ext in '' $ac_executable_extensions; do 8357 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then8379 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 8358 8380 ac_cv_path_JAVA="$as_dir/$ac_word$ac_exec_ext" 8359 8381 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 8395 8417 test -z "$as_dir" && as_dir=. 8396 8418 for ac_exec_ext in '' $ac_executable_extensions; do 8397 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then8419 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 8398 8420 ac_cv_path_JAVAC="$as_dir/$ac_word$ac_exec_ext" 8399 8421 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 8435 8457 test -z "$as_dir" && as_dir=. 8436 8458 for ac_exec_ext in '' $ac_executable_extensions; do 8437 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then8459 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 8438 8460 ac_cv_path_JAVAH="$as_dir/$ac_word$ac_exec_ext" 8439 8461 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 8477 8499 test -z "$as_dir" && as_dir=. 8478 8500 for ac_exec_ext in '' $ac_executable_extensions; do 8479 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then8501 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 8480 8502 ac_cv_path_JAVA="$as_dir/$ac_word$ac_exec_ext" 8481 8503 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 8518 8540 test -z "$as_dir" && as_dir=. 8519 8541 for ac_exec_ext in '' $ac_executable_extensions; do 8520 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then8542 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 8521 8543 ac_cv_path_JAVAC="$as_dir/$ac_word$ac_exec_ext" 8522 8544 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 8559 8581 test -z "$as_dir" && as_dir=. 8560 8582 for ac_exec_ext in '' $ac_executable_extensions; do 8561 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then8583 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 8562 8584 ac_cv_path_JAVAH="$as_dir/$ac_word$ac_exec_ext" 8563 8585 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 8593 8615 ${JAVA_HOME} \ 8594 8616 /apps/java/jdk1.6* \ 8617 /usr/lib/jvm/java-6-openjdk \ 8618 /usr/lib/jvm/icedtea-6 \ 8595 8619 /usr/lib/jvm/*sun-1.6* \ 8596 8620 /opt/sun-jdk-1.6* \ 8621 /usr/lib/jvm/icedtea-7 \ 8597 8622 /opt/icedtea6-* \ 8598 8623 /opt/sun-jdk-1.5* \ … … 8647 8672 test -z "$as_dir" && as_dir=. 8648 8673 for ac_exec_ext in '' $ac_executable_extensions; do 8649 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then8674 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 8650 8675 ac_cv_path_R="$as_dir/$ac_word$ac_exec_ext" 8651 8676 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 8689 8714 test -z "$as_dir" && as_dir=. 8690 8715 for ac_exec_ext in '' $ac_executable_extensions; do 8691 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then8716 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 8692 8717 ac_cv_path_R="$as_dir/$ac_word$ac_exec_ext" 8693 8718 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 8748 8773 test -z "$as_dir" && as_dir=. 8749 8774 for ac_exec_ext in '' $ac_executable_extensions; do 8750 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then8775 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 8751 8776 ac_cv_path_RUBY="$as_dir/$ac_word$ac_exec_ext" 8752 8777 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 8790 8815 test -z "$as_dir" && as_dir=. 8791 8816 for ac_exec_ext in '' $ac_executable_extensions; do 8792 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then8817 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 8793 8818 ac_cv_path_RUBY="$as_dir/$ac_word$ac_exec_ext" 8794 8819 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 8840 8865 for ac_exec_ext in '' $ac_executable_extensions; do 8841 8866 ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" 8842 { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; }|| continue8867 as_fn_executable_p "$ac_path_SED" || continue 8843 8868 # Check for GNU ac_path_SED and select it if it is found. 8844 8869 # Check for GNU $ac_path_SED … … 8925 8950 test -z "$as_dir" && as_dir=. 8926 8951 for ac_exec_ext in '' $ac_executable_extensions; do 8927 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then8952 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then 8928 8953 ac_cv_prog_AWK="$ac_prog" 8929 8954 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 … … 10026 10051 fi 10027 10052 10053 for ac_func in sws_getCachedContext 10054 do : 10055 ac_fn_cxx_check_func "$LINENO" "sws_getCachedContext" "ac_cv_func_sws_getCachedContext" 10056 if test "x$ac_cv_func_sws_getCachedContext" = xyes; then : 10057 cat >>confdefs.h <<_ACEOF 10058 #define HAVE_SWS_GETCACHEDCONTEXT 1 10059 _ACEOF 10060 10061 fi 10062 done 10063 10064 for ac_func in img_convert 10065 do : 10066 ac_fn_cxx_check_func "$LINENO" "img_convert" "ac_cv_func_img_convert" 10067 if test "x$ac_cv_func_img_convert" = xyes; then : 10068 cat >>confdefs.h <<_ACEOF 10069 #define HAVE_IMG_CONVERT 1 10070 _ACEOF 10071 10072 fi 10073 done 10074 10075 for ac_func in sws_scale 10076 do : 10077 ac_fn_cxx_check_func "$LINENO" "sws_scale" "ac_cv_func_sws_scale" 10078 if test "x$ac_cv_func_sws_scale" = xyes; then : 10079 cat >>confdefs.h <<_ACEOF 10080 #define HAVE_SWS_SCALE 1 10081 _ACEOF 10082 10083 fi 10084 done 10028 10085 10029 10086 cat confdefs.h - <<_ACEOF >conftest.$ac_ext … … 10152 10209 10153 10210 10154 ac_config_files="$ac_config_files Makefile packages/Makefile src/Makefile src/core/Makefile src/core2/Makefile src/objects/Makefile src/objects/RpHash.h gui/Makefile gui/apps/Makefile gui/apps/about gui/apps/copy_rappture_examples gui/apps/encodedata gui/apps/rappture gui/apps/rappture-csh.env gui/apps/rappture.env gui/apps/rappture.use gui/apps/rerun gui/apps/simsim gui/apps/xmldiff gui/pkgIndex.tcl gui/scripts/Makefile gui/src/Makefile builder/Makefile builder/pkgIndex.tcl builder/scripts/Makefile tester/Makefile tester/pkgIndex.tcl tester/scripts/Makefile lang/Makefile lang/java/Makefile lang/java/rappture/Makefile lang/perl/Makefile lang/perl/Makefile.PL lang/python/Makefile lang/python/setup.py lang/matlab/Makefile lang/octave/Makefile lang/octave/octave2/Makefile lang/octave/octave3/Makefile lang/R/Makefile lang/ruby/Makefile lang/ruby/build.rb lang/tcl/Makefile lang/tcl/pkgIndex.tcl lang/tcl/src/Makefile lang/tcl/scripts/Makefile lang/tcl/tests/Makefile lib/Makefile examples/3D/Makefile examples/Makefile examples/app-fermi/2.0/Makefile examples/app-fermi/Makefile examples/app-fermi/cee/Makefile examples/app-fermi/fortran/Makefile examples/app-fermi/java/Makefile examples/app-fermi/matlab/Makefile examples/app-fermi/matlab/compiled/Makefile examples/app-fermi/matlab/uncompiled/Makefile examples/app-fermi/octave/octave2/Makefile examples/app-fermi/octave/octave3/Makefile examples/app-fermi/octave/Makefile examples/app-fermi/perl/Makefile examples/app-fermi/python/Makefile examples/app-fermi/ruby/Makefile examples/app-fermi/tcl/Makefile examples/app-fermi/wrapper/Makefile examples/app-fermi/wrapper/cee/Makefile examples/app-fermi/wrapper/perl/Makefile examples/app-fermi/wrapper/python/Makefile examples/app-fermi/wrapper/tcl/Makefile examples/app-fermi/R/Makefile examples/c-example/Makefile examples/canvas/Makefile examples/demo.bash examples/flow/Makefile examples/flow/demo1/Makefile examples/flow/demo2/Makefile examples/flow/demo3/Makefile examples/graph/Makefile examples/objects/Makefile examples/objects/axis/Makefile examples/objects/contour/Makefile examples/objects/curve/Makefile examples/objects/dxWriter/Makefile examples/objects/floatBuffer/Makefile examples/objects/histogram/Makefile examples/objects/library/Makefile examples/objects/number/Makefile examples/objects/path/Makefile examples/objects/plot/Makefile examples/objects/scatter/Makefile examples/objects/string/Makefile examples/objects/tree/Makefile examples/objects/xmlparser/Makefile examples/zoo/Makefile examples/zoo/binary/Makefile examples/zoo/boolean/Makefile examples/zoo/choice/Makefile examples/zoo/cloud/Makefile examples/zoo/cloud/matlab/Makefile examples/zoo/curve/Makefile examples/zoo/ enable/Makefile examples/zoo/field/Makefile examples/zoo/group/Makefile examples/zoo/histogram/Makefile examples/zoo/image/Makefile examples/zoo/image/docs/Makefile examples/zoo/image/examples/Makefile examples/zoo/integer/Makefile examples/zoo/integer2/Makefile examples/zoo/loader/Makefile examples/zoo/loader/examples/Makefile examples/zoo/loadrun/Makefile examples/zoo/log/Makefile examples/zoo/note/Makefile examples/zoo/note/docs/Makefile examples/zoo/number/Makefile examples/zoo/number2/Makefile examples/zoo/parallelepiped/Makefile examples/zoo/periodicelement/Makefile examples/zoo/phase/Makefile examples/zoo/sequence/Makefile examples/zoo/sequence/examples/Makefile examples/zoo/string/Makefile examples/zoo/structure/Makefile examples/zoo/structure/examples/Makefile examples/zoo/table/Makefile examples/zoo/unirect2d/Makefile video/Makefile video/pkgIndex.tcl oldtest/Makefile oldtest/src/Makefile"10211 ac_config_files="$ac_config_files Makefile packages/Makefile src/Makefile src/core/Makefile src/core2/Makefile src/objects/Makefile src/objects/RpHash.h gui/Makefile gui/apps/Makefile gui/apps/about gui/apps/copy_rappture_examples gui/apps/encodedata gui/apps/rappture gui/apps/rappture-csh.env gui/apps/rappture.env gui/apps/rappture.use gui/apps/rerun gui/apps/simsim gui/apps/xmldiff gui/pkgIndex.tcl gui/scripts/Makefile gui/src/Makefile builder/Makefile builder/pkgIndex.tcl builder/scripts/Makefile tester/Makefile tester/pkgIndex.tcl tester/scripts/Makefile lang/Makefile lang/java/Makefile lang/java/rappture/Makefile lang/perl/Makefile lang/perl/Makefile.PL lang/python/Makefile lang/python/setup.py lang/matlab/Makefile lang/octave/Makefile lang/octave/octave2/Makefile lang/octave/octave3/Makefile lang/R/Makefile lang/ruby/Makefile lang/ruby/build.rb lang/tcl/Makefile lang/tcl/pkgIndex.tcl lang/tcl/src/Makefile lang/tcl/scripts/Makefile lang/tcl/tests/Makefile lib/Makefile examples/3D/Makefile examples/Makefile examples/app-fermi/2.0/Makefile examples/app-fermi/Makefile examples/app-fermi/cee/Makefile examples/app-fermi/fortran/Makefile examples/app-fermi/java/Makefile examples/app-fermi/matlab/Makefile examples/app-fermi/matlab/compiled/Makefile examples/app-fermi/matlab/uncompiled/Makefile examples/app-fermi/octave/octave2/Makefile examples/app-fermi/octave/octave3/Makefile examples/app-fermi/octave/Makefile examples/app-fermi/perl/Makefile examples/app-fermi/python/Makefile examples/app-fermi/ruby/Makefile examples/app-fermi/tcl/Makefile examples/app-fermi/wrapper/Makefile examples/app-fermi/wrapper/cee/Makefile examples/app-fermi/wrapper/perl/Makefile examples/app-fermi/wrapper/python/Makefile examples/app-fermi/wrapper/tcl/Makefile examples/app-fermi/R/Makefile examples/c-example/Makefile examples/canvas/Makefile examples/demo.bash examples/flow/Makefile examples/flow/demo1/Makefile examples/flow/demo2/Makefile examples/flow/demo3/Makefile examples/graph/Makefile examples/objects/Makefile examples/objects/axis/Makefile examples/objects/contour/Makefile examples/objects/curve/Makefile examples/objects/dxWriter/Makefile examples/objects/floatBuffer/Makefile examples/objects/histogram/Makefile examples/objects/library/Makefile examples/objects/number/Makefile examples/objects/path/Makefile examples/objects/plot/Makefile examples/objects/scatter/Makefile examples/objects/string/Makefile examples/objects/tree/Makefile examples/objects/xmlparser/Makefile examples/zoo/Makefile examples/zoo/binary/Makefile examples/zoo/boolean/Makefile examples/zoo/choice/Makefile examples/zoo/cloud/Makefile examples/zoo/cloud/matlab/Makefile examples/zoo/curve/Makefile examples/zoo/drawing/Makefile examples/zoo/enable/Makefile examples/zoo/field/Makefile examples/zoo/group/Makefile examples/zoo/histogram/Makefile examples/zoo/image/Makefile examples/zoo/image/docs/Makefile examples/zoo/image/examples/Makefile examples/zoo/integer/Makefile examples/zoo/integer2/Makefile examples/zoo/loader/Makefile examples/zoo/loader/examples/Makefile examples/zoo/log/Makefile examples/zoo/note/Makefile examples/zoo/note/docs/Makefile examples/zoo/number/Makefile examples/zoo/number2/Makefile examples/zoo/parallelepiped/Makefile examples/zoo/periodicelement/Makefile examples/zoo/phase/Makefile examples/zoo/sequence/Makefile examples/zoo/sequence/examples/Makefile examples/zoo/string/Makefile examples/zoo/structure/Makefile examples/zoo/structure/examples/Makefile examples/zoo/table/Makefile examples/zoo/unirect2d/Makefile video/Makefile video/pkgIndex.tcl oldtest/Makefile oldtest/src/Makefile" 10155 10212 10156 10213 cat >confcache <<\_ACEOF … … 10562 10619 # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. 10563 10620 # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. 10564 # In both cases, we have to default to `cp -p '.10621 # In both cases, we have to default to `cp -pR'. 10565 10622 ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || 10566 as_ln_s='cp -p '10623 as_ln_s='cp -pR' 10567 10624 elif ln conf$$.file conf$$ 2>/dev/null; then 10568 10625 as_ln_s=ln 10569 10626 else 10570 as_ln_s='cp -p '10627 as_ln_s='cp -pR' 10571 10628 fi 10572 10629 else 10573 as_ln_s='cp -p '10630 as_ln_s='cp -pR' 10574 10631 fi 10575 10632 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file … … 10631 10688 fi 10632 10689 10633 if test -x / >/dev/null 2>&1; then 10634 as_test_x='test -x' 10635 else 10636 if ls -dL / >/dev/null 2>&1; then 10637 as_ls_L_option=L 10638 else 10639 as_ls_L_option= 10640 fi 10641 as_test_x=' 10642 eval sh -c '\'' 10643 if test -d "$1"; then 10644 test -d "$1/."; 10645 else 10646 case $1 in #( 10647 -*)set "./$1";; 10648 esac; 10649 case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( 10650 ???[sx]*):;;*)false;;esac;fi 10651 '\'' sh 10652 ' 10653 fi 10654 as_executable_p=$as_test_x 10690 10691 # as_fn_executable_p FILE 10692 # ----------------------- 10693 # Test if FILE is an executable regular file. 10694 as_fn_executable_p () 10695 { 10696 test -f "$1" && test -x "$1" 10697 } # as_fn_executable_p 10698 as_test_x='test -x' 10699 as_executable_p=as_fn_executable_p 10655 10700 10656 10701 # Sed expression to map a string onto a valid CPP name. … … 10674 10719 ac_log=" 10675 10720 This file was extended by Rappture $as_me 1.1, which was 10676 generated by GNU Autoconf 2.6 8. Invocation command line was10721 generated by GNU Autoconf 2.69. Invocation command line was 10677 10722 10678 10723 CONFIG_FILES = $CONFIG_FILES … … 10736 10781 ac_cs_version="\\ 10737 10782 Rappture config.status 1.1 10738 configured by $0, generated by GNU Autoconf 2.6 8,10783 configured by $0, generated by GNU Autoconf 2.69, 10739 10784 with options \\"\$ac_cs_config\\" 10740 10785 10741 Copyright (C) 201 0Free Software Foundation, Inc.10786 Copyright (C) 2012 Free Software Foundation, Inc. 10742 10787 This config.status script is free software; the Free Software Foundation 10743 10788 gives unlimited permission to copy, distribute and modify it." … … 10830 10875 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 10831 10876 if \$ac_cs_recheck; then 10832 set X '$SHELL''$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion10877 set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion 10833 10878 shift 10834 10879 \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 … … 10961 11006 "examples/zoo/cloud/matlab/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/cloud/matlab/Makefile" ;; 10962 11007 "examples/zoo/curve/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/curve/Makefile" ;; 11008 "examples/zoo/drawing/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/drawing/Makefile" ;; 10963 11009 "examples/zoo/enable/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/enable/Makefile" ;; 10964 11010 "examples/zoo/field/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/field/Makefile" ;; … … 10972 11018 "examples/zoo/loader/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/loader/Makefile" ;; 10973 11019 "examples/zoo/loader/examples/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/loader/examples/Makefile" ;; 10974 "examples/zoo/loadrun/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/loadrun/Makefile" ;;10975 11020 "examples/zoo/log/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/log/Makefile" ;; 10976 11021 "examples/zoo/note/Makefile") CONFIG_FILES="$CONFIG_FILES examples/zoo/note/Makefile" ;; -
branches/nanovis2/configure.in
r2959 r3175 61 61 AC_CHECK_LIB(m, main,,AC_MSG_ERROR(librappture requires libm)) 62 62 63 AC_CHECK_LIB(ncurses, clrtoeol,,AC_MSG_ERROR([ncurse rs library missing?]))63 AC_CHECK_LIB(ncurses, clrtoeol,,AC_MSG_ERROR([ncurses library missing?])) 64 64 AC_CHECK_HEADERS(ncurses.h,,AC_MSG_WARN(ncurses headers missing ?)) 65 65 … … 544 544 examples/zoo/cloud/matlab/Makefile 545 545 examples/zoo/curve/Makefile 546 examples/zoo/drawing/Makefile 546 547 examples/zoo/enable/Makefile 547 548 examples/zoo/field/Makefile … … 555 556 examples/zoo/loader/Makefile 556 557 examples/zoo/loader/examples/Makefile 557 examples/zoo/loadrun/Makefile558 558 examples/zoo/log/Makefile 559 559 examples/zoo/note/Makefile -
branches/nanovis2/examples/demo.bash.in
r1738 r3175 12 12 13 13 ZOO="\ 14 ./zoo/log \ 15 ./zoo/note \ 16 ./zoo/cloud \ 17 ./zoo/cloud \ 18 ./zoo/curve \ 19 ./zoo/field \ 20 ./zoo/group \ 21 ./zoo/image \ 22 ./zoo/phase \ 23 ./zoo/table \ 24 ./zoo/structure \ 25 ./zoo/loadrun \ 26 ./zoo/unirect2d \ 27 ./zoo/binary \ 28 ./zoo/choice \ 29 ./zoo/enable \ 30 ./zoo/loader \ 31 ./zoo/number \ 32 ./zoo/string \ 33 ./zoo/number2 \ 34 ./zoo/sequence \ 35 ./zoo/boolean \ 36 ./zoo/integer \ 37 ./zoo/integer2 \ 14 ./zoo/binary 15 ./zoo/boolean 16 ./zoo/choice 17 ./zoo/cloud/matlab 18 ./zoo/cloud 19 ./zoo/curve 20 ./zoo/drawing 21 ./zoo/enable 22 ./zoo/field 23 ./zoo/group 24 ./zoo/histogram 25 ./zoo/image 26 ./zoo/integer 27 ./zoo/integer2 28 ./zoo/loader 29 ./zoo/log 30 ./zoo/note 31 ./zoo/number 32 ./zoo/number2 33 ./zoo/parallelepiped 34 ./zoo/periodicelement 35 ./zoo/phase 36 ./zoo/sequence 37 ./zoo/string 38 ./zoo/structure 39 ./zoo/table 40 ./zoo/unirect2d 38 41 " 39 42 40 43 FLOW=" \ 41 ./flow/demo1 \ 42 ./flow/demo2 \ 43 ./flow/demo3 \ 44 ./flow" 45 44 ./flow/demo1 45 ./flow/demo2 46 ./flow/demo3 47 ./flow 48 " 46 49 FERMI=" \ 47 ./app-fermi/cee \ 48 ./app-fermi/tcl \ 49 ./app-fermi/java \ 50 ./app-fermi/perl \ 51 ./app-fermi/ruby \ 52 ./app-fermi/fortran \ 53 ./app-fermi/matlab \ 54 ./app-fermi/matlab \ 55 ./app-fermi/octave/2 \ 56 ./app-fermi/octave/3 \ 57 ./app-fermi/python \ 58 ./app-fermi/wrapper/cee \ 59 ./app-fermi/wrapper/tcl \ 60 ./app-fermi/wrapper/python \ 50 ./app-fermi/cee 51 ./app-fermi/fortran 52 ./app-fermi/tcl 53 ./app-fermi/perl 54 ./app-fermi/python 55 ./app-fermi/ruby 56 ./app-fermi/java 57 ./app-fermi/R 58 ./app-fermi/matlab/uncompiled 59 ./app-fermi/matlab/compiled 60 ./app-fermi/octave/octave2 61 ./app-fermi/octave/octave3 62 ./app-fermi/wrapper/cee 63 ./app-fermi/wrapper/tcl 64 ./app-fermi/wrapper/perl 65 ./app-fermi/wrapper/python 61 66 " 62 67 -
branches/nanovis2/examples/graph/tool.xml
r555 r3175 13 13 </about> 14 14 <size>30x5</size> 15 <default>2*x+1</default> 15 16 </string> 16 17 <number id="min"> -
branches/nanovis2/examples/zoo/Makefile.in
r2301 r3175 20 20 cloud \ 21 21 curve \ 22 drawing \ 22 23 enable \ 23 24 field \ … … 28 29 integer2 \ 29 30 loader \ 30 loadrun \31 31 log \ 32 32 note \ -
branches/nanovis2/examples/zoo/drawing/Makefile.in
r2959 r3175 23 23 all: 24 24 25 install: 25 install: install-files install-images 26 27 install-files: 26 28 $(MKDIR_P) -m 0755 $(destdir) 27 29 for i in $(FILES) ; do \ 28 30 $(INSTALL) -m 0444 $$i $(destdir) ; \ 31 done 32 33 install-images: 34 $(MKDIR_P) -m 0755 $(destdir)/images 35 for i in $(srcdir)/images/* ; do \ 36 $(INSTALL) -m 0444 $$i $(destdir)/images ; \ 29 37 done 30 38 -
branches/nanovis2/examples/zoo/drawing/drawing.tcl
r2959 r3175 13 13 set driver [Rappture::library [lindex $argv 0]] 14 14 15 set title [$driver get input.(title).current] 16 set indeck [$driver get input.(indeck).current] 15 set value [$driver get input.choice(analysis).current] 16 append out "Analysis Choice: $value\n" 17 set value [$driver get input.number(trapezoid_top).current] 18 append out "Trapezoid Top: $value\n" 19 set value [$driver get input.number(substrate_length).current] 20 append out "Substrate Length: $value\n" 21 set value [$driver get input.number(feature_length).current] 22 append out "Feature Length: $value\n" 23 set value [$driver get input.number(feature_height).current] 24 append out "Feature Height: $value\n" 25 set value [$driver get input.string(indeck).current] 26 append out "String: $value\n" 17 27 18 $driver put output.string(outt).about.label "Echo of title" 19 $driver put output.string(outt).current $title 20 $driver put output.string(outi).about.label "Echo of input" 21 $driver put output.string(outi).current $indeck 28 $driver put output.string(out).about.label "Echo of inputs" 29 $driver put output.string(out).current $out 22 30 23 31 # save the updated XML describing the run... -
branches/nanovis2/examples/zoo/drawing/tool.xml
r2959 r3175 1 1 <?xml version="1.0"?> 2 2 <run> 3 <tool>3 <tool> 4 4 <title>drawing</title> 5 5 <about>Example of a Rappture <drawing> object. … … 13 13 tclsh @tool/drawing.tcl @driver 14 14 </command> 15 </tool> 16 <input> 15 <layout>wizard</layout> 16 </tool> 17 <input> 18 <boolean id="trapezoid_top"> 19 <about> <label>Enable trapezoid top</label> </about> 20 <default>off</default> 21 </boolean> 17 22 <drawing> 18 <about> 19 <label>Title</label> 20 <description>This text will be used as the title for all plots.</description> 21 <bbox>-.1 0 1.1 1</bbox> 22 </about> 23 <components> 24 <line> 25 <coords>.25 .75 .75 .75</coords> 26 <color>black</color> 27 <linewidth>2</linewidth> 28 <arrow>both</arrow> 29 </line> 30 <text> 31 <coords>.5 .8</coords> 32 <color>black</color> 33 <text>Feature Length = 50 nm</text> 34 <font>Arial 9</font> 35 <anchor>c</anchor> 36 </text> 37 <line> 38 <coords>.78 .4 .78 .7</coords> 39 <color>black</color> 40 <linewidth>2</linewidth> 41 <arrow>both</arrow> 42 </line> 43 <text> 44 <coords>.82 .48</coords> 45 <color>black</color> 46 <text>Feature 47 Height = 30 nm</text> 48 <font>Arial 9</font> 49 <anchor>nw</anchor> 50 </text> 51 <line> 52 <coords>0 .9 1 .9</coords> 53 <color>black</color> 54 <linewidth>2</linewidth> 55 <arrow>both</arrow> 56 </line> 57 <text> 58 <coords>.5 .91</coords> 59 <color>black</color> 60 <text>Substrate Length = 100 nm</text> 61 <font>Arial 9</font> 62 <anchor>n</anchor> 63 </text> 64 <line> 65 <coords>.35 .35 .65 .35</coords> 66 <color>black</color> 67 <linewidth>2</linewidth> 68 <arrow>both</arrow> 69 </line> 70 <text> 71 <coords>.5 .30</coords> 72 <color>black</color> 73 <text>Length of Trapezoid Top = 30 nm</text> 74 <font>Arial 9</font> 75 <anchor>s</anchor> 76 </text> 77 <line id="polyline"> 78 <coords>0 .7 .25 .7 .35 .4 .65 .4 .75 .7 1 .7</coords> 79 <color>red</color> 80 <linewidth>2</linewidth> 81 </line> 82 <grid> 83 <xcoords>0 .1 .2 .3 .4 .5 .6 .7 .8 .9 1</xcoords> 84 <ycoords>.2 .3 .4 .5 .6 .7</ycoords> 85 <color>grey70</color> 86 <linewidth>1</linewidth> 87 <dash>4 2</dash> 88 </grid> 89 <string> 90 <about> 91 <label>String:</label> 92 </about> 93 <coords>.1 1.1</coords> 94 <color>blue</color> 95 <font>Arial 9</font> 96 <anchor>nw</anchor> 97 <default>value</default> 98 </string> 99 <number> 100 <about> 101 <label>Number:</label> 102 </about> 103 <coords></coords> 104 <color>blue</color> 105 <font>Arial 12</font> 106 <anchor>n</anchor> 107 <default></default> 108 <min></min> 109 <max></max> 110 </number> 111 </components> 23 <about> 24 <label>Title</label> 25 <description>This text will be used as the title for all plots.</description> 26 </about> 27 <background> 28 <color>#FFFCDA</color> 29 <coordinates>-.1 0 1.1 1</coordinates> 30 <width>800</width> 31 <height>500</height> 32 </background> 33 <substitutions> 34 <variable> 35 <name>string</name> 36 <path>input.string(indeck)</path> 37 </variable> 38 <variable> 39 <name>feature_height</name> 40 <path>input.number(feature_height)</path> 41 </variable> 42 <variable> 43 <name>feature_length</name> 44 <path>input.number(feature_length)</path> 45 </variable> 46 <variable> 47 <name>trapezoid_top</name> 48 <path>input.number(trapezoid_top)</path> 49 </variable> 50 <variable> 51 <name>substrate_length</name> 52 <path>input.number(substrate_length)</path> 53 </variable> 54 <variable> 55 <name>analysis</name> 56 <path>input.choice(analysis)</path> 57 </variable> 58 </substitutions> 59 <components> 60 <grid> 61 <xcoords>0 .1 .2 .3 .4 .5 .6 .7 .8 .9 1</xcoords> 62 <ycoords>.2 .3 .4 .5 .6 .7</ycoords> 63 <color>grey70</color> 64 <linewidth>1</linewidth> 65 <dash>4 2</dash> 66 </grid> 67 <line id="feature_length"> 68 <coords>.25 .72 .75 .72</coords> 69 <color>black</color> 70 <linewidth>2</linewidth> 71 <arrow>both</arrow> 72 </line> 73 <text id="feature_length"> 74 <coords>.5 .73</coords> 75 <color>black</color> 76 <text>Feature Length = ${feature_length}</text> 77 <font>Arial 11</font> 78 <anchor>n</anchor> 79 <hotspot>inline</hotspot> 80 </text> 81 <line id="feature_height"> 82 <coords>.76 .4 .76 .7</coords> 83 <color>black</color> 84 <linewidth>2</linewidth> 85 <arrow>both</arrow> 86 </line> 87 <text id="feature_height"> 88 <coords>.77 .48</coords> 89 <color>black</color> 90 <text>Feature 91 Height = ${feature_height}</text> 92 <font>Arial 11</font> 93 <anchor>nw</anchor> 94 </text> 95 <hotspot id="feature_height"> 96 <coords>.95 .53</coords> 97 <controls>input.choice(analysis)</controls> 98 <controls>input.number(feature_height)</controls> 99 <controls>input.number(feature_length)</controls> 100 <controls>input.number(substrate_length)</controls> 101 </hotspot> 102 <line id="substrate_length"> 103 <coords>0 .8 1 .8</coords> 104 <color>black</color> 105 <linewidth>2</linewidth> 106 <arrow>both</arrow> 107 </line> 108 <text id="substrate_length"> 109 <coords>.5 .81</coords> 110 <color>black</color> 111 <text>Substrate Length = ${substrate_length}</text> 112 <font>Arial 11</font> 113 <hotspot>inline</hotspot> 114 <anchor>n</anchor> 115 </text> 116 <line id="trapezoid_top"> 117 <coords>.35 .38 .65 .38</coords> 118 <color>black</color> 119 <linewidth>2</linewidth> 120 <arrow>both</arrow> 121 </line> 122 <text id="trapezoid_top"> 123 <coords>.5 .35</coords> 124 <color>black</color> 125 <text>Length of Trapezoid Top = ${trapezoid_top}</text> 126 <font>Arial 11</font> 127 <anchor>s</anchor> 128 <hotspot>inline</hotspot> 129 </text> 130 <line id="polyline"> 131 <coords>0 .7 .25 .7 .35 .4 .65 .4 .75 .7 1 .7</coords> 132 <color>red</color> 133 <linewidth>2</linewidth> 134 </line> 135 <picture id="analysis"> 136 <coords>-.08 .06 0.17 0.15</coords> 137 <contents>file:images/${analysis}_F-d.png</contents> 138 <anchor>nw</anchor> 139 </picture> 140 <text id="analysis"> 141 <coords>.05 .4</coords> 142 <color>black</color> 143 <text>${analysis}</text> 144 <font>Arial 11</font> 145 <anchor>n</anchor> 146 <hotspot>inline</hotspot> 147 </text> 148 <text id="string"> 149 <coords>-.03 .85</coords> 150 <color>black</color> 151 <text>${string}</text> 152 <font>Arial 11</font> 153 <anchor>nw</anchor> 154 <hotspot>inline</hotspot> 155 </text> 156 </components> 112 157 </drawing> 113 114 <separator/> 115 158 <number id="feature_height"> 159 <about> 160 <label>Feature Height</label> 161 <description>Height of feature.</description> 162 </about> 163 <units>nm</units> 164 <min>10</min> 165 <max>70</max> 166 <default>30</default> 167 </number> 168 <number id="feature_length"> 169 <about> 170 <label>Feature Length</label> 171 <description>Length of feature.</description> 172 </about> 173 <units>nm</units> 174 <min>10</min> 175 <max>100</max> 176 <default>50</default> 177 </number> 178 <number id="substrate_length"> 179 <about> 180 <label>Substrate Length</label> 181 <description>Length of substrate.</description> 182 </about> 183 <units>nm</units> 184 <min>10</min> 185 <max>500</max> 186 <default>100</default> 187 </number> 188 <number id="trapezoid_top"> 189 <about> 190 <label>Trapezoid Top</label> 191 <description>Width of the Trapezoid Top.</description> 192 <enable>input.boolean(trapezoid_top)</enable> 193 </about> 194 <units>nm</units> 195 <min>10</min> 196 <max>70</max> 197 <default>30</default> 198 </number> 199 <choice id="analysis"> 200 <about> 201 <label>Type of Analysis</label> 202 <description>Determines the type of analysis to perform.</description> 203 </about> 204 <option> 205 <about> 206 <label>Hertz</label> 207 <description>Hertz analysis</description> 208 </about> 209 </option> 210 <option> 211 <about> 212 <label>LinCon</label> 213 <description>LinCon analysis</description> 214 </about> 215 </option> 216 <option> 217 <about> 218 <label>Chadwick</label> 219 <description>Chadwick analysis</description> 220 </about> 221 </option> 222 <option> 223 <about> 224 <label>DMT</label> 225 <description>DMT analysis</description> 226 </about> 227 </option> 228 <default>Chadwick</default> 229 </choice> 116 230 <string id="indeck"> 117 118 119 120 121 122 123 231 <about> 232 <label>Input</label> 233 <description>This is the control file for the program.</description> 234 <hints>EXAMPLE: .print ac vm(11) mag(i(vcc))</hints> 235 </about> 236 <size>40x10</size> 237 <default>Enter your SPICE commands 124 238 in this area. Right-click 125 239 for a menu of editing options.</default> 126 240 </string> 127 </input>241 </input> 128 242 </run> -
branches/nanovis2/examples/zoo/field/field.tcl
r1587 r3175 180 180 component "data" value 3} 181 181 182 set file "/tmp/dx[clock seconds]" 183 set fid [open $file w] 184 puts $fid $dx 185 close $fid 186 187 set fid [open "| gzip -c $file | mimencode" r] 188 $driver put output.field(f3d).component.dx [read $fid] 189 close $fid 190 191 file delete -force $file 182 set data [Rappture::encoding::encode -as zb64 $dx] 183 $driver put output.field(f3d).component.dx $data 192 184 } 193 185 -
branches/nanovis2/gui/apps/rappture.in
r2789 r3175 16 16 dir=`dirname $0` 17 17 . $dir/rappture.env 18 exec tclsh $dir/launcher.tcl "$@"18 exec tclsh $dir/launcher.tcl -- "$@" -
branches/nanovis2/gui/apps/vtkviewer-test
r2789 r3175 102 102 return $_type 103 103 } 104 public method shape {args} { 105 return "sphere" 106 } 104 107 105 108 private variable _data "" … … 116 119 global widgets 117 120 118 set file [tk_getOpenFile -title "Open VTK File "]121 set file [tk_getOpenFile -title "Open VTK File as PolyData"] 119 122 if {"" != $file && [catch { 120 123 set fid [open $file r] … … 123 126 close $fid 124 127 }] == 0} { 125 set obj [visData #auto $info " "]128 set obj [visData #auto $info "polydata"] 126 129 $widgets(vtkviewer) add $obj 127 130 } … … 150 153 151 154 # ---------------------------------------------------------------------- 152 # USAGE: send_ spheres_file155 # USAGE: send_glyphs_file 153 156 # 154 157 # Prompts the user for a text file, and then sends the text within 155 158 # that file along to the rendering widget. 156 159 # ---------------------------------------------------------------------- 157 proc send_ spheres_file {} {158 global widgets 159 160 set file [tk_getOpenFile -title "Open VTK File as Spheres"]160 proc send_glyphs_file {} { 161 global widgets 162 163 set file [tk_getOpenFile -title "Open VTK File as Glyphs"] 161 164 if {"" != $file && [catch { 162 165 set fid [open $file r] … … 165 168 close $fid 166 169 }] == 0} { 167 set obj [visData #auto $info "spheres"] 170 set obj [visData #auto $info "glyphs"] 171 $widgets(vtkviewer) add $obj 172 } 173 } 174 175 # ---------------------------------------------------------------------- 176 # USAGE: send_molecule_file 177 # 178 # Prompts the user for a text file, and then sends the text within 179 # that file along to the rendering widget. 180 # ---------------------------------------------------------------------- 181 proc send_molecule_file {} { 182 global widgets 183 184 set file [tk_getOpenFile -title "Open VTK File as Molecule"] 185 if {"" != $file && [catch { 186 set fid [open $file r] 187 fconfigure $fid -translation binary 188 set info [read $fid] 189 close $fid 190 }] == 0} { 191 set obj [visData #auto $info "molecule"] 168 192 $widgets(vtkviewer) add $obj 169 193 } … … 367 391 .mbar.file add command -label "Send VTK File..." -underline 0 -command send_file 368 392 .mbar.file add command -label "Send VTK File as Streamlines..." -underline 0 -command send_streamlines_file 369 .mbar.file add command -label "Send VTK File as Spheres..." -underline 0 -command send_spheres_file 393 .mbar.file add command -label "Send VTK File as Glyphs..." -underline 0 -command send_glyphs_file 394 .mbar.file add command -label "Send VTK File as Molecule..." -underline 0 -command send_molecule_file 370 395 .mbar.file add command -label "Load script..." -underline 0 -command load_script 371 396 .mbar.file add command -label "Reset" -underline 0 -command reset -
branches/nanovis2/gui/scripts/Makefile.in
r2992 r3175 30 30 $(srcdir)/color.tcl \ 31 31 $(srcdir)/combobox.tcl \ 32 $(srcdir)/combochecks.tcl \ 32 33 $(srcdir)/contourresult.tcl \ 33 34 $(srcdir)/controlOwner.tcl \ … … 46 47 $(srcdir)/drawingentry.tcl \ 47 48 $(srcdir)/dropdown.tcl \ 49 $(srcdir)/dropdownchecks.tcl \ 48 50 $(srcdir)/dropdownlist.tcl \ 49 51 $(srcdir)/editor.tcl \ … … 95 97 $(srcdir)/resources.tcl \ 96 98 $(srcdir)/resultset.tcl \ 99 $(srcdir)/resultselector.tcl \ 97 100 $(srcdir)/resultviewer.tcl \ 98 101 $(srcdir)/scroller.tcl \ -
branches/nanovis2/gui/scripts/analyzer.tcl
r2943 r3175 55 55 public method reset {{when -eventually}} 56 56 public method load {xmlobj} 57 public method clear {{xmlobj " "}}57 public method clear {{xmlobj "all"}} 58 58 public method download {option args} 59 59 … … 62 62 protected method _autoLabel {xmlobj path title cntVar} 63 63 protected method _fixResult {} 64 protected method _fixResultSet {args} 64 65 protected method _fixSize {} 65 66 protected method _fixSimControl {} … … 77 78 private variable _appName "" ;# Name of application 78 79 private variable _control "manual" ;# start mode 79 private variable _r uns "" ;# list of XML objects withresults80 private variable _resultset "" ;# ResultSet object with all results 80 81 private variable _pages 0 ;# number of pages for result sets 81 82 private variable _label2page ;# maps output label => result set … … 97 98 set _tool $tool 98 99 100 # use this to store all simulation results 101 set _resultset [Rappture::ResultSet ::#auto] 102 $_resultset notify add $this [itcl::code $this _fixResultSet] 103 104 # widget settings... 99 105 itk_option add hull.width hull.height 100 106 pack propagate $itk_component(hull) no … … 258 264 pack $w.top.l -side left 259 265 260 itk_component add resultselector {266 itk_component add viewselector { 261 267 Rappture::Combobox $w.top.sel -width 10 -editable no 262 268 } { … … 264 270 rename -font -textfont textFont Font 265 271 } 266 pack $itk_component( resultselector) -side left -expand yes -fill x267 bind $itk_component( resultselector) <<Value>> [itcl::code $this _fixResult]268 bind $itk_component( resultselector) <Enter> \272 pack $itk_component(viewselector) -side left -expand yes -fill x 273 bind $itk_component(viewselector) <<Value>> [itcl::code $this _fixResult] 274 bind $itk_component(viewselector) <Enter> \ 269 275 [itcl::code $this download coming] 270 276 271 Rappture::Tooltip::for $itk_component( resultselector) \277 Rappture::Tooltip::for $itk_component(viewselector) \ 272 278 "@[itcl::code $this _resultTooltip]" 273 279 274 $itk_component( resultselector) choices insert end \280 $itk_component(viewselector) choices insert end \ 275 281 --- "---" 276 282 … … 284 290 [itcl::code $this download coming] 285 291 286 $itk_component( resultselector) choices insert end \292 $itk_component(viewselector) choices insert end \ 287 293 @download [Rappture::filexfer::label download] 288 294 … … 307 313 308 314 set f [$itk_component(results) insert end -fraction 0.1] 309 itk_component add resultset { 310 Rappture::ResultSet $f.rset \ 311 -clearcommand [itcl::code $this clear] \ 312 -settingscommand [itcl::code $this _plot] \ 313 -promptcommand [itcl::code $this _simState] 314 } 315 pack $itk_component(resultset) -expand yes -fill both 316 bind $itk_component(resultset) <<Control>> [itcl::code $this _fixSize] 315 itk_component add resultselector { 316 Rappture::ResultSelector $f.rsel -resultset $_resultset \ 317 -settingscommand [itcl::code $this _plot] 318 } 319 pack $itk_component(resultselector) -expand yes -fill both 320 bind $itk_component(resultselector) <<Layout>> [itcl::code $this _fixSize] 317 321 bind $itk_component(results) <Configure> [itcl::code $this _fixSize] 318 322 … … 358 362 # ---------------------------------------------------------------------- 359 363 itcl::body Rappture::Analyzer::destructor {} { 360 foreach obj $_runs {361 itcl::delete object $obj362 }363 364 after cancel [itcl::code $this simulate] 365 $_resultset notify remove $this 366 itcl::delete object $_resultset 364 367 } 365 368 … … 378 381 # check to see if simulation is really needed 379 382 $_tool sync 380 if {[$ itk_component(resultset)contains [$_tool xml object]]383 if {[$_resultset contains [$_tool xml object]] 381 384 && ![string equal $_control "manual-resim"]} { 382 385 # not needed -- show results and return … … 466 469 # check to see if simulation is really needed 467 470 $_tool sync 468 if {![$ itk_component(resultset)contains [$_tool xml object]]471 if {![$_resultset contains [$_tool xml object]] 469 472 || [string equal $_control "manual-resim"]} { 470 473 # if control mode is "auto", then simulate right away … … 495 498 } 496 499 497 # look for all output.load children and load them first 498 # each run.xml is loaded as a previous simulation. 499 foreach item [$xmlobj children -type run output.load] { 500 set loadfile [$xmlobj get output.load.$item] 501 set loadobj [Rappture::library $loadfile] 502 load $loadobj 503 } 504 505 foreach item [$xmlobj children -type run output.include] { 506 set id [$xmlobj element -as id output.include.$item] 507 set inclfile [$xmlobj get output.include.$item] 508 set inclobj [Rappture::library $inclfile] 509 foreach c [$inclobj children output] { 510 switch -glob -- $c { 511 # We don't want to include these tags. 512 include* - time* - status* - user* { 513 continue 514 } 515 default { 516 set oldid [$inclobj element -as id output.$c] 517 set oldtype [$inclobj element -as type output.$c] 518 set newcomp "$oldtype\($id-$oldid\)" 519 $xmlobj copy output.$newcomp from $inclobj output.$c 520 } 521 } 522 } 523 } 524 525 lappend _runs $xmlobj 526 527 # Detect molecule elements that contain trajectory data and convert 528 # to sequences. 529 _trajToSequence $xmlobj output 530 531 # Go through the analysis and find all result sets. 532 set haveresults 0 533 foreach item [_reorder [$xmlobj children output]] { 534 switch -glob -- $item { 535 log* { 536 _autoLabel $xmlobj output.$item "Output Log" counters 537 } 538 number* { 539 _autoLabel $xmlobj output.$item "Number" counters 540 } 541 integer* { 542 _autoLabel $xmlobj output.$item "Integer" counters 543 } 544 string* { 545 _autoLabel $xmlobj output.$item "String" counters 546 } 547 histogram* - curve* - field* { 548 _autoLabel $xmlobj output.$item "Plot" counters 549 } 550 drawing* { 551 _autoLabel $xmlobj output.$item "Drawing" counters 552 } 553 structure* { 554 _autoLabel $xmlobj output.$item "Structure" counters 555 } 556 table* { 557 _autoLabel $xmlobj output.$item "Energy Levels" counters 558 } 559 sequence* { 560 _autoLabel $xmlobj output.$item "Sequence" counters 561 } 562 default { 563 if 0 { 564 puts stderr "unknown output $item" 565 } 566 } 567 } 568 set label [$xmlobj get output.$item.about.group] 569 if {"" == $label} { 570 set label [$xmlobj get output.$item.about.label] 571 } 572 573 set hidden [$xmlobj get output.$item.hide] 574 set hidden [expr {"" != $hidden && $hidden}] 575 576 if {"" != $label && !$hidden} { 577 set haveresults 1 578 } 579 } 580 # if there are any valid results, add them to the resultset 581 if {$haveresults} { 582 set index [$itk_component(resultset) add $xmlobj] 583 584 # add each result to a result viewer 585 foreach item [_reorder [$xmlobj children output]] { 586 set label [$xmlobj get output.$item.about.group] 587 if {"" == $label} { 588 set label [$xmlobj get output.$item.about.label] 589 } 590 set hidden [$xmlobj get output.$item.hide] 591 if { $hidden == "" } { 592 set hidden 0 593 } 594 if {"" != $label && !$hidden} { 595 if {![info exists _label2page($label)]} { 596 set name "page[incr _pages]" 597 set page [$itk_component(resultpages) insert end $name] 598 set _label2page($label) $page 599 set _label2desc($label) \ 600 [$xmlobj get output.$item.about.description] 601 Rappture::ResultViewer $page.rviewer 602 pack $page.rviewer -expand yes -fill both -pady 4 603 604 set end [$itk_component(resultselector) \ 605 choices index -value ---] 606 if {$end < 0} { 607 set end "end" 608 } 609 $itk_component(resultselector) choices insert $end \ 610 $name $label 611 } 612 613 # add/replace the latest result into this viewer 614 set page $_label2page($label) 615 616 if {![info exists reset($page)]} { 617 $page.rviewer clear $index 618 set reset($page) 1 619 } 620 $page.rviewer add $index $xmlobj output.$item 621 } 622 } 623 } 624 625 # show the first page by default 626 set max [$itk_component(resultselector) choices size] 627 for {set i 0} {$i < $max} {incr i} { 628 set first [$itk_component(resultselector) choices get -label $i] 629 if {$first != ""} { 630 set page [$itk_component(resultselector) choices get -value $i] 631 set char [string index $page 0] 632 if {$char != "@" && $char != "-"} { 633 $itk_component(resultpages) current $page 634 $itk_component(resultselector) value $first 635 set _lastlabel $first 636 break 637 } 638 } 639 } 500 $_resultset add $xmlobj 501 502 # NOTE: Adding will trigger a !change event on the ResultSet 503 # object, which will trigger calls to _fixResultSet to add 504 # the results to display. 640 505 } 641 506 … … 647 512 # Otherwise, all results are cleared. 648 513 # ---------------------------------------------------------------------- 649 itcl::body Rappture::Analyzer::clear {{xmlobj ""}} { 650 if {$xmlobj ne ""} { 651 set i [lsearch -exact $_runs $xmlobj] 652 if {$i >= 0} { 653 itcl::delete object $xmlobj 654 set _runs [lreplace $_runs $i $i] 655 656 # delete this result from all viewers 657 foreach label [array names _label2page] { 658 set page $_label2page($label) 659 $page.rviewer clear $xmlobj 660 } 661 } 514 itcl::body Rappture::Analyzer::clear {{xmlobj "all"}} { 515 if {$xmlobj eq "" || $xmlobj eq "all"} { 516 $_resultset clear 662 517 } else { 663 # clear everything 664 foreach obj $_runs { 665 itcl::delete object $obj 666 } 667 set _runs "" 668 } 669 670 if {[llength $_runs] == 0} { 671 # reset the size of the controls area 672 set ht [winfo height $itk_component(results)] 673 set cntlht [$itk_component(resultset) size -controlarea] 674 set frac [expr {double($cntlht)/$ht}] 675 $itk_component(results) fraction end $frac 676 677 foreach label [array names _label2page] { 678 set page $_label2page($label) 679 destroy $page.rviewer 680 } 681 $itk_component(resultselector) value "" 682 $itk_component(resultselector) choices delete 0 end 683 catch {unset _label2page} 684 catch {unset _label2desc} 685 set _plotlist "" 686 687 $itk_component(resultselector) choices insert end --- "---" 688 $itk_component(resultselector) choices insert end \ 689 @download [Rappture::filexfer::label download] 690 set _lastlabel "" 691 } 692 693 # 694 # HACK ALERT!! 695 # The following statement should be in place, but it causes 696 # vtk to dump core. Leave it out until we can fix the core dump. 697 # In the mean time, we leak memory... 698 # 699 #$itk_component(resultpages) delete -all 700 #set _pages 0 701 702 _simState on 703 _fixSimControl 704 reset 518 $_resultset clear $xmlobj 519 } 520 521 # NOTE: Clearing will trigger a !change event on the ResultSet 522 # object, which will trigger calls to _fixResultSet to clean up 523 # the results being displayed. 705 524 } 706 525 … … 714 533 # ---------------------------------------------------------------------- 715 534 itcl::body Rappture::Analyzer::download {option args} { 716 set title [$itk_component( resultselector) value]717 set page [$itk_component( resultselector) translate $title]535 set title [$itk_component(viewselector) value] 536 set page [$itk_component(viewselector) translate $title] 718 537 719 538 switch -- $option { … … 775 594 set ext "" 776 595 set f [$itk_component(resultpages) page $page] 777 set item [$itk_component( resultselector) value]596 set item [$itk_component(viewselector) value] 778 597 set result [$f.rviewer download now $widget $_appName $item] 779 598 if { $result == "" } { … … 811 630 # 812 631 # Used internally to update the plot shown in the current result 813 # viewer whenever the resultse tsettings have changed. Causes the632 # viewer whenever the resultselector settings have changed. Causes the 814 633 # desired results to show up on screen. 815 634 # ---------------------------------------------------------------------- … … 817 636 set _plotlist $args 818 637 819 set page [$itk_component( resultselector) value]820 set page [$itk_component( resultselector) translate $page]638 set page [$itk_component(viewselector) value] 639 set page [$itk_component(viewselector) translate $page] 821 640 if {"" != $page} { 822 641 set f [$itk_component(resultpages) page $page] … … 897 716 # ---------------------------------------------------------------------- 898 717 itcl::body Rappture::Analyzer::_fixResult {} { 899 set name [$itk_component( resultselector) value]718 set name [$itk_component(viewselector) value] 900 719 set page "" 901 720 if {"" != $name} { 902 set page [$itk_component( resultselector) translate $name]721 set page [$itk_component(viewselector) translate $name] 903 722 } 904 723 if {$page == "@download"} { 905 724 # put the combobox back to its last value 906 $itk_component( resultselector) component entry configure -state normal907 $itk_component( resultselector) component entry delete 0 end908 $itk_component( resultselector) component entry insert end $_lastlabel909 $itk_component( resultselector) component entry configure -state disabled725 $itk_component(viewselector) component entry configure -state normal 726 $itk_component(viewselector) component entry delete 0 end 727 $itk_component(viewselector) component entry insert end $_lastlabel 728 $itk_component(viewselector) component entry configure -state disabled 910 729 # perform the actual download 911 730 download start $itk_component(download) 912 731 } elseif {$page == "---"} { 913 732 # put the combobox back to its last value 914 $itk_component( resultselector) component entry configure -state normal915 $itk_component( resultselector) component entry delete 0 end916 $itk_component( resultselector) component entry insert end $_lastlabel917 $itk_component( resultselector) component entry configure -state disabled733 $itk_component(viewselector) component entry configure -state normal 734 $itk_component(viewselector) component entry delete 0 end 735 $itk_component(viewselector) component entry insert end $_lastlabel 736 $itk_component(viewselector) component entry configure -state disabled 918 737 } elseif {$page != ""} { 919 738 set _lastlabel $name … … 930 749 931 750 # ---------------------------------------------------------------------- 751 # USAGE: _fixResultSet ?<eventData>...? 752 # 753 # Used internally to react to changes within the ResultSet. When a 754 # result is added, a new result viewer is created for the object. 755 # When all results are cleared, the viewers are deleted. 756 # ---------------------------------------------------------------------- 757 itcl::body Rappture::Analyzer::_fixResultSet {args} { 758 array set eventData $args 759 switch -- $eventData(op) { 760 add { 761 set xmlobj $eventData(what) 762 763 # Detect molecule elements that contain trajectory data 764 # and convert to sequences. 765 _trajToSequence $xmlobj output 766 767 # Go through the analysis and find all result sets. 768 set haveresults 0 769 foreach item [_reorder [$xmlobj children output]] { 770 switch -glob -- $item { 771 log* { 772 _autoLabel $xmlobj output.$item "Output Log" counters 773 } 774 number* { 775 _autoLabel $xmlobj output.$item "Number" counters 776 } 777 integer* { 778 _autoLabel $xmlobj output.$item "Integer" counters 779 } 780 string* { 781 _autoLabel $xmlobj output.$item "String" counters 782 } 783 histogram* - curve* - field* { 784 _autoLabel $xmlobj output.$item "Plot" counters 785 } 786 drawing* { 787 _autoLabel $xmlobj output.$item "Drawing" counters 788 } 789 structure* { 790 _autoLabel $xmlobj output.$item "Structure" counters 791 } 792 table* { 793 _autoLabel $xmlobj output.$item "Energy Levels" counters 794 } 795 sequence* { 796 _autoLabel $xmlobj output.$item "Sequence" counters 797 } 798 } 799 set label [$xmlobj get output.$item.about.group] 800 if {"" == $label} { 801 set label [$xmlobj get output.$item.about.label] 802 } 803 804 set hidden [$xmlobj get output.$item.hide] 805 set hidden [expr {"" != $hidden && $hidden}] 806 807 if {"" != $label && !$hidden} { 808 set haveresults 1 809 } 810 } 811 812 # if there are any valid results, add them to the resultset 813 if {$haveresults} { 814 set index [$_resultset get simnum $xmlobj] 815 816 # add each result to a result viewer 817 foreach item [_reorder [$xmlobj children output]] { 818 set label [$xmlobj get output.$item.about.group] 819 if {"" == $label} { 820 set label [$xmlobj get output.$item.about.label] 821 } 822 set hidden [$xmlobj get output.$item.hide] 823 if { $hidden == "" } { 824 set hidden 0 825 } 826 if {"" != $label && !$hidden} { 827 if {![info exists _label2page($label)]} { 828 set name "page[incr _pages]" 829 set page [$itk_component(resultpages) \ 830 insert end $name] 831 set _label2page($label) $page 832 set _label2desc($label) \ 833 [$xmlobj get output.$item.about.description] 834 Rappture::ResultViewer $page.rviewer 835 pack $page.rviewer -expand yes -fill both -pady 4 836 837 set end [$itk_component(viewselector) \ 838 choices index -value ---] 839 if {$end < 0} { 840 set end "end" 841 } 842 $itk_component(viewselector) choices insert $end \ 843 $name $label 844 } 845 846 # add/replace the latest result into this viewer 847 set page $_label2page($label) 848 849 if {![info exists reset($page)]} { 850 $page.rviewer clear $index 851 set reset($page) 1 852 } 853 $page.rviewer add $index $xmlobj output.$item 854 } 855 } 856 } 857 858 # show the first page by default 859 set max [$itk_component(viewselector) choices size] 860 for {set i 0} {$i < $max} {incr i} { 861 set first [$itk_component(viewselector) choices get -label $i] 862 if {$first != ""} { 863 set page [$itk_component(viewselector) choices get -value $i] 864 set char [string index $page 0] 865 if {$char != "@" && $char != "-"} { 866 $itk_component(resultpages) current $page 867 $itk_component(viewselector) value $first 868 set _lastlabel $first 869 break 870 } 871 } 872 } 873 } 874 clear { 875 if {$eventData(what) ne "all"} { 876 # delete this result from all viewers 877 array set params $eventData(what) 878 foreach label [array names _label2page] { 879 set page $_label2page($label) 880 $page.rviewer clear $params(simnum) 881 } 882 } 883 884 if {[$_resultset size] == 0} { 885 # reset the size of the controls area 886 set ht [winfo height $itk_component(results)] 887 set cntlht [$itk_component(resultselector) size -controlarea] 888 set frac [expr {double($cntlht)/$ht}] 889 $itk_component(results) fraction end $frac 890 891 foreach label [array names _label2page] { 892 set page $_label2page($label) 893 destroy $page.rviewer 894 } 895 $itk_component(resultpages) delete -all 896 set _pages 0 897 898 $itk_component(viewselector) value "" 899 $itk_component(viewselector) choices delete 0 end 900 catch {unset _label2page} 901 catch {unset _label2desc} 902 set _plotlist "" 903 904 $itk_component(viewselector) choices insert end --- "---" 905 $itk_component(viewselector) choices insert end \ 906 @download [Rappture::filexfer::label download] 907 set _lastlabel "" 908 } 909 910 # fix Simulate button state 911 reset 912 } 913 default { 914 error "don't know how to handle op \"$eventData(op)\"" 915 } 916 } 917 } 918 919 # ---------------------------------------------------------------------- 932 920 # USAGE: _fixSize 933 921 # … … 939 927 set ht [winfo height $itk_component(results)] 940 928 if {$ht <= 1} { set ht [winfo reqheight $itk_component(results)] } 941 set cntlht [$itk_component(resultse t) size -controlarea]929 set cntlht [$itk_component(resultselector) size -controlarea] 942 930 set frac [expr {double($cntlht)/$ht}] 943 931 … … 1110 1098 itcl::body Rappture::Analyzer::_resultTooltip {} { 1111 1099 set tip "" 1112 set name [$itk_component( resultselector) value]1100 set name [$itk_component(viewselector) value] 1113 1101 if {[info exists _label2desc($name)] && 1114 1102 [string length $_label2desc($name)] > 0} { … … 1142 1130 # with no data, requiring simulation. 1143 1131 # 1144 if {[$itk_component(resultse t) size -controls] >= 2} {1132 if {[$itk_component(resultselector) size -controls] >= 2} { 1145 1133 pack $itk_interior.simol -fill x -before $itk_interior.nb 1146 1134 } else { -
branches/nanovis2/gui/scripts/choiceentry.tcl
r1929 r3175 240 240 # Assign the default value to this widget, if there is one. 241 241 # 242 set defval [ $_owner xml get $_path.default]242 set defval [string trim [$_owner xml get $_path.default]] 243 243 if {"" != $defval} { 244 244 if {[info exists _str2val($defval)]} { -
branches/nanovis2/gui/scripts/controlOwner.tcl
r2977 r3175 59 59 # in coordination with loaders inside the load function 60 60 array set _type2curpath { 61 drawing components61 drawing all 62 62 choice current 63 63 boolean current … … 260 260 error "\"$newobj\" is not a Rappture::library" 261 261 } 262 263 262 foreach path [array names _path2widget] { 264 263 # the following elements do not accept "current" tags, skip them … … 270 269 set type [[tool] xml element -as type $path] 271 270 if {[info exists _type2curpath($type)]} { 272 set currentpath $path.$_type2curpath($type) 271 if { $_type2curpath($type) == "all" } { 272 set currentpath $path 273 } else { 274 set currentpath $path.$_type2curpath($type) 275 } 273 276 } else { 274 277 # default incase i forgot an input type in _type2curpath -
branches/nanovis2/gui/scripts/controls.tcl
r2992 r3175 216 216 foreach {s0 s1} $match break 217 217 218 if {[string index $rest [expr {$s0-1}]] == "\"" 219 && [string index $rest [expr {$s1+1}]] == "\""} { 218 if {[string index $rest [expr {$s0-1}]] == "\""} { 220 219 # string in ""'s? then leave it alone 221 append enable [string range $rest 0 $s1] 222 set rest [string range $rest [expr {$s1+1}] end] 220 append enable [string range $rest 0 [expr {$s0-1}]] 221 set rest [string range $rest $s0 end] 222 if {[regexp -indices {[^\"]+\"} $rest match]} { 223 foreach {s0 s1} $match break 224 append enable [string range $rest $s0 $s1] 225 set rest [string range $rest [expr {$s1+1}] end] 226 } else { 227 puts stderr "WARNING: mismatched quote in enable condition for $path" 228 puts stderr " expr: [string trim [$_owner xml get $path.about.enable]]" 229 set rest "" 230 } 223 231 } else { 224 232 # … … 511 519 } 512 520 set _name2info($name-label) $label 513 514 $_tabs insert end $label \ 521 $_tabs insert end $name -text $label \ 515 522 -activebackground $itk_option(-background) 516 523 -
branches/nanovis2/gui/scripts/drawing.tcl
r2792 r3175 27 27 public method type { elem } 28 28 public method style { elem } 29 public method shape { elem } 29 30 public method values { elem } 30 31 public method data { elem } … … 36 37 private variable _actors 37 38 private variable _styles 39 private variable _shapes 38 40 private variable _labels 39 41 private variable _types … … 73 75 polygon* { 74 76 set _data($elem) [$_xmlobj get $path.$elem.vtk] 77 set _data($elem) [string trim $_data($elem)] 75 78 set _styles($elem) [$_xmlobj get $path.$elem.about.style] 76 79 set _labels($elem) [$_xmlobj get $path.$elem.about.label] … … 79 82 streamlines* { 80 83 set _data($elem) [$_xmlobj get $path.$elem.vtk] 84 set _data($elem) [string trim $_data($elem)] 81 85 set _styles($elem) [$_xmlobj get $path.$elem.about.style] 82 86 set _labels($elem) [$_xmlobj get $path.$elem.about.label] 83 87 set _types($elem) streamlines 84 88 } 85 spheres* {89 glyphs* { 86 90 set _data($elem) [$_xmlobj get $path.$elem.vtk] 91 set _data($elem) [string trim $_data($elem)] 87 92 set _styles($elem) [$_xmlobj get $path.$elem.about.style] 88 93 set _labels($elem) [$_xmlobj get $path.$elem.about.label] 89 set _types($elem) spheres 94 set _shapes($elem) [$_xmlobj get $path.$elem.about.shape] 95 set _types($elem) glyphs 96 } 97 molecule* { 98 set _data($elem) [$_xmlobj get $path.$elem.vtk] 99 set _data($elem) [string trim $_data($elem)] 100 set _styles($elem) [$_xmlobj get $path.$elem.about.style] 101 set _labels($elem) [$_xmlobj get $path.$elem.about.label] 102 set _types($elem) molecule 90 103 } 91 104 } … … 173 186 174 187 # 188 # shape -- 189 # 190 # Returns the shape of the glyphs in the drawing element. 191 # 192 itcl::body Rappture::Drawing::shape { elem } { 193 set shape "" 194 if { [info exists _shapes($elem)] } { 195 return $_shapes($elem) 196 } 197 switch -- $shape { 198 arrow - cone - cube - cylinder - dodecahedron - 199 icosahedron - line - octahedron - sphere - tetrahedron { 200 return $shape 201 } 202 default { 203 puts stderr "unknown glyph shape \"$shape\"" 204 } 205 } 206 return "" 207 } 208 209 # 175 210 # data -- 176 211 # -
branches/nanovis2/gui/scripts/drawingcontrols.tcl
r2992 r3175 39 39 private method FormatLabel {str} 40 40 private method Monitor {name state} 41 42 41 private variable _dispatcher "" 43 42 private variable _controls "" … … 46 45 private variable _owner "" 47 46 private variable _frame "" 47 private variable _closeOnChange 0 48 48 } 49 49 … … 180 180 set _name2info($name-disablestyle) $disablestyle 181 181 } 182 183 if 0 { 182 184 # 183 185 # If this element has an <enable> expression, then register … … 231 233 } 232 234 } 233 234 235 foreach cpath $deps { 235 236 $_owner dependenciesfor $cpath $path 236 237 } 237 238 } 238 set _name2info($name-enable) $enable 239 } 240 set _name2info($name-enable) yes 239 241 240 242 #set wid [$_owner widgetfor $path] … … 292 294 $_owner changed $path 293 295 } 296 if { [winfo class $wid] == "TextEntry" } { 297 return 298 } 299 eval $deactivatecommand 294 300 } 295 301 … … 459 465 grid rowconfigure $_frame 99 -weight 0 460 466 } 467 set _closeOnChange 0 468 set slaves [grid slaves $_frame] 469 if { [llength $slaves] == 1 } { 470 set slave [lindex $slaves 0] 471 set _closeOnChange 1 472 } 461 473 } 462 474 … … 526 538 $_dispatcher event -idle !layout 527 539 } 540 -
branches/nanovis2/gui/scripts/drawingentry.tcl
r2999 r3175 28 28 private variable _drawingWidth 0 29 29 private variable _owner 30 private variable _parser "" 30 private variable _xmlobj "" 31 private variable _parser ""; # Slave interpreter where all 32 # substituted variables are stored. 31 33 private variable _path 32 34 private variable _showing "" … … 41 43 private variable _cursor "" 42 44 43 constructor {owner path args} { # defined below } 44 45 constructor {owner path args} { 46 # defined below 47 } 48 destructor { 49 # defined below 50 } 45 51 public method value { args } 46 52 public method label {} … … 49 55 private method Activate { tag } 50 56 private method AdjustDrawingArea { xAspect yAspect } 57 private method ControlValue {path {units ""}} 51 58 private method Deactivate { tag } 52 59 private method Highlight { tag } … … 70 77 private method ScreenY { y } 71 78 private method XmlGet { path } 72 private method Withdraw {} 79 private method XmlGetSubst { path } 80 private method Withdraw { cname } 81 private method Hotspot { option cname item args } 82 private method IsEnabled { path } 83 private method NumControlsEnabled { cname } 73 84 } 74 85 … … 89 100 set _path $path 90 101 set _owner $owner 102 set _xmlobj [$_owner xml object] 91 103 # 92 104 # Display the current drawing. … … 100 112 pack $itk_component(drawing) -expand yes -fill both 101 113 bind $itk_component(drawing) <Configure> [itcl::code $this Redraw] 114 set _parser [interp create -safe] 102 115 Redraw 103 116 eval itk_initialize $args 104 117 } 105 118 119 itcl::body Rappture::DrawingEntry::destructor {} { 120 if { $_parser != "" } { 121 $_parser delete 122 } 123 } 106 124 # ---------------------------------------------------------------------- 107 125 # USAGE: label … … 112 130 itcl::body Rappture::DrawingEntry::label {} { 113 131 return "" 114 set label [$_ owner xmlget $_path.about.label]132 set label [$_xmlobj get $_path.about.label] 115 133 if {"" == $label} { 116 134 set label "Drawing" … … 129 147 itcl::body Rappture::DrawingEntry::tooltip {} { 130 148 return "" 131 set str [$_ owner xmlget $_path.about.description]149 set str [$_xmlobj get $_path.about.description] 132 150 return [string trim $str] 133 151 } … … 178 196 ParseBackground 179 197 ParseSubstitutions 180 foreach cname [$_ owner xmlchildren $_path.components] {198 foreach cname [$_xmlobj children $_path.components] { 181 199 switch -glob -- $cname { 182 200 "line*" { … … 227 245 } 228 246 # Coords 229 set xcoords [XmlGet $cpath.xcoords]247 set xcoords [XmlGetSubst $cpath.xcoords] 230 248 set xcoords [string trim $xcoords] 231 set ycoords [XmlGet $cpath.ycoords]249 set ycoords [XmlGetSubst $cpath.ycoords] 232 250 set ycoords [string trim $ycoords] 233 251 if { $ycoords == "" } { … … 273 291 #puts stderr "ParseGrid owner=$_owner cpath=$cpath xcoords=$xcoords ycoords=$ycoords" 274 292 set list {} 275 foreach attr [$_ owner xmlchildren $cpath] {293 foreach attr [$_xmlobj children $cpath] { 276 294 if { [info exists attr2option($attr)] } { 277 295 set option $attr2option($attr) 278 set value [XmlGet $cpath.$attr]296 set value [XmlGetSubst $cpath.$attr] 279 297 set options($option) $value 280 298 } … … 309 327 } 310 328 array unset _cname2controls $cname 311 foreach attr [$_ owner xmlchildren $cpath] {329 foreach attr [$_xmlobj children $cpath] { 312 330 if { [info exists attr2option($attr)] } { 313 331 set option $attr2option($attr) 314 set value [XmlGet $cpath.$attr]332 set value [XmlGetSubst $cpath.$attr] 315 333 set options($option) $value 316 334 } elseif { [string match "controls*" $attr] } { 317 set value [XmlGet $cpath.$attr]335 set value [XmlGetSubst $cpath.$attr] 318 336 lappend _cname2controls($cname) $value 319 $_ owner xmlput $value.hide 1337 $_xmlobj put $value.hide 1 320 338 } 321 339 } 322 340 # Coordinates 323 set coords [XmlGet $cpath.coords]341 set coords [XmlGetSubst $cpath.coords] 324 342 set coords [ScreenCoords $coords] 325 343 if { $coords == "" } { … … 327 345 } 328 346 set c $itk_component(drawing) 329 set img [Rappture::icon question_mark12]347 set img [Rappture::icon hotspot_normal] 330 348 foreach { x1 y1 } $coords break 331 349 set id [$itk_component(drawing) create image $x1 $y1] … … 338 356 $c bind $id <Leave> [itcl::code $this Deactivate $cname] 339 357 #$c bind $id <ButtonPress-1> [itcl::code $this Depress $cname] 340 $c bind $id <ButtonRelease-1> [itcl::code $this Invoke $cname $x1 $y1] 358 set bbox [$c bbox $id] 359 set y1 [lindex $bbox 1] 360 $c bind $id <ButtonPress-1> [itcl::code $this Invoke $cname $x1 $y1] 341 361 } 342 362 … … 360 380 # Coords 361 381 set coords {} 362 set coords [XmlGet $cpath.coords]382 set coords [XmlGetSubst $cpath.coords] 363 383 set coords [string trim $coords] 364 384 if { $coords == "" } { … … 369 389 #puts stderr "ParseLine owner=$_owner cpath=$cpath coords=$coords" 370 390 set list {} 371 foreach attr [$_ owner xmlchildren $cpath] {391 foreach attr [$_xmlobj children $cpath] { 372 392 if { [info exists attr2option($attr)] } { 373 393 set option $attr2option($attr) 374 set value [XmlGet $cpath.$attr]394 set value [XmlGetSubst $cpath.$attr] 375 395 set options($option) $value 376 396 } … … 389 409 "outline" "-outline" 390 410 "fill" "-fill" 391 "linewidth" "- linewidth"411 "linewidth" "-width" 392 412 } 393 413 #puts stderr "ParseOval owner=$_owner cpath=$cpath" … … 396 416 array set options { 397 417 -fill blue 398 - linewidth 1418 -width 1 399 419 -outline black 400 420 } 401 foreach attr [$_ owner xmlchildren $cpath] {421 foreach attr [$_xmlobj children $cpath] { 402 422 if { [info exists attr2option($attr)] } { 403 423 set option $attr2option($attr) 404 set value [XmlGet $cpath.$attr]424 set value [XmlGetSubst $cpath.$attr] 405 425 set options($option) $value 406 426 } … … 408 428 # Coordinates 409 429 set coords {} 410 set coords [XmlGet $cpath.coords]430 set coords [XmlGetSubst $cpath.coords] 411 431 set coords [string trim $coords] 412 432 if { $coords == "" } { … … 414 434 } 415 435 foreach { x1 y1 x2 y2 } [ScreenCoords $coords] break 416 set id [ eval $itk_component(drawing) create oval $coords]436 set id [$itk_component(drawing) create oval $x1 $y1 $x2 $y2] 417 437 set _cname2id($cname) $id 438 eval $itk_component(drawing) itemconfigure $id [array get options] 418 439 } 419 440 … … 430 451 -anchor nw 431 452 } 432 foreach attr [$_ owner xmlchildren $cpath] {453 foreach attr [$_xmlobj children $cpath] { 433 454 if { [info exists attr2option($attr)] } { 434 455 set option $attr2option($attr) 435 set value [XmlGet $cpath.$attr]456 set value [XmlGetSubst $cpath.$attr] 436 457 set options($option) $value 437 458 } 438 459 } 439 set contents [XmlGet $cpath.contents]460 set contents [XmlGetSubst $cpath.contents] 440 461 set img "" 441 462 if { [string compare -length 5 $contents "file:"] == 0 } { … … 454 475 } 455 476 # Coordinates 456 set coords [XmlGet $cpath.coords]477 set coords [XmlGetSubst $cpath.coords] 457 478 set coords [ScreenCoords $coords] 458 479 if { [llength $coords] == 2 } { 459 480 foreach { x1 y1 } $coords break 460 set w [XmlGet $cpath.width]481 set w [XmlGetSubst $cpath.width] 461 482 if { $w == "" || ![string is number $w] || $w <= 0.0 } { 462 483 set width [expr [image width $img] / 4] … … 464 485 set width [expr [ScreenX $w] - [ScreenX 0]] 465 486 } 466 set h [XmlGet $cpath.height]487 set h [XmlGetSubst $cpath.height] 467 488 if { $h == "" || ![string is number $h] || $h <= 0.0 } { 468 489 set height [expr [image height $img] / 4] … … 499 520 set width [expr [image width $img] / 4] 500 521 set height [expr [image height $img] / 4] 501 set dst [image create photo -width $width -height $height]522 set dst [image create photo -width $width -height $height] 502 523 blt::winop resample $img $dst 503 524 image delete $img … … 518 539 array set attr2option { 519 540 "linewidth" "-width" 520 "arrow" "-arrow"521 541 "color" "-fill" 522 542 } 523 543 # Set default options first and then let tool.xml override them. 524 544 array set options { 525 - arrow none526 - width 0527 - fillblack545 -width 1 546 -fill blue 547 -outline black 528 548 } 529 549 # Coords 530 set coords [XmlGet $cpath.coords]550 set coords [XmlGetSubst $cpath.coords] 531 551 set coords [string trim $coords] 532 552 if { $coords == "" } { … … 540 560 #puts stderr "ParsePolygon owner=$_owner cpath=$cpath coords=$coords" 541 561 set list {} 542 foreach attr [$_ owner xmlchildren $cpath] {562 foreach attr [$_xmlobj children $cpath] { 543 563 if { [info exists attr2option($attr)] } { 544 564 set option $attr2option($attr) 545 set value [XmlGet $cpath.$attr]565 set value [XmlGetSubst $cpath.$attr] 546 566 set options($option) $value 547 567 } … … 560 580 "outline" "-outline" 561 581 "fill" "-fill" 562 "linewidth" "- linewidth"582 "linewidth" "-width" 563 583 } 564 584 #puts stderr "ParseRectangle owner=$_owner cpath=$cpath" … … 567 587 array set options { 568 588 -fill blue 569 - linewidth 1589 -width 1 570 590 -outline black 571 591 } 572 foreach attr [$_ owner xmlchildren $cpath] {592 foreach attr [$_xmlobj children $cpath] { 573 593 if { [info exists attr2option($attr)] } { 574 594 set option $attr2option($attr) 575 set value [XmlGet $cpath.$attr]595 set value [XmlGetSubst $cpath.$attr] 576 596 set options($option) $value 577 597 } 578 598 } 579 599 # Coordinates 580 set coords [XmlGet $cpath.coords]600 set coords [XmlGetSubst $cpath.coords] 581 601 set coords [string trim $coords] 582 602 if { $coords == "" } { 583 603 set coords "0 0 1 1" 584 604 } 585 foreach { x1 y1 x2 y2 } [ScreenCoords $coords] break 586 set id [eval $itk_component(drawing) create rectangle $coords]605 foreach { x1 y1 x2 y2 } [ScreenCoords $coords] break 606 set id [$itk_component(drawing) create rectangle $x1 $y1 $x2 $y2] 587 607 set _cname2id($cname) $id 608 eval $itk_component(drawing) itemconfigure $id [array get options] 588 609 } 589 610 … … 594 615 array set attr2option { 595 616 "font" "-font" 596 "color" "-fill" 617 "color" "-foreground" 618 "valuecolor" "-valueforeground" 597 619 "text" "-text" 598 620 "anchor" "-anchor" … … 602 624 # Set default options first and then let tool.xml override them. 603 625 array set options { 604 -font {Arial 8} 626 -font {Arial 12} 627 -valuefont {Arial 12} 628 -valueforeground blue3 605 629 -text {} 606 -fill black630 -fill {} 607 631 -anchor c 608 632 } 609 foreach attr [$_ owner xmlchildren $cpath] {633 foreach attr [$_xmlobj children $cpath] { 610 634 if { [info exists attr2option($attr)] } { 611 635 set option $attr2option($attr) 612 set value [XmlGet $cpath.$attr] 636 if { $attr == "text" } { 637 set value [XmlGet $cpath.$attr] 638 } else { 639 set value [XmlGetSubst $cpath.$attr] 640 } 613 641 set options($option) $value 614 642 } 615 643 } 616 644 # Coords 617 set coords [XmlGet $cpath.coords]645 set coords [XmlGetSubst $cpath.coords] 618 646 set coords [string trim $coords] 619 647 if { $coords == "" } { … … 622 650 set coords [ScreenCoords $coords] 623 651 } 652 set hotspot [XmlGetSubst $cpath.hotspot] 653 if { $hotspot == "inline" } { 654 set options(-showicons) 1 655 } 656 set c $itk_component(drawing) 624 657 set options(-tags) $cname 625 set id [eval $itk_component(drawing) create text $coords] 658 set img [Rappture::icon hotspot_normal] 659 set options(-image) $img 660 set img [Rappture::icon hotspot_active] 661 set options(-activeimage) $img 662 set id [eval $c create hotspot $coords] 626 663 set _cname2id($cname) $id 627 eval $itk_component(drawing) itemconfigure $id [array get options] 664 set options(-interp) $_parser 665 eval $c itemconfigure $id [array get options] 666 if { $hotspot == "inline" } { 667 array unset _cname2controls $cname 668 foreach varName [Rappture::hotspot variables $c $id] { 669 if { [info exists _name2path($varName)] } { 670 set path $_name2path($varName) 671 $_xmlobj put $path.hide 1 672 lappend _cname2controls($cname) $path 673 } else { 674 puts stderr "unknown varName=$varName" 675 } 676 } 677 $c bind $id <Motion> \ 678 [itcl::code $this Hotspot watch $cname $id %x %y] 679 $c bind $id <Leave> \ 680 [itcl::code $this Hotspot deactivate $cname $id] 681 $c bind $id <Enter> \ 682 [itcl::code $this Hotspot activate $cname $id %x %y] 683 $c bind $id <ButtonRelease-1> \ 684 [itcl::code $this Hotspot invoke $cname $id %x %y] 685 } 686 } 687 688 689 itcl::body Rappture::DrawingEntry::Hotspot { option cname item args } { 690 if { [NumControlsEnabled $cname] == 0 } { 691 return 692 } 693 set c $itk_component(drawing) 694 switch -- $option { 695 "activate" { 696 foreach { x y } $args break 697 set varName [Rappture::hotspot identify $c $item $x $y] 698 $c itemconfigure $item -activevalue $varName 699 } 700 "deactivate" { 701 $c itemconfigure $item -activevalue "" 702 } 703 "watch" { 704 foreach { x y } $args break 705 set active [$c itemcget $item -activevalue] 706 set varName [Rappture::hotspot identify $c $item $x $y] 707 if { $varName != $active } { 708 $c itemconfigure $item -activevalue $varName 709 } 710 } 711 "invoke" { 712 foreach { x y } $args break 713 set active [$c itemcget $item -activevalue] 714 set varName [Rappture::hotspot identify $c $item $x $y] 715 if { $varName != "" } { 716 set bbox [$c bbox $item] 717 Invoke $cname $x [lindex $bbox 1] 718 } 719 } 720 } 628 721 } 629 722 … … 738 831 739 832 itcl::body Rappture::DrawingEntry::ParseBackground {} { 740 foreach elem [$_ owner xmlchildren $_path.background] {833 foreach elem [$_xmlobj children $_path.background] { 741 834 switch -glob -- $elem { 742 835 "color*" { … … 767 860 768 861 itcl::body Rappture::DrawingEntry::ParseSubstitutions {} { 769 foreach var [$_ owner xmlchildren $_path.substitutions] {862 foreach var [$_xmlobj children $_path.substitutions] { 770 863 if { ![string match "variable*" $var] } { 771 864 continue … … 775 868 set name "" 776 869 set path "" 777 foreach elem [$_ owner xmlchildren $varPath] {870 foreach elem [$_xmlobj children $varPath] { 778 871 switch -glob -- $elem { 779 872 "name*" { … … 826 919 set popup .drawingentrypopup 827 920 if { ![winfo exists $popup] } { 828 # Create a popup for the printdialog921 # Create a popup for the controls dialog 829 922 Rappture::Balloon $popup -title "Change values..." \ 830 -deactivatecommand [itcl::code $this Withdraw ]923 -deactivatecommand [itcl::code $this Withdraw $cname] 831 924 set inner [$popup component inner] 832 925 Rappture::DrawingControls $inner.controls $_owner \ … … 837 930 $inner.controls delete all 838 931 } 932 set count 0 839 933 foreach path $controls { 840 $inner.controls add $path 934 if { [IsEnabled $path] } { 935 $inner.controls add $path 936 incr count 937 } 938 } 939 if { $count == 0 } { 940 return 841 941 } 842 942 update … … 844 944 incr x [winfo rootx $itk_component(drawing)] 845 945 incr y [winfo rooty $itk_component(drawing)] 846 847 946 $popup activate @$x,$y above 848 947 } … … 852 951 # 853 952 itcl::body Rappture::DrawingEntry::Activate { cname } { 854 $itk_component(drawing) configure -cursor center_ptr 953 $itk_component(drawing) configure -cursor center_ptr 954 $itk_component(drawing) itemconfigure $_cname2id($cname) \ 955 -image [Rappture::icon hotspot_active] 855 956 } 856 957 … … 859 960 # 860 961 itcl::body Rappture::DrawingEntry::Deactivate { cname } { 861 $itk_component(drawing) configure -cursor left_ptr 862 } 863 864 # 865 # Invoke -- 866 # 867 itcl::body Rappture::DrawingEntry::Withdraw {} { 962 $itk_component(drawing) configure -cursor left_ptr 963 $itk_component(drawing) itemconfigure $_cname2id($cname) \ 964 -image [Rappture::icon hotspot_normal] 965 } 966 967 # 968 # Withdraw -- 969 # 970 itcl::body Rappture::DrawingEntry::Withdraw { cname } { 868 971 Redraw 869 972 } … … 879 982 # ---------------------------------------------------------------------- 880 983 itcl::body Rappture::DrawingEntry::value {args} { 881 # drawing entries have no value 984 # Redraw if there's a new library object. 985 if { [llength $args] > 0 } { 986 set libobj [lindex $args 0] 987 if { $libobj != "" } { 988 Redraw 989 } 990 } 882 991 return "" 883 992 } … … 889 998 itcl::body Rappture::DrawingEntry::InitSubstitutions {} { 890 999 # Load a new parser with the variables representing the substitution 891 set _parser [interp create -safe]892 1000 foreach name [array names _name2path] { 893 1001 set path $_name2path($name) … … 903 1011 904 1012 itcl::body Rappture::DrawingEntry::XmlGet { path } { 905 set value [$_owner xml get $path] 1013 set value [$_xmlobj get $path] 1014 return [string trim $value] 1015 } 1016 1017 itcl::body Rappture::DrawingEntry::XmlGetSubst { path } { 1018 set value [$_xmlobj get $path] 906 1019 if { $_parser == "" } { 907 1020 return $value 908 1021 } 909 return [$_parser eval [list subst -nocommands $value]] 910 } 911 1022 return [string trim [$_parser eval [list subst -nocommands $value]]] 1023 } 1024 1025 itcl::body Rappture::DrawingEntry::IsEnabled { path } { 1026 set enable [string trim [$_xmlobj get $path.about.enable]] 1027 if {"" == $enable} { 1028 return 1 1029 } 1030 if {![string is boolean $enable]} { 1031 set re {([a-zA-Z_]+[0-9]*|\([^\(\)]+\)|[a-zA-Z_]+[0-9]*\([^\(\)]+\))(\.([a-zA-Z_]+[0-9]*|\([^\(\)]+\)|[a-zA-Z_]+[0-9]*\([^\(\)]+\)))*(:[-a-zA-Z0-9/]+)?} 1032 set rest $enable 1033 set enable "" 1034 set deps "" 1035 while {1} { 1036 if {[regexp -indices $re $rest match]} { 1037 foreach {s0 s1} $match break 1038 1039 if {[string index $rest [expr {$s0-1}]] == "\"" 1040 && [string index $rest [expr {$s1+1}]] == "\""} { 1041 # string in ""'s? then leave it alone 1042 append enable [string range $rest 0 $s1] 1043 set rest [string range $rest [expr {$s1+1}] end] 1044 } else { 1045 # 1046 # This is a symbol which should be substituted 1047 # it can be either: 1048 # input.foo.bar 1049 # input.foo.bar:units 1050 # 1051 set cpath [string range $rest $s0 $s1] 1052 set parts [split $cpath :] 1053 set ccpath [lindex $parts 0] 1054 set units [lindex $parts 1] 1055 1056 # make sure we have the standard path notation 1057 set stdpath [$_owner regularize $ccpath] 1058 if {"" == $stdpath} { 1059 puts stderr "WARNING: don't recognize parameter $cpath in <enable> expression for $path. This may be buried in a structure that is not yet loaded." 1060 set stdpath $ccpath 1061 } 1062 # substitute [_controlValue ...] call in place of path 1063 append enable [string range $rest 0 [expr {$s0-1}]] 1064 append enable [format {[ControlValue %s %s]} $stdpath $units] 1065 lappend deps $stdpath 1066 set rest [string range $rest [expr {$s1+1}] end] 1067 } 1068 } else { 1069 append enable $rest 1070 break 1071 } 1072 } 1073 } 1074 return [expr $enable] 1075 } 1076 1077 # ---------------------------------------------------------------------- 1078 # USAGE: ControlValue <path> ?<units>? 1079 # 1080 # Used internally to get the value of a control with the specified 1081 # <path>. Returns the current value for the control. 1082 # ---------------------------------------------------------------------- 1083 itcl::body Rappture::DrawingEntry::ControlValue {path {units ""}} { 1084 if {"" != $_owner} { 1085 set val [$_owner valuefor $path] 1086 if {"" != $units} { 1087 set val [Rappture::Units::convert $val -to $units -units off] 1088 } 1089 return $val 1090 } 1091 return "" 1092 } 1093 1094 itcl::body Rappture::DrawingEntry::NumControlsEnabled { cname } { 1095 set controls $_cname2controls($cname) 1096 set count 0 1097 foreach path $controls { 1098 if { [IsEnabled $path] } { 1099 incr count 1100 } 1101 } 1102 return $count 1103 } -
branches/nanovis2/gui/scripts/field.tcl
r2744 r3175 51 51 private variable _comp2vtk ;# maps component name => vtkFloatArray 52 52 private variable _comp2vtkstreamlines ;# maps component name => vtkFloatArray 53 private variable _comp2vtkcontour ;# maps component name => vtkFloatArray 53 54 private variable _comp2vtkvolume ;# maps component name => vtkFloatArray 54 55 private variable _comp2volume ;# maps component name => vtkFloatArray … … 59 60 private variable _comp2cntls ;# maps component name => x,y control points 60 61 private variable _comp2extents 62 private variable _comp2limits 61 63 private variable _type "" 62 64 private variable _comp2flowhints 63 65 private common _counter 0 ;# counter for unique vector names 66 67 private method ConvertToVtkData { cname } 68 private method ReadVtkDataSet { cname contents } 69 private variable _fields {} 70 private variable _isVtk 64 71 } 65 72 … … 197 204 return [$mobj mesh] 198 205 } 206 if { [info exists _comp2vtkcontour($what)] } { 207 error "method \"mesh\" is not implemented for vtkcontour" 208 } 199 209 if { [info exists _comp2vtk($what)] } { 200 210 set mobj [lindex $_comp2vtk($what) 0] … … 232 242 return [lindex $_comp2xy($what) 1] ;# return yv 233 243 } 244 if { [info exists _comp2vtkcontour($what)] } { 245 error "method \"values\" is not implemented for vtkcontour" 246 } 234 247 if { [info exists _comp2vtkstreamlines($what)] } { 235 248 # FIXME: Need to process the vtk file data to pull out the field's 236 249 # values. 237 error "vtkstreamlines: values not implement s"250 error "vtkstreamlines: values not implemented" 238 251 return [lindex $_comp2vtkstreamlines($what) 1] 239 252 } … … 270 283 if { [info exists _comp2vtkvolume($what)] } { 271 284 return $_comp2vtkvolume($what) 285 } 286 if { [info exists _comp2vtkcontour($what)] } { 287 return $_comp2vtkcontour($what) 272 288 } 273 289 if { [info exists _comp2vtkstreamlines($what)] } { … … 589 605 array unset _comp2volume 590 606 array unset _comp2vtkstreamlines 607 array unset _comp2vtkcontour 591 608 array unset _comp2unirect2d 592 609 array unset _comp2unirect3d … … 607 624 set type "points-on-mesh" 608 625 } elseif {[$_field element $cname.vtk] != ""} { 626 set _isVtkData($cname) 1 609 627 if { [$_field get "about.view"] == "streamlines" } { 610 628 set type "vtkstreamlines" 629 } elseif { [$_field get "about.view"] == "contour" } { 630 set type "vtkcontour" 611 631 } else { 612 632 set type "vtk" … … 800 820 # Allow redirects to another element. 801 821 set vtkdata [$_field get $cname.vtk] 802 if { ![string match "!*" $vtkdata] } { 803 set _comp2vtkstreamlines($cname) $vtkdata 804 } else { 805 set path [string range $vtkdata 1 end] 806 if { [$_xmlobj element $path] == "" } { 807 error "bad redirection path \"$path\"" 808 } 809 puts stderr path=$path 810 set element [$_xmlobj element -as type $path] 811 if { $element != "vtk" } { 812 error "bad path \"$path\": must redirect to a vtk element" 813 } 814 set _comp2vtkstreamlines($cname) [$_xmlobj get $path] 815 } 822 set _comp2vtkstreamlines($cname) $vtkdata 823 set _comp2style($cname) [$_field get $cname.style] 824 incr _counter 825 } elseif {$type == "vtkcontour"} { 826 set _comp2dims($cname) "2D" 827 # Allow redirects to another element. 828 829 set data [$_field get $cname.vtk] 830 ReadVtkDataSet $cname $data 831 set _comp2vtkcontour($cname) $data 816 832 set _comp2style($cname) [$_field get $cname.style] 817 833 incr _counter … … 1024 1040 return "" 1025 1041 } 1042 if { [info exists _comp2vtkcontour($what)] } { 1043 return $_comp2contour($what) 1044 } 1026 1045 if { [info exists _comp2vtkstreamlines($what)] } { 1027 # Return the contents of the vtk file.1028 1046 return $_comp2vtkstreamlines($what) 1029 1047 } 1030 1048 if { [info exists _comp2vtkvolume($what)] } { 1031 # Return the contents of the vtk file.1032 1049 return $_comp2vtkvolume($what) 1033 1050 } … … 1043 1060 error "bad option \"$what\": should be [join [lsort [array names _comp2dims]] {, }]" 1044 1061 } 1062 1063 itcl::body Rappture::Field::ConvertToVtkData { comp } { 1064 set ds "" 1065 switch -- [typeof $comp] { 1066 "unirect2d" { 1067 foreach { x1 x2 xN y1 y2 yN } [$dataobj mesh $comp] break 1068 set spacingX [expr {double($x2 - $x1)/double($xN - 1)}] 1069 set spacingY [expr {double($y2 - $y1)/double($yN - 1)}] 1070 1071 set ds [vtkImageData $this-grdataTemp] 1072 $ds SetDimensions $xN $yN 1 1073 $ds SetOrigin $x1 $y1 0 1074 $ds SetSpacing $spacingX $spacingY 0 1075 set arr [vtkDoubleArray $this-arrTemp] 1076 foreach {val} [$dataobj values $comp] { 1077 $arr InsertNextValue $val 1078 } 1079 [$ds GetPointData] SetScalars $arr 1080 } 1081 "unirect3d" { 1082 foreach { x1 x2 xN y1 y2 yN z1 z2 zN } [$dataobj mesh $comp] break 1083 set spacingX [expr {double($x2 - $x1)/double($xN - 1)}] 1084 set spacingY [expr {double($y2 - $y1)/double($yN - 1)}] 1085 set spacingZ [expr {double($z2 - $z1)/double($zN - 1)}] 1086 1087 set ds [vtkImageData $this-grdataTemp] 1088 $ds SetDimensions $xN $yN $zN 1089 $ds SetOrigin $x1 $y1 $z1 1090 $ds SetSpacing $spacingX $spacingY $spacingZ 1091 set arr [vtkDoubleArray $this-arrTemp] 1092 foreach {val} [$dataobj values $comp] { 1093 $arr InsertNextValue $val 1094 } 1095 [$ds GetPointData] SetScalars $val 1096 } 1097 "vtkcontour" { 1098 return [$dataobj blob $comp] 1099 } 1100 "dx" { 1101 return [Rappture::ConvertDxToVtk $_comp2dx($what)] 1102 } 1103 default { 1104 set mesh [$dataobj mesh $comp] 1105 switch -- [$mesh GetClassName] { 1106 vtkPoints { 1107 # handle cloud of points 1108 set ds [vtkPolyData $this-polydataTemp] 1109 $ds SetPoints $mesh 1110 [$ds GetPointData] SetScalars [$dataobj values $comp] 1111 } 1112 vtkPolyData { 1113 set ds [vtkPolyData $this-polydataTemp] 1114 $ds ShallowCopy $mesh 1115 [$ds GetPointData] SetScalars [$dataobj values $comp] 1116 } 1117 vtkUnstructuredGrid { 1118 # handle 3D grid with connectivity 1119 set ds [vtkUnstructuredGrid $this-grdataTemp] 1120 $ds ShallowCopy $mesh 1121 [$ds GetPointData] SetScalars [$dataobj values $comp] 1122 } 1123 vtkRectilinearGrid { 1124 # handle 3D grid with connectivity 1125 set ds [vtkRectilinearGrid $this-grdataTemp] 1126 $ds ShallowCopy $mesh 1127 [$ds GetPointData] SetScalars [$dataobj values $comp] 1128 } 1129 default { 1130 error "don't know how to handle [$mesh GetClassName] data" 1131 } 1132 } 1133 } 1134 } 1135 1136 if {"" != $ds} { 1137 set writer [vtkDataSetWriter $this-dsWriterTmp] 1138 $writer SetInput $ds 1139 $writer SetFileTypeToASCII 1140 $writer WriteToOutputStringOn 1141 $writer Write 1142 set out [$writer GetOutputString] 1143 $ds Delete 1144 $writer Delete 1145 } else { 1146 set out "" 1147 error "No DataSet to write" 1148 } 1149 1150 append out "\n" 1151 return $out 1152 } 1153 1154 itcl::body Rappture::Field::ReadVtkDataSet { comp contents } { 1155 package require vtk 1156 1157 set reader $this-datasetreader 1158 vtkDataSetReader $reader 1159 1160 # Write the contents to a file just in case it's binary. 1161 set tmpfile file[pid].vtk 1162 set f [open "$tmpfile" "w"] 1163 fconfigure $f -translation binary -encoding binary 1164 puts $f $contents 1165 close $f 1166 $reader SetFileName $tmpfile 1167 $reader ReadAllScalarsOn 1168 $reader ReadAllVectorsOn 1169 $reader ReadAllFieldsOn 1170 $reader Update 1171 set dataset [$reader GetOutput] 1172 set limits {} 1173 foreach {xmin xmax ymin ymax zmin zmax} [$dataset GetBounds] break 1174 lappend limits xmin $xmin xmax $xmax ymin $ymin ymax $ymax 1175 set dataAttrs [$dataset GetPointData] 1176 if { $dataAttrs == ""} { 1177 puts stderr "No point data" 1178 } 1179 for {set i 0} {$i < [$dataAttrs GetNumberOfArrays] } {incr i} { 1180 set array [$dataAttrs GetArray $i] 1181 set name [$dataAttrs GetArrayName $i] 1182 foreach {min max} [$array GetRange] break 1183 lappend limits $name-min $min $name-max $max 1184 lappend _fields $name 1185 } 1186 set _comp2limits($comp) $limits 1187 puts stderr limits=$limits 1188 $reader Delete 1189 file delete $tmpfile 1190 } 1191 -
branches/nanovis2/gui/scripts/field2dresult.tcl
r2977 r3175 61 61 set servers [Rappture::VisViewer::GetServerList "nanovis"] 62 62 } 63 "vtkcontour" - "vtkheightmap" {63 "vtkcontour" - "vtkheightmap" - "vtkstreamlines" - "vtkviewer" { 64 64 set servers [Rappture::VisViewer::GetServerList "vtkvis"] 65 65 } … … 78 78 } 79 79 } 80 " vtkheightmap" {80 "flowvis" { 81 81 itk_component add renderer { 82 Rappture:: VtkHeightmapViewer $itk_interior.ren $servers82 Rappture::FlowvisViewer $itk_interior.ren $servers 83 83 } 84 84 } … … 88 88 } 89 89 } 90 " flowvis" {90 "vtkheightmap" { 91 91 itk_component add renderer { 92 Rappture::FlowvisViewer $itk_interior.ren $servers 92 Rappture::VtkHeightmapViewer $itk_interior.ren $servers 93 } 94 } 95 "vtkstreamlines" { 96 itk_component add renderer { 97 Rappture::VtkStreamlinesViewer $itk_interior.ren $servers 98 } 99 } 100 "vtkviewer" { 101 itk_component add renderer { 102 Rappture::VtkViewer $itk_interior.ren $servers 93 103 } 94 104 } -
branches/nanovis2/gui/scripts/field3dresult.tcl
r2977 r3175 59 59 set servers [Rappture::VisViewer::GetServerList "nanovis"] 60 60 } 61 "vtkcontour" - "vtk streamlines" - "vtkvolume" - "vtkviewer"{61 "vtkcontour" - "vtkheightmap" - "vtkstreamlines" - "vtkviewer" - "vtkvolume" { 62 62 set servers [Rappture::VisViewer::GetServerList "vtkvis"] 63 63 } … … 69 69 puts stderr "unknown render mode \"$flags(-mode)\"" 70 70 } 71 } 71 } 72 72 if {"" != $servers && $flags(-mode) != "vtk"} { 73 73 switch -- $flags(-mode) { … … 82 82 } 83 83 } 84 "vtkvolume" { 85 catch { 84 "vtkcontour" { 86 85 itk_component add renderer { 87 Rappture::Vtk VolumeViewer $itk_interior.ren $servers86 Rappture::VtkContourViewer $itk_interior.ren $servers 88 87 } 89 } errs 90 puts stderr errs=$errs 88 } 89 "vtkheightmap" { 90 itk_component add renderer { 91 Rappture::VtkHeightmapViewer $itk_interior.ren $servers 92 } 91 93 } 92 94 "vtkstreamlines" { 93 95 itk_component add renderer { 94 96 Rappture::VtkStreamlinesViewer $itk_interior.ren $servers 97 } 98 } 99 "vtkviewer" { 100 itk_component add renderer { 101 Rappture::VtkViewer $itk_interior.ren $servers 102 } 103 } 104 "vtkvolume" { 105 itk_component add renderer { 106 Rappture::VtkVolumeViewer $itk_interior.ren $servers 95 107 } 96 108 } -
branches/nanovis2/gui/scripts/gauge.tcl
r1850 r3175 239 239 } 240 240 real { 241 if {[string length $nv] <= 0 242 || ![string is double $nv] 243 || [regexp -nocase {^(inf|nan)$} $nv]} { 241 # "scan" will reject the number if the string is "NaN" or 242 # "Inf" or the empty string. It also is accepts large numbers 243 # (e.g. 111111111111111111111) that "string is double" 244 # rejects. The problem with "scan" is that it doesn't care if 245 # there are extra characters trailing the number (eg. "123a"). 246 # The extra %s substitution is used to detect this case. 247 if { [scan $nv "%g%s" dummy1 dummy2] != 1 } { 244 248 error "bad value \"$nv\": should be a real number" 245 249 } -
branches/nanovis2/gui/scripts/histogram.tcl
r2778 r3175 354 354 set count 0 355 355 foreach line [split $xydata \n] { 356 foreach {name value} $line break 357 $_yvalues($comp) append $value 358 $_xvalues($comp) append $count 359 lappend _xlabels($comp) $name 360 incr count 356 if {[llength $line] == 2} { 357 foreach {name value} $line break 358 $_yvalues($comp) append $value 359 $_xvalues($comp) append $count 360 lappend _xlabels($comp) $name 361 incr count 362 } 361 363 } 362 364 set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)] … … 368 370 foreach line [split $xhwdata \n] { 369 371 set n [scan $line {%s %s %s} name h w] 370 lappend _xlabels($comp) $name 371 $_xvalues($comp) append $count 372 $_yvalues($comp) append $h 373 if { $n == 3 } { 374 $_widths($comp) append $w 372 if {$n >= 2} { 373 lappend _xlabels($comp) $name 374 $_xvalues($comp) append $count 375 $_yvalues($comp) append $h 376 if { $n == 3 } { 377 $_widths($comp) append $w 378 } 379 incr count 375 380 } 376 incr count377 381 } 378 382 set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)] -
branches/nanovis2/gui/scripts/histogramresult.tcl
r2778 r3175 545 545 set xv [$dataobj mesh $comp] 546 546 set yv [$dataobj values $comp] 547 foreach x [$xv range 0 end] y [$yv range 0 end] { 548 append csvdata \ 549 [format "%20.15g, %20.15g\n" $x $y] 550 } 547 if { [$xv length] > 0 && [$yv length] > 0 } { 548 foreach x [$xv range 0 end] y [$yv range 0 end] { 549 append csvdata \ 550 [format "%20.15g, %20.15g\n" $x $y] 551 } 552 } 551 553 set first 0 552 554 } … … 717 719 # Compute default bar width for histogram elements. 718 720 if { [$zv length] == [$xv length] } { 719 foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] { 720 set elem "elem[incr count]" 721 set _elem2dataobj($elem) $dataobj 722 $g element create $elem -x $x -y $y -barwidth $z \ 723 -label $label -foreground $color \ 724 -mapx $mapx -mapy $mapy 725 } 721 if { [$xv length] > 0 && [$yv length] > 0 } { 722 set xvalues [$xv range 0 end] 723 set yvalues [$yv range 0 end] 724 set zvalues [$zv range 0 end] 725 foreach x $xvalues y $yvalues z $zvalues { 726 set elem "elem[incr count]" 727 set _elem2dataobj($elem) $dataobj 728 $g element create $elem -x $x -y $y -barwidth $z \ 729 -label $label -foreground $color \ 730 -mapx $mapx -mapy $mapy 731 } 732 } 726 733 } else { 727 734 set r [blt::vector expr {max($xv) - min($xv)}] 728 set z [expr {$r / ([$xv length]-1) * 0.8}] 735 set length [$xv length] 736 if { $length > 1 } { 737 set z [expr {$r / ([$xv length]-1) * 0.8}] 738 } else { 739 set z 1 740 } 729 741 set elem "elem[incr count]" 730 742 set _elem2dataobj($elem) $dataobj … … 1571 1583 # Determine the element name from the value 1572 1584 set index [expr round($value)] 1573 if { [info exists _xlabels($index)] } { 1574 return $_xlabels($index) 1575 } 1585 set d [expr abs($value - $index)] 1586 # Ignore values that aren't close to the integer value 1587 if { $d < 0.00000001 } { 1588 if { [info exists _xlabels($index)] } { 1589 return $_xlabels($index) 1590 } 1591 } 1576 1592 return " " 1577 1593 } -
branches/nanovis2/gui/scripts/htmlviewer.tcl
r2981 r3175 304 304 if {"" != $node} { 305 305 set bbox [$itk_component(html) bbox $node] 306 set realht [expr {[lindex $bbox 3]-[lindex $bbox 1]}] 306 if { [llength $bbox] == 4 } { 307 set realht [expr {[lindex $bbox 3]-[lindex $bbox 1]}] 308 } 307 309 } 308 310 if {$itk_option(-maxlines) > 0} { -
branches/nanovis2/gui/scripts/main.tcl
r2977 r3175 55 55 option add *Balloon*Radiobutton.font -*-helvetica-medium-r-normal-*-12-* 56 56 option add *Balloon*Checkbutton.font -*-helvetica-medium-r-normal-*-12-* 57 option add *ResultSe t.controlbarBackground #6666cc58 option add *ResultSe t.controlbarForeground white59 option add *ResultSe t.activeControlBackground #ccccff60 option add *ResultSe t.activeControlForeground black57 option add *ResultSelector.controlbarBackground #6666cc 58 option add *ResultSelector.controlbarForeground white 59 option add *ResultSelector.activeControlBackground #ccccff 60 option add *ResultSelector.activeControlForeground black 61 61 option add *Radiodial.length 3i 62 62 option add *BugReport*banner*foreground white … … 146 146 set xmlobj [Rappture::library $params(-tool)] 147 147 148 set installdir [file dirname $params(-tool)] 149 if {"." == $installdir} { 150 set installdir [pwd] 151 } 148 set installdir [file normalize [file dirname $params(-tool)]] 149 $xmlobj put tool.version.application.directory(tool) $installdir 152 150 153 151 set tool [Rappture::Tool ::#auto $xmlobj $installdir] -
branches/nanovis2/gui/scripts/mesh.tcl
r2792 r3175 366 366 if {![info exists _pts2elem($npts)]} { 367 367 switch -- $npts { 368 3 { 369 set _pts2elem($npts) $this-elem3 370 vtkTriangle $_pts2elem($npts) 371 } 368 372 4 { 369 373 set _pts2elem($npts) $this-elem4 -
branches/nanovis2/gui/scripts/nanovisviewer.tcl
r3023 r3175 117 117 private method volume { tag name } 118 118 private method GetVolumeInfo { w } 119 private method SetOrientation {} 119 120 120 121 private variable _arcball "" … … 1953 1954 incr row 1954 1955 } 1956 1957 itk_component add orientation { 1958 Rappture::Combobox $inner.orientation -width 10 -editable no 1959 } 1960 $inner.orientation choices insert end \ 1961 "front" "0 90 0" \ 1962 "back" "180 90 0" \ 1963 "top" "0 0 0" \ 1964 "bottom" "0 180 0" \ 1965 "left" "270 90 0 " \ 1966 "right" "90 90 0" \ 1967 "default" "45 45 0" 1968 $itk_component(orientation) value "default" 1969 bind $inner.orientation <<Value>> [itcl::code $this SetOrientation] 1970 1955 1971 blt::table configure $inner c0 c1 -resize none 1956 1972 blt::table configure $inner c2 -resize expand … … 2132 2148 } 2133 2149 2150 2151 itcl::body Rappture::NanovisViewer::SetOrientation {} { 2152 set angles [$itk_component(orientation) value] 2153 foreach name { theta phi psi } angle $angles { 2154 set _view($name) $angle 2155 } 2156 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 2157 SendCmd "camera angle $xyz" 2158 } -
branches/nanovis2/gui/scripts/note.tcl
r1641 r3175 1 1 2 # ---------------------------------------------------------------------- 2 3 # COMPONENT: Note - widget for displaying HTML notes … … 68 69 69 70 _setContents [$_owner xml get $_path.contents] 70 } 71 set w [$_owner xml get $_path.width] 72 if { $w != "" } { 73 $itk_component(html) configure -width $w 74 } 75 set h [$_owner xml get $_path.height] 76 if { $h != "" } { 77 $itk_component(html) configure -height $h 78 } 79 } 80 71 81 72 82 # ---------------------------------------------------------------------- -
branches/nanovis2/gui/scripts/numberresult.tcl
r2744 r3175 957 957 # - multiple axes? dim other axes 958 958 # - pop up tooltip about data 959 960 $g element deactivate $_hilite(elem) 959 if {$_hilite(elem) ne ""} { 960 $g element deactivate $_hilite(elem) 961 } 961 962 $g crosshairs configure -hide yes 962 963 Rappture::Tooltip::tooltip cancel … … 1041 1042 # - take down tooltip 1042 1043 # 1043 $g element deactivate $_hilite(elem) 1044 if {$_hilite(elem) ne ""} { 1045 $g element deactivate $_hilite(elem) 1046 } 1044 1047 1045 1048 set allx [$g x2axis use] -
branches/nanovis2/gui/scripts/periodictable.tcl
r2977 r3175 1 2 1 # ---------------------------------------------------------------------- 3 2 # COMPONENT: periodictable - drop-down list of items … … 7 6 # 8 7 # ====================================================================== 9 # AUTHOR: Michael McLennan, Purdue University10 # Copyright (c) 2004-20 05Purdue Research Foundation8 # AUTHOR: George Howlett, Purdue University 9 # Copyright (c) 2004-2012 Purdue Research Foundation 11 10 # 12 11 # See the file "license.terms" for information on usage and … … 32 31 public method value { {name ""} } 33 32 34 private variable _table 33 public proc FindElement { string } 34 public proc ElementIsType { string args } 35 35 36 private variable _dispatcher "" 36 37 private variable _current "" … … 43 44 protected method Activate { widget id x y } 44 45 protected method Deactivate { widget id } 45 protected method FindElement { string }46 46 private common _colors 47 47 array set _colors { … … 242 242 Lawrencium 103 Lr [262.110] 9 17 actinoid 243 243 } 244 245 private common _table 246 foreach { name number symbol weight row column type } $_tableData { 247 set _table($name) [list name $name number $number symbol $symbol \ 248 weight $weight row $row column $column type $type] 249 } 250 244 251 private common _types 245 252 array set _types { … … 302 309 $_dispatcher register !rebuild 303 310 $_dispatcher dispatch $this !rebuild "[itcl::code $this Redraw]; list" 304 foreach { name number symbol weight row column type } $_tableData { 305 set _table($name) [list name $name number $number symbol $symbol \ 306 weight $weight row $row column $column type $type] 311 312 foreach name [array names _table] { 307 313 set _state($name) "normal" 308 314 } 315 309 316 itk_component add scroller { 310 317 Rappture::Scroller $itk_interior.sc \ … … 494 501 set _current $elem 495 502 $_dispatcher event -idle !rebuild 503 } 504 505 # ---------------------------------------------------------------------- 506 # USAGE: FindElement <what> 507 # 508 # Checks to see if the given string <what> is recognized as an element 509 # name, symbol, or number. Returns the corresponding element name 510 # or "" if the element is not recognized. 511 # ---------------------------------------------------------------------- 512 itcl::body Rappture::PeriodicTable::FindElement { what } { 513 foreach name [array names _table] { 514 array unset info 515 array set info $_table($name) 516 if { $what eq $info(name) || $what eq $info(number) || 517 $what eq $info(symbol) } { 518 return $info(name) 519 } 520 } 521 return "" 522 } 523 524 # ---------------------------------------------------------------------- 525 # USAGE: ElementIsType <name> <type> <type>... 526 # 527 # Checks to see if the given element <name> is one of the specified 528 # <type> values. Returns true if the element is one of the types 529 # (logical or), or false if it is not. 530 # ---------------------------------------------------------------------- 531 itcl::body Rappture::PeriodicTable::ElementIsType { name args } { 532 foreach type $args { 533 if {[info exists _types($type)]} { 534 if {[lsearch -exact $_types($type) $name] >= 0} { 535 return 1 536 } 537 } 538 } 539 return 0 496 540 } 497 541 … … 608 652 $c configure -height $height -width $width -background white 609 653 } 610 611 # ----------------------------------------------------------------------612 # USAGE: FindElement613 #614 # Used to manipulate the selection in the table.615 #616 # ----------------------------------------------------------------------617 itcl::body Rappture::PeriodicTable::FindElement { what } {618 foreach name [array names _table] {619 array unset info620 array set info $_table($name)621 if { $what == $info(name) || $what == $info(number) ||622 $what == $info(symbol) } {623 return $info(name)624 }625 }626 return ""627 }628 -
branches/nanovis2/gui/scripts/radiodial.tcl
r1929 r3175 565 565 } 566 566 } 567 error "bad value \"$str\": should be something matching the raw values \"[join $_values ,]\"" 567 568 # didn't match -- build a return string of possible values 569 set labels "" 570 foreach vlist $_values { 571 foreach v $vlist { 572 lappend labels "\"$_val2label($v)\"" 573 } 574 } 575 error "bad value \"$str\": should be one of [join $labels ,]" 568 576 } 569 577 -
branches/nanovis2/gui/scripts/resultset.tcl
r2977 r3175 1 2 # ---------------------------------------------------------------------- 3 # COMPONENT: ResultSet - controls for a collection of related results 4 # 5 # This widget stores a collection of results that all represent 6 # the same quantity, but for various ranges of input values. 7 # It also manages the controls to select and visualize the data. 1 # ---------------------------------------------------------------------- 2 # COMPONENT: ResultSet - set of XML objects for simulated results 3 # 4 # This data structure collects all of the simulated results 5 # produced by a series of tool runs. It is used by the Analyzer, 6 # ResultSelector, and other widgets to keep track of all known runs 7 # and visualize the result that is currently selected. Each run 8 # has an index number ("#1", "#2", "#3", etc.) that can be used to 9 # label the run and refer to it later. 8 10 # ====================================================================== 9 11 # AUTHOR: Michael McLennan, Purdue University 10 # Copyright (c) 2004-20 05Purdue Research Foundation12 # Copyright (c) 2004-2012 Purdue Research Foundation 11 13 # 12 14 # See the file "license.terms" for information on usage and 13 15 # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. 14 16 # ====================================================================== 15 package require Itk 16 17 option add *ResultSet.width 4i widgetDefault 18 option add *ResultSet.height 4i widgetDefault 19 option add *ResultSet.missingData skip widgetDefault 20 option add *ResultSet.controlbarBackground gray widgetDefault 21 option add *ResultSet.controlbarForeground white widgetDefault 22 option add *ResultSet.activeControlBackground #ffffcc widgetDefault 23 option add *ResultSet.activeControlForeground black widgetDefault 24 option add *ResultSet.controlActiveForeground blue widgetDefault 25 option add *ResultSet.toggleBackground gray widgetDefault 26 option add *ResultSet.toggleForeground white widgetDefault 27 option add *ResultSet.textFont \ 28 -*-helvetica-medium-r-normal-*-12-* widgetDefault 29 option add *ResultSet.boldFont \ 30 -*-helvetica-bold-r-normal-*-12-* widgetDefault 17 package require Itcl 31 18 32 19 itcl::class Rappture::ResultSet { 33 inherit itk::Widget34 35 itk_option define -activecontrolbackground activeControlBackground Background ""36 itk_option define -activecontrolforeground activeControlForeground Foreground ""37 itk_option define -controlactiveforeground controlActiveForeground Foreground ""38 itk_option define -togglebackground toggleBackground Background ""39 itk_option define -toggleforeground toggleForeground Foreground ""40 itk_option define -textfont textFont Font ""41 itk_option define -boldfont boldFont Font ""42 itk_option define -foreground foreground Foreground ""43 itk_option define -clearcommand clearCommand ClearCommand ""44 itk_option define -settingscommand settingsCommand SettingsCommand ""45 itk_option define -promptcommand promptCommand PromptCommand ""46 47 20 constructor {args} { # defined below } 48 21 destructor { # defined below } … … 50 23 public method add {xmlobj} 51 24 public method clear {{xmlobj ""}} 52 public method activate {column} 25 public method diff {option args} 26 public method find {collist vallist} 27 public method get {collist xmlobj} 53 28 public method contains {xmlobj} 54 public method size {{what -results}} 55 56 protected method _doClear {what} 57 protected method _doSettings {{cmd ""}} 58 protected method _control {option args} 59 protected method _fixControls {args} 60 protected method _fixLayout {args} 61 protected method _fixNumResults {} 62 protected method _fixSettings {args} 63 protected method _fixValue {column why} 64 protected method _drawValue {column widget wmax} 65 protected method _toggleAll {{column "current"}} 66 protected method _getValues {column {which ""}} 67 protected method _getTooltip {role column} 68 protected method _getParamDesc {which {index "current"}} 29 public method size {} 30 31 public method notify {option args} 32 protected method _notifyHandler {args} 33 69 34 protected method _addOneResult {tuples xmlobj {simnum ""}} 70 35 … … 72 37 private variable _results "" ;# tuple of known results 73 38 private variable _resultnum 0 ;# counter for result #1, #2, etc. 74 private variable _recent "" ;# most recent result in _results 75 private variable _active "" ;# column with active control 76 private variable _plotall 0 ;# non-zero => plot all active results 77 private variable _layout ;# info used in _fixLayout 78 private variable _counter 0 ;# counter for unique control names 79 private variable _settings 0 ;# non-zero => _fixSettings in progress 80 81 private common _cntlInfo ;# maps column name => control info 39 private variable _notify ;# info used for notify command 82 40 } 83 41 84 itk::usual ResultSet {85 keep -background -foreground -cursor -font86 }87 88 42 # ---------------------------------------------------------------------- 89 43 # CONSTRUCTOR 90 44 # ---------------------------------------------------------------------- 91 45 itcl::body Rappture::ResultSet::constructor {args} { 92 option add hull.width hull.height93 pack propagate $itk_component(hull) no94 95 46 # create a dispatcher for events 96 47 Rappture::dispatcher _dispatcher 97 $_dispatcher register !fixcntls 98 $_dispatcher dispatch $this !fixcntls \ 99 [itcl::code $this _fixControls] 100 $_dispatcher register !layout 101 $_dispatcher dispatch $this !layout \ 102 [itcl::code $this _fixLayout] 103 $_dispatcher register !settings 104 $_dispatcher dispatch $this !settings \ 105 [itcl::code $this _fixSettings] 106 107 # initialize controls info 108 set _cntlInfo($this-all) "" 109 110 # initialize layout info 111 set _layout(mode) "usual" 112 set _layout(active) "" 48 $_dispatcher register !change 49 $_dispatcher dispatch $this !change \ 50 [itcl::code $this _notifyHandler] 113 51 114 52 # create a list of tuples for data … … 117 55 $_results column insert end -name simnum -label "simulation number" 118 56 119 120 itk_component add cntls { 121 frame $itk_interior.cntls 122 } { 123 usual 124 rename -background -controlbarbackground controlbarBackground Background 125 rename -highlightbackground -controlbarbackground controlbarBackground Background 126 } 127 pack $itk_component(cntls) -fill x -pady {0 2} 128 129 itk_component add clearall { 130 button $itk_component(cntls).clearall -text "Clear" -state disabled \ 131 -padx 1 -pady 1 \ 132 -relief flat -overrelief raised \ 133 -command [itcl::code $this _doClear all] 134 } { 135 usual 136 rename -background -controlbarbackground controlbarBackground Background 137 rename -foreground -controlbarforeground controlbarForeground Foreground 138 rename -highlightbackground -controlbarbackground controlbarBackground Background 139 } 140 pack $itk_component(clearall) -side right -padx 2 -pady 1 141 Rappture::Tooltip::for $itk_component(clearall) \ 142 "Clears all results collected so far." 143 144 itk_component add clear { 145 button $itk_component(cntls).clear -text "Clear One" -state disabled \ 146 -padx 1 -pady 1 \ 147 -relief flat -overrelief raised \ 148 -command [itcl::code $this _doClear current] 149 } { 150 usual 151 rename -background -controlbarbackground controlbarBackground Background 152 rename -foreground -controlbarforeground controlbarForeground Foreground 153 rename -highlightbackground -controlbarbackground controlbarBackground Background 154 } 155 pack $itk_component(clear) -side right -padx 2 -pady 1 156 Rappture::Tooltip::for $itk_component(clear) \ 157 "Clears the result that is currently selected." 158 159 itk_component add status { 160 label $itk_component(cntls).status -anchor w \ 161 -text "No results" -padx 0 -pady 0 162 } { 163 usual 164 rename -background -controlbarbackground controlbarBackground Background 165 rename -foreground -controlbarforeground controlbarForeground Foreground 166 rename -highlightbackground -controlbarbackground controlbarBackground Background 167 } 168 pack $itk_component(status) -side left -padx 2 -pady {2 0} 169 170 itk_component add dials { 171 frame $itk_interior.dials 172 } 173 pack $itk_component(dials) -expand yes -fill both 174 bind $itk_component(dials) <Configure> \ 175 [list $_dispatcher event -after 10 !layout why resize] 176 177 # create the permanent controls in the "short list" area 178 set dials $itk_component(dials) 179 frame $dials.bg 180 Rappture::Radiodial $dials.dial -valuewidth 0 181 Rappture::Tooltip::for $dials.dial \ 182 "@[itcl::code $this _getTooltip dial active]" 183 184 set fn [option get $itk_component(hull) textFont Font] 185 label $dials.all -text "All" -padx 8 \ 186 -borderwidth 1 -relief raised -font $fn 187 Rappture::Tooltip::for $dials.all \ 188 "@[itcl::code $this _getTooltip all active]" 189 bind $dials.all <ButtonRelease> [itcl::code $this _toggleAll] 190 191 frame $dials.labelmore 192 label $dials.labelmore.arrow -bitmap [Rappture::icon empty] -borderwidth 0 193 pack $dials.labelmore.arrow -side left -fill y 194 label $dials.labelmore.name -text "more parameters..." -font $fn \ 195 -borderwidth 0 -padx 0 -pady 1 196 pack $dials.labelmore.name -side left 197 label $dials.labelmore.value 198 pack $dials.labelmore.value -side left 199 200 eval itk_initialize $args 57 # clear notification info 58 set _notify(ALL) "" 59 60 eval configure $args 201 61 } 202 62 … … 205 65 # ---------------------------------------------------------------------- 206 66 itcl::body Rappture::ResultSet::destructor {} { 67 clear 207 68 itcl::delete object $_results 208 69 } … … 218 79 # ---------------------------------------------------------------------- 219 80 itcl::body Rappture::ResultSet::add {xmlobj} { 220 # make sure we fix up controls at some point221 $_dispatcher event -idle !fixcntls222 223 #224 # If this is the first result, then there are no diffs.225 # Add it right in.226 #227 81 set xmlobj0 [$_results get -format xmlobj end] 228 if {"" == $xmlobj0} { 229 # first element -- always add 82 if {$xmlobj0 eq ""} { 83 # 84 # If this is the first result, then there are no diffs. 85 # Add it right in. 86 # 230 87 set simnum "#[incr _resultnum]" 231 88 $_results insert end [list $xmlobj $simnum] 232 _fixNumResults 233 set _recent $xmlobj 234 return $simnum 235 } 236 237 # 238 # For all later results, find the diffs and add any new columns 239 # into the results tuple. The latest result is the most recent. 240 # 241 set simnum [_addOneResult $_results $xmlobj] 242 set _recent $xmlobj 243 _fixNumResults 89 } else { 90 # 91 # For all later results, find the diffs and add any new columns 92 # into the results tuple. The latest result is the most recent. 93 # 94 set simnum [_addOneResult $_results $xmlobj] 95 } 96 97 # make sure we fix up associated controls 98 $_dispatcher event -now !change op add what $xmlobj 244 99 245 100 return $simnum … … 253 108 # ---------------------------------------------------------------------- 254 109 itcl::body Rappture::ResultSet::clear {{xmlobj ""}} { 255 set shortlist $itk_component(dials)256 set controlsChanged 0257 258 # clear any currently highlighted result259 _doSettings260 261 110 if {$xmlobj ne ""} { 262 111 # … … 269 118 set irun [$_results find -format xmlobj $xmlobj] 270 119 if {[llength $irun] == 1} { 271 # figure out where we are in the active control, and 272 # what value we should display after this one is deleted 273 set vlist "" 274 foreach {label val} [_getValues $_active all] { 275 lappend vlist $label 276 } 277 set ipos [lsearch $vlist $_cntlInfo($this-$_active-value)] 278 279 set vcurr "" 280 set vnext "" 281 if {$ipos >= 0} { 282 # try to stay at this value, if we can 283 set vcurr [lindex $vlist $ipos] 284 285 # fall back to this value, if we have to 286 if {$ipos > 0} { incr ipos -1 } else { incr ipos } 287 set vnext [lindex $vlist $ipos] 288 } 289 290 # delete the value from the tuples of all results 120 # grab a description of what we're about to delete 121 set dlist [list simnum [$_results get -format simnum $irun]] 122 foreach col [lrange [$_results column names] 2 end] { 123 set raw [lindex [Rappture::LibraryObj::value $xmlobj $col] 0] 124 lappend dlist $col $raw ;# use "raw" (user-readable) label 125 } 126 127 # delete this from the tuples of all results 128 itcl::delete object $xmlobj 291 129 $_results delete $irun 292 130 … … 309 147 set _results $new 310 148 311 # delete any adjuster controls that disappeared 312 foreach col $_cntlInfo($this-all) { 313 if {[$_results column names $col] eq ""} { 314 set id $_cntlInfo($this-$col-id) 315 destroy $shortlist.label$id 316 array unset _cntlInfo $this-$col* 317 318 set i [lsearch -exact $_cntlInfo($this-all) $col] 319 if {$i >= 0} { 320 set _cntlInfo($this-all) [lreplace $_cntlInfo($this-all) $i $i] 149 # make sure we fix up associated controls at some point 150 $_dispatcher event -now !change op clear what $dlist 151 } 152 } else { 153 # 154 # Delete all results. 155 # 156 for {set irun 0} {$irun < [$_results size]} {incr irun} { 157 set xo [$_results get -format xmlobj $irun] 158 itcl::delete object $xo 159 } 160 $_results delete 0 end 161 162 # make sure we fix up associated controls at some point 163 $_dispatcher event -now !change op clear what all 164 } 165 166 if {[$_results size] == 0} { 167 # no results left? then reset to a clean state 168 eval $_results column delete [lrange [$_results column names] 2 end] 169 set _resultnum 0 170 } 171 } 172 173 # ---------------------------------------------------------------------- 174 # USAGE: diff names 175 # USAGE: diff values <column> ?<which>? 176 # 177 # Returns information about the diffs in the current set of known 178 # results. The "diff names" returns a list of column names for 179 # parameters that have diffs. (These are the columns in the tuples.) 180 # 181 # The "diff values" returns the various values associated with a 182 # particular <column> name. If the optional <which> is specified, 183 # then it is treated as an index into the list of values--0 for the 184 # first value, 1 for the second, etc. Each value is returned as 185 # a list with two words. The first is the the label associated with 186 # the value. The second is the normalized (numeric) value, which can 187 # be sorted to get a particular ordering. 188 # ---------------------------------------------------------------------- 189 itcl::body Rappture::ResultSet::diff {option args} { 190 switch -- $option { 191 names { 192 return [$_results column names] 193 } 194 values { 195 if {[llength $args] < 1} { 196 error "wrong # args: should be \"diff values col ?which?\"" 197 } 198 set col [lindex $args 0] 199 200 set which "all" 201 if {[llength $args] > 1} { 202 set which [lindex $args 1] 203 } 204 205 set rlist "" 206 # build an array of normalized values and their labels 207 if {$col == "simnum"} { 208 set nruns [$_results size] 209 for {set n 0} {$n < $nruns} {incr n} { 210 set simnum [$_results get -format simnum $n] 211 lappend rlist $simnum $n 212 } 213 } else { 214 set havenums 1 215 foreach rec [$_results get -format [list xmlobj $col]] { 216 set xo [lindex $rec 0] 217 set v [lindex $rec 1] 218 foreach {raw norm} \ 219 [Rappture::LibraryObj::value $xo $col] break 220 221 if {![info exists unique($v)]} { 222 # keep only unique label strings 223 set unique($v) $norm 321 224 } 322 323 if {$col == $_active} { 324 # control is going away -- switch to sim # control 325 set simnum0 [$_results get -format simnum 0] 326 set _cntlInfo($this-simnum-value) $simnum0 327 activate simnum 225 if {$havenums && ![string is double $norm]} { 226 set havenums 0 328 227 } 329 set controlsChanged 1 330 } 331 } 332 333 # can we find a tuple with the desired value for the active col? 334 if {$_active ne "" && $vcurr ne ""} { 335 set found "" 336 if {[$_results find -format $_active $vcurr] ne ""} { 337 set found $vcurr 338 } elseif {$vnext ne "" && [$_results find -format $_active $vnext] ne ""} { 339 set found $vnext 340 } 341 342 if {$found ne ""} { 343 # set the control to a value we were able to find 344 # this will trigger !settings and other adjustments 345 set _cntlInfo($this-$_active-value) $found 228 } 229 230 if {!$havenums} { 231 # don't have normalized nums? then sort and create nums 232 set rlist "" 233 set n 0 234 foreach val [lsort -dictionary [array names unique]] { 235 lappend rlist $val [incr n] 236 } 346 237 } else { 347 # if all else fails, show solution #1 348 set simnum0 [$_results get -format simnum 0] 349 set _cntlInfo($this-simnum-value) $simnum0 350 activate simnum 351 } 352 } 353 } 354 } else { 355 # 356 # Delete all results. 357 # 358 $_results delete 0 end 359 360 # delete all adjuster controls 361 foreach col $_cntlInfo($this-all) { 362 set id $_cntlInfo($this-$col-id) 363 destroy $shortlist.label$id 364 } 365 set controlsChanged 1 366 } 367 368 if {[$_results size] == 0} { 369 # 370 # No results left? Then clean everything up. 371 # 372 373 array unset _cntlInfo $this-* 374 # clean up control info 375 foreach key [array names _cntlInfo $this-*] { 376 catch {unset _cntlInfo($key)} 377 } 378 set _cntlInfo($this-all) "" 379 set _counter 0 380 set _resultnum 0 381 382 # clear out all results 383 eval $_results column delete [lrange [$_results column names] 2 end] 384 set _recent "" 385 set _active "" 386 387 set _plotall 0 388 $itk_component(dials).all configure -relief raised \ 389 -background $itk_option(-background) \ 390 -foreground $itk_option(-foreground) 391 } 392 393 # update status and Clear button 394 _fixNumResults 395 $_dispatcher event -idle !fixcntls 396 397 # let clients know that the number of controls has changed 398 if {$controlsChanged} { 399 event generate $itk_component(hull) <<Control>> 400 } 401 402 # if there's a callback for clearing, invoke it now... 403 if {[string length $itk_option(-clearcommand)] > 0} { 404 uplevel #0 $itk_option(-clearcommand) $xmlobj 405 } 406 } 407 408 # ---------------------------------------------------------------------- 409 # USAGE: activate <column> 410 # 411 # Clients use this to activate a particular column in the set of 412 # controls. When a column is active, its label is bold and its 413 # value has a radiodial in the "short list" area. 414 # ---------------------------------------------------------------------- 415 itcl::body Rappture::ResultSet::activate {column} { 416 set allowed [$_results column names] 417 if {[lsearch $allowed $column] < 0} { 418 error "bad value \"$column\": should be one of [join $allowed {, }]" 419 } 420 421 # column is now active 422 set _active $column 423 424 # keep track of usage, so we know which controls are popular 425 incr _cntlInfo($this-$column-usage) 426 427 # fix controls at next idle point 428 $_dispatcher event -idle !layout why data 429 $_dispatcher event -idle !settings column $_active 238 set rlist [array get unique] 239 } 240 } 241 242 if {$which eq "all"} { 243 return $rlist 244 } 245 246 # treat the "which" parameter as an XML object 247 set irun [lindex [$_results find -format xmlobj $which] 0] 248 if {$irun ne ""} { 249 set val [$_results get -format $col $irun] 250 array set val2norm $rlist 251 if {[info exists val2norm($val)]} { 252 return [list $val $val2norm($val)] 253 } 254 } 255 } 256 default { 257 error "bad option \"$option\": should be names or values" 258 } 259 } 260 } 261 262 # ---------------------------------------------------------------------- 263 # USAGE: find <columnList> <valueList> 264 # 265 # Searches through the results for a set of tuple values that match 266 # the <valueList> for the given <columnList>. Returns a list of 267 # matching xml objects or "" if there is no match. If the <valueList> 268 # is *, then it returns a list of all xml objects. 269 # ---------------------------------------------------------------------- 270 itcl::body Rappture::ResultSet::find {collist vallist} { 271 if {$vallist eq "*"} { 272 return [$_results get -format xmlobj] 273 } 274 275 set rlist "" 276 foreach irun [$_results find -format $collist -- $vallist] { 277 lappend rlist [$_results get -format xmlobj $irun] 278 } 279 return $rlist 280 } 281 282 # ---------------------------------------------------------------------- 283 # USAGE: get <columnList> <xmlobj> 284 # 285 # Returns values for the specified <columnList> for the given <xmlobj>. 286 # This is a way of querying associated data for the given object. 287 # ---------------------------------------------------------------------- 288 itcl::body Rappture::ResultSet::get {collist xmlobj} { 289 set irun [lindex [$_results find -format xmlobj $xmlobj] 0] 290 if {$irun ne ""} { 291 return [lindex [$_results get -format $collist $irun] 0] 292 } 293 return "" 430 294 } 431 295 … … 499 363 500 364 # ---------------------------------------------------------------------- 501 # USAGE: size ?-results|-controls|-controlarea? 502 # 503 # Returns various measures for the size of this area: 504 # -results ....... number of results loaded 505 # -controls ...... number of distinct control parameters 506 # -controlarea ... minimum size of usable control area, in pixels 507 # ---------------------------------------------------------------------- 508 itcl::body Rappture::ResultSet::size {{what -results}} { 509 switch -- $what { 510 -results { 511 return [$_results size] 512 } 513 -controls { 514 return [llength $_cntlInfo($this-all)] 515 } 516 -controlarea { 517 set ht [winfo reqheight $itk_component(cntls)] 518 incr ht 2 ;# padding below controls 519 520 set normalLine [font metrics $itk_option(-textfont) -linespace] 521 incr normalLine 2 ;# padding 522 set boldLine [font metrics $itk_option(-boldfont) -linespace] 523 incr boldLine 2 ;# padding 524 525 set numcntls [llength $_cntlInfo($this-all)] 526 switch -- $numcntls { 527 0 - 1 { 528 # 0 = no controls (no data at all) 529 # 1 = run control, but only 1 run so far 530 # add nothing 365 # USAGE: size 366 # 367 # Returns the number of results currently stored in the set. 368 # ---------------------------------------------------------------------- 369 itcl::body Rappture::ResultSet::size {} { 370 return [$_results size] 371 } 372 373 # ---------------------------------------------------------------------- 374 # USAGE: notify add <client> ?!event !event ...? <command> 375 # USAGE: notify get ?<client>? ?!event? 376 # USAGE: notify remove <client> ?!event !event ...? 377 # 378 # Clients use this to add/remove requests for notifications about 379 # various events that signal changes to the data in each ResultSet. 380 # 381 # The "notify add" operation takes a <client> name (any unique string 382 # identifying the client), an optional list of events, and the <command> 383 # that should be called for the callback. 384 # 385 # The "notify get" command returns information about clients and their 386 # registered callbacks. With no args, it returns a list of <client> 387 # names. If the <client> is specified, it returns a list of !events. 388 # If the <client> and !event is specified, it returns the <command>. 389 # 390 # The "notify remove" command removes any callback associated with 391 # a given <client>. If no particular !events are specified, then it 392 # removes callbacks for all events. 393 # ---------------------------------------------------------------------- 394 itcl::body Rappture::ResultSet::notify {option args} { 395 set allEvents {!change} 396 switch -- $option { 397 add { 398 if {[llength $args] < 2} { 399 error "wrong # args: should be \"notify add caller ?!event !event ...? command" 400 } 401 set caller [lindex $args 0] 402 set command [lindex $args end] 403 if {[llength $args] > 2} { 404 set events [lrange $args 1 end-1] 405 } else { 406 set events $allEvents 407 } 408 409 foreach name $events { 410 if {[lsearch -exact $allEvents $name] < 0} { 411 error "bad event \"$name\": should be [join $allEvents ,]" 412 } 413 if {[lsearch $_notify(ALL) $caller] < 0} { 414 lappend _notify(ALL) $caller 415 } 416 set _notify($caller-$name) $command 417 } 418 } 419 get { 420 switch -- [llength $args] { 421 0 { 422 return $_notify(ALL) 423 } 424 1 { 425 set caller [lindex $args 0] 426 set rlist "" 427 foreach key [array names _notify $caller-*] { 428 lappend rlist [lindex [split $key -] end] 429 } 430 return $rlist 431 } 432 2 { 433 set caller [lindex $args 0] 434 set name [lindex $args 1] 435 if {[info exists _notify($caller-$name)]} { 436 return $_notify($caller-$name) 437 } 438 return "" 531 439 } 532 440 default { 533 # non-active controls 534 incr ht [expr {($numcntls-1)*$normalLine}] 535 # active control 536 incr ht $boldLine 537 # dial for active control 538 incr ht [winfo reqheight $itk_component(dials).dial] 539 # padding around active control 540 incr ht 4 541 } 542 } 543 return $ht 441 error "wrong # args: should be \"notify get ?caller? ?!event?\"" 442 } 443 } 444 } 445 remove { 446 if {[llength $args] < 1} { 447 error "wrong # args: should be \"notify remove caller ?!event !event ...?" 448 } 449 set caller [lindex $args 0] 450 if {[llength $args] > 1} { 451 set events [lrange $args 1 end] 452 } else { 453 set events $allEvents 454 } 455 456 foreach name $events { 457 catch {unset _notify($caller-$name)} 458 } 459 if {[llength [array names _notify $caller-*]] == 0} { 460 set i [lsearch $_notify(ALL) $caller] 461 if {$i >= 0} { 462 set _notify(ALL) [lreplace $_notify(ALL) $i $i] 463 } 464 } 544 465 } 545 466 default { 546 error "bad option \"$what\": should be -results, -controls, or -controlarea" 547 } 548 } 549 } 550 551 # ---------------------------------------------------------------------- 552 # USAGE: _doClear all|current 553 # 554 # Invoked automatically when the user presses the "Clear One" or 555 # "Clear All" buttons. Invokes the -clearcommand to clear all data 556 # from this resultset and all other resultsets in an Analyzer. 557 # ---------------------------------------------------------------------- 558 itcl::body Rappture::ResultSet::_doClear {what} { 559 switch -- $what { 560 current { 561 set xmlobj "" 562 # value of xmlobj control is something like "#1" or "#2" 563 set irun [$_results find -format simnum $_cntlInfo($this-simnum-value)] 564 if {$irun ne ""} { 565 # convert index to a real xmlobj object 566 set xmlobj [$_results get -format xmlobj $irun] 567 } 568 clear $xmlobj 569 } 570 all { 571 clear 572 } 573 default { error "bad option \"$what\": should be current or all" } 574 } 575 } 576 577 # ---------------------------------------------------------------------- 578 # USAGE: _doSettings ?<command>? 579 # 580 # Used internally whenever the result selection changes to invoke 581 # the -settingscommand. This will notify some external widget, which 582 # with perform the plotting action specified in the <command>. 583 # ---------------------------------------------------------------------- 584 itcl::body Rappture::ResultSet::_doSettings {{cmd ""}} { 585 if {[string length $itk_option(-settingscommand)] > 0} { 586 uplevel #0 $itk_option(-settingscommand) $cmd 587 } 588 } 589 590 # ---------------------------------------------------------------------- 591 # USAGE: _control bind <widget> <column> 592 # USAGE: _control hilite <state> <column> <panel> 593 # USAGE: _control load <widget> <column> 594 # 595 # Used internally to manage the interactivity of controls. The "bind" 596 # operation sets up bindings on the label/value for each control, so 597 # you can mouse over and click on a control to activate it. The 598 # "hilite" operation controls highlighting of the control. The "load" 599 # operation loads data into the specified radiodial <widget>. 600 # ---------------------------------------------------------------------- 601 itcl::body Rappture::ResultSet::_control {option args} { 602 switch -- $option { 603 bind { 604 if {[llength $args] != 2} { 605 error "wrong # args: should be _control bind widget column" 606 } 607 set widget [lindex $args 0] 608 set col [lindex $args 1] 609 610 set panel [winfo parent $widget] 611 if {[string match label* [winfo name $panel]]} { 612 set panel [winfo parent $panel] 613 } 614 615 bind $widget <Enter> \ 616 [itcl::code $this _control hilite on $col $panel] 617 bind $widget <Leave> \ 618 [itcl::code $this _control hilite off $col $panel] 619 bind $widget <ButtonRelease> [itcl::code $this activate $col] 620 } 621 hilite { 622 if {[llength $args] != 3} { 623 error "wrong # args: should be _control hilite state column panel" 624 } 625 if {$_layout(mode) != "usual"} { 626 # abbreviated controls? then skip highlighting 627 return 628 } 629 set state [lindex $args 0] 630 set col [lindex $args 1] 631 set panel [lindex $args 2] 632 633 if {[string index $col 0] == "@"} { 634 # handle artificial names like "@more" 635 set id [string range $col 1 end] 636 } else { 637 # get id for ordinary columns 638 set id $_cntlInfo($this-$col-id) 639 } 640 641 # highlight any non-active entries 642 if {$col != $_active} { 643 if {$state} { 644 set fg $itk_option(-controlactiveforeground) 645 $panel.label$id.name configure -fg $fg 646 $panel.label$id.value configure -fg $fg 647 $panel.label$id.arrow configure -fg $fg \ 648 -bitmap [Rappture::icon rarrow2] 649 } else { 650 set fg $itk_option(-foreground) 651 $panel.label$id.name configure -fg $fg 652 $panel.label$id.value configure -fg $fg 653 $panel.label$id.arrow configure -fg $fg \ 654 -bitmap [Rappture::icon empty] 655 } 656 } 657 } 658 load { 659 if {[llength $args] != 2} { 660 error "wrong # args: should be _control load widget column" 661 } 662 set dial [lindex $args 0] 663 set col [lindex $args 1] 664 665 $dial clear 666 foreach {label val} [_getValues $col all] { 667 $dial add $label $val 668 } 669 } 670 default { 671 error "bad option \"$option\": should be bind, hilite, or load" 672 } 673 } 674 } 675 676 # ---------------------------------------------------------------------- 677 # USAGE: _fixControls ?<eventArgs...>? 678 # 679 # Called automatically at the idle point after one or more results 680 # have been added to this result set. Scans through all existing 681 # data and updates controls used to select the data. 682 # ---------------------------------------------------------------------- 683 itcl::body Rappture::ResultSet::_fixControls {args} { 684 if {[$_results size] == 0} { 685 return 686 } 687 688 set shortlist $itk_component(dials) 689 grid columnconfigure $shortlist 1 -weight 1 690 691 # 692 # Scan through all columns in the data and create any 693 # controls that just appeared. 694 # 695 $shortlist.dial configure -variable "" 696 697 set nadded 0 698 foreach col [$_results column names] { 699 set xmlobj [$_results get -format xmlobj 0] 700 701 # 702 # If this column doesn't have a control yet, then 703 # create one. 704 # 705 if {![info exists _cntlInfo($this-$col-id)]} { 706 set tip "" 707 if {$col eq "xmlobj"} { 708 continue 709 } elseif {$col eq "simnum"} { 710 set quantity "Simulation" 711 set tip "List of all simulations that you have performed so far." 712 } else { 713 # search for the first XML object with this element defined 714 foreach xmlobj [$_results get -format xmlobj] { 715 set quantity [$xmlobj get $col.about.label] 716 set tip [$xmlobj get $col.about.description] 717 if {"" != $quantity} { 718 break 719 } 720 } 721 if {"" == $quantity && "" != $xmlobj} { 722 set quantity [$xmlobj element -as id $col] 723 } 724 } 725 726 # Create the controls for the "short list" area. 727 set fn $itk_option(-textfont) 728 set w $shortlist.label$_counter 729 set row [lindex [grid size $shortlist] 1] 730 frame $w 731 grid $w -row $row -column 1 -sticky ew 732 label $w.arrow -bitmap [Rappture::icon empty] -borderwidth 0 733 pack $w.arrow -side left -fill y 734 _control bind $w.arrow $col 735 736 label $w.name -text $quantity -anchor w \ 737 -borderwidth 0 -padx 0 -pady 1 -font $fn 738 pack $w.name -side left 739 bind $w.name <Configure> [itcl::code $this _fixValue $col resize] 740 _control bind $w.name $col 741 742 label $w.value -anchor w \ 743 -borderwidth 0 -padx 0 -pady 1 -font $fn 744 pack $w.value -side left 745 bind $w.value <Configure> [itcl::code $this _fixValue $col resize] 746 _control bind $w.value $col 747 748 Rappture::Tooltip::for $w \ 749 "@[itcl::code $this _getTooltip label $col]" 750 751 # create a record for this control 752 lappend _cntlInfo($this-all) $col 753 set _cntlInfo($this-$col-id) $_counter 754 set _cntlInfo($this-$col-label) $quantity 755 set _cntlInfo($this-$col-tip) $tip 756 set _cntlInfo($this-$col-value) "" 757 set _cntlInfo($this-$col-usage) 0 758 set _cntlInfo($this-$col) "" 759 760 trace add variable _cntlInfo($this-$col-value) write \ 761 "[itcl::code $this _fixValue $col value]; list" 762 763 incr _counter 764 765 # fix the shortlist layout to show as many controls as we can 766 $_dispatcher event -now !layout why data 767 768 # let clients know that a new control appeared 769 # so they can fix the overall size accordingly 770 event generate $itk_component(hull) <<Control>> 771 772 incr nadded 773 } 774 775 # 776 # Determine the unique values for this column and load 777 # them into the control. 778 # 779 set id $_cntlInfo($this-$col-id) 780 781 if {$col == $_layout(active)} { 782 _control load $shortlist.dial $col 783 $shortlist.dial configure -variable \ 784 "::Rappture::ResultSet::_cntlInfo($this-$col-value)" 785 } 786 } 787 788 # 789 # Activate the most recent control. If a bunch of controls 790 # were just added, then activate the "Simulation" control, 791 # since that's the easiest way to page through results. 792 # 793 if {$nadded > 0} { 794 if {[$_results column names] == 3 || $nadded == 1} { 795 activate [lindex $_cntlInfo($this-all) end] 796 } else { 797 activate simnum 798 } 799 } 800 801 # 802 # Set all controls to the settings of the most recent addition. 803 # Setting the value slot will trigger the !settings event, which 804 # will then fix all other controls to match the one that changed. 805 # 806 set irun [lindex [$_results find -format xmlobj $_recent] 0] 807 if {$irun ne ""} { 808 set simnum [$_results get -format simnum $irun] 809 set _cntlInfo($this-simnum-value) $simnum 810 } 811 } 812 813 # ---------------------------------------------------------------------- 814 # USAGE: _fixLayout ?<eventArgs...>? 815 # 816 # Called automatically at the idle point after the controls have 817 # changed, or the size of the window has changed. Fixes the layout 818 # so that the active control is displayed, and other recent controls 819 # are shown above and/or below. At the very least, we must show the 820 # "more options..." control. 821 # ---------------------------------------------------------------------- 822 itcl::body Rappture::ResultSet::_fixLayout {args} { 823 array set eventdata $args 824 825 set shortlist $itk_component(dials) 826 827 # clear out the short list area 828 foreach w [grid slaves $shortlist] { 829 grid forget $w 830 } 831 832 # reset all labels back to an ordinary font/background 833 set fn $itk_option(-textfont) 834 set bg $itk_option(-background) 835 set fg $itk_option(-foreground) 836 foreach col $_cntlInfo($this-all) { 837 set id $_cntlInfo($this-$col-id) 838 $shortlist.label$id configure -background $bg 839 $shortlist.label$id.arrow configure -background $bg \ 840 -bitmap [Rappture::icon empty] 841 $shortlist.label$id.name configure -font $fn -background $bg 842 $shortlist.label$id.value configure -background $bg 843 } 844 845 # only 1 result? then we don't need any controls 846 if {[$_results size] < 2} { 847 return 848 } 849 850 # compute the number of controls that will fit in the shortlist area 851 set dials $itk_component(dials) 852 set h [winfo height $dials] 853 set normalLine [font metrics $itk_option(-textfont) -linespace] 854 set boldLine [font metrics $itk_option(-boldfont) -linespace] 855 set active [expr {$boldLine+[winfo reqheight $dials.dial]+4}] 856 857 if {$h < $active+$normalLine} { 858 # active control kinda big? then show parameter values only 859 set _layout(mode) abbreviated 860 set ncntls [expr {int(floor(double($h)/$normalLine))}] 861 } else { 862 set _layout(mode) usual 863 set ncntls [expr {int(floor(double($h-$active)/$normalLine))+1}] 864 } 865 866 # find the controls with the most usage 867 set order "" 868 foreach col $_cntlInfo($this-all) { 869 lappend order [list $col $_cntlInfo($this-$col-usage)] 870 } 871 set order [lsort -integer -decreasing -index 1 $order] 872 873 set mostUsed "" 874 if {[llength $order] <= $ncntls} { 875 # plenty of space? then show all controls 876 foreach item $order { 877 lappend mostUsed [lindex $item 0] 878 } 879 } else { 880 # otherwise, limit to the most-used controls 881 foreach item [lrange $order 0 [expr {$ncntls-1}]] { 882 lappend mostUsed [lindex $item 0] 883 } 884 885 # make sure the active control is included 886 if {"" != $_active && [lsearch -exact $mostUsed $_active] < 0} { 887 set mostUsed [lreplace [linsert $mostUsed 0 $_active] end end] 888 } 889 890 # if there are more controls, add the "more parameters..." entry 891 if {$ncntls > 2} { 892 set mostUsed [lreplace $mostUsed end end @more] 893 set rest [expr {[llength $order]-($ncntls-1)}] 894 if {$rest == 1} { 895 $dials.labelmore.name configure -text "1 more parameter..." 896 } else { 897 $dials.labelmore.name configure -text "$rest more parameters..." 898 } 899 } 900 } 901 902 # draw the active control 903 set row 0 904 foreach col [concat $_cntlInfo($this-all) @more] { 905 # this control not on the short list? then ignore it 906 if {[lsearch $mostUsed $col] < 0} { 907 continue 908 } 909 910 if {[string index $col 0] == "@"} { 911 set id [string range $col 1 end] 912 } else { 913 set id $_cntlInfo($this-$col-id) 914 } 915 grid $shortlist.label$id -row $row -column 1 -sticky ew -padx 4 916 917 if {$col == $_active} { 918 if {$_layout(mode) == "usual"} { 919 # put the background behind the active control in the shortlist 920 grid $shortlist.bg -row $row -rowspan 2 \ 921 -column 0 -columnspan 2 -sticky nsew 922 lower $shortlist.bg 923 924 # place the All and dial in the shortlist area 925 grid $shortlist.all -row $row -rowspan 2 -column 0 \ 926 -sticky nsew -padx 2 -pady 2 927 grid $shortlist.dial -row [expr {$row+1}] -column 1 \ 928 -sticky ew -padx 4 929 incr row 930 931 if {$_layout(active) != $_active} { 932 $shortlist.dial configure -variable "" 933 _control load $shortlist.dial $col 934 $shortlist.dial configure -variable \ 935 "::Rappture::ResultSet::_cntlInfo($this-$col-value)" 936 set _layout(active) $_active 937 } 938 } 939 } 940 incr row 941 } 942 943 # highlight the active control 944 if {[info exists _cntlInfo($this-$_active-id)]} { 945 set id $_cntlInfo($this-$_active-id) 946 set bf $itk_option(-boldfont) 947 set fg $itk_option(-activecontrolforeground) 948 set bg $itk_option(-activecontrolbackground) 949 950 if {$_layout(mode) == "usual"} { 951 $shortlist.label$id configure -background $bg 952 $shortlist.label$id.arrow configure -foreground $fg \ 953 -background $bg -bitmap [Rappture::icon rarrow] 954 $shortlist.label$id.name configure -foreground $fg \ 955 -background $bg -font $bf 956 $shortlist.label$id.value configure -foreground $fg \ 957 -background $bg 958 $shortlist.dial configure -background $bg 959 $shortlist.bg configure -background $bg 960 961 if {[$shortlist.all cget -relief] == "raised"} { 962 $shortlist.all configure -foreground $fg -background $bg 963 } 964 } 965 } 966 } 967 968 # ---------------------------------------------------------------------- 969 # USAGE: _fixNumResults 970 # 971 # Used internally to update the number of results displayed near the 972 # top of this widget. If there is only 1 result, then there is also 973 # a single "Clear" button. If there are no results, the clear button 974 # is diabled. 975 # ---------------------------------------------------------------------- 976 itcl::body Rappture::ResultSet::_fixNumResults {} { 977 switch [$_results size] { 978 0 { 979 $itk_component(status) configure -text "No results" 980 $itk_component(clearall) configure -state disabled -text "Clear" 981 pack forget $itk_component(clear) 982 } 983 1 { 984 $itk_component(status) configure -text "1 result" 985 $itk_component(clearall) configure -state normal -text "Clear" 986 pack forget $itk_component(clear) 987 } 988 default { 989 $itk_component(status) configure -text "[$_results size] results" 990 $itk_component(clearall) configure -state normal -text "Clear All" 991 $itk_component(clear) configure -state normal 992 pack $itk_component(clear) -side right \ 993 -after $itk_component(clearall) -padx {0 6} 994 } 995 } 996 } 997 998 # ---------------------------------------------------------------------- 999 # USAGE: _fixSettings ?<eventArgs...>? 1000 # 1001 # Called automatically at the idle point after a control has changed 1002 # to load new data into the plotting area at the top of this result 1003 # set. Extracts the current tuple of control values from the control 1004 # area, then finds the corresponding data values. Loads the data 1005 # by invoking a -settingscommand callback with parameters that 1006 # describe what data should be plotted. 1007 # ---------------------------------------------------------------------- 1008 itcl::body Rappture::ResultSet::_fixSettings {args} { 1009 array set eventdata $args 1010 if {[info exists eventdata(column)]} { 1011 set changed $eventdata(column) 1012 } else { 1013 set changed "" 1014 } 1015 1016 if {[info exists _cntlInfo($this-$_active-label)]} { 1017 lappend params $_cntlInfo($this-$_active-label) 1018 } else { 1019 lappend params "???" 1020 } 1021 if { $_active == "" } { 1022 return; # Nothing active. Don't do anything. 1023 } 1024 eval lappend params [_getValues $_active all] 1025 1026 switch -- [$_results size] { 1027 0 { 1028 # no data? then do nothing 1029 return 1030 } 1031 1 { 1032 # only one data set? then plot it 1033 set simnum [$_results get -format simnum 0] 1034 _doSettings [list \ 1035 $simnum [list -width 2 \ 1036 -param [_getValues $_active current] \ 1037 -description [_getParamDesc all] \ 1038 ] \ 1039 params $params \ 1040 ] 1041 return 1042 } 1043 } 1044 1045 # 1046 # Find the selected run. If the run setting changed, then 1047 # look at its current value. Otherwise, search the results 1048 # for a tuple that matches the current settings. 1049 # 1050 if {$changed == "xmlobj" || $changed == "simnum"} { 1051 set irun [$_results find -format simnum $_cntlInfo($this-simnum-value)] 1052 } else { 1053 set format "" 1054 set tuple "" 1055 foreach col [lrange [$_results column names] 2 end] { 1056 lappend format $col 1057 lappend tuple $_cntlInfo($this-$col-value) 1058 } 1059 set irun [lindex [$_results find -format $format -- $tuple] 0] 1060 1061 if {"" == $irun && "" != $changed} { 1062 # 1063 # No data for these settings. Try leaving the next 1064 # column open, then the next, and so forth, until 1065 # we find some data. 1066 # 1067 # allcols: foo bar baz qux 1068 # ^^^changed 1069 # 1070 # search: baz qux foo 1071 # 1072 set val $_cntlInfo($this-$changed-value) 1073 set allcols [lrange [$_results column names] 2 end] 1074 set i [lsearch -exact $allcols $changed] 1075 set search [concat \ 1076 [lrange $allcols [expr {$i+1}] end] \ 1077 [lrange $allcols 0 [expr {$i-1}]] \ 1078 ] 1079 set nsearch [llength $search] 1080 1081 for {set i 0} {$i < $nsearch} {incr i} { 1082 set format $changed 1083 set tuple [list $val] 1084 for {set j [expr {$i+1}]} {$j < $nsearch} {incr j} { 1085 set col [lindex $search $j] 1086 lappend format $col 1087 lappend tuple $_cntlInfo($this-$col-value) 1088 } 1089 set irun [lindex [$_results find -format $format -- $tuple] 0] 1090 if {"" != $irun} { 1091 break 1092 } 1093 } 1094 } 1095 } 1096 1097 # 1098 # If we found a particular run, then load its values into all 1099 # controls. 1100 # 1101 if {"" != $irun} { 1102 # stop reacting to value changes 1103 set _settings 1 1104 1105 set format [lrange [$_results column names] 2 end] 1106 if {[llength $format] == 1} { 1107 set data [$_results get -format $format $irun] 1108 } else { 1109 set data [lindex [$_results get -format $format $irun] 0] 1110 } 1111 1112 foreach col $format val $data { 1113 set _cntlInfo($this-$col-value) $val 1114 } 1115 set simnum [$_results get -format simnum $irun] 1116 set _cntlInfo($this-simnum-value) $simnum 1117 1118 # okay, react to value changes again 1119 set _settings 0 1120 } 1121 1122 # 1123 # Search for tuples matching the current setting and 1124 # plot them. 1125 # 1126 if {$_plotall && $_active == "simnum"} { 1127 set format "" 1128 } else { 1129 set format "" 1130 set tuple "" 1131 foreach col [lrange [$_results column names] 2 end] { 1132 if {!$_plotall || $col != $_active} { 1133 lappend format $col 1134 lappend tuple $_cntlInfo($this-$col-value) 1135 } 1136 } 1137 } 1138 1139 if {"" != $format} { 1140 set ilist [$_results find -format $format -- $tuple] 1141 } else { 1142 set ilist [$_results find] 1143 } 1144 1145 if {[llength $ilist] > 0} { 1146 # search for the result for these settings 1147 set format "" 1148 set tuple "" 1149 foreach col [lrange [$_results column names] 2 end] { 1150 lappend format $col 1151 lappend tuple $_cntlInfo($this-$col-value) 1152 } 1153 set icurr [$_results find -format $format -- $tuple] 1154 1155 if {[llength $ilist] == 1} { 1156 # single result -- always use active color 1157 set i [lindex $ilist 0] 1158 set simnum [$_results get -format simnum $i] 1159 set plist [list \ 1160 $simnum [list -width 2 \ 1161 -param [_getValues $_active $i] \ 1162 -description [_getParamDesc all $i] \ 1163 ] \ 1164 params $params \ 1165 ] 1166 } else { 1167 # 1168 # Get the color for all points according to 1169 # the color spectrum. 1170 # 1171 set plist [list params $params] 1172 foreach i $ilist { 1173 set simnum [$_results get -format simnum $i] 1174 if {$i == $icurr} { 1175 lappend plist $simnum [list -width 3 -raise 1 \ 1176 -param [_getValues $_active $i] \ 1177 -description [_getParamDesc all $i]] 1178 } else { 1179 lappend plist $simnum [list -brightness 0.7 -width 1 \ 1180 -param [_getValues $_active $i] \ 1181 -description [_getParamDesc all $i]] 1182 } 1183 } 1184 } 1185 1186 # 1187 # Load up the matching plots 1188 # 1189 _doSettings $plist 1190 } 1191 } 1192 1193 # ---------------------------------------------------------------------- 1194 # USAGE: _fixValue <columnName> <why> 1195 # 1196 # Called automatically whenver a value for a parameter dial changes. 1197 # Updates the interface to display the new value. The <why> is a 1198 # reason for the change, which may be "resize" (draw old value in 1199 # new size) or "value" (value changed). 1200 # ---------------------------------------------------------------------- 1201 itcl::body Rappture::ResultSet::_fixValue {col why} { 1202 if {[info exists _cntlInfo($this-$col-id)]} { 1203 set id $_cntlInfo($this-$col-id) 1204 1205 set widget $itk_component(dials).label$id 1206 set wmax [winfo width $itk_component(dials).dial] 1207 if {$wmax <= 1} { 1208 set wmax [expr {round(0.9*[winfo width $itk_component(cntls)])}] 1209 } 1210 _drawValue $col $widget $wmax 1211 1212 if {$why == "value" && !$_settings} { 1213 # keep track of usage, so we know which controls are popular 1214 incr _cntlInfo($this-$col-usage) 1215 1216 # adjust the settings according to the value in the column 1217 $_dispatcher event -idle !settings column $col 1218 } 1219 } 1220 } 1221 1222 # ---------------------------------------------------------------------- 1223 # USAGE: _drawValue <columnName> <widget> <widthMax> 1224 # 1225 # Used internally to fix the rendering of a "quantity = value" display. 1226 # If the name/value in <widget> are smaller than <widthMax>, then the 1227 # full "quantity = value" string is displayed. Otherwise, an 1228 # abbreviated form is displayed. 1229 # ---------------------------------------------------------------------- 1230 itcl::body Rappture::ResultSet::_drawValue {col widget wmax} { 1231 set quantity $_cntlInfo($this-$col-label) 1232 regsub -all {\n} $quantity " " quantity ;# take out newlines 1233 1234 set newval $_cntlInfo($this-$col-value) 1235 regsub -all {\n} $newval " " newval ;# take out newlines 1236 1237 set lfont [$widget.name cget -font] 1238 set vfont [$widget.value cget -font] 1239 1240 set wn [font measure $lfont $quantity] 1241 set wv [font measure $lfont " = $newval"] 1242 set w [expr {$wn + $wv}] 1243 1244 if {$w <= $wmax} { 1245 # if the text fits, then shown "quantity = value" 1246 $widget.name configure -text $quantity 1247 $widget.value configure -text " = $newval" 1248 } else { 1249 # Otherwise, we'll have to appreviate. 1250 # If the value is really long, then just show a little bit 1251 # of it. Otherwise, show as much of the value as we can. 1252 if {[string length $newval] > 30} { 1253 set frac 0.8 1254 } else { 1255 set frac 0.2 1256 } 1257 set wNameSpace [expr {round($frac*$wmax)}] 1258 set wValueSpace [expr {$wmax-$wNameSpace}] 1259 1260 # fit as much of the "quantity" label in the space available 1261 if {$wn < $wNameSpace} { 1262 $widget.name configure -text $quantity 1263 set wValueSpace [expr {$wmax-$wn}] 1264 } else { 1265 set wDots [font measure $lfont "..."] 1266 set wchar [expr {double($wn)/[string length $quantity]}] 1267 while {1} { 1268 # figure out a good size for the abbreviated string 1269 set cmax [expr {round(($wNameSpace-$wDots)/$wchar)}] 1270 if {$cmax < 0} {set cmax 0} 1271 set str "[string range $quantity 0 $cmax]..." 1272 if {[font measure $lfont $str] <= $wNameSpace 1273 || $wDots >= $wNameSpace} { 1274 break 1275 } 1276 # we're measuring with average chars, so we may have 1277 # to shave a little off and do this again 1278 set wDots [expr {$wDots+2*$wchar}] 1279 } 1280 $widget.name configure -text $str 1281 set wValueSpace [expr {$wmax-[font measure $lfont $str]}] 1282 } 1283 1284 if {$wv < $wValueSpace} { 1285 $widget.value configure -text " = $newval" 1286 } else { 1287 set wDots [font measure $vfont "..."] 1288 set wEq [font measure $vfont " = "] 1289 set wchar [expr {double($wv)/[string length " = $newval"]}] 1290 while {1} { 1291 # figure out a good size for the abbreviated string 1292 set cmax [expr {round(($wValueSpace-$wDots-$wEq)/$wchar)}] 1293 if {$cmax < 0} {set cmax 0} 1294 set str " = [string range $newval 0 $cmax]..." 1295 if {[font measure $vfont $str] <= $wValueSpace 1296 || $wDots >= $wValueSpace} { 1297 break 1298 } 1299 # we're measuring with average chars, so we may have 1300 # to shave a little off and do this again 1301 set wDots [expr {$wDots+2*$wchar}] 1302 } 1303 $widget.value configure -text $str 1304 } 1305 } 1306 } 1307 1308 # ---------------------------------------------------------------------- 1309 # USAGE: _toggleAll ?<columnName>? 1310 # 1311 # Called automatically whenever the user clicks on an "All" button. 1312 # Toggles the button between its on/off states. In the "on" state, 1313 # all results associated with the current control are sent to the 1314 # result viewer. 1315 # ---------------------------------------------------------------------- 1316 itcl::body Rappture::ResultSet::_toggleAll {{col "current"}} { 1317 if {$col == "current"} { 1318 set col $_active 1319 } 1320 if {![info exists _cntlInfo($this-$col-id)]} { 1321 return 1322 } 1323 set id $_cntlInfo($this-$col-id) 1324 set sbutton $itk_component(dials).all 1325 set current [$sbutton cget -relief] 1326 1327 if {$current == "sunken"} { 1328 $sbutton configure -relief raised \ 1329 -background $itk_option(-activecontrolbackground) \ 1330 -foreground $itk_option(-activecontrolforeground) 1331 set _plotall 0 1332 } else { 1333 $sbutton configure -relief sunken \ 1334 -background $itk_option(-togglebackground) \ 1335 -foreground $itk_option(-toggleforeground) 1336 set _plotall 1 1337 1338 if {$col != $_active} { 1339 # clicked on an inactive "All" button? then activate that column 1340 activate $col 1341 } 1342 } 1343 $_dispatcher event -idle !settings 1344 } 1345 1346 # ---------------------------------------------------------------------- 1347 # USAGE: _getValues <column> ?<which>? 1348 # 1349 # Called automatically whenever the user hovers a control within 1350 # this widget. Returns the tooltip associated with the control. 1351 # ---------------------------------------------------------------------- 1352 itcl::body Rappture::ResultSet::_getValues {col {which ""}} { 1353 if {$col == "simnum"} { 1354 # load the Simulation # control 1355 set nruns [$_results size] 1356 for {set n 0} {$n < $nruns} {incr n} { 1357 set v [$_results get -format simnum $n] 1358 set label2val($v) $n 1359 } 1360 } else { 1361 set havenums 1 1362 set vlist "" 1363 foreach rec [$_results get -format [list xmlobj $col]] { 1364 set xo [lindex $rec 0] 1365 set v [lindex $rec 1] 1366 1367 if {![info exists label2val($v)]} { 1368 lappend vlist $v 1369 foreach {raw norm} [Rappture::LibraryObj::value $xo $col] break 1370 set label2val($v) $norm 1371 1372 if {$havenums && ![string is double $norm]} { 1373 set havenums 0 1374 } 1375 } 1376 } 1377 1378 if {!$havenums} { 1379 # don't have normalized nums? then sort and create nums 1380 catch {unset label2val} 1381 1382 set n 0 1383 foreach v [lsort $vlist] { 1384 incr n 1385 set label2val($v) $n 1386 } 1387 } 1388 } 1389 1390 switch -- $which { 1391 current { 1392 set curr $_cntlInfo($this-$col-value) 1393 if {[info exists label2val($curr)]} { 1394 return [list $curr $label2val($curr)] 1395 } 1396 return "" 1397 } 1398 all { 1399 return [array get label2val] 1400 } 1401 default { 1402 if {[string is integer $which]} { 1403 if {$col == "simnum"} { 1404 set val [$_results get -format simnum $which] 1405 } else { 1406 # Be careful giving singleton elements as the "columns" 1407 # argument to "Tuples::get". It is expecting a list. 1408 set val [lindex [$_results get -format [list $col] $which] 0] 1409 } 1410 if {[info exists label2val($val)]} { 1411 return [list $val $label2val($val)] 1412 } 1413 return "" 1414 } 1415 error "bad option \"$which\": should be all, current, or an integer index" 1416 } 1417 } 1418 } 1419 1420 # ---------------------------------------------------------------------- 1421 # USAGE: _getTooltip <role> <column> 1422 # 1423 # Called automatically whenever the user hovers a control within 1424 # this widget. Returns the tooltip associated with the control. 1425 # ---------------------------------------------------------------------- 1426 itcl::body Rappture::ResultSet::_getTooltip {role column} { 1427 set label "" 1428 set tip "" 1429 if {$column == "active"} { 1430 set column $_active 1431 } 1432 if {[info exists _cntlInfo($this-$column-label)]} { 1433 set label $_cntlInfo($this-$column-label) 1434 } 1435 if {[info exists _cntlInfo($this-$column-tip)]} { 1436 set tip $_cntlInfo($this-$column-tip) 1437 } 1438 1439 switch -- $role { 1440 label { 1441 if {$column != $_active} { 1442 append tip "\n\nClick to activate this control." 1443 } 1444 } 1445 dial { 1446 append tip "\n\nClick to change the value of this parameter." 1447 } 1448 all { 1449 if {$label == ""} { 1450 set tip "Plot all values for this quantity." 1451 } else { 1452 set tip "Plot all values for $label." 1453 } 1454 if {$_plotall} { 1455 set what "all values" 1456 } else { 1457 set what "one value" 1458 } 1459 append tip "\n\nCurrently, plotting $what. Click to toggle." 1460 } 1461 } 1462 return [string trim $tip] 1463 } 1464 1465 # ---------------------------------------------------------------------- 1466 # USAGE: _getParamDesc <which> ?<index>? 1467 # 1468 # Used internally to build a descripton of parameters for the data 1469 # tuple at the specified <index>. This is passed on to the underlying 1470 # results viewer, so it will know what data is being viewed. 1471 # ---------------------------------------------------------------------- 1472 itcl::body Rappture::ResultSet::_getParamDesc {which {index "current"}} { 1473 if {$index == "current"} { 1474 # search for the result for these settings 1475 set format "" 1476 set tuple "" 1477 foreach col [lrange [$_results column names] 2 end] { 1478 lappend format $col 1479 lappend tuple $_cntlInfo($this-$col-value) 1480 } 1481 set index [$_results find -format $format -- $tuple] 1482 if {"" == $index} { 1483 return "" ;# somethings wrong -- bail out! 1484 } 1485 } 1486 1487 switch -- $which { 1488 active { 1489 if {"" == $_active} { 1490 return "" 1491 } 1492 } 1493 all { 1494 set desc "" 1495 foreach col $_cntlInfo($this-all) { 1496 set quantity $_cntlInfo($this-$col-label) 1497 # Be careful giving singleton elements as the "columns" 1498 # argument to "Tuples::get". It is expecting a list. 1499 set val [lindex [$_results get -format [list $col] $index] 0] 1500 if {$col == "simnum"} { 1501 set irun [lindex [$_results find -format xmlobj $val] 0] 1502 set val [$_results get -format simnum $irun] 1503 } 1504 append desc "$quantity = $val\n" 1505 } 1506 return [string trim $desc] 1507 } 1508 default { 1509 error "bad value \"$which\": should be active or all" 467 error "wrong # args: should be add, get, remove" 468 } 469 } 470 } 471 472 # ---------------------------------------------------------------------- 473 # USAGE: _notifyHandler ?<eventArgs>...? 474 # 475 # Called automatically whenever a !change event is triggered in this 476 # object. Scans through the list of clients that want to receive this 477 # event and executes each of their callbacks. 478 # ---------------------------------------------------------------------- 479 itcl::body Rappture::ResultSet::_notifyHandler {args} { 480 array set data $args 481 set event $data(event) 482 483 foreach caller $_notify(ALL) { 484 if {[info exists _notify($caller-$event)]} { 485 if {[catch {uplevel #0 $_notify($caller-$event) $args} result]} { 486 # anything go wrong? then throw a background error 487 bgerror "$result\n(while dispatching $event to $caller)" 488 } 1510 489 } 1511 490 } … … 1575 554 1576 555 # overwrite the first matching entry 556 # start by freeing the old result 1577 557 set index [lindex $ilist 0] 558 set xo [$tuples get -format xmlobj $index] 559 itcl::delete object $xo 560 561 # put this new result in its place 1578 562 $tuples put -format $cols $index $tuple 563 set simnum [$tuples get -format simnum $index] 1579 564 } else { 1580 565 if {$simnum eq ""} { … … 1586 571 return $simnum 1587 572 } 1588 1589 # ----------------------------------------------------------------------1590 # OPTION: -activecontrolbackground1591 # ----------------------------------------------------------------------1592 itcl::configbody Rappture::ResultSet::activecontrolbackground {1593 $_dispatcher event -idle !layout1594 }1595 1596 # ----------------------------------------------------------------------1597 # OPTION: -activecontrolforeground1598 # ----------------------------------------------------------------------1599 itcl::configbody Rappture::ResultSet::activecontrolforeground {1600 $_dispatcher event -idle !layout1601 }1602 -
branches/nanovis2/gui/scripts/sequenceresult.tcl
r2939 r3175 444 444 } 445 445 switch -- $type { 446 ::Rappture::Drawing { 447 Rappture::VtkViewer $viewer 448 pack $viewer -expand yes -fill both 449 } 446 450 ::Rappture::Curve { 447 451 Rappture::XyResult $viewer 452 pack $viewer -expand yes -fill both 453 } 454 ::Rappture::Histogram { 455 Rappture::HistogramResult $viewer 448 456 pack $viewer -expand yes -fill both 449 457 } … … 476 484 switch -- $dimensions { 477 485 2D { 486 global env 478 487 if { [$dataobj isunirect2d] } { 479 global env480 488 if { [$dataobj hints type] == "contour" } { 481 489 set mode "vtkcontour" … … 485 493 set mode "heightmap" 486 494 } 495 } elseif { [info exists env(VTKCONTOUR)] } { 496 set mode "vtkcontour" 487 497 } else { 488 498 set mode "vtk" 499 } 500 set extents [$dataobj extents] 501 if { $extents > 1 } { 502 set mode "flowvis" 489 503 } 490 504 Rappture::Field2DResult $viewer -mode $mode … … 508 522 } 509 523 } 524 "vtkvolume" { 525 set fmt "vtkvolume" 526 } 527 "vtkstreamlines" { 528 set fmt "vtkstreamlines" 529 } 510 530 "" { 511 531 set fmt "auto" -
branches/nanovis2/gui/scripts/sidebarframe.tcl
r2744 r3175 38 38 itk_option define -sashcursor sashCursor Cursor "" 39 39 40 public variable resizeframe 1 40 41 constructor {args} { # defined below } 41 42 … … 569 570 set x1 [expr {$w - $sbarw - $sashw}] 570 571 set x2 [expr {$w - $sbarw}] 571 place $itk_component(frame) -x 0 -y 0 -anchor nw -width $x1 -height $h 572 if { $resizeframe } { 573 set framew $x1 574 } else { 575 set framew [expr $w - $ctrlw] 576 } 577 place $itk_component(frame) -x 0 -y 0 -anchor nw -width $framew -height $h 572 578 place $itk_component(sashbg) -x $x1 -y 0 -anchor nw -width $sashw -height $h 573 579 place $itk_component(sidebar) -x $x2 -y 0 -anchor nw -width $sbarw -height $h -
branches/nanovis2/gui/scripts/textentry.tcl
r2744 r3175 37 37 itk_option define -height height Height 0 38 38 39 constructor {owner path args} { # defined below } 39 constructor {owner path args} { 40 # defined below 41 } 40 42 41 43 public method value {args} … … 254 256 -foreground $itk_option(-textforeground) 255 257 256 bind $itk_component(entry) <KeyPress> \ 258 # Make sure these event bindings occur after the class bindings. 259 # Otherwise you'll always get the entry value before the edit. 260 bind textentry <KeyPress> \ 257 261 [itcl::code $this _newValue] 258 bind $itk_component(entry)<Control-KeyPress-a> \262 bind textentry <Control-KeyPress-a> \ 259 263 "[list $itk_component(entry) selection range 0 end]; break" 264 set bindtags [bindtags $itk_component(entry)] 265 lappend bindtags textentry 266 bindtags $itk_component(entry) $bindtags 260 267 261 268 itk_component add emenu { … … 309 316 $itk_component(scrollbars) contents $itk_component(text) 310 317 311 bind $itk_component(text) <KeyPress> \ 318 # Make sure these event bindings occur after the class bindings. 319 # Otherwise you'll always get the text value before the edit. 320 bind textentry <KeyPress> \ 312 321 [itcl::code $this _newValue] 313 bind $itk_component(text)<Control-KeyPress-a> \322 bind textentry <Control-KeyPress-a> \ 314 323 "[list $itk_component(text) tag add sel 1.0 end]; break" 324 set bindtags [bindtags $itk_component(text)] 325 lappend bindtags textentry 326 bindtags $itk_component(text) $bindtags 315 327 316 328 itk_component add tmenu { -
branches/nanovis2/gui/scripts/tool.tcl
r2977 r3175 212 212 213 213 if { $status != 0 } { 214 # We're here because the exec-ed program failed 214 215 if { $::Rappture::Tool::job(control) != "" } { 215 set code [lindex $::Rappture::Tool::job(control) 0] 216 set mesg [lindex $::Rappture::Tool::job(control) 2] 217 if { $code == "EXITED" } { 218 set result "Program returned exit code $status:\n\n" 216 foreach { token pid code mesg } \ 217 $::Rappture::Tool::job(control) break 218 if { $token == "EXITED" } { 219 # This means that the program exited normally but 220 # returned a non-zero exitcode. Consider this an 221 # invalid result from the program. Append the stderr 222 # from the program to the message. 223 set result \ 224 "Program finished: exit code is $code\n\n" 219 225 append result $::Rappture::Tool::job(error) 220 } else { 221 set result \ 222 "Abnormal program termination \"$code\": $mesg" 226 } elseif { $token == "abort" } { 227 # The user pressed the abort button. 228 set result "Program terminated by user.\n\n" 229 append result $::Rappture::Tool::job(output) 230 } else { 231 # Abnormal termination 232 set result "Abnormal program termination: $mesg\n\n" 233 append result $::Rappture::Tool::job(output) 223 234 } 224 235 } -
branches/nanovis2/gui/scripts/unirect2d.tcl
r2830 r3175 52 52 } 53 53 set path [$field get $cname.mesh] 54 54 55 set m [$xmlobj element -as object $path] 55 56 GetValue $m "xaxis.min" _xMin … … 101 102 set n [expr $_xNum * $_yNum * $_compNum] 102 103 if { [$_values length] != $n } { 103 error "wrong \# of values in \"$cname.values\": expected $n values "104 error "wrong \# of values in \"$cname.values\": expected $n values, got [$_values length]" 104 105 } 105 106 } -
branches/nanovis2/gui/scripts/unirect3d.tcl
r2830 r3175 105 105 set n [expr $_xNum * $_yNum * $_zNum * $_compNum] 106 106 if { [$_values length] != $n } { 107 error "wrong \# of values in \"$cname.values\": expected $n values "107 error "wrong \# of values in \"$cname.values\": expected $n values, got [$_values length]" 108 108 } 109 109 } -
branches/nanovis2/gui/scripts/visviewer.tcl
r2977 r3175 152 152 153 153 itk_component add main { 154 Rappture::SidebarFrame $itk_interior.main 154 Rappture::SidebarFrame $itk_interior.main -resizeframe 0 155 155 } 156 156 pack $itk_component(main) -expand yes -fill both … … 168 168 if { [info exists env(VISRECORDER)] } { 169 169 set _logging 1 170 if { [file exists /tmp/recording.log] } { 171 file delete /tmp/recording.log 172 } 170 173 } 171 174 eval itk_initialize $args -
branches/nanovis2/gui/scripts/vtkheightmapviewer.tcl
r2792 r3175 1 2 1 # ---------------------------------------------------------------------- 3 2 # COMPONENT: vtkheightmapviewer - Vtk heightmap viewer -
branches/nanovis2/gui/scripts/vtkviewer.tcl
r2848 r3175 84 84 private method BuildAxisTab {} 85 85 private method BuildCameraTab {} 86 private method BuildColormap { colormap dataobj comp}86 private method BuildColormap { name styles } 87 87 private method BuildCutawayTab {} 88 88 private method BuildDownloadPopup { widget command } 89 private method BuildVolumeTab {} 89 private method BuildMeshTab {} 90 private method BuildMoleculeTab {} 90 91 private method ConvertToVtkData { dataobj comp } 91 92 private method DrawLegend {} … … 101 102 private method RequestLegend {} 102 103 private method SetColormap { dataobj comp } 104 private method ChangeColormap { dataobj comp color } 105 private method ColorsToColormap { color } 103 106 private method SetLegendTip { x y } 104 107 private method SetObjectStyle { dataobj comp } … … 106 109 107 110 private variable _arcball "" 108 private variable _outbuf ;# buffer for outgoing commands109 110 private variable _dlist "" ;# list of data objects111 private variable _outbuf; # buffer for outgoing commands 112 113 private variable _dlist ""; # list of data objects 111 114 private variable _allDataObjs 112 115 private variable _obj2datasets 113 private variable _obj2ovride ;# maps dataobj => style override 114 private variable _datasets ;# contains all the dataobj-component 115 ;# datasets in the server 116 private variable _colormaps ;# contains all the colormaps 117 ;# in the server. 118 private variable _dataset2style ;# maps dataobj-component to transfunc 119 private variable _style2datasets ;# maps tf back to list of 120 # dataobj-components using the tf. 121 122 private variable _click ;# info used for rotate operations 123 private variable _limits ;# autoscale min/max for all axes 124 private variable _view ;# view params for 3D view 116 private variable _obj2ovride; # maps dataobj => style override 117 private variable _datasets; # contains all the dataobj-component 118 # datasets in the server 119 private variable _colormaps; # contains all the colormaps 120 # in the server. 121 private variable _dataset2style; # maps dataobj-component to transfunc 122 private variable _style2datasets; # maps tf back to list of 123 # dataobj-components using the tf. 124 private variable _click ; # info used for rotate operations 125 private variable _limits ; # autoscale min/max for all axes 126 private variable _view ; # view params for 3D view 125 127 private variable _settings 126 private variable _volume 128 private variable _style; # Array of current component styles. 129 private variable _initialStyle; # Array of initial component styles. 127 130 private variable _axis 128 131 private variable _reset 1 ;# indicates if camera needs to be reset 129 132 # to starting position. 130 private variable _haveSpheres 0 133 private variable _haveGlyphs 0 134 private variable _haveMolecules 0 131 135 132 136 private variable _first "" ;# This is the topmost dataset. … … 141 145 private variable _resizePending 0 142 146 private variable _rotatePending 0 147 private variable _updatePending 0; 143 148 private variable _outline 144 149 } … … 163 168 $_dispatcher register !resize 164 169 $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list" 170 171 # Update state event 172 $_dispatcher register !update 173 $_dispatcher dispatch $this !update "[itcl::code $this DoUpdate]; list" 165 174 166 175 # Rotate event … … 187 196 # Initialize the view to some default parameters. 188 197 array set _view { 189 qw 1190 qx 0191 qy 0 192 qz 0 198 qw 0.853553 199 qx -0.353553 200 qy 0.353553 201 qz 0.146447 193 202 zoom 1.0 194 203 xpan 0 … … 219 228 labels 1 220 229 }] 221 array set _volume [subst {222 edges 1223 lighting 1224 opacity 40225 visible 1226 wireframe 0227 }]228 230 array set _settings [subst { 229 231 legend 1 232 molecule-representation "Ball and Stick" 233 molecule-edges 0 234 molecule-labels 0 235 molecule-lighting 1 236 molecule-opacity 100 237 molecule-visible 1 238 molecule-wireframe 0 239 molecule-palette elementDefault 240 mesh-edges 0 241 mesh-lighting 1 242 mesh-opacity 40 243 mesh-visible 1 244 mesh-wireframe 0 245 mesh-palette rainbow 230 246 }] 231 247 … … 268 284 } 269 285 pack $itk_component(reset) -side top -padx 2 -pady 2 270 Rappture::Tooltip::for $itk_component(reset) "Reset the view to the default zoom level" 286 Rappture::Tooltip::for $itk_component(reset) \ 287 "Reset the view to the default zoom level" 271 288 272 289 itk_component add zoomin { … … 294 311 Rappture::Tooltip::for $itk_component(zoomout) "Zoom out" 295 312 296 if { [catch { 297 BuildVolumeTab 313 puts stderr "BuildMeshTab" 314 if { [catch { BuildMeshTab } errs ] != 0 } { 315 puts stderr "errs=$errs" 316 } 317 puts stderr "BuildMoleculeTab" 318 if { [catch { BuildMoleculeTab } errs ] != 0 } { 319 global errorInfo 320 puts stderr "errs=$errs\nerrorInfo=$errorInfo" 321 } 298 322 BuildAxisTab 299 BuildCutawayTab323 #BuildCutawayTab 300 324 BuildCameraTab 301 } errs] != 0 } { 302 puts stderr errs=$errs 303 } 325 304 326 # Legend 305 327 … … 405 427 set _height 500 406 428 } 407 #puts stderr "DoResize screen size $_width $_height"408 429 set _start [clock clicks -milliseconds] 409 #puts stderr "screen size request width=$_width height=$_height"410 430 SendCmd "screen size $_width $_height" 411 431 #SendCmd "imgflush" … … 424 444 425 445 itcl::body Rappture::VtkViewer::EventuallyResize { w h } { 426 #puts stderr "EventuallyResize $w $h"427 446 set _width $w 428 447 set _height $h … … 437 456 438 457 itcl::body Rappture::VtkViewer::EventuallyRotate { q } { 439 #puts stderr "EventuallyRotate $w $h"440 458 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break 441 459 if { !$_rotatePending } { … … 695 713 # ---------------------------------------------------------------------- 696 714 itcl::body Rappture::VtkViewer::Connect {} { 697 #puts stderr "Enter Connect: [info level -1]"698 715 set _hosts [GetServerList "vtkvis"] 699 716 if { "" == $_hosts } { … … 702 719 set result [VisViewer::Connect $_hosts] 703 720 if { $result } { 704 #puts stderr "Connected to $_hostname sid=$_sid"705 721 set w [winfo width $itk_component(view)] 706 722 set h [winfo height $itk_component(view)] … … 789 805 set time [clock seconds] 790 806 set date [clock format $time] 791 #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"792 807 if { $_start > 0 } { 793 808 set finish [clock clicks -milliseconds] 794 #puts stderr "round trip time [expr $finish -$_start] milliseconds"795 809 set _start 0 796 810 } … … 878 892 SendCmd "camera mode persp" 879 893 } 894 880 895 DoRotate 881 896 PanCamera … … 887 902 FixSettings axis-xgrid axis-ygrid axis-zgrid axis-mode \ 888 903 axis-visible axis-labels \ 889 volume-edges volume-lighting volume-opacity volume-visible \890 volume-wireframe904 mesh-edges mesh-lighting mesh-opacity mesh-visible \ 905 mesh-wireframe 891 906 892 907 #SendCmd "imgflush" … … 904 919 if { ![info exists _datasets($tag)] } { 905 920 set bytes [$dataobj data $comp] 921 if { $bytes == "" } { 922 continue 923 } 906 924 set length [string length $bytes] 907 925 append _outbuf "dataset add $tag data follows $length\n" 908 926 append _outbuf $bytes 909 if { [$dataobj type $comp] != "spheres" } {910 }911 927 set _datasets($tag) 1 912 928 } … … 937 953 } 938 954 } 955 FixSettings molecule-representation 956 957 SendCmd "dataset maprange visible" 939 958 940 959 set _buffering 0; # Turn off buffering. … … 1013 1032 "reset" { 1014 1033 array set _view { 1015 qw 11016 qx 01017 qy 0 1018 qz 0 1034 qw 0.853553 1035 qx -0.353553 1036 qy 0.353553 1037 qz 0.146447 1019 1038 zoom 1.0 1020 1039 xpan 0 … … 1177 1196 } 1178 1197 switch -- $what { 1179 " volume-opacity" {1180 set val $_ volume(opacity)1198 "mesh-opacity" { 1199 set val $_settings(mesh-opacity) 1181 1200 set sval [expr { 0.01 * double($val) }] 1182 1201 foreach dataset [CurrentDatasets -visible $_first] { 1183 SendCmd "polydata opacity $sval $dataset" 1184 } 1185 } 1186 "volume-wireframe" { 1187 set bool $_volume(wireframe) 1202 foreach { dataobj comp } [split $dataset -] break 1203 set type [$dataobj type $comp] 1204 if { $type == "polydata" } { 1205 SendCmd "$type opacity $sval $dataset" 1206 } 1207 } 1208 } 1209 "mesh-wireframe" { 1210 set bool $_settings(mesh-wireframe) 1188 1211 foreach dataset [CurrentDatasets -visible $_first] { 1189 SendCmd "polydata wireframe $bool $dataset" 1190 } 1191 } 1192 "volume-visible" { 1193 set bool $_volume(visible) 1212 foreach { dataobj comp } [split $dataset -] break 1213 set type [$dataobj type $comp] 1214 if { $type == "polydata" } { 1215 SendCmd "$type wireframe $bool $dataset" 1216 } 1217 } 1218 } 1219 "mesh-visible" { 1220 set bool $_settings(mesh-visible) 1194 1221 foreach dataset [CurrentDatasets -visible $_first] { 1195 SendCmd "polydata visible $bool $dataset" 1196 } 1197 } 1198 "volume-lighting" { 1199 set bool $_volume(lighting) 1222 foreach { dataobj comp } [split $dataset -] break 1223 set type [$dataobj type $comp] 1224 if { $type == "polydata" } { 1225 SendCmd "$type visible $bool $dataset" 1226 } 1227 } 1228 } 1229 "mesh-lighting" { 1230 set bool $_settings(mesh-lighting) 1200 1231 foreach dataset [CurrentDatasets -visible $_first] { 1201 SendCmd "polydata lighting $bool $dataset" 1202 } 1203 } 1204 "volume-edges" { 1205 set bool $_volume(edges) 1232 foreach { dataobj comp } [split $dataset -] break 1233 set type [$dataobj type $comp] 1234 if { $type == "polydata" } { 1235 SendCmd "$type lighting $bool $dataset" 1236 } 1237 } 1238 } 1239 "mesh-edges" { 1240 set bool $_settings(mesh-edges) 1206 1241 foreach dataset [CurrentDatasets -visible $_first] { 1207 SendCmd "polydata edges $bool $dataset" 1242 foreach { dataobj comp } [split $dataset -] break 1243 set type [$dataobj type $comp] 1244 if { $type == "polydata" } { 1245 SendCmd "$type edges $bool $dataset" 1246 } 1247 } 1248 } 1249 "mesh-palette" { 1250 set palette [$itk_component(meshpalette) value] 1251 set _settings(mesh-palette) $palette 1252 foreach dataset [CurrentDatasets -visible $_first] { 1253 foreach {dataobj comp} [split $dataset -] break 1254 set type [$dataobj type $comp] 1255 if { $type == "polydata" } { 1256 ChangeColormap $dataobj $comp $palette 1257 } 1258 } 1259 set _legendPending 1 1260 } 1261 "molecule-opacity" { 1262 set val $_settings(molecule-opacity) 1263 set sval [expr { 0.01 * double($val) }] 1264 foreach dataset [CurrentDatasets -visible $_first] { 1265 foreach { dataobj comp } [split $dataset -] break 1266 set type [$dataobj type $comp] 1267 if { $type == "molecule" } { 1268 SendCmd "molecule opacity $sval $dataset" 1269 } 1270 } 1271 } 1272 "molecule-wireframe" { 1273 set bool $_settings(molecule-wireframe) 1274 foreach dataset [CurrentDatasets -visible $_first] { 1275 foreach { dataobj comp } [split $dataset -] break 1276 set type [$dataobj type $comp] 1277 if { $type == "molecule" } { 1278 SendCmd "molecule wireframe $bool $dataset" 1279 } 1280 } 1281 } 1282 "molecule-visible" { 1283 set bool $_settings(molecule-visible) 1284 foreach dataset [CurrentDatasets -visible $_first] { 1285 foreach { dataobj comp } [split $dataset -] break 1286 set type [$dataobj type $comp] 1287 if { $type == "molecule" } { 1288 SendCmd "molecule visible $bool $dataset" 1289 } 1290 } 1291 } 1292 "molecule-lighting" { 1293 set bool $_settings(molecule-lighting) 1294 foreach dataset [CurrentDatasets -visible $_first] { 1295 foreach { dataobj comp } [split $dataset -] break 1296 set type [$dataobj type $comp] 1297 if { $type == "molecule" } { 1298 SendCmd "molecule lighting $bool $dataset" 1299 } 1300 } 1301 } 1302 "molecule-edges" { 1303 set bool $_settings(molecule-edges) 1304 foreach dataset [CurrentDatasets -visible $_first] { 1305 foreach { dataobj comp } [split $dataset -] break 1306 set type [$dataobj type $comp] 1307 if { $type == "molecule" } { 1308 SendCmd "molecule edges $bool $dataset" 1309 } 1310 } 1311 } 1312 "molecule-palette" { 1313 set palette [$itk_component(moleculepalette) value] 1314 set _settings(molecule-palette) $palette 1315 foreach dataset [CurrentDatasets -visible $_first] { 1316 foreach {dataobj comp} [split $dataset -] break 1317 set type [$dataobj type $comp] 1318 if { $type == "molecule" } { 1319 ChangeColormap $dataobj $comp $palette 1320 if { $palette == "elementDefault" } { 1321 SendCmd "molecule colormode by_elements element $dataset" 1322 } else { 1323 # FIXME: Set the chosen scalar field name here 1324 SendCmd "molecule colormode scalar {} $dataset" 1325 } 1326 } 1327 } 1328 set _legendPending 1 1329 } 1330 "molecule-representation" { 1331 set value [$itk_component(representation) value] 1332 set value [$itk_component(representation) translate $value] 1333 switch -- $value { 1334 "ballandstick" { 1335 set rscale covalent 1336 set ashow 1 1337 set bshow 1 1338 set bstyle cylinder 1339 set ascale 0.3 1340 set bscale 0.075 1341 } 1342 "balls" - "spheres" { 1343 set rscale covalent 1344 set ashow 1 1345 set bshow 0 1346 set bstyle cylinder 1347 set ascale 0.3 1348 set bscale 0.075 1349 } 1350 "sticks" { 1351 set rscale none 1352 set ashow 1 1353 set bshow 1 1354 set bstyle cylinder 1355 set ascale 0.075 1356 set bscale 0.075 1357 } 1358 "spacefilling" { 1359 set rscale van_der_waals 1360 set ashow 1 1361 set bshow 0 1362 set bstyle cylinder 1363 set ascale 1.0 1364 set bscale 0.075 1365 } 1366 "rods" { 1367 set rscale none 1368 set ashow 1 1369 set bshow 1 1370 set bstyle cylinder 1371 set ascale 0.1 1372 set bscale 0.1 1373 } 1374 "wireframe" - "lines" { 1375 set rscale none 1376 set ashow 0 1377 set bshow 1 1378 set bstyle line 1379 set ascale 1.0 1380 set bscale 1.0 1381 } 1382 default { 1383 error "unknown representation $value" 1384 } 1385 } 1386 foreach dataset [CurrentDatasets -visible $_first] { 1387 foreach {dataobj comp} [split $dataset -] break 1388 set type [$dataobj type $comp] 1389 if { $type == "molecule" } { 1390 SendCmd [subst {molecule rscale $rscale $dataset 1391 molecule atoms $ashow $dataset 1392 molecule bonds $bshow $dataset 1393 molecule bstyle $bstyle $dataset 1394 molecule ascale $ascale $dataset 1395 molecule bscale $bscale $dataset}] 1396 } 1397 } 1398 } 1399 "molecule-labels" { 1400 set bool $_settings(molecule-labels) 1401 foreach dataset [CurrentDatasets -visible $_first] { 1402 foreach { dataobj comp } [split $dataset -] break 1403 set type [$dataobj type $comp] 1404 if { $type == "molecule" } { 1405 SendCmd "molecule labels $bool $dataset" 1406 } 1208 1407 } 1209 1408 } … … 1269 1468 # 1270 1469 itcl::body Rappture::VtkViewer::RequestLegend {} { 1271 #puts stderr "RequestLegend _first=$_first"1272 #puts stderr "RequestLegend width=$_width height=$_height"1273 1470 set font "Arial 8" 1274 1471 set lineht [font metrics $font -linespace] … … 1283 1480 foreach {dataobj comp} [split $dataset -] break 1284 1481 if { [info exists _dataset2style($dataset)] } { 1285 #puts stderr "RequestLegend w=$w h=$h"1286 1482 SendCmd "legend $_dataset2style($dataset) vmag {} {} $w $h 0" 1287 1483 break; … … 1291 1487 1292 1488 # 1489 # ChangeColormap -- 1490 # 1491 itcl::body Rappture::VtkViewer::ChangeColormap {dataobj comp color} { 1492 set tag $dataobj-$comp 1493 if { ![info exist _style($tag)] } { 1494 error "no initial colormap" 1495 } 1496 array set style $_style($tag) 1497 set style(-color) $color 1498 set _style($tag) [array get style] 1499 SetColormap $dataobj $comp 1500 } 1501 1502 # 1293 1503 # SetColormap -- 1294 1504 # 1295 1505 itcl::body Rappture::VtkViewer::SetColormap { dataobj comp } { 1296 1506 array set style { 1297 -color rainbow1507 -color BCGYR 1298 1508 -levels 6 1299 1509 -opacity 1.0 1300 1510 } 1511 if {[$dataobj type $comp] == "molecule"} { 1512 set style(-color) elementDefault 1513 } 1301 1514 set tag $dataobj-$comp 1302 array set style [$dataobj style $comp] 1303 set colormap "$style(-color):$style(-levels):$style(-opacity)" 1304 if { [info exists _colormaps($colormap)] } { 1305 puts stderr "Colormap $colormap already built" 1306 return $colormap 1307 } 1308 if { ![info exists _dataset2style($tag)] } { 1309 set _dataset2style($tag) $colormap 1310 lappend _style2datasets($colormap) $tag 1311 } 1312 if { ![info exists _colormaps($colormap)] } { 1313 # Build the pseudo colormap if it doesn't exist. 1314 BuildColormap $colormap $dataobj $comp 1315 set _colormaps($colormap) 1 1316 } 1317 switch -- [$dataobj type $comp] { 1318 "polygon" { 1319 SendCmd "pseudocolor colormap $colormap $tag" 1320 } 1321 "spheres" { 1322 #SendCmd "glyphs colormap $colormap $tag" 1323 } 1324 } 1325 return $colormap 1326 } 1327 1328 # 1329 # BuildColormap -- 1330 # 1331 itcl::body Rappture::VtkViewer::BuildColormap { colormap dataobj comp } { 1332 array set style { 1333 -color rainbow 1334 -levels 6 1335 -opacity 1.0 1336 } 1337 array set style [$dataobj style $comp] 1338 if {$style(-color) == "rainbow"} { 1339 set style(-color) "white:yellow:green:cyan:blue:magenta" 1340 } 1341 set clist [split $style(-color) :] 1515 if { ![info exists _initialStyle($tag)] } { 1516 # Save the initial component style. 1517 set _initialStyle($tag) [$dataobj style $comp] 1518 } 1519 1520 # Override defaults with initial style defined in xml. 1521 array set style $_initialStyle($tag) 1522 1523 if { ![info exists _style($tag)] } { 1524 set _style($tag) [array get style] 1525 } 1526 # Override initial style with current style. 1527 array set style $_style($tag) 1528 1529 if { $style(-color) == "elementDefault" } { 1530 set name "$style(-color)" 1531 } else { 1532 set name "$style(-color):$style(-levels):$style(-opacity)" 1533 } 1534 if { ![info exists _colormaps($name)] } { 1535 BuildColormap $name [array get style] 1536 set _colormaps($name) 1 1537 } 1538 if { ![info exists _dataset2style($tag)] || 1539 $_dataset2style($tag) != $name } { 1540 set _dataset2style($tag) $name 1541 switch -- [$dataobj type $comp] { 1542 "polygon" { 1543 SendCmd "pseudocolor colormap $name $tag" 1544 } 1545 "glyphs" { 1546 SendCmd "glyphs colormap $name $tag" 1547 } 1548 "molecule" { 1549 SendCmd "molecule colormap $name $tag" 1550 } 1551 } 1552 } 1553 } 1554 1555 itcl::body Rappture::VtkViewer::ColorsToColormap { colors } { 1556 switch -- $colors { 1557 "grey-to-blue" { 1558 return { 1559 0.0 0.200 0.200 0.200 1560 0.14285714285714285 0.400 0.400 0.400 1561 0.2857142857142857 0.600 0.600 0.600 1562 0.42857142857142855 0.900 0.900 0.900 1563 0.5714285714285714 0.800 1.000 1.000 1564 0.7142857142857143 0.600 1.000 1.000 1565 0.8571428571428571 0.400 0.900 1.000 1566 1.0 0.000 0.600 0.800 1567 } 1568 } 1569 "blue-to-grey" { 1570 return { 1571 0.0 0.000 0.600 0.800 1572 0.14285714285714285 0.400 0.900 1.000 1573 0.2857142857142857 0.600 1.000 1.000 1574 0.42857142857142855 0.800 1.000 1.000 1575 0.5714285714285714 0.900 0.900 0.900 1576 0.7142857142857143 0.600 0.600 0.600 1577 0.8571428571428571 0.400 0.400 0.400 1578 1.0 0.200 0.200 0.200 1579 } 1580 } 1581 "blue" { 1582 return { 1583 0.0 0.900 1.000 1.000 1584 0.1111111111111111 0.800 0.983 1.000 1585 0.2222222222222222 0.700 0.950 1.000 1586 0.3333333333333333 0.600 0.900 1.000 1587 0.4444444444444444 0.500 0.833 1.000 1588 0.5555555555555556 0.400 0.750 1.000 1589 0.6666666666666666 0.300 0.650 1.000 1590 0.7777777777777778 0.200 0.533 1.000 1591 0.8888888888888888 0.100 0.400 1.000 1592 1.0 0.000 0.250 1.000 1593 } 1594 } 1595 "brown-to-blue" { 1596 return { 1597 0.0 0.200 0.100 0.000 1598 0.09090909090909091 0.400 0.187 0.000 1599 0.18181818181818182 0.600 0.379 0.210 1600 0.2727272727272727 0.800 0.608 0.480 1601 0.36363636363636365 0.850 0.688 0.595 1602 0.45454545454545453 0.950 0.855 0.808 1603 0.5454545454545454 0.800 0.993 1.000 1604 0.6363636363636364 0.600 0.973 1.000 1605 0.7272727272727273 0.400 0.940 1.000 1606 0.8181818181818182 0.200 0.893 1.000 1607 0.9090909090909091 0.000 0.667 0.800 1608 1.0 0.000 0.480 0.600 1609 } 1610 } 1611 "blue-to-brown" { 1612 return { 1613 0.0 0.000 0.480 0.600 1614 0.09090909090909091 0.000 0.667 0.800 1615 0.18181818181818182 0.200 0.893 1.000 1616 0.2727272727272727 0.400 0.940 1.000 1617 0.36363636363636365 0.600 0.973 1.000 1618 0.45454545454545453 0.800 0.993 1.000 1619 0.5454545454545454 0.950 0.855 0.808 1620 0.6363636363636364 0.850 0.688 0.595 1621 0.7272727272727273 0.800 0.608 0.480 1622 0.8181818181818182 0.600 0.379 0.210 1623 0.9090909090909091 0.400 0.187 0.000 1624 1.0 0.200 0.100 0.000 1625 } 1626 } 1627 "blue-to-orange" { 1628 return { 1629 0.0 0.000 0.167 1.000 1630 0.09090909090909091 0.100 0.400 1.000 1631 0.18181818181818182 0.200 0.600 1.000 1632 0.2727272727272727 0.400 0.800 1.000 1633 0.36363636363636365 0.600 0.933 1.000 1634 0.45454545454545453 0.800 1.000 1.000 1635 0.5454545454545454 1.000 1.000 0.800 1636 0.6363636363636364 1.000 0.933 0.600 1637 0.7272727272727273 1.000 0.800 0.400 1638 0.8181818181818182 1.000 0.600 0.200 1639 0.9090909090909091 1.000 0.400 0.100 1640 1.0 1.000 0.167 0.000 1641 } 1642 } 1643 "orange-to-blue" { 1644 return { 1645 0.0 1.000 0.167 0.000 1646 0.09090909090909091 1.000 0.400 0.100 1647 0.18181818181818182 1.000 0.600 0.200 1648 0.2727272727272727 1.000 0.800 0.400 1649 0.36363636363636365 1.000 0.933 0.600 1650 0.45454545454545453 1.000 1.000 0.800 1651 0.5454545454545454 0.800 1.000 1.000 1652 0.6363636363636364 0.600 0.933 1.000 1653 0.7272727272727273 0.400 0.800 1.000 1654 0.8181818181818182 0.200 0.600 1.000 1655 0.9090909090909091 0.100 0.400 1.000 1656 1.0 0.000 0.167 1.000 1657 } 1658 } 1659 "rainbow" { 1660 set clist { 1661 "#EE82EE" 1662 "#4B0082" 1663 "blue" 1664 "#008000" 1665 "yellow" 1666 "#FFA500" 1667 "red" 1668 } 1669 } 1670 "BGYOR" { 1671 set clist { 1672 "blue" 1673 "#008000" 1674 "yellow" 1675 "#FFA500" 1676 "red" 1677 } 1678 } 1679 "ROYGB" { 1680 set clist { 1681 "red" 1682 "#FFA500" 1683 "yellow" 1684 "#008000" 1685 "blue" 1686 } 1687 } 1688 "RYGCB" { 1689 set clist { 1690 "red" 1691 "yellow" 1692 "green" 1693 "cyan" 1694 "blue" 1695 } 1696 } 1697 "BCGYR" { 1698 set clist { 1699 "blue" 1700 "cyan" 1701 "green" 1702 "yellow" 1703 "red" 1704 } 1705 } 1706 "spectral" { 1707 return { 1708 0.0 0.150 0.300 1.000 1709 0.1 0.250 0.630 1.000 1710 0.2 0.450 0.850 1.000 1711 0.3 0.670 0.970 1.000 1712 0.4 0.880 1.000 1.000 1713 0.5 1.000 1.000 0.750 1714 0.6 1.000 0.880 0.600 1715 0.7 1.000 0.680 0.450 1716 0.8 0.970 0.430 0.370 1717 0.9 0.850 0.150 0.196 1718 1.0 0.650 0.000 0.130 1719 } 1720 } 1721 "green-to-magenta" { 1722 return { 1723 0.0 0.000 0.316 0.000 1724 0.06666666666666667 0.000 0.526 0.000 1725 0.13333333333333333 0.000 0.737 0.000 1726 0.2 0.000 0.947 0.000 1727 0.26666666666666666 0.316 1.000 0.316 1728 0.3333333333333333 0.526 1.000 0.526 1729 0.4 0.737 1.000 0.737 1730 0.4666666666666667 1.000 1.000 1.000 1731 0.5333333333333333 1.000 0.947 1.000 1732 0.6 1.000 0.737 1.000 1733 0.6666666666666666 1.000 0.526 1.000 1734 0.7333333333333333 1.000 0.316 1.000 1735 0.8 0.947 0.000 0.947 1736 0.8666666666666667 0.737 0.000 0.737 1737 0.9333333333333333 0.526 0.000 0.526 1738 1.0 0.316 0.000 0.316 1739 } 1740 } 1741 "greyscale" { 1742 return { 1743 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1744 } 1745 } 1746 "nanohub" { 1747 set clist "white yellow green cyan blue magenta" 1748 } 1749 default { 1750 set clist $colors 1751 } 1752 } 1342 1753 set cmap {} 1343 for {set i 0} {$i < [llength $clist]} {incr i} { 1344 set x [expr {double($i)/([llength $clist]-1)}] 1754 set numColors [llength $clist] 1755 for {set i 0} {$i < $numColors} {incr i} { 1756 if { $numColors > 1 } { 1757 set x [expr {double($i)/($numColors-1)}] 1758 } else { 1759 set x [expr double($i)] 1760 } 1345 1761 set color [lindex $clist $i] 1346 1762 append cmap "$x [Color2RGB $color] " 1347 1763 } 1764 return $cmap 1765 } 1766 1767 # 1768 # BuildColormap -- 1769 # 1770 itcl::body Rappture::VtkViewer::BuildColormap { name styles } { 1771 puts stderr name=$name 1772 if { $name == "elementDefault" } { 1773 return 1774 } 1775 array set style $styles 1776 set cmap [ColorsToColormap $style(-color)] 1348 1777 if { [llength $cmap] == 0 } { 1349 1778 set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0" 1350 1779 } 1351 if { ![info exists _ volume(opacity)] } {1352 set _ volume(opacity) $style(-opacity)1353 } 1354 set max $_ volume(opacity)1780 if { ![info exists _settings(mesh-opacity)] } { 1781 set _settings(mesh-opacity) $style(-opacity) 1782 } 1783 set max $_settings(mesh-opacity) 1355 1784 1356 1785 set wmap "0.0 1.0 1.0 1.0" 1357 SendCmd "colormap add $colormap { $cmap } { $wmap }" 1358 } 1786 SendCmd "colormap add $name { $cmap } { $wmap }" 1787 } 1788 1359 1789 1360 1790 # ---------------------------------------------------------------------- … … 1386 1816 if { ![info exists _limits($tag)] } { 1387 1817 set data [$dataobj data $comp] 1818 if { $data == "" } { 1819 continue 1820 } 1388 1821 set tmpfile file[pid].vtk 1389 1822 set f [open "$tmpfile" "w"] … … 1401 1834 set _limits($tag) [$output GetBounds] 1402 1835 set pointData [$output GetPointData] 1403 puts stderr "\#scalars=[$reader GetNumberOfScalarsInFile]"1404 puts stderr "\#vectors=[$reader GetNumberOfVectorsInFile]"1405 puts stderr "\#tensors=[$reader GetNumberOfTensorsInFile]"1406 puts stderr "\#normals=[$reader GetNumberOfNormalsInFile]"1407 puts stderr "\#fielddata=[$reader GetNumberOfFieldDataInFile]"1408 puts stderr "fielddataname=[$reader GetFieldDataNameInFile 0]"1409 1836 set fieldData [$output GetFieldData] 1410 set pointData [$output GetPointData] 1411 puts stderr "field \#arrays=[$fieldData GetNumberOfArrays]" 1412 puts stderr "point \#arrays=[$pointData GetNumberOfArrays]" 1413 puts stderr "field \#components=[$fieldData GetNumberOfComponents]" 1414 puts stderr "point \#components=[$pointData GetNumberOfComponents]" 1415 puts stderr "field \#tuples=[$fieldData GetNumberOfTuples]" 1416 puts stderr "point \#tuples=[$pointData GetNumberOfTuples]" 1417 puts stderr "point \#scalars=[$pointData GetScalars]" 1418 puts stderr vectors=[$pointData GetVectors] 1837 if 0 { 1838 puts stderr "\#scalars=[$reader GetNumberOfScalarsInFile]" 1839 puts stderr "\#vectors=[$reader GetNumberOfVectorsInFile]" 1840 puts stderr "\#tensors=[$reader GetNumberOfTensorsInFile]" 1841 puts stderr "\#normals=[$reader GetNumberOfNormalsInFile]" 1842 puts stderr "\#fielddata=[$reader GetNumberOfFieldDataInFile]" 1843 puts stderr "fielddataname=[$reader GetFieldDataNameInFile 0]" 1844 puts stderr "field \#arrays=[$fieldData GetNumberOfArrays]" 1845 puts stderr "point \#arrays=[$pointData GetNumberOfArrays]" 1846 puts stderr "field \#components=[$fieldData GetNumberOfComponents]" 1847 puts stderr "point \#components=[$pointData GetNumberOfComponents]" 1848 puts stderr "field \#tuples=[$fieldData GetNumberOfTuples]" 1849 puts stderr "point \#tuples=[$pointData GetNumberOfTuples]" 1850 puts stderr "point \#scalars=[$pointData GetScalars]" 1851 puts stderr vectors=[$pointData GetVectors] 1852 } 1419 1853 rename $output "" 1420 1854 rename $reader "" … … 1444 1878 } 1445 1879 1446 itcl::body Rappture::VtkViewer::Build VolumeTab {} {1880 itcl::body Rappture::VtkViewer::BuildMeshTab {} { 1447 1881 1448 1882 set fg [option get $itk_component(hull) font Font] … … 1450 1884 1451 1885 set inner [$itk_component(main) insert end \ 1452 -title " VolumeSettings" \1453 -icon [Rappture::icon volume-on]]1886 -title "Mesh Settings" \ 1887 -icon [Rappture::icon mesh]] 1454 1888 $inner configure -borderwidth 4 1455 1889 1456 checkbutton $inner. volume\1457 -text "Show Volume" \1458 -variable [itcl::scope _ volume(visible)] \1459 -command [itcl::code $this AdjustSetting volume-visible] \1890 checkbutton $inner.mesh \ 1891 -text "Show Mesh" \ 1892 -variable [itcl::scope _settings(mesh-visible)] \ 1893 -command [itcl::code $this AdjustSetting mesh-visible] \ 1460 1894 -font "Arial 9" 1461 1895 1462 1896 checkbutton $inner.wireframe \ 1463 1897 -text "Show Wireframe" \ 1464 -variable [itcl::scope _ volume(wireframe)] \1465 -command [itcl::code $this AdjustSetting volume-wireframe] \1898 -variable [itcl::scope _settings(mesh-wireframe)] \ 1899 -command [itcl::code $this AdjustSetting mesh-wireframe] \ 1466 1900 -font "Arial 9" 1467 1901 1468 1902 checkbutton $inner.lighting \ 1469 1903 -text "Enable Lighting" \ 1470 -variable [itcl::scope _ volume(lighting)] \1471 -command [itcl::code $this AdjustSetting volume-lighting] \1904 -variable [itcl::scope _settings(mesh-lighting)] \ 1905 -command [itcl::code $this AdjustSetting mesh-lighting] \ 1472 1906 -font "Arial 9" 1473 1907 1474 1908 checkbutton $inner.edges \ 1475 1909 -text "Show Edges" \ 1476 -variable [itcl::scope _ volume(edges)] \1477 -command [itcl::code $this AdjustSetting volume-edges] \1910 -variable [itcl::scope _settings(mesh-edges)] \ 1911 -command [itcl::code $this AdjustSetting mesh-edges] \ 1478 1912 -font "Arial 9" 1913 1914 label $inner.palette_l -text "Palette" -font "Arial 9" 1915 itk_component add meshpalette { 1916 Rappture::Combobox $inner.palette -width 10 -editable no 1917 } 1918 $inner.palette choices insert end \ 1919 "BCGYR" "BCGYR" \ 1920 "BGYOR" "BGYOR" \ 1921 "blue" "blue" \ 1922 "blue-to-brown" "blue-to-brown" \ 1923 "blue-to-orange" "blue-to-orange" \ 1924 "blue-to-grey" "blue-to-grey" \ 1925 "green-to-magenta" "green-to-magenta" \ 1926 "greyscale" "greyscale" \ 1927 "nanohub" "nanohub" \ 1928 "rainbow" "rainbow" \ 1929 "spectral" "spectral" \ 1930 "ROYGB" "ROYGB" \ 1931 "RYGCB" "RYGCB" \ 1932 "brown-to-blue" "brown-to-blue" \ 1933 "grey-to-blue" "grey-to-blue" \ 1934 "orange-to-blue" "orange-to-blue" 1935 1936 $itk_component(meshpalette) value "BCGYR" 1937 bind $inner.palette <<Value>> \ 1938 [itcl::code $this AdjustSetting mesh-palette] 1479 1939 1480 1940 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1481 1941 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1482 -variable [itcl::scope _ volume(opacity)] \1942 -variable [itcl::scope _settings(mesh-opacity)] \ 1483 1943 -width 10 \ 1484 1944 -showvalue off \ 1485 -command [itcl::code $this AdjustSetting volume-opacity]1945 -command [itcl::code $this AdjustSetting mesh-opacity] 1486 1946 1487 1947 blt::table $inner \ 1488 0,0 $inner. volume-anchor w -pady 2 \1489 1,0 $inner.wireframe - anchor w -pady 2 \1490 2,0 $inner.lighting - anchor w -pady 2 \1491 3,0 $inner.edges - anchor w -pady 2 \1948 0,0 $inner.mesh -cspan 2 -anchor w -pady 2 \ 1949 1,0 $inner.wireframe -cspan 2 -anchor w -pady 2 \ 1950 2,0 $inner.lighting -cspan 2 -anchor w -pady 2 \ 1951 3,0 $inner.edges -cspan 2 -anchor w -pady 2 \ 1492 1952 4,0 $inner.opacity_l -anchor w -pady 2 \ 1493 5,0 $inner.opacity -fill x -pady 2 1953 4,1 $inner.opacity -fill x -pady 2 \ 1954 5,0 $inner.palette_l -anchor w -pady 2 \ 1955 5,1 $inner.palette -fill x -pady 2 1494 1956 1495 1957 blt::table configure $inner r* c* -resize none 1496 blt::table configure $inner r 6c1 -resize expand1958 blt::table configure $inner r7 c1 -resize expand 1497 1959 } 1498 1960 … … 1739 2201 } 1740 2202 1741 2203 itcl::body Rappture::VtkViewer::BuildMoleculeTab {} { 2204 set fg [option get $itk_component(hull) font Font] 2205 2206 set inner [$itk_component(main) insert end \ 2207 -title "Molecule Settings" \ 2208 -icon [Rappture::icon molecule]] 2209 $inner configure -borderwidth 4 2210 2211 checkbutton $inner.molecule \ 2212 -text "Show Molecule" \ 2213 -variable [itcl::scope _settings(molecule-visible)] \ 2214 -command [itcl::code $this AdjustSetting molecule-visible] \ 2215 -font "Arial 9" 2216 2217 checkbutton $inner.label \ 2218 -text "Show Atom Labels" \ 2219 -variable [itcl::scope _settings(molecule-labels)] \ 2220 -command [itcl::code $this AdjustSetting molecule-labels] \ 2221 -font "Arial 9" 2222 2223 checkbutton $inner.wireframe \ 2224 -text "Show Wireframe" \ 2225 -variable [itcl::scope _settings(molecule-wireframe)] \ 2226 -command [itcl::code $this AdjustSetting molecule-wireframe] \ 2227 -font "Arial 9" 2228 2229 checkbutton $inner.lighting \ 2230 -text "Enable Lighting" \ 2231 -variable [itcl::scope _settings(molecule-lighting)] \ 2232 -command [itcl::code $this AdjustSetting molecule-lighting] \ 2233 -font "Arial 9" 2234 2235 checkbutton $inner.edges \ 2236 -text "Show Edges" \ 2237 -variable [itcl::scope _settings(molecule-edges)] \ 2238 -command [itcl::code $this AdjustSetting molecule-edges] \ 2239 -font "Arial 9" 2240 2241 label $inner.rep_l -text "Molecule Representation" \ 2242 -font "Arial 9" 2243 2244 itk_component add representation { 2245 Rappture::Combobox $inner.rep -width 20 -editable no 2246 } 2247 $inner.rep choices insert end \ 2248 "ballandstick" "Ball and Stick" \ 2249 "spheres" "Spheres" \ 2250 "sticks" "Sticks" \ 2251 "rods" "Rods" \ 2252 "wireframe" "Wireframe" \ 2253 "spacefilling" "Space Filling" 2254 2255 bind $inner.rep <<Value>> \ 2256 [itcl::code $this AdjustSetting molecule-representation] 2257 $inner.rep value "Ball and Stick" 2258 2259 label $inner.palette_l -text "Palette" -font "Arial 9" 2260 itk_component add moleculepalette { 2261 Rappture::Combobox $inner.palette -width 10 -editable no 2262 } 2263 $inner.palette choices insert end \ 2264 "elementDefault" "elementDefault" \ 2265 "BCGYR" "BCGYR" \ 2266 "BGYOR" "BGYOR" \ 2267 "blue" "blue" \ 2268 "blue-to-brown" "blue-to-brown" \ 2269 "blue-to-orange" "blue-to-orange" \ 2270 "blue-to-grey" "blue-to-grey" \ 2271 "green-to-magenta" "green-to-magenta" \ 2272 "greyscale" "greyscale" \ 2273 "nanohub" "nanohub" \ 2274 "rainbow" "rainbow" \ 2275 "spectral" "spectral" \ 2276 "ROYGB" "ROYGB" \ 2277 "RYGCB" "RYGCB" \ 2278 "brown-to-blue" "brown-to-blue" \ 2279 "grey-to-blue" "grey-to-blue" \ 2280 "orange-to-blue" "orange-to-blue" 2281 2282 $itk_component(moleculepalette) value "elementDefault" 2283 bind $inner.palette <<Value>> \ 2284 [itcl::code $this AdjustSetting molecule-palette] 2285 2286 checkbutton $inner.labels -text "Show labels on atoms" \ 2287 -command [itcl::code $this labels update] \ 2288 -variable [itcl::scope _settings(molecule-labels)] \ 2289 -font "Arial 9" 2290 Rappture::Tooltip::for $inner.labels \ 2291 "Display atom symbol and serial number." 2292 2293 checkbutton $inner.rock -text "Rock molecule back and forth" \ 2294 -variable [itcl::scope _settings(molecule-rock)] \ 2295 -font "Arial 9" 2296 Rappture::Tooltip::for $inner.rock \ 2297 "Rotate the object back and forth around the y-axis." 2298 2299 checkbutton $inner.cell -text "Parallelepiped" \ 2300 -font "Arial 9" 2301 $inner.cell select 2302 2303 label $inner.opacity_l -text "Opacity" -font "Arial 9" 2304 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 2305 -variable [itcl::scope _settings(molecule-opacity)] \ 2306 -width 10 \ 2307 -showvalue off \ 2308 -command [itcl::code $this AdjustSetting molecule-opacity] 2309 2310 blt::table $inner \ 2311 0,0 $inner.molecule -anchor w -pady {1 0} \ 2312 1,0 $inner.label -anchor w -pady {1 0} \ 2313 2,0 $inner.edges -anchor w -pady {1 0} \ 2314 3,0 $inner.rep_l -anchor w -pady { 2 0 } \ 2315 4,0 $inner.rep -anchor w \ 2316 5,0 $inner.palette_l -anchor w -pady 2 \ 2317 6,0 $inner.palette -fill x -pady 2 \ 2318 7,0 $inner.opacity_l -anchor w -pady 2 \ 2319 8,0 $inner.opacity -fill x -pady 2 2320 2321 blt::table configure $inner r* -resize none 2322 blt::table configure $inner r9 -resize expand 2323 } 1742 2324 1743 2325 # … … 1804 2386 foreach comp [$dataobj components] { 1805 2387 set tag $dataobj-$comp 1806 set contents [ConvertToVtkData $dataobj $comp] 1807 append bytes "$contents\n\n" 2388 set contents [$dataobj data $comp] 2389 append bytes "$contents\n" 2390 append bytes "\# End of VTK file\n\n" 1808 2391 } 1809 2392 } … … 1870 2453 set settings(-wireframe) 1 1871 2454 } 1872 if { $type == " spheres" } {2455 if { $type == "glyphs" } { 1873 2456 array set settings { 1874 2457 -color \#808080 … … 1882 2465 -visible 1 1883 2466 } 2467 set shape [$dataobj shape $comp] 1884 2468 array set settings $style 1885 SendCmd "glyphs add sphere $tag"2469 SendCmd "glyphs add $shape $tag" 1886 2470 SendCmd "glyphs normscale 0 $tag" 1887 2471 SendCmd "glyphs gscale $settings(-gscale) $tag" … … 1889 2473 #SendCmd "glyphs ccolor [Color2RGB $settings(-color)] $tag" 1890 2474 #SendCmd "glyphs colormode ccolor {} $tag" 2475 SendCmd "glyphs gorient 0 {} $tag" 1891 2476 SendCmd "glyphs smode vcomp {} $tag" 1892 2477 SendCmd "glyphs opacity $settings(-opacity) $tag" 1893 2478 SendCmd "glyphs visible $settings(-visible) $tag" 1894 set _haveSpheres 1 2479 set _settings(glyphs-wireframe) $settings(-wireframe) 2480 set _haveGlyphs 1 2481 } elseif { $type == "molecule" } { 2482 array set settings { 2483 -color \#808080 2484 -gscale 1 2485 -edges 0 2486 -edgecolor black 2487 -linewidth 1.0 2488 -opacity 1.0 2489 -wireframe 0 2490 -lighting 1 2491 -visible 1 2492 } 2493 array set settings $style 2494 SendCmd "molecule add $tag" 2495 SendCmd "molecule opacity $settings(-opacity) $tag" 2496 SendCmd "molecule visible $settings(-visible) $tag" 2497 SendCmd "molecule rscale van_der_waals $tag" 2498 set _settings(molecule-wireframe) $settings(-wireframe) 2499 set _haveMolecules 1 1895 2500 } else { 1896 2501 array set settings { … … 1907 2512 SendCmd "polydata add $tag" 1908 2513 SendCmd "polydata visible $settings(-visible) $tag" 1909 set _volume(visible) $settings(-visible) 1910 } 1911 if { $type != "spheres" } { 2514 set _settings(mesh-visible) $settings(-visible) 1912 2515 SendCmd "polydata edges $settings(-edges) $tag" 1913 set _ volume(edges) $settings(-edges)2516 set _settings(mesh-edges) $settings(-edges) 1914 2517 SendCmd "polydata color [Color2RGB $settings(-color)] $tag" 1915 2518 SendCmd "polydata lighting $settings(-lighting) $tag" 1916 set _ volume(lighting) $settings(-lighting)2519 set _settings(mesh-lighting) $settings(-lighting) 1917 2520 SendCmd "polydata linecolor [Color2RGB $settings(-edgecolor)] $tag" 1918 2521 SendCmd "polydata linewidth $settings(-linewidth) $tag" 1919 2522 SendCmd "polydata opacity $settings(-opacity) $tag" 1920 set _ volume(opacity) $settings(-opacity)2523 set _settings(mesh-opacity) $settings(-opacity) 1921 2524 SendCmd "polydata wireframe $settings(-wireframe) $tag" 1922 set _ volume(wireframe) $settings(-wireframe)1923 } 1924 set _ volume(opacity) [expr $settings(-opacity) * 100.0]2525 set _settings(mesh-wireframe) $settings(-wireframe) 2526 } 2527 set _settings(mesh-opacity) [expr $settings(-opacity) * 100.0] 1925 2528 SetColormap $dataobj $comp 1926 2529 } … … 1941 2544 # ---------------------------------------------------------------------- 1942 2545 itcl::body Rappture::VtkViewer::ReceiveLegend { colormap title vmin vmax size } { 1943 #puts stderr "ReceiveLegend colormap=$colormap title=$title range=$vmin,$vmax size=$size"1944 2546 set _limits(vmin) $vmin 1945 2547 set _limits(vmax) $vmax … … 1951 2553 } 1952 2554 $_image(legend) configure -data $bytes 1953 #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"1954 2555 DrawLegend 1955 2556 } … … 2041 2642 # Make a swatch of the selected color 2042 2643 if { [catch { $_image(legend) get 10 $imgY } pixel] != 0 } { 2043 #puts stderr "out of range: $imgY"2044 2644 return 2045 2645 } … … 2054 2654 # Compute the value of the point 2055 2655 set t [expr 1.0 - (double($imgY) / double($imgHeight-1))] 2056 #puts stderr "t=$t x=$x y=$y imgY=$imgY"2057 2656 set value [expr $t * ($_limits(vmax) - $_limits(vmin)) + $_limits(vmin)] 2058 2657 set tipx [expr $x + 15] 2059 2658 set tipy [expr $y - 5] 2060 #puts stderr "tipx=$tipx tipy=$tipy x=$x y=$y"2061 2659 Rappture::Tooltip::text $c "$_title $value" 2062 2660 Rappture::Tooltip::tooltip show $c +$tipx,+$tipy … … 2094 2692 } 2095 2693 } 2694 -
branches/nanovis2/gui/scripts/vtkvolumeviewer.tcl
r2792 r3175 222 222 # Initialize the view to some default parameters. 223 223 array set _view { 224 qw 1225 qx 0226 qy 0 227 qz 0 224 qw 0.853553 225 qx -0.353553 226 qy 0.353553 227 qz 0.146447 228 228 zoom 1.0 229 229 xpan 0 … … 1185 1185 "reset" { 1186 1186 array set _view { 1187 qw 11188 qx 01189 qy 0 1190 qz 0 1187 qw 0.853553 1188 qx -0.353553 1189 qy 0.353553 1190 qz 0.146447 1191 1191 zoom 1.0 1192 1192 xpan 0 -
branches/nanovis2/gui/scripts/xyresult.tcl
r2811 r3175 283 283 -param "" 284 284 } 285 # Override the defaults with first the <style> specified and then the 286 # settings list passed into this routoue. 287 array set params [$dataobj hints style] 285 288 foreach {opt val} $settings { 286 289 if {![info exists params($opt)]} { … … 299 302 set _autoColorI 0 300 303 } 301 304 set color [lindex $itk_option(-autocolors) $_autoColorI] 302 305 if { "" == $color} { 303 306 set color black … … 694 697 set color $_dataobj2color($dataobj) 695 698 } else { 696 set color [$dataobj hints color] 697 if {"" == $color} { 698 set color black 699 } 699 set color black 700 700 } 701 701 if {[info exists _dataobj2width($dataobj)]} { … … 704 704 set lwidth 2 705 705 } 706 707 706 if {[info exists _dataobj2dashes($dataobj)]} { 708 707 set dashes $_dataobj2dashes($dataobj) … … 710 709 set dashes "" 711 710 } 712 713 711 if {([$xv length] <= 1) || ($lwidth == 0)} { 714 712 set sym square -
branches/nanovis2/gui/src/Makefile.in
r2743 r3175 51 51 OBJS = \ 52 52 RapptureGUI_Init.o \ 53 RpCanvHotspot.o \ 53 54 RpCanvPlacard.o \ 54 55 RpDiffview.o \ -
branches/nanovis2/gui/src/RapptureGUI_Init.c
r2717 r3175 23 23 24 24 extern Tcl_AppInitProc Rappturegui_Init; 25 extern Tcl_AppInitProc RpCanvHotspot_Init; 25 26 extern Tcl_AppInitProc RpCanvPlacard_Init; 27 extern Tcl_AppInitProc RpConvertDxToVtk_Init; 26 28 extern Tcl_AppInitProc RpDiffview_Init; 27 29 … … 48 50 return TCL_ERROR; 49 51 } 52 if (RpCanvHotspot_Init(interp) != TCL_OK) { 53 return TCL_ERROR; 54 } 50 55 return TCL_OK; 51 56 } -
branches/nanovis2/gui/src/RpDiffview.c
r2310 r3175 2774 2774 layoutPtr->lines = (DiffviewLayoutLine*)ckalloc( 2775 2775 (unsigned)(layoutPtr->numLines * sizeof(DiffviewLayoutLine))); 2776 layoutPtr->maxLines = layoutPtr->numLines; 2776 2777 } 2777 2778 layoutPtr->numLines = 0; -
branches/nanovis2/lang/Makefile.in
r2709 r3175 21 21 MEX = @MEX@ 22 22 OCTAVE = @OCTAVE_VERSION@ 23 JAVA C = @JAVAC@23 JAVA_INC_DIR = @JAVA_INC_DIR@ 24 24 R = @R@ 25 25 … … 42 42 LANGS += octave 43 43 endif 44 ifneq ($(JAVA C),)44 ifneq ($(JAVA_INC_DIR),) 45 45 LANGS += java 46 46 endif -
branches/nanovis2/lang/python/Makefile.in
r2061 r3175 42 42 $(LN_S) $(srcdir2)/Rappture/*.cc build/tmp 43 43 44 install: 44 install: all 45 45 $(MKDIR_P) -m 0755 $(pythonlib) 46 46 $(PYTHON) setup.py install --install-lib=$(pythonlib) -
branches/nanovis2/lang/python/Rappture/PyRpLibrary.cc
r1527 r3175 11 11 #include <Python.h> 12 12 #include <RpLibrary.h> 13 #include <ctype.h> 14 15 #define TRUE 1 16 #define FALSE 0 17 18 #define RP_OK 0 19 #define RP_ERROR 1 13 20 14 21 #ifndef Py_RETURN_NONE … … 28 35 29 36 static PyObject *ErrorObject; 30 RpLibrary * RpLibraryObject_AsLibrary(PyObject *lib);37 static RpLibrary * RpLibraryObject_AsLibrary(PyObject *lib); 31 38 static PyObject * RpLibraryObject_FromLibrary(RpLibrary *lib); 32 int boolAsInt(const char *inVal, int *outVal);33 int boolIntFromPyObject ( PyObject *inPyObj, const char *defaultVal,34 const char *argName, int *boolVal);35 int getArgCount (PyObject *args, PyObject *keywds, int *argc);39 static int StringToBoolean(const char *inVal, int *resultPtr); 40 static int PyObjectToBoolean(PyObject *objPtr, const char *defaultVal, 41 const char *argName, int *resultPtr); 42 static int getArgCount(PyObject *args, PyObject *keywds, int *argc); 36 43 37 44 typedef struct { … … 39 46 RpLibrary *lib; 40 47 } RpLibraryObject; 48 49 50 static int 51 getArgCount(PyObject *args, PyObject *keywds, int *argc) 52 { 53 int args_cnt = 0; 54 int keywds_cnt = 0; 55 56 if (argc == NULL) { 57 // incorrect use of function 58 // argc cannot be null 59 PyErr_Format(PyExc_ValueError,"getArgCount(): argc is NULL"); 60 return RP_ERROR; 61 } 62 if (args != NULL) { 63 if (!PyTuple_Check(args)) { 64 PyErr_Format(PyExc_TypeError, 65 "getArgCount(): \'args\' should be a PyTuple"); 66 return RP_ERROR; 67 } 68 args_cnt = PyTuple_Size(args); 69 } 70 if (keywds != NULL) { 71 if (!PyDict_Check(keywds)) { 72 PyErr_Format(PyExc_TypeError, 73 "getArgCount(): \'keywds\' should be a PyDict"); 74 return RP_ERROR; 75 } 76 keywds_cnt = PyDict_Size(keywds); 77 } 78 *argc = args_cnt + keywds_cnt; 79 return RP_OK; 80 } 81 82 /* 83 * StringToBoolean -- 84 * 85 * represent a boolean string as an integer. 86 * 87 * outVal set to 1 if the boolean value inVal could 88 * be associated with any of the following strings: 89 * "yes", "on", "true", "1". 90 * 91 * outVal set to 0 if the boolean value inVal could 92 * be associated with any of the following strings: 93 * "no", "off", "false", "0". 94 * 95 * returns a status integer to tell if the operation 96 * was successful (0) of if there was an error (!0) 97 * 98 * note: string comparisons are case insensitive. 99 */ 100 101 static int 102 StringToBoolean(const char *string, int *resultPtr) 103 { 104 char c; 105 106 if ((string == NULL) || (resultPtr == NULL) ) { 107 PyErr_Format(PyExc_TypeError, 108 "incorrect use of StringToBoolean(inVal,outVal)"); 109 return RP_ERROR; 110 } 111 c = tolower(string[0]); 112 if (((c == 'y') && (strcasecmp(string, "yes") == 0)) || 113 ((c == 'o') && (strcasecmp(string, "on") == 0)) || 114 ((c == 't') && (strcasecmp(string, "true") == 0)) || 115 ((c == '1') && (strcasecmp(string, "1") == 0))) { 116 *resultPtr = TRUE; 117 } else if (((c == 'n') && (strcasecmp(string, "no") == 0)) || 118 ((c == 'o') && (strcasecmp(string, "off") == 0)) || 119 ((c == 'f') && (strcasecmp(string, "false") == 0)) || 120 ((c == '0') && (strcasecmp(string, "0") == 0))) { 121 *resultPtr = FALSE; 122 } else { 123 PyErr_Format(PyExc_ValueError, 124 "unrecognized input: %s: should be one of: \'yes\',\'true\',\'on\',\'1\',1,True,\'no\',\'false\',\'off\',\'0\',0,False", string); 125 return RP_ERROR; 126 } 127 return RP_OK; 128 } 129 130 static int 131 PyObjectToBoolean(PyObject *objPtr, const char *defValue, const char *argName, 132 int *resultPtr) 133 { 134 int value; 135 136 value = FALSE; // Suppress compiler warning. 137 if ((defValue == NULL) || (argName == NULL) || (resultPtr == NULL)) { 138 // incorrect use of function 139 PyErr_Format(PyExc_ValueError, 140 "PyObjectToBoolean: defValue or argName or resultPtr is NULL"); 141 return RP_ERROR; 142 } 143 if (objPtr == NULL) { 144 return StringToBoolean(defValue, resultPtr); 145 } 146 if (PyBool_Check(objPtr)) { 147 value = PyObject_IsTrue(objPtr); 148 if (value < 0) { 149 PyErr_Format(PyExc_ValueError, 150 "PyObjectToBoolean: bad boolean object"); 151 return RP_ERROR; 152 } 153 } else if (PyLong_Check(objPtr)) { 154 long l; 155 156 l = PyLong_AsLong(objPtr); 157 value = (l == 0) ? FALSE : TRUE; 158 } else if (PyInt_Check(objPtr)) { 159 long l; 160 161 l = PyInt_AsLong(objPtr); 162 value = (l == 0) ? FALSE : TRUE; 163 } else if (PyFloat_Check(objPtr)) { 164 double d; 165 166 d = PyFloat_AS_DOUBLE(objPtr); 167 value = (d == 0.0) ? FALSE : TRUE; 168 } else if (PyString_Check(objPtr)) { 169 const char *string; 170 171 string = PyString_AsString(objPtr); 172 if (string == NULL) { 173 PyErr_Format(PyExc_TypeError, 174 "bad value: %s: cannot convert to string",argName); 175 return RP_ERROR; 176 } 177 return StringToBoolean(string, resultPtr); 178 } else { 179 PyErr_Format(PyExc_TypeError, 180 "unknown python type for %s", argName); 181 return RP_ERROR; 182 } 183 *resultPtr = value; 184 return RP_OK; 185 } 41 186 42 187 /* … … 46 191 * correct initialization, use RpLibraryObject_IsValid. 47 192 */ 48 49 int 50 RpLibraryObject_Check(PyObject *o) 51 { 52 int retval = 0; 53 54 if (o != NULL) { 55 if ( (*(o->ob_type->tp_name) == 'R') 56 && (strcmp(o->ob_type->tp_name,"Rappture.library") == 0) ) { 57 retval = 1; 58 } 59 } 60 61 return retval; 193 static int 194 RpLibraryObject_Check(PyObject *objPtr) 195 { 196 if (objPtr == NULL) { 197 return FALSE; 198 } 199 if (strcmp(objPtr->ob_type->tp_name, "Rappture.library") != 0) { 200 return FALSE; 201 } 202 return TRUE; 62 203 } 63 204 … … 70 211 * in by the user is a valid Rappture.library object 71 212 */ 72 73 int 74 RpLibraryObject_IsValid(PyObject *o) 75 {76 int retval = 0; 77 78 if (o != NULL) {79 if (RpLibraryObject_Check(o)) {80 if ( ((RpLibraryObject *)o)->lib != NULL ) { 81 retval = 1;82 }83 } 84 } 85 86 return retval;213 static int 214 RpLibraryObject_IsValid(PyObject *objPtr) 215 { 216 if (objPtr == NULL) { 217 return FALSE; // Passed a NULL pointer. Should 218 // probably segfault. 219 } 220 if (!RpLibraryObject_Check(objPtr)) { 221 return FALSE; // Not a rappture library object type. 222 } 223 if (((RpLibraryObject *)objPtr)->lib == NULL) { 224 return FALSE; // Is a rappture library object, but 225 // doesn't contain a valid library. 226 } 227 return TRUE; 87 228 } 88 229 89 230 static PyObject * 90 RpLibraryObject_new(PyTypeObject *type, PyObject *args, PyObject *kwds)231 NewProc(PyTypeObject *type, PyObject *args, PyObject *kwds) 91 232 { 92 233 RpLibraryObject *self = NULL; … … 95 236 if (self != NULL) { 96 237 self->lib = NULL; 97 } 98 else { 99 PyErr_SetString(PyExc_RuntimeError,"trouble creating new RpLibraryObject"); 100 } 101 238 } else { 239 PyErr_SetString(PyExc_RuntimeError, 240 "trouble creating new RpLibraryObject"); 241 } 102 242 return (PyObject *)self; 103 243 } 104 244 105 245 static int 106 RpLibraryObject_init(RpLibraryObject *self, PyObject *args, PyObject *kwds) 107 { 108 PyObject *inObj = NULL; 109 char *filename = NULL; 110 int retVal = 1; 111 112 if (!PyArg_ParseTuple(args, "|O", &inObj)) { 246 InitProc(RpLibraryObject *self, PyObject *args, PyObject *kwds) 247 { 248 PyObject *objPtr; 249 250 objPtr = NULL; 251 if (!PyArg_ParseTuple(args, "|O", &objPtr)) { 113 252 PyErr_Format(PyExc_TypeError, 114 253 "library() takes at most 1 argument, a file name or a Rappture Library Object"); … … 116 255 } 117 256 118 if (inObj != NULL) { 119 if (PyString_Check(inObj)) { 120 filename = PyString_AsString(inObj); 257 if (objPtr != NULL) { 258 if (PyString_Check(objPtr)) { 259 char *filename; 260 261 filename = PyString_AsString(objPtr); 121 262 if (filename == NULL) { 122 263 PyErr_Format(PyExc_ValueError,"a file name is required"); 123 264 } 124 265 self->lib = new RpLibrary(std::string(filename)); 125 } 126 else if (RpLibraryObject_IsValid(inObj)) { 127 self->lib = new RpLibrary( *(RpLibraryObject_AsLibrary(inObj)) ); 128 } 129 else if (RpLibraryObject_Check(inObj)) { 266 } else if (RpLibraryObject_IsValid(objPtr)) { 267 self->lib = new RpLibrary( *(RpLibraryObject_AsLibrary(objPtr)) ); 268 } else if (RpLibraryObject_Check(objPtr)) { 130 269 self->lib = new RpLibrary(); 131 } 132 else { 270 } else { 133 271 PyErr_Format(PyExc_TypeError,"unrecognized object type"); 134 272 return -1; 135 273 } 136 } 137 else { 274 } else { 138 275 self->lib = new RpLibrary(); 139 276 } 140 277 141 return retVal;278 return 1; 142 279 } 143 280 144 281 static void 145 RpLibraryObject_dealloc(RpLibraryObject *self)282 FreeProc(RpLibraryObject *self) 146 283 { 147 284 if (self) { … … 153 290 } 154 291 155 PyDoc_STRVAR( RpLibraryObject_copy_doc,292 PyDoc_STRVAR(CopyProcDoc, 156 293 "copy (topath, frompath [, fromobj=$self]) -> None, copies data\n\ 157 294 \n\ … … 170 307 171 308 static PyObject * 172 RpLibraryObject_copy(RpLibraryObject *self, PyObject *args, PyObject *keywds)309 CopyProc(RpLibraryObject *self, PyObject *args, PyObject *keywds) 173 310 { 174 311 char *topath = (char *)""; 175 312 char *frompath = (char *)""; 176 313 int argc = 0; 177 int status = 0;178 314 PyObject *fromobj = (PyObject *) self; 179 315 … … 191 327 } 192 328 193 status = getArgCount(args,keywds,&argc); 194 if (status != 0) { 329 if (getArgCount(args,keywds,&argc) != RP_OK) { 195 330 // trouble ensues 196 331 // error message was set in getArgCount() … … 234 369 } 235 370 236 PyDoc_STRVAR( RpLibraryObject_element_doc,371 PyDoc_STRVAR(ElementProcDoc, 237 372 "element ([path=\'\'][, as=\'object\']) -> returns string or Rappture Library Object\n\ 238 373 \n\ … … 253 388 254 389 static PyObject * 255 RpLibraryObject_element(RpLibraryObject *self, PyObject *args, PyObject *keywds)390 ElementProc(RpLibraryObject *self, PyObject *args, PyObject *keywds) 256 391 { 257 392 char* path = (char *)""; … … 260 395 PyObject* retVal = NULL; 261 396 int argc = 0; 262 int status = 0;263 397 264 398 static char *kwlist[] = { … … 274 408 } 275 409 276 status = getArgCount(args,keywds,&argc); 277 if (status != 0) { 410 if (getArgCount(args,keywds,&argc) != RP_OK) { 278 411 // trouble ensues 279 412 // error message was set in getArgCount() … … 299 432 300 433 if (retlib != NULL) { 301 if ( (as == NULL) 302 || ((*as == 'o') && (strcmp("object",as) == 0)) ) { 434 if ((as == NULL) || ((*as == 'o') && (strcmp("object",as) == 0)) ) { 303 435 // tested with ElementTests.testArguments_PathArg() 304 436 retVal = RpLibraryObject_FromLibrary(retlib); 305 } 306 else if ((*as == 'c') && (strcmp("component",as) == 0)) { 437 } else if ((*as == 'c') && (strcmp("component",as) == 0)) { 307 438 // tested with ElementTests.testArguments_TwoArgs() 308 439 retVal = PyString_FromString(retlib->nodeComp().c_str()); 309 } 310 else if ((*as == 'i') && (strcmp("id",as) == 0)) { 440 } else if ((*as == 'i') && (strcmp("id",as) == 0)) { 311 441 // tested with ElementTests.testArguments_AsId() 312 442 retVal = PyString_FromString(retlib->nodeId().c_str()); 313 } 314 else if ((*as == 't') && (strcmp("type",as) == 0)) { 443 } else if ((*as == 't') && (strcmp("type",as) == 0)) { 315 444 // tested with ElementTests.testArguments_AsKeywordArgs() 316 445 retVal = PyString_FromString(retlib->nodeType().c_str()); 317 } 318 else if ((*as == 'p') && (strcmp("path",as) == 0)) { 446 } else if ((*as == 'p') && (strcmp("path",as) == 0)) { 319 447 // tested with ElementTests.testArguments_TwoKeywordArgs() 320 448 retVal = PyString_FromString(retlib->nodePath().c_str()); 321 } 322 else { 449 } else { 323 450 // tested with ElementTests.testArguments_UnrecognizedAs() 324 451 PyErr_Format(PyExc_ValueError, … … 331 458 332 459 333 PyDoc_STRVAR( RpLibraryObject_get_doc,460 PyDoc_STRVAR(GetProcDoc, 334 461 "get ([path=\'\'][, decode=\'True\']) -> returns data at \'path\' as string\n\ 335 462 \n\ … … 341 468 342 469 static PyObject * 343 RpLibraryObject_get(RpLibraryObject *self, PyObject *args, PyObject *keywds)470 GetProc(RpLibraryObject *self, PyObject *args, PyObject *keywds) 344 471 { 345 472 char* path = (char *)""; 346 473 347 474 PyObject* decode = NULL; 348 int decode Val = 0;475 int decodeFlag; 349 476 350 477 PyObject* retVal = NULL; … … 353 480 354 481 int argc = 0; 355 int status = 0;356 482 357 483 static char *kwlist[] = { … … 367 493 } 368 494 369 status = getArgCount(args,keywds,&argc); 370 if (status != 0) { 495 if (getArgCount(args,keywds,&argc) != RP_OK) { 371 496 // trouble ensues 372 497 // error message was set in getArgCount() … … 387 512 return NULL; 388 513 } 389 390 status = boolIntFromPyObject(decode,"yes","decode",&decodeVal); 391 if (status != 0) { 514 if (PyObjectToBoolean(decode,"yes", "decode", &decodeFlag) != RP_OK) { 392 515 // tested with GetTests.testArgumentsDecodeError() 393 516 return NULL; 394 517 } 395 396 if (decodeVal == 1) { 397 // tested with GetTests.testArgumentsDecode() 398 // tested with GetTests.testArgumentsDecodeYes() 399 // tested with GetTests.testArgumentsDecodeTrue) 400 // tested with GetTests.testArgumentsDecodeOn() 401 // tested with GetTests.testArgumentsDecode1Str() 402 // tested with GetTests.testArgumentsDecode1Int() 518 if (decodeFlag) { 403 519 retValStr = self->lib->get(std::string(path)); 404 520 retVal = PyString_FromStringAndSize(retValStr.c_str(),retValStr.size()); 405 } 406 else { 407 // tested with GetTests.testArgumentsNoDecodeNo() 408 // tested with GetTests.testArgumentsNoDecodeFalse() 409 // tested with GetTests.testArgumentsNoDecodeOff() 410 // tested with GetTests.testArgumentsNoDecode0Str() 411 // tested with GetTests.testArgumentsNoDecode0Int() 521 } else { 412 522 retValBuf = self->lib->getData(std::string(path)); 413 523 retVal = PyString_FromStringAndSize(retValBuf.bytes(),retValBuf.size()); 414 524 } 415 416 525 return (PyObject *)retVal; 417 526 } 418 527 419 PyDoc_STRVAR(RpLibraryObject_parent_doc, 528 #ifdef notdef 529 PyDoc_STRVAR(ParentProcDoc, 420 530 "parent ([path=\'\'][, as=\'object\']) -> returns string or Rappture Library Object\n\ 421 531 \n\ … … 433 543 434 544 static PyObject * 435 RpLibraryObject_parent(RpLibraryObject *self, PyObject *args, PyObject *keywds)545 ParentProc(RpLibraryObject *self, PyObject *args, PyObject *keywds) 436 546 { 437 547 char* path = (char *)""; … … 440 550 PyObject* retVal = NULL; 441 551 int argc = 0; 442 int status = 0;443 552 444 553 static char *kwlist[] = { … … 448 557 }; 449 558 450 status = getArgCount(args,keywds,&argc); 451 if (status != 0) { 559 if (getArgCount(args,keywds,&argc) != RP_OK) { 452 560 // trouble ensues 453 561 // error message was set in getArgCount() … … 459 567 return NULL; 460 568 } 461 462 569 if (!PyArg_ParseTupleAndKeywords(args, keywds, "|ss", 463 570 kwlist, &path, &as)) { 464 571 /* incorrect input values */ 465 PyErr_SetString(PyExc_TypeError, "parent ([path=\'\'][, as=\'object\'])");466 return NULL;467 }468 572 PyErr_SetString(PyExc_TypeError, 573 "parent ([path=\'\'][, as=\'object\'])"); 574 return NULL; 575 } 469 576 if (self->lib) { 470 577 retlib = self->lib->parent(std::string(path)); 471 } 472 else { 578 } else { 473 579 PyErr_SetString(PyExc_RuntimeError, 474 580 "incorrectly initialized Rappture Library Object"); … … 477 583 478 584 if (retlib != NULL) { 479 if ( (as == NULL) 480 || ((*as == 'o') && (strcmp("object",as) == 0)) 481 ) { 585 if ((as == NULL) || ((*as == 'o') && (strcmp("object",as) == 0))) { 482 586 retVal = RpLibraryObject_FromLibrary(retlib); 483 } 484 else if ((*as == 'c') && (strcmp("component",as) == 0)) { 587 } else if ((*as == 'c') && (strcmp("component",as) == 0)) { 485 588 retVal = PyString_FromString(retlib->nodeComp().c_str()); 486 } 487 else if ((*as == 'i') && (strcmp("id",as) == 0)) { 589 } else if ((*as == 'i') && (strcmp("id",as) == 0)) { 488 590 retVal = PyString_FromString(retlib->nodeId().c_str()); 489 } 490 else if ((*as == 't') && (strcmp("type",as) == 0)) { 591 } else if ((*as == 't') && (strcmp("type",as) == 0)) { 491 592 retVal = PyString_FromString(retlib->nodeType().c_str()); 492 } 493 else if ((*as == 'p') && (strcmp("path",as) == 0)) { 593 } else if ((*as == 'p') && (strcmp("path",as) == 0)) { 494 594 retVal = PyString_FromString(retlib->nodePath().c_str()); 495 } 496 else { 595 } else { 497 596 PyErr_Format(PyExc_ValueError, 498 597 "parent() \'as\' arg must be \'object\' or \'component\' or \'id\' or \'type\' or \'path\'"); 499 598 } 500 599 } 501 502 600 return (PyObject *)retVal; 503 601 } 504 505 PyDoc_STRVAR(RpLibraryObject_put_doc, 602 #endif 603 604 PyDoc_STRVAR(PutProcDoc, 506 605 "put (path=\'\', value=\'\'[,id=None][,append=False][,type=\'string\'][,compress=False]) -> None\n\ 507 606 \n\ … … 532 631 533 632 static PyObject * 534 RpLibraryObject_put(RpLibraryObject *self, PyObject *args, PyObject *keywds)633 PutProc(RpLibraryObject *self, PyObject *args, PyObject *keywds) 535 634 { 536 635 char *path = (char *)""; 537 636 538 PyObject *value = NULL; 539 PyObject *valueStrObj = NULL; 540 char *value_char = NULL; 541 Py_ssize_t value_len = 0; 542 637 PyObject *valueObjPtr, *compressObjPtr, *appendObjPtr, *strObjPtr; 543 638 char *id = NULL; 544 545 PyObject* append = NULL; 546 int appendInt = 0; 547 639 int appendFlag, compressFlag; 548 640 char *type = (char *)"string"; 549 550 PyObject* compress = NULL;551 int compressInt = 0;552 553 641 int argc = 0; 554 int status = 0;555 642 556 643 static char *kwlist[] = { … … 563 650 NULL 564 651 }; 565 652 appendFlag = compressFlag = FALSE; 653 strObjPtr = appendObjPtr = valueObjPtr = compressObjPtr = NULL; 566 654 if (self->lib == NULL) { 567 655 PyErr_Format(PyExc_RuntimeError, … … 570 658 } 571 659 572 status = getArgCount(args,keywds,&argc); 573 if (status != 0) { 574 // trouble ensues 575 // error message was set in getArgCount() 576 return NULL; 577 } 578 660 if (getArgCount(args,keywds,&argc) != RP_OK) { 661 return NULL; 662 } 579 663 if (argc > 6) { 580 // tested with PutTests.testArguments_TooManyArgs()581 664 PyErr_Format(PyExc_TypeError, 582 665 "put() takes at most 6 arguments (%i given)",argc); 583 666 return NULL; 584 667 } 585 586 668 if (argc < 2) { 587 // tested with PutTests.testArguments_NotEnoughArgs()588 669 PyErr_Format(PyExc_TypeError, 589 670 "put() takes at least 2 arguments (%i given)",argc); 590 671 return NULL; 591 672 } 592 593 if (!PyArg_ParseTupleAndKeywords(args, keywds, "sO|sOsO", 594 kwlist, &path, &value, &id, &append, &type, &compress)) { 595 // tested with PutTests.testArguments_ArgsWrongType2() 596 PyErr_Format(PyExc_TypeError, "incorrect arguments: put(path=\'\',value=\'\'[,id=None][,append=False][,type=\'string\'][,compress=False])"); 597 return NULL; 598 } 599 600 if (value == NULL) { 673 if (!PyArg_ParseTupleAndKeywords(args, keywds, "sO|sOsO", kwlist, &path, 674 &valueObjPtr, &id, &appendObjPtr, &type, &compressObjPtr)) { 675 return NULL; 676 } 677 678 if (valueObjPtr == NULL) { 601 679 PyErr_Format(PyExc_ValueError, "put()'s \'value\' arg is required"); 602 680 return NULL; 603 681 } 604 682 605 valueStrObj = PyObject_Str(value); 606 607 status = boolIntFromPyObject(append,"no","append",&appendInt); 608 if (status != 0) { 609 // error message set inside of boolIntFromPyObject 610 // tested with PutTests.testArguments_AppendValError() 611 return NULL; 612 } 613 status = boolIntFromPyObject(compress,"no","compress",&compressInt); 614 if (status != 0) { 615 // error message set inside of boolIntFromPyObject 616 // tested with PutTests.testArguments_CompressValError() 617 return NULL; 618 } 619 620 if (RpLibraryObject_IsValid(value)) { 621 // tested with PutTests.testPutObject() 622 self->lib->put( std::string(path), 623 RpLibraryObject_AsLibrary(value), "", appendInt); 624 } 625 else if (valueStrObj != NULL) { 626 627 if (PyString_AsStringAndSize(valueStrObj, &value_char, &value_len) == -1) { 628 // user passed in an improper string 629 // exception raised within fxn 683 if (PyObjectToBoolean(appendObjPtr, "no"," append", &appendFlag) != RP_OK){ 684 return NULL; 685 } 686 if (PyObjectToBoolean(compressObjPtr, "no", "compress", &compressFlag) 687 != RP_OK) { 688 return NULL; 689 } 690 691 strObjPtr = PyObject_Str(valueObjPtr); 692 if (RpLibraryObject_IsValid(valueObjPtr)) { 693 self->lib->put( std::string(path), 694 RpLibraryObject_AsLibrary(valueObjPtr), "", appendFlag); 695 } else if (strObjPtr != NULL) { 696 char *string; 697 Py_ssize_t length; 698 699 if (PyString_AsStringAndSize(strObjPtr, &string, &length) == -1) { 630 700 return NULL; 631 701 } 632 633 if ( ( type == NULL ) 634 || ( (*type == 's') && (strcmp("string", type) == 0) ) ) { 635 if (compress == 0) { 636 // tested with PutTests.testArgumentsCheckAppend() 637 // tested with PutTests.testArgumentsCheckAppendYes() 702 if ((type == NULL) || ((*type=='s') && (strcmp("string", type) == 0))){ 703 if (compressFlag == 0) { 638 704 self->lib->put( std::string(path), 639 std::string(value_char), "", appendInt); 705 std::string(string), "", appendFlag); 706 } else { 707 self->lib->putData( std::string(path), string, length, 708 appendFlag); 640 709 } 641 else { 642 // tested with PutTests.testArgumentsCheckTypeStringCompressYes() 643 self->lib->putData( std::string(path), 644 value_char, value_len, appendInt); 645 } 646 } 647 else if ( (*type == 'f') && (strcmp("file",type) == 0) ) { 648 // tested with PutTests.testArgumentsCheckTypeFile() 649 // tested with PutTests.testArgumentsCheckTypeFileCompressTrue() 650 // tested with PutTests.testArgumentsCheckTypeFileCompressTrueNoDecode() 710 } else if ((*type == 'f') && (strcmp("file",type) == 0)) { 651 711 self->lib->putFile( std::string(path), 652 std::string(PyString_AsString(valueStrObj)), 653 compressInt,appendInt); 654 } 655 else { 656 // tested with PutTests.testArgumentsCheckTypeError() 712 std::string(PyString_AsString(strObjPtr)), 713 compressFlag, appendFlag); 714 } else { 657 715 PyErr_Format(PyExc_ValueError, 658 716 "\'type\' arg must be \'string\' or \'file\'"); 659 717 return NULL; 660 718 } 661 } 662 else { 719 } else { 663 720 PyErr_Format(PyExc_TypeError, 664 721 "put()'s \'value\' arg must be a string or Rappture Library Object"); 665 722 return NULL; 666 723 } 667 668 724 Py_RETURN_NONE; 669 725 } 670 726 671 PyDoc_STRVAR( RpLibraryObject_xml_doc,727 PyDoc_STRVAR(XmlProcDoc, 672 728 "xml () -> returns xml string\n\ 673 729 \n\ … … 677 733 678 734 static PyObject* 679 RpLibraryObject_xml(RpLibraryObject *self) 680 { 681 PyObject *retStr = NULL; 682 735 XmlProc(RpLibraryObject *self) 736 { 683 737 if (self->lib == NULL) { 684 738 PyErr_Format(PyExc_RuntimeError, 685 739 "self uninitialized Rappture Library Object"); 686 740 } 687 688 retStr = PyString_FromString(self->lib->xml().c_str()); 689 690 return (PyObject *)retStr; 691 } 692 693 PyDoc_STRVAR(RpLibraryObject_result_doc, 741 return PyString_FromString(self->lib->xml().c_str()); 742 } 743 744 PyDoc_STRVAR(ResultProcDoc, 694 745 "result ([status=0]) -> None, send results back to graphical user interface\n\ 695 746 \n\ … … 699 750 700 751 static PyObject* 701 R pLibraryObject_result(RpLibraryObject *self, PyObject *args, PyObject *keywds)752 ResultProc(RpLibraryObject *self, PyObject *args, PyObject *keywds) 702 753 { 703 754 int argc = 0; … … 715 766 } 716 767 717 status = getArgCount(args,keywds,&argc); 718 if (status != 0) { 768 if (getArgCount(args,keywds,&argc) != RP_OK) { 719 769 // trouble ensues 720 770 // error message was set in getArgCount() … … 742 792 static PyMethodDef RpLibraryObject_methods[] = { 743 793 744 {"copy", (PyCFunction)RpLibraryObject_copy, METH_VARARGS|METH_KEYWORDS, 745 RpLibraryObject_copy_doc}, 746 747 /* 748 {"children", (PyCFunction)RpLibraryObject_children, METH_VARARGS|METH_KEYWORDS, 749 RpLibraryObject_children_doc}, 750 */ 751 752 {"element", (PyCFunction)RpLibraryObject_element, METH_VARARGS|METH_KEYWORDS, 753 RpLibraryObject_element_doc}, 754 755 {"get", (PyCFunction)RpLibraryObject_get, METH_VARARGS|METH_KEYWORDS, 756 RpLibraryObject_get_doc}, 757 758 /* 759 {"parent", (PyCFunction)RpLibraryObject_parent, METH_VARARGS|METH_KEYWORDS, 760 RpLibraryObject_put_doc}, 761 */ 762 763 {"put", (PyCFunction)RpLibraryObject_put, METH_VARARGS|METH_KEYWORDS, 764 RpLibraryObject_put_doc}, 765 766 /* 767 {"remove", (PyCFunction)RpLibraryObject_remove, METH_VARARGS|METH_KEYWORDS, 768 RpLibraryObject_remove_doc}, 769 */ 770 771 {"xml", (PyCFunction)RpLibraryObject_xml, METH_NOARGS, 772 RpLibraryObject_xml_doc}, 773 774 {"result", (PyCFunction)RpLibraryObject_result, METH_VARARGS|METH_KEYWORDS, 775 RpLibraryObject_result_doc}, 794 {"copy", (PyCFunction)CopyProc, METH_VARARGS|METH_KEYWORDS, CopyProcDoc}, 795 796 #ifdef notdef 797 {"children", (PyCFunction)ChildrenProc, METH_VARARGS|METH_KEYWORDS, 798 ChildrenProcDoc}, 799 #endif 800 801 {"element", (PyCFunction)ElementProc, METH_VARARGS|METH_KEYWORDS, 802 ElementProcDoc}, 803 804 {"get", (PyCFunction)GetProc, METH_VARARGS|METH_KEYWORDS, 805 GetProcDoc}, 806 807 #ifdef notdef 808 {"parent", (PyCFunction)ParentProc, METH_VARARGS|METH_KEYWORDS, 809 ParentProcDoc}, 810 #endif 811 812 {"put", (PyCFunction)PutProc, METH_VARARGS|METH_KEYWORDS, PutProcDoc}, 813 814 #ifdef notdef 815 {"remove", (PyCFunction)RemoveProc, METH_VARARGS|METH_KEYWORDS, 816 RemoveProcDoc}, 817 #endif 818 819 {"xml", (PyCFunction)XmlProc, METH_NOARGS, XmlProcDoc}, 820 821 {"result", (PyCFunction)ResultProc, METH_VARARGS|METH_KEYWORDS, 822 ResultProcDoc}, 776 823 777 824 {NULL, NULL} /* sentinel */ … … 787 834 0, /*tp_itemsize*/ 788 835 /* methods */ 789 (destructor) RpLibraryObject_dealloc,/*tp_dealloc*/836 (destructor)FreeProc, /*tp_dealloc*/ 790 837 0, /*tp_print*/ 791 838 0, /*tp_getattr*/ … … 818 865 0, /*tp_descr_set*/ 819 866 0, /*tp_dictoffset*/ 820 (initproc) RpLibraryObject_init,/*tp_init*/867 (initproc)InitProc, /*tp_init*/ 821 868 0, /*tp_alloc*/ 822 RpLibraryObject_new,/*tp_new*/869 NewProc, /*tp_new*/ 823 870 0, /*tp_new*/ 824 871 }; … … 827 874 * used to create a RpLibrary object from a PyObject 828 875 */ 829 RpLibrary *876 static RpLibrary * 830 877 RpLibraryObject_AsLibrary(PyObject *lib) 831 878 { … … 852 899 if (self != NULL) { 853 900 self->lib = lib; 854 } 855 else { 901 } else { 856 902 // raise error 857 903 PyErr_SetString(PyExc_RuntimeError, 858 "trouble creating new RpLibraryObject"); 859 } 860 } 861 904 "trouble creating new RpLibraryObject"); 905 } 906 } 862 907 return (PyObject *)self; 863 }864 865 /*866 * int boolAsInt (inVal, outVal)867 *868 * represent a boolean string as an integer.869 *870 * outVal set to 1 if the boolean value inVal could871 * be associated with any of the following strings:872 * "yes", "on", "true", "1".873 *874 * outVal set to 0 if the boolean value inVal could875 * be associated with any of the following strings:876 * "no", "off", "false", "0".877 *878 * returns a status integer to tell if the operation879 * was successful (0) of if there was an error (!0)880 *881 * note: string comparisons are case insensitive.882 */883 884 int885 boolAsInt(const char *inVal, int *outVal)886 {887 int len = 0;888 int lcv = 0;889 int status = 1;890 char boolVal[7] = "\0\0\0\0\0\0";891 892 if ( (inVal == NULL) || (outVal == NULL) ) {893 PyErr_Format(PyExc_TypeError,"incorrect use of boolAsInt(inVal,outVal)");894 return status;895 }896 897 len = strlen(inVal);898 899 if (len > 5) {900 PyErr_Format(PyExc_ValueError,901 "unrecognized input: %s: should be one of: \'yes\',\'true\',\'on\',\'1\',1,True,\'no\',\'false\',\'off\',\'0\',0,False",boolVal);902 return status;903 }904 905 for (lcv = 0; lcv < len; lcv++) {906 boolVal[lcv] = tolower(inVal[lcv]);907 }908 909 if (910 ((*boolVal == 'y') && (strcmp("yes",boolVal) == 0)) ||911 ((*boolVal == 't') && (strcmp("true",boolVal) == 0)) ||912 ((*boolVal == 'o') && (strcmp("on",boolVal) == 0)) ||913 ((*boolVal == '1') && (strcmp("1",boolVal) == 0)) ) {914 915 status = 0;916 *outVal = 1;917 }918 else if (919 ((*boolVal == 'n') && (strcmp("no",boolVal) == 0)) ||920 ((*boolVal == 'f') && (strcmp("false",boolVal) == 0)) ||921 ((*boolVal == 'o') && (strcmp("off",boolVal) == 0)) ||922 ((*boolVal == '0') && (strcmp("0",boolVal) == 0)) ) {923 924 status = 0;925 *outVal = 0;926 }927 else {928 PyErr_Format(PyExc_ValueError,929 "unrecognized input: %s: should be one of: \'yes\',\'true\',\'on\',\'1\',1,True,\'no\',\'false\',\'off\',\'0\',0,False",boolVal);930 status = 1;931 }932 933 return status;934 }935 936 int937 boolIntFromPyObject (938 PyObject *inPyObj,939 const char *defaultVal,940 const char *argName,941 int *boolVal942 )943 {944 int status = -1;945 PyObject *inStrObj = NULL;946 char *inStr = NULL;947 948 if ( (defaultVal == NULL) ||949 (argName == NULL) ||950 (boolVal == NULL)951 ) {952 // incorrect use of function953 PyErr_Format(PyExc_ValueError,954 "boolIntFromPyObject(): defaultVal or argName or boolVal is NULL");955 return status;956 }957 958 if (inPyObj != NULL) {959 inStrObj = PyObject_Str(inPyObj);960 if (inStrObj == NULL) {961 PyErr_Format(PyExc_TypeError,962 "bad value: %s: no string representation",argName);963 return status;964 }965 966 inStr = PyString_AsString(inStrObj);967 if (inStr == NULL) {968 PyErr_Format(PyExc_TypeError,969 "bad value: %s: cannot convert to string",argName);970 return status;971 }972 }973 974 if (inStr != NULL) {975 status = boolAsInt(inStr,boolVal);976 }977 else {978 status = boolAsInt(defaultVal,boolVal);979 }980 981 return status;982 }983 984 int getArgCount (985 PyObject *args,986 PyObject *keywds,987 int *argc988 )989 {990 int status = 1;991 int args_cnt = 0;992 int keywds_cnt = 0;993 994 if (argc == NULL) {995 // incorrect use of function996 // argc cannot be null997 PyErr_Format(PyExc_ValueError,"getArgCount(): argc is NULL");998 return status;999 }1000 1001 if (args != NULL) {1002 if (!PyTuple_Check(args)) {1003 PyErr_Format(PyExc_TypeError,1004 "getArgCount(): \'args\' should be a PyTuple");1005 return status;1006 }1007 args_cnt = PyTuple_Size(args);1008 }1009 1010 if (keywds != NULL) {1011 if (!PyDict_Check(keywds)) {1012 PyErr_Format(PyExc_TypeError,1013 "getArgCount(): \'keywds\' should be a PyDict");1014 return status;1015 }1016 keywds_cnt = PyDict_Size(keywds);1017 }1018 1019 *argc = args_cnt + keywds_cnt;1020 status = 0;1021 1022 return status;1023 908 } 1024 909 -
branches/nanovis2/lang/python/Rappture/PyRpUtils.cc
r1326 r3175 25 25 RpUtils_progress(PyObject *self, PyObject *args, PyObject *keywds) 26 26 { 27 int percent = 0; 28 char* message = NULL; 29 int result = -1; 30 31 static char *kwlist[] = { 32 (char *)"percent", 33 (char *)"message", 34 NULL 27 double pct; 28 char *msg; 29 static char *kwlist[] = { 30 (char *)"percent", (char *)"message", NULL 35 31 }; 36 32 if (PyTuple_Size(args) != 2) { 37 PyErr_SetString(PyExc_TypeError,"progress() takes exactly 2 arguments"); 33 PyErr_Format(PyExc_ValueError, 34 "progress() takes exactly 2 arguments, got %ld", 35 PyTuple_Size(args)); 38 36 return NULL; 39 37 } 40 41 if (!PyArg_ParseTupleAndKeywords(args, keywds, "is", 42 kwlist, &percent, &message)) { 43 PyErr_SetString(PyExc_TypeError,"progress() takes exactly 2 arguments"); 38 if (!PyArg_ParseTupleAndKeywords(args, keywds, "ds", kwlist, 39 &pct, &msg)) { 44 40 return NULL; 45 41 } 46 47 result = Rappture::Utils::progress(percent,message); 48 if (result != 0) { 49 PyErr_SetString(PyExc_RuntimeError,"Error while writing to stdout"); 42 if (Rappture::Utils::progress((int)pct, msg) != 0) { 43 PyErr_SetString(PyExc_RuntimeError, "Error while writing to stdout"); 44 return NULL; 50 45 } 51 52 46 Py_INCREF(Py_None); 53 47 return Py_None; -
branches/nanovis2/lang/python/Rappture/tools.py
r2926 r3175 4 4 # AUTHOR: Derrick S. Kearney, Purdue University 5 5 # AUTHOR: Steve Clark, Purdue University 6 # Copyright (c) 2005-20 07Purdue Research Foundation, West Lafayette, IN6 # Copyright (c) 2005-2012 Purdue Research Foundation, West Lafayette, IN 7 7 # ====================================================================== 8 8 9 import sys, os, re, subprocess, select 9 import sys 10 import os 11 import re 12 import subprocess 13 import select 14 import signal 10 15 11 # getCommandOutput function written by Steve Clark 16 commandPid = 0 17 18 def sig_handler(signalType, frame): 19 global commandPid 20 if commandPid: 21 os.kill(commandPid,signal.SIGTERM) 22 12 23 13 24 def getCommandOutput(command, … … 15 26 global commandPid 16 27 28 sig_INT_handler = signal.signal(signal.SIGINT,sig_handler) 29 sig_HUP_handler = signal.signal(signal.SIGHUP,sig_handler) 30 sig_TERM_handler = signal.signal(signal.SIGTERM,sig_handler) 31 17 32 BUFSIZ = 4096 18 child = subprocess.Popen(command,shell=True,bufsize=BUFSIZ, \ 19 stdout=subprocess.PIPE, \ 20 stderr=subprocess.PIPE, \ 21 close_fds=True) 33 if isinstance(command,list): 34 child = subprocess.Popen(command,bufsize=BUFSIZ, \ 35 stdout=subprocess.PIPE, \ 36 stderr=subprocess.PIPE, \ 37 close_fds=True) 38 else: 39 child = subprocess.Popen(command,shell=True,bufsize=BUFSIZ, \ 40 stdout=subprocess.PIPE, \ 41 stderr=subprocess.PIPE, \ 42 close_fds=True) 22 43 commandPid = child.pid 23 44 childout = child.stdout … … 26 47 childerrFd = childerr.fileno() 27 48 28 outEOF = errEOF = 0 49 outEOF = False 50 errEOF = False 29 51 30 52 outData = [] 31 53 errData = [] 32 54 33 while 1:55 while True: 34 56 toCheck = [] 35 57 if not outEOF: … … 37 59 if not errEOF: 38 60 toCheck.append(childerrFd) 39 ready = select.select(toCheck,[],[]) # wait for input 40 if childoutFd in ready[0]: 61 try: 62 readyRead,readyWrite,readyException = select.select(toCheck,[],[]) # wait for input 63 except select.error,err: 64 readyRead = [] 65 readyWrite = [] 66 readyException = [] 67 if childoutFd in readyRead: 41 68 outChunk = os.read(childoutFd,BUFSIZ) 42 69 if outChunk == '': 43 outEOF = 170 outEOF = True 44 71 outData.append(outChunk) 45 72 if streamOutput: … … 47 74 sys.stdout.flush() 48 75 49 if childerrFd in ready [0]:76 if childerrFd in readyRead: 50 77 errChunk = os.read(childerrFd,BUFSIZ) 51 78 if errChunk == '': 52 errEOF = 179 errEOF = True 53 80 errData.append(errChunk) 54 81 if streamOutput: … … 59 86 break 60 87 61 err = child.wait()88 pid,err = os.waitpid(commandPid,0) 62 89 commandPid = 0 90 91 signal.signal(signal.SIGINT,sig_INT_handler) 92 signal.signal(signal.SIGHUP,sig_HUP_handler) 93 signal.signal(signal.SIGTERM,sig_TERM_handler) 94 63 95 if err != 0: 64 sys.stderr.write("%s failed w/ exit code %d\n" % (command,err)) 96 if os.WIFSIGNALED(err): 97 sys.stderr.write("%s failed w/ signal %d\n" % (command,os.WTERMSIG(err))) 98 else: 99 if os.WIFEXITED(err): 100 err = os.WEXITSTATUS(err) 101 sys.stderr.write("%s failed w/ exit code %d\n" % (command,err)) 65 102 if not streamOutput: 66 103 sys.stderr.write("%s\n" % ("".join(errData))) 67 104 68 105 return err,"".join(outData),"".join(errData) -
branches/nanovis2/lang/tcl/scripts/Makefile.in
r2698 r3175 61 61 62 62 TYPEFILES = \ 63 $(srcdir)/types/atomactive.tcl \ 64 $(srcdir)/types/atomelem.tcl \ 65 $(srcdir)/types/atomprops.tcl \ 63 66 $(srcdir)/types/boolean.tcl \ 64 67 $(srcdir)/types/choices.tcl \ -
branches/nanovis2/lang/tcl/scripts/objects/periodicelement/periodicelement.rp
r2638 r3175 18 18 help http://rappture.org/wiki/rp_xml_ele_periodicelement 19 19 20 attr active -title "Active Elements" \ 21 -type string -path default -only input \ 22 -tooltip "Specifies the set of elements that can be selected.\n\nCan be a list of element symbols or groups: actinoid, alkali-metal, alkaline-earth-metal, halogen, lanthanoid, metalloid, noble-gas, other-non-metal, post-transition-metal, transition-metal, or unknown." 23 attr inactive -title "Inactive Elements" \ 24 -type string -path default -only input \ 25 -tooltip "Specifies the set of elements that can't be selected.\n\nCan be a list of element symbols or groups: actinoid, alkali-metal, alkaline-earth-metal, halogen, lanthanoid, metalloid, noble-gas, other-non-metal, post-transition-metal, transition-metal, or unknown." 20 attr default -title "Default Value" -type atomelem -path default -only input -tooltip "Sets the value that this input has when the program first starts. This value is used by default unless the user explicitly changes it." 26 21 27 attr returnvalue -title "Return value" -type string -path default -only input -tooltip "Specifies the return value: name, symbol, number, or weight."22 attr returnvalue -title "Return value" -type atomprops -path returnvalue -only input -tooltip "Specifies how the selected element is reported to your program: name, symbol, number, or weight." 28 23 29 attr default -title "Default Value" -type string -path default -only input -tooltip "Sets the value that this input has when the program first starts. This value is used by default unless the user explicitly changes it." 24 attr active -title "Allowed Elements" \ 25 -type atomactive -path active -only input -tooltip "Specifies the set of elements that can be selected.\n\nCan allow or disallow one or more groups of elements on the periodic table: actinoid, alkali-metal, alkaline-earth-metal, halogen, lanthanoid, metalloid, noble-gas, other-non-metal, post-transition-metal, transition-metal, or unknown." 30 26 31 27 check default { 32 if {[llength $attr(options)] > 0} { 33 if {[string length [string trim $attr(default)]] == 0} { 34 return [list error "Must have a default value for this periodicelement."] 28 set defval [string trim $attr(default)] 29 if {[string length $defval] == 0} { 30 return [list error "Must have a default value for this periodicelement."] 31 } 32 33 # make sure that the given value is a valid element type 34 if {[Rappture::PeriodicTable::FindElement $defval] eq ""} { 35 return [list error "Bad value \"$defval\": must be a known element in the periodic table."] 36 } 37 38 # make sure that the given value isn't in conflict with allowed values 39 if {$attr(active) ne "" && [regexp {^(active|inactive): (.+)} $attr(active) match polarity vlist]} { 40 set found [eval Rappture::PeriodicTable::ElementIsType $attr(default) [split $vlist ,]] 41 if { (!$found && $polarity eq "active") 42 || ($found && $polarity eq "inactive") } { 43 return [list error "Default value \"$attr(default)\" is not one of the allowed values"] 35 44 } 45 } 46 } 36 47 37 # make sure that the default is really a choice 38 set defval [string trim $attr(default)] 39 set found 0 40 foreach rec $attr(options) { 41 set label [string trim [lindex $rec 0]] 42 set value [string trim [lindex $rec 1]] 43 if {$defval eq $label || $defval eq $value} { 44 set found 1 45 break 46 } 47 } 48 if {!$found} { 49 return [list error "Default value must be a label or value for one of the current periodicelements."] 50 } 48 check returnvalue { 49 if {[string length [string trim $attr(returnvalue)]] == 0} { 50 return [list error "Must choose at least one return value to report the selected element to your program."] 51 51 } 52 52 } -
branches/nanovis2/packages/vizservers/vtkvis/Makefile.in
r2864 r3175 83 83 PPMWriter.cpp \ 84 84 ReadBuffer.cpp \ 85 RpArc.cpp \ 86 RpArrow.cpp \ 87 RpBox.cpp \ 88 RpCone.cpp \ 85 89 RpContour2D.cpp \ 86 90 RpContour3D.cpp \ 87 91 RpCutplane.cpp \ 92 RpCylinder.cpp \ 93 RpDisk.cpp \ 88 94 RpGlyphs.cpp \ 95 RpGroup.cpp \ 89 96 RpHeightMap.cpp \ 97 RpLine.cpp \ 90 98 RpLIC.cpp \ 91 99 RpMolecule.cpp \ 92 100 RpPolyData.cpp \ 101 RpPolygon.cpp \ 93 102 RpPseudoColor.cpp \ 103 RpShape.cpp \ 104 RpSphere.cpp \ 94 105 RpStreamlines.cpp \ 95 106 RpVolume.cpp \ … … 100 111 RpVtkRendererGraphicsObjs.cpp \ 101 112 RpVtkRenderServer.cpp \ 113 RpWarp.cpp \ 102 114 TGAWriter.cpp \ 103 115 Trace.cpp … … 149 161 ReadBuffer.o: ReadBuffer.h Trace.h 150 162 ResponseQueue.o: ResponseQueue.h Trace.h 163 RpArc.o: RpArc.h RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h 164 RpArrow.o: RpArrow.h RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h 165 RpBox.o: RpBox.h RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h 166 RpCone.o: RpCone.h RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h 151 167 RpContour2D.o: RpContour2D.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h 152 168 RpContour3D.o: RpContour3D.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h 153 169 RpCutplane.o: RpCutplane.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h 170 RpCylinder.o: RpCylinder.h RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h 171 RpDisk.o: RpDisk.h RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h 154 172 RpGlyphs.o: RpGlyphs.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h 173 RpGroup.o: RpGroup.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h 155 174 RpHeightMap.o: RpHeightMap.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h 175 RpLine.o: RpLine.h RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h 156 176 RpLIC.o: RpLIC.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h RpVtkRenderServer.h 157 177 RpMolecule.o: RpMolecule.h RpMoleculeData.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h 178 RpMolecule2.o: RpMolecule2.h RpMoleculeData.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h 158 179 RpPolyData.o: RpPolyData.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h 180 RpPolygon.o: RpPolygon.h RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h 159 181 RpPseudoColor.o: RpPseudoColor.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h 182 RpShape.o: RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h 183 RpSphere.o: RpSphere.h RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h 160 184 RpStreamlines.o: RpStreamlines.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h 161 185 RpVolume.o: RpVolume.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h 162 186 RpVtkDataSet.o: RpVtkDataSet.h Trace.h 163 RpVtkGraphicsObject.o: RpVtkGraphicsObject.h RpVtkRenderer.h RpVtkDataSet.h RpContour2D.h RpContour3D.h RpCutplane.h RpGlyphs.h RpHeightMap.h RpLIC.h RpMolecule.h RpPolyData.h RpPseudoColor.h RpStreamlines.h RpVolume.hColorMap.h Trace.h164 RpVtkRenderer.o: RpVtkRenderer.h Rp Math.h vtkRpCubeAxesActor2D.h RpVtkDataSet.h RpContour2D.h RpContour3D.h RpCutplane.h RpGlyphs.h RpHeightMap.h RpLIC.h RpMolecule.h RpPolyData.h RpPseudoColor.h RpStreamlines.h RpVolume.h ColorMap.h Trace.h165 RpVtkRendererCmd.o: RpVtkRenderer.h RpVtkRendererGraphicsObjs.h vtkRpCubeAxesActor2D.h RpVtkDataSet.h Rp Contour2D.h RpContour3D.h RpCutplane.h RpGlyphs.h RpHeightMap.h RpLIC.h RpMolecule.h RpPolyData.h RpPseudoColor.h RpStreamlines.h RpVolume.h ColorMap.h ReadBuffer.h ResponseQueue.h Trace.h CmdProc.h PPMWriter.h TGAWriter.h166 RpVtkRendererGraphicsObjs.o: RpVtkRenderer.h RpVtkRendererGraphicsObjs.h RpVtkDataSet.h Rp Contour2D.h RpContour3D.h RpCutplane.h RpGlyphs.h RpHeightMap.h RpLIC.h RpMolecule.h RpPolyData.h RpPseudoColor.h RpStreamlines.h RpVolume.h ColorMap.h Trace.h187 RpVtkGraphicsObject.o: RpVtkGraphicsObject.h RpVtkRenderer.h RpVtkDataSet.h ColorMap.h Trace.h 188 RpVtkRenderer.o: RpVtkRenderer.h RpVtkRendererGraphicsObjs.h RpMath.h vtkRpCubeAxesActor2D.h RpVtkDataSet.h RpArc.h RpArrow.h RpBox.h RpCone.h RpContour2D.h RpContour3D.h RpCutplane.h RpCylinder.h RpDisk.h RpGlyphs.h RpGroup.h RpHeightMap.h RpLIC.h RpLine.h RpMolecule.h RpPolyData.h RpPolygon.h RpPseudoColor.h RpSphere.h RpStreamlines.h RpVolume.h ColorMap.h Trace.h 189 RpVtkRendererCmd.o: RpVtkRenderer.h RpVtkRendererGraphicsObjs.h vtkRpCubeAxesActor2D.h RpVtkDataSet.h RpArc.h RpArrow.h RpBox.h RpCone.h RpContour2D.h RpContour3D.h RpCutplane.h RpCylinder.h RpDisk.h RpGlyphs.h RpGroup.h RpHeightMap.h RpLIC.h RpLine.h RpMolecule.h RpPolyData.h RpPolygon.h RpPseudoColor.h RpSphere.h RpStreamlines.h RpVolume.h ColorMap.h ReadBuffer.h ResponseQueue.h Trace.h CmdProc.h PPMWriter.h TGAWriter.h 190 RpVtkRendererGraphicsObjs.o: RpVtkRenderer.h RpVtkRendererGraphicsObjs.h RpVtkDataSet.h RpArc.h RpArrow.h RpBox.h RpCone.h RpContour2D.h RpContour3D.h RpCutplane.h RpCylinder.h RpDisk.h RpGlyphs.h RpGroup.h RpHeightMap.h RpLIC.h RpLine.h RpMolecule.h RpPolyData.h RpPolygon.h RpPseudoColor.h RpSphere.h RpStreamlines.h RpVolume.h ColorMap.h Trace.h 167 191 RpVtkRenderServer.o: RpVtkRenderServer.h RpVtkRendererCmd.h RpVtkRenderer.h vtkRpAxisActor.h vtkRpCubeAxesActor.h vtkRpAxisActor2D.h vtkRpCubeAxesActor2D.h ReadBuffer.h ResponseQueue.h Trace.h PPMWriter.h TGAWriter.h 192 RpWarp.o: RpWarp.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h 168 193 Trace.o: Trace.h 169 194 TGAWriter.o: TGAWriter.h ResponseQueue.h Trace.h -
branches/nanovis2/packages/vizservers/vtkvis/ResponseQueue.cpp
r2578 r3175 72 72 Response *response = NULL; 73 73 74 if (sem_wait(&_ready) < 0) { 74 int ret; 75 while ((ret = sem_wait(&_ready)) < 0 && errno == EINTR) 76 continue; 77 if (ret < 0) { 75 78 ERROR("can't wait on semaphore: %s", strerror(errno)); 76 79 } -
branches/nanovis2/packages/vizservers/vtkvis/RpContour2D.cpp
r2612 r3175 6 6 */ 7 7 8 #include <c assert>8 #include <cfloat> 9 9 10 10 #include <vtkDataSet.h> … … 23 23 24 24 #include "RpContour2D.h" 25 #include "RpVtkRenderer.h" 25 26 #include "Trace.h" 26 27 … … 29 30 Contour2D::Contour2D(int numContours) : 30 31 VtkGraphicsObject(), 31 _numContours(numContours) 32 _numContours(numContours), 33 _colorMap(NULL), 34 _colorMode(COLOR_CONSTANT), 35 _colorFieldType(DataSet::POINT_DATA), 36 _renderer(NULL) 32 37 { 33 38 _edgeColor[0] = _color[0]; 34 39 _edgeColor[1] = _color[0]; 35 40 _edgeColor[2] = _color[0]; 41 _colorFieldRange[0] = DBL_MAX; 42 _colorFieldRange[1] = -DBL_MAX; 36 43 _lighting = false; 37 44 } … … 40 47 VtkGraphicsObject(), 41 48 _numContours(contours.size()), 42 _contours(contours) 49 _contours(contours), 50 _colorMap(NULL), 51 _colorMode(COLOR_CONSTANT), 52 _colorFieldType(DataSet::POINT_DATA), 53 _renderer(NULL) 43 54 { 44 55 _edgeColor[0] = _color[0]; 45 56 _edgeColor[1] = _color[0]; 46 57 _edgeColor[2] = _color[0]; 58 _colorFieldRange[0] = DBL_MAX; 59 _colorFieldRange[1] = -DBL_MAX; 47 60 _lighting = false; 48 61 } … … 58 71 } 59 72 73 void Contour2D::setDataSet(DataSet *dataSet, 74 Renderer *renderer) 75 { 76 if (_dataSet != dataSet) { 77 _dataSet = dataSet; 78 79 _renderer = renderer; 80 81 if (renderer->getUseCumulativeRange()) { 82 renderer->getCumulativeDataRange(_dataRange, 83 _dataSet->getActiveScalarsName(), 84 1); 85 renderer->getCumulativeDataRange(_vectorMagnitudeRange, 86 _dataSet->getActiveVectorsName(), 87 3); 88 for (int i = 0; i < 3; i++) { 89 renderer->getCumulativeDataRange(_vectorComponentRange[i], 90 _dataSet->getActiveVectorsName(), 91 3, i); 92 } 93 } else { 94 _dataSet->getScalarRange(_dataRange); 95 _dataSet->getVectorRange(_vectorMagnitudeRange); 96 for (int i = 0; i < 3; i++) { 97 _dataSet->getVectorRange(_vectorComponentRange[i], i); 98 } 99 } 100 101 update(); 102 } 103 } 104 60 105 /** 61 106 * \brief Internal method to re-compute contours after a state change … … 67 112 } 68 113 vtkDataSet *ds = _dataSet->getVtkDataSet(); 69 70 initProp();71 114 72 115 // Contour filter to generate isolines … … 166 209 } 167 210 } 168 if (_contourMapper == NULL) { 169 _contourMapper = vtkSmartPointer<vtkPolyDataMapper>::New(); 170 _contourMapper->SetResolveCoincidentTopologyToPolygonOffset(); 171 _contourMapper->ScalarVisibilityOff(); 211 212 initProp(); 213 214 if (_dsMapper == NULL) { 215 _dsMapper = vtkSmartPointer<vtkPolyDataMapper>::New(); 216 _dsMapper->SetResolveCoincidentTopologyToPolygonOffset(); 217 _dsMapper->ScalarVisibilityOff(); 172 218 vtkSmartPointer<vtkStripper> stripper = vtkSmartPointer<vtkStripper>::New(); 173 219 stripper->SetInputConnection(_contourFilter->GetOutputPort()); 174 _contourMapper->SetInputConnection(stripper->GetOutputPort()); 175 getActor()->SetMapper(_contourMapper); 176 } 177 178 _contourMapper->Update(); 220 _dsMapper->SetInputConnection(stripper->GetOutputPort()); 221 getActor()->SetMapper(_dsMapper); 222 } 223 224 if (_lut == NULL) { 225 setColorMap(ColorMap::getDefault()); 226 } 227 228 setColorMode(_colorMode); 229 230 _dsMapper->Update(); 179 231 } 180 232 181 233 void Contour2D::updateRanges(Renderer *renderer) 182 234 { 183 VtkGraphicsObject::updateRanges(renderer); 235 if (_dataSet == NULL) { 236 ERROR("called before setDataSet"); 237 return; 238 } 239 240 if (renderer->getUseCumulativeRange()) { 241 renderer->getCumulativeDataRange(_dataRange, 242 _dataSet->getActiveScalarsName(), 243 1); 244 renderer->getCumulativeDataRange(_vectorMagnitudeRange, 245 _dataSet->getActiveVectorsName(), 246 3); 247 for (int i = 0; i < 3; i++) { 248 renderer->getCumulativeDataRange(_vectorComponentRange[i], 249 _dataSet->getActiveVectorsName(), 250 3, i); 251 } 252 } else { 253 _dataSet->getScalarRange(_dataRange); 254 _dataSet->getVectorRange(_vectorMagnitudeRange); 255 for (int i = 0; i < 3; i++) { 256 _dataSet->getVectorRange(_vectorComponentRange[i], i); 257 } 258 } 184 259 260 // Need to update color map ranges 261 double *rangePtr = _colorFieldRange; 262 if (_colorFieldRange[0] > _colorFieldRange[1]) { 263 rangePtr = NULL; 264 } 265 setColorMode(_colorMode, _colorFieldType, _colorFieldName.c_str(), rangePtr); 266 185 267 if (_contours.empty() && _numContours > 0) { 186 268 // Contour isovalues need to be recomputed … … 189 271 } 190 272 273 void Contour2D::setColorMode(ColorMode mode) 274 { 275 _colorMode = mode; 276 if (_dataSet == NULL) 277 return; 278 279 switch (mode) { 280 case COLOR_BY_SCALAR: 281 setColorMode(mode, 282 _dataSet->getActiveScalarsType(), 283 _dataSet->getActiveScalarsName(), 284 _dataRange); 285 break; 286 case COLOR_BY_VECTOR_MAGNITUDE: 287 setColorMode(mode, 288 _dataSet->getActiveVectorsType(), 289 _dataSet->getActiveVectorsName(), 290 _vectorMagnitudeRange); 291 break; 292 case COLOR_BY_VECTOR_X: 293 setColorMode(mode, 294 _dataSet->getActiveVectorsType(), 295 _dataSet->getActiveVectorsName(), 296 _vectorComponentRange[0]); 297 break; 298 case COLOR_BY_VECTOR_Y: 299 setColorMode(mode, 300 _dataSet->getActiveVectorsType(), 301 _dataSet->getActiveVectorsName(), 302 _vectorComponentRange[1]); 303 break; 304 case COLOR_BY_VECTOR_Z: 305 setColorMode(mode, 306 _dataSet->getActiveVectorsType(), 307 _dataSet->getActiveVectorsName(), 308 _vectorComponentRange[2]); 309 break; 310 case COLOR_CONSTANT: 311 default: 312 setColorMode(mode, DataSet::POINT_DATA, NULL, NULL); 313 break; 314 } 315 } 316 317 void Contour2D::setColorMode(ColorMode mode, 318 const char *name, double range[2]) 319 { 320 if (_dataSet == NULL) 321 return; 322 DataSet::DataAttributeType type = DataSet::POINT_DATA; 323 int numComponents = 1; 324 if (name != NULL && strlen(name) > 0 && 325 !_dataSet->getFieldInfo(name, &type, &numComponents)) { 326 ERROR("Field not found: %s", name); 327 return; 328 } 329 setColorMode(mode, type, name, range); 330 } 331 332 void Contour2D::setColorMode(ColorMode mode, DataSet::DataAttributeType type, 333 const char *name, double range[2]) 334 { 335 _colorMode = mode; 336 _colorFieldType = type; 337 if (name == NULL) 338 _colorFieldName.clear(); 339 else 340 _colorFieldName = name; 341 if (range == NULL) { 342 _colorFieldRange[0] = DBL_MAX; 343 _colorFieldRange[1] = -DBL_MAX; 344 } else { 345 memcpy(_colorFieldRange, range, sizeof(double)*2); 346 } 347 348 if (_dataSet == NULL || _dsMapper == NULL) 349 return; 350 351 switch (type) { 352 case DataSet::POINT_DATA: 353 _dsMapper->SetScalarModeToUsePointFieldData(); 354 break; 355 case DataSet::CELL_DATA: 356 _dsMapper->SetScalarModeToUseCellFieldData(); 357 break; 358 default: 359 ERROR("Unsupported DataAttributeType: %d", type); 360 return; 361 } 362 363 if (name != NULL && strlen(name) > 0) { 364 _dsMapper->SelectColorArray(name); 365 } else { 366 _dsMapper->SetScalarModeToDefault(); 367 } 368 369 if (_lut != NULL) { 370 if (range != NULL) { 371 _lut->SetRange(range); 372 } else if (name != NULL && strlen(name) > 0) { 373 double r[2]; 374 int comp = -1; 375 if (mode == COLOR_BY_VECTOR_X) 376 comp = 0; 377 else if (mode == COLOR_BY_VECTOR_Y) 378 comp = 1; 379 else if (mode == COLOR_BY_VECTOR_Z) 380 comp = 2; 381 382 if (_renderer->getUseCumulativeRange()) { 383 int numComponents; 384 if (!_dataSet->getFieldInfo(name, type, &numComponents)) { 385 ERROR("Field not found: %s, type: %d", name, type); 386 return; 387 } else if (numComponents < comp+1) { 388 ERROR("Request for component %d in field with %d components", 389 comp, numComponents); 390 return; 391 } 392 _renderer->getCumulativeDataRange(r, name, type, numComponents, comp); 393 } else { 394 _dataSet->getDataRange(r, name, type, comp); 395 } 396 _lut->SetRange(r); 397 } 398 } 399 400 switch (mode) { 401 case COLOR_BY_SCALAR: 402 _dsMapper->ScalarVisibilityOn(); 403 break; 404 case COLOR_BY_VECTOR_MAGNITUDE: 405 _dsMapper->ScalarVisibilityOn(); 406 if (_lut != NULL) { 407 _lut->SetVectorModeToMagnitude(); 408 } 409 break; 410 case COLOR_BY_VECTOR_X: 411 _dsMapper->ScalarVisibilityOn(); 412 if (_lut != NULL) { 413 _lut->SetVectorModeToComponent(); 414 _lut->SetVectorComponent(0); 415 } 416 break; 417 case COLOR_BY_VECTOR_Y: 418 _dsMapper->ScalarVisibilityOn(); 419 if (_lut != NULL) { 420 _lut->SetVectorModeToComponent(); 421 _lut->SetVectorComponent(1); 422 } 423 break; 424 case COLOR_BY_VECTOR_Z: 425 _dsMapper->ScalarVisibilityOn(); 426 if (_lut != NULL) { 427 _lut->SetVectorModeToComponent(); 428 _lut->SetVectorComponent(2); 429 } 430 break; 431 case COLOR_CONSTANT: 432 default: 433 _dsMapper->ScalarVisibilityOff(); 434 break; 435 } 436 } 437 438 /** 439 * \brief Called when the color map has been edited 440 */ 441 void Contour2D::updateColorMap() 442 { 443 setColorMap(_colorMap); 444 } 445 446 /** 447 * \brief Associate a colormap lookup table with the DataSet 448 */ 449 void Contour2D::setColorMap(ColorMap *cmap) 450 { 451 if (cmap == NULL) 452 return; 453 454 _colorMap = cmap; 455 456 if (_lut == NULL) { 457 _lut = vtkSmartPointer<vtkLookupTable>::New(); 458 if (_dsMapper != NULL) { 459 _dsMapper->UseLookupTableScalarRangeOn(); 460 _dsMapper->SetLookupTable(_lut); 461 } 462 _lut->DeepCopy(cmap->getLookupTable()); 463 switch (_colorMode) { 464 case COLOR_CONSTANT: 465 case COLOR_BY_SCALAR: 466 _lut->SetRange(_dataRange); 467 break; 468 case COLOR_BY_VECTOR_MAGNITUDE: 469 _lut->SetRange(_vectorMagnitudeRange); 470 break; 471 case COLOR_BY_VECTOR_X: 472 _lut->SetRange(_vectorComponentRange[0]); 473 break; 474 case COLOR_BY_VECTOR_Y: 475 _lut->SetRange(_vectorComponentRange[1]); 476 break; 477 case COLOR_BY_VECTOR_Z: 478 _lut->SetRange(_vectorComponentRange[2]); 479 break; 480 default: 481 break; 482 } 483 } else { 484 double range[2]; 485 _lut->GetTableRange(range); 486 _lut->DeepCopy(cmap->getLookupTable()); 487 _lut->SetRange(range); 488 } 489 490 switch (_colorMode) { 491 case COLOR_BY_VECTOR_MAGNITUDE: 492 _lut->SetVectorModeToMagnitude(); 493 break; 494 case COLOR_BY_VECTOR_X: 495 _lut->SetVectorModeToComponent(); 496 _lut->SetVectorComponent(0); 497 break; 498 case COLOR_BY_VECTOR_Y: 499 _lut->SetVectorModeToComponent(); 500 _lut->SetVectorComponent(1); 501 break; 502 case COLOR_BY_VECTOR_Z: 503 _lut->SetVectorModeToComponent(); 504 _lut->SetVectorComponent(2); 505 break; 506 default: 507 break; 508 } 509 } 510 191 511 /** 192 512 * \brief Specify number of evenly spaced contour lines to render … … 239 559 void Contour2D::setClippingPlanes(vtkPlaneCollection *planes) 240 560 { 241 if (_ contourMapper != NULL) {242 _ contourMapper->SetClippingPlanes(planes);243 } 244 } 561 if (_dsMapper != NULL) { 562 _dsMapper->SetClippingPlanes(planes); 563 } 564 } -
branches/nanovis2/packages/vizservers/vtkvis/RpContour2D.h
r2612 r3175 14 14 #include <vtkActor.h> 15 15 #include <vtkPlaneCollection.h> 16 #include <vtkLookupTable.h> 16 17 17 18 #include <vector> 18 19 20 #include "ColorMap.h" 19 21 #include "RpVtkGraphicsObject.h" 20 22 … … 27 29 class Contour2D : public VtkGraphicsObject { 28 30 public: 31 enum ColorMode { 32 COLOR_BY_SCALAR, 33 COLOR_BY_VECTOR_MAGNITUDE, 34 COLOR_BY_VECTOR_X, 35 COLOR_BY_VECTOR_Y, 36 COLOR_BY_VECTOR_Z, 37 COLOR_CONSTANT 38 }; 39 29 40 Contour2D(int numContours); 30 41 … … 38 49 } 39 50 51 virtual void setDataSet(DataSet *dataSet, 52 Renderer *renderer); 53 40 54 virtual void setClippingPlanes(vtkPlaneCollection *planes); 41 55 … … 47 61 48 62 const std::vector<double>& getContourList() const; 63 64 void setColorMode(ColorMode mode, DataSet::DataAttributeType type, 65 const char *name, double range[2] = NULL); 66 67 void setColorMode(ColorMode mode, 68 const char *name, double range[2] = NULL); 69 70 void setColorMode(ColorMode mode); 71 72 void setColorMap(ColorMap *colorMap); 73 74 /** 75 * \brief Return the ColorMap in use 76 */ 77 ColorMap *getColorMap() 78 { 79 return _colorMap; 80 } 81 82 void updateColorMap(); 49 83 50 84 virtual void updateRanges(Renderer *renderer); … … 69 103 std::vector<double> _contours; 70 104 105 ColorMap *_colorMap; 106 ColorMode _colorMode; 107 std::string _colorFieldName; 108 DataSet::DataAttributeType _colorFieldType; 109 double _colorFieldRange[2]; 110 double _vectorMagnitudeRange[2]; 111 double _vectorComponentRange[3][2]; 112 Renderer *_renderer; 113 114 vtkSmartPointer<vtkLookupTable> _lut; 71 115 vtkSmartPointer<vtkContourFilter> _contourFilter; 72 vtkSmartPointer<vtkPolyDataMapper> _ contourMapper;116 vtkSmartPointer<vtkPolyDataMapper> _dsMapper; 73 117 }; 74 118 -
branches/nanovis2/packages/vizservers/vtkvis/RpGlyphs.cpp
r2641 r3175 107 107 _glyphSource = vtkSmartPointer<vtkLineSource>::New(); 108 108 break; 109 case ARROW: 109 case ARROW: { 110 110 _glyphSource = vtkSmartPointer<vtkArrowSource>::New(); 111 break; 112 case CONE: 111 vtkSmartPointer<vtkArrowSource> arrow = vtkArrowSource::SafeDownCast(_glyphSource); 112 arrow->SetTipResolution(8); 113 arrow->SetShaftResolution(8); 114 } 115 break; 116 case CONE: { 113 117 _glyphSource = vtkSmartPointer<vtkConeSource>::New(); 118 vtkSmartPointer<vtkConeSource> cone = vtkConeSource::SafeDownCast(_glyphSource); 119 cone->SetResolution(8); 120 } 114 121 break; 115 122 case CUBE: … … 119 126 case CYLINDER: { 120 127 vtkSmartPointer<vtkCylinderSource> csource = vtkSmartPointer<vtkCylinderSource>::New(); 121 vtkCylinderSource::SafeDownCast(csource)->SetResolution(6);128 csource->SetResolution(8); 122 129 _glyphSource = vtkSmartPointer<vtkTransformPolyDataFilter>::New(); 123 130 _glyphSource->SetInputConnection(csource->GetOutputPort()); … … 139 146 vtkPlatonicSolidSource::SafeDownCast(_glyphSource)->SetSolidTypeToOctahedron(); 140 147 break; 141 case SPHERE: 148 case SPHERE: { 142 149 _glyphSource = vtkSmartPointer<vtkSphereSource>::New(); 150 vtkSmartPointer<vtkSphereSource> sphere = vtkSphereSource::SafeDownCast(_glyphSource); 151 sphere->SetThetaResolution(14); 152 sphere->SetPhiResolution(14); 153 } 143 154 break; 144 155 case TETRAHEDRON: … … 169 180 } 170 181 #endif 182 183 //setQuality(0.8); 184 } 185 186 void Glyphs::setQuality(double quality) 187 { 188 switch (_glyphShape) { 189 case ARROW: { 190 vtkSmartPointer<vtkArrowSource> arrow = vtkArrowSource::SafeDownCast(_glyphSource); 191 int res = (int)(quality * 25); 192 if (res < 5) res = 5; 193 arrow->SetTipResolution(res); 194 arrow->SetShaftResolution(res); 195 } 196 break; 197 case CONE: { 198 vtkSmartPointer<vtkConeSource> cone = vtkConeSource::SafeDownCast(_glyphSource); 199 int res = (int)(quality * 25); 200 if (res < 5) res = 5; 201 cone->SetResolution(res); 202 } 203 break; 204 case SPHERE: { 205 vtkSmartPointer<vtkSphereSource> sphere = vtkSphereSource::SafeDownCast(_glyphSource); 206 int res = (int)(quality * 50); 207 if (res < 5) res = 5; 208 sphere->SetThetaResolution(res); 209 sphere->SetPhiResolution(res); 210 } 211 break; 212 case CYLINDER: { 213 assert (vtkTransformPolyDataFilter::SafeDownCast(_glyphSource) != NULL); 214 assert (vtkTransformPolyDataFilter::SafeDownCast(_glyphSource)->GetInput() != NULL); 215 TRACE("gsource input: %s", vtkTransformPolyDataFilter::SafeDownCast(_glyphSource)->GetInput()->GetClassName()); 216 vtkSmartPointer<vtkCylinderSource> csource = vtkCylinderSource::SafeDownCast(vtkTransformPolyDataFilter::SafeDownCast(_glyphSource)->GetInput()->GetProducerPort()); 217 int res = (int)(quality * 25); 218 if (res < 5) res = 5; 219 csource->SetResolution(res); 220 } 221 break; 222 default: 223 break; 224 } 171 225 } 172 226 … … 208 262 if (ds->GetPointData() == NULL || 209 263 ds->GetPointData()->GetScalars() == NULL) { 210 WARN("No scalar point data in dataset %s", _dataSet->getName().c_str());211 264 if (ds->GetCellData() != NULL && 212 265 ds->GetCellData()->GetScalars() != NULL) { 266 TRACE("Generating point data scalars from cell data for: %s", _dataSet->getName().c_str()); 213 267 cellToPtData = 214 268 vtkSmartPointer<vtkCellDataToPointData>::New(); … … 218 272 ds = cellToPtData->GetOutput(); 219 273 } else { 220 ERROR("No scalar celldata in dataset %s", _dataSet->getName().c_str());274 TRACE("No scalar data in dataset %s", _dataSet->getName().c_str()); 221 275 } 222 276 } … … 298 352 299 353 #ifdef HAVE_GLYPH3D_MAPPER 354 /** 355 * \brief Turn on/off orienting glyphs from a vector field 356 */ 357 void Glyphs::setOrientMode(bool mode, const char *name) 358 { 359 if (_glyphMapper != NULL) { 360 _glyphMapper->SetOrient(mode ? 1 : 0); 361 if (name != NULL && strlen(name) > 0) { 362 _glyphMapper->SetOrientationArray(name); 363 } else { 364 _glyphMapper->SetOrientationArray(vtkDataSetAttributes::VECTORS); 365 } 366 } 367 } 368 300 369 /** 301 370 * \brief Control how glyphs are scaled … … 638 707 639 708 /** 709 * \brief Turn on/off orienting glyphs from a vector field 710 */ 711 void Glyphs::setOrient(bool state) 712 { 713 #ifdef HAVE_GLYPH3D_MAPPER 714 if (_glyphMapper != NULL) { 715 _glyphMapper->SetOrient(state ? 1 : 0); 716 } 717 #else 718 if (_glyphGenerator != NULL) { 719 _glyphGenerator->SetOrient(state ? 1 : 0); 720 } 721 #endif 722 } 723 724 /** 640 725 * \brief Controls relative scaling of glyphs 641 726 */ -
branches/nanovis2/packages/vizservers/vtkvis/RpGlyphs.h
r2641 r3175 77 77 virtual void setClippingPlanes(vtkPlaneCollection *planes); 78 78 79 void setQuality(double quality); 80 81 void setOrient(bool state); 82 79 83 #ifdef HAVE_GLYPH3D_MAPPER 84 void setOrientMode(bool mode, const char *name); 85 80 86 void setScalingMode(ScalingMode mode, const char *name, double range[2]); 81 87 -
branches/nanovis2/packages/vizservers/vtkvis/RpMolecule.cpp
r2641 r3175 6 6 */ 7 7 8 #include <cstdio> 9 #include <cfloat> 8 10 #include <cassert> 9 11 10 12 #include <vtkDataSet.h> 13 #include <vtkCellArray.h> 11 14 #include <vtkPointData.h> 12 15 #include <vtkFloatArray.h> 16 #include <vtkDoubleArray.h> 17 #include <vtkIntArray.h> 18 #include <vtkStringArray.h> 13 19 #include <vtkPolyData.h> 14 20 #include <vtkPolyDataMapper.h> … … 17 23 #include <vtkTubeFilter.h> 18 24 #include <vtkSphereSource.h> 25 #include <vtkCylinderSource.h> 26 #include <vtkTransform.h> 27 #include <vtkTransformPolyDataFilter.h> 19 28 #include <vtkGlyph3D.h> 29 #include <vtkPointSetToLabelHierarchy.h> 30 #include <vtkLabelPlacementMapper.h> 31 #include <vtkTextProperty.h> 20 32 21 33 #include "RpMolecule.h" 22 34 #include "RpMoleculeData.h" 35 #include "RpVtkRenderer.h" 23 36 #include "Trace.h" 24 37 … … 27 40 Molecule::Molecule() : 28 41 VtkGraphicsObject(), 29 _atomScaling(NO_ATOM_SCALING), 30 _colorMap(NULL) 31 { 42 _radiusScale(0.3), 43 _atomScaling(COVALENT_RADIUS), 44 _labelsOn(false), 45 _colorMap(NULL), 46 _colorMode(COLOR_BY_ELEMENTS), 47 _colorFieldType(DataSet::POINT_DATA) 48 { 49 _bondColor[0] = _bondColor[1] = _bondColor[2] = 1.0f; 50 _colorFieldRange[0] = DBL_MAX; 51 _colorFieldRange[1] = -DBL_MAX; 32 52 _faceCulling = true; 33 53 } … … 41 61 TRACE("Deleting Molecule with NULL DataSet"); 42 62 #endif 63 } 64 65 void Molecule::setDataSet(DataSet *dataSet, 66 Renderer *renderer) 67 { 68 if (_dataSet != dataSet) { 69 _dataSet = dataSet; 70 71 _renderer = renderer; 72 73 if (renderer->getUseCumulativeRange()) { 74 renderer->getCumulativeDataRange(_dataRange, 75 _dataSet->getActiveScalarsName(), 76 1); 77 renderer->getCumulativeDataRange(_vectorMagnitudeRange, 78 _dataSet->getActiveVectorsName(), 79 3); 80 for (int i = 0; i < 3; i++) { 81 renderer->getCumulativeDataRange(_vectorComponentRange[i], 82 _dataSet->getActiveVectorsName(), 83 3, i); 84 } 85 } else { 86 _dataSet->getScalarRange(_dataRange); 87 _dataSet->getVectorRange(_vectorMagnitudeRange); 88 for (int i = 0; i < 3; i++) { 89 _dataSet->getVectorRange(_vectorComponentRange[i], i); 90 } 91 } 92 93 update(); 94 } 43 95 } 44 96 … … 65 117 setCulling(_bondProp->GetProperty(), true); 66 118 _bondProp->GetProperty()->EdgeVisibilityOff(); 119 _bondProp->GetProperty()->SetColor(_bondColor[0], _bondColor[1], _bondColor[2]); 67 120 _bondProp->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]); 68 121 _bondProp->GetProperty()->SetLineWidth(_edgeWidth); … … 72 125 _bondProp->GetProperty()->LightingOff(); 73 126 } 127 if (_labelProp == NULL) { 128 _labelProp = vtkSmartPointer<vtkActor2D>::New(); 129 } 74 130 if (_prop == NULL) { 75 131 _prop = vtkSmartPointer<vtkAssembly>::New(); … … 87 143 vtkDataSet *ds = _dataSet->getVtkDataSet(); 88 144 145 #ifndef MOLECULE_USE_GLYPH3D_MAPPER 89 146 if (_atomMapper == NULL) { 90 147 _atomMapper = vtkSmartPointer<vtkPolyDataMapper>::New(); … … 96 153 _bondMapper->SetResolveCoincidentTopologyToPolygonOffset(); 97 154 _bondMapper->ScalarVisibilityOn(); 155 } 156 #else 157 if (_atomMapper == NULL) { 158 _atomMapper = vtkSmartPointer<vtkGlyph3DMapper>::New(); 159 _atomMapper->SetResolveCoincidentTopologyToPolygonOffset(); 160 _atomMapper->ScalarVisibilityOn(); 161 } 162 if (_bondMapper == NULL) { 163 _bondMapper = vtkSmartPointer<vtkGlyph3DMapper>::New(); 164 _bondMapper->SetResolveCoincidentTopologyToPolygonOffset(); 165 _bondMapper->ScalarVisibilityOn(); 166 } 167 #endif 168 if (_labelMapper == NULL) { 169 _labelMapper = vtkSmartPointer<vtkLabelPlacementMapper>::New(); 170 _labelMapper->SetShapeToRoundedRect(); 171 _labelMapper->SetBackgroundColor(1.0, 1.0, 0.7); 172 _labelMapper->SetBackgroundOpacity(0.8); 173 _labelMapper->SetMargin(3); 98 174 } 99 175 … … 104 180 WARN("No element array in dataset %s", _dataSet->getName().c_str()); 105 181 setColorMap(ColorMap::getDefault()); 182 if (_atomScaling != NO_ATOM_SCALING) 183 _atomScaling = NO_ATOM_SCALING; 106 184 } else { 107 185 TRACE("Using element default colormap"); … … 112 190 initProp(); 113 191 114 addRadiusArray(ds, _atomScaling); 192 addLabelArray(ds); 193 addRadiusArray(ds, _atomScaling, _radiusScale); 115 194 116 195 vtkPolyData *pd = vtkPolyData::SafeDownCast(ds); … … 124 203 if (pd->GetNumberOfLines() > 0) { 125 204 // Bonds 126 vtkSmartPointer<vtkTubeFilter> tuber = vtkSmartPointer<vtkTubeFilter>::New(); 127 tuber->SetInput(pd); 128 tuber->SetNumberOfSides(6); 129 tuber->CappingOff(); 130 tuber->SetRadius(.03); 131 tuber->SetVaryRadiusToVaryRadiusOff(); 132 _bondMapper->SetInputConnection(tuber->GetOutputPort()); 205 #ifndef MOLECULE_USE_GLYPH3D_MAPPER 206 if (_tuber == NULL) 207 _tuber = vtkSmartPointer<vtkTubeFilter>::New(); 208 _tuber->SetInput(pd); 209 _tuber->SetNumberOfSides(12); 210 _tuber->CappingOff(); 211 _tuber->SetRadius(0.075); 212 _tuber->SetVaryRadiusToVaryRadiusOff(); 213 _bondMapper->SetInputConnection(_tuber->GetOutputPort()); 214 #else 215 setupBondPolyData(); 216 217 if (_cylinderSource == NULL) { 218 _cylinderSource = vtkSmartPointer<vtkCylinderSource>::New(); 219 _cylinderSource->SetRadius(0.075); 220 _cylinderSource->SetHeight(1.0); 221 _cylinderSource->SetResolution(12); 222 _cylinderSource->CappingOff(); 223 _cylinderTrans = vtkSmartPointer<vtkTransformPolyDataFilter>::New(); 224 _cylinderTrans->SetInputConnection(_cylinderSource->GetOutputPort()); 225 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New(); 226 trans->RotateZ(-90.0); 227 _cylinderTrans->SetTransform(trans); 228 } 229 if (_lineSource == NULL) { 230 _lineSource = vtkSmartPointer<vtkLineSource>::New(); 231 _lineSource->SetPoint1(-0.5, 0, 0); 232 _lineSource->SetPoint2(0.5, 0, 0); 233 } 234 235 _bondMapper->SetSourceConnection(_cylinderTrans->GetOutputPort()); 236 _bondMapper->SetInputConnection(_bondPD->GetProducerPort()); 237 _bondMapper->SetOrientationArray("bond_orientations"); 238 _bondMapper->SetOrientationModeToDirection(); 239 _bondMapper->OrientOn(); 240 _bondMapper->SetScaleArray("bond_scales"); 241 _bondMapper->SetScaleModeToScaleByVectorComponents(); 242 _bondMapper->ScalingOn(); 243 _bondMapper->ClampingOff(); 244 #endif 133 245 _bondProp->SetMapper(_bondMapper); 134 246 getAssembly()->AddPart(_bondProp); 135 247 } 136 248 if (pd->GetNumberOfVerts() > 0) { 249 vtkSmartPointer<vtkPointSetToLabelHierarchy> hier = vtkSmartPointer<vtkPointSetToLabelHierarchy>::New(); 250 hier->SetInput(pd); 251 hier->SetLabelArrayName("labels"); 252 hier->GetTextProperty()->SetColor(0, 0, 0); 253 _labelMapper->SetInputConnection(hier->GetOutputPort()); 254 _labelProp->SetMapper(_labelMapper); 255 137 256 // Atoms 138 257 vtkSmartPointer<vtkSphereSource> sphereSource = vtkSmartPointer<vtkSphereSource>::New(); 139 sphereSource->SetRadius(.08); 258 sphereSource->SetRadius(1.0); 259 sphereSource->SetThetaResolution(14); 260 sphereSource->SetPhiResolution(14); 261 #ifndef MOLECULE_USE_GLYPH3D_MAPPER 140 262 if (_glypher == NULL) 141 263 _glypher = vtkSmartPointer<vtkGlyph3D>::New(); 142 264 _glypher->SetSourceConnection(sphereSource->GetOutputPort()); 143 265 _glypher->SetInput(pd); 144 if (_atomScaling != NO_ATOM_SCALING && 145 ds->GetPointData() != NULL && 266 if (ds->GetPointData() != NULL && 146 267 ds->GetPointData()->GetVectors() != NULL) { 147 268 _glypher->SetScaleModeToScaleByVector(); … … 154 275 _glypher->OrientOff(); 155 276 _atomMapper->SetInputConnection(_glypher->GetOutputPort()); 277 #else 278 _atomMapper->SetSourceConnection(sphereSource->GetOutputPort()); 279 _atomMapper->SetInputConnection(pd->GetProducerPort()); 280 if (ds->GetPointData() != NULL && 281 ds->GetPointData()->GetVectors() != NULL) { 282 _atomMapper->SetScaleArray(vtkDataSetAttributes::VECTORS); 283 _atomMapper->SetScaleModeToScaleByMagnitude(); 284 _atomMapper->ScalingOn(); 285 } else { 286 _atomMapper->SetScaleModeToNoDataScaling(); 287 _atomMapper->ScalingOff(); 288 } 289 _atomMapper->OrientOff(); 290 #endif 156 291 _atomProp->SetMapper(_atomMapper); 157 292 getAssembly()->AddPart(_atomProp); … … 163 298 } 164 299 300 setAtomLabelVisibility(_labelsOn); 301 165 302 _atomMapper->Update(); 166 303 _bondMapper->Update(); 304 _labelMapper->Update(); 167 305 } 168 306 169 307 void Molecule::updateRanges(Renderer *renderer) 170 308 { 171 VtkGraphicsObject::updateRanges(renderer); 172 173 if (_lut != NULL && _dataSet != NULL) { 174 vtkDataSet *ds = _dataSet->getVtkDataSet(); 175 if (ds == NULL) 176 return; 177 if (ds->GetPointData() == NULL || 178 ds->GetPointData()->GetScalars() == NULL || 179 strcmp(ds->GetPointData()->GetScalars()->GetName(), "element") != 0) { 180 _lut->SetRange(_dataRange); 181 } 309 if (_dataSet == NULL) { 310 ERROR("called before setDataSet"); 311 return; 312 } 313 314 if (renderer->getUseCumulativeRange()) { 315 renderer->getCumulativeDataRange(_dataRange, 316 _dataSet->getActiveScalarsName(), 317 1); 318 renderer->getCumulativeDataRange(_vectorMagnitudeRange, 319 _dataSet->getActiveVectorsName(), 320 3); 321 for (int i = 0; i < 3; i++) { 322 renderer->getCumulativeDataRange(_vectorComponentRange[i], 323 _dataSet->getActiveVectorsName(), 324 3, i); 325 } 326 } else { 327 _dataSet->getScalarRange(_dataRange); 328 _dataSet->getVectorRange(_vectorMagnitudeRange); 329 for (int i = 0; i < 3; i++) { 330 _dataSet->getVectorRange(_vectorComponentRange[i], i); 331 } 332 } 333 334 // Need to update color map ranges 335 double *rangePtr = _colorFieldRange; 336 if (_colorFieldRange[0] > _colorFieldRange[1]) { 337 rangePtr = NULL; 338 } 339 setColorMode(_colorMode, _colorFieldType, _colorFieldName.c_str(), rangePtr); 340 } 341 342 void Molecule::setColorMode(ColorMode mode) 343 { 344 _colorMode = mode; 345 if (_dataSet == NULL) 346 return; 347 348 switch (mode) { 349 case COLOR_BY_ELEMENTS: // Assume default scalar is "element" array 350 setColorMode(mode, 351 DataSet::POINT_DATA, 352 "element"); 353 break; 354 case COLOR_BY_SCALAR: 355 setColorMode(mode, 356 _dataSet->getActiveScalarsType(), 357 _dataSet->getActiveScalarsName(), 358 _dataRange); 359 break; 360 case COLOR_BY_VECTOR_MAGNITUDE: 361 setColorMode(mode, 362 _dataSet->getActiveVectorsType(), 363 _dataSet->getActiveVectorsName(), 364 _vectorMagnitudeRange); 365 break; 366 case COLOR_BY_VECTOR_X: 367 setColorMode(mode, 368 _dataSet->getActiveVectorsType(), 369 _dataSet->getActiveVectorsName(), 370 _vectorComponentRange[0]); 371 break; 372 case COLOR_BY_VECTOR_Y: 373 setColorMode(mode, 374 _dataSet->getActiveVectorsType(), 375 _dataSet->getActiveVectorsName(), 376 _vectorComponentRange[1]); 377 break; 378 case COLOR_BY_VECTOR_Z: 379 setColorMode(mode, 380 _dataSet->getActiveVectorsType(), 381 _dataSet->getActiveVectorsName(), 382 _vectorComponentRange[2]); 383 break; 384 case COLOR_CONSTANT: 385 default: 386 setColorMode(mode, DataSet::POINT_DATA, NULL, NULL); 387 break; 388 } 389 } 390 391 void Molecule::setColorMode(ColorMode mode, 392 const char *name, double range[2]) 393 { 394 if (_dataSet == NULL) 395 return; 396 DataSet::DataAttributeType type = DataSet::POINT_DATA; 397 int numComponents = 1; 398 if (name != NULL && strlen(name) > 0 && 399 !_dataSet->getFieldInfo(name, &type, &numComponents)) { 400 ERROR("Field not found: %s", name); 401 return; 402 } 403 setColorMode(mode, type, name, range); 404 } 405 406 void Molecule::setColorMode(ColorMode mode, DataSet::DataAttributeType type, 407 const char *name, double range[2]) 408 { 409 _colorMode = mode; 410 _colorFieldType = type; 411 if (name == NULL) 412 _colorFieldName.clear(); 413 else 414 _colorFieldName = name; 415 if (range == NULL) { 416 _colorFieldRange[0] = DBL_MAX; 417 _colorFieldRange[1] = -DBL_MAX; 418 } else { 419 memcpy(_colorFieldRange, range, sizeof(double)*2); 420 } 421 422 if (_dataSet == NULL || (_atomMapper == NULL && _bondMapper == NULL)) 423 return; 424 425 switch (type) { 426 case DataSet::POINT_DATA: 427 if (_atomMapper != NULL) 428 _atomMapper->SetScalarModeToUsePointFieldData(); 429 if (_bondMapper != NULL) 430 _bondMapper->SetScalarModeToUsePointFieldData(); 431 break; 432 case DataSet::CELL_DATA: 433 if (_atomMapper != NULL) 434 _atomMapper->SetScalarModeToUseCellFieldData(); 435 if (_bondMapper != NULL) 436 _bondMapper->SetScalarModeToUseCellFieldData(); 437 break; 438 default: 439 ERROR("Unsupported DataAttributeType: %d", type); 440 return; 441 } 442 443 if (name != NULL && strlen(name) > 0) { 444 if (_atomMapper != NULL) 445 _atomMapper->SelectColorArray(name); 446 if (_bondMapper != NULL) 447 _bondMapper->SelectColorArray(name); 448 } else { 449 if (_atomMapper != NULL) 450 _atomMapper->SetScalarModeToDefault(); 451 if (_bondMapper != NULL) 452 _bondMapper->SetScalarModeToDefault(); 453 } 454 455 if (_lut != NULL) { 456 if (range != NULL) { 457 _lut->SetRange(range); 458 } else if (mode == COLOR_BY_ELEMENTS) { 459 double range[2]; 460 range[0] = 0; 461 range[1] = NUM_ELEMENTS; 462 _lut->SetRange(range); 463 } else if (name != NULL && strlen(name) > 0) { 464 double r[2]; 465 int comp = -1; 466 if (mode == COLOR_BY_VECTOR_X) 467 comp = 0; 468 else if (mode == COLOR_BY_VECTOR_Y) 469 comp = 1; 470 else if (mode == COLOR_BY_VECTOR_Z) 471 comp = 2; 472 473 if (_renderer->getUseCumulativeRange()) { 474 int numComponents; 475 if (!_dataSet->getFieldInfo(name, type, &numComponents)) { 476 ERROR("Field not found: %s, type: %d", name, type); 477 return; 478 } else if (numComponents < comp+1) { 479 ERROR("Request for component %d in field with %d components", 480 comp, numComponents); 481 return; 482 } 483 _renderer->getCumulativeDataRange(r, name, type, numComponents, comp); 484 } else { 485 _dataSet->getDataRange(r, name, type, comp); 486 } 487 _lut->SetRange(r); 488 } 489 } 490 491 switch (mode) { 492 case COLOR_BY_ELEMENTS: 493 if (_atomMapper != NULL) 494 _atomMapper->ScalarVisibilityOn(); 495 if (_bondMapper != NULL) 496 _bondMapper->ScalarVisibilityOn(); 497 break; 498 case COLOR_BY_SCALAR: 499 if (_atomMapper != NULL) 500 _atomMapper->ScalarVisibilityOn(); 501 if (_bondMapper != NULL) 502 _bondMapper->ScalarVisibilityOn(); 503 break; 504 case COLOR_BY_VECTOR_MAGNITUDE: 505 if (_atomMapper != NULL) 506 _atomMapper->ScalarVisibilityOn(); 507 if (_bondMapper != NULL) 508 _bondMapper->ScalarVisibilityOn(); 509 if (_lut != NULL) { 510 _lut->SetVectorModeToMagnitude(); 511 } 512 break; 513 case COLOR_BY_VECTOR_X: 514 if (_atomMapper != NULL) 515 _atomMapper->ScalarVisibilityOn(); 516 if (_bondMapper != NULL) 517 _bondMapper->ScalarVisibilityOn(); 518 if (_lut != NULL) { 519 _lut->SetVectorModeToComponent(); 520 _lut->SetVectorComponent(0); 521 } 522 break; 523 case COLOR_BY_VECTOR_Y: 524 if (_atomMapper != NULL) 525 _atomMapper->ScalarVisibilityOn(); 526 if (_bondMapper != NULL) 527 _bondMapper->ScalarVisibilityOn(); 528 if (_lut != NULL) { 529 _lut->SetVectorModeToComponent(); 530 _lut->SetVectorComponent(1); 531 } 532 break; 533 case COLOR_BY_VECTOR_Z: 534 if (_atomMapper != NULL) 535 _atomMapper->ScalarVisibilityOn(); 536 if (_bondMapper != NULL) 537 _bondMapper->ScalarVisibilityOn(); 538 if (_lut != NULL) { 539 _lut->SetVectorModeToComponent(); 540 _lut->SetVectorComponent(2); 541 } 542 break; 543 case COLOR_CONSTANT: 544 default: 545 if (_atomMapper != NULL) 546 _atomMapper->ScalarVisibilityOff(); 547 if (_bondMapper != NULL) 548 _bondMapper->ScalarVisibilityOff(); 549 break; 182 550 } 183 551 } … … 211 579 _bondMapper->SetLookupTable(_lut); 212 580 } 213 } 214 215 _lut->DeepCopy(cmap->getLookupTable()); 216 _lut->Modified(); 217 218 // Element color maps need to retain their range 219 // Only set LUT range if we are not coloring by element 220 vtkDataSet *ds = _dataSet->getVtkDataSet(); 221 if (ds == NULL) 222 return; 223 if (ds->GetPointData() == NULL || 224 ds->GetPointData()->GetScalars() == NULL || 225 strcmp(ds->GetPointData()->GetScalars()->GetName(), "element") != 0) { 226 _lut->SetRange(_dataRange); 581 _lut->DeepCopy(cmap->getLookupTable()); 582 switch (_colorMode) { 583 case COLOR_BY_ELEMENTS: { 584 double range[2]; 585 range[0] = 0; 586 range[1] = NUM_ELEMENTS; 587 _lut->SetRange(range); 588 } 589 break; 590 case COLOR_CONSTANT: 591 case COLOR_BY_SCALAR: 592 _lut->SetRange(_dataRange); 593 break; 594 case COLOR_BY_VECTOR_MAGNITUDE: 595 _lut->SetRange(_vectorMagnitudeRange); 596 break; 597 case COLOR_BY_VECTOR_X: 598 _lut->SetRange(_vectorComponentRange[0]); 599 break; 600 case COLOR_BY_VECTOR_Y: 601 _lut->SetRange(_vectorComponentRange[1]); 602 break; 603 case COLOR_BY_VECTOR_Z: 604 _lut->SetRange(_vectorComponentRange[2]); 605 break; 606 default: 607 break; 608 } 609 } else { 610 double range[2]; 611 _lut->GetTableRange(range); 612 _lut->DeepCopy(cmap->getLookupTable()); 613 _lut->SetRange(range); 614 } 615 } 616 617 /** 618 * \brief Turn on/off rendering of atom labels 619 */ 620 void Molecule::setAtomLabelVisibility(bool state) 621 { 622 _labelsOn = state; 623 if (_labelProp != NULL) { 624 _labelProp->SetVisibility((state ? 1 : 0)); 227 625 } 228 626 } … … 245 643 if (_bondProp != NULL) { 246 644 _bondProp->SetVisibility((state ? 1 : 0)); 645 } 646 } 647 648 /** 649 * \brief Toggle visibility of the prop 650 */ 651 void Molecule::setVisibility(bool state) 652 { 653 VtkGraphicsObject::setVisibility(state); 654 if (_labelProp != NULL) { 655 if (!state) 656 _labelProp->SetVisibility(0); 657 else 658 setAtomLabelVisibility(_labelsOn); 659 } 660 } 661 662 /** 663 * \brief Set opacity of molecule 664 */ 665 void Molecule::setOpacity(double opacity) 666 { 667 VtkGraphicsObject::setOpacity(opacity); 668 if (_labelMapper != NULL) { 669 _labelMapper->SetBackgroundOpacity(opacity); 670 } 671 } 672 673 void Molecule::setBondStyle(BondStyle style) 674 { 675 #ifdef MOLECULE_USE_GLYPH3D_MAPPER 676 switch (style) { 677 case BOND_STYLE_CYLINDER: 678 if (_bondProp != NULL) { 679 _bondProp->GetProperty()->SetLineWidth(_edgeWidth); 680 _bondProp->GetProperty()->SetLighting(_lighting ? 1 : 0); 681 } 682 if (_bondMapper != NULL && _cylinderTrans != NULL) { 683 _cylinderTrans->Modified(); 684 _bondMapper->SetSourceConnection(_cylinderTrans->GetOutputPort()); 685 _bondMapper->Modified(); 686 } 687 break; 688 case BOND_STYLE_LINE: 689 if (_bondProp != NULL) { 690 _bondProp->GetProperty()->LightingOff(); 691 } 692 if (_bondMapper != NULL && _lineSource != NULL) { 693 _lineSource->Modified(); 694 _bondMapper->SetSourceConnection(_lineSource->GetOutputPort()); 695 _bondMapper->Modified(); 696 } 697 break; 698 default: 699 WARN("Unknown bond style"); 700 } 701 #endif 702 } 703 704 /** 705 * \brief Set constant bond color 706 */ 707 void Molecule::setBondColor(float color[3]) 708 { 709 _bondColor[0] = color[0]; 710 _bondColor[1] = color[1]; 711 _bondColor[2] = color[2]; 712 if (_bondProp != NULL) { 713 _bondProp->GetProperty()->SetColor(_bondColor[0], _bondColor[1], _bondColor[2]); 714 } 715 } 716 717 /** 718 * \brief Set mode to determine how bonds are colored 719 */ 720 void Molecule::setBondColorMode(BondColorMode mode) 721 { 722 if (_bondMapper == NULL) return; 723 724 switch (mode) { 725 case BOND_COLOR_BY_ELEMENTS: 726 _bondMapper->ScalarVisibilityOn(); 727 break; 728 case BOND_COLOR_CONSTANT: 729 _bondMapper->ScalarVisibilityOff(); 730 break; 731 default: 732 WARN("Unknown bond color mode"); 247 733 } 248 734 } … … 271 757 if (_dataSet != NULL) { 272 758 vtkDataSet *ds = _dataSet->getVtkDataSet(); 273 addRadiusArray(ds, _atomScaling); 759 addRadiusArray(ds, _atomScaling, _radiusScale); 760 #ifndef MOLECULE_USE_GLYPH3D_MAPPER 274 761 if (_glypher != NULL) { 275 if (_atomScaling != NO_ATOM_SCALING && 276 ds->GetPointData() != NULL && 277 ds->GetPointData()->GetVectors() != NULL) { 278 _glypher->SetScaleModeToScaleByVector(); 279 _glypher->ScalingOn(); 280 } else { 281 _glypher->SetScaleModeToDataScalingOff(); 282 _glypher->ScalingOff(); 283 } 284 } 285 } 762 assert(ds->GetPointData() != NULL && 763 ds->GetPointData()->GetVectors() != NULL); 764 _glypher->SetScaleModeToScaleByVector(); 765 _glypher->ScalingOn(); 766 } 767 #else 768 if (_atomMapper != NULL) { 769 assert(ds->GetPointData() != NULL && 770 ds->GetPointData()->GetVectors() != NULL); 771 _atomMapper->SetScaleModeToScaleByMagnitude(); 772 _atomMapper->SetScaleArray(vtkDataSetAttributes::VECTORS); 773 _atomMapper->ScalingOn(); 774 } 775 #endif 776 } 777 } 778 779 /** 780 * \brief Set the constant radius scaling factor for atoms. This 781 * can be used to convert from Angstroms to atom coordinates units. 782 */ 783 void Molecule::setAtomRadiusScale(double scale) 784 { 785 _radiusScale = scale; 786 if (_dataSet != NULL) { 787 vtkDataSet *ds = _dataSet->getVtkDataSet(); 788 addRadiusArray(ds, _atomScaling, _radiusScale); 789 } 790 } 791 792 /** 793 * \brief Set the constant radius scaling factor for bonds. 794 */ 795 void Molecule::setBondRadiusScale(double scale) 796 { 797 #ifndef MOLECULE_USE_GLYPH3D_MAPPER 798 if (_tuber != NULL) { 799 _tuber->SetRadius(scale); 800 } 801 #else 802 if (_cylinderSource != NULL) { 803 _cylinderSource->SetRadius(scale); 804 // Workaround bug with source modification not causing 805 // mapper to be updated 806 if (_bondMapper != NULL) { 807 _bondMapper->Modified(); 808 } 809 } 810 #endif 811 } 812 813 #ifdef MOLECULE_USE_GLYPH3D_MAPPER 814 void Molecule::setupBondPolyData() 815 { 816 if (_dataSet == NULL) 817 return; 818 if (_bondPD == NULL) { 819 _bondPD = vtkSmartPointer<vtkPolyData>::New(); 820 } else { 821 _bondPD->Initialize(); 822 } 823 vtkPolyData *pd = vtkPolyData::SafeDownCast(_dataSet->getVtkDataSet()); 824 if (pd == NULL) 825 return; 826 vtkCellArray *lines = pd->GetLines(); 827 lines->InitTraversal(); 828 vtkIdType npts, *pts; 829 vtkSmartPointer<vtkPoints> bondPoints = vtkSmartPointer<vtkPoints>::New(); 830 vtkSmartPointer<vtkIntArray> bondElements = vtkSmartPointer<vtkIntArray>::New(); 831 vtkSmartPointer<vtkDoubleArray> bondVectors = vtkSmartPointer<vtkDoubleArray>::New(); 832 vtkSmartPointer<vtkDoubleArray> bondScales = vtkSmartPointer<vtkDoubleArray>::New(); 833 bondElements->SetName("element"); 834 bondVectors->SetName("bond_orientations"); 835 bondVectors->SetNumberOfComponents(3); 836 bondScales->SetName("bond_scales"); 837 bondScales->SetNumberOfComponents(3); 838 vtkDataArray *elements = NULL; 839 if (pd->GetPointData() != NULL && 840 pd->GetPointData()->GetScalars() != NULL && 841 strcmp(pd->GetPointData()->GetScalars()->GetName(), "element") == 0) { 842 elements = pd->GetPointData()->GetScalars(); 843 } 844 for (int i = 0; lines->GetNextCell(npts, pts); i++) { 845 assert(npts == 2); 846 double pt0[3], pt1[3]; 847 double newPt0[3], newPt1[3]; 848 //double *pt0 = pd->GetPoint(pts[0]); 849 //double *pt1 = pd->GetPoint(pts[1]); 850 pd->GetPoint(pts[0], pt0); 851 pd->GetPoint(pts[1], pt1); 852 double center[3]; 853 854 for (int j = 0; j < 3; j++) 855 center[j] = pt0[j] + (pt1[j] - pt0[j]) * 0.5; 856 for (int j = 0; j < 3; j++) 857 newPt0[j] = pt0[j] + (pt1[j] - pt0[j]) * 0.25; 858 for (int j = 0; j < 3; j++) 859 newPt1[j] = pt0[j] + (pt1[j] - pt0[j]) * 0.75; 860 861 bondPoints->InsertNextPoint(newPt0); 862 bondPoints->InsertNextPoint(newPt1); 863 864 TRACE("Bond %d: (%g,%g,%g)-(%g,%g,%g)-(%g,%g,%g)", i, 865 pt0[0], pt0[1], pt0[2], 866 center[0], center[1], center[2], 867 pt1[0], pt1[1], pt1[2]); 868 869 double vec[3]; 870 for (int j = 0; j < 3; j++) 871 vec[j] = center[j] - pt0[j]; 872 873 bondVectors->InsertNextTupleValue(vec); 874 bondVectors->InsertNextTupleValue(vec); 875 TRACE("Bond %d, vec: %g,%g,%g", i, vec[0], vec[1], vec[2]); 876 877 double scale[3]; 878 scale[0] = sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]); 879 scale[1] = 1.0; 880 scale[2] = 1.0; 881 882 bondScales->InsertNextTupleValue(scale); 883 bondScales->InsertNextTupleValue(scale); 884 885 if (elements != NULL) { 886 int element = (int)elements->GetComponent(pts[0], 0); 887 TRACE("Bond %d, elt 0: %d", i, element); 888 bondElements->InsertNextValue(element); 889 element = (int)elements->GetComponent(pts[1], 0); 890 TRACE("Bond %d, elt 1: %d", i, element); 891 bondElements->InsertNextValue(element); 892 } 893 } 894 _bondPD->SetPoints(bondPoints); 895 if (elements != NULL) 896 _bondPD->GetPointData()->SetScalars(bondElements); 897 _bondPD->GetPointData()->AddArray(bondVectors); 898 _bondPD->GetPointData()->AddArray(bondScales); 899 } 900 #endif 901 902 void Molecule::addLabelArray(vtkDataSet *dataSet) 903 { 904 vtkDataArray *elements = NULL; 905 if (dataSet->GetPointData() != NULL && 906 dataSet->GetPointData()->GetScalars() != NULL && 907 strcmp(dataSet->GetPointData()->GetScalars()->GetName(), "element") == 0) { 908 elements = dataSet->GetPointData()->GetScalars(); 909 } else { 910 WARN("Can't label atoms without an element array"); 911 } 912 913 vtkSmartPointer<vtkStringArray> labelArray = vtkSmartPointer<vtkStringArray>::New(); 914 labelArray->SetName("labels"); 915 vtkPolyData *pd = vtkPolyData::SafeDownCast(dataSet); 916 if (pd == NULL) { 917 ERROR("DataSet not a PolyData"); 918 return; 919 } 920 for (int i = 0; i < pd->GetNumberOfVerts(); i++) { 921 char buf[32]; 922 if (elements != NULL) { 923 int elt = (int)elements->GetComponent(i, 0); 924 sprintf(buf, "%s%d", g_elementNames[elt], i); 925 } else { 926 sprintf(buf, "%d", i); 927 } 928 labelArray->InsertNextValue(buf); 929 } 930 dataSet->GetPointData()->AddArray(labelArray); 286 931 } 287 932 … … 290 935 * specified in the "element" scalar array 291 936 */ 292 void Molecule::addRadiusArray(vtkDataSet *dataSet, AtomScaling scaling )293 { 294 if (dataSet->GetPointData() == NULL ||295 dataSet->GetPointData()->GetScalars() == NULL) {296 return;297 }298 vtkDataArray *elements = dataSet->GetPointData()->GetScalars();299 if (strcmp(elements->GetName(), "element") != 0) {300 return;937 void Molecule::addRadiusArray(vtkDataSet *dataSet, AtomScaling scaling, double scaleFactor) 938 { 939 vtkDataArray *elements = NULL; 940 if (dataSet->GetPointData() != NULL && 941 dataSet->GetPointData()->GetScalars() != NULL && 942 strcmp(dataSet->GetPointData()->GetScalars()->GetName(), "element") == 0) { 943 elements = dataSet->GetPointData()->GetScalars(); 944 } else if (scaling != NO_ATOM_SCALING) { 945 WARN("Can't use non-constant scaling without an element array"); 301 946 } 302 947 const float *radiusSource = NULL; … … 313 958 case NO_ATOM_SCALING: 314 959 default: 315 return;960 ; 316 961 } 317 962 vtkSmartPointer<vtkFloatArray> radii = vtkSmartPointer<vtkFloatArray>::New(); 318 963 radii->SetName("radius"); 319 964 radii->SetNumberOfComponents(3); 320 for (int i = 0; i < elements->GetNumberOfTuples(); i++) { 321 int elt = (int)elements->GetComponent(i, 0); 965 vtkPolyData *pd = vtkPolyData::SafeDownCast(dataSet); 966 if (pd == NULL) { 967 ERROR("DataSet not a PolyData"); 968 return; 969 } 970 for (int i = 0; i < pd->GetNumberOfVerts(); i++) { 322 971 float tuple[3]; 323 tuple[0] = radiusSource[elt]; 324 tuple[1] = 0; 325 tuple[2] = 0; 972 tuple[1] = tuple[2] = 0; 973 if (elements != NULL && radiusSource != NULL) { 974 int elt = (int)elements->GetComponent(i, 0); 975 tuple[0] = radiusSource[elt] * scaleFactor; 976 } else { 977 tuple[0] = scaleFactor; 978 } 326 979 radii->InsertNextTupleValue(tuple); 327 980 } … … 339 992 elementCmap->setNumberOfTableEntries(NUM_ELEMENTS+1); 340 993 for (int i = 0; i <= NUM_ELEMENTS; i++) { 341 cp[i].value = i/((double) (NUM_ELEMENTS+1));994 cp[i].value = i/((double)NUM_ELEMENTS); 342 995 for (int c = 0; c < 3; c++) { 343 996 cp[i].color[c] = ((double)g_elementColors[i][c])/255.; … … 355 1008 double range[2]; 356 1009 range[0] = 0; 357 range[1] = NUM_ELEMENTS +1;1010 range[1] = NUM_ELEMENTS; 358 1011 elementCmap->getLookupTable()->SetRange(range); 359 1012 -
branches/nanovis2/packages/vizservers/vtkvis/RpMolecule.h
r2612 r3175 13 13 #include <vtkPolyDataMapper.h> 14 14 #include <vtkActor.h> 15 #include <vtkActor2D.h> 15 16 #include <vtkAssembly.h> 17 #if ((VTK_MAJOR_VERSION > 5) || (VTK_MAJOR_VERSION == 5 && VTK_MINOR_VERSION >= 8)) 18 #define MOLECULE_USE_GLYPH3D_MAPPER 19 #include <vtkGlyph3DMapper.h> 20 #include <vtkTransformPolyDataFilter.h> 21 #include <vtkCylinderSource.h> 22 #include <vtkLineSource.h> 23 #else 16 24 #include <vtkGlyph3D.h> 25 #include <vtkTubeFilter.h> 26 #endif 27 #include <vtkLabelPlacementMapper.h> 17 28 18 29 #include "ColorMap.h" … … 41 52 ATOMIC_RADIUS 42 53 }; 54 enum BondStyle { 55 BOND_STYLE_CYLINDER, 56 BOND_STYLE_LINE 57 }; 58 enum ColorMode { 59 COLOR_BY_ELEMENTS, 60 COLOR_BY_SCALAR, 61 COLOR_BY_VECTOR_MAGNITUDE, 62 COLOR_BY_VECTOR_X, 63 COLOR_BY_VECTOR_Y, 64 COLOR_BY_VECTOR_Z, 65 COLOR_CONSTANT 66 }; 67 enum BondColorMode { 68 BOND_COLOR_BY_ELEMENTS, 69 BOND_COLOR_CONSTANT 70 }; 43 71 44 72 Molecule(); … … 50 78 } 51 79 80 virtual vtkProp *getOverlayProp() 81 { 82 return _labelProp; 83 } 84 85 virtual void setDataSet(DataSet *dataSet, 86 Renderer *renderer); 87 52 88 virtual void setClippingPlanes(vtkPlaneCollection *planes); 89 90 void setColorMode(ColorMode mode, DataSet::DataAttributeType type, 91 const char *name, double range[2] = NULL); 92 93 void setColorMode(ColorMode mode, 94 const char *name, double range[2] = NULL); 95 96 void setColorMode(ColorMode mode); 53 97 54 98 void setColorMap(ColorMap *colorMap); … … 68 112 void setAtomScaling(AtomScaling state); 69 113 114 void setAtomRadiusScale(double scale); 115 116 void setBondRadiusScale(double scale); 117 118 virtual void setVisibility(bool state); 119 120 virtual void setOpacity(double opacity); 121 70 122 void setAtomVisibility(bool state); 71 123 124 void setAtomLabelVisibility(bool state); 125 72 126 void setBondVisibility(bool state); 127 128 void setBondStyle(BondStyle style); 129 130 void setBondColor(float color[3]); 131 132 void setBondColorMode(BondColorMode mode); 73 133 74 134 static ColorMap *createElementColorMap(); … … 78 138 virtual void update(); 79 139 80 static void addRadiusArray(vtkDataSet *dataSet, AtomScaling scaling); 140 #ifdef MOLECULE_USE_GLYPH3D_MAPPER 141 void setupBondPolyData(); 142 #endif 81 143 144 static void addLabelArray(vtkDataSet *dataSet); 145 146 static void addRadiusArray(vtkDataSet *dataSet, AtomScaling scaling, double scaleFactor); 147 148 float _bondColor[3]; 149 double _radiusScale; 82 150 AtomScaling _atomScaling; 151 bool _labelsOn; 83 152 ColorMap *_colorMap; 153 ColorMode _colorMode; 154 std::string _colorFieldName; 155 DataSet::DataAttributeType _colorFieldType; 156 double _colorFieldRange[2]; 157 double _vectorMagnitudeRange[2]; 158 double _vectorComponentRange[3][2]; 159 Renderer *_renderer; 84 160 85 161 vtkSmartPointer<vtkLookupTable> _lut; 86 162 vtkSmartPointer<vtkActor> _atomProp; 87 163 vtkSmartPointer<vtkActor> _bondProp; 164 vtkSmartPointer<vtkActor2D> _labelProp; 165 #ifndef MOLECULE_USE_GLYPH3D_MAPPER 88 166 vtkSmartPointer<vtkGlyph3D> _glypher; 167 vtkSmartPointer<vtkTubeFilter> _tuber; 89 168 vtkSmartPointer<vtkPolyDataMapper> _atomMapper; 90 169 vtkSmartPointer<vtkPolyDataMapper> _bondMapper; 170 #else 171 vtkSmartPointer<vtkPolyData> _bondPD; 172 vtkSmartPointer<vtkCylinderSource> _cylinderSource; 173 vtkSmartPointer<vtkTransformPolyDataFilter>_cylinderTrans; 174 vtkSmartPointer<vtkLineSource> _lineSource; 175 vtkSmartPointer<vtkGlyph3DMapper> _atomMapper; 176 vtkSmartPointer<vtkGlyph3DMapper> _bondMapper; 177 #endif 178 vtkSmartPointer<vtkLabelPlacementMapper> _labelMapper; 91 179 }; 92 180 -
branches/nanovis2/packages/vizservers/vtkvis/RpMoleculeData.h
r2321 r3175 464 464 1.700f, // 109 Mt 465 465 }; 466 467 const char * g_elementNames[NUM_ELEMENTS+1] = { 468 "?", // 0 ? 469 "H", // 1 H 470 "He", // 2 He 471 "Li", // 3 Li 472 "Be", // 4 Be 473 "B", // 5 B 474 "C", // 6 C 475 "N", // 7 N 476 "O", // 8 O 477 "F", // 9 F 478 "Ne", // 10 Ne 479 "Na", // 11 Na 480 "Mg", // 12 Mg 481 "Al", // 13 Al 482 "Si", // 14 Si 483 "P", // 15 P 484 "S", // 16 S 485 "Cl", // 17 Cl 486 "Ar", // 18 Ar 487 "K", // 19 K 488 "Ca", // 20 Ca 489 "Sc", // 21 Sc 490 "Ti", // 22 Ti 491 "V", // 23 V 492 "Cr", // 24 Cr 493 "Mn", // 25 Mn 494 "Fe", // 26 Fe 495 "Co", // 27 Co 496 "Ni", // 28 Ni 497 "Cu", // 29 Cu 498 "Zn", // 30 Zn 499 "Ga", // 31 Ga 500 "Ge", // 32 Ge 501 "As", // 33 As 502 "Se", // 34 Se 503 "Br", // 35 Br 504 "Kr", // 36 Kr 505 "Rb", // 37 Rb 506 "Sr", // 38 Sr 507 "Y", // 39 Y 508 "Zr", // 40 Zr 509 "Nb", // 41 Nb 510 "Mo", // 42 Mo 511 "Tc", // 43 Tc 512 "Ru", // 44 Ru 513 "Rh", // 45 Rh 514 "Pd", // 46 Pd 515 "Ag", // 47 Ag 516 "Cd", // 48 Cd 517 "In", // 49 In 518 "Sn", // 50 Sn 519 "Sb", // 51 Sb 520 "Te", // 52 Te 521 "I", // 53 I 522 "Xe", // 54 Xe 523 "Cs", // 55 Cs 524 "Ba", // 56 Ba 525 "La", // 57 La 526 "Ce", // 58 Ce 527 "Pr", // 59 Pr 528 "Nd", // 60 Nd 529 "Pm", // 61 Pm 530 "Sm", // 62 Sm 531 "Eu", // 63 Eu 532 "Gd", // 64 Gd 533 "Tb", // 65 Tb 534 "Dy", // 66 Dy 535 "Ho", // 67 Ho 536 "Er", // 68 Er 537 "Tm", // 69 Tm 538 "Yb", // 70 Yb 539 "Lu", // 71 Lu 540 "Hf", // 72 Hf 541 "Ta", // 73 Ta 542 "W", // 74 W 543 "Re", // 75 Re 544 "Os", // 76 Os 545 "Ir", // 77 Ir 546 "Pt", // 78 Pt 547 "Au", // 79 Au 548 "Hg", // 80 Hg 549 "Tl", // 81 Tl 550 "Pb", // 82 Pb 551 "Bi", // 83 Bi 552 "Po", // 84 Po 553 "At", // 85 At 554 "Rn", // 86 Rn 555 "Fr", // 87 Fr 556 "Ra", // 88 Ra 557 "Ac", // 89 Ac 558 "Th", // 90 Th 559 "Pa", // 91 Pa 560 "U", // 92 U 561 "Np", // 93 Np 562 "Pu", // 94 Pu 563 "Am", // 95 Am 564 "Cm", // 96 Cm 565 "Bk", // 97 Bk 566 "Cf", // 98 Cf 567 "Es", // 99 Es 568 "Fm", // 100 Fm 569 "Md", // 101 Md 570 "No", // 102 No 571 "Lr", // 103 Lr 572 "Rf", // 104 Rf 573 "Db", // 105 Db 574 "Sg", // 106 Sg 575 "Bh", // 107 Bh 576 "Hs", // 108 Hs 577 "Mt", // 109 Mt 578 }; -
branches/nanovis2/packages/vizservers/vtkvis/RpPolyData.cpp
r2641 r3175 27 27 VtkGraphicsObject() 28 28 { 29 _color[0] = 0.0f;30 _color[1] = 0.0f;31 _color[2] = 1.0f;32 29 } 33 30 -
branches/nanovis2/packages/vizservers/vtkvis/RpVtkDataSet.cpp
r2639 r3175 13 13 #include <vtkCharArray.h> 14 14 #include <vtkDataSetReader.h> 15 #include <vtkDataSetWriter.h> 15 16 #include <vtkPolyData.h> 16 17 #include <vtkStructuredPoints.h> … … 140 141 } 141 142 143 void DataSet::writeDataFile(const char *filename) 144 { 145 if (_dataSet == NULL) 146 return; 147 148 vtkSmartPointer<vtkDataSetWriter> writer = vtkSmartPointer<vtkDataSetWriter>::New(); 149 150 writer->SetFileName(filename); 151 writer->SetInput(_dataSet); 152 writer->Write(); 153 } 154 142 155 /** 143 156 * \brief Read a VTK data file … … 192 205 void DataSet::print() const 193 206 { 194 TRACE("DataSet class: %s", _dataSet->GetClassName()); 195 196 TRACE("DataSet memory: %g MiB", _dataSet->GetActualMemorySize()/1024.); 207 print(_dataSet); 208 } 209 210 void DataSet::print(vtkDataSet *ds) 211 { 212 if (ds == NULL) 213 return; 214 215 TRACE("DataSet class: %s", ds->GetClassName()); 216 217 TRACE("DataSet memory: %g MiB", ds->GetActualMemorySize()/1024.); 197 218 198 219 double bounds[6]; 199 getBounds(bounds);220 ds->GetBounds(bounds); 200 221 201 222 // Topology … … 204 225 bounds[2], bounds[3], 205 226 bounds[4], bounds[5]); 206 TRACE("Points: %d Cells: %d", _dataSet->GetNumberOfPoints(), _dataSet->GetNumberOfCells());227 TRACE("Points: %d Cells: %d", ds->GetNumberOfPoints(), ds->GetNumberOfCells()); 207 228 208 229 double dataRange[2]; 209 if (_dataSet->GetPointData() != NULL) { 210 TRACE("PointData arrays: %d", _dataSet->GetPointData()->GetNumberOfArrays()); 211 for (int i = 0; i < _dataSet->GetPointData()->GetNumberOfArrays(); i++) { 212 _dataSet->GetPointData()->GetArray(i)->GetRange(dataRange, -1); 213 TRACE("PointData[%d]: '%s' comp:%d, (%g,%g)", i, 214 _dataSet->GetPointData()->GetArrayName(i), 215 _dataSet->GetPointData()->GetArray(i)->GetNumberOfComponents(), 216 dataRange[0], dataRange[1]); 217 } 218 } 219 if (_dataSet->GetCellData() != NULL) { 220 TRACE("CellData arrays: %d", _dataSet->GetCellData()->GetNumberOfArrays()); 221 for (int i = 0; i < _dataSet->GetCellData()->GetNumberOfArrays(); i++) { 222 _dataSet->GetCellData()->GetArray(i)->GetRange(dataRange, -1); 223 TRACE("CellData[%d]: '%s' comp:%d, (%g,%g)", i, 224 _dataSet->GetCellData()->GetArrayName(i), 225 _dataSet->GetCellData()->GetArray(i)->GetNumberOfComponents(), 226 dataRange[0], dataRange[1]); 227 } 228 } 229 if (_dataSet->GetFieldData() != NULL) { 230 TRACE("FieldData arrays: %d", _dataSet->GetFieldData()->GetNumberOfArrays()); 231 for (int i = 0; i < _dataSet->GetFieldData()->GetNumberOfArrays(); i++) { 232 _dataSet->GetFieldData()->GetArray(i)->GetRange(dataRange, -1); 233 TRACE("FieldData[%d]: '%s' comp:%d, tuples:%d (%g,%g)", i, 234 _dataSet->GetFieldData()->GetArrayName(i), 235 _dataSet->GetFieldData()->GetArray(i)->GetNumberOfComponents(), 236 _dataSet->GetFieldData()->GetArray(i)->GetNumberOfTuples(), 237 dataRange[0], dataRange[1]); 230 if (ds->GetPointData() != NULL) { 231 TRACE("PointData arrays: %d", ds->GetPointData()->GetNumberOfArrays()); 232 for (int i = 0; i < ds->GetPointData()->GetNumberOfArrays(); i++) { 233 if (ds->GetPointData()->GetArray(i) != NULL) { 234 ds->GetPointData()->GetArray(i)->GetRange(dataRange, -1); 235 TRACE("PointData[%d]: '%s' comp:%d, (%g,%g)", i, 236 ds->GetPointData()->GetArrayName(i), 237 ds->GetPointData()->GetAbstractArray(i)->GetNumberOfComponents(), 238 dataRange[0], dataRange[1]); 239 } else { 240 TRACE("PointData[%d]: '%s' comp:%d", i, 241 ds->GetPointData()->GetArrayName(i), 242 ds->GetPointData()->GetAbstractArray(i)->GetNumberOfComponents()); 243 } 244 } 245 } 246 if (ds->GetCellData() != NULL) { 247 TRACE("CellData arrays: %d", ds->GetCellData()->GetNumberOfArrays()); 248 for (int i = 0; i < ds->GetCellData()->GetNumberOfArrays(); i++) { 249 if (ds->GetCellData()->GetArray(i) != NULL) { 250 ds->GetCellData()->GetArray(i)->GetRange(dataRange, -1); 251 TRACE("CellData[%d]: '%s' comp:%d, (%g,%g)", i, 252 ds->GetCellData()->GetArrayName(i), 253 ds->GetCellData()->GetAbstractArray(i)->GetNumberOfComponents(), 254 dataRange[0], dataRange[1]); 255 } else { 256 TRACE("CellData[%d]: '%s' comp:%d", i, 257 ds->GetCellData()->GetArrayName(i), 258 ds->GetCellData()->GetAbstractArray(i)->GetNumberOfComponents()); 259 } 260 } 261 } 262 if (ds->GetFieldData() != NULL) { 263 TRACE("FieldData arrays: %d", ds->GetFieldData()->GetNumberOfArrays()); 264 for (int i = 0; i < ds->GetFieldData()->GetNumberOfArrays(); i++) { 265 if (ds->GetFieldData()->GetArray(i) != NULL) { 266 ds->GetFieldData()->GetArray(i)->GetRange(dataRange, -1); 267 TRACE("FieldData[%d]: '%s' comp:%d, tuples:%d (%g,%g)", i, 268 ds->GetFieldData()->GetArrayName(i), 269 ds->GetFieldData()->GetAbstractArray(i)->GetNumberOfComponents(), 270 ds->GetFieldData()->GetAbstractArray(i)->GetNumberOfTuples(), 271 dataRange[0], dataRange[1]); 272 } else { 273 TRACE("FieldData[%d]: '%s' comp:%d, tuples:%d", i, 274 ds->GetFieldData()->GetArrayName(i), 275 ds->GetFieldData()->GetAbstractArray(i)->GetNumberOfComponents(), 276 ds->GetFieldData()->GetAbstractArray(i)->GetNumberOfTuples()); 277 } 238 278 } 239 279 } … … 246 286 _dataSet->GetPointData()->GetNumberOfArrays() > 0) { 247 287 for (int i = 0; i < _dataSet->GetPointData()->GetNumberOfArrays(); i++) { 248 if (_dataSet->GetPointData()->GetArray(i)->GetNumberOfComponents() == 1) { 288 if (_dataSet->GetPointData()->GetArray(i) != NULL && 289 _dataSet->GetPointData()->GetArray(i)->GetNumberOfComponents() == 1) { 249 290 TRACE("Setting point scalars to '%s'", _dataSet->GetPointData()->GetArrayName(i)); 250 291 _dataSet->GetPointData()->SetActiveScalars(_dataSet->GetPointData()->GetArrayName(i)); … … 257 298 _dataSet->GetPointData()->GetNumberOfArrays() > 0) { 258 299 for (int i = 0; i < _dataSet->GetPointData()->GetNumberOfArrays(); i++) { 259 if (_dataSet->GetPointData()->GetArray(i)->GetNumberOfComponents() == 3) { 300 if (_dataSet->GetPointData()->GetArray(i) != NULL && 301 _dataSet->GetPointData()->GetArray(i)->GetNumberOfComponents() == 3) { 260 302 TRACE("Setting point vectors to '%s'", _dataSet->GetPointData()->GetArrayName(i)); 261 303 _dataSet->GetPointData()->SetActiveVectors(_dataSet->GetPointData()->GetArrayName(i)); … … 268 310 _dataSet->GetCellData()->GetNumberOfArrays() > 0) { 269 311 for (int i = 0; i < _dataSet->GetCellData()->GetNumberOfArrays(); i++) { 270 if (_dataSet->GetCellData()->GetArray(i)->GetNumberOfComponents() == 1) { 312 if (_dataSet->GetCellData()->GetArray(i) != NULL && 313 _dataSet->GetCellData()->GetArray(i)->GetNumberOfComponents() == 1) { 271 314 TRACE("Setting cell scalars to '%s'", _dataSet->GetCellData()->GetArrayName(i)); 272 315 _dataSet->GetCellData()->SetActiveScalars(_dataSet->GetCellData()->GetArrayName(i)); … … 279 322 _dataSet->GetCellData()->GetNumberOfArrays() > 0) { 280 323 for (int i = 0; i < _dataSet->GetCellData()->GetNumberOfArrays(); i++) { 281 if (_dataSet->GetCellData()->GetArray(i)->GetNumberOfComponents() == 3) { 324 if (_dataSet->GetCellData()->GetArray(i) != NULL && 325 _dataSet->GetCellData()->GetArray(i)->GetNumberOfComponents() == 3) { 282 326 TRACE("Setting cell vectors to '%s'", _dataSet->GetCellData()->GetArrayName(i)); 283 327 _dataSet->GetCellData()->SetActiveVectors(_dataSet->GetCellData()->GetArrayName(i)); … … 635 679 { 636 680 if (_dataSet->GetPointData() != NULL && 637 _dataSet->GetPointData()->GetA rray(fieldName) != NULL) {681 _dataSet->GetPointData()->GetAbstractArray(fieldName) != NULL) { 638 682 if (type != NULL) 639 683 *type = POINT_DATA; 640 684 if (numComponents != NULL) 641 *numComponents = _dataSet->GetPointData()->GetA rray(fieldName)->GetNumberOfComponents();685 *numComponents = _dataSet->GetPointData()->GetAbstractArray(fieldName)->GetNumberOfComponents(); 642 686 return true; 643 687 } else if (_dataSet->GetCellData() != NULL && 644 _dataSet->GetCellData()->GetA rray(fieldName) != NULL) {688 _dataSet->GetCellData()->GetAbstractArray(fieldName) != NULL) { 645 689 if (type != NULL) 646 690 *type = CELL_DATA; 647 691 if (numComponents != NULL) 648 *numComponents = _dataSet->GetCellData()->GetA rray(fieldName)->GetNumberOfComponents();692 *numComponents = _dataSet->GetCellData()->GetAbstractArray(fieldName)->GetNumberOfComponents(); 649 693 return true; 650 694 } else if (_dataSet->GetFieldData() != NULL && 651 _dataSet->GetFieldData()->GetA rray(fieldName) != NULL) {695 _dataSet->GetFieldData()->GetAbstractArray(fieldName) != NULL) { 652 696 if (type != NULL) 653 697 *type = FIELD_DATA; 654 698 if (numComponents != NULL) 655 *numComponents = _dataSet->GetFieldData()->GetA rray(fieldName)->GetNumberOfComponents();699 *numComponents = _dataSet->GetFieldData()->GetAbstractArray(fieldName)->GetNumberOfComponents(); 656 700 return true; 657 701 } … … 666 710 case POINT_DATA: 667 711 if (_dataSet->GetPointData() != NULL && 668 _dataSet->GetPointData()->GetA rray(fieldName) != NULL) {712 _dataSet->GetPointData()->GetAbstractArray(fieldName) != NULL) { 669 713 if (numComponents != NULL) 670 *numComponents = _dataSet->GetPointData()->GetA rray(fieldName)->GetNumberOfComponents();714 *numComponents = _dataSet->GetPointData()->GetAbstractArray(fieldName)->GetNumberOfComponents(); 671 715 return true; 672 716 } else … … 675 719 case CELL_DATA: 676 720 if (_dataSet->GetCellData() != NULL && 677 _dataSet->GetCellData()->GetA rray(fieldName) != NULL) {721 _dataSet->GetCellData()->GetAbstractArray(fieldName) != NULL) { 678 722 if (numComponents != NULL) 679 *numComponents = _dataSet->GetCellData()->GetA rray(fieldName)->GetNumberOfComponents();723 *numComponents = _dataSet->GetCellData()->GetAbstractArray(fieldName)->GetNumberOfComponents(); 680 724 return true; 681 725 } else … … 684 728 case FIELD_DATA: 685 729 if (_dataSet->GetFieldData() != NULL && 686 _dataSet->GetFieldData()->GetA rray(fieldName) != NULL) {730 _dataSet->GetFieldData()->GetAbstractArray(fieldName) != NULL) { 687 731 if (numComponents != NULL) 688 *numComponents = _dataSet->GetFieldData()->GetA rray(fieldName)->GetNumberOfComponents();732 *numComponents = _dataSet->GetFieldData()->GetAbstractArray(fieldName)->GetNumberOfComponents(); 689 733 return true; 690 734 } else … … 715 759 for (int i = 0; i < _dataSet->GetPointData()->GetNumberOfArrays(); i++) { 716 760 if (numComponents == -1 || 717 _dataSet->GetPointData()->GetArray(i)->GetNumberOfComponents() == numComponents) { 761 (_dataSet->GetPointData()->GetAbstractArray(i) != NULL && 762 _dataSet->GetPointData()->GetAbstractArray(i)->GetNumberOfComponents() == numComponents)) { 718 763 names.push_back(_dataSet->GetPointData()->GetArrayName(i)); 719 764 } … … 725 770 for (int i = 0; i < _dataSet->GetCellData()->GetNumberOfArrays(); i++) { 726 771 if (numComponents == -1 || 727 _dataSet->GetCellData()->GetArray(i)->GetNumberOfComponents() == numComponents) { 772 (_dataSet->GetCellData()->GetAbstractArray(i) != NULL && 773 _dataSet->GetCellData()->GetAbstractArray(i)->GetNumberOfComponents() == numComponents)) { 728 774 names.push_back(_dataSet->GetCellData()->GetArrayName(i)); 729 775 } … … 735 781 for (int i = 0; i < _dataSet->GetFieldData()->GetNumberOfArrays(); i++) { 736 782 if (numComponents == -1 || 737 _dataSet->GetFieldData()->GetArray(i)->GetNumberOfComponents() == numComponents) { 783 (_dataSet->GetFieldData()->GetAbstractArray(i) != NULL && 784 _dataSet->GetFieldData()->GetAbstractArray(i)->GetNumberOfComponents() == numComponents)) { 738 785 names.push_back(_dataSet->GetFieldData()->GetArrayName(i)); 739 786 } -
branches/nanovis2/packages/vizservers/vtkvis/RpVtkDataSet.h
r2640 r3175 37 37 DataSet(const std::string& name); 38 38 virtual ~DataSet(); 39 40 void writeDataFile(const char *filename); 39 41 40 42 bool setDataFile(const char *filename); … … 135 137 } 136 138 139 static void print(vtkDataSet *ds); 140 137 141 private: 138 142 DataSet(); -
branches/nanovis2/packages/vizservers/vtkvis/RpVtkGraphicsObject.cpp
r2641 r3175 18 18 _dataSet = dataSet; 19 19 20 if (renderer->getUseCumulativeRange()) { 20 if (renderer != NULL && 21 dataSet != NULL && 22 renderer->getUseCumulativeRange()) { 21 23 renderer->getCumulativeDataRange(_dataRange, 22 24 _dataSet->getActiveScalarsName(), 23 25 1); 24 } else {26 } else if (_dataSet != NULL) { 25 27 _dataSet->getScalarRange(_dataRange); 26 28 } … … 36 38 return; 37 39 } 40 if (renderer == NULL) { 41 ERROR("NULL renderer"); 42 return; 43 } 38 44 39 45 if (renderer->getUseCumulativeRange()) { … … 41 47 _dataSet->getActiveScalarsName(), 42 48 1); 43 } else 49 } else { 44 50 _dataSet->getScalarRange(_dataRange); 45 51 } -
branches/nanovis2/packages/vizservers/vtkvis/RpVtkGraphicsObject.h
r2771 r3175 72 72 73 73 /** 74 * \brief Specify input DataSet75 *76 * Default implementation calls update()77 *78 * \param[in] dataSet DataSet to use in rendering79 */80 virtual void setDataSet(DataSet *dataSet)81 {82 if (_dataSet != dataSet) {83 _dataSet = dataSet;84 85 update();86 }87 }88 89 /**90 74 * \brief Specify input DataSet and information on cumulative data ranges 91 75 * … … 163 147 { 164 148 return vtkAssembly::SafeDownCast(_prop); 149 } 150 151 virtual vtkProp *getOverlayProp() 152 { 153 return NULL; 165 154 } 166 155 … … 242 231 243 232 /** 233 * \brief Set 2D aspect ratio scaling 234 * 235 * \param aspect 0=no scaling, otherwise aspect 236 * is horiz/vertical ratio 237 */ 238 virtual void setAspect(double aspect) 239 { 240 ; 241 } 242 243 /** 244 244 * \brief Set the prop scaling 245 245 * … … 251 251 getProp3D()->SetScale(scale); 252 252 } 253 } 254 255 /** 256 * \brief Get the physical bounds of the prop 257 * 258 * If the prop is scaled, these bounds will be 259 * scaled as well 260 */ 261 virtual double *getBounds() 262 { 263 if (getProp() != NULL) 264 return getProp()->GetBounds(); 265 else 266 return NULL; 267 } 268 269 /** 270 * \brief Get the data bounds of the prop 271 * 272 * If the prop is scaled, these bounds will NOT 273 * be scaled, they will reflect the unscaled data 274 * bounds. 275 */ 276 virtual double *getUnscaledBounds() 277 { 278 if (getProp3D() != NULL) { 279 double scale[3]; 280 getProp3D()->GetScale(scale); 281 if (scale[0] == scale[1] && scale[1] == scale[2] && 282 scale[0] == 1.0) { 283 return getBounds(); 284 } else if (getBounds() != NULL) { 285 _unscaledBounds[0] = getBounds()[0] / scale[0]; 286 _unscaledBounds[1] = getBounds()[1] / scale[0]; 287 _unscaledBounds[2] = getBounds()[2] / scale[1]; 288 _unscaledBounds[3] = getBounds()[3] / scale[1]; 289 _unscaledBounds[4] = getBounds()[4] / scale[2]; 290 _unscaledBounds[5] = getBounds()[5] / scale[2]; 291 return _unscaledBounds; 292 } 293 } 294 return getBounds(); 253 295 } 254 296 … … 658 700 if (getActor() != NULL) { 659 701 setCulling(getActor()->GetProperty(), state); 660 702 } else if (getAssembly() != NULL) { 661 703 vtkProp3DCollection *props = getAssembly()->GetParts(); 662 704 vtkProp3D *prop; … … 743 785 DataSet *_dataSet; 744 786 double _dataRange[2]; 787 double _unscaledBounds[6]; 745 788 double _opacity; 746 789 float _color[3]; -
branches/nanovis2/packages/vizservers/vtkvis/RpVtkRenderer.cpp
r2865 r3175 24 24 #include <vtkCharArray.h> 25 25 #include <vtkAxisActor2D.h> 26 #include <vtkCubeAxesActor.h>27 26 #ifdef USE_CUSTOM_AXES 27 #include "vtkRpCubeAxesActor.h" 28 28 #include "vtkRpCubeAxesActor2D.h" 29 29 #else 30 #include <vtkCubeAxesActor.h> 30 31 #include <vtkCubeAxesActor2D.h> 31 32 #endif … … 58 59 _windowWidth(500), 59 60 _windowHeight(500), 61 _cameraMode(PERSPECTIVE), 60 62 _imgCameraPlane(PLANE_XY), 61 63 _imgCameraOffset(0), 62 64 _cameraZoomRatio(1), 63 65 _useCumulativeRange(true), 64 _cumulativeRangeOnlyVisible(false), 65 _cameraMode(PERSPECTIVE) 66 _cumulativeRangeOnlyVisible(false) 66 67 { 67 68 _bgColor[0] = 0; … … 141 142 { 142 143 TRACE("Enter"); 143 TRACE("Deleting Contour2Ds"); 144 for (Contour2DHashmap::iterator itr = _contour2Ds.begin(); 145 itr != _contour2Ds.end(); ++itr) { 146 delete itr->second; 147 } 148 _contour2Ds.clear(); 149 TRACE("Deleting Contour3Ds"); 150 for (Contour3DHashmap::iterator itr = _contour3Ds.begin(); 151 itr != _contour3Ds.end(); ++itr) { 152 delete itr->second; 153 } 154 _contour3Ds.clear(); 155 TRACE("Deleting Cutplanes"); 156 for (CutplaneHashmap::iterator itr = _cutplanes.begin(); 157 itr != _cutplanes.end(); ++itr) { 158 delete itr->second; 159 } 160 _cutplanes.clear(); 161 TRACE("Deleting Glyphs"); 162 for (GlyphsHashmap::iterator itr = _glyphs.begin(); 163 itr != _glyphs.end(); ++itr) { 164 delete itr->second; 165 } 166 _glyphs.clear(); 167 TRACE("Deleting HeightMaps"); 168 for (HeightMapHashmap::iterator itr = _heightMaps.begin(); 169 itr != _heightMaps.end(); ++itr) { 170 delete itr->second; 171 } 172 _heightMaps.clear(); 173 TRACE("Deleting LICs"); 174 for (LICHashmap::iterator itr = _lics.begin(); 175 itr != _lics.end(); ++itr) { 176 delete itr->second; 177 } 178 _lics.clear(); 179 TRACE("Deleting Molecules"); 180 for (MoleculeHashmap::iterator itr = _molecules.begin(); 181 itr != _molecules.end(); ++itr) { 182 delete itr->second; 183 } 184 _molecules.clear(); 185 TRACE("Deleting PolyDatas"); 186 for (PolyDataHashmap::iterator itr = _polyDatas.begin(); 187 itr != _polyDatas.end(); ++itr) { 188 delete itr->second; 189 } 190 _polyDatas.clear(); 191 TRACE("Deleting PseudoColors"); 192 for (PseudoColorHashmap::iterator itr = _pseudoColors.begin(); 193 itr != _pseudoColors.end(); ++itr) { 194 delete itr->second; 195 } 196 _pseudoColors.clear(); 197 TRACE("Deleting Streamlines"); 198 for (StreamlinesHashmap::iterator itr = _streamlines.begin(); 199 itr != _streamlines.end(); ++itr) { 200 delete itr->second; 201 } 202 _streamlines.clear(); 203 TRACE("Deleting Volumes"); 204 for (VolumeHashmap::iterator itr = _volumes.begin(); 205 itr != _volumes.end(); ++itr) { 206 delete itr->second; 207 } 208 _volumes.clear(); 144 145 deleteAllGraphicsObjects<Arc>(); 146 deleteAllGraphicsObjects<Arrow>(); 147 deleteAllGraphicsObjects<Box>(); 148 deleteAllGraphicsObjects<Cone>(); 149 deleteAllGraphicsObjects<Contour2D>(); 150 deleteAllGraphicsObjects<Contour3D>(); 151 deleteAllGraphicsObjects<Cutplane>(); 152 deleteAllGraphicsObjects<Cylinder>(); 153 deleteAllGraphicsObjects<Disk>(); 154 deleteAllGraphicsObjects<Glyphs>(); 155 deleteAllGraphicsObjects<Group>(); 156 deleteAllGraphicsObjects<HeightMap>(); 157 deleteAllGraphicsObjects<LIC>(); 158 deleteAllGraphicsObjects<Line>(); 159 deleteAllGraphicsObjects<Molecule>(); 160 deleteAllGraphicsObjects<PolyData>(); 161 deleteAllGraphicsObjects<Polygon>(); 162 deleteAllGraphicsObjects<PseudoColor>(); 163 deleteAllGraphicsObjects<Sphere>(); 164 deleteAllGraphicsObjects<Streamlines>(); 165 deleteAllGraphicsObjects<Volume>(); 166 deleteAllGraphicsObjects<Warp>(); 167 209 168 TRACE("Deleting ColorMaps"); 210 169 // Delete color maps and data sets last in case references still … … 280 239 deleteGraphicsObject<Streamlines>(itr->second->getName()); 281 240 deleteGraphicsObject<Volume>(itr->second->getName()); 241 deleteGraphicsObject<Warp>(itr->second->getName()); 282 242 283 243 if (itr->second->getProp() != NULL) { … … 546 506 547 507 _cubeAxesActor2D->ScalingOff(); 548 //_cubeAxesActor2D->SetShowActualBounds(0);508 _cubeAxesActor2D->SetShowActualBounds(1); 549 509 _cubeAxesActor2D->SetFontFactor(1.25); 550 510 // Use "nice" range and number of ticks/labels … … 878 838 void Renderer::updateColorMap(ColorMap *cmap) 879 839 { 880 for (Contour3DHashmap::iterator itr = _contour3Ds.begin(); 881 itr != _contour3Ds.end(); ++itr) { 882 if (itr->second->getColorMap() == cmap) { 883 itr->second->updateColorMap(); 884 _needsRedraw = true; 885 } 886 } 887 for (CutplaneHashmap::iterator itr = _cutplanes.begin(); 888 itr != _cutplanes.end(); ++itr) { 889 if (itr->second->getColorMap() == cmap) { 890 itr->second->updateColorMap(); 891 _needsRedraw = true; 892 } 893 } 894 for (GlyphsHashmap::iterator itr = _glyphs.begin(); 895 itr != _glyphs.end(); ++itr) { 896 if (itr->second->getColorMap() == cmap) { 897 itr->second->updateColorMap(); 898 _needsRedraw = true; 899 } 900 } 901 for (HeightMapHashmap::iterator itr = _heightMaps.begin(); 902 itr != _heightMaps.end(); ++itr) { 903 if (itr->second->getColorMap() == cmap) { 904 itr->second->updateColorMap(); 905 _needsRedraw = true; 906 } 907 } 908 for (LICHashmap::iterator itr = _lics.begin(); 909 itr != _lics.end(); ++itr) { 910 if (itr->second->getColorMap() == cmap) { 911 itr->second->updateColorMap(); 912 _needsRedraw = true; 913 } 914 } 915 for (MoleculeHashmap::iterator itr = _molecules.begin(); 916 itr != _molecules.end(); ++itr) { 917 if (itr->second->getColorMap() == cmap) { 918 itr->second->updateColorMap(); 919 _needsRedraw = true; 920 } 921 } 922 for (PseudoColorHashmap::iterator itr = _pseudoColors.begin(); 923 itr != _pseudoColors.end(); ++itr) { 924 if (itr->second->getColorMap() == cmap) { 925 itr->second->updateColorMap(); 926 _needsRedraw = true; 927 } 928 } 929 for (StreamlinesHashmap::iterator itr = _streamlines.begin(); 930 itr != _streamlines.end(); ++itr) { 931 if (itr->second->getColorMap() == cmap) { 932 itr->second->updateColorMap(); 933 _needsRedraw = true; 934 } 935 } 936 for (VolumeHashmap::iterator itr = _volumes.begin(); 937 itr != _volumes.end(); ++itr) { 938 if (itr->second->getColorMap() == cmap) { 939 itr->second->updateColorMap(); 940 _needsRedraw = true; 941 } 942 } 840 updateGraphicsObjectColorMap<Contour2D>(cmap); 841 updateGraphicsObjectColorMap<Contour3D>(cmap); 842 updateGraphicsObjectColorMap<Cutplane>(cmap); 843 updateGraphicsObjectColorMap<Glyphs>(cmap); 844 updateGraphicsObjectColorMap<HeightMap>(cmap); 845 updateGraphicsObjectColorMap<LIC>(cmap); 846 updateGraphicsObjectColorMap<Molecule>(cmap); 847 updateGraphicsObjectColorMap<PseudoColor>(cmap); 848 updateGraphicsObjectColorMap<Streamlines>(cmap); 849 updateGraphicsObjectColorMap<Volume>(cmap); 850 updateGraphicsObjectColorMap<Warp>(cmap); 943 851 } 944 852 … … 948 856 bool Renderer::colorMapUsed(ColorMap *cmap) 949 857 { 950 for (Contour3DHashmap::iterator itr = _contour3Ds.begin(); 951 itr != _contour3Ds.end(); ++itr) { 952 if (itr->second->getColorMap() == cmap) 953 return true; 954 } 955 for (CutplaneHashmap::iterator itr = _cutplanes.begin(); 956 itr != _cutplanes.end(); ++itr) { 957 if (itr->second->getColorMap() == cmap) 958 return true; 959 } 960 for (GlyphsHashmap::iterator itr = _glyphs.begin(); 961 itr != _glyphs.end(); ++itr) { 962 if (itr->second->getColorMap() == cmap) 963 return true; 964 } 965 for (HeightMapHashmap::iterator itr = _heightMaps.begin(); 966 itr != _heightMaps.end(); ++itr) { 967 if (itr->second->getColorMap() == cmap) 968 return true; 969 } 970 for (LICHashmap::iterator itr = _lics.begin(); 971 itr != _lics.end(); ++itr) { 972 if (itr->second->getColorMap() == cmap) 973 return true; 974 } 975 for (MoleculeHashmap::iterator itr = _molecules.begin(); 976 itr != _molecules.end(); ++itr) { 977 if (itr->second->getColorMap() == cmap) 978 return true; 979 } 980 for (PseudoColorHashmap::iterator itr = _pseudoColors.begin(); 981 itr != _pseudoColors.end(); ++itr) { 982 if (itr->second->getColorMap() == cmap) 983 return true; 984 } 985 for (StreamlinesHashmap::iterator itr = _streamlines.begin(); 986 itr != _streamlines.end(); ++itr) { 987 if (itr->second->getColorMap() == cmap) 988 return true; 989 } 990 for (VolumeHashmap::iterator itr = _volumes.begin(); 991 itr != _volumes.end(); ++itr) { 992 if (itr->second->getColorMap() == cmap) 993 return true; 994 } 858 if (graphicsObjectColorMapUsed<Contour2D>(cmap)) 859 return true; 860 if (graphicsObjectColorMapUsed<Contour3D>(cmap)) 861 return true; 862 if (graphicsObjectColorMapUsed<Cutplane>(cmap)) 863 return true; 864 if (graphicsObjectColorMapUsed<Glyphs>(cmap)) 865 return true; 866 if (graphicsObjectColorMapUsed<HeightMap>(cmap)) 867 return true; 868 if (graphicsObjectColorMapUsed<LIC>(cmap)) 869 return true; 870 if (graphicsObjectColorMapUsed<Molecule>(cmap)) 871 return true; 872 if (graphicsObjectColorMapUsed<PseudoColor>(cmap)) 873 return true; 874 if (graphicsObjectColorMapUsed<Streamlines>(cmap)) 875 return true; 876 if (graphicsObjectColorMapUsed<Volume>(cmap)) 877 return true; 878 if (graphicsObjectColorMapUsed<Warp>(cmap)) 879 return true; 880 995 881 return false; 996 882 } … … 1542 1428 } 1543 1429 _needsRedraw = true; 1430 } 1431 1432 void Renderer::setObjectAspects(double aspectRatio) 1433 { 1434 setGraphicsObjectAspect<Arc>(aspectRatio); 1435 setGraphicsObjectAspect<Arrow>(aspectRatio); 1436 setGraphicsObjectAspect<Box>(aspectRatio); 1437 setGraphicsObjectAspect<Cone>(aspectRatio); 1438 setGraphicsObjectAspect<Contour2D>(aspectRatio); 1439 setGraphicsObjectAspect<Contour3D>(aspectRatio); 1440 setGraphicsObjectAspect<Cutplane>(aspectRatio); 1441 setGraphicsObjectAspect<Cylinder>(aspectRatio); 1442 setGraphicsObjectAspect<Disk>(aspectRatio); 1443 setGraphicsObjectAspect<Glyphs>(aspectRatio); 1444 setGraphicsObjectAspect<HeightMap>(aspectRatio); 1445 setGraphicsObjectAspect<LIC>(aspectRatio); 1446 setGraphicsObjectAspect<Line>(aspectRatio); 1447 setGraphicsObjectAspect<Molecule>(aspectRatio); 1448 setGraphicsObjectAspect<PolyData>(aspectRatio); 1449 setGraphicsObjectAspect<Polygon>(aspectRatio); 1450 setGraphicsObjectAspect<PseudoColor>(aspectRatio); 1451 setGraphicsObjectAspect<Sphere>(aspectRatio); 1452 setGraphicsObjectAspect<Streamlines>(aspectRatio); 1453 setGraphicsObjectAspect<Volume>(aspectRatio); 1454 setGraphicsObjectAspect<Warp>(aspectRatio); 1544 1455 } 1545 1456 … … 2005 1916 double offsetX = pxOffsetX * pxToWorld; 2006 1917 double offsetY = pxOffsetY * pxToWorld; 1918 double plotWidthWorld = imgWidthPx * pxToWorld; 1919 double plotHeightWorld = imgHeightPx * pxToWorld; 2007 1920 2008 1921 TRACE("Window: %d %d", _windowWidth, _windowHeight); … … 2039 1952 _cameraClipPlanes[1]->SetNormal(1, 0, 0); 2040 1953 // top 2041 _cameraClipPlanes[2]->SetOrigin(0, _imgWorldOrigin[1] + _imgWorldDims[1], 0);1954 _cameraClipPlanes[2]->SetOrigin(0, _imgWorldOrigin[1] + plotHeightWorld, 0); 2042 1955 _cameraClipPlanes[2]->SetNormal(0, -1, 0); 2043 1956 // right 2044 _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + _imgWorldDims[0], 0, 0);1957 _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + plotWidthWorld, 0, 0); 2045 1958 _cameraClipPlanes[3]->SetNormal(-1, 0, 0); 2046 _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + _imgWorldDims[0],2047 _imgWorldOrigin[1], _imgWorldOrigin[1] + _imgWorldDims[1],1959 _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + plotWidthWorld, 1960 _imgWorldOrigin[1], _imgWorldOrigin[1] + plotHeightWorld, 2048 1961 _imgCameraOffset, _imgCameraOffset); 2049 1962 _cubeAxesActor2D->XAxisVisibilityOn(); … … 2062 1975 _cameraClipPlanes[1]->SetNormal(0, 0, 1); 2063 1976 // top 2064 _cameraClipPlanes[2]->SetOrigin(0, _imgWorldOrigin[1] + _imgWorldDims[1], 0);1977 _cameraClipPlanes[2]->SetOrigin(0, _imgWorldOrigin[1] + plotHeightWorld, 0); 2065 1978 _cameraClipPlanes[2]->SetNormal(0, -1, 0); 2066 1979 // right 2067 _cameraClipPlanes[3]->SetOrigin(0, 0, _imgWorldOrigin[0] + _imgWorldDims[0]);1980 _cameraClipPlanes[3]->SetOrigin(0, 0, _imgWorldOrigin[0] + plotWidthWorld); 2068 1981 _cameraClipPlanes[3]->SetNormal(0, 0, -1); 2069 1982 _cubeAxesActor2D->SetBounds(_imgCameraOffset, _imgCameraOffset, 2070 _imgWorldOrigin[1], _imgWorldOrigin[1] + _imgWorldDims[1],2071 _imgWorldOrigin[0], _imgWorldOrigin[0] + _imgWorldDims[0]);1983 _imgWorldOrigin[1], _imgWorldOrigin[1] + plotHeightWorld, 1984 _imgWorldOrigin[0], _imgWorldOrigin[0] + plotWidthWorld); 2072 1985 _cubeAxesActor2D->XAxisVisibilityOff(); 2073 1986 _cubeAxesActor2D->YAxisVisibilityOn(); … … 2085 1998 _cameraClipPlanes[1]->SetNormal(1, 0, 0); 2086 1999 // top 2087 _cameraClipPlanes[2]->SetOrigin(0, 0, _imgWorldOrigin[1] + _imgWorldDims[1]);2000 _cameraClipPlanes[2]->SetOrigin(0, 0, _imgWorldOrigin[1] + plotHeightWorld); 2088 2001 _cameraClipPlanes[2]->SetNormal(0, 0, -1); 2089 2002 // right 2090 _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + _imgWorldDims[0], 0, 0);2003 _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + plotWidthWorld, 0, 0); 2091 2004 _cameraClipPlanes[3]->SetNormal(-1, 0, 0); 2092 _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + _imgWorldDims[0],2005 _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + plotWidthWorld, 2093 2006 _imgCameraOffset, _imgCameraOffset, 2094 _imgWorldOrigin[1], _imgWorldOrigin[1] + _imgWorldDims[1]);2007 _imgWorldOrigin[1], _imgWorldOrigin[1] + plotHeightWorld); 2095 2008 _cubeAxesActor2D->XAxisVisibilityOn(); 2096 2009 _cubeAxesActor2D->YAxisVisibilityOff(); … … 2275 2188 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 2276 2189 } 2277 for (Contour2DHashmap::iterator itr = _contour2Ds.begin(); 2278 itr != _contour2Ds.end(); ++itr) { 2279 if ((!onlyVisible || itr->second->getVisibility()) && 2280 itr->second->getProp() != NULL) 2281 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 2282 } 2283 for (Contour3DHashmap::iterator itr = _contour3Ds.begin(); 2284 itr != _contour3Ds.end(); ++itr) { 2285 if ((!onlyVisible || itr->second->getVisibility()) && 2286 itr->second->getProp() != NULL) 2287 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 2288 } 2289 for (CutplaneHashmap::iterator itr = _cutplanes.begin(); 2290 itr != _cutplanes.end(); ++itr) { 2291 if ((!onlyVisible || itr->second->getVisibility()) && 2292 itr->second->getProp() != NULL) 2293 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 2294 } 2295 for (GlyphsHashmap::iterator itr = _glyphs.begin(); 2296 itr != _glyphs.end(); ++itr) { 2297 if ((!onlyVisible || itr->second->getVisibility()) && 2298 itr->second->getProp() != NULL) 2299 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 2300 } 2301 for (HeightMapHashmap::iterator itr = _heightMaps.begin(); 2302 itr != _heightMaps.end(); ++itr) { 2303 if ((!onlyVisible || itr->second->getVisibility()) && 2304 itr->second->getProp() != NULL) 2305 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 2306 } 2307 for (LICHashmap::iterator itr = _lics.begin(); 2308 itr != _lics.end(); ++itr) { 2309 if ((!onlyVisible || itr->second->getVisibility()) && 2310 itr->second->getProp() != NULL) 2311 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 2312 } 2313 for (MoleculeHashmap::iterator itr = _molecules.begin(); 2314 itr != _molecules.end(); ++itr) { 2315 if ((!onlyVisible || itr->second->getVisibility()) && 2316 itr->second->getProp() != NULL) 2317 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 2318 } 2319 for (PolyDataHashmap::iterator itr = _polyDatas.begin(); 2320 itr != _polyDatas.end(); ++itr) { 2321 if ((!onlyVisible || itr->second->getVisibility()) && 2322 itr->second->getProp() != NULL) 2323 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 2324 } 2325 for (PseudoColorHashmap::iterator itr = _pseudoColors.begin(); 2326 itr != _pseudoColors.end(); ++itr) { 2327 if ((!onlyVisible || itr->second->getVisibility()) && 2328 itr->second->getProp() != NULL) 2329 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 2330 } 2331 for (StreamlinesHashmap::iterator itr = _streamlines.begin(); 2332 itr != _streamlines.end(); ++itr) { 2333 if ((!onlyVisible || itr->second->getVisibility()) && 2334 itr->second->getProp() != NULL) 2335 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 2336 } 2337 for (VolumeHashmap::iterator itr = _volumes.begin(); 2338 itr != _volumes.end(); ++itr) { 2339 if ((!onlyVisible || itr->second->getVisibility()) && 2340 itr->second->getProp() != NULL) 2341 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 2342 } 2190 2191 mergeGraphicsObjectBounds<Arc>(bounds, onlyVisible); 2192 mergeGraphicsObjectBounds<Arrow>(bounds, onlyVisible); 2193 mergeGraphicsObjectBounds<Box>(bounds, onlyVisible); 2194 mergeGraphicsObjectBounds<Cone>(bounds, onlyVisible); 2195 mergeGraphicsObjectBounds<Contour2D>(bounds, onlyVisible); 2196 mergeGraphicsObjectBounds<Contour3D>(bounds, onlyVisible); 2197 mergeGraphicsObjectBounds<Cutplane>(bounds, onlyVisible); 2198 mergeGraphicsObjectBounds<Cylinder>(bounds, onlyVisible); 2199 mergeGraphicsObjectBounds<Disk>(bounds, onlyVisible); 2200 mergeGraphicsObjectBounds<Glyphs>(bounds, onlyVisible); 2201 mergeGraphicsObjectBounds<HeightMap>(bounds, onlyVisible); 2202 mergeGraphicsObjectBounds<LIC>(bounds, onlyVisible); 2203 mergeGraphicsObjectBounds<Line>(bounds, onlyVisible); 2204 mergeGraphicsObjectBounds<Molecule>(bounds, onlyVisible); 2205 mergeGraphicsObjectBounds<PolyData>(bounds, onlyVisible); 2206 mergeGraphicsObjectBounds<Polygon>(bounds, onlyVisible); 2207 mergeGraphicsObjectBounds<PseudoColor>(bounds, onlyVisible); 2208 mergeGraphicsObjectBounds<Sphere>(bounds, onlyVisible); 2209 mergeGraphicsObjectBounds<Streamlines>(bounds, onlyVisible); 2210 mergeGraphicsObjectBounds<Volume>(bounds, onlyVisible); 2211 mergeGraphicsObjectBounds<Warp>(bounds, onlyVisible); 2343 2212 2344 2213 for (int i = 0; i < 6; i += 2) { … … 2374 2243 2375 2244 /** 2245 * \brief Collect bounds of all graphics objects 2246 * 2247 * \param[out] bounds Bounds of all scene objects 2248 * \param[in] onlyVisible Only collect bounds of visible objects 2249 */ 2250 void Renderer::collectUnscaledBounds(double *bounds, bool onlyVisible) 2251 { 2252 bounds[0] = DBL_MAX; 2253 bounds[1] = -DBL_MAX; 2254 bounds[2] = DBL_MAX; 2255 bounds[3] = -DBL_MAX; 2256 bounds[4] = DBL_MAX; 2257 bounds[5] = -DBL_MAX; 2258 2259 for (DataSetHashmap::iterator itr = _dataSets.begin(); 2260 itr != _dataSets.end(); ++itr) { 2261 if ((!onlyVisible || itr->second->getVisibility()) && 2262 itr->second->getProp() != NULL) 2263 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 2264 } 2265 2266 mergeGraphicsObjectUnscaledBounds<Arc>(bounds, onlyVisible); 2267 mergeGraphicsObjectUnscaledBounds<Arrow>(bounds, onlyVisible); 2268 mergeGraphicsObjectUnscaledBounds<Box>(bounds, onlyVisible); 2269 mergeGraphicsObjectUnscaledBounds<Cone>(bounds, onlyVisible); 2270 mergeGraphicsObjectUnscaledBounds<Contour2D>(bounds, onlyVisible); 2271 mergeGraphicsObjectUnscaledBounds<Contour3D>(bounds, onlyVisible); 2272 mergeGraphicsObjectUnscaledBounds<Cutplane>(bounds, onlyVisible); 2273 mergeGraphicsObjectUnscaledBounds<Cylinder>(bounds, onlyVisible); 2274 mergeGraphicsObjectUnscaledBounds<Disk>(bounds, onlyVisible); 2275 mergeGraphicsObjectUnscaledBounds<Glyphs>(bounds, onlyVisible); 2276 mergeGraphicsObjectUnscaledBounds<HeightMap>(bounds, onlyVisible); 2277 mergeGraphicsObjectUnscaledBounds<LIC>(bounds, onlyVisible); 2278 mergeGraphicsObjectUnscaledBounds<Line>(bounds, onlyVisible); 2279 mergeGraphicsObjectUnscaledBounds<Molecule>(bounds, onlyVisible); 2280 mergeGraphicsObjectUnscaledBounds<PolyData>(bounds, onlyVisible); 2281 mergeGraphicsObjectUnscaledBounds<Polygon>(bounds, onlyVisible); 2282 mergeGraphicsObjectUnscaledBounds<PseudoColor>(bounds, onlyVisible); 2283 mergeGraphicsObjectUnscaledBounds<Sphere>(bounds, onlyVisible); 2284 mergeGraphicsObjectUnscaledBounds<Streamlines>(bounds, onlyVisible); 2285 mergeGraphicsObjectUnscaledBounds<Volume>(bounds, onlyVisible); 2286 mergeGraphicsObjectUnscaledBounds<Warp>(bounds, onlyVisible); 2287 2288 for (int i = 0; i < 6; i += 2) { 2289 if (bounds[i+1] < bounds[i]) { 2290 bounds[i] = -0.5; 2291 bounds[i+1] = 0.5; 2292 } 2293 } 2294 2295 int numDims = 0; 2296 if (bounds[0] != bounds[1]) 2297 numDims++; 2298 if (bounds[2] != bounds[3]) 2299 numDims++; 2300 if (bounds[4] != bounds[5]) 2301 numDims++; 2302 2303 if (numDims == 0) { 2304 bounds[0] -= .5; 2305 bounds[1] += .5; 2306 bounds[2] -= .5; 2307 bounds[3] += .5; 2308 } 2309 2310 TRACE("Bounds: %g %g %g %g %g %g", 2311 bounds[0], 2312 bounds[1], 2313 bounds[2], 2314 bounds[3], 2315 bounds[4], 2316 bounds[5]); 2317 } 2318 2319 /** 2376 2320 * \brief Update data ranges for color-mapping and contours 2377 2321 */ … … 2380 2324 collectDataRanges(); 2381 2325 2382 for (Contour2DHashmap::iterator itr = _contour2Ds.begin(); 2383 itr != _contour2Ds.end(); ++itr) { 2384 itr->second->updateRanges(this); 2385 } 2386 for (Contour3DHashmap::iterator itr = _contour3Ds.begin(); 2387 itr != _contour3Ds.end(); ++itr) { 2388 itr->second->updateRanges(this); 2389 } 2390 for (CutplaneHashmap::iterator itr = _cutplanes.begin(); 2391 itr != _cutplanes.end(); ++itr) { 2392 itr->second->updateRanges(this); 2393 } 2394 for (GlyphsHashmap::iterator itr = _glyphs.begin(); 2395 itr != _glyphs.end(); ++itr) { 2396 itr->second->updateRanges(this); 2397 } 2398 for (HeightMapHashmap::iterator itr = _heightMaps.begin(); 2399 itr != _heightMaps.end(); ++itr) { 2400 itr->second->updateRanges(this); 2401 } 2402 for (LICHashmap::iterator itr = _lics.begin(); 2403 itr != _lics.end(); ++itr) { 2404 itr->second->updateRanges(this); 2405 } 2406 for (MoleculeHashmap::iterator itr = _molecules.begin(); 2407 itr != _molecules.end(); ++itr) { 2408 itr->second->updateRanges(this); 2409 } 2410 for (PseudoColorHashmap::iterator itr = _pseudoColors.begin(); 2411 itr != _pseudoColors.end(); ++itr) { 2412 itr->second->updateRanges(this); 2413 } 2414 for (StreamlinesHashmap::iterator itr = _streamlines.begin(); 2415 itr != _streamlines.end(); ++itr) { 2416 itr->second->updateRanges(this); 2417 } 2418 for (VolumeHashmap::iterator itr = _volumes.begin(); 2419 itr != _volumes.end(); ++itr) { 2420 itr->second->updateRanges(this); 2421 } 2326 updateGraphicsObjectFieldRanges<Contour2D>(); 2327 updateGraphicsObjectFieldRanges<Contour3D>(); 2328 updateGraphicsObjectFieldRanges<Cutplane>(); 2329 updateGraphicsObjectFieldRanges<Glyphs>(); 2330 updateGraphicsObjectFieldRanges<HeightMap>(); 2331 updateGraphicsObjectFieldRanges<LIC>(); 2332 updateGraphicsObjectFieldRanges<Molecule>(); 2333 updateGraphicsObjectFieldRanges<PseudoColor>(); 2334 updateGraphicsObjectFieldRanges<Streamlines>(); 2335 updateGraphicsObjectFieldRanges<Volume>(); 2336 updateGraphicsObjectFieldRanges<Warp>(); 2422 2337 } 2423 2338 … … 2442 2357 if (!onlyVisible || itr->second->getVisibility()) { 2443 2358 double r[2]; 2359 r[0] = DBL_MAX; 2360 r[1] = -DBL_MAX; 2444 2361 itr->second->getDataRange(r, name, type, component); 2445 2362 range[0] = min2(range[0], r[0]); … … 2771 2688 * \brief Initialize the camera zoom region to include the bounding volume given 2772 2689 */ 2773 void Renderer::initCamera( )2690 void Renderer::initCamera(bool initCameraMode) 2774 2691 { 2775 2692 #ifdef WANT_TRACE … … 2792 2709 bool twod = is2D(bounds, &_imgCameraPlane, &_imgCameraOffset); 2793 2710 if (twod) { 2794 _cameraMode = IMAGE; 2711 if (initCameraMode) { 2712 TRACE("Changing camera mode to image"); 2713 _cameraMode = IMAGE; 2714 } 2795 2715 if (_imgCameraPlane == PLANE_ZY) { 2796 2716 _imgWorldOrigin[0] = bounds[4]; … … 2928 2848 if (id.compare("all") == 0 || getGraphicsObject<Volume>(id) != NULL) 2929 2849 setGraphicsObjectOpacity<Volume>(id, opacity); 2850 if (id.compare("all") == 0 || getGraphicsObject<Warp>(id) != NULL) 2851 setGraphicsObjectOpacity<Warp>(id, opacity); 2930 2852 2931 2853 _needsRedraw = true; … … 2978 2900 if (id.compare("all") == 0 || getGraphicsObject<Volume>(id) != NULL) 2979 2901 setGraphicsObjectVisibility<Volume>(id, state); 2902 if (id.compare("all") == 0 || getGraphicsObject<Warp>(id) != NULL) 2903 setGraphicsObjectVisibility<Warp>(id, state); 2980 2904 2981 2905 _needsRedraw = true; … … 3162 3086 * Mappers already using the PlaneCollection 3163 3087 */ 3164 for (Contour2DHashmap::iterator itr = _contour2Ds.begin(); 3165 itr != _contour2Ds.end(); ++itr) { 3166 itr->second->setClippingPlanes(_activeClipPlanes); 3167 } 3168 for (Contour3DHashmap::iterator itr = _contour3Ds.begin(); 3169 itr != _contour3Ds.end(); ++itr) { 3170 itr->second->setClippingPlanes(_activeClipPlanes); 3171 } 3172 for (CutplaneHashmap::iterator itr = _cutplanes.begin(); 3173 itr != _cutplanes.end(); ++itr) { 3174 itr->second->setClippingPlanes(_activeClipPlanes); 3175 } 3176 for (GlyphsHashmap::iterator itr = _glyphs.begin(); 3177 itr != _glyphs.end(); ++itr) { 3178 itr->second->setClippingPlanes(_activeClipPlanes); 3179 } 3180 for (HeightMapHashmap::iterator itr = _heightMaps.begin(); 3181 itr != _heightMaps.end(); ++itr) { 3182 itr->second->setClippingPlanes(_activeClipPlanes); 3183 } 3184 for (LICHashmap::iterator itr = _lics.begin(); 3185 itr != _lics.end(); ++itr) { 3186 itr->second->setClippingPlanes(_activeClipPlanes); 3187 } 3188 for (MoleculeHashmap::iterator itr = _molecules.begin(); 3189 itr != _molecules.end(); ++itr) { 3190 itr->second->setClippingPlanes(_activeClipPlanes); 3191 } 3192 for (PolyDataHashmap::iterator itr = _polyDatas.begin(); 3193 itr != _polyDatas.end(); ++itr) { 3194 itr->second->setClippingPlanes(_activeClipPlanes); 3195 } 3196 for (PseudoColorHashmap::iterator itr = _pseudoColors.begin(); 3197 itr != _pseudoColors.end(); ++itr) { 3198 itr->second->setClippingPlanes(_activeClipPlanes); 3199 } 3200 for (StreamlinesHashmap::iterator itr = _streamlines.begin(); 3201 itr != _streamlines.end(); ++itr) { 3202 itr->second->setClippingPlanes(_activeClipPlanes); 3203 } 3204 for (VolumeHashmap::iterator itr = _volumes.begin(); 3205 itr != _volumes.end(); ++itr) { 3206 itr->second->setClippingPlanes(_activeClipPlanes); 3207 } 3088 setGraphicsObjectClippingPlanes<Arc>(_activeClipPlanes); 3089 setGraphicsObjectClippingPlanes<Arrow>(_activeClipPlanes); 3090 setGraphicsObjectClippingPlanes<Box>(_activeClipPlanes); 3091 setGraphicsObjectClippingPlanes<Cone>(_activeClipPlanes); 3092 setGraphicsObjectClippingPlanes<Contour2D>(_activeClipPlanes); 3093 setGraphicsObjectClippingPlanes<Contour3D>(_activeClipPlanes); 3094 setGraphicsObjectClippingPlanes<Cutplane>(_activeClipPlanes); 3095 setGraphicsObjectClippingPlanes<Cylinder>(_activeClipPlanes); 3096 setGraphicsObjectClippingPlanes<Disk>(_activeClipPlanes); 3097 setGraphicsObjectClippingPlanes<Glyphs>(_activeClipPlanes); 3098 setGraphicsObjectClippingPlanes<Group>(_activeClipPlanes); 3099 setGraphicsObjectClippingPlanes<HeightMap>(_activeClipPlanes); 3100 setGraphicsObjectClippingPlanes<LIC>(_activeClipPlanes); 3101 setGraphicsObjectClippingPlanes<Line>(_activeClipPlanes); 3102 setGraphicsObjectClippingPlanes<Molecule>(_activeClipPlanes); 3103 setGraphicsObjectClippingPlanes<PolyData>(_activeClipPlanes); 3104 setGraphicsObjectClippingPlanes<Polygon>(_activeClipPlanes); 3105 setGraphicsObjectClippingPlanes<PseudoColor>(_activeClipPlanes); 3106 setGraphicsObjectClippingPlanes<Sphere>(_activeClipPlanes); 3107 setGraphicsObjectClippingPlanes<Streamlines>(_activeClipPlanes); 3108 setGraphicsObjectClippingPlanes<Volume>(_activeClipPlanes); 3109 setGraphicsObjectClippingPlanes<Warp>(_activeClipPlanes); 3208 3110 } 3209 3111 -
branches/nanovis2/packages/vizservers/vtkvis/RpVtkRenderer.h
r2866 r3175 30 30 #include "RpTypes.h" 31 31 #include "RpVtkDataSet.h" 32 #include "RpArc.h" 33 #include "RpArrow.h" 34 #include "RpBox.h" 35 #include "RpCone.h" 32 36 #include "RpContour2D.h" 33 37 #include "RpContour3D.h" 34 38 #include "RpCutplane.h" 39 #include "RpCylinder.h" 40 #include "RpDisk.h" 35 41 #include "RpGlyphs.h" 42 #include "RpGroup.h" 36 43 #include "RpHeightMap.h" 37 44 #include "RpLIC.h" 45 #include "RpLine.h" 38 46 #include "RpMolecule.h" 39 47 #include "RpPolyData.h" 48 #include "RpPolygon.h" 40 49 #include "RpPseudoColor.h" 50 #include "RpSphere.h" 41 51 #include "RpStreamlines.h" 42 52 #include "RpVolume.h" 53 #include "RpWarp.h" 43 54 #include "Trace.h" 44 55 … … 293 304 294 305 template<class GraphicsObject> 306 void deleteAllGraphicsObjects(); 307 308 template<class GraphicsObject> 309 void mergeGraphicsObjectBounds(double *bounds, bool onlyVisible); 310 311 template<class GraphicsObject> 312 void mergeGraphicsObjectUnscaledBounds(double *bounds, bool onlyVisible); 313 314 template<class GraphicsObject> 315 void updateGraphicsObjectFieldRanges(); 316 317 template<class GraphicsObject> 318 void setGraphicsObjectClippingPlanes(vtkPlaneCollection *planes); 319 320 template<class GraphicsObject> 321 void setGraphicsObjectAspect(double aspectRatio); 322 323 template<class GraphicsObject> 295 324 void setGraphicsObjectColorMap(const DataSetId& id, const ColorMapId& colorMapId); 296 325 297 326 template<class GraphicsObject> 327 void updateGraphicsObjectColorMap(ColorMap *cmap); 328 329 template<class GraphicsObject> 330 bool graphicsObjectColorMapUsed(ColorMap *cmap); 331 332 template<class GraphicsObject> 298 333 void setGraphicsObjectVolumeSlice(const DataSetId& id, Axis axis, double ratio); 299 334 … … 310 345 311 346 template<class GraphicsObject> 347 void setGraphicsObjectAspect(const DataSetId& id, double aspect); 348 349 template<class GraphicsObject> 312 350 void setGraphicsObjectScale(const DataSetId& id, double scale[3]); 313 351 … … 353 391 void setGraphicsObjectWireframe(const DataSetId& id, bool state); 354 392 393 // Arcs 394 395 bool addArc(const DataSetId& id, double pt1[3], double pt2[3]); 396 397 void setArcResolution(const DataSetId& id, int res); 398 399 // Arrows 400 401 bool addArrow(const DataSetId& id, double tipRadius, double shaftRadius, double tipLength); 402 403 void setArrowResolution(const DataSetId& id, int resTip, int resShaft); 404 405 // Cones 406 407 bool addCone(const DataSetId& id, double radius, double height, bool cap); 408 409 void setConeResolution(const DataSetId& id, int res); 410 355 411 // 2D Contour plots 356 412 … … 362 418 363 419 void setContour2DContourList(const DataSetId& id, const std::vector<double>& contours); 420 421 void setContour2DColorMode(const DataSetId& id, 422 Contour2D::ColorMode mode, 423 const char *name, double range[2] = NULL); 424 425 void setContour2DColorMode(const DataSetId& id, 426 Contour2D::ColorMode mode, 427 DataSet::DataAttributeType type, 428 const char *name, double range[2] = NULL); 364 429 365 430 // 3D Contour (isosurface) plots … … 388 453 const char *name, double range[2] = NULL); 389 454 455 // Cylinders 456 457 bool addCylinder(const DataSetId& id, double radius, double height, bool cap); 458 459 void setCylinderResolution(const DataSetId& id, int res); 460 461 // Disks 462 463 bool addDisk(const DataSetId& id, double innerRadius, double outerRadius); 464 465 void setDiskResolution(const DataSetId& id, int resRadial, int resCircum); 466 390 467 // Glyphs 391 468 … … 393 470 394 471 void setGlyphsShape(const DataSetId& id, Glyphs::GlyphShape shape); 472 473 void setGlyphsOrientMode(const DataSetId& id, bool state, const char *name); 395 474 396 475 void setGlyphsColorMode(const DataSetId& id, … … 428 507 void setHeightMapContourEdgeWidth(const DataSetId& id, float edgeWidth); 429 508 509 // Lines 510 511 bool addLine(const DataSetId& id, double pt1[3], double pt2[3]); 512 430 513 // Molecules 431 514 515 void setMoleculeAtomRadiusScale(const DataSetId& id, double scale); 516 517 void setMoleculeBondRadiusScale(const DataSetId& id, double scale); 518 432 519 void setMoleculeAtomScaling(const DataSetId& id, Molecule::AtomScaling scaling); 433 520 434 521 void setMoleculeAtomVisibility(const DataSetId& id, bool state); 435 522 523 void setMoleculeAtomLabelVisibility(const DataSetId& id, bool state); 524 436 525 void setMoleculeBondVisibility(const DataSetId& id, bool state); 526 527 void setMoleculeBondStyle(const DataSetId& id, Molecule::BondStyle style); 528 529 void setMoleculeBondColorMode(const DataSetId& id, Molecule::BondColorMode mode); 530 531 void setMoleculeBondColor(const DataSetId& id, float color[3]); 532 533 void setMoleculeColorMode(const DataSetId& id, 534 Molecule::ColorMode mode, 535 const char *name, double range[2] = NULL); 536 537 void setMoleculeColorMode(const DataSetId& id, 538 Molecule::ColorMode mode, 539 DataSet::DataAttributeType type, 540 const char *name, double range[2] = NULL); 541 542 // N-sided Regular Polygons 543 544 bool addPolygon(const DataSetId& id, int numSides); 437 545 438 546 // Color-mapped surfaces … … 447 555 const char *name, double range[2] = NULL); 448 556 557 // Spheres 558 559 void setSphereSection(const DataSetId& id, double thetaStart, double thetaEnd, 560 double phiStart, double phiEnd); 561 562 void setSphereResolution(const DataSetId& id, int thetaRes, int phiRes); 563 449 564 // Streamlines 450 565 … … 506 621 void setVolumeSampleDistance(const DataSetId& id, double distance); 507 622 623 // Warps 624 625 void setWarpWarpScale(const DataSetId& id, double scale); 626 508 627 private: 509 628 typedef std::tr1::unordered_map<DataSetId, DataSet *> DataSetHashmap; 510 629 typedef std::tr1::unordered_map<FieldId, double *> FieldRangeHashmap; 511 630 typedef std::tr1::unordered_map<ColorMapId, ColorMap *> ColorMapHashmap; 631 632 typedef std::tr1::unordered_map<DataSetId, Arc *> ArcHashmap; 633 typedef std::tr1::unordered_map<DataSetId, Arrow *> ArrowHashmap; 634 typedef std::tr1::unordered_map<DataSetId, Box *> BoxHashmap; 635 typedef std::tr1::unordered_map<DataSetId, Cone *> ConeHashmap; 512 636 typedef std::tr1::unordered_map<DataSetId, Contour2D *> Contour2DHashmap; 513 637 typedef std::tr1::unordered_map<DataSetId, Contour3D *> Contour3DHashmap; 514 638 typedef std::tr1::unordered_map<DataSetId, Cutplane *> CutplaneHashmap; 639 typedef std::tr1::unordered_map<DataSetId, Cylinder *> CylinderHashmap; 640 typedef std::tr1::unordered_map<DataSetId, Disk *> DiskHashmap; 515 641 typedef std::tr1::unordered_map<DataSetId, Glyphs *> GlyphsHashmap; 642 typedef std::tr1::unordered_map<DataSetId, Group *> GroupHashmap; 516 643 typedef std::tr1::unordered_map<DataSetId, HeightMap *> HeightMapHashmap; 517 644 typedef std::tr1::unordered_map<DataSetId, LIC *> LICHashmap; 645 typedef std::tr1::unordered_map<DataSetId, Line *> LineHashmap; 518 646 typedef std::tr1::unordered_map<DataSetId, Molecule *> MoleculeHashmap; 519 647 typedef std::tr1::unordered_map<DataSetId, PolyData *> PolyDataHashmap; 648 typedef std::tr1::unordered_map<DataSetId, Polygon *> PolygonHashmap; 520 649 typedef std::tr1::unordered_map<DataSetId, PseudoColor *> PseudoColorHashmap; 650 typedef std::tr1::unordered_map<DataSetId, Sphere *> SphereHashmap; 521 651 typedef std::tr1::unordered_map<DataSetId, Streamlines *> StreamlinesHashmap; 522 652 typedef std::tr1::unordered_map<DataSetId, Volume *> VolumeHashmap; 653 typedef std::tr1::unordered_map<DataSetId, Warp *> WarpHashmap; 523 654 524 655 static void printCameraInfo(vtkCamera *camera); … … 531 662 std::tr1::unordered_map<DataSetId, GraphicsObject *>&getGraphicsObjectHashmap(); 532 663 664 void setObjectAspects(double aspectRatio); 665 533 666 void collectBounds(double *bounds, bool onlyVisible); 667 668 void collectUnscaledBounds(double *bounds, bool onlyVisible); 534 669 535 670 void collectDataRanges(); … … 558 693 PrincipalPlane *plane, 559 694 double *offset) const; 560 void initCamera( );695 void initCamera(bool initCameraMode = false); 561 696 void initAxes(); 562 697 void resetAxes(double bounds[6] = NULL); … … 565 700 bool _needsRedraw; 566 701 int _windowWidth, _windowHeight; 702 CameraMode _cameraMode; 567 703 double _imgWorldOrigin[2]; 568 704 double _imgWorldDims[2]; … … 586 722 ColorMapHashmap _colorMaps; 587 723 DataSetHashmap _dataSets; 724 ArcHashmap _arcs; 725 ArrowHashmap _arrows; 726 BoxHashmap _boxes; 727 ConeHashmap _cones; 588 728 Contour2DHashmap _contour2Ds; 589 729 Contour3DHashmap _contour3Ds; 590 730 CutplaneHashmap _cutplanes; 731 CylinderHashmap _cylinders; 732 DiskHashmap _disks; 591 733 GlyphsHashmap _glyphs; 734 GroupHashmap _groups; 592 735 HeightMapHashmap _heightMaps; 593 736 LICHashmap _lics; 737 LineHashmap _lines; 594 738 MoleculeHashmap _molecules; 595 739 PolyDataHashmap _polyDatas; 740 PolygonHashmap _polygons; 596 741 PseudoColorHashmap _pseudoColors; 742 SphereHashmap _spheres; 597 743 StreamlinesHashmap _streamlines; 598 744 VolumeHashmap _volumes; 599 600 CameraMode _cameraMode; 745 WarpHashmap _warps; 601 746 602 747 vtkSmartPointer<vtkPlane> _cameraClipPlanes[4]; -
branches/nanovis2/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp
r2757 r3175 121 121 122 122 static int 123 ArcAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 124 Tcl_Obj *const *objv) 125 { 126 double pt1[3]; 127 double pt2[3]; 128 if (Tcl_GetDoubleFromObj(interp, objv[2], &pt1[0]) != TCL_OK || 129 Tcl_GetDoubleFromObj(interp, objv[3], &pt1[1]) != TCL_OK || 130 Tcl_GetDoubleFromObj(interp, objv[4], &pt1[2]) != TCL_OK || 131 Tcl_GetDoubleFromObj(interp, objv[5], &pt2[0]) != TCL_OK || 132 Tcl_GetDoubleFromObj(interp, objv[6], &pt2[1]) != TCL_OK || 133 Tcl_GetDoubleFromObj(interp, objv[7], &pt2[2]) != TCL_OK) { 134 return TCL_ERROR; 135 } 136 const char *name = Tcl_GetString(objv[8]); 137 if (!g_renderer->addArc(name, pt1, pt2)) { 138 Tcl_AppendResult(interp, "Failed to create arc", (char*)NULL); 139 return TCL_ERROR; 140 } 141 return TCL_OK; 142 } 143 144 static int 145 ArcDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 146 Tcl_Obj *const *objv) 147 { 148 if (objc == 3) { 149 const char *name = Tcl_GetString(objv[2]); 150 g_renderer->deleteGraphicsObject<Arc>(name); 151 } else { 152 g_renderer->deleteGraphicsObject<Arc>("all"); 153 } 154 return TCL_OK; 155 } 156 157 static int 158 ArcColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 159 Tcl_Obj *const *objv) 160 { 161 float color[3]; 162 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 163 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 164 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 165 return TCL_ERROR; 166 } 167 if (objc == 6) { 168 const char *name = Tcl_GetString(objv[5]); 169 g_renderer->setGraphicsObjectColor<Arc>(name, color); 170 } else { 171 g_renderer->setGraphicsObjectColor<Arc>("all", color); 172 } 173 return TCL_OK; 174 } 175 176 static int 177 ArcLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc, 178 Tcl_Obj *const *objv) 179 { 180 float width; 181 if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) { 182 return TCL_ERROR; 183 } 184 if (objc == 4) { 185 const char *name = Tcl_GetString(objv[3]); 186 g_renderer->setGraphicsObjectEdgeWidth<Arc>(name, width); 187 } else { 188 g_renderer->setGraphicsObjectEdgeWidth<Arc>("all", width); 189 } 190 return TCL_OK; 191 } 192 193 static int 194 ArcOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc, 195 Tcl_Obj *const *objv) 196 { 197 double opacity; 198 if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) { 199 return TCL_ERROR; 200 } 201 if (objc == 4) { 202 const char *name = Tcl_GetString(objv[3]); 203 g_renderer->setGraphicsObjectOpacity<Arc>(name, opacity); 204 } else { 205 g_renderer->setGraphicsObjectOpacity<Arc>("all", opacity); 206 } 207 return TCL_OK; 208 } 209 210 static int 211 ArcOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 212 Tcl_Obj *const *objv) 213 { 214 double quat[4]; 215 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 216 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 217 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 218 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 219 return TCL_ERROR; 220 } 221 if (objc == 7) { 222 const char *name = Tcl_GetString(objv[6]); 223 g_renderer->setGraphicsObjectOrientation<Arc>(name, quat); 224 } else { 225 g_renderer->setGraphicsObjectOrientation<Arc>("all", quat); 226 } 227 return TCL_OK; 228 } 229 230 static int 231 ArcPositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 232 Tcl_Obj *const *objv) 233 { 234 double pos[3]; 235 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 236 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 237 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 238 return TCL_ERROR; 239 } 240 if (objc == 6) { 241 const char *name = Tcl_GetString(objv[5]); 242 g_renderer->setGraphicsObjectPosition<Arc>(name, pos); 243 } else { 244 g_renderer->setGraphicsObjectPosition<Arc>("all", pos); 245 } 246 return TCL_OK; 247 } 248 249 static int 250 ArcResolutionOp(ClientData clientData, Tcl_Interp *interp, int objc, 251 Tcl_Obj *const *objv) 252 { 253 int res; 254 if (Tcl_GetIntFromObj(interp, objv[2], &res) != TCL_OK) { 255 return TCL_ERROR; 256 } 257 if (objc == 4) { 258 const char *name = Tcl_GetString(objv[3]); 259 g_renderer->setArcResolution(name, res); 260 } else { 261 g_renderer->setArcResolution("all", res); 262 } 263 return TCL_OK; 264 } 265 266 static int 267 ArcScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 268 Tcl_Obj *const *objv) 269 { 270 double scale[3]; 271 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 272 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 273 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 274 return TCL_ERROR; 275 } 276 if (objc == 6) { 277 const char *name = Tcl_GetString(objv[5]); 278 g_renderer->setGraphicsObjectScale<Arc>(name, scale); 279 } else { 280 g_renderer->setGraphicsObjectScale<Arc>("all", scale); 281 } 282 return TCL_OK; 283 } 284 285 static int 286 ArcVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 287 Tcl_Obj *const *objv) 288 { 289 bool state; 290 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 291 return TCL_ERROR; 292 } 293 if (objc == 4) { 294 const char *name = Tcl_GetString(objv[3]); 295 g_renderer->setGraphicsObjectVisibility<Arc>(name, state); 296 } else { 297 g_renderer->setGraphicsObjectVisibility<Arc>("all", state); 298 } 299 return TCL_OK; 300 } 301 302 static Rappture::CmdSpec arcOps[] = { 303 {"add", 1, ArcAddOp, 9, 9, "x1 y1 z1 x2 y2 z2 name"}, 304 {"color", 1, ArcColorOp, 5, 6, "r g b ?name?"}, 305 {"delete", 1, ArcDeleteOp, 2, 3, "?name?"}, 306 {"linecolor", 5, ArcColorOp, 5, 6, "r g b ?name?"}, 307 {"linewidth", 5, ArcLineWidthOp, 3, 4, "width ?name?"}, 308 {"opacity", 2, ArcOpacityOp, 3, 4, "value ?name?"}, 309 {"orient", 2, ArcOrientOp, 6, 7, "qw qx qy qz ?name?"}, 310 {"pos", 2, ArcPositionOp, 5, 6, "x y z ?name?"}, 311 {"resolution",1, ArcResolutionOp, 3, 4, "res ?name?"}, 312 {"scale", 2, ArcScaleOp, 5, 6, "sx sy sz ?name?"}, 313 {"visible", 1, ArcVisibleOp, 3, 4, "bool ?name?"} 314 }; 315 static int nArcOps = NumCmdSpecs(arcOps); 316 317 static int 318 ArcCmd(ClientData clientData, Tcl_Interp *interp, int objc, 319 Tcl_Obj *const *objv) 320 { 321 Tcl_ObjCmdProc *proc; 322 323 proc = Rappture::GetOpFromObj(interp, nArcOps, arcOps, 324 Rappture::CMDSPEC_ARG1, objc, objv, 0); 325 if (proc == NULL) { 326 return TCL_ERROR; 327 } 328 return (*proc) (clientData, interp, objc, objv); 329 } 330 331 static int 332 ArrowAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 333 Tcl_Obj *const *objv) 334 { 335 double tipRadius, shaftRadius, tipLength; 336 if (Tcl_GetDoubleFromObj(interp, objv[2], &tipRadius) != TCL_OK || 337 Tcl_GetDoubleFromObj(interp, objv[3], &shaftRadius) != TCL_OK || 338 Tcl_GetDoubleFromObj(interp, objv[4], &tipLength) != TCL_OK) { 339 return TCL_ERROR; 340 } 341 const char *name = Tcl_GetString(objv[5]); 342 if (!g_renderer->addArrow(name, tipRadius, shaftRadius, tipLength)) { 343 Tcl_AppendResult(interp, "Failed to create arrow", (char*)NULL); 344 return TCL_ERROR; 345 } 346 return TCL_OK; 347 } 348 349 static int 350 ArrowDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 351 Tcl_Obj *const *objv) 352 { 353 if (objc == 3) { 354 const char *name = Tcl_GetString(objv[2]); 355 g_renderer->deleteGraphicsObject<Arrow>(name); 356 } else { 357 g_renderer->deleteGraphicsObject<Arrow>("all"); 358 } 359 return TCL_OK; 360 } 361 362 static int 363 ArrowColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 364 Tcl_Obj *const *objv) 365 { 366 float color[3]; 367 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 368 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 369 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 370 return TCL_ERROR; 371 } 372 if (objc == 6) { 373 const char *name = Tcl_GetString(objv[5]); 374 g_renderer->setGraphicsObjectColor<Arrow>(name, color); 375 } else { 376 g_renderer->setGraphicsObjectColor<Arrow>("all", color); 377 } 378 return TCL_OK; 379 } 380 381 static int 382 ArrowEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc, 383 Tcl_Obj *const *objv) 384 { 385 bool state; 386 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 387 return TCL_ERROR; 388 } 389 if (objc == 4) { 390 const char *name = Tcl_GetString(objv[3]); 391 g_renderer->setGraphicsObjectEdgeVisibility<Arrow>(name, state); 392 } else { 393 g_renderer->setGraphicsObjectEdgeVisibility<Arrow>("all", state); 394 } 395 return TCL_OK; 396 } 397 398 static int 399 ArrowLightingOp(ClientData clientData, Tcl_Interp *interp, int objc, 400 Tcl_Obj *const *objv) 401 { 402 bool state; 403 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 404 return TCL_ERROR; 405 } 406 if (objc == 4) { 407 const char *name = Tcl_GetString(objv[3]); 408 g_renderer->setGraphicsObjectLighting<Arrow>(name, state); 409 } else { 410 g_renderer->setGraphicsObjectLighting<Arrow>("all", state); 411 } 412 return TCL_OK; 413 } 414 415 static int 416 ArrowLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 417 Tcl_Obj *const *objv) 418 { 419 float color[3]; 420 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 421 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 422 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 423 return TCL_ERROR; 424 } 425 if (objc == 6) { 426 const char *name = Tcl_GetString(objv[5]); 427 g_renderer->setGraphicsObjectEdgeColor<Arrow>(name, color); 428 } else { 429 g_renderer->setGraphicsObjectEdgeColor<Arrow>("all", color); 430 } 431 return TCL_OK; 432 } 433 434 static int 435 ArrowLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc, 436 Tcl_Obj *const *objv) 437 { 438 float width; 439 if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) { 440 return TCL_ERROR; 441 } 442 if (objc == 4) { 443 const char *name = Tcl_GetString(objv[3]); 444 g_renderer->setGraphicsObjectEdgeWidth<Arrow>(name, width); 445 } else { 446 g_renderer->setGraphicsObjectEdgeWidth<Arrow>("all", width); 447 } 448 return TCL_OK; 449 } 450 451 static int 452 ArrowMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc, 453 Tcl_Obj *const *objv) 454 { 455 double ambient, diffuse, specCoeff, specPower; 456 if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK || 457 Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK || 458 Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK || 459 Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) { 460 return TCL_ERROR; 461 } 462 463 if (objc == 7) { 464 const char *name = Tcl_GetString(objv[6]); 465 g_renderer->setGraphicsObjectAmbient<Arrow>(name, ambient); 466 g_renderer->setGraphicsObjectDiffuse<Arrow>(name, diffuse); 467 g_renderer->setGraphicsObjectSpecular<Arrow>(name, specCoeff, specPower); 468 } else { 469 g_renderer->setGraphicsObjectAmbient<Arrow>("all", ambient); 470 g_renderer->setGraphicsObjectDiffuse<Arrow>("all", diffuse); 471 g_renderer->setGraphicsObjectSpecular<Arrow>("all", specCoeff, specPower); 472 } 473 return TCL_OK; 474 } 475 476 static int 477 ArrowOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc, 478 Tcl_Obj *const *objv) 479 { 480 double opacity; 481 if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) { 482 return TCL_ERROR; 483 } 484 if (objc == 4) { 485 const char *name = Tcl_GetString(objv[3]); 486 g_renderer->setGraphicsObjectOpacity<Arrow>(name, opacity); 487 } else { 488 g_renderer->setGraphicsObjectOpacity<Arrow>("all", opacity); 489 } 490 return TCL_OK; 491 } 492 493 static int 494 ArrowOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 495 Tcl_Obj *const *objv) 496 { 497 double quat[4]; 498 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 499 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 500 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 501 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 502 return TCL_ERROR; 503 } 504 if (objc == 7) { 505 const char *name = Tcl_GetString(objv[6]); 506 g_renderer->setGraphicsObjectOrientation<Arrow>(name, quat); 507 } else { 508 g_renderer->setGraphicsObjectOrientation<Arrow>("all", quat); 509 } 510 return TCL_OK; 511 } 512 513 static int 514 ArrowPositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 515 Tcl_Obj *const *objv) 516 { 517 double pos[3]; 518 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 519 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 520 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 521 return TCL_ERROR; 522 } 523 if (objc == 6) { 524 const char *name = Tcl_GetString(objv[5]); 525 g_renderer->setGraphicsObjectPosition<Arrow>(name, pos); 526 } else { 527 g_renderer->setGraphicsObjectPosition<Arrow>("all", pos); 528 } 529 return TCL_OK; 530 } 531 532 static int 533 ArrowResolutionOp(ClientData clientData, Tcl_Interp *interp, int objc, 534 Tcl_Obj *const *objv) 535 { 536 int tipRes, shaftRes; 537 if (Tcl_GetIntFromObj(interp, objv[2], &tipRes) != TCL_OK || 538 Tcl_GetIntFromObj(interp, objv[3], &shaftRes) != TCL_OK) { 539 return TCL_ERROR; 540 } 541 if (objc == 4) { 542 const char *name = Tcl_GetString(objv[4]); 543 g_renderer->setArrowResolution(name, tipRes, shaftRes); 544 } else { 545 g_renderer->setArrowResolution("all", tipRes, shaftRes); 546 } 547 return TCL_OK; 548 } 549 550 static int 551 ArrowScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 552 Tcl_Obj *const *objv) 553 { 554 double scale[3]; 555 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 556 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 557 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 558 return TCL_ERROR; 559 } 560 if (objc == 6) { 561 const char *name = Tcl_GetString(objv[5]); 562 g_renderer->setGraphicsObjectScale<Arrow>(name, scale); 563 } else { 564 g_renderer->setGraphicsObjectScale<Arrow>("all", scale); 565 } 566 return TCL_OK; 567 } 568 569 static int 570 ArrowVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 571 Tcl_Obj *const *objv) 572 { 573 bool state; 574 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 575 return TCL_ERROR; 576 } 577 if (objc == 4) { 578 const char *name = Tcl_GetString(objv[3]); 579 g_renderer->setGraphicsObjectVisibility<Arrow>(name, state); 580 } else { 581 g_renderer->setGraphicsObjectVisibility<Arrow>("all", state); 582 } 583 return TCL_OK; 584 } 585 586 static int 587 ArrowWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc, 588 Tcl_Obj *const *objv) 589 { 590 bool state; 591 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 592 return TCL_ERROR; 593 } 594 if (objc == 4) { 595 const char *name = Tcl_GetString(objv[3]); 596 g_renderer->setGraphicsObjectWireframe<Arrow>(name, state); 597 } else { 598 g_renderer->setGraphicsObjectWireframe<Arrow>("all", state); 599 } 600 return TCL_OK; 601 } 602 603 static Rappture::CmdSpec arrowOps[] = { 604 {"add", 1, ArrowAddOp, 6, 6, "tipRadius shaftRadius tipLength name"}, 605 {"color", 1, ArrowColorOp, 5, 6, "r g b ?name?"}, 606 {"delete", 1, ArrowDeleteOp, 2, 3, "?name?"}, 607 {"edges", 1, ArrowEdgeVisibilityOp, 3, 4, "bool ?name?"}, 608 {"lighting", 3, ArrowLightingOp, 3, 4, "bool ?name?"}, 609 {"linecolor", 5, ArrowLineColorOp, 5, 6, "r g b ?name?"}, 610 {"linewidth", 5, ArrowLineWidthOp, 3, 4, "width ?name?"}, 611 {"material", 1, ArrowMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"}, 612 {"opacity", 2, ArrowOpacityOp, 3, 4, "value ?name?"}, 613 {"orient", 2, ArrowOrientOp, 6, 7, "qw qx qy qz ?name?"}, 614 {"pos", 2, ArrowPositionOp, 5, 6, "x y z ?name?"}, 615 {"resolution",1, ArrowResolutionOp, 4, 5, "tipRes shaftRes ?name?"}, 616 {"scale", 1, ArrowScaleOp, 5, 6, "sx sy sz ?name?"}, 617 {"visible", 1, ArrowVisibleOp, 3, 4, "bool ?name?"}, 618 {"wireframe", 1, ArrowWireframeOp, 3, 4, "bool ?name?"} 619 }; 620 static int nArrowOps = NumCmdSpecs(arrowOps); 621 622 static int 623 ArrowCmd(ClientData clientData, Tcl_Interp *interp, int objc, 624 Tcl_Obj *const *objv) 625 { 626 Tcl_ObjCmdProc *proc; 627 628 proc = Rappture::GetOpFromObj(interp, nArrowOps, arrowOps, 629 Rappture::CMDSPEC_ARG1, objc, objv, 0); 630 if (proc == NULL) { 631 return TCL_ERROR; 632 } 633 return (*proc) (clientData, interp, objc, objv); 634 } 635 636 static int 123 637 AxisColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 124 638 Tcl_Obj *const *objv) … … 360 874 361 875 proc = Rappture::GetOpFromObj(interp, nAxisOps, axisOps, 876 Rappture::CMDSPEC_ARG1, objc, objv, 0); 877 if (proc == NULL) { 878 return TCL_ERROR; 879 } 880 return (*proc) (clientData, interp, objc, objv); 881 } 882 883 static int 884 BoxAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 885 Tcl_Obj *const *objv) 886 { 887 const char *name = Tcl_GetString(objv[2]); 888 if (!g_renderer->addGraphicsObject<Box>(name)) { 889 Tcl_AppendResult(interp, "Failed to create box", (char*)NULL); 890 return TCL_ERROR; 891 } 892 return TCL_OK; 893 } 894 895 static int 896 BoxDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 897 Tcl_Obj *const *objv) 898 { 899 if (objc == 3) { 900 const char *name = Tcl_GetString(objv[2]); 901 g_renderer->deleteGraphicsObject<Box>(name); 902 } else { 903 g_renderer->deleteGraphicsObject<Box>("all"); 904 } 905 return TCL_OK; 906 } 907 908 static int 909 BoxColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 910 Tcl_Obj *const *objv) 911 { 912 float color[3]; 913 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 914 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 915 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 916 return TCL_ERROR; 917 } 918 if (objc == 6) { 919 const char *name = Tcl_GetString(objv[5]); 920 g_renderer->setGraphicsObjectColor<Box>(name, color); 921 } else { 922 g_renderer->setGraphicsObjectColor<Box>("all", color); 923 } 924 return TCL_OK; 925 } 926 927 static int 928 BoxEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc, 929 Tcl_Obj *const *objv) 930 { 931 bool state; 932 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 933 return TCL_ERROR; 934 } 935 if (objc == 4) { 936 const char *name = Tcl_GetString(objv[3]); 937 g_renderer->setGraphicsObjectEdgeVisibility<Box>(name, state); 938 } else { 939 g_renderer->setGraphicsObjectEdgeVisibility<Box>("all", state); 940 } 941 return TCL_OK; 942 } 943 944 static int 945 BoxLightingOp(ClientData clientData, Tcl_Interp *interp, int objc, 946 Tcl_Obj *const *objv) 947 { 948 bool state; 949 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 950 return TCL_ERROR; 951 } 952 if (objc == 4) { 953 const char *name = Tcl_GetString(objv[3]); 954 g_renderer->setGraphicsObjectLighting<Box>(name, state); 955 } else { 956 g_renderer->setGraphicsObjectLighting<Box>("all", state); 957 } 958 return TCL_OK; 959 } 960 961 static int 962 BoxLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 963 Tcl_Obj *const *objv) 964 { 965 float color[3]; 966 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 967 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 968 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 969 return TCL_ERROR; 970 } 971 if (objc == 6) { 972 const char *name = Tcl_GetString(objv[5]); 973 g_renderer->setGraphicsObjectEdgeColor<Box>(name, color); 974 } else { 975 g_renderer->setGraphicsObjectEdgeColor<Box>("all", color); 976 } 977 return TCL_OK; 978 } 979 980 static int 981 BoxLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc, 982 Tcl_Obj *const *objv) 983 { 984 float width; 985 if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) { 986 return TCL_ERROR; 987 } 988 if (objc == 4) { 989 const char *name = Tcl_GetString(objv[3]); 990 g_renderer->setGraphicsObjectEdgeWidth<Box>(name, width); 991 } else { 992 g_renderer->setGraphicsObjectEdgeWidth<Box>("all", width); 993 } 994 return TCL_OK; 995 } 996 997 static int 998 BoxMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc, 999 Tcl_Obj *const *objv) 1000 { 1001 double ambient, diffuse, specCoeff, specPower; 1002 if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK || 1003 Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK || 1004 Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK || 1005 Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) { 1006 return TCL_ERROR; 1007 } 1008 1009 if (objc == 7) { 1010 const char *name = Tcl_GetString(objv[6]); 1011 g_renderer->setGraphicsObjectAmbient<Box>(name, ambient); 1012 g_renderer->setGraphicsObjectDiffuse<Box>(name, diffuse); 1013 g_renderer->setGraphicsObjectSpecular<Box>(name, specCoeff, specPower); 1014 } else { 1015 g_renderer->setGraphicsObjectAmbient<Box>("all", ambient); 1016 g_renderer->setGraphicsObjectDiffuse<Box>("all", diffuse); 1017 g_renderer->setGraphicsObjectSpecular<Box>("all", specCoeff, specPower); 1018 } 1019 return TCL_OK; 1020 } 1021 1022 static int 1023 BoxOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc, 1024 Tcl_Obj *const *objv) 1025 { 1026 double opacity; 1027 if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) { 1028 return TCL_ERROR; 1029 } 1030 if (objc == 4) { 1031 const char *name = Tcl_GetString(objv[3]); 1032 g_renderer->setGraphicsObjectOpacity<Box>(name, opacity); 1033 } else { 1034 g_renderer->setGraphicsObjectOpacity<Box>("all", opacity); 1035 } 1036 return TCL_OK; 1037 } 1038 1039 static int 1040 BoxOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 1041 Tcl_Obj *const *objv) 1042 { 1043 double quat[4]; 1044 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 1045 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 1046 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 1047 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 1048 return TCL_ERROR; 1049 } 1050 if (objc == 7) { 1051 const char *name = Tcl_GetString(objv[6]); 1052 g_renderer->setGraphicsObjectOrientation<Box>(name, quat); 1053 } else { 1054 g_renderer->setGraphicsObjectOrientation<Box>("all", quat); 1055 } 1056 return TCL_OK; 1057 } 1058 1059 static int 1060 BoxPositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 1061 Tcl_Obj *const *objv) 1062 { 1063 double pos[3]; 1064 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 1065 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 1066 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 1067 return TCL_ERROR; 1068 } 1069 if (objc == 6) { 1070 const char *name = Tcl_GetString(objv[5]); 1071 g_renderer->setGraphicsObjectPosition<Box>(name, pos); 1072 } else { 1073 g_renderer->setGraphicsObjectPosition<Box>("all", pos); 1074 } 1075 return TCL_OK; 1076 } 1077 1078 static int 1079 BoxScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 1080 Tcl_Obj *const *objv) 1081 { 1082 double scale[3]; 1083 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 1084 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 1085 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 1086 return TCL_ERROR; 1087 } 1088 if (objc == 6) { 1089 const char *name = Tcl_GetString(objv[5]); 1090 g_renderer->setGraphicsObjectScale<Box>(name, scale); 1091 } else { 1092 g_renderer->setGraphicsObjectScale<Box>("all", scale); 1093 } 1094 return TCL_OK; 1095 } 1096 1097 static int 1098 BoxVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 1099 Tcl_Obj *const *objv) 1100 { 1101 bool state; 1102 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 1103 return TCL_ERROR; 1104 } 1105 if (objc == 4) { 1106 const char *name = Tcl_GetString(objv[3]); 1107 g_renderer->setGraphicsObjectVisibility<Box>(name, state); 1108 } else { 1109 g_renderer->setGraphicsObjectVisibility<Box>("all", state); 1110 } 1111 return TCL_OK; 1112 } 1113 1114 static int 1115 BoxWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc, 1116 Tcl_Obj *const *objv) 1117 { 1118 bool state; 1119 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 1120 return TCL_ERROR; 1121 } 1122 if (objc == 4) { 1123 const char *name = Tcl_GetString(objv[3]); 1124 g_renderer->setGraphicsObjectWireframe<Box>(name, state); 1125 } else { 1126 g_renderer->setGraphicsObjectWireframe<Box>("all", state); 1127 } 1128 return TCL_OK; 1129 } 1130 1131 static Rappture::CmdSpec boxOps[] = { 1132 {"add", 1, BoxAddOp, 3, 3, "name"}, 1133 {"color", 1, BoxColorOp, 5, 6, "r g b ?name?"}, 1134 {"delete", 1, BoxDeleteOp, 2, 3, "?name?"}, 1135 {"edges", 1, BoxEdgeVisibilityOp, 3, 4, "bool ?name?"}, 1136 {"lighting", 3, BoxLightingOp, 3, 4, "bool ?name?"}, 1137 {"linecolor", 5, BoxLineColorOp, 5, 6, "r g b ?name?"}, 1138 {"linewidth", 5, BoxLineWidthOp, 3, 4, "width ?name?"}, 1139 {"material", 1, BoxMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"}, 1140 {"opacity", 2, BoxOpacityOp, 3, 4, "value ?name?"}, 1141 {"orient", 2, BoxOrientOp, 6, 7, "qw qx qy qz ?name?"}, 1142 {"pos", 2, BoxPositionOp, 5, 6, "x y z ?name?"}, 1143 {"scale", 1, BoxScaleOp, 5, 6, "sx sy sz ?name?"}, 1144 {"visible", 1, BoxVisibleOp, 3, 4, "bool ?name?"}, 1145 {"wireframe", 1, BoxWireframeOp, 3, 4, "bool ?name?"} 1146 }; 1147 static int nBoxOps = NumCmdSpecs(boxOps); 1148 1149 static int 1150 BoxCmd(ClientData clientData, Tcl_Interp *interp, int objc, 1151 Tcl_Obj *const *objv) 1152 { 1153 Tcl_ObjCmdProc *proc; 1154 1155 proc = Rappture::GetOpFromObj(interp, nBoxOps, boxOps, 362 1156 Rappture::CMDSPEC_ARG1, objc, objv, 0); 363 1157 if (proc == NULL) { … … 552 1346 553 1347 static Rappture::CmdSpec cameraOps[] = { 554 {"get", 1, CameraGetOp, 2, 2, ""},555 {"mode", 1, CameraModeOp, 3, 3, "mode"},1348 {"get", 1, CameraGetOp, 2, 2, ""}, 1349 {"mode", 1, CameraModeOp, 3, 3, "mode"}, 556 1350 {"orient", 3, CameraOrientOp, 6, 6, "qw qx qy qz"}, 557 {"ortho", 1, CameraOrthoOp, 7, 7, "coordMode x y width height"},558 {"pan", 1, CameraPanOp, 4, 4, "panX panY"},559 {"reset", 2, CameraResetOp, 2, 3, "?all?"},1351 {"ortho", 1, CameraOrthoOp, 7, 7, "coordMode x y width height"}, 1352 {"pan", 1, CameraPanOp, 4, 4, "panX panY"}, 1353 {"reset", 2, CameraResetOp, 2, 3, "?all?"}, 560 1354 {"rotate", 2, CameraRotateOp, 5, 5, "angle angle angle"}, 561 {"set", 1, CameraSetOp, 11, 11, "posX posY posZ focalPtX focalPtY focalPtZ viewUpX viewUpY viewUpZ"},562 {"zoom", 1, CameraZoomOp, 3, 3, "zoomAmount"}1355 {"set", 1, CameraSetOp, 11, 11, "posX posY posZ focalPtX focalPtY focalPtZ viewUpX viewUpY viewUpZ"}, 1356 {"zoom", 1, CameraZoomOp, 3, 3, "zoomAmount"} 563 1357 }; 564 1358 static int nCameraOps = NumCmdSpecs(cameraOps); … … 692 1486 693 1487 static int 1488 ConeAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 1489 Tcl_Obj *const *objv) 1490 { 1491 double radius, height; 1492 bool cap; 1493 if (Tcl_GetDoubleFromObj(interp, objv[2], &radius) != TCL_OK || 1494 Tcl_GetDoubleFromObj(interp, objv[3], &height) != TCL_OK || 1495 GetBooleanFromObj(interp, objv[4], &cap) != TCL_OK) { 1496 return TCL_ERROR; 1497 } 1498 const char *name = Tcl_GetString(objv[5]); 1499 if (!g_renderer->addCone(name, radius, height, cap)) { 1500 Tcl_AppendResult(interp, "Failed to create cone", (char*)NULL); 1501 return TCL_ERROR; 1502 } 1503 return TCL_OK; 1504 } 1505 1506 static int 1507 ConeDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 1508 Tcl_Obj *const *objv) 1509 { 1510 if (objc == 3) { 1511 const char *name = Tcl_GetString(objv[2]); 1512 g_renderer->deleteGraphicsObject<Cone>(name); 1513 } else { 1514 g_renderer->deleteGraphicsObject<Cone>("all"); 1515 } 1516 return TCL_OK; 1517 } 1518 1519 static int 1520 ConeColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 1521 Tcl_Obj *const *objv) 1522 { 1523 float color[3]; 1524 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 1525 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 1526 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 1527 return TCL_ERROR; 1528 } 1529 if (objc == 6) { 1530 const char *name = Tcl_GetString(objv[5]); 1531 g_renderer->setGraphicsObjectColor<Cone>(name, color); 1532 } else { 1533 g_renderer->setGraphicsObjectColor<Cone>("all", color); 1534 } 1535 return TCL_OK; 1536 } 1537 1538 static int 1539 ConeEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc, 1540 Tcl_Obj *const *objv) 1541 { 1542 bool state; 1543 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 1544 return TCL_ERROR; 1545 } 1546 if (objc == 4) { 1547 const char *name = Tcl_GetString(objv[3]); 1548 g_renderer->setGraphicsObjectEdgeVisibility<Cone>(name, state); 1549 } else { 1550 g_renderer->setGraphicsObjectEdgeVisibility<Cone>("all", state); 1551 } 1552 return TCL_OK; 1553 } 1554 1555 static int 1556 ConeLightingOp(ClientData clientData, Tcl_Interp *interp, int objc, 1557 Tcl_Obj *const *objv) 1558 { 1559 bool state; 1560 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 1561 return TCL_ERROR; 1562 } 1563 if (objc == 4) { 1564 const char *name = Tcl_GetString(objv[3]); 1565 g_renderer->setGraphicsObjectLighting<Cone>(name, state); 1566 } else { 1567 g_renderer->setGraphicsObjectLighting<Cone>("all", state); 1568 } 1569 return TCL_OK; 1570 } 1571 1572 static int 1573 ConeLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 1574 Tcl_Obj *const *objv) 1575 { 1576 float color[3]; 1577 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 1578 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 1579 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 1580 return TCL_ERROR; 1581 } 1582 if (objc == 6) { 1583 const char *name = Tcl_GetString(objv[5]); 1584 g_renderer->setGraphicsObjectEdgeColor<Cone>(name, color); 1585 } else { 1586 g_renderer->setGraphicsObjectEdgeColor<Cone>("all", color); 1587 } 1588 return TCL_OK; 1589 } 1590 1591 static int 1592 ConeLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc, 1593 Tcl_Obj *const *objv) 1594 { 1595 float width; 1596 if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) { 1597 return TCL_ERROR; 1598 } 1599 if (objc == 4) { 1600 const char *name = Tcl_GetString(objv[3]); 1601 g_renderer->setGraphicsObjectEdgeWidth<Cone>(name, width); 1602 } else { 1603 g_renderer->setGraphicsObjectEdgeWidth<Cone>("all", width); 1604 } 1605 return TCL_OK; 1606 } 1607 1608 static int 1609 ConeMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc, 1610 Tcl_Obj *const *objv) 1611 { 1612 double ambient, diffuse, specCoeff, specPower; 1613 if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK || 1614 Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK || 1615 Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK || 1616 Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) { 1617 return TCL_ERROR; 1618 } 1619 1620 if (objc == 7) { 1621 const char *name = Tcl_GetString(objv[6]); 1622 g_renderer->setGraphicsObjectAmbient<Cone>(name, ambient); 1623 g_renderer->setGraphicsObjectDiffuse<Cone>(name, diffuse); 1624 g_renderer->setGraphicsObjectSpecular<Cone>(name, specCoeff, specPower); 1625 } else { 1626 g_renderer->setGraphicsObjectAmbient<Cone>("all", ambient); 1627 g_renderer->setGraphicsObjectDiffuse<Cone>("all", diffuse); 1628 g_renderer->setGraphicsObjectSpecular<Cone>("all", specCoeff, specPower); 1629 } 1630 return TCL_OK; 1631 } 1632 1633 static int 1634 ConeOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc, 1635 Tcl_Obj *const *objv) 1636 { 1637 double opacity; 1638 if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) { 1639 return TCL_ERROR; 1640 } 1641 if (objc == 4) { 1642 const char *name = Tcl_GetString(objv[3]); 1643 g_renderer->setGraphicsObjectOpacity<Cone>(name, opacity); 1644 } else { 1645 g_renderer->setGraphicsObjectOpacity<Cone>("all", opacity); 1646 } 1647 return TCL_OK; 1648 } 1649 1650 static int 1651 ConeOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 1652 Tcl_Obj *const *objv) 1653 { 1654 double quat[4]; 1655 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 1656 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 1657 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 1658 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 1659 return TCL_ERROR; 1660 } 1661 if (objc == 7) { 1662 const char *name = Tcl_GetString(objv[6]); 1663 g_renderer->setGraphicsObjectOrientation<Cone>(name, quat); 1664 } else { 1665 g_renderer->setGraphicsObjectOrientation<Cone>("all", quat); 1666 } 1667 return TCL_OK; 1668 } 1669 1670 static int 1671 ConePositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 1672 Tcl_Obj *const *objv) 1673 { 1674 double pos[3]; 1675 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 1676 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 1677 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 1678 return TCL_ERROR; 1679 } 1680 if (objc == 6) { 1681 const char *name = Tcl_GetString(objv[5]); 1682 g_renderer->setGraphicsObjectPosition<Cone>(name, pos); 1683 } else { 1684 g_renderer->setGraphicsObjectPosition<Cone>("all", pos); 1685 } 1686 return TCL_OK; 1687 } 1688 1689 static int 1690 ConeResolutionOp(ClientData clientData, Tcl_Interp *interp, int objc, 1691 Tcl_Obj *const *objv) 1692 { 1693 int res; 1694 if (Tcl_GetIntFromObj(interp, objv[2], &res) != TCL_OK) { 1695 return TCL_ERROR; 1696 } 1697 if (objc == 4) { 1698 const char *name = Tcl_GetString(objv[3]); 1699 g_renderer->setConeResolution(name, res); 1700 } else { 1701 g_renderer->setConeResolution("all", res); 1702 } 1703 return TCL_OK; 1704 } 1705 1706 static int 1707 ConeScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 1708 Tcl_Obj *const *objv) 1709 { 1710 double scale[3]; 1711 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 1712 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 1713 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 1714 return TCL_ERROR; 1715 } 1716 if (objc == 6) { 1717 const char *name = Tcl_GetString(objv[5]); 1718 g_renderer->setGraphicsObjectScale<Cone>(name, scale); 1719 } else { 1720 g_renderer->setGraphicsObjectScale<Cone>("all", scale); 1721 } 1722 return TCL_OK; 1723 } 1724 1725 static int 1726 ConeVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 1727 Tcl_Obj *const *objv) 1728 { 1729 bool state; 1730 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 1731 return TCL_ERROR; 1732 } 1733 if (objc == 4) { 1734 const char *name = Tcl_GetString(objv[3]); 1735 g_renderer->setGraphicsObjectVisibility<Cone>(name, state); 1736 } else { 1737 g_renderer->setGraphicsObjectVisibility<Cone>("all", state); 1738 } 1739 return TCL_OK; 1740 } 1741 1742 static int 1743 ConeWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc, 1744 Tcl_Obj *const *objv) 1745 { 1746 bool state; 1747 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 1748 return TCL_ERROR; 1749 } 1750 if (objc == 4) { 1751 const char *name = Tcl_GetString(objv[3]); 1752 g_renderer->setGraphicsObjectWireframe<Cone>(name, state); 1753 } else { 1754 g_renderer->setGraphicsObjectWireframe<Cone>("all", state); 1755 } 1756 return TCL_OK; 1757 } 1758 1759 static Rappture::CmdSpec coneOps[] = { 1760 {"add", 1, ConeAddOp, 6, 6, "radius height cap name"}, 1761 {"color", 1, ConeColorOp, 5, 6, "r g b ?name?"}, 1762 {"delete", 1, ConeDeleteOp, 2, 3, "?name?"}, 1763 {"edges", 1, ConeEdgeVisibilityOp, 3, 4, "bool ?name?"}, 1764 {"lighting", 3, ConeLightingOp, 3, 4, "bool ?name?"}, 1765 {"linecolor", 5, ConeLineColorOp, 5, 6, "r g b ?name?"}, 1766 {"linewidth", 5, ConeLineWidthOp, 3, 4, "width ?name?"}, 1767 {"material", 1, ConeMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"}, 1768 {"opacity", 2, ConeOpacityOp, 3, 4, "value ?name?"}, 1769 {"orient", 2, ConeOrientOp, 6, 7, "qw qx qy qz ?name?"}, 1770 {"pos", 2, ConePositionOp, 5, 6, "x y z ?name?"}, 1771 {"resolution",1, ConeResolutionOp, 3, 4, "res ?name?"}, 1772 {"scale", 1, ConeScaleOp, 5, 6, "sx sy sz ?name?"}, 1773 {"visible", 1, ConeVisibleOp, 3, 4, "bool ?name?"}, 1774 {"wireframe", 1, ConeWireframeOp, 3, 4, "bool ?name?"} 1775 }; 1776 static int nConeOps = NumCmdSpecs(coneOps); 1777 1778 static int 1779 ConeCmd(ClientData clientData, Tcl_Interp *interp, int objc, 1780 Tcl_Obj *const *objv) 1781 { 1782 Tcl_ObjCmdProc *proc; 1783 1784 proc = Rappture::GetOpFromObj(interp, nConeOps, coneOps, 1785 Rappture::CMDSPEC_ARG1, objc, objv, 0); 1786 if (proc == NULL) { 1787 return TCL_ERROR; 1788 } 1789 return (*proc) (clientData, interp, objc, objv); 1790 } 1791 1792 static int 694 1793 Contour2DAddContourListOp(ClientData clientData, Tcl_Interp *interp, int objc, 695 1794 Tcl_Obj *const *objv) … … 784 1883 785 1884 static int 1885 Contour2DColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc, 1886 Tcl_Obj *const *objv) 1887 { 1888 const char *colorMapName = Tcl_GetString(objv[2]); 1889 if (objc == 4) { 1890 const char *dataSetName = Tcl_GetString(objv[3]); 1891 g_renderer->setGraphicsObjectColorMap<Contour2D>(dataSetName, colorMapName); 1892 } else { 1893 g_renderer->setGraphicsObjectColorMap<Contour2D>("all", colorMapName); 1894 } 1895 return TCL_OK; 1896 } 1897 1898 static int 1899 Contour2DColorModeOp(ClientData clientData, Tcl_Interp *interp, int objc, 1900 Tcl_Obj *const *objv) 1901 { 1902 Contour2D::ColorMode mode; 1903 const char *str = Tcl_GetString(objv[2]); 1904 if (str[0] == 'c' && strcmp(str, "ccolor") == 0) { 1905 mode = Contour2D::COLOR_CONSTANT; 1906 } else if (str[0] == 's' && strcmp(str, "scalar") == 0) { 1907 mode = Contour2D::COLOR_BY_SCALAR; 1908 } else if (str[0] == 'v' && strcmp(str, "vmag") == 0) { 1909 mode = Contour2D::COLOR_BY_VECTOR_MAGNITUDE; 1910 } else if (str[0] == 'v' && strcmp(str, "vx") == 0) { 1911 mode = Contour2D::COLOR_BY_VECTOR_X; 1912 } else if (str[0] == 'v' && strcmp(str, "vy") == 0) { 1913 mode = Contour2D::COLOR_BY_VECTOR_Y; 1914 } else if (str[0] == 'v' && strcmp(str, "vz") == 0) { 1915 mode = Contour2D::COLOR_BY_VECTOR_Z; 1916 } else { 1917 Tcl_AppendResult(interp, "bad color mode option \"", str, 1918 "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor'", (char*)NULL); 1919 return TCL_ERROR; 1920 } 1921 const char *fieldName = Tcl_GetString(objv[3]); 1922 if (mode == Contour2D::COLOR_CONSTANT) { 1923 fieldName = NULL; 1924 } 1925 if (objc == 5) { 1926 const char *name = Tcl_GetString(objv[4]); 1927 g_renderer->setContour2DColorMode(name, mode, fieldName); 1928 } else { 1929 g_renderer->setContour2DColorMode("all", mode, fieldName); 1930 } 1931 return TCL_OK; 1932 } 1933 1934 static int 786 1935 Contour2DLightingOp(ClientData clientData, Tcl_Interp *interp, int objc, 787 1936 Tcl_Obj *const *objv) … … 930 2079 static Rappture::CmdSpec contour2dOps[] = { 931 2080 {"add", 1, Contour2DAddOp, 4, 5, "oper value ?dataSetName?"}, 932 {"color", 1, Contour2DLineColorOp, 5, 6, "r g b ?dataSetName?"}, 2081 {"ccolor", 2, Contour2DLineColorOp, 5, 6, "r g b ?dataSetName?"}, 2082 {"colormap", 7, Contour2DColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 2083 {"colormode", 7, Contour2DColorModeOp, 4, 5, "mode fieldName ?dataSetName?"}, 933 2084 {"delete", 1, Contour2DDeleteOp, 2, 3, "?dataSetName?"}, 934 2085 {"lighting", 3, Contour2DLightingOp, 3, 4, "bool ?dataSetName?"}, … … 1684 2835 1685 2836 static int 2837 CylinderAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 2838 Tcl_Obj *const *objv) 2839 { 2840 double radius, height; 2841 bool cap = true; 2842 if (Tcl_GetDoubleFromObj(interp, objv[2], &radius) != TCL_OK || 2843 Tcl_GetDoubleFromObj(interp, objv[3], &height) != TCL_OK || 2844 GetBooleanFromObj(interp, objv[4], &cap) != TCL_OK) { 2845 return TCL_ERROR; 2846 } 2847 const char *name = Tcl_GetString(objv[5]); 2848 if (!g_renderer->addCylinder(name, radius, height, cap)) { 2849 Tcl_AppendResult(interp, "Failed to create cylinder", (char*)NULL); 2850 return TCL_ERROR; 2851 } 2852 return TCL_OK; 2853 } 2854 2855 static int 2856 CylinderDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 2857 Tcl_Obj *const *objv) 2858 { 2859 if (objc == 3) { 2860 const char *name = Tcl_GetString(objv[2]); 2861 g_renderer->deleteGraphicsObject<Cylinder>(name); 2862 } else { 2863 g_renderer->deleteGraphicsObject<Cylinder>("all"); 2864 } 2865 return TCL_OK; 2866 } 2867 2868 static int 2869 CylinderColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 2870 Tcl_Obj *const *objv) 2871 { 2872 float color[3]; 2873 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 2874 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 2875 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 2876 return TCL_ERROR; 2877 } 2878 if (objc == 6) { 2879 const char *name = Tcl_GetString(objv[5]); 2880 g_renderer->setGraphicsObjectColor<Cylinder>(name, color); 2881 } else { 2882 g_renderer->setGraphicsObjectColor<Cylinder>("all", color); 2883 } 2884 return TCL_OK; 2885 } 2886 2887 static int 2888 CylinderEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc, 2889 Tcl_Obj *const *objv) 2890 { 2891 bool state; 2892 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 2893 return TCL_ERROR; 2894 } 2895 if (objc == 4) { 2896 const char *name = Tcl_GetString(objv[3]); 2897 g_renderer->setGraphicsObjectEdgeVisibility<Cylinder>(name, state); 2898 } else { 2899 g_renderer->setGraphicsObjectEdgeVisibility<Cylinder>("all", state); 2900 } 2901 return TCL_OK; 2902 } 2903 2904 static int 2905 CylinderLightingOp(ClientData clientData, Tcl_Interp *interp, int objc, 2906 Tcl_Obj *const *objv) 2907 { 2908 bool state; 2909 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 2910 return TCL_ERROR; 2911 } 2912 if (objc == 4) { 2913 const char *name = Tcl_GetString(objv[3]); 2914 g_renderer->setGraphicsObjectLighting<Cylinder>(name, state); 2915 } else { 2916 g_renderer->setGraphicsObjectLighting<Cylinder>("all", state); 2917 } 2918 return TCL_OK; 2919 } 2920 2921 static int 2922 CylinderLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 2923 Tcl_Obj *const *objv) 2924 { 2925 float color[3]; 2926 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 2927 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 2928 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 2929 return TCL_ERROR; 2930 } 2931 if (objc == 6) { 2932 const char *name = Tcl_GetString(objv[5]); 2933 g_renderer->setGraphicsObjectEdgeColor<Cylinder>(name, color); 2934 } else { 2935 g_renderer->setGraphicsObjectEdgeColor<Cylinder>("all", color); 2936 } 2937 return TCL_OK; 2938 } 2939 2940 static int 2941 CylinderLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc, 2942 Tcl_Obj *const *objv) 2943 { 2944 float width; 2945 if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) { 2946 return TCL_ERROR; 2947 } 2948 if (objc == 4) { 2949 const char *name = Tcl_GetString(objv[3]); 2950 g_renderer->setGraphicsObjectEdgeWidth<Cylinder>(name, width); 2951 } else { 2952 g_renderer->setGraphicsObjectEdgeWidth<Cylinder>("all", width); 2953 } 2954 return TCL_OK; 2955 } 2956 2957 static int 2958 CylinderMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc, 2959 Tcl_Obj *const *objv) 2960 { 2961 double ambient, diffuse, specCoeff, specPower; 2962 if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK || 2963 Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK || 2964 Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK || 2965 Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) { 2966 return TCL_ERROR; 2967 } 2968 2969 if (objc == 7) { 2970 const char *name = Tcl_GetString(objv[6]); 2971 g_renderer->setGraphicsObjectAmbient<Cylinder>(name, ambient); 2972 g_renderer->setGraphicsObjectDiffuse<Cylinder>(name, diffuse); 2973 g_renderer->setGraphicsObjectSpecular<Cylinder>(name, specCoeff, specPower); 2974 } else { 2975 g_renderer->setGraphicsObjectAmbient<Cylinder>("all", ambient); 2976 g_renderer->setGraphicsObjectDiffuse<Cylinder>("all", diffuse); 2977 g_renderer->setGraphicsObjectSpecular<Cylinder>("all", specCoeff, specPower); 2978 } 2979 return TCL_OK; 2980 } 2981 2982 static int 2983 CylinderOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc, 2984 Tcl_Obj *const *objv) 2985 { 2986 double opacity; 2987 if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) { 2988 return TCL_ERROR; 2989 } 2990 if (objc == 4) { 2991 const char *name = Tcl_GetString(objv[3]); 2992 g_renderer->setGraphicsObjectOpacity<Cylinder>(name, opacity); 2993 } else { 2994 g_renderer->setGraphicsObjectOpacity<Cylinder>("all", opacity); 2995 } 2996 return TCL_OK; 2997 } 2998 2999 static int 3000 CylinderOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 3001 Tcl_Obj *const *objv) 3002 { 3003 double quat[4]; 3004 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 3005 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 3006 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 3007 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 3008 return TCL_ERROR; 3009 } 3010 if (objc == 7) { 3011 const char *name = Tcl_GetString(objv[6]); 3012 g_renderer->setGraphicsObjectOrientation<Cylinder>(name, quat); 3013 } else { 3014 g_renderer->setGraphicsObjectOrientation<Cylinder>("all", quat); 3015 } 3016 return TCL_OK; 3017 } 3018 3019 static int 3020 CylinderPositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 3021 Tcl_Obj *const *objv) 3022 { 3023 double pos[3]; 3024 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 3025 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 3026 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 3027 return TCL_ERROR; 3028 } 3029 if (objc == 6) { 3030 const char *name = Tcl_GetString(objv[5]); 3031 g_renderer->setGraphicsObjectPosition<Cylinder>(name, pos); 3032 } else { 3033 g_renderer->setGraphicsObjectPosition<Cylinder>("all", pos); 3034 } 3035 return TCL_OK; 3036 } 3037 3038 static int 3039 CylinderResolutionOp(ClientData clientData, Tcl_Interp *interp, int objc, 3040 Tcl_Obj *const *objv) 3041 { 3042 int res; 3043 if (Tcl_GetIntFromObj(interp, objv[2], &res) != TCL_OK) { 3044 return TCL_ERROR; 3045 } 3046 if (objc == 4) { 3047 const char *name = Tcl_GetString(objv[3]); 3048 g_renderer->setCylinderResolution(name, res); 3049 } else { 3050 g_renderer->setCylinderResolution("all", res); 3051 } 3052 return TCL_OK; 3053 } 3054 3055 static int 3056 CylinderScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 3057 Tcl_Obj *const *objv) 3058 { 3059 double scale[3]; 3060 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 3061 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 3062 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 3063 return TCL_ERROR; 3064 } 3065 if (objc == 6) { 3066 const char *name = Tcl_GetString(objv[5]); 3067 g_renderer->setGraphicsObjectScale<Cylinder>(name, scale); 3068 } else { 3069 g_renderer->setGraphicsObjectScale<Cylinder>("all", scale); 3070 } 3071 return TCL_OK; 3072 } 3073 3074 static int 3075 CylinderVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 3076 Tcl_Obj *const *objv) 3077 { 3078 bool state; 3079 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 3080 return TCL_ERROR; 3081 } 3082 if (objc == 4) { 3083 const char *name = Tcl_GetString(objv[3]); 3084 g_renderer->setGraphicsObjectVisibility<Cylinder>(name, state); 3085 } else { 3086 g_renderer->setGraphicsObjectVisibility<Cylinder>("all", state); 3087 } 3088 return TCL_OK; 3089 } 3090 3091 static int 3092 CylinderWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc, 3093 Tcl_Obj *const *objv) 3094 { 3095 bool state; 3096 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 3097 return TCL_ERROR; 3098 } 3099 if (objc == 4) { 3100 const char *name = Tcl_GetString(objv[3]); 3101 g_renderer->setGraphicsObjectWireframe<Cylinder>(name, state); 3102 } else { 3103 g_renderer->setGraphicsObjectWireframe<Cylinder>("all", state); 3104 } 3105 return TCL_OK; 3106 } 3107 3108 static Rappture::CmdSpec cylinderOps[] = { 3109 {"add", 1, CylinderAddOp, 6, 6, " radius height cap name"}, 3110 {"color", 1, CylinderColorOp, 5, 6, "r g b ?name?"}, 3111 {"delete", 1, CylinderDeleteOp, 2, 3, "?name?"}, 3112 {"edges", 1, CylinderEdgeVisibilityOp, 3, 4, "bool ?name?"}, 3113 {"lighting", 3, CylinderLightingOp, 3, 4, "bool ?name?"}, 3114 {"linecolor", 5, CylinderLineColorOp, 5, 6, "r g b ?name?"}, 3115 {"linewidth", 5, CylinderLineWidthOp, 3, 4, "width ?name?"}, 3116 {"material", 1, CylinderMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"}, 3117 {"opacity", 2, CylinderOpacityOp, 3, 4, "value ?name?"}, 3118 {"orient", 2, CylinderOrientOp, 6, 7, "qw qx qy qz ?name?"}, 3119 {"pos", 2, CylinderPositionOp, 5, 6, "x y z ?name?"}, 3120 {"resolution",1, CylinderResolutionOp, 3, 4, "res ?name?"}, 3121 {"scale", 1, CylinderScaleOp, 5, 6, "sx sy sz ?name?"}, 3122 {"visible", 1, CylinderVisibleOp, 3, 4, "bool ?name?"}, 3123 {"wireframe", 1, CylinderWireframeOp, 3, 4, "bool ?name?"} 3124 }; 3125 static int nCylinderOps = NumCmdSpecs(cylinderOps); 3126 3127 static int 3128 CylinderCmd(ClientData clientData, Tcl_Interp *interp, int objc, 3129 Tcl_Obj *const *objv) 3130 { 3131 Tcl_ObjCmdProc *proc; 3132 3133 proc = Rappture::GetOpFromObj(interp, nCylinderOps, cylinderOps, 3134 Rappture::CMDSPEC_ARG1, objc, objv, 0); 3135 if (proc == NULL) { 3136 return TCL_ERROR; 3137 } 3138 return (*proc) (clientData, interp, objc, objv); 3139 } 3140 3141 static int 1686 3142 DataSetActiveScalarsOp(ClientData clientData, Tcl_Interp *interp, int objc, 1687 3143 Tcl_Obj *const *objv) … … 2099 3555 2100 3556 proc = Rappture::GetOpFromObj(interp, nDataSetOps, dataSetOps, 3557 Rappture::CMDSPEC_ARG1, objc, objv, 0); 3558 if (proc == NULL) { 3559 return TCL_ERROR; 3560 } 3561 return (*proc) (clientData, interp, objc, objv); 3562 } 3563 3564 static int 3565 DiskAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 3566 Tcl_Obj *const *objv) 3567 { 3568 double innerRadius, outerRadius; 3569 if (Tcl_GetDoubleFromObj(interp, objv[2], &innerRadius) != TCL_OK || 3570 Tcl_GetDoubleFromObj(interp, objv[3], &outerRadius) != TCL_OK) { 3571 return TCL_ERROR; 3572 } 3573 const char *name = Tcl_GetString(objv[4]); 3574 if (!g_renderer->addDisk(name, innerRadius, outerRadius)) { 3575 Tcl_AppendResult(interp, "Failed to create disk", (char*)NULL); 3576 return TCL_ERROR; 3577 } 3578 return TCL_OK; 3579 } 3580 3581 static int 3582 DiskDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 3583 Tcl_Obj *const *objv) 3584 { 3585 if (objc == 3) { 3586 const char *name = Tcl_GetString(objv[2]); 3587 g_renderer->deleteGraphicsObject<Disk>(name); 3588 } else { 3589 g_renderer->deleteGraphicsObject<Disk>("all"); 3590 } 3591 return TCL_OK; 3592 } 3593 3594 static int 3595 DiskColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 3596 Tcl_Obj *const *objv) 3597 { 3598 float color[3]; 3599 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 3600 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 3601 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 3602 return TCL_ERROR; 3603 } 3604 if (objc == 6) { 3605 const char *name = Tcl_GetString(objv[5]); 3606 g_renderer->setGraphicsObjectColor<Disk>(name, color); 3607 } else { 3608 g_renderer->setGraphicsObjectColor<Disk>("all", color); 3609 } 3610 return TCL_OK; 3611 } 3612 3613 static int 3614 DiskEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc, 3615 Tcl_Obj *const *objv) 3616 { 3617 bool state; 3618 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 3619 return TCL_ERROR; 3620 } 3621 if (objc == 4) { 3622 const char *name = Tcl_GetString(objv[3]); 3623 g_renderer->setGraphicsObjectEdgeVisibility<Disk>(name, state); 3624 } else { 3625 g_renderer->setGraphicsObjectEdgeVisibility<Disk>("all", state); 3626 } 3627 return TCL_OK; 3628 } 3629 3630 static int 3631 DiskLightingOp(ClientData clientData, Tcl_Interp *interp, int objc, 3632 Tcl_Obj *const *objv) 3633 { 3634 bool state; 3635 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 3636 return TCL_ERROR; 3637 } 3638 if (objc == 4) { 3639 const char *name = Tcl_GetString(objv[3]); 3640 g_renderer->setGraphicsObjectLighting<Disk>(name, state); 3641 } else { 3642 g_renderer->setGraphicsObjectLighting<Disk>("all", state); 3643 } 3644 return TCL_OK; 3645 } 3646 3647 static int 3648 DiskLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 3649 Tcl_Obj *const *objv) 3650 { 3651 float color[3]; 3652 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 3653 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 3654 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 3655 return TCL_ERROR; 3656 } 3657 if (objc == 6) { 3658 const char *name = Tcl_GetString(objv[5]); 3659 g_renderer->setGraphicsObjectEdgeColor<Disk>(name, color); 3660 } else { 3661 g_renderer->setGraphicsObjectEdgeColor<Disk>("all", color); 3662 } 3663 return TCL_OK; 3664 } 3665 3666 static int 3667 DiskLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc, 3668 Tcl_Obj *const *objv) 3669 { 3670 float width; 3671 if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) { 3672 return TCL_ERROR; 3673 } 3674 if (objc == 4) { 3675 const char *name = Tcl_GetString(objv[3]); 3676 g_renderer->setGraphicsObjectEdgeWidth<Disk>(name, width); 3677 } else { 3678 g_renderer->setGraphicsObjectEdgeWidth<Disk>("all", width); 3679 } 3680 return TCL_OK; 3681 } 3682 3683 static int 3684 DiskMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc, 3685 Tcl_Obj *const *objv) 3686 { 3687 double ambient, diffuse, specCoeff, specPower; 3688 if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK || 3689 Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK || 3690 Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK || 3691 Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) { 3692 return TCL_ERROR; 3693 } 3694 3695 if (objc == 7) { 3696 const char *name = Tcl_GetString(objv[6]); 3697 g_renderer->setGraphicsObjectAmbient<Disk>(name, ambient); 3698 g_renderer->setGraphicsObjectDiffuse<Disk>(name, diffuse); 3699 g_renderer->setGraphicsObjectSpecular<Disk>(name, specCoeff, specPower); 3700 } else { 3701 g_renderer->setGraphicsObjectAmbient<Disk>("all", ambient); 3702 g_renderer->setGraphicsObjectDiffuse<Disk>("all", diffuse); 3703 g_renderer->setGraphicsObjectSpecular<Disk>("all", specCoeff, specPower); 3704 } 3705 return TCL_OK; 3706 } 3707 3708 static int 3709 DiskOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc, 3710 Tcl_Obj *const *objv) 3711 { 3712 double opacity; 3713 if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) { 3714 return TCL_ERROR; 3715 } 3716 if (objc == 4) { 3717 const char *name = Tcl_GetString(objv[3]); 3718 g_renderer->setGraphicsObjectOpacity<Disk>(name, opacity); 3719 } else { 3720 g_renderer->setGraphicsObjectOpacity<Disk>("all", opacity); 3721 } 3722 return TCL_OK; 3723 } 3724 3725 static int 3726 DiskOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 3727 Tcl_Obj *const *objv) 3728 { 3729 double quat[4]; 3730 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 3731 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 3732 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 3733 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 3734 return TCL_ERROR; 3735 } 3736 if (objc == 7) { 3737 const char *name = Tcl_GetString(objv[6]); 3738 g_renderer->setGraphicsObjectOrientation<Disk>(name, quat); 3739 } else { 3740 g_renderer->setGraphicsObjectOrientation<Disk>("all", quat); 3741 } 3742 return TCL_OK; 3743 } 3744 3745 static int 3746 DiskPositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 3747 Tcl_Obj *const *objv) 3748 { 3749 double pos[3]; 3750 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 3751 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 3752 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 3753 return TCL_ERROR; 3754 } 3755 if (objc == 6) { 3756 const char *name = Tcl_GetString(objv[5]); 3757 g_renderer->setGraphicsObjectPosition<Disk>(name, pos); 3758 } else { 3759 g_renderer->setGraphicsObjectPosition<Disk>("all", pos); 3760 } 3761 return TCL_OK; 3762 } 3763 3764 static int 3765 DiskResolutionOp(ClientData clientData, Tcl_Interp *interp, int objc, 3766 Tcl_Obj *const *objv) 3767 { 3768 int radial, circum; 3769 if (Tcl_GetIntFromObj(interp, objv[2], &radial) != TCL_OK || 3770 Tcl_GetIntFromObj(interp, objv[3], &circum) != TCL_OK) { 3771 return TCL_ERROR; 3772 } 3773 if (objc == 5) { 3774 const char *name = Tcl_GetString(objv[4]); 3775 g_renderer->setDiskResolution(name, radial, circum); 3776 } else { 3777 g_renderer->setDiskResolution("all", radial, circum); 3778 } 3779 return TCL_OK; 3780 } 3781 3782 static int 3783 DiskScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 3784 Tcl_Obj *const *objv) 3785 { 3786 double scale[3]; 3787 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 3788 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 3789 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 3790 return TCL_ERROR; 3791 } 3792 if (objc == 6) { 3793 const char *name = Tcl_GetString(objv[5]); 3794 g_renderer->setGraphicsObjectScale<Disk>(name, scale); 3795 } else { 3796 g_renderer->setGraphicsObjectScale<Disk>("all", scale); 3797 } 3798 return TCL_OK; 3799 } 3800 3801 static int 3802 DiskVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 3803 Tcl_Obj *const *objv) 3804 { 3805 bool state; 3806 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 3807 return TCL_ERROR; 3808 } 3809 if (objc == 4) { 3810 const char *name = Tcl_GetString(objv[3]); 3811 g_renderer->setGraphicsObjectVisibility<Disk>(name, state); 3812 } else { 3813 g_renderer->setGraphicsObjectVisibility<Disk>("all", state); 3814 } 3815 return TCL_OK; 3816 } 3817 3818 static int 3819 DiskWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc, 3820 Tcl_Obj *const *objv) 3821 { 3822 bool state; 3823 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 3824 return TCL_ERROR; 3825 } 3826 if (objc == 4) { 3827 const char *name = Tcl_GetString(objv[3]); 3828 g_renderer->setGraphicsObjectWireframe<Disk>(name, state); 3829 } else { 3830 g_renderer->setGraphicsObjectWireframe<Disk>("all", state); 3831 } 3832 return TCL_OK; 3833 } 3834 3835 static Rappture::CmdSpec diskOps[] = { 3836 {"add", 1, DiskAddOp, 5, 5, "innerRadius outerRadius name"}, 3837 {"color", 1, DiskColorOp, 5, 6, "r g b ?name?"}, 3838 {"delete", 1, DiskDeleteOp, 2, 3, "?name?"}, 3839 {"edges", 1, DiskEdgeVisibilityOp, 3, 4, "bool ?name?"}, 3840 {"lighting", 3, DiskLightingOp, 3, 4, "bool ?name?"}, 3841 {"linecolor", 5, DiskLineColorOp, 5, 6, "r g b ?name?"}, 3842 {"linewidth", 5, DiskLineWidthOp, 3, 4, "width ?name?"}, 3843 {"material", 1, DiskMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"}, 3844 {"opacity", 2, DiskOpacityOp, 3, 4, "value ?name?"}, 3845 {"orient", 2, DiskOrientOp, 6, 7, "qw qx qy qz ?name?"}, 3846 {"pos", 2, DiskPositionOp, 5, 6, "x y z ?name?"}, 3847 {"resolution",1, DiskResolutionOp, 4, 5, "resRadial resCircum ?name?"}, 3848 {"scale", 1, DiskScaleOp, 5, 6, "sx sy sz ?name?"}, 3849 {"visible", 1, DiskVisibleOp, 3, 4, "bool ?name?"}, 3850 {"wireframe", 1, DiskWireframeOp, 3, 4, "bool ?name?"} 3851 }; 3852 static int nDiskOps = NumCmdSpecs(diskOps); 3853 3854 static int 3855 DiskCmd(ClientData clientData, Tcl_Interp *interp, int objc, 3856 Tcl_Obj *const *objv) 3857 { 3858 Tcl_ObjCmdProc *proc; 3859 3860 proc = Rappture::GetOpFromObj(interp, nDiskOps, diskOps, 2101 3861 Rappture::CMDSPEC_ARG1, objc, objv, 0); 2102 3862 if (proc == NULL) { … … 2361 4121 2362 4122 static int 4123 GlyphsOrientGlyphsOp(ClientData clientData, Tcl_Interp *interp, int objc, 4124 Tcl_Obj *const *objv) 4125 { 4126 bool state; 4127 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 4128 return TCL_ERROR; 4129 } 4130 const char *fieldName = Tcl_GetString(objv[3]); 4131 if (objc == 5) { 4132 const char *name = Tcl_GetString(objv[4]); 4133 g_renderer->setGlyphsOrientMode(name, state, fieldName); 4134 } else { 4135 g_renderer->setGlyphsOrientMode("all", state, fieldName); 4136 } 4137 return TCL_OK; 4138 } 4139 4140 static int 2363 4141 GlyphsPositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 2364 4142 Tcl_Obj *const *objv) … … 2527 4305 {"delete", 1, GlyphsDeleteOp, 2, 3, "?dataSetName?"}, 2528 4306 {"edges", 1, GlyphsEdgeVisibilityOp, 3, 4, "bool ?dataSetName?"}, 2529 {"gscale", 1, GlyphsScaleFactorOp, 3, 4, "scaleFactor ?dataSetName?"}, 4307 {"gorient", 2, GlyphsOrientGlyphsOp, 4, 5, "bool fieldName ?dataSetName?"}, 4308 {"gscale", 2, GlyphsScaleFactorOp, 3, 4, "scaleFactor ?dataSetName?"}, 2530 4309 {"lighting", 3, GlyphsLightingOp, 3, 4, "bool ?dataSetName?"}, 2531 4310 {"linecolor", 5, GlyphsLineColorOp, 5, 6, "r g b ?dataSetName?"}, … … 3433 5212 3434 5213 static int 5214 LineAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 5215 Tcl_Obj *const *objv) 5216 { 5217 double pt1[3]; 5218 double pt2[3]; 5219 if (Tcl_GetDoubleFromObj(interp, objv[2], &pt1[0]) != TCL_OK || 5220 Tcl_GetDoubleFromObj(interp, objv[3], &pt1[1]) != TCL_OK || 5221 Tcl_GetDoubleFromObj(interp, objv[4], &pt1[2]) != TCL_OK || 5222 Tcl_GetDoubleFromObj(interp, objv[5], &pt2[0]) != TCL_OK || 5223 Tcl_GetDoubleFromObj(interp, objv[6], &pt2[1]) != TCL_OK || 5224 Tcl_GetDoubleFromObj(interp, objv[7], &pt2[2]) != TCL_OK) { 5225 return TCL_ERROR; 5226 } 5227 const char *name = Tcl_GetString(objv[8]); 5228 if (!g_renderer->addLine(name, pt1, pt2)) { 5229 Tcl_AppendResult(interp, "Failed to create line", (char*)NULL); 5230 return TCL_ERROR; 5231 } 5232 return TCL_OK; 5233 } 5234 5235 static int 5236 LineDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 5237 Tcl_Obj *const *objv) 5238 { 5239 if (objc == 3) { 5240 const char *name = Tcl_GetString(objv[2]); 5241 g_renderer->deleteGraphicsObject<Line>(name); 5242 } else { 5243 g_renderer->deleteGraphicsObject<Line>("all"); 5244 } 5245 return TCL_OK; 5246 } 5247 5248 static int 5249 LineColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 5250 Tcl_Obj *const *objv) 5251 { 5252 float color[3]; 5253 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 5254 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 5255 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 5256 return TCL_ERROR; 5257 } 5258 if (objc == 6) { 5259 const char *name = Tcl_GetString(objv[5]); 5260 g_renderer->setGraphicsObjectColor<Line>(name, color); 5261 } else { 5262 g_renderer->setGraphicsObjectColor<Line>("all", color); 5263 } 5264 return TCL_OK; 5265 } 5266 5267 static int 5268 LineLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc, 5269 Tcl_Obj *const *objv) 5270 { 5271 float width; 5272 if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) { 5273 return TCL_ERROR; 5274 } 5275 if (objc == 4) { 5276 const char *name = Tcl_GetString(objv[3]); 5277 g_renderer->setGraphicsObjectEdgeWidth<Line>(name, width); 5278 } else { 5279 g_renderer->setGraphicsObjectEdgeWidth<Line>("all", width); 5280 } 5281 return TCL_OK; 5282 } 5283 5284 static int 5285 LineOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc, 5286 Tcl_Obj *const *objv) 5287 { 5288 double opacity; 5289 if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) { 5290 return TCL_ERROR; 5291 } 5292 if (objc == 4) { 5293 const char *name = Tcl_GetString(objv[3]); 5294 g_renderer->setGraphicsObjectOpacity<Line>(name, opacity); 5295 } else { 5296 g_renderer->setGraphicsObjectOpacity<Line>("all", opacity); 5297 } 5298 return TCL_OK; 5299 } 5300 5301 static int 5302 LineOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 5303 Tcl_Obj *const *objv) 5304 { 5305 double quat[4]; 5306 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 5307 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 5308 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 5309 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 5310 return TCL_ERROR; 5311 } 5312 if (objc == 7) { 5313 const char *name = Tcl_GetString(objv[6]); 5314 g_renderer->setGraphicsObjectOrientation<Line>(name, quat); 5315 } else { 5316 g_renderer->setGraphicsObjectOrientation<Line>("all", quat); 5317 } 5318 return TCL_OK; 5319 } 5320 5321 static int 5322 LinePositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 5323 Tcl_Obj *const *objv) 5324 { 5325 double pos[3]; 5326 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 5327 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 5328 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 5329 return TCL_ERROR; 5330 } 5331 if (objc == 6) { 5332 const char *name = Tcl_GetString(objv[5]); 5333 g_renderer->setGraphicsObjectPosition<Line>(name, pos); 5334 } else { 5335 g_renderer->setGraphicsObjectPosition<Line>("all", pos); 5336 } 5337 return TCL_OK; 5338 } 5339 5340 static int 5341 LineScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 5342 Tcl_Obj *const *objv) 5343 { 5344 double scale[3]; 5345 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 5346 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 5347 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 5348 return TCL_ERROR; 5349 } 5350 if (objc == 6) { 5351 const char *name = Tcl_GetString(objv[5]); 5352 g_renderer->setGraphicsObjectScale<Line>(name, scale); 5353 } else { 5354 g_renderer->setGraphicsObjectScale<Line>("all", scale); 5355 } 5356 return TCL_OK; 5357 } 5358 5359 static int 5360 LineVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 5361 Tcl_Obj *const *objv) 5362 { 5363 bool state; 5364 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 5365 return TCL_ERROR; 5366 } 5367 if (objc == 4) { 5368 const char *name = Tcl_GetString(objv[3]); 5369 g_renderer->setGraphicsObjectVisibility<Line>(name, state); 5370 } else { 5371 g_renderer->setGraphicsObjectVisibility<Line>("all", state); 5372 } 5373 return TCL_OK; 5374 } 5375 5376 static Rappture::CmdSpec lineOps[] = { 5377 {"add", 1, LineAddOp, 9, 9, "x1 y1 z1 x2 y2 z2 name"}, 5378 {"color", 1, LineColorOp, 5, 6, "r g b ?name?"}, 5379 {"delete", 1, LineDeleteOp, 2, 3, "?name?"}, 5380 {"linecolor", 5, LineColorOp, 5, 6, "r g b ?name?"}, 5381 {"linewidth", 5, LineLineWidthOp, 3, 4, "width ?name?"}, 5382 {"opacity", 2, LineOpacityOp, 3, 4, "value ?name?"}, 5383 {"orient", 2, LineOrientOp, 6, 7, "qw qx qy qz ?name?"}, 5384 {"pos", 2, LinePositionOp, 5, 6, "x y z ?name?"}, 5385 {"scale", 2, LineScaleOp, 5, 6, "sx sy sz ?name?"}, 5386 {"visible", 1, LineVisibleOp, 3, 4, "bool ?name?"} 5387 }; 5388 static int nLineOps = NumCmdSpecs(lineOps); 5389 5390 static int 5391 LineCmd(ClientData clientData, Tcl_Interp *interp, int objc, 5392 Tcl_Obj *const *objv) 5393 { 5394 Tcl_ObjCmdProc *proc; 5395 5396 proc = Rappture::GetOpFromObj(interp, nLineOps, lineOps, 5397 Rappture::CMDSPEC_ARG1, objc, objv, 0); 5398 if (proc == NULL) { 5399 return TCL_ERROR; 5400 } 5401 return (*proc) (clientData, interp, objc, objv); 5402 } 5403 5404 static int 3435 5405 MoleculeAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 3436 5406 Tcl_Obj *const *objv) … … 3464 5434 } else { 3465 5435 g_renderer->setMoleculeAtomVisibility("all", state); 5436 } 5437 return TCL_OK; 5438 } 5439 5440 static int 5441 MoleculeAtomLabelVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc, 5442 Tcl_Obj *const *objv) 5443 { 5444 bool state; 5445 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 5446 return TCL_ERROR; 5447 } 5448 if (objc == 4) { 5449 const char *name = Tcl_GetString(objv[3]); 5450 g_renderer->setMoleculeAtomLabelVisibility(name, state); 5451 } else { 5452 g_renderer->setMoleculeAtomLabelVisibility("all", state); 5453 } 5454 return TCL_OK; 5455 } 5456 5457 static int 5458 MoleculeAtomScaleFactorOp(ClientData clientData, Tcl_Interp *interp, int objc, 5459 Tcl_Obj *const *objv) 5460 { 5461 double scale; 5462 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale) != TCL_OK) { 5463 return TCL_ERROR; 5464 } 5465 if (objc == 4) { 5466 const char *name = Tcl_GetString(objv[3]); 5467 g_renderer->setMoleculeAtomRadiusScale(name, scale); 5468 } else { 5469 g_renderer->setMoleculeAtomRadiusScale("all", scale); 3466 5470 } 3467 5471 return TCL_OK; … … 3497 5501 3498 5502 static int 5503 MoleculeBondColorModeOp(ClientData clientData, Tcl_Interp *interp, int objc, 5504 Tcl_Obj *const *objv) 5505 { 5506 Molecule::BondColorMode mode; 5507 const char *colorMode = Tcl_GetString(objv[2]); 5508 if (colorMode[0] == 'c' && strcmp(colorMode, "constant") == 0) { 5509 mode = Molecule::BOND_COLOR_CONSTANT; 5510 } else if (colorMode[0] == 'b' && strcmp(colorMode, "by_elements") == 0) { 5511 mode = Molecule::BOND_COLOR_BY_ELEMENTS; 5512 } else { 5513 Tcl_AppendResult(interp, "bad bcmode option \"", colorMode, 5514 "\": should be constant or by_elements", (char*)NULL); 5515 return TCL_ERROR; 5516 } 5517 if (objc == 4) { 5518 const char *name = Tcl_GetString(objv[3]); 5519 g_renderer->setMoleculeBondColorMode(name, mode); 5520 } else { 5521 g_renderer->setMoleculeBondColorMode("all", mode); 5522 } 5523 return TCL_OK; 5524 } 5525 5526 static int 5527 MoleculeBondColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 5528 Tcl_Obj *const *objv) 5529 { 5530 float color[3]; 5531 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 5532 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 5533 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 5534 return TCL_ERROR; 5535 } 5536 if (objc == 6) { 5537 const char *name = Tcl_GetString(objv[5]); 5538 g_renderer->setMoleculeBondColor(name, color); 5539 } else { 5540 g_renderer->setMoleculeBondColor("all", color); 5541 } 5542 return TCL_OK; 5543 } 5544 5545 static int 5546 MoleculeBondScaleFactorOp(ClientData clientData, Tcl_Interp *interp, int objc, 5547 Tcl_Obj *const *objv) 5548 { 5549 double scale; 5550 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale) != TCL_OK) { 5551 return TCL_ERROR; 5552 } 5553 if (objc == 4) { 5554 const char *name = Tcl_GetString(objv[3]); 5555 g_renderer->setMoleculeBondRadiusScale(name, scale); 5556 } else { 5557 g_renderer->setMoleculeBondRadiusScale("all", scale); 5558 } 5559 return TCL_OK; 5560 } 5561 5562 static int 5563 MoleculeBondStyleOp(ClientData clientData, Tcl_Interp *interp, int objc, 5564 Tcl_Obj *const *objv) 5565 { 5566 Molecule::BondStyle style; 5567 const char *styleStr = Tcl_GetString(objv[2]); 5568 if (styleStr[0] == 'c' && strcmp(styleStr, "cylinder") == 0) { 5569 style = Molecule::BOND_STYLE_CYLINDER; 5570 } else if (styleStr[0] == 'l' && strcmp(styleStr, "line") == 0) { 5571 style = Molecule::BOND_STYLE_LINE; 5572 } else { 5573 Tcl_AppendResult(interp, "bad bstyle option \"", styleStr, 5574 "\": should be cylinder or line", (char*)NULL); 5575 return TCL_ERROR; 5576 } 5577 if (objc == 4) { 5578 const char *name = Tcl_GetString(objv[3]); 5579 g_renderer->setMoleculeBondStyle(name, style); 5580 } else { 5581 g_renderer->setMoleculeBondStyle("all", style); 5582 } 5583 return TCL_OK; 5584 } 5585 5586 static int 3499 5587 MoleculeBondVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc, 3500 5588 Tcl_Obj *const *objv) … … 3514 5602 3515 5603 static int 5604 MoleculeColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 5605 Tcl_Obj *const *objv) 5606 { 5607 float color[3]; 5608 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 5609 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 5610 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 5611 return TCL_ERROR; 5612 } 5613 if (objc == 6) { 5614 const char *name = Tcl_GetString(objv[5]); 5615 g_renderer->setGraphicsObjectColor<Molecule>(name, color); 5616 } else { 5617 g_renderer->setGraphicsObjectColor<Molecule>("all", color); 5618 } 5619 return TCL_OK; 5620 } 5621 5622 static int 3516 5623 MoleculeColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc, 3517 5624 Tcl_Obj *const *objv) … … 3523 5630 } else { 3524 5631 g_renderer->setGraphicsObjectColorMap<Molecule>("all", colorMapName); 5632 } 5633 return TCL_OK; 5634 } 5635 5636 static int 5637 MoleculeColorModeOp(ClientData clientData, Tcl_Interp *interp, int objc, 5638 Tcl_Obj *const *objv) 5639 { 5640 Molecule::ColorMode mode; 5641 const char *str = Tcl_GetString(objv[2]); 5642 if (str[0] == 'b' && strcmp(str, "by_elements") == 0) { 5643 mode = Molecule::COLOR_BY_ELEMENTS; 5644 } else if (str[0] == 'c' && strcmp(str, "ccolor") == 0) { 5645 mode = Molecule::COLOR_CONSTANT; 5646 } else if (str[0] == 's' && strcmp(str, "scalar") == 0) { 5647 mode = Molecule::COLOR_BY_SCALAR; 5648 } else if (str[0] == 'v' && strcmp(str, "vmag") == 0) { 5649 mode = Molecule::COLOR_BY_VECTOR_MAGNITUDE; 5650 } else if (str[0] == 'v' && strcmp(str, "vx") == 0) { 5651 mode = Molecule::COLOR_BY_VECTOR_X; 5652 } else if (str[0] == 'v' && strcmp(str, "vy") == 0) { 5653 mode = Molecule::COLOR_BY_VECTOR_Y; 5654 } else if (str[0] == 'v' && strcmp(str, "vz") == 0) { 5655 mode = Molecule::COLOR_BY_VECTOR_Z; 5656 } else { 5657 Tcl_AppendResult(interp, "bad color mode option \"", str, 5658 "\": should be one of: 'by_elements', 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor'", (char*)NULL); 5659 return TCL_ERROR; 5660 } 5661 const char *fieldName = Tcl_GetString(objv[3]); 5662 if (mode == Molecule::COLOR_CONSTANT) { 5663 fieldName = NULL; 5664 } 5665 #if 0 5666 else if (mode == Molecule::COLOR_BY_ELEMENTS) { 5667 fieldName = "element"; 5668 } 5669 #endif 5670 if (objc == 5) { 5671 const char *name = Tcl_GetString(objv[4]); 5672 g_renderer->setMoleculeColorMode(name, mode, fieldName); 5673 } else { 5674 g_renderer->setMoleculeColorMode("all", mode, fieldName); 3525 5675 } 3526 5676 return TCL_OK; … … 3721 5871 static Rappture::CmdSpec moleculeOps[] = { 3722 5872 {"add", 2, MoleculeAddOp, 2, 3, "?dataSetName?"}, 5873 {"ascale", 2, MoleculeAtomScaleFactorOp, 3, 4, "value ?dataSetName?"}, 3723 5874 {"atoms", 2, MoleculeAtomVisibilityOp, 3, 4, "bool ?dataSetName?"}, 5875 {"bcmode", 3, MoleculeBondColorModeOp, 3, 4, "mode ?dataSetName?"}, 5876 {"bcolor", 3, MoleculeBondColorOp, 5, 6, "r g b ?dataSetName?"}, 3724 5877 {"bonds", 2, MoleculeBondVisibilityOp, 3, 4, "bool ?dataSetName?"}, 3725 {"colormap", 1, MoleculeColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 5878 {"bscale", 3, MoleculeBondScaleFactorOp, 3, 4, "value ?dataSetName?"}, 5879 {"bstyle", 3, MoleculeBondStyleOp, 3, 4, "value ?dataSetName?"}, 5880 {"ccolor", 2, MoleculeColorOp, 5, 6, "r g b ?dataSetName?"}, 5881 {"colormap", 7, MoleculeColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 5882 {"colormode", 7, MoleculeColorModeOp, 4, 5, "mode fieldName ?dataSetName?"}, 3726 5883 {"delete", 1, MoleculeDeleteOp, 2, 3, "?dataSetName?"}, 3727 5884 {"edges", 1, MoleculeEdgeVisibilityOp, 3, 4, "bool ?dataSetName?"}, 5885 {"labels", 2, MoleculeAtomLabelVisibilityOp, 3, 4, "bool ?dataSetName?"}, 3728 5886 {"lighting", 3, MoleculeLightingOp, 3, 4, "bool ?dataSetName?"}, 3729 5887 {"linecolor", 5, MoleculeLineColorOp, 5, 6, "r g b ?dataSetName?"}, … … 3875 6033 3876 6034 static int 6035 PolyDataMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc, 6036 Tcl_Obj *const *objv) 6037 { 6038 double ambient, diffuse, specCoeff, specPower; 6039 if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK || 6040 Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK || 6041 Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK || 6042 Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) { 6043 return TCL_ERROR; 6044 } 6045 6046 if (objc == 7) { 6047 const char *name = Tcl_GetString(objv[6]); 6048 g_renderer->setGraphicsObjectAmbient<PolyData>(name, ambient); 6049 g_renderer->setGraphicsObjectDiffuse<PolyData>(name, diffuse); 6050 g_renderer->setGraphicsObjectSpecular<PolyData>(name, specCoeff, specPower); 6051 } else { 6052 g_renderer->setGraphicsObjectAmbient<PolyData>("all", ambient); 6053 g_renderer->setGraphicsObjectDiffuse<PolyData>("all", diffuse); 6054 g_renderer->setGraphicsObjectSpecular<PolyData>("all", specCoeff, specPower); 6055 } 6056 return TCL_OK; 6057 } 6058 6059 static int 3877 6060 PolyDataOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc, 3878 6061 Tcl_Obj *const *objv) … … 4008 6191 {"linecolor", 5, PolyDataLineColorOp, 5, 6, "r g b ?dataSetName?"}, 4009 6192 {"linewidth", 5, PolyDataLineWidthOp, 3, 4, "width ?dataSetName?"}, 6193 {"material", 1, PolyDataMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?dataSetName?"}, 4010 6194 {"opacity", 2, PolyDataOpacityOp, 3, 4, "value ?dataSetName?"}, 4011 6195 {"orient", 2, PolyDataOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, … … 4025 6209 4026 6210 proc = Rappture::GetOpFromObj(interp, nPolyDataOps, polyDataOps, 6211 Rappture::CMDSPEC_ARG1, objc, objv, 0); 6212 if (proc == NULL) { 6213 return TCL_ERROR; 6214 } 6215 return (*proc) (clientData, interp, objc, objv); 6216 } 6217 6218 static int 6219 PolygonAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 6220 Tcl_Obj *const *objv) 6221 { 6222 int numSides; 6223 if (Tcl_GetIntFromObj(interp, objv[2], &numSides) != TCL_OK) { 6224 return TCL_ERROR; 6225 } 6226 const char *name = Tcl_GetString(objv[3]); 6227 if (!g_renderer->addPolygon(name, numSides)) { 6228 Tcl_AppendResult(interp, "Failed to create polygon", (char*)NULL); 6229 return TCL_ERROR; 6230 } 6231 return TCL_OK; 6232 } 6233 6234 static int 6235 PolygonDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 6236 Tcl_Obj *const *objv) 6237 { 6238 if (objc == 3) { 6239 const char *name = Tcl_GetString(objv[2]); 6240 g_renderer->deleteGraphicsObject<Polygon>(name); 6241 } else { 6242 g_renderer->deleteGraphicsObject<Polygon>("all"); 6243 } 6244 return TCL_OK; 6245 } 6246 6247 static int 6248 PolygonColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 6249 Tcl_Obj *const *objv) 6250 { 6251 float color[3]; 6252 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 6253 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 6254 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 6255 return TCL_ERROR; 6256 } 6257 if (objc == 6) { 6258 const char *name = Tcl_GetString(objv[5]); 6259 g_renderer->setGraphicsObjectColor<Polygon>(name, color); 6260 } else { 6261 g_renderer->setGraphicsObjectColor<Polygon>("all", color); 6262 } 6263 return TCL_OK; 6264 } 6265 6266 static int 6267 PolygonEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc, 6268 Tcl_Obj *const *objv) 6269 { 6270 bool state; 6271 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 6272 return TCL_ERROR; 6273 } 6274 if (objc == 4) { 6275 const char *name = Tcl_GetString(objv[3]); 6276 g_renderer->setGraphicsObjectEdgeVisibility<Polygon>(name, state); 6277 } else { 6278 g_renderer->setGraphicsObjectEdgeVisibility<Polygon>("all", state); 6279 } 6280 return TCL_OK; 6281 } 6282 6283 static int 6284 PolygonLightingOp(ClientData clientData, Tcl_Interp *interp, int objc, 6285 Tcl_Obj *const *objv) 6286 { 6287 bool state; 6288 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 6289 return TCL_ERROR; 6290 } 6291 if (objc == 4) { 6292 const char *name = Tcl_GetString(objv[3]); 6293 g_renderer->setGraphicsObjectLighting<Polygon>(name, state); 6294 } else { 6295 g_renderer->setGraphicsObjectLighting<Polygon>("all", state); 6296 } 6297 return TCL_OK; 6298 } 6299 6300 static int 6301 PolygonLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 6302 Tcl_Obj *const *objv) 6303 { 6304 float color[3]; 6305 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 6306 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 6307 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 6308 return TCL_ERROR; 6309 } 6310 if (objc == 6) { 6311 const char *name = Tcl_GetString(objv[5]); 6312 g_renderer->setGraphicsObjectEdgeColor<Polygon>(name, color); 6313 } else { 6314 g_renderer->setGraphicsObjectEdgeColor<Polygon>("all", color); 6315 } 6316 return TCL_OK; 6317 } 6318 6319 static int 6320 PolygonLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc, 6321 Tcl_Obj *const *objv) 6322 { 6323 float width; 6324 if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) { 6325 return TCL_ERROR; 6326 } 6327 if (objc == 4) { 6328 const char *name = Tcl_GetString(objv[3]); 6329 g_renderer->setGraphicsObjectEdgeWidth<Polygon>(name, width); 6330 } else { 6331 g_renderer->setGraphicsObjectEdgeWidth<Polygon>("all", width); 6332 } 6333 return TCL_OK; 6334 } 6335 6336 static int 6337 PolygonMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc, 6338 Tcl_Obj *const *objv) 6339 { 6340 double ambient, diffuse, specCoeff, specPower; 6341 if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK || 6342 Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK || 6343 Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK || 6344 Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) { 6345 return TCL_ERROR; 6346 } 6347 6348 if (objc == 7) { 6349 const char *name = Tcl_GetString(objv[6]); 6350 g_renderer->setGraphicsObjectAmbient<Polygon>(name, ambient); 6351 g_renderer->setGraphicsObjectDiffuse<Polygon>(name, diffuse); 6352 g_renderer->setGraphicsObjectSpecular<Polygon>(name, specCoeff, specPower); 6353 } else { 6354 g_renderer->setGraphicsObjectAmbient<Polygon>("all", ambient); 6355 g_renderer->setGraphicsObjectDiffuse<Polygon>("all", diffuse); 6356 g_renderer->setGraphicsObjectSpecular<Polygon>("all", specCoeff, specPower); 6357 } 6358 return TCL_OK; 6359 } 6360 6361 static int 6362 PolygonOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc, 6363 Tcl_Obj *const *objv) 6364 { 6365 double opacity; 6366 if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) { 6367 return TCL_ERROR; 6368 } 6369 if (objc == 4) { 6370 const char *name = Tcl_GetString(objv[3]); 6371 g_renderer->setGraphicsObjectOpacity<Polygon>(name, opacity); 6372 } else { 6373 g_renderer->setGraphicsObjectOpacity<Polygon>("all", opacity); 6374 } 6375 return TCL_OK; 6376 } 6377 6378 static int 6379 PolygonOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 6380 Tcl_Obj *const *objv) 6381 { 6382 double quat[4]; 6383 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 6384 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 6385 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 6386 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 6387 return TCL_ERROR; 6388 } 6389 if (objc == 7) { 6390 const char *name = Tcl_GetString(objv[6]); 6391 g_renderer->setGraphicsObjectOrientation<Polygon>(name, quat); 6392 } else { 6393 g_renderer->setGraphicsObjectOrientation<Polygon>("all", quat); 6394 } 6395 return TCL_OK; 6396 } 6397 6398 static int 6399 PolygonPositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 6400 Tcl_Obj *const *objv) 6401 { 6402 double pos[3]; 6403 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 6404 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 6405 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 6406 return TCL_ERROR; 6407 } 6408 if (objc == 6) { 6409 const char *name = Tcl_GetString(objv[5]); 6410 g_renderer->setGraphicsObjectPosition<Polygon>(name, pos); 6411 } else { 6412 g_renderer->setGraphicsObjectPosition<Polygon>("all", pos); 6413 } 6414 return TCL_OK; 6415 } 6416 6417 static int 6418 PolygonScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 6419 Tcl_Obj *const *objv) 6420 { 6421 double scale[3]; 6422 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 6423 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 6424 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 6425 return TCL_ERROR; 6426 } 6427 if (objc == 6) { 6428 const char *name = Tcl_GetString(objv[5]); 6429 g_renderer->setGraphicsObjectScale<Polygon>(name, scale); 6430 } else { 6431 g_renderer->setGraphicsObjectScale<Polygon>("all", scale); 6432 } 6433 return TCL_OK; 6434 } 6435 6436 static int 6437 PolygonVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 6438 Tcl_Obj *const *objv) 6439 { 6440 bool state; 6441 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 6442 return TCL_ERROR; 6443 } 6444 if (objc == 4) { 6445 const char *name = Tcl_GetString(objv[3]); 6446 g_renderer->setGraphicsObjectVisibility<Polygon>(name, state); 6447 } else { 6448 g_renderer->setGraphicsObjectVisibility<Polygon>("all", state); 6449 } 6450 return TCL_OK; 6451 } 6452 6453 static int 6454 PolygonWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc, 6455 Tcl_Obj *const *objv) 6456 { 6457 bool state; 6458 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 6459 return TCL_ERROR; 6460 } 6461 if (objc == 4) { 6462 const char *name = Tcl_GetString(objv[3]); 6463 g_renderer->setGraphicsObjectWireframe<Polygon>(name, state); 6464 } else { 6465 g_renderer->setGraphicsObjectWireframe<Polygon>("all", state); 6466 } 6467 return TCL_OK; 6468 } 6469 6470 static Rappture::CmdSpec polygonOps[] = { 6471 {"add", 1, PolygonAddOp, 4, 4, "numSides name"}, 6472 {"color", 1, PolygonColorOp, 5, 6, "r g b ?name?"}, 6473 {"delete", 1, PolygonDeleteOp, 2, 3, "?name?"}, 6474 {"edges", 1, PolygonEdgeVisibilityOp, 3, 4, "bool ?name?"}, 6475 {"lighting", 3, PolygonLightingOp, 3, 4, "bool ?name?"}, 6476 {"linecolor", 5, PolygonLineColorOp, 5, 6, "r g b ?name?"}, 6477 {"linewidth", 5, PolygonLineWidthOp, 3, 4, "width ?name?"}, 6478 {"material", 1, PolygonMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"}, 6479 {"opacity", 2, PolygonOpacityOp, 3, 4, "value ?name?"}, 6480 {"orient", 2, PolygonOrientOp, 6, 7, "qw qx qy qz ?name?"}, 6481 {"pos", 2, PolygonPositionOp, 5, 6, "x y z ?name?"}, 6482 {"scale", 1, PolygonScaleOp, 5, 6, "sx sy sz ?name?"}, 6483 {"visible", 1, PolygonVisibleOp, 3, 4, "bool ?name?"}, 6484 {"wireframe", 1, PolygonWireframeOp, 3, 4, "bool ?name?"} 6485 }; 6486 static int nPolygonOps = NumCmdSpecs(polygonOps); 6487 6488 static int 6489 PolygonCmd(ClientData clientData, Tcl_Interp *interp, int objc, 6490 Tcl_Obj *const *objv) 6491 { 6492 Tcl_ObjCmdProc *proc; 6493 6494 proc = Rappture::GetOpFromObj(interp, nPolygonOps, polygonOps, 4027 6495 Rappture::CMDSPEC_ARG1, objc, objv, 0); 4028 6496 if (proc == NULL) { … … 4473 6941 4474 6942 proc = Rappture::GetOpFromObj(interp, nScreenOps, screenOps, 6943 Rappture::CMDSPEC_ARG1, objc, objv, 0); 6944 if (proc == NULL) { 6945 return TCL_ERROR; 6946 } 6947 return (*proc) (clientData, interp, objc, objv); 6948 } 6949 6950 static int 6951 SphereAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 6952 Tcl_Obj *const *objv) 6953 { 6954 const char *name = Tcl_GetString(objv[2]); 6955 if (!g_renderer->addGraphicsObject<Sphere>(name)) { 6956 Tcl_AppendResult(interp, "Failed to create sphere", (char*)NULL); 6957 return TCL_ERROR; 6958 } 6959 return TCL_OK; 6960 } 6961 6962 static int 6963 SphereDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 6964 Tcl_Obj *const *objv) 6965 { 6966 if (objc == 3) { 6967 const char *name = Tcl_GetString(objv[2]); 6968 g_renderer->deleteGraphicsObject<Sphere>(name); 6969 } else { 6970 g_renderer->deleteGraphicsObject<Sphere>("all"); 6971 } 6972 return TCL_OK; 6973 } 6974 6975 static int 6976 SphereColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 6977 Tcl_Obj *const *objv) 6978 { 6979 float color[3]; 6980 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 6981 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 6982 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 6983 return TCL_ERROR; 6984 } 6985 if (objc == 6) { 6986 const char *name = Tcl_GetString(objv[5]); 6987 g_renderer->setGraphicsObjectColor<Sphere>(name, color); 6988 } else { 6989 g_renderer->setGraphicsObjectColor<Sphere>("all", color); 6990 } 6991 return TCL_OK; 6992 } 6993 6994 static int 6995 SphereEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc, 6996 Tcl_Obj *const *objv) 6997 { 6998 bool state; 6999 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 7000 return TCL_ERROR; 7001 } 7002 if (objc == 4) { 7003 const char *name = Tcl_GetString(objv[3]); 7004 g_renderer->setGraphicsObjectEdgeVisibility<Sphere>(name, state); 7005 } else { 7006 g_renderer->setGraphicsObjectEdgeVisibility<Sphere>("all", state); 7007 } 7008 return TCL_OK; 7009 } 7010 7011 static int 7012 SphereLightingOp(ClientData clientData, Tcl_Interp *interp, int objc, 7013 Tcl_Obj *const *objv) 7014 { 7015 bool state; 7016 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 7017 return TCL_ERROR; 7018 } 7019 if (objc == 4) { 7020 const char *name = Tcl_GetString(objv[3]); 7021 g_renderer->setGraphicsObjectLighting<Sphere>(name, state); 7022 } else { 7023 g_renderer->setGraphicsObjectLighting<Sphere>("all", state); 7024 } 7025 return TCL_OK; 7026 } 7027 7028 static int 7029 SphereLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 7030 Tcl_Obj *const *objv) 7031 { 7032 float color[3]; 7033 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 7034 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 7035 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 7036 return TCL_ERROR; 7037 } 7038 if (objc == 6) { 7039 const char *name = Tcl_GetString(objv[5]); 7040 g_renderer->setGraphicsObjectEdgeColor<Sphere>(name, color); 7041 } else { 7042 g_renderer->setGraphicsObjectEdgeColor<Sphere>("all", color); 7043 } 7044 return TCL_OK; 7045 } 7046 7047 static int 7048 SphereLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc, 7049 Tcl_Obj *const *objv) 7050 { 7051 float width; 7052 if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) { 7053 return TCL_ERROR; 7054 } 7055 if (objc == 4) { 7056 const char *name = Tcl_GetString(objv[3]); 7057 g_renderer->setGraphicsObjectEdgeWidth<Sphere>(name, width); 7058 } else { 7059 g_renderer->setGraphicsObjectEdgeWidth<Sphere>("all", width); 7060 } 7061 return TCL_OK; 7062 } 7063 7064 static int 7065 SphereMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc, 7066 Tcl_Obj *const *objv) 7067 { 7068 double ambient, diffuse, specCoeff, specPower; 7069 if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK || 7070 Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK || 7071 Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK || 7072 Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) { 7073 return TCL_ERROR; 7074 } 7075 7076 if (objc == 7) { 7077 const char *name = Tcl_GetString(objv[6]); 7078 g_renderer->setGraphicsObjectAmbient<Sphere>(name, ambient); 7079 g_renderer->setGraphicsObjectDiffuse<Sphere>(name, diffuse); 7080 g_renderer->setGraphicsObjectSpecular<Sphere>(name, specCoeff, specPower); 7081 } else { 7082 g_renderer->setGraphicsObjectAmbient<Sphere>("all", ambient); 7083 g_renderer->setGraphicsObjectDiffuse<Sphere>("all", diffuse); 7084 g_renderer->setGraphicsObjectSpecular<Sphere>("all", specCoeff, specPower); 7085 } 7086 return TCL_OK; 7087 } 7088 7089 static int 7090 SphereOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc, 7091 Tcl_Obj *const *objv) 7092 { 7093 double opacity; 7094 if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) { 7095 return TCL_ERROR; 7096 } 7097 if (objc == 4) { 7098 const char *name = Tcl_GetString(objv[3]); 7099 g_renderer->setGraphicsObjectOpacity<Sphere>(name, opacity); 7100 } else { 7101 g_renderer->setGraphicsObjectOpacity<Sphere>("all", opacity); 7102 } 7103 return TCL_OK; 7104 } 7105 7106 static int 7107 SphereOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 7108 Tcl_Obj *const *objv) 7109 { 7110 double quat[4]; 7111 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 7112 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 7113 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 7114 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 7115 return TCL_ERROR; 7116 } 7117 if (objc == 7) { 7118 const char *name = Tcl_GetString(objv[6]); 7119 g_renderer->setGraphicsObjectOrientation<Sphere>(name, quat); 7120 } else { 7121 g_renderer->setGraphicsObjectOrientation<Sphere>("all", quat); 7122 } 7123 return TCL_OK; 7124 } 7125 7126 static int 7127 SpherePositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 7128 Tcl_Obj *const *objv) 7129 { 7130 double pos[3]; 7131 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 7132 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 7133 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 7134 return TCL_ERROR; 7135 } 7136 if (objc == 6) { 7137 const char *name = Tcl_GetString(objv[5]); 7138 g_renderer->setGraphicsObjectPosition<Sphere>(name, pos); 7139 } else { 7140 g_renderer->setGraphicsObjectPosition<Sphere>("all", pos); 7141 } 7142 return TCL_OK; 7143 } 7144 7145 static int 7146 SphereResolutionOp(ClientData clientData, Tcl_Interp *interp, int objc, 7147 Tcl_Obj *const *objv) 7148 { 7149 int theta, phi; 7150 if (Tcl_GetIntFromObj(interp, objv[2], &theta) != TCL_OK || 7151 Tcl_GetIntFromObj(interp, objv[3], &phi) != TCL_OK) { 7152 return TCL_ERROR; 7153 } 7154 if (objc == 5) { 7155 const char *name = Tcl_GetString(objv[4]); 7156 g_renderer->setSphereResolution(name, theta, phi); 7157 } else { 7158 g_renderer->setSphereResolution("all", theta, phi); 7159 } 7160 return TCL_OK; 7161 } 7162 7163 static int 7164 SphereScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 7165 Tcl_Obj *const *objv) 7166 { 7167 double scale[3]; 7168 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 7169 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 7170 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 7171 return TCL_ERROR; 7172 } 7173 if (objc == 6) { 7174 const char *name = Tcl_GetString(objv[5]); 7175 g_renderer->setGraphicsObjectScale<Sphere>(name, scale); 7176 } else { 7177 g_renderer->setGraphicsObjectScale<Sphere>("all", scale); 7178 } 7179 return TCL_OK; 7180 } 7181 7182 static int 7183 SphereSectionOp(ClientData clientData, Tcl_Interp *interp, int objc, 7184 Tcl_Obj *const *objv) 7185 { 7186 double thetaStart, thetaEnd, phiStart, phiEnd; 7187 if (Tcl_GetDoubleFromObj(interp, objv[2], &thetaStart) != TCL_OK || 7188 Tcl_GetDoubleFromObj(interp, objv[3], &thetaEnd) != TCL_OK || 7189 Tcl_GetDoubleFromObj(interp, objv[4], &phiStart) != TCL_OK || 7190 Tcl_GetDoubleFromObj(interp, objv[5], &phiEnd) != TCL_OK) { 7191 return TCL_ERROR; 7192 } 7193 if (objc == 7) { 7194 const char *name = Tcl_GetString(objv[6]); 7195 g_renderer->setSphereSection(name, thetaStart, thetaEnd, phiStart, phiEnd); 7196 } else { 7197 g_renderer->setSphereSection("all", thetaStart, thetaEnd, phiStart, phiEnd); 7198 } 7199 return TCL_OK; 7200 } 7201 7202 static int 7203 SphereVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 7204 Tcl_Obj *const *objv) 7205 { 7206 bool state; 7207 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 7208 return TCL_ERROR; 7209 } 7210 if (objc == 4) { 7211 const char *name = Tcl_GetString(objv[3]); 7212 g_renderer->setGraphicsObjectVisibility<Sphere>(name, state); 7213 } else { 7214 g_renderer->setGraphicsObjectVisibility<Sphere>("all", state); 7215 } 7216 return TCL_OK; 7217 } 7218 7219 static int 7220 SphereWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc, 7221 Tcl_Obj *const *objv) 7222 { 7223 bool state; 7224 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 7225 return TCL_ERROR; 7226 } 7227 if (objc == 4) { 7228 const char *name = Tcl_GetString(objv[3]); 7229 g_renderer->setGraphicsObjectWireframe<Sphere>(name, state); 7230 } else { 7231 g_renderer->setGraphicsObjectWireframe<Sphere>("all", state); 7232 } 7233 return TCL_OK; 7234 } 7235 7236 static Rappture::CmdSpec sphereOps[] = { 7237 {"add", 1, SphereAddOp, 3, 3, "name"}, 7238 {"color", 1, SphereColorOp, 5, 6, "r g b ?name?"}, 7239 {"delete", 1, SphereDeleteOp, 2, 3, "?name?"}, 7240 {"edges", 1, SphereEdgeVisibilityOp, 3, 4, "bool ?name?"}, 7241 {"lighting", 3, SphereLightingOp, 3, 4, "bool ?name?"}, 7242 {"linecolor", 5, SphereLineColorOp, 5, 6, "r g b ?name?"}, 7243 {"linewidth", 5, SphereLineWidthOp, 3, 4, "width ?name?"}, 7244 {"material", 1, SphereMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"}, 7245 {"opacity", 2, SphereOpacityOp, 3, 4, "value ?name?"}, 7246 {"orient", 2, SphereOrientOp, 6, 7, "qw qx qy qz ?name?"}, 7247 {"pos", 2, SpherePositionOp, 5, 6, "x y z ?name?"}, 7248 {"resolution",1, SphereResolutionOp, 4, 5, "thetaRes phiRes ?name?"}, 7249 {"scale", 2, SphereScaleOp, 5, 6, "sx sy sz ?name?"}, 7250 {"section", 2, SphereSectionOp, 6, 7, "thetaStart thetaEnd phiStart phiEnd ?name?"}, 7251 {"visible", 1, SphereVisibleOp, 3, 4, "bool ?name?"}, 7252 {"wireframe", 1, SphereWireframeOp, 3, 4, "bool ?name?"} 7253 }; 7254 static int nSphereOps = NumCmdSpecs(sphereOps); 7255 7256 static int 7257 SphereCmd(ClientData clientData, Tcl_Interp *interp, int objc, 7258 Tcl_Obj *const *objv) 7259 { 7260 Tcl_ObjCmdProc *proc; 7261 7262 proc = Rappture::GetOpFromObj(interp, nSphereOps, sphereOps, 4475 7263 Rappture::CMDSPEC_ARG1, objc, objv, 0); 4476 7264 if (proc == NULL) { … … 5480 8268 5481 8269 proc = Rappture::GetOpFromObj(interp, nVolumeOps, volumeOps, 8270 Rappture::CMDSPEC_ARG1, objc, objv, 0); 8271 if (proc == NULL) { 8272 return TCL_ERROR; 8273 } 8274 return (*proc) (clientData, interp, objc, objv); 8275 } 8276 8277 static int 8278 WarpAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 8279 Tcl_Obj *const *objv) 8280 { 8281 if (objc == 3) { 8282 const char *name = Tcl_GetString(objv[2]); 8283 if (!g_renderer->addGraphicsObject<Warp>(name)) { 8284 Tcl_AppendResult(interp, "Failed to create warp", (char*)NULL); 8285 return TCL_ERROR; 8286 } 8287 } else { 8288 if (!g_renderer->addGraphicsObject<Warp>("all")) { 8289 Tcl_AppendResult(interp, "Failed to create warp for one or more data sets", (char*)NULL); 8290 return TCL_ERROR; 8291 } 8292 } 8293 return TCL_OK; 8294 } 8295 8296 static int 8297 WarpColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc, 8298 Tcl_Obj *const *objv) 8299 { 8300 const char *colorMapName = Tcl_GetString(objv[2]); 8301 if (objc == 4) { 8302 const char *dataSetName = Tcl_GetString(objv[3]); 8303 g_renderer->setGraphicsObjectColorMap<Warp>(dataSetName, colorMapName); 8304 } else { 8305 g_renderer->setGraphicsObjectColorMap<Warp>("all", colorMapName); 8306 } 8307 return TCL_OK; 8308 } 8309 8310 static int 8311 WarpDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 8312 Tcl_Obj *const *objv) 8313 { 8314 if (objc == 3) { 8315 const char *name = Tcl_GetString(objv[2]); 8316 g_renderer->deleteGraphicsObject<Warp>(name); 8317 } else { 8318 g_renderer->deleteGraphicsObject<Warp>("all"); 8319 } 8320 return TCL_OK; 8321 } 8322 8323 static int 8324 WarpEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc, 8325 Tcl_Obj *const *objv) 8326 { 8327 bool state; 8328 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 8329 return TCL_ERROR; 8330 } 8331 if (objc == 4) { 8332 const char *name = Tcl_GetString(objv[3]); 8333 g_renderer->setGraphicsObjectEdgeVisibility<Warp>(name, state); 8334 } else { 8335 g_renderer->setGraphicsObjectEdgeVisibility<Warp>("all", state); 8336 } 8337 return TCL_OK; 8338 } 8339 8340 static int 8341 WarpLightingOp(ClientData clientData, Tcl_Interp *interp, int objc, 8342 Tcl_Obj *const *objv) 8343 { 8344 bool state; 8345 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 8346 return TCL_ERROR; 8347 } 8348 if (objc == 4) { 8349 const char *name = Tcl_GetString(objv[3]); 8350 g_renderer->setGraphicsObjectLighting<Warp>(name, state); 8351 } else { 8352 g_renderer->setGraphicsObjectLighting<Warp>("all", state); 8353 } 8354 return TCL_OK; 8355 } 8356 8357 static int 8358 WarpLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 8359 Tcl_Obj *const *objv) 8360 { 8361 float color[3]; 8362 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 8363 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 8364 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 8365 return TCL_ERROR; 8366 } 8367 if (objc == 6) { 8368 const char *name = Tcl_GetString(objv[5]); 8369 g_renderer->setGraphicsObjectEdgeColor<Warp>(name, color); 8370 } else { 8371 g_renderer->setGraphicsObjectEdgeColor<Warp>("all", color); 8372 } 8373 return TCL_OK; 8374 } 8375 8376 static int 8377 WarpLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc, 8378 Tcl_Obj *const *objv) 8379 { 8380 float width; 8381 if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) { 8382 return TCL_ERROR; 8383 } 8384 if (objc == 4) { 8385 const char *name = Tcl_GetString(objv[3]); 8386 g_renderer->setGraphicsObjectEdgeWidth<Warp>(name, width); 8387 } else { 8388 g_renderer->setGraphicsObjectEdgeWidth<Warp>("all", width); 8389 } 8390 return TCL_OK; 8391 } 8392 8393 static int 8394 WarpOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc, 8395 Tcl_Obj *const *objv) 8396 { 8397 double opacity; 8398 if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) { 8399 return TCL_ERROR; 8400 } 8401 if (objc == 4) { 8402 const char *name = Tcl_GetString(objv[3]); 8403 g_renderer->setGraphicsObjectOpacity<Warp>(name, opacity); 8404 } else { 8405 g_renderer->setGraphicsObjectOpacity<Warp>("all", opacity); 8406 } 8407 return TCL_OK; 8408 } 8409 8410 static int 8411 WarpOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 8412 Tcl_Obj *const *objv) 8413 { 8414 double quat[4]; 8415 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 8416 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 8417 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 8418 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 8419 return TCL_ERROR; 8420 } 8421 if (objc == 7) { 8422 const char *name = Tcl_GetString(objv[6]); 8423 g_renderer->setGraphicsObjectOrientation<Warp>(name, quat); 8424 } else { 8425 g_renderer->setGraphicsObjectOrientation<Warp>("all", quat); 8426 } 8427 return TCL_OK; 8428 } 8429 8430 static int 8431 WarpPositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 8432 Tcl_Obj *const *objv) 8433 { 8434 double pos[3]; 8435 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 8436 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 8437 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 8438 return TCL_ERROR; 8439 } 8440 if (objc == 6) { 8441 const char *name = Tcl_GetString(objv[5]); 8442 g_renderer->setGraphicsObjectPosition<Warp>(name, pos); 8443 } else { 8444 g_renderer->setGraphicsObjectPosition<Warp>("all", pos); 8445 } 8446 return TCL_OK; 8447 } 8448 8449 static int 8450 WarpScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 8451 Tcl_Obj *const *objv) 8452 { 8453 double scale[3]; 8454 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 8455 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 8456 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 8457 return TCL_ERROR; 8458 } 8459 if (objc == 6) { 8460 const char *name = Tcl_GetString(objv[5]); 8461 g_renderer->setGraphicsObjectScale<Warp>(name, scale); 8462 } else { 8463 g_renderer->setGraphicsObjectScale<Warp>("all", scale); 8464 } 8465 return TCL_OK; 8466 } 8467 8468 static int 8469 WarpVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 8470 Tcl_Obj *const *objv) 8471 { 8472 bool state; 8473 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 8474 return TCL_ERROR; 8475 } 8476 if (objc == 4) { 8477 const char *name = Tcl_GetString(objv[3]); 8478 g_renderer->setGraphicsObjectVisibility<Warp>(name, state); 8479 } else { 8480 g_renderer->setGraphicsObjectVisibility<Warp>("all", state); 8481 } 8482 return TCL_OK; 8483 } 8484 8485 static int 8486 WarpWarpScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 8487 Tcl_Obj *const *objv) 8488 { 8489 double scale; 8490 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale) != TCL_OK) { 8491 return TCL_ERROR; 8492 } 8493 if (objc == 4) { 8494 const char *name = Tcl_GetString(objv[3]); 8495 g_renderer->setWarpWarpScale(name, scale); 8496 } else { 8497 g_renderer->setWarpWarpScale("all", scale); 8498 } 8499 return TCL_OK; 8500 } 8501 8502 static int 8503 WarpWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc, 8504 Tcl_Obj *const *objv) 8505 { 8506 bool state; 8507 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 8508 return TCL_ERROR; 8509 } 8510 if (objc == 4) { 8511 const char *name = Tcl_GetString(objv[3]); 8512 g_renderer->setGraphicsObjectWireframe<Warp>(name, state); 8513 } else { 8514 g_renderer->setGraphicsObjectWireframe<Warp>("all", state); 8515 } 8516 return TCL_OK; 8517 } 8518 8519 static Rappture::CmdSpec warpOps[] = { 8520 {"add", 1, WarpAddOp, 2, 3, "?dataSetName?"}, 8521 {"colormap", 1, WarpColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 8522 {"delete", 1, WarpDeleteOp, 2, 3, "?dataSetName?"}, 8523 {"edges", 1, WarpEdgeVisibilityOp, 3, 4, "bool ?dataSetName?"}, 8524 {"lighting", 3, WarpLightingOp, 3, 4, "bool ?dataSetName?"}, 8525 {"linecolor", 5, WarpLineColorOp, 5, 6, "r g b ?dataSetName?"}, 8526 {"linewidth", 5, WarpLineWidthOp, 3, 4, "width ?dataSetName?"}, 8527 {"opacity", 2, WarpOpacityOp, 3, 4, "value ?dataSetName?"}, 8528 {"orient", 2, WarpOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, 8529 {"pos", 1, WarpPositionOp, 5, 6, "x y z ?dataSetName?"}, 8530 {"scale", 2, WarpScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 8531 {"visible", 1, WarpVisibleOp, 3, 4, "bool ?dataSetName?"}, 8532 {"warpscale", 2, WarpWarpScaleOp, 3, 4, "value ?dataSetName?"}, 8533 {"wireframe", 2, WarpWireframeOp, 3, 4, "bool ?dataSetName?"} 8534 }; 8535 static int nWarpOps = NumCmdSpecs(warpOps); 8536 8537 static int 8538 WarpCmd(ClientData clientData, Tcl_Interp *interp, int objc, 8539 Tcl_Obj *const *objv) 8540 { 8541 Tcl_ObjCmdProc *proc; 8542 8543 proc = Rappture::GetOpFromObj(interp, nWarpOps, warpOps, 5482 8544 Rappture::CMDSPEC_ARG1, objc, objv, 0); 5483 8545 if (proc == NULL) { … … 5584 8646 { 5585 8647 Tcl_MakeSafe(interp); 8648 Tcl_CreateObjCommand(interp, "arc", ArcCmd, clientData, NULL); 8649 Tcl_CreateObjCommand(interp, "arrow", ArrowCmd, clientData, NULL); 5586 8650 Tcl_CreateObjCommand(interp, "axis", AxisCmd, clientData, NULL); 8651 Tcl_CreateObjCommand(interp, "box", BoxCmd, clientData, NULL); 5587 8652 Tcl_CreateObjCommand(interp, "camera", CameraCmd, clientData, NULL); 5588 8653 Tcl_CreateObjCommand(interp, "colormap", ColorMapCmd, clientData, NULL); 8654 Tcl_CreateObjCommand(interp, "cone", ConeCmd, clientData, NULL); 5589 8655 Tcl_CreateObjCommand(interp, "contour2d", Contour2DCmd, clientData, NULL); 5590 8656 Tcl_CreateObjCommand(interp, "contour3d", Contour3DCmd, clientData, NULL); 5591 8657 Tcl_CreateObjCommand(interp, "cutplane", CutplaneCmd, clientData, NULL); 8658 Tcl_CreateObjCommand(interp, "cylinder", CylinderCmd, clientData, NULL); 5592 8659 Tcl_CreateObjCommand(interp, "dataset", DataSetCmd, clientData, NULL); 8660 Tcl_CreateObjCommand(interp, "disk", DiskCmd, clientData, NULL); 5593 8661 Tcl_CreateObjCommand(interp, "glyphs", GlyphsCmd, clientData, NULL); 5594 8662 Tcl_CreateObjCommand(interp, "heightmap", HeightMapCmd, clientData, NULL); … … 5596 8664 Tcl_CreateObjCommand(interp, "legend", LegendCmd, clientData, NULL); 5597 8665 Tcl_CreateObjCommand(interp, "lic", LICCmd, clientData, NULL); 8666 Tcl_CreateObjCommand(interp, "line", LineCmd, clientData, NULL); 5598 8667 Tcl_CreateObjCommand(interp, "molecule", MoleculeCmd, clientData, NULL); 5599 8668 Tcl_CreateObjCommand(interp, "polydata", PolyDataCmd, clientData, NULL); 8669 Tcl_CreateObjCommand(interp, "polygon", PolygonCmd, clientData, NULL); 5600 8670 Tcl_CreateObjCommand(interp, "pseudocolor", PseudoColorCmd, clientData, NULL); 5601 8671 Tcl_CreateObjCommand(interp, "renderer", RendererCmd, clientData, NULL); 5602 8672 Tcl_CreateObjCommand(interp, "screen", ScreenCmd, clientData, NULL); 8673 Tcl_CreateObjCommand(interp, "sphere", SphereCmd, clientData, NULL); 5603 8674 Tcl_CreateObjCommand(interp, "streamlines", StreamlinesCmd, clientData, NULL); 5604 8675 Tcl_CreateObjCommand(interp, "volume", VolumeCmd, clientData, NULL); 8676 Tcl_CreateObjCommand(interp, "warp", WarpCmd, clientData, NULL); 5605 8677 } 5606 8678 … … 5610 8682 void Rappture::VtkVis::exitTcl(Tcl_Interp *interp) 5611 8683 { 5612 8684 Tcl_DeleteCommand(interp, "arc"); 8685 Tcl_DeleteCommand(interp, "arrow"); 5613 8686 Tcl_DeleteCommand(interp, "axis"); 8687 Tcl_DeleteCommand(interp, "box"); 5614 8688 Tcl_DeleteCommand(interp, "camera"); 5615 8689 Tcl_DeleteCommand(interp, "colormap"); 8690 Tcl_DeleteCommand(interp, "cone"); 5616 8691 Tcl_DeleteCommand(interp, "contour2d"); 5617 8692 Tcl_DeleteCommand(interp, "contour3d"); 5618 8693 Tcl_DeleteCommand(interp, "cutplane"); 8694 Tcl_DeleteCommand(interp, "cylinder"); 5619 8695 Tcl_DeleteCommand(interp, "dataset"); 8696 Tcl_DeleteCommand(interp, "disk"); 5620 8697 Tcl_DeleteCommand(interp, "glyphs"); 5621 8698 Tcl_DeleteCommand(interp, "heightmap"); … … 5623 8700 Tcl_DeleteCommand(interp, "legend"); 5624 8701 Tcl_DeleteCommand(interp, "lic"); 8702 Tcl_DeleteCommand(interp, "line"); 5625 8703 Tcl_DeleteCommand(interp, "molecule"); 5626 8704 Tcl_DeleteCommand(interp, "polydata"); 8705 Tcl_DeleteCommand(interp, "polygon"); 5627 8706 Tcl_DeleteCommand(interp, "pseudocolor"); 5628 8707 Tcl_DeleteCommand(interp, "renderer"); 5629 8708 Tcl_DeleteCommand(interp, "screen"); 8709 Tcl_DeleteCommand(interp, "sphere"); 5630 8710 Tcl_DeleteCommand(interp, "streamlines"); 5631 8711 Tcl_DeleteCommand(interp, "volume"); 8712 Tcl_DeleteCommand(interp, "warp"); 5632 8713 5633 8714 Tcl_DeleteInterp(interp); -
branches/nanovis2/packages/vizservers/vtkvis/RpVtkRendererGraphicsObjs.cpp
r2757 r3175 14 14 #include <vtkDataSetReader.h> 15 15 16 #include "RpVtkRendererGraphicsObjs.h" 16 17 #include "RpVtkRenderer.h" 17 18 #include "RpVtkDataSet.h" 19 #include "RpBox.h" 18 20 #include "RpContour2D.h" 19 21 #include "RpContour3D.h" … … 22 24 #include "RpHeightMap.h" 23 25 #include "RpLIC.h" 26 #include "RpLine.h" 24 27 #include "RpMolecule.h" 25 28 #include "RpPolyData.h" 26 29 #include "RpPseudoColor.h" 30 #include "RpSphere.h" 27 31 #include "RpStreamlines.h" 28 32 #include "RpVolume.h" … … 35 39 36 40 template<> 41 Renderer::ArcHashmap & 42 Renderer::getGraphicsObjectHashmap<Arc>() 43 { return _arcs; } 44 45 template<> 46 Renderer::ArrowHashmap & 47 Renderer::getGraphicsObjectHashmap<Arrow>() 48 { return _arrows; } 49 50 template<> 51 Renderer::BoxHashmap & 52 Renderer::getGraphicsObjectHashmap<Box>() 53 { return _boxes; } 54 55 template<> 56 Renderer::ConeHashmap & 57 Renderer::getGraphicsObjectHashmap<Cone>() 58 { return _cones; } 59 60 template<> 37 61 Renderer::Contour2DHashmap & 38 62 Renderer::getGraphicsObjectHashmap<Contour2D>() … … 50 74 51 75 template<> 76 Renderer::CylinderHashmap & 77 Renderer::getGraphicsObjectHashmap<Cylinder>() 78 { return _cylinders; } 79 80 template<> 81 Renderer::DiskHashmap & 82 Renderer::getGraphicsObjectHashmap<Disk>() 83 { return _disks; } 84 85 template<> 52 86 Renderer::GlyphsHashmap & 53 87 Renderer::getGraphicsObjectHashmap<Glyphs>() 54 88 { return _glyphs; } 89 90 template<> 91 Renderer::GroupHashmap & 92 Renderer::getGraphicsObjectHashmap<Group>() 93 { return _groups; } 55 94 56 95 template<> … … 65 104 66 105 template<> 106 Renderer::LineHashmap & 107 Renderer::getGraphicsObjectHashmap<Line>() 108 { return _lines; } 109 110 template<> 67 111 Renderer::MoleculeHashmap & 68 112 Renderer::getGraphicsObjectHashmap<Molecule>() … … 75 119 76 120 template<> 121 Renderer::PolygonHashmap & 122 Renderer::getGraphicsObjectHashmap<Polygon>() 123 { return _polygons; } 124 125 template<> 77 126 Renderer::PseudoColorHashmap & 78 127 Renderer::getGraphicsObjectHashmap<PseudoColor>() 79 128 { return _pseudoColors; } 129 130 template<> 131 Renderer::SphereHashmap & 132 Renderer::getGraphicsObjectHashmap<Sphere>() 133 { return _spheres; } 80 134 81 135 template<> … … 89 143 { return _volumes; } 90 144 145 template<> 146 Renderer::WarpHashmap & 147 Renderer::getGraphicsObjectHashmap<Warp>() 148 { return _warps; } 149 150 template Arc *Renderer::getGraphicsObject(const DataSetId&); 151 template Arrow *Renderer::getGraphicsObject(const DataSetId&); 152 template Box *Renderer::getGraphicsObject(const DataSetId&); 153 template Cone *Renderer::getGraphicsObject(const DataSetId&); 154 template Cylinder *Renderer::getGraphicsObject(const DataSetId&); 155 template Disk *Renderer::getGraphicsObject(const DataSetId&); 156 template Group *Renderer::getGraphicsObject(const DataSetId&); 157 template Line *Renderer::getGraphicsObject(const DataSetId&); 158 template Polygon *Renderer::getGraphicsObject(const DataSetId&); 159 template Sphere *Renderer::getGraphicsObject(const DataSetId&); 160 161 template <> 162 bool Renderer::addGraphicsObject<Box>(const DataSetId& id) 163 { 164 Box *gobj; 165 if ((gobj = getGraphicsObject<Box>(id)) != NULL) { 166 WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str()); 167 deleteGraphicsObject<Box>(id); 168 } 169 170 gobj = new Box(); 171 172 gobj->setDataSet(NULL, this); 173 174 if (gobj->getProp() == NULL && 175 gobj->getOverlayProp() == NULL) { 176 delete gobj; 177 return false; 178 } else { 179 if (gobj->getProp()) 180 _renderer->AddViewProp(gobj->getProp()); 181 if (gobj->getOverlayProp()) 182 _renderer->AddViewProp(gobj->getOverlayProp()); 183 } 184 185 getGraphicsObjectHashmap<Box>()[id] = gobj; 186 187 initCamera(); 188 _needsRedraw = true; 189 return true; 190 } 191 192 template <> 193 bool Renderer::addGraphicsObject<Sphere>(const DataSetId& id) 194 { 195 Sphere *gobj; 196 if ((gobj = getGraphicsObject<Sphere>(id)) != NULL) { 197 WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str()); 198 deleteGraphicsObject<Sphere>(id); 199 } 200 201 gobj = new Sphere(); 202 203 gobj->setDataSet(NULL, this); 204 205 if (gobj->getProp() == NULL && 206 gobj->getOverlayProp() == NULL) { 207 delete gobj; 208 return false; 209 } else { 210 if (gobj->getProp()) 211 _renderer->AddViewProp(gobj->getProp()); 212 if (gobj->getOverlayProp()) 213 _renderer->AddViewProp(gobj->getOverlayProp()); 214 } 215 216 getGraphicsObjectHashmap<Sphere>()[id] = gobj; 217 218 initCamera(); 219 _needsRedraw = true; 220 return true; 221 } 222 91 223 /** 92 224 * \brief Set the volume slice used for mapping volumetric data … … 129 261 130 262 using namespace Rappture::VtkVis; 263 264 /** 265 * \brief Create a new Arc and associate it with an ID 266 */ 267 bool Renderer::addArc(const DataSetId& id, double pt1[3], double pt2[3]) 268 { 269 Arc *gobj; 270 if ((gobj = getGraphicsObject<Arc>(id)) != NULL) { 271 WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str()); 272 deleteGraphicsObject<Arc>(id); 273 } 274 275 gobj = new Arc(); 276 277 gobj->setDataSet(NULL, this); 278 279 if (gobj->getProp() == NULL && 280 gobj->getOverlayProp() == NULL) { 281 delete gobj; 282 return false; 283 } else { 284 if (gobj->getProp()) 285 _renderer->AddViewProp(gobj->getProp()); 286 if (gobj->getOverlayProp()) 287 _renderer->AddViewProp(gobj->getOverlayProp()); 288 } 289 290 gobj->setEndPoints(pt1, pt2); 291 292 getGraphicsObjectHashmap<Arc>()[id] = gobj; 293 294 initCamera(); 295 _needsRedraw = true; 296 return true; 297 } 298 299 /** 300 * \brief Set Arc resolution 301 */ 302 void Renderer::setArcResolution(const DataSetId& id, int res) 303 { 304 ArcHashmap::iterator itr; 305 306 bool doAll = false; 307 308 if (id.compare("all") == 0) { 309 itr = _arcs.begin(); 310 doAll = true; 311 } else { 312 itr = _arcs.find(id); 313 } 314 if (itr == _arcs.end()) { 315 ERROR("Arc not found: %s", id.c_str()); 316 return; 317 } 318 319 do { 320 itr->second->setResolution(res); 321 } while (doAll && ++itr != _arcs.end()); 322 323 _needsRedraw = true; 324 } 325 326 /** 327 * \brief Create a new Arrow and associate it with an ID 328 */ 329 bool Renderer::addArrow(const DataSetId& id, double tipRadius, double shaftRadius, double tipLength) 330 { 331 Arrow *gobj; 332 if ((gobj = getGraphicsObject<Arrow>(id)) != NULL) { 333 WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str()); 334 deleteGraphicsObject<Arrow>(id); 335 } 336 337 gobj = new Arrow(); 338 339 gobj->setDataSet(NULL, this); 340 341 if (gobj->getProp() == NULL && 342 gobj->getOverlayProp() == NULL) { 343 delete gobj; 344 return false; 345 } else { 346 if (gobj->getProp()) 347 _renderer->AddViewProp(gobj->getProp()); 348 if (gobj->getOverlayProp()) 349 _renderer->AddViewProp(gobj->getOverlayProp()); 350 } 351 352 gobj->setRadii(tipRadius, shaftRadius); 353 gobj->setTipLength(tipLength); 354 355 getGraphicsObjectHashmap<Arrow>()[id] = gobj; 356 357 initCamera(); 358 _needsRedraw = true; 359 return true; 360 } 361 362 /** 363 * \brief Set Arrow resolution 364 */ 365 void Renderer::setArrowResolution(const DataSetId& id, int tipRes, int shaftRes) 366 { 367 ArrowHashmap::iterator itr; 368 369 bool doAll = false; 370 371 if (id.compare("all") == 0) { 372 itr = _arrows.begin(); 373 doAll = true; 374 } else { 375 itr = _arrows.find(id); 376 } 377 if (itr == _arrows.end()) { 378 ERROR("Arrow not found: %s", id.c_str()); 379 return; 380 } 381 382 do { 383 itr->second->setResolution(tipRes, shaftRes); 384 } while (doAll && ++itr != _arrows.end()); 385 386 _needsRedraw = true; 387 } 388 389 /** 390 * \brief Create a new Cone and associate it with an ID 391 */ 392 bool Renderer::addCone(const DataSetId& id, double radius, double height, bool cap) 393 { 394 Cone *gobj; 395 if ((gobj = getGraphicsObject<Cone>(id)) != NULL) { 396 WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str()); 397 deleteGraphicsObject<Cone>(id); 398 } 399 400 gobj = new Cone(); 401 402 gobj->setDataSet(NULL, this); 403 404 if (gobj->getProp() == NULL && 405 gobj->getOverlayProp() == NULL) { 406 delete gobj; 407 return false; 408 } else { 409 if (gobj->getProp()) 410 _renderer->AddViewProp(gobj->getProp()); 411 if (gobj->getOverlayProp()) 412 _renderer->AddViewProp(gobj->getOverlayProp()); 413 } 414 415 gobj->setRadius(radius); 416 gobj->setHeight(height); 417 gobj->setCapping(cap); 418 419 getGraphicsObjectHashmap<Cone>()[id] = gobj; 420 421 initCamera(); 422 _needsRedraw = true; 423 return true; 424 } 425 426 /** 427 * \brief Set Cone resolution 428 */ 429 void Renderer::setConeResolution(const DataSetId& id, int res) 430 { 431 ConeHashmap::iterator itr; 432 433 bool doAll = false; 434 435 if (id.compare("all") == 0) { 436 itr = _cones.begin(); 437 doAll = true; 438 } else { 439 itr = _cones.find(id); 440 } 441 if (itr == _cones.end()) { 442 ERROR("Cone not found: %s", id.c_str()); 443 return; 444 } 445 446 do { 447 itr->second->setResolution(res); 448 } while (doAll && ++itr != _cones.end()); 449 450 _needsRedraw = true; 451 } 131 452 132 453 /** … … 278 599 } 279 600 601 602 /** 603 * \brief Set the color mode for the specified DataSet 604 */ 605 void Renderer::setContour2DColorMode(const DataSetId& id, 606 Contour2D::ColorMode mode, 607 DataSet::DataAttributeType type, 608 const char *name, double range[2]) 609 { 610 Contour2DHashmap::iterator itr; 611 612 bool doAll = false; 613 614 if (id.compare("all") == 0) { 615 itr = _contour2Ds.begin(); 616 doAll = true; 617 } else { 618 itr = _contour2Ds.find(id); 619 } 620 if (itr == _contour2Ds.end()) { 621 ERROR("Contour2D not found: %s", id.c_str()); 622 return; 623 } 624 625 do { 626 itr->second->setColorMode(mode, type, name, range); 627 } while (doAll && ++itr != _contour2Ds.end()); 628 629 _needsRedraw = true; 630 } 631 632 /** 633 * \brief Set the color mode for the specified DataSet 634 */ 635 void Renderer::setContour2DColorMode(const DataSetId& id, 636 Contour2D::ColorMode mode, 637 const char *name, double range[2]) 638 { 639 Contour2DHashmap::iterator itr; 640 641 bool doAll = false; 642 643 if (id.compare("all") == 0) { 644 itr = _contour2Ds.begin(); 645 doAll = true; 646 } else { 647 itr = _contour2Ds.find(id); 648 } 649 if (itr == _contour2Ds.end()) { 650 ERROR("Contour2D not found: %s", id.c_str()); 651 return; 652 } 653 654 do { 655 itr->second->setColorMode(mode, name, range); 656 } while (doAll && ++itr != _contour2Ds.end()); 657 658 _needsRedraw = true; 659 } 660 280 661 /** 281 662 * \brief Create a new Contour3D and associate it with the named DataSet … … 543 924 itr->second->setColorMode(mode, name, range); 544 925 } while (doAll && ++itr != _cutplanes.end()); 926 927 _needsRedraw = true; 928 } 929 930 /** 931 * \brief Create a new Cylinder and associate it with an ID 932 */ 933 bool Renderer::addCylinder(const DataSetId& id, double radius, double height, bool cap) 934 { 935 Cylinder *gobj; 936 if ((gobj = getGraphicsObject<Cylinder>(id)) != NULL) { 937 WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str()); 938 deleteGraphicsObject<Cylinder>(id); 939 } 940 941 gobj = new Cylinder(); 942 943 gobj->setDataSet(NULL, this); 944 945 if (gobj->getProp() == NULL && 946 gobj->getOverlayProp() == NULL) { 947 delete gobj; 948 return false; 949 } else { 950 if (gobj->getProp()) 951 _renderer->AddViewProp(gobj->getProp()); 952 if (gobj->getOverlayProp()) 953 _renderer->AddViewProp(gobj->getOverlayProp()); 954 } 955 956 gobj->setRadius(radius); 957 gobj->setHeight(height); 958 gobj->setCapping(cap); 959 960 getGraphicsObjectHashmap<Cylinder>()[id] = gobj; 961 962 initCamera(); 963 _needsRedraw = true; 964 return true; 965 } 966 967 /** 968 * \brief Set Cylinder resolution 969 */ 970 void Renderer::setCylinderResolution(const DataSetId& id, int res) 971 { 972 CylinderHashmap::iterator itr; 973 974 bool doAll = false; 975 976 if (id.compare("all") == 0) { 977 itr = _cylinders.begin(); 978 doAll = true; 979 } else { 980 itr = _cylinders.find(id); 981 } 982 if (itr == _cylinders.end()) { 983 ERROR("Cylinder not found: %s", id.c_str()); 984 return; 985 } 986 987 do { 988 itr->second->setResolution(res); 989 } while (doAll && ++itr != _cylinders.end()); 990 991 _needsRedraw = true; 992 } 993 994 /** 995 * \brief Create a new Disk and associate it with an ID 996 */ 997 bool Renderer::addDisk(const DataSetId& id, double innerRadius, double outerRadius) 998 { 999 Disk *gobj; 1000 if ((gobj = getGraphicsObject<Disk>(id)) != NULL) { 1001 WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str()); 1002 deleteGraphicsObject<Disk>(id); 1003 } 1004 1005 gobj = new Disk(); 1006 1007 gobj->setDataSet(NULL, this); 1008 1009 if (gobj->getProp() == NULL && 1010 gobj->getOverlayProp() == NULL) { 1011 delete gobj; 1012 return false; 1013 } else { 1014 if (gobj->getProp()) 1015 _renderer->AddViewProp(gobj->getProp()); 1016 if (gobj->getOverlayProp()) 1017 _renderer->AddViewProp(gobj->getOverlayProp()); 1018 } 1019 1020 gobj->setRadii(innerRadius, outerRadius); 1021 1022 getGraphicsObjectHashmap<Disk>()[id] = gobj; 1023 1024 initCamera(); 1025 _needsRedraw = true; 1026 return true; 1027 } 1028 1029 /** 1030 * \brief Set Disk resolution 1031 */ 1032 void Renderer::setDiskResolution(const DataSetId& id, int resRadial, int resCircum) 1033 { 1034 DiskHashmap::iterator itr; 1035 1036 bool doAll = false; 1037 1038 if (id.compare("all") == 0) { 1039 itr = _disks.begin(); 1040 doAll = true; 1041 } else { 1042 itr = _disks.find(id); 1043 } 1044 if (itr == _disks.end()) { 1045 ERROR("Disk not found: %s", id.c_str()); 1046 return; 1047 } 1048 1049 do { 1050 itr->second->setResolution(resRadial, resCircum); 1051 } while (doAll && ++itr != _disks.end()); 545 1052 546 1053 _needsRedraw = true; … … 698 1205 699 1206 /** 1207 * \brief Controls if glyphs are oriented from a vector field for the 1208 * given DataSet 1209 */ 1210 void Renderer::setGlyphsOrientMode(const DataSetId& id, bool state, 1211 const char *name) 1212 { 1213 GlyphsHashmap::iterator itr; 1214 1215 bool doAll = false; 1216 1217 if (id.compare("all") == 0) { 1218 itr = _glyphs.begin(); 1219 doAll = true; 1220 } else { 1221 itr = _glyphs.find(id); 1222 } 1223 if (itr == _glyphs.end()) { 1224 ERROR("Glyphs not found: %s", id.c_str()); 1225 return; 1226 } 1227 1228 do { 1229 #ifdef HAVE_GLYPH3D_MAPPER 1230 itr->second->setOrientMode(state, name); 1231 #else 1232 if (name != NULL && strlen(name) > 0) { 1233 WARN("Glyphs orient mode doesn't support named fields for VTK < 5.8.0"); 1234 } 1235 itr->second->setOrient(state); 1236 #endif 1237 } while (doAll && ++itr != _glyphs.end()); 1238 1239 _renderer->ResetCameraClippingRange(); 1240 _needsRedraw = true; 1241 } 1242 1243 /** 700 1244 * \brief Set the shape of Glyphs for the given DataSet 701 1245 */ … … 875 1419 } while (doAll && ++itr != _heightMaps.end()); 876 1420 877 initCamera(); 1421 _renderer->ResetCameraClippingRange(); 1422 resetAxes(); 878 1423 _needsRedraw = true; 879 1424 } … … 1045 1590 1046 1591 /** 1047 * \brief Set radius standard for scaling atoms 1048 */ 1049 void Renderer::setMoleculeAtomScaling(const DataSetId& id, Molecule::AtomScaling scaling) 1592 * \brief Create a new Line and associate it with an ID 1593 */ 1594 bool Renderer::addLine(const DataSetId& id, double pt1[3], double pt2[3]) 1595 { 1596 Line *gobj; 1597 if ((gobj = getGraphicsObject<Line>(id)) != NULL) { 1598 WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str()); 1599 deleteGraphicsObject<Line>(id); 1600 } 1601 1602 gobj = new Line(); 1603 1604 gobj->setDataSet(NULL, this); 1605 1606 if (gobj->getProp() == NULL && 1607 gobj->getOverlayProp() == NULL) { 1608 delete gobj; 1609 return false; 1610 } else { 1611 if (gobj->getProp()) 1612 _renderer->AddViewProp(gobj->getProp()); 1613 if (gobj->getOverlayProp()) 1614 _renderer->AddViewProp(gobj->getOverlayProp()); 1615 } 1616 1617 gobj->setEndPoints(pt1, pt2); 1618 1619 getGraphicsObjectHashmap<Line>()[id] = gobj; 1620 1621 initCamera(); 1622 _needsRedraw = true; 1623 return true; 1624 } 1625 1626 /** 1627 * \brief Set radius scale factor for atoms 1628 */ 1629 void Renderer::setMoleculeAtomRadiusScale(const DataSetId& id, double scale) 1050 1630 { 1051 1631 MoleculeHashmap::iterator itr; … … 1065 1645 1066 1646 do { 1647 itr->second->setAtomRadiusScale(scale); 1648 } while (doAll && ++itr != _molecules.end()); 1649 1650 _renderer->ResetCameraClippingRange(); 1651 resetAxes(); 1652 _needsRedraw = true; 1653 } 1654 1655 /** 1656 * \brief Set radius standard for scaling atoms 1657 */ 1658 void Renderer::setMoleculeAtomScaling(const DataSetId& id, Molecule::AtomScaling scaling) 1659 { 1660 MoleculeHashmap::iterator itr; 1661 1662 bool doAll = false; 1663 1664 if (id.compare("all") == 0) { 1665 itr = _molecules.begin(); 1666 doAll = true; 1667 } else { 1668 itr = _molecules.find(id); 1669 } 1670 if (itr == _molecules.end()) { 1671 ERROR("Molecule not found: %s", id.c_str()); 1672 return; 1673 } 1674 1675 do { 1067 1676 itr->second->setAtomScaling(scaling); 1068 1677 } while (doAll && ++itr != _molecules.end()); 1069 1678 1679 _renderer->ResetCameraClippingRange(); 1680 resetAxes(); 1070 1681 _needsRedraw = true; 1071 1682 } … … 1099 1710 1100 1711 /** 1101 * \brief Turn on/off rendering of the Molecule bonds for the given DataSet1102 */ 1103 void Renderer::setMolecule BondVisibility(const DataSetId& id, bool state)1712 * \brief Turn on/off rendering of the Molecule atom labels for the given DataSet 1713 */ 1714 void Renderer::setMoleculeAtomLabelVisibility(const DataSetId& id, bool state) 1104 1715 { 1105 1716 MoleculeHashmap::iterator itr; … … 1119 1730 1120 1731 do { 1732 itr->second->setAtomLabelVisibility(state); 1733 } while (doAll && ++itr != _molecules.end()); 1734 1735 _needsRedraw = true; 1736 } 1737 1738 /** 1739 * \brief Set radius scale factor for atoms 1740 */ 1741 void Renderer::setMoleculeBondRadiusScale(const DataSetId& id, double scale) 1742 { 1743 MoleculeHashmap::iterator itr; 1744 1745 bool doAll = false; 1746 1747 if (id.compare("all") == 0) { 1748 itr = _molecules.begin(); 1749 doAll = true; 1750 } else { 1751 itr = _molecules.find(id); 1752 } 1753 if (itr == _molecules.end()) { 1754 ERROR("Molecule not found: %s", id.c_str()); 1755 return; 1756 } 1757 1758 do { 1759 itr->second->setBondRadiusScale(scale); 1760 } while (doAll && ++itr != _molecules.end()); 1761 1762 _renderer->ResetCameraClippingRange(); 1763 resetAxes(); 1764 _needsRedraw = true; 1765 } 1766 1767 /** 1768 * \brief Turn on/off rendering of the Molecule bonds for the given DataSet 1769 */ 1770 void Renderer::setMoleculeBondVisibility(const DataSetId& id, bool state) 1771 { 1772 MoleculeHashmap::iterator itr; 1773 1774 bool doAll = false; 1775 1776 if (id.compare("all") == 0) { 1777 itr = _molecules.begin(); 1778 doAll = true; 1779 } else { 1780 itr = _molecules.find(id); 1781 } 1782 if (itr == _molecules.end()) { 1783 ERROR("Molecule not found: %s", id.c_str()); 1784 return; 1785 } 1786 1787 do { 1121 1788 itr->second->setBondVisibility(state); 1122 1789 } while (doAll && ++itr != _molecules.end()); 1123 1790 1124 1791 _needsRedraw = true; 1792 } 1793 1794 void Renderer::setMoleculeBondStyle(const DataSetId& id, Molecule::BondStyle style) 1795 { 1796 MoleculeHashmap::iterator itr; 1797 1798 bool doAll = false; 1799 1800 if (id.compare("all") == 0) { 1801 itr = _molecules.begin(); 1802 doAll = true; 1803 } else { 1804 itr = _molecules.find(id); 1805 } 1806 if (itr == _molecules.end()) { 1807 ERROR("Molecule not found: %s", id.c_str()); 1808 return; 1809 } 1810 1811 do { 1812 itr->second->setBondStyle(style); 1813 } while (doAll && ++itr != _molecules.end()); 1814 1815 _needsRedraw = true; 1816 } 1817 1818 void Renderer::setMoleculeBondColorMode(const DataSetId& id, Molecule::BondColorMode mode) 1819 { 1820 MoleculeHashmap::iterator itr; 1821 1822 bool doAll = false; 1823 1824 if (id.compare("all") == 0) { 1825 itr = _molecules.begin(); 1826 doAll = true; 1827 } else { 1828 itr = _molecules.find(id); 1829 } 1830 if (itr == _molecules.end()) { 1831 ERROR("Molecule not found: %s", id.c_str()); 1832 return; 1833 } 1834 1835 do { 1836 itr->second->setBondColorMode(mode); 1837 } while (doAll && ++itr != _molecules.end()); 1838 1839 _needsRedraw = true; 1840 } 1841 1842 void Renderer::setMoleculeBondColor(const DataSetId& id, float color[3]) 1843 { 1844 MoleculeHashmap::iterator itr; 1845 1846 bool doAll = false; 1847 1848 if (id.compare("all") == 0) { 1849 itr = _molecules.begin(); 1850 doAll = true; 1851 } else { 1852 itr = _molecules.find(id); 1853 } 1854 if (itr == _molecules.end()) { 1855 ERROR("Molecule not found: %s", id.c_str()); 1856 return; 1857 } 1858 1859 do { 1860 itr->second->setBondColor(color); 1861 } while (doAll && ++itr != _molecules.end()); 1862 1863 _needsRedraw = true; 1864 } 1865 1866 1867 /** 1868 * \brief Set the color mode for the specified DataSet 1869 */ 1870 void Renderer::setMoleculeColorMode(const DataSetId& id, 1871 Molecule::ColorMode mode, 1872 DataSet::DataAttributeType type, 1873 const char *name, double range[2]) 1874 { 1875 MoleculeHashmap::iterator itr; 1876 1877 bool doAll = false; 1878 1879 if (id.compare("all") == 0) { 1880 itr = _molecules.begin(); 1881 doAll = true; 1882 } else { 1883 itr = _molecules.find(id); 1884 } 1885 if (itr == _molecules.end()) { 1886 ERROR("Molecule not found: %s", id.c_str()); 1887 return; 1888 } 1889 1890 do { 1891 itr->second->setColorMode(mode, type, name, range); 1892 } while (doAll && ++itr != _molecules.end()); 1893 1894 _needsRedraw = true; 1895 } 1896 1897 /** 1898 * \brief Set the color mode for the specified DataSet 1899 */ 1900 void Renderer::setMoleculeColorMode(const DataSetId& id, 1901 Molecule::ColorMode mode, 1902 const char *name, double range[2]) 1903 { 1904 MoleculeHashmap::iterator itr; 1905 1906 bool doAll = false; 1907 1908 if (id.compare("all") == 0) { 1909 itr = _molecules.begin(); 1910 doAll = true; 1911 } else { 1912 itr = _molecules.find(id); 1913 } 1914 if (itr == _molecules.end()) { 1915 ERROR("Molecule not found: %s", id.c_str()); 1916 return; 1917 } 1918 1919 do { 1920 itr->second->setColorMode(mode, name, range); 1921 } while (doAll && ++itr != _molecules.end()); 1922 1923 _needsRedraw = true; 1924 } 1925 1926 /** 1927 * \brief Create a new n-sided regular Polygon and associate it with an ID 1928 */ 1929 bool Renderer::addPolygon(const DataSetId& id, int numSides) 1930 { 1931 Polygon *gobj; 1932 if ((gobj = getGraphicsObject<Polygon>(id)) != NULL) { 1933 WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str()); 1934 deleteGraphicsObject<Polygon>(id); 1935 } 1936 1937 gobj = new Polygon(); 1938 1939 gobj->setDataSet(NULL, this); 1940 1941 if (gobj->getProp() == NULL && 1942 gobj->getOverlayProp() == NULL) { 1943 delete gobj; 1944 return false; 1945 } else { 1946 if (gobj->getProp()) 1947 _renderer->AddViewProp(gobj->getProp()); 1948 if (gobj->getOverlayProp()) 1949 _renderer->AddViewProp(gobj->getOverlayProp()); 1950 } 1951 1952 gobj->setNumberOfSides(numSides); 1953 1954 getGraphicsObjectHashmap<Polygon>()[id] = gobj; 1955 1956 initCamera(); 1957 _needsRedraw = true; 1958 return true; 1125 1959 } 1126 1960 … … 1180 2014 itr->second->setColorMode(mode, name, range); 1181 2015 } while (doAll && ++itr != _pseudoColors.end()); 2016 2017 _needsRedraw = true; 2018 } 2019 2020 /** 2021 * \brief Set Sphere resolution 2022 */ 2023 void Renderer::setSphereResolution(const DataSetId& id, int thetaRes, int phiRes) 2024 { 2025 SphereHashmap::iterator itr; 2026 2027 bool doAll = false; 2028 2029 if (id.compare("all") == 0) { 2030 itr = _spheres.begin(); 2031 doAll = true; 2032 } else { 2033 itr = _spheres.find(id); 2034 } 2035 if (itr == _spheres.end()) { 2036 ERROR("Sphere not found: %s", id.c_str()); 2037 return; 2038 } 2039 2040 do { 2041 itr->second->setThetaResolution(thetaRes); 2042 itr->second->setPhiResolution(phiRes); 2043 } while (doAll && ++itr != _spheres.end()); 2044 2045 _needsRedraw = true; 2046 } 2047 2048 /** 2049 * \brief Set Sphere section 2050 */ 2051 void Renderer::setSphereSection(const DataSetId& id, double thetaStart, double thetaEnd, 2052 double phiStart, double phiEnd) 2053 { 2054 SphereHashmap::iterator itr; 2055 2056 bool doAll = false; 2057 2058 if (id.compare("all") == 0) { 2059 itr = _spheres.begin(); 2060 doAll = true; 2061 } else { 2062 itr = _spheres.find(id); 2063 } 2064 if (itr == _spheres.end()) { 2065 ERROR("Sphere not found: %s", id.c_str()); 2066 return; 2067 } 2068 2069 do { 2070 itr->second->setStartTheta(thetaStart); 2071 itr->second->setEndTheta(thetaEnd); 2072 itr->second->setStartPhi(phiStart); 2073 itr->second->setEndPhi(phiEnd); 2074 } while (doAll && ++itr != _spheres.end()); 1182 2075 1183 2076 _needsRedraw = true; … … 1740 2633 _needsRedraw = true; 1741 2634 } 2635 2636 /** 2637 * \brief Set amount to scale vector magnitudes when warping 2638 * a mesh 2639 */ 2640 void Renderer::setWarpWarpScale(const DataSetId& id, double scale) 2641 { 2642 WarpHashmap::iterator itr; 2643 2644 bool doAll = false; 2645 2646 if (id.compare("all") == 0) { 2647 itr = _warps.begin(); 2648 doAll = true; 2649 } else { 2650 itr = _warps.find(id); 2651 } 2652 2653 if (itr == _warps.end()) { 2654 ERROR("Warp not found: %s", id.c_str()); 2655 return; 2656 } 2657 2658 do { 2659 itr->second->setWarpScale(scale); 2660 } while (doAll && ++itr != _warps.end()); 2661 2662 _renderer->ResetCameraClippingRange(); 2663 resetAxes(); 2664 _needsRedraw = true; 2665 } -
branches/nanovis2/packages/vizservers/vtkvis/RpVtkRendererGraphicsObjs.h
r2612 r3175 60 60 if (gobj->getProp()) 61 61 _renderer->RemoveViewProp(gobj->getProp()); 62 if (gobj->getOverlayProp()) 63 _renderer->RemoveViewProp(gobj->getOverlayProp()); 62 64 delete gobj; 63 65 … … 67 69 initCamera(); 68 70 _needsRedraw = true; 71 } 72 73 template<class GraphicsObject> 74 void Renderer::deleteAllGraphicsObjects() 75 { 76 std::tr1::unordered_map<DataSetId, GraphicsObject *>& hashmap = 77 getGraphicsObjectHashmap<GraphicsObject>(); 78 typename std::tr1::unordered_map<DataSetId, GraphicsObject *>::iterator itr; 79 80 itr = hashmap.begin(); 81 if (itr == hashmap.end()) 82 return; 83 84 TRACE("Deleting all %s objects", itr->second->getClassName()); 85 86 for (; itr != hashmap.end(); ++itr) { 87 delete itr->second; 88 } 89 hashmap.clear(); 69 90 } 70 91 … … 100 121 gobj->setDataSet(ds, this); 101 122 102 if (gobj->getProp() == NULL) { 123 if (gobj->getProp() == NULL && 124 gobj->getOverlayProp() == NULL) { 103 125 delete gobj; 104 126 return false; 105 127 } else { 106 _renderer->AddViewProp(gobj->getProp()); 128 if (gobj->getProp()) 129 _renderer->AddViewProp(gobj->getProp()); 130 if (gobj->getOverlayProp()) 131 _renderer->AddViewProp(gobj->getOverlayProp()); 107 132 } 108 133 … … 233 258 do { 234 259 itr->second->setPosition(pos); 260 } while (doAll && ++itr != hashmap.end()); 261 262 resetAxes(); 263 _needsRedraw = true; 264 } 265 266 /** 267 * \brief Set the prop scaling by 2D aspect ratio 268 */ 269 template<class GraphicsObject> 270 void Renderer::setGraphicsObjectAspect(const DataSetId& id, double aspect) 271 { 272 std::tr1::unordered_map<DataSetId, GraphicsObject *>& hashmap = 273 getGraphicsObjectHashmap<GraphicsObject>(); 274 typename std::tr1::unordered_map<DataSetId, GraphicsObject *>::iterator itr; 275 276 bool doAll = false; 277 278 if (id.compare("all") == 0) { 279 itr = hashmap.begin(); 280 doAll = true; 281 } else { 282 itr = hashmap.find(id); 283 } 284 if (itr == hashmap.end()) { 285 ERROR("%s not found: %s", typeid(GraphicsObject).name(), id.c_str()); 286 return; 287 } 288 289 do { 290 itr->second->setAspect(aspect); 235 291 } while (doAll && ++itr != hashmap.end()); 236 292 … … 709 765 } 710 766 767 template<class GraphicsObject> 768 void Renderer::updateGraphicsObjectColorMap(ColorMap *cmap) 769 { 770 std::tr1::unordered_map<DataSetId, GraphicsObject *>& hashmap = 771 getGraphicsObjectHashmap<GraphicsObject>(); 772 typename std::tr1::unordered_map<DataSetId, GraphicsObject *>::iterator itr; 773 774 for (itr = hashmap.begin(); itr != hashmap.end(); ++itr) { 775 if (itr->second->getColorMap() == cmap) { 776 itr->second->updateColorMap(); 777 _needsRedraw = true; 778 } 779 } 780 } 781 782 template<class GraphicsObject> 783 bool Renderer::graphicsObjectColorMapUsed(ColorMap *cmap) 784 { 785 std::tr1::unordered_map<DataSetId, GraphicsObject *>& hashmap = 786 getGraphicsObjectHashmap<GraphicsObject>(); 787 typename std::tr1::unordered_map<DataSetId, GraphicsObject *>::iterator itr; 788 789 for (itr = hashmap.begin(); itr != hashmap.end(); ++itr) { 790 if (itr->second->getColorMap() == cmap) 791 return true; 792 } 793 return false; 794 } 795 796 template<class GraphicsObject> 797 void Renderer::mergeGraphicsObjectBounds(double *bounds, bool onlyVisible) 798 { 799 std::tr1::unordered_map<DataSetId, GraphicsObject *>& hashmap = 800 getGraphicsObjectHashmap<GraphicsObject>(); 801 typename std::tr1::unordered_map<DataSetId, GraphicsObject *>::iterator itr; 802 803 for (itr = hashmap.begin(); itr != hashmap.end(); ++itr) { 804 if ((!onlyVisible || itr->second->getVisibility()) && 805 itr->second->getProp() != NULL) 806 mergeBounds(bounds, bounds, itr->second->getBounds()); 807 } 808 } 809 810 template<class GraphicsObject> 811 void Renderer::mergeGraphicsObjectUnscaledBounds(double *bounds, bool onlyVisible) 812 { 813 std::tr1::unordered_map<DataSetId, GraphicsObject *>& hashmap = 814 getGraphicsObjectHashmap<GraphicsObject>(); 815 typename std::tr1::unordered_map<DataSetId, GraphicsObject *>::iterator itr; 816 817 for (itr = hashmap.begin(); itr != hashmap.end(); ++itr) { 818 if ((!onlyVisible || itr->second->getVisibility()) && 819 itr->second->getProp() != NULL) 820 mergeBounds(bounds, bounds, itr->second->getUnscaledBounds()); 821 } 822 } 823 824 template<class GraphicsObject> 825 void Renderer::updateGraphicsObjectFieldRanges() 826 { 827 std::tr1::unordered_map<DataSetId, GraphicsObject *>& hashmap = 828 getGraphicsObjectHashmap<GraphicsObject>(); 829 typename std::tr1::unordered_map<DataSetId, GraphicsObject *>::iterator itr; 830 831 for (itr = hashmap.begin(); itr != hashmap.end(); ++itr) { 832 itr->second->updateRanges(this); 833 } 834 } 835 836 template<class GraphicsObject> 837 void Renderer::setGraphicsObjectClippingPlanes(vtkPlaneCollection *planes) 838 { 839 std::tr1::unordered_map<DataSetId, GraphicsObject *>& hashmap = 840 getGraphicsObjectHashmap<GraphicsObject>(); 841 typename std::tr1::unordered_map<DataSetId, GraphicsObject *>::iterator itr; 842 843 for (itr = hashmap.begin(); itr != hashmap.end(); ++itr) { 844 itr->second->setClippingPlanes(planes); 845 } 846 } 847 848 template<class GraphicsObject> 849 void Renderer::setGraphicsObjectAspect(double aspectRatio) 850 { 851 std::tr1::unordered_map<DataSetId, GraphicsObject *>& hashmap = 852 getGraphicsObjectHashmap<GraphicsObject>(); 853 typename std::tr1::unordered_map<DataSetId, GraphicsObject *>::iterator itr; 854 855 for (itr = hashmap.begin(); itr != hashmap.end(); ++itr) { 856 itr->second->setAspect(aspectRatio); 857 } 858 } 859 711 860 } 712 861 } -
branches/nanovis2/packages/vizservers/vtkvis/protocol.txt
r2892 r3175 129 129 dataset visible <bool> <?datasetName?> 130 130 131 arc add <pt1X> <pt1Y> <pt1Z> <pt2X> <pt2Y> <pt2Z> <name> 132 arc color <r> <g> <b> <?name?> 133 arc delete <?name?> 134 arc linecolor <r> <g> <b> <?name?> 135 arc linewidth <val> <?name?> 136 arc opacity <val> <?name?> 137 arc orient <qw> <qx> <qy> <qz> <?name?> 138 arc pos <x> <y> <z> <?name?> 139 arc resolution <res> <?name?> 140 arc scale <sx> <sy> <sz> <?name?> 141 arc visible <bool> <?name?> 142 143 arrow add <tipRadius> <shaftRadius> <tipLength> <name> 144 Arrow will have base at 0,0,0 and tip at 1, 0, 0 145 arrow color <r> <g> <b> <?name?> 146 arrow delete <?name?> 147 arrow edges <bool> <?name?> 148 arrow lighting <bool> <?name?> 149 arrow linecolor <r> <g> <b> <?name?> 150 arrow linewidth <val> <?name?> 151 arrow material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp> <?name?> 152 arrow opacity <val> <?name?> 153 arrow orient <qw> <qx> <qy> <qz> <?name?> 154 arrow pos <x> <y> <z> <?name?> 155 arrow resolution <tipRes> <shaftRes> <?name?> 156 arrow scale <sx> <sy> <sz> <?name?> 157 arrow visible <bool> <?name?> 158 arrow wireframe <bool> <?name?> 159 160 box add <name> 161 box color <r> <g> <b> <?name?> 162 box delete <?name?> 163 box edges <bool> <?name?> 164 box lighting <bool> <?name?> 165 box linecolor <r> <g> <b> <?name?> 166 box linewidth <val> <?name?> 167 box material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp> <?name?> 168 box opacity <val> <?name?> 169 box orient <qw> <qx> <qy> <qz> <?name?> 170 box pos <x> <y> <z> <?name?> 171 box scale <sx> <sy> <sz> <?name?> 172 box visible <bool> <?name?> 173 box wireframe <bool> <?name?> 174 175 cone add <radius> <height> <cap> <name> 176 <cap> = boolean flag for cap disks 177 cone color <r> <g> <b> <?name?> 178 cone delete <?name?> 179 cone edges <bool> <?name?> 180 cone lighting <bool> <?name?> 181 cone linecolor <r> <g> <b> <?name?> 182 cone linewidth <val> <?name?> 183 cone material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp> <?name?> 184 cone opacity <val> <?name?> 185 cone orient <qw> <qx> <qy> <qz> <?name?> 186 cone pos <x> <y> <z> <?name?> 187 cone resolution <res> <?name?> 188 cone scale <sx> <sy> <sz> <?name?> 189 cone visible <bool> <?name?> 190 cone wireframe <bool> <?name?> 191 131 192 contour2d add numcontours <n> <?datasetName?> 132 193 Generate evenly spaced contours including range endpoints. See also … … 134 195 contour2d add contourlist <list> <?datasetName?> 135 196 list = {isoval1 isoval2 isoval3...} 136 contour2d c olor <r> <g> <b> <?datasetName?>197 contour2d ccolor <r> <g> <b> <?datasetName?> 137 198 synonym for linecolor 199 contour2d colormap <colormapName> <?datasetName?> 200 contour2d colormode <scalar|vmag|vx|vy|vz|ccolor> <fieldName> <?datasetName?> 201 Set the field used to color the object. 'ccolor' means to use 202 the constant color defined by the ccolor subcommand. 'scalar' uses 203 the active scalar field. 'vmag' uses the magnitude of the current 204 vector field, and 'vx','vy','vz' use the corresponding component of 205 the active vector field. 138 206 contour2d delete <?datasetName?> 139 207 contour2d lighting <bool> <?datasetName?> … … 194 262 cutplane wireframe <bool> <?datasetName?> 195 263 264 cylinder add <radius> <height> <cap> <name> 265 <cap> = boolean flag for cap disks 266 cylinder color <r> <g> <b> <?name?> 267 cylinder delete <?name?> 268 cylinder edges <bool> <?name?> 269 cylinder lighting <bool> <?name?> 270 cylinder linecolor <r> <g> <b> <?name?> 271 cylinder linewidth <val> <?name?> 272 cylinder material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp> <?name?> 273 cylinder opacity <val> <?name?> 274 cylinder orient <qw> <qx> <qy> <qz> <?name?> 275 cylinder pos <x> <y> <z> <?name?> 276 cylinder resolution <res> <?name?> 277 cylinder scale <sx> <sy> <sz> <?name?> 278 cylinder visible <bool> <?name?> 279 cylinder wireframe <bool> <?name?> 280 281 disk add <innerRadius> <outerRadius> <name> 282 disk color <r> <g> <b> <?name?> 283 disk delete <?name?> 284 disk edges <bool> <?name?> 285 disk lighting <bool> <?name?> 286 disk linecolor <r> <g> <b> <?name?> 287 disk linewidth <val> <?name?> 288 disk material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp> <?name?> 289 disk opacity <val> <?name?> 290 disk orient <qw> <qx> <qy> <qz> <?name?> 291 disk pos <x> <y> <z> <?name?> 292 disk resolution <resRadial> <resCircum> <?name?> 293 disk scale <sx> <sy> <sz> <?name?> 294 disk visible <bool> <?name?> 295 disk wireframe <bool> <?name?> 296 196 297 glyphs add <shape> <?dataSetName?> 197 298 See 'glyphs shape' for list of shapes … … 204 305 glyphs delete <?dataSetName?> 205 306 glyphs edges <bool> <?datasetName?> 307 glyphs gorient <bool> <fieldName> <?datasetName?> 308 Set the glyph orientation mode: orient glyphs by 309 a named vector field, or set to default orientation (off) 206 310 glyphs gscale <scaleFactor> <?datasetName?> 207 311 Set glyph scaling factor … … 268 372 lic visible <bool> <?datasetName?> 269 373 374 line add <pt1X> <pt1Y> <pt1Z> <pt2X> <pt2Y> <pt2Z> <name> 375 line color <r> <g> <b> <?name?> 376 line delete <?name?> 377 line linecolor <r> <g> <b> <?name?> 378 line linewidth <val> <?name?> 379 line opacity <val> <?name?> 380 line orient <qw> <qx> <qy> <qz> <?name?> 381 line pos <x> <y> <z> <?name?> 382 line scale <sx> <sy> <sz> <?name?> 383 line visible <bool> <?name?> 384 270 385 molecule add <?datasetName?> 271 386 molecule atoms <bool> <?datasetName?> 272 387 Toggle rendering of atoms 388 molecule ascale <val> <?datasetName?> 389 Set atom scale factor 390 molecule bcmode <by_elements|constant> <?datasetName?> 391 Set bond color mode 392 molecule bcolor <r> <g> <b> <?datasetName?> 393 Set constant bond color 273 394 molecule bonds <bool> <?datasetName?> 274 395 Toggle rendering of bonds 396 molecule bscale <val> <?datasetName?> 397 Set bond scale factor 398 molecule bstyle <cylinder|line> <?datasetName?> 399 Set bond render style 400 molecule ccolor r g b <?datasetName?> 275 401 molecule colormap <colormapName> <?datasetName?> 402 molecule colormode <by_elements|scalar|vmag|vx|vy|vz|ccolor> <fieldName> <?datasetName?> 403 Set the field used to color the object. 'ccolor' means to use 404 the constant color defined by the ccolor subcommand. 'scalar' uses 405 the active scalar field. 'vmag' uses the magnitude of the current 406 vector field, and 'vx','vy','vz' use the corresponding component of 407 the active vector field. 276 408 molecule delete <?datasetName?> 277 409 molecule edges <bool> <?datasetName?> 410 molecule labels <bool> <?datasetName?> 278 411 molecule lighting <bool> <?datasetName?> 279 412 molecule linecolor <r> <g> <b> <?datasetName?> … … 284 417 molecule rscale <val> <?dataSetName?> 285 418 Atom radius scaling 286 val = van_der_wa lls|covalent|atomic|none419 val = van_der_waals|covalent|atomic|none 287 420 molecule scale <sx> <sy> <sz> <?dataSetName?> 288 421 molecule visible <bool> <?datasetName?> … … 296 429 polydata linecolor <r> <g> <b> <?datasetName?> 297 430 polydata linewidth <val> <?datasetName?> 431 polydata material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp> 298 432 polydata opacity <val> <?datasetName?> 299 433 polydata orient <qw> <qx> <qy> <qz> <?dataSetName?> … … 304 438 polydata wireframe <bool> <?datasetName?> 305 439 440 polygon add <numSides> <name> 441 polygon color <r> <g> <b> <?name?> 442 polygon delete <?name?> 443 polygon edges <bool> <?name?> 444 polygon lighting <bool> <?name?> 445 polygon linecolor <r> <g> <b> <?name?> 446 polygon linewidth <val> <?name?> 447 polygon material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp> <?name?> 448 polygon opacity <val> <?name?> 449 polygon orient <qw> <qx> <qy> <qz> <?name?> 450 polygon pos <x> <y> <z> <?name?> 451 polygon scale <sx> <sy> <sz> <?name?> 452 polygon visible <bool> <?name?> 453 polygon wireframe <bool> <?name?> 454 306 455 pseudocolor add <?datasetName?> 307 pseudocolor ccolor r g b<?datasetName?>456 pseudocolor ccolor <r> <g> <b> <?datasetName?> 308 457 pseudocolor colormap <colormapName> <?datasetName?> 309 458 pseudocolor colormode <scalar|vmag|vx|vy|vz|ccolor> <fieldName> <?datasetName?> … … 324 473 pseudocolor visible <bool> <?datasetName?> 325 474 pseudocolor wireframe <bool> <?datasetName?> 475 476 sphere add <name> 477 sphere color <r> <g> <b> <?name?> 478 sphere delete <?name?> 479 sphere edges <bool> <?name?> 480 sphere lighting <bool> <?name?> 481 sphere linecolor <r> <g> <b> <?name?> 482 sphere linewidth <val> <?name?> 483 sphere material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp> <?name?> 484 sphere opacity <val> <?name?> 485 sphere orient <qw> <qx> <qy> <qz> <?name?> 486 sphere pos <x> <y> <z> <?name?> 487 sphere resolution <thetaRes> <phiRes> <?name?> 488 sphere scale <sx> <sy> <sz> <?name?> 489 sphere section <thetaStart> <thetaEnd> <phiStart> <phiEnd> <?name?> 490 Angles are in degrees 491 sphere visible <bool> <?name?> 492 sphere wireframe <bool> <?name?> 326 493 327 494 streamlines add <?datasetName?> … … 396 563 volume visible <bool> <?datasetName?> 397 564 565 warp add <?dataSetName?> 566 warp colormap <colorMapName> <?dataSetName?> 567 warp delete <?dataSetName?> 568 warp edges <bool> <?dataSetName?> 569 warp lighting <bool> <?dataSetName?> 570 warp linecolor <r> <g> <b> <?dataSetName?> 571 warp linewidth <width> <?dataSetName?> 572 warp opacity <value> <?dataSetName?> 573 warp orient <qw> <qx> <qy> <qz> <?dataSetName?> 574 warp pos <x> <y> <z> <?dataSetName?> 575 warp scale <sx> <sy> <sz> <?dataSetName?> 576 warp visible <bool> <?dataSetName?> 577 warp warpscale <value> <?dataSetName?> 578 Specify amount to scale vector magnitudes when warping 579 warp wireframe <bool> <?datasetName?> 580 398 581 ================================================================================ 399 582 Replies: -
branches/nanovis2/packages/vizservers/vtkvis/vtkRpAxisActor.cpp
r2864 r3175 2 2 3 3 Program: Visualization Toolkit 4 Module: vtkRpAxisActor.c xx4 Module: vtkRpAxisActor.cpp 5 5 Thanks: Kathleen Bonnell, B Division, Lawrence Livermore Nat'l Laboratory 6 6 -
branches/nanovis2/packages/vizservers/vtkvis/vtkRpAxisActor2D.cpp
r2864 r3175 2 2 3 3 Program: Visualization Toolkit 4 Module: vtkRpAxisActor2D.c xx4 Module: vtkRpAxisActor2D.cpp 5 5 6 6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -
branches/nanovis2/src/core/RpLibrary.cc
r2408 r3175 63 63 parser = scew_parser_create(); 64 64 65 scew_parser_ignore_whitespaces(parser, 1); 65 // Don't ignore whitespaces! 66 // Things like string inputs may have trailing newlines that 67 // matter to the underlying application. 68 scew_parser_ignore_whitespaces(parser, 0); 66 69 67 70 /* Loads an XML file */ -
branches/nanovis2/tester/scripts/statuslist.tcl
r2139 r3175 289 289 set c $itk_component(listview) 290 290 291 # translate the screen y to the canvas y (may be scrolled down) 292 set y [$c canvasy $y] 293 291 294 set index "" 292 295 foreach id [$c find overlapping 10 $y 10 $y] { -
branches/nanovis2/tester/scripts/stringdiffs.tcl
r2139 r3175 32 32 33 33 protected method _yview {args} 34 protected method _ysbar {args} 34 35 } 35 36 … … 128 129 $itk_component(body1) configure \ 129 130 -xscrollcommand [list $itk_component(xsbar1) set] \ 130 -yscrollcommand [ list $itk_component(ysbar) set]131 -yscrollcommand [itcl::code $this _ysbar body1] 131 132 $itk_component(body2) configure \ 132 -xscrollcommand [list $itk_component(xsbar2) set] 133 -xscrollcommand [list $itk_component(xsbar2) set] \ 134 -yscrollcommand [itcl::code $this _ysbar body2] 133 135 134 136 grid $itk_component(title1) -row 0 -column 0 -sticky nsew … … 205 207 # USAGE: _yview <arg> <arg>... 206 208 # 207 # Loads two values into the viewer and shows their differences. 208 # If the strings are short, the diffs are shown inline. Otherwise, 209 # they are show with side-by-side viewers. 209 # Called whenever the scrollbar changes the y-view of the diffs. 210 # Sends the new command along to both views so they are aligned. 210 211 # ---------------------------------------------------------------------- 211 212 itcl::body Rappture::Tester::StringDiffs::_yview {args} { 212 213 eval $itk_component(body1) yview $args 213 214 eval $itk_component(body2) yview $args 215 } 216 217 # ---------------------------------------------------------------------- 218 # USAGE: _ysbar <whichChanged> <arg> <arg>... 219 # 220 # Called whenever the y-view of one widget changes. Copies the 221 # current view from the <whichChanged> widget to the other side, 222 # and updates the bubble to display the correct view. 223 # ---------------------------------------------------------------------- 224 itcl::body Rappture::Tester::StringDiffs::_ysbar {which args} { 225 switch -- $which { 226 body1 { 227 set pos [lindex [$itk_component(body1) yview] 0] 228 $itk_component(body2) yview moveto $pos 229 } 230 body2 { 231 set pos [lindex [$itk_component(body2) yview] 0] 232 $itk_component(body1) yview moveto $pos 233 } 234 } 235 eval $itk_component(ysbar) set $args 214 236 } 215 237
Note: See TracChangeset
for help on using the changeset viewer.