Changeset 700 for trunk/gui


Ignore:
Timestamp:
May 4, 2007 1:50:53 PM (17 years ago)
Author:
nkissebe
Message:

initial modifications to pyMol for remote visualization server support

Location:
trunk/gui/vizservers/pymol
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/vizservers/pymol/layer0/MyPNG.c

    r699 r700  
    1414Z* -------------------------------------------------------------------
    1515*/
     16#define _HAVE_LIBPNG /* _HAVE_LIBPNG not integrated into autotools build *NJK* */
    1617
    1718#ifdef _HAVE_LIBPNG
     
    3940
    4041
     42/* Persistent image capture buffer *NJK* */
     43/* we make image buffer a pymol global to reduce time spent */
     44/* allocating and reallocating memory for image captures    */
     45struct _CImage {
     46    void *data;
     47    int   allocated;
     48    int   used;
     49};
     50
     51int ImageInit(PyMOLGlobals *G)
     52{
     53   register CImage *I=NULL;
     54   if( (I=(G->Image=Calloc(CImage,1)))) {
     55 
     56     UtilZeroMem(I,sizeof(CImage));
     57     I->data = NULL;
     58         I->used = 0;
     59         I->allocated = 0;
     60     return 1;
     61   } else {
     62     return 0;
     63   }
     64}
     65
     66/* PNG stdout support *NJK */
     67/* add ability to write PNG files to standard output        */
     68/* we have to write to memory first so we can inform client */
     69/* how much data is going to be sent                        */
     70
     71static void
     72user_write_data(png_structp png_ptr, png_bytep buf, png_size_t length)
     73{
     74    voidp write_io_ptr = png_get_io_ptr(png_ptr);
     75    struct _CImage *data = write_io_ptr;
     76    int available;
     77        int needed;
     78        void *newdata;
     79
     80        available = data->allocated - data->used;
     81
     82        if (length > available) {
     83                needed = length - available;
     84
     85                if (needed < 32768)
     86                        needed = 32768;
     87
     88                newdata = realloc(data->data, data->allocated + needed);
     89
     90                if (newdata != NULL) {
     91                   data->data = newdata;
     92                   data->allocated += needed;
     93                }
     94                else
     95                    return;
     96        }
     97
     98        memcpy((unsigned char *)data->data + data->used, buf, length);
     99
     100        data->used += length;
     101    return;
     102}
     103
     104static void
     105user_flush_data(png_structp png_ptr)
     106{
     107        return;
     108}
     109
    41110int MyPNGWrite(PyMOLGlobals *G,char *file_name,unsigned char *p,
    42111               unsigned int width,unsigned int height,float dpi)
     
    44113#ifdef _HAVE_LIBPNG
    45114
    46    FILE *fp;
     115   FILE *fp = 0; /* PNG stdout support *NJK* */
    47116   png_structp png_ptr;
    48117   png_infop info_ptr;
     
    56125
    57126   /* open the file */
    58    fp = fopen(file_name, "wb");
    59    if (fp == NULL) {
    60      return 0;
    61    } else if(feof(fp)) {
    62      fclose(fp);
    63          return 0;
     127   if (strcmp(file_name,"-.png") != 0) { /* PNG stdout support *NJK* */
     128      fp = fopen(file_name, "wb");
     129      if (fp == NULL) {
     130        return 0;
     131      } else if(feof(fp)) {
     132        fclose(fp);
     133            return 0;
     134      }
    64135   }
    65136   /* Create and initialize the png_struct with the desired error handler
     
    73144   if (png_ptr == NULL)
    74145   {
    75       fclose(fp);
     146      if (fp != NULL)  /* PNG stdout support *NJK* */
     147         fclose(fp);
    76148      return 0;
    77149   }
     
    81153   if (info_ptr == NULL)
    82154   {
    83       fclose(fp);
     155      if (fp != NULL)  /* PNG stdout support *NJK* */
     156          fclose(fp);
    84157      png_destroy_write_struct(&png_ptr,  (png_infopp)NULL);
    85158      return 0;
     
    92165   {
    93166      /* If we get here, we had a problem reading the file */
    94       fclose(fp);
     167      if (fp != NULL)  /* PNG stdout support *NJK* */
     168         fclose(fp);
    95169      png_destroy_write_struct(&png_ptr,  (png_infopp)NULL);
    96170      return 0;
     
    98172
    99173   /* set up the output control if you are using standard C streams */
    100    png_init_io(png_ptr, fp);
     174   if (fp != NULL) /* PNG stdout support *NJK* */
     175      png_init_io(png_ptr, fp);
     176   else {
     177      G->Image->used = 0;
     178      png_set_write_fn(png_ptr, G->Image, user_write_data, user_flush_data);
     179   }
    101180
    102181   /* Set the image information here.  Width and height are up to 2^31,
     
    115194     png_set_pHYs(png_ptr, info_ptr, dots_per_meter, dots_per_meter, PNG_RESOLUTION_METER);
    116195   }
     196   png_set_compression_level(png_ptr,1); /* PNG stdout support *NJK* */
    117197
    118198   png_set_gamma(png_ptr, SettingGet(G,cSetting_png_screen_gamma),
     
    139219
    140220   /* close the file */
    141    fclose(fp);
     221   if (fp != NULL) /* PNG stdout support *NJK* */
     222       fclose(fp);
     223   else {
     224       /* Sample counting patch *NJK */
     225       fprintf(stdout, "image follows: %d %d\n", G->Image->used, PyMOLEndPerf(G->GLQueryId));
     226       PyMOLStartPerf(G->GLQueryId);
     227       fwrite(G->Image->data,1,G->Image->used,stdout);
     228       fflush(stdout);
     229       G->Image->used = 0;
     230   }
    142231
    143232        mfree(row_pointers);
     
    321410} /* end of source */
    322411
    323 
    324 
    325 
    326 
    327 
    328 
    329 
    330 
     412/* BMP save image support *NJK* */
     413void
     414bmp_header_add_int(unsigned char* header, unsigned int pos, unsigned int data)
     415{
     416  header[pos++] = data & 0xff;
     417  header[pos++] = (data >> 8) & 0xff;
     418  header[pos++] = (data >> 16) & 0xff;
     419  header[pos++] = (data >> 24) & 0xff;
     420}
     421 
     422void
     423bmp_header_add_short(unsigned char* header, unsigned int pos, unsigned short data)
     424{
     425  header[pos++] = data & 0xff;
     426  header[pos++] = (data >> 8) & 0xff;
     427}
     428 
     429int MyBMPWrite(PyMOLGlobals *G,char *bmp,unsigned char *save_image,int width,int height,float dpi)
     430{
     431  unsigned char header[54];
     432  int pos = 0;
     433  int pad = 0;
     434  int fsize = 0;
     435  int row = 0;
     436  int col = 0;
     437  unsigned char *scr;
     438  unsigned char *src = save_image;
     439  unsigned char tmp;
     440  struct _CImage *data = G->Image;
     441 
     442  if ((3 * width) % 4 > 0)
     443    pad = 4 - ((3 * width) % 4);
     444   
     445  header[pos++] = 'B';
     446  header[pos++] = 'M';
     447   
     448  /* file size in bytes */
     449  fsize = (3 * width + pad) * height + sizeof(header);
     450  bmp_header_add_int(header,pos,fsize);
     451  pos+=4;
     452 
     453  /* reserved value (must be 0) */
     454  bmp_header_add_int(header, pos, 0);
     455  pos+=4;
     456 
     457  /* offset in bytes to start of bitmap data */
     458  bmp_header_add_int(header, pos, sizeof(header));
     459  pos+=4;
     460 
     461  /* size of the BITMAPINFOHEADER */
     462  bmp_header_add_int(header, pos, 40);
     463  pos+=4;
     464
     465  /* width of the image in pixels */
     466  bmp_header_add_int(header, pos, width);
     467  pos+=4;
     468
     469  /* height of the image in pixels */
     470  bmp_header_add_int(header, pos, height);
     471  pos+=4;
     472
     473  /* 1 plane */
     474  bmp_header_add_short(header, pos, 1);
     475  pos+=2;
     476
     477  /* 24 bits/pixel */
     478  bmp_header_add_short(header, pos, 24);
     479  pos+=2;
     480
     481  /* no compression */
     482  /* size of image for compression */
     483
     484  bmp_header_add_int(header, pos, 0);
     485  pos+=4;
     486  bmp_header_add_int(header, pos, 0);
     487  pos+=4;
     488
     489  /* x pixels per meter */
     490  /* y pixels per meter */
     491  bmp_header_add_int(header, pos, 0);
     492  pos+=4;
     493  bmp_header_add_int(header, pos, 0);
     494  pos+=4;
     495
     496  /* number of colors used (0 = compute from bits/pixel) */
     497  /* number of important colors (0 = all colors important) */
     498  bmp_header_add_int(header, pos, 0);
     499  pos+=4;
     500  bmp_header_add_int(header, pos, 0);
     501  pos+=4;
     502
     503  if (data->allocated < fsize) {
     504        char *newdata;
     505
     506        newdata = realloc(data->data, fsize);
     507
     508        if (newdata) {
     509                data->data = newdata;
     510                data->allocated = fsize;
     511        }
     512  }
     513
     514  if (data->allocated < fsize)
     515      return(0);
     516
     517  scr = data->data;
     518
     519  for (row=0; row < height; row++) {
     520    for (col=0; col < width; col++) {
     521      tmp = src[0];
     522      scr[0] = src[2];
     523      scr[1] = src[1];
     524      scr[2] = tmp;
     525      scr += 3;
     526      src += 4;
     527    }
     528    scr += pad;  /* skip over padding already in screen data */
     529  }
     530
     531  if (strcmp(bmp,"-.bmp") == 0) {
     532    /* Sample counting patch *NJK* */
     533    fprintf(stdout,"image follows: %d %d\n",fsize, PyMOLEndPerf(G->GLQueryId));
     534    PyMOLStartPerf(G->GLQueryId);
     535    fwrite(header,1,54,stdout);
     536    fwrite(data->data,1,fsize-sizeof(header), stdout);
     537    fflush(stdout);
     538  }
     539  else {
     540    FILE *fp;
     541
     542    fp = fopen(bmp,"wb");
     543    fwrite(header,1,54, fp);
     544    fwrite(data->data,1,fsize-sizeof(header), fp);
     545    fflush(fp);
     546    fclose(fp);
     547  }
     548
     549  return(1);
     550}
     551
  • trunk/gui/vizservers/pymol/layer0/PyMOLGlobals.h

    r699 r700  
    5555typedef struct _CGO CGO;
    5656typedef struct _CPlugIOManager CPlugIOManager;
     57typedef struct _CImage CImage; /* Persistent image capture buffer *NJK* */
    5758
    5859#ifndef _PYMOL_NOPY
     
    150151
    151152  int DragDirtyFlag; /* do we need an extra callback to handle a mouse drag? */
     153  int CmdPipe[2]; /* Sleep Interruption Patch *NJK* */
     154  CImage *Image;  /* Persistent image capture buffer *NJK* */
     155  int GLQueryId;  /* Sample counting patch *NJK* */
    152156
    153157
  • trunk/gui/vizservers/pymol/layer0/os_gl.c

    r699 r700  
    33
    44#include<stdio.h>
     5
     6/* Sample counting patch *NJK* */
     7void PyMOLInitPerf(GLsizei n, GLuint *id)
     8{
     9    *id = 0;
     10
     11    glGenQueriesARB(1, id);
     12}
     13
     14void PyMOLStartPerf(GLuint id)
     15{
     16    glBeginQueryARB(GL_SAMPLES_PASSED_ARB, id);
     17}
     18
     19unsigned int PyMOLEndPerf(GLuint id)
     20{
     21    GLuint count = 0;
     22
     23    glEndQueryARB(GL_SAMPLES_PASSED_ARB);
     24    glGetQueryObjectuivARB(id, GL_QUERY_RESULT_ARB, &count);
     25
     26        return(count);
     27}
    528
    629void PyMOLReadPixels(GLint x,
  • trunk/gui/vizservers/pymol/layer1/Ortho.c

    r699 r700  
    19171917void OrthoCommandIn(PyMOLGlobals *G,char *buffer)
    19181918{
     1919  char c = 1; /* Sleep Interruption Patch *NJK* */
    19191920  register COrtho *I=G->Ortho;
    19201921  if(I->cmds)
    19211922        QueueStrIn(I->cmds,buffer);
     1923  write(G->CmdPipe[1],&c,1); /* Sleep Interruption Patch *NJK* */
    19221924}
    19231925/*========================================================================*/
  • trunk/gui/vizservers/pymol/layer1/P.c

    r699 r700  
    298298{ /* can only be called by the glut process */
    299299#ifndef WIN32
     300  fd_set fds; /* Sleep Interruption Patch *NJK* */
    300301  struct timeval tv;
    301302  PRINTFD(G,FB_Threads)
     
    304305  tv.tv_sec=0;
    305306  tv.tv_usec=usec;
    306   select(0,NULL,NULL,NULL,&tv);
     307  /* Sleep Interruption Patch *NJK* */
     308  FD_ZERO(&fds);
     309  FD_SET(TempPyMOLGlobals->CmdPipe[0],&fds);
     310  select(TempPyMOLGlobals->CmdPipe[0]+1,&fds,NULL,NULL,&tv);
     311  if (FD_ISSET(TempPyMOLGlobals->CmdPipe[0],&fds)) {
     312    char c;
     313    read(TempPyMOLGlobals->CmdPipe[0],&c,1);
     314  }
    307315  PRINTFD(G,FB_Threads)
    308316    " PSleep-DEBUG: nap over.\n"
  • trunk/gui/vizservers/pymol/layer1/Scene.c

    r699 r700  
    14961496  }
    14971497  SceneImageFinish(G,image); 
     1498}
     1499
     1500/* BMP save image support *NJK* */
     1501void SceneBMP(PyMOLGlobals *G,char *bmp,float dpi,int quiet)
     1502{
     1503  register CScene *I=G->Scene;
     1504
     1505  GLvoid *image = SceneImagePrepare(G);
     1506  if(image && I->Image) {
     1507    int width = I->Image->width;
     1508    int height = I->Image->height;
     1509    unsigned char *save_image = image;
     1510
     1511    if((image==I->Image->data) && I->Image->stereo) {
     1512      width = I->Image->width;
     1513      save_image = Alloc(unsigned char, I->Image->size*2);
     1514      interlace((unsigned int*)save_image,(unsigned int*)I->Image->data,width,height);
     1515      width *= 2;
     1516    }
     1517    if(dpi<0.0F) dpi = SettingGetGlobal_f(G,cSetting_image_dots_per_inch);
     1518    if(MyBMPWrite(G,bmp,save_image,width,height,dpi)) {
     1519      if(!quiet) {
     1520        PRINTFB(G,FB_Scene,FB_Actions)
     1521          " SceneBMP: wrote %dx%d pixel image to file \"%s\".\n",
     1522          width,I->Image->height,bmp
     1523          ENDFB(G);
     1524      }
     1525    } else {
     1526      PRINTFB(G,FB_Scene,FB_Errors)
     1527        " SceneBMP-Error: error writing \"%s\"! Please check directory...\n",
     1528        bmp
     1529        ENDFB(G);
     1530    }
     1531
     1532    if(save_image && (save_image!=image))
     1533      FreeP(save_image);
     1534  }
     1535  SceneImageFinish(G,image);
    14981536}
    14991537/*========================================================================*/
     
    47994837  return 1;
    48004838}
     4839/* BMP save image support *NJK* */
     4840static int SceneDeferredBMPImage(DeferredImage *di)
     4841{
     4842  PyMOLGlobals *G=di->G;
     4843  SceneMakeSizedImage(G,di->width, di->height,di->antialias);
     4844  if(di->filename) {
     4845    SceneBMP(G,di->filename, di->dpi, di->quiet);
     4846    FreeP(di->filename);
     4847  }
     4848  return 1;
     4849}
    48014850static int SceneDeferredImage(DeferredImage *di)
    48024851{
     
    48074856    FreeP(di->filename);
    48084857  }
     4858  return 1;
     4859}
     4860/* BMP save image support *NJK* */
     4861int SceneDeferBMPImage(PyMOLGlobals *G,int width, int height,
     4862                  char *filename, int antialias, float dpi, int quiet)
     4863{
     4864  DeferredImage *di = Calloc(DeferredImage,1);
     4865  if(di) {
     4866    DeferredInit(G,&di->deferred);
     4867    di->G = G;
     4868    di->width = width;
     4869    di->height = height;
     4870    di->antialias = antialias;
     4871    di->deferred.fn = (DeferredFn*)SceneDeferredBMPImage;
     4872    di->dpi = dpi;
     4873    di->quiet = quiet;
     4874    if(filename) {
     4875      int stlen = strlen(filename);
     4876      di->filename = Alloc(char,stlen+1);
     4877      strcpy(di->filename, filename);
     4878    }
     4879  }
     4880  OrthoDefer(G,&di->deferred);
    48094881  return 1;
    48104882}
  • trunk/gui/vizservers/pymol/layer4/Cmd.c

    r699 r700  
    54635463}
    54645464
     5465/* BMP save image support *NJK* */
     5466static PyObject *CmdBMP(PyObject *self,   PyObject *args)
     5467{
     5468  PyMOLGlobals *G = NULL;
     5469  char *str1;
     5470  int ok=false;
     5471  int quiet;
     5472  int width,height;
     5473  float dpi;
     5474  ok = PyArg_ParseTuple(args,"siifi",&str1,&width,&height,&dpi,&quiet);
     5475  if (ok) {
     5476    API_SETUP_PYMOL_GLOBALS;
     5477        ok = (G!=NULL);
     5478  }
     5479  if (ok) {
     5480    APIEntry(G);
     5481    ExecutiveDrawNow(G);        /* TODO STATUS */
     5482    if(width||height) {
     5483      SceneDeferBMPImage(G,width,height,str1,-1,dpi,quiet);
     5484    } else {
     5485      SceneBMP(G,str1,dpi,quiet);
     5486    }
     5487    APIExit(G);
     5488  }
     5489  return APIResultOk(ok);
     5490}
     5491
     5492/* Virtual Mouse command *NJK* */
     5493static PyObject *CmdVMouse(PyObject *self,    PyObject *args)
     5494{
     5495  PyMOLGlobals *G = NULL;
     5496  int ok = false;
     5497  int button, modifier, state, x, y;
     5498
     5499  ok = PyArg_ParseTuple(args,"iiiii",&button,&modifier,&state,&x,&y);
     5500
     5501  if(ok) {
     5502    API_SETUP_PYMOL_GLOBALS;
     5503    ok = (G!=NULL);
     5504  }
     5505  if (ok) {
     5506    APIEntry(G);
     5507    if ((state == 0) || (state == 1))
     5508       ProcessMainButton(button,modifier,state,x,y);
     5509    else if (state == 2)
     5510       ProcessMainDrag(x,y);
     5511    else if (state == 3)
     5512       ProcessMainPassive(x,y);
     5513    APIExit(G);
     5514  }
     5515
     5516  return APIResultOk(ok);
     5517}
     5518
    54655519static PyObject *CmdMPNG(PyObject *self,        PyObject *args)
    54665520{
     
    76117665  {"attach",                CmdAttach,               METH_VARARGS },
    76127666  {"bg_color",              CmdBackgroundColor,      METH_VARARGS },
     7667  {"bmp",                   CmdBMP,                  METH_VARARGS }, /* BMP save image support *NJK* */
    76137668  {"bond",                  CmdBond,                 METH_VARARGS },
    76147669  {"busy_draw",             CmdBusyDraw,             METH_VARARGS },
     
    78417896  {"unset_bond",            CmdUnsetBond,            METH_VARARGS },
    78427897  {"update",                CmdUpdate,               METH_VARARGS },
     7898  {"vmouse",                CmdVMouse,               METH_VARARGS }, /* Virtual Mouse command *NJK* */
    78437899  {"window",                CmdWindow,               METH_VARARGS },
    78447900  {"zoom",                      CmdZoom,                 METH_VARARGS },
  • trunk/gui/vizservers/pymol/layer5/PyMOL.c

    r699 r700  
    24742474      result->G->PyMOL = result; /* store the instance pointer */
    24752475
     2476      pipe(result->G->CmdPipe);  /* Sleep Interruption Patch *NJK* */
    24762477      result->BusyFlag = false;
    24772478      result->InterruptFlag = false;
     
    25672568  TetsurfInit(G);
    25682569  EditorInit(G);
     2570  ImageInit(G); /* Persistent image capture buffer *NJK* */
     2571  PyMOLInitPerf(1,&G->GLQueryId); /* Sample counting patch *NJK* */
     2572  PyMOLStartPerf(G->GLQueryId); /* Sample counting patch *NJK* */
    25692573
    25702574#ifdef TRACKER_UNIT_TEST
  • trunk/gui/vizservers/pymol/layer5/main.c

    r699 r700  
    551551}
    552552/*========================================================================*/
     553/* Virtual mouse support *NJK* */
     554void ProcessMainDrag(int x,int y)
     555{
     556  PyMOLGlobals *G = TempPyMOLGlobals;
     557
     558  CMain *I = G->Main;
     559 
     560  y=G->Option->winY-y;
     561   
     562  PyMOL_Drag(PyMOLInstance,x,y,I->Modifiers);
     563   
     564  if(PyMOL_GetRedisplay(PyMOLInstance, true)) {
     565    if(G->HaveGUI) {
     566      p_glutPostRedisplay();
     567    }
     568    I->IdleMode = 0;
     569  }
     570}
     571/*========================================================================*/
    553572static void MainButton(int button,int state,int x,int y)
    554573{
     
    590609}
    591610/*========================================================================*/
     611/* Virtual mouse support *NJK* */
     612void ProcessMainButton(int button,int glMod,int state,int x,int y)
     613{
     614  PyMOLGlobals *G = TempPyMOLGlobals;
     615
     616  CMain *I = G->Main;
     617
     618  I->IdleMode = 0; /* restore responsiveness */
     619   
     620  if(PyMOL_GetPassive(PyMOLInstance, true)) {
     621    ProcessMainDrag(x,y);
     622  } else {
     623    /* stay blocked here because Clicks->SexFrame->PParse */
     624   
     625    y=G->Option->winY-y;
     626     
     627    I->Modifiers = ((glMod&P_GLUT_ACTIVE_SHIFT) ? cOrthoSHIFT : 0) |
     628      ((glMod&P_GLUT_ACTIVE_CTRL) ? cOrthoCTRL : 0) |
     629      ((glMod&P_GLUT_ACTIVE_ALT) ? cOrthoALT : 0);
     630     
     631    switch(button) {
     632    case P_GLUT_BUTTON_SCROLL_FORWARD:
     633    case P_GLUT_BUTTON_SCROLL_BACKWARD:
     634      x=G->Option->winX/2;
     635      y=G->Option->winY/2; /* force into scene */
     636      break;
     637    }
     638    PyMOL_Button(PyMOLInstance,button,state,x,y,I->Modifiers);
     639  }
     640}
     641/*========================================================================*/
    592642static void MainPassive(int x,int y)
    593643{
     
    634684 
    635685}
    636 
     686/*========================================================================*/
     687/* Virtual mouse support *NJK* */
     688void ProcessMainPassive(int x,int y)
     689{
     690  PyMOLGlobals *G = TempPyMOLGlobals;
     691  CMain *I = G->Main;
     692
     693  #define PASSIVE_EDGE 20
     694
     695  if(PyMOL_GetPassive(G->PyMOL,false)) { /* a harmless race condition -- we don't want
     696                                           to slow Python down buy locking on passive
     697                                           mouse motion */
     698   
     699    if((y<-PASSIVE_EDGE)||(x<-PASSIVE_EDGE)||
     700       (x>(G->Option->winX+PASSIVE_EDGE))||
     701       (y>(G->Option->winY+PASSIVE_EDGE))) {       
     702      /* release passive drag if mouse leaves window... */
     703       
     704      y=G->Option->winY-y;
     705     
     706      PyMOL_Button(PyMOLInstance,P_GLUT_LEFT_BUTTON, P_GLUT_UP,x,y,I->Modifiers);
     707     
     708      PyMOL_GetPassive(G->PyMOL,true); /* reset the flag */
     709       
     710    } else {
     711       
     712      y=G->Option->winY-y;
     713       
     714      PyMOL_Drag(PyMOLInstance,x,y,I->Modifiers);
     715       
     716    }
     717     
     718    if(PyMOL_GetRedisplay(PyMOLInstance, true)) {
     719      if(G->HaveGUI) {
     720        p_glutPostRedisplay();
     721      }     
     722      I->IdleMode = 0;
     723    }
     724  }
     725}
    637726/*========================================================================*/
    638727static void MainDrawLocked(void)
  • trunk/gui/vizservers/pymol/modules/pymol/api.py

    r699 r700  
    5959
    6060#--------------------------------------------------------------------
     61# vmouse adds Virutal mouse support *NJK*
    6162import controlling
    6263from controlling import \
     
    6869      set_key,            \
    6970      unmask,             \
     71      vmouse,             \
    7072      edit_mode
    7173
     
    124126
    125127#--------------------------------------------------------------------
     128# bmp adds BMP save image support *NJK*
    126129from exporting import \
     130      bmp,                \
    127131      png,                \
    128132      export_coords,      \
  • trunk/gui/vizservers/pymol/modules/pymol/cmd.py

    r699 r700  
    998998                unlock(-1)
    999999            return r
     1000 
     1001        # BMP save image support *NJK*
     1002        # writing BMP files (thread-unsafe)
     1003 
     1004        def _bmp(a,width=0,height=0,dpi=-1.0,quiet=1): # INTERNAL - can only be safely called by GLUT thread
     1005            # INTERNAL - can only be safely called by GLUT thread
     1006            # WARNING: internal routine, subject to change
     1007            try:
     1008                lock()
     1009                fname = a
     1010                if not re.search("\.bmp$",fname):
     1011                    fname = fname +".bmp"
     1012                fname = exp_path(fname)
     1013                r = _cmd.bmp(str(fname),int(width),int(height),float(dpi),int(quiet))
     1014            finally:
     1015                unlock()
     1016            return r
    10001017
    10011018        # quitting (thread-specific)
  • trunk/gui/vizservers/pymol/modules/pymol/controlling.py

    r699 r700  
    700700        return r
    701701
     702    # Virtual mouse support *NJK*
     703    def vmouse(b,m,s,x,y):
     704        r = DEFAULT_SUCCESS
     705        try:
     706            lock()
     707            _cmd.vmouse(int(b),int(m),int(s),int(x),int(y))
     708        finally:
     709            unlock(r)
     710        if _raising(r): raise pymol.CmdException
     711        return r
  • trunk/gui/vizservers/pymol/modules/pymol/exporting.py

    r699 r700  
    131131        else:
    132132            r = cmd._do("cmd._png('%s',%d,%d,%1.6f,%d,%d)"%(filename,width,height,dpi,ray,quiet))
     133        if _raising(r): raise QuietException
     134        return r
     135
     136    # BMP save image support *NJK*
     137    def bmp(filename,width=0,height=0,dpi=-1.0,quiet=1):
     138        '''
     139DESCRIPTION
     140
     141    "bmp" writes a bmp format image file of the current image to disk.
     142
     143USAGE
     144
     145    bmp filename
     146
     147PYMOL API
     148
     149    cmd.bmp( string file )
     150            '''
     151        r = DEFAULT_ERROR
     152        if thread.get_ident() ==pymol.glutThread:
     153            r = cmd._bmp(str(filename),int(width),int(height),float(dpi),int(quiet))
     154        else:
     155            r = cmd._do("cmd._bmp('%s',%d,%d,%1.6f,%d)"%(filename,width,height,dpi,quiet))
    133156        if _raising(r): raise QuietException
    134157        return r
  • trunk/gui/vizservers/pymol/modules/pymol/keywords.py

    r699 r700  
    2323        'backward'      : [ self_cmd.backward          , 0 , 0 , ''  , parsing.STRICT ],
    2424        'bg_color'      : [ self_cmd.bg_color          , 0 , 0 , ''  , parsing.STRICT ],
     25        'bmp'           : [ self_cmd.bmp               , 0 , 0 , ''  , parsing.SECURE ], # BMP save image support *NJK*
    2526        'bond'          : [ self_cmd.bond              , 0 , 0 , ''  , parsing.STRICT ],
    2627        'break'         : [ self_cmd.python_help       , 0 , 0 , ''  , parsing.PYTHON ],   
     
    252253        'view'          : [ self_cmd.view              , 0 , 0 , ''  , parsing.STRICT ],   
    253254        'viewport'      : [ self_cmd.viewport          , 0 , 0 , ''  , parsing.STRICT ],
     255        'vmouse'        : [ self_cmd.vmouse            , 0 , 0 , ''  , parsing.STRICT ], # Virtual mouse support *NJK*
    254256        'window'        : [ self_cmd.window            , 0 , 0 , ''  , parsing.STRICT ],         
    255257        'while'         : [ self_cmd.python_help       , 0 , 0 , ''  , parsing.PYTHON ],   
Note: See TracChangeset for help on using the changeset viewer.