Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

py_render.C

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr
00003  *cr            (C) Copyright 1995-2011 The Board of Trustees of the
00004  *cr                        University of Illinois
00005  *cr                         All Rights Reserved
00006  *cr
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  * RCS INFORMATION:
00011  *
00012  *      $RCSfile: py_render.C,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.13 $       $Date: 2010/12/16 04:08:57 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  *  Python interface to external renderer commands  
00019  ***************************************************************************/
00020 
00021 #include "py_commands.h"
00022 #include "VMDApp.h"
00023 
00024 // listall(): list the supported render methods
00025 
00026 static PyObject *listall(PyObject *self, PyObject *args) {
00027   if (!PyArg_ParseTuple(args, (char *)""))
00028     return NULL;
00029 
00030   PyObject *newlist = PyList_New(0);
00031   VMDApp *app = get_vmdapp();
00032   for (int i=0; i<app->filerender_num(); i++)
00033     PyList_Append(newlist, PyString_FromString(app->filerender_name(i)));
00034   
00035   return newlist;
00036 }
00037 
00038 // render(method, filename)
00039 
00040 static PyObject *render(PyObject *self, PyObject *args, PyObject *keywds) {
00041   char *method, *filename;
00042   static char *kwlist[] = {
00043     (char *)"method", (char *)"filename", NULL
00044   };
00045 
00046   if (!PyArg_ParseTupleAndKeywords(args, keywds, (char *)"ss", kwlist,
00047     &method, &filename))
00048     return NULL;
00049 
00050   VMDApp *app = get_vmdapp();
00051   
00052   if (!app->filerender_render(method, filename, NULL)) {
00053     PyErr_SetString(PyExc_ValueError, "Unable to render to file");
00054     return NULL;
00055   }
00056 
00057   Py_INCREF(Py_None);
00058   return Py_None;
00059 }
00060 
00061 static PyMethodDef methods[] = {
00062   {(char *)"listall", (vmdPyMethod)listall, METH_VARARGS},
00063   {(char *)"render", (PyCFunction)render, METH_VARARGS | METH_KEYWORDS},
00064   {NULL, NULL}
00065 };
00066 
00067 void initrender() {
00068   (void)Py_InitModule((char *)"render", methods);
00069 }

Generated on Sun May 27 01:59:01 2012 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002