00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "py_commands.h"
00022 #include "CommandQueue.h"
00023 #include "VMDApp.h"
00024 #include "Axes.h"
00025
00026
00027 static PyObject *get_location(PyObject *self, PyObject *args) {
00028 if (!PyArg_ParseTuple(args, (char *)":axes.get_location"))
00029 return NULL;
00030
00031 VMDApp *app = get_vmdapp();
00032 return PyString_FromString(app->axes->loc_description(app->axes->location()));
00033 }
00034
00035
00036 static PyObject *set_location(PyObject *self, PyObject *args) {
00037 char *location;
00038 if (!PyArg_ParseTuple(args, (char *)"s:axes.set_location", &location))
00039 return NULL;
00040
00041 VMDApp *app = get_vmdapp();
00042 if (app->axes_set_location(location)) {
00043 Py_INCREF(Py_None);
00044 return Py_None;
00045 }
00046 PyErr_SetString(PyExc_ValueError, (char *)"Invalid axes location");
00047 return NULL;
00048 }
00049
00050 static PyMethodDef methods[] = {
00051 {(char *)"get_location", (vmdPyMethod)get_location, METH_VARARGS},
00052 {(char *)"set_location", (vmdPyMethod)set_location, METH_VARARGS},
00053 {NULL, NULL}
00054 };
00055
00056 void initaxes() {
00057 PyObject *m = Py_InitModule((char *)"axes", methods);
00058 VMDApp *app = get_vmdapp();
00059 PyModule_AddStringConstant(m, (char *)"OFF", (char *)app->axes->loc_description(0));
00060 PyModule_AddStringConstant(m, (char *)"ORIGIN", (char *)app->axes->loc_description(1));
00061 PyModule_AddStringConstant(m, (char *)"LOWERLEFT", (char *)app->axes->loc_description(2));
00062 PyModule_AddStringConstant(m, (char *)"LOWERRIGHT", (char *)app->axes->loc_description(3));
00063 PyModule_AddStringConstant(m, (char *)"UPPERLEFT", (char *)app->axes->loc_description(4));
00064 PyModule_AddStringConstant(m, (char *)"UPPERRIGHT", (char *)app->axes->loc_description(5));
00065 }