Changeset 2615 for trunk/packages/vizservers/pymolproxy/pymolproxy.c
- Timestamp:
- Oct 12, 2011, 2:43:48 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/pymolproxy/pymolproxy.c
r2614 r2615 10 10 * server. Responses from the pymol server are translated into Tcl 11 11 * commands and send to the molvisviewer widget. For example, resulting 12 * image rendered offscreen is returned as BMP-formatted image data.12 * image rendered offscreen is returned as ppm-formatted image data. 13 13 * 14 14 * Copyright (c) 2004-2006 Purdue Research Foundation … … 846 846 SetStickRadius(proxyPtr); 847 847 } 848 }849 850 static int851 BmpCmd(ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])852 {853 char buffer[BUFSIZ];854 unsigned int nBytes=0;855 PymolProxy *proxyPtr = clientData;856 Image *imgPtr;857 size_t length;858 clear_error(proxyPtr);859 860 if (proxyPtr->flags & INVALIDATE_CACHE)861 proxyPtr->cacheId++;862 863 proxyPtr->flags &= ~(UPDATE_PENDING|FORCE_UPDATE|INVALIDATE_CACHE);864 865 /* Force pymol to update the current scene. */866 UpdateSettings(proxyPtr);867 868 Pymol(proxyPtr, "refresh\n");869 Pymol(proxyPtr, "bmp -\n");870 if (Expect(proxyPtr, "bmp image follows: ", buffer, BUFSIZ) != TCL_OK) {871 return TCL_ERROR;872 }873 if (sscanf(buffer, "bmp image follows: %d\n", &nBytes) != 1) {874 Tcl_AppendResult(interp, "can't get # bytes from \"", buffer, "\"",875 (char *)NULL);876 return TCL_ERROR;877 }878 sprintf(buffer, "nv>image %d %d %d %d\n", nBytes, proxyPtr->cacheId,879 proxyPtr->frame, proxyPtr->rockOffset);880 881 length = strlen(buffer);882 imgPtr = NewImage(proxyPtr, nBytes + length);883 strcpy(imgPtr->data, buffer);884 if (ReadFollowingData(&proxyPtr->server, imgPtr->data + length, nBytes)885 != BUFFER_OK) {886 ERROR("can't read %d bytes for \"image follows\" buffer: %s", nBytes,887 strerror(errno));888 return TCL_ERROR;889 }890 stats.nFrames++;891 stats.nBytes += nBytes;892 return proxyPtr->status;893 848 } 894 849 … … 2112 2067 proxy.interp = interp; 2113 2068 2114 Tcl_CreateCommand(interp, "bmp", BmpCmd, &proxy, NULL);2115 2069 Tcl_CreateCommand(interp, "cartoon", CartoonCmd, &proxy, NULL); 2116 2070 Tcl_CreateCommand(interp, "cartoontrace", CartoonTraceCmd, &proxy, NULL);
Note: See TracChangeset
for help on using the changeset viewer.