diff --git a/source/blender/python/api2_2x/BezTriple.c b/source/blender/python/api2_2x/BezTriple.c index fb7de1b5d87..94911cac1e7 100644 --- a/source/blender/python/api2_2x/BezTriple.c +++ b/source/blender/python/api2_2x/BezTriple.c @@ -31,13 +31,103 @@ #include "BezTriple.h" +#include + +#include +#include +#include +#include +#include +#include + +#include "constant.h" +#include "gen_utils.h" +#include "modules.h" + +/*****************************************************************************/ +/* Python API function prototypes for the BezTriple module. */ +/*****************************************************************************/ +static PyObject *M_BezTriple_New (PyObject * self, PyObject * args); +static PyObject *M_BezTriple_Get (PyObject * self, PyObject * args); + +/*****************************************************************************/ +/* Python C_BezTriple instance methods declarations: */ +/*****************************************************************************/ +static PyObject *BezTriple_setPoints (C_BezTriple * self, PyObject * args); +static PyObject *BezTriple_getPoints (C_BezTriple * self); +static PyObject *BezTriple_getTriple (C_BezTriple * self); + +/*****************************************************************************/ +/* Python BezTriple_Type callback function prototypes: */ +/*****************************************************************************/ +static void BezTripleDeAlloc (C_BezTriple * self); +static int BezTripleSetAttr (C_BezTriple * self, char *name, PyObject * v); +static PyObject *BezTripleGetAttr (C_BezTriple * self, char *name); +static PyObject *BezTripleRepr (C_BezTriple * self); + +/*****************************************************************************/ +/* Python method structure definition for Blender.BezTriple module: */ +/*****************************************************************************/ + +struct PyMethodDef M_BezTriple_methods[] = { + {"New", (PyCFunction) M_BezTriple_New, METH_VARARGS | METH_KEYWORDS, 0}, + {"Get", M_BezTriple_Get, METH_VARARGS, 0}, + {"get", M_BezTriple_Get, METH_VARARGS, 0}, + {NULL, NULL, 0, NULL} +}; + +/*****************************************************************************/ +/* Python C_BezTriple methods table: */ +/*****************************************************************************/ +static PyMethodDef C_BezTriple_methods[] = { + /* name, method, flags, doc */ + {"setPoints", (PyCFunction) BezTriple_setPoints, METH_VARARGS, + "(str) - Change BezTriple point coordinates"}, + {"getPoints", (PyCFunction) BezTriple_getPoints, METH_NOARGS, + "() - return BezTriple knot point x and y coordinates"}, + {"getTriple", (PyCFunction) BezTriple_getTriple, METH_VARARGS, + "() - return list of floating point triplets. order is H1, knot, H2"}, + {NULL, NULL, 0, NULL} +}; + + +/*****************************************************************************/ +/* Python BezTriple_Type structure definition: */ +/*****************************************************************************/ +PyTypeObject BezTriple_Type = { + PyObject_HEAD_INIT (NULL) 0, /* ob_size */ + "BezTriple", /* tp_name */ + sizeof (C_BezTriple), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor) BezTripleDeAlloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc) BezTripleGetAttr, /* tp_getattr */ + (setattrfunc) BezTripleSetAttr, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc) BezTripleRepr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_as_hash */ + 0, 0, 0, 0, 0, 0, + 0, /* tp_doc */ + 0, 0, 0, 0, 0, 0, + C_BezTriple_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tm_getset */ + 0 +}; + + /*****************************************************************************/ /* Function: M_BezTriple_New */ /* Python equivalent: Blender.BezTriple.New */ /*****************************************************************************/ -static PyObject *M_BezTriple_New(PyObject *self, PyObject *args) +static PyObject * +M_BezTriple_New (PyObject * self, PyObject * args) { - return 0; + return 0; } /*****************************************************************************/ @@ -48,60 +138,83 @@ static PyObject *M_BezTriple_New(PyObject *self, PyObject *args) /* passed in, a list of all ipo data names in the */ /* current scene is returned. */ /*****************************************************************************/ -static PyObject *M_BezTriple_Get(PyObject *self, PyObject *args) +static PyObject * +M_BezTriple_Get (PyObject * self, PyObject * args) { - return 0; + return 0; } - - - /*****************************************************************************/ /* Function: BezTripleDeAlloc */ /* Description: This is a callback function for the C_BezTriple type. It is */ /* the destructor function. */ /*****************************************************************************/ -static void BezTripleDeAlloc (C_BezTriple *self) +static void +BezTripleDeAlloc (C_BezTriple * self) { PyObject_DEL (self); } -static PyObject* BezTriple_getPoints (C_BezTriple *self) -{ -struct BezTriple *bezt = self->beztriple; - PyObject* l = PyList_New(0); - int i; - for(i = 0;i<2;i++) - { - PyList_Append( l, PyFloat_FromDouble(bezt->vec[1][i])); - } +static PyObject * +BezTriple_getPoints (C_BezTriple * self) +{ + struct BezTriple *bezt = self->beztriple; + PyObject *l = PyList_New (0); + int i; + for (i = 0; i < 2; i++) + { + PyList_Append (l, PyFloat_FromDouble (bezt->vec[1][i])); + } return l; } -static PyObject * BezTriple_setPoints (C_BezTriple *self,PyObject *args) -{ +static PyObject * +BezTriple_getTriple (C_BezTriple * self) +{ + int i; + struct BezTriple *bezt = self->beztriple; + PyObject *retlist = PyList_New (0); + PyObject *point; - int i; - struct BezTriple *bezt = self->beztriple; - PyObject*popo = 0; - if (!PyArg_ParseTuple(args, "O", &popo)) - return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected tuple argument")); - if ( PyTuple_Check(popo) == 0) - { - puts("error in BezTriple_setPoints"); - Py_INCREF(Py_None); - return Py_None; - } - for(i = 0;i<2;i++) - { - bezt->vec[1][i] = PyFloat_AsDouble(PyTuple_GetItem(popo, i)); - bezt->vec[0][i] = bezt->vec[1][i] -1; - bezt->vec[2][i] = bezt->vec[1][i] +1; - } + for (i = 0; i < 3; i++) + { + point = Py_BuildValue ("[fff]", + bezt->vec[i][0], + bezt->vec[i][1], bezt->vec[i][2]); + + PyList_Append (retlist, point); + } + + return retlist; +} - Py_INCREF(Py_None); +static PyObject * +BezTriple_setPoints (C_BezTriple * self, PyObject * args) +{ + + int i; + struct BezTriple *bezt = self->beztriple; + PyObject *popo = 0; + if (!PyArg_ParseTuple (args, "O", &popo)) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "expected tuple argument")); + if (PyTuple_Check (popo) == 0) + { + puts ("error in BezTriple_setPoints"); + Py_INCREF (Py_None); + return Py_None; + } + for (i = 0; i < 2; i++) + { + bezt->vec[1][i] = PyFloat_AsDouble (PyTuple_GetItem (popo, i)); + bezt->vec[0][i] = bezt->vec[1][i] - 1; + bezt->vec[2][i] = bezt->vec[1][i] + 1; + } + + + Py_INCREF (Py_None); return Py_None; } @@ -112,10 +225,12 @@ static PyObject * BezTriple_setPoints (C_BezTriple *self,PyObject *args) /* the function that accesses C_BezTriple "member variables" and */ /* methods. */ /*****************************************************************************/ -static PyObject *BezTripleGetAttr (C_BezTriple *self, char *name) +static PyObject * +BezTripleGetAttr (C_BezTriple * self, char *name) { -if (strcmp (name, "pt") == 0)return BezTriple_getPoints(self); - return Py_FindMethod(C_BezTriple_methods, (PyObject *)self, name); + if (strcmp (name, "pt") == 0) + return BezTriple_getPoints (self); + return Py_FindMethod (C_BezTriple_methods, (PyObject *) self, name); } /*****************************************************************************/ @@ -123,10 +238,12 @@ if (strcmp (name, "pt") == 0)return BezTriple_getPoints(self); /* Description: This is a callback function for the C_BezTriple type. It is the */ /* function that sets BezTriple Data attributes (member variables).*/ /*****************************************************************************/ -static int BezTripleSetAttr (C_BezTriple *self, char *name, PyObject *value) +static int +BezTripleSetAttr (C_BezTriple * self, char *name, PyObject * value) { - if (strcmp (name, "pt") == 0) BezTriple_setPoints(self,value); - return 0; /* normal exit */ + if (strcmp (name, "pt") == 0) + BezTriple_setPoints (self, value); + return 0; /* normal exit */ } /*****************************************************************************/ @@ -134,17 +251,29 @@ static int BezTripleSetAttr (C_BezTriple *self, char *name, PyObject *value) /* Description: This is a callback function for the C_BezTriple type. It */ /* builds a meaninful string to represent BezTriple objects. */ /*****************************************************************************/ -static PyObject *BezTripleRepr (C_BezTriple *self) +static PyObject * +BezTripleRepr (C_BezTriple * self) { - /* float vec[3][3]; - float alfa; - short s[3][2]; - short h1, h2; - char f1, f2, f3, hide; - */ - char str[1000]; - sprintf(str,"BezTriple %f %f %f %f %f %f %f %f %f %f\n %d %d %d %d %d %d %d %d %d %d %d %d\n",self->beztriple->vec[0][0],self->beztriple->vec[0][1],self->beztriple->vec[0][2],self->beztriple->vec[1][0],self->beztriple->vec[1][1],self->beztriple->vec[1][2],self->beztriple->vec[2][0],self->beztriple->vec[2][1],self->beztriple->vec[2][2],self->beztriple->alfa,self->beztriple->s[0][0],self->beztriple->s[0][1],self->beztriple->s[1][0],self->beztriple->s[1][1],self->beztriple->s[2][0],self->beztriple->s[1][1],self->beztriple->h1,self->beztriple->h2,self->beztriple->f1,self->beztriple->f2,self->beztriple->f3,self->beztriple->hide); - return PyString_FromString(str); + /* float vec[3][3]; + float alfa; + short s[3][2]; + short h1, h2; + char f1, f2, f3, hide; + */ + char str[1000]; + sprintf (str, + "BezTriple %f %f %f %f %f %f %f %f %f %f\n %d %d %d %d %d %d %d %d %d %d %d %d\n", + self->beztriple->vec[0][0], self->beztriple->vec[0][1], + self->beztriple->vec[0][2], self->beztriple->vec[1][0], + self->beztriple->vec[1][1], self->beztriple->vec[1][2], + self->beztriple->vec[2][0], self->beztriple->vec[2][1], + self->beztriple->vec[2][2], self->beztriple->alfa, + self->beztriple->s[0][0], self->beztriple->s[0][1], + self->beztriple->s[1][0], self->beztriple->s[1][1], + self->beztriple->s[2][0], self->beztriple->s[1][1], + self->beztriple->h1, self->beztriple->h2, self->beztriple->f1, + self->beztriple->f2, self->beztriple->f3, self->beztriple->hide); + return PyString_FromString (str); } /* Three Python BezTriple_Type helper functions needed by the Object module: */ @@ -154,19 +283,20 @@ static PyObject *BezTripleRepr (C_BezTriple *self) /* Description: This function will create a new C_BezTriple from an existing */ /* Blender ipo structure. */ /*****************************************************************************/ -PyObject *BezTriple_CreatePyObject (BezTriple *bzt) +PyObject * +BezTriple_CreatePyObject (BezTriple * bzt) { - C_BezTriple *pybeztriple; + C_BezTriple *pybeztriple; - pybeztriple = (C_BezTriple *)PyObject_NEW (C_BezTriple, &BezTriple_Type); + pybeztriple = (C_BezTriple *) PyObject_NEW (C_BezTriple, &BezTriple_Type); - if (!pybeztriple) - return EXPP_ReturnPyObjError (PyExc_MemoryError, - "couldn't create C_BezTriple object"); + if (!pybeztriple) + return EXPP_ReturnPyObjError (PyExc_MemoryError, + "couldn't create C_BezTriple object"); - pybeztriple->beztriple = bzt; + pybeztriple->beztriple = bzt; - return (PyObject *)pybeztriple; + return (PyObject *) pybeztriple; } /*****************************************************************************/ @@ -174,9 +304,10 @@ PyObject *BezTriple_CreatePyObject (BezTriple *bzt) /* Description: This function returns true when the given PyObject is of the */ /* type BezTriple. Otherwise it will return false. */ /*****************************************************************************/ -int BezTriple_CheckPyObject (PyObject *pyobj) +int +BezTriple_CheckPyObject (PyObject * pyobj) { - return (pyobj->ob_type == &BezTriple_Type); + return (pyobj->ob_type == &BezTriple_Type); } /*****************************************************************************/ @@ -184,7 +315,8 @@ int BezTriple_CheckPyObject (PyObject *pyobj) /* Description: This function returns the Blender beztriple from the given */ /* PyObject. */ /*****************************************************************************/ -BezTriple *BezTriple_FromPyObject (PyObject *pyobj) +BezTriple * +BezTriple_FromPyObject (PyObject * pyobj) { - return ((C_BezTriple *)pyobj)->beztriple; + return ((C_BezTriple *) pyobj)->beztriple; } diff --git a/source/blender/python/api2_2x/BezTriple.h b/source/blender/python/api2_2x/BezTriple.h index 74ed54f0eab..26d9fd18593 100644 --- a/source/blender/python/api2_2x/BezTriple.h +++ b/source/blender/python/api2_2x/BezTriple.h @@ -33,98 +33,17 @@ #define EXPP_BEZTRIPLE_H #include - -#include -#include -#include -#include -#include -#include - -#include "constant.h" -#include "gen_utils.h" -#include "modules.h" - - -/*****************************************************************************/ -/* Python API function prototypes for the BezTriple module. */ -/*****************************************************************************/ -static PyObject *M_BezTriple_New (PyObject *self, PyObject *args); -static PyObject *M_BezTriple_Get (PyObject *self, PyObject *args); - - - -/*****************************************************************************/ -/* Python method structure definition for Blender.BezTriple module: */ -/*****************************************************************************/ - -struct PyMethodDef M_BezTriple_methods[] = { - {"New",(PyCFunction)M_BezTriple_New, METH_VARARGS|METH_KEYWORDS,0}, - {"Get", M_BezTriple_Get, METH_VARARGS, 0}, - {"get", M_BezTriple_Get, METH_VARARGS, 0}, - {NULL, NULL, 0, NULL} -}; +#include /*****************************************************************************/ /* Python C_BezTriple structure definition: */ /*****************************************************************************/ -typedef struct { - PyObject_HEAD - BezTriple *beztriple; -} C_BezTriple; -/*****************************************************************************/ -/* Python C_BezTriple methods declarations: */ -/*****************************************************************************/ -static PyObject *BezTriple_setPoints(C_BezTriple *self, PyObject *args); -static PyObject *BezTriple_getPoints(C_BezTriple *self); - -/*****************************************************************************/ -/* Python C_BezTriple methods table: */ -/*****************************************************************************/ -static PyMethodDef C_BezTriple_methods[] = { - /* name, method, flags, doc */ -{"setPoints", (PyCFunction)BezTriple_setPoints, METH_VARARGS, - "(str) - Change BezTriple point coordinates"}, -{"getPoints", (PyCFunction)BezTriple_getPoints, METH_NOARGS, - "(str) - Change BezTriple point coordinates"}, - {0} -}; - -/*****************************************************************************/ -/* Python BezTriple_Type callback function prototypes: */ -/*****************************************************************************/ -static void BezTripleDeAlloc (C_BezTriple *self); -static int BezTripleSetAttr (C_BezTriple *self, char *name, PyObject *v); -static PyObject *BezTripleGetAttr (C_BezTriple *self, char *name); -static PyObject *BezTripleRepr (C_BezTriple *self); - -/*****************************************************************************/ -/* Python BezTriple_Type structure definition: */ -/*****************************************************************************/ -PyTypeObject BezTriple_Type = +typedef struct { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "BezTriple", /* tp_name */ - sizeof (C_BezTriple), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)BezTripleDeAlloc, /* tp_dealloc */ - 0, /* tp_print */ - (getattrfunc)BezTripleGetAttr, /* tp_getattr */ - (setattrfunc)BezTripleSetAttr, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)BezTripleRepr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_as_hash */ - 0,0,0,0,0,0, - 0, /* tp_doc */ - 0,0,0,0,0,0, - C_BezTriple_methods, /* tp_methods */ - 0, /* tp_members */ -}; + PyObject_HEAD BezTriple * beztriple; +} +C_BezTriple; + #endif /* EXPP_BEZTRIPLE_H */ diff --git a/source/blender/python/api2_2x/Curve.c b/source/blender/python/api2_2x/Curve.c index 2587df53498..de6ec87b8db 100644 --- a/source/blender/python/api2_2x/Curve.c +++ b/source/blender/python/api2_2x/Curve.c @@ -24,125 +24,372 @@ * * This is a new part of Blender. * - * Contributor(s): Jacques Guignot + * Contributor(s): Jacques Guignot, Stephen Swaney * * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ +#include #include "Curve.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include "gen_utils.h" + +/*****************************************************************************/ +/* The following string definitions are used for documentation strings. */ +/* In Python these will be written to the console when doing a */ +/* Blender.Curve.__doc__ */ +/*****************************************************************************/ + +char M_Curve_doc[] = "The Blender Curve module\n\n\ +This module provides access to **Curve Data** in Blender.\n\ +Functions :\n\ + New(opt name) : creates a new curve object with the given name (optional)\n\ + Get(name) : retreives a curve with the given name (mandatory)\n\ + get(name) : same as Get. Kept for compatibility reasons"; +char M_Curve_New_doc[] = ""; +char M_Curve_Get_doc[] = "xxx"; + + + +/*****************************************************************************/ +/* Python API function prototypes for the Curve module. */ +/*****************************************************************************/ +static PyObject *M_Curve_New (PyObject * self, PyObject * args); +static PyObject *M_Curve_Get (PyObject * self, PyObject * args); + + +/*****************************************************************************/ +/* Python BPy_Curve instance methods declarations: */ +/*****************************************************************************/ +static PyObject *Curve_getName (BPy_Curve * self); +static PyObject *Curve_setName (BPy_Curve * self, PyObject * args); +static PyObject *Curve_getPathLen (BPy_Curve * self); +static PyObject *Curve_setPathLen (BPy_Curve * self, PyObject * args); +static PyObject *Curve_getTotcol (BPy_Curve * self); +static PyObject *Curve_setTotcol (BPy_Curve * self, PyObject * args); +static PyObject *Curve_getMode (BPy_Curve * self); +static PyObject *Curve_setMode (BPy_Curve * self, PyObject * args); +static PyObject *Curve_getBevresol (BPy_Curve * self); +static PyObject *Curve_setBevresol (BPy_Curve * self, PyObject * args); +static PyObject *Curve_getResolu (BPy_Curve * self); +static PyObject *Curve_setResolu (BPy_Curve * self, PyObject * args); +static PyObject *Curve_getResolv (BPy_Curve * self); +static PyObject *Curve_setResolv (BPy_Curve * self, PyObject * args); +static PyObject *Curve_getWidth (BPy_Curve * self); +static PyObject *Curve_setWidth (BPy_Curve * self, PyObject * args); +static PyObject *Curve_getExt1 (BPy_Curve * self); +static PyObject *Curve_setExt1 (BPy_Curve * self, PyObject * args); +static PyObject *Curve_getExt2 (BPy_Curve * self); +static PyObject *Curve_setExt2 (BPy_Curve * self, PyObject * args); +static PyObject *Curve_getControlPoint (BPy_Curve * self, PyObject * args); +static PyObject *Curve_setControlPoint (BPy_Curve * self, PyObject * args); +static PyObject *Curve_getLoc (BPy_Curve * self); +static PyObject *Curve_setLoc (BPy_Curve * self, PyObject * args); +static PyObject *Curve_getRot (BPy_Curve * self); +static PyObject *Curve_setRot (BPy_Curve * self, PyObject * args); +static PyObject *Curve_getSize (BPy_Curve * self); +static PyObject *Curve_setSize (BPy_Curve * self, PyObject * args); +static PyObject *Curve_getNumCurves (BPy_Curve * self); +static PyObject *Curve_isNurb (BPy_Curve * self, PyObject * args); +static PyObject *Curve_getNumPoints (BPy_Curve * self, PyObject * args); +static PyObject *Curve_getNumPoints (BPy_Curve * self, PyObject * args); + +/*****************************************************************************/ +/* Python method definitions for Blender.Curve module: */ +/*****************************************************************************/ +struct PyMethodDef M_Curve_methods[] = { + {"New", (PyCFunction) M_Curve_New, METH_VARARGS, M_Curve_New_doc}, + {"Get", M_Curve_Get, METH_VARARGS, M_Curve_Get_doc}, + {"get", M_Curve_Get, METH_VARARGS, M_Curve_Get_doc}, + {NULL, NULL, 0, NULL} +}; + + +/*****************************************************************************/ +/* Python BPy_Curve instance methods table: */ +/*****************************************************************************/ +static PyMethodDef BPy_Curve_methods[] = { + {"getName", (PyCFunction) Curve_getName, + METH_NOARGS, "() - Return Curve Data name"}, + {"setName", (PyCFunction) Curve_setName, + METH_VARARGS, "() - Sets Curve Data name"}, + {"getPathLen", (PyCFunction) Curve_getPathLen, + METH_NOARGS, "() - Return Curve path length"}, + {"setPathLen", (PyCFunction) Curve_setPathLen, + METH_VARARGS, "(int) - Sets Curve path length"}, + {"getTotcol", (PyCFunction) Curve_getTotcol, + METH_NOARGS, "() - Return the number of materials of the curve"}, + {"setTotcol", (PyCFunction) Curve_setTotcol, + METH_VARARGS, "(int) - Sets the number of materials of the curve"}, + {"getFlag", (PyCFunction) Curve_getMode, + METH_NOARGS, "() - Return flag (see the doc for semantic)"}, + {"setFlag", (PyCFunction) Curve_setMode, + METH_VARARGS, "(int) - Sets flag (see the doc for semantic)"}, + {"getBevresol", (PyCFunction) Curve_getBevresol, + METH_NOARGS, "() - Return bevel resolution"}, + {"setBevresol", (PyCFunction) Curve_setBevresol, + METH_VARARGS, "(int) - Sets bevel resolution"}, + {"getResolu", (PyCFunction) Curve_getResolu, + METH_NOARGS, "() - Return U resolution"}, + {"setResolu", (PyCFunction) Curve_setResolu, + METH_VARARGS, "(int) - Sets U resolution"}, + {"getResolv", (PyCFunction) Curve_getResolv, + METH_NOARGS, "() - Return V resolution"}, + {"setResolv", (PyCFunction) Curve_setResolv, + METH_VARARGS, "(int) - Sets V resolution"}, + {"getWidth", (PyCFunction) Curve_getWidth, + METH_NOARGS, "() - Return curve width"}, + {"setWidth", (PyCFunction) Curve_setWidth, + METH_VARARGS, "(int) - Sets curve width"}, + {"getExt1", (PyCFunction) Curve_getExt1, + METH_NOARGS, "() - Returns extent 1 of the bevel"}, + {"setExt1", (PyCFunction) Curve_setExt1, + METH_VARARGS, "(int) - Sets extent 1 of the bevel"}, + {"getExt2", (PyCFunction) Curve_getExt2, + METH_NOARGS, "() - Return extent 2 of the bevel "}, + {"setExt2", (PyCFunction) Curve_setExt2, + METH_VARARGS, "(int) - Sets extent 2 of the bevel "}, + {"getControlPoint", (PyCFunction) Curve_getControlPoint, + METH_VARARGS, "(int numcurve,int numpoint) -\ +Gets a control point.Depending upon the curve type, returne a list of 4 or 9 floats"}, + {"setControlPoint", (PyCFunction) Curve_setControlPoint, + METH_VARARGS, "(int numcurve,int numpoint,float x,float y,float z,\ +float w)(nurbs) or (int numcurve,int numpoint,float x1,...,x9(bezier)\ +Sets a control point "}, + {"getLoc", (PyCFunction) Curve_getLoc, + METH_NOARGS, "() - Gets Location of the curve (a 3-tuple) "}, + {"setLoc", (PyCFunction) Curve_setLoc, + METH_VARARGS, "(3-tuple) - Sets Location "}, + {"getRot", (PyCFunction) Curve_getRot, + METH_NOARGS, "() - Gets curve rotation"}, + {"setRot", (PyCFunction) Curve_setRot, + METH_VARARGS, "(3-tuple) - Sets curve rotation"}, + {"getSize", (PyCFunction) Curve_getSize, + METH_NOARGS, "() - Gets curve size"}, + {"setSize", (PyCFunction) Curve_setSize, + METH_VARARGS, "(3-tuple) - Sets curve size"}, + {"getNumCurves", (PyCFunction) Curve_getNumCurves, + METH_NOARGS, "() - Gets # of curves"}, + {"isNurb", (PyCFunction) Curve_isNurb, + METH_NOARGS, + "(nothing or integer) - returns 1 or 0, depending upon the curve being a Nurb"}, + {"getNumPoints", (PyCFunction) Curve_getNumPoints, + METH_VARARGS, + "(nothing or integer) - returns the number of points of the specified curve"}, + {NULL, NULL, 0, NULL} +}; + + +/*****************************************************************************/ +/* Python Curve_Type callback function prototypes: */ +/*****************************************************************************/ +static void CurveDeAlloc (BPy_Curve * msh); +/* static int CurvePrint (BPy_Curve *msh, FILE *fp, int flags); */ +static int CurveSetAttr (BPy_Curve * msh, char *name, PyObject * v); +static PyObject *CurveGetAttr (BPy_Curve * msh, char *name); +static PyObject *CurveRepr (BPy_Curve * msh); + +PyObject *Curve_CreatePyObject (struct Curve *curve); +int Curve_CheckPyObject (PyObject * py_obj); +struct Curve *Curve_FromPyObject (PyObject * py_obj); + + + +/*****************************************************************************/ +/* Python Curve_Type structure definition: */ +/*****************************************************************************/ +PyTypeObject Curve_Type = { + PyObject_HEAD_INIT (NULL) /* required macro */ + 0, /* ob_size */ + "Curve", /* tp_name - for printing */ + sizeof (BPy_Curve), /* tp_basicsize - for allocation */ + 0, /* tp_itemsize - for allocation */ + /* methods for standard operations */ + (destructor) CurveDeAlloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc) CurveGetAttr, /* tp_getattr */ + (setattrfunc) CurveSetAttr, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc) CurveRepr, /* tp_repr */ + /* methods for standard classes */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_as_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + /* Flags to define presence of optional/expaned features */ + 0, /* tp_flags */ + 0, /* tp_doc - documentation string */ + 0, /* tp_traverse */ + + /* delete references to contained objects */ + 0, /* tp_clear */ + + 0, /* tp_richcompare - rich comparisions */ + 0, /* tp_weaklistoffset - weak reference enabler */ + + /* new release 2.2 stuff - Iterators */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + + /* Attribute descriptor and subclassing stuff */ + BPy_Curve_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset; */ + 0, /* tp_base; */ + 0, /* tp_dict; */ + 0, /* tp_descr_get; */ + 0, /* tp_descr_set; */ + 0, /* tp_dictoffset; */ + 0, /* tp_init; */ + 0, /* tp_alloc; */ + 0, /* tp_new; */ + 0, /* tp_free; Low-level free-memory routine */ + 0, /* tp_is_gc */ + 0, /* tp_bases; */ + 0, /* tp_mro; method resolution order */ + 0, /* tp_defined; */ + 0, /* tp_weakllst */ + 0, +}; /*****************************************************************************/ /* Function: M_Curve_New */ /* Python equivalent: Blender.Curve.New */ /*****************************************************************************/ -static PyObject *M_Curve_New(PyObject *self, PyObject *args) +static PyObject * +M_Curve_New (PyObject * self, PyObject * args) { char buf[24]; - char*name=NULL ; - BPy_Curve *pycurve; /* for Curve Data object wrapper in Python */ - Curve *blcurve = 0; /* for actual Curve Data we create in Blender */ - - if (!PyArg_ParseTuple(args, "|s", &name)) + char *name = NULL; + BPy_Curve *pycurve; /* for Curve Data object wrapper in Python */ + Curve *blcurve = 0; /* for actual Curve Data we create in Blender */ + + if (!PyArg_ParseTuple (args, "|s", &name)) return (EXPP_ReturnPyObjError (PyExc_AttributeError, "expected string argument or no argument")); - blcurve = add_curve(OB_CURVE); /* first create the Curve Data in Blender */ - - if (blcurve == NULL) /* bail out if add_curve() failed */ + blcurve = add_curve (OB_CURVE); /* first create the Curve Data in Blender */ + + if (blcurve == NULL) /* bail out if add_curve() failed */ return (EXPP_ReturnPyObjError (PyExc_RuntimeError, "couldn't create Curve Data in Blender")); /* return user count to zero because add_curve() inc'd it */ blcurve->id.us = 0; /* create python wrapper obj */ - pycurve = (BPy_Curve *)PyObject_NEW(BPy_Curve, &Curve_Type); + pycurve = (BPy_Curve *) PyObject_NEW (BPy_Curve, &Curve_Type); if (pycurve == NULL) return (EXPP_ReturnPyObjError (PyExc_MemoryError, "couldn't create Curve Data object")); - pycurve->curve = blcurve; /* link Python curve wrapper to Blender Curve */ + pycurve->curve = blcurve; /* link Python curve wrapper to Blender Curve */ if (name) { - PyOS_snprintf(buf, sizeof(buf), "%s", name); - rename_id(&blcurve->id, buf); + PyOS_snprintf (buf, sizeof (buf), "%s", name); + rename_id (&blcurve->id, buf); } - return (PyObject *)pycurve; + return (PyObject *) pycurve; } /*****************************************************************************/ /* Function: M_Curve_Get */ /* Python equivalent: Blender.Curve.Get */ /*****************************************************************************/ -static PyObject *M_Curve_Get(PyObject *self, PyObject *args) +static PyObject * +M_Curve_Get (PyObject * self, PyObject * args) { - - char *name = NULL; - Curve *curv_iter; + + char *name = NULL; + Curve *curv_iter; BPy_Curve *wanted_curv; - if (!PyArg_ParseTuple(args, "|s", &name))//expects nothing or a string + if (!PyArg_ParseTuple (args, "|s", &name)) /* expects nothing or a string */ return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected string argument")); - if(name){//a name has been given - /* Use the name to search for the curve requested */ - wanted_curv = NULL; - curv_iter = G.main->curve.first; + "expected string argument")); + if (name) + { /*a name has been given */ + /* Use the name to search for the curve requested */ + wanted_curv = NULL; + curv_iter = G.main->curve.first; - while ((curv_iter) && (wanted_curv == NULL)) { + while ((curv_iter) && (wanted_curv == NULL)) + { - if (strcmp (name, curv_iter->id.name+2) == 0) { - wanted_curv = (BPy_Curve *)PyObject_NEW(BPy_Curve, &Curve_Type); - if (wanted_curv) wanted_curv->curve = curv_iter; - } + if (strcmp (name, curv_iter->id.name + 2) == 0) + { + wanted_curv = + (BPy_Curve *) PyObject_NEW (BPy_Curve, &Curve_Type); + if (wanted_curv) + wanted_curv->curve = curv_iter; + } - curv_iter = curv_iter->id.next; - } + curv_iter = curv_iter->id.next; + } - if (wanted_curv == NULL) { /* Requested curve doesn't exist */ - char error_msg[64]; - PyOS_snprintf(error_msg, sizeof(error_msg), - "Curve \"%s\" not found", name); - return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg)); - } - + if (wanted_curv == NULL) + { /* Requested curve doesn't exist */ + char error_msg[64]; + PyOS_snprintf (error_msg, sizeof (error_msg), + "Curve \"%s\" not found", name); + return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg)); + } - return (PyObject*)wanted_curv; - }//if(name) - else{//no name has been given; return a list of all curves by name. - PyObject *curvlist; - curv_iter = G.main->curve.first; - curvlist = PyList_New (0); + return (PyObject *) wanted_curv; + } /* end of if(name) */ + else + { + /* no name has been given; return a list of all curves by name. */ + PyObject *curvlist; - if (curvlist == NULL) - return (PythonReturnErrorObject (PyExc_MemoryError, - "couldn't create PyList")); + curv_iter = G.main->curve.first; + curvlist = PyList_New (0); - while (curv_iter) { -BPy_Curve *found_cur=(BPy_Curve*)PyObject_NEW(BPy_Curve,&Curve_Type); - found_cur->curve = curv_iter; - PyList_Append (curvlist, (PyObject *)found_cur); + if (curvlist == NULL) + return (PythonReturnErrorObject (PyExc_MemoryError, + "couldn't create PyList")); - curv_iter = curv_iter->id.next; - } + while (curv_iter) + { + BPy_Curve *found_cur = + (BPy_Curve *) PyObject_NEW (BPy_Curve, &Curve_Type); + found_cur->curve = curv_iter; + PyList_Append (curvlist, (PyObject *) found_cur); - return (curvlist); - }//else + curv_iter = curv_iter->id.next; + } + + return (curvlist); + } /* end of else */ } /*****************************************************************************/ /* Function: Curve_Init */ /*****************************************************************************/ -PyObject *Curve_Init (void) +PyObject * +Curve_Init (void) { - PyObject *submodule; + PyObject *submodule; Curve_Type.ob_type = &PyType_Type; - submodule = Py_InitModule3("Blender.Curve",M_Curve_methods, M_Curve_doc); + submodule = Py_InitModule3 ("Blender.Curve", M_Curve_methods, M_Curve_doc); return (submodule); } @@ -150,243 +397,273 @@ PyObject *Curve_Init (void) /* Python BPy_Curve methods: */ /* gives access to */ /* name, pathlen totcol flag bevresol */ -/* resolu resolv width ext1 ext2 */ +/* resolu resolv width ext1 ext2 */ /* controlpoint loc rot size */ /* numpts */ /*****************************************************************************/ -static PyObject *Curve_getName(BPy_Curve *self) +static PyObject * +Curve_getName (BPy_Curve * self) { - PyObject *attr = PyString_FromString(self->curve->id.name+2); + PyObject *attr = PyString_FromString (self->curve->id.name + 2); - if (attr) return attr; + if (attr) + return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.name attribute")); + "couldn't get Curve.name attribute")); } -static PyObject *Curve_setName(BPy_Curve *self, PyObject *args) +static PyObject * +Curve_setName (BPy_Curve * self, PyObject * args) { - char*name; + char *name; char buf[50]; - - if (!PyArg_ParseTuple(args, "s", &(name))) + + if (!PyArg_ParseTuple (args, "s", &(name))) return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected string argument")); - PyOS_snprintf(buf, sizeof(buf), "%s", name); - rename_id(&self->curve->id, buf); /* proper way in Blender */ + "expected string argument")); + PyOS_snprintf (buf, sizeof (buf), "%s", name); + rename_id (&self->curve->id, buf); /* proper way in Blender */ - Py_INCREF(Py_None); + Py_INCREF (Py_None); return Py_None; } -static PyObject *Curve_getPathLen(BPy_Curve *self) +static PyObject * +Curve_getPathLen (BPy_Curve * self) { - PyObject *attr = PyInt_FromLong((long)self->curve->pathlen); + PyObject *attr = PyInt_FromLong ((long) self->curve->pathlen); - if (attr) return attr; + if (attr) + return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.pathlen attribute")); + "couldn't get Curve.pathlen attribute")); } -static PyObject *Curve_setPathLen(BPy_Curve *self, PyObject *args) +static PyObject * +Curve_setPathLen (BPy_Curve * self, PyObject * args) { - if (!PyArg_ParseTuple(args, "i", &(self->curve->pathlen))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int argument")); - - Py_INCREF(Py_None); - return Py_None; -} - - -static PyObject *Curve_getTotcol(BPy_Curve *self) -{ - PyObject *attr = PyInt_FromLong((long)self->curve->totcol); - - if (attr) return attr; - - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.totcol attribute")); -} - - -static PyObject *Curve_setTotcol(BPy_Curve *self, PyObject *args) -{ - - if (!PyArg_ParseTuple(args, "i", &(self->curve->totcol))) + if (!PyArg_ParseTuple (args, "i", &(self->curve->pathlen))) return (EXPP_ReturnPyObjError (PyExc_AttributeError, "expected int argument")); - - Py_INCREF(Py_None); + + Py_INCREF (Py_None); return Py_None; } -static PyObject *Curve_getMode(BPy_Curve *self) +static PyObject * +Curve_getTotcol (BPy_Curve * self) { - PyObject *attr = PyInt_FromLong((long)self->curve->flag); + PyObject *attr = PyInt_FromLong ((long) self->curve->totcol); - if (attr) return attr; + if (attr) + return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.flag attribute")); + "couldn't get Curve.totcol attribute")); } -static PyObject *Curve_setMode(BPy_Curve *self, PyObject *args) +static PyObject * +Curve_setTotcol (BPy_Curve * self, PyObject * args) { - if (!PyArg_ParseTuple(args, "i", &(self->curve->flag))) + if (!PyArg_ParseTuple (args, "i", &(self->curve->totcol))) return (EXPP_ReturnPyObjError (PyExc_AttributeError, "expected int argument")); - - Py_INCREF(Py_None); + + Py_INCREF (Py_None); return Py_None; } -static PyObject *Curve_getBevresol(BPy_Curve *self) +static PyObject * +Curve_getMode (BPy_Curve * self) { - PyObject *attr = PyInt_FromLong((long)self->curve->bevresol); + PyObject *attr = PyInt_FromLong ((long) self->curve->flag); - if (attr) return attr; + if (attr) + return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.bevresol attribute")); + "couldn't get Curve.flag attribute")); } -static PyObject *Curve_setBevresol(BPy_Curve *self, PyObject *args) +static PyObject * +Curve_setMode (BPy_Curve * self, PyObject * args) { - if (!PyArg_ParseTuple(args, "i", &(self->curve->bevresol))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int argument")); - - Py_INCREF(Py_None); + if (!PyArg_ParseTuple (args, "i", &(self->curve->flag))) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected int argument")); + + Py_INCREF (Py_None); return Py_None; } -static PyObject *Curve_getResolu(BPy_Curve *self) +static PyObject * +Curve_getBevresol (BPy_Curve * self) { - PyObject *attr = PyInt_FromLong((long)self->curve->resolu); + PyObject *attr = PyInt_FromLong ((long) self->curve->bevresol); - if (attr) return attr; + if (attr) + return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.resolu attribute")); + "couldn't get Curve.bevresol attribute")); } -static PyObject *Curve_setResolu(BPy_Curve *self, PyObject *args) +static PyObject * +Curve_setBevresol (BPy_Curve * self, PyObject * args) { - if (!PyArg_ParseTuple(args, "i", &(self->curve->resolu))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int argument")); - - Py_INCREF(Py_None); + if (!PyArg_ParseTuple (args, "i", &(self->curve->bevresol))) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected int argument")); + + Py_INCREF (Py_None); + return Py_None; +} + + +static PyObject * +Curve_getResolu (BPy_Curve * self) +{ + PyObject *attr = PyInt_FromLong ((long) self->curve->resolu); + + if (attr) + return attr; + + return (EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Curve.resolu attribute")); +} + + +static PyObject * +Curve_setResolu (BPy_Curve * self, PyObject * args) +{ + + if (!PyArg_ParseTuple (args, "i", &(self->curve->resolu))) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected int argument")); + + Py_INCREF (Py_None); return Py_None; } -static PyObject *Curve_getResolv(BPy_Curve *self) +static PyObject * +Curve_getResolv (BPy_Curve * self) { - PyObject *attr = PyInt_FromLong((long)self->curve->resolv); + PyObject *attr = PyInt_FromLong ((long) self->curve->resolv); - if (attr) return attr; + if (attr) + return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.resolv attribute")); + "couldn't get Curve.resolv attribute")); } -static PyObject *Curve_setResolv(BPy_Curve *self, PyObject *args) +static PyObject * +Curve_setResolv (BPy_Curve * self, PyObject * args) { - if (!PyArg_ParseTuple(args, "i", &(self->curve->resolv))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int argument")); - - Py_INCREF(Py_None); + if (!PyArg_ParseTuple (args, "i", &(self->curve->resolv))) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected int argument")); + + Py_INCREF (Py_None); return Py_None; } -static PyObject *Curve_getWidth(BPy_Curve *self) +static PyObject * +Curve_getWidth (BPy_Curve * self) { - PyObject *attr = PyFloat_FromDouble((double)self->curve->width); + PyObject *attr = PyFloat_FromDouble ((double) self->curve->width); - if (attr) return attr; + if (attr) + return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.width attribute")); + "couldn't get Curve.width attribute")); } -static PyObject *Curve_setWidth(BPy_Curve *self, PyObject *args) +static PyObject * +Curve_setWidth (BPy_Curve * self, PyObject * args) { - if (!PyArg_ParseTuple(args, "f", &(self->curve->width))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected float argument")); - - Py_INCREF(Py_None); + if (!PyArg_ParseTuple (args, "f", &(self->curve->width))) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected float argument")); + + Py_INCREF (Py_None); return Py_None; } -static PyObject *Curve_getExt1(BPy_Curve *self) +static PyObject * +Curve_getExt1 (BPy_Curve * self) { - PyObject *attr = PyFloat_FromDouble((double)self->curve->ext1); + PyObject *attr = PyFloat_FromDouble ((double) self->curve->ext1); - if (attr) return attr; + if (attr) + return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.ext1 attribute")); + "couldn't get Curve.ext1 attribute")); } -static PyObject *Curve_setExt1(BPy_Curve *self, PyObject *args) +static PyObject * +Curve_setExt1 (BPy_Curve * self, PyObject * args) { - if (!PyArg_ParseTuple(args, "f", &(self->curve->ext1))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected float argument")); - - Py_INCREF(Py_None); + if (!PyArg_ParseTuple (args, "f", &(self->curve->ext1))) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected float argument")); + + Py_INCREF (Py_None); return Py_None; } -static PyObject *Curve_getExt2(BPy_Curve *self) +static PyObject * +Curve_getExt2 (BPy_Curve * self) { - PyObject *attr = PyFloat_FromDouble((double)self->curve->ext2); + PyObject *attr = PyFloat_FromDouble ((double) self->curve->ext2); - if (attr) return attr; + if (attr) + return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.ext2 attribute")); + "couldn't get Curve.ext2 attribute")); } -static PyObject *Curve_setExt2(BPy_Curve *self, PyObject *args) +static PyObject * +Curve_setExt2 (BPy_Curve * self, PyObject * args) { - if (!PyArg_ParseTuple(args, "f", &(self->curve->ext2))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected float argument")); - - Py_INCREF(Py_None); + if (!PyArg_ParseTuple (args, "f", &(self->curve->ext2))) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected float argument")); + + Py_INCREF (Py_None); return Py_None; } @@ -433,83 +710,96 @@ static PyObject *Curve_setControlPoint(BPy_Curve *self, PyObject *args) */ -static PyObject *Curve_setControlPoint(BPy_Curve *self, PyObject *args) -{ PyObject *listargs=0; - Nurb*ptrnurb = self->curve->nurb.first; - int numcourbe,numpoint,i,j; - if (!ptrnurb){ Py_INCREF(Py_None);return Py_None;} +static PyObject * +Curve_setControlPoint (BPy_Curve * self, PyObject * args) +{ + PyObject *listargs = 0; + Nurb *ptrnurb = self->curve->nurb.first; + int numcourbe, numpoint, i, j; + + if (!ptrnurb) + { + Py_INCREF (Py_None); + return Py_None; + } if (ptrnurb->bp) - if (!PyArg_ParseTuple(args, "iiO", &numcourbe,&numpoint,&listargs)) + if (!PyArg_ParseTuple (args, "iiO", &numcourbe, &numpoint, &listargs)) return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int int list arguments")); + "expected int int list arguments")); if (ptrnurb->bezt) - if (!PyArg_ParseTuple(args, "iiO", &numcourbe,&numpoint,&listargs)) + if (!PyArg_ParseTuple (args, "iiO", &numcourbe, &numpoint, &listargs)) return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int int list arguments")); + "expected int int list arguments")); + + for (i = 0; i < numcourbe; i++) + ptrnurb = ptrnurb->next; - for(i = 0;i< numcourbe;i++) - ptrnurb=ptrnurb->next; if (ptrnurb->bp) - for(i = 0;i<4;i++) - ptrnurb->bp[numpoint].vec[i] = PyFloat_AsDouble(PyList_GetItem(listargs,i)); + for (i = 0; i < 4; i++) + ptrnurb->bp[numpoint].vec[i] = + PyFloat_AsDouble (PyList_GetItem (listargs, i)); + if (ptrnurb->bezt) - for(i = 0;i<3;i++) - for(j = 0;j<3;j++) - ptrnurb->bezt[numpoint].vec[i][j] = PyFloat_AsDouble(PyList_GetItem(listargs,i*3+j)); - - Py_INCREF(Py_None); + for (i = 0; i < 3; i++) + for (j = 0; j < 3; j++) + ptrnurb->bezt[numpoint].vec[i][j] = + PyFloat_AsDouble (PyList_GetItem (listargs, i * 3 + j)); + + Py_INCREF (Py_None); return Py_None; } -static PyObject *Curve_getControlPoint(BPy_Curve *self, PyObject *args) +static PyObject * +Curve_getControlPoint (BPy_Curve * self, PyObject * args) { - PyObject* liste = PyList_New(0); /* return values */ + PyObject *liste = PyList_New (0); /* return values */ - Nurb*ptrnurb; - int i,j; + Nurb *ptrnurb; + int i, j; /* input args: requested curve and point number on curve */ - int numcourbe, numpoint; - - if (!PyArg_ParseTuple(args, "ii", &numcourbe,&numpoint)) + int numcourbe, numpoint; + + if (!PyArg_ParseTuple (args, "ii", &numcourbe, &numpoint)) return (EXPP_ReturnPyObjError (PyExc_AttributeError, "expected int int arguments")); - if( (numcourbe < 0) || (numpoint < 0) ) + if ((numcourbe < 0) || (numpoint < 0)) return (EXPP_ReturnPyObjError (PyExc_AttributeError, " arguments must be non-negative")); /* if no nurbs in this curve obj */ - if (!self->curve->nurb.first) return liste; + if (!self->curve->nurb.first) + return liste; /* walk the list of nurbs to find requested numcourbe */ ptrnurb = self->curve->nurb.first; - for(i = 0; i < numcourbe; i++) + for (i = 0; i < numcourbe; i++) { - ptrnurb=ptrnurb->next; - if( !ptrnurb ) /* if zero, we ran just ran out of curves */ - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "curve index out of range")); + ptrnurb = ptrnurb->next; + if (!ptrnurb) /* if zero, we ran just ran out of curves */ + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "curve index out of range")); } - + /* check numpoint param against pntsu */ - if( numpoint >= ptrnurb->pntsu ) - return (EXPP_ReturnPyObjError( PyExc_AttributeError, - "point index out of range")); + if (numpoint >= ptrnurb->pntsu) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "point index out of range")); - if (ptrnurb->bp) /* if we are a nurb curve, you get 4 values */ + if (ptrnurb->bp) /* if we are a nurb curve, you get 4 values */ { - for(i = 0; i< 4; i++) - PyList_Append(liste, PyFloat_FromDouble( ptrnurb->bp[numpoint].vec[i])); + for (i = 0; i < 4; i++) + PyList_Append (liste, + PyFloat_FromDouble (ptrnurb->bp[numpoint].vec[i])); } - - if (ptrnurb->bezt) /* if we are a bezier, you get 9 values */ + + if (ptrnurb->bezt) /* if we are a bezier, you get 9 values */ { - /* note to jacques: I commented out the PyList_New() since we are appending the values below. this never gets filled and just returns 9 null objs at the front of the list */ - /* liste = PyList_New(9); */ - for(i = 0; i< 3; i++) - for(j = 0; j< 3; j++) - PyList_Append(liste, - PyFloat_FromDouble( ptrnurb->bezt[numpoint].vec[i][j])); + for (i = 0; i < 3; i++) + for (j = 0; j < 3; j++) + PyList_Append (liste, + PyFloat_FromDouble (ptrnurb->bezt[numpoint]. + vec[i][j])); } return liste; @@ -517,112 +807,126 @@ static PyObject *Curve_getControlPoint(BPy_Curve *self, PyObject *args) -static PyObject *Curve_getLoc(BPy_Curve *self) +static PyObject * +Curve_getLoc (BPy_Curve * self) { int i; - PyObject* liste = PyList_New(3); - for(i = 0;i< 3;i++) - PyList_SetItem(liste, i, PyFloat_FromDouble( self->curve->loc[i])); + PyObject *liste = PyList_New (3); + for (i = 0; i < 3; i++) + PyList_SetItem (liste, i, PyFloat_FromDouble (self->curve->loc[i])); return liste; } -static PyObject *Curve_setLoc(BPy_Curve *self, PyObject *args) +static PyObject * +Curve_setLoc (BPy_Curve * self, PyObject * args) { - PyObject *listargs=0; - int i; - if (!PyArg_ParseTuple(args, "O", &listargs)) - return EXPP_ReturnPyObjError(PyExc_AttributeError,"expected list argument"); -if (!PyList_Check(listargs)) - return (EXPP_ReturnPyObjError(PyExc_TypeError,"expected a list")); - for(i = 0;i<3;i++){ - PyObject * xx = PyList_GetItem(listargs,i); - self->curve->loc[i] =PyFloat_AsDouble(xx); - } - Py_INCREF(Py_None); + PyObject *listargs = 0; + int i; + if (!PyArg_ParseTuple (args, "O", &listargs)) + return EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected list argument"); + if (!PyList_Check (listargs)) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected a list")); + for (i = 0; i < 3; i++) + { + PyObject *xx = PyList_GetItem (listargs, i); + self->curve->loc[i] = PyFloat_AsDouble (xx); + } + Py_INCREF (Py_None); return Py_None; } -static PyObject *Curve_getRot(BPy_Curve *self) +static PyObject * +Curve_getRot (BPy_Curve * self) { int i; - PyObject* liste = PyList_New(3); - for(i = 0;i< 3;i++) - PyList_SetItem(liste, i, PyFloat_FromDouble( self->curve->rot[i])); + PyObject *liste = PyList_New (3); + for (i = 0; i < 3; i++) + PyList_SetItem (liste, i, PyFloat_FromDouble (self->curve->rot[i])); return liste; } -static PyObject *Curve_setRot(BPy_Curve *self, PyObject *args) +static PyObject * +Curve_setRot (BPy_Curve * self, PyObject * args) { - PyObject *listargs=0; - int i; - if (!PyArg_ParseTuple(args, "O", &listargs)) - return EXPP_ReturnPyObjError(PyExc_AttributeError,"expected list argument"); -if (!PyList_Check(listargs)) - return (EXPP_ReturnPyObjError(PyExc_TypeError,"expected a list")); - for(i = 0;i<3;i++){ - PyObject * xx = PyList_GetItem(listargs,i); - self->curve->rot[i] =PyFloat_AsDouble(xx); - } - Py_INCREF(Py_None); + PyObject *listargs = 0; + int i; + if (!PyArg_ParseTuple (args, "O", &listargs)) + return EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected list argument"); + if (!PyList_Check (listargs)) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected a list")); + for (i = 0; i < 3; i++) + { + PyObject *xx = PyList_GetItem (listargs, i); + self->curve->rot[i] = PyFloat_AsDouble (xx); + } + Py_INCREF (Py_None); return Py_None; } -static PyObject *Curve_getSize(BPy_Curve *self) +static PyObject * +Curve_getSize (BPy_Curve * self) { int i; - PyObject* liste = PyList_New(3); - for(i = 0;i< 3;i++) - PyList_SetItem(liste, i, PyFloat_FromDouble( self->curve->size[i])); + PyObject *liste = PyList_New (3); + for (i = 0; i < 3; i++) + PyList_SetItem (liste, i, PyFloat_FromDouble (self->curve->size[i])); return liste; } -static PyObject *Curve_setSize(BPy_Curve *self, PyObject *args) +static PyObject * +Curve_setSize (BPy_Curve * self, PyObject * args) { - PyObject *listargs=0; - int i; - if (!PyArg_ParseTuple(args, "O", &listargs)) - return EXPP_ReturnPyObjError(PyExc_AttributeError,"expected list argument"); -if (!PyList_Check(listargs)) - return (EXPP_ReturnPyObjError(PyExc_TypeError,"expected a list")); - for(i = 0;i<3;i++){ - PyObject * xx = PyList_GetItem(listargs,i); - self->curve->size[i] =PyFloat_AsDouble(xx); - } - Py_INCREF(Py_None); + PyObject *listargs = 0; + int i; + if (!PyArg_ParseTuple (args, "O", &listargs)) + return EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected list argument"); + if (!PyList_Check (listargs)) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected a list")); + for (i = 0; i < 3; i++) + { + PyObject *xx = PyList_GetItem (listargs, i); + self->curve->size[i] = PyFloat_AsDouble (xx); + } + Py_INCREF (Py_None); return Py_None; } -/* sds */ + /* * Count the number of splines in a Curve Object * int getNumCurves() */ -static PyObject *Curve_getNumCurves(BPy_Curve *self) +static PyObject * +Curve_getNumCurves (BPy_Curve * self) { Nurb *ptrnurb; - PyObject* ret_val; - int num_curves = 0; /* start with no splines */ + PyObject *ret_val; + int num_curves = 0; /* start with no splines */ /* get curve */ ptrnurb = self->curve->nurb.first; - if( ptrnurb ) /* we have some nurbs in this curve */ + if (ptrnurb) /* we have some nurbs in this curve */ { - while( 1 ) + while (1) { ++num_curves; ptrnurb = ptrnurb->next; - if( !ptrnurb ) /* no more curves */ + if (!ptrnurb) /* no more curves */ break; } } - ret_val = PyInt_FromLong((long) num_curves); + ret_val = PyInt_FromLong ((long) num_curves); - if (ret_val) return ret_val; + if (ret_val) + return ret_val; /* oops! */ return (EXPP_ReturnPyObjError (PyExc_RuntimeError, @@ -636,44 +940,46 @@ static PyObject *Curve_getNumCurves(BPy_Curve *self) * */ -static PyObject *Curve_getNumPoints(BPy_Curve *self, PyObject *args) +static PyObject * +Curve_getNumPoints (BPy_Curve * self, PyObject * args) { Nurb *ptrnurb; - PyObject* ret_val; - int curve_num = 0; /* default spline number */ + PyObject *ret_val; + int curve_num = 0; /* default spline number */ int i; /* parse input arg */ - if( !PyArg_ParseTuple( args, "|i", &curve_num )) - return( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected int argument")); + if (!PyArg_ParseTuple (args, "|i", &curve_num)) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected int argument")); /* check arg - must be non-negative */ - if( curve_num < 0 ) - return( EXPP_ReturnPyObjError( PyExc_AttributeError, - "argument must be non-negative")); - - + if (curve_num < 0) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "argument must be non-negative")); + + /* walk the list of curves looking for our curve */ ptrnurb = self->curve->nurb.first; - if( !ptrnurb ) /* no splines in this Curve */ + if (!ptrnurb) /* no splines in this Curve */ { - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "no splines in this Curve")); + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "no splines in this Curve")); } - - for( i = 0; i < curve_num; i++ ) + + for (i = 0; i < curve_num; i++) { ptrnurb = ptrnurb->next; - if( !ptrnurb ) /* if zero, we ran just ran out of curves */ - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "curve index out of range")); + if (!ptrnurb) /* if zero, we ran just ran out of curves */ + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "curve index out of range")); } - - /* pntsu is the number of points in curve */ - ret_val = PyInt_FromLong((long) ptrnurb->pntsu); - if (ret_val) return ret_val; + /* pntsu is the number of points in curve */ + ret_val = PyInt_FromLong ((long) ptrnurb->pntsu); + + if (ret_val) + return ret_val; /* oops! */ return (EXPP_ReturnPyObjError (PyExc_RuntimeError, @@ -686,45 +992,46 @@ static PyObject *Curve_getNumPoints(BPy_Curve *self, PyObject *args) * int isNurb( curve_num=0 ) */ -static PyObject *Curve_isNurb( BPy_Curve *self, PyObject *args ) +static PyObject * +Curve_isNurb (BPy_Curve * self, PyObject * args) { - int curve_num=0; /* default value */ + int curve_num = 0; /* default value */ int is_nurb; Nurb *ptrnurb; - PyObject* ret_val; + PyObject *ret_val; int i; /* parse and check input args */ - if( !PyArg_ParseTuple( args, "|i", &curve_num )) + if (!PyArg_ParseTuple (args, "|i", &curve_num)) { - return( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected int argument")); + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected int argument")); } - if( curve_num < 0 ) + if (curve_num < 0) { - return( EXPP_ReturnPyObjError( PyExc_AttributeError, + return (EXPP_ReturnPyObjError (PyExc_AttributeError, "curve number must be non-negative")); } ptrnurb = self->curve->nurb.first; - if( !ptrnurb ) /* no splines in this curve */ - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "no splines in this Curve")); + if (!ptrnurb) /* no splines in this curve */ + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "no splines in this Curve")); - for( i = 0; i < curve_num; i++ ) + for (i = 0; i < curve_num; i++) { ptrnurb = ptrnurb->next; - if( !ptrnurb ) /* if zero, we ran just ran out of curves */ - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "curve index out of range")); + if (!ptrnurb) /* if zero, we ran just ran out of curves */ + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "curve index out of range")); } - + /* right now, there are only two curve types, nurb and bezier. */ is_nurb = ptrnurb->bp ? 1 : 0; - - ret_val = PyInt_FromLong( (long) is_nurb ); - if( ret_val ) + + ret_val = PyInt_FromLong ((long) is_nurb); + if (ret_val) return ret_val; /* oops */ @@ -732,16 +1039,14 @@ static PyObject *Curve_isNurb( BPy_Curve *self, PyObject *args ) "couldn't get curve type")); } - - - /*****************************************************************************/ /* Function: CurveDeAlloc */ /* Description: This is a callback function for the BPy_Curve type. It is */ /* the destructor function. */ /*****************************************************************************/ -static void CurveDeAlloc (BPy_Curve *self) +static void +CurveDeAlloc (BPy_Curve * self) { PyObject_DEL (self); } @@ -752,53 +1057,52 @@ static void CurveDeAlloc (BPy_Curve *self) /* the function that accesses BPy_Curve "member variables" and */ /* methods. */ /*****************************************************************************/ -static PyObject *CurveGetAttr (BPy_Curve *self, char *name)//getattr +static PyObject * +CurveGetAttr (BPy_Curve * self, char *name) /* getattr */ { PyObject *attr = Py_None; - if (strcmp(name, "name") == 0) - attr = PyString_FromString(self->curve->id.name+2); - if (strcmp(name, "pathlen") == 0) - attr = PyInt_FromLong(self->curve->pathlen); - if (strcmp(name, "totcol") == 0) - attr = PyInt_FromLong(self->curve->totcol); - if (strcmp(name, "flag") == 0) - attr = PyInt_FromLong(self->curve->flag); - if (strcmp(name, "bevresol") == 0) - attr = PyInt_FromLong(self->curve->bevresol); - if (strcmp(name, "resolu") == 0) - attr = PyInt_FromLong(self->curve->resolu); - if (strcmp(name, "resolv") == 0) - attr = PyInt_FromLong(self->curve->resolv); - if (strcmp(name, "width") == 0) - attr = PyFloat_FromDouble(self->curve->width); - if (strcmp(name, "ext1") == 0) - attr = PyFloat_FromDouble(self->curve->ext1); - if (strcmp(name, "ext2") == 0) - attr = PyFloat_FromDouble(self->curve->ext2); - if (strcmp(name, "loc") == 0) - return Curve_getLoc(self); - if (strcmp(name, "rot") == 0) - return Curve_getRot(self); - if (strcmp(name, "size") == 0) - return Curve_getSize(self); + if (strcmp (name, "name") == 0) + attr = PyString_FromString (self->curve->id.name + 2); + if (strcmp (name, "pathlen") == 0) + attr = PyInt_FromLong (self->curve->pathlen); + if (strcmp (name, "totcol") == 0) + attr = PyInt_FromLong (self->curve->totcol); + if (strcmp (name, "flag") == 0) + attr = PyInt_FromLong (self->curve->flag); + if (strcmp (name, "bevresol") == 0) + attr = PyInt_FromLong (self->curve->bevresol); + if (strcmp (name, "resolu") == 0) + attr = PyInt_FromLong (self->curve->resolu); + if (strcmp (name, "resolv") == 0) + attr = PyInt_FromLong (self->curve->resolv); + if (strcmp (name, "width") == 0) + attr = PyFloat_FromDouble (self->curve->width); + if (strcmp (name, "ext1") == 0) + attr = PyFloat_FromDouble (self->curve->ext1); + if (strcmp (name, "ext2") == 0) + attr = PyFloat_FromDouble (self->curve->ext2); + if (strcmp (name, "loc") == 0) + return Curve_getLoc (self); + if (strcmp (name, "rot") == 0) + return Curve_getRot (self); + if (strcmp (name, "size") == 0) + return Curve_getSize (self); #if 0 - if (strcmp(name, "numpts") == 0) - return Curve_getNumPoints(self); + if (strcmp (name, "numpts") == 0) + return Curve_getNumPoints (self); #endif - - - if (!attr) return (EXPP_ReturnPyObjError (PyExc_MemoryError, - "couldn't create PyObject")); + "couldn't create PyObject")); - if (attr != Py_None) return attr; /* member attribute found, return it */ + if (attr != Py_None) + return attr; /* member attribute found, return it */ /* not an attribute, search the methods table */ - return Py_FindMethod(BPy_Curve_methods, (PyObject *)self, name); + return Py_FindMethod (BPy_Curve_methods, (PyObject *) self, name); } /*****************************************************************************/ @@ -806,19 +1110,21 @@ static PyObject *CurveGetAttr (BPy_Curve *self, char *name)//getattr /* Description: This is a callback function for the BPy_Curve type. It is the */ /* function that sets Curve Data attributes (member variables). */ /*****************************************************************************/ -static int CurveSetAttr (BPy_Curve *self, char *name, PyObject *value) -{ PyObject *valtuple; +static int +CurveSetAttr (BPy_Curve * self, char *name, PyObject * value) +{ + PyObject *valtuple; PyObject *error = NULL; - valtuple = Py_BuildValue("(O)", value); - //resolu resolv width ext1 ext2 - if (!valtuple) - return EXPP_ReturnIntError(PyExc_MemoryError, - "CurveSetAttr: couldn't create PyTuple"); + valtuple = Py_BuildValue ("(O)", value); + /* resolu resolv width ext1 ext2 */ + if (!valtuple) + return EXPP_ReturnIntError (PyExc_MemoryError, + "CurveSetAttr: couldn't create PyTuple"); if (strcmp (name, "name") == 0) error = Curve_setName (self, valtuple); else if (strcmp (name, "pathlen") == 0) - error = Curve_setPathLen(self, valtuple); + error = Curve_setPathLen (self, valtuple); else if (strcmp (name, "resolu") == 0) error = Curve_setResolu (self, valtuple); else if (strcmp (name, "resolv") == 0) @@ -836,24 +1142,24 @@ static int CurveSetAttr (BPy_Curve *self, char *name, PyObject *value) else if (strcmp (name, "size") == 0) error = Curve_setSize (self, valtuple); - else { /* Error */ - Py_DECREF(valtuple); + else + { /* Error */ + Py_DECREF (valtuple); - if ((strcmp (name, "Types") == 0) || - (strcmp (name, "Modes") == 0)) - return (EXPP_ReturnIntError (PyExc_AttributeError, - "constant dictionary -- cannot be changed")); + if ((strcmp (name, "Types") == 0) || (strcmp (name, "Modes") == 0)) + return (EXPP_ReturnIntError (PyExc_AttributeError, + "constant dictionary -- cannot be changed")); - else - return (EXPP_ReturnIntError (PyExc_KeyError, - "attribute not found")); - } + else + return (EXPP_ReturnIntError (PyExc_KeyError, "attribute not found")); + } - Py_DECREF(valtuple); + Py_DECREF (valtuple); - if (error != Py_None) return -1; - Py_DECREF(Py_None); - return 0; + if (error != Py_None) + return -1; + Py_DECREF (Py_None); + return 0; } @@ -862,39 +1168,42 @@ static int CurveSetAttr (BPy_Curve *self, char *name, PyObject *value) /* Description: This is a callback function for the BPy_Curve type. It */ /* builds a meaninful string to represent curve objects. */ /*****************************************************************************/ -static PyObject *CurveRepr (BPy_Curve *self) //used by 'repr' +static PyObject * +CurveRepr (BPy_Curve * self) /* used by 'repr' */ { - - return PyString_FromFormat("[Curve \"%s\"]", self->curve->id.name+2); + + return PyString_FromFormat ("[Curve \"%s\"]", self->curve->id.name + 2); } -PyObject* Curve_CreatePyObject (struct Curve *curve) +PyObject * +Curve_CreatePyObject (struct Curve * curve) { - BPy_Curve * blen_object; + BPy_Curve *blen_object; - blen_object = (BPy_Curve*)PyObject_NEW (BPy_Curve, &Curve_Type); + blen_object = (BPy_Curve *) PyObject_NEW (BPy_Curve, &Curve_Type); - if (blen_object == NULL) + if (blen_object == NULL) { - return (NULL); + return (NULL); } - blen_object->curve = curve; - return ((PyObject*)blen_object); + blen_object->curve = curve; + return ((PyObject *) blen_object); } -int Curve_CheckPyObject (PyObject *py_obj) +int +Curve_CheckPyObject (PyObject * py_obj) { -return (py_obj->ob_type == &Curve_Type); + return (py_obj->ob_type == &Curve_Type); } -struct Curve* Curve_FromPyObject (PyObject *py_obj) +struct Curve * +Curve_FromPyObject (PyObject * py_obj) { - BPy_Curve * blen_obj; + BPy_Curve *blen_obj; - blen_obj = (BPy_Curve*)py_obj; - return (blen_obj->curve); + blen_obj = (BPy_Curve *) py_obj; + return (blen_obj->curve); } - diff --git a/source/blender/python/api2_2x/Curve.h b/source/blender/python/api2_2x/Curve.h index a89d0b7c94f..a42aa13a611 100644 --- a/source/blender/python/api2_2x/Curve.h +++ b/source/blender/python/api2_2x/Curve.h @@ -24,7 +24,7 @@ * * This is a new part of Blender. * - * Contributor(s): Jacques Guignot + * Contributor(s): Jacques Guignot, Stephen Swaney * * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ @@ -32,197 +32,6 @@ #ifndef EXPP_CURVE_H #define EXPP_CURVE_H -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "gen_utils.h" -#include "bpy_types.h" - -/*****************************************************************************/ -/* Python API function prototypes for the Curve module. */ -/*****************************************************************************/ -static PyObject *M_Curve_New (PyObject *self, PyObject *args); -static PyObject *M_Curve_Get (PyObject *self, PyObject *args); - -/*****************************************************************************/ -/* The following string definitions are used for documentation strings. */ -/* In Python these will be written to the console when doing a */ -/* Blender.Curve.__doc__ */ -/*****************************************************************************/ -char M_Curve_doc[] = "The Blender Curve module\n\n\ -This module provides access to **Curve Data** in Blender.\n\ -Functions :\n\ - New(opt name) : creates a new curve object with the given name (optional)\n\ - Get(name) : retreives a curve with the given name (mandatory)\n\ - get(name) : same as Get. Kept for compatibility reasons"; -char M_Curve_New_doc[] =""; -char M_Curve_Get_doc[] ="xxx"; -/*****************************************************************************/ -/* Python method structure definition for Blender.Curve module: */ -/*****************************************************************************/ -struct PyMethodDef M_Curve_methods[] = { - {"New",(PyCFunction)M_Curve_New, METH_VARARGS,M_Curve_New_doc}, - {"Get", M_Curve_Get, METH_VARARGS, M_Curve_Get_doc}, - {"get", M_Curve_Get, METH_VARARGS, M_Curve_Get_doc}, - {NULL, NULL, 0, NULL} -}; - - -/*****************************************************************************/ -/* Python BPy_Curve methods declarations: */ -/*****************************************************************************/ -static PyObject *Curve_getName(BPy_Curve *self); -static PyObject *Curve_setName(BPy_Curve *self, PyObject *args); -static PyObject *Curve_getPathLen(BPy_Curve *self); -static PyObject *Curve_setPathLen(BPy_Curve *self, PyObject *args); -static PyObject *Curve_getTotcol(BPy_Curve *self); -static PyObject *Curve_setTotcol(BPy_Curve *self, PyObject *args); -static PyObject *Curve_getMode(BPy_Curve *self); -static PyObject *Curve_setMode(BPy_Curve *self, PyObject *args); -static PyObject *Curve_getBevresol(BPy_Curve *self); -static PyObject *Curve_setBevresol(BPy_Curve *self, PyObject *args); -static PyObject *Curve_getResolu(BPy_Curve *self); -static PyObject *Curve_setResolu(BPy_Curve *self, PyObject *args); -static PyObject *Curve_getResolv(BPy_Curve *self); -static PyObject *Curve_setResolv(BPy_Curve *self, PyObject *args); -static PyObject *Curve_getWidth(BPy_Curve *self); -static PyObject *Curve_setWidth(BPy_Curve *self, PyObject *args); -static PyObject *Curve_getExt1(BPy_Curve *self); -static PyObject *Curve_setExt1(BPy_Curve *self, PyObject *args); -static PyObject *Curve_getExt2(BPy_Curve *self); -static PyObject *Curve_setExt2(BPy_Curve *self, PyObject *args); -static PyObject *Curve_getControlPoint(BPy_Curve *self, PyObject *args); -static PyObject *Curve_setControlPoint(BPy_Curve *self, PyObject *args); -static PyObject *Curve_getLoc(BPy_Curve *self); -static PyObject *Curve_setLoc(BPy_Curve *self, PyObject *args); -static PyObject *Curve_getRot(BPy_Curve *self); -static PyObject *Curve_setRot(BPy_Curve *self, PyObject *args); -static PyObject *Curve_getSize(BPy_Curve *self); -static PyObject *Curve_setSize(BPy_Curve *self, PyObject *args); -static PyObject *Curve_getNumCurves(BPy_Curve *self); -static PyObject *Curve_isNurb( BPy_Curve *self, PyObject *args ); -static PyObject *Curve_getNumPoints(BPy_Curve *self, PyObject *args); -static PyObject *Curve_getNumPoints(BPy_Curve *self, PyObject *args); - -/*****************************************************************************/ -/* Python BPy_Curve methods table: */ -/*****************************************************************************/ -static PyMethodDef BPy_Curve_methods[] = { - {"getName", (PyCFunction)Curve_getName, - METH_NOARGS,"() - Return Curve Data name"}, - {"setName", (PyCFunction)Curve_setName, - METH_VARARGS,"() - Sets Curve Data name"}, - {"getPathLen", (PyCFunction)Curve_getPathLen, - METH_NOARGS,"() - Return Curve path length"}, - {"setPathLen", (PyCFunction)Curve_setPathLen, - METH_VARARGS,"(int) - Sets Curve path length"}, - {"getTotcol", (PyCFunction)Curve_getTotcol, - METH_NOARGS,"() - Return the number of materials of the curve"}, - {"setTotcol", (PyCFunction)Curve_setTotcol, - METH_VARARGS,"(int) - Sets the number of materials of the curve"}, - {"getFlag", (PyCFunction)Curve_getMode, - METH_NOARGS,"() - Return flag (see the doc for semantic)"}, - {"setFlag", (PyCFunction)Curve_setMode, - METH_VARARGS,"(int) - Sets flag (see the doc for semantic)"}, - {"getBevresol", (PyCFunction)Curve_getBevresol, - METH_NOARGS,"() - Return bevel resolution"}, - {"setBevresol", (PyCFunction)Curve_setBevresol, - METH_VARARGS,"(int) - Sets bevel resolution"}, - {"getResolu", (PyCFunction)Curve_getResolu, - METH_NOARGS,"() - Return U resolution"}, - {"setResolu", (PyCFunction)Curve_setResolu, - METH_VARARGS,"(int) - Sets U resolution"}, - {"getResolv", (PyCFunction)Curve_getResolv, - METH_NOARGS,"() - Return V resolution"}, - {"setResolv", (PyCFunction)Curve_setResolv, - METH_VARARGS,"(int) - Sets V resolution"}, - {"getWidth", (PyCFunction)Curve_getWidth, - METH_NOARGS,"() - Return curve width"}, - {"setWidth", (PyCFunction)Curve_setWidth, - METH_VARARGS,"(int) - Sets curve width"}, - {"getExt1", (PyCFunction)Curve_getExt1, - METH_NOARGS,"() - Returns extent 1 of the bevel"}, - {"setExt1", (PyCFunction)Curve_setExt1, - METH_VARARGS,"(int) - Sets extent 1 of the bevel"}, - {"getExt2", (PyCFunction)Curve_getExt2, - METH_NOARGS,"() - Return extent 2 of the bevel "}, - {"setExt2", (PyCFunction)Curve_setExt2, - METH_VARARGS,"(int) - Sets extent 2 of the bevel "}, - {"getControlPoint", (PyCFunction)Curve_getControlPoint, - METH_VARARGS,"(int numcurve,int numpoint) -\ -Gets a control point.Depending upon the curve type, returne a list of 4 or 9 floats"}, - {"setControlPoint", (PyCFunction)Curve_setControlPoint, - METH_VARARGS,"(int numcurve,int numpoint,float x,float y,float z,\ -loat w)(nurbs) or (int numcurve,int numpoint,float x1,...,x9(bezier)\ -Sets a control point "}, - {"getLoc", (PyCFunction)Curve_getLoc, - METH_NOARGS,"() - Gets Location of the curve (a 3-tuple) "}, - {"setLoc", (PyCFunction)Curve_setLoc, - METH_VARARGS,"(3-tuple) - Sets Location "}, - {"getRot", (PyCFunction)Curve_getRot, - METH_NOARGS,"() - Gets curve rotation"}, - {"setRot", (PyCFunction)Curve_setRot, - METH_VARARGS,"(3-tuple) - Sets curve rotation"}, - {"getSize", (PyCFunction)Curve_getSize, - METH_NOARGS,"() - Gets curve size"}, - {"setSize", (PyCFunction)Curve_setSize, - METH_VARARGS,"(3-tuple) - Sets curve size"}, - {"getNumCurves", (PyCFunction)Curve_getNumCurves, - METH_NOARGS,"() - Gets # of curves"}, - {"isNurb", (PyCFunction)Curve_isNurb, - METH_VARARGS,"(nothing or integer) - returns 1 or 0, depending upon the curve being a Nurb"}, - {"getNumPoints", (PyCFunction)Curve_getNumPoints, - METH_VARARGS,"(nothing or integer) - returns the number of points of the specified curve"}, - {0} -}; - -/*****************************************************************************/ -/* Python Curve_Type callback function prototypes: */ -/*****************************************************************************/ -static void CurveDeAlloc (BPy_Curve *msh); -//static int CurvePrint (BPy_Curve *msh, FILE *fp, int flags); -static int CurveSetAttr (BPy_Curve *msh, char *name, PyObject *v); -static PyObject *CurveGetAttr (BPy_Curve *msh, char *name); -static PyObject *CurveRepr (BPy_Curve *msh); -// PyObject* Curve_CreatePyObject (struct Curve *curve); -//int Curve_CheckPyObject (PyObject *py_obj); -//struct Curve* Curve_FromPyObject (PyObject *py_obj); - - -/*****************************************************************************/ -/* Python Curve_Type structure definition: */ -/*****************************************************************************/ -PyTypeObject Curve_Type = -{ - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "Curve", /* tp_name */ - sizeof (BPy_Curve), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)CurveDeAlloc, /* tp_dealloc */ - 0, /* tp_print */ - (getattrfunc)CurveGetAttr, /* tp_getattr */ - (setattrfunc)CurveSetAttr, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)CurveRepr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_as_hash */ - 0,0,0,0,0,0, - 0, /* tp_doc */ - 0,0,0,0,0,0, - BPy_Curve_methods, /* tp_methods */ - 0, /* tp_members */ -}; +#include #endif /* EXPP_CURVE_H */ diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c index 97f7bb88a64..5ad4387b483 100644 --- a/source/blender/python/api2_2x/Draw.c +++ b/source/blender/python/api2_2x/Draw.c @@ -34,130 +34,412 @@ * implementation. Non-trivial original comments are marked with an * @ symbol at their beginning. */ +#include "Draw.h" + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef WIN32 +#include "BLI_winstuff.h" +#endif + +#include "MEM_guardedalloc.h" + +#include "BMF_Api.h" + +#include "DNA_screen_types.h" + +#include "DNA_text_types.h" + +#include "BKE_global.h" +#include "BKE_library.h" +#include "BKE_object.h" + +#include "BIF_gl.h" +#include "BIF_screen.h" +#include "BIF_space.h" +#include "BIF_interface.h" +#include "BIF_mywindow.h" #include "BIF_toolbox.h" -#include "Draw.h" +#include "BPI_script.h" /* script struct */ + +#include "interface.h" +#include "mydevice.h" /*@ for all the event constants */ + /* declared in ../BPY_extern.h, * used to control global dictionary persistence: */ extern short EXPP_releaseGlobalDict; -static void Button_dealloc(PyObject *self) -{ - Button *but = (Button*)self; +/* This one was an extern in BPY_main.h, but only opy_draw.c was using it */ +int g_window_redrawn; - if(but->type == 3) MEM_freeN (but->val.asstr); - - PyObject_DEL (self); +/*@ hack to flag that window redraw has happened inside slider callback: */ +int EXPP_disable_force_draw = 0; + +/* + * forward declarations for internal functions + */ +static void Button_dealloc (PyObject * self); +static PyObject *Button_getattr (PyObject * self, char *name); +static PyObject *Button_repr (PyObject * self); +static int Button_setattr (PyObject * self, char *name, PyObject * v); + +static Button *newbutton (void); + +/* GUI interface routines */ + +static void exit_pydraw (SpaceScript * sc, short error); +static void exec_callback (SpaceScript * sc, PyObject * callback, + PyObject * args); +static void spacescript_do_pywin_buttons (SpaceScript * sc, + unsigned short event); + +static PyObject *Method_Exit (PyObject * self, PyObject * args); +static PyObject *Method_Register (PyObject * self, PyObject * args); +static PyObject *Method_Redraw (PyObject * self, PyObject * args); +static PyObject *Method_Draw (PyObject * self, PyObject * args); +static PyObject *Method_Create (PyObject * self, PyObject * args); + +static PyObject *Method_Button (PyObject * self, PyObject * args); +static PyObject *Method_Menu (PyObject * self, PyObject * args); +static PyObject *Method_Toggle (PyObject * self, PyObject * args); +static PyObject *Method_Slider (PyObject * self, PyObject * args); +static PyObject *Method_Scrollbar (PyObject * self, PyObject * args); +static PyObject *Method_Number (PyObject * self, PyObject * args); +static PyObject *Method_String (PyObject * self, PyObject * args); +static PyObject *Method_GetStringWidth (PyObject * self, PyObject * args); +static PyObject *Method_Text (PyObject * self, PyObject * args); +static PyObject *Method_PupMenu (PyObject * self, PyObject * args); + +static uiBlock *Get_uiBlock (void); +static void py_slider_update (void *butv, void *data2_unused); + +static char Draw_doc[] = "The Blender.Draw submodule"; + +static char Method_Register_doc[] = + "(draw, event, button) - Register callbacks for windowing\n\n\ +(draw) A function to draw the screen, taking no arguments\n\ +(event) A function to handle events, taking 2 arguments (evt, val)\n\ + (evt) The event number\n\ + (val) The value modifier (for key and mouse press/release)\n\ +(button) A function to handle button events, taking 1 argument (evt)\n\ + (evt) The button number\n\n\ +A None object can be passed if a callback is unused."; + + +static char Method_Redraw_doc[] = "([after]) - Queue a redraw event\n\n\ +[after=0] Determines whether the redraw is processed before\n\ +or after other input events.\n\n\ +Redraw events are buffered so that regardless of how many events\n\ +are queued the window only receives one redraw event."; + +static char Method_Draw_doc[] = "() - Force an immediate redraw\n\n\ +Forced redraws are not buffered, in other words the window is redrawn\n\ +exactly once for everytime this function is called."; + + +static char Method_Create_doc[] = + "(value) - Create a default Button object\n\n\ + (value) - The value to store in the button\n\n\ + Valid values are ints, floats, and strings"; + +static char Method_Button_doc[] = + "(name, event, x, y, width, height, [tooltip]) - Create a new Button \ +(push) button\n\n\ +(name) A string to display on the button\n\ +(event) The event number to pass to the button event function when activated\n\ +(x, y) The lower left coordinate of the button\n\ +(width, height) The button width and height\n\ +[tooltip=] The button's tooltip"; + +static char Method_Menu_doc[] = + "(name, event, x, y, width, height, default, [tooltip]) - Create a new Menu \ +button\n\n\ +(name) A string to display on the button\n\ +(event) The event number to pass to the button event function when activated\n\ +(x, y) The lower left coordinate of the button\n\ +(width, height) The button width and height\n\ +(default) The number of the option to be selected by default\n\ +[tooltip=" "] The button's tooltip\n\n\ +The menu options are specified through the name of the\n\ +button. Options are followed by a format code and separated\n\ +by the '|' (pipe) character.\n\ +Valid format codes are\n\ + %t - The option should be used as the title\n\ + %xN - The option should set the integer N in the button value."; + +static char Method_Toggle_doc[] = + "(name, event, x, y, width, height, default, [tooltip]) - Create a new Toggle \ +button\n\n\ +(name) A string to display on the button\n\ +(event) The event number to pass to the button event function when activated\n\ +(x, y) The lower left coordinate of the button\n\ +(width, height) The button width and height\n\ +(default) An integer (0 or 1) specifying the default state\n\ +[tooltip=] The button's tooltip"; + + +static char Method_Slider_doc[] = + "(name, event, x, y, width, height, initial, min, max, [update, tooltip]) - \ +Create a new Slider button\n\n\ +(name) A string to display on the button\n\ +(event) The event number to pass to the button event function when activated\n\ +(x, y) The lower left coordinate of the button\n\ +(width, height) The button width and height\n\ +(initial, min, max) Three values (int or float) specifying the initial \ + and limit values.\n\ +[update=1] A value controlling whether the slider will emit events as it \ +is edited.\n\ + A non-zero value (default) enables the events. A zero value supresses them.\n\ +[tooltip=] The button's tooltip"; + + +static char Method_Scrollbar_doc[] = + "(event, x, y, width, height, initial, min, max, [update, tooltip]) - Create a \ +new Scrollbar\n\n\ +(event) The event number to pass to the button event function when activated\n\ +(x, y) The lower left coordinate of the button\n\ +(width, height) The button width and height\n\ +(initial, min, max) Three values (int or float) specifying the initial and limit values.\n\ +[update=1] A value controlling whether the slider will emit events as it is edited.\n\ + A non-zero value (default) enables the events. A zero value supresses them.\n\ +[tooltip=] The button's tooltip"; + +static char Method_Number_doc[] = + "(name, event, x, y, width, height, initial, min, max, [tooltip]) - Create a \ +new Number button\n\n\ +(name) A string to display on the button\n\ +(event) The event number to pass to the button event function when activated\n\ +(x, y) The lower left coordinate of the button\n\ +(width, height) The button width and height\n\ +(initial, min, max) Three values (int or float) specifying the initial and \ +limit values.\n\ +[tooltip=] The button's tooltip"; + +static char Method_String_doc[] = + "(name, event, x, y, width, height, initial, length, [tooltip]) - Create a \ +new String button\n\n\ +(name) A string to display on the button\n\ +(event) The event number to pass to the button event function when activated\n\ +(x, y) The lower left coordinate of the button\n\ +(width, height) The button width and height\n\ +(initial) The string to display initially\n\ +(length) The maximum input length\n\ +[tooltip=] The button's tooltip"; + + +static char Method_GetStringWidth_doc[] = + "(text, font = 'normal') - Return the width in pixels of the given string\n\ +(font) The font size: 'normal' (default), 'small' or 'tiny'."; + + + +static char Method_Text_doc[] = + "(text, font = 'normal') - Draw text onscreen\n\n\ +(text) The text to draw\n\ +(font) The font size: 'normal' (default), 'small' or 'tiny'.\n\n\ +NEW! - This function now returns the width of the drawn string."; + + +static char Method_PupMenu_doc[] = + "(string, maxrow = None) - Display a pop-up menu at the screen.\n\ +The contents of the pop-up are specified through the 'string' argument,\n\ +like with Draw.Menu.\n\ +'maxrow' is an optional int to control how many rows the pop-up should have.\n\ +Options are followed by a format code and separated\n\ +by the '|' (pipe) character.\n\ +Valid format codes are\n\ + %t - The option should be used as the title\n\ + %xN - The option should set the integer N in the button value.\n\n\ +Ex: Draw.PupMenu('OK?%t|QUIT BLENDER') # should be familiar ..."; + +static char Method_Exit_doc[] = "() - Exit the windowing interface"; + +/* +* here we engage in some macro trickery to define the PyBethodDef table +*/ + +#define _MethodDef(func, prefix) \ + {#func, prefix##_##func, METH_VARARGS, prefix##_##func##_doc} + +/* So that _MethodDef(delete, Scene) expands to: + * {"delete", Scene_delete, METH_VARARGS, Scene_delete_doc} */ + +#undef MethodDef +#define MethodDef(func) _MethodDef(func, Method) + +static struct PyMethodDef Draw_methods[] = { + MethodDef (Create), + MethodDef (Button), + MethodDef (Toggle), + MethodDef (Menu), + MethodDef (Slider), + MethodDef (Scrollbar), + MethodDef (Number), + MethodDef (String), + MethodDef (GetStringWidth), + MethodDef (Text), + MethodDef (PupMenu), + MethodDef (Exit), + MethodDef (Redraw), + MethodDef (Draw), + MethodDef (Register), + {NULL, NULL} +}; + +PyTypeObject Button_Type = { + PyObject_HEAD_INIT (NULL) 0, /*ob_size */ + "Button", /*tp_name */ + sizeof (Button), /*tp_basicsize */ + 0, /*tp_itemsize */ + (destructor) Button_dealloc, /*tp_dealloc */ + (printfunc) 0, /*tp_print */ + (getattrfunc) Button_getattr, /*tp_getattr */ + (setattrfunc) Button_setattr, /*tp_setattr */ + (cmpfunc) 0, /*tp_cmp */ + (reprfunc) Button_repr, /*tp_repr */ +}; + + +static void +Button_dealloc (PyObject * self) +{ + Button *but = (Button *) self; + + if (but->type == 3) + MEM_freeN (but->val.asstr); + + PyObject_DEL (self); } -static PyObject *Button_getattr(PyObject *self, char *name) +static PyObject * +Button_getattr (PyObject * self, char *name) { - Button *but = (Button*)self; - - if(strcmp(name, "val") == 0) { - if (but->type==1) - return Py_BuildValue("i", but->val.asint); - else if (but->type==2) - return Py_BuildValue("f", but->val.asfloat); - else if (but->type==3) - return Py_BuildValue("s", but->val.asstr); + Button *but = (Button *) self; + + if (strcmp (name, "val") == 0) + { + if (but->type == 1) + return Py_BuildValue ("i", but->val.asint); + else if (but->type == 2) + return Py_BuildValue ("f", but->val.asfloat); + else if (but->type == 3) + return Py_BuildValue ("s", but->val.asstr); + } + + PyErr_SetString (PyExc_AttributeError, name); + return NULL; +} + +static int +Button_setattr (PyObject * self, char *name, PyObject * v) +{ + Button *but = (Button *) self; + + if (strcmp (name, "val") == 0) + { + if (but->type == 1) + PyArg_Parse (v, "i", &but->val.asint); + else if (but->type == 2) + PyArg_Parse (v, "f", &but->val.asfloat); + else if (but->type == 3) + { + char *newstr; + PyArg_Parse (v, "s", &newstr); + + /* if the length of the new string is the same as */ + /* the old one, just copy, else delete and realloc. */ + if (but->slen == strlen (newstr)) + { + strncpy (but->val.asstr, newstr, but->slen); + } + else + { + MEM_freeN (but->val.asstr); + but->slen = strlen (newstr); + but->val.asstr = MEM_mallocN (but->slen + 1, "button setattr"); + strcpy (but->val.asstr, newstr); + } } + } + else + { + PyErr_SetString (PyExc_AttributeError, name); + return -1; + } - PyErr_SetString(PyExc_AttributeError, name); - return NULL; + return 0; } -static int Button_setattr(PyObject *self, char *name, PyObject *v) +static PyObject * +Button_repr (PyObject * self) { - Button *but= (Button*) self; - - if(strcmp(name, "val") == 0) { - if (but->type==1) - PyArg_Parse(v, "i", &but->val.asint); - else if (but->type==2) - PyArg_Parse(v, "f", &but->val.asfloat); - else if (but->type==3) { - char *newstr; - PyArg_Parse(v, "s", &newstr); - - /* if the length of the new string is the same as */ - /* the old one, just copy, else delete and realloc. */ - if( but->slen == strlen( newstr) ) { - strncpy(but->val.asstr, newstr, but->slen); - } - else { - MEM_freeN( but->val.asstr); - but->slen = strlen( newstr ); - but->val.asstr = MEM_mallocN( but->slen + 1, - "button setattr"); - strcpy( but->val.asstr, newstr ); - } - } - } else { - PyErr_SetString(PyExc_AttributeError, name); - return -1; - } - - return 0; + return PyObject_Repr (Button_getattr (self, "val")); } -static PyObject *Button_repr(PyObject *self) +static Button * +newbutton (void) { - return PyObject_Repr(Button_getattr(self, "val")); -} + Button *but = (Button *) PyObject_NEW (Button, &Button_Type); -static Button *newbutton (void) -{ - Button *but= (Button *) PyObject_NEW(Button, &Button_Type); - - return but; + return but; } /* GUI interface routines */ -static void exit_pydraw(SpaceScript *sc, short err) +static void +exit_pydraw (SpaceScript * sc, short err) { - Script *script = NULL; + Script *script = NULL; - if (!sc || !sc->script) return; + if (!sc || !sc->script) + return; - script = sc->script; + script = sc->script; - if (err) { - PyErr_Print(); - script->flags = 0; /* mark script struct for deletion */ - error("Python script error: check console"); - scrarea_queue_redraw(sc->area); - } + if (err) + { + PyErr_Print (); + script->flags = 0; /* mark script struct for deletion */ + error ("Python script error: check console"); + scrarea_queue_redraw (sc->area); + } - Py_XDECREF((PyObject *) script->py_draw); - Py_XDECREF((PyObject *) script->py_event); - Py_XDECREF((PyObject *) script->py_button); + Py_XDECREF ((PyObject *) script->py_draw); + Py_XDECREF ((PyObject *) script->py_event); + Py_XDECREF ((PyObject *) script->py_button); - script->py_draw = script->py_event = script->py_button = NULL; + script->py_draw = script->py_event = script->py_button = NULL; } -static void exec_callback(SpaceScript *sc, PyObject *callback, PyObject *args) +static void +exec_callback (SpaceScript * sc, PyObject * callback, PyObject * args) { - PyObject *result = PyObject_CallObject (callback, args); + PyObject *result = PyObject_CallObject (callback, args); - if (result == NULL && sc->script) { /* errors in the script */ - if (sc->script->lastspace == SPACE_TEXT) {/*if it can be an ALT+P script*/ - Text *text = G.main->text.first; - while (text) { /* find it and free its compiled code */ - if (!strcmp(text->id.name+2, sc->script->id.name+2)) { - BPY_free_compiled_text(text); - break; - } - text = text->id.next; - } + if (result == NULL && sc->script) + { /* errors in the script */ + if (sc->script->lastspace == SPACE_TEXT) + { /*if it can be an ALT+P script */ + Text *text = G.main->text.first; + while (text) + { /* find it and free its compiled code */ + if (!strcmp (text->id.name + 2, sc->script->id.name + 2)) + { + BPY_free_compiled_text (text); + break; } - exit_pydraw(sc, 1); + text = text->id.next; + } } - - Py_XDECREF (result); - Py_DECREF (args); + exit_pydraw (sc, 1); + } + + Py_XDECREF (result); + Py_DECREF (args); } /* BPY_spacescript_do_pywin_draw, the static spacescript_do_pywin_buttons and @@ -166,83 +448,98 @@ static void exec_callback(SpaceScript *sc, PyObject *callback, PyObject *args) * (see Method_Register below). They are called (only the two BPY_ ones) * from blender/src/drawscript.c */ -void BPY_spacescript_do_pywin_draw(SpaceScript *sc) +void +BPY_spacescript_do_pywin_draw (SpaceScript * sc) { - uiBlock *block; - char butblock[20]; - Script *script = sc->script; + uiBlock *block; + char butblock[20]; + Script *script = sc->script; - sprintf(butblock, "win %d", curarea->win); - block = uiNewBlock(&curarea->uiblocks, butblock, UI_EMBOSSX, - UI_HELV, curarea->win); + sprintf (butblock, "win %d", curarea->win); + block = uiNewBlock (&curarea->uiblocks, butblock, UI_EMBOSSX, + UI_HELV, curarea->win); - if (script->py_draw) { - glPushAttrib(GL_ALL_ATTRIB_BITS); - exec_callback(sc, script->py_draw, Py_BuildValue("()")); - glPopAttrib(); - } else { - glClearColor(0.4375, 0.4375, 0.4375, 0.0); - glClear(GL_COLOR_BUFFER_BIT); - } + if (script->py_draw) + { + glPushAttrib (GL_ALL_ATTRIB_BITS); + exec_callback (sc, script->py_draw, Py_BuildValue ("()")); + glPopAttrib (); + } + else + { + glClearColor (0.4375, 0.4375, 0.4375, 0.0); + glClear (GL_COLOR_BUFFER_BIT); + } - uiDrawBlock(block); + uiDrawBlock (block); - curarea->win_swap = WIN_BACK_OK; + curarea->win_swap = WIN_BACK_OK; } -static void spacescript_do_pywin_buttons(SpaceScript *sc, unsigned short event) +static void +spacescript_do_pywin_buttons (SpaceScript * sc, unsigned short event) { - if (sc->script->py_button) { - exec_callback(sc, sc->script->py_button, Py_BuildValue("(i)", event)); - } + if (sc->script->py_button) + { + exec_callback (sc, sc->script->py_button, Py_BuildValue ("(i)", event)); + } } -void BPY_spacescript_do_pywin_event(SpaceScript *sc, unsigned short event, short val) +void +BPY_spacescript_do_pywin_event (SpaceScript * sc, unsigned short event, + short val) { - if (event == QKEY && G.qual & (LR_ALTKEY|LR_CTRLKEY)) { - /* finish script: user pressed ALT+Q or CONTROL+Q */ - Script *script = sc->script; + if (event == QKEY && G.qual & (LR_ALTKEY | LR_CTRLKEY)) + { + /* finish script: user pressed ALT+Q or CONTROL+Q */ + Script *script = sc->script; - exit_pydraw(sc, 0); + exit_pydraw (sc, 0); - script->flags &=~SCRIPT_GUI; /* we're done with this script */ + script->flags &= ~SCRIPT_GUI; /* we're done with this script */ - return; - } + return; + } - if (val) { - if (uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event = 0; + if (val) + { + if (uiDoBlocks (&curarea->uiblocks, event) != UI_NOTHING) + event = 0; - if (event == UI_BUT_EVENT) - spacescript_do_pywin_buttons(sc, val); - } + if (event == UI_BUT_EVENT) + spacescript_do_pywin_buttons (sc, val); + } - if (sc->script->py_event) - exec_callback(sc, sc->script->py_event, Py_BuildValue("(ii)", event, val)); + if (sc->script->py_event) + exec_callback (sc, sc->script->py_event, + Py_BuildValue ("(ii)", event, val)); } -static PyObject *Method_Exit (PyObject *self, PyObject *args) -{ - SpaceScript *sc; - Script *script; +static PyObject * +Method_Exit (PyObject * self, PyObject * args) +{ + SpaceScript *sc; + Script *script; -/* if users call Draw.Exit when we are already out of the SPACE_SCRIPT, we - * simply return, for compatibility */ - if (curarea->spacetype == SPACE_SCRIPT) sc = curarea->spacedata.first; - else return EXPP_incr_ret (Py_None); + /* if users call Draw.Exit when we are already out of the SPACE_SCRIPT, we + * simply return, for compatibility */ + if (curarea->spacetype == SPACE_SCRIPT) + sc = curarea->spacedata.first; + else + return EXPP_incr_ret (Py_None); - if (!PyArg_ParseTuple(args, "")) - return EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected empty argument list"); + if (!PyArg_ParseTuple (args, "")) + return EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected empty argument list"); - exit_pydraw(sc, 0); + exit_pydraw (sc, 0); - script = sc->script; + script = sc->script; -/* remove our lock to the current namespace */ - script->flags &=~SCRIPT_GUI; + /* remove our lock to the current namespace */ + script->flags &= ~SCRIPT_GUI; - return EXPP_incr_ret (Py_None); + return EXPP_incr_ret (Py_None); } /* Method_Register (Draw.Register) registers callbacks for drawing, events @@ -251,217 +548,243 @@ static PyObject *Method_Exit (PyObject *self, PyObject *args) * the SPACE_SCRIPT window with this script is redrawn, the registered * callbacks are executed and deleted (a new call to Register re-inserts them * or new ones).*/ -static PyObject *Method_Register (PyObject *self, PyObject *args) +static PyObject * +Method_Register (PyObject * self, PyObject * args) { - PyObject *newdrawc = NULL, *neweventc = NULL, *newbuttonc = NULL; - SpaceScript *sc; - Script *script; - int startspace = 0; + PyObject *newdrawc = NULL, *neweventc = NULL, *newbuttonc = NULL; + SpaceScript *sc; + Script *script; + int startspace = 0; - if (!PyArg_ParseTuple(args, "O|OO", &newdrawc, &neweventc, &newbuttonc)) - return EXPP_ReturnPyObjError (PyExc_TypeError, - "expected one or three PyObjects"); + if (!PyArg_ParseTuple (args, "O|OO", &newdrawc, &neweventc, &newbuttonc)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected one or three PyObjects"); - if (!PyCallable_Check(newdrawc)) newdrawc = NULL; - if (!PyCallable_Check(neweventc)) neweventc = NULL; - if (!PyCallable_Check(newbuttonc)) newbuttonc = NULL; + if (!PyCallable_Check (newdrawc)) + newdrawc = NULL; + if (!PyCallable_Check (neweventc)) + neweventc = NULL; + if (!PyCallable_Check (newbuttonc)) + newbuttonc = NULL; - if (!(newdrawc || neweventc || newbuttonc)) - return EXPP_incr_ret(Py_None); + if (!(newdrawc || neweventc || newbuttonc)) + return EXPP_incr_ret (Py_None); - startspace = curarea->spacetype; + startspace = curarea->spacetype; -/* first make sure the current area is of type SPACE_SCRIPT */ - if (startspace != SPACE_SCRIPT) newspace (curarea, SPACE_SCRIPT); + /* first make sure the current area is of type SPACE_SCRIPT */ + if (startspace != SPACE_SCRIPT) + newspace (curarea, SPACE_SCRIPT); - sc = curarea->spacedata.first; + sc = curarea->spacedata.first; -/* this is a little confusing: we need to know which script is being executed - * now, so we can preserve its namespace from being deleted. - * There are two possibilities: - * a) One new script was created and the interpreter still hasn't returned - * from executing it. - * b) Any number of scripts were executed but left registered callbacks and - * so were not deleted yet. */ + /* this is a little confusing: we need to know which script is being executed + * now, so we can preserve its namespace from being deleted. + * There are two possibilities: + * a) One new script was created and the interpreter still hasn't returned + * from executing it. + * b) Any number of scripts were executed but left registered callbacks and + * so were not deleted yet. */ -/* To find out if we're dealing with a) or b), we start with the last - * created one: */ - script = G.main->script.last; + /* To find out if we're dealing with a) or b), we start with the last + * created one: */ + script = G.main->script.last; - if (!script) { - return EXPP_ReturnPyObjError (PyExc_RuntimeError, - "Draw.Register: couldn't get pointer to script struct"); - } + if (!script) + { + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "Draw.Register: couldn't get pointer to script struct"); + } -/* if the flag SCRIPT_RUNNING is set, this script is case a): */ - if (!(script->flags & SCRIPT_RUNNING)) { - script = sc->script; - } -/* otherwise it's case b) and the script we want is here: */ - else sc->script = script; + /* if the flag SCRIPT_RUNNING is set, this script is case a): */ + if (!(script->flags & SCRIPT_RUNNING)) + { + script = sc->script; + } + /* otherwise it's case b) and the script we want is here: */ + else + sc->script = script; -/* Now we have the right script and can set a lock so its namespace can't be - * deleted for as long as we need it */ - script->flags |= SCRIPT_GUI; + /* Now we have the right script and can set a lock so its namespace can't be + * deleted for as long as we need it */ + script->flags |= SCRIPT_GUI; -/* save the last space so we can go back to it upon finishing */ - if (!script->lastspace) script->lastspace = startspace; + /* save the last space so we can go back to it upon finishing */ + if (!script->lastspace) + script->lastspace = startspace; -/* clean the old callbacks */ - exit_pydraw(sc, 0); + /* clean the old callbacks */ + exit_pydraw (sc, 0); -/* prepare the new ones and insert them */ - Py_XINCREF(newdrawc); - Py_XINCREF(neweventc); - Py_XINCREF(newbuttonc); + /* prepare the new ones and insert them */ + Py_XINCREF (newdrawc); + Py_XINCREF (neweventc); + Py_XINCREF (newbuttonc); - script->py_draw = newdrawc; - script->py_event = neweventc; - script->py_button = newbuttonc; + script->py_draw = newdrawc; + script->py_event = neweventc; + script->py_button = newbuttonc; - scrarea_queue_redraw(sc->area); + scrarea_queue_redraw (sc->area); - return EXPP_incr_ret (Py_None); + return EXPP_incr_ret (Py_None); } -static PyObject *Method_Redraw (PyObject *self, PyObject *args) +static PyObject * +Method_Redraw (PyObject * self, PyObject * args) { - int after= 0; + int after = 0; - if (!PyArg_ParseTuple(args, "|i", &after)) - return EXPP_ReturnPyObjError (PyExc_TypeError, - "expected int argument (or nothing)"); + if (!PyArg_ParseTuple (args, "|i", &after)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected int argument (or nothing)"); - /* XXX shouldn't we redraw all spacescript wins with this script on ?*/ - if (after) addafterqueue(curarea->win, REDRAW, 1); - else scrarea_queue_winredraw(curarea); + /* XXX shouldn't we redraw all spacescript wins with this script on ? */ + if (after) + addafterqueue (curarea->win, REDRAW, 1); + else + scrarea_queue_winredraw (curarea); - return EXPP_incr_ret(Py_None); + return EXPP_incr_ret (Py_None); } -static PyObject *Method_Draw (PyObject *self, PyObject *args) +static PyObject * +Method_Draw (PyObject * self, PyObject * args) { - /*@ If forced drawing is disable queue a redraw event instead */ - if (EXPP_disable_force_draw) { - scrarea_queue_winredraw(curarea); - return EXPP_incr_ret (Py_None); - } + /*@ If forced drawing is disable queue a redraw event instead */ + if (EXPP_disable_force_draw) + { + scrarea_queue_winredraw (curarea); + return EXPP_incr_ret (Py_None); + } - if (!PyArg_ParseTuple(args, "")) - return EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected empty argument list"); + if (!PyArg_ParseTuple (args, "")) + return EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected empty argument list"); - scrarea_do_windraw(curarea); + scrarea_do_windraw (curarea); - screen_swapbuffers(); + screen_swapbuffers (); - return EXPP_incr_ret (Py_None); + return EXPP_incr_ret (Py_None); } -static PyObject *Method_Create (PyObject *self, PyObject *args) +static PyObject * +Method_Create (PyObject * self, PyObject * args) { - Button *but; - PyObject *in; + Button *but; + PyObject *in; - if (!PyArg_ParseTuple(args, "O", &in)) - return EXPP_ReturnPyObjError (PyExc_TypeError, - "expected PyObject argument"); - - but= newbutton(); - if(PyFloat_Check(in)) { - but->type= 2; - but->val.asfloat= PyFloat_AsDouble(in); - } else if (PyInt_Check(in)) { - but->type= 1; - but->val.asint= PyInt_AsLong(in); - } else if (PyString_Check(in)) { - char *newstr= PyString_AsString(in); - - but->type= 3; - but->slen= strlen(newstr); - but->val.asstr= MEM_mallocN(but->slen+1, "button string"); - - strcpy(but->val.asstr, newstr); - } - - return (PyObject *) but; + if (!PyArg_ParseTuple (args, "O", &in)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected PyObject argument"); + + but = newbutton (); + if (PyFloat_Check (in)) + { + but->type = 2; + but->val.asfloat = PyFloat_AsDouble (in); + } + else if (PyInt_Check (in)) + { + but->type = 1; + but->val.asint = PyInt_AsLong (in); + } + else if (PyString_Check (in)) + { + char *newstr = PyString_AsString (in); + + but->type = 3; + but->slen = strlen (newstr); + but->val.asstr = MEM_mallocN (but->slen + 1, "button string"); + + strcpy (but->val.asstr, newstr); + } + + return (PyObject *) but; } -static uiBlock *Get_uiBlock(void) +static uiBlock * +Get_uiBlock (void) { - char butblock[32]; - - sprintf(butblock, "win %d", curarea->win); + char butblock[32]; - return uiGetBlock(butblock, curarea); + sprintf (butblock, "win %d", curarea->win); + + return uiGetBlock (butblock, curarea); } -static PyObject *Method_Button (PyObject *self, PyObject *args) +static PyObject * +Method_Button (PyObject * self, PyObject * args) { - uiBlock *block; - char *name, *tip= NULL; - int event; - int x, y, w, h; - - if (!PyArg_ParseTuple(args, "siiiii|s", &name, &event, - &x, &y, &w, &h, &tip)) - return EXPP_ReturnPyObjError (PyExc_TypeError, - "expected a string, five ints and optionally another string as arguments"); - - block= Get_uiBlock(); + uiBlock *block; + char *name, *tip = NULL; + int event; + int x, y, w, h; - if(block) uiDefBut(block, BUT, event, name, x, y, w, h, - 0, 0, 0, 0, 0, tip); - - return EXPP_incr_ret(Py_None); + if (!PyArg_ParseTuple (args, "siiiii|s", &name, &event, + &x, &y, &w, &h, &tip)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected a string, five ints and optionally another string as arguments"); + + block = Get_uiBlock (); + + if (block) + uiDefBut (block, BUT, event, name, x, y, w, h, 0, 0, 0, 0, 0, tip); + + return EXPP_incr_ret (Py_None); } -static PyObject *Method_Menu (PyObject *self, PyObject *args) +static PyObject * +Method_Menu (PyObject * self, PyObject * args) { - uiBlock *block; - char *name, *tip= NULL; - int event, def; - int x, y, w, h; - Button *but; - - if (!PyArg_ParseTuple(args, "siiiiii|s", &name, &event, - &x, &y, &w, &h, &def, &tip)) - return EXPP_ReturnPyObjError (PyExc_TypeError, - "expected a string, six ints and optionally another string as arguments"); + uiBlock *block; + char *name, *tip = NULL; + int event, def; + int x, y, w, h; + Button *but; - but= newbutton(); - but->type= 1; - but->val.asint= def; - - block= Get_uiBlock(); - if(block) uiDefButI(block, MENU, event, name, x, y, w, h, - &but->val.asint, 0, 0, 0, 0, tip); - - return (PyObject *) but; + if (!PyArg_ParseTuple (args, "siiiiii|s", &name, &event, + &x, &y, &w, &h, &def, &tip)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected a string, six ints and optionally another string as arguments"); + + but = newbutton (); + but->type = 1; + but->val.asint = def; + + block = Get_uiBlock (); + if (block) + uiDefButI (block, MENU, event, name, x, y, w, h, + &but->val.asint, 0, 0, 0, 0, tip); + + return (PyObject *) but; } -static PyObject *Method_Toggle (PyObject *self, PyObject *args) +static PyObject * +Method_Toggle (PyObject * self, PyObject * args) { - uiBlock *block; - char *name, *tip= NULL; - int event; - int x, y, w, h, def; - Button *but; - - if (!PyArg_ParseTuple(args, "siiiiii|s", &name, &event, - &x, &y, &w, &h, &def, &tip)) - return EXPP_ReturnPyObjError (PyExc_TypeError, - "expected a string, six ints and optionally another string as arguments"); + uiBlock *block; + char *name, *tip = NULL; + int event; + int x, y, w, h, def; + Button *but; - but= newbutton(); - but->type= 1; - but->val.asint= def; - - block= Get_uiBlock(); - if(block) uiDefButI(block, TOG, event, name, x, y, w, h, - &but->val.asint, 0, 0, 0, 0, tip); - - return (PyObject *) but; + if (!PyArg_ParseTuple (args, "siiiiii|s", &name, &event, + &x, &y, &w, &h, &def, &tip)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected a string, six ints and optionally another string as arguments"); + + but = newbutton (); + but->type = 1; + but->val.asint = def; + + block = Get_uiBlock (); + if (block) + uiDefButI (block, TOG, event, name, x, y, w, h, + &but->val.asint, 0, 0, 0, 0, tip); + + return (PyObject *) but; } /*@DO NOT TOUCH THIS FUNCTION ! @@ -471,425 +794,467 @@ static PyObject *Method_Toggle (PyObject *self, PyObject *args) XXX This is condemned to be dinosource in future - it's a hack. */ -static void py_slider_update(void *butv, void *data2_unused) +static void +py_slider_update (void *butv, void *data2_unused) { - uiBut *but= butv; + uiBut *but = butv; - EXPP_disable_force_draw= 1; - /*@ - Disable forced drawing, otherwise the button object which - is still being used might be deleted - */ + EXPP_disable_force_draw = 1; + /*@ + Disable forced drawing, otherwise the button object which + is still being used might be deleted + */ -/*@ - spacetext_do_pywin_buttons(curarea->spacedata.first, but->retval); */ + /*@ + spacetext_do_pywin_buttons(curarea->spacedata.first, but->retval); */ - g_window_redrawn = 0; - curarea->win_swap= WIN_BACK_OK; - /* removed global uiFrontBuf (contact ton when this goes wrong here) */ - spacescript_do_pywin_buttons(curarea->spacedata.first, uiButGetRetVal(but)); + g_window_redrawn = 0; + curarea->win_swap = WIN_BACK_OK; + /* removed global uiFrontBuf (contact ton when this goes wrong here) */ + spacescript_do_pywin_buttons (curarea->spacedata.first, + uiButGetRetVal (but)); - if (!g_window_redrawn){ /*@ if Redraw already called */ - disable_where_script(1); - M_Window_Redraw(0, Py_BuildValue("(i)", SPACE_VIEW3D)); - disable_where_script(0); - } + if (!g_window_redrawn) + { /*@ if Redraw already called */ + disable_where_script (1); + M_Window_Redraw (0, Py_BuildValue ("(i)", SPACE_VIEW3D)); + disable_where_script (0); + } - EXPP_disable_force_draw= 0; + EXPP_disable_force_draw = 0; } -static PyObject *Method_Slider (PyObject *self, PyObject *args) +static PyObject * +Method_Slider (PyObject * self, PyObject * args) { - uiBlock *block; - char *name, *tip= NULL; - int event; - int x, y, w, h, realtime=1; - Button *but; - PyObject *mino, *maxo, *inio; - - if (!PyArg_ParseTuple(args, "siiiiiOOO|is", &name, &event, - &x, &y, &w, &h, &inio, &mino, &maxo, &realtime, &tip)) - return EXPP_ReturnPyObjError (PyExc_TypeError, - "expected a string, five ints, three PyObjects\n\ + uiBlock *block; + char *name, *tip = NULL; + int event; + int x, y, w, h, realtime = 1; + Button *but; + PyObject *mino, *maxo, *inio; + + if (!PyArg_ParseTuple (args, "siiiiiOOO|is", &name, &event, + &x, &y, &w, &h, &inio, &mino, &maxo, &realtime, + &tip)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected a string, five ints, three PyObjects\n\ and optionally another int and string as arguments"); - but= newbutton(); - if (PyFloat_Check(inio)) { - float ini, min, max; + but = newbutton (); - ini= PyFloat_AsDouble(inio); - min= PyFloat_AsDouble(mino); - max= PyFloat_AsDouble(maxo); - - but->type= 2; - but->val.asfloat= ini; + if (PyFloat_Check (inio)) + { + float ini, min, max; - block= Get_uiBlock(); - if(block) { - uiBut *ubut; - ubut= uiDefButF(block, NUMSLI, event, name, x, y, w, h, - &but->val.asfloat, min, max, 0, 0, tip); - if (realtime) uiButSetFunc(ubut, py_slider_update, ubut, NULL); - } - } - else { - int ini, min, max; + ini = PyFloat_AsDouble (inio); + min = PyFloat_AsDouble (mino); + max = PyFloat_AsDouble (maxo); - ini= PyInt_AsLong(inio); - min= PyInt_AsLong(mino); - max= PyInt_AsLong(maxo); - - but->type= 1; - but->val.asint= ini; - - block= Get_uiBlock(); - if(block) { - uiBut *ubut; - ubut= uiDefButI(block, NUMSLI, event, name, x, y, w, h, - &but->val.asint, min, max, 0, 0, tip); - if (realtime) uiButSetFunc(ubut, py_slider_update, ubut, NULL); - } + but->type = 2; + but->val.asfloat = ini; + + block = Get_uiBlock (); + if (block) + { + uiBut *ubut; + ubut = uiDefButF (block, NUMSLI, event, name, x, y, w, h, + &but->val.asfloat, min, max, 0, 0, tip); + if (realtime) + uiButSetFunc (ubut, py_slider_update, ubut, NULL); } - return (PyObject *) but; + } + else + { + int ini, min, max; + + ini = PyInt_AsLong (inio); + min = PyInt_AsLong (mino); + max = PyInt_AsLong (maxo); + + but->type = 1; + but->val.asint = ini; + + block = Get_uiBlock (); + if (block) + { + uiBut *ubut; + ubut = uiDefButI (block, NUMSLI, event, name, x, y, w, h, + &but->val.asint, min, max, 0, 0, tip); + if (realtime) + uiButSetFunc (ubut, py_slider_update, ubut, NULL); + } + } + return (PyObject *) but; } -static PyObject *Method_Scrollbar (PyObject *self, PyObject *args) +static PyObject * +Method_Scrollbar (PyObject * self, PyObject * args) { - char *tip= NULL; - uiBlock *block; - int event; - int x, y, w, h, realtime=1; - Button *but; - PyObject *mino, *maxo, *inio; - float ini, min, max; + char *tip = NULL; + uiBlock *block; + int event; + int x, y, w, h, realtime = 1; + Button *but; + PyObject *mino, *maxo, *inio; + float ini, min, max; - if (!PyArg_ParseTuple(args, "iiiiiOOO|is", &event, &x, &y, &w, &h, - &inio, &mino, &maxo, &realtime, &tip)) - return EXPP_ReturnPyObjError (PyExc_TypeError, - "expected five ints, three PyObjects and optionally\n\ + if (!PyArg_ParseTuple (args, "iiiiiOOO|is", &event, &x, &y, &w, &h, + &inio, &mino, &maxo, &realtime, &tip)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected five ints, three PyObjects and optionally\n\ another int and string as arguments"); - if (!PyNumber_Check(inio) || !PyNumber_Check(inio) || !PyNumber_Check(inio)) - return EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected numbers for initial, min, and max"); + if (!PyNumber_Check (inio) || !PyNumber_Check (inio) + || !PyNumber_Check (inio)) + return EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected numbers for initial, min, and max"); - but= newbutton(); + but = newbutton (); - if (PyFloat_Check(inio)) but->type= 2; - else but->type= 1; + if (PyFloat_Check (inio)) + but->type = 2; + else + but->type = 1; - ini= PyFloat_AsDouble(inio); - min= PyFloat_AsDouble(mino); - max= PyFloat_AsDouble(maxo); + ini = PyFloat_AsDouble (inio); + min = PyFloat_AsDouble (mino); + max = PyFloat_AsDouble (maxo); - if (but->type==2) { - but->val.asfloat= ini; - block= Get_uiBlock(); - if(block) { - uiBut *ubut; - ubut= uiDefButF(block, SCROLL, event, "", x, y, w, h, - &but->val.asfloat, min, max, 0, 0, tip); - if (realtime) uiButSetFunc(ubut, py_slider_update, ubut, NULL); - } - } else { - but->val.asint= ini; - block= Get_uiBlock(); - if(block) { - uiBut *ubut; - ubut= uiDefButI(block, SCROLL, event, "", x, y, w, h, - &but->val.asint, min, max, 0, 0, tip); - if (realtime) uiButSetFunc(ubut, py_slider_update, ubut, NULL); - } + if (but->type == 2) + { + but->val.asfloat = ini; + block = Get_uiBlock (); + if (block) + { + uiBut *ubut; + ubut = uiDefButF (block, SCROLL, event, "", x, y, w, h, + &but->val.asfloat, min, max, 0, 0, tip); + if (realtime) + uiButSetFunc (ubut, py_slider_update, ubut, NULL); } + } + else + { + but->val.asint = ini; + block = Get_uiBlock (); + if (block) + { + uiBut *ubut; + ubut = uiDefButI (block, SCROLL, event, "", x, y, w, h, + &but->val.asint, min, max, 0, 0, tip); + if (realtime) + uiButSetFunc (ubut, py_slider_update, ubut, NULL); + } + } - return (PyObject *) but; + return (PyObject *) but; } -static PyObject *Method_Number (PyObject *self, PyObject *args) +static PyObject * +Method_Number (PyObject * self, PyObject * args) { - uiBlock *block; - char *name, *tip= NULL; - int event; - int x, y, w, h; - Button *but; - PyObject *mino, *maxo, *inio; - - if (!PyArg_ParseTuple(args, "siiiiiOOO|s", &name, &event, - &x, &y, &w, &h, &inio, &mino, &maxo, &tip)) - return EXPP_ReturnPyObjError (PyExc_TypeError, - "expected a string, five ints, three PyObjects and\n\ + uiBlock *block; + char *name, *tip = NULL; + int event; + int x, y, w, h; + Button *but; + PyObject *mino, *maxo, *inio; + + if (!PyArg_ParseTuple (args, "siiiiiOOO|s", &name, &event, + &x, &y, &w, &h, &inio, &mino, &maxo, &tip)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected a string, five ints, three PyObjects and\n\ optionally another string as arguments"); - but= newbutton(); - - if (PyFloat_Check(inio)) { - float ini, min, max; + but = newbutton (); - ini= PyFloat_AsDouble(inio); - min= PyFloat_AsDouble(mino); - max= PyFloat_AsDouble(maxo); - - but->type= 2; - but->val.asfloat= ini; - - block= Get_uiBlock(); - if(block) uiDefButF(block, NUM, event, name, x, y, w, h, - &but->val.asfloat, min, max, 0, 0, tip); - } else { - int ini, min, max; + if (PyFloat_Check (inio)) + { + float ini, min, max; - ini= PyInt_AsLong(inio); - min= PyInt_AsLong(mino); - max= PyInt_AsLong(maxo); - - but->type= 1; - but->val.asint= ini; - - block= Get_uiBlock(); - if(block) uiDefButI(block, NUM, event, name, x, y, w, h, - &but->val.asint, min, max, 0, 0, tip); - } + ini = PyFloat_AsDouble (inio); + min = PyFloat_AsDouble (mino); + max = PyFloat_AsDouble (maxo); - return (PyObject *) but; + but->type = 2; + but->val.asfloat = ini; + + block = Get_uiBlock (); + if (block) + uiDefButF (block, NUM, event, name, x, y, w, h, + &but->val.asfloat, min, max, 0, 0, tip); + } + else + { + int ini, min, max; + + ini = PyInt_AsLong (inio); + min = PyInt_AsLong (mino); + max = PyInt_AsLong (maxo); + + but->type = 1; + but->val.asint = ini; + + block = Get_uiBlock (); + if (block) + uiDefButI (block, NUM, event, name, x, y, w, h, + &but->val.asint, min, max, 0, 0, tip); + } + + return (PyObject *) but; } -static PyObject *Method_String (PyObject *self, PyObject *args) +static PyObject * +Method_String (PyObject * self, PyObject * args) { - uiBlock *block; - char *name, *tip= NULL, *newstr; - int event; - int x, y, w, h, len; - Button *but; - - if (!PyArg_ParseTuple(args, "siiiiisi|s", &name, &event, - &x, &y, &w, &h, &newstr, &len, &tip)) - return EXPP_ReturnPyObjError (PyExc_TypeError, - "expected a string, five ints, a string, an int and\n\ + uiBlock *block; + char *name, *tip = NULL, *newstr; + int event; + int x, y, w, h, len; + Button *but; + + if (!PyArg_ParseTuple (args, "siiiiisi|s", &name, &event, + &x, &y, &w, &h, &newstr, &len, &tip)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected a string, five ints, a string, an int and\n\ optionally another string as arguments"); - but= newbutton(); - but->type= 3; - but->slen= len; - but->val.asstr= MEM_mallocN(len+1, "button string"); - - strncpy(but->val.asstr, newstr, len); - but->val.asstr[len]= 0; - - block= Get_uiBlock(); - if(block) uiDefBut(block, TEX, event, name, x, y, w, h, - but->val.asstr, 0, len, 0, 0, tip); + but = newbutton (); + but->type = 3; + but->slen = len; + but->val.asstr = MEM_mallocN (len + 1, "button string"); - return (PyObject *) but; + strncpy (but->val.asstr, newstr, len); + but->val.asstr[len] = 0; + + block = Get_uiBlock (); + if (block) + uiDefBut (block, TEX, event, name, x, y, w, h, + but->val.asstr, 0, len, 0, 0, tip); + + return (PyObject *) but; } -static PyObject *Method_GetStringWidth (PyObject *self, PyObject *args) +static PyObject * +Method_GetStringWidth (PyObject * self, PyObject * args) { - char *text; - char *font_str = "normal"; - struct BMF_Font *font; - PyObject *width; + char *text; + char *font_str = "normal"; + struct BMF_Font *font; + PyObject *width; - if (!PyArg_ParseTuple(args, "s|s", &text, &font_str)) - return EXPP_ReturnPyObjError (PyExc_TypeError, - "expected one or two string arguments"); + if (!PyArg_ParseTuple (args, "s|s", &text, &font_str)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected one or two string arguments"); - if (!strcmp (font_str, "normal")) font = (&G)->font; - else if (!strcmp (font_str, "small" )) font = (&G)->fonts; - else if (!strcmp (font_str, "tiny" )) font = (&G)->fontss; - else - return EXPP_ReturnPyObjError (PyExc_AttributeError, - "\"font\" must be: 'normal' (default), 'small' or 'tiny'."); + if (!strcmp (font_str, "normal")) + font = (&G)->font; + else if (!strcmp (font_str, "small")) + font = (&G)->fonts; + else if (!strcmp (font_str, "tiny")) + font = (&G)->fontss; + else + return EXPP_ReturnPyObjError (PyExc_AttributeError, + "\"font\" must be: 'normal' (default), 'small' or 'tiny'."); - width = PyInt_FromLong(BMF_GetStringWidth (font, text)); + width = PyInt_FromLong (BMF_GetStringWidth (font, text)); - if (!width) - return EXPP_ReturnPyObjError (PyExc_MemoryError, - "couldn't create PyInt"); + if (!width) + return EXPP_ReturnPyObjError (PyExc_MemoryError, "couldn't create PyInt"); - return width; + return width; } -static PyObject *Method_Text (PyObject *self, PyObject *args) +static PyObject * +Method_Text (PyObject * self, PyObject * args) { - char *text; - char *font_str = NULL; - struct BMF_Font *font; + char *text; + char *font_str = NULL; + struct BMF_Font *font; - if (!PyArg_ParseTuple(args, "s|s", &text, &font_str)) - return EXPP_ReturnPyObjError (PyExc_TypeError, - "expected one or two string arguments"); + if (!PyArg_ParseTuple (args, "s|s", &text, &font_str)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected one or two string arguments"); - if (!font_str) font = (&G)->font; - else if (!strcmp (font_str, "normal")) font = (&G)->font; - else if (!strcmp (font_str, "small" )) font = (&G)->fonts; - else if (!strcmp (font_str, "tiny" )) font = (&G)->fontss; - else - return EXPP_ReturnPyObjError (PyExc_AttributeError, - "\"font\" must be: 'normal' (default), 'small' or 'tiny'."); + if (!font_str) + font = (&G)->font; + else if (!strcmp (font_str, "normal")) + font = (&G)->font; + else if (!strcmp (font_str, "small")) + font = (&G)->fonts; + else if (!strcmp (font_str, "tiny")) + font = (&G)->fontss; + else + return EXPP_ReturnPyObjError (PyExc_AttributeError, + "\"font\" must be: 'normal' (default), 'small' or 'tiny'."); - BMF_DrawString(font, text); + BMF_DrawString (font, text); - return PyInt_FromLong (BMF_GetStringWidth (font, text)); + return PyInt_FromLong (BMF_GetStringWidth (font, text)); } -static PyObject *Method_PupMenu (PyObject *self, PyObject *args) +static PyObject * +Method_PupMenu (PyObject * self, PyObject * args) { - char *text; - int maxrow = -1; - PyObject *ret; + char *text; + int maxrow = -1; + PyObject *ret; - if (!PyArg_ParseTuple(args, "s|i", &text, &maxrow)) - return EXPP_ReturnPyObjError (PyExc_TypeError, - "expected a string and optionally an int as arguments"); + if (!PyArg_ParseTuple (args, "s|i", &text, &maxrow)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected a string and optionally an int as arguments"); - if (maxrow >= 0) - ret = PyInt_FromLong (pupmenu_col (text, maxrow)); - else - ret = PyInt_FromLong (pupmenu (text)); + if (maxrow >= 0) + ret = PyInt_FromLong (pupmenu_col (text, maxrow)); + else + ret = PyInt_FromLong (pupmenu (text)); - if (ret) return ret; + if (ret) + return ret; - return EXPP_ReturnPyObjError (PyExc_MemoryError, - "couldn't create a PyInt"); + return EXPP_ReturnPyObjError (PyExc_MemoryError, "couldn't create a PyInt"); } -PyObject *Draw_Init (void) +PyObject * +Draw_Init (void) { - PyObject *submodule, *dict; + PyObject *submodule, *dict; - Button_Type.ob_type = &PyType_Type; + Button_Type.ob_type = &PyType_Type; - submodule = Py_InitModule3("Blender.Draw", Draw_methods, Draw_doc); + submodule = Py_InitModule3 ("Blender.Draw", Draw_methods, Draw_doc); - dict= PyModule_GetDict(submodule); + dict = PyModule_GetDict (submodule); #define EXPP_ADDCONST(x) \ PyDict_SetItemString(dict, #x, PyInt_FromLong(x)) -/* So, for example: - * EXPP_ADDCONST(LEFTMOUSE) becomes - * PyDict_SetItemString(dict, "LEFTMOUSE", PyInt_FromLong(LEFTMOUSE)) */ + /* So, for example: + * EXPP_ADDCONST(LEFTMOUSE) becomes + * PyDict_SetItemString(dict, "LEFTMOUSE", PyInt_FromLong(LEFTMOUSE)) + */ - EXPP_ADDCONST(LEFTMOUSE); - EXPP_ADDCONST(MIDDLEMOUSE); - EXPP_ADDCONST(RIGHTMOUSE); - EXPP_ADDCONST(MOUSEX); - EXPP_ADDCONST(MOUSEY); - EXPP_ADDCONST(TIMER0); - EXPP_ADDCONST(TIMER1); - EXPP_ADDCONST(TIMER2); - EXPP_ADDCONST(TIMER3); - EXPP_ADDCONST(KEYBD); - EXPP_ADDCONST(RAWKEYBD); - EXPP_ADDCONST(REDRAW); - EXPP_ADDCONST(INPUTCHANGE); - EXPP_ADDCONST(QFULL); - EXPP_ADDCONST(WINFREEZE); - EXPP_ADDCONST(WINTHAW); - EXPP_ADDCONST(WINCLOSE); - EXPP_ADDCONST(WINQUIT); + EXPP_ADDCONST (LEFTMOUSE); + EXPP_ADDCONST (MIDDLEMOUSE); + EXPP_ADDCONST (RIGHTMOUSE); + EXPP_ADDCONST (MOUSEX); + EXPP_ADDCONST (MOUSEY); + EXPP_ADDCONST (TIMER0); + EXPP_ADDCONST (TIMER1); + EXPP_ADDCONST (TIMER2); + EXPP_ADDCONST (TIMER3); + EXPP_ADDCONST (KEYBD); + EXPP_ADDCONST (RAWKEYBD); + EXPP_ADDCONST (REDRAW); + EXPP_ADDCONST (INPUTCHANGE); + EXPP_ADDCONST (QFULL); + EXPP_ADDCONST (WINFREEZE); + EXPP_ADDCONST (WINTHAW); + EXPP_ADDCONST (WINCLOSE); + EXPP_ADDCONST (WINQUIT); #ifndef IRISGL - EXPP_ADDCONST(Q_FIRSTTIME); + EXPP_ADDCONST (Q_FIRSTTIME); #endif - EXPP_ADDCONST(AKEY); - EXPP_ADDCONST(BKEY); - EXPP_ADDCONST(CKEY); - EXPP_ADDCONST(DKEY); - EXPP_ADDCONST(EKEY); - EXPP_ADDCONST(FKEY); - EXPP_ADDCONST(GKEY); - EXPP_ADDCONST(HKEY); - EXPP_ADDCONST(IKEY); - EXPP_ADDCONST(JKEY); - EXPP_ADDCONST(KKEY); - EXPP_ADDCONST(LKEY); - EXPP_ADDCONST(MKEY); - EXPP_ADDCONST(NKEY); - EXPP_ADDCONST(OKEY); - EXPP_ADDCONST(PKEY); - EXPP_ADDCONST(QKEY); - EXPP_ADDCONST(RKEY); - EXPP_ADDCONST(SKEY); - EXPP_ADDCONST(TKEY); - EXPP_ADDCONST(UKEY); - EXPP_ADDCONST(VKEY); - EXPP_ADDCONST(WKEY); - EXPP_ADDCONST(XKEY); - EXPP_ADDCONST(YKEY); - EXPP_ADDCONST(ZKEY); - EXPP_ADDCONST(ZEROKEY); - EXPP_ADDCONST(ONEKEY); - EXPP_ADDCONST(TWOKEY); - EXPP_ADDCONST(THREEKEY); - EXPP_ADDCONST(FOURKEY); - EXPP_ADDCONST(FIVEKEY); - EXPP_ADDCONST(SIXKEY); - EXPP_ADDCONST(SEVENKEY); - EXPP_ADDCONST(EIGHTKEY); - EXPP_ADDCONST(NINEKEY); - EXPP_ADDCONST(CAPSLOCKKEY); - EXPP_ADDCONST(LEFTCTRLKEY); - EXPP_ADDCONST(LEFTALTKEY); - EXPP_ADDCONST(RIGHTALTKEY); - EXPP_ADDCONST(RIGHTCTRLKEY); - EXPP_ADDCONST(RIGHTSHIFTKEY); - EXPP_ADDCONST(LEFTSHIFTKEY); - EXPP_ADDCONST(ESCKEY); - EXPP_ADDCONST(TABKEY); - EXPP_ADDCONST(RETKEY); - EXPP_ADDCONST(SPACEKEY); - EXPP_ADDCONST(LINEFEEDKEY); - EXPP_ADDCONST(BACKSPACEKEY); - EXPP_ADDCONST(DELKEY); - EXPP_ADDCONST(SEMICOLONKEY); - EXPP_ADDCONST(PERIODKEY); - EXPP_ADDCONST(COMMAKEY); - EXPP_ADDCONST(QUOTEKEY); - EXPP_ADDCONST(ACCENTGRAVEKEY); - EXPP_ADDCONST(MINUSKEY); - EXPP_ADDCONST(SLASHKEY); - EXPP_ADDCONST(BACKSLASHKEY); - EXPP_ADDCONST(EQUALKEY); - EXPP_ADDCONST(LEFTBRACKETKEY); - EXPP_ADDCONST(RIGHTBRACKETKEY); - EXPP_ADDCONST(LEFTARROWKEY); - EXPP_ADDCONST(DOWNARROWKEY); - EXPP_ADDCONST(RIGHTARROWKEY); - EXPP_ADDCONST(UPARROWKEY); - EXPP_ADDCONST(PAD2); - EXPP_ADDCONST(PAD4); - EXPP_ADDCONST(PAD6); - EXPP_ADDCONST(PAD8); - EXPP_ADDCONST(PAD1); - EXPP_ADDCONST(PAD3); - EXPP_ADDCONST(PAD5); - EXPP_ADDCONST(PAD7); - EXPP_ADDCONST(PAD9); - EXPP_ADDCONST(PADPERIOD); - EXPP_ADDCONST(PADSLASHKEY); - EXPP_ADDCONST(PADASTERKEY); - EXPP_ADDCONST(PAD0); - EXPP_ADDCONST(PADMINUS); - EXPP_ADDCONST(PADENTER); - EXPP_ADDCONST(PADPLUSKEY); - EXPP_ADDCONST(F1KEY); - EXPP_ADDCONST(F2KEY); - EXPP_ADDCONST(F3KEY); - EXPP_ADDCONST(F4KEY); - EXPP_ADDCONST(F5KEY); - EXPP_ADDCONST(F6KEY); - EXPP_ADDCONST(F7KEY); - EXPP_ADDCONST(F8KEY); - EXPP_ADDCONST(F9KEY); - EXPP_ADDCONST(F10KEY); - EXPP_ADDCONST(F11KEY); - EXPP_ADDCONST(F12KEY); - EXPP_ADDCONST(PAUSEKEY); - EXPP_ADDCONST(INSERTKEY); - EXPP_ADDCONST(HOMEKEY); - EXPP_ADDCONST(PAGEUPKEY); - EXPP_ADDCONST(PAGEDOWNKEY); - EXPP_ADDCONST(ENDKEY); + EXPP_ADDCONST (AKEY); + EXPP_ADDCONST (BKEY); + EXPP_ADDCONST (CKEY); + EXPP_ADDCONST (DKEY); + EXPP_ADDCONST (EKEY); + EXPP_ADDCONST (FKEY); + EXPP_ADDCONST (GKEY); + EXPP_ADDCONST (HKEY); + EXPP_ADDCONST (IKEY); + EXPP_ADDCONST (JKEY); + EXPP_ADDCONST (KKEY); + EXPP_ADDCONST (LKEY); + EXPP_ADDCONST (MKEY); + EXPP_ADDCONST (NKEY); + EXPP_ADDCONST (OKEY); + EXPP_ADDCONST (PKEY); + EXPP_ADDCONST (QKEY); + EXPP_ADDCONST (RKEY); + EXPP_ADDCONST (SKEY); + EXPP_ADDCONST (TKEY); + EXPP_ADDCONST (UKEY); + EXPP_ADDCONST (VKEY); + EXPP_ADDCONST (WKEY); + EXPP_ADDCONST (XKEY); + EXPP_ADDCONST (YKEY); + EXPP_ADDCONST (ZKEY); + EXPP_ADDCONST (ZEROKEY); + EXPP_ADDCONST (ONEKEY); + EXPP_ADDCONST (TWOKEY); + EXPP_ADDCONST (THREEKEY); + EXPP_ADDCONST (FOURKEY); + EXPP_ADDCONST (FIVEKEY); + EXPP_ADDCONST (SIXKEY); + EXPP_ADDCONST (SEVENKEY); + EXPP_ADDCONST (EIGHTKEY); + EXPP_ADDCONST (NINEKEY); + EXPP_ADDCONST (CAPSLOCKKEY); + EXPP_ADDCONST (LEFTCTRLKEY); + EXPP_ADDCONST (LEFTALTKEY); + EXPP_ADDCONST (RIGHTALTKEY); + EXPP_ADDCONST (RIGHTCTRLKEY); + EXPP_ADDCONST (RIGHTSHIFTKEY); + EXPP_ADDCONST (LEFTSHIFTKEY); + EXPP_ADDCONST (ESCKEY); + EXPP_ADDCONST (TABKEY); + EXPP_ADDCONST (RETKEY); + EXPP_ADDCONST (SPACEKEY); + EXPP_ADDCONST (LINEFEEDKEY); + EXPP_ADDCONST (BACKSPACEKEY); + EXPP_ADDCONST (DELKEY); + EXPP_ADDCONST (SEMICOLONKEY); + EXPP_ADDCONST (PERIODKEY); + EXPP_ADDCONST (COMMAKEY); + EXPP_ADDCONST (QUOTEKEY); + EXPP_ADDCONST (ACCENTGRAVEKEY); + EXPP_ADDCONST (MINUSKEY); + EXPP_ADDCONST (SLASHKEY); + EXPP_ADDCONST (BACKSLASHKEY); + EXPP_ADDCONST (EQUALKEY); + EXPP_ADDCONST (LEFTBRACKETKEY); + EXPP_ADDCONST (RIGHTBRACKETKEY); + EXPP_ADDCONST (LEFTARROWKEY); + EXPP_ADDCONST (DOWNARROWKEY); + EXPP_ADDCONST (RIGHTARROWKEY); + EXPP_ADDCONST (UPARROWKEY); + EXPP_ADDCONST (PAD2); + EXPP_ADDCONST (PAD4); + EXPP_ADDCONST (PAD6); + EXPP_ADDCONST (PAD8); + EXPP_ADDCONST (PAD1); + EXPP_ADDCONST (PAD3); + EXPP_ADDCONST (PAD5); + EXPP_ADDCONST (PAD7); + EXPP_ADDCONST (PAD9); + EXPP_ADDCONST (PADPERIOD); + EXPP_ADDCONST (PADSLASHKEY); + EXPP_ADDCONST (PADASTERKEY); + EXPP_ADDCONST (PAD0); + EXPP_ADDCONST (PADMINUS); + EXPP_ADDCONST (PADENTER); + EXPP_ADDCONST (PADPLUSKEY); + EXPP_ADDCONST (F1KEY); + EXPP_ADDCONST (F2KEY); + EXPP_ADDCONST (F3KEY); + EXPP_ADDCONST (F4KEY); + EXPP_ADDCONST (F5KEY); + EXPP_ADDCONST (F6KEY); + EXPP_ADDCONST (F7KEY); + EXPP_ADDCONST (F8KEY); + EXPP_ADDCONST (F9KEY); + EXPP_ADDCONST (F10KEY); + EXPP_ADDCONST (F11KEY); + EXPP_ADDCONST (F12KEY); + EXPP_ADDCONST (PAUSEKEY); + EXPP_ADDCONST (INSERTKEY); + EXPP_ADDCONST (HOMEKEY); + EXPP_ADDCONST (PAGEUPKEY); + EXPP_ADDCONST (PAGEDOWNKEY); + EXPP_ADDCONST (ENDKEY); - return submodule; + return submodule; } diff --git a/source/blender/python/api2_2x/Draw.h b/source/blender/python/api2_2x/Draw.h index d97681f5233..b04fb5eb0ef 100644 --- a/source/blender/python/api2_2x/Draw.h +++ b/source/blender/python/api2_2x/Draw.h @@ -33,298 +33,51 @@ * bpython/intern dir, with minor modifications to suit the current * implementation. Important original comments are marked with an @ symbol. */ -#ifdef HAVE_CONFIG_H -#include -#endif +#ifndef EXPP_DRAW_H_ +#define EXPP_DRAW_H_ -#ifdef WIN32 -#include "BLI_winstuff.h" -#endif - -#include "MEM_guardedalloc.h" - -#include "BMF_Api.h" - -#include "DNA_screen_types.h" #include "DNA_space_types.h" -#include "DNA_text_types.h" - -#include "BKE_global.h" -#include "BKE_library.h" -#include "BKE_object.h" - -#include "BIF_gl.h" -#include "BIF_screen.h" -#include "BIF_space.h" -#include "BIF_interface.h" -#include "BIF_mywindow.h" - -#include "BPI_script.h" /* script struct */ - -#include "interface.h" -#include "mydevice.h" /*@ for all the event constants */ #include "Python.h" #include "gen_utils.h" #include "modules.h" -/*@ hack to flag that window redraw has happened inside slider callback: */ -int EXPP_disable_force_draw = 0; - /* From Window.h, used here by py_slider_update() */ -PyObject *M_Window_Redraw(PyObject *self, PyObject *args); +PyObject *M_Window_Redraw (PyObject * self, PyObject * args); -/* This one was an extern in BPY_main.h, but only opy_draw.c was using it */ -int g_window_redrawn; -static char Draw_doc[] = -"The Blender.Draw submodule"; - -static uiBlock *Get_uiBlock (void); void initDraw (void); -/* Button Object */ +/* + * Button Object stuct + */ -typedef struct _Button { - PyObject_VAR_HEAD - - int type; /*@ 1 == int, 2 == float, 3 == string */ - int slen; /*@ length of string (if type == 3) */ - union { +typedef struct _Button +{ + PyObject_VAR_HEAD /* required Py Macro */ + int type; /*@ 1 == int, 2 == float, 3 == string */ + int slen; /*@ length of string (if type == 3) */ + union + { int asint; float asfloat; char *asstr; - } val; -} Button; + } + val; + char *tooltip; +} +Button; -static void Button_dealloc(PyObject *self); -static PyObject *Button_getattr(PyObject *self, char *name); -static PyObject *Button_repr(PyObject *self); -static int Button_setattr(PyObject *self, char *name, PyObject *v); -PyTypeObject Button_Type = -{ - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "Button", /*tp_name*/ - sizeof(Button), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor) Button_dealloc, /*tp_dealloc*/ - (printfunc) 0, /*tp_print*/ - (getattrfunc) Button_getattr, /*tp_getattr*/ - (setattrfunc) Button_setattr, /*tp_setattr*/ - (cmpfunc) 0, /*tp_cmp*/ - (reprfunc) Button_repr, /*tp_repr*/ -}; +/* + * these are declared in ../BPY_extern.h +*/ +void BPY_spacescript_do_pywin_draw (SpaceScript * sc); +void BPY_spacescript_do_pywin_event (SpaceScript * sc, + unsigned short event, short val); +void BPY_free_compiled_text (Text * text); -static Button *newbutton (void); - -/* GUI interface routines */ - -static void exit_pydraw(SpaceScript *sc, short error); -static void exec_callback(SpaceScript *sc, PyObject *callback, PyObject *args); - -/* these are declared in ../BPY_extern.h */ -void BPY_spacescript_do_pywin_draw(SpaceScript *sc); -static void spacescript_do_pywin_buttons(SpaceScript *sc, unsigned short event); -void BPY_spacescript_do_pywin_event(SpaceScript *sc, unsigned short event, short val); -void BPY_free_compiled_text(Text *text); - -static char Method_Exit_doc[] = -"() - Exit the windowing interface"; - -static PyObject *Method_Exit (PyObject *self, PyObject *args); - -static char Method_Register_doc[] = -"(draw, event, button) - Register callbacks for windowing\n\n\ -(draw) A function to draw the screen, taking no arguments\n\ -(event) A function to handle events, taking 2 arguments (evt, val)\n\ - (evt) The event number\n\ - (val) The value modifier (for key and mouse press/release)\n\ -(button) A function to handle button events, taking 1 argument (evt)\n\ - (evt) The button number\n\n\ -A None object can be passed if a callback is unused."; - -static PyObject *Method_Register (PyObject *self, PyObject *args); - -static char Method_Redraw_doc[] = -"([after]) - Queue a redraw event\n\n\ -[after=0] Determines whether the redraw is processed before\n\ -or after other input events.\n\n\ -Redraw events are buffered so that regardless of how many events\n\ -are queued the window only receives one redraw event."; - -static PyObject *Method_Redraw (PyObject *self, PyObject *args); - -static char Method_Draw_doc[] = -"() - Force an immediate redraw\n\n\ -Forced redraws are not buffered, in other words the window is redrawn\n\ -exactly once for everytime this function is called."; - -static PyObject *Method_Draw (PyObject *self, PyObject *args); - -static char Method_Create_doc[] = -"(value) - Create a default Button object\n\n\ -(value) - The value to store in the button\n\n\ -Valid values are ints, floats, and strings"; - -static PyObject *Method_Create (PyObject *self, PyObject *args); - -static uiBlock *Get_uiBlock(void); - -static char Method_Button_doc[] = -"(name, event, x, y, width, height, [tooltip]) - Create a new Button \ -(push) button\n\n\ -(name) A string to display on the button\n\ -(event) The event number to pass to the button event function when activated\n\ -(x, y) The lower left coordinate of the button\n\ -(width, height) The button width and height\n\ -[tooltip=""] The button's tooltip"; - -static PyObject *Method_Button (PyObject *self, PyObject *args); - -static char Method_Menu_doc[] = -"(name, event, x, y, width, height, default, [tooltip]) - Create a new Menu \ -button\n\n\ -(name) A string to display on the button\n\ -(event) The event number to pass to the button event function when activated\n\ -(x, y) The lower left coordinate of the button\n\ -(width, height) The button width and height\n\ -(default) The number of the option to be selected by default\n\ -[tooltip=""] The button's tooltip\n\n\ -The menu options are specified through the name of the\n\ -button. Options are followed by a format code and separated\n\ -by the '|' (pipe) character.\n\ -Valid format codes are\n\ - %t - The option should be used as the title\n\ - %xN - The option should set the integer N in the button value."; - -static PyObject *Method_Menu (PyObject *self, PyObject *args); - -static char Method_Toggle_doc[] = -"(name, event, x, y, width, height, default, [tooltip]) - Create a new Toggle \ -button\n\n\ -(name) A string to display on the button\n\ -(event) The event number to pass to the button event function when activated\n\ -(x, y) The lower left coordinate of the button\n\ -(width, height) The button width and height\n\ -(default) An integer (0 or 1) specifying the default state\n\ -[tooltip=""] The button's tooltip"; - -static PyObject *Method_Toggle (PyObject *self, PyObject *args); -static void py_slider_update(void *butv, void *data2_unused); - -static char Method_Slider_doc[] = -"(name, event, x, y, width, height, initial, min, max, [update, tooltip]) - \ -Create a new Slider button\n\n\ -(name) A string to display on the button\n\ -(event) The event number to pass to the button event function when activated\n\ -(x, y) The lower left coordinate of the button\n\ -(width, height) The button width and height\n\ -(initial, min, max) Three values (int or float) specifying the initial \ - and limit values.\n\ -[update=1] A value controlling whether the slider will emit events as it \ -is edited.\n\ - A non-zero value (default) enables the events. A zero value supresses them.\n\ -[tooltip=""] The button's tooltip"; - -static PyObject *Method_Slider (PyObject *self, PyObject *args); - -static char Method_Scrollbar_doc[] = -"(event, x, y, width, height, initial, min, max, [update, tooltip]) - Create a \ -new Scrollbar\n\n\ -(event) The event number to pass to the button event function when activated\n\ -(x, y) The lower left coordinate of the button\n\ -(width, height) The button width and height\n\ -(initial, min, max) Three values (int or float) specifying the initial and limit values.\n\ -[update=1] A value controlling whether the slider will emit events as it is edited.\n\ - A non-zero value (default) enables the events. A zero value supresses them.\n\ -[tooltip=""] The button's tooltip"; - -static PyObject *Method_Scrollbar (PyObject *self, PyObject *args); - -static char Method_Number_doc[] = -"(name, event, x, y, width, height, initial, min, max, [tooltip]) - Create a \ -new Number button\n\n\ -(name) A string to display on the button\n\ -(event) The event number to pass to the button event function when activated\n\ -(x, y) The lower left coordinate of the button\n\ -(width, height) The button width and height\n\ -(initial, min, max) Three values (int or float) specifying the initial and \ -limit values.\n\ -[tooltip=""] The button's tooltip"; - -static PyObject *Method_Number (PyObject *self, PyObject *args); - -static char Method_String_doc[] = -"(name, event, x, y, width, height, initial, length, [tooltip]) - Create a \ -new String button\n\n\ -(name) A string to display on the button\n\ -(event) The event number to pass to the button event function when activated\n\ -(x, y) The lower left coordinate of the button\n\ -(width, height) The button width and height\n\ -(initial) The string to display initially\n\ -(length) The maximum input length\n\ -[tooltip=""] The button's tooltip"; - -static PyObject *Method_String (PyObject *self, PyObject *args); - -static char Method_GetStringWidth_doc[] = -"(text, font = 'normal') - Return the width in pixels of the given string\n\ -(font) The font size: 'normal' (default), 'small' or 'tiny'."; - -static char Method_Text_doc[] = -"(text, font = 'normal') - Draw text onscreen\n\n\ -(text) The text to draw\n\ -(font) The font size: 'normal' (default), 'small' or 'tiny'.\n\n\ -NEW! - This function now returns the width of the drawn string."; - -static PyObject *Method_GetStringWidth (PyObject *self, PyObject *args); -static PyObject *Method_Text (PyObject *self, PyObject *args); - -static char Method_PupMenu_doc[] = -"(string, maxrow = None) - Display a pop-up menu at the screen.\n\ -The contents of the pop-up are specified through the 'string' argument,\n\ -like with Draw.Menu.\n\ -'maxrow' is an optional int to control how many rows the pop-up should have.\n\ -Options are followed by a format code and separated\n\ -by the '|' (pipe) character.\n\ -Valid format codes are\n\ - %t - The option should be used as the title\n\ - %xN - The option should set the integer N in the button value.\n\n\ -Ex: Draw.PupMenu('OK?%t|QUIT BLENDER') # should be familiar ..."; - -static PyObject *Method_PupMenu (PyObject *self, PyObject *args); - -#define _MethodDef(func, prefix) \ - {#func, prefix##_##func, METH_VARARGS, prefix##_##func##_doc} - -/* So that _MethodDef(delete, Scene) expands to: - * {"delete", Scene_delete, METH_VARARGS, Scene_delete_doc} */ - -#undef MethodDef -#define MethodDef(func) _MethodDef(func, Method) - -static struct PyMethodDef Draw_methods[] = { - MethodDef(Create), - MethodDef(Button), - MethodDef(Toggle), - MethodDef(Menu), - MethodDef(Slider), - MethodDef(Scrollbar), - MethodDef(Number), - MethodDef(String), - MethodDef(GetStringWidth), - MethodDef(Text), - MethodDef(PupMenu), - MethodDef(Exit), - MethodDef(Redraw), - MethodDef(Draw), - MethodDef(Register), - - {NULL, NULL} -}; - -PyObject *M_Draw_Init (void); +PyObject *M_Draw_Init (void); +#endif /* EXPP_DRAW_H */ diff --git a/source/blender/python/api2_2x/Ipo.c b/source/blender/python/api2_2x/Ipo.c index 707e079fae2..e3dc0a5c9e1 100644 --- a/source/blender/python/api2_2x/Ipo.c +++ b/source/blender/python/api2_2x/Ipo.c @@ -30,52 +30,207 @@ */ #include "Ipo.h" + +#include +#include +#include +#include +#include + +#include "constant.h" +#include "gen_utils.h" +#include "modules.h" + + +/* forward declarations */ +void GetIpoCurveName (IpoCurve * icu, char *s); +void getname_mat_ei (int nr, char *str); +void getname_world_ei (int nr, char *str); +void getname_cam_ei (int nr, char *str); +void getname_ob_ei (int nr, char *str); + +/*****************************************************************************/ +/* Python API function prototypes for the Ipo module. */ +/*****************************************************************************/ +static PyObject *M_Ipo_New (PyObject * self, PyObject * args); +static PyObject *M_Ipo_Get (PyObject * self, PyObject * args); +static PyObject *M_Ipo_Recalc (PyObject * self, PyObject * args); + +/*****************************************************************************/ +/* The following string definitions are used for documentation strings. */ +/* In Python these will be written to the console when doing a */ +/* Blender.Ipo.__doc__ */ +/*****************************************************************************/ +char M_Ipo_doc[] = ""; +char M_Ipo_New_doc[] = ""; +char M_Ipo_Get_doc[] = ""; + + +/*****************************************************************************/ +/* Python method structure definition for Blender.Ipo module: */ +/*****************************************************************************/ + +struct PyMethodDef M_Ipo_methods[] = { + {"New", (PyCFunction) M_Ipo_New, METH_VARARGS | METH_KEYWORDS, + M_Ipo_New_doc}, + {"Get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc}, + {"get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc}, + {"Recalc", M_Ipo_Recalc, METH_VARARGS, M_Ipo_Get_doc}, + {NULL, NULL, 0, NULL} +}; + +/*****************************************************************************/ +/* Python BPy_Ipo methods declarations: */ +/*****************************************************************************/ +static PyObject *Ipo_getName (BPy_Ipo * self); +static PyObject *Ipo_setName (BPy_Ipo * self, PyObject * args); +static PyObject *Ipo_getBlocktype (BPy_Ipo * self); +static PyObject *Ipo_setBlocktype (BPy_Ipo * self, PyObject * args); +static PyObject *Ipo_getRctf (BPy_Ipo * self); +static PyObject *Ipo_setRctf (BPy_Ipo * self, PyObject * args); + +static PyObject *Ipo_getCurve (BPy_Ipo * self, PyObject * args); +static PyObject *Ipo_getCurves (BPy_Ipo * self); +static PyObject *Ipo_addCurve (BPy_Ipo * self, PyObject * args); +static PyObject *Ipo_getNcurves (BPy_Ipo * self); +static PyObject *Ipo_getNBezPoints (BPy_Ipo * self, PyObject * args); +static PyObject *Ipo_DeleteBezPoints (BPy_Ipo * self, PyObject * args); +static PyObject *Ipo_getCurveBP (BPy_Ipo * self, PyObject * args); +static PyObject *Ipo_getCurvecurval (BPy_Ipo * self, PyObject * args); +static PyObject *Ipo_EvaluateCurveOn (BPy_Ipo * self, PyObject * args); + + +static PyObject *Ipo_setCurveBeztriple (BPy_Ipo * self, PyObject * args); +static PyObject *Ipo_getCurveBeztriple (BPy_Ipo * self, PyObject * args); + +/*****************************************************************************/ +/* Python BPy_Ipo methods table: */ +/*****************************************************************************/ +static PyMethodDef BPy_Ipo_methods[] = { + /* name, method, flags, doc */ + {"getName", (PyCFunction) Ipo_getName, METH_NOARGS, + "() - Return Ipo Data name"}, + {"setName", (PyCFunction) Ipo_setName, METH_VARARGS, + "(str) - Change Ipo Data name"}, + {"getBlocktype", (PyCFunction) Ipo_getBlocktype, METH_NOARGS, + "() - Return Ipo blocktype -"}, + {"setBlocktype", (PyCFunction) Ipo_setBlocktype, METH_VARARGS, + "(str) - Change Ipo blocktype"}, + {"getRctf", (PyCFunction) Ipo_getRctf, METH_NOARGS, + "() - Return Ipo rctf - "}, + {"setRctf", (PyCFunction) Ipo_setRctf, METH_VARARGS, + "(str) - Change Ipo rctf"}, + {"addCurve", (PyCFunction) Ipo_addCurve, METH_VARARGS, + "() - Return Ipo ncurves"}, + {"getNcurves", (PyCFunction) Ipo_getNcurves, METH_NOARGS, + "() - Return Ipo ncurves"}, + {"getNBezPoints", (PyCFunction) Ipo_getNBezPoints, METH_VARARGS, + "() - Return curve number of Bez points"}, + {"delBezPoint", (PyCFunction) Ipo_DeleteBezPoints, METH_VARARGS, + "() - Return curve number of Bez points"}, + {"getCurveBP", (PyCFunction) Ipo_getCurveBP, METH_VARARGS, + "() - Return Ipo ncurves"}, + {"EvaluateCurveOn", (PyCFunction) Ipo_EvaluateCurveOn, METH_VARARGS, + "() - Return curve value at given time"}, + {"getCurveCurval", (PyCFunction) Ipo_getCurvecurval, METH_VARARGS, + "() - Return curval"}, + {"getCurveBeztriple", (PyCFunction) Ipo_getCurveBeztriple, METH_VARARGS, + "() - Return Ipo ncurves"}, + {"setCurveBeztriple", (PyCFunction) Ipo_setCurveBeztriple, METH_VARARGS, + "() - Return curval"}, + {"getCurves", (PyCFunction) Ipo_getCurves, METH_NOARGS, + "() - Return curval"}, + {"getCurve", (PyCFunction) Ipo_getCurve, METH_VARARGS, + "() - Return curval"}, + {NULL, NULL, 0, NULL} +}; + +/*****************************************************************************/ +/* Python Ipo_Type callback function prototypes: */ +/*****************************************************************************/ +static void IpoDeAlloc (BPy_Ipo * self); +//static int IpoPrint (BPy_Ipo *self, FILE *fp, int flags); +static int IpoSetAttr (BPy_Ipo * self, char *name, PyObject * v); +static PyObject *IpoGetAttr (BPy_Ipo * self, char *name); +static PyObject *IpoRepr (BPy_Ipo * self); + +/*****************************************************************************/ +/* Python Ipo_Type structure definition: */ +/*****************************************************************************/ +PyTypeObject Ipo_Type = { + PyObject_HEAD_INIT (NULL) 0, /* ob_size */ + "Ipo", /* tp_name */ + sizeof (BPy_Ipo), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor) IpoDeAlloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc) IpoGetAttr, /* tp_getattr */ + (setattrfunc) IpoSetAttr, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc) IpoRepr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_as_hash */ + 0, 0, 0, 0, 0, 0, + 0, /* tp_doc */ + 0, 0, 0, 0, 0, 0, + BPy_Ipo_methods, /* tp_methods */ + 0, /* tp_members */ +}; + /*****************************************************************************/ /* Function: M_Ipo_New */ /* Python equivalent: Blender.Ipo.New */ /*****************************************************************************/ - - -static PyObject *M_Ipo_New(PyObject *self, PyObject *args) +static PyObject * +M_Ipo_New (PyObject * self, PyObject * args) { - Ipo *add_ipo(char *name, int idcode); - char*name = NULL,*code=NULL; - int idcode = -1; - BPy_Ipo *pyipo; - Ipo *blipo; + Ipo *add_ipo (char *name, int idcode); + char *name = NULL, *code = NULL; + int idcode = -1; + BPy_Ipo *pyipo; + Ipo *blipo; - if (!PyArg_ParseTuple(args, "ss", &code,&name)) - return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected string string arguments")); + if (!PyArg_ParseTuple (args, "ss", &code, &name)) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "expected string string arguments")); + + if (!strcmp (code, "Object")) + idcode = ID_OB; + if (!strcmp (code, "Camera")) + idcode = ID_CA; + if (!strcmp (code, "World")) + idcode = ID_WO; + if (!strcmp (code, "Material")) + idcode = ID_MA; - if (!strcmp(code,"Object"))idcode = ID_OB; - if (!strcmp(code,"Camera"))idcode = ID_CA; - if (!strcmp(code,"World"))idcode = ID_WO; - if (!strcmp(code,"Material"))idcode = ID_MA; - if (idcode == -1) - return (EXPP_ReturnPyObjError (PyExc_TypeError,"Bad code")); - - - blipo = add_ipo(name,idcode); + return (EXPP_ReturnPyObjError (PyExc_TypeError, "Bad code")); - if (blipo){ - /* return user count to zero because add_ipo() inc'd it */ - blipo->id.us = 0; - /* create python wrapper obj */ - pyipo = (BPy_Ipo *)PyObject_NEW(BPy_Ipo, &Ipo_Type); - } + + blipo = add_ipo (name, idcode); + + if (blipo) + { + /* return user count to zero because add_ipo() inc'd it */ + blipo->id.us = 0; + /* create python wrapper obj */ + pyipo = (BPy_Ipo *) PyObject_NEW (BPy_Ipo, &Ipo_Type); + } else return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't create Ipo Data in Blender")); + "couldn't create Ipo Data in Blender")); if (pyipo == NULL) return (EXPP_ReturnPyObjError (PyExc_MemoryError, - "couldn't create Ipo Data object")); + "couldn't create Ipo Data object")); - pyipo->ipo = blipo; + pyipo->ipo = blipo; - return (PyObject *)pyipo; + return (PyObject *) pyipo; } /*****************************************************************************/ @@ -86,89 +241,101 @@ static PyObject *M_Ipo_New(PyObject *self, PyObject *args) /* passed in, a list of all ipo data names in the */ /* current scene is returned. */ /*****************************************************************************/ -static PyObject *M_Ipo_Get(PyObject *self, PyObject *args) +static PyObject * +M_Ipo_Get (PyObject * self, PyObject * args) { - char *name = NULL; + char *name = NULL; Ipo *ipo_iter; PyObject *ipolist, *pyobj; BPy_Ipo *wanted_ipo = NULL; char error_msg[64]; - if (!PyArg_ParseTuple(args, "|s", &name)) + if (!PyArg_ParseTuple (args, "|s", &name)) return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected string argument (or nothing)")); + "expected string argument (or nothing)")); ipo_iter = G.main->ipo.first; - if (name) { /* (name) - Search ipo by name */ - while ((ipo_iter) && (wanted_ipo == NULL)) { - if (strcmp (name, ipo_iter->id.name+2) == 0) { - wanted_ipo = (BPy_Ipo *)PyObject_NEW(BPy_Ipo, &Ipo_Type); - if (wanted_ipo) wanted_ipo->ipo = ipo_iter; - } - ipo_iter = ipo_iter->id.next; - } - - if (wanted_ipo == NULL) { /* Requested ipo doesn't exist */ - PyOS_snprintf(error_msg, sizeof(error_msg), - "Ipo \"%s\" not found", name); - return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg)); - } - - return (PyObject *)wanted_ipo; - } - - else { /* () - return a list with all ipos in the scene */ - int index = 0; - - ipolist = PyList_New (BLI_countlist (&(G.main->ipo))); - - if (ipolist == NULL) - return (PythonReturnErrorObject (PyExc_MemoryError, - "couldn't create PyList")); - - while (ipo_iter) { - pyobj = Ipo_CreatePyObject (ipo_iter); - - if (!pyobj) - return (PythonReturnErrorObject (PyExc_MemoryError, - "couldn't create PyString")); - - PyList_SET_ITEM (ipolist, index, pyobj); - - ipo_iter = ipo_iter->id.next; - index++; - } - - return (ipolist); + if (name) + { /* (name) - Search ipo by name */ + while ((ipo_iter) && (wanted_ipo == NULL)) + { + if (strcmp (name, ipo_iter->id.name + 2) == 0) + { + wanted_ipo = (BPy_Ipo *) PyObject_NEW (BPy_Ipo, &Ipo_Type); + if (wanted_ipo) + wanted_ipo->ipo = ipo_iter; + } + ipo_iter = ipo_iter->id.next; } + + if (wanted_ipo == NULL) + { /* Requested ipo doesn't exist */ + PyOS_snprintf (error_msg, sizeof (error_msg), + "Ipo \"%s\" not found", name); + return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg)); + } + + return (PyObject *) wanted_ipo; + } + + else + { /* () - return a list with all ipos in the scene */ + int index = 0; + + ipolist = PyList_New (BLI_countlist (&(G.main->ipo))); + + if (ipolist == NULL) + return (PythonReturnErrorObject (PyExc_MemoryError, + "couldn't create PyList")); + + while (ipo_iter) + { + pyobj = Ipo_CreatePyObject (ipo_iter); + + if (!pyobj) + return (PythonReturnErrorObject (PyExc_MemoryError, + "couldn't create PyString")); + + PyList_SET_ITEM (ipolist, index, pyobj); + + ipo_iter = ipo_iter->id.next; + index++; + } + + return (ipolist); + } } -static PyObject * M_Ipo_Recalc(PyObject *self, PyObject *args) -{ - void testhandles_ipocurve(IpoCurve *icu); - PyObject *a; -IpoCurve *icu; -if (!PyArg_ParseTuple(args, "O", &a)) - return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected ipo argument)")); -icu = IpoCurve_FromPyObject(a); - testhandles_ipocurve(icu); - -Py_INCREF(Py_None); +static PyObject * +M_Ipo_Recalc (PyObject * self, PyObject * args) +{ + void testhandles_ipocurve (IpoCurve * icu); + PyObject *a; + IpoCurve *icu; + if (!PyArg_ParseTuple (args, "O", &a)) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "expected ipo argument)")); + icu = IpoCurve_FromPyObject (a); + testhandles_ipocurve (icu); + + Py_INCREF (Py_None); return Py_None; } + /*****************************************************************************/ /* Function: Ipo_Init */ /*****************************************************************************/ -PyObject *Ipo_Init (void) +PyObject * +Ipo_Init (void) { - PyObject *submodule; + PyObject *submodule; Ipo_Type.ob_type = &PyType_Type; - submodule = Py_InitModule3("Blender.Ipo", M_Ipo_methods, M_Ipo_doc); + submodule = Py_InitModule3 ("Blender.Ipo", M_Ipo_methods, M_Ipo_doc); return (submodule); } @@ -176,425 +343,567 @@ PyObject *Ipo_Init (void) /*****************************************************************************/ /* Python BPy_Ipo methods: */ /*****************************************************************************/ -static PyObject *Ipo_getName(BPy_Ipo *self) +static PyObject * +Ipo_getName (BPy_Ipo * self) { - PyObject *attr = PyString_FromString(self->ipo->id.name+2); + PyObject *attr = PyString_FromString (self->ipo->id.name + 2); - if (attr) return attr; - Py_INCREF(Py_None); + if (attr) + return attr; + Py_INCREF (Py_None); return Py_None; } - - - - - - -static PyObject *Ipo_setName(BPy_Ipo *self, PyObject *args) +static PyObject * +Ipo_setName (BPy_Ipo * self, PyObject * args) { char *name; char buf[21]; - if (!PyArg_ParseTuple(args, "s", &name)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected string argument")); + if (!PyArg_ParseTuple (args, "s", &name)) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "expected string argument")); - PyOS_snprintf(buf, sizeof(buf), "%s", name); + PyOS_snprintf (buf, sizeof (buf), "%s", name); - rename_id(&self->ipo->id, buf); + rename_id (&self->ipo->id, buf); - Py_INCREF(Py_None); + Py_INCREF (Py_None); return Py_None; } -static PyObject *Ipo_getBlocktype(BPy_Ipo *self) +static PyObject * +Ipo_getBlocktype (BPy_Ipo * self) { - PyObject *attr = PyInt_FromLong(self->ipo->blocktype); - if (attr) return attr; - return (EXPP_ReturnPyObjError (PyExc_RuntimeError,"couldn't get Ipo.blocktype attribute")); + PyObject *attr = PyInt_FromLong (self->ipo->blocktype); + if (attr) + return attr; + return (EXPP_ReturnPyObjError + (PyExc_RuntimeError, "couldn't get Ipo.blocktype attribute")); } -static PyObject *Ipo_setBlocktype(BPy_Ipo *self, PyObject *args) +static PyObject * +Ipo_setBlocktype (BPy_Ipo * self, PyObject * args) { int blocktype = 0; - if (!PyArg_ParseTuple(args, "i", &blocktype)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected string argument")); + if (!PyArg_ParseTuple (args, "i", &blocktype)) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "expected string argument")); - self->ipo->blocktype = (short)blocktype; + self->ipo->blocktype = (short) blocktype; - Py_INCREF(Py_None); + Py_INCREF (Py_None); return Py_None; } - -static PyObject *Ipo_getRctf(BPy_Ipo *self) +static PyObject * +Ipo_getRctf (BPy_Ipo * self) { - PyObject* l = PyList_New(0); - PyList_Append( l, PyFloat_FromDouble(self->ipo->cur.xmin)); - PyList_Append( l, PyFloat_FromDouble(self->ipo->cur.xmax)); - PyList_Append( l, PyFloat_FromDouble(self->ipo->cur.ymin)); - PyList_Append( l, PyFloat_FromDouble(self->ipo->cur.ymax)); + PyObject *l = PyList_New (0); + PyList_Append (l, PyFloat_FromDouble (self->ipo->cur.xmin)); + PyList_Append (l, PyFloat_FromDouble (self->ipo->cur.xmax)); + PyList_Append (l, PyFloat_FromDouble (self->ipo->cur.ymin)); + PyList_Append (l, PyFloat_FromDouble (self->ipo->cur.ymax)); return l; } -static PyObject *Ipo_setRctf(BPy_Ipo *self, PyObject *args) +static PyObject * +Ipo_setRctf (BPy_Ipo * self, PyObject * args) { - float v[4]; - if (!PyArg_ParseTuple(args, "ffff",v,v+1,v+2,v+3)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected 4 float argument")); + float v[4]; + if (!PyArg_ParseTuple (args, "ffff", v, v + 1, v + 2, v + 3)) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "expected 4 float argument")); - self->ipo->cur.xmin = v[0]; - self->ipo->cur.xmax = v[1]; - self->ipo->cur.ymin = v[2]; - self->ipo->cur.ymax = v[3]; + self->ipo->cur.xmin = v[0]; + self->ipo->cur.xmax = v[1]; + self->ipo->cur.ymin = v[2]; + self->ipo->cur.ymax = v[3]; - Py_INCREF(Py_None); + Py_INCREF (Py_None); return Py_None; } -static PyObject *Ipo_getNcurves(BPy_Ipo *self) -{ - int i = 0; +static PyObject * +Ipo_getNcurves (BPy_Ipo * self) +{ + int i = 0; - IpoCurve *icu; - for (icu=self->ipo->curve.first; icu; icu=icu->next){ - i++; - } + IpoCurve *icu; + for (icu = self->ipo->curve.first; icu; icu = icu->next) + { + i++; + } - return (PyInt_FromLong(i) ); + return (PyInt_FromLong (i)); } - - - -static PyObject *Ipo_addCurve(BPy_Ipo *self, PyObject *args) +static PyObject * +Ipo_addCurve (BPy_Ipo * self, PyObject * args) { - IpoCurve *get_ipocurve(ID *from, short type, int adrcode, Ipo *useipo); - void allspace(unsigned short event, short val) ; - void allqueue(unsigned short event, short val); - int param = 0,ok = 0; - char*s = 0; - IpoCurve*icu; - Link * link; - struct Object * object = NULL; + IpoCurve *get_ipocurve (ID * from, short type, int adrcode, Ipo * useipo); + void allspace (unsigned short event, short val); + void allqueue (unsigned short event, short val); + int param = 0, ok = 0; + char *s = 0; + IpoCurve *icu; + Link *link; + struct Object *object = NULL; - if (!PyArg_ParseTuple(args, "s",&s)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected string argument")); - - /* insertkey demande un pointeur sur l'objet pour lequel on veut ajouter - une courbe IPO*/ - link = G.main->object.first; - while (link) - { - object = (Object*)link; - if (object->ipo == self->ipo)break; - link = link->next; - } - /* todo : what kind of object.... -#define GS(a) (*((short *)(a))) - printf("object %p\n",object); - printf("type %d\n",GS(object->id.name)); - */ + if (!PyArg_ParseTuple (args, "s", &s)) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "expected string argument")); - if (!strcmp(s,"LocX")){param = OB_LOC_X;ok = 1;} - if (!strcmp(s,"LocY")){param = OB_LOC_Y;ok = 1;} - if (!strcmp(s,"LocZ")){param = OB_LOC_Z;ok = 1;} - if (!strcmp(s,"RotX")){param = OB_ROT_X;ok = 1;} - if (!strcmp(s,"RotY")){param = OB_ROT_Y;ok = 1;} - if (!strcmp(s,"RotZ")){param = OB_ROT_Z;ok = 1;} - if (!strcmp(s,"SizeX")){param = OB_SIZE_X;ok = 1;} - if (!strcmp(s,"SizeY")){param = OB_SIZE_Y;ok = 1;} - if (!strcmp(s,"SizeZ")){param = OB_SIZE_Z;ok = 1;} + /* insertkey demande un pointeur sur l'objet pour lequel on veut ajouter + une courbe IPO */ + link = G.main->object.first; + while (link) + { + object = (Object *) link; + if (object->ipo == self->ipo) + break; + link = link->next; + } + /* todo : what kind of object.... + #define GS(a) (*((short *)(a))) + printf("object %p\n",object); + printf("type %d\n",GS(object->id.name)); + */ - if (!strcmp(s,"DLocX")){param = OB_DLOC_X;ok = 1;} - if (!strcmp(s,"DLocY")){param = OB_DLOC_Y;ok = 1;} - if (!strcmp(s,"DLocZ")){param = OB_DLOC_Z;ok = 1;} - if (!strcmp(s,"DRotX")){param = OB_DROT_X;ok = 1;} - if (!strcmp(s,"DRotY")){param = OB_DROT_Y;ok = 1;} - if (!strcmp(s,"DRotZ")){param = OB_DROT_Z;ok = 1;} - if (!strcmp(s,"DSizeX")){param = OB_DSIZE_X;ok = 1;} - if (!strcmp(s,"DSizeY")){param = OB_DSIZE_Y;ok = 1;} - if (!strcmp(s,"DSizeZ")){param = OB_DSIZE_Z;ok = 1;} + if (!strcmp (s, "LocX")) + { + param = OB_LOC_X; + ok = 1; + } + if (!strcmp (s, "LocY")) + { + param = OB_LOC_Y; + ok = 1; + } + if (!strcmp (s, "LocZ")) + { + param = OB_LOC_Z; + ok = 1; + } + if (!strcmp (s, "RotX")) + { + param = OB_ROT_X; + ok = 1; + } + if (!strcmp (s, "RotY")) + { + param = OB_ROT_Y; + ok = 1; + } + if (!strcmp (s, "RotZ")) + { + param = OB_ROT_Z; + ok = 1; + } + if (!strcmp (s, "SizeX")) + { + param = OB_SIZE_X; + ok = 1; + } + if (!strcmp (s, "SizeY")) + { + param = OB_SIZE_Y; + ok = 1; + } + if (!strcmp (s, "SizeZ")) + { + param = OB_SIZE_Z; + ok = 1; + } - if (!strcmp(s,"Layer")){param = OB_LAY;ok = 1;} - if (!strcmp(s,"Time")){param = OB_TIME;ok = 1;} + if (!strcmp (s, "DLocX")) + { + param = OB_DLOC_X; + ok = 1; + } + if (!strcmp (s, "DLocY")) + { + param = OB_DLOC_Y; + ok = 1; + } + if (!strcmp (s, "DLocZ")) + { + param = OB_DLOC_Z; + ok = 1; + } + if (!strcmp (s, "DRotX")) + { + param = OB_DROT_X; + ok = 1; + } + if (!strcmp (s, "DRotY")) + { + param = OB_DROT_Y; + ok = 1; + } + if (!strcmp (s, "DRotZ")) + { + param = OB_DROT_Z; + ok = 1; + } + if (!strcmp (s, "DSizeX")) + { + param = OB_DSIZE_X; + ok = 1; + } + if (!strcmp (s, "DSizeY")) + { + param = OB_DSIZE_Y; + ok = 1; + } + if (!strcmp (s, "DSizeZ")) + { + param = OB_DSIZE_Z; + ok = 1; + } - if (!strcmp(s,"ColR")){param = OB_COL_R;ok = 1;} - if (!strcmp(s,"ColG")){param = OB_COL_G;ok = 1;} - if (!strcmp(s,"ColB")){param = OB_COL_B;ok = 1;} - if (!strcmp(s,"ColA")){param = OB_COL_A;ok = 1;} - if(!ok) return (EXPP_ReturnPyObjError (PyExc_ValueError, "Not a valid param.")); + if (!strcmp (s, "Layer")) + { + param = OB_LAY; + ok = 1; + } + if (!strcmp (s, "Time")) + { + param = OB_TIME; + ok = 1; + } - icu = get_ipocurve(&(object->id),ID_OB, param, 0); + if (!strcmp (s, "ColR")) + { + param = OB_COL_R; + ok = 1; + } + if (!strcmp (s, "ColG")) + { + param = OB_COL_G; + ok = 1; + } + if (!strcmp (s, "ColB")) + { + param = OB_COL_B; + ok = 1; + } + if (!strcmp (s, "ColA")) + { + param = OB_COL_A; + ok = 1; + } + if (!ok) + return (EXPP_ReturnPyObjError (PyExc_ValueError, "Not a valid param.")); + + icu = get_ipocurve (&(object->id), ID_OB, param, 0); #define REMAKEIPO 1 #define REDRAWIPO 0x4023 - allspace(REMAKEIPO, 0); - allqueue(REDRAWIPO, 0); + allspace (REMAKEIPO, 0); + allqueue (REDRAWIPO, 0); - return IpoCurve_CreatePyObject(icu); + return IpoCurve_CreatePyObject (icu); } - -void GetIpoCurveName(IpoCurve *icu,char*s); -void getname_mat_ei(int nr, char *str); -void getname_world_ei(int nr, char *str); -void getname_cam_ei(int nr, char *str); -void getname_ob_ei(int nr, char *str); - -static PyObject *Ipo_getCurve(BPy_Ipo *self, PyObject *args) +static PyObject * +Ipo_getCurve (BPy_Ipo * self, PyObject * args) { - //int num = 0 , i = 0; - char*str; - IpoCurve *icu = 0; - if (!PyArg_ParseTuple(args, "s",&str)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected string argument")); - for (icu=self->ipo->curve.first; icu; icu=icu->next){ - char str1[80]; - GetIpoCurveName(icu,str1); - if (!strcmp(str1,str))return IpoCurve_CreatePyObject(icu); - } + //int num = 0 , i = 0; + char *str; + IpoCurve *icu = 0; + if (!PyArg_ParseTuple (args, "s", &str)) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "expected string argument")); + for (icu = self->ipo->curve.first; icu; icu = icu->next) + { + char str1[80]; + GetIpoCurveName (icu, str1); + if (!strcmp (str1, str)) + return IpoCurve_CreatePyObject (icu); + } - Py_INCREF(Py_None); + Py_INCREF (Py_None); return Py_None; } -void GetIpoCurveName(IpoCurve *icu,char*s) +void +GetIpoCurveName (IpoCurve * icu, char *s) { - switch (icu->blocktype) - { - case ID_MA : {getname_mat_ei(icu->adrcode,s);break;} - case ID_WO : {getname_world_ei(icu->adrcode,s);break;} - case ID_CA : {getname_cam_ei(icu->adrcode,s);break;} - case ID_OB : {getname_ob_ei(icu->adrcode,s);break;} - } + switch (icu->blocktype) + { + case ID_MA: + { + getname_mat_ei (icu->adrcode, s); + break; + } + case ID_WO: + { + getname_world_ei (icu->adrcode, s); + break; + } + case ID_CA: + { + getname_cam_ei (icu->adrcode, s); + break; + } + case ID_OB: + { + getname_ob_ei (icu->adrcode, s); + break; + } + } } -static PyObject *Ipo_getCurves(BPy_Ipo *self) +static PyObject * +Ipo_getCurves (BPy_Ipo * self) { - PyObject *attr = PyList_New(0); + PyObject *attr = PyList_New (0); IpoCurve *icu; - for (icu=self->ipo->curve.first; icu; icu=icu->next) - { - PyList_Append(attr, IpoCurve_CreatePyObject(icu)); - } - return attr; + for (icu = self->ipo->curve.first; icu; icu = icu->next) + { + PyList_Append (attr, IpoCurve_CreatePyObject (icu)); + } + return attr; } -static PyObject *Ipo_getNBezPoints(BPy_Ipo *self, PyObject *args) -{ - int num = 0 , i = 0; - IpoCurve *icu = 0; - if (!PyArg_ParseTuple(args, "i",&num)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument")); - icu =self->ipo->curve.first; - if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve")); - for(i = 0;inext; - - } - return (PyInt_FromLong(icu->totvert) ); -} - -static PyObject *Ipo_DeleteBezPoints(BPy_Ipo *self, PyObject *args) -{ - int num = 0 , i = 0; - IpoCurve *icu = 0; - if (!PyArg_ParseTuple(args, "i",&num)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument")); - icu =self->ipo->curve.first; - if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve")); - for(i = 0;inext; - - } - icu->totvert--; - return (PyInt_FromLong(icu->totvert) ); -} - - - - - -static PyObject *Ipo_getCurveBP(BPy_Ipo *self, PyObject *args) -{ - struct BPoint *ptrbpoint; - int num = 0,i; - IpoCurve *icu; - PyObject* l; - - if (!PyArg_ParseTuple(args, "i",&num)) +static PyObject * +Ipo_getNBezPoints (BPy_Ipo * self, PyObject * args) +{ + int num = 0, i = 0; + IpoCurve *icu = 0; + if (!PyArg_ParseTuple (args, "i", &num)) return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument")); - icu =self->ipo->curve.first; - if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve")); - for(i = 0;inext; - + icu = self->ipo->curve.first; + if (!icu) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "No IPO curve")); + for (i = 0; i < num; i++) + { + if (!icu) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "Bad curve number")); + icu = icu->next; + } - ptrbpoint = icu->bp; - if(!ptrbpoint)return EXPP_ReturnPyObjError(PyExc_TypeError,"No base point"); - - l = PyList_New(0); - for(i=0;i<4;i++) - PyList_Append( l, PyFloat_FromDouble(ptrbpoint->vec[i])); - return l; + return (PyInt_FromLong (icu->totvert)); } -static PyObject *Ipo_getCurveBeztriple(BPy_Ipo *self, PyObject *args) -{ - struct BezTriple *ptrbt; - int num = 0,pos,i,j; - IpoCurve *icu; - PyObject* l = PyList_New(0); +static PyObject * +Ipo_DeleteBezPoints (BPy_Ipo * self, PyObject * args) +{ + int num = 0, i = 0; + IpoCurve *icu = 0; + if (!PyArg_ParseTuple (args, "i", &num)) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument")); + icu = self->ipo->curve.first; + if (!icu) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "No IPO curve")); + for (i = 0; i < num; i++) + { + if (!icu) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "Bad curve number")); + icu = icu->next; - if (!PyArg_ParseTuple(args, "ii",&num,&pos)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected int argument")); - icu =self->ipo->curve.first; - if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve")); - for(i = 0;inext; - } - if (pos >= icu->totvert) - return EXPP_ReturnPyObjError(PyExc_TypeError,"Bad bezt number"); - - ptrbt = icu->bezt + pos; - if(!ptrbt) - return EXPP_ReturnPyObjError(PyExc_TypeError,"No bez triple"); - - for(i=0;i<3;i++) - for(j=0;j<3;j++) - PyList_Append( l, PyFloat_FromDouble(ptrbt->vec[i][j])); - return l; + } + icu->totvert--; + return (PyInt_FromLong (icu->totvert)); } -static PyObject *Ipo_setCurveBeztriple(BPy_Ipo *self, PyObject *args) -{ - struct BezTriple *ptrbt; - int num = 0,pos,i; - IpoCurve *icu; - PyObject *listargs=0; +static PyObject * +Ipo_getCurveBP (BPy_Ipo * self, PyObject * args) +{ + struct BPoint *ptrbpoint; + int num = 0, i; + IpoCurve *icu; + PyObject *l; - if (!PyArg_ParseTuple(args, "iiO",&num,&pos,&listargs)) - return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected int int object argument")); - if(!PyTuple_Check(listargs)) -return (EXPP_ReturnPyObjError (PyExc_TypeError,"3rd arg should be a tuple")); - icu =self->ipo->curve.first; - if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve")); - for(i = 0;inext; - } - if (pos >= icu->totvert) - return EXPP_ReturnPyObjError(PyExc_TypeError,"Bad bezt number"); + if (!PyArg_ParseTuple (args, "i", &num)) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument")); + icu = self->ipo->curve.first; + if (!icu) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "No IPO curve")); + for (i = 0; i < num; i++) + { + if (!icu) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "Bad curve number")); + icu = icu->next; - ptrbt = icu->bezt + pos; - if(!ptrbt) - return EXPP_ReturnPyObjError(PyExc_TypeError,"No bez triple"); - - for(i=0;i<9;i++) - { - PyObject * xx = PyTuple_GetItem(listargs,i); - ptrbt->vec[i/3][i%3] = PyFloat_AsDouble(xx); - } + } + ptrbpoint = icu->bp; + if (!ptrbpoint) + return EXPP_ReturnPyObjError (PyExc_TypeError, "No base point"); - Py_INCREF(Py_None); + l = PyList_New (0); + for (i = 0; i < 4; i++) + PyList_Append (l, PyFloat_FromDouble (ptrbpoint->vec[i])); + return l; +} + +static PyObject * +Ipo_getCurveBeztriple (BPy_Ipo * self, PyObject * args) +{ + struct BezTriple *ptrbt; + int num = 0, pos, i, j; + IpoCurve *icu; + PyObject *l = PyList_New (0); + + if (!PyArg_ParseTuple (args, "ii", &num, &pos)) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument")); + icu = self->ipo->curve.first; + if (!icu) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "No IPO curve")); + for (i = 0; i < num; i++) + { + if (!icu) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "Bad ipo number")); + icu = icu->next; + } + if (pos >= icu->totvert) + return EXPP_ReturnPyObjError (PyExc_TypeError, "Bad bezt number"); + + ptrbt = icu->bezt + pos; + if (!ptrbt) + return EXPP_ReturnPyObjError (PyExc_TypeError, "No bez triple"); + + for (i = 0; i < 3; i++) + for (j = 0; j < 3; j++) + PyList_Append (l, PyFloat_FromDouble (ptrbt->vec[i][j])); + return l; +} + + +static PyObject * +Ipo_setCurveBeztriple (BPy_Ipo * self, PyObject * args) +{ + struct BezTriple *ptrbt; + int num = 0, pos, i; + IpoCurve *icu; + PyObject *listargs = 0; + + if (!PyArg_ParseTuple (args, "iiO", &num, &pos, &listargs)) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "expected int int object argument")); + if (!PyTuple_Check (listargs)) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "3rd arg should be a tuple")); + icu = self->ipo->curve.first; + if (!icu) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "No IPO curve")); + for (i = 0; i < num; i++) + { + if (!icu) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "Bad ipo number")); + icu = icu->next; + } + if (pos >= icu->totvert) + return EXPP_ReturnPyObjError (PyExc_TypeError, "Bad bezt number"); + + ptrbt = icu->bezt + pos; + if (!ptrbt) + return EXPP_ReturnPyObjError (PyExc_TypeError, "No bez triple"); + + for (i = 0; i < 9; i++) + { + PyObject *xx = PyTuple_GetItem (listargs, i); + ptrbt->vec[i / 3][i % 3] = PyFloat_AsDouble (xx); + } + + Py_INCREF (Py_None); return Py_None; } +static PyObject * +Ipo_EvaluateCurveOn (BPy_Ipo * self, PyObject * args) +{ + float eval_icu (IpoCurve * icu, float ipotime); + int num = 0, i; + IpoCurve *icu; + float time = 0; -static PyObject *Ipo_EvaluateCurveOn(BPy_Ipo *self, PyObject *args) -{ - float eval_icu(IpoCurve *icu, float ipotime) ; - - int num = 0,i; - IpoCurve *icu; - float time = 0; + if (!PyArg_ParseTuple (args, "if", &num, &time)) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument")); + icu = self->ipo->curve.first; + if (!icu) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "No IPO curve")); + for (i = 0; i < num; i++) + { + if (!icu) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "Bad ipo number")); + icu = icu->next; - if (!PyArg_ParseTuple(args, "if",&num,&time)) - return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected int argument")); - icu =self->ipo->curve.first; - if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve")); - for(i = 0;inext; - } - return PyFloat_FromDouble(eval_icu(icu,time)); + return PyFloat_FromDouble (eval_icu (icu, time)); } -static PyObject *Ipo_getCurvecurval(BPy_Ipo *self, PyObject *args) -{ - int numcurve = 0,i; - IpoCurve *icu; - char*stringname = 0; +static PyObject * +Ipo_getCurvecurval (BPy_Ipo * self, PyObject * args) +{ + int numcurve = 0, i; + IpoCurve *icu; + char *stringname = 0; - icu =self->ipo->curve.first; - if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve")); + icu = self->ipo->curve.first; + if (!icu) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "No IPO curve")); - if (PyNumber_Check(PySequence_GetItem(args,0)))// args is an integer - { - if (!PyArg_ParseTuple(args, "i",&numcurve)) - return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected int or string argument")); - for(i = 0;inext; - } - } + if (PyNumber_Check (PySequence_GetItem (args, 0))) // args is an integer + { + if (!PyArg_ParseTuple (args, "i", &numcurve)) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "expected int or string argument")); + for (i = 0; i < numcurve; i++) + { + if (!icu) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "Bad ipo number")); + icu = icu->next; + } + } - else // args is a string - { -if (!PyArg_ParseTuple(args, "s",&stringname)) - return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected int or string argument")); - while (icu) - { - char str1[10]; - GetIpoCurveName(icu,str1); - if (!strcmp(str1,stringname))break; - icu=icu->next; - } - } - - if (icu) return PyFloat_FromDouble(icu->curval); - Py_INCREF(Py_None); + else // args is a string + { + if (!PyArg_ParseTuple (args, "s", &stringname)) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "expected int or string argument")); + while (icu) + { + char str1[10]; + GetIpoCurveName (icu, str1); + if (!strcmp (str1, stringname)) + break; + icu = icu->next; + } + } + + if (icu) + return PyFloat_FromDouble (icu->curval); + Py_INCREF (Py_None); return Py_None; } - /*****************************************************************************/ /* Function: IpoDeAlloc */ /* Description: This is a callback function for the BPy_Ipo type. It is */ /* the destructor function. */ /*****************************************************************************/ -static void IpoDeAlloc (BPy_Ipo *self) +static void +IpoDeAlloc (BPy_Ipo * self) { PyObject_DEL (self); } @@ -605,10 +914,12 @@ static void IpoDeAlloc (BPy_Ipo *self) /* the function that accesses BPy_Ipo "member variables" and */ /* methods. */ /*****************************************************************************/ -static PyObject *IpoGetAttr (BPy_Ipo *self, char *name) +static PyObject * +IpoGetAttr (BPy_Ipo * self, char *name) { -if (strcmp (name, "curves") == 0)return Ipo_getCurves (self); - return Py_FindMethod(BPy_Ipo_methods, (PyObject *)self, name); + if (strcmp (name, "curves") == 0) + return Ipo_getCurves (self); + return Py_FindMethod (BPy_Ipo_methods, (PyObject *) self, name); } /*****************************************************************************/ @@ -616,9 +927,10 @@ if (strcmp (name, "curves") == 0)return Ipo_getCurves (self); /* Description: This is a callback function for the BPy_Ipo type. It is the */ /* function that sets Ipo Data attributes (member variables).*/ /*****************************************************************************/ -static int IpoSetAttr (BPy_Ipo *self, char *name, PyObject *value) +static int +IpoSetAttr (BPy_Ipo * self, char *name, PyObject * value) { - return 0; /* normal exit */ + return 0; /* normal exit */ } /*****************************************************************************/ @@ -626,9 +938,11 @@ static int IpoSetAttr (BPy_Ipo *self, char *name, PyObject *value) /* Description: This is a callback function for the BPy_Ipo type. It */ /* builds a meaninful string to represent ipo objects. */ /*****************************************************************************/ -static PyObject *IpoRepr (BPy_Ipo *self) +static PyObject * +IpoRepr (BPy_Ipo * self) { - return PyString_FromFormat("[Ipo \"%s\" %d]", self->ipo->id.name+2,self->ipo->blocktype); + return PyString_FromFormat ("[Ipo \"%s\" %d]", self->ipo->id.name + 2, + self->ipo->blocktype); } /* Three Python Ipo_Type helper functions needed by the Object module: */ @@ -638,14 +952,16 @@ static PyObject *IpoRepr (BPy_Ipo *self) /* Description: This function will create a new BPy_Ipo from an existing */ /* Blender ipo structure. */ /*****************************************************************************/ -PyObject *Ipo_CreatePyObject (Ipo *ipo) +PyObject * +Ipo_CreatePyObject (Ipo * ipo) { - BPy_Ipo *pyipo; - pyipo = (BPy_Ipo *)PyObject_NEW (BPy_Ipo, &Ipo_Type); - if (!pyipo) - return EXPP_ReturnPyObjError (PyExc_MemoryError,"couldn't create BPy_Ipo object"); - pyipo->ipo = ipo; - return (PyObject *)pyipo; + BPy_Ipo *pyipo; + pyipo = (BPy_Ipo *) PyObject_NEW (BPy_Ipo, &Ipo_Type); + if (!pyipo) + return EXPP_ReturnPyObjError (PyExc_MemoryError, + "couldn't create BPy_Ipo object"); + pyipo->ipo = ipo; + return (PyObject *) pyipo; } /*****************************************************************************/ @@ -653,9 +969,10 @@ PyObject *Ipo_CreatePyObject (Ipo *ipo) /* Description: This function returns true when the given PyObject is of the */ /* type Ipo. Otherwise it will return false. */ /*****************************************************************************/ -int Ipo_CheckPyObject (PyObject *pyobj) +int +Ipo_CheckPyObject (PyObject * pyobj) { - return (pyobj->ob_type == &Ipo_Type); + return (pyobj->ob_type == &Ipo_Type); } /*****************************************************************************/ @@ -663,7 +980,8 @@ int Ipo_CheckPyObject (PyObject *pyobj) /* Description: This function returns the Blender ipo from the given */ /* PyObject. */ /*****************************************************************************/ -Ipo *Ipo_FromPyObject (PyObject *pyobj) +Ipo * +Ipo_FromPyObject (PyObject * pyobj) { - return ((BPy_Ipo *)pyobj)->ipo; + return ((BPy_Ipo *) pyobj)->ipo; } diff --git a/source/blender/python/api2_2x/Ipo.h b/source/blender/python/api2_2x/Ipo.h index 1f78b613903..24b55e0480b 100644 --- a/source/blender/python/api2_2x/Ipo.h +++ b/source/blender/python/api2_2x/Ipo.h @@ -33,157 +33,17 @@ #define EXPP_IPO_H #include - -#include -#include -#include -#include -#include #include -#include "constant.h" -#include "gen_utils.h" -#include "modules.h" - - -/*****************************************************************************/ -/* Python API function prototypes for the Ipo module. */ -/*****************************************************************************/ -static PyObject *M_Ipo_New (PyObject *self, PyObject *args); -static PyObject *M_Ipo_Get (PyObject *self, PyObject *args); -static PyObject *M_Ipo_Recalc (PyObject *self, PyObject *args); - -/*****************************************************************************/ -/* The following string definitions are used for documentation strings. */ -/* In Python these will be written to the console when doing a */ -/* Blender.Ipo.__doc__ */ -/*****************************************************************************/ -char M_Ipo_doc[] = ""; -char M_Ipo_New_doc[] =""; -char M_Ipo_Get_doc[] =""; - - -/*****************************************************************************/ -/* Python method structure definition for Blender.Ipo module: */ -/*****************************************************************************/ - -struct PyMethodDef M_Ipo_methods[] = { - {"New",(PyCFunction)M_Ipo_New, METH_VARARGS|METH_KEYWORDS,M_Ipo_New_doc}, - {"Get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc}, - {"get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc}, - {"Recalc", M_Ipo_Recalc, METH_VARARGS, M_Ipo_Get_doc}, - {NULL, NULL, 0, NULL} -}; - /*****************************************************************************/ /* Python BPy_Ipo structure definition: */ /*****************************************************************************/ -typedef struct { - PyObject_HEAD - Ipo *ipo; -} BPy_Ipo; - -/*****************************************************************************/ -/* Python BPy_Ipo methods declarations: */ -/*****************************************************************************/ -static PyObject *Ipo_getName(BPy_Ipo *self); -static PyObject *Ipo_setName(BPy_Ipo *self, PyObject *args); -static PyObject *Ipo_getBlocktype(BPy_Ipo *self); -static PyObject *Ipo_setBlocktype(BPy_Ipo *self, PyObject *args); -static PyObject *Ipo_getRctf(BPy_Ipo *self); -static PyObject *Ipo_setRctf(BPy_Ipo *self, PyObject *args); - -static PyObject *Ipo_getCurve(BPy_Ipo *self, PyObject *args); -static PyObject *Ipo_getCurves(BPy_Ipo *self); -static PyObject *Ipo_addCurve(BPy_Ipo *self, PyObject *args); -static PyObject *Ipo_getNcurves(BPy_Ipo *self); -static PyObject *Ipo_getNBezPoints(BPy_Ipo *self, PyObject *args); -static PyObject *Ipo_DeleteBezPoints(BPy_Ipo *self, PyObject *args); -static PyObject *Ipo_getCurveBP(BPy_Ipo *self, PyObject *args); -static PyObject *Ipo_getCurvecurval(BPy_Ipo *self, PyObject *args); -static PyObject *Ipo_EvaluateCurveOn(BPy_Ipo *self, PyObject *args); - - -static PyObject *Ipo_setCurveBeztriple(BPy_Ipo *self, PyObject *args); -static PyObject *Ipo_getCurveBeztriple(BPy_Ipo *self, PyObject *args); - -/*****************************************************************************/ -/* Python BPy_Ipo methods table: */ -/*****************************************************************************/ -static PyMethodDef BPy_Ipo_methods[] = { - /* name, method, flags, doc */ - {"getName", (PyCFunction)Ipo_getName, METH_NOARGS, - "() - Return Ipo Data name"}, -{"setName", (PyCFunction)Ipo_setName, METH_VARARGS, - "(str) - Change Ipo Data name"}, - {"getBlocktype", (PyCFunction)Ipo_getBlocktype, METH_NOARGS, - "() - Return Ipo blocktype -"}, - {"setBlocktype", (PyCFunction)Ipo_setBlocktype, METH_VARARGS, - "(str) - Change Ipo blocktype"}, - {"getRctf", (PyCFunction)Ipo_getRctf, METH_NOARGS, - "() - Return Ipo rctf - "}, - {"setRctf", (PyCFunction)Ipo_setRctf, METH_VARARGS, - "(str) - Change Ipo rctf"}, - {"addCurve", (PyCFunction)Ipo_addCurve, METH_VARARGS, - "() - Return Ipo ncurves"}, - {"getNcurves", (PyCFunction)Ipo_getNcurves, METH_NOARGS, - "() - Return Ipo ncurves"}, - {"getNBezPoints", (PyCFunction)Ipo_getNBezPoints, METH_VARARGS, - "() - Return curve number of Bez points"}, - {"delBezPoint", (PyCFunction)Ipo_DeleteBezPoints, METH_VARARGS, - "() - Return curve number of Bez points"}, - {"getCurveBP", (PyCFunction)Ipo_getCurveBP, METH_VARARGS, - "() - Return Ipo ncurves"}, - {"EvaluateCurveOn", (PyCFunction)Ipo_EvaluateCurveOn, METH_VARARGS, - "() - Return curve value at given time"}, - {"getCurveCurval", (PyCFunction)Ipo_getCurvecurval, METH_VARARGS, - "() - Return curval"}, - {"getCurveBeztriple", (PyCFunction)Ipo_getCurveBeztriple, METH_VARARGS, - "() - Return Ipo ncurves"}, - {"setCurveBeztriple", (PyCFunction)Ipo_setCurveBeztriple, METH_VARARGS, - "() - Return curval"}, - {"getCurves", (PyCFunction)Ipo_getCurves, METH_NOARGS, - "() - Return curval"}, - {"getCurve", (PyCFunction)Ipo_getCurve, METH_VARARGS, - "() - Return curval"}, - {0} -}; - -/*****************************************************************************/ -/* Python Ipo_Type callback function prototypes: */ -/*****************************************************************************/ -static void IpoDeAlloc (BPy_Ipo *self); -//static int IpoPrint (BPy_Ipo *self, FILE *fp, int flags); -static int IpoSetAttr (BPy_Ipo *self, char *name, PyObject *v); -static PyObject *IpoGetAttr (BPy_Ipo *self, char *name); -static PyObject *IpoRepr (BPy_Ipo *self); - -/*****************************************************************************/ -/* Python Ipo_Type structure definition: */ -/*****************************************************************************/ -PyTypeObject Ipo_Type = +typedef struct { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "Ipo", /* tp_name */ - sizeof (BPy_Ipo), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)IpoDeAlloc, /* tp_dealloc */ - 0, /* tp_print */ - (getattrfunc)IpoGetAttr, /* tp_getattr */ - (setattrfunc)IpoSetAttr, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)IpoRepr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_as_hash */ - 0,0,0,0,0,0, - 0, /* tp_doc */ - 0,0,0,0,0,0, - BPy_Ipo_methods, /* tp_methods */ - 0, /* tp_members */ -}; + PyObject_HEAD /* required macro */ + Ipo * ipo; +} +BPy_Ipo; + #endif /* EXPP_IPO_H */ diff --git a/source/blender/python/api2_2x/Ipocurve.c b/source/blender/python/api2_2x/Ipocurve.c index ebb6eec5251..d5af53dfc00 100644 --- a/source/blender/python/api2_2x/Ipocurve.c +++ b/source/blender/python/api2_2x/Ipocurve.c @@ -31,28 +31,146 @@ #include "Ipocurve.h" +#include +#include +#include +#include +#include + +#include "constant.h" +#include "gen_utils.h" +#include "modules.h" + +/*****************************************************************************/ +/* Python API function prototypes for the IpoCurve module. */ +/*****************************************************************************/ +static PyObject *M_IpoCurve_New (PyObject * self, PyObject * args); +static PyObject *M_IpoCurve_Get (PyObject * self, PyObject * args); + +/*****************************************************************************/ +/* The following string definitions are used for documentation strings. */ +/* In Python these will be written to the console when doing a */ +/* Blender.IpoCurve.__doc__ */ +/*****************************************************************************/ +char M_IpoCurve_doc[] = ""; +char M_IpoCurve_New_doc[] = ""; +char M_IpoCurve_Get_doc[] = ""; + +/*****************************************************************************/ +/* Python method structure definition for Blender.IpoCurve module: */ +/*****************************************************************************/ + +struct PyMethodDef M_IpoCurve_methods[] = { + {"New", (PyCFunction) M_IpoCurve_New, METH_VARARGS | METH_KEYWORDS, + M_IpoCurve_New_doc}, + {"Get", M_IpoCurve_Get, METH_VARARGS, M_IpoCurve_Get_doc}, + {"get", M_IpoCurve_Get, METH_VARARGS, M_IpoCurve_Get_doc}, + {NULL, NULL, 0, NULL} +}; + +/*****************************************************************************/ +/* Python C_IpoCurve methods declarations: */ +/*****************************************************************************/ +static PyObject *IpoCurve_getName (C_IpoCurve * self); +static PyObject *IpoCurve_Recalc (C_IpoCurve * self); +static PyObject *IpoCurve_setName (C_IpoCurve * self, PyObject * args); +static PyObject *IpoCurve_addBezier (C_IpoCurve * self, PyObject * args); +static PyObject *IpoCurve_setInterpolation (C_IpoCurve * self, + PyObject * args); +static PyObject *IpoCurve_getInterpolation (C_IpoCurve * self); +static PyObject *IpoCurve_setExtrapolation (C_IpoCurve * self, + PyObject * args); +static PyObject *IpoCurve_getExtrapolation (C_IpoCurve * self); +static PyObject *IpoCurve_getPoints (C_IpoCurve * self); + +/*****************************************************************************/ +/* Python C_IpoCurve methods table: */ +/*****************************************************************************/ +static PyMethodDef C_IpoCurve_methods[] = { + /* name, method, flags, doc */ + {"getName", (PyCFunction) IpoCurve_getName, METH_NOARGS, + "() - Return IpoCurve Data name"}, + {"Recalc", (PyCFunction) IpoCurve_Recalc, METH_NOARGS, + "() - Return IpoCurve Data name"}, + {"update", (PyCFunction) IpoCurve_Recalc, METH_NOARGS, + "() - Return IpoCurve Data name"}, + {"setName", (PyCFunction) IpoCurve_setName, METH_VARARGS, + "(str) - Change IpoCurve Data name"}, + {"addBezier", (PyCFunction) IpoCurve_addBezier, METH_VARARGS, + "(str) - Change IpoCurve Data name"}, + {"setInterpolation", (PyCFunction) IpoCurve_setInterpolation, METH_VARARGS, + "(str) - Change IpoCurve Data name"}, + {"getInterpolation", (PyCFunction) IpoCurve_getInterpolation, METH_NOARGS, + "(str) - Change IpoCurve Data name"}, + {"setExtrapolation", (PyCFunction) IpoCurve_setExtrapolation, METH_VARARGS, + "(str) - Change IpoCurve Data name"}, + {"getExtrapolation", (PyCFunction) IpoCurve_getExtrapolation, METH_NOARGS, + "(str) - Change IpoCurve Data name"}, + {"getPoints", (PyCFunction) IpoCurve_getPoints, METH_NOARGS, + "(str) - Change IpoCurve Data name"}, + {NULL, NULL, 0, NULL} +}; + +/*****************************************************************************/ +/* Python IpoCurve_Type callback function prototypes: */ +/*****************************************************************************/ +static void IpoCurveDeAlloc (C_IpoCurve * self); +//static int IpoCurvePrint (C_IpoCurve *self, FILE *fp, int flags); +static int IpoCurveSetAttr (C_IpoCurve * self, char *name, PyObject * v); +static PyObject *IpoCurveGetAttr (C_IpoCurve * self, char *name); +static PyObject *IpoCurveRepr (C_IpoCurve * self); + +/*****************************************************************************/ +/* Python IpoCurve_Type structure definition: */ +/*****************************************************************************/ +PyTypeObject IpoCurve_Type = { + PyObject_HEAD_INIT (NULL) /* required macro */ + 0, /* ob_size */ + "IpoCurve", /* tp_name */ + sizeof (C_IpoCurve), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor) IpoCurveDeAlloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc) IpoCurveGetAttr, /* tp_getattr */ + (setattrfunc) IpoCurveSetAttr, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc) IpoCurveRepr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_as_hash */ + 0, 0, 0, 0, 0, 0, + 0, /* tp_doc */ + 0, 0, 0, 0, 0, 0, + C_IpoCurve_methods, /* tp_methods */ + 0, /* tp_members */ +}; + /*****************************************************************************/ /* Function: M_IpoCurve_New */ /* Python equivalent: Blender.IpoCurve.New */ /*****************************************************************************/ -static PyObject *M_IpoCurve_New(PyObject *self, PyObject *args) +static PyObject * +M_IpoCurve_New (PyObject * self, PyObject * args) { - return 0; + return 0; } - /*****************************************************************************/ /* Function: Ipo_Init */ /*****************************************************************************/ -PyObject *IpoCurve_Init (void) +PyObject * +IpoCurve_Init (void) { - PyObject *submodule; + PyObject *submodule; IpoCurve_Type.ob_type = &PyType_Type; - submodule = Py_InitModule3("Blender.IpoCurve", M_IpoCurve_methods, M_IpoCurve_doc); + submodule = + Py_InitModule3 ("Blender.IpoCurve", M_IpoCurve_methods, M_IpoCurve_doc); return (submodule); } @@ -65,185 +183,231 @@ PyObject *IpoCurve_Init (void) /* passed in, a list of all ipo data names in the */ /* current scene is returned. */ /*****************************************************************************/ -static PyObject *M_IpoCurve_Get(PyObject *self, PyObject *args) +static PyObject * +M_IpoCurve_Get (PyObject * self, PyObject * args) { - return 0; + return 0; } - /*****************************************************************************/ /* Python C_IpoCurve methods: */ /*****************************************************************************/ -static PyObject *IpoCurve_setInterpolation( C_IpoCurve * self, PyObject *args) +static PyObject * +IpoCurve_setInterpolation (C_IpoCurve * self, PyObject * args) { - char*interpolationtype = 0; - int id = -1; - if (!PyArg_ParseTuple(args, "s", &interpolationtype)) - return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected string argument")); - if (!strcmp(interpolationtype,"Bezier"))id = IPO_BEZ; - if (!strcmp(interpolationtype,"Constant"))id = IPO_CONST; - if (!strcmp(interpolationtype,"Linear"))id = IPO_LIN; - if (id == -1) - return (EXPP_ReturnPyObjError (PyExc_TypeError,"bad interpolation type")); + char *interpolationtype = 0; + int id = -1; + if (!PyArg_ParseTuple (args, "s", &interpolationtype)) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "expected string argument")); + if (!strcmp (interpolationtype, "Bezier")) + id = IPO_BEZ; + if (!strcmp (interpolationtype, "Constant")) + id = IPO_CONST; + if (!strcmp (interpolationtype, "Linear")) + id = IPO_LIN; + if (id == -1) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "bad interpolation type")); - self->ipocurve->ipo = id; - Py_INCREF(Py_None); + self->ipocurve->ipo = id; + Py_INCREF (Py_None); return Py_None; } -static PyObject *IpoCurve_getInterpolation( C_IpoCurve * self) -{ char*str = 0; - IpoCurve *icu = self->ipocurve; - if (icu->ipo == IPO_BEZ) str = "Bezier"; - if (icu->ipo == IPO_CONST) str = "Bonstant"; - if (icu->ipo == IPO_LIN) str = "Linear"; +static PyObject * +IpoCurve_getInterpolation (C_IpoCurve * self) +{ + char *str = 0; + IpoCurve *icu = self->ipocurve; + if (icu->ipo == IPO_BEZ) + str = "Bezier"; + if (icu->ipo == IPO_CONST) + str = "Bonstant"; + if (icu->ipo == IPO_LIN) + str = "Linear"; - if (!str) - return (EXPP_ReturnPyObjError (PyExc_TypeError,"unknown interpolation type")); -return PyString_FromString(str); + if (!str) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "unknown interpolation type")); + return PyString_FromString (str); } -static PyObject *IpoCurve_setExtrapolation( C_IpoCurve * self, PyObject *args) +static PyObject * +IpoCurve_setExtrapolation (C_IpoCurve * self, PyObject * args) { - char*extrapolationtype = 0; - int id = -1; - if (!PyArg_ParseTuple(args, "s", &extrapolationtype)) - return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected string argument")); - if (!strcmp(extrapolationtype,"Constant"))id = 0; - if (!strcmp(extrapolationtype,"Extrapolation"))id = 1; - if (!strcmp(extrapolationtype,"Cyclic"))id = 2; - if (!strcmp(extrapolationtype,"Cyclic_extrapolation"))id = 3; + char *extrapolationtype = 0; + int id = -1; + if (!PyArg_ParseTuple (args, "s", &extrapolationtype)) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "expected string argument")); + if (!strcmp (extrapolationtype, "Constant")) + id = 0; + if (!strcmp (extrapolationtype, "Extrapolation")) + id = 1; + if (!strcmp (extrapolationtype, "Cyclic")) + id = 2; + if (!strcmp (extrapolationtype, "Cyclic_extrapolation")) + id = 3; - if (id == -1) - return (EXPP_ReturnPyObjError (PyExc_TypeError,"bad interpolation type")); - self->ipocurve->extrap = id; - Py_INCREF(Py_None); + if (id == -1) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "bad interpolation type")); + self->ipocurve->extrap = id; + Py_INCREF (Py_None); + return Py_None; +} + +static PyObject * +IpoCurve_getExtrapolation (C_IpoCurve * self) +{ + char *str = 0; + IpoCurve *icu = self->ipocurve; + if (icu->extrap == 0) + str = "Constant"; + if (icu->extrap == 1) + str = "Extrapolation"; + if (icu->extrap == 2) + str = "Cyclic"; + if (icu->extrap == 3) + str = "Cyclic_extrapolation"; + + return PyString_FromString (str); +} + +static PyObject * +IpoCurve_addBezier (C_IpoCurve * self, PyObject * args) +{ + short MEM_freeN (void *vmemh); + void *MEM_mallocN (unsigned int len, char *str); + float x, y; + int npoints; + IpoCurve *icu; + BezTriple *bzt, *tmp; + static char name[10] = "mlml"; + PyObject *popo = 0; + if (!PyArg_ParseTuple (args, "O", &popo)) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "expected tuple argument")); + + x = PyFloat_AsDouble (PyTuple_GetItem (popo, 0)); + y = PyFloat_AsDouble (PyTuple_GetItem (popo, 1)); + icu = self->ipocurve; + npoints = icu->totvert; + tmp = icu->bezt; + icu->bezt = MEM_mallocN (sizeof (BezTriple) * (npoints + 1), name); + if (tmp) + { + memmove (icu->bezt, tmp, sizeof (BezTriple) * npoints); + MEM_freeN (tmp); + } + memmove (icu->bezt + npoints, icu->bezt, sizeof (BezTriple)); + icu->totvert++; + bzt = icu->bezt + npoints; + bzt->vec[0][0] = x - 1; + bzt->vec[1][0] = x; + bzt->vec[2][0] = x + 1; + bzt->vec[0][1] = y - 1; + bzt->vec[1][1] = y; + bzt->vec[2][1] = y + 1; + /* set handle type to Auto */ + bzt->h1 = HD_AUTO; + bzt->h2 = HD_AUTO; + + Py_INCREF (Py_None); return Py_None; } - -static PyObject *IpoCurve_getExtrapolation( C_IpoCurve * self) +static PyObject * +IpoCurve_setName (C_IpoCurve * self, PyObject * args) { - char*str = 0; - IpoCurve *icu = self->ipocurve; - if (icu->extrap == 0) str = "Constant"; - if (icu->extrap == 1) str = "Extrapolation"; - if (icu->extrap == 2) str = "Cyclic"; - if (icu->extrap == 3) str = "Cyclic_extrapolation"; - -return PyString_FromString(str); + return 0; } - - -static PyObject *IpoCurve_addBezier( C_IpoCurve * self, PyObject *args) +static PyObject * +IpoCurve_Recalc (C_IpoCurve * self) { -short MEM_freeN(void *vmemh) ; - void *MEM_mallocN(unsigned int len, char *str); - float x,y; - int npoints; - IpoCurve *icu; - BezTriple *bzt,*tmp; - static char name[10] = "mlml"; - PyObject*popo = 0; - if (!PyArg_ParseTuple(args, "O", &popo)) - return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected tuple argument")); - - x = PyFloat_AsDouble(PyTuple_GetItem(popo,0)); - y = PyFloat_AsDouble(PyTuple_GetItem(popo,1)); - icu = self->ipocurve; - npoints = icu->totvert; - tmp = icu->bezt; - icu->bezt = MEM_mallocN(sizeof(BezTriple)*(npoints+1),name); - if(tmp){ - memmove(icu->bezt,tmp,sizeof(BezTriple)*npoints); - MEM_freeN(tmp); - } - memmove(icu->bezt+npoints,icu->bezt,sizeof(BezTriple)); - icu->totvert++; - bzt = icu->bezt + npoints; - bzt->vec[0][0] = x-1; - bzt->vec[1][0] = x; - bzt->vec[2][0] = x+1; - bzt->vec[0][1] = y-1; - bzt->vec[1][1] = y; - bzt->vec[2][1] = y+1; - /* set handle type to Auto */ - bzt->h1= HD_AUTO; - bzt->h2= HD_AUTO; - - Py_INCREF(Py_None); + void testhandles_ipocurve (IpoCurve * icu); + IpoCurve *icu = self->ipocurve; + testhandles_ipocurve (icu); + Py_INCREF (Py_None); return Py_None; } -static PyObject *IpoCurve_setName(C_IpoCurve *self, PyObject *args) +static PyObject * +IpoCurve_getName (C_IpoCurve * self) { - return 0; -} + char *nametab[24] = + { "LocX", "LocY", "LocZ", "dLocX", "dLocY", "dLocZ", "RotX", "RotY", + "RotZ", "dRotX", "dRotY", "dRotZ", "SizeX", "SizeY", "SizeZ", "dSizeX", + "dSizeY", + "dSizeZ", "Layer", "Time", "ColR", "ColG", "ColB", "ColA" + }; -static PyObject *IpoCurve_Recalc(C_IpoCurve *self) -{ - void testhandles_ipocurve(IpoCurve *icu); - IpoCurve *icu = self->ipocurve; - testhandles_ipocurve(icu); - Py_INCREF(Py_None); - return Py_None; -} + if (self->ipocurve->blocktype != ID_OB) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "This function doesn't support this ipocurve type yet"); -static PyObject* IpoCurve_getName (C_IpoCurve *self) -{ - char * nametab[24] = {"LocX","LocY","LocZ","dLocX","dLocY","dLocZ","RotX","RotY","RotZ","dRotX","dRotY","dRotZ","SizeX","SizeY","SizeZ","dSizeX","dSizeY","dSizeZ","Layer","Time","ColR","ColG","ColB","ColA"}; + // printf("IpoCurve_getName %d\n",self->ipocurve->vartype); + if (self->ipocurve->adrcode <= 0) + return PyString_FromString ("Index too small"); + if (self->ipocurve->adrcode >= 25) + return PyString_FromString ("Index too big"); - if (self->ipocurve->blocktype != ID_OB) - return EXPP_ReturnPyObjError (PyExc_TypeError, - "This function doesn't support this ipocurve type yet"); - - // printf("IpoCurve_getName %d\n",self->ipocurve->vartype); - if (self->ipocurve->adrcode <=0 ) -return PyString_FromString("Index too small"); - if (self->ipocurve->adrcode >= 25 ) -return PyString_FromString("Index too big"); - -return PyString_FromString(nametab[self->ipocurve->adrcode-1]); + return PyString_FromString (nametab[self->ipocurve->adrcode - 1]); } - -static void IpoCurveDeAlloc (C_IpoCurve *self) +static void +IpoCurveDeAlloc (C_IpoCurve * self) { PyObject_DEL (self); } -static PyObject* IpoCurve_getPoints (C_IpoCurve *self) -{ -struct BezTriple *bezt; - PyObject* l = PyList_New(0); - int i; - for(i = 0;iipocurve->totvert;i++) - { - bezt = self->ipocurve->bezt + i; - PyList_Append( l, BezTriple_CreatePyObject(bezt)); - } - return l; +static PyObject * +IpoCurve_getPoints (C_IpoCurve * self) +{ + struct BezTriple *bezt; + PyObject *po; + + PyObject *list = PyList_New (0); + int i; + + for (i = 0; i < self->ipocurve->totvert; i++) + { + bezt = self->ipocurve->bezt + i; + po = BezTriple_CreatePyObject (bezt); +#if 0 + if (BezTriple_CheckPyObject (po)) + printf ("po is ok\n"); + else + printf ("po is hosed\n"); +#endif + PyList_Append (list, po); + /* + PyList_Append( list, BezTriple_CreatePyObject(bezt)); + */ + } + return list; } - -int IpoCurve_setPoints (C_IpoCurve *self, PyObject *value ) -{ -struct BezTriple *bezt; - PyObject* l = PyList_New(0); - int i; - for(i = 0;iipocurve->totvert;i++) - { - bezt = self->ipocurve->bezt + i; - PyList_Append( l, BezTriple_CreatePyObject(bezt)); - } +int +IpoCurve_setPoints (C_IpoCurve * self, PyObject * value) +{ + struct BezTriple *bezt; + PyObject *l = PyList_New (0); + int i; + for (i = 0; i < self->ipocurve->totvert; i++) + { + bezt = self->ipocurve->bezt + i; + PyList_Append (l, BezTriple_CreatePyObject (bezt)); + } return 0; } @@ -254,11 +418,14 @@ struct BezTriple *bezt; /* the function that accesses C_IpoCurve "member variables" and */ /* methods. */ /*****************************************************************************/ -static PyObject *IpoCurveGetAttr (C_IpoCurve *self, char *name) +static PyObject * +IpoCurveGetAttr (C_IpoCurve * self, char *name) { -if (strcmp (name, "bezierPoints") == 0)return IpoCurve_getPoints(self); -if (strcmp (name, "name") == 0)return IpoCurve_getName(self); - return Py_FindMethod(C_IpoCurve_methods, (PyObject *)self, name); + if (strcmp (name, "bezierPoints") == 0) + return IpoCurve_getPoints (self); + if (strcmp (name, "name") == 0) + return IpoCurve_getName (self); + return Py_FindMethod (C_IpoCurve_methods, (PyObject *) self, name); } /*****************************************************************************/ @@ -266,10 +433,12 @@ if (strcmp (name, "name") == 0)return IpoCurve_getName(self); /* Description: This is a callback function for the C_IpoCurve type. It is the */ /* function that sets IpoCurve Data attributes (member variables).*/ /*****************************************************************************/ -static int IpoCurveSetAttr (C_IpoCurve *self, char *name, PyObject *value) +static int +IpoCurveSetAttr (C_IpoCurve * self, char *name, PyObject * value) { -if (strcmp (name, "bezierPoints") == 0)return IpoCurve_setPoints(self,value); - return 0; /* normal exit */ + if (strcmp (name, "bezierPoints") == 0) + return IpoCurve_setPoints (self, value); + return 0; /* normal exit */ } /*****************************************************************************/ @@ -277,13 +446,14 @@ if (strcmp (name, "bezierPoints") == 0)return IpoCurve_setPoints(self,value); /* Description: This is a callback function for the C_IpoCurve type. It */ /* builds a meaninful string to represent ipo objects. */ /*****************************************************************************/ -static PyObject *IpoCurveRepr (C_IpoCurve *self) +static PyObject * +IpoCurveRepr (C_IpoCurve * self) { - void GetIpoCurveName(IpoCurve *icu,char*s); - char s[100],s1[100]; - GetIpoCurveName(self->ipocurve,s1); - sprintf(s,"IpoCurve %s \n",s1); - return PyString_FromString(s); + void GetIpoCurveName (IpoCurve * icu, char *s); + char s[100], s1[100]; + GetIpoCurveName (self->ipocurve, s1); + sprintf (s, "IpoCurve %s \n", s1); + return PyString_FromString (s); } /* Three Python IpoCurve_Type helper functions needed by the Object module: */ @@ -293,19 +463,20 @@ static PyObject *IpoCurveRepr (C_IpoCurve *self) /* Description: This function will create a new C_IpoCurve from an existing */ /* Blender ipo structure. */ /*****************************************************************************/ -PyObject *IpoCurve_CreatePyObject (IpoCurve *ipo) +PyObject * +IpoCurve_CreatePyObject (IpoCurve * ipo) { - C_IpoCurve *pyipo; + C_IpoCurve *pyipo; - pyipo = (C_IpoCurve *)PyObject_NEW (C_IpoCurve, &IpoCurve_Type); + pyipo = (C_IpoCurve *) PyObject_NEW (C_IpoCurve, &IpoCurve_Type); - if (!pyipo) - return EXPP_ReturnPyObjError (PyExc_MemoryError, - "couldn't create C_IpoCurve object"); + if (!pyipo) + return EXPP_ReturnPyObjError (PyExc_MemoryError, + "couldn't create C_IpoCurve object"); - pyipo->ipocurve = ipo; + pyipo->ipocurve = ipo; - return (PyObject *)pyipo; + return (PyObject *) pyipo; } /*****************************************************************************/ @@ -313,9 +484,10 @@ PyObject *IpoCurve_CreatePyObject (IpoCurve *ipo) /* Description: This function returns true when the given PyObject is of the */ /* type IpoCurve. Otherwise it will return false. */ /*****************************************************************************/ -int IpoCurve_CheckPyObject (PyObject *pyobj) +int +IpoCurve_CheckPyObject (PyObject * pyobj) { - return (pyobj->ob_type == &IpoCurve_Type); + return (pyobj->ob_type == &IpoCurve_Type); } /*****************************************************************************/ @@ -323,7 +495,8 @@ int IpoCurve_CheckPyObject (PyObject *pyobj) /* Description: This function returns the Blender ipo from the given */ /* PyObject. */ /*****************************************************************************/ -IpoCurve *IpoCurve_FromPyObject (PyObject *pyobj) +IpoCurve * +IpoCurve_FromPyObject (PyObject * pyobj) { - return ((C_IpoCurve *)pyobj)->ipocurve; + return ((C_IpoCurve *) pyobj)->ipocurve; } diff --git a/source/blender/python/api2_2x/Ipocurve.h b/source/blender/python/api2_2x/Ipocurve.h index 856088d4235..f0085f02009 100644 --- a/source/blender/python/api2_2x/Ipocurve.h +++ b/source/blender/python/api2_2x/Ipocurve.h @@ -33,131 +33,17 @@ #define EXPP_IPOCURVE_H #include - -#include -#include -#include -#include -#include -#include - -#include "constant.h" -#include "gen_utils.h" -#include "modules.h" - - -/*****************************************************************************/ -/* Python API function prototypes for the IpoCurve module. */ -/*****************************************************************************/ -static PyObject *M_IpoCurve_New (PyObject *self, PyObject *args); -static PyObject *M_IpoCurve_Get (PyObject *self, PyObject *args); - -/*****************************************************************************/ -/* The following string definitions are used for documentation strings. */ -/* In Python these will be written to the console when doing a */ -/* Blender.IpoCurve.__doc__ */ -/*****************************************************************************/ -char M_IpoCurve_doc[] = ""; -char M_IpoCurve_New_doc[] =""; -char M_IpoCurve_Get_doc[] =""; - - -/*****************************************************************************/ -/* Python method structure definition for Blender.IpoCurve module: */ -/*****************************************************************************/ - -struct PyMethodDef M_IpoCurve_methods[] = { - {"New",(PyCFunction)M_IpoCurve_New, METH_VARARGS|METH_KEYWORDS,M_IpoCurve_New_doc}, - {"Get", M_IpoCurve_Get, METH_VARARGS, M_IpoCurve_Get_doc}, - {"get", M_IpoCurve_Get, METH_VARARGS, M_IpoCurve_Get_doc}, - {NULL, NULL, 0, NULL} -}; +#include /* declaration of IpoCurve */ /*****************************************************************************/ /* Python C_IpoCurve structure definition: */ /*****************************************************************************/ -typedef struct { - PyObject_HEAD - IpoCurve *ipocurve; -} C_IpoCurve; - -/*****************************************************************************/ -/* Python C_IpoCurve methods declarations: */ -/*****************************************************************************/ -static PyObject *IpoCurve_getName(C_IpoCurve *self); -static PyObject *IpoCurve_Recalc(C_IpoCurve *self); -static PyObject *IpoCurve_setName(C_IpoCurve *self, PyObject *args); -static PyObject *IpoCurve_addBezier( C_IpoCurve*self, PyObject *args); -static PyObject *IpoCurve_setInterpolation( C_IpoCurve*self, PyObject *args); -static PyObject *IpoCurve_getInterpolation( C_IpoCurve*self); -static PyObject *IpoCurve_setExtrapolation( C_IpoCurve*self, PyObject *args); -static PyObject *IpoCurve_getExtrapolation( C_IpoCurve*self); -static PyObject *IpoCurve_getPoints( C_IpoCurve*self); - - -/*****************************************************************************/ -/* Python C_IpoCurve methods table: */ -/*****************************************************************************/ -static PyMethodDef C_IpoCurve_methods[] = { - /* name, method, flags, doc */ - {"getName", (PyCFunction)IpoCurve_getName, METH_NOARGS, - "() - Return IpoCurve Data name"}, - {"Recalc", (PyCFunction)IpoCurve_Recalc, METH_NOARGS, - "() - Return IpoCurve Data name"}, - {"update", (PyCFunction)IpoCurve_Recalc, METH_NOARGS, - "() - Return IpoCurve Data name"}, -{"setName", (PyCFunction)IpoCurve_setName, METH_VARARGS, - "(str) - Change IpoCurve Data name"}, -{"addBezier", (PyCFunction)IpoCurve_addBezier, METH_VARARGS, - "(str) - Change IpoCurve Data name"}, -{"setInterpolation", (PyCFunction)IpoCurve_setInterpolation, METH_VARARGS, - "(str) - Change IpoCurve Data name"}, -{"getInterpolation", (PyCFunction)IpoCurve_getInterpolation, METH_NOARGS, - "(str) - Change IpoCurve Data name"}, -{"setExtrapolation", (PyCFunction)IpoCurve_setExtrapolation, METH_VARARGS, - "(str) - Change IpoCurve Data name"}, -{"getExtrapolation", (PyCFunction)IpoCurve_getExtrapolation, METH_NOARGS, - "(str) - Change IpoCurve Data name"}, -{"getPoints", (PyCFunction)IpoCurve_getPoints, METH_NOARGS, - "(str) - Change IpoCurve Data name"}, - {0} -}; - -/*****************************************************************************/ -/* Python IpoCurve_Type callback function prototypes: */ -/*****************************************************************************/ -static void IpoCurveDeAlloc (C_IpoCurve *self); -//static int IpoCurvePrint (C_IpoCurve *self, FILE *fp, int flags); -static int IpoCurveSetAttr (C_IpoCurve *self, char *name, PyObject *v); -static PyObject *IpoCurveGetAttr (C_IpoCurve *self, char *name); -static PyObject *IpoCurveRepr (C_IpoCurve *self); - -/*****************************************************************************/ -/* Python IpoCurve_Type structure definition: */ -/*****************************************************************************/ -PyTypeObject IpoCurve_Type = +typedef struct { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "IpoCurve", /* tp_name */ - sizeof (C_IpoCurve), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)IpoCurveDeAlloc, /* tp_dealloc */ - 0, /* tp_print */ - (getattrfunc)IpoCurveGetAttr, /* tp_getattr */ - (setattrfunc)IpoCurveSetAttr, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)IpoCurveRepr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_as_hash */ - 0,0,0,0,0,0, - 0, /* tp_doc */ - 0,0,0,0,0,0, - C_IpoCurve_methods, /* tp_methods */ - 0, /* tp_members */ -}; + PyObject_HEAD /* required macro */ + IpoCurve * ipocurve; +} +C_IpoCurve; + #endif /* EXPP_IPOCURVE_H */ diff --git a/source/blender/python/api2_2x/bpy_types.h b/source/blender/python/api2_2x/bpy_types.h index f8dae9f438b..4e02eba6b1c 100644 --- a/source/blender/python/api2_2x/bpy_types.h +++ b/source/blender/python/api2_2x/bpy_types.h @@ -42,7 +42,7 @@ #include #include -#include "rgbTuple.h" /* for BPy_rgbTuple */ +#include "rgbTuple.h" /* for BPy_rgbTuple */ /*****************************************************************************/ /* Camera Data */ @@ -50,15 +50,16 @@ extern PyTypeObject Camera_Type; #define BPy_Camera_Check(v) \ - ((v)->ob_type == &Camera_Type) /* for type checking */ + ((v)->ob_type == &Camera_Type) /* for type checking */ /* Python BPy_Camera structure definition */ -typedef struct { - PyObject_HEAD - Camera *camera; +typedef struct +{ + PyObject_HEAD /* required py macro */ + Camera * camera; -} BPy_Camera; -/**/ +} +BPy_Camera; /*****************************************************************************/ /* Lamp Data */ @@ -66,31 +67,31 @@ typedef struct { extern PyTypeObject Lamp_Type; #define BPy_Lamp_Check(v) \ - ((v)->ob_type == &Lamp_Type) /* for type checking */ + ((v)->ob_type == &Lamp_Type) /* for type checking */ /* Python BPy_Lamp structure definition */ -typedef struct { - PyObject_HEAD - Lamp *lamp; +typedef struct +{ + PyObject_HEAD /* required py macro */ + Lamp * lamp; BPy_rgbTuple *color; -} BPy_Lamp; -/**/ - +} +BPy_Lamp; /*****************************************************************************/ /* Ipo Data */ /*****************************************************************************/ extern PyTypeObject Ipo_Type; -#define BPy_Ipo_Check(v) ((v)->ob_type == &Ipo_Type) /* for type checking */ +#define BPy_Ipo_Check(v) ((v)->ob_type == &Ipo_Type) /* for type checking */ /* Python BPy_Ipo structure definition */ -typedef struct { - PyObject_HEAD - Ipo *ipo; -} BPy_Ipo; -/**/ - +typedef struct +{ + PyObject_HEAD /* required py macro */ + Ipo * ipo; +} +BPy_Ipo; /*****************************************************************************/ /* Metaball Data */ @@ -100,12 +101,12 @@ extern PyTypeObject Metaball_Type; #define BPy_Metaball_Check(v) ((v)->ob_type==&Metaball_Type) /* Python BPy_Metaball structure definition */ -typedef struct { - PyObject_HEAD - MetaBall *metaball; -} BPy_Metaball; -/**/ - +typedef struct +{ + PyObject_HEAD /* required py macro */ + MetaBall * metaball; +} +BPy_Metaball; /*****************************************************************************/ /* Effect Data */ @@ -115,11 +116,12 @@ extern PyTypeObject Effect_Type; #define BPy_Effect_Check(v) ((v)->ob_type==&Effect_Type) /* Python BPy_Effect structure definition */ -typedef struct { - PyObject_HEAD - Effect *effect; -} BPy_Effect; -/**/ +typedef struct +{ + PyObject_HEAD /* required py macro */ + Effect * effect; +} +BPy_Effect; /*****************************************************************************/ /* Wave Data */ @@ -129,11 +131,12 @@ extern PyTypeObject Wave_Type; #define BPy_Wave_Check(v) ((v)->ob_type==&Wave_Type) /* Python BPy_Wave structure definition */ -typedef struct { - PyObject_HEAD - Effect *wave; -} BPy_Wave; -/**/ +typedef struct +{ + PyObject_HEAD /* required py macro */ + Effect * wave; +} +BPy_Wave; /*****************************************************************************/ /* Build Data */ @@ -143,11 +146,12 @@ extern PyTypeObject Build_Type; #define BPy_Build_Check(v) ((v)->ob_type==&Build_Type) /* Python BPy_Build structure definition */ -typedef struct { - PyObject_HEAD - Effect *build; -} BPy_Build; -/**/ +typedef struct +{ + PyObject_HEAD /* required py macro */ + Effect * build; +} +BPy_Build; /*****************************************************************************/ /* Particle Data */ @@ -157,11 +161,12 @@ extern PyTypeObject Particle_Type; #define BPy_Particle_Check(v) ((v)->ob_type==&Particle_Type) /* Python BPy_Particle structure definition */ -typedef struct { - PyObject_HEAD - Effect *particle; -} BPy_Particle; -/**/ +typedef struct +{ + PyObject_HEAD /* required py macro */ + Effect * particle; +} +BPy_Particle; /*****************************************************************************/ /* Curve Data */ @@ -171,11 +176,12 @@ extern PyTypeObject Curve_Type; #define BPy_Curve_Check(v) ((v)->ob_type==&Curve_Type) /* Python BPy_Curve structure definition */ -typedef struct { - PyObject_HEAD - Curve *curve; -} BPy_Curve; -/**/ +typedef struct +{ + PyObject_HEAD /* required py macro */ + Curve * curve; +} +BPy_Curve; /*****************************************************************************/ /* World Data */ @@ -185,11 +191,11 @@ extern PyTypeObject World_Type; #define BPy_World_Check(v) ((v)->ob_type==&World_Type) /* Python BPy_World structure definition */ -typedef struct { - PyObject_HEAD - World *world; -} BPy_World; -/**/ - +typedef struct +{ + PyObject_HEAD /* required py macro */ + World * world; +} +BPy_World; #endif /* EXPP_bpy_types_h */