Ignore:
Timestamp:
Aug 25, 2011, 1:09:15 PM (13 years ago)
Author:
gah
Message:

update from branch

Location:
branches/blt4/packages/vizservers
Files:
61 edited

Legend:

Unmodified
Added
Removed
  • branches/blt4/packages/vizservers/Makefile.in

    r2201 r2409  
    4848        done
    4949        $(INSTALL) -m 0555 start_viz.sh $(bindir)/start_viz.sh
     50        $(INSTALL) -m 0555 start_nanoscale.sh $(bindir)/start_nanoscale.sh
    5051
    5152clean:
     
    5859          $(MAKE) -C $$i distclean ; \
    5960        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  
    85898589CPPFLAGS=$save_CPPFLAGS
    85908590
    8591  if test "${CG_DIR}" = "/usr" ; then
     8591if test "${CG_DIR}" = "/usr" ; then
    85928592  CG_DIR=""
    85938593else
     
    86278627
    86288628
    8629 ac_config_files="$ac_config_files Makefile nanoscale/Makefile 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"
     8629ac_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"
    86308630
    86318631cat >confcache <<\_ACEOF
     
    93379337    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
    93389338    "nanoscale/Makefile") CONFIG_FILES="$CONFIG_FILES nanoscale/Makefile" ;;
     9339    "nanoscale/renderservers.tcl") CONFIG_FILES="$CONFIG_FILES nanoscale/renderservers.tcl" ;;
    93399340    "nanovis/Makefile") CONFIG_FILES="$CONFIG_FILES nanovis/Makefile" ;;
    93409341    "nanovis/newmat11/Makefile") CONFIG_FILES="$CONFIG_FILES nanovis/newmat11/Makefile" ;;
     
    93499350    "vtkvis/Makefile") CONFIG_FILES="$CONFIG_FILES vtkvis/Makefile" ;;
    93509351    "start_viz.sh") CONFIG_FILES="$CONFIG_FILES start_viz.sh" ;;
     9352    "start_nanoscale.sh") CONFIG_FILES="$CONFIG_FILES start_nanoscale.sh" ;;
    93519353
    93529354  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
     
    99419943fi
    99429944
    9943 
  • branches/blt4/packages/vizservers/configure.in

    r2201 r2409  
    317317CPPFLAGS=$save_CPPFLAGS
    318318
    319  if test "${CG_DIR}" = "/usr" ; then
     319if test "${CG_DIR}" = "/usr" ; then
    320320  CG_DIR=""
    321321else
     
    356356
    357357AC_OUTPUT([
    358   Makefile \
     358   Makefile \
    359359   nanoscale/Makefile \
     360   nanoscale/renderservers.tcl \
    360361   nanovis/Makefile \
    361362   nanovis/newmat11/Makefile \
     
    369370   vtkvis/Doxyfile \
    370371   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 nanoscale
    21
    32CC              = @CC@
    43CFLAGS          = @CFLAGS@
    54EXTRA_CFLAGS    = -Wall
    6 DEFINES         = @DEFINES@
    7 CC_SWITCHES     = $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDES)
     5CC_SWITCHES     = $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDES) $(DEFINES)
    86LDFLAGS         = @LDFLAGS@
    97
     
    2119
    2220INSTALL         = @INSTALL@
    23 INSTALL_PROGRAM = ${INSTALL} -m 555
    24 INSTALL_DATA    = ${INSTALL} -m 444
    25 INSTALL_SCRIPT  = ${INSTALL} -m 444
     21INSTALL_PROGRAM = ${INSTALL} -m 0555
     22INSTALL_DATA    = ${INSTALL} -m 0444
     23INSTALL_SCRIPT  = ${INSTALL} -m 0444
     24RM              = rm -f
    2625
    27 SERVER_OBJS     = server.o
     26SERVER_OBJS     = server2.o
    2827CLIENT_OBJS     = client.o clientlib.o
    2928
     29TCL_LIB_SPEC    = @TCL_LIB_SPEC@
     30TCL_INC_SPEC    = @TCL_INC_SPEC@
     31LD_RUN_PATH     = $(libdir)
     32
     33DEFINES         = -DSERVERSFILE=\"$(libdir)/renderservers.tcl\"
     34INCLUDES        = $(TCL_INC_SPEC)
     35LIBS            = $(TCL_LIB_SPEC) \
     36                -Wl,-rpath,$(LD_RUN_PATH)
     37
    3038.PHONY: all install clean distclean
     39
     40TARGETS         = nanoscale
    3141
    3242all: $(TARGETS)
     
    3545        $(CC) $(CC_SWITCHES) -o $@ $^ $(LIBS)
    3646
    37 install: nanoscale
     47install: nanoscale renderservers.tcl
    3848        $(INSTALL_PROGRAM) -D nanoscale $(bindir)/nanoscale
     49        $(INSTALL_SCRIPT) renderservers.tcl $(libdir)
    3950
    4051client: $(CLIENT_OBJS)
     
    4455
    4556clean:
    46         rm -rf a.out $(SERVER_OBJS) *~ core* $(TARGETS) *.log *.tmp logfile* .deps/*.d
     57        $(RM) -r a.out $(SERVER_OBJS) *~ core* $(TARGETS) *.log *.tmp logfile* .deps/*.d
    4758
    4859distclean: clean
    49         rm Makefile
     60        $(RM) Makefile config.h renderservers.tcl
    5061
  • branches/blt4/packages/vizservers/nanoscale/server2.c

    r2341 r2409  
    11
    22#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>
    313#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
    1815#include <tcl.h>
    1916
    2017#define TRUE    1
    2118#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
    2323
    2424#define ERROR(...)      LogMessage(LOG_ERR, __FILE__, __LINE__, __VA_ARGS__)
    25 #ifdef WANT_TRACE
    2625#define TRACE(...)      LogMessage(LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__)
    27 #else
    28 #define TRACE(...)
    29 #endif
    3026#define WARN(...)       LogMessage(LOG_WARNING, __FILE__, __LINE__, __VA_ARGS__)
    3127#define INFO(...)       LogMessage(LOG_INFO, __FILE__, __LINE__, __VA_ARGS__)
    3228
     29static 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 */
    3344typedef struct {
    3445    const char *name;                   /* Name of server. */
    3546    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. */
    3952} RenderServer;
    4053
    41 static Tcl_HashTable serverTable;
    42 static int debugFlag = FALSE;
     54static 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. */
     59static int debug = FALSE;
     60static pid_t serverPid;
    4361
    4462void
     
    5876        s++;
    5977    }
    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);
    6180    length += vsnprintf(message + length, MSG_LEN - length, fmt, lst);
    6281    message[MSG_LEN] = '\0';
    63     if (debugFlag) {
     82    if (debug) {
    6483        fprintf(stderr, "%s\n", message);
    6584    } else {
     
    7695}
    7796
     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 */
    78126static int
    79127RegisterServerCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     
    85133    int f;
    86134    int port;
     135    int numCmdArgs, numEnvArgs;
     136    char *const *cmdArgs;
     137    char *const *envArgs;
    87138    struct sockaddr_in addr;
    88139    RenderServer *serverPtr;
    89140    Tcl_HashEntry *hPtr;
    90141
    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);
    94146        return TCL_ERROR;
    95147    }
    96148    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);
    101153    if (!isNew) {
    102         Tcl_AppendResult("a server is already listening on port ",
     154        Tcl_AppendResult(interp, "a server is already listening on port ",
    103155                Tcl_GetString(objv[2]), (char *)NULL);
    104156        return TCL_ERROR;
     
    106158    objPtr = Tcl_SubstObj(interp, objv[3],
    107159                          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) {
    109162        return TCL_ERROR;
    110163    }
     
    118171    }
    119172 
    120     /* If program is killed, drop the socket address reservation
    121      * immediately. */
     173    /* If the render server instance should be killed, drop the socket address
     174     * reservation immediately, don't linger. */
    122175    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) {
    125177        Tcl_AppendResult(interp, "can't create set socket option for \"",
    126178                serverName, "\": ", Tcl_PosixError(interp), (char *)NULL);
     
    132184    addr.sin_port = htons(port);
    133185    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) {
    136187        Tcl_AppendResult(interp, "can't bind to socket for \"",
    137188                serverName, "\": ", Tcl_PosixError(interp), (char *)NULL);
     
    139190    }
    140191    /* Listen on the specified port. */
    141     status = listen(f, 5);
    142     if (status < 0) {
     192    if (listen(f, 5) < 0) {
    143193        Tcl_AppendResult(interp, "can't listen to socket for \"",
    144194                serverName, "\": ", Tcl_PosixError(interp), (char *)NULL);
    145195        return TCL_ERROR;
    146196    }
     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    }
    147212    serverPtr = malloc(sizeof(RenderServer));
     213    memset(serverPtr, 0, sizeof(RenderServer));
    148214    if (serverPtr == NULL) {
    149215        Tcl_AppendResult(interp, "can't allocate structure for \"",
     
    152218    }
    153219    serverPtr->name = strdup(serverName);
    154     serverPtr->argv = argv;
    155     serverPtr->argc = argc;
     220    serverPtr->cmdArgs = cmdArgs;
     221    serverPtr->numCmdArgs = numCmdArgs;
    156222    serverPtr->listenerFd = f;
     223    serverPtr->envArgs = envArgs;
     224    serverPtr->numEnvArgs = numEnvArgs;
     225    Tcl_SetHashValue(hPtr, serverPtr);
    157226    return TCL_OK;
    158227}
     
    168237                         NULL);
    169238    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)));
    171240        return FALSE;
    172241    }
     
    178247main(int argc, char **argv)
    179248{
    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. */
    187261    Tcl_HashEntry *hPtr;
    188262    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;
    192267    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");
    200272    Tcl_InitHashTable(&serverTable, TCL_ONE_WORD_KEYS);
     273
     274    /* Process command line switches. */
    201275    while (1) {
    202276        int c;
     
    207281        };
    208282
    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);
    210284        if (c == -1) {
    211285            break;
     
    216290            maxCards = strtoul(optarg, 0, 0);
    217291            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");
    219293                return 1;
    220294            }
    221295            break;
    222296        case 'd':                       /* Debug  */
    223             debugFlag = TRUE;
     297            debug = TRUE;
    224298            break;
    225299
    226         case 'f':                       /* Server files */
     300        case 'f':                       /* Server file path. */
    227301            fileName = strdup(optarg);
    228302            break;
     
    235309    }
    236310
     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();
    237321    if (!ParseServersFile(fileName)) {
    238322        exit(1);
     
    240324
    241325    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
    252337
    253338    /* Build the array of servers listener file descriptors. */
     
    257342         hPtr = Tcl_NextHashEntry(&iter)) {
    258343        RenderServer *serverPtr;
    259 
     344       
    260345        serverPtr = Tcl_GetHashValue(hPtr);
    261346        FD_SET(serverPtr->listenerFd, &serverFds);
     
    264349        }
    265350    }
    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        }
    268360        for (hPtr = Tcl_FirstHashEntry(&serverTable, &iter); hPtr != NULL;
    269361             hPtr = Tcl_NextHashEntry(&iter)) {
    270362            RenderServer *serverPtr;
     363            pid_t child;
     364            int f;
     365            socklen_t length;
     366            struct sockaddr_in newaddr;
    271367
    272368            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);
    287406                }
    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);
    293411                }
    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. */
    327421                }
    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);
    329438            } else {
    330                 /* Reap initial child which will exit immediately
    331                  * (grandchild continues) */
    332                 waitpid(status, NULL, 0);
     439                close(f);
    333440            }
    334441        }
    335     }
    336     ERROR("select failed: ", strerror(errno));
     442    }
    337443    exit(1);
    338444}
    339 
  • branches/blt4/packages/vizservers/nanovis/Command.cpp

    r2307 r2409  
    11341134{
    11351135    TRACE("Data Loading\n");
    1136     fflush(stdout);
    11371136
    11381137    int nbytes;
     
    12061205    } else if ((nBytes > 5) && (strncmp(bytes, "<FET>", 5) == 0)) {
    12071206        TRACE("FET loading...\n");
    1208         fflush(stdout);
    12091207        std::stringstream fdata;
    12101208        fdata.write(nBytes - 5, bytes + 5);
     
    12181216    } else if ((nBytes > 5) && (strncmp(bytes, "<ODX>", 5) == 0)) {
    12191217        TRACE("Loading DX using OpenDX library...\n");
    1220         fflush(stdout);
    12211218        Rappture::Outcome context;
    12221219        volPtr = load_volume_stream_odx(context, tag, bytes + 5, nBytes -5);
     
    12271224    } else {
    12281225        TRACE("OpenDX loading...\n");
    1229         fflush(stdout);
    12301226        std::stringstream fdata;
    12311227        fdata.write(bytes, nBytes);
     
    12721268                volPtr->wAxis.min(), volPtr->wAxis.max(),
    12731269                Volume::valueMin, Volume::valueMax);
    1274         nWritten  = write(0, info, strlen(info));
     1270        nWritten  = write(1, info, strlen(info));
    12751271        assert(nWritten == (ssize_t)strlen(info));
    12761272    }
  • branches/blt4/packages/vizservers/nanovis/DataLoader.cpp

    r2120 r2409  
    44#include <stdlib.h>
    55#include <math.h>
     6#include <Trace.h>
    67
    78inline void endian_swap(unsigned int& x)
     
    3536        if (path.size() == 0)
    3637        {
    37                 printf("file not found[%s]\n", path.c_str());
    38                 return NULL;
     38            ERROR("file not found[%s]\n", path.c_str());
     39            return NULL;
    3940        }
    4041
     
    4243        if (fp == NULL)
    4344        {
    44                 printf("ERROR :file not found %s\n", path.c_str());
    45                 return NULL;
     45            ERROR("file not found %s\n", path.c_str());
     46            return NULL;
    4647        }
    4748
     
    173174        if (path.size() == 0)
    174175        {
    175                 printf("file not found[%s]\n", path.c_str());
    176                 return NULL;
     176            ERROR("file not found[%s]\n", path.c_str());
     177            return NULL;
    177178        }
    178179
     
    180181        if (fp == NULL)
    181182        {
    182                 printf("ERROR :file not found %s\n", path.c_str());
    183                 return NULL;
     183            ERROR("file not found %s\n", path.c_str());
     184            return NULL;
    184185        }
    185186
     
    243244                                if (length > max)
    244245                                {
    245                                         //printf("max %lf %lf %fl\n", x, y, z);
     246                                        //TRACE("max %lf %lf %fl\n", x, y, z);
    246247                                        max = length;
    247248                                }
     
    262263        fclose(fp);
    263264
    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",
    265266                width, height, depth, min, max, axisScaleX, axisScaleY, axisScaleZ);
    266267        return data;
     
    273274        if (fname == 0)
    274275        {
    275                 printf("file name is null\n");
    276                 return NULL;
     276            ERROR("file name is null\n");
     277            return NULL;
    277278        }
    278279
     
    280281        if (fp == NULL)
    281282        {
    282                 printf("ERROR :file not found %s\n", fname);
    283                 return NULL;
     283            ERROR("file not found %s\n", fname);
     284            return NULL;
    284285        }
    285286
     
    302303        if (fname == 0)
    303304        {
    304                 printf("file name is null\n");
    305                 return;
     305            ERROR("file name is null\n");
     306            return;
    306307        }
    307308
     
    309310        if (fp == NULL)
    310311        {
    311                 printf("ERROR :file not found %s\n", fname);
    312                 return;
     312            ERROR("file not found %s\n", fname);
     313            return;
    313314        }
    314315
     
    326327        if (path.size() == 0)
    327328        {
    328                 printf("file not found[%s]\n", path.c_str());
    329                 return NULL;
     329            ERROR("file not found[%s]\n", path.c_str());
     330            return NULL;
    330331        }
    331332
     
    333334        if (fp == NULL)
    334335        {
    335                 printf("ERROR :file not found %s\n", path.c_str());
    336                 return NULL;
     336            ERROR("file not found %s\n", path.c_str());
     337            return NULL;
    337338        }
    338339
     
    387388                                if (length > max)
    388389                                {
    389                                         printf("max %lf %lf %fl\n", x, y, z);
     390                                        TRACE("max %lf %lf %fl\n", x, y, z);
    390391                                        max = length;
    391392                                }
     
    406407        fclose(fp);
    407408
    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",
    409410                width, height, depth, min, max, axisScaleX, axisScaleY, axisScaleZ);
    410411        return data;
  • branches/blt4/packages/vizservers/nanovis/Event.cpp

    r2120 r2409  
    2828   
    2929void 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);
    3131}
    3232
  • branches/blt4/packages/vizservers/nanovis/EventPlayer.cpp

    r1982 r2409  
    7575    float ave = interval_sum / (cur_event-1);
    7676    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);
    7979    exit(0);
    8080  }
     
    121121
    122122  //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());
    124124  int status = write(socket_fd, msg.c_str(), strlen(msg.c_str()));
    125125  if (status <= 0) {
     
    131131  int sizes[2];
    132132  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]);
    134134  int len = sizes[0] + sizes[1];
    135135#else
     
    152152  }
    153153
    154   //printf("Read message to server.\n");
     154  //TRACE("Read message to server.\n");
    155155
    156156  //end timer
  • branches/blt4/packages/vizservers/nanovis/FlowCmd.cpp

    r2120 r2409  
    849849        length = sprintf(info, "nv>data tag %s min %g max %g\n",
    850850                flowPtr->name(), dataPtr->magMin(), dataPtr->magMax());
    851         nWritten  = write(0, info, length);
     851        nWritten  = write(1, info, length);
    852852        assert(nWritten == (ssize_t)strlen(info));
    853853    }
  • branches/blt4/packages/vizservers/nanovis/HeightMap.cpp

    r1982 r2409  
    563563    if (_vertexBufferObjectID)
    564564    {
    565         printf("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\n");
     565        TRACE("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\n");
    566566        glColor3f(1.0f, 1.0f, 1.0f);
    567567        glShadeModel(GL_SMOOTH);
  • branches/blt4/packages/vizservers/nanovis/Nv.cpp

    r1053 r2409  
    2121    if(lastError) {
    2222        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");
    2828        cgDestroyContext(g_context);
    29         fflush(stdout);
    3029        exit(-1);
    3130    }
     
    3433void NvInit(char* path)
    3534{
    36     printf("Nanovis GL Initialized\n");
     35    TRACE("Nanovis GL Initialized\n");
    3736}
    3837
  • branches/blt4/packages/vizservers/nanovis/NvEventLog.cpp

    r2120 r2409  
    2626        logName = (char*) calloc(logNameLen,sizeof(char));
    2727        strncpy(logName,"/tmp/nanovis_log.txt",logNameLen);
    28     }
    29     else {
     28    } else {
    3029        logNameLen = 17+1+strlen(user);
    3130        logName = (char*) calloc(logNameLen,sizeof(char));
    3231        strncpy(logName,"/tmp/nanovis_log_",logNameLen);
    33         strncat(logName,user,strlen(user));
     32        strncat(logName, user, strlen(user));
    3433    }
    3534
    3635    //open log and map stderr to log file
    3736    NanoVis::logfile = fopen(logName, "w");
    38     close(2);
    3937    dup2(fileno(NanoVis::logfile), 2);
    40     dup2(2,1);
    41     //flush junk
    42     fflush(stdout);
    43     fflush(stderr);
     38    /* dup2(2,1); */
    4439
    4540    // clean up malloc'd memory
     
    7772{
    7873    struct timeval time;
     74
    7975    gettimeofday(&time, NULL);
    8076    double new_time = time.tv_sec*1000. + time.tv_usec/1000.;
  • branches/blt4/packages/vizservers/nanovis/NvVectorField.cpp

    r1515 r2409  
    3838    _vectorFieldId = volPtr->id;
    3939    _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);
    4141    _physicalSize = volPtr->getPhysicalBBoxMax() - _physicalMin;
    42     printf("_pysicalSize %f %f %f\n",
     42    TRACE("_pysicalSize %f %f %f\n",
    4343           _physicalSize.x, _physicalSize.y, _physicalSize.z);
    4444}
  • branches/blt4/packages/vizservers/nanovis/NvZincBlendeReconstructor.cpp

    r1053 r2409  
    6060        {
    6161#ifdef _LOADER_DEBUG_
    62             printf("VERSION 1\n");
    63             fflush(stdout);
     62            TRACE("VERSION 1\n");
    6463#endif
    6564           version = 1;
     
    6968        {
    7069#ifdef _LOADER_DEBUG_
    71             printf("VERSION 2\n");
    72             fflush(stdout);
     70            TRACE("VERSION 2\n");
    7371#endif
    7472           version = 2;
     
    105103        catch (...)
    106104        {
    107             printf("ERROR\n");
     105            TRACE("ERROR\n");
    108106        }
    109107
     
    123121                sscanf(pt, "%s%f%f%f", str[0], &(delta.x), &(delta.y), &(delta.z));
    124122#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);
    127124#endif
    128125            }
     
    131128                sscanf(pt, "%s%d", str[0], &datacount);
    132129#ifdef _LOADER_DEBUG_
    133                 printf("datacount = %d\n", datacount);
    134                 fflush(stdout);
     130                TRACE("datacount = %d\n", datacount);
    135131#endif
    136132            }
     
    146142                sscanf(pt, "%s%d%d%d", str[0], &width, &height, &depth);
    147143#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);
    150145#endif
    151146            }
     
    154149                sscanf(pt, "%s%lf", str[0], &emptyvalue);
    155150#ifdef _LOADER_DEBUG_
    156                 printf("empryvalue %lf\n", emptyvalue);
    157                 fflush(stdout);
     151                TRACE("empryvalue %lf\n", emptyvalue);
    158152#endif
    159153            }
     
    162156                sscanf(pt, "%s%lf", str[0], &emptyvalue);
    163157#ifdef _LOADER_DEBUG_
    164                 printf("emptyvalue %lf\n", emptyvalue);
     158                TRACE("emptyvalue %lf\n", emptyvalue);
    165159#endif
    166160            }
     
    247241
    248242#ifdef _LOADER_DEBUG_
    249         printf("index %d\n", index);
    250         fflush(stdout);
     243        TRACE("index %d\n", index);
    251244#endif
    252245
     
    321314
    322315#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);
    325317#endif
    326318
    327319        if (index < 0) {
    328320#ifdef _LOADER_DEBUG_
    329             printf("There is an invalid data\n");
    330             fflush(stdout);
     321            TRACE("There is an invalid data\n");
    331322#endif
    332323            srcPtr +=8;
     
    398389
    399390#ifdef _LOADER_DEBUG_
    400     printf("%s", buff);
    401     fflush(stdout);
     391    TRACE("%s", buff);
    402392#endif
    403393}
     
    421411        else if (strstr((const char*) buff, "object") != 0)
    422412        {
    423             printf("VERSION 1\n");
    424             fflush(stdout);
     413            TRACE("VERSION 1\n");
    425414           version = 1;
    426415           break;
     
    428417        else if (strstr(buff, "record format") != 0)
    429418        {
    430             printf("VERSION 2\n");
    431             fflush(stdout);
     419            TRACE("VERSION 2\n");
    432420           version = 2;
    433421           break;
     
    463451        catch (...)
    464452        {
    465             printf("ERROR\n");
     453            TRACE("ERROR\n");
    466454        }
    467455
     
    481469                sscanf(pt, "%s%f%f%f", str[0], &(delta.x), &(delta.y), &(delta.z));
    482470#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);
    485472#endif
    486473            }
     
    488475            {
    489476                sscanf(pt, "%s%d", str[0], &datacount);
    490                 printf("datacount = %d\n", datacount);
    491                 fflush(stdout);
     477                TRACE("datacount = %d\n", datacount);
    492478            }
    493479            else if ((pt = strstr(buff, "datatype")) != 0)
     
    502488                sscanf(pt, "%s%d%d%d", str[0], &width, &height, &depth);
    503489#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);
    506491#endif
    507492            }
     
    510495                sscanf(pt, "%s%lf", str[0], &emptyvalue);
    511496#ifdef _LOADER_DEBUG_
    512                 printf("empryvalue %lf\n", emptyvalue);
    513                 fflush(stdout);
     497                TRACE("empryvalue %lf\n", emptyvalue);
    514498#endif
    515499            }
     
    518502                sscanf(pt, "%s%lf", str[0], &emptyvalue);
    519503#ifdef _LOADER_DEBUG_
    520                 printf("emptyvalue %lf\n", emptyvalue);
     504                TRACE("emptyvalue %lf\n", emptyvalue);
    521505#endif
    522506            }
     
    555539
    556540#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  
    128128    _clusterHeader->startPointerCluster[level - 1] = clusterBlock;
    129129
    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);
    132131       
    133132    int i = 0;
     
    142141    }
    143142    if (count != i) {
    144         printf("ERROR\n");
     143        TRACE("ERROR\n");
    145144    }
    146145    return clusterBlock;
     
    266265   
    267266    if (left == 0 || right == count - 1) {
    268         printf("error\n");
     267        TRACE("error\n");
    269268        exit(1);
    270269    } else {
  • branches/blt4/packages/vizservers/nanovis/ParticleSystem.cpp

    r2307 r2409  
    1 #include "ParticleSystem.h"
    2 #include "ParticleEmitter.h"
     1
    32#include <vr3d/vr3d.h>
    43#include <time.h>
     
    1817#endif
    1918#endif
    20 
     19#include "ParticleSystem.h"
     20#include "ParticleEmitter.h"
     21#include "Trace.h"
    2122#include <vrutil/vrFilePath.h>
    2223#include <pthread.h>
     
    9596                                printf("%f\n",ti - t);
    9697                                queue.push();
    97                                 printf("%d loaded\n", curIndex);
     98                                TRACE("%d loaded\n", curIndex);
    9899                                ++curIndex;
    99100                        }
     
    101102                else
    102103                {
    103                         //printf("full\n");
     104                        //TRACE("full\n");
    104105                }
    105106        }
     
    488489    if(lastError) {
    489490        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");
    495496
    496497        cgDestroyContext(_context);
     
    11241125                                        _vectorFields[0]->updatePixels(data);
    11251126                                        float ti = clock() / (float) CLOCKS_PER_SEC;
    1126                                         printf("pixels %f\n",ti - t);
     1127                                        TRACE("pixels %f\n",ti - t);
    11271128                                        _queue.pop();
    11281129                                        oldTime = time;
    11291130
    11301131                                        firstLoad = false;
    1131                                         printf("%d bound\n", index++);
     1132                                        TRACE("%d bound\n", index++);
    11321133                                }
    11331134                        }               
     
    13311332        for (iter = _newParticles.begin(); iter != _newParticles.end(); iter++)
    13321333        {
    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);
    13341335                glMultiTexCoord3f(GL_TEXTURE0, iter->position.x,iter->position.y,iter->position.z);
    13351336               
     
    13401341                glVertex2f(     (float)(iter->index % _width),
    13411342                        (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));
    13431344        }
    13441345        glEnd();
     
    13871388        for (iter = _newParticles.begin(); iter != _newParticles.end(); iter++)
    13881389        {
    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);
    13901391                glMultiTexCoord3f(GL_TEXTURE0, iter->position.x,iter->position.y,iter->position.z);
    13911392               
     
    13961397                glVertex2f(     (float)(iter->index % _width),
    13971398                        (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));
    13991400        }
    14001401        glEnd();
     
    14881489
    14891490        ///////////////////////////////
    1490         // DEBUG
     1491        // _DEBUG
    14911492        /*
    14921493        {
     
    14941495        static float debug[256];
    14951496        glReadPixels(0, 0, _width, _height, GL_RGB, GL_FLOAT, (float*)debug);
    1496         printf("[%d]", _currentSortIndex);
     1497        TRACE("[%d]", _currentSortIndex);
    14971498        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");
    15001501        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    15011502       
     
    15031504        */
    15041505        ///////////////////////////////
    1505         // DEBUG
     1506        // _DEBUG
    15061507        /*
    15071508        {
     
    15091510                static float debug[256];
    15101511                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);
    15131514                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");
    15161517                glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    15171518        }
     
    15441545
    15451546        ///////////////////////////////
    1546         // DEBUG
     1547        // _DEBUG
    15471548        /*
    15481549        {
     
    15501551                static float debug[256];
    15511552                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);
    15541555                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");
    15571558                glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    15581559        }
     
    16081609
    16091610        ///////////////////////////////
    1610         // DEBUG
     1611        // _DEBUG
    16111612        /*
    16121613        {
     
    16141615                static float debug[256];
    16151616                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);
    16181619                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");
    16211622                glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    16221623        }
     
    18091810
    18101811                        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);
    18121813                        //cgSetParameter1f(_mvTanHalfFOVParam, -tan(_fov * PI / 180 * 0.5) * _screenHeight * 0.5);
    18131814                        //float v = tan(_fov * PI / 180 * 0.5) * _screenHeight * 0.5;
  • branches/blt4/packages/vizservers/nanovis/ParticleSystemFactory.cpp

    r1816 r2409  
    33#include <vrutil/vrFilePath.h>
    44#include <stdio.h>
     5#include "Trace.h"
    56
    67#ifdef _WIN32
     
    7576                if (!stat)
    7677                {
    77                         //printf("Parse error at line %d\n", XML_GetCurrentLineNumber(parser));
     78                        //TRACE("Parse error at line %d\n", XML_GetCurrentLineNumber(parser));
    7879                        break;
    7980                }
     
    198199                                index = path.rfind('\\');
    199200                                if (index == -1)
    200                                         printf("file not found\n");
     201                                        TRACE("file not found\n");
    201202                        }
    202203
  • branches/blt4/packages/vizservers/nanovis/RpAVTranslate.cpp

    r2120 r2409  
    104104    if (_fmtPtr == NULL) {
    105105        /*
    106         printf(  "Could not deduce output format from"
     106          TRACE(  "Could not deduce output format from"
    107107                 "file extension: using MPEG.\n");
    108108        */
  • branches/blt4/packages/vizservers/nanovis/RpDX.cpp

    r1982 r2409  
    5353    }
    5454    // open the file with libdx
    55     fprintf(stdout, "Calling DXImportDX(%s)\n", filename);
    56     fflush(stdout);
     55    TRACE("Calling DXImportDX(%s)\n", filename);
    5756    DXenable_locks(0);
    5857    _dxobj = DXImportDX((char*)filename,NULL,NULL,NULL,NULL);
     
    7473    DXGetArrayInfo(dxpos, &_n, &type, &category, &_rank, &_shape);
    7574
    76     fprintf(stdout, "_n = %d\n",_n);
     75    TRACE("_n = %d\n",_n);
    7776    if (type != TYPE_FLOAT) {
    7877        result.addError("\"positions\" is not type float (type=%d)\n", type);
    7978        return;
    8079    }
    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);
    8382
    8483    float* pos = NULL;
     
    140139    DXQueryGridPositions(dxpos, NULL, _axisLen, _origin, _delta);
    141140
    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]);
    149147
    150148    // grab the data array from the dx object and store it in _data
     
    180178    // print debug info
    181179    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",
    184181            _positions[pt],_positions[pt+1],_positions[pt+2], _data[lcv],
    185182            _positions[pt+3],_positions[pt+4],_positions[pt+5],_data[lcv+1],
    186183            _positions[pt+6],_positions[pt+7],_positions[pt+8],_data[lcv+2]);
    187         fflush(stdout);
    188184    }
    189185    __collectDataStats();
     
    262258    pos = (float*) DXGetArrayData(dxpos);
    263259    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");
    266261    }
    267262
     
    272267    if (_positions == NULL) {
    273268        // malloc failed, raise error
    274         fprintf(stdout, "malloc of _axisLen array failed");
    275         fflush(stdout);
     269        TRACE("malloc of _axisLen array failed");
    276270    }
    277271    memcpy(_positions,pos,sizeof(float)*_n*_numAxis);
     
    298292    if (_data == NULL) {
    299293        // malloc failed, raise error
    300         fprintf(stdout, "malloc of _data array failed");
    301         fflush(stdout);
     294        TRACE("malloc of _data array failed");
    302295    }
    303296    memset(_data,0,_n);
    304297
    305298    // build the interpolator and interpolate
    306     fprintf(stdout, "creating DXNewInterpolator...\n");
    307     fflush(stdout);
     299    TRACE("creating DXNewInterpolator...\n");
    308300    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);
    314305    DXInterpolate(interpolator,&interppts,_positions,_data);
    315     fprintf(stdout,"interppts = %i\n",interppts);
    316     fflush(stdout);
     306    TRACE("interppts = %i\n",interppts);
    317307
    318308    // print debug info
    319309    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",
    322311            _positions[pt],_positions[pt+1],_positions[pt+2], _data[lcv],
    323312            _positions[pt+3],_positions[pt+4],_positions[pt+5],_data[lcv+1],
    324313            _positions[pt+6],_positions[pt+7],_positions[pt+8],_data[lcv+2]);
    325         fflush(stdout);
    326314    }
    327315
     
    340328DX::interpolate(int* newAxisLen)
    341329{
    342     fprintf(stdout, "----begin interpolation----\n");
    343     fflush(stdout);
     330    TRACE("----begin interpolation----\n");
    344331    if (newAxisLen != NULL) {
    345332        for (int i = 0; i < _numAxis; i++) {
     
    349336    __getInterpPos();
    350337    __getInterpData();
    351     fprintf(stdout, "----end interpolation----\n");
    352     fflush(stdout);
     338    TRACE("----end interpolation----\n");
    353339    return *this;
    354340}
  • branches/blt4/packages/vizservers/nanovis/Texture1D.cpp

    r1982 r2409  
    9292    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max);
    9393       
    94     //printf("%d", glGetError());
     94    //TRACE("%d", glGetError());
    9595    TRACE("max texture size: %d\n", max);
    9696}
  • branches/blt4/packages/vizservers/nanovis/Texture3D.cpp

    r1982 r2409  
    207207    glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT, &max);
    208208       
    209     //printf("%d", glGetError());
     209    //TRACE("%d", glGetError());
    210210    TRACE("max 3d texture size: %d\n", max);
    211211}
  • branches/blt4/packages/vizservers/nanovis/Trace.cpp

    r1990 r2409  
    88#include <GL/glut.h>
    99#include <syslog.h>
     10
     11static 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};
    1021
    1122void
     
    2536        s++;
    2637    }
    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);
    2840    length += vsnprintf(message + length, MSG_LEN - length, fmt, lst);
    2941    message[MSG_LEN] = '\0';
  • branches/blt4/packages/vizservers/nanovis/Unirect.cpp

    r1982 r2409  
    666666    dmin = pow((dx*dy*dz)/(nSamples*nSamples*nSamples), 0.333);
    667667   
    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);
    669669
    670670    /* Recompute new number of points for each axis. */
  • branches/blt4/packages/vizservers/nanovis/VelocityArrowsSlice.cpp

    r2120 r2409  
    9797#else
    9898    /*
    99         printf("test1\n");
     99      TRACE("test1\n");
    100100        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");
    103103        IplImage* pTextureImage = cvLoadImage(path);
    104         printf("test3\n");
     104        TRACE("test3\n");
    105105        if (pTextureImage)
    106106        {
    107             printf("file(%s) has been loaded\n", path);
     107            TRACE("file(%s) has been loaded\n", path);
    108108            _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);
    110110            //cvReleaseImage(&pTextureImage);
    111111        }
    112112        else
    113113        {
    114             printf("not found\n");
     114            TRACE("not found\n");
    115115        }
    116116        if (path) delete [] path;
  • branches/blt4/packages/vizservers/nanovis/VolumeInterpolator.cpp

    r1982 r2409  
    127127            _volumes[0]->depth != refPtr->depth ||
    128128            _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");
    130130            return;
    131131        }
  • branches/blt4/packages/vizservers/nanovis/VolumeRenderer.cpp

    r1982 r2409  
    241241        ConvexPolygon static_poly;
    242242        for(int j = 0; j < volPtr->get_cutplane_count(); j++) {
    243             if(!volPtr->cutplane_is_enabled(j))
     243            if(!volPtr->cutplane_is_enabled(j)) {
    244244                continue;
    245            
     245            }
    246246            float offset = volPtr->get_cutplane(j)->offset;
    247247            int axis = volPtr->get_cutplane(j)->orient;
     
    646646        goto error;
    647647    }
    648     //printf("Data at Offset: %ld\n", bfOffBits);
     648    //TRACE("Data at Offset: %ld\n", bfOffBits);
    649649   
    650650    /* skip size of bitmap info header */
     
    656656        goto error;
    657657    }
    658     //printf("Width of Bitmap: %d\n", texture->width);
     658    //TRACE("Width of Bitmap: %d\n", texture->width);
    659659   
    660660    /* get the height of the bitmap */
     
    663663        goto error;
    664664    }
    665     //printf("Height of Bitmap: %d\n", texture->height);
     665    //TRACE("Height of Bitmap: %d\n", texture->height);
    666666   
    667667    /* get the number of planes (must be set to 1) */
     
    681681    }
    682682   
    683     //printf("Bits per Pixel: %d\n", biBitCount);
     683    //TRACE("Bits per Pixel: %d\n", biBitCount);
    684684    if (biBitCount != 24) {
    685685        ERROR("Bits per Pixel not 24\n");
  • branches/blt4/packages/vizservers/nanovis/dxReader.cpp

    r1982 r2409  
    5151                    std::iostream& fin)
    5252{
    53     printf("load_volume_stream2 %s\n", tag);
     53    TRACE("load_volume_stream2 %s\n", tag);
    5454    Rappture::MeshTri2D xymesh;
    5555    int dummy, nx, ny, nz, nxy, npts;
     
    408408    if (volPtr) {
    409409        volPtr->location(Vector3(dx0, dy0, dz0));
    410         printf("volume moved\n");
     410        TRACE("volume moved\n");
    411411    }
    412412    return volPtr;
     
    417417                   std::iostream& fin)
    418418{
    419     printf("load_volume_stream\n");
     419    TRACE("load_volume_stream\n");
    420420
    421421    Rappture::MeshTri2D xymesh;
     
    845845                         std::iostream& fin)
    846846{
    847     printf("load_volume_stream\n");
     847    TRACE("load_volume_stream\n");
    848848 
    849849    Rappture::MeshTri2D xymesh;
  • branches/blt4/packages/vizservers/nanovis/dxReader2.cpp

    r1982 r2409  
    8989    computeSimpleGradient(data, nx, ny, nz);
    9090
    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());
    9594
    9695    Volume *volPtr;
  • branches/blt4/packages/vizservers/nanovis/nanovis.cpp

    r1990 r2409  
    241241    ssize_t nWritten;
    242242
    243     nWritten = write(0, str, strlen(str));
     243    nWritten = write(2, str, strlen(str));
    244244}
    245245
     
    428428    }
    429429    TRACE("cg program compiling: %s\n", path);
    430     fflush(stdout);
    431430    CGprogram program;
    432431    program = cgCreateProgramFromFile(context, CG_SOURCE, path, profile,
     
    591590        sprintf(prefix, "nv>legend %s %g %g", volArg, min, max);
    592591        ppm_write(prefix);
    593         nWritten = write(0, "\n", 1);
     592        nWritten = write(1, "\n", 1);
    594593        assert(nWritten == 1);
    595594    }
     
    756755    if(lastError) {
    757756        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");
    763762        cgDestroyContext(g_context);
    764         fflush(stdout);
    765763        DoExit(-1);
    766764    }
     
    770768{
    771769    // 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),
    774772           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");
    777775    if (path == NULL) {
    778776        ERROR("No path defined for shaders or resources\n");
     
    785783        //assert(false);
    786784    }
    787     INFO("Using GLEW %s\n", glewGetString(GLEW_VERSION));
     785    TRACE("Using GLEW %s\n", glewGetString(GLEW_VERSION));
    788786
    789787    if (!R2FilePath::getInstance()->setPath(path)) {
     
    10611059    char string[200];
    10621060    sprintf(string, "%s %d\n", prefix, fsize);
    1063     nWritten = write(0, string, strlen(string));
     1061    nWritten = write(1, string, strlen(string));
    10641062    assert(nWritten == (ssize_t)strlen(string));
    10651063    header[pos++] = 'B';
     
    11141112    }
    11151113
    1116     nWritten = write(0, header, SIZEOF_BMP_HEADER);
     1114    nWritten = write(1, header, SIZEOF_BMP_HEADER);
    11171115    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);
    11191117    assert(nWritten == (3*win_width+pad)*win_height);
    11201118    stats.nFrames++;
     
    11801178        srcRowPtr += bytesPerRow;
    11811179    }
    1182     if (writev(0, iov, nRecs) < 0) {
     1180    if (writev(1, iov, nRecs) < 0) {
    11831181        ERROR("write failed: %s\n", strerror(errno));
    11841182    }
     
    12221220    iov[1].iov_base = (char *)data;
    12231221    iov[1].iov_len = dlen;
    1224     if (writev(0, iov, nRecs) < 0) {
     1222    if (writev(1, iov, nRecs) < 0) {
    12251223        ERROR("write failed: %s\n", strerror(errno));
    12261224    }
     
    18631861    case 'a' :
    18641862        {
    1865             printf("flowvis active\n");
     1863            TRACE("flowvis active\n");
    18661864            char cmd[] = {
    18671865                "foreach flow [flow names] {\n"
     
    18781876    case 'd' :
    18791877        {
    1880             printf("flowvis deactived\n");
     1878            TRACE("flowvis deactived\n");
    18811879            char cmd[] = {
    18821880                "foreach flow [flow names] {\n"
     
    18921890    case '1' :
    18931891        {
    1894             printf("add vector field\n");
     1892            TRACE("add vector field\n");
    18951893            char cmd[] = {
    18961894                "flow create flow1\n"
     
    19151913            };
    19161914            Tcl_Eval(interp, cmd);
    1917             printf("add vector field\n");
     1915            TRACE("add vector field\n");
    19181916            addVectorField("/home/iwoo/projects/nanovis/rappture/packages/vizservers/nanovis/data/flowvis_dx_files/3DWireLeakage/SiO2/SiO2.dx",
    19191917                           "vf_name1", "plane_name1", "plane_name2", Vector4(1, 0, 0, 1), Vector4(1, 1, 0, 1));
     
    19221920    case '3':
    19231921        {
    1924             printf("activate\n");
     1922            TRACE("activate\n");
    19251923            char cmd[] = {
    19261924                "flow1 particles add plane2 -hide no\n"
     
    19341932    case '4' :
    19351933        {
    1936             printf("deactivate\n");
     1934            TRACE("deactivate\n");
    19371935            char cmd[] = {
    19381936                "flow1 particles add plane2 -hide yes\n"
     
    19461944    case '5' :
    19471945        {
    1948             printf("vector field deleted (vf_name2)\n");
     1946            TRACE("vector field deleted (vf_name2)\n");
    19491947            char cmd[] = {
    19501948                "flow delete flow2\n"
     
    19581956    case '6' :
    19591957        {
    1960             printf("add device shape\n");
     1958            TRACE("add device shape\n");
    19611959            char cmd[] = {
    19621960                "flow1 box add box1 -corner1 {0 0 0} -corner2 {30 3 3} -color { 1 0 0 1 }\n"
     
    19851983    case '7' :
    19861984        {
    1987             printf("hide shape \n");
     1985            TRACE("hide shape \n");
    19881986            char cmd[] = {
    19891987                "flow1 box configure box1 -hide yes\n"
     
    19971995    case '8' :
    19981996        {
    1999             printf("show shape\n");
     1997            TRACE("show shape\n");
    20001998            char cmd[] = {
    20011999                "flow1 box configure box1 -hide no\n"
     
    20092007    case '9' :
    20102008        {
    2011             printf("show a shape \n");
     2009            TRACE("show a shape \n");
    20122010            char cmd[] = {
    20132011                "flow1 box configure box3 -hide no\n"
     
    20212019    case '0' :
    20222020        {
    2023             printf("delete a shape \n");
     2021            TRACE("delete a shape \n");
    20242022            char cmd[] = {
    20252023                "flow1 box delete box3\n"
     
    20332031    case 'r' :
    20342032        {
    2035             printf("reset \n");
     2033            TRACE("reset \n");
    20362034            char cmd[] = {
    20372035                "flow reset\n"
     
    21292127
    21302128    TRACE("Enter xinetd_listen\n");
     2129
    21312130    int flags = fcntl(0, F_GETFL, 0);
    21322131    fcntl(0, F_SETFL, flags & ~O_NONBLOCK);
     
    21602159            ch = (char)c;
    21612160            Tcl_DStringAppend(&cmdbuffer, &ch, 1);
     2161            TRACE("in xinetd_listen: checking buffer=%s\n",
     2162                  Tcl_DStringValue(&cmdbuffer));
    21622163            if (ch == '\n') {
    21632164                isComplete = Tcl_CommandComplete(Tcl_DStringValue(&cmdbuffer));
     
    21792180            isComplete = false;
    21802181            nCommands++;
    2181     CHECK_FRAMEBUFFER_STATUS();
     2182            CHECK_FRAMEBUFFER_STATUS();
    21822183        }
    21832184    }
     
    21982199        iov[2].iov_len = 1;
    21992200        iov[2].iov_base = (char *)'\n';
    2200         if (writev(0, iov, 3) < 0) {
     2201        if (writev(1, iov, 3) < 0) {
    22012202            ERROR("write failed: %s\n", strerror(errno));
    22022203        }
    22032204        TRACE("Leaving xinetd_listen on ERROR\n");
    22042205        return;
     2206    }
     2207    if (feof(NanoVis::stdin)) {
     2208        DoExit(90);
    22052209    }
    22062210
     
    22212225#endif
    22222226
     2227    if (feof(NanoVis::stdin)) {
     2228        DoExit(90);
     2229    }
    22232230#if DO_RLE
    22242231    do_rle();
    22252232    int sizes[2] = {  offsets_size*sizeof(offsets[0]), rle_size };
    22262233    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 byte
     2234    write(1, &sizes, sizeof(sizes));
     2235    write(1, offsets, offsets_size*sizeof(offsets[0]));
     2236    write(1, rle, rle_size);    //unsigned byte
    22302237#else
    22312238    NanoVis::ppm_write("\nnv>image -type image -bytes");
    22322239#endif
    2233     if (feof(NanoVis::stdin)) {
    2234         DoExit(90);
    2235     }
    22362240    TRACE("Leaving xinetd_listen OK\n");
    22372241}
     
    22402244/*----------------------------------------------------*/
    22412245int
    2242 main(int argc, char** argv)
     2246main(int argc, char **argv)
    22432247{
    22442248    const char *path;
    22452249    char *newPath;
    22462250    struct timeval tv;
    2247 
     2251        int n, i;
    22482252    newPath = NULL;
    22492253    path = NULL;
    22502254    NanoVis::stdin = stdin;
    22512255
    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); */
    22532260    gettimeofday(&tv, NULL);
    22542261    stats.start = tv;
     
    23702377#endif
    23712378    }
     2379
    23722380    R2FilePath::getInstance()->setWorkingDirectory(argc, (const char**) argv);
    23732381    vrFilePath::getInstance()->setWorkingDirectory(argc, (const char**) argv);
    23742382
    23752383#ifdef XINETD
    2376     signal(SIGPIPE,SIG_IGN);
     2384#ifdef notdef
     2385    signal(SIGPIPE, SIG_IGN);
     2386#endif
    23772387    NvInitService();
    23782388#endif
     
    24332443    //sprintf(prefix, "nv>height_top_view %s %g %g", volArg, min, max);
    24342444    //ppm_write(prefix);
    2435     //write(0, "\n", 1);
     2445    //write(1, "\n", 1);
    24362446    //plane_render->remove_plane(index);
    24372447
  • branches/blt4/packages/vizservers/nanovis/nanovis.h

    r1823 r2409  
    6868#include "config.h"
    6969
     70#define NANOVIS_VERSION         "1.0"
    7071
    7172//defines for the image based flow visualization
  • branches/blt4/packages/vizservers/pymolproxy/pymolproxy.c

    r2003 r2409  
    6767#include <sys/wait.h>
    6868#include <time.h>
     69#include <syslog.h>
    6970#include <unistd.h>
    7071#include <tcl.h>
     
    9596static Stats stats;
    9697
     98#define READTRACE       0
     99#define EXPECTTRACE     0
     100#define WRITETRACE      0
     101
     102static int debug = FALSE;
     103
    97104static FILE *flog;
    98 static int debug = FALSE;
    99105static FILE *scriptFile;
    100106static int savescript = FALSE;
     
    168174} PymolProxy;
    169175
     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
     181static 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
     192void
     193LogMessage(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}
    170218
    171219static void PollForEvents(PymolProxy *proxyPtr);
    172220static void
    173 trace TCL_VARARGS_DEF(const char *, arg1)
     221Debug TCL_VARARGS_DEF(const char *, arg1)
    174222{
    175223    if (debug) {
     
    219267    ssize_t nRead;
    220268
    221 #ifdef notdef
    222     trace("Entering FillBuffer (mark=%d, fill=%d)\n", readPtr->mark,
     269#if READTRACE
     270    Debug("Entering FillBuffer (mark=%d, fill=%d)\n", readPtr->mark,
    223271          readPtr->fill);
    224272#endif
     
    242290    if (nRead <= 0) {
    243291        if (errno != EAGAIN) {
    244 #ifdef notdef
    245             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",
    247295                  nRead, readPtr->mark, readPtr->fill);
    248296#endif
     
    252300    }
    253301    readPtr->fill += nRead;
    254 #ifdef notdef
    255     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",
    256304          nRead, readPtr->mark, readPtr->fill);
    257305#endif
     
    265313    int status;
    266314
    267 #ifdef notdef
    268     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);
    269317#endif
    270318    status = BUFFER_OK;
    271319    for (;;) {
    272320        /* Look for the next newline (the next full line). */
    273 #ifdef notdef
    274         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);
    275323#endif
    276324        for (i = readPtr->mark; i < readPtr->fill; i++) {
     
    283331                *nBytesPtr = i - readPtr->mark;
    284332                readPtr->mark = i;
    285 #ifdef notdef
    286                 trace("Leaving GetLine(%.*s)\n", *nBytesPtr, p);
     333#if READTRACE
     334                Debug("Leaving GetLine(%.*s)\n", *nBytesPtr, p);
    287335#endif
    288336                return p;
     
    300348        }
    301349    }
    302 #ifdef notdef
    303     trace("Leaving GetLine failed to read line\n");
     350#if READTRACE
     351    Debug("Leaving GetLine failed to read line\n");
    304352#endif
    305353    *nBytesPtr = BUFFER_CONTINUE;
     
    310358GetBytes(ReadBuffer *readPtr, char *out, int nBytes)
    311359{
    312 #ifdef notdef
    313     trace("Entering GetBytes(%d)\n", nBytes);
     360#if READTRACE
     361    Debug("Entering GetBytes(%d)\n", nBytes);
    314362#endif
    315363    while (nBytes > 0) {
     
    329377        if (nBytes == 0) {
    330378            /* Received requested # bytes. */
    331 #ifdef notdef
    332             trace("Leaving GetBytes(%d)\n", nBytes);
     379#if READTRACE
     380            Debug("Leaving GetBytes(%d)\n", nBytes);
    333381#endif
    334382            return BUFFER_OK;
     
    339387            return BUFFER_ERROR;
    340388        }
    341 #ifdef notdef
    342         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);
    343391#endif
    344392    }
    345 #ifdef notdef
    346     trace("Leaving GetBytes(%d)\n", nBytes);
     393#if READTRACE
     394    Debug("Leaving GetBytes(%d)\n", nBytes);
    347395#endif
    348396    return BUFFER_OK;
     
    376424    sprintf(cmd, "/bin/rm -rf /tmp/pymol%d", getpid());
    377425    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));
    379427    }
    380428}
     
    389437        return proxyPtr->status;
    390438    }
    391 #ifndef notdef
    392     trace("Entering Expect(want=\"%s\", maxSize=%d)\n", match, maxSize);
     439#if EXPECTTRACE
     440    Debug("Entering Expect(want=\"%s\", maxSize=%d)\n", match, maxSize);
    393441#endif
    394442    c = match[0];
     
    400448        line = GetLine(&proxyPtr->server, &nBytes);
    401449        if (line != NULL) {
    402 #ifndef notdef
    403             trace("pymol says (read %d bytes):%.*s", nBytes, nBytes, line);
     450#if EXPECTTRACE
     451            Debug("pymol says (read %d bytes):%.*s", nBytes, nBytes, line);
    404452#endif
    405453            if ((c == line[0]) && (strncmp(line, match, length) == 0)) {
     
    409457                memcpy(out, line, nBytes);
    410458                clear_error(proxyPtr);
    411 #ifndef notdef
    412                 trace("Leaving Expect: got (%.*s)\n", nBytes, out);
     459#if EXPECTTRACE
     460                Debug("Leaving Expect: got (%.*s)\n", nBytes, out);
    413461#endif
    414462                return BUFFER_OK;
     
    420468        }
    421469    }
    422     trace("Leaving Expect: failed to find (%s)\n", match);
     470    ERROR("Leaving Expect: failed to find (%s)\n", match);
    423471    proxyPtr->error = 2;
    424472    proxyPtr->status = TCL_ERROR;
     
    556604    start = CVT2SECS(tv);
    557605
    558     trace("command from client is (%s)", cmd);
     606    Debug("command from client is (%s)", cmd);
    559607    result = Tcl_Eval(interp, cmd);
    560608
     
    574622    imgPtr = malloc(sizeof(Image) + dataLength);
    575623    if (imgPtr == NULL) {
    576         fprintf(stderr, "can't allocate image of %lu bytes",
    577                 (unsigned long)(sizeof(Image) + dataLength));
     624        ERROR("can't allocate image of %lu bytes",
     625              (unsigned long)(sizeof(Image) + dataLength));
    578626        abort();
    579627    }
     
    605653
    606654    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");
    608656        return;
    609657    }
     
    613661        assert(imgPtr->nextPtr == NULL);
    614662        prevPtr = imgPtr->prevPtr;
    615 #ifdef notdef
    616         trace("WriteImage: want to write %d bytes.", imgPtr->bytesLeft);
     663#if WRITETRACE
     664        Debug("WriteImage: want to write %d bytes.", imgPtr->bytesLeft);
    617665#endif
    618666        for (bytesLeft = imgPtr->bytesLeft; bytesLeft > 0; /*empty*/) {
    619667            ssize_t nWritten;
    620 #ifdef notdef
    621             trace("WriteImage: try to write %d bytes.", bytesLeft);
     668#if WRITETRACE
     669            Debug("WriteImage: try to write %d bytes.", bytesLeft);
    622670#endif
    623671            nWritten = write(fd, imgPtr->data + imgPtr->nWritten, bytesLeft);
    624 #ifdef notdef
    625             trace("WriteImage: wrote %d bytes.", nWritten);
     672#if WRITETRACE
     673            Debug("WriteImage: wrote %d bytes.", nWritten);
    626674#endif
    627675            if (nWritten < 0) {
    628                 trace("Error writing fd(%d), %d/%s.", fd, errno,
     676                ERROR("Error writing fd(%d), %d/%s.", fd, errno,
    629677                      strerror(errno));
    630678                return;
     
    668716    va_end(ap);
    669717   
    670     trace("to-pymol>(%s) code=%d", buffer, result);
     718    Debug("to-pymol>(%s) code=%d", buffer, result);
    671719    script("%s\n", buffer);
    672720   
     
    676724    nWritten = write(proxyPtr->sin, buffer, length);
    677725    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)",
    679727              nWritten, length);
    680728    }
     
    689737    result = Expect(proxyPtr, expect, buffer, BUFSIZ);
    690738    if (result == BUFFER_ERROR) {
    691         trace("timeout reading data (buffer=%s)", buffer);
     739        ERROR("timeout reading data (buffer=%s)", buffer);
    692740        proxyPtr->error = 1;
    693741        proxyPtr->status = TCL_ERROR;
     
    801849    Pymol(proxyPtr, "bmp -\n");
    802850    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);
    804852    }
    805853    if (sscanf(buffer, "bmp image follows: %d\n", &nBytes) != 1) {
     
    815863    strcpy(imgPtr->data, buffer);
    816864    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);
    818866        return  TCL_ERROR;
    819867    }
     
    12951343    strcpy(imgPtr->data, buffer);
    12961344    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);
    12981346        return  TCL_ERROR;
    12991347    }
     
    13541402    sprintf(buffer, "nv>image %d print \"%s\" %d\n", nBytes, token,
    13551403            proxyPtr->rockOffset);
    1356     trace("header is png is (%s)\n", buffer);
     1404    Debug("header is png is (%s)\n", buffer);
    13571405    length = strlen(buffer);
    13581406    imgPtr = NewImage(proxyPtr, nBytes + length);
    13591407    strcpy(imgPtr->data, buffer);
    13601408    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);
    13621410        return  TCL_ERROR;
    13631411    }
     
    19241972    child = fork();
    19251973    if (child < 0) {
    1926         fprintf(stderr, "can't fork process: %s\n", strerror(errno));
     1974        ERROR("can't fork process: %s\n", strerror(errno));
    19271975        return -3;
    19281976    }
     
    19511999       
    19522000        execvp(argv[0], argv);
    1953         trace("Failed to start pymol `%s'", argv[0]);
     2001        ERROR("Failed to start pymol `%s'", argv[0]);
    19542002        exit(-1);
    19552003    }
    19562004    stats.child = child;
     2005
     2006    Debug("Started %s DISPLAY=%s\n", argv[0], getenv("DISPLAY"));
    19572007
    19582008    /* close opposite end of pipe, these now belong to the child process  */
     
    19612011    close(serr[1]);
    19622012
     2013#ifdef notdef
    19632014    signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE (e.g. nanoscale terminates)*/
     2015#endif
    19642016
    19652017    memset(&proxy, 0, sizeof(PymolProxy));
     
    19732025    interp = Tcl_CreateInterp();
    19742026    if (CreateTmpDir(interp) != TCL_OK) {
    1975         trace(Tcl_GetStringResult(interp));
     2027        ERROR(Tcl_GetStringResult(interp));
    19762028    }
    19772029    Tcl_MakeSafe(interp);
     
    20072059    stats.start = end;
    20082060
     2061    if (write(cout, "PyMol 1.0\n", 10) != 10) {
     2062        ERROR("short write of signature");
     2063    }
     2064   
    20092065    // Main Proxy Loop
    20102066    //  accept tcl commands from socket
     
    20212077    status = waitpid(child, &result, WNOHANG);
    20222078    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));
    20242080    } else if (status == 0) {
    2025         trace("attempting to signal (SIGTERM) pymol server.");
     2081        ERROR("attempting to signal (SIGTERM) pymol server.");
    20262082        kill(-child, SIGTERM);          // Kill process group
    20272083        alarm(5);
     
    20302086       
    20312087        while ((status == -1) && (errno == EINTR)) {
    2032             trace("Attempting to signal (SIGKILL) pymol server.");
     2088            ERROR("Attempting to signal (SIGKILL) pymol server.");
    20332089            kill(-child, SIGKILL);      // Kill process group
    20342090            alarm(10);
     
    20382094    }
    20392095   
    2040     trace("pymol server process ended (result=%d)", result);
     2096    ERROR("pymol server process ended (result=%d)", result);
    20412097    DestroyTmpDir();
    20422098
     
    20502106}
    20512107
    2052 #ifdef STANDALONE
     2108
     2109static void
     2110PollForEvents(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}
    20532254
    20542255int
     
    20722273}
    20732274
    2074 #endif
    2075 
    2076 
    2077 static void
    2078 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 in
    2115          * the pymol server process' stdout or stderr.  We don't want the
    2116          * 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 if
    2190          * the client's busy (e.g. sending us another command), there's a
    2191          * chance we'll deadlock.  Therefore, the file descriptor is
    2192          * non-blocking and we write only what we can.  Must be careful not to
    2193          * 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 currently
    2202              * transmitting an image back to the client. The image will be
    2203              * 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  
    248248 * \brief Perform linear interpolation of two color control points
    249249 */
    250 void ColorMap::lerp(double *result, const ControlPoint& cp1, const ControlPoint& cp2, double value)
     250void ColorMap::lerp(double *result,
     251                    const ControlPoint& cp1,
     252                    const ControlPoint& cp2,
     253                    double value)
    251254{
    252255    double factor = (value - cp1.value) / (cp2.value - cp1.value);
     
    259262 * \brief Perform linear interpolation of two opacity control points
    260263 */
    261 void ColorMap::lerp(double *result, const OpacityControlPoint& cp1, const OpacityControlPoint& cp2, double value)
     264void ColorMap::lerp(double *result,
     265                    const OpacityControlPoint& cp1,
     266                    const OpacityControlPoint& cp2,
     267                    double value)
    262268{
    263269    double factor = (value - cp1.value) / (cp2.value - cp1.value);
  • branches/blt4/packages/vizservers/vtkvis/Makefile.in

    r2322 r2409  
    2323MKDIR_P         = @MKDIR_P@
    2424
    25 GL_LIB_SPEC     = -lGL
     25GL_LIB_SPEC     = -lGL -lm
    2626
    2727TCL_LIB_SPEC    = @TCL_LIB_SPEC@
     
    3232VTK_INC_SPEC    = @VTK_INC_SPEC@
    3333
    34 LD_RUN_PATH     = $(VTK_LIB_DIR)
     34LD_RUN_PATH     = $(VTK_LIB_DIR):$(libdir)
    3535
    3636LIBS            = \
     
    5151USE_OFFSCREEN_RENDERING = yes
    5252
    53 EXTRA_CFLAGS    = -Wall -Wno-deprecated #vtk uses deprecated strstream header (instead of sstream)
     53#vtk uses deprecated strstream header (instead of sstream)
     54EXTRA_CFLAGS    = -Wall -Wno-deprecated
    5455DEFINES         =
    5556ifdef DEBUG
     
    129130ColorMap.o: ColorMap.h RpMolecule.h Trace.h
    130131PPMWriter.o: PPMWriter.h Trace.h
    131 RpContour2D.o: RpContour2D.h RpVtkDataSet.h Trace.h
    132 RpContour3D.o: RpContour3D.h RpVtkDataSet.h Trace.h
    133 RpGlyphs.o: RpGlyphs.h RpVtkDataSet.h ColorMap.h Trace.h
    134 RpHeightMap.o: RpHeightMap.h RpVtkDataSet.h Trace.h
    135 RpLIC.o: RpLIC.h RpVtkDataSet.h Trace.h RpVtkRenderServer.h
    136 RpMolecule.o: RpMolecule.h RpMoleculeData.h RpVtkDataSet.h ColorMap.h Trace.h
    137 RpPolyData.o: RpPolyData.h RpVtkDataSet.h Trace.h
    138 RpPseudoColor.o: RpPseudoColor.h RpVtkDataSet.h Trace.h
    139 RpStreamlines.o: RpStreamlines.h RpVtkDataSet.h Trace.h
    140 RpVolume.o: RpVolume.h RpVtkDataSet.h ColorMap.h Trace.h
     132RpContour2D.o: RpContour2D.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h
     133RpContour3D.o: RpContour3D.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h
     134RpGlyphs.o: RpGlyphs.h RpVtkGraphicsObject.h RpVtkDataSet.h ColorMap.h Trace.h
     135RpHeightMap.o: RpHeightMap.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h
     136RpLIC.o: RpLIC.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h RpVtkRenderServer.h
     137RpMolecule.o: RpMolecule.h RpMoleculeData.h RpVtkGraphicsObject.h RpVtkDataSet.h ColorMap.h Trace.h
     138RpPolyData.o: RpPolyData.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h
     139RpPseudoColor.o: RpPseudoColor.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h
     140RpStreamlines.o: RpStreamlines.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h
     141RpVolume.o: RpVolume.h RpVtkGraphicsObject.h RpVtkDataSet.h ColorMap.h Trace.h
    141142RpVtkDataSet.o: RpVtkDataSet.h Trace.h
    142143RpVtkRenderer.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  
    2626
    2727Contour2D::Contour2D() :
    28     _dataSet(NULL),
    29     _numContours(0),
    30     _edgeWidth(1.0f),
    31     _opacity(1.0)
     28    VtkGraphicsObject(),
     29    _numContours(0)
    3230{
    3331    _dataRange[0] = 0;
    3432    _dataRange[1] = 1;
    35     _edgeColor[0] = 0;
    36     _edgeColor[1] = 0;
    37     _edgeColor[2] = 0;
    3833}
    3934
     
    6863
    6964/**
    70  * \brief Returns the DataSet this Contour2D renders
    71  */
    72 DataSet *Contour2D::getDataSet()
    73 {
    74     return _dataSet;
    75 }
    76 
    77 /**
    78  * \brief Get the VTK Prop for the contour lines
    79  */
    80 vtkProp *Contour2D::getProp()
    81 {
    82     return _contourActor;
    83 }
    84 
    85 /**
    8665 * \brief Create and initialize a VTK Prop to render isolines
    8766 */
    8867void Contour2D::initProp()
    8968{
    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();
    9878    }
    9979}
     
    189169        _contourMapper->SetResolveCoincidentTopologyToPolygonOffset();
    190170        _contourMapper->SetInputConnection(_contourFilter->GetOutputPort());
    191         _contourActor->SetMapper(_contourMapper);
     171        getActor()->SetMapper(_contourMapper);
    192172    }
    193173
     
    263243
    264244/**
    265  * \brief Turn on/off rendering of this contour set
    266  */
    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 set
    276  *
    277  * \return Is contour set visible?
    278  */
    279 bool Contour2D::getVisibility() const
    280 {
    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 lines
    290  */
    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 lines
    300  */
    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 /**
    321245 * \brief Set a group of world coordinate planes to clip rendering
    322246 *
     
    329253    }
    330254}
    331 
    332 /**
    333  * \brief Turn on/off lighting of this object
    334  */
    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  
    1717#include <vector>
    1818
    19 #include "RpVtkDataSet.h"
     19#include "RpVtkGraphicsObject.h"
    2020
    2121namespace Rappture {
     
    2525 * \brief 2D Contour lines (isolines)
    2626 */
    27 class Contour2D {
     27class Contour2D : public VtkGraphicsObject {
    2828public:
    2929    Contour2D();
    3030    virtual ~Contour2D();
    3131
    32     void setDataSet(DataSet *dataset);
     32    virtual const char *getClassName() const
     33    {
     34        return "Contour2D";
     35    }
    3336
    34     DataSet *getDataSet();
     37    virtual void setDataSet(DataSet *dataset);
    3538
    36     vtkProp *getProp();
     39    virtual void setClippingPlanes(vtkPlaneCollection *planes);
    3740
    3841    void setContours(int numContours);
     
    4649    const std::vector<double>& getContourList() const;
    4750
    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 
    6251private:
    63     void initProp();
    64     void update();
    65 
    66     DataSet *_dataSet;
     52    virtual void initProp();
     53    virtual void update();
    6754
    6855    int _numContours;
     
    7057    double _dataRange[2];
    7158
    72     float _edgeColor[3];
    73     float _edgeWidth;
    74     double _opacity;
    7559    vtkSmartPointer<vtkContourFilter> _contourFilter;
    7660    vtkSmartPointer<vtkPolyDataMapper> _contourMapper;
    77     vtkSmartPointer<vtkActor> _contourActor;
    7861};
    7962
  • branches/blt4/packages/vizservers/vtkvis/RpContour3D.cpp

    r2322 r2409  
    2626
    2727Contour3D::Contour3D() :
    28     _dataSet(NULL),
    29     _numContours(0),
    30     _edgeWidth(1.0f),
    31     _opacity(1.0),
    32     _lighting(true)
     28    VtkGraphicsObject(),
     29    _numContours(0)
    3330{
    3431    _dataRange[0] = 0;
    3532    _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;
    4236}
    4337
     
    7266
    7367/**
    74  * \brief Returns the DataSet this Contour3D renders
    75  */
    76 DataSet *Contour3D::getDataSet()
    77 {
    78     return _dataSet;
    79 }
    80 
    81 /**
    82  * \brief Get the VTK Prop for the isosurfaces
    83  */
    84 vtkProp *Contour3D::getProp()
    85 {
    86     return _contourActor;
    87 }
    88 
    89 /**
    9068 * \brief Create and initialize a VTK Prop to render isosurfaces
    9169 */
    9270void Contour3D::initProp()
    9371{
    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);
    10281        if (!_lighting)
    103             _contourActor->GetProperty()->LightingOff();
     82            property->LightingOff();
    10483    }
    10584}
     
    216195        _contourMapper->SetResolveCoincidentTopologyToPolygonOffset();
    217196        _contourMapper->SetInputConnection(_contourFilter->GetOutputPort());
    218         _contourActor->SetMapper(_contourMapper);
     197        getActor()->SetMapper(_contourMapper);
    219198    }
    220199
     
    317296
    318297/**
    319  * \brief Turn on/off rendering of this contour set
    320  */
    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 set
    330  *
    331  * \return Is contour set visible?
    332  */
    333 bool Contour3D::getVisibility() const
    334 {
    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 isosurfaces
    344  */
    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 representations
    354  */
    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 isosurfaces
    370  */
    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 edges
    382  */
    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 edges
    392  */
    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 /**
    413298 * \brief Set a group of world coordinate planes to clip rendering
    414299 *
     
    421306    }
    422307}
    423 
    424 /**
    425  * \brief Turn on/off lighting of this object
    426  */
    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  
    1818#include <vector>
    1919
    20 #include "RpVtkDataSet.h"
     20#include "RpVtkGraphicsObject.h"
    2121
    2222namespace Rappture {
     
    2626 * \brief 3D Contour isosurfaces (geometry)
    2727 */
    28 class Contour3D {
     28class Contour3D : public VtkGraphicsObject {
    2929public:
    3030    Contour3D();
    3131    virtual ~Contour3D();
    3232
    33     void setDataSet(DataSet *dataset);
     33    virtual const char *getClassName() const
     34    {
     35        return "Contour3D";
     36    }
    3437
    35     DataSet *getDataSet();
     38    virtual void setDataSet(DataSet *dataset);
    3639
    37     vtkProp *getProp();
     40    virtual void setClippingPlanes(vtkPlaneCollection *planes);
    3841
    3942    void setContours(int numContours);
     
    4750    const std::vector<double>& getContourList() const;
    4851
    49     void setVisibility(bool state);
    50 
    51     bool getVisibility() const;
    52 
    53     void setOpacity(double opacity);
    54 
    55     void setWireframe(bool state);
    56 
    5752    void setLookupTable(vtkLookupTable *lut);
    5853
    5954    vtkLookupTable *getLookupTable();
    6055
    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 
    7356private:
    74     void initProp();
    75     void update();
    76 
    77     DataSet *_dataSet;
     57    virtual void initProp();
     58    virtual void update();
    7859
    7960    int _numContours;
     
    8162    double _dataRange[2];
    8263
    83     float _color[3];
    84     float _edgeColor[3];
    85     float _edgeWidth;
    86     double _opacity;
    87     bool _lighting;
    88 
    8964    vtkSmartPointer<vtkContourFilter> _contourFilter;
    9065    vtkSmartPointer<vtkLookupTable> _lut;
    9166    vtkSmartPointer<vtkPolyDataMapper> _contourMapper;
    92     vtkSmartPointer<vtkActor> _contourActor;
    9367};
    9468
  • branches/blt4/packages/vizservers/vtkvis/RpGlyphs.cpp

    r2322 r2409  
    2727
    2828Glyphs::Glyphs() :
    29     _dataSet(NULL),
    30     _opacity(1.0),
    31     _lighting(true),
     29    VtkGraphicsObject(),
    3230    _glyphShape(ARROW),
    33     _scaleFactor(1.0)
    34 {
     31    _scaleFactor(1.0),
     32    _colorMode(COLOR_BY_SCALAR)
     33{
     34    _faceCulling = true;
    3535}
    3636
    3737Glyphs::~Glyphs()
    3838{
    39 }
    40 
    41 /**
    42  * \brief Get the VTK Prop for the Glyphs
    43  */
    44 vtkProp *Glyphs::getProp()
    45 {
    46     return _prop;
    47 }
    48 
    49 /**
    50  * \brief Create and initialize a VTK Prop to render Glyphs
    51  */
    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 DataSet
    66  *
    67  * The DataSet must be a PolyData point set
    68  * with vectors and/or scalars
    69  */
    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 renders
    80  */
    81 DataSet *Glyphs::getDataSet()
    82 {
    83     return _dataSet;
    8439}
    8540
     
    12782        return;
    12883    }
     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
    12993    if (_glyphGenerator != NULL) {
    13094        _glyphGenerator->SetSourceConnection(_glyphSource->GetOutputPort());
     
    142106
    143107    vtkDataSet *ds = _dataSet->getVtkDataSet();
    144     double dataRange[2];
    145     _dataSet->getDataRange(dataRange);
    146108
    147109    if (_glyphGenerator == NULL) {
    148110        _glyphGenerator = vtkSmartPointer<vtkGlyph3D>::New();
    149111    }
     112
     113    initProp();
    150114
    151115    setGlyphShape(_glyphShape);
     
    180144
    181145    if (ds->GetPointData()->GetScalars() == NULL) {
     146        TRACE("Setting color mode to vector magnitude");
    182147        _glyphGenerator->SetColorModeToColorByVector();
    183     } else {
     148        _colorMode = COLOR_BY_VECTOR;
     149    } else {
     150        TRACE("Setting color mode to scalar");
    184151        _glyphGenerator->SetColorModeToColorByScalar();
    185      }
     152        _colorMode = COLOR_BY_SCALAR;
     153    }
    186154    if (_glyphShape == SPHERE) {
    187155        _glyphGenerator->OrientOff();
     
    212180
    213181    if (ds->GetPointData()->GetScalars() == NULL) {
    214         _pdMapper->UseLookupTableScalarRangeOff();
    215     } else {
     182        double dataRange[2];
     183        _dataSet->getVectorMagnitudeRange(dataRange);
    216184        _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();
    220195    _pdMapper->SetLookupTable(_lut);
    221 
    222     initProp();
    223 
    224     _prop->SetMapper(_pdMapper);
     196    _pdMapper->UseLookupTableScalarRangeOn();
     197
     198    getActor()->SetMapper(_pdMapper);
    225199    _pdMapper->Update();
     200}
     201
     202/**
     203 * \brief Control how glyphs are scaled
     204 */
     205void 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 */
     233void 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    }
    226264}
    227265
     
    257295    }
    258296
     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
    259313    if (_pdMapper != NULL) {
    260314        _pdMapper->SetLookupTable(_lut);
    261315    }
    262 }
    263 
    264 /**
    265  * \brief Turn on/off rendering of this Glyphs
    266  */
    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 Glyphs
    276  *
    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 Glyphs
    290  */
    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 Glyphs
    300  */
    301 double Glyphs::getOpacity()
    302 {
    303     return _opacity;
    304316}
    305317
     
    315327    }
    316328}
    317 
    318 /**
    319  * \brief Turn on/off lighting of this object
    320  */
    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  
    1818#include <vtkPlaneCollection.h>
    1919
    20 #include "RpVtkDataSet.h"
     20#include "RpVtkGraphicsObject.h"
    2121#include "ColorMap.h"
    2222
     
    2626/**
    2727 * \brief Oriented and scaled 3D glyph shapes
     28 *
     29 * The DataSet must be a PolyData point set
     30 * with vectors and/or scalars
    2831 */
    29 class Glyphs {
     32class Glyphs : public VtkGraphicsObject {
    3033public:
    3134    enum GlyphShape {
     
    4043        TETRAHEDRON
    4144    };
     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    };
    4257
    4358    Glyphs();
    4459    virtual ~Glyphs();
    4560
    46     void setDataSet(DataSet *dataset);
     61    virtual const char *getClassName() const
     62    {
     63        return "Glyphs";
     64    }
    4765
    48     DataSet *getDataSet();
     66    virtual void setClippingPlanes(vtkPlaneCollection *planes);
    4967
    50     vtkProp *getProp();
     68    void setScalingMode(ScalingMode mode);
     69
     70    void setColorMode(ColorMode mode);
    5171
    5272    void setGlyphShape(GlyphShape shape);
     
    5878    vtkLookupTable *getLookupTable();
    5979
    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 
    7280private:
    73     void initProp();
    74     void update();
    75 
    76     DataSet *_dataSet;
    77 
    78     double _opacity;
    79     bool _lighting;
     81    virtual void update();
    8082
    8183    GlyphShape _glyphShape;
    8284    double _scaleFactor;
     85    ColorMode _colorMode;
    8386
    8487    vtkSmartPointer<vtkLookupTable> _lut;
    85     vtkSmartPointer<vtkActor> _prop;
    8688    vtkSmartPointer<vtkGlyph3D> _glyphGenerator;
    8789    vtkSmartPointer<vtkPolyDataAlgorithm> _glyphSource;
  • branches/blt4/packages/vizservers/vtkvis/RpHeightMap.cpp

    r2322 r2409  
    3636
    3737HeightMap::HeightMap() :
    38     _dataSet(NULL),
     38    VtkGraphicsObject(),
    3939    _numContours(0),
    40     _edgeWidth(1.0),
    4140    _contourEdgeWidth(1.0),
    42     _opacity(1.0),
    4341    _warpScale(1.0),
    4442    _sliceAxis(Z_AXIS),
     
    4745    _dataRange[0] = 0.0;
    4846    _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;
    5550}
    5651
     
    107102
    108103/**
    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 */
     106void 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    }
    114130}
    115131
     
    372388    _dsActor->SetMapper(_dsMapper);
    373389
    374     if (_props == NULL) {
    375         _props = 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);
    378394    }
    379395
     
    599615
    600616/**
    601  * \brief Get the VTK Prop for the colormapped dataset
    602  */
    603 vtkProp *HeightMap::getProp()
    604 {
    605     return _props;
    606 }
    607 
    608 /**
    609  * \brief Create and initialize VTK Props to render the colormapped dataset
    610  */
    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 /**
    638617 * \brief Get the VTK colormap lookup table in use
    639618 */
     
    728707
    729708/**
    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 */
     711void HeightMap::setLighting(bool state)
     712{
     713    if (_dsActor != NULL)
     714        _dsActor->GetProperty()->SetLighting((state ? 1 : 0));
    771715}
    772716
     
    852796}
    853797
    854 /**
    855  * \brief Turn on/off lighting of this object
    856  */
    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  
    2020#include <vtkExtractVOI.h>
    2121#include <vtkWarpScalar.h>
    22 #include <vtkPropAssembly.h>
     22#include <vtkAssembly.h>
    2323#include <vtkPolyData.h>
    2424
    2525#include <vector>
    2626
    27 #include "RpVtkDataSet.h"
     27#include "RpVtkGraphicsObject.h"
    2828
    2929namespace Rappture {
     
    3333 * \brief Color-mapped plot of data set
    3434 */
    35 class HeightMap {
     35class HeightMap : public VtkGraphicsObject {
    3636public:
    3737    enum Axis {
     
    4444    virtual ~HeightMap();
    4545
    46     void setDataSet(DataSet *dataset);
     46    virtual const char *getClassName() const
     47    {
     48        return "HeightMap";
     49    }
    4750
    48     DataSet *getDataSet();
     51    virtual void setDataSet(DataSet *dataset);
    4952
    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);
    5162
    5263    void selectVolumeSlice(Axis axis, double ratio);
     
    6879    vtkLookupTable *getLookupTable();
    6980
    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 
    8281    void setContourVisibility(bool state);
    8382
     
    8685    void setContourEdgeWidth(float edgeWidth);
    8786
    88     void setClippingPlanes(vtkPlaneCollection *planes);
     87private:
     88    virtual void initProp();
     89    virtual void update();
    8990
    90     void setLighting(bool state);
    91 
    92 private:
    9391    vtkAlgorithmOutput *initWarp(vtkAlgorithmOutput *input);
    9492    vtkAlgorithmOutput *initWarp(vtkPolyData *input);
    95     void initProp();
    96     void update();
    97 
    98     DataSet * _dataSet;
    9993
    10094    int _numContours;
     
    106100    float _edgeWidth;
    107101    float _contourEdgeWidth;
    108     double _opacity;
    109102    double _warpScale;
    110103    double _dataScale;
     
    122115    vtkSmartPointer<vtkActor> _dsActor;
    123116    vtkSmartPointer<vtkActor> _contourActor;
    124     vtkSmartPointer<vtkPropAssembly> _props;
    125117};
    126118
  • branches/blt4/packages/vizservers/vtkvis/RpLIC.cpp

    r2322 r2409  
    2626
    2727LIC::LIC() :
    28     _dataSet(NULL),
    29     _edgeWidth(1.0f),
    30     _opacity(1.0),
    31     _lighting(false),
     28    VtkGraphicsObject(),
    3229    _sliceAxis(Z_AXIS)
    3330{
    34     _edgeColor[0] = 0.0f;
    35     _edgeColor[1] = 0.0f;
    36     _edgeColor[2] = 0.0f;
    3731}
    3832
    3933LIC::~LIC()
    4034{
    41 }
    42 
    43 /**
    44  * \brief Get the VTK Prop for the LIC
    45  */
    46 vtkProp *LIC::getProp()
    47 {
    48     return _prop;
    4935}
    5036
     
    5339    if (_prop == NULL) {
    5440        _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);
    6047        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    }
    8450}
    8551
     
    224190
    225191    initProp();
    226     _prop->SetMapper(_mapper);
     192    getActor()->SetMapper(_mapper);
    227193
    228194    _mapper->Update();
     
    369335
    370336/**
    371  * \brief Turn on/off rendering of this LIC
    372  */
    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 LIC
    382  *
    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 LIC
    396  */
    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 LIC
    407  */
    408 double LIC::getOpacity()
    409 {
    410     return _opacity;
    411 }
    412 
    413 /**
    414  * \brief Turn on/off rendering of edges
    415  */
    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 edges
    425  */
    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 /**
    446337 * \brief Set a group of world coordinate planes to clip rendering
    447338 *
     
    454345    }
    455346}
    456 
    457 /**
    458  * \brief Turn on/off lighting of this object
    459  */
    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  
    1919#include <vtkLookupTable.h>
    2020
    21 #include "RpVtkDataSet.h"
     21#include "RpVtkGraphicsObject.h"
    2222
    2323namespace Rappture {
     
    2626/**
    2727 * \brief Line Integral Convolution visualization of vector fields
     28 *
     29 *  The DataSet must contain vectors
    2830 */
    29 class LIC {
     31class LIC : public VtkGraphicsObject {
    3032public:
    3133    enum Axis {
     
    3840    virtual ~LIC();
    3941
    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);
    4548
    4649    void selectVolumeSlice(Axis axis, double ratio);
     
    5053    vtkLookupTable *getLookupTable();
    5154
    52     void setOpacity(double opacity);
     55private:
     56    virtual void initProp();
     57    virtual void update();
    5358
    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;
    8059    Axis _sliceAxis;
    8160
    8261    vtkSmartPointer<vtkLookupTable> _lut;
    83     vtkSmartPointer<vtkActor> _prop;
    8462    vtkSmartPointer<vtkExtractVOI> _volumeSlicer;
    8563    vtkSmartPointer<vtkProbeFilter> _probeFilter;
  • branches/blt4/packages/vizservers/vtkvis/RpMolecule.cpp

    r2322 r2409  
    2626
    2727Molecule::Molecule() :
    28     _dataSet(NULL),
    29     _edgeWidth(1.0),
    30     _opacity(1.0),
    31     _lighting(true),
     28    VtkGraphicsObject(),
    3229    _atomScaling(NO_ATOM_SCALING)
    3330{
    34     _edgeColor[0] = 0.0;
    35     _edgeColor[1] = 0.0;
    36     _edgeColor[2] = 0.0;
     31    _faceCulling = true;
    3732}
    3833
     
    4843
    4944/**
    50  * \brief Get the VTK Prop for the Molecule
    51  */
    52 vtkProp *Molecule::getProp()
    53 {
    54     return _props;
    55 }
    56 
    57 /**
    5845 * \brief Create and initialize VTK Props to render a Molecule
    5946 */
     
    6249    if (_atomProp == NULL) {
    6350        _atomProp = vtkSmartPointer<vtkActor>::New();
     51        if (_faceCulling && _opacity == 1.0)
     52            setCulling(_atomProp->GetProperty(), true);
    6453        _atomProp->GetProperty()->EdgeVisibilityOff();
    6554        _atomProp->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);
     
    7261    if (_bondProp == NULL) {
    7362        _bondProp = vtkSmartPointer<vtkActor>::New();
     63        if (_faceCulling && _opacity == 1.0)
     64            setCulling(_bondProp->GetProperty(), true);
    7465        _bondProp->GetProperty()->EdgeVisibilityOff();
    7566        _bondProp->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);
     
    8071            _bondProp->GetProperty()->LightingOff();
    8172    }
    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    }
    10876}
    10977
     
    194162            _bondMapper->SetInputConnection(tuber->GetOutputPort());
    195163            _bondProp->SetMapper(_bondMapper);
    196             _props->AddPart(_bondProp);
     164            getAssembly()->AddPart(_bondProp);
    197165        }
    198166        if (pd->GetNumberOfVerts() > 0) {
     
    217185            _atomMapper->SetInputConnection(_glypher->GetOutputPort());
    218186            _atomProp->SetMapper(_atomMapper);
    219             _props->AddPart(_atomProp);
     187            getAssembly()->AddPart(_atomProp);
    220188        }
    221189    } else {
     
    259227
    260228/**
    261  * \brief Turn on/off rendering of this Molecule
    262  */
    263 void Molecule::setVisibility(bool state)
    264 {
    265     if (_props != NULL) {
    266         _props->SetVisibility((state ? 1 : 0));
    267     }
    268 }
    269 
    270 /**
    271229 * \brief Turn on/off rendering of the atoms
    272230 */
     
    286244        _bondProp->SetVisibility((state ? 1 : 0));
    287245    }
    288 }
    289 
    290 /**
    291  * \brief Get visibility state of the Molecule
    292  *
    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 Molecule
    306  */
    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 representations
    318  */
    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 edges
    343  */
    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 edges
    356  */
    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);
    378246}
    379247
     
    394262
    395263/**
    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 */
    407266void Molecule::setAtomScaling(AtomScaling state)
    408267{
  • branches/blt4/packages/vizservers/vtkvis/RpMolecule.h

    r2322 r2409  
    1313#include <vtkPolyDataMapper.h>
    1414#include <vtkActor.h>
    15 #include <vtkPropAssembly.h>
     15#include <vtkAssembly.h>
    1616#include <vtkGlyph3D.h>
    1717
    1818#include "ColorMap.h"
    19 #include "RpVtkDataSet.h"
     19#include "RpVtkGraphicsObject.h"
    2020
    2121namespace Rappture {
     
    3333 * "element," it will be color-mapped as a standard scalar field.
    3434 */
    35 class Molecule {
     35class Molecule : public VtkGraphicsObject {
    3636public:
    3737    enum AtomScaling {
     
    4545    virtual ~Molecule();
    4646
    47     void setDataSet(DataSet *dataset);
     47    virtual const char *getClassName() const
     48    {
     49        return "Molecule";
     50    }
    4851
    49     DataSet *getDataSet();
    50 
    51     vtkProp *getProp();
     52    virtual void setClippingPlanes(vtkPlaneCollection *planes);
    5253
    5354    void setLookupTable(vtkLookupTable *lut);
     
    6162    void setBondVisibility(bool state);
    6263
    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 
    8164    static ColorMap *createElementColorMap();
    8265
    8366private:
    84     void initProp();
    85     void update();
     67    virtual void initProp();
     68    virtual void update();
    8669
    8770    static void addRadiusArray(vtkDataSet *dataSet, AtomScaling scaling);
    8871
    89     DataSet *_dataSet;
    90 
    91     float _edgeColor[3];
    92     float _edgeWidth;
    93     double _opacity;
    94     bool _lighting;
    9572    AtomScaling _atomScaling;
    9673
    9774    vtkSmartPointer<vtkLookupTable> _lut;
    98     vtkSmartPointer<vtkPropAssembly> _props;
    9975    vtkSmartPointer<vtkActor> _atomProp;
    10076    vtkSmartPointer<vtkActor> _bondProp;
  • branches/blt4/packages/vizservers/vtkvis/RpPolyData.cpp

    r2322 r2409  
    2424
    2525PolyData::PolyData() :
    26     _dataSet(NULL),
    27     _edgeWidth(1.0),
    28     _opacity(1.0),
    29     _lighting(true)
     26    VtkGraphicsObject()
    3027{
    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;
    3731}
    3832
     
    4842
    4943/**
    50  * \brief Get the VTK Prop for the mesh
    51  */
    52 vtkProp *PolyData::getProp()
    53 {
    54     return _pdActor;
    55 }
    56 
    57 /**
    5844 * \brief Create and initialize a VTK Prop to render a mesh
    5945 */
    6046void PolyData::initProp()
    6147{
    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);
    7057        if (!_lighting)
    71             _pdActor->GetProperty()->LightingOff();
     58            property->LightingOff();
    7259    }
    73 }
    74 
    75 /**
    76  * \brief Specify input DataSet (PolyData)
    77  *
    78  * The DataSet must be a PolyData object
    79  */
    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 renders
    90  */
    91 DataSet *PolyData::getDataSet()
    92 {
    93     return _dataSet;
    9460}
    9561
     
    12591                vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New();
    12692                mesher->SetInput(pd);
     93                mesher->ReleaseDataFlagOn();
     94                _pdMapper->SetInputConnection(mesher->GetOutputPort());
    12795#if defined(DEBUG) && defined(WANT_TRACE)
    12896                mesher->Update();
     
    134102                      outpd->GetNumberOfStrips());
    135103#endif
    136                 _pdMapper->SetInputConnection(mesher->GetOutputPort());
    137104            } else {
    138105                vtkSmartPointer<vtkDelaunay3D> mesher = vtkSmartPointer<vtkDelaunay3D>::New();
    139106                mesher->SetInput(pd);
     107                mesher->ReleaseDataFlagOn();
    140108                // Delaunay3D returns an UnstructuredGrid, so feed it through a surface filter
    141109                // to get the grid boundary as a PolyData
    142110                vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
    143111                gf->SetInputConnection(mesher->GetOutputPort());
     112                gf->ReleaseDataFlagOn();
    144113                _pdMapper->SetInputConnection(gf->GetOutputPort());
    145114            }
     
    150119    } else {
    151120        // DataSet is NOT a vtkPolyData
    152         WARN("DataSet is not a PolyData");
     121        TRACE("DataSet is not a PolyData");
    153122        vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
    154123        gf->SetInput(ds);
     124        gf->ReleaseDataFlagOn();
    155125        _pdMapper->SetInputConnection(gf->GetOutputPort());
    156126    }
    157127
    158128    initProp();
    159     _pdActor->SetMapper(_pdMapper);
     129    getActor()->SetMapper(_pdMapper);
    160130    _pdMapper->Update();
    161 }
    162 
    163 /**
    164  * \brief Turn on/off rendering of this mesh
    165  */
    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 mesh
    175  *
    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 mesh
    189  */
    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 representations
    199  */
    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 faces
    215  */
    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 edges
    227  */
    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 edges
    237  */
    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);
    255131}
    256132
     
    267143}
    268144
    269 /**
    270  * \brief Turn on/off lighting of this object
    271  */
    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  
    1313#include <vtkActor.h>
    1414
     15#include "RpVtkGraphicsObject.h"
    1516#include "RpVtkDataSet.h"
    1617
     
    2021/**
    2122 * \brief VTK Mesh (Polygon data)
     23 *
     24 * The DataSet must be a PolyData object
    2225 */
    23 class PolyData {
     26class PolyData : public VtkGraphicsObject {
    2427public:
    2528    PolyData();
    2629    virtual ~PolyData();
    2730
    28     void setDataSet(DataSet *dataset);
     31    virtual const char *getClassName() const
     32    {
     33        return "PolyData";
     34    }
    2935
    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);
    5337
    5438private:
    55     void initProp();
    56     void update();
     39    virtual void initProp();
     40    virtual void update();
    5741
    58     DataSet *_dataSet;
    59 
    60     float _color[3];
    61     float _edgeColor[3];
    62     float _edgeWidth;
    63     double _opacity;
    64     bool _lighting;
    6542    vtkSmartPointer<vtkPolyDataMapper> _pdMapper;
    66     vtkSmartPointer<vtkActor> _pdActor;
    6743};
    6844
  • branches/blt4/packages/vizservers/vtkvis/RpPseudoColor.cpp

    r2322 r2409  
    2929
    3030PseudoColor::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{
    3933}
    4034
     
    5044
    5145/**
    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 */
     48void 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    }
    7061}
    7162
     
    170161
    171162    initProp();
    172     _dsActor->SetMapper(_dsMapper);
     163    getActor()->SetMapper(_dsMapper);
    173164    _dsMapper->Update();
    174 }
    175 
    176 /**
    177  * \brief Get the VTK Prop for the colormapped dataset
    178  */
    179 vtkProp *PseudoColor::getProp()
    180 {
    181     return _dsActor;
    182 }
    183 
    184 /**
    185  * \brief Create and initialize a VTK Prop to render the colormapped dataset
    186  */
    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     }
    199165}
    200166
     
    225191
    226192/**
    227  * \brief Turn on/off rendering of this colormapped dataset
    228  */
    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 dataset
    238  *
    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 dataset
    252  */
    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 representations
    262  */
    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 edges
    278  */
    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 edges
    288  */
    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 /**
    309193 * \brief Set a group of world coordinate planes to clip rendering
    310194 *
     
    317201    }
    318202}
    319 
    320 /**
    321  * \brief Turn on/off lighting of this object
    322  */
    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  
    1515#include <vtkPlaneCollection.h>
    1616
     17#include "RpVtkGraphicsObject.h"
    1718#include "RpVtkDataSet.h"
    1819
     
    2223/**
    2324 * \brief Color-mapped plot of data set
     25 *
     26 * Currently the DataSet must be image data (2D uniform grid)
    2427 */
    25 class PseudoColor {
     28class PseudoColor : public VtkGraphicsObject {
    2629public:
    2730    PseudoColor();
    2831    virtual ~PseudoColor();
    2932
    30     void setDataSet(DataSet *dataset);
     33    virtual const char *getClassName() const
     34    {
     35        return "PseudoColor";
     36    }
    3137
    32     DataSet *getDataSet();
    33 
    34     vtkProp *getProp();
     38    virtual void setClippingPlanes(vtkPlaneCollection *planes);
    3539
    3640    void setLookupTable(vtkLookupTable *lut);
     
    3842    vtkLookupTable *getLookupTable();
    3943
    40     void setVisibility(bool state);
     44private:
     45    virtual void initProp();
     46    virtual void update();
    4147
    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;
    6848    vtkSmartPointer<vtkLookupTable> _lut;
    6949    vtkSmartPointer<vtkDataSetMapper> _dsMapper;
    70     vtkSmartPointer<vtkActor> _dsActor;
    7150};
    7251
  • branches/blt4/packages/vizservers/vtkvis/RpStreamlines.cpp

    r2322 r2409  
    99#include <ctime>
    1010#include <cfloat>
     11#include <cmath>
     12
     13#include <vtkMath.h>
    1114#include <vtkActor.h>
    1215#include <vtkProperty.h>
     
    2124#include <vtkTubeFilter.h>
    2225#include <vtkRibbonFilter.h>
     26#include <vtkTransform.h>
     27#include <vtkTransformPolyDataFilter.h>
    2328
    2429#include "RpStreamlines.h"
     
    2833
    2934Streamlines::Streamlines() :
    30     _dataSet(NULL),
     35    VtkGraphicsObject(),
    3136    _lineType(LINES),
    32     _edgeWidth(1.0f),
    33     _opacity(1.0),
    34     _lighting(false),
     37    _colorMode(COLOR_BY_VECTOR_MAGNITUDE),
    3538    _seedVisible(true)
    3639{
    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;
    4044    _seedColor[0] = 1.0f;
    4145    _seedColor[1] = 1.0f;
    4246    _seedColor[2] = 1.0f;
     47    vtkMath::RandomSeed((int)time(NULL));
     48    srand((unsigned int)time(NULL));
    4349}
    4450
     
    4854
    4955/**
    50  * \brief Get the VTK Prop for the Streamlines
    51  */
    52 vtkProp *Streamlines::getProp()
    53 {
    54     return _props;
    55 }
    56 
    57 /**
    5856 * \brief Create and initialize a VTK Prop to render Streamlines
    5957 */
    6058void Streamlines::initProp()
    6159{
    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);
    6867        if (!_lighting)
    69             _prop->GetProperty()->LightingOff();
     68            _linesActor->GetProperty()->LightingOff();
    7069        switch (_lineType) {
    7170        case LINES:
    72             _prop->GetProperty()->SetRepresentationToWireframe();
    73             _prop->GetProperty()->EdgeVisibilityOff();
     71            setCulling(_linesActor->GetProperty(), false);
     72            _linesActor->GetProperty()->SetRepresentationToWireframe();
     73            _linesActor->GetProperty()->EdgeVisibilityOff();
    7474            break;
    7575        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();
    7880            break;
    7981        case RIBBONS:
    80             _prop->GetProperty()->SetRepresentationToSurface();
    81             _prop->GetProperty()->EdgeVisibilityOff();
     82            setCulling(_linesActor->GetProperty(), false);
     83            _linesActor->GetProperty()->SetRepresentationToSurface();
     84            _linesActor->GetProperty()->EdgeVisibilityOff();
    8285            break;
    8386        default:
     
    9497        _seedActor->GetProperty()->LightingOff();
    9598    }
    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 */
     109double 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 */
    124125void Streamlines::getRandomPoint(double pt[3], const double bounds[6])
    125126{
    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 */
     140void 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 */
     165void 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 */
     181void Streamlines::getRandomCellPt(double pt[3], vtkDataSet *ds)
    135182{
    136183    int numCells = (int)ds->GetNumberOfCells();
     184    // XXX: Not uniform distribution (shouldn't use mod, and assumes
     185    // all cells are equal area/volume)
    137186    int cell = rand() % numCells;
    138187    double bounds[6];
    139188    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);
    146191}
    147192
     
    157202    vtkDataSet *ds = _dataSet->getVtkDataSet();
    158203    double dataRange[2];
    159     _dataSet->getDataRange(dataRange);
     204    _dataSet->getVectorMagnitudeRange(dataRange);
    160205    double bounds[6];
    161206    _dataSet->getBounds(bounds);
     
    175220    if (ds->GetPointData() == NULL ||
    176221        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());
    178223        if (ds->GetCellData() == NULL ||
    179224            ds->GetCellData()->GetVectors() == NULL) {
     
    194239
    195240    _streamTracer->SetInput(ds);
    196 
    197     // Set up seed source object
    198     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 
    218241    _streamTracer->SetMaximumPropagation(maxBound);
    219     _streamTracer->SetSource(seed);
    220242
    221243    if (_pdMapper == NULL) {
     
    223245        _pdMapper->SetResolveCoincidentTopologyToPolygonOffset();
    224246        _pdMapper->ScalarVisibilityOn();
    225         // _pdMapper->ScalarVisibilityOff();
    226247    }
    227248    if (_seedMapper == NULL) {
    228249        _seedMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
    229250        _seedMapper->SetResolveCoincidentTopologyToPolygonOffset();
    230         _seedMapper->SetInput(seed);
    231     }
     251    }
     252
     253    // Set up seed source object
     254    setSeedToRandomPoints(200);
    232255
    233256    switch (_lineType) {
     
    272295
    273296    _lut = vtkSmartPointer<vtkLookupTable>::New();
     297    _lut->SetRange(dataRange);
    274298    _lut->SetVectorModeToMagnitude();
    275299
     
    281305    }
    282306    _pdMapper->SetColorModeToMapScalars();
    283     _pdMapper->UseLookupTableScalarRangeOff();
     307    _pdMapper->UseLookupTableScalarRangeOn();
    284308    _pdMapper->SetLookupTable(_lut);
    285309
    286     _prop->SetMapper(_pdMapper);
     310    _linesActor->SetMapper(_pdMapper);
    287311    _pdMapper->Update();
    288312    _seedMapper->Update();
     
    291315/**
    292316 * \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
    293321 *
    294322 * \param[in] numPoints Number of random seed points to generate
     
    302330        vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New();
    303331
    304         srand((unsigned int)time(NULL));
    305332        for (int i = 0; i < numPoints; i++) {
    306333            double pt[3];
    307             getRandomCellPt(_dataSet->getVtkDataSet(), pt);
     334            getRandomCellPt(pt, _dataSet->getVtkDataSet());
    308335            TRACE("Seed pt: %g %g %g", pt[0], pt[1], pt[2]);
    309336            pts->InsertNextPoint(pt);
     
    384411
    385412/**
     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 */
     421void 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/**
    386505 * \brief Use seed points from an n-sided polygon
    387506 *
    388507 * \param[in] center Center point of polygon
    389508 * \param[in] normal Normal vector to orient polygon
     509 * \param[in] angle Angle in degrees to rotate about normal
    390510 * \param[in] radius Radius of circumscribing circle
    391511 * \param[in] numSides Number of polygon sides (and points) to generate
     
    393513void Streamlines::setSeedToPolygon(double center[3],
    394514                                   double normal[3],
     515                                   double angle,
    395516                                   double radius,
    396517                                   int numSides)
     
    406527        seed->GeneratePolygonOn();
    407528
     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
    408538        TRACE("Seed points: %d", numSides);
    409539        vtkSmartPointer<vtkDataSet> oldSeed;
     
    412542        }
    413543
    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
    415560        if (oldSeed != NULL) {
    416561            oldSeed->SetPipelineInformation(NULL);
    417562        }
    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 */
     576void 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);
    420677    }
    421678}
     
    442699        _pdMapper->SetInputConnection(_streamTracer->GetOutputPort());
    443700        _lineFilter = NULL;
    444         _prop->GetProperty()->SetRepresentationToWireframe();
    445         _prop->GetProperty()->LightingOff();
     701        setCulling(_linesActor->GetProperty(), false);
     702        _linesActor->GetProperty()->SetRepresentationToWireframe();
     703        _linesActor->GetProperty()->LightingOff();
    446704    }
    447705}
     
    468726        tubeFilter->SetRadius(radius);
    469727        _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();
    472732     }
    473733}
     
    493753        ribbonFilter->UseDefaultNormalOn();
    494754        _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
     761void 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;
    497846    }
    498847}
     
    517866    }
    518867
     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
    519904    if (_pdMapper != NULL) {
    520905        _pdMapper->SetLookupTable(_lut);
     
    523908
    524909/**
     910 * \brief Turn on/off lighting of this object
     911 */
     912void 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 */
     922void 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/**
    525938 * \brief Turn on/off rendering of this Streamlines
    526939 */
    527940void Streamlines::setVisibility(bool state)
    528941{
    529     if (_prop != NULL) {
    530         _prop->SetVisibility((state ? 1 : 0));
     942    if (_linesActor != NULL) {
     943        _linesActor->SetVisibility((state ? 1 : 0));
    531944    }
    532945    if (_seedActor != NULL) {
     
    556969bool Streamlines::getVisibility()
    557970{
    558     if (_prop == NULL) {
     971    if (_linesActor == NULL) {
    559972        return false;
    560973    } 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    }
    585976}
    586977
     
    590981void Streamlines::setEdgeVisibility(bool state)
    591982{
    592     if (_prop != NULL) {
    593         _prop->GetProperty()->SetEdgeVisibility((state ? 1 : 0));
     983    if (_linesActor != NULL) {
     984        _linesActor->GetProperty()->SetEdgeVisibility((state ? 1 : 0));
    594985    }
    595986}
     
    597988/**
    598989 * \brief Set RGB color of stream lines
     990 */
     991void 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
    5991002 */
    6001003void Streamlines::setEdgeColor(float color[3])
     
    6031006    _edgeColor[1] = color[1];
    6041007    _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]);
    6071010}
    6081011
     
    6251028{
    6261029    _edgeWidth = edgeWidth;
    627     if (_prop != NULL)
    628         _prop->GetProperty()->SetLineWidth(_edgeWidth);
     1030    if (_linesActor != NULL)
     1031        _linesActor->GetProperty()->SetLineWidth(_edgeWidth);
    6291032}
    6301033
     
    6431046    }
    6441047}
    645 
    646 /**
    647  * \brief Turn on/off lighting of this object
    648  */
    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  
    1616#include <vtkPolyDataMapper.h>
    1717#include <vtkLookupTable.h>
    18 #include <vtkPropAssembly.h>
     18#include <vtkAssembly.h>
    1919
    20 #include "RpVtkDataSet.h"
     20#include "RpVtkGraphicsObject.h"
    2121
    2222namespace Rappture {
     
    2525/**
    2626 * \brief Streamline visualization of vector fields
     27 *
     28 * The DataSet must contain vectors
    2729 */
    28 class Streamlines {
     30class Streamlines : public VtkGraphicsObject {
    2931public:
    3032    enum LineType {
     
    3335        RIBBONS
    3436    };
     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    };
    3545
    3646    Streamlines();
    3747    virtual ~Streamlines();
    3848
    39     void setDataSet(DataSet *dataset);
     49    virtual const char *getClassName() const
     50    {
     51        return "Streamlines";
     52    }
    4053
    41     DataSet *getDataSet();
     54    virtual void setLighting(bool state);
    4255
    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);
    4471
    4572    void setSeedToRandomPoints(int numPoints);
     
    4774    void setSeedToRake(double start[3], double end[3], int numPoints);
    4875
     76    void setSeedToDisk(double center[3], double normal[3],
     77                       double radius, double innerRadius, int numPoints);
     78
    4979    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);
    5186
    5287    void setMaxPropagation(double length);
     
    5893    void setLineTypeToRibbons(double width, double angle);
    5994
     95    void setColorMode(ColorMode mode);
     96
    6097    void setLookupTable(vtkLookupTable *lut);
    6198
    6299    vtkLookupTable *getLookupTable();
    63100
    64     void setOpacity(double opacity);
    65 
    66     double getOpacity();
    67 
    68     void setVisibility(bool state);
    69 
    70101    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);
    79102
    80103    void setSeedColor(float color[3]);
    81104
    82     void setClippingPlanes(vtkPlaneCollection *planes);
     105private:
     106    virtual void initProp();
     107    virtual void update();
    83108
    84     void setLighting(bool state);
    85 
    86 private:
    87     void initProp();
    88     void update();
    89 
     109    static double getRandomNum(double min, double max);
    90110    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);
    94119
    95120    LineType _lineType;
    96     float _edgeColor[3];
    97     float _edgeWidth;
     121    ColorMode _colorMode;
     122    float _color[3];
    98123    float _seedColor[3];
    99     double _opacity;
    100     bool _lighting;
    101124    bool _seedVisible;
    102125
    103126    vtkSmartPointer<vtkLookupTable> _lut;
    104     vtkSmartPointer<vtkActor> _prop;
     127    vtkSmartPointer<vtkActor> _linesActor;
    105128    vtkSmartPointer<vtkActor> _seedActor;
    106     vtkSmartPointer<vtkPropAssembly> _props;
    107129    vtkSmartPointer<vtkStreamTracer> _streamTracer;
    108130    vtkSmartPointer<vtkPolyDataAlgorithm> _lineFilter;
  • branches/blt4/packages/vizservers/vtkvis/RpVolume.cpp

    r2322 r2409  
    2727
    2828Volume::Volume() :
    29     _dataSet(NULL),
    30     _opacity(1.0),
     29    VtkGraphicsObject(),
    3130    _colorMap(NULL)
    3231{
     
    4443
    4544/**
    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
    5046 */
    51 void Volume::setDataSet(DataSet *dataSet)
     47void Volume::initProp()
    5248{
    53     if (_dataSet != dataSet) {
    54         _dataSet = dataSet;
    55         update();
     49    if (_prop == NULL) {
     50        _prop = vtkSmartPointer<vtkVolume>::New();
     51        getVolume()->GetProperty()->SetInterpolationTypeToLinear();
    5652    }
    57 }
    58 
    59 /**
    60  * \brief Returns the DataSet this Volume renders
    61  */
    62 DataSet *Volume::getDataSet()
    63 {
    64     return _dataSet;
    6553}
    6654
     
    129117    }
    130118
    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));
    133122
    134     _volumeProp->SetMapper(_volumeMapper);
     123    getVolume()->SetMapper(_volumeMapper);
    135124    _volumeMapper->Update();
    136 }
    137 
    138 /**
    139  * \brief Get the VTK Prop for the Volume
    140  */
    141 vtkProp *Volume::getProp()
    142 {
    143     return _volumeProp;
    144 }
    145 
    146 /**
    147  * \brief Create and initialize a VTK Prop to render the Volume
    148  */
    149 void Volume::initProp()
    150 {
    151     if (_volumeProp == NULL) {
    152         _volumeProp = vtkSmartPointer<vtkVolume>::New();
    153         _volumeProp->GetProperty()->SetInterpolationTypeToLinear();
    154     }
    155125}
    156126
     
    161131{
    162132    _colorMap = cmap;
    163     if (_volumeProp != NULL) {
     133    if (getVolume() != NULL) {
    164134        double dataRange[2];
    165135        _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));
    168138    }
    169139}
     
    176146{
    177147    _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));
    181151    }
    182152}
     
    199169    // across the different mappers/algorithms.  This only works with the
    200170    // 3D texture mapper, not the GPU raycast mapper
    201     if (_volumeProp != NULL) {
     171    if (getVolume() != NULL) {
    202172        if (opacity < 1.0e-6)
    203173            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);
    229175    }
    230176}
     
    241187    }
    242188}
    243 
    244 /**
    245  * \brief Set the ambient lighting/shading coefficient
    246  */
    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 coefficient
    256  */
    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 power
    266  */
    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 object
    277  */
    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  
    1515#include <vtkPlaneCollection.h>
    1616
    17 #include "RpVtkDataSet.h"
     17#include "RpVtkGraphicsObject.h"
    1818#include "ColorMap.h"
    1919
     
    2323/**
    2424 * \brief Volume Rendering
     25 *
     26 * Currently the DataSet must be image data (3D uniform grid),
     27 * or an UnstructuredGrid
    2528 */
    26 class Volume {
     29class Volume : public VtkGraphicsObject {
    2730public:
    2831    enum BlendMode {
     
    3538    virtual ~Volume();
    3639
    37     void setDataSet(DataSet *dataset);
     40    virtual const char *getClassName() const
     41    {
     42        return "Volume";
     43    }
    3844
    39     DataSet *getDataSet();
     45    virtual void setOpacity(double opacity);
    4046
    41     vtkProp *getProp();
     47    virtual void setClippingPlanes(vtkPlaneCollection *planes);
    4248
    4349    void setColorMap(ColorMap *cmap);
     50
    4451    void setColorMap(ColorMap *cmap, double dataRange[2]);
    4552
    4653    ColorMap *getColorMap();
    4754
    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 
    6455private:
    65     void initProp();
    66     void update();
    67 
    68     DataSet *_dataSet;
    69     double _opacity;
     56    virtual void initProp();
     57    virtual void update();
    7058
    7159    ColorMap *_colorMap;
    72     vtkSmartPointer<vtkVolume> _volumeProp;
    7360    vtkSmartPointer<vtkAbstractVolumeMapper> _volumeMapper;
    7461};
  • branches/blt4/packages/vizservers/vtkvis/RpVtkDataSet.cpp

    r2322 r2409  
    1717#include <vtkProperty.h>
    1818#include <vtkPointData.h>
     19#include <vtkCellData.h>
    1920#include <vtkLookupTable.h>
    2021
     
    2829    _visible(true)
    2930{
    30     _dataRange[0] = 0;
    31     _dataRange[1] = 1;
    32     for (int i = 0; i < 6; i++) {
    33         _bounds[i] = 0;
    34     }
    3531}
    3632
     
    123119    _dataSet->SetPipelineInformation(NULL);
    124120
    125     _dataSet->GetScalarRange(_dataRange);
    126     _dataSet->GetBounds(_bounds);
    127 
    128121    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]);
    130129    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());
    134134    return true;
    135135}
     
    144144    _dataSet = ds;
    145145    _dataSet->SetPipelineInformation(NULL);
    146     _dataSet->GetScalarRange(_dataRange);
    147     _dataSet->GetBounds(_bounds);
    148146
    149147    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]);
    151155    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());
    155160    return true;
    156161}
     
    184189        return NULL;
    185190    }
    186     _dataSet->GetScalarRange(_dataRange);
    187     _dataSet->GetBounds(_bounds);
    188191
    189192    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]);
    191204    return _dataSet;
    192205}
     
    197210bool DataSet::is2D() const
    198211{
    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]);
    200215}
    201216
     
    219234 * \brief Get the underlying VTK DataSet subclass class name
    220235 */
    221 const char *DataSet::getVtkType()
     236const char *DataSet::getVtkType() const
    222237{
    223238    return _dataSet->GetClassName();
     
    225240
    226241/**
     242 * \brief Set the ative scalar array to the named field
     243 */
     244bool 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 */
     263bool 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/**
    227280 * \brief Get the range of scalar values in the DataSet
    228281 */
    229 void DataSet::getDataRange(double minmax[2])
    230 {
    231     memcpy(minmax, _dataRange, sizeof(double)*2);
     282void 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 */
     291void 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 */
     310void 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 */
     326void 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    }
    232337}
    233338
     
    235340 * \brief Get the bounds the DataSet
    236341 */
    237 void DataSet::getBounds(double bounds[6])
    238 {
    239     memcpy(bounds, _bounds, sizeof(double)*6);
     342void DataSet::getBounds(double bounds[6]) const
     343{
     344    _dataSet->GetBounds(bounds);
    240345}
    241346
     
    247352 * \return the value of the nearest point or 0 if no scalar data available
    248353 */
    249 double DataSet::getDataValue(double x, double y, double z)
     354double DataSet::getDataValue(double x, double y, double z) const
    250355{
    251356    if (_dataSet == NULL)
  • branches/blt4/packages/vizservers/vtkvis/RpVtkDataSet.h

    r2302 r2409  
    4343    vtkDataSet *getVtkDataSet();
    4444
    45     const char *getVtkType();
     45    const char *getVtkType() const;
    4646
    47     void getDataRange(double minmax[2]);
     47    bool setActiveScalars(const char *name);
    4848
    49     void getBounds(double bounds[6]);
     49    bool setActiveVectors(const char *name);
    5050
    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;
    5262
    5363    void setVisibility(bool state);
     
    6070    std::string _name;
    6171    vtkSmartPointer<vtkDataSet> _dataSet;
    62     double _dataRange[2];
    63     double _bounds[6];
    6472    bool _visible;
    6573};
  • branches/blt4/packages/vizservers/vtkvis/RpVtkRenderServer.cpp

    r2302 r2409  
    168168    g_fdOut = fileno(stdout);
    169169
     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
    170177    g_renderer = new Renderer();
    171178    vtkSmartPointer<vtkUnsignedCharArray> imgData =
  • branches/blt4/packages/vizservers/vtkvis/RpVtkRenderer.cpp

    r2322 r2409  
    6565    _cameraPan[0] = 0;
    6666    _cameraPan[1] = 0;
     67    _cameraOrientation[0] = 1.0;
     68    _cameraOrientation[1] = 0.0;
     69    _cameraOrientation[2] = 0.0;
     70    _cameraOrientation[3] = 0.0;
    6771    _cumulativeDataRange[0] = 0.0;
    6872    _cumulativeDataRange[1] = 1.0;
     
    125129    initAxes();
    126130    initCamera();
    127     storeCameraOrientation();
    128131    addColorMap("default", ColorMap::getDefault());
    129132    addColorMap("volumeDefault", ColorMap::getVolumeDefault());
     
    682685    } else
    683686        return false;
     687}
     688
     689bool 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
     722bool 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;
    684753}
    685754
     
    853922
    854923/**
     924 * \brief Turn on/off rendering of all axes
     925 */
     926void 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/**
    855942 * \brief Turn on/off rendering of all axes gridlines
    856943 */
    857944void Renderer::setAxesGridVisibility(bool state)
    858945{
     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 */
     954void 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 */
     964void 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 */
     974void 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 */
     997void Renderer::setAxisVisibility(Axis axis, bool state)
     998{
    859999    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        }
    8631015        _needsRedraw = true;
    8641016    }
     
    8831035
    8841036/**
    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 */
     1039void Renderer::setAxisLabelVisibility(Axis axis, bool state)
    9061040{
    9071041    if (_cubeAxesActor != NULL) {
    9081042        if (axis == X_AXIS) {
    909             _cubeAxesActor->SetXAxisVisibility((state ? 1 : 0));
     1043            _cubeAxesActor->SetXAxisLabelVisibility((state ? 1 : 0));
    9101044        } else if (axis == Y_AXIS) {
    911             _cubeAxesActor->SetYAxisVisibility((state ? 1 : 0));
     1045            _cubeAxesActor->SetYAxisLabelVisibility((state ? 1 : 0));
    9121046        } else if (axis == Z_AXIS) {
    913             _cubeAxesActor->SetZAxisVisibility((state ? 1 : 0));
     1047            _cubeAxesActor->SetZAxisLabelVisibility((state ? 1 : 0));
    9141048        }
    9151049        _needsRedraw = true;
     
    9171051    if (_cubeAxesActor2D != NULL) {
    9181052        if (axis == X_AXIS) {
    919             _cubeAxesActor2D->SetXAxisVisibility((state ? 1 : 0));
     1053            _cubeAxesActor2D->GetXAxisActor2D()->SetLabelVisibility((state ? 1 : 0));
    9201054        } 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 */
     1064void 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));
    9221081        }
    9231082        _needsRedraw = true;
     
    12001359    } else
    12011360        return itr->second;
     1361}
     1362
     1363/**
     1364 * \brief Set the prop orientation with a quaternion
     1365 */
     1366void 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 */
     1394void 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 */
     1422void 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 */
     1450void 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 */
     1478void 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;
    12021501}
    12031502
     
    14681767
    14691768/**
     1769 * \brief Set the prop orientation with a quaternion
     1770 */
     1771void 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 */
     1799void 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 */
     1827void 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 */
     1855void 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 */
     1883void 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/**
    14701909 * \brief Set the number of equally spaced isosurfaces for the given DataSet
    14711910 */
     
    18702309
    18712310/**
     2311 * \brief Set the prop orientation with a quaternion
     2312 */
     2313void 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 */
     2341void 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 */
     2369void 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 */
     2397void 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 */
     2425void 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 */
     2453void 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/**
    18722478 * \brief Associate an existing named color map with a Glyphs for the given DataSet
    18732479 */
     
    19232529
    19242530/**
    1925  * \brief Set the shape of Glyphs for the given DataSet
    1926  */
    1927 void Renderer::setGlyphsShape(const DataSetId& id, Glyphs::GlyphShape shape)
     2531 * \brief Controls the array used to color glyphs for the given DataSet
     2532 */
     2533void Renderer::setGlyphsColorMode(const DataSetId& id, Glyphs::ColorMode mode)
    19282534{
    19292535    GlyphsHashmap::iterator itr;
     
    19432549
    19442550    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 */
     2560void 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 */
     2588void 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 {
    19452606        itr->second->setGlyphShape(shape);
    19462607    } while (doAll && ++itr != _glyphs.end());
     
    19792640
    19802641/**
    1981  * \brief Set opacity of Glyphs for the given DataSet
    1982  */
    1983 void Renderer::setGlyphsOpacity(const DataSetId& id, double opacity)
     2642 * \brief Set the visibility of polygon edges for the specified DataSet
     2643 */
     2644void Renderer::setGlyphsEdgeVisibility(const DataSetId& id, bool state)
    19842645{
    19852646    GlyphsHashmap::iterator itr;
     
    19992660
    20002661    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 */
     2671void 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 */
     2701void 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 */
     2728void 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 */
     2754void 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 {
    20012772        itr->second->setOpacity(opacity);
    20022773    } while (doAll && ++itr != _glyphs.end());
     
    20332804
    20342805/**
    2035  * \brief Turn Glyphs lighting on/off for the specified DataSet
    2036  */
    2037 void Renderer::setGlyphsLighting(const DataSetId& id, bool state)
     2806 * \brief Turn on/off wireframe rendering of Glyphs for the given DataSet
     2807 */
     2808void Renderer::setGlyphsWireframe(const DataSetId& id, bool state)
    20382809{
    20392810    GlyphsHashmap::iterator itr;
     
    20532824
    20542825    do {
    2055         itr->second->setLighting(state);
     2826        itr->second->setWireframe(state);
    20562827    } while (doAll && ++itr != _glyphs.end());
     2828
    20572829    _needsRedraw = true;
    20582830}
     
    21302902
    21312903/**
     2904 * \brief Set an additional transform on the prop
     2905 */
     2906void 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 */
     2934void 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 */
     2962void 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 */
     2990void 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 */
     3018void 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/**
    21323044 * \brief Set the volume slice used for mapping volumetric data
    21333045 */
     
    26043516
    26053517/**
     3518 * \brief Set the prop orientation with a quaternion
     3519 */
     3520void 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 */
     3548void 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 */
     3576void 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 */
     3604void 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 */
     3632void 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/**
    26063658 * \brief Set the volume slice used for mapping volumetric data
    26073659 */
     
    29073959
    29083960/**
     3961 * \brief Set the prop orientation with a quaternion
     3962 */
     3963void 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 */
     3991void 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 */
     4019void 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 */
     4047void 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 */
     4075void 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/**
    29094101 * \brief Associate an existing named color map with a Molecule for the given DataSet
    29104102 */
     
    32864478    } else
    32874479        return itr->second;
     4480}
     4481
     4482/**
     4483 * \brief Set an additional transform on the prop
     4484 */
     4485void 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 */
     4513void 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 */
     4541void 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 */
     4569void 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 */
     4597void 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;
    32884620}
    32894621
     
    35744906
    35754907/**
     4908 * \brief Set the prop orientation with a quaternion
     4909 */
     4910void 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 */
     4938void 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 */
     4966void 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 */
     4994void 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 */
     5022void 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/**
    35765048 * \brief Associate an existing named color map with a PseudoColor for the given DataSet
    35775049 */
     
    38615333        ColorMap *cmap = getColorMap("default");
    38625334        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
    38665336        if (_useCumulativeRange) {
    38675337            lut->SetRange(_cumulativeDataRange);
     
    38715341            lut->SetRange(range);
    38725342        }
    3873 #endif
    38745343        streamlines->setLookupTable(lut);
    38755344
     
    38965365
    38975366/**
     5367 * \brief Set the prop orientation with a quaternion
     5368 */
     5369void 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 */
     5397void 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 */
     5425void 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 */
     5453void 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 */
     5481void 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/**
    38985507 * \brief Set the streamlines seed to points distributed randomly inside
    38995508 * cells of DataSet
     
    39265535 * \brief Set the streamlines seed to points along a line
    39275536 */
    3928 void Renderer::setStreamlinesSeedToRake(const DataSetId& id, double start[3], double end[3], int numPoints)
     5537void Renderer::setStreamlinesSeedToRake(const DataSetId& id,
     5538                                        double start[3], double end[3],
     5539                                        int numPoints)
    39295540{
    39305541    StreamlinesHashmap::iterator itr;
     
    39515562
    39525563/**
     5564 * \brief Set the streamlines seed to points inside a disk, with optional
     5565 * hole
     5566 */
     5567void 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/**
    39535595 * \brief Set the streamlines seed to vertices of an n-sided polygon
    39545596 */
    39555597void Renderer::setStreamlinesSeedToPolygon(const DataSetId& id,
    39565598                                           double center[3], double normal[3],
    3957                                            double radius, int numSides)
     5599                                           double angle, double radius,
     5600                                           int numSides)
    39585601{
    39595602    StreamlinesHashmap::iterator itr;
     
    39735616
    39745617    do {
    3975         itr->second->setSeedToPolygon(center, normal, radius, numSides);
     5618        itr->second->setSeedToPolygon(center, normal, angle, radius, numSides);
    39765619    } while (doAll && ++itr != _streamlines.end());
    39775620
     
    39805623
    39815624/**
    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 */
     5627void Renderer::setStreamlinesSeedToFilledPolygon(const DataSetId& id,
     5628                                                 double center[3],
     5629                                                 double normal[3],
     5630                                                 double angle, double radius,
     5631                                                 int numSides, int numPoints)
    39855632{
    39865633    StreamlinesHashmap::iterator itr;
     
    40005647
    40015648    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 */
     5659void 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 {
    40025677        itr->second->setLineTypeToLines();
    40035678    } while (doAll && ++itr != _streamlines.end());
     
    41635838    do {
    41645839        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 */
     5848void 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);
    41655867    } while (doAll && ++itr != _streamlines.end());
    41665868
     
    42055907        lut->DeepCopy(cmap->getLookupTable());
    42065908
    4207 #if 0
    42085909        if (_useCumulativeRange) {
    42095910            lut->SetRange(_cumulativeDataRange);
     
    42155916            }
    42165917        }
    4217 #endif
    42185918
    42195919        itr->second->setLookupTable(lut);
     
    42785978}
    42795979
     5980/**
     5981 * \brief Set the RGB color for the specified DataSet
     5982 */
     5983void 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}
    42806006
    42816007/**
     
    44226148    } else
    44236149        return itr->second;
     6150}
     6151
     6152/**
     6153 * \brief Set the prop orientation with a quaternion
     6154 */
     6155void 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 */
     6183void 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 */
     6211void 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 */
     6239void 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 */
     6267void 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;
    44246290}
    44256291
     
    47326598
    47336599/**
     6600 * \brief Set the VTK camera parameters based on a 4x4 view matrix
     6601 */
     6602void 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
     6634inline 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
     6668inline 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
     6702inline 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
     6719inline 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
     6727inline 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
     6741inline double *quatReciprocal(double quat[4])
     6742{
     6743    return quatReciprocal(quat, quat);
     6744}
     6745
     6746inline void copyQuat(const double quat[4], double result[4])
     6747{
     6748    memcpy(result, quat, sizeof(double)*4);
     6749}
     6750
     6751/**
    47346752 * \brief Set the orientation of the camera from a quaternion
     6753 * rotation
    47356754 *
    47366755 * \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 */
     6758void Renderer::setCameraOrientation(const double quat[4], bool absolute)
    47396759{
    47406760    if (_cameraMode == IMAGE)
     
    47426762    vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera();
    47436763    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
    47796803    _renderer->ResetCameraClippingRange();
    47806804    printCameraInfo(camera);
     
    47896813 * \param[in] viewUp x,y,z up vector of camera
    47906814 */
    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 camera
    4799     restoreCameraOrientation();
     6815void 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();
    48006824    _needsRedraw = true;
    48016825}
     
    48126836                                               double viewUp[3])
    48136837{
    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 to
    4821  * be able to later restore the saved orientation and position
    4822  */
    4823 void Renderer::storeCameraOrientation()
    4824 {
    48256838    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);
    48416842}
    48426843
     
    48566857            camera->SetFocalPoint(0, 0, 0);
    48576858            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;
    48616863        }
    48626864        setViewAngle(_windowHeight);
     
    48656867        _renderer->ResetCamera(bounds);
    48666868        _renderer->ResetCameraClippingRange();
    4867         computeScreenWorldCoords();
     6869        //computeScreenWorldCoords();
    48686870    }
    48696871
     
    48756877
    48766878    _needsRedraw = true;
     6879}
     6880
     6881void Renderer::resetCameraClippingRange()
     6882{
     6883    _renderer->ResetCameraClippingRange();
    48776884}
    48786885
     
    48936900    camera->Roll(roll); // Roll about camera view axis
    48946901    _renderer->ResetCameraClippingRange();
    4895     storeCameraOrientation();
    4896     computeScreenWorldCoords();
     6902    //computeScreenWorldCoords();
    48976903    _needsRedraw = true;
    48986904}
     
    49056911 * etc.
    49066912 *
    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)
    49096917 * \param[in] absolute Control if pan amount is relative to current or absolute
    49106918 */
     
    49526960        }
    49536961
    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        }
    49917000    }
    49927001
     
    50327041        camera->Zoom(z); // Change ortho parallel scale (Dolly has no effect in ortho)
    50337042        _renderer->ResetCameraClippingRange();
    5034         storeCameraOrientation();
    50357043    } else {
    50367044        camera->Dolly(z); // Move camera forward/back
    50377045        _renderer->ResetCameraClippingRange();
    5038         storeCameraOrientation();
    50397046        //computeScreenWorldCoords();
    50407047    }
     
    54387445        }
    54397446    }
    5440 #if 0
    5441     // Currently lookup table/scalar data range not used, colormap is used to
    5442     // color streamlines by vector magnitude
    54437447    for (StreamlinesHashmap::iterator itr = _streamlines.begin();
    54447448         itr != _streamlines.end(); ++itr) {
     
    54567460        }
    54577461    }
    5458 #endif
    54597462    for (VolumeHashmap::iterator itr = _volumes.begin();
    54607463         itr != _volumes.end(); ++itr) {
     
    55377540        resetAxes();
    55387541        _renderer->ResetCamera(bounds);
    5539         computeScreenWorldCoords();
     7542        //computeScreenWorldCoords();
    55407543        break;
    55417544    case PERSPECTIVE:
     
    55437546        resetAxes();
    55447547        _renderer->ResetCamera(bounds);
    5545         computeScreenWorldCoords();
     7548        //computeScreenWorldCoords();
    55467549        break;
    55477550    default:
     
    58317834
    58327835/**
     7836 * \brief Control the use of two sided lighting
     7837 */
     7838void Renderer::setUseTwoSidedLighting(bool state)
     7839{
     7840    _renderer->SetTwoSidedLighting(state ? 1 : 0);
     7841    _needsRedraw = true;
     7842}
     7843
     7844/**
    58337845 * \brief Control the use of the depth peeling algorithm for transparency
    58347846 */
     
    58367848{
    58377849    _renderer->SetUseDepthPeeling(state ? 1 : 0);
     7850    _needsRedraw = true;
     7851}
     7852
     7853/**
     7854 * \brief Sets flag to trigger rendering next time render() is called
     7855 */
     7856void Renderer::eventuallyRender()
     7857{
    58387858    _needsRedraw = true;
    58397859}
  • branches/blt4/packages/vizservers/vtkvis/RpVtkRenderer.h

    r2322 r2409  
    6767        FLY_STATIC_EDGES,
    6868        FLY_STATIC_TRIAD
     69    };
     70
     71    enum AxesTickPosition {
     72        TICKS_INSIDE,
     73        TICKS_OUTSIDE,
     74        TICKS_BOTH
    6975    };
    7076
     
    102108    bool setDataFile(const DataSetId& id, const char *filename);
    103109
     110    bool setDataSetActiveScalars(const DataSetId& id, const char *scalarName);
     111
     112    bool setDataSetActiveVectors(const DataSetId& id, const char *vectorName);
     113
    104114    double getDataValueAtPixel(const DataSetId& id, int x, int y);
    105115
     
    114124    // Render window
    115125
     126    /// Get the VTK render window object this Renderer uses
    116127    vtkRenderWindow *getRenderWindow()
    117128    {
     
    135146    void resetCamera(bool resetOrientation = true);
    136147
     148    void resetCameraClippingRange();
     149
    137150    void setCameraZoomRegion(double x, double y, double width, double height);
    138151
     
    143156    void rotateCamera(double yaw, double pitch, double roll);
    144157
    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]);
    150167
    151168    void getCameraOrientationAndPosition(double position[3],
     
    153170                                         double viewUp[3]);
    154171
    155     void panCamera(double x, double y, bool absolute = true);
    156 
    157     void zoomCamera(double z, bool absolute = true);
    158 
    159172    // Rendering an image
    160173
     
    165178    void setClipPlane(Axis axis, double ratio, int direction);
    166179
     180    void setUseTwoSidedLighting(bool state);
     181
    167182    void setUseDepthPeeling(bool state);
    168183
     184    void eventuallyRender();
     185
    169186    bool render();
    170187
     
    175192    void setAxesFlyMode(AxesFlyMode mode);
    176193
     194    void setAxesVisibility(bool state);
     195
    177196    void setAxesGridVisibility(bool state);
    178197
    179     void setAxesVisibility(bool state);
     198    void setAxesLabelVisibility(bool state);
     199
     200    void setAxesTickVisibility(bool state);
     201
     202    void setAxesTickPosition(AxesTickPosition pos);
    180203
    181204    void setAxesColor(double color[3]);
    182205
     206    void setAxisVisibility(Axis axis, bool state);
     207
    183208    void setAxisGridVisibility(Axis axis, bool state);
    184209
    185     void setAxisVisibility(Axis axis, bool state);
     210    void setAxisLabelVisibility(Axis axis, bool state);
     211
     212    void setAxisTickVisibility(Axis axis, bool state);
    186213
    187214    void setAxisTitle(Axis axis, const char *title);
     
    211238    Contour2D *getContour2D(const DataSetId& id);
    212239
     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
    213260    void setContour2DContours(const DataSetId& id, int numContours);
    214261
    215262    void setContour2DContourList(const DataSetId& id, const std::vector<double>& contours);
    216263
    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 
    227264    // 3D Contour (isosurface) plots
    228265
     
    233270    Contour3D *getContour3D(const DataSetId& id);
    234271
     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
    235298    void setContour3DContours(const DataSetId& id, int numContours);
    236299
     
    239302    void setContour3DColorMap(const DataSetId& id, const ColorMapId& colorMapId);
    240303
    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 
    257304    // Glyphs
    258305
     
    263310    Glyphs *getGlyphs(const DataSetId& id);
    264311
     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
    265338    void setGlyphsColorMap(const DataSetId& id, const ColorMapId& colorMapId);
    266339
    267340    void setGlyphsShape(const DataSetId& id, Glyphs::GlyphShape shape);
    268341
     342    void setGlyphsColorMode(const DataSetId& id, Glyphs::ColorMode mode);
     343
     344    void setGlyphsScalingMode(const DataSetId& id, Glyphs::ScalingMode mode);
     345
    269346    void setGlyphsScaleFactor(const DataSetId& id, double scale);
    270347
    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 
    277348    // Height maps
    278349
     
    283354    HeightMap *getHeightMap(const DataSetId& id);
    284355
     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
    285378    void setHeightMapVolumeSlice(const DataSetId& id, HeightMap::Axis axis, double ratio);
    286379
     
    293386    void setHeightMapContourList(const DataSetId& id, const std::vector<double>& contours);
    294387
    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 
    305388    void setHeightMapContourVisibility(const DataSetId& id, bool state);
    306389
     
    309392    void setHeightMapContourEdgeWidth(const DataSetId& id, float edgeWidth);
    310393
    311     void setHeightMapLighting(const DataSetId& id, bool state);
    312 
    313394    // LIC plots
    314395
     
    319400    LIC *getLIC(const DataSetId& id);
    320401
     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
    321424    void setLICVolumeSlice(const DataSetId& id, LIC::Axis axis, double ratio);
    322425
    323426    void setLICColorMap(const DataSetId& id, const ColorMapId& colorMapId);
    324427
    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 
    337428    // Molecules
    338429
     
    343434    Molecule *getMolecule(const DataSetId& id);
    344435
     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
    345460    void setMoleculeColorMap(const DataSetId& id, const ColorMapId& colorMapId);
    346461
    347     void setMoleculeOpacity(const DataSetId& id, double opacity);
    348 
    349462    void setMoleculeAtomScaling(const DataSetId& id, Molecule::AtomScaling scaling);
    350463
     
    353466    void setMoleculeBondVisibility(const DataSetId& id, bool state);
    354467
    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 
    367468    // PolyData Meshes
    368469
     
    373474    PolyData *getPolyData(const DataSetId& id);
    374475
     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
    375496    void setPolyDataOpacity(const DataSetId& id, double opacity);
    376497
    377498    void setPolyDataVisibility(const DataSetId& id, bool state);
    378499
    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 
    387500    void setPolyDataWireframe(const DataSetId& id, bool state);
    388501
    389     void setPolyDataLighting(const DataSetId& id, bool state);
    390502
    391503    // Color-mapped surfaces
     
    397509    PseudoColor *getPseudoColor(const DataSetId& id);
    398510
     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
    399535    void setPseudoColorColorMap(const DataSetId& id, const ColorMapId& colorMapId);
    400536
    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 
    415537    // Streamlines
    416538
     
    421543    Streamlines *getStreamlines(const DataSetId& id);
    422544
     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
    423569    void setStreamlinesSeedToRandomPoints(const DataSetId& id, int numPoints);
    424570
    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);
    429589
    430590    void setStreamlinesLength(const DataSetId& id, double length);
     
    436596    void setStreamlinesTypeToRibbons(const DataSetId& id, double width, double angle);
    437597
    438     void setStreamlinesOpacity(const DataSetId& id, double opacity);
    439 
    440     void setStreamlinesVisibility(const DataSetId& id, bool state);
    441 
    442598    void setStreamlinesSeedVisibility(const DataSetId& id, bool state);
    443599
     600    void setStreamlinesColorMode(const DataSetId& id, Streamlines::ColorMode mode);
     601
    444602    void setStreamlinesColorMap(const DataSetId& id, const ColorMapId& colorMapId);
    445603
    446604    void setStreamlinesSeedColor(const DataSetId& id, float color[3]);
    447605
    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 
    456606    // Volumes
    457607
     
    462612    Volume *getVolume(const DataSetId& id);
    463613
     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
    464636    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);
    477637
    478638private:
     
    494654    void updateRanges(bool useCumulative);
    495655
     656    void setCameraFromMatrix(vtkCamera *camera, vtkMatrix4x4 &mat);
     657
    496658    void computeDisplayToWorld(double x, double y, double z, double worldPt[4]);
    497659
     
    500662    void computeScreenWorldCoords();
    501663
    502     void storeCameraOrientation();
    503     void restoreCameraOrientation();
    504664    void initCamera();
    505665    void initAxes();
     
    512672    double _imgWorldDims[2];
    513673    double _screenWorldCoords[4];
    514     double _cameraPos[3];
    515     double _cameraFocalPoint[3];
    516     double _cameraUp[3];
     674    double _cameraOrientation[4];
    517675    double _cameraZoomRatio;
    518676    double _cameraPan[2];
  • branches/blt4/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp

    r2322 r2409  
    126126
    127127static int
     128AxisLabelsVisibleOp(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
     153static int
    128154AxisNameOp(ClientData clientData, Tcl_Interp *interp, int objc,
    129155           Tcl_Obj *const *objv)
     
    141167        Tcl_AppendResult(interp, "bad axis option \"", string,
    142168                         "\": should be axisName title", (char*)NULL);
     169        return TCL_ERROR;
     170    }
     171    return TCL_OK;
     172}
     173
     174static int
     175AxisTicksVisibleOp(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
     200static int
     201AxisTickPositionOp(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);
    143215        return TCL_ERROR;
    144216    }
     
    197269    {"flymode", 1, AxisFlyModeOp, 3, 3, "mode"},
    198270    {"grid",    1, AxisGridOp, 4, 4, "axis bool"},
     271    {"labels",  1, AxisLabelsVisibleOp, 4, 4, "axis bool"},
    199272    {"name",    1, AxisNameOp, 4, 4, "axis title"},
     273    {"tickpos", 2, AxisTickPositionOp, 3, 3, "position"},
     274    {"ticks",   2, AxisTicksVisibleOp, 4, 4, "axis bool"},
    200275    {"units",   1, AxisUnitsOp, 4, 4, "axis units"},
    201276    {"visible", 1, AxisVisibleOp, 4, 4, "axis bool"}
     
    682757
    683758static int
     759Contour2DOrientOp(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
     778static int
     779Contour2DPositionOp(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
     797static int
     798Contour2DScaleOp(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
     816static int
    684817Contour2DVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
    685818                   Tcl_Obj *const *objv)
     
    704837    {"linecolor", 5, Contour2DLineColorOp, 5, 6, "r g b ?dataSetName?"},
    705838    {"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?"},
    707843    {"visible",   1, Contour2DVisibleOp, 3, 4, "bool ?dataSetName?"}
    708844};
     
    9281064
    9291065static int
     1066Contour3DOrientOp(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
     1085static int
     1086Contour3DPositionOp(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
     1104static int
     1105Contour3DScaleOp(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
     1123static int
    9301124Contour3DVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
    9311125                   Tcl_Obj *const *objv)
     
    9631157static Rappture::CmdSpec contour3dOps[] = {
    9641158    {"add",       1, Contour3DAddOp, 4, 5, "oper value ?dataSetName?"},
    965     {"color",     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?"},
    9671161    {"delete",    1, Contour3DDeleteOp, 2, 3, "?dataSetName?"},
    9681162    {"edges",     1, Contour3DEdgeVisibilityOp, 3, 4, "bool ?dataSetName?"},
     
    9701164    {"linecolor", 5, Contour3DLineColorOp, 5, 6, "r g b ?dataSetName?"},
    9711165    {"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?"},
    9731170    {"visible",   1, Contour3DVisibleOp, 3, 4, "bool ?dataSetName?"},
    9741171    {"wireframe", 1, Contour3DWireframeOp, 3, 4, "bool ?dataSetName?"}
     
    9881185    }
    9891186    return (*proc) (clientData, interp, objc, objv);
     1187}
     1188
     1189static int
     1190DataSetActiveScalarsOp(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
     1211static int
     1212DataSetActiveVectorsOp(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;
    9901231}
    9911232
     
    11881429    {"maprange", 1, DataSetMapRangeOp, 3, 3, "value"},
    11891430    {"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?"}
    11911434};
    11921435static int nDataSetOps = NumCmdSpecs(dataSetOps);
     
    12491492
    12501493static int
     1494GlyphsColorOp(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
     1512static int
    12511513GlyphsColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc,
    12521514                 Tcl_Obj *const *objv)
     
    12581520    } else {
    12591521        g_renderer->setGlyphsColorMap("all", colorMapName);
     1522    }
     1523    return TCL_OK;
     1524}
     1525
     1526static int
     1527GlyphsColorModeOp(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);
    12601550    }
    12611551    return TCL_OK;
     
    12761566
    12771567static int
     1568GlyphsEdgeVisibilityOp(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
     1584static int
    12781585GlyphsLightingOp(ClientData clientData, Tcl_Interp *interp, int objc,
    12791586                 Tcl_Obj *const *objv)
     
    12931600
    12941601static int
     1602GlyphsLineColorOp(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
     1620static int
     1621GlyphsLineWidthOp(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
     1637static int
    12951638GlyphsOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc,
    12961639                Tcl_Obj *const *objv)
     
    13101653
    13111654static int
     1655GlyphsOrientOp(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
     1674static int
     1675GlyphsPositionOp(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
     1693static int
    13121694GlyphsScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
    13131695              Tcl_Obj *const *objv)
    13141696{
     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
     1712static int
     1713GlyphsScaleFactorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1714                    Tcl_Obj *const *objv)
     1715{
    13151716    double scale;
    13161717    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale) != TCL_OK) {
     
    13221723    } else {
    13231724        g_renderer->setGlyphsScaleFactor("all", scale);
     1725    }
     1726    return TCL_OK;
     1727}
     1728
     1729static int
     1730GlyphsScalingModeOp(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);
    13241753    }
    13251754    return TCL_OK;
     
    13831812}
    13841813
     1814static int
     1815GlyphsWireframeOp(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
    13851831static 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?"}
    13941850};
    13951851static int nGlyphsOps = NumCmdSpecs(glyphsOps);
     
    16602116    } else {
    16612117        g_renderer->setHeightMapOpacity("all", opacity);
     2118    }
     2119    return TCL_OK;
     2120}
     2121
     2122static int
     2123HeightMapOrientOp(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
     2142static int
     2143HeightMapPositionOp(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
     2161static int
     2162HeightMapScaleOp(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);
    16622176    }
    16632177    return TCL_OK;
     
    17242238    {"linecolor",    5, HeightMapLineColorOp, 5, 6, "r g b ?dataSetName?"},
    17252239    {"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?"},
    17272244    {"visible",      2, HeightMapVisibleOp, 3, 4, "bool ?dataSetName?"},
    17282245    {"volumeslice",  2, HeightMapVolumeSliceOp, 4, 5, "axis ratio ?dataSetName?"}
     
    19252442
    19262443static int
     2444LICOrientOp(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
     2463static int
     2464LICPositionOp(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
     2482static int
     2483LICScaleOp(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
     2501static int
    19272502LICVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
    19282503             Tcl_Obj *const *objv)
     
    19802555    {"linecolor",   5, LICLineColorOp, 5, 6, "r g b ?dataSetName?"},
    19812556    {"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?"},
    19832561    {"visible",     2, LICVisibleOp, 3, 4, "bool ?dataSetName?"},
    19842562    {"volumeslice", 2, LICVolumeSliceOp, 4, 5, "axis ratio ?dataSetName?"}
     
    21902768
    21912769static int
     2770MoleculeOrientOp(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
     2789static int
     2790MoleculePositionOp(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
     2808static int
     2809MoleculeScaleOp(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
     2827static int
    21922828MoleculeVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
    21932829                  Tcl_Obj *const *objv)
     
    22332869    {"linecolor",  5, MoleculeLineColorOp, 5, 6, "r g b ?dataSetName?"},
    22342870    {"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?"},
    22372876    {"visible",    1, MoleculeVisibleOp, 3, 4, "bool ?dataSetName?"},
    22382877    {"wireframe",  1, MoleculeWireframeOp, 3, 4, "bool ?dataSetName?"}
     
    23823021    } else {
    23833022        g_renderer->setPolyDataOpacity("all", opacity);
     3023    }
     3024    return TCL_OK;
     3025}
     3026
     3027static int
     3028PolyDataOrientOp(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
     3047static int
     3048PolyDataPositionOp(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
     3066static int
     3067PolyDataScaleOp(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);
    23843081    }
    23853082    return TCL_OK;
     
    24283125    {"linecolor", 5, PolyDataLineColorOp, 5, 6, "r g b ?dataSetName?"},
    24293126    {"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?"},
    24313131    {"visible",   1, PolyDataVisibleOp, 3, 4, "bool ?dataSetName?"},
    24323132    {"wireframe", 1, PolyDataWireframeOp, 3, 4, "bool ?dataSetName?"}
     
    25713271    } else {
    25723272        g_renderer->setPseudoColorOpacity("all", opacity);
     3273    }
     3274    return TCL_OK;
     3275}
     3276
     3277static int
     3278PseudoColorOrientOp(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
     3297static int
     3298PseudoColorPositionOp(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
     3316static int
     3317PseudoColorScaleOp(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);
    25733331    }
    25743332    return TCL_OK;
     
    26173375    {"linecolor", 5, PseudoColorLineColorOp, 5, 6, "r g b ?dataSetName?"},
    26183376    {"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?"},
    26203381    {"visible",   1, PseudoColorVisibleOp, 3, 4, "bool ?dataSetName?"},
    26213382    {"wireframe", 1, PseudoColorWireframeOp, 3, 4, "bool ?dataSetName?"}
     
    26793440}
    26803441
     3442static int
     3443RendererTwoSidedLightingOp(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
     3454static int
     3455RendererRenderOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3456                 Tcl_Obj *const *objv)
     3457{
     3458    g_renderer->eventuallyRender();
     3459    return TCL_OK;
     3460}
     3461
    26813462static 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, ""}
    26843467};
    26853468static int nRendererOps = NumCmdSpecs(rendererOps);
     
    27643547
    27653548static 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)
     3549StreamlinesColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3550                   Tcl_Obj *const *objv)
    28463551{
    28473552    float color[3];
     
    28533558    if (objc == 6) {
    28543559        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
     3567static int
     3568StreamlinesColorMapOp(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
     3581static int
     3582StreamlinesColorModeOp(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
     3613static int
     3614StreamlinesDeleteOp(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
     3626static int
     3627StreamlinesEdgeVisibilityOp(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
     3643static int
     3644StreamlinesLengthOp(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
     3660static int
     3661StreamlinesLightingOp(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
     3677static int
     3678StreamlinesLineColorOp(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]);
    28553689        g_renderer->setStreamlinesEdgeColor(name, color);
    28563690    } else {
     
    29033737    } else {
    29043738        g_renderer->setStreamlinesOpacity("all", opacity);
     3739    }
     3740    return TCL_OK;
     3741}
     3742
     3743static int
     3744StreamlinesOrientOp(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
     3763static int
     3764StreamlinesPositionOp(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
     3782static int
     3783StreamlinesScaleOp(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);
    29053797    }
    29063798    return TCL_OK;
     
    29473839
    29483840static int
     3841StreamlinesSeedDiskOp(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], &center[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
     3872static int
    29493873StreamlinesSeedPolygonOp(ClientData clientData, Tcl_Interp *interp, int objc,
    29503874                         Tcl_Obj *const *objv)
    29513875{
    2952     double center[3], normal[3], radius;
     3876    double center[3], normal[3], angle, radius;
    29533877    int numSides;
    29543878    for (int i = 0; i < 3; i++) {
     
    29603884        }
    29613885    }
    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
     3908static int
     3909StreamlinesSeedFilledPolygonOp(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], &center[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);
    29733945    }
    29743946    return TCL_OK;
     
    30374009static Rappture::CmdSpec streamlinesSeedOps[] = {
    30384010    {"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?"},
    30404014    {"rake",    3, StreamlinesSeedRakeOp, 10, 11, "startX startY startZ endX endY endZ numPoints ?dataSetName?"},
    30414015    {"random",  3, StreamlinesSeedRandomOp, 4, 5, "numPoints ?dataSetName?"},
     
    30984072static Rappture::CmdSpec streamlinesOps[] = {
    30994073    {"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?"},
    31014077    {"delete",    1, StreamlinesDeleteOp, 2, 3, "?dataSetName?"},
    31024078    {"edges",     1, StreamlinesEdgeVisibilityOp, 3, 4, "bool ?dataSetName?"},
     
    31064082    {"lines",     5, StreamlinesLinesOp, 2, 3, "?dataSetName?"},
    31074083    {"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?"},
    31094087    {"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?"},
    31114090    {"tubes",     1, StreamlinesTubesOp, 4, 5, "numSides radius ?dataSetName?"},
    31124091    {"visible",   1, StreamlinesVisibleOp, 3, 4, "bool ?dataSetName?"}
     
    31984177    } else {
    31994178        g_renderer->setVolumeOpacity("all", opacity);
     4179    }
     4180    return TCL_OK;
     4181}
     4182
     4183static int
     4184VolumeOrientOp(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
     4203static int
     4204VolumePositionOp(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
     4222static int
     4223VolumeScaleOp(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);
    32004237    }
    32014238    return TCL_OK;
     
    33004337    {"delete",   1, VolumeDeleteOp, 2, 3, "?dataSetName?"},
    33014338    {"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?"},
    33044344    {"visible",  1, VolumeVisibleOp, 3, 4, "bool ?dataSetName?"}
    33054345};
  • branches/blt4/packages/vizservers/vtkvis/protocol.txt

    r2323 r2409  
    1515renderer depthpeel <bool>
    1616         Set use of depth peeling algorithm for transparency
     17renderer light2side <bool>
     18         Toggle use of two-sided lighting (controls if backfaces are lit with a
     19         flipped normal)
     20renderer render
     21         Force a new image to be rendered - use for advancing animation
    1722
    1823axis color <r> <g> <b>
     
    2126     <mode> = static_edges|static_triad|outer_edges|furthest_triad|closest_triad
    2227axis grid <bool>
     28axis labels <axis> <bool>
     29     Toggle visibility of axis labels
     30     <axis> = x|y|z|all
    2331axis name <axis> <title>
     32axis tickpos <position>
     33     Set position of ticks on 3D axes (not implemented for 2D axes)
     34     <position> = inside|outside|both
     35axis ticks <axis> <bool>
     36     Toggle visibility of axis tick marks
     37     <axis> = x|y|z|all
    2438axis units <axis> <units>
    2539     Currently only supported when camera mode is not image mode
     
    2842
    2943camera get
    30        Request current camera orientation
     44       Request current camera parameters
    3145camera mode <mode>
    3246       <mode> = persp|ortho|image
     
    3751       Data is assumed to lie in XY plane (z = 0)
    3852camera 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
    4057camera reset <?all?>
    4158       Option all resets orientation/rotation as well as pan/zoom/clip range
    4259camera rotate <yaw> <pitch> <roll>
    43        Specify relative rotation in Euler angles (FIXME)
     60       Specify relative rotation in Euler angles
    4461camera 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
    4763camera 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.
    4966
    5067colormap add <colorMapName> <colorMap> <opacityMap>
     
    6885        "all"
    6986dataset opacity <val> <?datasetName?>
     87dataset scalar <scalarName> <?datasetName?>
     88        Set the active scalar field to plot
     89dataset vector <vectorName> <?datasetName?>
     90        Set the active vector field to plot
    7091dataset visible <bool> <?datasetName?>
    7192
     
    80101contour2d linewidth <val> <?datasetName?>
    81102contour2d opacity <val> <?datasetName?>
     103contour2d orient <qw> <qx> <qy> <qz> <?dataSetName?>
     104contour2d pos <x> <y> <z> <?dataSetName?>
     105contour2d scale <sx> <sy> <sz> <?dataSetName?>
    82106contour2d visible <bool> <?datasetName?>
    83107
     
    87111contour3d add contourlist <list> <?datasetName?>
    88112          list = {isoval1 isoval2 isoval3...}
    89 contour3d color r g b <?datasetName?>
     113contour3d ccolor r g b <?datasetName?>
    90114contour3d colormap <colorMapName> <?dataSetName?>
    91115contour3d delete <?datasetName?>
     
    95119contour3d linewidth <val> <?datasetName?>
    96120contour3d opacity <val> <?datasetName?>
     121contour3d orient <qw> <qx> <qy> <qz> <?dataSetName?>
     122contour3d pos <x> <y> <z> <?dataSetName?>
     123contour3d scale <sx> <sy> <sz> <?dataSetName?>
    97124contour3d visible <bool> <?datasetName?>
    98125contour3d wireframe <bool> <?datasetName?>
    99126
    100127glyphs add <?dataSetName?>
     128glyphs ccolor r g b <?datasetName?>
    101129glyphs colormap <colorMapName> <?dataSetName?>
     130glyphs 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
    102133glyphs delete <?dataSetName?>
     134glyphs edges <bool> <?datasetName?>
     135glyphs gscale <scaleFactor> <?datasetName?>
     136       Set glyph scaling factor
    103137glyphs lighting <bool> <?datasetName?>
     138glyphs linecolor <r> <g> <b> <?datasetName?>
     139glyphs linewidth <val> <?datasetName?>
    104140glyphs opacity <val> <?datasetName?>
    105 glyphs scale <scaleFactor> <?datasetName?>
     141glyphs orient <qw> <qx> <qy> <qz> <?dataSetName?>
     142glyphs pos <x> <y> <z> <?dataSetName?>
     143glyphs scale <sx> <sy> <sz> <?dataSetName?>
    106144glyphs shape <arrow|cone|cube|cylinder|dodecahedron|icosahedron|octahedron|sphere|tetrahedron> <?datasetName?>
     145glyphs 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
    107148glyphs visible <bool> <?datasetName?>
     149glyphs wireframe <bool> <?datasetName?>
    108150
    109151heightmap add numcontours <n> <?dataSetName?>
     
    123165heightmap linewidth <width> <?dataSetName?>
    124166heightmap opacity <value> <?dataSetName?>
     167heightmap orient <qw> <qx> <qy> <qz> <?dataSetName?>
     168heightmap pos <x> <y> <z> <?dataSetName?>
     169heightmap scale <sx> <sy> <sz> <?dataSetName?>
    125170heightmap visible <bool> <?dataSetName?>
    126171heightmap volumeslice axis ratio <?dataSetName?>
     
    136181lic linewidth <val> <?datasetName?>
    137182lic opacity <val> <?datasetName?>
     183lic orient <qw> <qx> <qy> <qz> <?dataSetName?>
     184lic pos <x> <y> <z> <?dataSetName?>
     185lic scale <sx> <sy> <sz> <?dataSetName?>
    138186lic visible <bool> <?datasetName?>
    139187lic volumeslice <axis> <ratio> <?datasetName?>
     
    151199molecule linewidth <val> <?datasetName?>
    152200molecule opacity <val> <?datasetName?>
    153 molecule scaleatoms <val> <?dataSetName?>
     201molecule orient <qw> <qx> <qy> <qz> <?dataSetName?>
     202molecule pos <x> <y> <z> <?dataSetName?>
     203molecule rscale <val> <?dataSetName?>
     204         Atom radius scaling
    154205         val = van_der_walls|covalent|atomic|none
     206molecule scale <sx> <sy> <sz> <?dataSetName?>
    155207molecule visible <bool> <?datasetName?>
    156208molecule wireframe <bool> <?datasetName?>
     
    164216polydata linewidth <val> <?datasetName?>
    165217polydata opacity <val> <?datasetName?>
     218polydata orient <qw> <qx> <qy> <qz> <?dataSetName?>
     219polydata pos <x> <y> <z> <?dataSetName?>
     220polydata scale <sx> <sy> <sz> <?dataSetName?>
    166221polydata visible <bool> <?datasetName?>
    167222polydata wireframe <bool> <?datasetName?>
     
    175230pseudocolor linewidth <val> <?datasetName?>
    176231pseudocolor opacity <val> <?datasetName?>
     232pseudocolor orient <qw> <qx> <qy> <qz> <?dataSetName?>
     233pseudocolor pos <x> <y> <z> <?dataSetName?>
     234pseudocolor scale <sx> <sy> <sz> <?dataSetName?>
    177235pseudocolor visible <bool> <?datasetName?>
    178236pseudocolor wireframe <bool> <?datasetName?>
    179237
    180238streamlines add <?datasetName?>
     239streamlines ccolor <r> <g> <b> <?datasetName?>
     240            Set the constant color of streamlines used for color mode 'ccolor'
    181241streamlines colormap <colormapName> <?datasetName?>
    182242            Colormap used to color streamlines/tubes/ribbons by vector magnitude
     243streamlines 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.
    183249streamlines delete <?datasetName?>
    184250streamlines edges <bool> <?datasetName?>
     
    193259streamlines linewidth <val> <?datasetName?>
    194260streamlines opacity <val> <?datasetName?>
     261streamlines orient <qw> <qx> <qy> <qz> <?dataSetName?>
     262streamlines pos <x> <y> <z> <?dataSetName?>
    195263streamlines ribbons <width> <angle> <?datasetName?>
    196264            Set rendering type to ribbons, width is minimum half-width, angle is
    197265            degrees offset from normal orientation
     266streamlines scale <sx> <sy> <sz> <?dataSetName?>
    198267streamlines seed color <r> <g> <b> <?datasetName?>
    199 streamlines seed polygon <centerX> <centerY> <centerZ> <normalX> <normalY> <normalZ> <radius> <numSides> <?dataSetName?>
     268streamlines 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
     271streamlines 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
     274streamlines seed polygon <centerX> <centerY> <centerZ> <normalX> <normalY> <normalZ> <angle> <radius> <numSides> <?dataSetName?>
     275            Create seed points from vertices of a regular n-sided polygon
    200276streamlines seed rake <startX> <startY> <startZ> <endX> <endY> <endZ> <numPoints> <?datasetName?>
    201277streamlines seed random <numPoints> <?datasetName?>
     
    210286volume delete <?datasetName?>
    211287volume lighting <bool> <?datasetName?>
     288volume orient <qw> <qx> <qy> <qz> <?dataSetName?>
     289volume pos <x> <y> <z> <?dataSetName?>
     290volume scale <sx> <sy> <sz> <?dataSetName?>
    212291volume shading ambient <coeff> <?datasetName?>
    213292volume shading diffuse <coeff> <?datasetName?>
Note: See TracChangeset for help on using the changeset viewer.