Changeset 1807 for branches


Ignore:
Timestamp:
Jul 14, 2010, 3:54:10 PM (14 years ago)
Author:
gah
Message:
 
Location:
branches/blt4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/blt4/gui/scripts/molvisviewer.tcl

    r1795 r1807  
    5353    private variable _obj2models;       # array containing list of models
    5454                                        # for each data object.
    55 
     55    private variable _waitForImage 0
    5656    private variable _view
    5757    private variable _click
     
    678678set count 0
    679679itcl::body Rappture::MolvisViewer::ReceiveImage { size cacheid frame rock } {
     680    set _waitForImage 0;                # Turn off wait loop.
    680681    set tag "$frame,$rock"
    681682    global count
     
    769770            }
    770771            if {"" != $data1} {
     772                # Save the PDB data in case the user wants to later save it.
    771773                set _pdbdata $data1
    772                 SendCmd "loadpdb -defer \"$data1\" $model $state"
     774                set nBytes [string length $data1]
     775
     776                # We know we're buffered here, so append the "loadpdb" command
     777                # with the data payload immediately afterwards.
     778                append _outbuf "loadpdb -defer $nBytes $model $state\n"
     779                append _outbuf $data1
    773780                set _dataobjs($model-$state)  1
    774781            }
     
    776783            set data2 [$dataobj get components.molecule.pdb]
    777784            if {"" != $data2} {
     785                # Save the PDB data in case the user wants to later save it.
    778786                set _pdbdata $data2
    779                 SendCmd "loadpdb -defer \"$data2\" $model $state"
     787                set nBytes [string length $data2]
     788
     789                # We know we're buffered here, so append the "loadpdb" command
     790                # with the data payload immediately afterwards.
     791                append _outbuf "loadpdb -defer $nBytes $model $state\n"
     792                append _outbuf $data2
    780793                set _dataobjs($model-$state)  1
    781794            }
     
    820833                }
    821834                if {"" != $data3} {
     835                    # Save the PDB data in case the user wants to later save it.
    822836                    set _pdbdata $data3
    823                     SendCmd "loadpdb -defer \"$data3\" $model $state"
    824                     set _dataobjs($model-$state) 1
     837                    set nBytes [string length $data3]
     838
     839                    # We know we're buffered here, so append the "loadpdb"
     840                    # command with the data payload immediately afterwards.
     841                    append _outbuf "loadpdb -defer $nBytes $model $state\n"
     842                    append _outbuf $data3
    825843                }
     844                set _dataobjs($model-$state) 1
    826845            }
    827846        }
     
    934953    if { $flush } {
    935954        SendCmd "bmp";                  # Flush the results.
     955        set _waitForImage 1
    936956    }
    937957    set _buffering 0;                   # Turn off buffering.
     
    945965    blt::busy release $itk_component(hull)
    946966
     967    if { $_waitForImage } {
     968        tkwait variable [itcl::scope _waitForImage]
     969    }
    947970    debug "exiting rebuild"
    948971}
     
    14411464        }
    14421465    }
     1466    update idletasks
     1467    update
    14431468}
    14441469
  • branches/blt4/packages/vizservers/pymolproxy/pymolproxy.c

    r1719 r1807  
    10381038}
    10391039
     1040/*
     1041 * LoadPDBCmd --
     1042 *
     1043 *      Load a PDB file into pymol.  There is no good way to load PDB data
     1044 *      into pymol without using a file.  This causes problems in that we
     1045 *      don't know when pymol is done with the file.  So there's always
     1046 *      a bit of mess left around. We use the same file for every file
     1047 *      so there's a chance that pymol is still using a file while we're
     1048 *      overwriting it. 
     1049 *
     1050 *      The command expects the number of bytes in the pdb data, the
     1051 *      name, and the state.
     1052 */
    10401053static int
    10411054LoadPDBCmd(ClientData clientData, Tcl_Interp *interp, int argc,
     
    10461059    int state = 1;
    10471060    int i, defer = 0, push = 0, varg = 1;
    1048    
     1061    int nBytes;
     1062
    10491063    if (proxyPtr == NULL)
    10501064        return TCL_ERROR;
    10511065    clear_error(proxyPtr);
    1052     pdbdata = name = NULL;      /* Suppress compiler warning. */
     1066    pdbdata = name = NULL;              /* Suppress compiler warning. */
     1067    nBytes = 0;                         /* Suppress compiler warning. */
    10531068    for(i = 1; i < argc; i++) {
    10541069        if ( strcmp(argv[i],"-defer") == 0 )
     
    10571072            push = 1;
    10581073        else if (varg == 1) {
    1059             pdbdata = argv[i];
     1074            nBytes = atoi(argv[i]);
    10601075            varg++;
    10611076        } else if (varg == 2) {
     
    10671082        }
    10681083    }
    1069    
    10701084    if (!defer || push) {
    10711085        proxyPtr->flags |= UPDATE_PENDING;
     
    10801094        char fileName[200];
    10811095        FILE *f;
    1082         size_t nBytes;
    10831096        ssize_t nWritten;
    1084 
     1097        char *data;
     1098
     1099        data = malloc(sizeof(char) * nBytes);
     1100        if (data == NULL) {
     1101            trace("can't allocate %d bytes for \"pdbdata\" buffer", nBytes);
     1102            return  TCL_ERROR;
     1103        }
     1104        if (GetBytes(&proxyPtr->client, data, nBytes) != BUFFER_OK) {
     1105            trace("can't read %d bytes for \"pdbdata\" buffer", nBytes);
     1106            return  TCL_ERROR;
     1107        }
    10851108        sprintf(fileName, "/tmp/pymol%d.pdb", getpid());
    10861109        f = fopen(fileName, "w");
     
    10891112            perror("pymolproxy");
    10901113        }
    1091         nBytes = strlen(pdbdata);
    1092         nWritten = fwrite(pdbdata, sizeof(char), nBytes, f);
     1114        nWritten = fwrite(data, sizeof(char), nBytes, f);
    10931115        if (nBytes != nWritten) {
    10941116            trace("short write %d wanted %d bytes", nWritten, nBytes);
     
    18441866
    18451867    child = fork();
    1846        
    18471868    if (child < 0) {
    18481869        fprintf(stderr, "can't fork process: %s\n", strerror(errno));
     
    19431964    } else if (status == 0) {
    19441965        trace("attempting to signal (SIGTERM) pymol server.");
    1945         kill(-child, SIGTERM); // kill process group
     1966        kill(-child, SIGTERM);          // Kill process group
    19461967        alarm(5);
    19471968        status = waitpid(child, &result, 0);
     
    19501971        while ((status == -1) && (errno == EINTR)) {
    19511972            trace("Attempting to signal (SIGKILL) pymol server.");
    1952             kill(-child, SIGKILL); // kill process group
     1973            kill(-child, SIGKILL);      // Kill process group
    19531974            alarm(10);
    19541975            status = waitpid(child, &result, 0);
Note: See TracChangeset for help on using the changeset viewer.