Changeset 2688 for trunk/packages


Ignore:
Timestamp:
Nov 16, 2011, 12:56:37 PM (13 years ago)
Author:
gah
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/pymolproxy/pymolproxy2.c

    r2637 r2688  
    9494static FILE *frecord;
    9595static int recording = FALSE;
     96static int pymolIsAlive = TRUE;
    9697
    9798#define WANT_DEBUG      0
     
    723724{
    724725    PymolProxy *p = clientData;
    725     int i, push, defer, state, size;
     726    int i, push, defer, bool, size;
    726727    const char *model;
    727728
     
    729730    model = "all";
    730731    size = 14;
    731     state = TRUE;
     732    bool = TRUE;
    732733    push = defer = FALSE;
    733734    for(i = 1; i < argc; i++) {
     
    744745                size = atoi(argv[i]);
    745746            }
    746         } else if (Tcl_GetBoolean(interp, argv[i], &state) != TCL_OK) {
     747        } else if (Tcl_GetBoolean(interp, argv[i], &bool) != TCL_OK) {
    747748            return TCL_ERROR;
    748749        }
     
    757758    SendCmd(p, "set label_color,white,%s\nset label_size,%d,%s\n",
    758759            model, size, model);
    759     if (state) {
     760    if (bool) {
    760761        SendCmd(p, "label %s,\"%%s%%s\" %% (ID,name)\n", model);
    761762    } else {
     
    843844        p->flags |= FORCE_UPDATE;
    844845    }
     846    p->cacheId = state;
    845847
    846848    /* Does not invalidate cache? */
     
    984986    /* Force pymol to update the current scene. */
    985987    SendCmd(p, "refresh\n");
    986 #ifdef notdef
    987     SendCmd(p, "png \"- %d %d %d\"\n", p->frame, p->cacheId, p->rockOffset);
    988 #endif
    989     SendCmd(p, "png -\n");
     988    /* This is a hack. We're encoding the filename to pass extra information
     989     * to the MyPNGWrite routine inside of pymol. Ideally these would be
     990     * parameters of a new "molvispng" command that would be passed all the
     991     * way through to MyPNGWrite.
     992     *
     993     * The extra information is contained in the token we get from the
     994     * molvisviewer client, the frame number, and rock offset. */
     995    SendCmd(p, "png -:%d:%d:%d\n", p->cacheId, p->frame, p->rockOffset);
    990996    return p->status;
    991997}
     
    10011007    /* Force pymol to update the current scene. */
    10021008    SendCmd(p, "refresh\n");
    1003 #ifdef notdef
    1004     SendCmd(p, "png \"- %d %d %d\",format=1\n", p->frame, p->cacheId,
     1009    /* This is a hack. We're encoding the filename to pass extra information
     1010     * to the MyPNGWrite routine inside of pymol. Ideally these would be
     1011     * parameters of a new "molvispng" command that would be passed all the
     1012     * way through to MyPNGWrite.
     1013     *
     1014     * The extra information is contained in the token we get from the
     1015     * molvisviewer client, the frame number, and rock offset. */
     1016    SendCmd(p, "png -:%d:%d:%d,format=1\n", p->cacheId, p->frame,
    10051017            p->rockOffset);
    1006 #endif
    1007     SendCmd(p, "png -,format=1\n");
    10081018    p->flags &= ~(UPDATE_PENDING|FORCE_UPDATE);
    10091019    return p->status;
     
    10421052        SendCmd(p, "bg_color %s\nrefresh\n", bgcolor);
    10431053    }
    1044     SendCmd(p, "ray %d,%d\n", width, height);
    1045 #ifdef notdef
    1046     SendCmd(p, "png \"- print 0 0\",dpi=300\nbg_color black\n");
    1047 #endif
    1048     SendCmd(p, "png -,dpi=300\nbg_color black\n");
     1054    /* This is a hack. We're encoding the filename to pass extra information
     1055     * to the MyPNGWrite routine inside of pymol. Ideally these would be
     1056     * parameters of a new "molvispng" command that would be passed all the
     1057     * way through to MyPNGWrite. 
     1058     *
     1059     * The extra information is contained in the token we get from the
     1060     * molvisviewer client, the frame number, and rock offset.
     1061     */
     1062    SendCmd(p, "png -:%s:0:0,width=%d,height=%d,ray=1,dpi=300\n",
     1063            token, width, height);
     1064    SendCmd(p, "bg_color black\n");
    10491065    return p->status;
    10501066}
     
    18911907{
    18921908    ERROR("pymol (%d) died unexpectedly", stats.pid);
     1909    pymolIsAlive = FALSE;
    18931910    /*DoExit(1);*/
    18941911}
     
    19872004        exit(-1);
    19882005    } else {
     2006        pymolIsAlive = TRUE;
    19892007        signal(SIGCHLD, ChildHandler);
    19902008    }
     
    21042122#endif
    21052123    Tcl_DStringInit(&command);
    2106     for (;;) {
     2124    while (pymolIsAlive) {
    21072125        tvPtr = NULL;
    21082126#if READ_DEBUG
    21092127        DEBUG("Start I/O set");
    21102128#endif
    2111         while (WaitForNextLine(&p->client, tvPtr)) {
     2129        while ((pymolIsAlive) && (WaitForNextLine(&p->client, tvPtr))) {
    21122130            size_t numBytes;
    21132131            const char *line;
     
    21822200#endif
    21832201    list.headPtr = list.tailPtr = NULL;
    2184     for (;;) {
     2202    while (pymolIsAlive) {
    21852203        while (WaitForNextLine(bp, NULL)) {
    21862204            Image *imgPtr;
     
    22002218                return NULL;
    22012219            }
    2202             if (strncmp(line, "ppm image follows: ", 16) != 0) {
     2220#if WRITE_DEBUG
     2221            DEBUG("Writer: line found is %s\n", line);
     2222#endif
     2223            if (strncmp(line, "image follows: ", 15) != 0) {
    22032224                continue;
    22042225            }
    2205 #ifdef notdef
    22062226            if (sscanf(line, "image follows: %d %s %d %d\n", &numBytes, cacheId,
    22072227                       &frameNum, &rockOffset) != 4) {
     
    22102230                return NULL;
    22112231            }
    2212 #endif
    2213             if (sscanf(line, "ppm image follows: %d\n", &numBytes) != 1) {
    2214                 ERROR("can't get # bytes from \"%s\"", line);
    2215                 DEBUG("Leaving Writer thread");
    2216                 return NULL;
    2217             }
    22182232#if WRITE_DEBUG
    22192233            DEBUG("found image line \"%.*s\"", numBytes, line);
    22202234#endif
    2221             strcpy(cacheId, "0");
    2222             frameNum = 0;
    2223             rockOffset = 0;
    2224             sprintf(header, "nv>image %d %s %d %d\n", numBytes, cacheId, frameNum,
    2225                     rockOffset);
     2235            sprintf(header, "nv>image %d %s %d %d\n", numBytes, cacheId,
     2236                    frameNum, rockOffset);
    22262237            hdrLength = strlen(header);
    22272238#if WRITE_DEBUG
    2228             DEBUG("Queueing image numBytes=%d frameNum=%d, rockOffset=%d size=%d\n", numBytes, frameNum, rockOffset, numBytes + hdrLength);
     2239            DEBUG("Queueing image numBytes=%d cacheId=%s, frameNum=%d, rockOffset=%d size=%d\n", numBytes, cacheId, frameNum, rockOffset, numBytes + hdrLength);
    22292240#endif
    22302241            imgPtr = NewImage(&list, numBytes + hdrLength);
Note: See TracChangeset for help on using the changeset viewer.