removed unuseful function calls in BezTriple.[ch]

general cleaning of Ipocurve.c Ipocurve.h Ipo.h Ipo.c
updated doc
This commit is contained in:
Jacques Guignot 2003-08-05 10:19:28 +00:00
parent 683c322b0e
commit 05187adc2f
6 changed files with 177 additions and 84 deletions

@ -54,18 +54,6 @@ static PyObject *M_BezTriple_Get(PyObject *self, PyObject *args)
}
/*****************************************************************************/
/* Python C_BezTriple methods: */
/*****************************************************************************/
static PyObject *BezTriple_getName(C_BezTriple *self)
{
return 0;
}
static PyObject *BezTriple_setName(C_BezTriple *self, PyObject *args)
{
return 0;
}
/*****************************************************************************/
@ -90,53 +78,31 @@ struct BezTriple *bezt = self->beztriple;
return l;
}
static PyObject* BezTriple_geth1t (C_BezTriple *self)
{
/*champ h1 de la struct*/
return PyString_FromString("Auto");
}
static PyObject* BezTriple_geth2t (C_BezTriple *self)
{
/*champ h2 de la struct*/
return PyString_FromString("Auto");
}
static PyObject* BezTriple_geth1 (C_BezTriple *self)
{ PyObject* ret = PyTuple_New(2);
PyTuple_SetItem(ret, 0 , PyFloat_FromDouble(self->beztriple->vec[0][0]));
PyTuple_SetItem(ret, 1 , PyFloat_FromDouble(self->beztriple->vec[0][1]));
return ret;
}
static PyObject* BezTriple_geth2 (C_BezTriple *self)
{ PyObject* ret = PyTuple_New(2);
PyTuple_SetItem(ret, 0 , PyFloat_FromDouble(self->beztriple->vec[2][0]));
PyTuple_SetItem(ret, 1 , PyFloat_FromDouble(self->beztriple->vec[2][1]));
return ret;
}
static PyObject* BezTriple_getf1 (C_BezTriple *self)
{
return PyInt_FromLong(self->beztriple->f1);
}
static PyObject* BezTriple_getf2 (C_BezTriple *self)
{
return PyInt_FromLong(self->beztriple->f2);
}
static PyObject* BezTriple_getf3 (C_BezTriple *self)
{
return PyInt_FromLong(self->beztriple->f3);
}
int BezTriple_setPoints (C_BezTriple *self,PyObject *value)
static PyObject * BezTriple_setPoints (C_BezTriple *self,PyObject *args)
{
int i;
struct BezTriple *bezt = self->beztriple;
if ( PyList_Check(value) == 0)
{puts("error in BezTriple_setPoints");
return -1;}
for(i = 0;i<2;i++)bezt->vec[1][i] = PyFloat_AsDouble(PyList_GetItem(value, i));
return 0;
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;
}
@ -149,17 +115,6 @@ int BezTriple_setPoints (C_BezTriple *self,PyObject *value)
static PyObject *BezTripleGetAttr (C_BezTriple *self, char *name)
{
if (strcmp (name, "pt") == 0)return BezTriple_getPoints(self);
if (strcmp (name, "h1") == 0)return BezTriple_geth1(self);
if (strcmp (name, "h2") == 0)return BezTriple_geth2(self);
if (strcmp (name, "f1") == 0)return BezTriple_getf1(self);
if (strcmp (name, "f2") == 0)return BezTriple_getf2(self);
if (strcmp (name, "f3") == 0)return BezTriple_getf3(self);
if (strcmp (name, "h1t") == 0)return BezTriple_geth1t(self);
if (strcmp (name, "h1Type") == 0)return BezTriple_geth1t(self);
if (strcmp (name, "h2t") == 0)return BezTriple_geth2t(self);
if (strcmp (name, "h2Type") == 0)return BezTriple_geth2t(self);
return Py_FindMethod(C_BezTriple_methods, (PyObject *)self, name);
}

@ -76,18 +76,18 @@ typedef struct {
/*****************************************************************************/
/* Python C_BezTriple methods declarations: */
/*****************************************************************************/
static PyObject *BezTriple_getName(C_BezTriple *self);
static PyObject *BezTriple_setName(C_BezTriple *self, PyObject *args);
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 */
{"getName", (PyCFunction)BezTriple_getName, METH_NOARGS,
"() - Return BezTriple Data name"},
{"setName", (PyCFunction)BezTriple_setName, METH_VARARGS,
"(str) - Change BezTriple Data name"},
{"setPoints", (PyCFunction)BezTriple_setPoints, METH_VARARGS,
"(str) - Change BezTriple point coordinates"},
{"getPoints", (PyCFunction)BezTriple_getPoints, METH_NOARGS,
"(str) - Change BezTriple point coordinates"},
{0}
};
@ -95,7 +95,6 @@ static PyMethodDef C_BezTriple_methods[] = {
/* Python BezTriple_Type callback function prototypes: */
/*****************************************************************************/
static void BezTripleDeAlloc (C_BezTriple *self);
//static int BezTriplePrint (C_BezTriple *self, FILE *fp, int flags);
static int BezTripleSetAttr (C_BezTriple *self, char *name, PyObject *v);
static PyObject *BezTripleGetAttr (C_BezTriple *self, char *name);
static PyObject *BezTripleRepr (C_BezTriple *self);

@ -93,6 +93,7 @@ static PyObject *Ipo_setBlocktype(C_Ipo *self, PyObject *args);
static PyObject *Ipo_getRctf(C_Ipo *self);
static PyObject *Ipo_setRctf(C_Ipo *self, PyObject *args);
static PyObject *Ipo_getCurves(C_Ipo *self);
static PyObject *Ipo_addCurve(C_Ipo *self, PyObject *args);
static PyObject *Ipo_getNcurves(C_Ipo *self);
static PyObject *Ipo_getNBezPoints(C_Ipo *self, PyObject *args);
@ -140,6 +141,8 @@ static PyMethodDef C_Ipo_methods[] = {
"() - Return Ipo ncurves"},
{"setCurveBeztriple", (PyCFunction)Ipo_setCurveBeztriple, METH_VARARGS,
"() - Return curval"},
{"getCurves", (PyCFunction)Ipo_getCurves, METH_NOARGS,
"() - Return curval"},
{0}
};

@ -85,41 +85,73 @@ static PyObject *IpoCurve_setInterpolation( C_IpoCurve * self, PyObject *args)
if (!strcmp(interpolationtype,"Constant"))id = IPO_CONST;
if (!strcmp(interpolationtype,"Linear"))id = IPO_LIN;
if (id == -1)
return (EXPP_ReturnPyObjError (PyExc_TypeError,"bad interpolation ytpe"));
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *IpoCurve_getInterpolation( C_IpoCurve * self)
{
return (EXPP_ReturnPyObjError (PyExc_TypeError,"bad interpolation type"));
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";
if (!str)
return (EXPP_ReturnPyObjError (PyExc_TypeError,"unknown interpolation type"));
return PyString_FromString(str);
}
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;
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;
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";
Py_INCREF(Py_None);
return Py_None;
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);
char *str=0;
float x,y;
int npoints;
IpoCurve *icu;
BezTriple *bzt,*tmp;
static char name[10] = "mlml";
PyObject*popo = 0;
if (!PyArg_ParseTuple(args, "Os", &popo,&str))
return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected list argument"));
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;

@ -92,6 +92,7 @@ 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);
/*****************************************************************************/
@ -116,6 +117,8 @@ static PyMethodDef C_IpoCurve_methods[] = {
{"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}
};

@ -3,7 +3,9 @@
"""
The Blender.Ipo submodule
This module provides access to the Ipo Data in Blender.
This module provides access to the Ipo Data in Blender. An Ipo is composed of several Ipocurves.
A datatype is defined : IpoCurve type. The member functions of this data type are given below.
Example::
@ -148,3 +150,102 @@ class Ipo:
@rtype: float
@return: the current value of the selected curve of the Ipo at the given time.
"""
class IpoCurve:
"""
The IpoCurve object
===================
This object gives access to generic data from all ipocurves objects in Blender.
@cvar name: The Curve Data name.
@cvar bezierPoints : The list of the Bezier points.
"""
def setExtrapolation(extrapolationtype):
"""
Sets the extrapolation type of the curve.
@type extrapolationtype: string
@param extrapolationtype: the extrapolatrion type of the curve. Can be Constant, Extrapolation, Cyclic or Cyclic_extrapolation.
@rtype: PyNone
@return: PyNone
"""
def getExtrapolation():
"""
Gets the extrapolation type of the curve.
@rtype: string
@return: the extrapolation type of the curve.Can be Constant, Extrapolation, Cyclic or Cyclic_extrapolation.
"""
def setInterpolation(interpolationtype):
"""
Sets the interpolation type of the curve.
@type interpolationtype: string
@param interpolationtype: the interpolatrion type of the curve. Can be Constant, Bezier, or Linear.
@rtype: PyNone
@return: PyNone
"""
def getInterpolation():
"""
Gets the interpolation type of the curve.
@rtype: string
@return: the interpolation type of the curve.Can be Constant, Bezier, or Linear.
"""
def addBezier(coordlist):
"""
Adds a Bezier point to a curve.
@type coordlist: tuple of (at least) 2 floats
@param coordlist: the x and y coordinates of the new Bezier point.
@rtype: PyNone
@return: PyNone
"""
def Recalc():
"""
Recomputes the curent value of the curve.
@rtype: PyNone
@return: PyNone
"""
def getName():
"""
Returns the name of the ipo curve.This name can be : LocX,LocY,LocZ,dLocX,dLocY,dLocZ,RotX,RotY,RotZ,dRotX,dRotY,dRotZ,SizeX,SizeY,SizeZ,dSizeX,dSizeY,dSizeZ,Layer,Time,ColR,ColG,ColB, or ColA.
@rtype: string
@return: the name of the ipo curve.
"""
def getPoints():
"""
Returns all the points of the ipo curve.
@rtype: list
@return: the points of the ipo curve.
"""
class BezTriple:
"""
The BezTriple object
====================
This object gives access to generic data from all beztriple objects in Blender.
@cvar name: The Curve Data name.
@cvar bezierPoints : The list of the Bezier points.
"""
def getPoints():
"""
Returns the xy coordinates of the Bezier point.
@rtype: list
@return: list of the coordinates of the Bezier point.
"""
def setPoints(newval):
"""
Sets the point xy coordinates.
@type newval: tuple of (at least) 2 floats
@param newval: the x and y coordinates of the new Bezier point.
@rtype: PyNone
@return: PyNone
"""