Changeset 2409 for branches/blt4/packages/vizservers
- Timestamp:
- Aug 25, 2011, 1:09:15 PM (13 years ago)
- Location:
- branches/blt4/packages/vizservers
- Files:
-
- 61 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/blt4/packages/vizservers/Makefile.in
r2201 r2409 48 48 done 49 49 $(INSTALL) -m 0555 start_viz.sh $(bindir)/start_viz.sh 50 $(INSTALL) -m 0555 start_nanoscale.sh $(bindir)/start_nanoscale.sh 50 51 51 52 clean: … … 58 59 $(MAKE) -C $$i distclean ; \ 59 60 done 60 rm -f Makefile start_viz.sh *~61 $(RM) -r Makefile config.cache config.log config.status start_viz.sh start_nanoscale.sh *~ autom4te.cache -
branches/blt4/packages/vizservers/configure
r2201 r2409 8589 8589 CPPFLAGS=$save_CPPFLAGS 8590 8590 8591 8591 if test "${CG_DIR}" = "/usr" ; then 8592 8592 CG_DIR="" 8593 8593 else … … 8627 8627 8628 8628 8629 ac_config_files="$ac_config_files Makefile nanoscale/Makefile nano vis/Makefile nanovis/newmat11/Makefile nanovis/R2/src/Makefile nanovis/vrutil/Makefile nanovis/vrmath/Makefile nanovis/vr3d/Makefile nanovis/imgLoaders/Makefile nanovis/transfer-function/Makefile pymolproxy/Makefile vtkvis/Doxyfile vtkvis/Makefile start_viz.sh"8629 ac_config_files="$ac_config_files Makefile nanoscale/Makefile nanoscale/renderservers.tcl nanovis/Makefile nanovis/newmat11/Makefile nanovis/R2/src/Makefile nanovis/vrutil/Makefile nanovis/vrmath/Makefile nanovis/vr3d/Makefile nanovis/imgLoaders/Makefile nanovis/transfer-function/Makefile pymolproxy/Makefile vtkvis/Doxyfile vtkvis/Makefile start_viz.sh start_nanoscale.sh" 8630 8630 8631 8631 cat >confcache <<\_ACEOF … … 9337 9337 "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; 9338 9338 "nanoscale/Makefile") CONFIG_FILES="$CONFIG_FILES nanoscale/Makefile" ;; 9339 "nanoscale/renderservers.tcl") CONFIG_FILES="$CONFIG_FILES nanoscale/renderservers.tcl" ;; 9339 9340 "nanovis/Makefile") CONFIG_FILES="$CONFIG_FILES nanovis/Makefile" ;; 9340 9341 "nanovis/newmat11/Makefile") CONFIG_FILES="$CONFIG_FILES nanovis/newmat11/Makefile" ;; … … 9349 9350 "vtkvis/Makefile") CONFIG_FILES="$CONFIG_FILES vtkvis/Makefile" ;; 9350 9351 "start_viz.sh") CONFIG_FILES="$CONFIG_FILES start_viz.sh" ;; 9352 "start_nanoscale.sh") CONFIG_FILES="$CONFIG_FILES start_nanoscale.sh" ;; 9351 9353 9352 9354 *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; … … 9941 9943 fi 9942 9944 9943 -
branches/blt4/packages/vizservers/configure.in
r2201 r2409 317 317 CPPFLAGS=$save_CPPFLAGS 318 318 319 319 if test "${CG_DIR}" = "/usr" ; then 320 320 CG_DIR="" 321 321 else … … 356 356 357 357 AC_OUTPUT([ 358 Makefile \358 Makefile \ 359 359 nanoscale/Makefile \ 360 nanoscale/renderservers.tcl \ 360 361 nanovis/Makefile \ 361 362 nanovis/newmat11/Makefile \ … … 369 370 vtkvis/Doxyfile \ 370 371 vtkvis/Makefile \ 371 start_viz.sh ])372 372 start_viz.sh \ 373 start_nanoscale.sh]) -
branches/blt4/packages/vizservers/nanoscale/Makefile.in
r1029 r2409 1 TARGETS = client mycat nanoscale2 1 3 2 CC = @CC@ 4 3 CFLAGS = @CFLAGS@ 5 4 EXTRA_CFLAGS = -Wall 6 DEFINES = @DEFINES@ 7 CC_SWITCHES = $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDES) 5 CC_SWITCHES = $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDES) $(DEFINES) 8 6 LDFLAGS = @LDFLAGS@ 9 7 … … 21 19 22 20 INSTALL = @INSTALL@ 23 INSTALL_PROGRAM = ${INSTALL} -m 555 24 INSTALL_DATA = ${INSTALL} -m 444 25 INSTALL_SCRIPT = ${INSTALL} -m 444 21 INSTALL_PROGRAM = ${INSTALL} -m 0555 22 INSTALL_DATA = ${INSTALL} -m 0444 23 INSTALL_SCRIPT = ${INSTALL} -m 0444 24 RM = rm -f 26 25 27 SERVER_OBJS = server .o26 SERVER_OBJS = server2.o 28 27 CLIENT_OBJS = client.o clientlib.o 29 28 29 TCL_LIB_SPEC = @TCL_LIB_SPEC@ 30 TCL_INC_SPEC = @TCL_INC_SPEC@ 31 LD_RUN_PATH = $(libdir) 32 33 DEFINES = -DSERVERSFILE=\"$(libdir)/renderservers.tcl\" 34 INCLUDES = $(TCL_INC_SPEC) 35 LIBS = $(TCL_LIB_SPEC) \ 36 -Wl,-rpath,$(LD_RUN_PATH) 37 30 38 .PHONY: all install clean distclean 39 40 TARGETS = nanoscale 31 41 32 42 all: $(TARGETS) … … 35 45 $(CC) $(CC_SWITCHES) -o $@ $^ $(LIBS) 36 46 37 install: nanoscale 47 install: nanoscale renderservers.tcl 38 48 $(INSTALL_PROGRAM) -D nanoscale $(bindir)/nanoscale 49 $(INSTALL_SCRIPT) renderservers.tcl $(libdir) 39 50 40 51 client: $(CLIENT_OBJS) … … 44 55 45 56 clean: 46 rm -rfa.out $(SERVER_OBJS) *~ core* $(TARGETS) *.log *.tmp logfile* .deps/*.d57 $(RM) -r a.out $(SERVER_OBJS) *~ core* $(TARGETS) *.log *.tmp logfile* .deps/*.d 47 58 48 59 distclean: clean 49 rm Makefile60 $(RM) Makefile config.h renderservers.tcl 50 61 -
branches/blt4/packages/vizservers/nanoscale/server2.c
r2341 r2409 1 1 2 2 #include <stdio.h> 3 #include <string.h> 4 #include <errno.h> 5 #include <arpa/inet.h> 6 #include <getopt.h> 7 #include <stdarg.h> 8 #include <stdlib.h> 9 #include <sys/wait.h> 10 #include <sys/stat.h> 11 #include <sys/file.h> 12 #include <syslog.h> 3 13 #include <unistd.h> 4 #include <stdlib.h> 5 #include <signal.h> 6 #include <sys/types.h> 7 #include <sys/socket.h> 8 #include <sys/wait.h> 9 #include <sys/select.h> 10 #include <sys/time.h> 11 #include <arpa/inet.h> 12 #include <fcntl.h> 13 #include <netinet/in.h> 14 #include <getopt.h> 15 #include <errno.h> 16 #include <syslog.h> 17 #include <stdarg.h> 14 18 15 #include <tcl.h> 19 16 20 17 #define TRUE 1 21 18 #define FALSE 0 22 #define DEF_SERVERS "/opt/hubzero/rappture/render/lib/servers.cf" 19 20 #ifndef SERVERSFILE 21 #define SERVERSFILE "/opt/hubzero/rappture/render/lib/renderservers.tcl" 22 #endif 23 23 24 24 #define ERROR(...) LogMessage(LOG_ERR, __FILE__, __LINE__, __VA_ARGS__) 25 #ifdef WANT_TRACE26 25 #define TRACE(...) LogMessage(LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__) 27 #else28 #define TRACE(...)29 #endif30 26 #define WARN(...) LogMessage(LOG_WARNING, __FILE__, __LINE__, __VA_ARGS__) 31 27 #define INFO(...) LogMessage(LOG_INFO, __FILE__, __LINE__, __VA_ARGS__) 32 28 29 static const char *syslogLevels[] = { 30 "emergency", /* System is unusable */ 31 "alert", /* Action must be taken immediately */ 32 "critical", /* Critical conditions */ 33 "error", /* Error conditions */ 34 "warning", /* Warning conditions */ 35 "notice", /* Normal but significant condition */ 36 "info", /* Informational */ 37 "debug", /* Debug-level messages */ 38 }; 39 40 /* RenderServer -- 41 * 42 * Contains information to describe/execute a render server. 43 */ 33 44 typedef struct { 34 45 const char *name; /* Name of server. */ 35 46 int port; /* Port to listen to. */ 36 int argc; /* # of args in command. */ 37 char **argv; /* Command to execute for server. */ 38 int listenerFd; /* Descriptor the of listener socket. */ 47 int numCmdArgs; /* # of args in command. */ 48 int numEnvArgs; /* # of args in environment. */ 49 char *const *cmdArgs; /* Command to execute for server. */ 50 char *const *envArgs; /* Environment strings to set. */ 51 int listenerFd; /* Descriptor of the listener socket. */ 39 52 } RenderServer; 40 53 41 static Tcl_HashTable serverTable; 42 static int debugFlag = FALSE; 54 static Tcl_HashTable serverTable; /* Table of render servers 55 * representing services available to 56 * clients. A new instances is forked 57 * and executed each time a new 58 * request is accepted. */ 59 static int debug = FALSE; 60 static pid_t serverPid; 43 61 44 62 void … … 58 76 s++; 59 77 } 60 length = snprintf(message, MSG_LEN, "line %d of \"%s\": ", lineNum, s); 78 length = snprintf(message, MSG_LEN, "nanoscale (%d %d) %s: %s:%d ", 79 serverPid, getpid(), syslogLevels[priority], s, lineNum); 61 80 length += vsnprintf(message + length, MSG_LEN - length, fmt, lst); 62 81 message[MSG_LEN] = '\0'; 63 if (debug Flag) {82 if (debug) { 64 83 fprintf(stderr, "%s\n", message); 65 84 } else { … … 76 95 } 77 96 97 /* 98 * RegisterServerCmd -- 99 * 100 * Registers a render server to be run when a client connects 101 * on the designated port. The form of the commands is 102 * 103 * register_server <name> <port> <cmd> <environ> 104 * 105 * where 106 * 107 * name Token for the render server. 108 * port Port to listen to accept connections. 109 * cmd Command to be run to start the render server. 110 * environ Name-value pairs of representing environment 111 * variables. 112 * 113 * Note that "cmd" and "environ" are variable and backslash 114 * substituted. A listener socket automatically is established on 115 * the given port to accept client requests. 116 * 117 * Example: 118 * 119 * register_server myServer 12345 { 120 * /path/to/myserver arg arg 121 * } { 122 * LD_LIBRARY_PATH $libdir/myServer 123 * } 124 * 125 */ 78 126 static int 79 127 RegisterServerCmd(ClientData clientData, Tcl_Interp *interp, int objc, … … 85 133 int f; 86 134 int port; 135 int numCmdArgs, numEnvArgs; 136 char *const *cmdArgs; 137 char *const *envArgs; 87 138 struct sockaddr_in addr; 88 139 RenderServer *serverPtr; 89 140 Tcl_HashEntry *hPtr; 90 141 91 if (objc != 4) { 92 Tcl_AppendResult("wrong # args: should be \"", Tcl_GetString(objv[0]), 93 " serverName port cmd", (char *)NULL); 142 if ((objc < 4) || (objc > 5)) { 143 Tcl_AppendResult(interp, "wrong # args: should be \"", 144 Tcl_GetString(objv[0]), " serverName port cmd ?environ?", 145 (char *)NULL); 94 146 return TCL_ERROR; 95 147 } 96 148 serverName = Tcl_GetString(objv[1]); 97 if (Tcl_GetInt (interp, objv[2], &port) != TCL_OK) {98 return TCL_ERROR; 99 } 100 hPtr = Tcl_CreateHashEntry(&serverTable, (char *) port, &isNew);149 if (Tcl_GetIntFromObj(interp, objv[2], &port) != TCL_OK) { 150 return TCL_ERROR; 151 } 152 hPtr = Tcl_CreateHashEntry(&serverTable, (char *)((long)port), &isNew); 101 153 if (!isNew) { 102 Tcl_AppendResult( "a server is already listening on port ",154 Tcl_AppendResult(interp, "a server is already listening on port ", 103 155 Tcl_GetString(objv[2]), (char *)NULL); 104 156 return TCL_ERROR; … … 106 158 objPtr = Tcl_SubstObj(interp, objv[3], 107 159 TCL_SUBST_VARIABLES | TCL_SUBST_BACKSLASHES); 108 if (Tcl_SplitList(interp, Tcl_GetString(objPtr), &argc, &argv) != TCL_OK) { 160 if (Tcl_SplitList(interp, Tcl_GetString(objPtr), &numCmdArgs, 161 (const char ***)&cmdArgs) != TCL_OK) { 109 162 return TCL_ERROR; 110 163 } … … 118 171 } 119 172 120 /* If program is killed, drop the socket address reservation121 * immediately. */173 /* If the render server instance should be killed, drop the socket address 174 * reservation immediately, don't linger. */ 122 175 bool = TRUE; 123 status = setsockopt(f, SOL_SOCKET, SO_REUSEADDR, &bool, sizeof(bool)); 124 if (status < 0) { 176 if (setsockopt(f, SOL_SOCKET, SO_REUSEADDR, &bool, sizeof(bool)) < 0) { 125 177 Tcl_AppendResult(interp, "can't create set socket option for \"", 126 178 serverName, "\": ", Tcl_PosixError(interp), (char *)NULL); … … 132 184 addr.sin_port = htons(port); 133 185 addr.sin_addr.s_addr = htonl(INADDR_ANY); 134 status = bind(f, (struct sockaddr *)&addr, sizeof(addr)); 135 if (status < 0) { 186 if (bind(f, (struct sockaddr *)&addr, sizeof(addr)) < 0) { 136 187 Tcl_AppendResult(interp, "can't bind to socket for \"", 137 188 serverName, "\": ", Tcl_PosixError(interp), (char *)NULL); … … 139 190 } 140 191 /* Listen on the specified port. */ 141 status = listen(f, 5); 142 if (status < 0) { 192 if (listen(f, 5) < 0) { 143 193 Tcl_AppendResult(interp, "can't listen to socket for \"", 144 194 serverName, "\": ", Tcl_PosixError(interp), (char *)NULL); 145 195 return TCL_ERROR; 146 196 } 197 numEnvArgs = 0; 198 envArgs = NULL; 199 if (objc == 5) { 200 objPtr = Tcl_SubstObj(interp, objv[4], 201 TCL_SUBST_VARIABLES | TCL_SUBST_BACKSLASHES); 202 if (Tcl_SplitList(interp, Tcl_GetString(objPtr), &numEnvArgs, 203 (const char ***)&envArgs) != TCL_OK) { 204 return TCL_ERROR; 205 } 206 if (numEnvArgs & 0x1) { 207 Tcl_AppendResult(interp, "odd # elements in enviroment list", 208 (char *)NULL); 209 return TCL_ERROR; 210 } 211 } 147 212 serverPtr = malloc(sizeof(RenderServer)); 213 memset(serverPtr, 0, sizeof(RenderServer)); 148 214 if (serverPtr == NULL) { 149 215 Tcl_AppendResult(interp, "can't allocate structure for \"", … … 152 218 } 153 219 serverPtr->name = strdup(serverName); 154 serverPtr-> argv = argv;155 serverPtr-> argc = argc;220 serverPtr->cmdArgs = cmdArgs; 221 serverPtr->numCmdArgs = numCmdArgs; 156 222 serverPtr->listenerFd = f; 223 serverPtr->envArgs = envArgs; 224 serverPtr->numEnvArgs = numEnvArgs; 225 Tcl_SetHashValue(hPtr, serverPtr); 157 226 return TCL_OK; 158 227 } … … 168 237 NULL); 169 238 if (Tcl_EvalFile(interp, fileName) != TCL_OK) { 170 ERROR(" can't add server: %s", Tcl_GetString(Tcl_GetObjResult(interp)));239 ERROR("Can't add server: %s", Tcl_GetString(Tcl_GetObjResult(interp))); 171 240 return FALSE; 172 241 } … … 178 247 main(int argc, char **argv) 179 248 { 180 int status; 181 struct sockaddr_in recvAddr; 182 int serverFds[FD_SETSIZE], maxFd; 183 int n; 184 char displaySetting[200]; 185 int maxCards; 186 int dispNum; 249 #ifdef SA_NOCLDWAIT 250 struct sigaction action; 251 #endif 252 fd_set serverFds; 253 int maxFd; /* Highest file descriptor in use. */ 254 char display[200]; /* String used to manage the X 255 * DISPLAY variable for each render 256 * server instance. */ 257 int maxCards; /* Maximum number of video cards, each 258 * represented by a different X 259 * screen. */ 260 int screenNum; /* Current X screen number. */ 187 261 Tcl_HashEntry *hPtr; 188 262 Tcl_HashSearch iter; 189 const char *fileName; 190 191 dispNum = 0; 263 const char *fileName; /* Path to servers file. */ 264 265 serverPid = getpid(); 266 screenNum = 0; 192 267 maxCards = 1; 193 fileName = DEF_SERVERS; 194 debugFlags = FALSE; 195 strcpy(displaySetting, "DISPLAY=:0.0"); 196 if (putenv(displaySetting) < 0) { 197 ERROR("can't set DISPLAY variable: ", strerror(errno)); 198 exit(1); 199 } 268 fileName = SERVERSFILE; 269 debug = FALSE; 270 271 strcpy(display, ":0.0"); 200 272 Tcl_InitHashTable(&serverTable, TCL_ONE_WORD_KEYS); 273 274 /* Process command line switches. */ 201 275 while (1) { 202 276 int c; … … 207 281 }; 208 282 209 c = getopt_long(argc, argv, " +p:x:d", long_options, &option_index);283 c = getopt_long(argc, argv, "x:f:d", long_options, &option_index); 210 284 if (c == -1) { 211 285 break; … … 216 290 maxCards = strtoul(optarg, 0, 0); 217 291 if ((maxCards < 1) || (maxCards > 10)) { 218 fprintf(stderr, " bad number of max videocards specified\n");292 fprintf(stderr, "Bad number of max videocards specified\n"); 219 293 return 1; 220 294 } 221 295 break; 222 296 case 'd': /* Debug */ 223 debug Flag= TRUE;297 debug = TRUE; 224 298 break; 225 299 226 case 'f': /* Server file s*/300 case 'f': /* Server file path. */ 227 301 fileName = strdup(optarg); 228 302 break; … … 235 309 } 236 310 311 if (!debug) { 312 /* Detach this process from the controlling terminal process. The 313 * current directory becomes /tmp and redirect stdin/stdout/stderr to 314 * /dev/null. */ 315 if (daemon(0,0) < 0) { 316 ERROR("Can't daemonize nanoscale: %s", strerror(errno)); 317 exit(1); 318 } 319 } 320 serverPid = getpid(); 237 321 if (!ParseServersFile(fileName)) { 238 322 exit(1); … … 240 324 241 325 if (serverTable.numEntries == 0) { 242 ERROR("no servers designated."); 243 exit(0); 244 } 245 246 if (!debugFlag) { 247 if (daemon(0,1) < 0) { 248 ERROR("can't daemonize nanoscale: ", strerror(errno)); 249 exit(1); 250 } 251 } 326 ERROR("No servers designated."); 327 exit(1); 328 } 329 signal(SIGPIPE, SIG_IGN); 330 #ifdef SA_NOCLDWAIT 331 memset(&action, 0, sizeof(action)); 332 action.sa_flags = SA_NOCLDWAIT; 333 sigaction(SIGCHLD, &action, 0); 334 #else 335 signal(SIGCHLD, SIG_IGN); 336 #endif 252 337 253 338 /* Build the array of servers listener file descriptors. */ … … 257 342 hPtr = Tcl_NextHashEntry(&iter)) { 258 343 RenderServer *serverPtr; 259 344 260 345 serverPtr = Tcl_GetHashValue(hPtr); 261 346 FD_SET(serverPtr->listenerFd, &serverFds); … … 264 349 } 265 350 } 266 while (select(maxFd+1, serverFds, NULL, NULL, 0) > 0) { 267 351 352 for (;;) { 353 fd_set readFds; 354 355 memcpy(&readFds, &serverFds, sizeof(serverFds)); 356 if (select(maxFd+1, &readFds, NULL, NULL, 0) <= 0) { 357 ERROR("Select failed: %s", strerror(errno)); 358 break; /* Error on select. */ 359 } 268 360 for (hPtr = Tcl_FirstHashEntry(&serverTable, &iter); hPtr != NULL; 269 361 hPtr = Tcl_NextHashEntry(&iter)) { 270 362 RenderServer *serverPtr; 363 pid_t child; 364 int f; 365 socklen_t length; 366 struct sockaddr_in newaddr; 271 367 272 368 serverPtr = Tcl_GetHashValue(hPtr); 273 if (FD_ISSET(serverPtr->listenerFd, &serverFds)) { 274 struct sockaddr_in newaddr; 275 unsigned int addrlen; 276 int f; 277 int child; 278 279 /* Accept the new connection. */ 280 unsigned int addrlen = sizeof(newaddr); 281 f = accept(serverPtr->listenerFd, (struct sockaddr *)&newaddr, 282 sizeof(newaddr)); 283 if (f < 0) { 284 ERROR("can't accept server \"", serverPtr->name, 285 "\": ", strerror(errno)); 286 continue; 369 if (!FD_ISSET(serverPtr->listenerFd, &readFds)) { 370 continue; 371 } 372 /* Rotate the display's screen number. If we have multiple video 373 * cards, try to spread the jobs out among them. */ 374 screenNum++; 375 if (screenNum >= maxCards) { 376 screenNum = 0; 377 } 378 /* Accept the new connection. */ 379 length = sizeof(newaddr); 380 f = accept(serverPtr->listenerFd, (struct sockaddr *)&newaddr, 381 &length); 382 if (f < 0) { 383 ERROR("Can't accept server \"%s\": %s", serverPtr->name, 384 strerror(errno)); 385 exit(1); 386 } 387 INFO("Connecting \"%s\" to %s\n", serverPtr->name, 388 inet_ntoa(newaddr.sin_addr)); 389 390 /* Fork the new process. Connect I/O to the new socket. */ 391 child = fork(); 392 if (child < 0) { 393 ERROR("Can't fork \"%s\": %s", serverPtr->name, 394 strerror(errno)); 395 continue; 396 } 397 if (child == 0) { /* Child process. */ 398 int i; 399 int errFd; 400 401 umask(0); 402 if ((!debug) && (setsid() < 0)) { 403 ERROR("Can't setsid \"%s\": %s", serverPtr->name, 404 strerror(errno)); 405 exit(1); 287 406 } 288 INFO("Connected to %s\n", inet_ntoa(newaddr.sin_addr)); 289 290 dispNum++; 291 if (dispNum >= maxCards) { 292 dispNum = 0; 407 if ((!debug) && ((chdir("/")) < 0)) { 408 ERROR("Can't change to root directory for \"%s\": %s", 409 serverPtr->name, strerror(errno)); 410 exit(1); 293 411 } 294 /* Fork the new process. Connect I/O to the new socket. */ 295 child = fork(); 296 if (child < 0) { 297 ERROR("can't fork \"", serverPtr->name, "\": ", 298 strerror(errno)); 299 continue; 300 } else if (child == 0) { 301 int i; 302 303 /* Child process. */ 304 if (!debugFlag) { 305 /* Disassociate server from */ 306 status = daemon(0,1); 307 if (status < 0) { 308 ERROR("can't daemonize \"", serverPtr->name, 309 "\": ", strerror(errno)); 310 } 311 } 312 dup2(f, 0); /* Stdin */ 313 dup2(f, 1); /* Stdout */ 314 315 for(i = 3; i <= FD_SETSIZE; i++) { 316 close(i); /* Close all the other descriptors. */ 317 } 318 if (maxCards > 1) { 319 displaySetting[11] = dispNum + '0'; 320 } 321 INFO("%s: client %s connecting to display %d", 322 serverPtr->name, inet_ntoa(newaddr.sin_addr), dispNum); 323 status = execvp(serverPtr->argv[0], serverPtr->argv); 324 ERROR("can't execute \"", serverPtr->argv[0], 325 "\": ", strerror(errno)); 326 _exit(1); 412 413 /* Dup the descriptors and start the server. */ 414 415 dup2(f, 0); /* Stdin */ 416 dup2(f, 1); /* Stdout */ 417 errFd = open("/dev/null", O_WRONLY, 0600); 418 dup2(errFd, 2); /* Stderr */ 419 for(i = 3; i <= FD_SETSIZE; i++) { 420 close(i); /* Close all the other descriptors. */ 327 421 } 328 _exit(EINVAL); 422 423 /* Set the screen number in the DISPLAY variable. */ 424 display[3] = screenNum + '0'; 425 setenv("DISPLAY", display, 0); 426 /* Set the enviroment, if necessary. */ 427 for (i = 0; i < serverPtr->numEnvArgs; i += 2) { 428 setenv(serverPtr->envArgs[i], serverPtr->envArgs[i+1], 0); 429 } 430 INFO("Executing %s: client %s, %s on DISPLAY=%s", 431 serverPtr->name, inet_ntoa(newaddr.sin_addr), 432 serverPtr->cmdArgs[0], display); 433 /* Replace the current process with the render server. */ 434 execvp(serverPtr->cmdArgs[0], serverPtr->cmdArgs); 435 ERROR("Can't execute \"%s\": %s", serverPtr->cmdArgs[0], 436 strerror(errno)); 437 exit(1); 329 438 } else { 330 /* Reap initial child which will exit immediately 331 * (grandchild continues) */ 332 waitpid(status, NULL, 0); 439 close(f); 333 440 } 334 441 } 335 } 336 ERROR("select failed: ", strerror(errno)); 442 } 337 443 exit(1); 338 444 } 339 -
branches/blt4/packages/vizservers/nanovis/Command.cpp
r2307 r2409 1134 1134 { 1135 1135 TRACE("Data Loading\n"); 1136 fflush(stdout);1137 1136 1138 1137 int nbytes; … … 1206 1205 } else if ((nBytes > 5) && (strncmp(bytes, "<FET>", 5) == 0)) { 1207 1206 TRACE("FET loading...\n"); 1208 fflush(stdout);1209 1207 std::stringstream fdata; 1210 1208 fdata.write(nBytes - 5, bytes + 5); … … 1218 1216 } else if ((nBytes > 5) && (strncmp(bytes, "<ODX>", 5) == 0)) { 1219 1217 TRACE("Loading DX using OpenDX library...\n"); 1220 fflush(stdout);1221 1218 Rappture::Outcome context; 1222 1219 volPtr = load_volume_stream_odx(context, tag, bytes + 5, nBytes -5); … … 1227 1224 } else { 1228 1225 TRACE("OpenDX loading...\n"); 1229 fflush(stdout);1230 1226 std::stringstream fdata; 1231 1227 fdata.write(bytes, nBytes); … … 1272 1268 volPtr->wAxis.min(), volPtr->wAxis.max(), 1273 1269 Volume::valueMin, Volume::valueMax); 1274 nWritten = write( 0, info, strlen(info));1270 nWritten = write(1, info, strlen(info)); 1275 1271 assert(nWritten == (ssize_t)strlen(info)); 1276 1272 } -
branches/blt4/packages/vizservers/nanovis/DataLoader.cpp
r2120 r2409 4 4 #include <stdlib.h> 5 5 #include <math.h> 6 #include <Trace.h> 6 7 7 8 inline void endian_swap(unsigned int& x) … … 35 36 if (path.size() == 0) 36 37 { 37 printf("file not found[%s]\n", path.c_str());38 38 ERROR("file not found[%s]\n", path.c_str()); 39 return NULL; 39 40 } 40 41 … … 42 43 if (fp == NULL) 43 44 { 44 printf("ERROR :file not found %s\n", path.c_str());45 45 ERROR("file not found %s\n", path.c_str()); 46 return NULL; 46 47 } 47 48 … … 173 174 if (path.size() == 0) 174 175 { 175 printf("file not found[%s]\n", path.c_str());176 176 ERROR("file not found[%s]\n", path.c_str()); 177 return NULL; 177 178 } 178 179 … … 180 181 if (fp == NULL) 181 182 { 182 printf("ERROR :file not found %s\n", path.c_str());183 183 ERROR("file not found %s\n", path.c_str()); 184 return NULL; 184 185 } 185 186 … … 243 244 if (length > max) 244 245 { 245 // printf("max %lf %lf %fl\n", x, y, z);246 //TRACE("max %lf %lf %fl\n", x, y, z); 246 247 max = length; 247 248 } … … 262 263 fclose(fp); 263 264 264 printf("width %d, height %d, depth %d, min %f, max %f, scaleX %f, scaleY %f, scaleZ %f\n",265 TRACE("width %d, height %d, depth %d, min %f, max %f, scaleX %f, scaleY %f, scaleZ %f\n", 265 266 width, height, depth, min, max, axisScaleX, axisScaleY, axisScaleZ); 266 267 return data; … … 273 274 if (fname == 0) 274 275 { 275 printf("file name is null\n");276 276 ERROR("file name is null\n"); 277 return NULL; 277 278 } 278 279 … … 280 281 if (fp == NULL) 281 282 { 282 printf("ERROR :file not found %s\n", fname);283 283 ERROR("file not found %s\n", fname); 284 return NULL; 284 285 } 285 286 … … 302 303 if (fname == 0) 303 304 { 304 printf("file name is null\n");305 305 ERROR("file name is null\n"); 306 return; 306 307 } 307 308 … … 309 310 if (fp == NULL) 310 311 { 311 printf("ERROR :file not found %s\n", fname);312 312 ERROR("file not found %s\n", fname); 313 return; 313 314 } 314 315 … … 326 327 if (path.size() == 0) 327 328 { 328 printf("file not found[%s]\n", path.c_str());329 329 ERROR("file not found[%s]\n", path.c_str()); 330 return NULL; 330 331 } 331 332 … … 333 334 if (fp == NULL) 334 335 { 335 printf("ERROR :file not found %s\n", path.c_str());336 336 ERROR("file not found %s\n", path.c_str()); 337 return NULL; 337 338 } 338 339 … … 387 388 if (length > max) 388 389 { 389 printf("max %lf %lf %fl\n", x, y, z);390 TRACE("max %lf %lf %fl\n", x, y, z); 390 391 max = length; 391 392 } … … 406 407 fclose(fp); 407 408 408 printf("width %d, height %d, depth %d, min %f, max %f, scaleX %f, scaleY %f, scaleZ %f\n",409 TRACE("width %d, height %d, depth %d, min %f, max %f, scaleX %f, scaleY %f, scaleZ %f\n", 409 410 width, height, depth, min, max, axisScaleX, axisScaleY, axisScaleZ); 410 411 return data; -
branches/blt4/packages/vizservers/nanovis/Event.cpp
r2120 r2409 28 28 29 29 void Event::write(FILE* fd){ 30 fprintf(fd, "%d %f %f %f %g\n", type, parameter[0], parameter[1], parameter[2], msec);30 fprintf(fd, "%d %f %f %f %g\n", type, parameter[0], parameter[1], parameter[2], msec); 31 31 } 32 32 -
branches/blt4/packages/vizservers/nanovis/EventPlayer.cpp
r1982 r2409 75 75 float ave = interval_sum / (cur_event-1); 76 76 float fps = 1/ave; 77 printf("Average frame time = %.6f\n", ave);78 printf("Frames per second = %f\n", fps);77 TRACE("Average frame time = %.6f\n", ave); 78 TRACE("Frames per second = %f\n", fps); 79 79 exit(0); 80 80 } … … 121 121 122 122 //send msg 123 // printf("Writing message %04d to server: '%s'\n", cur_event, msg.c_str());123 //TRACE("Writing message %04d to server: '%s'\n", cur_event, msg.c_str()); 124 124 int status = write(socket_fd, msg.c_str(), strlen(msg.c_str())); 125 125 if (status <= 0) { … … 131 131 int sizes[2]; 132 132 status = read(socket_fd, &sizes, sizeof(sizes)); 133 printf("Reading %d,%d bytes\n", sizes[0], sizes[1]);133 TRACE("Reading %d,%d bytes\n", sizes[0], sizes[1]); 134 134 int len = sizes[0] + sizes[1]; 135 135 #else … … 152 152 } 153 153 154 // printf("Read message to server.\n");154 //TRACE("Read message to server.\n"); 155 155 156 156 //end timer -
branches/blt4/packages/vizservers/nanovis/FlowCmd.cpp
r2120 r2409 849 849 length = sprintf(info, "nv>data tag %s min %g max %g\n", 850 850 flowPtr->name(), dataPtr->magMin(), dataPtr->magMax()); 851 nWritten = write( 0, info, length);851 nWritten = write(1, info, length); 852 852 assert(nWritten == (ssize_t)strlen(info)); 853 853 } -
branches/blt4/packages/vizservers/nanovis/HeightMap.cpp
r1982 r2409 563 563 if (_vertexBufferObjectID) 564 564 { 565 printf("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\n");565 TRACE("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\n"); 566 566 glColor3f(1.0f, 1.0f, 1.0f); 567 567 glShadeModel(GL_SMOOTH); -
branches/blt4/packages/vizservers/nanovis/Nv.cpp
r1053 r2409 21 21 if(lastError) { 22 22 const char *listing = cgGetLastListing(g_context); 23 printf("\n---------------------------------------------------\n");24 printf("%s\n\n", cgGetErrorString(lastError));25 printf("%s\n", listing);26 printf("-----------------------------------------------------\n");27 printf("Cg error, exiting...\n");23 ERROR("\n---------------------------------------------------\n"); 24 ERROR("%s\n\n", cgGetErrorString(lastError)); 25 ERROR("%s\n", listing); 26 ERROR("-----------------------------------------------------\n"); 27 ERROR("Cg error, exiting...\n"); 28 28 cgDestroyContext(g_context); 29 fflush(stdout);30 29 exit(-1); 31 30 } … … 34 33 void NvInit(char* path) 35 34 { 36 printf("Nanovis GL Initialized\n");35 TRACE("Nanovis GL Initialized\n"); 37 36 } 38 37 -
branches/blt4/packages/vizservers/nanovis/NvEventLog.cpp
r2120 r2409 26 26 logName = (char*) calloc(logNameLen,sizeof(char)); 27 27 strncpy(logName,"/tmp/nanovis_log.txt",logNameLen); 28 } 29 else { 28 } else { 30 29 logNameLen = 17+1+strlen(user); 31 30 logName = (char*) calloc(logNameLen,sizeof(char)); 32 31 strncpy(logName,"/tmp/nanovis_log_",logNameLen); 33 strncat(logName, user,strlen(user));32 strncat(logName, user, strlen(user)); 34 33 } 35 34 36 35 //open log and map stderr to log file 37 36 NanoVis::logfile = fopen(logName, "w"); 38 close(2);39 37 dup2(fileno(NanoVis::logfile), 2); 40 dup2(2,1); 41 //flush junk 42 fflush(stdout); 43 fflush(stderr); 38 /* dup2(2,1); */ 44 39 45 40 // clean up malloc'd memory … … 77 72 { 78 73 struct timeval time; 74 79 75 gettimeofday(&time, NULL); 80 76 double new_time = time.tv_sec*1000. + time.tv_usec/1000.; -
branches/blt4/packages/vizservers/nanovis/NvVectorField.cpp
r1515 r2409 38 38 _vectorFieldId = volPtr->id; 39 39 _physicalMin = volPtr->getPhysicalBBoxMin(); 40 printf("_pysicalMin %f %f %f\n", _physicalMin.x, _physicalMin.y, _physicalMin.z);40 TRACE("_pysicalMin %f %f %f\n", _physicalMin.x, _physicalMin.y, _physicalMin.z); 41 41 _physicalSize = volPtr->getPhysicalBBoxMax() - _physicalMin; 42 printf("_pysicalSize %f %f %f\n",42 TRACE("_pysicalSize %f %f %f\n", 43 43 _physicalSize.x, _physicalSize.y, _physicalSize.z); 44 44 } -
branches/blt4/packages/vizservers/nanovis/NvZincBlendeReconstructor.cpp
r1053 r2409 60 60 { 61 61 #ifdef _LOADER_DEBUG_ 62 printf("VERSION 1\n"); 63 fflush(stdout); 62 TRACE("VERSION 1\n"); 64 63 #endif 65 64 version = 1; … … 69 68 { 70 69 #ifdef _LOADER_DEBUG_ 71 printf("VERSION 2\n"); 72 fflush(stdout); 70 TRACE("VERSION 2\n"); 73 71 #endif 74 72 version = 2; … … 105 103 catch (...) 106 104 { 107 printf("ERROR\n");105 TRACE("ERROR\n"); 108 106 } 109 107 … … 123 121 sscanf(pt, "%s%f%f%f", str[0], &(delta.x), &(delta.y), &(delta.z)); 124 122 #ifdef _LOADER_DEBUG_ 125 printf("delta : %f %f %f\n", delta.x, delta.y, delta.z); 126 fflush(stdout); 123 TRACE("delta : %f %f %f\n", delta.x, delta.y, delta.z); 127 124 #endif 128 125 } … … 131 128 sscanf(pt, "%s%d", str[0], &datacount); 132 129 #ifdef _LOADER_DEBUG_ 133 printf("datacount = %d\n", datacount); 134 fflush(stdout); 130 TRACE("datacount = %d\n", datacount); 135 131 #endif 136 132 } … … 146 142 sscanf(pt, "%s%d%d%d", str[0], &width, &height, &depth); 147 143 #ifdef _LOADER_DEBUG_ 148 printf("width height depth %d %d %d\n", width, height, depth); 149 fflush(stdout); 144 TRACE("width height depth %d %d %d\n", width, height, depth); 150 145 #endif 151 146 } … … 154 149 sscanf(pt, "%s%lf", str[0], &emptyvalue); 155 150 #ifdef _LOADER_DEBUG_ 156 printf("empryvalue %lf\n", emptyvalue); 157 fflush(stdout); 151 TRACE("empryvalue %lf\n", emptyvalue); 158 152 #endif 159 153 } … … 162 156 sscanf(pt, "%s%lf", str[0], &emptyvalue); 163 157 #ifdef _LOADER_DEBUG_ 164 printf("emptyvalue %lf\n", emptyvalue);158 TRACE("emptyvalue %lf\n", emptyvalue); 165 159 #endif 166 160 } … … 247 241 248 242 #ifdef _LOADER_DEBUG_ 249 printf("index %d\n", index); 250 fflush(stdout); 243 TRACE("index %d\n", index); 251 244 #endif 252 245 … … 321 314 322 315 #ifdef _LOADER_DEBUG_ 323 printf("[%d] index %d (width:%lf height:%lf depth:%lf)\n", i, index, srcPtr->indexX, srcPtr->indexY, srcPtr->indexZ); 324 fflush(stdout); 316 TRACE("[%d] index %d (width:%lf height:%lf depth:%lf)\n", i, index, srcPtr->indexX, srcPtr->indexY, srcPtr->indexZ); 325 317 #endif 326 318 327 319 if (index < 0) { 328 320 #ifdef _LOADER_DEBUG_ 329 printf("There is an invalid data\n"); 330 fflush(stdout); 321 TRACE("There is an invalid data\n"); 331 322 #endif 332 323 srcPtr +=8; … … 398 389 399 390 #ifdef _LOADER_DEBUG_ 400 printf("%s", buff); 401 fflush(stdout); 391 TRACE("%s", buff); 402 392 #endif 403 393 } … … 421 411 else if (strstr((const char*) buff, "object") != 0) 422 412 { 423 printf("VERSION 1\n"); 424 fflush(stdout); 413 TRACE("VERSION 1\n"); 425 414 version = 1; 426 415 break; … … 428 417 else if (strstr(buff, "record format") != 0) 429 418 { 430 printf("VERSION 2\n"); 431 fflush(stdout); 419 TRACE("VERSION 2\n"); 432 420 version = 2; 433 421 break; … … 463 451 catch (...) 464 452 { 465 printf("ERROR\n");453 TRACE("ERROR\n"); 466 454 } 467 455 … … 481 469 sscanf(pt, "%s%f%f%f", str[0], &(delta.x), &(delta.y), &(delta.z)); 482 470 #ifdef _LOADER_DEBUG_ 483 printf("delta : %f %f %f\n", delta.x, delta.y, delta.z); 484 fflush(stdout); 471 TRACE("delta : %f %f %f\n", delta.x, delta.y, delta.z); 485 472 #endif 486 473 } … … 488 475 { 489 476 sscanf(pt, "%s%d", str[0], &datacount); 490 printf("datacount = %d\n", datacount); 491 fflush(stdout); 477 TRACE("datacount = %d\n", datacount); 492 478 } 493 479 else if ((pt = strstr(buff, "datatype")) != 0) … … 502 488 sscanf(pt, "%s%d%d%d", str[0], &width, &height, &depth); 503 489 #ifdef _LOADER_DEBUG_ 504 printf("width height depth %d %d %d\n", width, height, depth); 505 fflush(stdout); 490 TRACE("width height depth %d %d %d\n", width, height, depth); 506 491 #endif 507 492 } … … 510 495 sscanf(pt, "%s%lf", str[0], &emptyvalue); 511 496 #ifdef _LOADER_DEBUG_ 512 printf("empryvalue %lf\n", emptyvalue); 513 fflush(stdout); 497 TRACE("empryvalue %lf\n", emptyvalue); 514 498 #endif 515 499 } … … 518 502 sscanf(pt, "%s%lf", str[0], &emptyvalue); 519 503 #ifdef _LOADER_DEBUG_ 520 printf("emptyvalue %lf\n", emptyvalue);504 TRACE("emptyvalue %lf\n", emptyvalue); 521 505 #endif 522 506 } … … 555 539 556 540 #ifdef _LOADER_DEBUG_ 557 printf("%s", buff); 558 fflush(stdout); 559 #endif 560 } 541 TRACE("%s", buff); 542 #endif 543 } -
branches/blt4/packages/vizservers/nanovis/PCASplit.cpp
r1028 r2409 128 128 _clusterHeader->startPointerCluster[level - 1] = clusterBlock; 129 129 130 printf("Cluster created %d [in level %d]:total %d\n", count, level, cc); 131 fflush(stdout); 130 TRACE("Cluster created %d [in level %d]:total %d\n", count, level, cc); 132 131 133 132 int i = 0; … … 142 141 } 143 142 if (count != i) { 144 printf("ERROR\n");143 TRACE("ERROR\n"); 145 144 } 146 145 return clusterBlock; … … 266 265 267 266 if (left == 0 || right == count - 1) { 268 printf("error\n");267 TRACE("error\n"); 269 268 exit(1); 270 269 } else { -
branches/blt4/packages/vizservers/nanovis/ParticleSystem.cpp
r2307 r2409 1 #include "ParticleSystem.h" 2 #include "ParticleEmitter.h" 1 3 2 #include <vr3d/vr3d.h> 4 3 #include <time.h> … … 18 17 #endif 19 18 #endif 20 19 #include "ParticleSystem.h" 20 #include "ParticleEmitter.h" 21 #include "Trace.h" 21 22 #include <vrutil/vrFilePath.h> 22 23 #include <pthread.h> … … 95 96 printf("%f\n",ti - t); 96 97 queue.push(); 97 printf("%d loaded\n", curIndex);98 TRACE("%d loaded\n", curIndex); 98 99 ++curIndex; 99 100 } … … 101 102 else 102 103 { 103 // printf("full\n");104 //TRACE("full\n"); 104 105 } 105 106 } … … 488 489 if(lastError) { 489 490 const char *listing = cgGetLastListing(_context); 490 printf("\n---------------------------------------------------\n");491 printf("%s\n\n", cgGetErrorString(lastError));492 printf("%s\n", listing);493 printf("-----------------------------------------------------\n");494 printf("Cg error, exiting...\n");491 ERROR("\n---------------------------------------------------\n"); 492 ERROR("%s\n\n", cgGetErrorString(lastError)); 493 ERROR("%s\n", listing); 494 ERROR("-----------------------------------------------------\n"); 495 ERROR("Cg error, exiting...\n"); 495 496 496 497 cgDestroyContext(_context); … … 1124 1125 _vectorFields[0]->updatePixels(data); 1125 1126 float ti = clock() / (float) CLOCKS_PER_SEC; 1126 printf("pixels %f\n",ti - t);1127 TRACE("pixels %f\n",ti - t); 1127 1128 _queue.pop(); 1128 1129 oldTime = time; 1129 1130 1130 1131 firstLoad = false; 1131 printf("%d bound\n", index++);1132 TRACE("%d bound\n", index++); 1132 1133 } 1133 1134 } … … 1331 1332 for (iter = _newParticles.begin(); iter != _newParticles.end(); iter++) 1332 1333 { 1333 //printf("[%d] %f %f %f\n", iter->index, iter->position.x,iter->position.y,iter->position.z);1334 //TRACE("[%d] %f %f %f\n", iter->index, iter->position.x,iter->position.y,iter->position.z); 1334 1335 glMultiTexCoord3f(GL_TEXTURE0, iter->position.x,iter->position.y,iter->position.z); 1335 1336 … … 1340 1341 glVertex2f( (float)(iter->index % _width), 1341 1342 (float)(iter->index / _height) + 1/* + offsetY*/ /* + offsetY shouldn't be */); 1342 // printf("%f %f\n", (float) (iter->index % _width), (float)(iter->index / _width));1343 //TRACE("%f %f\n", (float) (iter->index % _width), (float)(iter->index / _width)); 1343 1344 } 1344 1345 glEnd(); … … 1387 1388 for (iter = _newParticles.begin(); iter != _newParticles.end(); iter++) 1388 1389 { 1389 // printf("[%d] %f %f %f\n", iter->index, iter->position.x,iter->position.y,iter->position.z);1390 //TRACE("[%d] %f %f %f\n", iter->index, iter->position.x,iter->position.y,iter->position.z); 1390 1391 glMultiTexCoord3f(GL_TEXTURE0, iter->position.x,iter->position.y,iter->position.z); 1391 1392 … … 1396 1397 glVertex2f( (float)(iter->index % _width), 1397 1398 (float)(iter->index / _height) + 1/* + offsetY*/ /* + offsetY shouldn't be */); 1398 // printf("%f %f\n", (float) (iter->index % _width), (float)(iter->index / _width));1399 //TRACE("%f %f\n", (float) (iter->index % _width), (float)(iter->index / _width)); 1399 1400 } 1400 1401 glEnd(); … … 1488 1489 1489 1490 /////////////////////////////// 1490 // DEBUG1491 // _DEBUG 1491 1492 /* 1492 1493 { … … 1494 1495 static float debug[256]; 1495 1496 glReadPixels(0, 0, _width, _height, GL_RGB, GL_FLOAT, (float*)debug); 1496 printf("[%d]", _currentSortIndex);1497 TRACE("[%d]", _currentSortIndex); 1497 1498 for (int i = 0; i < _width * _height * 3; i += 3) 1498 printf("%.2f, %.2f, %.2f\n", debug[i], debug[i+1], debug[i+2]);1499 printf("\n");1499 TRACE("%.2f, %.2f, %.2f\n", debug[i], debug[i+1], debug[i+2]); 1500 TRACE("\n"); 1500 1501 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 1501 1502 … … 1503 1504 */ 1504 1505 /////////////////////////////// 1505 // DEBUG1506 // _DEBUG 1506 1507 /* 1507 1508 { … … 1509 1510 static float debug[256]; 1510 1511 glReadPixels(0, 0, _width, _height, GL_RGB, GL_FLOAT, (float*)debug); 1511 printf("\n");1512 printf("currentPos[%d]", _currentPosIndex);1512 TRACE("\n"); 1513 TRACE("currentPos[%d]", _currentPosIndex); 1513 1514 for (int i = 0; i < _width * _height * 3; i += 3) 1514 printf("%.2f, %.2f, %.2f\n", debug[i], debug[i+1], debug[i+2]);1515 printf("\n");1515 TRACE("%.2f, %.2f, %.2f\n", debug[i], debug[i+1], debug[i+2]); 1516 TRACE("\n"); 1516 1517 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 1517 1518 } … … 1544 1545 1545 1546 /////////////////////////////// 1546 // DEBUG1547 // _DEBUG 1547 1548 /* 1548 1549 { … … 1550 1551 static float debug[256]; 1551 1552 glReadPixels(0, 0, _width, _height, GL_RGB, GL_FLOAT, (float*)debug); 1552 printf("\n");1553 printf("[%d]", _currentSortIndex);1553 TRACE("\n"); 1554 TRACE("[%d]", _currentSortIndex); 1554 1555 for (int i = 0; i < _width * _height * 3; i += 3) 1555 printf("%.2f, %.2f, %.2f\n", debug[i], debug[i+1], debug[i+2]);1556 printf("\n");1556 TRACE("%.2f, %.2f, %.2f\n", debug[i], debug[i+1], debug[i+2]); 1557 TRACE("\n"); 1557 1558 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 1558 1559 } … … 1608 1609 1609 1610 /////////////////////////////// 1610 // DEBUG1611 // _DEBUG 1611 1612 /* 1612 1613 { … … 1614 1615 static float debug[256]; 1615 1616 glReadPixels(0, 0, _width, _height, GL_RGB, GL_FLOAT, (float*)debug); 1616 printf("\n");1617 printf("[%d]", _currentSortIndex);1617 TRACE("\n"); 1618 TRACE("[%d]", _currentSortIndex); 1618 1619 for (int i = 0; i < _width * _height * 3; i += 3) 1619 printf("%.2f, %.2f, %.2f\n", debug[i], debug[i+1], debug[i+2]);1620 printf("\n");1620 TRACE("%.2f, %.2f, %.2f\n", debug[i], debug[i+1], debug[i+2]); 1621 TRACE("\n"); 1621 1622 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 1622 1623 } … … 1809 1810 1810 1811 cgSetParameter1f(_mvCurrentTimeParam, _currentTime); 1811 // printf("%f %f, %f %d\n", _fov, tan(_fov), tan(_fov / 2.0), _screenHeight);1812 //TRACE("%f %f, %f %d\n", _fov, tan(_fov), tan(_fov / 2.0), _screenHeight); 1812 1813 //cgSetParameter1f(_mvTanHalfFOVParam, -tan(_fov * PI / 180 * 0.5) * _screenHeight * 0.5); 1813 1814 //float v = tan(_fov * PI / 180 * 0.5) * _screenHeight * 0.5; -
branches/blt4/packages/vizservers/nanovis/ParticleSystemFactory.cpp
r1816 r2409 3 3 #include <vrutil/vrFilePath.h> 4 4 #include <stdio.h> 5 #include "Trace.h" 5 6 6 7 #ifdef _WIN32 … … 75 76 if (!stat) 76 77 { 77 // printf("Parse error at line %d\n", XML_GetCurrentLineNumber(parser));78 //TRACE("Parse error at line %d\n", XML_GetCurrentLineNumber(parser)); 78 79 break; 79 80 } … … 198 199 index = path.rfind('\\'); 199 200 if (index == -1) 200 printf("file not found\n");201 TRACE("file not found\n"); 201 202 } 202 203 -
branches/blt4/packages/vizservers/nanovis/RpAVTranslate.cpp
r2120 r2409 104 104 if (_fmtPtr == NULL) { 105 105 /* 106 printf( "Could not deduce output format from"106 TRACE( "Could not deduce output format from" 107 107 "file extension: using MPEG.\n"); 108 108 */ -
branches/blt4/packages/vizservers/nanovis/RpDX.cpp
r1982 r2409 53 53 } 54 54 // open the file with libdx 55 fprintf(stdout, "Calling DXImportDX(%s)\n", filename); 56 fflush(stdout); 55 TRACE("Calling DXImportDX(%s)\n", filename); 57 56 DXenable_locks(0); 58 57 _dxobj = DXImportDX((char*)filename,NULL,NULL,NULL,NULL); … … 74 73 DXGetArrayInfo(dxpos, &_n, &type, &category, &_rank, &_shape); 75 74 76 fprintf(stdout,"_n = %d\n",_n);75 TRACE("_n = %d\n",_n); 77 76 if (type != TYPE_FLOAT) { 78 77 result.addError("\"positions\" is not type float (type=%d)\n", type); 79 78 return; 80 79 } 81 fprintf(stdout,"_rank = %d\n",_rank);82 fprintf(stdout,"_shape = %d\n",_shape);80 TRACE("_rank = %d\n",_rank); 81 TRACE("_shape = %d\n",_shape); 83 82 84 83 float* pos = NULL; … … 140 139 DXQueryGridPositions(dxpos, NULL, _axisLen, _origin, _delta); 141 140 142 fprintf(stdout, "_max = [%g,%g,%g]\n",_max[0],_max[1],_max[2]); 143 fprintf(stdout, "_delta = [%g,%g,%g]\n",_delta[0],_delta[1],_delta[2]); 144 fprintf(stdout, " [%g,%g,%g]\n",_delta[3],_delta[4],_delta[5]); 145 fprintf(stdout, " [%g,%g,%g]\n",_delta[6],_delta[7],_delta[8]); 146 fprintf(stdout, "_origin = [%g,%g,%g]\n",_origin[0],_origin[1],_origin[2]); 147 fprintf(stdout, "_axisLen = [%i,%i,%i]\n",_axisLen[0],_axisLen[1],_axisLen[2]); 148 fflush(stdout); 141 TRACE("_max = [%g,%g,%g]\n",_max[0],_max[1],_max[2]); 142 TRACE("_delta = [%g,%g,%g]\n",_delta[0],_delta[1],_delta[2]); 143 TRACE(" [%g,%g,%g]\n",_delta[3],_delta[4],_delta[5]); 144 TRACE(" [%g,%g,%g]\n",_delta[6],_delta[7],_delta[8]); 145 TRACE("_origin = [%g,%g,%g]\n",_origin[0],_origin[1],_origin[2]); 146 TRACE("_axisLen = [%i,%i,%i]\n",_axisLen[0],_axisLen[1],_axisLen[2]); 149 147 150 148 // grab the data array from the dx object and store it in _data … … 180 178 // print debug info 181 179 for (int lcv = 0, pt = 0; lcv < _n; lcv +=3, pt+=9) { 182 fprintf(stdout, 183 "(%f,%f,%f)|->% 8e\n(%f,%f,%f)|->% 8e\n(%f,%f,%f)|->% 8e\n", 180 TRACE("(%f,%f,%f)|->% 8e\n(%f,%f,%f)|->% 8e\n(%f,%f,%f)|->% 8e\n", 184 181 _positions[pt],_positions[pt+1],_positions[pt+2], _data[lcv], 185 182 _positions[pt+3],_positions[pt+4],_positions[pt+5],_data[lcv+1], 186 183 _positions[pt+6],_positions[pt+7],_positions[pt+8],_data[lcv+2]); 187 fflush(stdout);188 184 } 189 185 __collectDataStats(); … … 262 258 pos = (float*) DXGetArrayData(dxpos); 263 259 if (pos == NULL) { 264 fprintf(stdout, "DXGetArrayData failed to return positions array\n"); 265 fflush(stdout); 260 TRACE("DXGetArrayData failed to return positions array\n"); 266 261 } 267 262 … … 272 267 if (_positions == NULL) { 273 268 // malloc failed, raise error 274 fprintf(stdout, "malloc of _axisLen array failed"); 275 fflush(stdout); 269 TRACE("malloc of _axisLen array failed"); 276 270 } 277 271 memcpy(_positions,pos,sizeof(float)*_n*_numAxis); … … 298 292 if (_data == NULL) { 299 293 // malloc failed, raise error 300 fprintf(stdout, "malloc of _data array failed"); 301 fflush(stdout); 294 TRACE("malloc of _data array failed"); 302 295 } 303 296 memset(_data,0,_n); 304 297 305 298 // build the interpolator and interpolate 306 fprintf(stdout, "creating DXNewInterpolator...\n"); 307 fflush(stdout); 299 TRACE("creating DXNewInterpolator...\n"); 308 300 interpolator = DXNewInterpolator(_dxobj,INTERP_INIT_IMMEDIATE,-1.0); 309 fprintf(stdout,"_rank = %i\n",_rank); 310 fprintf(stdout,"_shape = %i\n",_shape); 311 fprintf(stdout,"_n = %i\n",_n); 312 fprintf(stdout,"start interppts = %i\n",interppts); 313 fflush(stdout); 301 TRACE("_rank = %i\n",_rank); 302 TRACE("_shape = %i\n",_shape); 303 TRACE("_n = %i\n",_n); 304 TRACE("start interppts = %i\n",interppts); 314 305 DXInterpolate(interpolator,&interppts,_positions,_data); 315 fprintf(stdout,"interppts = %i\n",interppts); 316 fflush(stdout); 306 TRACE("interppts = %i\n",interppts); 317 307 318 308 // print debug info 319 309 for (int lcv = 0, pt = 0; lcv < pts; lcv+=3,pt+=9) { 320 fprintf(stdout, 321 "(%f,%f,%f)|->% 8e\n(%f,%f,%f)|->% 8e\n(%f,%f,%f)|->% 8e\n", 310 TRACE("(%f,%f,%f)|->% 8e\n(%f,%f,%f)|->% 8e\n(%f,%f,%f)|->% 8e\n", 322 311 _positions[pt],_positions[pt+1],_positions[pt+2], _data[lcv], 323 312 _positions[pt+3],_positions[pt+4],_positions[pt+5],_data[lcv+1], 324 313 _positions[pt+6],_positions[pt+7],_positions[pt+8],_data[lcv+2]); 325 fflush(stdout);326 314 } 327 315 … … 340 328 DX::interpolate(int* newAxisLen) 341 329 { 342 fprintf(stdout, "----begin interpolation----\n"); 343 fflush(stdout); 330 TRACE("----begin interpolation----\n"); 344 331 if (newAxisLen != NULL) { 345 332 for (int i = 0; i < _numAxis; i++) { … … 349 336 __getInterpPos(); 350 337 __getInterpData(); 351 fprintf(stdout, "----end interpolation----\n"); 352 fflush(stdout); 338 TRACE("----end interpolation----\n"); 353 339 return *this; 354 340 } -
branches/blt4/packages/vizservers/nanovis/Texture1D.cpp
r1982 r2409 92 92 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max); 93 93 94 // printf("%d", glGetError());94 //TRACE("%d", glGetError()); 95 95 TRACE("max texture size: %d\n", max); 96 96 } -
branches/blt4/packages/vizservers/nanovis/Texture3D.cpp
r1982 r2409 207 207 glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT, &max); 208 208 209 // printf("%d", glGetError());209 //TRACE("%d", glGetError()); 210 210 TRACE("max 3d texture size: %d\n", max); 211 211 } -
branches/blt4/packages/vizservers/nanovis/Trace.cpp
r1990 r2409 8 8 #include <GL/glut.h> 9 9 #include <syslog.h> 10 11 static const char *syslogLevels[] = { 12 "emergency", /* System is unusable */ 13 "alert", /* Action must be taken immediately */ 14 "critical", /* Critical conditions */ 15 "error", /* Error conditions */ 16 "warning", /* Warning conditions */ 17 "notice", /* Normal but significant condition */ 18 "info", /* Informational */ 19 "debug", /* Debug-level messages */ 20 }; 10 21 11 22 void … … 25 36 s++; 26 37 } 27 length = snprintf(message, MSG_LEN, "line %d of \"%s\": ", lineNum, s); 38 length = snprintf(message, MSG_LEN, "nanovis (%d) %s: %s:%d ", 39 getpid(), syslogLevels[priority], s, lineNum); 28 40 length += vsnprintf(message + length, MSG_LEN - length, fmt, lst); 29 41 message[MSG_LEN] = '\0'; -
branches/blt4/packages/vizservers/nanovis/Unirect.cpp
r1982 r2409 666 666 dmin = pow((dx*dy*dz)/(nSamples*nSamples*nSamples), 0.333); 667 667 668 printf("dx:%lf dy:%lf dz:%lf dmin:%lf\n", dx, dy, dz, dmin);668 TRACE("dx:%lf dy:%lf dz:%lf dmin:%lf\n", dx, dy, dz, dmin); 669 669 670 670 /* Recompute new number of points for each axis. */ -
branches/blt4/packages/vizservers/nanovis/VelocityArrowsSlice.cpp
r2120 r2409 97 97 #else 98 98 /* 99 printf("test1\n");99 TRACE("test1\n"); 100 100 const char *path = R2FilePath::getInstance()->getPath("arrows_flip2.png"); 101 if (path) printf("test2 %s\n", path);102 else printf("tt\n");101 if (path) TRACE("test2 %s\n", path); 102 else TRACE("tt\n"); 103 103 IplImage* pTextureImage = cvLoadImage(path); 104 printf("test3\n");104 TRACE("test3\n"); 105 105 if (pTextureImage) 106 106 { 107 printf("file(%s) has been loaded\n", path);107 TRACE("file(%s) has been loaded\n", path); 108 108 _arrowsTex = new Texture2D(pTextureImage->width, pTextureImage->height, GL_FLOAT, GL_LINEAR, 3, (float*) pTextureImage->imageData); 109 printf("file(%s) has been loaded\n", path);109 TRACE("file(%s) has been loaded\n", path); 110 110 //cvReleaseImage(&pTextureImage); 111 111 } 112 112 else 113 113 { 114 printf("not found\n");114 TRACE("not found\n"); 115 115 } 116 116 if (path) delete [] path; -
branches/blt4/packages/vizservers/nanovis/VolumeInterpolator.cpp
r1982 r2409 127 127 _volumes[0]->depth != refPtr->depth || 128 128 _volumes[0]->n_components() != refPtr->n_components()) { 129 printf("The volume should be the same width, height, number of components\n");129 TRACE("The volume should be the same width, height, number of components\n"); 130 130 return; 131 131 } -
branches/blt4/packages/vizservers/nanovis/VolumeRenderer.cpp
r1982 r2409 241 241 ConvexPolygon static_poly; 242 242 for(int j = 0; j < volPtr->get_cutplane_count(); j++) { 243 if(!volPtr->cutplane_is_enabled(j)) 243 if(!volPtr->cutplane_is_enabled(j)) { 244 244 continue; 245 245 } 246 246 float offset = volPtr->get_cutplane(j)->offset; 247 247 int axis = volPtr->get_cutplane(j)->orient; … … 646 646 goto error; 647 647 } 648 // printf("Data at Offset: %ld\n", bfOffBits);648 //TRACE("Data at Offset: %ld\n", bfOffBits); 649 649 650 650 /* skip size of bitmap info header */ … … 656 656 goto error; 657 657 } 658 // printf("Width of Bitmap: %d\n", texture->width);658 //TRACE("Width of Bitmap: %d\n", texture->width); 659 659 660 660 /* get the height of the bitmap */ … … 663 663 goto error; 664 664 } 665 // printf("Height of Bitmap: %d\n", texture->height);665 //TRACE("Height of Bitmap: %d\n", texture->height); 666 666 667 667 /* get the number of planes (must be set to 1) */ … … 681 681 } 682 682 683 // printf("Bits per Pixel: %d\n", biBitCount);683 //TRACE("Bits per Pixel: %d\n", biBitCount); 684 684 if (biBitCount != 24) { 685 685 ERROR("Bits per Pixel not 24\n"); -
branches/blt4/packages/vizservers/nanovis/dxReader.cpp
r1982 r2409 51 51 std::iostream& fin) 52 52 { 53 printf("load_volume_stream2 %s\n", tag);53 TRACE("load_volume_stream2 %s\n", tag); 54 54 Rappture::MeshTri2D xymesh; 55 55 int dummy, nx, ny, nz, nxy, npts; … … 408 408 if (volPtr) { 409 409 volPtr->location(Vector3(dx0, dy0, dz0)); 410 printf("volume moved\n");410 TRACE("volume moved\n"); 411 411 } 412 412 return volPtr; … … 417 417 std::iostream& fin) 418 418 { 419 printf("load_volume_stream\n");419 TRACE("load_volume_stream\n"); 420 420 421 421 Rappture::MeshTri2D xymesh; … … 845 845 std::iostream& fin) 846 846 { 847 printf("load_volume_stream\n");847 TRACE("load_volume_stream\n"); 848 848 849 849 Rappture::MeshTri2D xymesh; -
branches/blt4/packages/vizservers/nanovis/dxReader2.cpp
r1982 r2409 89 89 computeSimpleGradient(data, nx, ny, nz); 90 90 91 fprintf(stdout,"nx = %i ny = %i nz = %i\n",nx,ny,nz); 92 fprintf(stdout,"dx = %lg dy = %lg dz = %lg\n",dx,dy,dz); 93 fprintf(stdout,"dataMin = %lg\tdataMax = %lg\tnzero_min = %lg\n", dxObj.dataMin(),dxObj.dataMax(),dxObj.nzero_min()); 94 fflush(stdout); 91 TRACE("nx = %i ny = %i nz = %i\n",nx,ny,nz); 92 TRACE("dx = %lg dy = %lg dz = %lg\n",dx,dy,dz); 93 TRACE("dataMin = %lg\tdataMax = %lg\tnzero_min = %lg\n", dxObj.dataMin(),dxObj.dataMax(),dxObj.nzero_min()); 95 94 96 95 Volume *volPtr; -
branches/blt4/packages/vizservers/nanovis/nanovis.cpp
r1990 r2409 241 241 ssize_t nWritten; 242 242 243 nWritten = write( 0, str, strlen(str));243 nWritten = write(2, str, strlen(str)); 244 244 } 245 245 … … 428 428 } 429 429 TRACE("cg program compiling: %s\n", path); 430 fflush(stdout);431 430 CGprogram program; 432 431 program = cgCreateProgramFromFile(context, CG_SOURCE, path, profile, … … 591 590 sprintf(prefix, "nv>legend %s %g %g", volArg, min, max); 592 591 ppm_write(prefix); 593 nWritten = write( 0, "\n", 1);592 nWritten = write(1, "\n", 1); 594 593 assert(nWritten == 1); 595 594 } … … 756 755 if(lastError) { 757 756 const char *listing = cgGetLastListing(g_context); 758 printf("\n---------------------------------------------------\n");759 printf("%s\n\n", cgGetErrorString(lastError));760 printf("%s\n", listing);761 printf("-----------------------------------------------------\n");762 printf("Cg error, exiting...\n");757 TRACE("\n---------------------------------------------------\n"); 758 TRACE("%s\n\n", cgGetErrorString(lastError)); 759 TRACE("%s\n", listing); 760 TRACE("-----------------------------------------------------\n"); 761 TRACE("Cg error, exiting...\n"); 763 762 cgDestroyContext(g_context); 764 fflush(stdout);765 763 DoExit(-1); 766 764 } … … 770 768 { 771 769 // print system information 772 INFO("-----------------------------------------------------------\n");773 INFO("OpenGL driver: %s %s\n", glGetString(GL_VENDOR),770 TRACE("-----------------------------------------------------------\n"); 771 TRACE("OpenGL driver: %s %s\n", glGetString(GL_VENDOR), 774 772 glGetString(GL_VERSION)); 775 INFO("Graphics hardware: %s\n", glGetString(GL_RENDERER));776 INFO("-----------------------------------------------------------\n");773 TRACE("Graphics hardware: %s\n", glGetString(GL_RENDERER)); 774 TRACE("-----------------------------------------------------------\n"); 777 775 if (path == NULL) { 778 776 ERROR("No path defined for shaders or resources\n"); … … 785 783 //assert(false); 786 784 } 787 INFO("Using GLEW %s\n", glewGetString(GLEW_VERSION));785 TRACE("Using GLEW %s\n", glewGetString(GLEW_VERSION)); 788 786 789 787 if (!R2FilePath::getInstance()->setPath(path)) { … … 1061 1059 char string[200]; 1062 1060 sprintf(string, "%s %d\n", prefix, fsize); 1063 nWritten = write( 0, string, strlen(string));1061 nWritten = write(1, string, strlen(string)); 1064 1062 assert(nWritten == (ssize_t)strlen(string)); 1065 1063 header[pos++] = 'B'; … … 1114 1112 } 1115 1113 1116 nWritten = write( 0, header, SIZEOF_BMP_HEADER);1114 nWritten = write(1, header, SIZEOF_BMP_HEADER); 1117 1115 assert(nWritten == SIZEOF_BMP_HEADER); 1118 nWritten = write( 0, screen_buffer, (3*win_width+pad)*win_height);1116 nWritten = write(1, screen_buffer, (3*win_width+pad)*win_height); 1119 1117 assert(nWritten == (3*win_width+pad)*win_height); 1120 1118 stats.nFrames++; … … 1180 1178 srcRowPtr += bytesPerRow; 1181 1179 } 1182 if (writev( 0, iov, nRecs) < 0) {1180 if (writev(1, iov, nRecs) < 0) { 1183 1181 ERROR("write failed: %s\n", strerror(errno)); 1184 1182 } … … 1222 1220 iov[1].iov_base = (char *)data; 1223 1221 iov[1].iov_len = dlen; 1224 if (writev( 0, iov, nRecs) < 0) {1222 if (writev(1, iov, nRecs) < 0) { 1225 1223 ERROR("write failed: %s\n", strerror(errno)); 1226 1224 } … … 1863 1861 case 'a' : 1864 1862 { 1865 printf("flowvis active\n");1863 TRACE("flowvis active\n"); 1866 1864 char cmd[] = { 1867 1865 "foreach flow [flow names] {\n" … … 1878 1876 case 'd' : 1879 1877 { 1880 printf("flowvis deactived\n");1878 TRACE("flowvis deactived\n"); 1881 1879 char cmd[] = { 1882 1880 "foreach flow [flow names] {\n" … … 1892 1890 case '1' : 1893 1891 { 1894 printf("add vector field\n");1892 TRACE("add vector field\n"); 1895 1893 char cmd[] = { 1896 1894 "flow create flow1\n" … … 1915 1913 }; 1916 1914 Tcl_Eval(interp, cmd); 1917 printf("add vector field\n");1915 TRACE("add vector field\n"); 1918 1916 addVectorField("/home/iwoo/projects/nanovis/rappture/packages/vizservers/nanovis/data/flowvis_dx_files/3DWireLeakage/SiO2/SiO2.dx", 1919 1917 "vf_name1", "plane_name1", "plane_name2", Vector4(1, 0, 0, 1), Vector4(1, 1, 0, 1)); … … 1922 1920 case '3': 1923 1921 { 1924 printf("activate\n");1922 TRACE("activate\n"); 1925 1923 char cmd[] = { 1926 1924 "flow1 particles add plane2 -hide no\n" … … 1934 1932 case '4' : 1935 1933 { 1936 printf("deactivate\n");1934 TRACE("deactivate\n"); 1937 1935 char cmd[] = { 1938 1936 "flow1 particles add plane2 -hide yes\n" … … 1946 1944 case '5' : 1947 1945 { 1948 printf("vector field deleted (vf_name2)\n");1946 TRACE("vector field deleted (vf_name2)\n"); 1949 1947 char cmd[] = { 1950 1948 "flow delete flow2\n" … … 1958 1956 case '6' : 1959 1957 { 1960 printf("add device shape\n");1958 TRACE("add device shape\n"); 1961 1959 char cmd[] = { 1962 1960 "flow1 box add box1 -corner1 {0 0 0} -corner2 {30 3 3} -color { 1 0 0 1 }\n" … … 1985 1983 case '7' : 1986 1984 { 1987 printf("hide shape \n");1985 TRACE("hide shape \n"); 1988 1986 char cmd[] = { 1989 1987 "flow1 box configure box1 -hide yes\n" … … 1997 1995 case '8' : 1998 1996 { 1999 printf("show shape\n");1997 TRACE("show shape\n"); 2000 1998 char cmd[] = { 2001 1999 "flow1 box configure box1 -hide no\n" … … 2009 2007 case '9' : 2010 2008 { 2011 printf("show a shape \n");2009 TRACE("show a shape \n"); 2012 2010 char cmd[] = { 2013 2011 "flow1 box configure box3 -hide no\n" … … 2021 2019 case '0' : 2022 2020 { 2023 printf("delete a shape \n");2021 TRACE("delete a shape \n"); 2024 2022 char cmd[] = { 2025 2023 "flow1 box delete box3\n" … … 2033 2031 case 'r' : 2034 2032 { 2035 printf("reset \n");2033 TRACE("reset \n"); 2036 2034 char cmd[] = { 2037 2035 "flow reset\n" … … 2129 2127 2130 2128 TRACE("Enter xinetd_listen\n"); 2129 2131 2130 int flags = fcntl(0, F_GETFL, 0); 2132 2131 fcntl(0, F_SETFL, flags & ~O_NONBLOCK); … … 2160 2159 ch = (char)c; 2161 2160 Tcl_DStringAppend(&cmdbuffer, &ch, 1); 2161 TRACE("in xinetd_listen: checking buffer=%s\n", 2162 Tcl_DStringValue(&cmdbuffer)); 2162 2163 if (ch == '\n') { 2163 2164 isComplete = Tcl_CommandComplete(Tcl_DStringValue(&cmdbuffer)); … … 2179 2180 isComplete = false; 2180 2181 nCommands++; 2181 CHECK_FRAMEBUFFER_STATUS();2182 CHECK_FRAMEBUFFER_STATUS(); 2182 2183 } 2183 2184 } … … 2198 2199 iov[2].iov_len = 1; 2199 2200 iov[2].iov_base = (char *)'\n'; 2200 if (writev( 0, iov, 3) < 0) {2201 if (writev(1, iov, 3) < 0) { 2201 2202 ERROR("write failed: %s\n", strerror(errno)); 2202 2203 } 2203 2204 TRACE("Leaving xinetd_listen on ERROR\n"); 2204 2205 return; 2206 } 2207 if (feof(NanoVis::stdin)) { 2208 DoExit(90); 2205 2209 } 2206 2210 … … 2221 2225 #endif 2222 2226 2227 if (feof(NanoVis::stdin)) { 2228 DoExit(90); 2229 } 2223 2230 #if DO_RLE 2224 2231 do_rle(); 2225 2232 int sizes[2] = { offsets_size*sizeof(offsets[0]), rle_size }; 2226 2233 TRACE("Writing %d,%d\n", sizes[0], sizes[1]); 2227 write( 0, &sizes, sizeof(sizes));2228 write( 0, offsets, offsets_size*sizeof(offsets[0]));2229 write( 0, rle, rle_size); //unsigned byte2234 write(1, &sizes, sizeof(sizes)); 2235 write(1, offsets, offsets_size*sizeof(offsets[0])); 2236 write(1, rle, rle_size); //unsigned byte 2230 2237 #else 2231 2238 NanoVis::ppm_write("\nnv>image -type image -bytes"); 2232 2239 #endif 2233 if (feof(NanoVis::stdin)) {2234 DoExit(90);2235 }2236 2240 TRACE("Leaving xinetd_listen OK\n"); 2237 2241 } … … 2240 2244 /*----------------------------------------------------*/ 2241 2245 int 2242 main(int argc, char **argv)2246 main(int argc, char **argv) 2243 2247 { 2244 2248 const char *path; 2245 2249 char *newPath; 2246 2250 struct timeval tv; 2247 2251 int n, i; 2248 2252 newPath = NULL; 2249 2253 path = NULL; 2250 2254 NanoVis::stdin = stdin; 2251 2255 2252 openlog("nanovis", LOG_CONS | LOG_PERROR | LOG_PID, LOG_USER); 2256 fprintf(stdout, "NanoVis %s\n", NANOVIS_VERSION); 2257 fflush(stdout); 2258 2259 /* openlog("nanovis", LOG_CONS | LOG_PERROR | LOG_PID, LOG_USER); */ 2253 2260 gettimeofday(&tv, NULL); 2254 2261 stats.start = tv; … … 2370 2377 #endif 2371 2378 } 2379 2372 2380 R2FilePath::getInstance()->setWorkingDirectory(argc, (const char**) argv); 2373 2381 vrFilePath::getInstance()->setWorkingDirectory(argc, (const char**) argv); 2374 2382 2375 2383 #ifdef XINETD 2376 signal(SIGPIPE,SIG_IGN); 2384 #ifdef notdef 2385 signal(SIGPIPE, SIG_IGN); 2386 #endif 2377 2387 NvInitService(); 2378 2388 #endif … … 2433 2443 //sprintf(prefix, "nv>height_top_view %s %g %g", volArg, min, max); 2434 2444 //ppm_write(prefix); 2435 //write( 0, "\n", 1);2445 //write(1, "\n", 1); 2436 2446 //plane_render->remove_plane(index); 2437 2447 -
branches/blt4/packages/vizservers/nanovis/nanovis.h
r1823 r2409 68 68 #include "config.h" 69 69 70 #define NANOVIS_VERSION "1.0" 70 71 71 72 //defines for the image based flow visualization -
branches/blt4/packages/vizservers/pymolproxy/pymolproxy.c
r2003 r2409 67 67 #include <sys/wait.h> 68 68 #include <time.h> 69 #include <syslog.h> 69 70 #include <unistd.h> 70 71 #include <tcl.h> … … 95 96 static Stats stats; 96 97 98 #define READTRACE 0 99 #define EXPECTTRACE 0 100 #define WRITETRACE 0 101 102 static int debug = FALSE; 103 97 104 static FILE *flog; 98 static int debug = FALSE;99 105 static FILE *scriptFile; 100 106 static int savescript = FALSE; … … 168 174 } PymolProxy; 169 175 176 #define ERROR(...) LogMessage(LOG_ERR, __FILE__, __LINE__, __VA_ARGS__) 177 #define TRACE(...) LogMessage(LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__) 178 #define WARN(...) LogMessage(LOG_WARNING, __FILE__, __LINE__, __VA_ARGS__) 179 #define INFO(...) LogMessage(LOG_INFO, __FILE__, __LINE__, __VA_ARGS__) 180 181 static const char *syslogLevels[] = { 182 "emergency", /* System is unusable */ 183 "alert", /* Action must be taken immediately */ 184 "critical", /* Critical conditions */ 185 "error", /* Error conditions */ 186 "warning", /* Warning conditions */ 187 "notice", /* Normal but significant condition */ 188 "info", /* Informational */ 189 "debug", /* Debug-level messages */ 190 }; 191 192 void 193 LogMessage(int priority, const char *path, int lineNum, const char* fmt, ...) 194 { 195 #define MSG_LEN (2047) 196 char message[MSG_LEN+1]; 197 const char *s; 198 int length; 199 va_list lst; 200 201 va_start(lst, fmt); 202 s = strrchr(path, '/'); 203 if (s == NULL) { 204 s = path; 205 } else { 206 s++; 207 } 208 length = snprintf(message, MSG_LEN, "pymolproxy (%d) %s: %s:%d ", 209 getpid(), syslogLevels[priority], s, lineNum); 210 length += vsnprintf(message + length, MSG_LEN - length, fmt, lst); 211 message[MSG_LEN] = '\0'; 212 if (debug) { 213 fprintf(stderr, "%s\n", message); 214 } else { 215 syslog(priority, message, length); 216 } 217 } 170 218 171 219 static void PollForEvents(PymolProxy *proxyPtr); 172 220 static void 173 traceTCL_VARARGS_DEF(const char *, arg1)221 Debug TCL_VARARGS_DEF(const char *, arg1) 174 222 { 175 223 if (debug) { … … 219 267 ssize_t nRead; 220 268 221 #if def notdef222 trace("Entering FillBuffer (mark=%d, fill=%d)\n", readPtr->mark,269 #if READTRACE 270 Debug("Entering FillBuffer (mark=%d, fill=%d)\n", readPtr->mark, 223 271 readPtr->fill); 224 272 #endif … … 242 290 if (nRead <= 0) { 243 291 if (errno != EAGAIN) { 244 #if def notdef245 trace("in FillBuffer: read failed %d: %s", errno, strerror(errno));246 trace("Leaving FillBuffer FAIL(read %d bytes) mark=%d, fill=%d\n",292 #if READTRACE 293 Debug("in FillBuffer: read failed %d: %s", errno, strerror(errno)); 294 Debug("Leaving FillBuffer FAIL(read %d bytes) mark=%d, fill=%d\n", 247 295 nRead, readPtr->mark, readPtr->fill); 248 296 #endif … … 252 300 } 253 301 readPtr->fill += nRead; 254 #if def notdef255 trace("Leaving FillBuffer (read %d bytes) mark=%d, fill=%d\n",302 #if READTRACE 303 Debug("Leaving FillBuffer (read %d bytes) mark=%d, fill=%d\n", 256 304 nRead, readPtr->mark, readPtr->fill); 257 305 #endif … … 265 313 int status; 266 314 267 #if def notdef268 trace("Entering GetLine (mark=%d, fill=%d)\n",readPtr->mark, readPtr->fill);315 #if READTRACE 316 Debug("Entering GetLine (mark=%d, fill=%d)\n",readPtr->mark, readPtr->fill); 269 317 #endif 270 318 status = BUFFER_OK; 271 319 for (;;) { 272 320 /* Look for the next newline (the next full line). */ 273 #if def notdef274 trace("in GetLine: mark=%d fill=%d\n", readPtr->mark, readPtr->fill);321 #if READTRACE 322 Debug("in GetLine: mark=%d fill=%d\n", readPtr->mark, readPtr->fill); 275 323 #endif 276 324 for (i = readPtr->mark; i < readPtr->fill; i++) { … … 283 331 *nBytesPtr = i - readPtr->mark; 284 332 readPtr->mark = i; 285 #if def notdef286 trace("Leaving GetLine(%.*s)\n", *nBytesPtr, p);333 #if READTRACE 334 Debug("Leaving GetLine(%.*s)\n", *nBytesPtr, p); 287 335 #endif 288 336 return p; … … 300 348 } 301 349 } 302 #if def notdef303 trace("Leaving GetLine failed to read line\n");350 #if READTRACE 351 Debug("Leaving GetLine failed to read line\n"); 304 352 #endif 305 353 *nBytesPtr = BUFFER_CONTINUE; … … 310 358 GetBytes(ReadBuffer *readPtr, char *out, int nBytes) 311 359 { 312 #if def notdef313 trace("Entering GetBytes(%d)\n", nBytes);360 #if READTRACE 361 Debug("Entering GetBytes(%d)\n", nBytes); 314 362 #endif 315 363 while (nBytes > 0) { … … 329 377 if (nBytes == 0) { 330 378 /* Received requested # bytes. */ 331 #if def notdef332 trace("Leaving GetBytes(%d)\n", nBytes);379 #if READTRACE 380 Debug("Leaving GetBytes(%d)\n", nBytes); 333 381 #endif 334 382 return BUFFER_OK; … … 339 387 return BUFFER_ERROR; 340 388 } 341 #if def notdef342 trace("in GetBytes: mark=%d fill=%d\n", readPtr->mark, readPtr->fill);389 #if READTRACE 390 Debug("in GetBytes: mark=%d fill=%d\n", readPtr->mark, readPtr->fill); 343 391 #endif 344 392 } 345 #if def notdef346 trace("Leaving GetBytes(%d)\n", nBytes);393 #if READTRACE 394 Debug("Leaving GetBytes(%d)\n", nBytes); 347 395 #endif 348 396 return BUFFER_OK; … … 376 424 sprintf(cmd, "/bin/rm -rf /tmp/pymol%d", getpid()); 377 425 if (system(cmd) < 0) { 378 trace("can't delete tmp directory: %s\n", strerror(errno));426 ERROR("can't delete tmp directory: %s\n", strerror(errno)); 379 427 } 380 428 } … … 389 437 return proxyPtr->status; 390 438 } 391 #if ndef notdef392 trace("Entering Expect(want=\"%s\", maxSize=%d)\n", match, maxSize);439 #if EXPECTTRACE 440 Debug("Entering Expect(want=\"%s\", maxSize=%d)\n", match, maxSize); 393 441 #endif 394 442 c = match[0]; … … 400 448 line = GetLine(&proxyPtr->server, &nBytes); 401 449 if (line != NULL) { 402 #if ndef notdef403 trace("pymol says (read %d bytes):%.*s", nBytes, nBytes, line);450 #if EXPECTTRACE 451 Debug("pymol says (read %d bytes):%.*s", nBytes, nBytes, line); 404 452 #endif 405 453 if ((c == line[0]) && (strncmp(line, match, length) == 0)) { … … 409 457 memcpy(out, line, nBytes); 410 458 clear_error(proxyPtr); 411 #if ndef notdef412 trace("Leaving Expect: got (%.*s)\n", nBytes, out);459 #if EXPECTTRACE 460 Debug("Leaving Expect: got (%.*s)\n", nBytes, out); 413 461 #endif 414 462 return BUFFER_OK; … … 420 468 } 421 469 } 422 trace("Leaving Expect: failed to find (%s)\n", match);470 ERROR("Leaving Expect: failed to find (%s)\n", match); 423 471 proxyPtr->error = 2; 424 472 proxyPtr->status = TCL_ERROR; … … 556 604 start = CVT2SECS(tv); 557 605 558 trace("command from client is (%s)", cmd);606 Debug("command from client is (%s)", cmd); 559 607 result = Tcl_Eval(interp, cmd); 560 608 … … 574 622 imgPtr = malloc(sizeof(Image) + dataLength); 575 623 if (imgPtr == NULL) { 576 fprintf(stderr,"can't allocate image of %lu bytes",577 624 ERROR("can't allocate image of %lu bytes", 625 (unsigned long)(sizeof(Image) + dataLength)); 578 626 abort(); 579 627 } … … 605 653 606 654 if (proxyPtr->tailPtr == NULL) { 607 trace("Should not be here: no image available to write");655 ERROR("Should not be here: no image available to write"); 608 656 return; 609 657 } … … 613 661 assert(imgPtr->nextPtr == NULL); 614 662 prevPtr = imgPtr->prevPtr; 615 #if def notdef616 trace("WriteImage: want to write %d bytes.", imgPtr->bytesLeft);663 #if WRITETRACE 664 Debug("WriteImage: want to write %d bytes.", imgPtr->bytesLeft); 617 665 #endif 618 666 for (bytesLeft = imgPtr->bytesLeft; bytesLeft > 0; /*empty*/) { 619 667 ssize_t nWritten; 620 #if def notdef621 trace("WriteImage: try to write %d bytes.", bytesLeft);668 #if WRITETRACE 669 Debug("WriteImage: try to write %d bytes.", bytesLeft); 622 670 #endif 623 671 nWritten = write(fd, imgPtr->data + imgPtr->nWritten, bytesLeft); 624 #if def notdef625 trace("WriteImage: wrote %d bytes.", nWritten);672 #if WRITETRACE 673 Debug("WriteImage: wrote %d bytes.", nWritten); 626 674 #endif 627 675 if (nWritten < 0) { 628 trace("Error writing fd(%d), %d/%s.", fd, errno,676 ERROR("Error writing fd(%d), %d/%s.", fd, errno, 629 677 strerror(errno)); 630 678 return; … … 668 716 va_end(ap); 669 717 670 trace("to-pymol>(%s) code=%d", buffer, result);718 Debug("to-pymol>(%s) code=%d", buffer, result); 671 719 script("%s\n", buffer); 672 720 … … 676 724 nWritten = write(proxyPtr->sin, buffer, length); 677 725 if (nWritten != length) { 678 trace("short write to pymol (wrote=%d, should have been %d)",726 ERROR("short write to pymol (wrote=%d, should have been %d)", 679 727 nWritten, length); 680 728 } … … 689 737 result = Expect(proxyPtr, expect, buffer, BUFSIZ); 690 738 if (result == BUFFER_ERROR) { 691 trace("timeout reading data (buffer=%s)", buffer);739 ERROR("timeout reading data (buffer=%s)", buffer); 692 740 proxyPtr->error = 1; 693 741 proxyPtr->status = TCL_ERROR; … … 801 849 Pymol(proxyPtr, "bmp -\n"); 802 850 if (Expect(proxyPtr, "bmp image follows: ", buffer, BUFSIZ) != BUFFER_OK) { 803 trace("can't find image follows line (%s)", buffer);851 ERROR("can't find image follows line (%s)", buffer); 804 852 } 805 853 if (sscanf(buffer, "bmp image follows: %d\n", &nBytes) != 1) { … … 815 863 strcpy(imgPtr->data, buffer); 816 864 if (GetBytes(&proxyPtr->server, imgPtr->data + length, nBytes)!=BUFFER_OK){ 817 trace("can't read %d bytes for \"image follows\" buffer", nBytes);865 ERROR("can't read %d bytes for \"image follows\" buffer", nBytes); 818 866 return TCL_ERROR; 819 867 } … … 1295 1343 strcpy(imgPtr->data, buffer); 1296 1344 if (GetBytes(&proxyPtr->server, imgPtr->data + length, nBytes)!=BUFFER_OK){ 1297 trace("can't read %d bytes for \"image follows\" buffer", nBytes);1345 ERROR("can't read %d bytes for \"image follows\" buffer", nBytes); 1298 1346 return TCL_ERROR; 1299 1347 } … … 1354 1402 sprintf(buffer, "nv>image %d print \"%s\" %d\n", nBytes, token, 1355 1403 proxyPtr->rockOffset); 1356 trace("header is png is (%s)\n", buffer);1404 Debug("header is png is (%s)\n", buffer); 1357 1405 length = strlen(buffer); 1358 1406 imgPtr = NewImage(proxyPtr, nBytes + length); 1359 1407 strcpy(imgPtr->data, buffer); 1360 1408 if (GetBytes(&proxyPtr->server, imgPtr->data + length, nBytes)!=BUFFER_OK){ 1361 trace("can't read %d bytes for \"image follows\" buffer", nBytes);1409 ERROR("can't read %d bytes for \"image follows\" buffer", nBytes); 1362 1410 return TCL_ERROR; 1363 1411 } … … 1924 1972 child = fork(); 1925 1973 if (child < 0) { 1926 fprintf(stderr,"can't fork process: %s\n", strerror(errno));1974 ERROR("can't fork process: %s\n", strerror(errno)); 1927 1975 return -3; 1928 1976 } … … 1951 1999 1952 2000 execvp(argv[0], argv); 1953 trace("Failed to start pymol `%s'", argv[0]);2001 ERROR("Failed to start pymol `%s'", argv[0]); 1954 2002 exit(-1); 1955 2003 } 1956 2004 stats.child = child; 2005 2006 Debug("Started %s DISPLAY=%s\n", argv[0], getenv("DISPLAY")); 1957 2007 1958 2008 /* close opposite end of pipe, these now belong to the child process */ … … 1961 2011 close(serr[1]); 1962 2012 2013 #ifdef notdef 1963 2014 signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE (e.g. nanoscale terminates)*/ 2015 #endif 1964 2016 1965 2017 memset(&proxy, 0, sizeof(PymolProxy)); … … 1973 2025 interp = Tcl_CreateInterp(); 1974 2026 if (CreateTmpDir(interp) != TCL_OK) { 1975 trace(Tcl_GetStringResult(interp));2027 ERROR(Tcl_GetStringResult(interp)); 1976 2028 } 1977 2029 Tcl_MakeSafe(interp); … … 2007 2059 stats.start = end; 2008 2060 2061 if (write(cout, "PyMol 1.0\n", 10) != 10) { 2062 ERROR("short write of signature"); 2063 } 2064 2009 2065 // Main Proxy Loop 2010 2066 // accept tcl commands from socket … … 2021 2077 status = waitpid(child, &result, WNOHANG); 2022 2078 if (status == -1) { 2023 trace("error waiting on pymol server to exit: %s", strerror(errno));2079 ERROR("error waiting on pymol server to exit: %s", strerror(errno)); 2024 2080 } else if (status == 0) { 2025 trace("attempting to signal (SIGTERM) pymol server.");2081 ERROR("attempting to signal (SIGTERM) pymol server."); 2026 2082 kill(-child, SIGTERM); // Kill process group 2027 2083 alarm(5); … … 2030 2086 2031 2087 while ((status == -1) && (errno == EINTR)) { 2032 trace("Attempting to signal (SIGKILL) pymol server.");2088 ERROR("Attempting to signal (SIGKILL) pymol server."); 2033 2089 kill(-child, SIGKILL); // Kill process group 2034 2090 alarm(10); … … 2038 2094 } 2039 2095 2040 trace("pymol server process ended (result=%d)", result);2096 ERROR("pymol server process ended (result=%d)", result); 2041 2097 DestroyTmpDir(); 2042 2098 … … 2050 2106 } 2051 2107 2052 #ifdef STANDALONE 2108 2109 static void 2110 PollForEvents(PymolProxy *proxyPtr) 2111 { 2112 Tcl_DString clientCmds; 2113 struct pollfd pollResults[4]; 2114 int flags; 2115 2116 flags = fcntl(proxyPtr->cin, F_GETFL); 2117 fcntl(proxyPtr->cin, F_SETFL, flags|O_NONBLOCK); 2118 2119 pollResults[0].fd = proxyPtr->cout; 2120 pollResults[1].fd = proxyPtr->sout; 2121 pollResults[2].fd = proxyPtr->serr; 2122 pollResults[0].events = pollResults[1].events = 2123 pollResults[2].events = POLLIN; 2124 2125 pollResults[3].fd = proxyPtr->cin; 2126 pollResults[3].events = POLLOUT; 2127 2128 InitBuffer(&proxyPtr->client, proxyPtr->cout); 2129 InitBuffer(&proxyPtr->server, proxyPtr->sout); 2130 2131 Tcl_DStringInit(&clientCmds); 2132 for (;;) { 2133 int timeout, nChannels; 2134 2135 nChannels = (proxyPtr->headPtr != NULL) ? 4 : 3; 2136 2137 #define PENDING_TIMEOUT 10 /* milliseconds. */ 2138 timeout = (proxyPtr->flags & UPDATE_PENDING) ? PENDING_TIMEOUT : -1; 2139 nChannels = poll(pollResults, nChannels, timeout); 2140 if (nChannels < 0) { 2141 ERROR("POLL ERROR: %s", strerror(errno)); 2142 continue; /* or exit? */ 2143 } 2144 2145 /* 2146 * The next two sections are to drain any leftover data in 2147 * the pymol server process' stdout or stderr. We don't want the 2148 * the pymol server to block writing to stderr or stdout. 2149 */ 2150 if (pollResults[1].revents & POLLIN) { 2151 int nBytes; 2152 char *line; 2153 2154 Debug("Reading pymol stdout\n"); 2155 /* Don't care what's in the server output buffer. */ 2156 FlushBuffer(&proxyPtr->server); 2157 line = GetLine(&proxyPtr->server, &nBytes); 2158 if (line != NULL) { 2159 Debug("STDOUT>%.*s", nBytes, line); 2160 Debug("Done with pymol stdout\n"); 2161 } else if (nBytes == BUFFER_CONTINUE) { 2162 Debug("Done with pymol stdout\n"); 2163 } else { 2164 ERROR("Failed reading pymol stdout (nBytes=%d)\n", nBytes); 2165 goto error; /* Get out on EOF or error. */ 2166 } 2167 } 2168 2169 if (pollResults[2].revents & POLLIN) { 2170 ssize_t nRead; 2171 char buf[BUFSIZ]; 2172 2173 Debug("Reading pymol stderr\n"); 2174 /* pyMol Stderr Connection: pymol standard error output */ 2175 2176 nRead = read(pollResults[2].fd, buf, BUFSIZ-1); 2177 if (nRead <= 0) { 2178 ERROR("unexpected read error from server (stderr): %s", 2179 strerror(errno)); 2180 if (errno != EINTR) { 2181 ERROR("lost connection (stderr) to pymol server."); 2182 return; 2183 } 2184 } 2185 buf[nRead] = '\0'; 2186 Debug("stderr>%s", buf); 2187 Debug("Done reading pymol stderr\n"); 2188 } 2189 2190 /* We have some descriptors ready. */ 2191 if (pollResults[0].revents & POLLIN) { 2192 Debug("Reading client stdout\n"); 2193 for (;;) { 2194 int nBytes; 2195 char *line; 2196 2197 line = GetLine(&proxyPtr->client, &nBytes); 2198 if (line != NULL) { 2199 const char *cmd; 2200 2201 Tcl_DStringAppend(&clientCmds, line, nBytes); 2202 cmd = Tcl_DStringValue(&clientCmds); 2203 if (Tcl_CommandComplete(cmd)) { 2204 /* May execute more than one command. */ 2205 ExecuteCommand(proxyPtr->interp, cmd); 2206 Tcl_DStringSetLength(&clientCmds, 0); 2207 } 2208 continue; 2209 } 2210 if (nBytes == BUFFER_CONTINUE) { 2211 break; 2212 } 2213 ERROR("Failed reading client stdout (nBytes=%d)\n", nBytes); 2214 goto error; /* Get out on EOF or error. */ 2215 } 2216 Debug("done with client stdout\n"); 2217 } 2218 /* 2219 * Write the currently queued image if there is one. 2220 * 2221 * We want to transmit the current image back to the client. But if 2222 * the client's busy (e.g. sending us another command), there's a 2223 * chance we'll deadlock. Therefore, the file descriptor is 2224 * non-blocking and we write only what we can. Must be careful not to 2225 * refresh the image until we're done. 2226 */ 2227 2228 /* Handle all the pending setting changes now. */ 2229 UpdateSettings(proxyPtr); 2230 2231 /* Write the current image buffer. */ 2232 if (proxyPtr->headPtr == NULL) { 2233 /* We might want to refresh the image if we're not currently 2234 * transmitting an image back to the client. The image will be 2235 * refreshed after the image has been completely transmitted. */ 2236 if ((nChannels == 0) || (proxyPtr->flags & FORCE_UPDATE)) { 2237 if (proxyPtr->flags & UPDATE_PENDING) { 2238 Tcl_Eval(proxyPtr->interp, "bmp"); 2239 proxyPtr->flags &= ~UPDATE_PENDING; 2240 } 2241 proxyPtr->flags &= ~FORCE_UPDATE; 2242 continue; 2243 } 2244 } 2245 if ((proxyPtr->headPtr != NULL) && 2246 (pollResults[3].revents & POLLOUT)) { 2247 WriteImage(proxyPtr, pollResults[3].fd); 2248 } 2249 } 2250 error: 2251 Tcl_DStringFree(&clientCmds); 2252 return; 2253 } 2053 2254 2054 2255 int … … 2072 2273 } 2073 2274 2074 #endif2075 2076 2077 static void2078 PollForEvents(PymolProxy *proxyPtr)2079 {2080 Tcl_DString clientCmds;2081 struct pollfd pollResults[4];2082 int flags;2083 2084 flags = fcntl(proxyPtr->cin, F_GETFL);2085 fcntl(proxyPtr->cin, F_SETFL, flags|O_NONBLOCK);2086 2087 pollResults[0].fd = proxyPtr->cout;2088 pollResults[1].fd = proxyPtr->sout;2089 pollResults[2].fd = proxyPtr->serr;2090 pollResults[0].events = pollResults[1].events =2091 pollResults[2].events = POLLIN;2092 2093 pollResults[3].fd = proxyPtr->cin;2094 pollResults[3].events = POLLOUT;2095 2096 InitBuffer(&proxyPtr->client, proxyPtr->cout);2097 InitBuffer(&proxyPtr->server, proxyPtr->sout);2098 2099 Tcl_DStringInit(&clientCmds);2100 for (;;) {2101 int timeout, nChannels;2102 2103 nChannels = (proxyPtr->headPtr != NULL) ? 4 : 3;2104 2105 #define PENDING_TIMEOUT 10 /* milliseconds. */2106 timeout = (proxyPtr->flags & UPDATE_PENDING) ? PENDING_TIMEOUT : -1;2107 nChannels = poll(pollResults, nChannels, timeout);2108 if (nChannels < 0) {2109 trace("POLL ERROR: %s", strerror(errno));2110 continue; /* or exit? */2111 }2112 2113 /*2114 * The next two sections are to drain any leftover data in2115 * the pymol server process' stdout or stderr. We don't want the2116 * the pymol server to block writing to stderr or stdout.2117 */2118 if (pollResults[1].revents & POLLIN) {2119 int nBytes;2120 char *line;2121 2122 trace("Reading pymol stdout\n");2123 /* Don't care what's in the server output buffer. */2124 FlushBuffer(&proxyPtr->server);2125 line = GetLine(&proxyPtr->server, &nBytes);2126 if (line != NULL) {2127 trace("STDOUT>%.*s", nBytes, line);2128 trace("Done with pymol stdout\n");2129 } else if (nBytes == BUFFER_CONTINUE) {2130 trace("Done with pymol stdout\n");2131 } else {2132 trace("Failed reading pymol stdout (nBytes=%d)\n", nBytes);2133 goto error; /* Get out on EOF or error. */2134 }2135 }2136 2137 if (pollResults[2].revents & POLLIN) {2138 ssize_t nRead;2139 char buf[BUFSIZ];2140 2141 trace("Reading pymol stderr\n");2142 /* pyMol Stderr Connection: pymol standard error output */2143 2144 nRead = read(pollResults[2].fd, buf, BUFSIZ-1);2145 if (nRead <= 0) {2146 trace("unexpected read error from server (stderr): %s",2147 strerror(errno));2148 if (errno != EINTR) {2149 trace("lost connection (stderr) to pymol server.");2150 return;2151 }2152 }2153 buf[nRead] = '\0';2154 trace("stderr>%s", buf);2155 trace("Done reading pymol stderr\n");2156 }2157 2158 /* We have some descriptors ready. */2159 if (pollResults[0].revents & POLLIN) {2160 trace("Reading client stdout\n");2161 for (;;) {2162 int nBytes;2163 char *line;2164 2165 line = GetLine(&proxyPtr->client, &nBytes);2166 if (line != NULL) {2167 const char *cmd;2168 2169 Tcl_DStringAppend(&clientCmds, line, nBytes);2170 cmd = Tcl_DStringValue(&clientCmds);2171 if (Tcl_CommandComplete(cmd)) {2172 /* May execute more than one command. */2173 ExecuteCommand(proxyPtr->interp, cmd);2174 Tcl_DStringSetLength(&clientCmds, 0);2175 }2176 continue;2177 }2178 if (nBytes == BUFFER_CONTINUE) {2179 break;2180 }2181 trace("Failed reading client stdout (nBytes=%d)\n", nBytes);2182 goto error; /* Get out on EOF or error. */2183 }2184 trace("done with client stdout\n");2185 }2186 /*2187 * Write the currently queued image if there is one.2188 *2189 * We want to transmit the current image back to the client. But if2190 * the client's busy (e.g. sending us another command), there's a2191 * chance we'll deadlock. Therefore, the file descriptor is2192 * non-blocking and we write only what we can. Must be careful not to2193 * refresh the image until we're done.2194 */2195 2196 /* Handle all the pending setting changes now. */2197 UpdateSettings(proxyPtr);2198 2199 /* Write the current image buffer. */2200 if (proxyPtr->headPtr == NULL) {2201 /* We might want to refresh the image if we're not currently2202 * transmitting an image back to the client. The image will be2203 * refreshed after the image has been completely transmitted. */2204 if ((nChannels == 0) || (proxyPtr->flags & FORCE_UPDATE)) {2205 if (proxyPtr->flags & UPDATE_PENDING) {2206 Tcl_Eval(proxyPtr->interp, "bmp");2207 proxyPtr->flags &= ~UPDATE_PENDING;2208 }2209 proxyPtr->flags &= ~FORCE_UPDATE;2210 continue;2211 }2212 }2213 if ((proxyPtr->headPtr != NULL) &&2214 (pollResults[3].revents & POLLOUT)) {2215 WriteImage(proxyPtr, pollResults[3].fd);2216 }2217 }2218 error:2219 Tcl_DStringFree(&clientCmds);2220 return;2221 }2222 -
branches/blt4/packages/vizservers/vtkvis/ColorMap.cpp
r2322 r2409 248 248 * \brief Perform linear interpolation of two color control points 249 249 */ 250 void ColorMap::lerp(double *result, const ControlPoint& cp1, const ControlPoint& cp2, double value) 250 void ColorMap::lerp(double *result, 251 const ControlPoint& cp1, 252 const ControlPoint& cp2, 253 double value) 251 254 { 252 255 double factor = (value - cp1.value) / (cp2.value - cp1.value); … … 259 262 * \brief Perform linear interpolation of two opacity control points 260 263 */ 261 void ColorMap::lerp(double *result, const OpacityControlPoint& cp1, const OpacityControlPoint& cp2, double value) 264 void ColorMap::lerp(double *result, 265 const OpacityControlPoint& cp1, 266 const OpacityControlPoint& cp2, 267 double value) 262 268 { 263 269 double factor = (value - cp1.value) / (cp2.value - cp1.value); -
branches/blt4/packages/vizservers/vtkvis/Makefile.in
r2322 r2409 23 23 MKDIR_P = @MKDIR_P@ 24 24 25 GL_LIB_SPEC = -lGL 25 GL_LIB_SPEC = -lGL -lm 26 26 27 27 TCL_LIB_SPEC = @TCL_LIB_SPEC@ … … 32 32 VTK_INC_SPEC = @VTK_INC_SPEC@ 33 33 34 LD_RUN_PATH = $(VTK_LIB_DIR) 34 LD_RUN_PATH = $(VTK_LIB_DIR):$(libdir) 35 35 36 36 LIBS = \ … … 51 51 USE_OFFSCREEN_RENDERING = yes 52 52 53 EXTRA_CFLAGS = -Wall -Wno-deprecated #vtk uses deprecated strstream header (instead of sstream) 53 #vtk uses deprecated strstream header (instead of sstream) 54 EXTRA_CFLAGS = -Wall -Wno-deprecated 54 55 DEFINES = 55 56 ifdef DEBUG … … 129 130 ColorMap.o: ColorMap.h RpMolecule.h Trace.h 130 131 PPMWriter.o: PPMWriter.h Trace.h 131 RpContour2D.o: RpContour2D.h RpVtk DataSet.h Trace.h132 RpContour3D.o: RpContour3D.h RpVtk DataSet.h Trace.h133 RpGlyphs.o: RpGlyphs.h RpVtk DataSet.h ColorMap.h Trace.h134 RpHeightMap.o: RpHeightMap.h RpVtk DataSet.h Trace.h135 RpLIC.o: RpLIC.h RpVtk DataSet.h Trace.h RpVtkRenderServer.h136 RpMolecule.o: RpMolecule.h RpMoleculeData.h RpVtk DataSet.h ColorMap.h Trace.h137 RpPolyData.o: RpPolyData.h RpVtk DataSet.h Trace.h138 RpPseudoColor.o: RpPseudoColor.h RpVtk DataSet.h Trace.h139 RpStreamlines.o: RpStreamlines.h RpVtk DataSet.h Trace.h140 RpVolume.o: RpVolume.h RpVtk DataSet.h ColorMap.h Trace.h132 RpContour2D.o: RpContour2D.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h 133 RpContour3D.o: RpContour3D.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h 134 RpGlyphs.o: RpGlyphs.h RpVtkGraphicsObject.h RpVtkDataSet.h ColorMap.h Trace.h 135 RpHeightMap.o: RpHeightMap.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h 136 RpLIC.o: RpLIC.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h RpVtkRenderServer.h 137 RpMolecule.o: RpMolecule.h RpMoleculeData.h RpVtkGraphicsObject.h RpVtkDataSet.h ColorMap.h Trace.h 138 RpPolyData.o: RpPolyData.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h 139 RpPseudoColor.o: RpPseudoColor.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h 140 RpStreamlines.o: RpStreamlines.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h 141 RpVolume.o: RpVolume.h RpVtkGraphicsObject.h RpVtkDataSet.h ColorMap.h Trace.h 141 142 RpVtkDataSet.o: RpVtkDataSet.h Trace.h 142 143 RpVtkRenderer.o: RpVtkRenderer.h RpVtkDataSet.h RpContour2D.h RpContour3D.h RpGlyphs.h RpHeightMap.h RpLIC.h RpMolecule.h RpPolyData.h RpPseudoColor.h RpStreamlines.h RpVolume.h ColorMap.h Trace.h -
branches/blt4/packages/vizservers/vtkvis/RpContour2D.cpp
r2322 r2409 26 26 27 27 Contour2D::Contour2D() : 28 _dataSet(NULL), 29 _numContours(0), 30 _edgeWidth(1.0f), 31 _opacity(1.0) 28 VtkGraphicsObject(), 29 _numContours(0) 32 30 { 33 31 _dataRange[0] = 0; 34 32 _dataRange[1] = 1; 35 _edgeColor[0] = 0;36 _edgeColor[1] = 0;37 _edgeColor[2] = 0;38 33 } 39 34 … … 68 63 69 64 /** 70 * \brief Returns the DataSet this Contour2D renders71 */72 DataSet *Contour2D::getDataSet()73 {74 return _dataSet;75 }76 77 /**78 * \brief Get the VTK Prop for the contour lines79 */80 vtkProp *Contour2D::getProp()81 {82 return _contourActor;83 }84 85 /**86 65 * \brief Create and initialize a VTK Prop to render isolines 87 66 */ 88 67 void Contour2D::initProp() 89 68 { 90 if (_contourActor == NULL) { 91 _contourActor = vtkSmartPointer<vtkActor>::New(); 92 _contourActor->GetProperty()->EdgeVisibilityOn(); 93 _contourActor->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]); 94 _contourActor->GetProperty()->SetLineWidth(_edgeWidth); 95 _contourActor->GetProperty()->SetOpacity(_opacity); 96 _contourActor->GetProperty()->SetAmbient(.2); 97 _contourActor->GetProperty()->LightingOff(); 69 if (_prop == NULL) { 70 _prop = vtkSmartPointer<vtkActor>::New(); 71 vtkProperty *property = getActor()->GetProperty(); 72 property->EdgeVisibilityOn(); 73 property->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]); 74 property->SetLineWidth(_edgeWidth); 75 property->SetOpacity(_opacity); 76 property->SetAmbient(.2); 77 property->LightingOff(); 98 78 } 99 79 } … … 189 169 _contourMapper->SetResolveCoincidentTopologyToPolygonOffset(); 190 170 _contourMapper->SetInputConnection(_contourFilter->GetOutputPort()); 191 _contourActor->SetMapper(_contourMapper);171 getActor()->SetMapper(_contourMapper); 192 172 } 193 173 … … 263 243 264 244 /** 265 * \brief Turn on/off rendering of this contour set266 */267 void Contour2D::setVisibility(bool state)268 {269 if (_contourActor != NULL) {270 _contourActor->SetVisibility((state ? 1 : 0));271 }272 }273 274 /**275 * \brief Get visibility state of the contour set276 *277 * \return Is contour set visible?278 */279 bool Contour2D::getVisibility() const280 {281 if (_contourActor == NULL) {282 return false;283 } else {284 return (_contourActor->GetVisibility() != 0);285 }286 }287 288 /**289 * \brief Set opacity used to render contour lines290 */291 void Contour2D::setOpacity(double opacity)292 {293 _opacity = opacity;294 if (_contourActor != NULL)295 _contourActor->GetProperty()->SetOpacity(opacity);296 }297 298 /**299 * \brief Set RGB color of contour lines300 */301 void Contour2D::setEdgeColor(float color[3])302 {303 _edgeColor[0] = color[0];304 _edgeColor[1] = color[1];305 _edgeColor[2] = color[2];306 if (_contourActor != NULL)307 _contourActor->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);308 }309 310 /**311 * \brief Set pixel width of contour lines (may be a no-op)312 */313 void Contour2D::setEdgeWidth(float edgeWidth)314 {315 _edgeWidth = edgeWidth;316 if (_contourActor != NULL)317 _contourActor->GetProperty()->SetLineWidth(_edgeWidth);318 }319 320 /**321 245 * \brief Set a group of world coordinate planes to clip rendering 322 246 * … … 329 253 } 330 254 } 331 332 /**333 * \brief Turn on/off lighting of this object334 */335 void Contour2D::setLighting(bool state)336 {337 if (_contourActor != NULL)338 _contourActor->GetProperty()->SetLighting((state ? 1 : 0));339 } -
branches/blt4/packages/vizservers/vtkvis/RpContour2D.h
r2302 r2409 17 17 #include <vector> 18 18 19 #include "RpVtk DataSet.h"19 #include "RpVtkGraphicsObject.h" 20 20 21 21 namespace Rappture { … … 25 25 * \brief 2D Contour lines (isolines) 26 26 */ 27 class Contour2D {27 class Contour2D : public VtkGraphicsObject { 28 28 public: 29 29 Contour2D(); 30 30 virtual ~Contour2D(); 31 31 32 void setDataSet(DataSet *dataset); 32 virtual const char *getClassName() const 33 { 34 return "Contour2D"; 35 } 33 36 34 DataSet *getDataSet();37 virtual void setDataSet(DataSet *dataset); 35 38 36 v tkProp *getProp();39 virtual void setClippingPlanes(vtkPlaneCollection *planes); 37 40 38 41 void setContours(int numContours); … … 46 49 const std::vector<double>& getContourList() const; 47 50 48 void setVisibility(bool state);49 50 bool getVisibility() const;51 52 void setOpacity(double opacity);53 54 void setEdgeColor(float color[3]);55 56 void setEdgeWidth(float edgeWidth);57 58 void setClippingPlanes(vtkPlaneCollection *planes);59 60 void setLighting(bool state);61 62 51 private: 63 void initProp(); 64 void update(); 65 66 DataSet *_dataSet; 52 virtual void initProp(); 53 virtual void update(); 67 54 68 55 int _numContours; … … 70 57 double _dataRange[2]; 71 58 72 float _edgeColor[3];73 float _edgeWidth;74 double _opacity;75 59 vtkSmartPointer<vtkContourFilter> _contourFilter; 76 60 vtkSmartPointer<vtkPolyDataMapper> _contourMapper; 77 vtkSmartPointer<vtkActor> _contourActor;78 61 }; 79 62 -
branches/blt4/packages/vizservers/vtkvis/RpContour3D.cpp
r2322 r2409 26 26 27 27 Contour3D::Contour3D() : 28 _dataSet(NULL), 29 _numContours(0), 30 _edgeWidth(1.0f), 31 _opacity(1.0), 32 _lighting(true) 28 VtkGraphicsObject(), 29 _numContours(0) 33 30 { 34 31 _dataRange[0] = 0; 35 32 _dataRange[1] = 1; 36 _color[0] = 0; 37 _color[1] = 0; 38 _color[2] = 1; 39 _edgeColor[0] = 0; 40 _edgeColor[1] = 0; 41 _edgeColor[2] = 0; 33 _color[0] = 0.0f; 34 _color[1] = 0.0f; 35 _color[2] = 1.0f; 42 36 } 43 37 … … 72 66 73 67 /** 74 * \brief Returns the DataSet this Contour3D renders75 */76 DataSet *Contour3D::getDataSet()77 {78 return _dataSet;79 }80 81 /**82 * \brief Get the VTK Prop for the isosurfaces83 */84 vtkProp *Contour3D::getProp()85 {86 return _contourActor;87 }88 89 /**90 68 * \brief Create and initialize a VTK Prop to render isosurfaces 91 69 */ 92 70 void Contour3D::initProp() 93 71 { 94 if (_contourActor == NULL) { 95 _contourActor = vtkSmartPointer<vtkActor>::New(); 96 _contourActor->GetProperty()->EdgeVisibilityOff(); 97 _contourActor->GetProperty()->SetColor(_color[0], _color[1], _color[2]); 98 _contourActor->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]); 99 _contourActor->GetProperty()->SetLineWidth(_edgeWidth); 100 _contourActor->GetProperty()->SetOpacity(_opacity); 101 _contourActor->GetProperty()->SetAmbient(.2); 72 if (_prop == NULL) { 73 _prop = vtkSmartPointer<vtkActor>::New(); 74 vtkProperty *property = getActor()->GetProperty(); 75 property->EdgeVisibilityOff(); 76 property->SetColor(_color[0], _color[1], _color[2]); 77 property->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]); 78 property->SetLineWidth(_edgeWidth); 79 property->SetOpacity(_opacity); 80 property->SetAmbient(.2); 102 81 if (!_lighting) 103 _contourActor->GetProperty()->LightingOff();82 property->LightingOff(); 104 83 } 105 84 } … … 216 195 _contourMapper->SetResolveCoincidentTopologyToPolygonOffset(); 217 196 _contourMapper->SetInputConnection(_contourFilter->GetOutputPort()); 218 _contourActor->SetMapper(_contourMapper);197 getActor()->SetMapper(_contourMapper); 219 198 } 220 199 … … 317 296 318 297 /** 319 * \brief Turn on/off rendering of this contour set320 */321 void Contour3D::setVisibility(bool state)322 {323 if (_contourActor != NULL) {324 _contourActor->SetVisibility((state ? 1 : 0));325 }326 }327 328 /**329 * \brief Get visibility state of the contour set330 *331 * \return Is contour set visible?332 */333 bool Contour3D::getVisibility() const334 {335 if (_contourActor == NULL) {336 return false;337 } else {338 return (_contourActor->GetVisibility() != 0);339 }340 }341 342 /**343 * \brief Set opacity used to render isosurfaces344 */345 void Contour3D::setOpacity(double opacity)346 {347 _opacity = opacity;348 if (_contourActor != NULL)349 _contourActor->GetProperty()->SetOpacity(opacity);350 }351 352 /**353 * \brief Switch between wireframe and surface representations354 */355 void Contour3D::setWireframe(bool state)356 {357 if (_contourActor != NULL) {358 if (state) {359 _contourActor->GetProperty()->SetRepresentationToWireframe();360 _contourActor->GetProperty()->LightingOff();361 } else {362 _contourActor->GetProperty()->SetRepresentationToSurface();363 _contourActor->GetProperty()->SetLighting((_lighting ? 1 : 0));364 }365 }366 }367 368 /**369 * \brief Set RGB color of isosurfaces370 */371 void Contour3D::setColor(float color[3])372 {373 _color[0] = color[0];374 _color[1] = color[1];375 _color[2] = color[2];376 if (_contourActor != NULL)377 _contourActor->GetProperty()->SetColor(_color[0], _color[1], _color[2]);378 }379 380 /**381 * \brief Turn on/off rendering of mesh edges382 */383 void Contour3D::setEdgeVisibility(bool state)384 {385 if (_contourActor != NULL) {386 _contourActor->GetProperty()->SetEdgeVisibility((state ? 1 : 0));387 }388 }389 390 /**391 * \brief Set RGB color of isosurface edges392 */393 void Contour3D::setEdgeColor(float color[3])394 {395 _edgeColor[0] = color[0];396 _edgeColor[1] = color[1];397 _edgeColor[2] = color[2];398 if (_contourActor != NULL)399 _contourActor->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);400 }401 402 /**403 * \brief Set pixel width of contour lines (may be a no-op)404 */405 void Contour3D::setEdgeWidth(float edgeWidth)406 {407 _edgeWidth = edgeWidth;408 if (_contourActor != NULL)409 _contourActor->GetProperty()->SetLineWidth(_edgeWidth);410 }411 412 /**413 298 * \brief Set a group of world coordinate planes to clip rendering 414 299 * … … 421 306 } 422 307 } 423 424 /**425 * \brief Turn on/off lighting of this object426 */427 void Contour3D::setLighting(bool state)428 {429 _lighting = state;430 if (_contourActor != NULL)431 _contourActor->GetProperty()->SetLighting((state ? 1 : 0));432 } -
branches/blt4/packages/vizservers/vtkvis/RpContour3D.h
r2302 r2409 18 18 #include <vector> 19 19 20 #include "RpVtk DataSet.h"20 #include "RpVtkGraphicsObject.h" 21 21 22 22 namespace Rappture { … … 26 26 * \brief 3D Contour isosurfaces (geometry) 27 27 */ 28 class Contour3D {28 class Contour3D : public VtkGraphicsObject { 29 29 public: 30 30 Contour3D(); 31 31 virtual ~Contour3D(); 32 32 33 void setDataSet(DataSet *dataset); 33 virtual const char *getClassName() const 34 { 35 return "Contour3D"; 36 } 34 37 35 DataSet *getDataSet();38 virtual void setDataSet(DataSet *dataset); 36 39 37 v tkProp *getProp();40 virtual void setClippingPlanes(vtkPlaneCollection *planes); 38 41 39 42 void setContours(int numContours); … … 47 50 const std::vector<double>& getContourList() const; 48 51 49 void setVisibility(bool state);50 51 bool getVisibility() const;52 53 void setOpacity(double opacity);54 55 void setWireframe(bool state);56 57 52 void setLookupTable(vtkLookupTable *lut); 58 53 59 54 vtkLookupTable *getLookupTable(); 60 55 61 void setColor(float color[3]);62 63 void setEdgeVisibility(bool state);64 65 void setEdgeColor(float color[3]);66 67 void setEdgeWidth(float edgeWidth);68 69 void setClippingPlanes(vtkPlaneCollection *planes);70 71 void setLighting(bool state);72 73 56 private: 74 void initProp(); 75 void update(); 76 77 DataSet *_dataSet; 57 virtual void initProp(); 58 virtual void update(); 78 59 79 60 int _numContours; … … 81 62 double _dataRange[2]; 82 63 83 float _color[3];84 float _edgeColor[3];85 float _edgeWidth;86 double _opacity;87 bool _lighting;88 89 64 vtkSmartPointer<vtkContourFilter> _contourFilter; 90 65 vtkSmartPointer<vtkLookupTable> _lut; 91 66 vtkSmartPointer<vtkPolyDataMapper> _contourMapper; 92 vtkSmartPointer<vtkActor> _contourActor;93 67 }; 94 68 -
branches/blt4/packages/vizservers/vtkvis/RpGlyphs.cpp
r2322 r2409 27 27 28 28 Glyphs::Glyphs() : 29 _dataSet(NULL), 30 _opacity(1.0), 31 _lighting(true), 29 VtkGraphicsObject(), 32 30 _glyphShape(ARROW), 33 _scaleFactor(1.0) 34 { 31 _scaleFactor(1.0), 32 _colorMode(COLOR_BY_SCALAR) 33 { 34 _faceCulling = true; 35 35 } 36 36 37 37 Glyphs::~Glyphs() 38 38 { 39 }40 41 /**42 * \brief Get the VTK Prop for the Glyphs43 */44 vtkProp *Glyphs::getProp()45 {46 return _prop;47 }48 49 /**50 * \brief Create and initialize a VTK Prop to render Glyphs51 */52 void Glyphs::initProp()53 {54 if (_prop == NULL) {55 _prop = vtkSmartPointer<vtkActor>::New();56 _prop->GetProperty()->EdgeVisibilityOff();57 _prop->GetProperty()->SetOpacity(_opacity);58 _prop->GetProperty()->SetAmbient(.2);59 if (!_lighting)60 _prop->GetProperty()->LightingOff();61 }62 }63 64 /**65 * \brief Specify input DataSet66 *67 * The DataSet must be a PolyData point set68 * with vectors and/or scalars69 */70 void Glyphs::setDataSet(DataSet *dataSet)71 {72 if (_dataSet != dataSet) {73 _dataSet = dataSet;74 update();75 }76 }77 78 /**79 * \brief Returns the DataSet this Glyphs renders80 */81 DataSet *Glyphs::getDataSet()82 {83 return _dataSet;84 39 } 85 40 … … 127 82 return; 128 83 } 84 85 if (_glyphShape == ICOSAHEDRON || 86 _glyphShape == TETRAHEDRON) { 87 // These shapes are created with front faces pointing inside 88 setCullFace(CULL_FRONT); 89 } else { 90 setCullFace(CULL_BACK); 91 } 92 129 93 if (_glyphGenerator != NULL) { 130 94 _glyphGenerator->SetSourceConnection(_glyphSource->GetOutputPort()); … … 142 106 143 107 vtkDataSet *ds = _dataSet->getVtkDataSet(); 144 double dataRange[2];145 _dataSet->getDataRange(dataRange);146 108 147 109 if (_glyphGenerator == NULL) { 148 110 _glyphGenerator = vtkSmartPointer<vtkGlyph3D>::New(); 149 111 } 112 113 initProp(); 150 114 151 115 setGlyphShape(_glyphShape); … … 180 144 181 145 if (ds->GetPointData()->GetScalars() == NULL) { 146 TRACE("Setting color mode to vector magnitude"); 182 147 _glyphGenerator->SetColorModeToColorByVector(); 183 } else { 148 _colorMode = COLOR_BY_VECTOR; 149 } else { 150 TRACE("Setting color mode to scalar"); 184 151 _glyphGenerator->SetColorModeToColorByScalar(); 185 } 152 _colorMode = COLOR_BY_SCALAR; 153 } 186 154 if (_glyphShape == SPHERE) { 187 155 _glyphGenerator->OrientOff(); … … 212 180 213 181 if (ds->GetPointData()->GetScalars() == NULL) { 214 _pdMapper->UseLookupTableScalarRangeOff();215 } else {182 double dataRange[2]; 183 _dataSet->getVectorMagnitudeRange(dataRange); 216 184 _lut->SetRange(dataRange); 217 _pdMapper->UseLookupTableScalarRangeOn(); 218 } 219 185 //_pdMapper->SetScalarModeToUsePointFieldData(); 186 //_pdMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName()); 187 } else { 188 double dataRange[2]; 189 _dataSet->getDataRange(dataRange); 190 _lut->SetRange(dataRange); 191 //_pdMapper->SetScalarModeToDefault(); 192 } 193 194 //_lut->SetVectorModeToMagnitude(); 220 195 _pdMapper->SetLookupTable(_lut); 221 222 initProp(); 223 224 _prop->SetMapper(_pdMapper); 196 _pdMapper->UseLookupTableScalarRangeOn(); 197 198 getActor()->SetMapper(_pdMapper); 225 199 _pdMapper->Update(); 200 } 201 202 /** 203 * \brief Control how glyphs are scaled 204 */ 205 void Glyphs::setScalingMode(ScalingMode mode) 206 { 207 if (_glyphGenerator != NULL) { 208 switch (mode) { 209 case SCALE_BY_SCALAR: 210 _glyphGenerator->SetScaleModeToScaleByScalar(); 211 _glyphGenerator->ScalingOn(); 212 break; 213 case SCALE_BY_VECTOR: 214 _glyphGenerator->SetScaleModeToScaleByVector(); 215 _glyphGenerator->ScalingOn(); 216 break; 217 case SCALE_BY_VECTOR_COMPONENTS: 218 _glyphGenerator->SetScaleModeToScaleByVectorComponents(); 219 _glyphGenerator->ScalingOn(); 220 break; 221 case SCALING_OFF: 222 default: 223 _glyphGenerator->SetScaleModeToDataScalingOff(); 224 _glyphGenerator->ScalingOff(); 225 } 226 _pdMapper->Update(); 227 } 228 } 229 230 /** 231 * \brief Control how glyphs are colored 232 */ 233 void Glyphs::setColorMode(ColorMode mode) 234 { 235 _colorMode = mode; 236 if (_glyphGenerator != NULL) { 237 switch (mode) { 238 case COLOR_BY_SCALE: 239 _glyphGenerator->SetColorModeToColorByScale(); 240 _pdMapper->ScalarVisibilityOn(); 241 break; 242 case COLOR_BY_VECTOR: { 243 _glyphGenerator->SetColorModeToColorByVector(); 244 _pdMapper->ScalarVisibilityOn(); 245 double dataRange[2]; 246 _dataSet->getVectorMagnitudeRange(dataRange); 247 _lut->SetRange(dataRange); 248 } 249 break; 250 case COLOR_BY_SCALAR: { 251 _glyphGenerator->SetColorModeToColorByScalar(); 252 _pdMapper->ScalarVisibilityOn(); 253 double dataRange[2]; 254 _dataSet->getDataRange(dataRange); 255 _lut->SetRange(dataRange); 256 } 257 break; 258 case COLOR_CONSTANT: 259 default: 260 _pdMapper->ScalarVisibilityOff(); 261 } 262 _pdMapper->Update(); 263 } 226 264 } 227 265 … … 257 295 } 258 296 297 switch (_colorMode) { 298 case COLOR_BY_VECTOR: { 299 double dataRange[2]; 300 _dataSet->getVectorMagnitudeRange(dataRange); 301 _lut->SetRange(dataRange); 302 } 303 break; 304 case COLOR_BY_SCALAR: 305 default: { 306 double dataRange[2]; 307 _dataSet->getDataRange(dataRange); 308 _lut->SetRange(dataRange); 309 } 310 break; 311 } 312 259 313 if (_pdMapper != NULL) { 260 314 _pdMapper->SetLookupTable(_lut); 261 315 } 262 }263 264 /**265 * \brief Turn on/off rendering of this Glyphs266 */267 void Glyphs::setVisibility(bool state)268 {269 if (_prop != NULL) {270 _prop->SetVisibility((state ? 1 : 0));271 }272 }273 274 /**275 * \brief Get visibility state of the Glyphs276 *277 * \return Are the glyphs visible?278 */279 bool Glyphs::getVisibility()280 {281 if (_prop == NULL) {282 return false;283 } else {284 return (_prop->GetVisibility() != 0);285 }286 }287 288 /**289 * \brief Set opacity used to render the Glyphs290 */291 void Glyphs::setOpacity(double opacity)292 {293 _opacity = opacity;294 if (_prop != NULL)295 _prop->GetProperty()->SetOpacity(opacity);296 }297 298 /**299 * \brief Get opacity used to render the Glyphs300 */301 double Glyphs::getOpacity()302 {303 return _opacity;304 316 } 305 317 … … 315 327 } 316 328 } 317 318 /**319 * \brief Turn on/off lighting of this object320 */321 void Glyphs::setLighting(bool state)322 {323 _lighting = state;324 if (_prop != NULL)325 _prop->GetProperty()->SetLighting((state ? 1 : 0));326 } -
branches/blt4/packages/vizservers/vtkvis/RpGlyphs.h
r2322 r2409 18 18 #include <vtkPlaneCollection.h> 19 19 20 #include "RpVtk DataSet.h"20 #include "RpVtkGraphicsObject.h" 21 21 #include "ColorMap.h" 22 22 … … 26 26 /** 27 27 * \brief Oriented and scaled 3D glyph shapes 28 * 29 * The DataSet must be a PolyData point set 30 * with vectors and/or scalars 28 31 */ 29 class Glyphs {32 class Glyphs : public VtkGraphicsObject { 30 33 public: 31 34 enum GlyphShape { … … 40 43 TETRAHEDRON 41 44 }; 45 enum ScalingMode { 46 SCALE_BY_SCALAR, 47 SCALE_BY_VECTOR, 48 SCALE_BY_VECTOR_COMPONENTS, 49 SCALING_OFF 50 }; 51 enum ColorMode { 52 COLOR_BY_SCALE, 53 COLOR_BY_SCALAR, 54 COLOR_BY_VECTOR, 55 COLOR_CONSTANT 56 }; 42 57 43 58 Glyphs(); 44 59 virtual ~Glyphs(); 45 60 46 void setDataSet(DataSet *dataset); 61 virtual const char *getClassName() const 62 { 63 return "Glyphs"; 64 } 47 65 48 DataSet *getDataSet();66 virtual void setClippingPlanes(vtkPlaneCollection *planes); 49 67 50 vtkProp *getProp(); 68 void setScalingMode(ScalingMode mode); 69 70 void setColorMode(ColorMode mode); 51 71 52 72 void setGlyphShape(GlyphShape shape); … … 58 78 vtkLookupTable *getLookupTable(); 59 79 60 void setOpacity(double opacity);61 62 double getOpacity();63 64 void setVisibility(bool state);65 66 bool getVisibility();67 68 void setClippingPlanes(vtkPlaneCollection *planes);69 70 void setLighting(bool state);71 72 80 private: 73 void initProp(); 74 void update(); 75 76 DataSet *_dataSet; 77 78 double _opacity; 79 bool _lighting; 81 virtual void update(); 80 82 81 83 GlyphShape _glyphShape; 82 84 double _scaleFactor; 85 ColorMode _colorMode; 83 86 84 87 vtkSmartPointer<vtkLookupTable> _lut; 85 vtkSmartPointer<vtkActor> _prop;86 88 vtkSmartPointer<vtkGlyph3D> _glyphGenerator; 87 89 vtkSmartPointer<vtkPolyDataAlgorithm> _glyphSource; -
branches/blt4/packages/vizservers/vtkvis/RpHeightMap.cpp
r2322 r2409 36 36 37 37 HeightMap::HeightMap() : 38 _dataSet(NULL),38 VtkGraphicsObject(), 39 39 _numContours(0), 40 _edgeWidth(1.0),41 40 _contourEdgeWidth(1.0), 42 _opacity(1.0),43 41 _warpScale(1.0), 44 42 _sliceAxis(Z_AXIS), … … 47 45 _dataRange[0] = 0.0; 48 46 _dataRange[1] = 1.0; 49 _edgeColor[0] = 0.0; 50 _edgeColor[1] = 0.0; 51 _edgeColor[2] = 0.0; 52 _contourEdgeColor[0] = 1.0; 53 _contourEdgeColor[1] = 0.0; 54 _contourEdgeColor[2] = 0.0; 47 _contourEdgeColor[0] = 1.0f; 48 _contourEdgeColor[1] = 0.0f; 49 _contourEdgeColor[2] = 0.0f; 55 50 } 56 51 … … 107 102 108 103 /** 109 * \brief Returns the DataSet this HeightMap renders 110 */ 111 DataSet *HeightMap::getDataSet() 112 { 113 return _dataSet; 104 * \brief Create and initialize VTK Props to render the colormapped dataset 105 */ 106 void HeightMap::initProp() 107 { 108 if (_dsActor == NULL) { 109 _dsActor = vtkSmartPointer<vtkActor>::New(); 110 _dsActor->GetProperty()->SetOpacity(_opacity); 111 _dsActor->GetProperty()->SetEdgeColor(_edgeColor[0], 112 _edgeColor[1], 113 _edgeColor[2]); 114 _dsActor->GetProperty()->SetLineWidth(_edgeWidth); 115 _dsActor->GetProperty()->EdgeVisibilityOff(); 116 _dsActor->GetProperty()->SetAmbient(.2); 117 _dsActor->GetProperty()->LightingOn(); 118 } 119 if (_contourActor == NULL) { 120 _contourActor = vtkSmartPointer<vtkActor>::New(); 121 _contourActor->GetProperty()->SetOpacity(_opacity); 122 _contourActor->GetProperty()->SetEdgeColor(_contourEdgeColor[0], 123 _contourEdgeColor[1], 124 _contourEdgeColor[2]); 125 _contourActor->GetProperty()->SetLineWidth(_contourEdgeWidth); 126 _contourActor->GetProperty()->EdgeVisibilityOn(); 127 _contourActor->GetProperty()->SetAmbient(.2); 128 _contourActor->GetProperty()->LightingOff(); 129 } 114 130 } 115 131 … … 372 388 _dsActor->SetMapper(_dsMapper); 373 389 374 if (_prop s== NULL) {375 _prop s = vtkSmartPointer<vtkPropAssembly>::New();376 _props->AddPart(_dsActor);377 _props->AddPart(_contourActor);390 if (_prop == NULL) { 391 _prop = vtkSmartPointer<vtkAssembly>::New(); 392 getAssembly()->AddPart(_dsActor); 393 getAssembly()->AddPart(_contourActor); 378 394 } 379 395 … … 599 615 600 616 /** 601 * \brief Get the VTK Prop for the colormapped dataset602 */603 vtkProp *HeightMap::getProp()604 {605 return _props;606 }607 608 /**609 * \brief Create and initialize VTK Props to render the colormapped dataset610 */611 void HeightMap::initProp()612 {613 if (_dsActor == NULL) {614 _dsActor = vtkSmartPointer<vtkActor>::New();615 _dsActor->GetProperty()->SetOpacity(_opacity);616 _dsActor->GetProperty()->SetEdgeColor(_edgeColor[0],617 _edgeColor[1],618 _edgeColor[2]);619 _dsActor->GetProperty()->SetLineWidth(_edgeWidth);620 _dsActor->GetProperty()->EdgeVisibilityOff();621 _dsActor->GetProperty()->SetAmbient(.2);622 _dsActor->GetProperty()->LightingOn();623 }624 if (_contourActor == NULL) {625 _contourActor = vtkSmartPointer<vtkActor>::New();626 _contourActor->GetProperty()->SetOpacity(_opacity);627 _contourActor->GetProperty()->SetEdgeColor(_contourEdgeColor[0],628 _contourEdgeColor[1],629 _contourEdgeColor[2]);630 _contourActor->GetProperty()->SetLineWidth(_contourEdgeWidth);631 _contourActor->GetProperty()->EdgeVisibilityOn();632 _contourActor->GetProperty()->SetAmbient(.2);633 _contourActor->GetProperty()->LightingOff();634 }635 }636 637 /**638 617 * \brief Get the VTK colormap lookup table in use 639 618 */ … … 728 707 729 708 /** 730 * \brief Turn on/off rendering of this HeightMap 731 */ 732 void HeightMap::setVisibility(bool state) 733 { 734 if (_dsActor != NULL) { 735 _dsActor->SetVisibility((state ? 1 : 0)); 736 } 737 if (_contourActor != NULL) { 738 _contourActor->SetVisibility((state ? 1 : 0)); 739 } 740 } 741 742 /** 743 * \brief Get visibility state of the HeightMap 744 * 745 * \return Is HeightMap visible? 746 */ 747 bool HeightMap::getVisibility() 748 { 749 if (_dsActor != NULL && 750 _dsActor->GetVisibility() != 0) { 751 return true; 752 } else if (_contourActor != NULL && 753 _contourActor->GetVisibility() != 0) { 754 return true; 755 } 756 return false; 757 } 758 759 /** 760 * \brief Set opacity used to render the HeightMap 761 */ 762 void HeightMap::setOpacity(double opacity) 763 { 764 _opacity = opacity; 765 if (_dsActor != NULL) { 766 _dsActor->GetProperty()->SetOpacity(opacity); 767 } 768 if (_contourActor != NULL) { 769 _contourActor->GetProperty()->SetOpacity(opacity); 770 } 709 * \brief Turn on/off lighting of this object 710 */ 711 void HeightMap::setLighting(bool state) 712 { 713 if (_dsActor != NULL) 714 _dsActor->GetProperty()->SetLighting((state ? 1 : 0)); 771 715 } 772 716 … … 852 796 } 853 797 854 /**855 * \brief Turn on/off lighting of this object856 */857 void HeightMap::setLighting(bool state)858 {859 if (_dsActor != NULL)860 _dsActor->GetProperty()->SetLighting((state ? 1 : 0));861 } -
branches/blt4/packages/vizservers/vtkvis/RpHeightMap.h
r2302 r2409 20 20 #include <vtkExtractVOI.h> 21 21 #include <vtkWarpScalar.h> 22 #include <vtk PropAssembly.h>22 #include <vtkAssembly.h> 23 23 #include <vtkPolyData.h> 24 24 25 25 #include <vector> 26 26 27 #include "RpVtk DataSet.h"27 #include "RpVtkGraphicsObject.h" 28 28 29 29 namespace Rappture { … … 33 33 * \brief Color-mapped plot of data set 34 34 */ 35 class HeightMap {35 class HeightMap : public VtkGraphicsObject { 36 36 public: 37 37 enum Axis { … … 44 44 virtual ~HeightMap(); 45 45 46 void setDataSet(DataSet *dataset); 46 virtual const char *getClassName() const 47 { 48 return "HeightMap"; 49 } 47 50 48 DataSet *getDataSet();51 virtual void setDataSet(DataSet *dataset); 49 52 50 vtkProp *getProp(); 53 virtual void setLighting(bool state); 54 55 virtual void setEdgeVisibility(bool state); 56 57 virtual void setEdgeColor(float color[3]); 58 59 virtual void setEdgeWidth(float edgeWidth); 60 61 virtual void setClippingPlanes(vtkPlaneCollection *planes); 51 62 52 63 void selectVolumeSlice(Axis axis, double ratio); … … 68 79 vtkLookupTable *getLookupTable(); 69 80 70 void setVisibility(bool state);71 72 bool getVisibility();73 74 void setOpacity(double opacity);75 76 void setEdgeVisibility(bool state);77 78 void setEdgeColor(float color[3]);79 80 void setEdgeWidth(float edgeWidth);81 82 81 void setContourVisibility(bool state); 83 82 … … 86 85 void setContourEdgeWidth(float edgeWidth); 87 86 88 void setClippingPlanes(vtkPlaneCollection *planes); 87 private: 88 virtual void initProp(); 89 virtual void update(); 89 90 90 void setLighting(bool state);91 92 private:93 91 vtkAlgorithmOutput *initWarp(vtkAlgorithmOutput *input); 94 92 vtkAlgorithmOutput *initWarp(vtkPolyData *input); 95 void initProp();96 void update();97 98 DataSet * _dataSet;99 93 100 94 int _numContours; … … 106 100 float _edgeWidth; 107 101 float _contourEdgeWidth; 108 double _opacity;109 102 double _warpScale; 110 103 double _dataScale; … … 122 115 vtkSmartPointer<vtkActor> _dsActor; 123 116 vtkSmartPointer<vtkActor> _contourActor; 124 vtkSmartPointer<vtkPropAssembly> _props;125 117 }; 126 118 -
branches/blt4/packages/vizservers/vtkvis/RpLIC.cpp
r2322 r2409 26 26 27 27 LIC::LIC() : 28 _dataSet(NULL), 29 _edgeWidth(1.0f), 30 _opacity(1.0), 31 _lighting(false), 28 VtkGraphicsObject(), 32 29 _sliceAxis(Z_AXIS) 33 30 { 34 _edgeColor[0] = 0.0f;35 _edgeColor[1] = 0.0f;36 _edgeColor[2] = 0.0f;37 31 } 38 32 39 33 LIC::~LIC() 40 34 { 41 }42 43 /**44 * \brief Get the VTK Prop for the LIC45 */46 vtkProp *LIC::getProp()47 {48 return _prop;49 35 } 50 36 … … 53 39 if (_prop == NULL) { 54 40 _prop = vtkSmartPointer<vtkActor>::New(); 55 _prop->GetProperty()->SetOpacity(_opacity); 56 _prop->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]); 57 _prop->GetProperty()->SetLineWidth(_edgeWidth); 58 _prop->GetProperty()->EdgeVisibilityOff(); 59 _prop->GetProperty()->SetAmbient(.2); 41 vtkProperty *property = getActor()->GetProperty(); 42 property->SetOpacity(_opacity); 43 property->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]); 44 property->SetLineWidth(_edgeWidth); 45 property->EdgeVisibilityOff(); 46 property->SetAmbient(.2); 60 47 if (!_lighting) 61 _prop->GetProperty()->LightingOff(); 62 } 63 } 64 65 /** 66 * \brief Specify input DataSet 67 * 68 * The DataSet must contain vectors 69 */ 70 void LIC::setDataSet(DataSet *dataSet) 71 { 72 if (_dataSet != dataSet) { 73 _dataSet = dataSet; 74 update(); 75 } 76 } 77 78 /** 79 * \brief Returns the DataSet this LIC renders 80 */ 81 DataSet *LIC::getDataSet() 82 { 83 return _dataSet; 48 property->LightingOff(); 49 } 84 50 } 85 51 … … 224 190 225 191 initProp(); 226 _prop->SetMapper(_mapper);192 getActor()->SetMapper(_mapper); 227 193 228 194 _mapper->Update(); … … 369 335 370 336 /** 371 * \brief Turn on/off rendering of this LIC372 */373 void LIC::setVisibility(bool state)374 {375 if (_prop != NULL) {376 _prop->SetVisibility((state ? 1 : 0));377 }378 }379 380 /**381 * \brief Get visibility state of the LIC382 *383 * \return Is the LIC texture visible?384 */385 bool LIC::getVisibility()386 {387 if (_prop == NULL) {388 return false;389 } else {390 return (_prop->GetVisibility() != 0);391 }392 }393 394 /**395 * \brief Set opacity used to render the LIC396 */397 void LIC::setOpacity(double opacity)398 {399 _opacity = opacity;400 if (_prop != NULL) {401 _prop->GetProperty()->SetOpacity(opacity);402 }403 }404 405 /**406 * \brief Get opacity used to render the LIC407 */408 double LIC::getOpacity()409 {410 return _opacity;411 }412 413 /**414 * \brief Turn on/off rendering of edges415 */416 void LIC::setEdgeVisibility(bool state)417 {418 if (_prop != NULL) {419 _prop->GetProperty()->SetEdgeVisibility((state ? 1 : 0));420 }421 }422 423 /**424 * \brief Set RGB color of edges425 */426 void LIC::setEdgeColor(float color[3])427 {428 _edgeColor[0] = color[0];429 _edgeColor[1] = color[1];430 _edgeColor[2] = color[2];431 if (_prop != NULL)432 _prop->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);433 }434 435 /**436 * \brief Set pixel width of edges (may be a no-op)437 */438 void LIC::setEdgeWidth(float edgeWidth)439 {440 _edgeWidth = edgeWidth;441 if (_prop != NULL)442 _prop->GetProperty()->SetLineWidth(_edgeWidth);443 }444 445 /**446 337 * \brief Set a group of world coordinate planes to clip rendering 447 338 * … … 454 345 } 455 346 } 456 457 /**458 * \brief Turn on/off lighting of this object459 */460 void LIC::setLighting(bool state)461 {462 _lighting = state;463 if (_prop != NULL)464 _prop->GetProperty()->SetLighting((state ? 1 : 0));465 } -
branches/blt4/packages/vizservers/vtkvis/RpLIC.h
r2322 r2409 19 19 #include <vtkLookupTable.h> 20 20 21 #include "RpVtk DataSet.h"21 #include "RpVtkGraphicsObject.h" 22 22 23 23 namespace Rappture { … … 26 26 /** 27 27 * \brief Line Integral Convolution visualization of vector fields 28 * 29 * The DataSet must contain vectors 28 30 */ 29 class LIC {31 class LIC : public VtkGraphicsObject { 30 32 public: 31 33 enum Axis { … … 38 40 virtual ~LIC(); 39 41 40 void setDataSet(DataSet *dataset); 41 42 DataSet *getDataSet(); 43 44 vtkProp *getProp(); 42 virtual const char *getClassName() const 43 { 44 return "LIC"; 45 } 46 47 virtual void setClippingPlanes(vtkPlaneCollection *planes); 45 48 46 49 void selectVolumeSlice(Axis axis, double ratio); … … 50 53 vtkLookupTable *getLookupTable(); 51 54 52 void setOpacity(double opacity); 55 private: 56 virtual void initProp(); 57 virtual void update(); 53 58 54 double getOpacity();55 56 void setVisibility(bool state);57 58 bool getVisibility();59 60 void setEdgeVisibility(bool state);61 62 void setEdgeColor(float color[3]);63 64 void setEdgeWidth(float edgeWidth);65 66 void setClippingPlanes(vtkPlaneCollection *planes);67 68 void setLighting(bool state);69 70 private:71 void initProp();72 void update();73 74 DataSet *_dataSet;75 76 float _edgeColor[3];77 float _edgeWidth;78 double _opacity;79 bool _lighting;80 59 Axis _sliceAxis; 81 60 82 61 vtkSmartPointer<vtkLookupTable> _lut; 83 vtkSmartPointer<vtkActor> _prop;84 62 vtkSmartPointer<vtkExtractVOI> _volumeSlicer; 85 63 vtkSmartPointer<vtkProbeFilter> _probeFilter; -
branches/blt4/packages/vizservers/vtkvis/RpMolecule.cpp
r2322 r2409 26 26 27 27 Molecule::Molecule() : 28 _dataSet(NULL), 29 _edgeWidth(1.0), 30 _opacity(1.0), 31 _lighting(true), 28 VtkGraphicsObject(), 32 29 _atomScaling(NO_ATOM_SCALING) 33 30 { 34 _edgeColor[0] = 0.0; 35 _edgeColor[1] = 0.0; 36 _edgeColor[2] = 0.0; 31 _faceCulling = true; 37 32 } 38 33 … … 48 43 49 44 /** 50 * \brief Get the VTK Prop for the Molecule51 */52 vtkProp *Molecule::getProp()53 {54 return _props;55 }56 57 /**58 45 * \brief Create and initialize VTK Props to render a Molecule 59 46 */ … … 62 49 if (_atomProp == NULL) { 63 50 _atomProp = vtkSmartPointer<vtkActor>::New(); 51 if (_faceCulling && _opacity == 1.0) 52 setCulling(_atomProp->GetProperty(), true); 64 53 _atomProp->GetProperty()->EdgeVisibilityOff(); 65 54 _atomProp->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]); … … 72 61 if (_bondProp == NULL) { 73 62 _bondProp = vtkSmartPointer<vtkActor>::New(); 63 if (_faceCulling && _opacity == 1.0) 64 setCulling(_bondProp->GetProperty(), true); 74 65 _bondProp->GetProperty()->EdgeVisibilityOff(); 75 66 _bondProp->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]); … … 80 71 _bondProp->GetProperty()->LightingOff(); 81 72 } 82 if (_props == NULL) { 83 _props = vtkSmartPointer<vtkPropAssembly>::New(); 84 } 85 } 86 87 /** 88 * \brief Specify input DataSet (PolyData) 89 * 90 * The DataSet must be a PolyData object. Vertices are used for atom 91 * positions and Lines are used to draw bonds. A scalar field and 92 * color map may be supplied to color the atoms and bonds. 93 */ 94 void Molecule::setDataSet(DataSet *dataSet) 95 { 96 if (_dataSet != dataSet) { 97 _dataSet = dataSet; 98 update(); 99 } 100 } 101 102 /** 103 * \brief Returns the DataSet this Molecule renders 104 */ 105 DataSet *Molecule::getDataSet() 106 { 107 return _dataSet; 73 if (_prop == NULL) { 74 _prop = vtkSmartPointer<vtkAssembly>::New(); 75 } 108 76 } 109 77 … … 194 162 _bondMapper->SetInputConnection(tuber->GetOutputPort()); 195 163 _bondProp->SetMapper(_bondMapper); 196 _props->AddPart(_bondProp);164 getAssembly()->AddPart(_bondProp); 197 165 } 198 166 if (pd->GetNumberOfVerts() > 0) { … … 217 185 _atomMapper->SetInputConnection(_glypher->GetOutputPort()); 218 186 _atomProp->SetMapper(_atomMapper); 219 _props->AddPart(_atomProp);187 getAssembly()->AddPart(_atomProp); 220 188 } 221 189 } else { … … 259 227 260 228 /** 261 * \brief Turn on/off rendering of this Molecule262 */263 void Molecule::setVisibility(bool state)264 {265 if (_props != NULL) {266 _props->SetVisibility((state ? 1 : 0));267 }268 }269 270 /**271 229 * \brief Turn on/off rendering of the atoms 272 230 */ … … 286 244 _bondProp->SetVisibility((state ? 1 : 0)); 287 245 } 288 }289 290 /**291 * \brief Get visibility state of the Molecule292 *293 * \return Is mesh visible?294 */295 bool Molecule::getVisibility()296 {297 if (_props == NULL) {298 return false;299 } else {300 return (_props->GetVisibility() != 0);301 }302 }303 304 /**305 * \brief Set opacity used to render the Molecule306 */307 void Molecule::setOpacity(double opacity)308 {309 _opacity = opacity;310 if (_atomProp != NULL)311 _atomProp->GetProperty()->SetOpacity(opacity);312 if (_bondProp != NULL)313 _bondProp->GetProperty()->SetOpacity(opacity);314 }315 316 /**317 * \brief Switch between wireframe and surface representations318 */319 void Molecule::setWireframe(bool state)320 {321 if (_atomProp != NULL) {322 if (state) {323 _atomProp->GetProperty()->SetRepresentationToWireframe();324 _atomProp->GetProperty()->LightingOff();325 } else {326 _atomProp->GetProperty()->SetRepresentationToSurface();327 _atomProp->GetProperty()->SetLighting((_lighting ? 1 : 0));328 }329 }330 if (_bondProp != NULL) {331 if (state) {332 _bondProp->GetProperty()->SetRepresentationToWireframe();333 _bondProp->GetProperty()->LightingOff();334 } else {335 _bondProp->GetProperty()->SetRepresentationToSurface();336 _bondProp->GetProperty()->SetLighting((_lighting ? 1 : 0));337 }338 }339 }340 341 /**342 * \brief Turn on/off rendering of mesh edges343 */344 void Molecule::setEdgeVisibility(bool state)345 {346 if (_atomProp != NULL) {347 _atomProp->GetProperty()->SetEdgeVisibility((state ? 1 : 0));348 }349 if (_bondProp != NULL) {350 _bondProp->GetProperty()->SetEdgeVisibility((state ? 1 : 0));351 }352 }353 354 /**355 * \brief Set RGB color of polygon edges356 */357 void Molecule::setEdgeColor(float color[3])358 {359 _edgeColor[0] = color[0];360 _edgeColor[1] = color[1];361 _edgeColor[2] = color[2];362 if (_atomProp != NULL)363 _atomProp->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);364 if (_bondProp != NULL)365 _bondProp->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);366 }367 368 /**369 * \brief Set pixel width of polygon edges (may be a no-op)370 */371 void Molecule::setEdgeWidth(float edgeWidth)372 {373 _edgeWidth = edgeWidth;374 if (_atomProp != NULL)375 _atomProp->GetProperty()->SetLineWidth(_edgeWidth);376 if (_bondProp != NULL)377 _bondProp->GetProperty()->SetLineWidth(_edgeWidth);378 246 } 379 247 … … 394 262 395 263 /** 396 * \brief Turn on/off lighting of this object 397 */ 398 void Molecule::setLighting(bool state) 399 { 400 _lighting = state; 401 if (_atomProp != NULL) 402 _atomProp->GetProperty()->SetLighting((state ? 1 : 0)); 403 if (_bondProp != NULL) 404 _bondProp->GetProperty()->SetLighting((state ? 1 : 0)); 405 } 406 264 * \brief Set the radius type used for scaling atoms 265 */ 407 266 void Molecule::setAtomScaling(AtomScaling state) 408 267 { -
branches/blt4/packages/vizservers/vtkvis/RpMolecule.h
r2322 r2409 13 13 #include <vtkPolyDataMapper.h> 14 14 #include <vtkActor.h> 15 #include <vtk PropAssembly.h>15 #include <vtkAssembly.h> 16 16 #include <vtkGlyph3D.h> 17 17 18 18 #include "ColorMap.h" 19 #include "RpVtk DataSet.h"19 #include "RpVtkGraphicsObject.h" 20 20 21 21 namespace Rappture { … … 33 33 * "element," it will be color-mapped as a standard scalar field. 34 34 */ 35 class Molecule {35 class Molecule : public VtkGraphicsObject { 36 36 public: 37 37 enum AtomScaling { … … 45 45 virtual ~Molecule(); 46 46 47 void setDataSet(DataSet *dataset); 47 virtual const char *getClassName() const 48 { 49 return "Molecule"; 50 } 48 51 49 DataSet *getDataSet(); 50 51 vtkProp *getProp(); 52 virtual void setClippingPlanes(vtkPlaneCollection *planes); 52 53 53 54 void setLookupTable(vtkLookupTable *lut); … … 61 62 void setBondVisibility(bool state); 62 63 63 void setVisibility(bool state);64 65 bool getVisibility();66 67 void setOpacity(double opacity);68 69 void setWireframe(bool state);70 71 void setEdgeVisibility(bool state);72 73 void setEdgeColor(float color[3]);74 75 void setEdgeWidth(float edgeWidth);76 77 void setClippingPlanes(vtkPlaneCollection *planes);78 79 void setLighting(bool state);80 81 64 static ColorMap *createElementColorMap(); 82 65 83 66 private: 84 v oid initProp();85 v oid update();67 virtual void initProp(); 68 virtual void update(); 86 69 87 70 static void addRadiusArray(vtkDataSet *dataSet, AtomScaling scaling); 88 71 89 DataSet *_dataSet;90 91 float _edgeColor[3];92 float _edgeWidth;93 double _opacity;94 bool _lighting;95 72 AtomScaling _atomScaling; 96 73 97 74 vtkSmartPointer<vtkLookupTable> _lut; 98 vtkSmartPointer<vtkPropAssembly> _props;99 75 vtkSmartPointer<vtkActor> _atomProp; 100 76 vtkSmartPointer<vtkActor> _bondProp; -
branches/blt4/packages/vizservers/vtkvis/RpPolyData.cpp
r2322 r2409 24 24 25 25 PolyData::PolyData() : 26 _dataSet(NULL), 27 _edgeWidth(1.0), 28 _opacity(1.0), 29 _lighting(true) 26 VtkGraphicsObject() 30 27 { 31 _color[0] = 0.0; 32 _color[1] = 0.0; 33 _color[2] = 1.0; 34 _edgeColor[0] = 0.0; 35 _edgeColor[1] = 0.0; 36 _edgeColor[2] = 0.0; 28 _color[0] = 0.0f; 29 _color[1] = 0.0f; 30 _color[2] = 1.0f; 37 31 } 38 32 … … 48 42 49 43 /** 50 * \brief Get the VTK Prop for the mesh51 */52 vtkProp *PolyData::getProp()53 {54 return _pdActor;55 }56 57 /**58 44 * \brief Create and initialize a VTK Prop to render a mesh 59 45 */ 60 46 void PolyData::initProp() 61 47 { 62 if (_pdActor == NULL) { 63 _pdActor = vtkSmartPointer<vtkActor>::New(); 64 _pdActor->GetProperty()->EdgeVisibilityOn(); 65 _pdActor->GetProperty()->SetColor(_color[0], _color[1], _color[2]); 66 _pdActor->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]); 67 _pdActor->GetProperty()->SetLineWidth(_edgeWidth); 68 _pdActor->GetProperty()->SetOpacity(_opacity); 69 _pdActor->GetProperty()->SetAmbient(.2); 48 if (_prop == NULL) { 49 _prop = vtkSmartPointer<vtkActor>::New(); 50 vtkProperty *property = getActor()->GetProperty(); 51 property->EdgeVisibilityOn(); 52 property->SetColor(_color[0], _color[1], _color[2]); 53 property->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]); 54 property->SetLineWidth(_edgeWidth); 55 property->SetOpacity(_opacity); 56 property->SetAmbient(.2); 70 57 if (!_lighting) 71 _pdActor->GetProperty()->LightingOff();58 property->LightingOff(); 72 59 } 73 }74 75 /**76 * \brief Specify input DataSet (PolyData)77 *78 * The DataSet must be a PolyData object79 */80 void PolyData::setDataSet(DataSet *dataSet)81 {82 if (_dataSet != dataSet) {83 _dataSet = dataSet;84 update();85 }86 }87 88 /**89 * \brief Returns the DataSet this PolyData renders90 */91 DataSet *PolyData::getDataSet()92 {93 return _dataSet;94 60 } 95 61 … … 125 91 vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New(); 126 92 mesher->SetInput(pd); 93 mesher->ReleaseDataFlagOn(); 94 _pdMapper->SetInputConnection(mesher->GetOutputPort()); 127 95 #if defined(DEBUG) && defined(WANT_TRACE) 128 96 mesher->Update(); … … 134 102 outpd->GetNumberOfStrips()); 135 103 #endif 136 _pdMapper->SetInputConnection(mesher->GetOutputPort());137 104 } else { 138 105 vtkSmartPointer<vtkDelaunay3D> mesher = vtkSmartPointer<vtkDelaunay3D>::New(); 139 106 mesher->SetInput(pd); 107 mesher->ReleaseDataFlagOn(); 140 108 // Delaunay3D returns an UnstructuredGrid, so feed it through a surface filter 141 109 // to get the grid boundary as a PolyData 142 110 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 143 111 gf->SetInputConnection(mesher->GetOutputPort()); 112 gf->ReleaseDataFlagOn(); 144 113 _pdMapper->SetInputConnection(gf->GetOutputPort()); 145 114 } … … 150 119 } else { 151 120 // DataSet is NOT a vtkPolyData 152 WARN("DataSet is not a PolyData");121 TRACE("DataSet is not a PolyData"); 153 122 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 154 123 gf->SetInput(ds); 124 gf->ReleaseDataFlagOn(); 155 125 _pdMapper->SetInputConnection(gf->GetOutputPort()); 156 126 } 157 127 158 128 initProp(); 159 _pdActor->SetMapper(_pdMapper);129 getActor()->SetMapper(_pdMapper); 160 130 _pdMapper->Update(); 161 }162 163 /**164 * \brief Turn on/off rendering of this mesh165 */166 void PolyData::setVisibility(bool state)167 {168 if (_pdActor != NULL) {169 _pdActor->SetVisibility((state ? 1 : 0));170 }171 }172 173 /**174 * \brief Get visibility state of the mesh175 *176 * \return Is mesh visible?177 */178 bool PolyData::getVisibility()179 {180 if (_pdActor == NULL) {181 return false;182 } else {183 return (_pdActor->GetVisibility() != 0);184 }185 }186 187 /**188 * \brief Set opacity used to render the mesh189 */190 void PolyData::setOpacity(double opacity)191 {192 _opacity = opacity;193 if (_pdActor != NULL)194 _pdActor->GetProperty()->SetOpacity(opacity);195 }196 197 /**198 * \brief Switch between wireframe and surface representations199 */200 void PolyData::setWireframe(bool state)201 {202 if (_pdActor != NULL) {203 if (state) {204 _pdActor->GetProperty()->SetRepresentationToWireframe();205 _pdActor->GetProperty()->LightingOff();206 } else {207 _pdActor->GetProperty()->SetRepresentationToSurface();208 _pdActor->GetProperty()->SetLighting((_lighting ? 1 : 0));209 }210 }211 }212 213 /**214 * \brief Set RGB color of polygon faces215 */216 void PolyData::setColor(float color[3])217 {218 _color[0] = color[0];219 _color[1] = color[1];220 _color[2] = color[2];221 if (_pdActor != NULL)222 _pdActor->GetProperty()->SetColor(_color[0], _color[1], _color[2]);223 }224 225 /**226 * \brief Turn on/off rendering of mesh edges227 */228 void PolyData::setEdgeVisibility(bool state)229 {230 if (_pdActor != NULL) {231 _pdActor->GetProperty()->SetEdgeVisibility((state ? 1 : 0));232 }233 }234 235 /**236 * \brief Set RGB color of polygon edges237 */238 void PolyData::setEdgeColor(float color[3])239 {240 _edgeColor[0] = color[0];241 _edgeColor[1] = color[1];242 _edgeColor[2] = color[2];243 if (_pdActor != NULL)244 _pdActor->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);245 }246 247 /**248 * \brief Set pixel width of polygon edges (may be a no-op)249 */250 void PolyData::setEdgeWidth(float edgeWidth)251 {252 _edgeWidth = edgeWidth;253 if (_pdActor != NULL)254 _pdActor->GetProperty()->SetLineWidth(_edgeWidth);255 131 } 256 132 … … 267 143 } 268 144 269 /**270 * \brief Turn on/off lighting of this object271 */272 void PolyData::setLighting(bool state)273 {274 _lighting = state;275 if (_pdActor != NULL)276 _pdActor->GetProperty()->SetLighting((state ? 1 : 0));277 } -
branches/blt4/packages/vizservers/vtkvis/RpPolyData.h
r2322 r2409 13 13 #include <vtkActor.h> 14 14 15 #include "RpVtkGraphicsObject.h" 15 16 #include "RpVtkDataSet.h" 16 17 … … 20 21 /** 21 22 * \brief VTK Mesh (Polygon data) 23 * 24 * The DataSet must be a PolyData object 22 25 */ 23 class PolyData {26 class PolyData : public VtkGraphicsObject { 24 27 public: 25 28 PolyData(); 26 29 virtual ~PolyData(); 27 30 28 void setDataSet(DataSet *dataset); 31 virtual const char *getClassName() const 32 { 33 return "PolyData"; 34 } 29 35 30 DataSet *getDataSet(); 31 32 vtkProp *getProp(); 33 34 void setVisibility(bool state); 35 36 bool getVisibility(); 37 38 void setOpacity(double opacity); 39 40 void setWireframe(bool state); 41 42 void setColor(float color[3]); 43 44 void setEdgeVisibility(bool state); 45 46 void setEdgeColor(float color[3]); 47 48 void setEdgeWidth(float edgeWidth); 49 50 void setClippingPlanes(vtkPlaneCollection *planes); 51 52 void setLighting(bool state); 36 virtual void setClippingPlanes(vtkPlaneCollection *planes); 53 37 54 38 private: 55 v oid initProp();56 v oid update();39 virtual void initProp(); 40 virtual void update(); 57 41 58 DataSet *_dataSet;59 60 float _color[3];61 float _edgeColor[3];62 float _edgeWidth;63 double _opacity;64 bool _lighting;65 42 vtkSmartPointer<vtkPolyDataMapper> _pdMapper; 66 vtkSmartPointer<vtkActor> _pdActor;67 43 }; 68 44 -
branches/blt4/packages/vizservers/vtkvis/RpPseudoColor.cpp
r2322 r2409 29 29 30 30 PseudoColor::PseudoColor() : 31 _dataSet(NULL), 32 _edgeWidth(1.0), 33 _opacity(1.0), 34 _lighting(true) 35 { 36 _edgeColor[0] = 0.0; 37 _edgeColor[1] = 0.0; 38 _edgeColor[2] = 0.0; 31 VtkGraphicsObject() 32 { 39 33 } 40 34 … … 50 44 51 45 /** 52 * \brief Specify input DataSet with scalars to colormap 53 * 54 * Currently the DataSet must be image data (2D uniform grid) 55 */ 56 void PseudoColor::setDataSet(DataSet *dataSet) 57 { 58 if (_dataSet != dataSet) { 59 _dataSet = dataSet; 60 update(); 61 } 62 } 63 64 /** 65 * \brief Returns the DataSet this PseudoColor renders 66 */ 67 DataSet *PseudoColor::getDataSet() 68 { 69 return _dataSet; 46 * \brief Create and initialize a VTK Prop to render the colormapped dataset 47 */ 48 void PseudoColor::initProp() 49 { 50 if (_prop == NULL) { 51 _prop = vtkSmartPointer<vtkActor>::New(); 52 vtkProperty *property = getActor()->GetProperty(); 53 property->SetOpacity(_opacity); 54 property->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]); 55 property->SetLineWidth(_edgeWidth); 56 property->EdgeVisibilityOff(); 57 property->SetAmbient(.2); 58 if (!_lighting) 59 property->LightingOff(); 60 } 70 61 } 71 62 … … 170 161 171 162 initProp(); 172 _dsActor->SetMapper(_dsMapper);163 getActor()->SetMapper(_dsMapper); 173 164 _dsMapper->Update(); 174 }175 176 /**177 * \brief Get the VTK Prop for the colormapped dataset178 */179 vtkProp *PseudoColor::getProp()180 {181 return _dsActor;182 }183 184 /**185 * \brief Create and initialize a VTK Prop to render the colormapped dataset186 */187 void PseudoColor::initProp()188 {189 if (_dsActor == NULL) {190 _dsActor = vtkSmartPointer<vtkActor>::New();191 _dsActor->GetProperty()->SetOpacity(_opacity);192 _dsActor->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);193 _dsActor->GetProperty()->SetLineWidth(_edgeWidth);194 _dsActor->GetProperty()->EdgeVisibilityOff();195 _dsActor->GetProperty()->SetAmbient(.2);196 if (!_lighting)197 _dsActor->GetProperty()->LightingOff();198 }199 165 } 200 166 … … 225 191 226 192 /** 227 * \brief Turn on/off rendering of this colormapped dataset228 */229 void PseudoColor::setVisibility(bool state)230 {231 if (_dsActor != NULL) {232 _dsActor->SetVisibility((state ? 1 : 0));233 }234 }235 236 /**237 * \brief Get visibility state of the colormapped dataset238 *239 * \return Is PseudoColor visible?240 */241 bool PseudoColor::getVisibility()242 {243 if (_dsActor == NULL) {244 return false;245 } else {246 return (_dsActor->GetVisibility() != 0);247 }248 }249 250 /**251 * \brief Set opacity used to render the colormapped dataset252 */253 void PseudoColor::setOpacity(double opacity)254 {255 _opacity = opacity;256 if (_dsActor != NULL)257 _dsActor->GetProperty()->SetOpacity(opacity);258 }259 260 /**261 * \brief Switch between wireframe and surface representations262 */263 void PseudoColor::setWireframe(bool state)264 {265 if (_dsActor != NULL) {266 if (state) {267 _dsActor->GetProperty()->SetRepresentationToWireframe();268 _dsActor->GetProperty()->LightingOff();269 } else {270 _dsActor->GetProperty()->SetRepresentationToSurface();271 _dsActor->GetProperty()->SetLighting((_lighting ? 1 : 0));272 }273 }274 }275 276 /**277 * \brief Turn on/off rendering of mesh edges278 */279 void PseudoColor::setEdgeVisibility(bool state)280 {281 if (_dsActor != NULL) {282 _dsActor->GetProperty()->SetEdgeVisibility((state ? 1 : 0));283 }284 }285 286 /**287 * \brief Set RGB color of polygon edges288 */289 void PseudoColor::setEdgeColor(float color[3])290 {291 _edgeColor[0] = color[0];292 _edgeColor[1] = color[1];293 _edgeColor[2] = color[2];294 if (_dsActor != NULL)295 _dsActor->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);296 }297 298 /**299 * \brief Set pixel width of polygon edges (may be a no-op)300 */301 void PseudoColor::setEdgeWidth(float edgeWidth)302 {303 _edgeWidth = edgeWidth;304 if (_dsActor != NULL)305 _dsActor->GetProperty()->SetLineWidth(_edgeWidth);306 }307 308 /**309 193 * \brief Set a group of world coordinate planes to clip rendering 310 194 * … … 317 201 } 318 202 } 319 320 /**321 * \brief Turn on/off lighting of this object322 */323 void PseudoColor::setLighting(bool state)324 {325 _lighting = state;326 if (_dsActor != NULL)327 _dsActor->GetProperty()->SetLighting((state ? 1 : 0));328 } -
branches/blt4/packages/vizservers/vtkvis/RpPseudoColor.h
r2322 r2409 15 15 #include <vtkPlaneCollection.h> 16 16 17 #include "RpVtkGraphicsObject.h" 17 18 #include "RpVtkDataSet.h" 18 19 … … 22 23 /** 23 24 * \brief Color-mapped plot of data set 25 * 26 * Currently the DataSet must be image data (2D uniform grid) 24 27 */ 25 class PseudoColor {28 class PseudoColor : public VtkGraphicsObject { 26 29 public: 27 30 PseudoColor(); 28 31 virtual ~PseudoColor(); 29 32 30 void setDataSet(DataSet *dataset); 33 virtual const char *getClassName() const 34 { 35 return "PseudoColor"; 36 } 31 37 32 DataSet *getDataSet(); 33 34 vtkProp *getProp(); 38 virtual void setClippingPlanes(vtkPlaneCollection *planes); 35 39 36 40 void setLookupTable(vtkLookupTable *lut); … … 38 42 vtkLookupTable *getLookupTable(); 39 43 40 void setVisibility(bool state); 44 private: 45 virtual void initProp(); 46 virtual void update(); 41 47 42 bool getVisibility();43 44 void setOpacity(double opacity);45 46 void setWireframe(bool state);47 48 void setEdgeVisibility(bool state);49 50 void setEdgeColor(float color[3]);51 52 void setEdgeWidth(float edgeWidth);53 54 void setClippingPlanes(vtkPlaneCollection *planes);55 56 void setLighting(bool state);57 58 private:59 void initProp();60 void update();61 62 DataSet * _dataSet;63 64 float _edgeColor[3];65 float _edgeWidth;66 double _opacity;67 bool _lighting;68 48 vtkSmartPointer<vtkLookupTable> _lut; 69 49 vtkSmartPointer<vtkDataSetMapper> _dsMapper; 70 vtkSmartPointer<vtkActor> _dsActor;71 50 }; 72 51 -
branches/blt4/packages/vizservers/vtkvis/RpStreamlines.cpp
r2322 r2409 9 9 #include <ctime> 10 10 #include <cfloat> 11 #include <cmath> 12 13 #include <vtkMath.h> 11 14 #include <vtkActor.h> 12 15 #include <vtkProperty.h> … … 21 24 #include <vtkTubeFilter.h> 22 25 #include <vtkRibbonFilter.h> 26 #include <vtkTransform.h> 27 #include <vtkTransformPolyDataFilter.h> 23 28 24 29 #include "RpStreamlines.h" … … 28 33 29 34 Streamlines::Streamlines() : 30 _dataSet(NULL),35 VtkGraphicsObject(), 31 36 _lineType(LINES), 32 _edgeWidth(1.0f), 33 _opacity(1.0), 34 _lighting(false), 37 _colorMode(COLOR_BY_VECTOR_MAGNITUDE), 35 38 _seedVisible(true) 36 39 { 37 _edgeColor[0] = 0.0f; 38 _edgeColor[1] = 0.0f; 39 _edgeColor[2] = 0.0f; 40 _faceCulling = true; 41 _color[0] = 1.0f; 42 _color[1] = 1.0f; 43 _color[2] = 1.0f; 40 44 _seedColor[0] = 1.0f; 41 45 _seedColor[1] = 1.0f; 42 46 _seedColor[2] = 1.0f; 47 vtkMath::RandomSeed((int)time(NULL)); 48 srand((unsigned int)time(NULL)); 43 49 } 44 50 … … 48 54 49 55 /** 50 * \brief Get the VTK Prop for the Streamlines51 */52 vtkProp *Streamlines::getProp()53 {54 return _props;55 }56 57 /**58 56 * \brief Create and initialize a VTK Prop to render Streamlines 59 57 */ 60 58 void Streamlines::initProp() 61 59 { 62 if (_prop == NULL) { 63 _prop = vtkSmartPointer<vtkActor>::New(); 64 _prop->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]); 65 _prop->GetProperty()->SetLineWidth(_edgeWidth); 66 _prop->GetProperty()->SetOpacity(_opacity); 67 _prop->GetProperty()->SetAmbient(.2); 60 if (_linesActor == NULL) { 61 _linesActor = vtkSmartPointer<vtkActor>::New(); 62 _linesActor->GetProperty()->SetColor(_color[0], _color[1], _color[2]); 63 _linesActor->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]); 64 _linesActor->GetProperty()->SetLineWidth(_edgeWidth); 65 _linesActor->GetProperty()->SetOpacity(_opacity); 66 _linesActor->GetProperty()->SetAmbient(.2); 68 67 if (!_lighting) 69 _ prop->GetProperty()->LightingOff();68 _linesActor->GetProperty()->LightingOff(); 70 69 switch (_lineType) { 71 70 case LINES: 72 _prop->GetProperty()->SetRepresentationToWireframe(); 73 _prop->GetProperty()->EdgeVisibilityOff(); 71 setCulling(_linesActor->GetProperty(), false); 72 _linesActor->GetProperty()->SetRepresentationToWireframe(); 73 _linesActor->GetProperty()->EdgeVisibilityOff(); 74 74 break; 75 75 case TUBES: 76 _prop->GetProperty()->SetRepresentationToSurface(); 77 _prop->GetProperty()->EdgeVisibilityOff(); 76 if (_faceCulling && _opacity == 1.0) 77 setCulling(_linesActor->GetProperty(), true); 78 _linesActor->GetProperty()->SetRepresentationToSurface(); 79 _linesActor->GetProperty()->EdgeVisibilityOff(); 78 80 break; 79 81 case RIBBONS: 80 _prop->GetProperty()->SetRepresentationToSurface(); 81 _prop->GetProperty()->EdgeVisibilityOff(); 82 setCulling(_linesActor->GetProperty(), false); 83 _linesActor->GetProperty()->SetRepresentationToSurface(); 84 _linesActor->GetProperty()->EdgeVisibilityOff(); 82 85 break; 83 86 default: … … 94 97 _seedActor->GetProperty()->LightingOff(); 95 98 } 96 if (_props == NULL) { 97 _props = vtkSmartPointer<vtkPropAssembly>::New(); 98 _props->AddPart(_prop); 99 _props->AddPart(_seedActor); 100 } 101 } 102 103 /** 104 * \brief Specify input DataSet 105 * 106 * The DataSet must contain vectors 107 */ 108 void Streamlines::setDataSet(DataSet *dataSet) 109 { 110 if (_dataSet != dataSet) { 111 _dataSet = dataSet; 112 update(); 113 } 114 } 115 116 /** 117 * \brief Returns the DataSet this Streamlines renders 118 */ 119 DataSet *Streamlines::getDataSet() 120 { 121 return _dataSet; 122 } 123 99 if (_prop == NULL) { 100 _prop = vtkSmartPointer<vtkAssembly>::New(); 101 getAssembly()->AddPart(_linesActor); 102 getAssembly()->AddPart(_seedActor); 103 } 104 } 105 106 /** 107 * \brief Get a pseudo-random number in range [min,max] 108 */ 109 double Streamlines::getRandomNum(double min, double max) 110 { 111 #if 1 112 return vtkMath::Random(min, max); 113 #else 114 int r = rand(); 115 return (min + ((double)r / RAND_MAX) * (max - min)); 116 #endif 117 } 118 119 /** 120 * \brief Get a random 3D point within an AABB 121 * 122 * \param[out] pt The random point 123 * \param[in] bounds The bounds of the AABB 124 */ 124 125 void Streamlines::getRandomPoint(double pt[3], const double bounds[6]) 125 126 { 126 int r = rand(); 127 pt[0] = bounds[0] + ((double)r / RAND_MAX) * (bounds[1] - bounds[0]); 128 r = rand(); 129 pt[1] = bounds[2] + ((double)r / RAND_MAX) * (bounds[3] - bounds[2]); 130 r = rand(); 131 pt[2] = bounds[4] + ((double)r / RAND_MAX) * (bounds[5] - bounds[4]); 132 } 133 134 void Streamlines::getRandomCellPt(vtkDataSet *ds, double pt[3]) 127 pt[0] = getRandomNum(bounds[0], bounds[1]); 128 pt[1] = getRandomNum(bounds[2], bounds[3]); 129 pt[2] = getRandomNum(bounds[4], bounds[5]); 130 } 131 132 /** 133 * \brief Get a random point within a triangle (including edges) 134 * 135 * \param[out] pt The random point 136 * \param[in] v1 Triangle vertex 1 137 * \param[in] v2 Triangle vertex 2 138 * \param[in] v3 Triangle vertex 3 139 */ 140 void Streamlines::getRandomPointInTriangle(double pt[3], 141 const double v1[3], 142 const double v2[3], 143 const double v3[3]) 144 { 145 // Choose random barycentric coordinates 146 double bary[3]; 147 bary[0] = getRandomNum(0, 1); 148 bary[1] = getRandomNum(0, 1); 149 if (bary[0] + bary[1] > 1.0) { 150 bary[0] = 1.0 - bary[0]; 151 bary[1] = 1.0 - bary[1]; 152 } 153 bary[2] = 1.0 - bary[0] - bary[1]; 154 155 TRACE("bary %g %g %g", bary[0], bary[1], bary[2]); 156 // Convert to cartesian coords 157 for (int i = 0; i < 3; i++) { 158 pt[i] = v1[i] * bary[0] + v2[i] * bary[1] + v3[i] * bary[2]; 159 } 160 } 161 162 /** 163 * \brief Get a random point on a line segment (including endpoints) 164 */ 165 void Streamlines::getRandomPointOnLineSegment(double pt[3], 166 const double endpt[3], 167 const double endpt2[3]) 168 { 169 double ratio = getRandomNum(0, 1); 170 pt[0] = endpt[0] + ratio * (endpt2[0] - endpt[0]); 171 pt[1] = endpt[1] + ratio * (endpt2[1] - endpt[1]); 172 pt[2] = endpt[2] + ratio * (endpt2[2] - endpt[2]); 173 } 174 175 /** 176 * \brief Get a random point within a vtkDataSet's mesh 177 * 178 * Note: This currently doesn't give a uniform distribution of 179 * points in space and can generate points outside the mesh 180 */ 181 void Streamlines::getRandomCellPt(double pt[3], vtkDataSet *ds) 135 182 { 136 183 int numCells = (int)ds->GetNumberOfCells(); 184 // XXX: Not uniform distribution (shouldn't use mod, and assumes 185 // all cells are equal area/volume) 137 186 int cell = rand() % numCells; 138 187 double bounds[6]; 139 188 ds->GetCellBounds(cell, bounds); 140 int r = rand(); 141 pt[0] = bounds[0] + ((double)r / RAND_MAX) * (bounds[1] - bounds[0]); 142 r = rand(); 143 pt[1] = bounds[2] + ((double)r / RAND_MAX) * (bounds[3] - bounds[2]); 144 r = rand(); 145 pt[2] = bounds[4] + ((double)r / RAND_MAX) * (bounds[5] - bounds[4]); 189 // Note: point is inside AABB of cell, but may be outside the cell 190 getRandomPoint(pt, bounds); 146 191 } 147 192 … … 157 202 vtkDataSet *ds = _dataSet->getVtkDataSet(); 158 203 double dataRange[2]; 159 _dataSet->get DataRange(dataRange);204 _dataSet->getVectorMagnitudeRange(dataRange); 160 205 double bounds[6]; 161 206 _dataSet->getBounds(bounds); … … 175 220 if (ds->GetPointData() == NULL || 176 221 ds->GetPointData()->GetVectors() == NULL) { 177 WARN("No vector point data found in DataSet %s", _dataSet->getName().c_str());222 TRACE("No vector point data found in DataSet %s", _dataSet->getName().c_str()); 178 223 if (ds->GetCellData() == NULL || 179 224 ds->GetCellData()->GetVectors() == NULL) { … … 194 239 195 240 _streamTracer->SetInput(ds); 196 197 // Set up seed source object198 vtkSmartPointer<vtkPolyData> seed = vtkSmartPointer<vtkPolyData>::New();199 vtkSmartPointer<vtkPoints> pts = vtkSmartPointer<vtkPoints>::New();200 vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New();201 202 int numPoints = 200;203 srand((unsigned int)time(NULL));204 for (int i = 0; i < numPoints; i++) {205 double pt[3];206 getRandomCellPt(ds, pt);207 TRACE("Seed pt: %g %g %g", pt[0], pt[1], pt[2]);208 pts->InsertNextPoint(pt);209 cells->InsertNextCell(1);210 cells->InsertCellPoint(i);211 }212 213 seed->SetPoints(pts);214 seed->SetVerts(cells);215 216 TRACE("Seed points: %d", seed->GetNumberOfPoints());217 218 241 _streamTracer->SetMaximumPropagation(maxBound); 219 _streamTracer->SetSource(seed);220 242 221 243 if (_pdMapper == NULL) { … … 223 245 _pdMapper->SetResolveCoincidentTopologyToPolygonOffset(); 224 246 _pdMapper->ScalarVisibilityOn(); 225 // _pdMapper->ScalarVisibilityOff();226 247 } 227 248 if (_seedMapper == NULL) { 228 249 _seedMapper = vtkSmartPointer<vtkPolyDataMapper>::New(); 229 250 _seedMapper->SetResolveCoincidentTopologyToPolygonOffset(); 230 _seedMapper->SetInput(seed); 231 } 251 } 252 253 // Set up seed source object 254 setSeedToRandomPoints(200); 232 255 233 256 switch (_lineType) { … … 272 295 273 296 _lut = vtkSmartPointer<vtkLookupTable>::New(); 297 _lut->SetRange(dataRange); 274 298 _lut->SetVectorModeToMagnitude(); 275 299 … … 281 305 } 282 306 _pdMapper->SetColorModeToMapScalars(); 283 _pdMapper->UseLookupTableScalarRangeO ff();307 _pdMapper->UseLookupTableScalarRangeOn(); 284 308 _pdMapper->SetLookupTable(_lut); 285 309 286 _ prop->SetMapper(_pdMapper);310 _linesActor->SetMapper(_pdMapper); 287 311 _pdMapper->Update(); 288 312 _seedMapper->Update(); … … 291 315 /** 292 316 * \brief Use randomly distributed seed points 317 * 318 * Note: The current implementation doesn't give a uniform 319 * distribution of points, and points outside the mesh bounds 320 * may be generated 293 321 * 294 322 * \param[in] numPoints Number of random seed points to generate … … 302 330 vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New(); 303 331 304 srand((unsigned int)time(NULL));305 332 for (int i = 0; i < numPoints; i++) { 306 333 double pt[3]; 307 getRandomCellPt( _dataSet->getVtkDataSet(), pt);334 getRandomCellPt(pt, _dataSet->getVtkDataSet()); 308 335 TRACE("Seed pt: %g %g %g", pt[0], pt[1], pt[2]); 309 336 pts->InsertNextPoint(pt); … … 384 411 385 412 /** 413 * \brief Create seed points inside a disk with an optional hole 414 * 415 * \param[in] center Center point of disk 416 * \param[in] normal Normal vector to orient disk 417 * \param[in] radius Radius of disk 418 * \param[in] innerRadius Radius of hole at center of disk 419 * \param[in] numPoints Number of random points to generate 420 */ 421 void Streamlines::setSeedToDisk(double center[3], 422 double normal[3], 423 double radius, 424 double innerRadius, 425 int numPoints) 426 { 427 if (_streamTracer != NULL) { 428 // Set up seed source object 429 vtkSmartPointer<vtkPolyData> seed = vtkSmartPointer<vtkPolyData>::New(); 430 vtkSmartPointer<vtkPoints> pts = vtkSmartPointer<vtkPoints>::New(); 431 vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New(); 432 433 // The following code is based on vtkRegularPolygonSource::RequestData 434 435 double px[3]; 436 double py[3]; 437 double axis[3] = {1., 0., 0.}; 438 439 if (vtkMath::Normalize(normal) == 0.0) { 440 normal[0] = 0.0; 441 normal[1] = 0.0; 442 normal[2] = 1.0; 443 } 444 445 // Find axis in plane (orthogonal to normal) 446 bool done = false; 447 vtkMath::Cross(normal, axis, px); 448 if (vtkMath::Normalize(px) > 1.0e-3) { 449 done = true; 450 } 451 if (!done) { 452 axis[0] = 0.0; 453 axis[1] = 1.0; 454 axis[2] = 0.0; 455 vtkMath::Cross(normal, axis, px); 456 if (vtkMath::Normalize(px) > 1.0e-3) { 457 done = true; 458 } 459 } 460 if (!done) { 461 axis[0] = 0.0; 462 axis[1] = 0.0; 463 axis[2] = 1.0; 464 vtkMath::Cross(normal, axis, px); 465 vtkMath::Normalize(px); 466 } 467 // Create third orthogonal basis vector 468 vtkMath::Cross(px, normal, py); 469 470 double minSquared = (innerRadius*innerRadius)/(radius*radius); 471 for (int j = 0; j < numPoints; j++) { 472 // Get random sweep angle and radius 473 double angle = getRandomNum(0, 2.0 * vtkMath::DoublePi()); 474 // Need sqrt to get uniform distribution 475 double r = sqrt(getRandomNum(minSquared, 1)) * radius; 476 double pt[3]; 477 for (int i = 0; i < 3; i++) { 478 pt[i] = center[i] + r * (px[i] * cos(angle) + py[i] * sin(angle)); 479 } 480 TRACE("Seed pt: %g %g %g", pt[0], pt[1], pt[2]); 481 pts->InsertNextPoint(pt); 482 cells->InsertNextCell(1); 483 cells->InsertCellPoint(j); 484 } 485 486 seed->SetPoints(pts); 487 seed->SetVerts(cells); 488 489 TRACE("Seed points: %d", seed->GetNumberOfPoints()); 490 vtkSmartPointer<vtkDataSet> oldSeed; 491 if (_streamTracer->GetSource() != NULL) { 492 oldSeed = _streamTracer->GetSource(); 493 } 494 495 _streamTracer->SetSource(seed); 496 if (oldSeed != NULL) { 497 oldSeed->SetPipelineInformation(NULL); 498 } 499 500 _seedMapper->SetInput(seed); 501 } 502 } 503 504 /** 386 505 * \brief Use seed points from an n-sided polygon 387 506 * 388 507 * \param[in] center Center point of polygon 389 508 * \param[in] normal Normal vector to orient polygon 509 * \param[in] angle Angle in degrees to rotate about normal 390 510 * \param[in] radius Radius of circumscribing circle 391 511 * \param[in] numSides Number of polygon sides (and points) to generate … … 393 513 void Streamlines::setSeedToPolygon(double center[3], 394 514 double normal[3], 515 double angle, 395 516 double radius, 396 517 int numSides) … … 406 527 seed->GeneratePolygonOn(); 407 528 529 if (angle != 0.0) { 530 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New(); 531 trans->RotateWXYZ(angle, normal); 532 vtkSmartPointer<vtkTransformPolyDataFilter> transFilt = 533 vtkSmartPointer<vtkTransformPolyDataFilter>::New(); 534 transFilt->SetInputConnection(seed->GetOutputPort()); 535 transFilt->SetTransform(trans); 536 } 537 408 538 TRACE("Seed points: %d", numSides); 409 539 vtkSmartPointer<vtkDataSet> oldSeed; … … 412 542 } 413 543 414 _streamTracer->SetSourceConnection(seed->GetOutputPort()); 544 if (angle != 0.0) { 545 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New(); 546 trans->Translate(+center[0], +center[1], +center[2]); 547 trans->RotateWXYZ(angle, normal); 548 trans->Translate(-center[0], -center[1], -center[2]); 549 vtkSmartPointer<vtkTransformPolyDataFilter> transFilt = 550 vtkSmartPointer<vtkTransformPolyDataFilter>::New(); 551 transFilt->SetInputConnection(seed->GetOutputPort()); 552 transFilt->SetTransform(trans); 553 _streamTracer->SetSourceConnection(transFilt->GetOutputPort()); 554 _seedMapper->SetInputConnection(transFilt->GetOutputPort()); 555 } else { 556 _streamTracer->SetSourceConnection(seed->GetOutputPort()); 557 _seedMapper->SetInputConnection(seed->GetOutputPort()); 558 } 559 415 560 if (oldSeed != NULL) { 416 561 oldSeed->SetPipelineInformation(NULL); 417 562 } 418 419 _seedMapper->SetInputConnection(seed->GetOutputPort()); 563 } 564 } 565 566 /** 567 * \brief Use seed points from an n-sided polygon 568 * 569 * \param[in] center Center point of polygon 570 * \param[in] normal Normal vector to orient polygon 571 * \param[in] angle Angle in degrees to rotate about normal 572 * \param[in] radius Radius of circumscribing circle 573 * \param[in] numSides Number of polygon sides (and points) to generate 574 * \param[in] numPoints Number of random points to generate 575 */ 576 void Streamlines::setSeedToFilledPolygon(double center[3], 577 double normal[3], 578 double angle, 579 double radius, 580 int numSides, 581 int numPoints) 582 { 583 if (_streamTracer != NULL) { 584 // Set up seed source object 585 vtkSmartPointer<vtkPolyData> seed = vtkSmartPointer<vtkPolyData>::New(); 586 vtkSmartPointer<vtkPoints> pts = vtkSmartPointer<vtkPoints>::New(); 587 vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New(); 588 589 // The following code is based on vtkRegularPolygonSource::RequestData 590 591 double px[3]; 592 double py[3]; 593 double axis[3] = {1., 0., 0.}; 594 595 if (vtkMath::Normalize(normal) == 0.0) { 596 normal[0] = 0.0; 597 normal[1] = 0.0; 598 normal[2] = 1.0; 599 } 600 601 // Find axis in plane (orthogonal to normal) 602 bool done = false; 603 vtkMath::Cross(normal, axis, px); 604 if (vtkMath::Normalize(px) > 1.0e-3) { 605 done = true; 606 } 607 if (!done) { 608 axis[0] = 0.0; 609 axis[1] = 1.0; 610 axis[2] = 0.0; 611 vtkMath::Cross(normal, axis, px); 612 if (vtkMath::Normalize(px) > 1.0e-3) { 613 done = true; 614 } 615 } 616 if (!done) { 617 axis[0] = 0.0; 618 axis[1] = 0.0; 619 axis[2] = 1.0; 620 vtkMath::Cross(normal, axis, px); 621 vtkMath::Normalize(px); 622 } 623 // Create third orthogonal basis vector 624 vtkMath::Cross(px, normal, py); 625 626 double verts[numSides][3]; 627 double sliceTheta = 2.0 * vtkMath::DoublePi() / (double)numSides; 628 angle = vtkMath::RadiansFromDegrees(angle); 629 for (int j = 0; j < numSides; j++) { 630 for (int i = 0; i < 3; i++) { 631 double theta = sliceTheta * (double)j - angle; 632 verts[j][i] = center[i] + radius * (px[i] * cos(theta) + 633 py[i] * sin(theta)); 634 } 635 TRACE("Vert %d: %g %g %g", j, verts[j][0], verts[j][1], verts[j][2]); 636 } 637 638 // Note: this gives a uniform distribution because the polygon is regular and 639 // the triangular sections have equal area 640 if (numSides == 3) { 641 for (int j = 0; j < numPoints; j++) { 642 double pt[3]; 643 getRandomPointInTriangle(pt, verts[0], verts[1], verts[2]); 644 TRACE("Seed pt: %g %g %g", pt[0], pt[1], pt[2]); 645 pts->InsertNextPoint(pt); 646 cells->InsertNextCell(1); 647 cells->InsertCellPoint(j); 648 } 649 } else { 650 for (int j = 0; j < numPoints; j++) { 651 // Get random triangle section 652 int tri = rand() % numSides; 653 double pt[3]; 654 getRandomPointInTriangle(pt, center, verts[tri], verts[(tri+1) % numSides]); 655 TRACE("Seed pt: %g %g %g", pt[0], pt[1], pt[2]); 656 pts->InsertNextPoint(pt); 657 cells->InsertNextCell(1); 658 cells->InsertCellPoint(j); 659 } 660 } 661 662 seed->SetPoints(pts); 663 seed->SetVerts(cells); 664 665 TRACE("Seed points: %d", seed->GetNumberOfPoints()); 666 vtkSmartPointer<vtkDataSet> oldSeed; 667 if (_streamTracer->GetSource() != NULL) { 668 oldSeed = _streamTracer->GetSource(); 669 } 670 671 _streamTracer->SetSource(seed); 672 if (oldSeed != NULL) { 673 oldSeed->SetPipelineInformation(NULL); 674 } 675 676 _seedMapper->SetInput(seed); 420 677 } 421 678 } … … 442 699 _pdMapper->SetInputConnection(_streamTracer->GetOutputPort()); 443 700 _lineFilter = NULL; 444 _prop->GetProperty()->SetRepresentationToWireframe(); 445 _prop->GetProperty()->LightingOff(); 701 setCulling(_linesActor->GetProperty(), false); 702 _linesActor->GetProperty()->SetRepresentationToWireframe(); 703 _linesActor->GetProperty()->LightingOff(); 446 704 } 447 705 } … … 468 726 tubeFilter->SetRadius(radius); 469 727 _pdMapper->SetInputConnection(_lineFilter->GetOutputPort()); 470 _prop->GetProperty()->SetRepresentationToSurface(); 471 _prop->GetProperty()->LightingOn(); 728 if (_faceCulling && _opacity == 1.0) 729 setCulling(_linesActor->GetProperty(), true); 730 _linesActor->GetProperty()->SetRepresentationToSurface(); 731 _linesActor->GetProperty()->LightingOn(); 472 732 } 473 733 } … … 493 753 ribbonFilter->UseDefaultNormalOn(); 494 754 _pdMapper->SetInputConnection(_lineFilter->GetOutputPort()); 495 _prop->GetProperty()->SetRepresentationToSurface(); 496 _prop->GetProperty()->LightingOn(); 755 setCulling(_linesActor->GetProperty(), false); 756 _linesActor->GetProperty()->SetRepresentationToSurface(); 757 _linesActor->GetProperty()->LightingOn(); 758 } 759 } 760 761 void Streamlines::setColorMode(ColorMode mode) 762 { 763 _colorMode = mode; 764 if (_dataSet == NULL || _pdMapper == NULL) 765 return; 766 767 vtkDataSet *ds = _dataSet->getVtkDataSet(); 768 769 switch (mode) { 770 case COLOR_BY_SCALAR: { 771 _pdMapper->ScalarVisibilityOn(); 772 _pdMapper->SetScalarModeToDefault(); 773 if (_lut != NULL) { 774 double dataRange[2]; 775 _dataSet->getDataRange(dataRange); 776 _lut->SetRange(dataRange); 777 } 778 } 779 break; 780 case COLOR_BY_VECTOR_MAGNITUDE: { 781 _pdMapper->ScalarVisibilityOn(); 782 _pdMapper->SetScalarModeToUsePointFieldData(); 783 if (ds->GetPointData() != NULL && 784 ds->GetPointData()->GetVectors() != NULL) { 785 _pdMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName()); 786 } 787 if (_lut != NULL) { 788 double dataRange[2]; 789 _dataSet->getVectorMagnitudeRange(dataRange); 790 TRACE("vmag range: %g %g", dataRange[0], dataRange[1]); 791 _lut->SetRange(dataRange); 792 _lut->SetVectorModeToMagnitude(); 793 } 794 } 795 break; 796 case COLOR_BY_VECTOR_X: 797 _pdMapper->ScalarVisibilityOn(); 798 _pdMapper->SetScalarModeToUsePointFieldData(); 799 if (ds->GetPointData() != NULL && 800 ds->GetPointData()->GetVectors() != NULL) { 801 _pdMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName()); 802 } 803 if (_lut != NULL) { 804 double dataRange[2]; 805 _dataSet->getVectorComponentRange(dataRange, 0); 806 _lut->SetRange(dataRange); 807 _lut->SetVectorModeToComponent(); 808 _lut->SetVectorComponent(0); 809 } 810 break; 811 case COLOR_BY_VECTOR_Y: 812 _pdMapper->ScalarVisibilityOn(); 813 _pdMapper->SetScalarModeToUsePointFieldData(); 814 if (ds->GetPointData() != NULL && 815 ds->GetPointData()->GetVectors() != NULL) { 816 _pdMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName()); 817 } 818 if (_lut != NULL) { 819 double dataRange[2]; 820 _dataSet->getVectorComponentRange(dataRange, 1); 821 _lut->SetRange(dataRange); 822 _lut->SetVectorModeToComponent(); 823 _lut->SetVectorComponent(1); 824 } 825 break; 826 case COLOR_BY_VECTOR_Z: 827 _pdMapper->ScalarVisibilityOn(); 828 _pdMapper->SetScalarModeToUsePointFieldData(); 829 if (ds->GetPointData() != NULL && 830 ds->GetPointData()->GetVectors() != NULL) { 831 _pdMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName()); 832 } 833 if (_lut != NULL) { 834 double dataRange[2]; 835 _dataSet->getVectorComponentRange(dataRange, 2); 836 TRACE("vz range: %g %g", dataRange[0], dataRange[1]); 837 _lut->SetRange(dataRange); 838 _lut->SetVectorModeToComponent(); 839 _lut->SetVectorComponent(2); 840 } 841 break; 842 case COLOR_CONSTANT: 843 default: 844 _pdMapper->ScalarVisibilityOff(); 845 break; 497 846 } 498 847 } … … 517 866 } 518 867 868 switch (_colorMode) { 869 case COLOR_BY_VECTOR_MAGNITUDE: { 870 double dataRange[2]; 871 _dataSet->getVectorMagnitudeRange(dataRange); 872 _lut->SetVectorModeToMagnitude(); 873 _lut->SetRange(dataRange); 874 } 875 break; 876 case COLOR_BY_VECTOR_X: { 877 double dataRange[2]; 878 _dataSet->getVectorComponentRange(dataRange, 0); 879 _lut->SetVectorModeToComponent(); 880 _lut->SetVectorComponent(0); 881 _lut->SetRange(dataRange); 882 } 883 break; 884 case COLOR_BY_VECTOR_Y: { 885 double dataRange[2]; 886 _dataSet->getVectorComponentRange(dataRange, 1); 887 _lut->SetVectorModeToComponent(); 888 _lut->SetVectorComponent(1); 889 _lut->SetRange(dataRange); 890 } 891 break; 892 case COLOR_BY_VECTOR_Z: { 893 double dataRange[2]; 894 _dataSet->getVectorComponentRange(dataRange, 2); 895 _lut->SetVectorModeToComponent(); 896 _lut->SetVectorComponent(2); 897 _lut->SetRange(dataRange); 898 } 899 break; 900 default: 901 break; 902 } 903 519 904 if (_pdMapper != NULL) { 520 905 _pdMapper->SetLookupTable(_lut); … … 523 908 524 909 /** 910 * \brief Turn on/off lighting of this object 911 */ 912 void Streamlines::setLighting(bool state) 913 { 914 _lighting = state; 915 if (_linesActor != NULL) 916 _linesActor->GetProperty()->SetLighting((state ? 1 : 0)); 917 } 918 919 /** 920 * \brief Set opacity of this object 921 */ 922 void Streamlines::setOpacity(double opacity) 923 { 924 _opacity = opacity; 925 if (_linesActor != NULL) { 926 _linesActor->GetProperty()->SetOpacity(_opacity); 927 if (_opacity < 1.0) 928 setCulling(_linesActor->GetProperty(), false); 929 else if (_faceCulling && _lineType == TUBES) 930 setCulling(_linesActor->GetProperty(), true); 931 } 932 if (_seedActor != NULL) { 933 _seedActor->GetProperty()->SetOpacity(_opacity); 934 } 935 } 936 937 /** 525 938 * \brief Turn on/off rendering of this Streamlines 526 939 */ 527 940 void Streamlines::setVisibility(bool state) 528 941 { 529 if (_ prop!= NULL) {530 _ prop->SetVisibility((state ? 1 : 0));942 if (_linesActor != NULL) { 943 _linesActor->SetVisibility((state ? 1 : 0)); 531 944 } 532 945 if (_seedActor != NULL) { … … 556 969 bool Streamlines::getVisibility() 557 970 { 558 if (_ prop== NULL) {971 if (_linesActor == NULL) { 559 972 return false; 560 973 } else { 561 return (_prop->GetVisibility() != 0); 562 } 563 } 564 565 /** 566 * \brief Set opacity used to render the Streamlines 567 */ 568 void Streamlines::setOpacity(double opacity) 569 { 570 _opacity = opacity; 571 if (_prop != NULL) { 572 _prop->GetProperty()->SetOpacity(opacity); 573 } 574 if (_seedActor != NULL) { 575 _seedActor->GetProperty()->SetOpacity(opacity); 576 } 577 } 578 579 /** 580 * \brief Get opacity used to render the Streamlines 581 */ 582 double Streamlines::getOpacity() 583 { 584 return _opacity; 974 return (_linesActor->GetVisibility() != 0); 975 } 585 976 } 586 977 … … 590 981 void Streamlines::setEdgeVisibility(bool state) 591 982 { 592 if (_ prop!= NULL) {593 _ prop->GetProperty()->SetEdgeVisibility((state ? 1 : 0));983 if (_linesActor != NULL) { 984 _linesActor->GetProperty()->SetEdgeVisibility((state ? 1 : 0)); 594 985 } 595 986 } … … 597 988 /** 598 989 * \brief Set RGB color of stream lines 990 */ 991 void Streamlines::setColor(float color[3]) 992 { 993 _color[0] = color[0]; 994 _color[1] = color[1]; 995 _color[2] = color[2]; 996 if (_linesActor != NULL) 997 _linesActor->GetProperty()->SetColor(_color[0], _color[1], _color[2]); 998 } 999 1000 /** 1001 * \brief Set RGB color of stream line edges 599 1002 */ 600 1003 void Streamlines::setEdgeColor(float color[3]) … … 603 1006 _edgeColor[1] = color[1]; 604 1007 _edgeColor[2] = color[2]; 605 if (_ prop!= NULL)606 _ prop->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);1008 if (_linesActor != NULL) 1009 _linesActor->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]); 607 1010 } 608 1011 … … 625 1028 { 626 1029 _edgeWidth = edgeWidth; 627 if (_ prop!= NULL)628 _ prop->GetProperty()->SetLineWidth(_edgeWidth);1030 if (_linesActor != NULL) 1031 _linesActor->GetProperty()->SetLineWidth(_edgeWidth); 629 1032 } 630 1033 … … 643 1046 } 644 1047 } 645 646 /**647 * \brief Turn on/off lighting of this object648 */649 void Streamlines::setLighting(bool state)650 {651 _lighting = state;652 if (_prop != NULL)653 _prop->GetProperty()->SetLighting((state ? 1 : 0));654 } -
branches/blt4/packages/vizservers/vtkvis/RpStreamlines.h
r2322 r2409 16 16 #include <vtkPolyDataMapper.h> 17 17 #include <vtkLookupTable.h> 18 #include <vtk PropAssembly.h>18 #include <vtkAssembly.h> 19 19 20 #include "RpVtk DataSet.h"20 #include "RpVtkGraphicsObject.h" 21 21 22 22 namespace Rappture { … … 25 25 /** 26 26 * \brief Streamline visualization of vector fields 27 * 28 * The DataSet must contain vectors 27 29 */ 28 class Streamlines {30 class Streamlines : public VtkGraphicsObject { 29 31 public: 30 32 enum LineType { … … 33 35 RIBBONS 34 36 }; 37 enum ColorMode { 38 COLOR_BY_SCALAR, 39 COLOR_BY_VECTOR_MAGNITUDE, 40 COLOR_BY_VECTOR_X, 41 COLOR_BY_VECTOR_Y, 42 COLOR_BY_VECTOR_Z, 43 COLOR_CONSTANT 44 }; 35 45 36 46 Streamlines(); 37 47 virtual ~Streamlines(); 38 48 39 void setDataSet(DataSet *dataset); 49 virtual const char *getClassName() const 50 { 51 return "Streamlines"; 52 } 40 53 41 DataSet *getDataSet();54 virtual void setLighting(bool state); 42 55 43 vtkProp *getProp(); 56 virtual void setOpacity(double opacity); 57 58 virtual void setVisibility(bool state); 59 60 virtual bool getVisibility(); 61 62 virtual void setColor(float color[3]); 63 64 virtual void setEdgeVisibility(bool state); 65 66 virtual void setEdgeColor(float color[3]); 67 68 virtual void setEdgeWidth(float edgeWidth); 69 70 virtual void setClippingPlanes(vtkPlaneCollection *planes); 44 71 45 72 void setSeedToRandomPoints(int numPoints); … … 47 74 void setSeedToRake(double start[3], double end[3], int numPoints); 48 75 76 void setSeedToDisk(double center[3], double normal[3], 77 double radius, double innerRadius, int numPoints); 78 49 79 void setSeedToPolygon(double center[3], double normal[3], 50 double radius, int numSides); 80 double angle, double radius, 81 int numSides); 82 83 void setSeedToFilledPolygon(double center[3], double normal[3], 84 double angle, double radius, 85 int numSides, int numPoints); 51 86 52 87 void setMaxPropagation(double length); … … 58 93 void setLineTypeToRibbons(double width, double angle); 59 94 95 void setColorMode(ColorMode mode); 96 60 97 void setLookupTable(vtkLookupTable *lut); 61 98 62 99 vtkLookupTable *getLookupTable(); 63 100 64 void setOpacity(double opacity);65 66 double getOpacity();67 68 void setVisibility(bool state);69 70 101 void setSeedVisibility(bool state); 71 72 bool getVisibility();73 74 void setEdgeVisibility(bool state);75 76 void setEdgeColor(float color[3]);77 78 void setEdgeWidth(float edgeWidth);79 102 80 103 void setSeedColor(float color[3]); 81 104 82 void setClippingPlanes(vtkPlaneCollection *planes); 105 private: 106 virtual void initProp(); 107 virtual void update(); 83 108 84 void setLighting(bool state); 85 86 private: 87 void initProp(); 88 void update(); 89 109 static double getRandomNum(double min, double max); 90 110 static void getRandomPoint(double pt[3], const double bounds[6]); 91 static void getRandomCellPt(vtkDataSet *ds, double pt[3]); 92 93 DataSet *_dataSet; 111 static void getRandomPointInTriangle(double pt[3], 112 const double v1[3], 113 const double v2[3], 114 const double v3[3]); 115 static void getRandomPointOnLineSegment(double pt[3], 116 const double endpt[3], 117 const double endpt2[3]); 118 static void getRandomCellPt(double pt[3], vtkDataSet *ds); 94 119 95 120 LineType _lineType; 96 float _edgeColor[3];97 float _ edgeWidth;121 ColorMode _colorMode; 122 float _color[3]; 98 123 float _seedColor[3]; 99 double _opacity;100 bool _lighting;101 124 bool _seedVisible; 102 125 103 126 vtkSmartPointer<vtkLookupTable> _lut; 104 vtkSmartPointer<vtkActor> _ prop;127 vtkSmartPointer<vtkActor> _linesActor; 105 128 vtkSmartPointer<vtkActor> _seedActor; 106 vtkSmartPointer<vtkPropAssembly> _props;107 129 vtkSmartPointer<vtkStreamTracer> _streamTracer; 108 130 vtkSmartPointer<vtkPolyDataAlgorithm> _lineFilter; -
branches/blt4/packages/vizservers/vtkvis/RpVolume.cpp
r2322 r2409 27 27 28 28 Volume::Volume() : 29 _dataSet(NULL), 30 _opacity(1.0), 29 VtkGraphicsObject(), 31 30 _colorMap(NULL) 32 31 { … … 44 43 45 44 /** 46 * \brief Specify input DataSet with scalars 47 * 48 * Currently the DataSet must be image data (3D uniform grid), 49 * or an UnstructuredGrid 45 * \brief Create and initialize a VTK Prop to render the Volume 50 46 */ 51 void Volume:: setDataSet(DataSet *dataSet)47 void Volume::initProp() 52 48 { 53 if (_ dataSet != dataSet) {54 _ dataSet = dataSet;55 update();49 if (_prop == NULL) { 50 _prop = vtkSmartPointer<vtkVolume>::New(); 51 getVolume()->GetProperty()->SetInterpolationTypeToLinear(); 56 52 } 57 }58 59 /**60 * \brief Returns the DataSet this Volume renders61 */62 DataSet *Volume::getDataSet()63 {64 return _dataSet;65 53 } 66 54 … … 129 117 } 130 118 131 _volumeProp->GetProperty()->SetColor(_colorMap->getColorTransferFunction(dataRange)); 132 _volumeProp->GetProperty()->SetScalarOpacity(_colorMap->getOpacityTransferFunction(dataRange)); 119 vtkVolumeProperty *volProperty = getVolume()->GetProperty(); 120 volProperty->SetColor(_colorMap->getColorTransferFunction(dataRange)); 121 volProperty->SetScalarOpacity(_colorMap->getOpacityTransferFunction(dataRange)); 133 122 134 _volumeProp->SetMapper(_volumeMapper);123 getVolume()->SetMapper(_volumeMapper); 135 124 _volumeMapper->Update(); 136 }137 138 /**139 * \brief Get the VTK Prop for the Volume140 */141 vtkProp *Volume::getProp()142 {143 return _volumeProp;144 }145 146 /**147 * \brief Create and initialize a VTK Prop to render the Volume148 */149 void Volume::initProp()150 {151 if (_volumeProp == NULL) {152 _volumeProp = vtkSmartPointer<vtkVolume>::New();153 _volumeProp->GetProperty()->SetInterpolationTypeToLinear();154 }155 125 } 156 126 … … 161 131 { 162 132 _colorMap = cmap; 163 if ( _volumeProp!= NULL) {133 if (getVolume() != NULL) { 164 134 double dataRange[2]; 165 135 _dataSet->getDataRange(dataRange); 166 _volumeProp->GetProperty()->SetColor(_colorMap->getColorTransferFunction(dataRange));167 _volumeProp->GetProperty()->SetScalarOpacity(_colorMap->getOpacityTransferFunction(dataRange));136 getVolume()->GetProperty()->SetColor(_colorMap->getColorTransferFunction(dataRange)); 137 getVolume()->GetProperty()->SetScalarOpacity(_colorMap->getOpacityTransferFunction(dataRange)); 168 138 } 169 139 } … … 176 146 { 177 147 _colorMap = cmap; 178 if ( _volumeProp!= NULL) {179 _volumeProp->GetProperty()->SetColor(_colorMap->getColorTransferFunction(dataRange));180 _volumeProp->GetProperty()->SetScalarOpacity(_colorMap->getOpacityTransferFunction(dataRange));148 if (getVolume() != NULL) { 149 getVolume()->GetProperty()->SetColor(_colorMap->getColorTransferFunction(dataRange)); 150 getVolume()->GetProperty()->SetScalarOpacity(_colorMap->getOpacityTransferFunction(dataRange)); 181 151 } 182 152 } … … 199 169 // across the different mappers/algorithms. This only works with the 200 170 // 3D texture mapper, not the GPU raycast mapper 201 if ( _volumeProp!= NULL) {171 if (getVolume() != NULL) { 202 172 if (opacity < 1.0e-6) 203 173 opacity = 1.0e-6; 204 _volumeProp->GetProperty()->SetScalarOpacityUnitDistance(1.0/opacity); 205 } 206 } 207 208 /** 209 * \brief Turn on/off rendering of this Volume 210 */ 211 void Volume::setVisibility(bool state) 212 { 213 if (_volumeProp != NULL) { 214 _volumeProp->SetVisibility((state ? 1 : 0)); 215 } 216 } 217 218 /** 219 * \brief Get visibility state of the Volume 220 * 221 * \return Is PseudoColor visible? 222 */ 223 bool Volume::getVisibility() 224 { 225 if (_volumeProp == NULL) { 226 return false; 227 } else { 228 return (_volumeProp->GetVisibility() != 0); 174 getVolume()->GetProperty()->SetScalarOpacityUnitDistance(1.0/opacity); 229 175 } 230 176 } … … 241 187 } 242 188 } 243 244 /**245 * \brief Set the ambient lighting/shading coefficient246 */247 void Volume::setAmbient(double coeff)248 {249 if (_volumeProp != NULL) {250 _volumeProp->GetProperty()->SetAmbient(coeff);251 }252 }253 254 /**255 * \brief Set the diffuse lighting/shading coefficient256 */257 void Volume::setDiffuse(double coeff)258 {259 if (_volumeProp != NULL) {260 _volumeProp->GetProperty()->SetDiffuse(coeff);261 }262 }263 264 /**265 * \brief Set the specular lighting/shading coefficient and power266 */267 void Volume::setSpecular(double coeff, double power)268 {269 if (_volumeProp != NULL) {270 _volumeProp->GetProperty()->SetSpecular(coeff);271 _volumeProp->GetProperty()->SetSpecularPower(power);272 }273 }274 275 /**276 * \brief Turn on/off lighting of this object277 */278 void Volume::setLighting(bool state)279 {280 if (_volumeProp != NULL)281 _volumeProp->GetProperty()->SetShade((state ? 1 : 0));282 } -
branches/blt4/packages/vizservers/vtkvis/RpVolume.h
r2302 r2409 15 15 #include <vtkPlaneCollection.h> 16 16 17 #include "RpVtk DataSet.h"17 #include "RpVtkGraphicsObject.h" 18 18 #include "ColorMap.h" 19 19 … … 23 23 /** 24 24 * \brief Volume Rendering 25 * 26 * Currently the DataSet must be image data (3D uniform grid), 27 * or an UnstructuredGrid 25 28 */ 26 class Volume {29 class Volume : public VtkGraphicsObject { 27 30 public: 28 31 enum BlendMode { … … 35 38 virtual ~Volume(); 36 39 37 void setDataSet(DataSet *dataset); 40 virtual const char *getClassName() const 41 { 42 return "Volume"; 43 } 38 44 39 DataSet *getDataSet();45 virtual void setOpacity(double opacity); 40 46 41 v tkProp *getProp();47 virtual void setClippingPlanes(vtkPlaneCollection *planes); 42 48 43 49 void setColorMap(ColorMap *cmap); 50 44 51 void setColorMap(ColorMap *cmap, double dataRange[2]); 45 52 46 53 ColorMap *getColorMap(); 47 54 48 void setOpacity(double opacity);49 50 void setVisibility(bool state);51 52 bool getVisibility();53 54 void setClippingPlanes(vtkPlaneCollection *planes);55 56 void setAmbient(double coeff);57 58 void setDiffuse(double coeff);59 60 void setSpecular(double coeff, double power);61 62 void setLighting(bool state);63 64 55 private: 65 void initProp(); 66 void update(); 67 68 DataSet *_dataSet; 69 double _opacity; 56 virtual void initProp(); 57 virtual void update(); 70 58 71 59 ColorMap *_colorMap; 72 vtkSmartPointer<vtkVolume> _volumeProp;73 60 vtkSmartPointer<vtkAbstractVolumeMapper> _volumeMapper; 74 61 }; -
branches/blt4/packages/vizservers/vtkvis/RpVtkDataSet.cpp
r2322 r2409 17 17 #include <vtkProperty.h> 18 18 #include <vtkPointData.h> 19 #include <vtkCellData.h> 19 20 #include <vtkLookupTable.h> 20 21 … … 28 29 _visible(true) 29 30 { 30 _dataRange[0] = 0;31 _dataRange[1] = 1;32 for (int i = 0; i < 6; i++) {33 _bounds[i] = 0;34 }35 31 } 36 32 … … 123 119 _dataSet->SetPipelineInformation(NULL); 124 120 125 _dataSet->GetScalarRange(_dataRange);126 _dataSet->GetBounds(_bounds);127 128 121 TRACE("DataSet class: %s", _dataSet->GetClassName()); 129 TRACE("Scalar Range: %.12e, %.12e", _dataRange[0], _dataRange[1]); 122 #ifdef WANT_TRACE 123 double dataRange[2]; 124 getDataRange(dataRange); 125 double bounds[6]; 126 getBounds(bounds); 127 #endif 128 TRACE("Scalar Range: %.12e, %.12e", dataRange[0], dataRange[1]); 130 129 TRACE("DataSet bounds: %g %g %g %g %g %g", 131 _bounds[0], _bounds[1], 132 _bounds[2], _bounds[3], 133 _bounds[4], _bounds[5]); 130 bounds[0], bounds[1], 131 bounds[2], bounds[3], 132 bounds[4], bounds[5]); 133 TRACE("Points: %d Cells: %d", _dataSet->GetNumberOfPoints(), _dataSet->GetNumberOfCells()); 134 134 return true; 135 135 } … … 144 144 _dataSet = ds; 145 145 _dataSet->SetPipelineInformation(NULL); 146 _dataSet->GetScalarRange(_dataRange);147 _dataSet->GetBounds(_bounds);148 146 149 147 TRACE("DataSet class: %s", _dataSet->GetClassName()); 150 TRACE("Scalar Range: %.12e, %.12e", _dataRange[0], _dataRange[1]); 148 #ifdef WANT_TRACE 149 double dataRange[2]; 150 getDataRange(dataRange); 151 double bounds[6]; 152 getBounds(bounds); 153 #endif 154 TRACE("Scalar Range: %.12e, %.12e", dataRange[0], dataRange[1]); 151 155 TRACE("DataSet bounds: %g %g %g %g %g %g", 152 _bounds[0], _bounds[1], 153 _bounds[2], _bounds[3], 154 _bounds[4], _bounds[5]); 156 bounds[0], bounds[1], 157 bounds[2], bounds[3], 158 bounds[4], bounds[5]); 159 TRACE("Points: %d Cells: %d", _dataSet->GetNumberOfPoints(), _dataSet->GetNumberOfCells()); 155 160 return true; 156 161 } … … 184 189 return NULL; 185 190 } 186 _dataSet->GetScalarRange(_dataRange);187 _dataSet->GetBounds(_bounds);188 191 189 192 TRACE("DataSet class: %s", _dataSet->GetClassName()); 190 TRACE("Scalar Range: %.12e, %.12e", _dataRange[0], _dataRange[1]); 193 #ifdef WANT_TRACE 194 double dataRange[2]; 195 getDataRange(dataRange); 196 double bounds[6]; 197 getBounds(bounds); 198 #endif 199 TRACE("Scalar Range: %.12e, %.12e", dataRange[0], dataRange[1]); 200 TRACE("DataSet bounds: %g %g %g %g %g %g", 201 bounds[0], bounds[1], 202 bounds[2], bounds[3], 203 bounds[4], bounds[5]); 191 204 return _dataSet; 192 205 } … … 197 210 bool DataSet::is2D() const 198 211 { 199 return (_bounds[4] == 0. && _bounds[4] == _bounds[5]); 212 double bounds[6]; 213 getBounds(bounds); 214 return (bounds[4] == 0. && bounds[4] == bounds[5]); 200 215 } 201 216 … … 219 234 * \brief Get the underlying VTK DataSet subclass class name 220 235 */ 221 const char *DataSet::getVtkType() 236 const char *DataSet::getVtkType() const 222 237 { 223 238 return _dataSet->GetClassName(); … … 225 240 226 241 /** 242 * \brief Set the ative scalar array to the named field 243 */ 244 bool DataSet::setActiveScalars(const char *name) 245 { 246 bool found = false; 247 if (_dataSet != NULL) { 248 if (_dataSet->GetPointData() != NULL) { 249 if (_dataSet->GetPointData()->SetActiveScalars(name) >= 0) 250 found = true; 251 } 252 if (_dataSet->GetCellData() != NULL) { 253 if (_dataSet->GetCellData()->SetActiveScalars(name) >= 0) 254 found = true; 255 } 256 } 257 return found; 258 } 259 260 /** 261 * \brief Set the ative vector array to the named field 262 */ 263 bool DataSet::setActiveVectors(const char *name) 264 { 265 bool found = false; 266 if (_dataSet != NULL) { 267 if (_dataSet->GetPointData() != NULL) { 268 if (_dataSet->GetPointData()->SetActiveVectors(name) >= 0) 269 found = true; 270 } 271 if (_dataSet->GetCellData() != NULL) { 272 if (_dataSet->GetCellData()->SetActiveVectors(name) >= 0) 273 found = true; 274 } 275 } 276 return found; 277 } 278 279 /** 227 280 * \brief Get the range of scalar values in the DataSet 228 281 */ 229 void DataSet::getDataRange(double minmax[2]) 230 { 231 memcpy(minmax, _dataRange, sizeof(double)*2); 282 void DataSet::getDataRange(double minmax[2]) const 283 { 284 _dataSet->GetScalarRange(minmax); 285 } 286 287 /** 288 * \brief Get the range of scalar values (or vector magnitudes) for 289 * the named field in the DataSet 290 */ 291 void DataSet::getDataRange(double minmax[2], const char *fieldName) const 292 { 293 if (_dataSet == NULL) 294 return; 295 if (_dataSet->GetPointData() != NULL && 296 _dataSet->GetPointData()->GetArray(fieldName) != NULL) { 297 _dataSet->GetPointData()->GetArray(fieldName)->GetRange(minmax, -1); 298 } else if (_dataSet->GetCellData() != NULL && 299 _dataSet->GetCellData()->GetArray(fieldName) != NULL) { 300 _dataSet->GetCellData()->GetArray(fieldName)->GetRange(minmax, -1); 301 } else if (_dataSet->GetFieldData() != NULL && 302 _dataSet->GetFieldData()->GetArray(fieldName) != NULL) { 303 _dataSet->GetFieldData()->GetArray(fieldName)->GetRange(minmax, -1); 304 } 305 } 306 307 /** 308 * \brief Get the range of vector magnitudes in the DataSet 309 */ 310 void DataSet::getVectorMagnitudeRange(double minmax[2]) const 311 { 312 if (_dataSet == NULL) 313 return; 314 if (_dataSet->GetPointData() != NULL && 315 _dataSet->GetPointData()->GetVectors() != NULL) { 316 _dataSet->GetPointData()->GetVectors()->GetRange(minmax, -1); 317 } else if (_dataSet->GetCellData() != NULL && 318 _dataSet->GetCellData()->GetVectors() != NULL) { 319 _dataSet->GetCellData()->GetVectors()->GetRange(minmax, -1); 320 } 321 } 322 323 /** 324 * \brief Get the range of a vector component in the DataSet 325 */ 326 void DataSet::getVectorComponentRange(double minmax[2], int component) const 327 { 328 if (_dataSet == NULL) 329 return; 330 if (_dataSet->GetPointData() != NULL && 331 _dataSet->GetPointData()->GetVectors() != NULL) { 332 _dataSet->GetPointData()->GetVectors()->GetRange(minmax, component); 333 } else if (_dataSet->GetCellData() != NULL && 334 _dataSet->GetCellData()->GetVectors() != NULL) { 335 _dataSet->GetCellData()->GetVectors()->GetRange(minmax, component); 336 } 232 337 } 233 338 … … 235 340 * \brief Get the bounds the DataSet 236 341 */ 237 void DataSet::getBounds(double bounds[6]) 238 { 239 memcpy(bounds, _bounds, sizeof(double)*6);342 void DataSet::getBounds(double bounds[6]) const 343 { 344 _dataSet->GetBounds(bounds); 240 345 } 241 346 … … 247 352 * \return the value of the nearest point or 0 if no scalar data available 248 353 */ 249 double DataSet::getDataValue(double x, double y, double z) 354 double DataSet::getDataValue(double x, double y, double z) const 250 355 { 251 356 if (_dataSet == NULL) -
branches/blt4/packages/vizservers/vtkvis/RpVtkDataSet.h
r2302 r2409 43 43 vtkDataSet *getVtkDataSet(); 44 44 45 const char *getVtkType() ;45 const char *getVtkType() const; 46 46 47 void getDataRange(double minmax[2]);47 bool setActiveScalars(const char *name); 48 48 49 void getBounds(double bounds[6]);49 bool setActiveVectors(const char *name); 50 50 51 double getDataValue(double x, double y, double z); 51 void getDataRange(double minmax[2]) const; 52 53 void getDataRange(double minmax[2], const char *fieldName) const; 54 55 void getVectorMagnitudeRange(double minmax[2]) const; 56 57 void getVectorComponentRange(double minmax[2], int component) const; 58 59 void getBounds(double bounds[6]) const; 60 61 double getDataValue(double x, double y, double z) const; 52 62 53 63 void setVisibility(bool state); … … 60 70 std::string _name; 61 71 vtkSmartPointer<vtkDataSet> _dataSet; 62 double _dataRange[2];63 double _bounds[6];64 72 bool _visible; 65 73 }; -
branches/blt4/packages/vizservers/vtkvis/RpVtkRenderServer.cpp
r2302 r2409 168 168 g_fdOut = fileno(stdout); 169 169 170 /* This synchronizes the client with the server, so that the client 171 * doesn't start writing commands before the server is ready. It could 172 * also be used to supply information about the server (version, memory 173 * size, etc). */ 174 fprintf(stdout, "VtkVis 1.0\n"); 175 fflush(stdout); 176 170 177 g_renderer = new Renderer(); 171 178 vtkSmartPointer<vtkUnsignedCharArray> imgData = -
branches/blt4/packages/vizservers/vtkvis/RpVtkRenderer.cpp
r2322 r2409 65 65 _cameraPan[0] = 0; 66 66 _cameraPan[1] = 0; 67 _cameraOrientation[0] = 1.0; 68 _cameraOrientation[1] = 0.0; 69 _cameraOrientation[2] = 0.0; 70 _cameraOrientation[3] = 0.0; 67 71 _cumulativeDataRange[0] = 0.0; 68 72 _cumulativeDataRange[1] = 1.0; … … 125 129 initAxes(); 126 130 initCamera(); 127 storeCameraOrientation();128 131 addColorMap("default", ColorMap::getDefault()); 129 132 addColorMap("volumeDefault", ColorMap::getVolumeDefault()); … … 682 685 } else 683 686 return false; 687 } 688 689 bool Renderer::setDataSetActiveScalars(const DataSetId& id, const char *scalarName) 690 { 691 DataSetHashmap::iterator itr; 692 693 bool doAll = false; 694 695 if (id.compare("all") == 0) { 696 itr = _dataSets.begin(); 697 doAll = true; 698 } else { 699 itr = _dataSets.find(id); 700 } 701 if (itr == _dataSets.end()) { 702 ERROR("DataSet not found: %s", id.c_str()); 703 return false; 704 } 705 706 bool ret = true; 707 do { 708 if (!itr->second->setActiveScalars(scalarName)) { 709 ret = false; 710 } 711 } while (doAll && ++itr != _dataSets.end()); 712 713 if (ret) { 714 collectDataRanges(_cumulativeDataRange, _cumulativeRangeOnlyVisible); 715 updateRanges(_useCumulativeRange); 716 _needsRedraw = true; 717 } 718 719 return ret; 720 } 721 722 bool Renderer::setDataSetActiveVectors(const DataSetId& id, const char *vectorName) 723 { 724 DataSetHashmap::iterator itr; 725 726 bool doAll = false; 727 728 if (id.compare("all") == 0) { 729 itr = _dataSets.begin(); 730 doAll = true; 731 } else { 732 itr = _dataSets.find(id); 733 } 734 if (itr == _dataSets.end()) { 735 ERROR("DataSet not found: %s", id.c_str()); 736 return false; 737 } 738 739 bool ret = true; 740 do { 741 if (!itr->second->setActiveVectors(vectorName)) { 742 ret = false; 743 } 744 } while (doAll && ++itr != _dataSets.end()); 745 746 if (ret) { 747 collectDataRanges(_cumulativeDataRange, _cumulativeRangeOnlyVisible); 748 updateRanges(_useCumulativeRange); 749 _needsRedraw = true; 750 } 751 752 return ret; 684 753 } 685 754 … … 853 922 854 923 /** 924 * \brief Turn on/off rendering of all axes 925 */ 926 void Renderer::setAxesVisibility(bool state) 927 { 928 if (_cubeAxesActor != NULL) { 929 _cubeAxesActor->SetVisibility((state ? 1 : 0)); 930 _needsRedraw = true; 931 } 932 if (_cubeAxesActor2D != NULL) { 933 _cubeAxesActor2D->SetVisibility((state ? 1 : 0)); 934 _needsRedraw = true; 935 } 936 setAxisVisibility(X_AXIS, state); 937 setAxisVisibility(Y_AXIS, state); 938 setAxisVisibility(Z_AXIS, state); 939 } 940 941 /** 855 942 * \brief Turn on/off rendering of all axes gridlines 856 943 */ 857 944 void Renderer::setAxesGridVisibility(bool state) 858 945 { 946 setAxisGridVisibility(X_AXIS, state); 947 setAxisGridVisibility(Y_AXIS, state); 948 setAxisGridVisibility(Z_AXIS, state); 949 } 950 951 /** 952 * \brief Turn on/off rendering of all axis labels 953 */ 954 void Renderer::setAxesLabelVisibility(bool state) 955 { 956 setAxisLabelVisibility(X_AXIS, state); 957 setAxisLabelVisibility(Y_AXIS, state); 958 setAxisLabelVisibility(Z_AXIS, state); 959 } 960 961 /** 962 * \brief Turn on/off rendering of all axis ticks 963 */ 964 void Renderer::setAxesTickVisibility(bool state) 965 { 966 setAxisTickVisibility(X_AXIS, state); 967 setAxisTickVisibility(Y_AXIS, state); 968 setAxisTickVisibility(Z_AXIS, state); 969 } 970 971 /** 972 * \brief Control position of ticks on 3D axes 973 */ 974 void Renderer::setAxesTickPosition(AxesTickPosition pos) 975 { 976 if (_cubeAxesActor == NULL) 977 return; 978 979 switch (pos) { 980 case TICKS_BOTH: 981 _cubeAxesActor->SetTickLocationToBoth(); 982 break; 983 case TICKS_OUTSIDE: 984 _cubeAxesActor->SetTickLocationToOutside(); 985 break; 986 case TICKS_INSIDE: 987 default: 988 _cubeAxesActor->SetTickLocationToInside(); 989 break; 990 } 991 _needsRedraw = true; 992 } 993 994 /** 995 * \brief Turn on/off rendering of the specified axis 996 */ 997 void Renderer::setAxisVisibility(Axis axis, bool state) 998 { 859 999 if (_cubeAxesActor != NULL) { 860 _cubeAxesActor->SetDrawXGridlines((state ? 1 : 0)); 861 _cubeAxesActor->SetDrawYGridlines((state ? 1 : 0)); 862 _cubeAxesActor->SetDrawZGridlines((state ? 1 : 0)); 1000 if (axis == X_AXIS) { 1001 _cubeAxesActor->SetXAxisVisibility((state ? 1 : 0)); 1002 } else if (axis == Y_AXIS) { 1003 _cubeAxesActor->SetYAxisVisibility((state ? 1 : 0)); 1004 } else if (axis == Z_AXIS) { 1005 _cubeAxesActor->SetZAxisVisibility((state ? 1 : 0)); 1006 } 1007 _needsRedraw = true; 1008 } 1009 if (_cubeAxesActor2D != NULL) { 1010 if (axis == X_AXIS) { 1011 _cubeAxesActor2D->SetXAxisVisibility((state ? 1 : 0)); 1012 } else if (axis == Y_AXIS) { 1013 _cubeAxesActor2D->SetYAxisVisibility((state ? 1 : 0)); 1014 } 863 1015 _needsRedraw = true; 864 1016 } … … 883 1035 884 1036 /** 885 * \brief Turn on/off rendering of all axes 886 */ 887 void Renderer::setAxesVisibility(bool state) 888 { 889 if (_cubeAxesActor != NULL) { 890 _cubeAxesActor->SetVisibility((state ? 1 : 0)); 891 _needsRedraw = true; 892 } 893 if (_cubeAxesActor2D != NULL) { 894 _cubeAxesActor2D->SetVisibility((state ? 1 : 0)); 895 _needsRedraw = true; 896 } 897 setAxisVisibility(X_AXIS, state); 898 setAxisVisibility(Y_AXIS, state); 899 setAxisVisibility(Z_AXIS, state); 900 } 901 902 /** 903 * \brief Turn on/off rendering of the specified axis 904 */ 905 void Renderer::setAxisVisibility(Axis axis, bool state) 1037 * \brief Toggle label visibility for the specified axis 1038 */ 1039 void Renderer::setAxisLabelVisibility(Axis axis, bool state) 906 1040 { 907 1041 if (_cubeAxesActor != NULL) { 908 1042 if (axis == X_AXIS) { 909 _cubeAxesActor->SetXAxis Visibility((state ? 1 : 0));1043 _cubeAxesActor->SetXAxisLabelVisibility((state ? 1 : 0)); 910 1044 } else if (axis == Y_AXIS) { 911 _cubeAxesActor->SetYAxis Visibility((state ? 1 : 0));1045 _cubeAxesActor->SetYAxisLabelVisibility((state ? 1 : 0)); 912 1046 } else if (axis == Z_AXIS) { 913 _cubeAxesActor->SetZAxis Visibility((state ? 1 : 0));1047 _cubeAxesActor->SetZAxisLabelVisibility((state ? 1 : 0)); 914 1048 } 915 1049 _needsRedraw = true; … … 917 1051 if (_cubeAxesActor2D != NULL) { 918 1052 if (axis == X_AXIS) { 919 _cubeAxesActor2D-> SetXAxisVisibility((state ? 1 : 0));1053 _cubeAxesActor2D->GetXAxisActor2D()->SetLabelVisibility((state ? 1 : 0)); 920 1054 } else if (axis == Y_AXIS) { 921 _cubeAxesActor2D->SetYAxisVisibility((state ? 1 : 0)); 1055 _cubeAxesActor2D->GetYAxisActor2D()->SetLabelVisibility((state ? 1 : 0)); 1056 } 1057 _needsRedraw = true; 1058 } 1059 } 1060 1061 /** 1062 * \brief Toggle tick visibility for the specified axis 1063 */ 1064 void Renderer::setAxisTickVisibility(Axis axis, bool state) 1065 { 1066 if (_cubeAxesActor != NULL) { 1067 if (axis == X_AXIS) { 1068 _cubeAxesActor->SetXAxisTickVisibility((state ? 1 : 0)); 1069 } else if (axis == Y_AXIS) { 1070 _cubeAxesActor->SetYAxisTickVisibility((state ? 1 : 0)); 1071 } else if (axis == Z_AXIS) { 1072 _cubeAxesActor->SetZAxisTickVisibility((state ? 1 : 0)); 1073 } 1074 _needsRedraw = true; 1075 } 1076 if (_cubeAxesActor2D != NULL) { 1077 if (axis == X_AXIS) { 1078 _cubeAxesActor2D->GetXAxisActor2D()->SetTickVisibility((state ? 1 : 0)); 1079 } else if (axis == Y_AXIS) { 1080 _cubeAxesActor2D->GetYAxisActor2D()->SetTickVisibility((state ? 1 : 0)); 922 1081 } 923 1082 _needsRedraw = true; … … 1200 1359 } else 1201 1360 return itr->second; 1361 } 1362 1363 /** 1364 * \brief Set the prop orientation with a quaternion 1365 */ 1366 void Renderer::setContour2DTransform(const DataSetId& id, vtkMatrix4x4 *trans) 1367 { 1368 Contour2DHashmap::iterator itr; 1369 1370 bool doAll = false; 1371 1372 if (id.compare("all") == 0) { 1373 itr = _contour2Ds.begin(); 1374 doAll = true; 1375 } else { 1376 itr = _contour2Ds.find(id); 1377 } 1378 if (itr == _contour2Ds.end()) { 1379 ERROR("Contour2D not found: %s", id.c_str()); 1380 return; 1381 } 1382 1383 do { 1384 itr->second->setTransform(trans); 1385 } while (doAll && ++itr != _contour2Ds.end()); 1386 1387 resetAxes(); 1388 _needsRedraw = true; 1389 } 1390 1391 /** 1392 * \brief Set the prop orientation with a quaternion 1393 */ 1394 void Renderer::setContour2DOrientation(const DataSetId& id, double quat[4]) 1395 { 1396 Contour2DHashmap::iterator itr; 1397 1398 bool doAll = false; 1399 1400 if (id.compare("all") == 0) { 1401 itr = _contour2Ds.begin(); 1402 doAll = true; 1403 } else { 1404 itr = _contour2Ds.find(id); 1405 } 1406 if (itr == _contour2Ds.end()) { 1407 ERROR("Contour2D not found: %s", id.c_str()); 1408 return; 1409 } 1410 1411 do { 1412 itr->second->setOrientation(quat); 1413 } while (doAll && ++itr != _contour2Ds.end()); 1414 1415 resetAxes(); 1416 _needsRedraw = true; 1417 } 1418 1419 /** 1420 * \brief Set the prop orientation with a rotation about an axis 1421 */ 1422 void Renderer::setContour2DOrientation(const DataSetId& id, double angle, double axis[3]) 1423 { 1424 Contour2DHashmap::iterator itr; 1425 1426 bool doAll = false; 1427 1428 if (id.compare("all") == 0) { 1429 itr = _contour2Ds.begin(); 1430 doAll = true; 1431 } else { 1432 itr = _contour2Ds.find(id); 1433 } 1434 if (itr == _contour2Ds.end()) { 1435 ERROR("Contour2D not found: %s", id.c_str()); 1436 return; 1437 } 1438 1439 do { 1440 itr->second->setOrientation(angle, axis); 1441 } while (doAll && ++itr != _contour2Ds.end()); 1442 1443 resetAxes(); 1444 _needsRedraw = true; 1445 } 1446 1447 /** 1448 * \brief Set the prop position in world coords 1449 */ 1450 void Renderer::setContour2DPosition(const DataSetId& id, double pos[3]) 1451 { 1452 Contour2DHashmap::iterator itr; 1453 1454 bool doAll = false; 1455 1456 if (id.compare("all") == 0) { 1457 itr = _contour2Ds.begin(); 1458 doAll = true; 1459 } else { 1460 itr = _contour2Ds.find(id); 1461 } 1462 if (itr == _contour2Ds.end()) { 1463 ERROR("Contour2D not found: %s", id.c_str()); 1464 return; 1465 } 1466 1467 do { 1468 itr->second->setPosition(pos); 1469 } while (doAll && ++itr != _contour2Ds.end()); 1470 1471 resetAxes(); 1472 _needsRedraw = true; 1473 } 1474 1475 /** 1476 * \brief Set the prop scaling 1477 */ 1478 void Renderer::setContour2DScale(const DataSetId& id, double scale[3]) 1479 { 1480 Contour2DHashmap::iterator itr; 1481 1482 bool doAll = false; 1483 1484 if (id.compare("all") == 0) { 1485 itr = _contour2Ds.begin(); 1486 doAll = true; 1487 } else { 1488 itr = _contour2Ds.find(id); 1489 } 1490 if (itr == _contour2Ds.end()) { 1491 ERROR("Contour2D not found: %s", id.c_str()); 1492 return; 1493 } 1494 1495 do { 1496 itr->second->setScale(scale); 1497 } while (doAll && ++itr != _contour2Ds.end()); 1498 1499 resetAxes(); 1500 _needsRedraw = true; 1202 1501 } 1203 1502 … … 1468 1767 1469 1768 /** 1769 * \brief Set the prop orientation with a quaternion 1770 */ 1771 void Renderer::setContour3DTransform(const DataSetId& id, vtkMatrix4x4 *trans) 1772 { 1773 Contour3DHashmap::iterator itr; 1774 1775 bool doAll = false; 1776 1777 if (id.compare("all") == 0) { 1778 itr = _contour3Ds.begin(); 1779 doAll = true; 1780 } else { 1781 itr = _contour3Ds.find(id); 1782 } 1783 if (itr == _contour3Ds.end()) { 1784 ERROR("Contour3D not found: %s", id.c_str()); 1785 return; 1786 } 1787 1788 do { 1789 itr->second->setTransform(trans); 1790 } while (doAll && ++itr != _contour3Ds.end()); 1791 1792 resetAxes(); 1793 _needsRedraw = true; 1794 } 1795 1796 /** 1797 * \brief Set the prop orientation with a quaternion 1798 */ 1799 void Renderer::setContour3DOrientation(const DataSetId& id, double quat[4]) 1800 { 1801 Contour3DHashmap::iterator itr; 1802 1803 bool doAll = false; 1804 1805 if (id.compare("all") == 0) { 1806 itr = _contour3Ds.begin(); 1807 doAll = true; 1808 } else { 1809 itr = _contour3Ds.find(id); 1810 } 1811 if (itr == _contour3Ds.end()) { 1812 ERROR("Contour3D not found: %s", id.c_str()); 1813 return; 1814 } 1815 1816 do { 1817 itr->second->setOrientation(quat); 1818 } while (doAll && ++itr != _contour3Ds.end()); 1819 1820 resetAxes(); 1821 _needsRedraw = true; 1822 } 1823 1824 /** 1825 * \brief Set the prop orientation with a rotation about an axis 1826 */ 1827 void Renderer::setContour3DOrientation(const DataSetId& id, double angle, double axis[3]) 1828 { 1829 Contour3DHashmap::iterator itr; 1830 1831 bool doAll = false; 1832 1833 if (id.compare("all") == 0) { 1834 itr = _contour3Ds.begin(); 1835 doAll = true; 1836 } else { 1837 itr = _contour3Ds.find(id); 1838 } 1839 if (itr == _contour3Ds.end()) { 1840 ERROR("Contour3D not found: %s", id.c_str()); 1841 return; 1842 } 1843 1844 do { 1845 itr->second->setOrientation(angle, axis); 1846 } while (doAll && ++itr != _contour3Ds.end()); 1847 1848 resetAxes(); 1849 _needsRedraw = true; 1850 } 1851 1852 /** 1853 * \brief Set the prop position in world coords 1854 */ 1855 void Renderer::setContour3DPosition(const DataSetId& id, double pos[3]) 1856 { 1857 Contour3DHashmap::iterator itr; 1858 1859 bool doAll = false; 1860 1861 if (id.compare("all") == 0) { 1862 itr = _contour3Ds.begin(); 1863 doAll = true; 1864 } else { 1865 itr = _contour3Ds.find(id); 1866 } 1867 if (itr == _contour3Ds.end()) { 1868 ERROR("Contour3D not found: %s", id.c_str()); 1869 return; 1870 } 1871 1872 do { 1873 itr->second->setPosition(pos); 1874 } while (doAll && ++itr != _contour3Ds.end()); 1875 1876 resetAxes(); 1877 _needsRedraw = true; 1878 } 1879 1880 /** 1881 * \brief Set the prop scaling 1882 */ 1883 void Renderer::setContour3DScale(const DataSetId& id, double scale[3]) 1884 { 1885 Contour3DHashmap::iterator itr; 1886 1887 bool doAll = false; 1888 1889 if (id.compare("all") == 0) { 1890 itr = _contour3Ds.begin(); 1891 doAll = true; 1892 } else { 1893 itr = _contour3Ds.find(id); 1894 } 1895 if (itr == _contour3Ds.end()) { 1896 ERROR("Contour3D not found: %s", id.c_str()); 1897 return; 1898 } 1899 1900 do { 1901 itr->second->setScale(scale); 1902 } while (doAll && ++itr != _contour3Ds.end()); 1903 1904 resetAxes(); 1905 _needsRedraw = true; 1906 } 1907 1908 /** 1470 1909 * \brief Set the number of equally spaced isosurfaces for the given DataSet 1471 1910 */ … … 1870 2309 1871 2310 /** 2311 * \brief Set the prop orientation with a quaternion 2312 */ 2313 void Renderer::setGlyphsTransform(const DataSetId& id, vtkMatrix4x4 *trans) 2314 { 2315 GlyphsHashmap::iterator itr; 2316 2317 bool doAll = false; 2318 2319 if (id.compare("all") == 0) { 2320 itr = _glyphs.begin(); 2321 doAll = true; 2322 } else { 2323 itr = _glyphs.find(id); 2324 } 2325 if (itr == _glyphs.end()) { 2326 ERROR("Glyphs not found: %s", id.c_str()); 2327 return; 2328 } 2329 2330 do { 2331 itr->second->setTransform(trans); 2332 } while (doAll && ++itr != _glyphs.end()); 2333 2334 resetAxes(); 2335 _needsRedraw = true; 2336 } 2337 2338 /** 2339 * \brief Set the prop orientation with a quaternion 2340 */ 2341 void Renderer::setGlyphsOrientation(const DataSetId& id, double quat[4]) 2342 { 2343 GlyphsHashmap::iterator itr; 2344 2345 bool doAll = false; 2346 2347 if (id.compare("all") == 0) { 2348 itr = _glyphs.begin(); 2349 doAll = true; 2350 } else { 2351 itr = _glyphs.find(id); 2352 } 2353 if (itr == _glyphs.end()) { 2354 ERROR("Glyphs not found: %s", id.c_str()); 2355 return; 2356 } 2357 2358 do { 2359 itr->second->setOrientation(quat); 2360 } while (doAll && ++itr != _glyphs.end()); 2361 2362 resetAxes(); 2363 _needsRedraw = true; 2364 } 2365 2366 /** 2367 * \brief Set the prop orientation with a rotation about an axis 2368 */ 2369 void Renderer::setGlyphsOrientation(const DataSetId& id, double angle, double axis[3]) 2370 { 2371 GlyphsHashmap::iterator itr; 2372 2373 bool doAll = false; 2374 2375 if (id.compare("all") == 0) { 2376 itr = _glyphs.begin(); 2377 doAll = true; 2378 } else { 2379 itr = _glyphs.find(id); 2380 } 2381 if (itr == _glyphs.end()) { 2382 ERROR("Glyphs not found: %s", id.c_str()); 2383 return; 2384 } 2385 2386 do { 2387 itr->second->setOrientation(angle, axis); 2388 } while (doAll && ++itr != _glyphs.end()); 2389 2390 resetAxes(); 2391 _needsRedraw = true; 2392 } 2393 2394 /** 2395 * \brief Set the prop position in world coords 2396 */ 2397 void Renderer::setGlyphsPosition(const DataSetId& id, double pos[3]) 2398 { 2399 GlyphsHashmap::iterator itr; 2400 2401 bool doAll = false; 2402 2403 if (id.compare("all") == 0) { 2404 itr = _glyphs.begin(); 2405 doAll = true; 2406 } else { 2407 itr = _glyphs.find(id); 2408 } 2409 if (itr == _glyphs.end()) { 2410 ERROR("Glyphs not found: %s", id.c_str()); 2411 return; 2412 } 2413 2414 do { 2415 itr->second->setPosition(pos); 2416 } while (doAll && ++itr != _glyphs.end()); 2417 2418 resetAxes(); 2419 _needsRedraw = true; 2420 } 2421 2422 /** 2423 * \brief Set the prop scaling 2424 */ 2425 void Renderer::setGlyphsScale(const DataSetId& id, double scale[3]) 2426 { 2427 GlyphsHashmap::iterator itr; 2428 2429 bool doAll = false; 2430 2431 if (id.compare("all") == 0) { 2432 itr = _glyphs.begin(); 2433 doAll = true; 2434 } else { 2435 itr = _glyphs.find(id); 2436 } 2437 if (itr == _glyphs.end()) { 2438 ERROR("Glyphs not found: %s", id.c_str()); 2439 return; 2440 } 2441 2442 do { 2443 itr->second->setScale(scale); 2444 } while (doAll && ++itr != _glyphs.end()); 2445 2446 resetAxes(); 2447 _needsRedraw = true; 2448 } 2449 2450 /** 2451 * \brief Set the RGB polygon color for the specified DataSet 2452 */ 2453 void Renderer::setGlyphsColor(const DataSetId& id, float color[3]) 2454 { 2455 GlyphsHashmap::iterator itr; 2456 2457 bool doAll = false; 2458 2459 if (id.compare("all") == 0) { 2460 itr = _glyphs.begin(); 2461 doAll = true; 2462 } else { 2463 itr = _glyphs.find(id); 2464 } 2465 if (itr == _glyphs.end()) { 2466 ERROR("Glyphs not found: %s", id.c_str()); 2467 return; 2468 } 2469 2470 do { 2471 itr->second->setColor(color); 2472 } while (doAll && ++itr != _glyphs.end()); 2473 2474 _needsRedraw = true; 2475 } 2476 2477 /** 1872 2478 * \brief Associate an existing named color map with a Glyphs for the given DataSet 1873 2479 */ … … 1923 2529 1924 2530 /** 1925 * \brief Set the shape of Glyphs for the given DataSet1926 */ 1927 void Renderer::setGlyphs Shape(const DataSetId& id, Glyphs::GlyphShape shape)2531 * \brief Controls the array used to color glyphs for the given DataSet 2532 */ 2533 void Renderer::setGlyphsColorMode(const DataSetId& id, Glyphs::ColorMode mode) 1928 2534 { 1929 2535 GlyphsHashmap::iterator itr; … … 1943 2549 1944 2550 do { 2551 itr->second->setColorMode(mode); 2552 } while (doAll && ++itr != _glyphs.end()); 2553 2554 _needsRedraw = true; 2555 } 2556 2557 /** 2558 * \brief Controls the array used to scale glyphs for the given DataSet 2559 */ 2560 void Renderer::setGlyphsScalingMode(const DataSetId& id, Glyphs::ScalingMode mode) 2561 { 2562 GlyphsHashmap::iterator itr; 2563 2564 bool doAll = false; 2565 2566 if (id.compare("all") == 0) { 2567 itr = _glyphs.begin(); 2568 doAll = true; 2569 } else { 2570 itr = _glyphs.find(id); 2571 } 2572 if (itr == _glyphs.end()) { 2573 ERROR("Glyphs not found: %s", id.c_str()); 2574 return; 2575 } 2576 2577 do { 2578 itr->second->setScalingMode(mode); 2579 } while (doAll && ++itr != _glyphs.end()); 2580 2581 _renderer->ResetCameraClippingRange(); 2582 _needsRedraw = true; 2583 } 2584 2585 /** 2586 * \brief Set the shape of Glyphs for the given DataSet 2587 */ 2588 void Renderer::setGlyphsShape(const DataSetId& id, Glyphs::GlyphShape shape) 2589 { 2590 GlyphsHashmap::iterator itr; 2591 2592 bool doAll = false; 2593 2594 if (id.compare("all") == 0) { 2595 itr = _glyphs.begin(); 2596 doAll = true; 2597 } else { 2598 itr = _glyphs.find(id); 2599 } 2600 if (itr == _glyphs.end()) { 2601 ERROR("Glyphs not found: %s", id.c_str()); 2602 return; 2603 } 2604 2605 do { 1945 2606 itr->second->setGlyphShape(shape); 1946 2607 } while (doAll && ++itr != _glyphs.end()); … … 1979 2640 1980 2641 /** 1981 * \brief Set opacity of Glyphs for the givenDataSet1982 */ 1983 void Renderer::setGlyphs Opacity(const DataSetId& id, double opacity)2642 * \brief Set the visibility of polygon edges for the specified DataSet 2643 */ 2644 void Renderer::setGlyphsEdgeVisibility(const DataSetId& id, bool state) 1984 2645 { 1985 2646 GlyphsHashmap::iterator itr; … … 1999 2660 2000 2661 do { 2662 itr->second->setEdgeVisibility(state); 2663 } while (doAll && ++itr != _glyphs.end()); 2664 2665 _needsRedraw = true; 2666 } 2667 2668 /** 2669 * \brief Set the RGB polygon edge color for the specified DataSet 2670 */ 2671 void Renderer::setGlyphsEdgeColor(const DataSetId& id, float color[3]) 2672 { 2673 GlyphsHashmap::iterator itr; 2674 2675 bool doAll = false; 2676 2677 if (id.compare("all") == 0) { 2678 itr = _glyphs.begin(); 2679 doAll = true; 2680 } else { 2681 itr = _glyphs.find(id); 2682 } 2683 if (itr == _glyphs.end()) { 2684 ERROR("Glyphs not found: %s", id.c_str()); 2685 return; 2686 } 2687 2688 do { 2689 itr->second->setEdgeColor(color); 2690 } while (doAll && ++itr != _glyphs.end()); 2691 2692 _needsRedraw = true; 2693 } 2694 2695 /** 2696 * \brief Set the polygon edge width for the specified DataSet (may be a no-op) 2697 * 2698 * If the OpenGL implementation/hardware does not support wide lines, 2699 * this function may not have an effect. 2700 */ 2701 void Renderer::setGlyphsEdgeWidth(const DataSetId& id, float edgeWidth) 2702 { 2703 GlyphsHashmap::iterator itr; 2704 2705 bool doAll = false; 2706 2707 if (id.compare("all") == 0) { 2708 itr = _glyphs.begin(); 2709 doAll = true; 2710 } else { 2711 itr = _glyphs.find(id); 2712 } 2713 if (itr == _glyphs.end()) { 2714 ERROR("Glyphs not found: %s", id.c_str()); 2715 return; 2716 } 2717 2718 do { 2719 itr->second->setEdgeWidth(edgeWidth); 2720 } while (doAll && ++itr != _glyphs.end()); 2721 2722 _needsRedraw = true; 2723 } 2724 2725 /** 2726 * \brief Turn Glyphs lighting on/off for the specified DataSet 2727 */ 2728 void Renderer::setGlyphsLighting(const DataSetId& id, bool state) 2729 { 2730 GlyphsHashmap::iterator itr; 2731 2732 bool doAll = false; 2733 2734 if (id.compare("all") == 0) { 2735 itr = _glyphs.begin(); 2736 doAll = true; 2737 } else { 2738 itr = _glyphs.find(id); 2739 } 2740 if (itr == _glyphs.end()) { 2741 ERROR("Glyphs not found: %s", id.c_str()); 2742 return; 2743 } 2744 2745 do { 2746 itr->second->setLighting(state); 2747 } while (doAll && ++itr != _glyphs.end()); 2748 _needsRedraw = true; 2749 } 2750 2751 /** 2752 * \brief Set opacity of Glyphs for the given DataSet 2753 */ 2754 void Renderer::setGlyphsOpacity(const DataSetId& id, double opacity) 2755 { 2756 GlyphsHashmap::iterator itr; 2757 2758 bool doAll = false; 2759 2760 if (id.compare("all") == 0) { 2761 itr = _glyphs.begin(); 2762 doAll = true; 2763 } else { 2764 itr = _glyphs.find(id); 2765 } 2766 if (itr == _glyphs.end()) { 2767 ERROR("Glyphs not found: %s", id.c_str()); 2768 return; 2769 } 2770 2771 do { 2001 2772 itr->second->setOpacity(opacity); 2002 2773 } while (doAll && ++itr != _glyphs.end()); … … 2033 2804 2034 2805 /** 2035 * \brief Turn Glyphs lighting on/off for the specifiedDataSet2036 */ 2037 void Renderer::setGlyphs Lighting(const DataSetId& id, bool state)2806 * \brief Turn on/off wireframe rendering of Glyphs for the given DataSet 2807 */ 2808 void Renderer::setGlyphsWireframe(const DataSetId& id, bool state) 2038 2809 { 2039 2810 GlyphsHashmap::iterator itr; … … 2053 2824 2054 2825 do { 2055 itr->second->set Lighting(state);2826 itr->second->setWireframe(state); 2056 2827 } while (doAll && ++itr != _glyphs.end()); 2828 2057 2829 _needsRedraw = true; 2058 2830 } … … 2130 2902 2131 2903 /** 2904 * \brief Set an additional transform on the prop 2905 */ 2906 void Renderer::setHeightMapTransform(const DataSetId& id, vtkMatrix4x4 *trans) 2907 { 2908 HeightMapHashmap::iterator itr; 2909 2910 bool doAll = false; 2911 2912 if (id.compare("all") == 0) { 2913 itr = _heightMaps.begin(); 2914 doAll = true; 2915 } else { 2916 itr = _heightMaps.find(id); 2917 } 2918 if (itr == _heightMaps.end()) { 2919 ERROR("HeightMap not found: %s", id.c_str()); 2920 return; 2921 } 2922 2923 do { 2924 itr->second->setTransform(trans); 2925 } while (doAll && ++itr != _heightMaps.end()); 2926 2927 resetAxes(); 2928 _needsRedraw = true; 2929 } 2930 2931 /** 2932 * \brief Set the prop orientation with a quaternion 2933 */ 2934 void Renderer::setHeightMapOrientation(const DataSetId& id, double quat[4]) 2935 { 2936 HeightMapHashmap::iterator itr; 2937 2938 bool doAll = false; 2939 2940 if (id.compare("all") == 0) { 2941 itr = _heightMaps.begin(); 2942 doAll = true; 2943 } else { 2944 itr = _heightMaps.find(id); 2945 } 2946 if (itr == _heightMaps.end()) { 2947 ERROR("HeightMap not found: %s", id.c_str()); 2948 return; 2949 } 2950 2951 do { 2952 itr->second->setOrientation(quat); 2953 } while (doAll && ++itr != _heightMaps.end()); 2954 2955 resetAxes(); 2956 _needsRedraw = true; 2957 } 2958 2959 /** 2960 * \brief Set the prop orientation with a rotation about an axis 2961 */ 2962 void Renderer::setHeightMapOrientation(const DataSetId& id, double angle, double axis[3]) 2963 { 2964 HeightMapHashmap::iterator itr; 2965 2966 bool doAll = false; 2967 2968 if (id.compare("all") == 0) { 2969 itr = _heightMaps.begin(); 2970 doAll = true; 2971 } else { 2972 itr = _heightMaps.find(id); 2973 } 2974 if (itr == _heightMaps.end()) { 2975 ERROR("HeightMap not found: %s", id.c_str()); 2976 return; 2977 } 2978 2979 do { 2980 itr->second->setOrientation(angle, axis); 2981 } while (doAll && ++itr != _heightMaps.end()); 2982 2983 resetAxes(); 2984 _needsRedraw = true; 2985 } 2986 2987 /** 2988 * \brief Set the prop position in world coords 2989 */ 2990 void Renderer::setHeightMapPosition(const DataSetId& id, double pos[3]) 2991 { 2992 HeightMapHashmap::iterator itr; 2993 2994 bool doAll = false; 2995 2996 if (id.compare("all") == 0) { 2997 itr = _heightMaps.begin(); 2998 doAll = true; 2999 } else { 3000 itr = _heightMaps.find(id); 3001 } 3002 if (itr == _heightMaps.end()) { 3003 ERROR("HeightMap not found: %s", id.c_str()); 3004 return; 3005 } 3006 3007 do { 3008 itr->second->setPosition(pos); 3009 } while (doAll && ++itr != _heightMaps.end()); 3010 3011 resetAxes(); 3012 _needsRedraw = true; 3013 } 3014 3015 /** 3016 * \brief Set the prop scaling 3017 */ 3018 void Renderer::setHeightMapScale(const DataSetId& id, double scale[3]) 3019 { 3020 HeightMapHashmap::iterator itr; 3021 3022 bool doAll = false; 3023 3024 if (id.compare("all") == 0) { 3025 itr = _heightMaps.begin(); 3026 doAll = true; 3027 } else { 3028 itr = _heightMaps.find(id); 3029 } 3030 if (itr == _heightMaps.end()) { 3031 ERROR("HeightMap not found: %s", id.c_str()); 3032 return; 3033 } 3034 3035 do { 3036 itr->second->setScale(scale); 3037 } while (doAll && ++itr != _heightMaps.end()); 3038 3039 resetAxes(); 3040 _needsRedraw = true; 3041 } 3042 3043 /** 2132 3044 * \brief Set the volume slice used for mapping volumetric data 2133 3045 */ … … 2604 3516 2605 3517 /** 3518 * \brief Set the prop orientation with a quaternion 3519 */ 3520 void Renderer::setLICTransform(const DataSetId& id, vtkMatrix4x4 *trans) 3521 { 3522 LICHashmap::iterator itr; 3523 3524 bool doAll = false; 3525 3526 if (id.compare("all") == 0) { 3527 itr = _lics.begin(); 3528 doAll = true; 3529 } else { 3530 itr = _lics.find(id); 3531 } 3532 if (itr == _lics.end()) { 3533 ERROR("LIC not found: %s", id.c_str()); 3534 return; 3535 } 3536 3537 do { 3538 itr->second->setTransform(trans); 3539 } while (doAll && ++itr != _lics.end()); 3540 3541 resetAxes(); 3542 _needsRedraw = true; 3543 } 3544 3545 /** 3546 * \brief Set the prop orientation with a quaternion 3547 */ 3548 void Renderer::setLICOrientation(const DataSetId& id, double quat[4]) 3549 { 3550 LICHashmap::iterator itr; 3551 3552 bool doAll = false; 3553 3554 if (id.compare("all") == 0) { 3555 itr = _lics.begin(); 3556 doAll = true; 3557 } else { 3558 itr = _lics.find(id); 3559 } 3560 if (itr == _lics.end()) { 3561 ERROR("LIC not found: %s", id.c_str()); 3562 return; 3563 } 3564 3565 do { 3566 itr->second->setOrientation(quat); 3567 } while (doAll && ++itr != _lics.end()); 3568 3569 resetAxes(); 3570 _needsRedraw = true; 3571 } 3572 3573 /** 3574 * \brief Set the prop orientation with a rotation about an axis 3575 */ 3576 void Renderer::setLICOrientation(const DataSetId& id, double angle, double axis[3]) 3577 { 3578 LICHashmap::iterator itr; 3579 3580 bool doAll = false; 3581 3582 if (id.compare("all") == 0) { 3583 itr = _lics.begin(); 3584 doAll = true; 3585 } else { 3586 itr = _lics.find(id); 3587 } 3588 if (itr == _lics.end()) { 3589 ERROR("LIC not found: %s", id.c_str()); 3590 return; 3591 } 3592 3593 do { 3594 itr->second->setOrientation(angle, axis); 3595 } while (doAll && ++itr != _lics.end()); 3596 3597 resetAxes(); 3598 _needsRedraw = true; 3599 } 3600 3601 /** 3602 * \brief Set the prop position in world coords 3603 */ 3604 void Renderer::setLICPosition(const DataSetId& id, double pos[3]) 3605 { 3606 LICHashmap::iterator itr; 3607 3608 bool doAll = false; 3609 3610 if (id.compare("all") == 0) { 3611 itr = _lics.begin(); 3612 doAll = true; 3613 } else { 3614 itr = _lics.find(id); 3615 } 3616 if (itr == _lics.end()) { 3617 ERROR("LIC not found: %s", id.c_str()); 3618 return; 3619 } 3620 3621 do { 3622 itr->second->setPosition(pos); 3623 } while (doAll && ++itr != _lics.end()); 3624 3625 resetAxes(); 3626 _needsRedraw = true; 3627 } 3628 3629 /** 3630 * \brief Set the prop scaling 3631 */ 3632 void Renderer::setLICScale(const DataSetId& id, double scale[3]) 3633 { 3634 LICHashmap::iterator itr; 3635 3636 bool doAll = false; 3637 3638 if (id.compare("all") == 0) { 3639 itr = _lics.begin(); 3640 doAll = true; 3641 } else { 3642 itr = _lics.find(id); 3643 } 3644 if (itr == _lics.end()) { 3645 ERROR("LIC not found: %s", id.c_str()); 3646 return; 3647 } 3648 3649 do { 3650 itr->second->setScale(scale); 3651 } while (doAll && ++itr != _lics.end()); 3652 3653 resetAxes(); 3654 _needsRedraw = true; 3655 } 3656 3657 /** 2606 3658 * \brief Set the volume slice used for mapping volumetric data 2607 3659 */ … … 2907 3959 2908 3960 /** 3961 * \brief Set the prop orientation with a quaternion 3962 */ 3963 void Renderer::setMoleculeTransform(const DataSetId& id, vtkMatrix4x4 *trans) 3964 { 3965 MoleculeHashmap::iterator itr; 3966 3967 bool doAll = false; 3968 3969 if (id.compare("all") == 0) { 3970 itr = _molecules.begin(); 3971 doAll = true; 3972 } else { 3973 itr = _molecules.find(id); 3974 } 3975 if (itr == _molecules.end()) { 3976 ERROR("Molecule not found: %s", id.c_str()); 3977 return; 3978 } 3979 3980 do { 3981 itr->second->setTransform(trans); 3982 } while (doAll && ++itr != _molecules.end()); 3983 3984 resetAxes(); 3985 _needsRedraw = true; 3986 } 3987 3988 /** 3989 * \brief Set the prop orientation with a quaternion 3990 */ 3991 void Renderer::setMoleculeOrientation(const DataSetId& id, double quat[4]) 3992 { 3993 MoleculeHashmap::iterator itr; 3994 3995 bool doAll = false; 3996 3997 if (id.compare("all") == 0) { 3998 itr = _molecules.begin(); 3999 doAll = true; 4000 } else { 4001 itr = _molecules.find(id); 4002 } 4003 if (itr == _molecules.end()) { 4004 ERROR("Molecule not found: %s", id.c_str()); 4005 return; 4006 } 4007 4008 do { 4009 itr->second->setOrientation(quat); 4010 } while (doAll && ++itr != _molecules.end()); 4011 4012 resetAxes(); 4013 _needsRedraw = true; 4014 } 4015 4016 /** 4017 * \brief Set the prop orientation with a rotation about an axis 4018 */ 4019 void Renderer::setMoleculeOrientation(const DataSetId& id, double angle, double axis[3]) 4020 { 4021 MoleculeHashmap::iterator itr; 4022 4023 bool doAll = false; 4024 4025 if (id.compare("all") == 0) { 4026 itr = _molecules.begin(); 4027 doAll = true; 4028 } else { 4029 itr = _molecules.find(id); 4030 } 4031 if (itr == _molecules.end()) { 4032 ERROR("Molecule not found: %s", id.c_str()); 4033 return; 4034 } 4035 4036 do { 4037 itr->second->setOrientation(angle, axis); 4038 } while (doAll && ++itr != _molecules.end()); 4039 4040 resetAxes(); 4041 _needsRedraw = true; 4042 } 4043 4044 /** 4045 * \brief Set the prop position in world coords 4046 */ 4047 void Renderer::setMoleculePosition(const DataSetId& id, double pos[3]) 4048 { 4049 MoleculeHashmap::iterator itr; 4050 4051 bool doAll = false; 4052 4053 if (id.compare("all") == 0) { 4054 itr = _molecules.begin(); 4055 doAll = true; 4056 } else { 4057 itr = _molecules.find(id); 4058 } 4059 if (itr == _molecules.end()) { 4060 ERROR("Molecule not found: %s", id.c_str()); 4061 return; 4062 } 4063 4064 do { 4065 itr->second->setPosition(pos); 4066 } while (doAll && ++itr != _molecules.end()); 4067 4068 resetAxes(); 4069 _needsRedraw = true; 4070 } 4071 4072 /** 4073 * \brief Set the prop scaling 4074 */ 4075 void Renderer::setMoleculeScale(const DataSetId& id, double scale[3]) 4076 { 4077 MoleculeHashmap::iterator itr; 4078 4079 bool doAll = false; 4080 4081 if (id.compare("all") == 0) { 4082 itr = _molecules.begin(); 4083 doAll = true; 4084 } else { 4085 itr = _molecules.find(id); 4086 } 4087 if (itr == _molecules.end()) { 4088 ERROR("Molecule not found: %s", id.c_str()); 4089 return; 4090 } 4091 4092 do { 4093 itr->second->setScale(scale); 4094 } while (doAll && ++itr != _molecules.end()); 4095 4096 resetAxes(); 4097 _needsRedraw = true; 4098 } 4099 4100 /** 2909 4101 * \brief Associate an existing named color map with a Molecule for the given DataSet 2910 4102 */ … … 3286 4478 } else 3287 4479 return itr->second; 4480 } 4481 4482 /** 4483 * \brief Set an additional transform on the prop 4484 */ 4485 void Renderer::setPolyDataTransform(const DataSetId& id, vtkMatrix4x4 *trans) 4486 { 4487 PolyDataHashmap::iterator itr; 4488 4489 bool doAll = false; 4490 4491 if (id.compare("all") == 0) { 4492 itr = _polyDatas.begin(); 4493 doAll = true; 4494 } else { 4495 itr = _polyDatas.find(id); 4496 } 4497 if (itr == _polyDatas.end()) { 4498 ERROR("PolyData not found: %s", id.c_str()); 4499 return; 4500 } 4501 4502 do { 4503 itr->second->setTransform(trans); 4504 } while (doAll && ++itr != _polyDatas.end()); 4505 4506 resetAxes(); 4507 _needsRedraw = true; 4508 } 4509 4510 /** 4511 * \brief Set the prop orientation with a quaternion 4512 */ 4513 void Renderer::setPolyDataOrientation(const DataSetId& id, double quat[4]) 4514 { 4515 PolyDataHashmap::iterator itr; 4516 4517 bool doAll = false; 4518 4519 if (id.compare("all") == 0) { 4520 itr = _polyDatas.begin(); 4521 doAll = true; 4522 } else { 4523 itr = _polyDatas.find(id); 4524 } 4525 if (itr == _polyDatas.end()) { 4526 ERROR("PolyData not found: %s", id.c_str()); 4527 return; 4528 } 4529 4530 do { 4531 itr->second->setOrientation(quat); 4532 } while (doAll && ++itr != _polyDatas.end()); 4533 4534 resetAxes(); 4535 _needsRedraw = true; 4536 } 4537 4538 /** 4539 * \brief Set the prop orientation with a rotation about an axis 4540 */ 4541 void Renderer::setPolyDataOrientation(const DataSetId& id, double angle, double axis[3]) 4542 { 4543 PolyDataHashmap::iterator itr; 4544 4545 bool doAll = false; 4546 4547 if (id.compare("all") == 0) { 4548 itr = _polyDatas.begin(); 4549 doAll = true; 4550 } else { 4551 itr = _polyDatas.find(id); 4552 } 4553 if (itr == _polyDatas.end()) { 4554 ERROR("PolyData not found: %s", id.c_str()); 4555 return; 4556 } 4557 4558 do { 4559 itr->second->setOrientation(angle, axis); 4560 } while (doAll && ++itr != _polyDatas.end()); 4561 4562 resetAxes(); 4563 _needsRedraw = true; 4564 } 4565 4566 /** 4567 * \brief Set the prop position in world coords 4568 */ 4569 void Renderer::setPolyDataPosition(const DataSetId& id, double pos[3]) 4570 { 4571 PolyDataHashmap::iterator itr; 4572 4573 bool doAll = false; 4574 4575 if (id.compare("all") == 0) { 4576 itr = _polyDatas.begin(); 4577 doAll = true; 4578 } else { 4579 itr = _polyDatas.find(id); 4580 } 4581 if (itr == _polyDatas.end()) { 4582 ERROR("PolyData not found: %s", id.c_str()); 4583 return; 4584 } 4585 4586 do { 4587 itr->second->setPosition(pos); 4588 } while (doAll && ++itr != _polyDatas.end()); 4589 4590 resetAxes(); 4591 _needsRedraw = true; 4592 } 4593 4594 /** 4595 * \brief Set the prop scaling 4596 */ 4597 void Renderer::setPolyDataScale(const DataSetId& id, double scale[3]) 4598 { 4599 PolyDataHashmap::iterator itr; 4600 4601 bool doAll = false; 4602 4603 if (id.compare("all") == 0) { 4604 itr = _polyDatas.begin(); 4605 doAll = true; 4606 } else { 4607 itr = _polyDatas.find(id); 4608 } 4609 if (itr == _polyDatas.end()) { 4610 ERROR("PolyData not found: %s", id.c_str()); 4611 return; 4612 } 4613 4614 do { 4615 itr->second->setScale(scale); 4616 } while (doAll && ++itr != _polyDatas.end()); 4617 4618 resetAxes(); 4619 _needsRedraw = true; 3288 4620 } 3289 4621 … … 3574 4906 3575 4907 /** 4908 * \brief Set the prop orientation with a quaternion 4909 */ 4910 void Renderer::setPseudoColorTransform(const DataSetId& id, vtkMatrix4x4 *trans) 4911 { 4912 PseudoColorHashmap::iterator itr; 4913 4914 bool doAll = false; 4915 4916 if (id.compare("all") == 0) { 4917 itr = _pseudoColors.begin(); 4918 doAll = true; 4919 } else { 4920 itr = _pseudoColors.find(id); 4921 } 4922 if (itr == _pseudoColors.end()) { 4923 ERROR("PseudoColor not found: %s", id.c_str()); 4924 return; 4925 } 4926 4927 do { 4928 itr->second->setTransform(trans); 4929 } while (doAll && ++itr != _pseudoColors.end()); 4930 4931 resetAxes(); 4932 _needsRedraw = true; 4933 } 4934 4935 /** 4936 * \brief Set the prop orientation with a quaternion 4937 */ 4938 void Renderer::setPseudoColorOrientation(const DataSetId& id, double quat[4]) 4939 { 4940 PseudoColorHashmap::iterator itr; 4941 4942 bool doAll = false; 4943 4944 if (id.compare("all") == 0) { 4945 itr = _pseudoColors.begin(); 4946 doAll = true; 4947 } else { 4948 itr = _pseudoColors.find(id); 4949 } 4950 if (itr == _pseudoColors.end()) { 4951 ERROR("PseudoColor not found: %s", id.c_str()); 4952 return; 4953 } 4954 4955 do { 4956 itr->second->setOrientation(quat); 4957 } while (doAll && ++itr != _pseudoColors.end()); 4958 4959 resetAxes(); 4960 _needsRedraw = true; 4961 } 4962 4963 /** 4964 * \brief Set the prop orientation with a rotation about an axis 4965 */ 4966 void Renderer::setPseudoColorOrientation(const DataSetId& id, double angle, double axis[3]) 4967 { 4968 PseudoColorHashmap::iterator itr; 4969 4970 bool doAll = false; 4971 4972 if (id.compare("all") == 0) { 4973 itr = _pseudoColors.begin(); 4974 doAll = true; 4975 } else { 4976 itr = _pseudoColors.find(id); 4977 } 4978 if (itr == _pseudoColors.end()) { 4979 ERROR("PseudoColor not found: %s", id.c_str()); 4980 return; 4981 } 4982 4983 do { 4984 itr->second->setOrientation(angle, axis); 4985 } while (doAll && ++itr != _pseudoColors.end()); 4986 4987 resetAxes(); 4988 _needsRedraw = true; 4989 } 4990 4991 /** 4992 * \brief Set the prop position in world coords 4993 */ 4994 void Renderer::setPseudoColorPosition(const DataSetId& id, double pos[3]) 4995 { 4996 PseudoColorHashmap::iterator itr; 4997 4998 bool doAll = false; 4999 5000 if (id.compare("all") == 0) { 5001 itr = _pseudoColors.begin(); 5002 doAll = true; 5003 } else { 5004 itr = _pseudoColors.find(id); 5005 } 5006 if (itr == _pseudoColors.end()) { 5007 ERROR("PseudoColor not found: %s", id.c_str()); 5008 return; 5009 } 5010 5011 do { 5012 itr->second->setPosition(pos); 5013 } while (doAll && ++itr != _pseudoColors.end()); 5014 5015 resetAxes(); 5016 _needsRedraw = true; 5017 } 5018 5019 /** 5020 * \brief Set the prop scaling 5021 */ 5022 void Renderer::setPseudoColorScale(const DataSetId& id, double scale[3]) 5023 { 5024 PseudoColorHashmap::iterator itr; 5025 5026 bool doAll = false; 5027 5028 if (id.compare("all") == 0) { 5029 itr = _pseudoColors.begin(); 5030 doAll = true; 5031 } else { 5032 itr = _pseudoColors.find(id); 5033 } 5034 if (itr == _pseudoColors.end()) { 5035 ERROR("PseudoColor not found: %s", id.c_str()); 5036 return; 5037 } 5038 5039 do { 5040 itr->second->setScale(scale); 5041 } while (doAll && ++itr != _pseudoColors.end()); 5042 5043 resetAxes(); 5044 _needsRedraw = true; 5045 } 5046 5047 /** 3576 5048 * \brief Associate an existing named color map with a PseudoColor for the given DataSet 3577 5049 */ … … 3861 5333 ColorMap *cmap = getColorMap("default"); 3862 5334 lut->DeepCopy(cmap->getLookupTable()); 3863 #if 0 3864 // Currently lookup table/scalar data range not used, colormap is used to 3865 // color streamlines by vector magnitude 5335 3866 5336 if (_useCumulativeRange) { 3867 5337 lut->SetRange(_cumulativeDataRange); … … 3871 5341 lut->SetRange(range); 3872 5342 } 3873 #endif3874 5343 streamlines->setLookupTable(lut); 3875 5344 … … 3896 5365 3897 5366 /** 5367 * \brief Set the prop orientation with a quaternion 5368 */ 5369 void Renderer::setStreamlinesTransform(const DataSetId& id, vtkMatrix4x4 *trans) 5370 { 5371 StreamlinesHashmap::iterator itr; 5372 5373 bool doAll = false; 5374 5375 if (id.compare("all") == 0) { 5376 itr = _streamlines.begin(); 5377 doAll = true; 5378 } else { 5379 itr = _streamlines.find(id); 5380 } 5381 if (itr == _streamlines.end()) { 5382 ERROR("Streamlines not found: %s", id.c_str()); 5383 return; 5384 } 5385 5386 do { 5387 itr->second->setTransform(trans); 5388 } while (doAll && ++itr != _streamlines.end()); 5389 5390 resetAxes(); 5391 _needsRedraw = true; 5392 } 5393 5394 /** 5395 * \brief Set the prop orientation with a quaternion 5396 */ 5397 void Renderer::setStreamlinesOrientation(const DataSetId& id, double quat[4]) 5398 { 5399 StreamlinesHashmap::iterator itr; 5400 5401 bool doAll = false; 5402 5403 if (id.compare("all") == 0) { 5404 itr = _streamlines.begin(); 5405 doAll = true; 5406 } else { 5407 itr = _streamlines.find(id); 5408 } 5409 if (itr == _streamlines.end()) { 5410 ERROR("Streamlines not found: %s", id.c_str()); 5411 return; 5412 } 5413 5414 do { 5415 itr->second->setOrientation(quat); 5416 } while (doAll && ++itr != _streamlines.end()); 5417 5418 resetAxes(); 5419 _needsRedraw = true; 5420 } 5421 5422 /** 5423 * \brief Set the prop orientation with a rotation about an axis 5424 */ 5425 void Renderer::setStreamlinesOrientation(const DataSetId& id, double angle, double axis[3]) 5426 { 5427 StreamlinesHashmap::iterator itr; 5428 5429 bool doAll = false; 5430 5431 if (id.compare("all") == 0) { 5432 itr = _streamlines.begin(); 5433 doAll = true; 5434 } else { 5435 itr = _streamlines.find(id); 5436 } 5437 if (itr == _streamlines.end()) { 5438 ERROR("Streamlines not found: %s", id.c_str()); 5439 return; 5440 } 5441 5442 do { 5443 itr->second->setOrientation(angle, axis); 5444 } while (doAll && ++itr != _streamlines.end()); 5445 5446 resetAxes(); 5447 _needsRedraw = true; 5448 } 5449 5450 /** 5451 * \brief Set the prop position in world coords 5452 */ 5453 void Renderer::setStreamlinesPosition(const DataSetId& id, double pos[3]) 5454 { 5455 StreamlinesHashmap::iterator itr; 5456 5457 bool doAll = false; 5458 5459 if (id.compare("all") == 0) { 5460 itr = _streamlines.begin(); 5461 doAll = true; 5462 } else { 5463 itr = _streamlines.find(id); 5464 } 5465 if (itr == _streamlines.end()) { 5466 ERROR("Streamlines not found: %s", id.c_str()); 5467 return; 5468 } 5469 5470 do { 5471 itr->second->setPosition(pos); 5472 } while (doAll && ++itr != _streamlines.end()); 5473 5474 resetAxes(); 5475 _needsRedraw = true; 5476 } 5477 5478 /** 5479 * \brief Set the prop scaling 5480 */ 5481 void Renderer::setStreamlinesScale(const DataSetId& id, double scale[3]) 5482 { 5483 StreamlinesHashmap::iterator itr; 5484 5485 bool doAll = false; 5486 5487 if (id.compare("all") == 0) { 5488 itr = _streamlines.begin(); 5489 doAll = true; 5490 } else { 5491 itr = _streamlines.find(id); 5492 } 5493 if (itr == _streamlines.end()) { 5494 ERROR("Streamlines not found: %s", id.c_str()); 5495 return; 5496 } 5497 5498 do { 5499 itr->second->setScale(scale); 5500 } while (doAll && ++itr != _streamlines.end()); 5501 5502 resetAxes(); 5503 _needsRedraw = true; 5504 } 5505 5506 /** 3898 5507 * \brief Set the streamlines seed to points distributed randomly inside 3899 5508 * cells of DataSet … … 3926 5535 * \brief Set the streamlines seed to points along a line 3927 5536 */ 3928 void Renderer::setStreamlinesSeedToRake(const DataSetId& id, double start[3], double end[3], int numPoints) 5537 void Renderer::setStreamlinesSeedToRake(const DataSetId& id, 5538 double start[3], double end[3], 5539 int numPoints) 3929 5540 { 3930 5541 StreamlinesHashmap::iterator itr; … … 3951 5562 3952 5563 /** 5564 * \brief Set the streamlines seed to points inside a disk, with optional 5565 * hole 5566 */ 5567 void Renderer::setStreamlinesSeedToDisk(const DataSetId& id, 5568 double center[3], double normal[3], 5569 double radius, double innerRadius, 5570 int numPoints) 5571 { 5572 StreamlinesHashmap::iterator itr; 5573 5574 bool doAll = false; 5575 5576 if (id.compare("all") == 0) { 5577 itr = _streamlines.begin(); 5578 doAll = true; 5579 } else { 5580 itr = _streamlines.find(id); 5581 } 5582 if (itr == _streamlines.end()) { 5583 ERROR("Streamlines not found: %s", id.c_str()); 5584 return; 5585 } 5586 5587 do { 5588 itr->second->setSeedToDisk(center, normal, radius, innerRadius, numPoints); 5589 } while (doAll && ++itr != _streamlines.end()); 5590 5591 _needsRedraw = true; 5592 } 5593 5594 /** 3953 5595 * \brief Set the streamlines seed to vertices of an n-sided polygon 3954 5596 */ 3955 5597 void Renderer::setStreamlinesSeedToPolygon(const DataSetId& id, 3956 5598 double center[3], double normal[3], 3957 double radius, int numSides) 5599 double angle, double radius, 5600 int numSides) 3958 5601 { 3959 5602 StreamlinesHashmap::iterator itr; … … 3973 5616 3974 5617 do { 3975 itr->second->setSeedToPolygon(center, normal, radius, numSides);5618 itr->second->setSeedToPolygon(center, normal, angle, radius, numSides); 3976 5619 } while (doAll && ++itr != _streamlines.end()); 3977 5620 … … 3980 5623 3981 5624 /** 3982 * \brief Set Streamlines rendering to polylines for the specified DataSet 3983 */ 3984 void Renderer::setStreamlinesTypeToLines(const DataSetId& id) 5625 * \brief Set the streamlines seed to vertices of an n-sided polygon 5626 */ 5627 void Renderer::setStreamlinesSeedToFilledPolygon(const DataSetId& id, 5628 double center[3], 5629 double normal[3], 5630 double angle, double radius, 5631 int numSides, int numPoints) 3985 5632 { 3986 5633 StreamlinesHashmap::iterator itr; … … 4000 5647 4001 5648 do { 5649 itr->second->setSeedToFilledPolygon(center, normal, angle, 5650 radius, numSides, numPoints); 5651 } while (doAll && ++itr != _streamlines.end()); 5652 5653 _needsRedraw = true; 5654 } 5655 5656 /** 5657 * \brief Set Streamlines rendering to polylines for the specified DataSet 5658 */ 5659 void Renderer::setStreamlinesTypeToLines(const DataSetId& id) 5660 { 5661 StreamlinesHashmap::iterator itr; 5662 5663 bool doAll = false; 5664 5665 if (id.compare("all") == 0) { 5666 itr = _streamlines.begin(); 5667 doAll = true; 5668 } else { 5669 itr = _streamlines.find(id); 5670 } 5671 if (itr == _streamlines.end()) { 5672 ERROR("Streamlines not found: %s", id.c_str()); 5673 return; 5674 } 5675 5676 do { 4002 5677 itr->second->setLineTypeToLines(); 4003 5678 } while (doAll && ++itr != _streamlines.end()); … … 4163 5838 do { 4164 5839 itr->second->setSeedVisibility(state); 5840 } while (doAll && ++itr != _streamlines.end()); 5841 5842 _needsRedraw = true; 5843 } 5844 5845 /** 5846 * \brief Set the color mode for the specified DataSet 5847 */ 5848 void Renderer::setStreamlinesColorMode(const DataSetId& id, Streamlines::ColorMode mode) 5849 { 5850 StreamlinesHashmap::iterator itr; 5851 5852 bool doAll = false; 5853 5854 if (id.compare("all") == 0) { 5855 itr = _streamlines.begin(); 5856 doAll = true; 5857 } else { 5858 itr = _streamlines.find(id); 5859 } 5860 if (itr == _streamlines.end()) { 5861 ERROR("Streamlines not found: %s", id.c_str()); 5862 return; 5863 } 5864 5865 do { 5866 itr->second->setColorMode(mode); 4165 5867 } while (doAll && ++itr != _streamlines.end()); 4166 5868 … … 4205 5907 lut->DeepCopy(cmap->getLookupTable()); 4206 5908 4207 #if 04208 5909 if (_useCumulativeRange) { 4209 5910 lut->SetRange(_cumulativeDataRange); … … 4215 5916 } 4216 5917 } 4217 #endif4218 5918 4219 5919 itr->second->setLookupTable(lut); … … 4278 5978 } 4279 5979 5980 /** 5981 * \brief Set the RGB color for the specified DataSet 5982 */ 5983 void Renderer::setStreamlinesColor(const DataSetId& id, float color[3]) 5984 { 5985 StreamlinesHashmap::iterator itr; 5986 5987 bool doAll = false; 5988 5989 if (id.compare("all") == 0) { 5990 itr = _streamlines.begin(); 5991 doAll = true; 5992 } else { 5993 itr = _streamlines.find(id); 5994 } 5995 if (itr == _streamlines.end()) { 5996 ERROR("Streamlines not found: %s", id.c_str()); 5997 return; 5998 } 5999 6000 do { 6001 itr->second->setColor(color); 6002 } while (doAll && ++itr != _streamlines.end()); 6003 6004 _needsRedraw = true; 6005 } 4280 6006 4281 6007 /** … … 4422 6148 } else 4423 6149 return itr->second; 6150 } 6151 6152 /** 6153 * \brief Set the prop orientation with a quaternion 6154 */ 6155 void Renderer::setVolumeTransform(const DataSetId& id, vtkMatrix4x4 *trans) 6156 { 6157 VolumeHashmap::iterator itr; 6158 6159 bool doAll = false; 6160 6161 if (id.compare("all") == 0) { 6162 itr = _volumes.begin(); 6163 doAll = true; 6164 } else { 6165 itr = _volumes.find(id); 6166 } 6167 if (itr == _volumes.end()) { 6168 ERROR("Volume not found: %s", id.c_str()); 6169 return; 6170 } 6171 6172 do { 6173 itr->second->setTransform(trans); 6174 } while (doAll && ++itr != _volumes.end()); 6175 6176 resetAxes(); 6177 _needsRedraw = true; 6178 } 6179 6180 /** 6181 * \brief Set the prop orientation with a quaternion 6182 */ 6183 void Renderer::setVolumeOrientation(const DataSetId& id, double quat[4]) 6184 { 6185 VolumeHashmap::iterator itr; 6186 6187 bool doAll = false; 6188 6189 if (id.compare("all") == 0) { 6190 itr = _volumes.begin(); 6191 doAll = true; 6192 } else { 6193 itr = _volumes.find(id); 6194 } 6195 if (itr == _volumes.end()) { 6196 ERROR("Volume not found: %s", id.c_str()); 6197 return; 6198 } 6199 6200 do { 6201 itr->second->setOrientation(quat); 6202 } while (doAll && ++itr != _volumes.end()); 6203 6204 resetAxes(); 6205 _needsRedraw = true; 6206 } 6207 6208 /** 6209 * \brief Set the prop orientation with a rotation about an axis 6210 */ 6211 void Renderer::setVolumeOrientation(const DataSetId& id, double angle, double axis[3]) 6212 { 6213 VolumeHashmap::iterator itr; 6214 6215 bool doAll = false; 6216 6217 if (id.compare("all") == 0) { 6218 itr = _volumes.begin(); 6219 doAll = true; 6220 } else { 6221 itr = _volumes.find(id); 6222 } 6223 if (itr == _volumes.end()) { 6224 ERROR("Volume not found: %s", id.c_str()); 6225 return; 6226 } 6227 6228 do { 6229 itr->second->setOrientation(angle, axis); 6230 } while (doAll && ++itr != _volumes.end()); 6231 6232 resetAxes(); 6233 _needsRedraw = true; 6234 } 6235 6236 /** 6237 * \brief Set the prop position in world coords 6238 */ 6239 void Renderer::setVolumePosition(const DataSetId& id, double pos[3]) 6240 { 6241 VolumeHashmap::iterator itr; 6242 6243 bool doAll = false; 6244 6245 if (id.compare("all") == 0) { 6246 itr = _volumes.begin(); 6247 doAll = true; 6248 } else { 6249 itr = _volumes.find(id); 6250 } 6251 if (itr == _volumes.end()) { 6252 ERROR("Volume not found: %s", id.c_str()); 6253 return; 6254 } 6255 6256 do { 6257 itr->second->setPosition(pos); 6258 } while (doAll && ++itr != _volumes.end()); 6259 6260 resetAxes(); 6261 _needsRedraw = true; 6262 } 6263 6264 /** 6265 * \brief Set the prop scaling 6266 */ 6267 void Renderer::setVolumeScale(const DataSetId& id, double scale[3]) 6268 { 6269 VolumeHashmap::iterator itr; 6270 6271 bool doAll = false; 6272 6273 if (id.compare("all") == 0) { 6274 itr = _volumes.begin(); 6275 doAll = true; 6276 } else { 6277 itr = _volumes.find(id); 6278 } 6279 if (itr == _volumes.end()) { 6280 ERROR("Volume not found: %s", id.c_str()); 6281 return; 6282 } 6283 6284 do { 6285 itr->second->setScale(scale); 6286 } while (doAll && ++itr != _volumes.end()); 6287 6288 resetAxes(); 6289 _needsRedraw = true; 4424 6290 } 4425 6291 … … 4732 6598 4733 6599 /** 6600 * \brief Set the VTK camera parameters based on a 4x4 view matrix 6601 */ 6602 void Renderer::setCameraFromMatrix(vtkCamera *camera, vtkMatrix4x4& mat) 6603 { 6604 double d = camera->GetDistance(); 6605 double vu[3]; 6606 vu[0] = mat[1][0]; 6607 vu[1] = mat[1][1]; 6608 vu[2] = mat[1][2]; 6609 double trans[3]; 6610 trans[0] = mat[0][3]; 6611 trans[1] = mat[1][3]; 6612 trans[2] = mat[2][3]; 6613 mat[0][3] = 0; 6614 mat[1][3] = 0; 6615 mat[2][3] = 0; 6616 double vpn[3] = {mat[2][0], mat[2][1], mat[2][2]}; 6617 double pos[3]; 6618 // With translation removed, we have an orthogonal matrix, 6619 // so the inverse is the transpose 6620 mat.Transpose(); 6621 mat.MultiplyPoint(trans, pos); 6622 pos[0] = -pos[0]; 6623 pos[1] = -pos[1]; 6624 pos[2] = -pos[2]; 6625 double fp[3]; 6626 fp[0] = pos[0] - vpn[0] * d; 6627 fp[1] = pos[1] - vpn[1] * d; 6628 fp[2] = pos[2] - vpn[2] * d; 6629 camera->SetPosition(pos); 6630 camera->SetFocalPoint(fp); 6631 camera->SetViewUp(vu); 6632 } 6633 6634 inline void quaternionToMatrix4x4(const double quat[4], vtkMatrix4x4& mat) 6635 { 6636 double ww = quat[0]*quat[0]; 6637 double wx = quat[0]*quat[1]; 6638 double wy = quat[0]*quat[2]; 6639 double wz = quat[0]*quat[3]; 6640 6641 double xx = quat[1]*quat[1]; 6642 double yy = quat[2]*quat[2]; 6643 double zz = quat[3]*quat[3]; 6644 6645 double xy = quat[1]*quat[2]; 6646 double xz = quat[1]*quat[3]; 6647 double yz = quat[2]*quat[3]; 6648 6649 double rr = xx + yy + zz; 6650 // normalization factor, just in case quaternion was not normalized 6651 double f = double(1)/double(sqrt(ww + rr)); 6652 double s = (ww - rr)*f; 6653 f *= 2; 6654 6655 mat[0][0] = xx*f + s; 6656 mat[1][0] = (xy + wz)*f; 6657 mat[2][0] = (xz - wy)*f; 6658 6659 mat[0][1] = (xy - wz)*f; 6660 mat[1][1] = yy*f + s; 6661 mat[2][1] = (yz + wx)*f; 6662 6663 mat[0][2] = (xz + wy)*f; 6664 mat[1][2] = (yz - wx)*f; 6665 mat[2][2] = zz*f + s; 6666 } 6667 6668 inline void quaternionToTransposeMatrix4x4(const double quat[4], vtkMatrix4x4& mat) 6669 { 6670 double ww = quat[0]*quat[0]; 6671 double wx = quat[0]*quat[1]; 6672 double wy = quat[0]*quat[2]; 6673 double wz = quat[0]*quat[3]; 6674 6675 double xx = quat[1]*quat[1]; 6676 double yy = quat[2]*quat[2]; 6677 double zz = quat[3]*quat[3]; 6678 6679 double xy = quat[1]*quat[2]; 6680 double xz = quat[1]*quat[3]; 6681 double yz = quat[2]*quat[3]; 6682 6683 double rr = xx + yy + zz; 6684 // normalization factor, just in case quaternion was not normalized 6685 double f = double(1)/double(sqrt(ww + rr)); 6686 double s = (ww - rr)*f; 6687 f *= 2; 6688 6689 mat[0][0] = xx*f + s; 6690 mat[0][1] = (xy + wz)*f; 6691 mat[0][2] = (xz - wy)*f; 6692 6693 mat[1][0] = (xy - wz)*f; 6694 mat[1][1] = yy*f + s; 6695 mat[1][2] = (yz + wx)*f; 6696 6697 mat[2][0] = (xz + wy)*f; 6698 mat[2][1] = (yz - wx)*f; 6699 mat[2][2] = zz*f + s; 6700 } 6701 6702 inline double *quatMult(const double q1[4], const double q2[4], double result[4]) 6703 { 6704 double q1w = q1[0]; 6705 double q1x = q1[1]; 6706 double q1y = q1[2]; 6707 double q1z = q1[3]; 6708 double q2w = q2[0]; 6709 double q2x = q2[1]; 6710 double q2y = q2[2]; 6711 double q2z = q2[3]; 6712 result[0] = (q1w*q2w) - (q1x*q2x) - (q1y*q2y) - (q1z*q2z); 6713 result[1] = (q1w*q2x) + (q1x*q2w) + (q1y*q2z) - (q1z*q2y); 6714 result[2] = (q1w*q2y) + (q1y*q2w) + (q1z*q2x) - (q1x*q2z); 6715 result[3] = (q1w*q2z) + (q1z*q2w) + (q1x*q2y) - (q1y*q2x); 6716 return result; 6717 } 6718 6719 inline double *quatConjugate(const double quat[4], double result[4]) 6720 { 6721 result[1] = -quat[1]; 6722 result[2] = -quat[2]; 6723 result[3] = -quat[3]; 6724 return result; 6725 } 6726 6727 inline double *quatReciprocal(const double quat[4], double result[4]) 6728 { 6729 double denom = 6730 quat[0]*quat[0] + 6731 quat[1]*quat[1] + 6732 quat[2]*quat[2] + 6733 quat[3]*quat[3]; 6734 quatConjugate(quat, result); 6735 for (int i = 0; i < 4; i++) { 6736 result[i] /= denom; 6737 } 6738 return result; 6739 } 6740 6741 inline double *quatReciprocal(double quat[4]) 6742 { 6743 return quatReciprocal(quat, quat); 6744 } 6745 6746 inline void copyQuat(const double quat[4], double result[4]) 6747 { 6748 memcpy(result, quat, sizeof(double)*4); 6749 } 6750 6751 /** 4734 6752 * \brief Set the orientation of the camera from a quaternion 6753 * rotation 4735 6754 * 4736 6755 * \param[in] quat A quaternion with scalar part first: w,x,y,z 4737 */ 4738 void Renderer::setCameraOrientation(double quat[4]) 6756 * \param[in] absolute Is rotation absolute or relative? 6757 */ 6758 void Renderer::setCameraOrientation(const double quat[4], bool absolute) 4739 6759 { 4740 6760 if (_cameraMode == IMAGE) … … 4742 6762 vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera(); 4743 6763 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New(); 4744 double mat3[3][3]; 4745 vtkMath::QuaternionToMatrix3x3(quat, mat3); 4746 vtkSmartPointer<vtkMatrix4x4> mat4 = vtkSmartPointer<vtkMatrix4x4>::New(); 4747 for (int r = 0; r < 3; r++) { 4748 memcpy((*mat4)[r], mat3[r], sizeof(double)*3); 4749 } 4750 TRACE("Arcball camera matrix: %g %g %g %g %g %g %g %g %g", 4751 (*mat4)[0][0], (*mat4)[0][1], (*mat4)[0][2], 4752 (*mat4)[1][0], (*mat4)[1][1], (*mat4)[1][2], 4753 (*mat4)[2][0], (*mat4)[2][1], (*mat4)[2][2]); 4754 camera->SetPosition(0, 0, 1); 4755 camera->SetFocalPoint(0, 0, 0); 4756 camera->SetViewUp(0, 1, 0); 4757 setViewAngle(_windowHeight); 4758 double bounds[6]; 4759 collectBounds(bounds, false); 4760 _renderer->ResetCamera(bounds); 4761 camera->GetFocalPoint(_cameraFocalPoint); 4762 trans->Translate(+_cameraFocalPoint[0], +_cameraFocalPoint[1], +_cameraFocalPoint[2]); 4763 trans->Concatenate(mat4); 4764 trans->Translate(-_cameraFocalPoint[0], -_cameraFocalPoint[1], -_cameraFocalPoint[2]); 4765 camera->ApplyTransform(trans); 4766 storeCameraOrientation(); 4767 if (_cameraZoomRatio != 1.0) { 4768 double z = _cameraZoomRatio; 4769 _cameraZoomRatio = 1.0; 4770 zoomCamera(z, true); 4771 } 4772 if (_cameraPan[0] != 0.0 || _cameraPan[1] != 0.0) { 4773 double panx = _cameraPan[0]; 4774 double pany = -_cameraPan[1]; 4775 _cameraPan[0] = 0; 4776 _cameraPan[1] = 0; 4777 panCamera(panx, pany, true); 4778 } 6764 vtkSmartPointer<vtkMatrix4x4> rotMat = vtkSmartPointer<vtkMatrix4x4>::New(); 6765 6766 double q[4]; 6767 copyQuat(quat, q); 6768 6769 if (absolute) { 6770 double abs[4]; 6771 // Save absolute rotation 6772 copyQuat(q, abs); 6773 // Compute relative rotation 6774 quatMult(quatReciprocal(_cameraOrientation), q, q); 6775 // Store absolute rotation 6776 copyQuat(abs, _cameraOrientation); 6777 } else { 6778 // Compute new absolute rotation 6779 quatMult(_cameraOrientation, q, _cameraOrientation); 6780 } 6781 6782 quaternionToTransposeMatrix4x4(q, *rotMat); 6783 #ifdef DEBUG 6784 TRACE("Rotation matrix:\n %g %g %g\n %g %g %g\n %g %g %g", 6785 (*rotMat)[0][0], (*rotMat)[0][1], (*rotMat)[0][2], 6786 (*rotMat)[1][0], (*rotMat)[1][1], (*rotMat)[1][2], 6787 (*rotMat)[2][0], (*rotMat)[2][1], (*rotMat)[2][2]); 6788 vtkSmartPointer<vtkMatrix4x4> camMat = vtkSmartPointer<vtkMatrix4x4>::New(); 6789 camMat->DeepCopy(camera->GetViewTransformMatrix()); 6790 TRACE("Camera matrix:\n %g %g %g %g\n %g %g %g %g\n %g %g %g %g\n %g %g %g %g", 6791 (*camMat)[0][0], (*camMat)[0][1], (*camMat)[0][2], (*camMat)[0][3], 6792 (*camMat)[1][0], (*camMat)[1][1], (*camMat)[1][2], (*camMat)[1][3], 6793 (*camMat)[2][0], (*camMat)[2][1], (*camMat)[2][2], (*camMat)[2][3], 6794 (*camMat)[3][0], (*camMat)[3][1], (*camMat)[3][2], (*camMat)[3][3]); 6795 printCameraInfo(camera); 6796 #endif 6797 trans->Translate(0, 0, -camera->GetDistance()); 6798 trans->Concatenate(rotMat); 6799 trans->Translate(0, 0, camera->GetDistance()); 6800 trans->Concatenate(camera->GetViewTransformMatrix()); 6801 setCameraFromMatrix(camera, *trans->GetMatrix()); 6802 4779 6803 _renderer->ResetCameraClippingRange(); 4780 6804 printCameraInfo(camera); … … 4789 6813 * \param[in] viewUp x,y,z up vector of camera 4790 6814 */ 4791 void Renderer::setCameraOrientationAndPosition( double position[3],4792 double focalPoint[3],4793 double viewUp[3])4794 { 4795 memcpy(_cameraPos, position, sizeof(double)*3);4796 memcpy(_cameraFocalPoint, focalPoint, sizeof(double)*3);4797 memcpy(_cameraUp, viewUp, sizeof(double)*3);4798 // Apply the new parameters to the VTK camera4799 restoreCameraOrientation();6815 void Renderer::setCameraOrientationAndPosition(const double position[3], 6816 const double focalPoint[3], 6817 const double viewUp[3]) 6818 { 6819 vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera(); 6820 camera->SetPosition(position); 6821 camera->SetFocalPoint(focalPoint); 6822 camera->SetViewUp(viewUp); 6823 _renderer->ResetCameraClippingRange(); 4800 6824 _needsRedraw = true; 4801 6825 } … … 4812 6836 double viewUp[3]) 4813 6837 { 4814 memcpy(position, _cameraPos, sizeof(double)*3);4815 memcpy(focalPoint, _cameraFocalPoint, sizeof(double)*3);4816 memcpy(viewUp, _cameraUp, sizeof(double)*3);4817 }4818 4819 /**4820 * \brief Saves the current camera orientation and position in order to4821 * be able to later restore the saved orientation and position4822 */4823 void Renderer::storeCameraOrientation()4824 {4825 6838 vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera(); 4826 camera->GetPosition(_cameraPos); 4827 camera->GetFocalPoint(_cameraFocalPoint); 4828 camera->GetViewUp(_cameraUp); 4829 } 4830 4831 /** 4832 * \brief Use the stored orientation and position to set the camera's 4833 * current state 4834 */ 4835 void Renderer::restoreCameraOrientation() 4836 { 4837 vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera(); 4838 camera->SetPosition(_cameraPos); 4839 camera->SetFocalPoint(_cameraFocalPoint); 4840 camera->SetViewUp(_cameraUp); 6839 camera->GetPosition(position); 6840 camera->GetFocalPoint(focalPoint); 6841 camera->GetViewUp(viewUp); 4841 6842 } 4842 6843 … … 4856 6857 camera->SetFocalPoint(0, 0, 0); 4857 6858 camera->SetViewUp(0, 1, 0); 4858 storeCameraOrientation(); 4859 } else { 4860 restoreCameraOrientation(); 6859 _cameraOrientation[0] = 1.0; 6860 _cameraOrientation[1] = 0.0; 6861 _cameraOrientation[2] = 0.0; 6862 _cameraOrientation[3] = 0.0; 4861 6863 } 4862 6864 setViewAngle(_windowHeight); … … 4865 6867 _renderer->ResetCamera(bounds); 4866 6868 _renderer->ResetCameraClippingRange(); 4867 computeScreenWorldCoords();6869 //computeScreenWorldCoords(); 4868 6870 } 4869 6871 … … 4875 6877 4876 6878 _needsRedraw = true; 6879 } 6880 6881 void Renderer::resetCameraClippingRange() 6882 { 6883 _renderer->ResetCameraClippingRange(); 4877 6884 } 4878 6885 … … 4893 6900 camera->Roll(roll); // Roll about camera view axis 4894 6901 _renderer->ResetCameraClippingRange(); 4895 storeCameraOrientation(); 4896 computeScreenWorldCoords(); 6902 //computeScreenWorldCoords(); 4897 6903 _needsRedraw = true; 4898 6904 } … … 4905 6911 * etc. 4906 6912 * 4907 * \param[in] x Viewport coordinate horizontal panning 4908 * \param[in] y Viewport coordinate vertical panning (with origin at top) 6913 * \param[in] x Viewport coordinate horizontal panning (positive number pans 6914 * camera left, object right) 6915 * \param[in] y Viewport coordinate vertical panning (positive number pans 6916 * camera up, object down) 4909 6917 * \param[in] absolute Control if pan amount is relative to current or absolute 4910 6918 */ … … 4952 6960 } 4953 6961 4954 vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera(); 4955 double viewFocus[4], focalDepth, viewPoint[3]; 4956 double newPickPoint[4], oldPickPoint[4], motionVector[3]; 4957 4958 camera->GetFocalPoint(viewFocus); 4959 computeWorldToDisplay(viewFocus[0], viewFocus[1], viewFocus[2], 4960 viewFocus); 4961 focalDepth = viewFocus[2]; 4962 4963 computeDisplayToWorld(( x * 2. + 1.) * _windowWidth / 2.0, 4964 ( y * 2. + 1.) * _windowHeight / 2.0, 4965 focalDepth, 4966 newPickPoint); 4967 4968 computeDisplayToWorld(_windowWidth / 2.0, 4969 _windowHeight / 2.0, 4970 focalDepth, 4971 oldPickPoint); 4972 4973 // Camera motion is reversed 4974 motionVector[0] = oldPickPoint[0] - newPickPoint[0]; 4975 motionVector[1] = oldPickPoint[1] - newPickPoint[1]; 4976 motionVector[2] = oldPickPoint[2] - newPickPoint[2]; 4977 4978 camera->GetFocalPoint(viewFocus); 4979 camera->GetPosition(viewPoint); 4980 camera->SetFocalPoint(motionVector[0] + viewFocus[0], 4981 motionVector[1] + viewFocus[1], 4982 motionVector[2] + viewFocus[2]); 4983 4984 camera->SetPosition(motionVector[0] + viewPoint[0], 4985 motionVector[1] + viewPoint[1], 4986 motionVector[2] + viewPoint[2]); 4987 4988 _renderer->ResetCameraClippingRange(); 4989 storeCameraOrientation(); 4990 //computeScreenWorldCoords(); 6962 if (x != 0.0 || y != 0.0) { 6963 vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera(); 6964 double viewFocus[4], focalDepth, viewPoint[3]; 6965 double newPickPoint[4], oldPickPoint[4], motionVector[3]; 6966 6967 camera->GetFocalPoint(viewFocus); 6968 computeWorldToDisplay(viewFocus[0], viewFocus[1], viewFocus[2], 6969 viewFocus); 6970 focalDepth = viewFocus[2]; 6971 6972 computeDisplayToWorld(( x * 2. + 1.) * _windowWidth / 2.0, 6973 ( y * 2. + 1.) * _windowHeight / 2.0, 6974 focalDepth, 6975 newPickPoint); 6976 6977 computeDisplayToWorld(_windowWidth / 2.0, 6978 _windowHeight / 2.0, 6979 focalDepth, 6980 oldPickPoint); 6981 6982 // Camera motion is reversed 6983 motionVector[0] = oldPickPoint[0] - newPickPoint[0]; 6984 motionVector[1] = oldPickPoint[1] - newPickPoint[1]; 6985 motionVector[2] = oldPickPoint[2] - newPickPoint[2]; 6986 6987 camera->GetFocalPoint(viewFocus); 6988 camera->GetPosition(viewPoint); 6989 camera->SetFocalPoint(motionVector[0] + viewFocus[0], 6990 motionVector[1] + viewFocus[1], 6991 motionVector[2] + viewFocus[2]); 6992 6993 camera->SetPosition(motionVector[0] + viewPoint[0], 6994 motionVector[1] + viewPoint[1], 6995 motionVector[2] + viewPoint[2]); 6996 6997 _renderer->ResetCameraClippingRange(); 6998 //computeScreenWorldCoords(); 6999 } 4991 7000 } 4992 7001 … … 5032 7041 camera->Zoom(z); // Change ortho parallel scale (Dolly has no effect in ortho) 5033 7042 _renderer->ResetCameraClippingRange(); 5034 storeCameraOrientation();5035 7043 } else { 5036 7044 camera->Dolly(z); // Move camera forward/back 5037 7045 _renderer->ResetCameraClippingRange(); 5038 storeCameraOrientation();5039 7046 //computeScreenWorldCoords(); 5040 7047 } … … 5438 7445 } 5439 7446 } 5440 #if 05441 // Currently lookup table/scalar data range not used, colormap is used to5442 // color streamlines by vector magnitude5443 7447 for (StreamlinesHashmap::iterator itr = _streamlines.begin(); 5444 7448 itr != _streamlines.end(); ++itr) { … … 5456 7460 } 5457 7461 } 5458 #endif5459 7462 for (VolumeHashmap::iterator itr = _volumes.begin(); 5460 7463 itr != _volumes.end(); ++itr) { … … 5537 7540 resetAxes(); 5538 7541 _renderer->ResetCamera(bounds); 5539 computeScreenWorldCoords();7542 //computeScreenWorldCoords(); 5540 7543 break; 5541 7544 case PERSPECTIVE: … … 5543 7546 resetAxes(); 5544 7547 _renderer->ResetCamera(bounds); 5545 computeScreenWorldCoords();7548 //computeScreenWorldCoords(); 5546 7549 break; 5547 7550 default: … … 5831 7834 5832 7835 /** 7836 * \brief Control the use of two sided lighting 7837 */ 7838 void Renderer::setUseTwoSidedLighting(bool state) 7839 { 7840 _renderer->SetTwoSidedLighting(state ? 1 : 0); 7841 _needsRedraw = true; 7842 } 7843 7844 /** 5833 7845 * \brief Control the use of the depth peeling algorithm for transparency 5834 7846 */ … … 5836 7848 { 5837 7849 _renderer->SetUseDepthPeeling(state ? 1 : 0); 7850 _needsRedraw = true; 7851 } 7852 7853 /** 7854 * \brief Sets flag to trigger rendering next time render() is called 7855 */ 7856 void Renderer::eventuallyRender() 7857 { 5838 7858 _needsRedraw = true; 5839 7859 } -
branches/blt4/packages/vizservers/vtkvis/RpVtkRenderer.h
r2322 r2409 67 67 FLY_STATIC_EDGES, 68 68 FLY_STATIC_TRIAD 69 }; 70 71 enum AxesTickPosition { 72 TICKS_INSIDE, 73 TICKS_OUTSIDE, 74 TICKS_BOTH 69 75 }; 70 76 … … 102 108 bool setDataFile(const DataSetId& id, const char *filename); 103 109 110 bool setDataSetActiveScalars(const DataSetId& id, const char *scalarName); 111 112 bool setDataSetActiveVectors(const DataSetId& id, const char *vectorName); 113 104 114 double getDataValueAtPixel(const DataSetId& id, int x, int y); 105 115 … … 114 124 // Render window 115 125 126 /// Get the VTK render window object this Renderer uses 116 127 vtkRenderWindow *getRenderWindow() 117 128 { … … 135 146 void resetCamera(bool resetOrientation = true); 136 147 148 void resetCameraClippingRange(); 149 137 150 void setCameraZoomRegion(double x, double y, double width, double height); 138 151 … … 143 156 void rotateCamera(double yaw, double pitch, double roll); 144 157 145 void setCameraOrientation(double quat[4]); 146 147 void setCameraOrientationAndPosition(double position[3], 148 double focalPoint[3], 149 double viewUp[3]); 158 void setCameraOrientation(const double quat[4], bool absolute = true); 159 160 void panCamera(double x, double y, bool absolute = true); 161 162 void zoomCamera(double z, bool absolute = true); 163 164 void setCameraOrientationAndPosition(const double position[3], 165 const double focalPoint[3], 166 const double viewUp[3]); 150 167 151 168 void getCameraOrientationAndPosition(double position[3], … … 153 170 double viewUp[3]); 154 171 155 void panCamera(double x, double y, bool absolute = true);156 157 void zoomCamera(double z, bool absolute = true);158 159 172 // Rendering an image 160 173 … … 165 178 void setClipPlane(Axis axis, double ratio, int direction); 166 179 180 void setUseTwoSidedLighting(bool state); 181 167 182 void setUseDepthPeeling(bool state); 168 183 184 void eventuallyRender(); 185 169 186 bool render(); 170 187 … … 175 192 void setAxesFlyMode(AxesFlyMode mode); 176 193 194 void setAxesVisibility(bool state); 195 177 196 void setAxesGridVisibility(bool state); 178 197 179 void setAxesVisibility(bool state); 198 void setAxesLabelVisibility(bool state); 199 200 void setAxesTickVisibility(bool state); 201 202 void setAxesTickPosition(AxesTickPosition pos); 180 203 181 204 void setAxesColor(double color[3]); 182 205 206 void setAxisVisibility(Axis axis, bool state); 207 183 208 void setAxisGridVisibility(Axis axis, bool state); 184 209 185 void setAxisVisibility(Axis axis, bool state); 210 void setAxisLabelVisibility(Axis axis, bool state); 211 212 void setAxisTickVisibility(Axis axis, bool state); 186 213 187 214 void setAxisTitle(Axis axis, const char *title); … … 211 238 Contour2D *getContour2D(const DataSetId& id); 212 239 240 void setContour2DTransform(const DataSetId& id, vtkMatrix4x4 *trans); 241 242 void setContour2DOrientation(const DataSetId& id, double quat[4]); 243 244 void setContour2DOrientation(const DataSetId& id, double angle, double axis[3]); 245 246 void setContour2DPosition(const DataSetId& id, double pos[3]); 247 248 void setContour2DScale(const DataSetId& id, double scale[3]); 249 250 void setContour2DEdgeColor(const DataSetId& id, float color[3]); 251 252 void setContour2DEdgeWidth(const DataSetId& id, float edgeWidth); 253 254 void setContour2DLighting(const DataSetId& id, bool state); 255 256 void setContour2DOpacity(const DataSetId& id, double opacity); 257 258 void setContour2DVisibility(const DataSetId& id, bool state); 259 213 260 void setContour2DContours(const DataSetId& id, int numContours); 214 261 215 262 void setContour2DContourList(const DataSetId& id, const std::vector<double>& contours); 216 263 217 void setContour2DOpacity(const DataSetId& id, double opacity);218 219 void setContour2DVisibility(const DataSetId& id, bool state);220 221 void setContour2DEdgeColor(const DataSetId& id, float color[3]);222 223 void setContour2DEdgeWidth(const DataSetId& id, float edgeWidth);224 225 void setContour2DLighting(const DataSetId& id, bool state);226 227 264 // 3D Contour (isosurface) plots 228 265 … … 233 270 Contour3D *getContour3D(const DataSetId& id); 234 271 272 void setContour3DTransform(const DataSetId& id, vtkMatrix4x4 *trans); 273 274 void setContour3DOrientation(const DataSetId& id, double quat[4]); 275 276 void setContour3DOrientation(const DataSetId& id, double angle, double axis[3]); 277 278 void setContour3DPosition(const DataSetId& id, double pos[3]); 279 280 void setContour3DScale(const DataSetId& id, double scale[3]); 281 282 void setContour3DColor(const DataSetId& id, float color[3]); 283 284 void setContour3DEdgeVisibility(const DataSetId& id, bool state); 285 286 void setContour3DEdgeColor(const DataSetId& id, float color[3]); 287 288 void setContour3DEdgeWidth(const DataSetId& id, float edgeWidth); 289 290 void setContour3DLighting(const DataSetId& id, bool state); 291 292 void setContour3DOpacity(const DataSetId& id, double opacity); 293 294 void setContour3DVisibility(const DataSetId& id, bool state); 295 296 void setContour3DWireframe(const DataSetId& id, bool state); 297 235 298 void setContour3DContours(const DataSetId& id, int numContours); 236 299 … … 239 302 void setContour3DColorMap(const DataSetId& id, const ColorMapId& colorMapId); 240 303 241 void setContour3DOpacity(const DataSetId& id, double opacity);242 243 void setContour3DVisibility(const DataSetId& id, bool state);244 245 void setContour3DColor(const DataSetId& id, float color[3]);246 247 void setContour3DEdgeVisibility(const DataSetId& id, bool state);248 249 void setContour3DEdgeColor(const DataSetId& id, float color[3]);250 251 void setContour3DEdgeWidth(const DataSetId& id, float edgeWidth);252 253 void setContour3DWireframe(const DataSetId& id, bool state);254 255 void setContour3DLighting(const DataSetId& id, bool state);256 257 304 // Glyphs 258 305 … … 263 310 Glyphs *getGlyphs(const DataSetId& id); 264 311 312 void setGlyphsTransform(const DataSetId& id, vtkMatrix4x4 *trans); 313 314 void setGlyphsOrientation(const DataSetId& id, double quat[4]); 315 316 void setGlyphsOrientation(const DataSetId& id, double angle, double axis[3]); 317 318 void setGlyphsPosition(const DataSetId& id, double pos[3]); 319 320 void setGlyphsScale(const DataSetId& id, double scale[3]); 321 322 void setGlyphsColor(const DataSetId& id, float color[3]); 323 324 void setGlyphsEdgeVisibility(const DataSetId& id, bool state); 325 326 void setGlyphsEdgeColor(const DataSetId& id, float color[3]); 327 328 void setGlyphsEdgeWidth(const DataSetId& id, float edgeWidth); 329 330 void setGlyphsLighting(const DataSetId& id, bool state); 331 332 void setGlyphsOpacity(const DataSetId& id, double opacity); 333 334 void setGlyphsVisibility(const DataSetId& id, bool state); 335 336 void setGlyphsWireframe(const DataSetId& id, bool state); 337 265 338 void setGlyphsColorMap(const DataSetId& id, const ColorMapId& colorMapId); 266 339 267 340 void setGlyphsShape(const DataSetId& id, Glyphs::GlyphShape shape); 268 341 342 void setGlyphsColorMode(const DataSetId& id, Glyphs::ColorMode mode); 343 344 void setGlyphsScalingMode(const DataSetId& id, Glyphs::ScalingMode mode); 345 269 346 void setGlyphsScaleFactor(const DataSetId& id, double scale); 270 347 271 void setGlyphsOpacity(const DataSetId& id, double opacity);272 273 void setGlyphsVisibility(const DataSetId& id, bool state);274 275 void setGlyphsLighting(const DataSetId& id, bool state);276 277 348 // Height maps 278 349 … … 283 354 HeightMap *getHeightMap(const DataSetId& id); 284 355 356 void setHeightMapTransform(const DataSetId& id, vtkMatrix4x4 *trans); 357 358 void setHeightMapOrientation(const DataSetId& id, double quat[4]); 359 360 void setHeightMapOrientation(const DataSetId& id, double angle, double axis[3]); 361 362 void setHeightMapPosition(const DataSetId& id, double pos[3]); 363 364 void setHeightMapScale(const DataSetId& id, double scale[3]); 365 366 void setHeightMapEdgeVisibility(const DataSetId& id, bool state); 367 368 void setHeightMapEdgeColor(const DataSetId& id, float color[3]); 369 370 void setHeightMapEdgeWidth(const DataSetId& id, float edgeWidth); 371 372 void setHeightMapLighting(const DataSetId& id, bool state); 373 374 void setHeightMapOpacity(const DataSetId& id, double opacity); 375 376 void setHeightMapVisibility(const DataSetId& id, bool state); 377 285 378 void setHeightMapVolumeSlice(const DataSetId& id, HeightMap::Axis axis, double ratio); 286 379 … … 293 386 void setHeightMapContourList(const DataSetId& id, const std::vector<double>& contours); 294 387 295 void setHeightMapOpacity(const DataSetId& id, double opacity);296 297 void setHeightMapVisibility(const DataSetId& id, bool state);298 299 void setHeightMapEdgeVisibility(const DataSetId& id, bool state);300 301 void setHeightMapEdgeColor(const DataSetId& id, float color[3]);302 303 void setHeightMapEdgeWidth(const DataSetId& id, float edgeWidth);304 305 388 void setHeightMapContourVisibility(const DataSetId& id, bool state); 306 389 … … 309 392 void setHeightMapContourEdgeWidth(const DataSetId& id, float edgeWidth); 310 393 311 void setHeightMapLighting(const DataSetId& id, bool state);312 313 394 // LIC plots 314 395 … … 319 400 LIC *getLIC(const DataSetId& id); 320 401 402 void setLICTransform(const DataSetId& id, vtkMatrix4x4 *trans); 403 404 void setLICOrientation(const DataSetId& id, double quat[4]); 405 406 void setLICOrientation(const DataSetId& id, double angle, double axis[3]); 407 408 void setLICPosition(const DataSetId& id, double pos[3]); 409 410 void setLICScale(const DataSetId& id, double scale[3]); 411 412 void setLICEdgeVisibility(const DataSetId& id, bool state); 413 414 void setLICEdgeColor(const DataSetId& id, float color[3]); 415 416 void setLICEdgeWidth(const DataSetId& id, float edgeWidth); 417 418 void setLICLighting(const DataSetId& id, bool state); 419 420 void setLICOpacity(const DataSetId& id, double opacity); 421 422 void setLICVisibility(const DataSetId& id, bool state); 423 321 424 void setLICVolumeSlice(const DataSetId& id, LIC::Axis axis, double ratio); 322 425 323 426 void setLICColorMap(const DataSetId& id, const ColorMapId& colorMapId); 324 427 325 void setLICOpacity(const DataSetId& id, double opacity);326 327 void setLICVisibility(const DataSetId& id, bool state);328 329 void setLICEdgeVisibility(const DataSetId& id, bool state);330 331 void setLICEdgeColor(const DataSetId& id, float color[3]);332 333 void setLICEdgeWidth(const DataSetId& id, float edgeWidth);334 335 void setLICLighting(const DataSetId& id, bool state);336 337 428 // Molecules 338 429 … … 343 434 Molecule *getMolecule(const DataSetId& id); 344 435 436 void setMoleculeTransform(const DataSetId& id, vtkMatrix4x4 *trans); 437 438 void setMoleculeOrientation(const DataSetId& id, double quat[4]); 439 440 void setMoleculeOrientation(const DataSetId& id, double angle, double axis[3]); 441 442 void setMoleculePosition(const DataSetId& id, double pos[3]); 443 444 void setMoleculeScale(const DataSetId& id, double scale[3]); 445 446 void setMoleculeEdgeVisibility(const DataSetId& id, bool state); 447 448 void setMoleculeEdgeColor(const DataSetId& id, float color[3]); 449 450 void setMoleculeEdgeWidth(const DataSetId& id, float edgeWidth); 451 452 void setMoleculeLighting(const DataSetId& id, bool state); 453 454 void setMoleculeOpacity(const DataSetId& id, double opacity); 455 456 void setMoleculeVisibility(const DataSetId& id, bool state); 457 458 void setMoleculeWireframe(const DataSetId& id, bool state); 459 345 460 void setMoleculeColorMap(const DataSetId& id, const ColorMapId& colorMapId); 346 461 347 void setMoleculeOpacity(const DataSetId& id, double opacity);348 349 462 void setMoleculeAtomScaling(const DataSetId& id, Molecule::AtomScaling scaling); 350 463 … … 353 466 void setMoleculeBondVisibility(const DataSetId& id, bool state); 354 467 355 void setMoleculeVisibility(const DataSetId& id, bool state);356 357 void setMoleculeEdgeVisibility(const DataSetId& id, bool state);358 359 void setMoleculeEdgeColor(const DataSetId& id, float color[3]);360 361 void setMoleculeEdgeWidth(const DataSetId& id, float edgeWidth);362 363 void setMoleculeWireframe(const DataSetId& id, bool state);364 365 void setMoleculeLighting(const DataSetId& id, bool state);366 367 468 // PolyData Meshes 368 469 … … 373 474 PolyData *getPolyData(const DataSetId& id); 374 475 476 void setPolyDataTransform(const DataSetId& id, vtkMatrix4x4 *trans); 477 478 void setPolyDataOrientation(const DataSetId& id, double quat[4]); 479 480 void setPolyDataOrientation(const DataSetId& id, double angle, double axis[3]); 481 482 void setPolyDataPosition(const DataSetId& id, double pos[3]); 483 484 void setPolyDataScale(const DataSetId& id, double scale[3]); 485 486 void setPolyDataColor(const DataSetId& id, float color[3]); 487 488 void setPolyDataEdgeVisibility(const DataSetId& id, bool state); 489 490 void setPolyDataEdgeColor(const DataSetId& id, float color[3]); 491 492 void setPolyDataEdgeWidth(const DataSetId& id, float edgeWidth); 493 494 void setPolyDataLighting(const DataSetId& id, bool state); 495 375 496 void setPolyDataOpacity(const DataSetId& id, double opacity); 376 497 377 498 void setPolyDataVisibility(const DataSetId& id, bool state); 378 499 379 void setPolyDataColor(const DataSetId& id, float color[3]);380 381 void setPolyDataEdgeVisibility(const DataSetId& id, bool state);382 383 void setPolyDataEdgeColor(const DataSetId& id, float color[3]);384 385 void setPolyDataEdgeWidth(const DataSetId& id, float edgeWidth);386 387 500 void setPolyDataWireframe(const DataSetId& id, bool state); 388 501 389 void setPolyDataLighting(const DataSetId& id, bool state);390 502 391 503 // Color-mapped surfaces … … 397 509 PseudoColor *getPseudoColor(const DataSetId& id); 398 510 511 void setPseudoColorTransform(const DataSetId& id, vtkMatrix4x4 *trans); 512 513 void setPseudoColorOrientation(const DataSetId& id, double quat[4]); 514 515 void setPseudoColorOrientation(const DataSetId& id, double angle, double axis[3]); 516 517 void setPseudoColorPosition(const DataSetId& id, double pos[3]); 518 519 void setPseudoColorScale(const DataSetId& id, double scale[3]); 520 521 void setPseudoColorEdgeVisibility(const DataSetId& id, bool state); 522 523 void setPseudoColorEdgeColor(const DataSetId& id, float color[3]); 524 525 void setPseudoColorEdgeWidth(const DataSetId& id, float edgeWidth); 526 527 void setPseudoColorLighting(const DataSetId& id, bool state); 528 529 void setPseudoColorOpacity(const DataSetId& id, double opacity); 530 531 void setPseudoColorVisibility(const DataSetId& id, bool state); 532 533 void setPseudoColorWireframe(const DataSetId& id, bool state); 534 399 535 void setPseudoColorColorMap(const DataSetId& id, const ColorMapId& colorMapId); 400 536 401 void setPseudoColorOpacity(const DataSetId& id, double opacity);402 403 void setPseudoColorVisibility(const DataSetId& id, bool state);404 405 void setPseudoColorEdgeVisibility(const DataSetId& id, bool state);406 407 void setPseudoColorEdgeColor(const DataSetId& id, float color[3]);408 409 void setPseudoColorEdgeWidth(const DataSetId& id, float edgeWidth);410 411 void setPseudoColorWireframe(const DataSetId& id, bool state);412 413 void setPseudoColorLighting(const DataSetId& id, bool state);414 415 537 // Streamlines 416 538 … … 421 543 Streamlines *getStreamlines(const DataSetId& id); 422 544 545 void setStreamlinesTransform(const DataSetId& id, vtkMatrix4x4 *trans); 546 547 void setStreamlinesOrientation(const DataSetId& id, double quat[4]); 548 549 void setStreamlinesOrientation(const DataSetId& id, double angle, double axis[3]); 550 551 void setStreamlinesPosition(const DataSetId& id, double pos[3]); 552 553 void setStreamlinesScale(const DataSetId& id, double scale[3]); 554 555 void setStreamlinesColor(const DataSetId& id, float color[3]); 556 557 void setStreamlinesEdgeVisibility(const DataSetId& id, bool state); 558 559 void setStreamlinesEdgeColor(const DataSetId& id, float color[3]); 560 561 void setStreamlinesEdgeWidth(const DataSetId& id, float edgeWidth); 562 563 void setStreamlinesLighting(const DataSetId& id, bool state); 564 565 void setStreamlinesOpacity(const DataSetId& id, double opacity); 566 567 void setStreamlinesVisibility(const DataSetId& id, bool state); 568 423 569 void setStreamlinesSeedToRandomPoints(const DataSetId& id, int numPoints); 424 570 425 void setStreamlinesSeedToRake(const DataSetId& id, double start[3], double end[3], int numPoints); 426 427 void setStreamlinesSeedToPolygon(const DataSetId& id, double center[3], double normal[3], 428 double radius, int numSides); 571 void setStreamlinesSeedToRake(const DataSetId& id, 572 double start[3], double end[3], 573 int numPoints); 574 575 void setStreamlinesSeedToDisk(const DataSetId& id, 576 double center[3], double normal[3], 577 double radius, double innerRadius, 578 int numPoints); 579 580 void setStreamlinesSeedToPolygon(const DataSetId& id, 581 double center[3], double normal[3], 582 double angle, double radius, 583 int numSides); 584 585 void setStreamlinesSeedToFilledPolygon(const DataSetId& id, 586 double center[3], double normal[3], 587 double angle, double radius, 588 int numSides, int numPoints); 429 589 430 590 void setStreamlinesLength(const DataSetId& id, double length); … … 436 596 void setStreamlinesTypeToRibbons(const DataSetId& id, double width, double angle); 437 597 438 void setStreamlinesOpacity(const DataSetId& id, double opacity);439 440 void setStreamlinesVisibility(const DataSetId& id, bool state);441 442 598 void setStreamlinesSeedVisibility(const DataSetId& id, bool state); 443 599 600 void setStreamlinesColorMode(const DataSetId& id, Streamlines::ColorMode mode); 601 444 602 void setStreamlinesColorMap(const DataSetId& id, const ColorMapId& colorMapId); 445 603 446 604 void setStreamlinesSeedColor(const DataSetId& id, float color[3]); 447 605 448 void setStreamlinesEdgeVisibility(const DataSetId& id, bool state);449 450 void setStreamlinesEdgeColor(const DataSetId& id, float color[3]);451 452 void setStreamlinesEdgeWidth(const DataSetId& id, float edgeWidth);453 454 void setStreamlinesLighting(const DataSetId& id, bool state);455 456 606 // Volumes 457 607 … … 462 612 Volume *getVolume(const DataSetId& id); 463 613 614 void setVolumeTransform(const DataSetId& id, vtkMatrix4x4 *trans); 615 616 void setVolumeOrientation(const DataSetId& id, double quat[4]); 617 618 void setVolumeOrientation(const DataSetId& id, double angle, double axis[3]); 619 620 void setVolumePosition(const DataSetId& id, double pos[3]); 621 622 void setVolumeScale(const DataSetId& id, double scale[3]); 623 624 void setVolumeAmbient(const DataSetId& id, double coeff); 625 626 void setVolumeDiffuse(const DataSetId& id, double coeff); 627 628 void setVolumeSpecular(const DataSetId& id, double coeff, double power); 629 630 void setVolumeLighting(const DataSetId& id, bool state); 631 632 void setVolumeOpacity(const DataSetId& id, double opacity); 633 634 void setVolumeVisibility(const DataSetId& id, bool state); 635 464 636 void setVolumeColorMap(const DataSetId& id, const ColorMapId& colorMapId); 465 466 void setVolumeOpacity(const DataSetId& id, double opacity);467 468 void setVolumeVisibility(const DataSetId& id, bool state);469 470 void setVolumeAmbient(const DataSetId& id, double coeff);471 472 void setVolumeDiffuse(const DataSetId& id, double coeff);473 474 void setVolumeSpecular(const DataSetId& id, double coeff, double power);475 476 void setVolumeLighting(const DataSetId& id, bool state);477 637 478 638 private: … … 494 654 void updateRanges(bool useCumulative); 495 655 656 void setCameraFromMatrix(vtkCamera *camera, vtkMatrix4x4 &mat); 657 496 658 void computeDisplayToWorld(double x, double y, double z, double worldPt[4]); 497 659 … … 500 662 void computeScreenWorldCoords(); 501 663 502 void storeCameraOrientation();503 void restoreCameraOrientation();504 664 void initCamera(); 505 665 void initAxes(); … … 512 672 double _imgWorldDims[2]; 513 673 double _screenWorldCoords[4]; 514 double _cameraPos[3]; 515 double _cameraFocalPoint[3]; 516 double _cameraUp[3]; 674 double _cameraOrientation[4]; 517 675 double _cameraZoomRatio; 518 676 double _cameraPan[2]; -
branches/blt4/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp
r2322 r2409 126 126 127 127 static int 128 AxisLabelsVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 129 Tcl_Obj *const *objv) 130 { 131 bool visible; 132 if (GetBooleanFromObj(interp, objv[3], &visible) != TCL_OK) { 133 return TCL_ERROR; 134 } 135 const char *string = Tcl_GetString(objv[2]); 136 char c = string[0]; 137 if ((c == 'x') && (strcmp(string, "x") == 0)) { 138 g_renderer->setAxisLabelVisibility(Renderer::X_AXIS, visible); 139 } else if ((c == 'y') && (strcmp(string, "y") == 0)) { 140 g_renderer->setAxisLabelVisibility(Renderer::Y_AXIS, visible); 141 } else if ((c == 'z') && (strcmp(string, "z") == 0)) { 142 g_renderer->setAxisLabelVisibility(Renderer::Z_AXIS, visible); 143 } else if ((c == 'a') && (strcmp(string, "all") == 0)) { 144 g_renderer->setAxesLabelVisibility(visible); 145 } else { 146 Tcl_AppendResult(interp, "bad axis option \"", string, 147 "\": should be axisName visible", (char*)NULL); 148 return TCL_ERROR; 149 } 150 return TCL_OK; 151 } 152 153 static int 128 154 AxisNameOp(ClientData clientData, Tcl_Interp *interp, int objc, 129 155 Tcl_Obj *const *objv) … … 141 167 Tcl_AppendResult(interp, "bad axis option \"", string, 142 168 "\": should be axisName title", (char*)NULL); 169 return TCL_ERROR; 170 } 171 return TCL_OK; 172 } 173 174 static int 175 AxisTicksVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 176 Tcl_Obj *const *objv) 177 { 178 bool visible; 179 if (GetBooleanFromObj(interp, objv[3], &visible) != TCL_OK) { 180 return TCL_ERROR; 181 } 182 const char *string = Tcl_GetString(objv[2]); 183 char c = string[0]; 184 if ((c == 'x') && (strcmp(string, "x") == 0)) { 185 g_renderer->setAxisTickVisibility(Renderer::X_AXIS, visible); 186 } else if ((c == 'y') && (strcmp(string, "y") == 0)) { 187 g_renderer->setAxisTickVisibility(Renderer::Y_AXIS, visible); 188 } else if ((c == 'z') && (strcmp(string, "z") == 0)) { 189 g_renderer->setAxisTickVisibility(Renderer::Z_AXIS, visible); 190 } else if ((c == 'a') && (strcmp(string, "all") == 0)) { 191 g_renderer->setAxesTickVisibility(visible); 192 } else { 193 Tcl_AppendResult(interp, "bad axis option \"", string, 194 "\": should be axisName visible", (char*)NULL); 195 return TCL_ERROR; 196 } 197 return TCL_OK; 198 } 199 200 static int 201 AxisTickPositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 202 Tcl_Obj *const *objv) 203 { 204 const char *string = Tcl_GetString(objv[2]); 205 char c = string[0]; 206 if ((c == 'i') && (strcmp(string, "inside") == 0)) { 207 g_renderer->setAxesTickPosition(Renderer::TICKS_INSIDE); 208 } else if ((c == 'o') && (strcmp(string, "outside") == 0)) { 209 g_renderer->setAxesTickPosition(Renderer::TICKS_OUTSIDE); 210 } else if ((c == 'b') && (strcmp(string, "both") == 0)) { 211 g_renderer->setAxesTickPosition(Renderer::TICKS_BOTH); 212 } else { 213 Tcl_AppendResult(interp, "bad axis option \"", string, 214 "\": should be inside, outside or both", (char*)NULL); 143 215 return TCL_ERROR; 144 216 } … … 197 269 {"flymode", 1, AxisFlyModeOp, 3, 3, "mode"}, 198 270 {"grid", 1, AxisGridOp, 4, 4, "axis bool"}, 271 {"labels", 1, AxisLabelsVisibleOp, 4, 4, "axis bool"}, 199 272 {"name", 1, AxisNameOp, 4, 4, "axis title"}, 273 {"tickpos", 2, AxisTickPositionOp, 3, 3, "position"}, 274 {"ticks", 2, AxisTicksVisibleOp, 4, 4, "axis bool"}, 200 275 {"units", 1, AxisUnitsOp, 4, 4, "axis units"}, 201 276 {"visible", 1, AxisVisibleOp, 4, 4, "axis bool"} … … 682 757 683 758 static int 759 Contour2DOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 760 Tcl_Obj *const *objv) 761 { 762 double quat[4]; 763 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 764 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 765 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 766 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 767 return TCL_ERROR; 768 } 769 if (objc == 7) { 770 const char *name = Tcl_GetString(objv[6]); 771 g_renderer->setContour2DOrientation(name, quat); 772 } else { 773 g_renderer->setContour2DOrientation("all", quat); 774 } 775 return TCL_OK; 776 } 777 778 static int 779 Contour2DPositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 780 Tcl_Obj *const *objv) 781 { 782 double pos[3]; 783 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 784 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 785 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 786 return TCL_ERROR; 787 } 788 if (objc == 6) { 789 const char *name = Tcl_GetString(objv[5]); 790 g_renderer->setContour2DPosition(name, pos); 791 } else { 792 g_renderer->setContour2DPosition("all", pos); 793 } 794 return TCL_OK; 795 } 796 797 static int 798 Contour2DScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 799 Tcl_Obj *const *objv) 800 { 801 double scale[3]; 802 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 803 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 804 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 805 return TCL_ERROR; 806 } 807 if (objc == 6) { 808 const char *name = Tcl_GetString(objv[5]); 809 g_renderer->setContour2DScale(name, scale); 810 } else { 811 g_renderer->setContour2DScale("all", scale); 812 } 813 return TCL_OK; 814 } 815 816 static int 684 817 Contour2DVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 685 818 Tcl_Obj *const *objv) … … 704 837 {"linecolor", 5, Contour2DLineColorOp, 5, 6, "r g b ?dataSetName?"}, 705 838 {"linewidth", 5, Contour2DLineWidthOp, 3, 4, "width ?dataSetName?"}, 706 {"opacity", 1, Contour2DOpacityOp, 3, 4, "value ?dataSetName?"}, 839 {"opacity", 2, Contour2DOpacityOp, 3, 4, "value ?dataSetName?"}, 840 {"orient", 2, Contour2DOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, 841 {"pos", 1, Contour2DPositionOp, 5, 6, "x y z ?dataSetName?"}, 842 {"scale", 1, Contour2DScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 707 843 {"visible", 1, Contour2DVisibleOp, 3, 4, "bool ?dataSetName?"} 708 844 }; … … 928 1064 929 1065 static int 1066 Contour3DOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 1067 Tcl_Obj *const *objv) 1068 { 1069 double quat[4]; 1070 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 1071 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 1072 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 1073 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 1074 return TCL_ERROR; 1075 } 1076 if (objc == 7) { 1077 const char *name = Tcl_GetString(objv[6]); 1078 g_renderer->setContour3DOrientation(name, quat); 1079 } else { 1080 g_renderer->setContour3DOrientation("all", quat); 1081 } 1082 return TCL_OK; 1083 } 1084 1085 static int 1086 Contour3DPositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 1087 Tcl_Obj *const *objv) 1088 { 1089 double pos[3]; 1090 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 1091 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 1092 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 1093 return TCL_ERROR; 1094 } 1095 if (objc == 6) { 1096 const char *name = Tcl_GetString(objv[5]); 1097 g_renderer->setContour3DPosition(name, pos); 1098 } else { 1099 g_renderer->setContour3DPosition("all", pos); 1100 } 1101 return TCL_OK; 1102 } 1103 1104 static int 1105 Contour3DScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 1106 Tcl_Obj *const *objv) 1107 { 1108 double scale[3]; 1109 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 1110 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 1111 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 1112 return TCL_ERROR; 1113 } 1114 if (objc == 6) { 1115 const char *name = Tcl_GetString(objv[5]); 1116 g_renderer->setContour3DScale(name, scale); 1117 } else { 1118 g_renderer->setContour3DScale("all", scale); 1119 } 1120 return TCL_OK; 1121 } 1122 1123 static int 930 1124 Contour3DVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 931 1125 Tcl_Obj *const *objv) … … 963 1157 static Rappture::CmdSpec contour3dOps[] = { 964 1158 {"add", 1, Contour3DAddOp, 4, 5, "oper value ?dataSetName?"}, 965 {"c olor", 6, Contour3DColorOp, 5, 6, "r g b ?dataSetName?"},966 {"colormap", 6, Contour3DColorMapOp, 3, 4, "colorMapName ?dataSetName?"},1159 {"ccolor", 2, Contour3DColorOp, 5, 6, "r g b ?dataSetName?"}, 1160 {"colormap", 2, Contour3DColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 967 1161 {"delete", 1, Contour3DDeleteOp, 2, 3, "?dataSetName?"}, 968 1162 {"edges", 1, Contour3DEdgeVisibilityOp, 3, 4, "bool ?dataSetName?"}, … … 970 1164 {"linecolor", 5, Contour3DLineColorOp, 5, 6, "r g b ?dataSetName?"}, 971 1165 {"linewidth", 5, Contour3DLineWidthOp, 3, 4, "width ?dataSetName?"}, 972 {"opacity", 1, Contour3DOpacityOp, 3, 4, "value ?dataSetName?"}, 1166 {"opacity", 2, Contour3DOpacityOp, 3, 4, "value ?dataSetName?"}, 1167 {"orient", 2, Contour3DOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, 1168 {"pos", 1, Contour3DPositionOp, 5, 6, "x y z ?dataSetName?"}, 1169 {"scale", 1, Contour3DScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 973 1170 {"visible", 1, Contour3DVisibleOp, 3, 4, "bool ?dataSetName?"}, 974 1171 {"wireframe", 1, Contour3DWireframeOp, 3, 4, "bool ?dataSetName?"} … … 988 1185 } 989 1186 return (*proc) (clientData, interp, objc, objv); 1187 } 1188 1189 static int 1190 DataSetActiveScalarsOp(ClientData clientData, Tcl_Interp *interp, int objc, 1191 Tcl_Obj *const *objv) 1192 { 1193 const char *scalarName = Tcl_GetString(objv[2]); 1194 if (objc == 4) { 1195 const char *name = Tcl_GetString(objv[3]); 1196 if (!g_renderer->setDataSetActiveScalars(name, scalarName)) { 1197 Tcl_AppendResult(interp, "scalar \"", scalarName, 1198 "\" not found", (char*)NULL); 1199 return TCL_ERROR; 1200 } 1201 } else { 1202 if (!g_renderer->setDataSetActiveScalars("all", scalarName)) { 1203 Tcl_AppendResult(interp, "scalar \"", scalarName, 1204 "\" not found in one or more data sets", (char*)NULL); 1205 return TCL_ERROR; 1206 } 1207 } 1208 return TCL_OK; 1209 } 1210 1211 static int 1212 DataSetActiveVectorsOp(ClientData clientData, Tcl_Interp *interp, int objc, 1213 Tcl_Obj *const *objv) 1214 { 1215 const char *vectorName = Tcl_GetString(objv[2]); 1216 if (objc == 4) { 1217 const char *name = Tcl_GetString(objv[3]); 1218 if (!g_renderer->setDataSetActiveVectors(name, vectorName)) { 1219 Tcl_AppendResult(interp, "vector \"", vectorName, 1220 "\" not found", (char*)NULL); 1221 return TCL_ERROR; 1222 } 1223 } else { 1224 if (!g_renderer->setDataSetActiveVectors("all", vectorName)) { 1225 Tcl_AppendResult(interp, "vector \"", vectorName, 1226 "\" not found in one or more data sets", (char*)NULL); 1227 return TCL_ERROR; 1228 } 1229 } 1230 return TCL_OK; 990 1231 } 991 1232 … … 1188 1429 {"maprange", 1, DataSetMapRangeOp, 3, 3, "value"}, 1189 1430 {"opacity", 1, DataSetOpacityOp, 3, 4, "value ?name?"}, 1190 {"visible", 1, DataSetVisibleOp, 3, 4, "bool ?name?"} 1431 {"scalar", 1, DataSetActiveScalarsOp, 3, 4, "scalarName ?name?"}, 1432 {"vector", 2, DataSetActiveVectorsOp, 3, 4, "vectorName ?name?"}, 1433 {"visible", 2, DataSetVisibleOp, 3, 4, "bool ?name?"} 1191 1434 }; 1192 1435 static int nDataSetOps = NumCmdSpecs(dataSetOps); … … 1249 1492 1250 1493 static int 1494 GlyphsColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 1495 Tcl_Obj *const *objv) 1496 { 1497 float color[3]; 1498 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 1499 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 1500 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 1501 return TCL_ERROR; 1502 } 1503 if (objc == 6) { 1504 const char *name = Tcl_GetString(objv[5]); 1505 g_renderer->setGlyphsColor(name, color); 1506 } else { 1507 g_renderer->setGlyphsColor("all", color); 1508 } 1509 return TCL_OK; 1510 } 1511 1512 static int 1251 1513 GlyphsColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc, 1252 1514 Tcl_Obj *const *objv) … … 1258 1520 } else { 1259 1521 g_renderer->setGlyphsColorMap("all", colorMapName); 1522 } 1523 return TCL_OK; 1524 } 1525 1526 static int 1527 GlyphsColorModeOp(ClientData clientData, Tcl_Interp *interp, int objc, 1528 Tcl_Obj *const *objv) 1529 { 1530 Glyphs::ColorMode mode; 1531 const char *str = Tcl_GetString(objv[2]); 1532 if (str[0] == 'c' && strcmp(str, "ccolor") == 0) { 1533 mode = Glyphs::COLOR_CONSTANT; 1534 } else if (str[0] == 's' && strcmp(str, "scale") == 0) { 1535 mode = Glyphs::COLOR_BY_SCALE; 1536 } else if (str[0] == 's' && strcmp(str, "scalar") == 0) { 1537 mode = Glyphs::COLOR_BY_SCALAR; 1538 } else if (str[0] == 'v' && strcmp(str, "vector") == 0) { 1539 mode = Glyphs::COLOR_BY_VECTOR; 1540 } else { 1541 Tcl_AppendResult(interp, "bad color mode option \"", str, 1542 "\": should be one of: 'scale', 'scalar', 'vector', 'ccolor'", (char*)NULL); 1543 return TCL_ERROR; 1544 } 1545 if (objc == 4) { 1546 const char *name = Tcl_GetString(objv[3]); 1547 g_renderer->setGlyphsColorMode(name, mode); 1548 } else { 1549 g_renderer->setGlyphsColorMode("all", mode); 1260 1550 } 1261 1551 return TCL_OK; … … 1276 1566 1277 1567 static int 1568 GlyphsEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc, 1569 Tcl_Obj *const *objv) 1570 { 1571 bool state; 1572 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 1573 return TCL_ERROR; 1574 } 1575 if (objc == 4) { 1576 const char *name = Tcl_GetString(objv[3]); 1577 g_renderer->setGlyphsEdgeVisibility(name, state); 1578 } else { 1579 g_renderer->setGlyphsEdgeVisibility("all", state); 1580 } 1581 return TCL_OK; 1582 } 1583 1584 static int 1278 1585 GlyphsLightingOp(ClientData clientData, Tcl_Interp *interp, int objc, 1279 1586 Tcl_Obj *const *objv) … … 1293 1600 1294 1601 static int 1602 GlyphsLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 1603 Tcl_Obj *const *objv) 1604 { 1605 float color[3]; 1606 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 1607 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 1608 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 1609 return TCL_ERROR; 1610 } 1611 if (objc == 6) { 1612 const char *name = Tcl_GetString(objv[5]); 1613 g_renderer->setGlyphsEdgeColor(name, color); 1614 } else { 1615 g_renderer->setGlyphsEdgeColor("all", color); 1616 } 1617 return TCL_OK; 1618 } 1619 1620 static int 1621 GlyphsLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc, 1622 Tcl_Obj *const *objv) 1623 { 1624 float width; 1625 if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) { 1626 return TCL_ERROR; 1627 } 1628 if (objc == 4) { 1629 const char *name = Tcl_GetString(objv[3]); 1630 g_renderer->setGlyphsEdgeWidth(name, width); 1631 } else { 1632 g_renderer->setGlyphsEdgeWidth("all", width); 1633 } 1634 return TCL_OK; 1635 } 1636 1637 static int 1295 1638 GlyphsOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc, 1296 1639 Tcl_Obj *const *objv) … … 1310 1653 1311 1654 static int 1655 GlyphsOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 1656 Tcl_Obj *const *objv) 1657 { 1658 double quat[4]; 1659 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 1660 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 1661 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 1662 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 1663 return TCL_ERROR; 1664 } 1665 if (objc == 7) { 1666 const char *name = Tcl_GetString(objv[6]); 1667 g_renderer->setGlyphsOrientation(name, quat); 1668 } else { 1669 g_renderer->setGlyphsOrientation("all", quat); 1670 } 1671 return TCL_OK; 1672 } 1673 1674 static int 1675 GlyphsPositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 1676 Tcl_Obj *const *objv) 1677 { 1678 double pos[3]; 1679 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 1680 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 1681 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 1682 return TCL_ERROR; 1683 } 1684 if (objc == 6) { 1685 const char *name = Tcl_GetString(objv[5]); 1686 g_renderer->setGlyphsPosition(name, pos); 1687 } else { 1688 g_renderer->setGlyphsPosition("all", pos); 1689 } 1690 return TCL_OK; 1691 } 1692 1693 static int 1312 1694 GlyphsScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 1313 1695 Tcl_Obj *const *objv) 1314 1696 { 1697 double scale[3]; 1698 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 1699 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 1700 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 1701 return TCL_ERROR; 1702 } 1703 if (objc == 6) { 1704 const char *name = Tcl_GetString(objv[5]); 1705 g_renderer->setGlyphsScale(name, scale); 1706 } else { 1707 g_renderer->setGlyphsScale("all", scale); 1708 } 1709 return TCL_OK; 1710 } 1711 1712 static int 1713 GlyphsScaleFactorOp(ClientData clientData, Tcl_Interp *interp, int objc, 1714 Tcl_Obj *const *objv) 1715 { 1315 1716 double scale; 1316 1717 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale) != TCL_OK) { … … 1322 1723 } else { 1323 1724 g_renderer->setGlyphsScaleFactor("all", scale); 1725 } 1726 return TCL_OK; 1727 } 1728 1729 static int 1730 GlyphsScalingModeOp(ClientData clientData, Tcl_Interp *interp, int objc, 1731 Tcl_Obj *const *objv) 1732 { 1733 Glyphs::ScalingMode mode; 1734 const char *str = Tcl_GetString(objv[2]); 1735 if (str[0] == 's' && strcmp(str, "scalar") == 0) { 1736 mode = Glyphs::SCALE_BY_SCALAR; 1737 } else if (str[0] == 'v' && strcmp(str, "vector") == 0) { 1738 mode = Glyphs::SCALE_BY_VECTOR; 1739 } else if (str[0] == 'v' && strcmp(str, "vector_comp") == 0) { 1740 mode = Glyphs::SCALE_BY_VECTOR_COMPONENTS; 1741 } else if (str[0] == 'o' && strcmp(str, "off") == 0) { 1742 mode = Glyphs::SCALING_OFF; 1743 } else { 1744 Tcl_AppendResult(interp, "bad scaling mode option \"", str, 1745 "\": should be one of: 'scalar', 'vector', 'vector_comp', 'off'", (char*)NULL); 1746 return TCL_ERROR; 1747 } 1748 if (objc == 4) { 1749 const char *name = Tcl_GetString(objv[3]); 1750 g_renderer->setGlyphsScalingMode(name, mode); 1751 } else { 1752 g_renderer->setGlyphsScalingMode("all", mode); 1324 1753 } 1325 1754 return TCL_OK; … … 1383 1812 } 1384 1813 1814 static int 1815 GlyphsWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc, 1816 Tcl_Obj *const *objv) 1817 { 1818 bool state; 1819 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 1820 return TCL_ERROR; 1821 } 1822 if (objc == 4) { 1823 const char *name = Tcl_GetString(objv[3]); 1824 g_renderer->setGlyphsWireframe(name, state); 1825 } else { 1826 g_renderer->setGlyphsWireframe("all", state); 1827 } 1828 return TCL_OK; 1829 } 1830 1385 1831 static Rappture::CmdSpec glyphsOps[] = { 1386 {"add", 1, GlyphsAddOp, 3, 4, "shape ?dataSetNme?"}, 1387 {"colormap", 1, GlyphsColorMapOp, 3, 4, "colorMapName ?dataSetNme?"}, 1388 {"delete", 1, GlyphsDeleteOp, 2, 3, "?dataSetName?"}, 1389 {"lighting", 1, GlyphsLightingOp, 3, 4, "bool ?dataSetName?"}, 1390 {"opacity", 1, GlyphsOpacityOp, 3, 4, "value ?dataSetName?"}, 1391 {"scale", 2, GlyphsScaleOp, 3, 4, "scaleFactor ?dataSetName?"}, 1392 {"shape", 2, GlyphsShapeOp, 3, 4, "shapeVal ?dataSetName?"}, 1393 {"visible", 1, GlyphsVisibleOp, 3, 4, "bool ?dataSetName?"} 1832 {"add", 1, GlyphsAddOp, 3, 4, "shape ?dataSetNme?"}, 1833 {"ccolor", 2, GlyphsColorOp, 5, 6, "r g b ?dataSetName?"}, 1834 {"colormap", 7, GlyphsColorMapOp, 3, 4, "colorMapName ?dataSetNme?"}, 1835 {"colormode", 7, GlyphsColorModeOp, 3, 4, "mode ?dataSetNme?"}, 1836 {"delete", 1, GlyphsDeleteOp, 2, 3, "?dataSetName?"}, 1837 {"edges", 1, GlyphsEdgeVisibilityOp, 3, 4, "bool ?dataSetName?"}, 1838 {"gscale", 1, GlyphsScaleFactorOp, 3, 4, "scaleFactor ?dataSetName?"}, 1839 {"lighting", 3, GlyphsLightingOp, 3, 4, "bool ?dataSetName?"}, 1840 {"linecolor", 5, GlyphsLineColorOp, 5, 6, "r g b ?dataSetName?"}, 1841 {"linewidth", 5, GlyphsLineWidthOp, 3, 4, "width ?dataSetName?"}, 1842 {"opacity", 2, GlyphsOpacityOp, 3, 4, "value ?dataSetName?"}, 1843 {"orient", 2, GlyphsOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, 1844 {"pos", 1, GlyphsPositionOp, 5, 6, "x y z ?dataSetName?"}, 1845 {"scale", 2, GlyphsScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 1846 {"shape", 2, GlyphsShapeOp, 3, 4, "shapeVal ?dataSetName?"}, 1847 {"smode", 2, GlyphsScalingModeOp, 3, 4, "mode ?dataSetNme?"}, 1848 {"visible", 1, GlyphsVisibleOp, 3, 4, "bool ?dataSetName?"}, 1849 {"wireframe", 1, GlyphsWireframeOp, 3, 4, "bool ?dataSetName?"} 1394 1850 }; 1395 1851 static int nGlyphsOps = NumCmdSpecs(glyphsOps); … … 1660 2116 } else { 1661 2117 g_renderer->setHeightMapOpacity("all", opacity); 2118 } 2119 return TCL_OK; 2120 } 2121 2122 static int 2123 HeightMapOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 2124 Tcl_Obj *const *objv) 2125 { 2126 double quat[4]; 2127 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 2128 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 2129 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 2130 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 2131 return TCL_ERROR; 2132 } 2133 if (objc == 7) { 2134 const char *name = Tcl_GetString(objv[6]); 2135 g_renderer->setHeightMapOrientation(name, quat); 2136 } else { 2137 g_renderer->setHeightMapOrientation("all", quat); 2138 } 2139 return TCL_OK; 2140 } 2141 2142 static int 2143 HeightMapPositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 2144 Tcl_Obj *const *objv) 2145 { 2146 double pos[3]; 2147 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 2148 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 2149 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 2150 return TCL_ERROR; 2151 } 2152 if (objc == 6) { 2153 const char *name = Tcl_GetString(objv[5]); 2154 g_renderer->setHeightMapPosition(name, pos); 2155 } else { 2156 g_renderer->setHeightMapPosition("all", pos); 2157 } 2158 return TCL_OK; 2159 } 2160 2161 static int 2162 HeightMapScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 2163 Tcl_Obj *const *objv) 2164 { 2165 double scale[3]; 2166 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 2167 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 2168 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 2169 return TCL_ERROR; 2170 } 2171 if (objc == 6) { 2172 const char *name = Tcl_GetString(objv[5]); 2173 g_renderer->setHeightMapScale(name, scale); 2174 } else { 2175 g_renderer->setHeightMapScale("all", scale); 1662 2176 } 1663 2177 return TCL_OK; … … 1724 2238 {"linecolor", 5, HeightMapLineColorOp, 5, 6, "r g b ?dataSetName?"}, 1725 2239 {"linewidth", 5, HeightMapLineWidthOp, 3, 4, "width ?dataSetName?"}, 1726 {"opacity", 1, HeightMapOpacityOp, 3, 4, "value ?dataSetName?"}, 2240 {"opacity", 2, HeightMapOpacityOp, 3, 4, "value ?dataSetName?"}, 2241 {"orient", 2, HeightMapOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, 2242 {"pos", 1, HeightMapPositionOp, 5, 6, "x y z ?dataSetName?"}, 2243 {"scale", 1, HeightMapScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 1727 2244 {"visible", 2, HeightMapVisibleOp, 3, 4, "bool ?dataSetName?"}, 1728 2245 {"volumeslice", 2, HeightMapVolumeSliceOp, 4, 5, "axis ratio ?dataSetName?"} … … 1925 2442 1926 2443 static int 2444 LICOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 2445 Tcl_Obj *const *objv) 2446 { 2447 double quat[4]; 2448 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 2449 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 2450 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 2451 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 2452 return TCL_ERROR; 2453 } 2454 if (objc == 7) { 2455 const char *name = Tcl_GetString(objv[6]); 2456 g_renderer->setLICOrientation(name, quat); 2457 } else { 2458 g_renderer->setLICOrientation("all", quat); 2459 } 2460 return TCL_OK; 2461 } 2462 2463 static int 2464 LICPositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 2465 Tcl_Obj *const *objv) 2466 { 2467 double pos[3]; 2468 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 2469 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 2470 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 2471 return TCL_ERROR; 2472 } 2473 if (objc == 6) { 2474 const char *name = Tcl_GetString(objv[5]); 2475 g_renderer->setLICPosition(name, pos); 2476 } else { 2477 g_renderer->setLICPosition("all", pos); 2478 } 2479 return TCL_OK; 2480 } 2481 2482 static int 2483 LICScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 2484 Tcl_Obj *const *objv) 2485 { 2486 double scale[3]; 2487 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 2488 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 2489 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 2490 return TCL_ERROR; 2491 } 2492 if (objc == 6) { 2493 const char *name = Tcl_GetString(objv[5]); 2494 g_renderer->setLICScale(name, scale); 2495 } else { 2496 g_renderer->setLICScale("all", scale); 2497 } 2498 return TCL_OK; 2499 } 2500 2501 static int 1927 2502 LICVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 1928 2503 Tcl_Obj *const *objv) … … 1980 2555 {"linecolor", 5, LICLineColorOp, 5, 6, "r g b ?dataSetName?"}, 1981 2556 {"linewidth", 5, LICLineWidthOp, 3, 4, "width ?dataSetName?"}, 1982 {"opacity", 1, LICOpacityOp, 3, 4, "value ?dataSetName?"}, 2557 {"opacity", 2, LICOpacityOp, 3, 4, "value ?dataSetName?"}, 2558 {"orient", 2, LICOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, 2559 {"pos", 1, LICPositionOp, 5, 6, "x y z ?dataSetName?"}, 2560 {"scale", 1, LICScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 1983 2561 {"visible", 2, LICVisibleOp, 3, 4, "bool ?dataSetName?"}, 1984 2562 {"volumeslice", 2, LICVolumeSliceOp, 4, 5, "axis ratio ?dataSetName?"} … … 2190 2768 2191 2769 static int 2770 MoleculeOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 2771 Tcl_Obj *const *objv) 2772 { 2773 double quat[4]; 2774 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 2775 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 2776 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 2777 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 2778 return TCL_ERROR; 2779 } 2780 if (objc == 7) { 2781 const char *name = Tcl_GetString(objv[6]); 2782 g_renderer->setMoleculeOrientation(name, quat); 2783 } else { 2784 g_renderer->setMoleculeOrientation("all", quat); 2785 } 2786 return TCL_OK; 2787 } 2788 2789 static int 2790 MoleculePositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 2791 Tcl_Obj *const *objv) 2792 { 2793 double pos[3]; 2794 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 2795 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 2796 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 2797 return TCL_ERROR; 2798 } 2799 if (objc == 6) { 2800 const char *name = Tcl_GetString(objv[5]); 2801 g_renderer->setMoleculePosition(name, pos); 2802 } else { 2803 g_renderer->setMoleculePosition("all", pos); 2804 } 2805 return TCL_OK; 2806 } 2807 2808 static int 2809 MoleculeScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 2810 Tcl_Obj *const *objv) 2811 { 2812 double scale[3]; 2813 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 2814 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 2815 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 2816 return TCL_ERROR; 2817 } 2818 if (objc == 6) { 2819 const char *name = Tcl_GetString(objv[5]); 2820 g_renderer->setMoleculeScale(name, scale); 2821 } else { 2822 g_renderer->setMoleculeScale("all", scale); 2823 } 2824 return TCL_OK; 2825 } 2826 2827 static int 2192 2828 MoleculeVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 2193 2829 Tcl_Obj *const *objv) … … 2233 2869 {"linecolor", 5, MoleculeLineColorOp, 5, 6, "r g b ?dataSetName?"}, 2234 2870 {"linewidth", 5, MoleculeLineWidthOp, 3, 4, "width ?dataSetName?"}, 2235 {"opacity", 1, MoleculeOpacityOp, 3, 4, "value ?dataSetName?"}, 2236 {"scaleatoms", 1, MoleculeAtomScalingOp, 3, 4, "scaling ?dataSetName?"}, 2871 {"opacity", 2, MoleculeOpacityOp, 3, 4, "value ?dataSetName?"}, 2872 {"orient", 2, MoleculeOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, 2873 {"pos", 1, MoleculePositionOp, 5, 6, "x y z ?dataSetName?"}, 2874 {"rscale", 1, MoleculeAtomScalingOp, 3, 4, "scaling ?dataSetName?"}, 2875 {"scale", 1, MoleculeScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 2237 2876 {"visible", 1, MoleculeVisibleOp, 3, 4, "bool ?dataSetName?"}, 2238 2877 {"wireframe", 1, MoleculeWireframeOp, 3, 4, "bool ?dataSetName?"} … … 2382 3021 } else { 2383 3022 g_renderer->setPolyDataOpacity("all", opacity); 3023 } 3024 return TCL_OK; 3025 } 3026 3027 static int 3028 PolyDataOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 3029 Tcl_Obj *const *objv) 3030 { 3031 double quat[4]; 3032 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 3033 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 3034 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 3035 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 3036 return TCL_ERROR; 3037 } 3038 if (objc == 7) { 3039 const char *name = Tcl_GetString(objv[6]); 3040 g_renderer->setPolyDataOrientation(name, quat); 3041 } else { 3042 g_renderer->setPolyDataOrientation("all", quat); 3043 } 3044 return TCL_OK; 3045 } 3046 3047 static int 3048 PolyDataPositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 3049 Tcl_Obj *const *objv) 3050 { 3051 double pos[3]; 3052 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 3053 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 3054 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 3055 return TCL_ERROR; 3056 } 3057 if (objc == 6) { 3058 const char *name = Tcl_GetString(objv[5]); 3059 g_renderer->setPolyDataPosition(name, pos); 3060 } else { 3061 g_renderer->setPolyDataPosition("all", pos); 3062 } 3063 return TCL_OK; 3064 } 3065 3066 static int 3067 PolyDataScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 3068 Tcl_Obj *const *objv) 3069 { 3070 double scale[3]; 3071 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 3072 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 3073 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 3074 return TCL_ERROR; 3075 } 3076 if (objc == 6) { 3077 const char *name = Tcl_GetString(objv[5]); 3078 g_renderer->setPolyDataScale(name, scale); 3079 } else { 3080 g_renderer->setPolyDataScale("all", scale); 2384 3081 } 2385 3082 return TCL_OK; … … 2428 3125 {"linecolor", 5, PolyDataLineColorOp, 5, 6, "r g b ?dataSetName?"}, 2429 3126 {"linewidth", 5, PolyDataLineWidthOp, 3, 4, "width ?dataSetName?"}, 2430 {"opacity", 1, PolyDataOpacityOp, 3, 4, "value ?dataSetName?"}, 3127 {"opacity", 2, PolyDataOpacityOp, 3, 4, "value ?dataSetName?"}, 3128 {"orient", 2, PolyDataOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, 3129 {"pos", 1, PolyDataPositionOp, 5, 6, "x y z ?dataSetName?"}, 3130 {"scale", 1, PolyDataScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 2431 3131 {"visible", 1, PolyDataVisibleOp, 3, 4, "bool ?dataSetName?"}, 2432 3132 {"wireframe", 1, PolyDataWireframeOp, 3, 4, "bool ?dataSetName?"} … … 2571 3271 } else { 2572 3272 g_renderer->setPseudoColorOpacity("all", opacity); 3273 } 3274 return TCL_OK; 3275 } 3276 3277 static int 3278 PseudoColorOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 3279 Tcl_Obj *const *objv) 3280 { 3281 double quat[4]; 3282 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 3283 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 3284 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 3285 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 3286 return TCL_ERROR; 3287 } 3288 if (objc == 7) { 3289 const char *name = Tcl_GetString(objv[6]); 3290 g_renderer->setPseudoColorOrientation(name, quat); 3291 } else { 3292 g_renderer->setPseudoColorOrientation("all", quat); 3293 } 3294 return TCL_OK; 3295 } 3296 3297 static int 3298 PseudoColorPositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 3299 Tcl_Obj *const *objv) 3300 { 3301 double pos[3]; 3302 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 3303 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 3304 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 3305 return TCL_ERROR; 3306 } 3307 if (objc == 6) { 3308 const char *name = Tcl_GetString(objv[5]); 3309 g_renderer->setPseudoColorPosition(name, pos); 3310 } else { 3311 g_renderer->setPseudoColorPosition("all", pos); 3312 } 3313 return TCL_OK; 3314 } 3315 3316 static int 3317 PseudoColorScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 3318 Tcl_Obj *const *objv) 3319 { 3320 double scale[3]; 3321 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 3322 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 3323 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 3324 return TCL_ERROR; 3325 } 3326 if (objc == 6) { 3327 const char *name = Tcl_GetString(objv[5]); 3328 g_renderer->setPseudoColorScale(name, scale); 3329 } else { 3330 g_renderer->setPseudoColorScale("all", scale); 2573 3331 } 2574 3332 return TCL_OK; … … 2617 3375 {"linecolor", 5, PseudoColorLineColorOp, 5, 6, "r g b ?dataSetName?"}, 2618 3376 {"linewidth", 5, PseudoColorLineWidthOp, 3, 4, "width ?dataSetName?"}, 2619 {"opacity", 1, PseudoColorOpacityOp, 3, 4, "value ?dataSetName?"}, 3377 {"opacity", 2, PseudoColorOpacityOp, 3, 4, "value ?dataSetName?"}, 3378 {"orient", 2, PseudoColorOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, 3379 {"pos", 1, PseudoColorPositionOp, 5, 6, "x y z ?dataSetName?"}, 3380 {"scale", 1, PseudoColorScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 2620 3381 {"visible", 1, PseudoColorVisibleOp, 3, 4, "bool ?dataSetName?"}, 2621 3382 {"wireframe", 1, PseudoColorWireframeOp, 3, 4, "bool ?dataSetName?"} … … 2679 3440 } 2680 3441 3442 static int 3443 RendererTwoSidedLightingOp(ClientData clientData, Tcl_Interp *interp, int objc, 3444 Tcl_Obj *const *objv) 3445 { 3446 bool state; 3447 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 3448 return TCL_ERROR; 3449 } 3450 g_renderer->setUseTwoSidedLighting(state); 3451 return TCL_OK; 3452 } 3453 3454 static int 3455 RendererRenderOp(ClientData clientData, Tcl_Interp *interp, int objc, 3456 Tcl_Obj *const *objv) 3457 { 3458 g_renderer->eventuallyRender(); 3459 return TCL_OK; 3460 } 3461 2681 3462 static Rappture::CmdSpec rendererOps[] = { 2682 {"clipplane", 1, RendererClipPlaneOp, 5, 5, "axis ratio direction"}, 2683 {"depthpeel", 1, RendererDepthPeelingOp, 3, 3, "bool"} 3463 {"clipplane", 1, RendererClipPlaneOp, 5, 5, "axis ratio direction"}, 3464 {"depthpeel", 1, RendererDepthPeelingOp, 3, 3, "bool"}, 3465 {"light2side", 1, RendererTwoSidedLightingOp, 3, 3, "bool"}, 3466 {"render", 1, RendererRenderOp, 2, 2, ""} 2684 3467 }; 2685 3468 static int nRendererOps = NumCmdSpecs(rendererOps); … … 2764 3547 2765 3548 static int 2766 StreamlinesColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc, 2767 Tcl_Obj *const *objv) 2768 { 2769 const char *colorMapName = Tcl_GetString(objv[2]); 2770 if (objc == 4) { 2771 const char *dataSetName = Tcl_GetString(objv[3]); 2772 g_renderer->setStreamlinesColorMap(dataSetName, colorMapName); 2773 } else { 2774 g_renderer->setStreamlinesColorMap("all", colorMapName); 2775 } 2776 return TCL_OK; 2777 } 2778 2779 static int 2780 StreamlinesDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 2781 Tcl_Obj *const *objv) 2782 { 2783 if (objc == 3) { 2784 const char *name = Tcl_GetString(objv[2]); 2785 g_renderer->deleteStreamlines(name); 2786 } else { 2787 g_renderer->deleteStreamlines("all"); 2788 } 2789 return TCL_OK; 2790 } 2791 2792 static int 2793 StreamlinesEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc, 2794 Tcl_Obj *const *objv) 2795 { 2796 bool state; 2797 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 2798 return TCL_ERROR; 2799 } 2800 if (objc == 4) { 2801 const char *name = Tcl_GetString(objv[3]); 2802 g_renderer->setStreamlinesEdgeVisibility(name, state); 2803 } else { 2804 g_renderer->setStreamlinesEdgeVisibility("all", state); 2805 } 2806 return TCL_OK; 2807 } 2808 2809 static int 2810 StreamlinesLengthOp(ClientData clientData, Tcl_Interp *interp, int objc, 2811 Tcl_Obj *const *objv) 2812 { 2813 double length; 2814 if (Tcl_GetDoubleFromObj(interp, objv[2], &length) != TCL_OK) { 2815 return TCL_ERROR; 2816 } 2817 if (objc == 4) { 2818 const char *name = Tcl_GetString(objv[3]); 2819 g_renderer->setStreamlinesLength(name, length); 2820 } else { 2821 g_renderer->setStreamlinesLength("all", length); 2822 } 2823 return TCL_OK; 2824 } 2825 2826 static int 2827 StreamlinesLightingOp(ClientData clientData, Tcl_Interp *interp, int objc, 2828 Tcl_Obj *const *objv) 2829 { 2830 bool state; 2831 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 2832 return TCL_ERROR; 2833 } 2834 if (objc == 4) { 2835 const char *name = Tcl_GetString(objv[3]); 2836 g_renderer->setStreamlinesLighting(name, state); 2837 } else { 2838 g_renderer->setStreamlinesLighting("all", state); 2839 } 2840 return TCL_OK; 2841 } 2842 2843 static int 2844 StreamlinesLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 2845 Tcl_Obj *const *objv) 3549 StreamlinesColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 3550 Tcl_Obj *const *objv) 2846 3551 { 2847 3552 float color[3]; … … 2853 3558 if (objc == 6) { 2854 3559 const char *name = Tcl_GetString(objv[5]); 3560 g_renderer->setStreamlinesColor(name, color); 3561 } else { 3562 g_renderer->setStreamlinesColor("all", color); 3563 } 3564 return TCL_OK; 3565 } 3566 3567 static int 3568 StreamlinesColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc, 3569 Tcl_Obj *const *objv) 3570 { 3571 const char *colorMapName = Tcl_GetString(objv[2]); 3572 if (objc == 4) { 3573 const char *dataSetName = Tcl_GetString(objv[3]); 3574 g_renderer->setStreamlinesColorMap(dataSetName, colorMapName); 3575 } else { 3576 g_renderer->setStreamlinesColorMap("all", colorMapName); 3577 } 3578 return TCL_OK; 3579 } 3580 3581 static int 3582 StreamlinesColorModeOp(ClientData clientData, Tcl_Interp *interp, int objc, 3583 Tcl_Obj *const *objv) 3584 { 3585 Streamlines::ColorMode mode; 3586 const char *str = Tcl_GetString(objv[2]); 3587 if (str[0] == 's' && strcmp(str, "scalar") == 0) { 3588 mode = Streamlines::COLOR_BY_SCALAR; 3589 } else if (str[0] == 'v' && strcmp(str, "vmag") == 0) { 3590 mode = Streamlines::COLOR_BY_VECTOR_MAGNITUDE; 3591 } else if (str[0] == 'v' && strcmp(str, "vx") == 0) { 3592 mode = Streamlines::COLOR_BY_VECTOR_X; 3593 } else if (str[0] == 'v' && strcmp(str, "vy") == 0) { 3594 mode = Streamlines::COLOR_BY_VECTOR_Y; 3595 } else if (str[0] == 'v' && strcmp(str, "vz") == 0) { 3596 mode = Streamlines::COLOR_BY_VECTOR_Z; 3597 } else if (str[0] == 'c' && strcmp(str, "ccolor") == 0) { 3598 mode = Streamlines::COLOR_CONSTANT; 3599 } else { 3600 Tcl_AppendResult(interp, "bad color mode option \"", str, 3601 "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor'", (char*)NULL); 3602 return TCL_ERROR; 3603 } 3604 if (objc == 4) { 3605 const char *dataSetName = Tcl_GetString(objv[3]); 3606 g_renderer->setStreamlinesColorMode(dataSetName, mode); 3607 } else { 3608 g_renderer->setStreamlinesColorMode("all", mode); 3609 } 3610 return TCL_OK; 3611 } 3612 3613 static int 3614 StreamlinesDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 3615 Tcl_Obj *const *objv) 3616 { 3617 if (objc == 3) { 3618 const char *name = Tcl_GetString(objv[2]); 3619 g_renderer->deleteStreamlines(name); 3620 } else { 3621 g_renderer->deleteStreamlines("all"); 3622 } 3623 return TCL_OK; 3624 } 3625 3626 static int 3627 StreamlinesEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc, 3628 Tcl_Obj *const *objv) 3629 { 3630 bool state; 3631 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 3632 return TCL_ERROR; 3633 } 3634 if (objc == 4) { 3635 const char *name = Tcl_GetString(objv[3]); 3636 g_renderer->setStreamlinesEdgeVisibility(name, state); 3637 } else { 3638 g_renderer->setStreamlinesEdgeVisibility("all", state); 3639 } 3640 return TCL_OK; 3641 } 3642 3643 static int 3644 StreamlinesLengthOp(ClientData clientData, Tcl_Interp *interp, int objc, 3645 Tcl_Obj *const *objv) 3646 { 3647 double length; 3648 if (Tcl_GetDoubleFromObj(interp, objv[2], &length) != TCL_OK) { 3649 return TCL_ERROR; 3650 } 3651 if (objc == 4) { 3652 const char *name = Tcl_GetString(objv[3]); 3653 g_renderer->setStreamlinesLength(name, length); 3654 } else { 3655 g_renderer->setStreamlinesLength("all", length); 3656 } 3657 return TCL_OK; 3658 } 3659 3660 static int 3661 StreamlinesLightingOp(ClientData clientData, Tcl_Interp *interp, int objc, 3662 Tcl_Obj *const *objv) 3663 { 3664 bool state; 3665 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 3666 return TCL_ERROR; 3667 } 3668 if (objc == 4) { 3669 const char *name = Tcl_GetString(objv[3]); 3670 g_renderer->setStreamlinesLighting(name, state); 3671 } else { 3672 g_renderer->setStreamlinesLighting("all", state); 3673 } 3674 return TCL_OK; 3675 } 3676 3677 static int 3678 StreamlinesLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 3679 Tcl_Obj *const *objv) 3680 { 3681 float color[3]; 3682 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 3683 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 3684 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 3685 return TCL_ERROR; 3686 } 3687 if (objc == 6) { 3688 const char *name = Tcl_GetString(objv[5]); 2855 3689 g_renderer->setStreamlinesEdgeColor(name, color); 2856 3690 } else { … … 2903 3737 } else { 2904 3738 g_renderer->setStreamlinesOpacity("all", opacity); 3739 } 3740 return TCL_OK; 3741 } 3742 3743 static int 3744 StreamlinesOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 3745 Tcl_Obj *const *objv) 3746 { 3747 double quat[4]; 3748 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 3749 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 3750 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 3751 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 3752 return TCL_ERROR; 3753 } 3754 if (objc == 7) { 3755 const char *name = Tcl_GetString(objv[6]); 3756 g_renderer->setStreamlinesOrientation(name, quat); 3757 } else { 3758 g_renderer->setStreamlinesOrientation("all", quat); 3759 } 3760 return TCL_OK; 3761 } 3762 3763 static int 3764 StreamlinesPositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 3765 Tcl_Obj *const *objv) 3766 { 3767 double pos[3]; 3768 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 3769 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 3770 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 3771 return TCL_ERROR; 3772 } 3773 if (objc == 6) { 3774 const char *name = Tcl_GetString(objv[5]); 3775 g_renderer->setStreamlinesPosition(name, pos); 3776 } else { 3777 g_renderer->setStreamlinesPosition("all", pos); 3778 } 3779 return TCL_OK; 3780 } 3781 3782 static int 3783 StreamlinesScaleOp(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->setStreamlinesScale(name, scale); 3795 } else { 3796 g_renderer->setStreamlinesScale("all", scale); 2905 3797 } 2906 3798 return TCL_OK; … … 2947 3839 2948 3840 static int 3841 StreamlinesSeedDiskOp(ClientData clientData, Tcl_Interp *interp, int objc, 3842 Tcl_Obj *const *objv) 3843 { 3844 double center[3], normal[3], radius, innerRadius; 3845 int numPoints; 3846 for (int i = 0; i < 3; i++) { 3847 if (Tcl_GetDoubleFromObj(interp, objv[3+i], ¢er[i]) != TCL_OK) { 3848 return TCL_ERROR; 3849 } 3850 if (Tcl_GetDoubleFromObj(interp, objv[6+i], &normal[i]) != TCL_OK) { 3851 return TCL_ERROR; 3852 } 3853 } 3854 if (Tcl_GetDoubleFromObj(interp, objv[9], &radius) != TCL_OK) { 3855 return TCL_ERROR; 3856 } 3857 if (Tcl_GetDoubleFromObj(interp, objv[10], &innerRadius) != TCL_OK) { 3858 return TCL_ERROR; 3859 } 3860 if (Tcl_GetIntFromObj(interp, objv[11], &numPoints) != TCL_OK) { 3861 return TCL_ERROR; 3862 } 3863 if (objc == 13) { 3864 const char *name = Tcl_GetString(objv[12]); 3865 g_renderer->setStreamlinesSeedToDisk(name, center, normal, radius, innerRadius, numPoints); 3866 } else { 3867 g_renderer->setStreamlinesSeedToDisk("all", center, normal, radius, innerRadius, numPoints); 3868 } 3869 return TCL_OK; 3870 } 3871 3872 static int 2949 3873 StreamlinesSeedPolygonOp(ClientData clientData, Tcl_Interp *interp, int objc, 2950 3874 Tcl_Obj *const *objv) 2951 3875 { 2952 double center[3], normal[3], radius;3876 double center[3], normal[3], angle, radius; 2953 3877 int numSides; 2954 3878 for (int i = 0; i < 3; i++) { … … 2960 3884 } 2961 3885 } 2962 if (Tcl_GetDoubleFromObj(interp, objv[9], &radius) != TCL_OK) { 2963 return TCL_ERROR; 2964 } 2965 if (Tcl_GetIntFromObj(interp, objv[10], &numSides) != TCL_OK) { 2966 return TCL_ERROR; 2967 } 2968 if (objc == 12) { 2969 const char *name = Tcl_GetString(objv[11]); 2970 g_renderer->setStreamlinesSeedToPolygon(name, center, normal, radius, numSides); 2971 } else { 2972 g_renderer->setStreamlinesSeedToPolygon("all", center, normal, radius, numSides); 3886 if (Tcl_GetDoubleFromObj(interp, objv[9], &angle) != TCL_OK) { 3887 return TCL_ERROR; 3888 } 3889 if (Tcl_GetDoubleFromObj(interp, objv[10], &radius) != TCL_OK) { 3890 return TCL_ERROR; 3891 } 3892 if (Tcl_GetIntFromObj(interp, objv[11], &numSides) != TCL_OK) { 3893 return TCL_ERROR; 3894 } 3895 if (numSides < 3) { 3896 Tcl_AppendResult(interp, "numSides must be 3 or greater", (char*)NULL); 3897 return TCL_ERROR; 3898 } 3899 if (objc == 13) { 3900 const char *name = Tcl_GetString(objv[12]); 3901 g_renderer->setStreamlinesSeedToPolygon(name, center, normal, angle, radius, numSides); 3902 } else { 3903 g_renderer->setStreamlinesSeedToPolygon("all", center, normal, angle, radius, numSides); 3904 } 3905 return TCL_OK; 3906 } 3907 3908 static int 3909 StreamlinesSeedFilledPolygonOp(ClientData clientData, Tcl_Interp *interp, int objc, 3910 Tcl_Obj *const *objv) 3911 { 3912 double center[3], normal[3], angle, radius; 3913 int numSides, numPoints; 3914 for (int i = 0; i < 3; i++) { 3915 if (Tcl_GetDoubleFromObj(interp, objv[3+i], ¢er[i]) != TCL_OK) { 3916 return TCL_ERROR; 3917 } 3918 if (Tcl_GetDoubleFromObj(interp, objv[6+i], &normal[i]) != TCL_OK) { 3919 return TCL_ERROR; 3920 } 3921 } 3922 if (Tcl_GetDoubleFromObj(interp, objv[9], &angle) != TCL_OK) { 3923 return TCL_ERROR; 3924 } 3925 if (Tcl_GetDoubleFromObj(interp, objv[10], &radius) != TCL_OK) { 3926 return TCL_ERROR; 3927 } 3928 if (Tcl_GetIntFromObj(interp, objv[11], &numSides) != TCL_OK) { 3929 return TCL_ERROR; 3930 } 3931 if (numSides < 3) { 3932 Tcl_AppendResult(interp, "numSides must be 3 or greater", (char*)NULL); 3933 return TCL_ERROR; 3934 } 3935 if (Tcl_GetIntFromObj(interp, objv[12], &numPoints) != TCL_OK) { 3936 return TCL_ERROR; 3937 } 3938 if (objc == 14) { 3939 const char *name = Tcl_GetString(objv[13]); 3940 g_renderer->setStreamlinesSeedToFilledPolygon(name, center, normal, angle, 3941 radius, numSides, numPoints); 3942 } else { 3943 g_renderer->setStreamlinesSeedToFilledPolygon("all", center, normal, angle, 3944 radius, numSides, numPoints); 2973 3945 } 2974 3946 return TCL_OK; … … 3037 4009 static Rappture::CmdSpec streamlinesSeedOps[] = { 3038 4010 {"color", 1, StreamlinesSeedColorOp, 6, 7, "r g b ?dataSetName?"}, 3039 {"polygon", 1, StreamlinesSeedPolygonOp, 11, 12, "centerX centerY centerZ normalX normalY normalZ radius numSides ?dataSetName?"}, 4011 {"disk", 1, StreamlinesSeedDiskOp, 12, 13, "centerX centerY centerZ normalX normalY normalZ radius innerRadius numPoints ?dataSetName?"}, 4012 {"fpoly", 1, StreamlinesSeedFilledPolygonOp, 13, 14, "centerX centerY centerZ normalX normalY normalZ angle radius numSides numPoints ?dataSetName?"}, 4013 {"polygon", 1, StreamlinesSeedPolygonOp, 12, 13, "centerX centerY centerZ normalX normalY normalZ angle radius numSides ?dataSetName?"}, 3040 4014 {"rake", 3, StreamlinesSeedRakeOp, 10, 11, "startX startY startZ endX endY endZ numPoints ?dataSetName?"}, 3041 4015 {"random", 3, StreamlinesSeedRandomOp, 4, 5, "numPoints ?dataSetName?"}, … … 3098 4072 static Rappture::CmdSpec streamlinesOps[] = { 3099 4073 {"add", 1, StreamlinesAddOp, 2, 3, "?dataSetName?"}, 3100 {"colormap", 1, StreamlinesColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 4074 {"ccolor", 1, StreamlinesColorOp, 5, 6, "r g b ?dataSetName?"}, 4075 {"colormap", 7, StreamlinesColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 4076 {"colormode", 7, StreamlinesColorModeOp, 3, 4, "mode ?dataSetNme?"}, 3101 4077 {"delete", 1, StreamlinesDeleteOp, 2, 3, "?dataSetName?"}, 3102 4078 {"edges", 1, StreamlinesEdgeVisibilityOp, 3, 4, "bool ?dataSetName?"}, … … 3106 4082 {"lines", 5, StreamlinesLinesOp, 2, 3, "?dataSetName?"}, 3107 4083 {"linewidth", 5, StreamlinesLineWidthOp, 3, 4, "width ?dataSetName?"}, 3108 {"opacity", 1, StreamlinesOpacityOp, 3, 4, "val ?dataSetName?"}, 4084 {"opacity", 2, StreamlinesOpacityOp, 3, 4, "val ?dataSetName?"}, 4085 {"orient", 2, StreamlinesOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, 4086 {"pos", 1, StreamlinesPositionOp, 5, 6, "x y z ?dataSetName?"}, 3109 4087 {"ribbons", 1, StreamlinesRibbonsOp, 4, 5, "width angle ?dataSetName?"}, 3110 {"seed", 1, StreamlinesSeedOp, 4, 11, "op params... ?dataSetName?"}, 4088 {"scale", 2, StreamlinesScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 4089 {"seed", 2, StreamlinesSeedOp, 4, 14, "op params... ?dataSetName?"}, 3111 4090 {"tubes", 1, StreamlinesTubesOp, 4, 5, "numSides radius ?dataSetName?"}, 3112 4091 {"visible", 1, StreamlinesVisibleOp, 3, 4, "bool ?dataSetName?"} … … 3198 4177 } else { 3199 4178 g_renderer->setVolumeOpacity("all", opacity); 4179 } 4180 return TCL_OK; 4181 } 4182 4183 static int 4184 VolumeOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 4185 Tcl_Obj *const *objv) 4186 { 4187 double quat[4]; 4188 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 4189 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 4190 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 4191 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 4192 return TCL_ERROR; 4193 } 4194 if (objc == 7) { 4195 const char *name = Tcl_GetString(objv[6]); 4196 g_renderer->setVolumeOrientation(name, quat); 4197 } else { 4198 g_renderer->setVolumeOrientation("all", quat); 4199 } 4200 return TCL_OK; 4201 } 4202 4203 static int 4204 VolumePositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 4205 Tcl_Obj *const *objv) 4206 { 4207 double pos[3]; 4208 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 4209 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 4210 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 4211 return TCL_ERROR; 4212 } 4213 if (objc == 6) { 4214 const char *name = Tcl_GetString(objv[5]); 4215 g_renderer->setVolumePosition(name, pos); 4216 } else { 4217 g_renderer->setVolumePosition("all", pos); 4218 } 4219 return TCL_OK; 4220 } 4221 4222 static int 4223 VolumeScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 4224 Tcl_Obj *const *objv) 4225 { 4226 double scale[3]; 4227 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 4228 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 4229 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 4230 return TCL_ERROR; 4231 } 4232 if (objc == 6) { 4233 const char *name = Tcl_GetString(objv[5]); 4234 g_renderer->setVolumeScale(name, scale); 4235 } else { 4236 g_renderer->setVolumeScale("all", scale); 3200 4237 } 3201 4238 return TCL_OK; … … 3300 4337 {"delete", 1, VolumeDeleteOp, 2, 3, "?dataSetName?"}, 3301 4338 {"lighting", 1, VolumeLightingOp, 3, 4, "bool ?dataSetName?"}, 3302 {"opacity", 1, VolumeOpacityOp, 3, 4, "val ?dataSetName?"}, 3303 {"shading", 1, VolumeShadingOp, 4, 6, "oper val ?dataSetName?"}, 4339 {"opacity", 2, VolumeOpacityOp, 3, 4, "val ?dataSetName?"}, 4340 {"orient", 2, VolumeOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, 4341 {"pos", 1, VolumePositionOp, 5, 6, "x y z ?dataSetName?"}, 4342 {"scale", 2, VolumeScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 4343 {"shading", 2, VolumeShadingOp, 4, 6, "oper val ?dataSetName?"}, 3304 4344 {"visible", 1, VolumeVisibleOp, 3, 4, "bool ?dataSetName?"} 3305 4345 }; -
branches/blt4/packages/vizservers/vtkvis/protocol.txt
r2323 r2409 15 15 renderer depthpeel <bool> 16 16 Set use of depth peeling algorithm for transparency 17 renderer light2side <bool> 18 Toggle use of two-sided lighting (controls if backfaces are lit with a 19 flipped normal) 20 renderer render 21 Force a new image to be rendered - use for advancing animation 17 22 18 23 axis color <r> <g> <b> … … 21 26 <mode> = static_edges|static_triad|outer_edges|furthest_triad|closest_triad 22 27 axis grid <bool> 28 axis labels <axis> <bool> 29 Toggle visibility of axis labels 30 <axis> = x|y|z|all 23 31 axis name <axis> <title> 32 axis tickpos <position> 33 Set position of ticks on 3D axes (not implemented for 2D axes) 34 <position> = inside|outside|both 35 axis ticks <axis> <bool> 36 Toggle visibility of axis tick marks 37 <axis> = x|y|z|all 24 38 axis units <axis> <units> 25 39 Currently only supported when camera mode is not image mode … … 28 42 29 43 camera get 30 Request current camera orientation44 Request current camera parameters 31 45 camera mode <mode> 32 46 <mode> = persp|ortho|image … … 37 51 Data is assumed to lie in XY plane (z = 0) 38 52 camera pan <x> <y> 39 <x,y> world coordinates 53 <x,y> viewport coordinates (window center at 0,0). Positive x pan 54 means pan object to right (camera to left). Positive y pan means 55 pan object down (camera up). For example a pan of 0.5, 0.5 would 56 move the object center to the lower right corner of the window 40 57 camera reset <?all?> 41 58 Option all resets orientation/rotation as well as pan/zoom/clip range 42 59 camera rotate <yaw> <pitch> <roll> 43 Specify relative rotation in Euler angles (FIXME)60 Specify relative rotation in Euler angles 44 61 camera set <posX> <posY> <posZ> <focalPtX> <focalPtY> <focalPtZ> <viewUpX> <viewUpY> <viewUpZ> 45 Set camera orientation using camera position, focal point and view up 46 vector 62 Set camera parameters: camera position, focal point and view up vector 47 63 camera zoom <z> 48 Specify zoom ratio 64 Specify zoom ratio. z > 1 is a zoom in, z < 1 is zoom out. z = 1 65 resets to default. 49 66 50 67 colormap add <colorMapName> <colorMap> <opacityMap> … … 68 85 "all" 69 86 dataset opacity <val> <?datasetName?> 87 dataset scalar <scalarName> <?datasetName?> 88 Set the active scalar field to plot 89 dataset vector <vectorName> <?datasetName?> 90 Set the active vector field to plot 70 91 dataset visible <bool> <?datasetName?> 71 92 … … 80 101 contour2d linewidth <val> <?datasetName?> 81 102 contour2d opacity <val> <?datasetName?> 103 contour2d orient <qw> <qx> <qy> <qz> <?dataSetName?> 104 contour2d pos <x> <y> <z> <?dataSetName?> 105 contour2d scale <sx> <sy> <sz> <?dataSetName?> 82 106 contour2d visible <bool> <?datasetName?> 83 107 … … 87 111 contour3d add contourlist <list> <?datasetName?> 88 112 list = {isoval1 isoval2 isoval3...} 89 contour3d c olor r g b <?datasetName?>113 contour3d ccolor r g b <?datasetName?> 90 114 contour3d colormap <colorMapName> <?dataSetName?> 91 115 contour3d delete <?datasetName?> … … 95 119 contour3d linewidth <val> <?datasetName?> 96 120 contour3d opacity <val> <?datasetName?> 121 contour3d orient <qw> <qx> <qy> <qz> <?dataSetName?> 122 contour3d pos <x> <y> <z> <?dataSetName?> 123 contour3d scale <sx> <sy> <sz> <?dataSetName?> 97 124 contour3d visible <bool> <?datasetName?> 98 125 contour3d wireframe <bool> <?datasetName?> 99 126 100 127 glyphs add <?dataSetName?> 128 glyphs ccolor r g b <?datasetName?> 101 129 glyphs colormap <colorMapName> <?dataSetName?> 130 glyphs colormode <scale|scalar|vector|ccolor> <?dataSetName?> 131 Set the color mode: color by scale, scalar field or 132 vector magnitude -- uses the current color map 102 133 glyphs delete <?dataSetName?> 134 glyphs edges <bool> <?datasetName?> 135 glyphs gscale <scaleFactor> <?datasetName?> 136 Set glyph scaling factor 103 137 glyphs lighting <bool> <?datasetName?> 138 glyphs linecolor <r> <g> <b> <?datasetName?> 139 glyphs linewidth <val> <?datasetName?> 104 140 glyphs opacity <val> <?datasetName?> 105 glyphs scale <scaleFactor> <?datasetName?> 141 glyphs orient <qw> <qx> <qy> <qz> <?dataSetName?> 142 glyphs pos <x> <y> <z> <?dataSetName?> 143 glyphs scale <sx> <sy> <sz> <?dataSetName?> 106 144 glyphs shape <arrow|cone|cube|cylinder|dodecahedron|icosahedron|octahedron|sphere|tetrahedron> <?datasetName?> 145 glyphs smode <scalar|vector|vector_comp|off> <?dataSetName?> 146 Set the scaling mode: use the scalar field, vector magnitude 147 (uniform scale), vector components, or disable scaling 107 148 glyphs visible <bool> <?datasetName?> 149 glyphs wireframe <bool> <?datasetName?> 108 150 109 151 heightmap add numcontours <n> <?dataSetName?> … … 123 165 heightmap linewidth <width> <?dataSetName?> 124 166 heightmap opacity <value> <?dataSetName?> 167 heightmap orient <qw> <qx> <qy> <qz> <?dataSetName?> 168 heightmap pos <x> <y> <z> <?dataSetName?> 169 heightmap scale <sx> <sy> <sz> <?dataSetName?> 125 170 heightmap visible <bool> <?dataSetName?> 126 171 heightmap volumeslice axis ratio <?dataSetName?> … … 136 181 lic linewidth <val> <?datasetName?> 137 182 lic opacity <val> <?datasetName?> 183 lic orient <qw> <qx> <qy> <qz> <?dataSetName?> 184 lic pos <x> <y> <z> <?dataSetName?> 185 lic scale <sx> <sy> <sz> <?dataSetName?> 138 186 lic visible <bool> <?datasetName?> 139 187 lic volumeslice <axis> <ratio> <?datasetName?> … … 151 199 molecule linewidth <val> <?datasetName?> 152 200 molecule opacity <val> <?datasetName?> 153 molecule scaleatoms <val> <?dataSetName?> 201 molecule orient <qw> <qx> <qy> <qz> <?dataSetName?> 202 molecule pos <x> <y> <z> <?dataSetName?> 203 molecule rscale <val> <?dataSetName?> 204 Atom radius scaling 154 205 val = van_der_walls|covalent|atomic|none 206 molecule scale <sx> <sy> <sz> <?dataSetName?> 155 207 molecule visible <bool> <?datasetName?> 156 208 molecule wireframe <bool> <?datasetName?> … … 164 216 polydata linewidth <val> <?datasetName?> 165 217 polydata opacity <val> <?datasetName?> 218 polydata orient <qw> <qx> <qy> <qz> <?dataSetName?> 219 polydata pos <x> <y> <z> <?dataSetName?> 220 polydata scale <sx> <sy> <sz> <?dataSetName?> 166 221 polydata visible <bool> <?datasetName?> 167 222 polydata wireframe <bool> <?datasetName?> … … 175 230 pseudocolor linewidth <val> <?datasetName?> 176 231 pseudocolor opacity <val> <?datasetName?> 232 pseudocolor orient <qw> <qx> <qy> <qz> <?dataSetName?> 233 pseudocolor pos <x> <y> <z> <?dataSetName?> 234 pseudocolor scale <sx> <sy> <sz> <?dataSetName?> 177 235 pseudocolor visible <bool> <?datasetName?> 178 236 pseudocolor wireframe <bool> <?datasetName?> 179 237 180 238 streamlines add <?datasetName?> 239 streamlines ccolor <r> <g> <b> <?datasetName?> 240 Set the constant color of streamlines used for color mode 'ccolor' 181 241 streamlines colormap <colormapName> <?datasetName?> 182 242 Colormap used to color streamlines/tubes/ribbons by vector magnitude 243 streamlines colormode <scalar|vmag|vx|vy|vz|ccolor> <?datasetName?> 244 Set the field used to color the streamlines. 'ccolor' means to use 245 the constant color defined by the ccolor subcommand. 'scalar' uses 246 the active scalar field. 'vmag' uses the magnitude of the current 247 vector field, and 'vx','vy','vz' use the corresponding component of 248 the active vector field. 183 249 streamlines delete <?datasetName?> 184 250 streamlines edges <bool> <?datasetName?> … … 193 259 streamlines linewidth <val> <?datasetName?> 194 260 streamlines opacity <val> <?datasetName?> 261 streamlines orient <qw> <qx> <qy> <qz> <?dataSetName?> 262 streamlines pos <x> <y> <z> <?dataSetName?> 195 263 streamlines ribbons <width> <angle> <?datasetName?> 196 264 Set rendering type to ribbons, width is minimum half-width, angle is 197 265 degrees offset from normal orientation 266 streamlines scale <sx> <sy> <sz> <?dataSetName?> 198 267 streamlines seed color <r> <g> <b> <?datasetName?> 199 streamlines seed polygon <centerX> <centerY> <centerZ> <normalX> <normalY> <normalZ> <radius> <numSides> <?dataSetName?> 268 streamlines seed disk <centerX> <centerY> <centerZ> <normalX> <normalY> <normalZ> <radius> <innerRadius> <numPoints> <?dataSetName?> 269 Create a disk seed area with optional hole, filled with randomly 270 placed points 271 streamlines seed fpoly <centerX> <centerY> <centerZ> <normalX> <normalY> <normalZ> <angle> <radius> <numSides> <numPoints> <?dataSetName?> 272 Create a regular n-sided polygonal seed area filled with randomly 273 placed points 274 streamlines seed polygon <centerX> <centerY> <centerZ> <normalX> <normalY> <normalZ> <angle> <radius> <numSides> <?dataSetName?> 275 Create seed points from vertices of a regular n-sided polygon 200 276 streamlines seed rake <startX> <startY> <startZ> <endX> <endY> <endZ> <numPoints> <?datasetName?> 201 277 streamlines seed random <numPoints> <?datasetName?> … … 210 286 volume delete <?datasetName?> 211 287 volume lighting <bool> <?datasetName?> 288 volume orient <qw> <qx> <qy> <qz> <?dataSetName?> 289 volume pos <x> <y> <z> <?dataSetName?> 290 volume scale <sx> <sy> <sz> <?dataSetName?> 212 291 volume shading ambient <coeff> <?datasetName?> 213 292 volume shading diffuse <coeff> <?datasetName?>
Note: See TracChangeset
for help on using the changeset viewer.