diff options
Diffstat (limited to 'source/blender/freestyle/intern/python')
24 files changed, 809 insertions, 236 deletions
diff --git a/source/blender/freestyle/intern/python/BinaryPredicate0D.h b/source/blender/freestyle/intern/python/BinaryPredicate0D.h index 6ad25ab2816..dd192877675 100644 --- a/source/blender/freestyle/intern/python/BinaryPredicate0D.h +++ b/source/blender/freestyle/intern/python/BinaryPredicate0D.h @@ -13,8 +13,7 @@ extern "C" { extern PyTypeObject BinaryPredicate0D_Type; -#define BPy_BinaryPredicate0D_Check(v) \ - ((v)->ob_type == &BinaryPredicate0D_Type) +#define BPy_BinaryPredicate0D_Check(v) (( (PyObject *) v)->ob_type == &BinaryPredicate0D_Type) /*---------------------------Python BPy_BinaryPredicate0D structure definition----------*/ typedef struct { diff --git a/source/blender/freestyle/intern/python/BinaryPredicate1D.h b/source/blender/freestyle/intern/python/BinaryPredicate1D.h index 2745ca6fc3f..035e2b6cb17 100644 --- a/source/blender/freestyle/intern/python/BinaryPredicate1D.h +++ b/source/blender/freestyle/intern/python/BinaryPredicate1D.h @@ -13,8 +13,7 @@ extern "C" { extern PyTypeObject BinaryPredicate1D_Type; -#define BPy_BinaryPredicate1D_Check(v) \ - ((v)->ob_type == &BinaryPredicate1D_Type) +#define BPy_BinaryPredicate1D_Check(v) (( (PyObject *) v)->ob_type == &BinaryPredicate1D_Type) /*---------------------------Python BPy_BinaryPredicate1D structure definition----------*/ typedef struct { diff --git a/source/blender/freestyle/intern/python/Freestyle.cpp b/source/blender/freestyle/intern/python/Freestyle.cpp index 5f98f0f2a89..a5aada0c470 100644 --- a/source/blender/freestyle/intern/python/Freestyle.cpp +++ b/source/blender/freestyle/intern/python/Freestyle.cpp @@ -8,6 +8,7 @@ #include "Interface0D/CurvePoint.h" #include "Interface1D.h" #include "Nature.h" +#include "StrokeAttribute.h" #include "UnaryFunction0D.h" #include "UnaryFunction1D.h" #include "UnaryPredicate0D.h" @@ -134,6 +135,7 @@ PyObject *Freestyle_Init( void ) Interface0D_Init( module ); Interface1D_Init( module ); Nature_Init( module ); + StrokeAttribute_Init( module ); UnaryFunction0D_Init( module ); UnaryFunction1D_Init( module ); UnaryPredicate0D_Init( module ); diff --git a/source/blender/freestyle/intern/python/Freestyle.h b/source/blender/freestyle/intern/python/Freestyle.h index 7e7ed56f5f2..9cdef4df2d2 100644 --- a/source/blender/freestyle/intern/python/Freestyle.h +++ b/source/blender/freestyle/intern/python/Freestyle.h @@ -11,8 +11,7 @@ extern "C" { extern PyTypeObject Freestyle_Type; -#define BPy_Freestyle_Check(v) \ - ((v)->ob_type == &Freestyle_Type) +#define BPy_Freestyle_Check(v) (( (PyObject *) v)->ob_type == &Freestyle_Type) /*---------------------------Python BPy_Freestyle structure definition----------*/ typedef struct { diff --git a/source/blender/freestyle/intern/python/Id.h b/source/blender/freestyle/intern/python/Id.h index 608ff3eef99..d5e90a0a3e5 100644 --- a/source/blender/freestyle/intern/python/Id.h +++ b/source/blender/freestyle/intern/python/Id.h @@ -16,8 +16,7 @@ extern "C" { extern PyTypeObject Id_Type; -#define BPy_Id_Check(v) \ - ((v)->ob_type == &Id_Type) +#define BPy_Id_Check(v) (( (PyObject *) v)->ob_type == &Id_Type) /*---------------------------Python BPy_Id structure definition----------*/ typedef struct { diff --git a/source/blender/freestyle/intern/python/IntegrationType.h b/source/blender/freestyle/intern/python/IntegrationType.h index 2ac81fdddfb..ab212ac6560 100644 --- a/source/blender/freestyle/intern/python/IntegrationType.h +++ b/source/blender/freestyle/intern/python/IntegrationType.h @@ -13,8 +13,7 @@ extern "C" { extern PyTypeObject IntegrationType_Type; -#define BPy_IntegrationType_Check(v) \ - ((v)->ob_type == &IntegrationType_Type) +#define BPy_IntegrationType_Check(v) (( (PyObject *) v)->ob_type == &IntegrationType_Type) /*---------------------------Python BPy_IntegrationType structure definition----------*/ typedef struct { diff --git a/source/blender/freestyle/intern/python/Interface0D.h b/source/blender/freestyle/intern/python/Interface0D.h index 10df1463da8..aaecc6dad94 100644 --- a/source/blender/freestyle/intern/python/Interface0D.h +++ b/source/blender/freestyle/intern/python/Interface0D.h @@ -13,8 +13,7 @@ extern "C" { extern PyTypeObject Interface0D_Type; -#define BPy_Interface0D_Check(v) \ - ((v)->ob_type == &Interface0D_Type) +#define BPy_Interface0D_Check(v) (( (PyObject *) v)->ob_type == &Interface0D_Type) /*---------------------------Python BPy_Interface0D structure definition----------*/ typedef struct { diff --git a/source/blender/freestyle/intern/python/Interface0D/CurvePoint.cpp b/source/blender/freestyle/intern/python/Interface0D/CurvePoint.cpp index f76fc9c9931..e1cf63727e5 100644 --- a/source/blender/freestyle/intern/python/Interface0D/CurvePoint.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/CurvePoint.cpp @@ -14,9 +14,9 @@ static PyObject * CurvePoint___copy__( BPy_CurvePoint *self ); static PyObject * CurvePoint_A( BPy_CurvePoint *self ); static PyObject * CurvePoint_B( BPy_CurvePoint *self ); static PyObject * CurvePoint_t2d( BPy_CurvePoint *self ); -static PyObject *CurvePoint_SetA( BPy_CurvePoint *self , PyObject *args); -static PyObject *CurvePoint_SetB( BPy_CurvePoint *self , PyObject *args); -static PyObject *CurvePoint_SetT2d( BPy_CurvePoint *self , PyObject *args); +static PyObject *CurvePoint_setA( BPy_CurvePoint *self , PyObject *args); +static PyObject *CurvePoint_setB( BPy_CurvePoint *self , PyObject *args); +static PyObject *CurvePoint_setT2d( BPy_CurvePoint *self , PyObject *args); static PyObject *CurvePoint_curvatureFredo( BPy_CurvePoint *self , PyObject *args); /*----------------------CurvePoint instance definitions ----------------------------*/ @@ -25,9 +25,9 @@ static PyMethodDef BPy_CurvePoint_methods[] = { {"A", ( PyCFunction ) CurvePoint_A, METH_NOARGS, "( )Returns the first SVertex upon which the CurvePoint is built."}, {"B", ( PyCFunction ) CurvePoint_B, METH_NOARGS, "( )Returns the second SVertex upon which the CurvePoint is built."}, {"t2d", ( PyCFunction ) CurvePoint_t2d, METH_NOARGS, "( )Returns the interpolation parameter."}, - {"SetA", ( PyCFunction ) CurvePoint_SetA, METH_VARARGS, "(SVertex sv )Sets the first SVertex upon which to build the CurvePoint."}, - {"SetB", ( PyCFunction ) CurvePoint_SetB, METH_VARARGS, "(SVertex sv )Sets the second SVertex upon which to build the CurvePoint."}, - {"SetT2d", ( PyCFunction ) CurvePoint_SetT2d, METH_VARARGS, "( )Sets the 2D interpolation parameter to use."}, + {"setA", ( PyCFunction ) CurvePoint_setA, METH_VARARGS, "(SVertex sv )Sets the first SVertex upon which to build the CurvePoint."}, + {"setB", ( PyCFunction ) CurvePoint_setB, METH_VARARGS, "(SVertex sv )Sets the second SVertex upon which to build the CurvePoint."}, + {"setT2d", ( PyCFunction ) CurvePoint_setT2d, METH_VARARGS, "( )Sets the 2D interpolation parameter to use."}, {"curvatureFredo", ( PyCFunction ) CurvePoint_curvatureFredo, METH_NOARGS, "( )angle in radians."}, {NULL, NULL, 0, NULL} }; @@ -182,41 +182,41 @@ PyObject * CurvePoint_t2d( BPy_CurvePoint *self ) { return PyFloat_FromDouble( self->cp->t2d() ); } -PyObject *CurvePoint_SetA( BPy_CurvePoint *self , PyObject *args) { +PyObject *CurvePoint_setA( BPy_CurvePoint *self , PyObject *args) { PyObject *py_sv; if(!( PyArg_ParseTuple(args, "O", &py_sv) && BPy_SVertex_Check(py_sv) )) { - cout << "ERROR: CurvePoint_SetA" << endl; + cout << "ERROR: CurvePoint_setA" << endl; Py_RETURN_NONE; } - self->cp->SetA( ((BPy_SVertex *) py_sv)->sv ); + self->cp->setA( ((BPy_SVertex *) py_sv)->sv ); Py_RETURN_NONE; } -PyObject *CurvePoint_SetB( BPy_CurvePoint *self , PyObject *args) { +PyObject *CurvePoint_setB( BPy_CurvePoint *self , PyObject *args) { PyObject *py_sv; if(!( PyArg_ParseTuple(args, "O", &py_sv) && BPy_SVertex_Check(py_sv) )) { - cout << "ERROR: CurvePoint_SetB" << endl; + cout << "ERROR: CurvePoint_setB" << endl; Py_RETURN_NONE; } - self->cp->SetB( ((BPy_SVertex *) py_sv)->sv ); + self->cp->setB( ((BPy_SVertex *) py_sv)->sv ); Py_RETURN_NONE; } -PyObject *CurvePoint_SetT2d( BPy_CurvePoint *self , PyObject *args) { +PyObject *CurvePoint_setT2d( BPy_CurvePoint *self , PyObject *args) { float t; if( !PyArg_ParseTuple(args, "f", &t) ) { - cout << "ERROR: CurvePoint_SetT2d" << endl; + cout << "ERROR: CurvePoint_setT2d" << endl; Py_RETURN_NONE; } - self->cp->SetT2d( t ); + self->cp->setT2d( t ); Py_RETURN_NONE; } diff --git a/source/blender/freestyle/intern/python/Interface0D/CurvePoint.h b/source/blender/freestyle/intern/python/Interface0D/CurvePoint.h index ac30f74c4dd..e40f261504f 100644 --- a/source/blender/freestyle/intern/python/Interface0D/CurvePoint.h +++ b/source/blender/freestyle/intern/python/Interface0D/CurvePoint.h @@ -14,8 +14,7 @@ extern "C" { extern PyTypeObject CurvePoint_Type; -#define BPy_CurvePoint_Check(v) \ - ((v)->ob_type == &CurvePoint_Type) +#define BPy_CurvePoint_Check(v) (( (PyObject *) v)->ob_type == &CurvePoint_Type) /*---------------------------Python BPy_CurvePoint structure definition----------*/ typedef struct { diff --git a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/StrokeVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/StrokeVertex.cpp index 7f2e364d0b4..69069a68f33 100644 --- a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/StrokeVertex.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/StrokeVertex.cpp @@ -1,104 +1,254 @@ - PyObject *_wrap_StrokeVertex_getExactTypeName(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_new_StrokeVertex__SWIG_0(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_new_StrokeVertex__SWIG_1(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_new_StrokeVertex__SWIG_2(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_new_StrokeVertex__SWIG_3(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_new_StrokeVertex__SWIG_4(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_new_StrokeVertex__SWIG_5(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_new_StrokeVertex(PyObject *self, PyObject *args) { -} - - - PyObject *_wrap_delete_StrokeVertex(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_StrokeVertex_x(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_StrokeVertex_y(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_StrokeVertex_getPoint(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_StrokeVertex_attribute__SWIG_0(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_StrokeVertex_attribute__SWIG_1(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_StrokeVertex_attribute(PyObject *self, PyObject *args) { -} - - - PyObject *_wrap_StrokeVertex_curvilinearAbscissa(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_StrokeVertex_strokeLength(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_StrokeVertex_u(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_StrokeVertex_SetX(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_StrokeVertex_SetY(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_StrokeVertex_SetPoint__SWIG_0(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_StrokeVertex_SetPoint__SWIG_1(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_StrokeVertex_SetPoint(PyObject *self, PyObject *args) { -} - - - PyObject *_wrap_StrokeVertex_SetAttribute(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_StrokeVertex_SetCurvilinearAbscissa(PyObject *self , PyObject *args) { -} - - - PyObject *_wrap_StrokeVertex_SetStrokeLength(PyObject *self , PyObject *args) { -} +#include "StrokeVertex.h" + +#include "../../Convert.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +/*--------------- Python API function prototypes for StrokeVertex instance -----------*/ +static int StrokeVertex___init__(BPy_StrokeVertex *self, PyObject *args, PyObject *kwds); + + +/*----------------------StrokeVertex instance definitions ----------------------------*/ +static PyMethodDef BPy_StrokeVertex_methods[] = { +// {"__copy__", ( PyCFunction ) StrokeVertex___copy__, METH_NOARGS, "( )Cloning method."}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_StrokeVertex type definition ------------------------------*/ + +PyTypeObject StrokeVertex_Type = { + PyObject_HEAD_INIT( NULL ) + 0, /* ob_size */ + "StrokeVertex", /* tp_name */ + sizeof( BPy_StrokeVertex ), /* tp_basicsize */ + 0, /* tp_itemsize */ + + /* methods */ + NULL, /* tp_dealloc */ + NULL, /* printfunc tp_print; */ + NULL, /* getattrfunc tp_getattr; */ + NULL, /* setattrfunc tp_setattr; */ + NULL, /* tp_compare */ + NULL, /* tp_repr */ + + /* Method suites for standard classes */ + + NULL, /* PyNumberMethods *tp_as_number; */ + NULL, /* PySequenceMethods *tp_as_sequence; */ + NULL, /* PyMappingMethods *tp_as_mapping; */ + + /* More standard operations (here for binary compatibility) */ + + NULL, /* hashfunc tp_hash; */ + NULL, /* ternaryfunc tp_call; */ + NULL, /* reprfunc tp_str; */ + NULL, /* getattrofunc tp_getattro; */ + NULL, /* setattrofunc tp_setattro; */ + /* Functions to access object as input/output buffer */ + NULL, /* PyBufferProcs *tp_as_buffer; */ + + /*** Flags to define presence of optional/expanded features ***/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */ + + NULL, /* char *tp_doc; Documentation string */ + /*** Assigned meaning in release 2.0 ***/ + /* call function for all accessible objects */ + NULL, /* traverseproc tp_traverse; */ + + /* delete references to contained objects */ + NULL, /* inquiry tp_clear; */ + + /*** Assigned meaning in release 2.1 ***/ + /*** rich comparisons ***/ + NULL, /* richcmpfunc tp_richcompare; */ + + /*** weak reference enabler ***/ + 0, /* long tp_weaklistoffset; */ + + /*** Added in release 2.2 ***/ + /* Iterators */ + NULL, /* getiterfunc tp_iter; */ + NULL, /* iternextfunc tp_iternext; */ + + /*** Attribute descriptor and subclassing stuff ***/ + BPy_StrokeVertex_methods, /* struct PyMethodDef *tp_methods; */ + NULL, /* struct PyMemberDef *tp_members; */ + NULL, /* struct PyGetSetDef *tp_getset; */ + &Interface0D_Type, /* struct _typeobject *tp_base; */ + NULL, /* PyObject *tp_dict; */ + NULL, /* descrgetfunc tp_descr_get; */ + NULL, /* descrsetfunc tp_descr_set; */ + 0, /* long tp_dictoffset; */ + (initproc)StrokeVertex___init__, /* initproc tp_init; */ + NULL, /* allocfunc tp_alloc; */ + NULL, /* newfunc tp_new; */ + + /* Low-level free-memory routine */ + NULL, /* freefunc tp_free; */ + + /* For PyObject_IS_GC */ + NULL, /* inquiry tp_is_gc; */ + NULL, /* PyObject *tp_bases; */ + + /* method resolution order */ + NULL, /* PyObject *tp_mro; */ + NULL, /* PyObject *tp_cache; */ + NULL, /* PyObject *tp_subclasses; */ + NULL, /* PyObject *tp_weaklist; */ + NULL +}; + +//-------------------MODULE INITIALIZATION-------------------------------- + + +//------------------------INSTANCE METHODS ---------------------------------- + +int StrokeVertex___init__(BPy_StrokeVertex *self, PyObject *args, PyObject *kwds) +{ + + PyObject *obj1 = 0, *obj2 = 0 , *obj3 = 0; + + if (! PyArg_ParseTuple(args, "|OOO", &obj1, &obj2, &obj3) ) + return -1; + + if( !obj1 && !obj2 && !obj3 ){ + self->cp = new CurvePoint(); + } else if( PyFloat_Check(obj3) ) { + if( BPy_SVertex_Check(obj1) && BPy_SVertex_Check(obj2) ) { + self->cp = new CurvePoint( ((BPy_SVertex *) obj1)->sv, + ((BPy_SVertex *) obj2)->sv, + PyFloat_AsDouble( obj3 ) ); + } else if( BPy_CurvePoint_Check(obj1) && BPy_CurvePoint_Check(obj2) ) { + self->cp = new CurvePoint( ((BPy_CurvePoint *) obj1)->cp, + ((BPy_CurvePoint *) obj2)->cp, + PyFloat_AsDouble( obj3 ) ); + } else { + return -1; + } + } else { + return -1; + } + + self->py_if0D.if0D = self->cp; + + return 0; +} + + + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + + +// PyObject *_wrap_StrokeVertex_getExactTypeName(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_new_StrokeVertex__SWIG_0(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_new_StrokeVertex__SWIG_1(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_new_StrokeVertex__SWIG_2(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_new_StrokeVertex__SWIG_3(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_new_StrokeVertex__SWIG_4(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_new_StrokeVertex__SWIG_5(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_new_StrokeVertex(PyObject *self, PyObject *args) { +// } +// +// +// PyObject *_wrap_delete_StrokeVertex(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_StrokeVertex_x(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_StrokeVertex_y(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_StrokeVertex_getPoint(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_StrokeVertex_attribute__SWIG_0(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_StrokeVertex_attribute__SWIG_1(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_StrokeVertex_attribute(PyObject *self, PyObject *args) { +// } +// +// +// PyObject *_wrap_StrokeVertex_curvilinearAbscissa(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_StrokeVertex_strokeLength(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_StrokeVertex_u(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_StrokeVertex_SetX(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_StrokeVertex_SetY(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_StrokeVertex_SetPoint__SWIG_0(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_StrokeVertex_SetPoint__SWIG_1(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_StrokeVertex_SetPoint(PyObject *self, PyObject *args) { +// } +// +// +// PyObject *_wrap_StrokeVertex_SetAttribute(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_StrokeVertex_SetCurvilinearAbscissa(PyObject *self , PyObject *args) { +// } +// +// +// PyObject *_wrap_StrokeVertex_SetStrokeLength(PyObject *self , PyObject *args) { +// } +// diff --git a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/StrokeVertex.h b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/StrokeVertex.h new file mode 100644 index 00000000000..dccecb093f5 --- /dev/null +++ b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/StrokeVertex.h @@ -0,0 +1,31 @@ +#ifndef FREESTYLE_PYTHON_STROKEVERTEX_H +#define FREESTYLE_PYTHON_STROKEVERTEX_H + +#include "../CurvePoint.h" +#include "../../stroke/Stroke.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject StrokeVertex_Type; + +#define BPy_StrokeVertex_Check(v) (( (PyObject *) v)->ob_type == &StrokeVertex_Type) + +/*---------------------------Python BPy_StrokeVertex structure definition----------*/ +typedef struct { + BPy_CurvePoint py_cp; + StrokeVertex *sv; +} BPy_StrokeVertex; + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_STROKEVERTEX_H */ diff --git a/source/blender/freestyle/intern/python/Interface0D/SVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/SVertex.cpp index eb91d7daf10..d0c622d1df2 100644 --- a/source/blender/freestyle/intern/python/Interface0D/SVertex.cpp +++ b/source/blender/freestyle/intern/python/Interface0D/SVertex.cpp @@ -14,10 +14,10 @@ static int SVertex___init__(BPy_SVertex *self, PyObject *args, PyObject *kwds); static PyObject * SVertex___copy__( BPy_SVertex *self ); static PyObject * SVertex_normals( BPy_SVertex *self ); static PyObject * SVertex_normalsSize( BPy_SVertex *self ); -static PyObject * SVertex_SetPoint3D( BPy_SVertex *self , PyObject *args); -static PyObject * SVertex_SetPoint2D( BPy_SVertex *self , PyObject *args); +static PyObject * SVertex_setPoint3D( BPy_SVertex *self , PyObject *args); +static PyObject * SVertex_setPoint2D( BPy_SVertex *self , PyObject *args); static PyObject * SVertex_AddNormal( BPy_SVertex *self , PyObject *args); -static PyObject * SVertex_SetId( BPy_SVertex *self , PyObject *args); +static PyObject * SVertex_setId( BPy_SVertex *self , PyObject *args); static PyObject *SVertex_AddFEdge( BPy_SVertex *self , PyObject *args); /*----------------------SVertex instance definitions ----------------------------*/ @@ -25,10 +25,10 @@ static PyMethodDef BPy_SVertex_methods[] = { {"__copy__", ( PyCFunction ) SVertex___copy__, METH_NOARGS, "( )Cloning method."}, {"normals", ( PyCFunction ) SVertex_normals, METH_NOARGS, "Returns the normals for this Vertex as a list. In a smooth surface, a vertex has exactly one normal. In a sharp surface, a vertex can have any number of normals."}, {"normalsSize", ( PyCFunction ) SVertex_normalsSize, METH_NOARGS, "Returns the number of different normals for this vertex." }, - {"SetPoint3D", ( PyCFunction ) SVertex_SetPoint3D, METH_VARARGS, "Sets the 3D coordinates of the SVertex." }, - {"SetPoint2D", ( PyCFunction ) SVertex_SetPoint2D, METH_VARARGS, "Sets the 3D projected coordinates of the SVertex." }, + {"setPoint3D", ( PyCFunction ) SVertex_setPoint3D, METH_VARARGS, "Sets the 3D coordinates of the SVertex." }, + {"setPoint2D", ( PyCFunction ) SVertex_setPoint2D, METH_VARARGS, "Sets the 3D projected coordinates of the SVertex." }, {"AddNormal", ( PyCFunction ) SVertex_AddNormal, METH_VARARGS, "Adds a normal to the Svertex's set of normals. If the same normal is already in the set, nothing changes." }, - {"SetId", ( PyCFunction ) SVertex_SetId, METH_VARARGS, "Sets the Id." }, + {"setId", ( PyCFunction ) SVertex_setId, METH_VARARGS, "Sets the Id." }, {"AddFEdge", ( PyCFunction ) SVertex_AddFEdge, METH_VARARGS, "Add an FEdge to the list of edges emanating from this SVertex." }, {NULL, NULL, 0, NULL} }; @@ -177,36 +177,36 @@ PyObject * SVertex_normalsSize( BPy_SVertex *self ) { return PyInt_FromLong( self->sv->normalsSize() ); } -PyObject *SVertex_SetPoint3D( BPy_SVertex *self , PyObject *args) { +PyObject *SVertex_setPoint3D( BPy_SVertex *self , PyObject *args) { PyObject *py_point; if(!( PyArg_ParseTuple(args, "O", &py_point) && PyList_Check(py_point) && PyList_Size(py_point) == 3 )) { - cout << "ERROR: SVertex_SetPoint3D" << endl; + cout << "ERROR: SVertex_setPoint3D" << endl; Py_RETURN_NONE; } Vec3r v( PyFloat_AsDouble( PyList_GetItem(py_point, 0) ), PyFloat_AsDouble( PyList_GetItem(py_point, 1) ), PyFloat_AsDouble( PyList_GetItem(py_point, 2) ) ); - self->sv->SetPoint3D( v ); + self->sv->setPoint3D( v ); Py_RETURN_NONE; } -PyObject *SVertex_SetPoint2D( BPy_SVertex *self , PyObject *args) { +PyObject *SVertex_setPoint2D( BPy_SVertex *self , PyObject *args) { PyObject *py_point; if(!( PyArg_ParseTuple(args, "O", &py_point) && PyList_Check(py_point) && PyList_Size(py_point) == 3 )) { - cout << "ERROR: SVertex_SetPoint2D" << endl; + cout << "ERROR: SVertex_setPoint2D" << endl; Py_RETURN_NONE; } Vec3r v( PyFloat_AsDouble( PyList_GetItem(py_point, 0) ), PyFloat_AsDouble( PyList_GetItem(py_point, 1) ), PyFloat_AsDouble( PyList_GetItem(py_point, 2) ) ); - self->sv->SetPoint2D( v ); + self->sv->setPoint2D( v ); Py_RETURN_NONE; } @@ -228,15 +228,15 @@ PyObject *SVertex_AddNormal( BPy_SVertex *self , PyObject *args) { Py_RETURN_NONE; } -PyObject *SVertex_SetId( BPy_SVertex *self , PyObject *args) { +PyObject *SVertex_setId( BPy_SVertex *self , PyObject *args) { BPy_Id *py_id; if( !PyArg_ParseTuple(args, "O", &py_id) ) { - cout << "ERROR: SVertex_SetId" << endl; + cout << "ERROR: SVertex_setId" << endl; Py_RETURN_NONE; } - self->sv->SetId( *(py_id->id) ); + self->sv->setId( *(py_id->id) ); Py_RETURN_NONE; } diff --git a/source/blender/freestyle/intern/python/Interface0D/SVertex.h b/source/blender/freestyle/intern/python/Interface0D/SVertex.h index ac89133ab55..099417b5139 100644 --- a/source/blender/freestyle/intern/python/Interface0D/SVertex.h +++ b/source/blender/freestyle/intern/python/Interface0D/SVertex.h @@ -15,8 +15,7 @@ extern "C" { extern PyTypeObject SVertex_Type; -#define BPy_SVertex_Check(v) \ - ((v)->ob_type == &SVertex_Type) +#define BPy_SVertex_Check(v) (( (PyObject *) v)->ob_type == &SVertex_Type) /*---------------------------Python BPy_SVertex structure definition----------*/ typedef struct { diff --git a/source/blender/freestyle/intern/python/Interface0D/ViewVertex.h b/source/blender/freestyle/intern/python/Interface0D/ViewVertex.h index 98eeb504a3d..98bcb9bac90 100644 --- a/source/blender/freestyle/intern/python/Interface0D/ViewVertex.h +++ b/source/blender/freestyle/intern/python/Interface0D/ViewVertex.h @@ -15,8 +15,7 @@ extern "C" { extern PyTypeObject ViewVertex_Type; -#define BPy_ViewVertex_Check(v) \ - ((v)->ob_type == &ViewVertex_Type) +#define BPy_ViewVertex_Check(v) (( (PyObject *) v)->ob_type == &ViewVertex_Type) /*---------------------------Python BPy_ViewVertex structure definition----------*/ typedef struct { diff --git a/source/blender/freestyle/intern/python/Interface1D.h b/source/blender/freestyle/intern/python/Interface1D.h index f39203744e4..c49a8c130b0 100644 --- a/source/blender/freestyle/intern/python/Interface1D.h +++ b/source/blender/freestyle/intern/python/Interface1D.h @@ -13,8 +13,7 @@ extern "C" { extern PyTypeObject Interface1D_Type; -#define BPy_Interface1D_Check(v) \ - ((v)->ob_type == &Interface1D_Type) +#define BPy_Interface1D_Check(v) (( (PyObject *) v)->ob_type == &Interface1D_Type) /*---------------------------Python BPy_Interface1D structure definition----------*/ typedef struct { diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge.cpp index 6a00ad66123..0cdfb9f1e0d 100644 --- a/source/blender/freestyle/intern/python/Interface1D/FEdge.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/FEdge.cpp @@ -20,13 +20,13 @@ static PyObject * FEdge_previousEdge( BPy_FEdge *self ); static PyObject * FEdge_getVertices( BPy_FEdge *self ); static PyObject * FEdge_getPoints( BPy_FEdge *self ); static PyObject * FEdge_isSmooth( BPy_FEdge *self ); -static PyObject * FEdge_SetVertexA( BPy_FEdge *self , PyObject *args); -static PyObject * FEdge_SetVertexB( BPy_FEdge *self , PyObject *args); -static PyObject * FEdge_SetId( BPy_FEdge *self , PyObject *args); -static PyObject * FEdge_SetNextEdge( BPy_FEdge *self , PyObject *args); -static PyObject * FEdge_SetPreviousEdge( BPy_FEdge *self , PyObject *args); -static PyObject * FEdge_SetSmooth( BPy_FEdge *self , PyObject *args); -static PyObject * FEdge_SetNature( BPy_FEdge *self, PyObject *args ); +static PyObject * FEdge_setVertexA( BPy_FEdge *self , PyObject *args); +static PyObject * FEdge_setVertexB( BPy_FEdge *self , PyObject *args); +static PyObject * FEdge_setId( BPy_FEdge *self , PyObject *args); +static PyObject * FEdge_setNextEdge( BPy_FEdge *self , PyObject *args); +static PyObject * FEdge_setPreviousEdge( BPy_FEdge *self , PyObject *args); +static PyObject * FEdge_setSmooth( BPy_FEdge *self , PyObject *args); +static PyObject * FEdge_setNature( BPy_FEdge *self, PyObject *args ); /*----------------------FEdge instance definitions ----------------------------*/ static PyMethodDef BPy_FEdge_methods[] = { @@ -39,13 +39,13 @@ static PyMethodDef BPy_FEdge_methods[] = { {"getVertices", ( PyCFunction ) FEdge_getVertices, METH_NOARGS, "Returns the vertices"}, {"getPoints", ( PyCFunction ) FEdge_getPoints, METH_NOARGS, "Returns the points. The difference with getVertices() is that here we can iterate over points of the 1D element at any given sampling. At each call, a virtual point is created."}, {"isSmooth", ( PyCFunction ) FEdge_isSmooth, METH_NOARGS, "() Returns true if this FEdge is a smooth FEdge."}, - {"SetVertexA", ( PyCFunction ) FEdge_SetVertexA, METH_VARARGS, "(SVertex v) Sets the first SVertex. ."}, - {"SetVertexB", ( PyCFunction ) FEdge_SetVertexB, METH_VARARGS, "(SVertex v) Sets the second SVertex. "}, - {"SetId", ( PyCFunction ) FEdge_SetId, METH_VARARGS, "(Id id) Sets the FEdge Id ."}, - {"SetNextEdge", ( PyCFunction ) FEdge_SetNextEdge, METH_VARARGS, "(FEdge e) Sets the pointer to the next FEdge. "}, - {"SetPreviousEdge", ( PyCFunction ) FEdge_SetPreviousEdge, METH_VARARGS, "(FEdge e) Sets the pointer to the previous FEdge. "}, - {"SetSmooth", ( PyCFunction ) FEdge_SetSmooth, METH_VARARGS, "(bool b) Sets the flag telling whether this FEdge is smooth or sharp. true for Smooth, false for Sharp. "}, - {"SetNature", ( PyCFunction ) FEdge_SetNature, METH_VARARGS, "(Nature n) Sets the nature of this FEdge. "}, + {"setVertexA", ( PyCFunction ) FEdge_setVertexA, METH_VARARGS, "(SVertex v) Sets the first SVertex. ."}, + {"setVertexB", ( PyCFunction ) FEdge_setVertexB, METH_VARARGS, "(SVertex v) Sets the second SVertex. "}, + {"setId", ( PyCFunction ) FEdge_setId, METH_VARARGS, "(Id id) Sets the FEdge Id ."}, + {"setNextEdge", ( PyCFunction ) FEdge_setNextEdge, METH_VARARGS, "(FEdge e) Sets the pointer to the next FEdge. "}, + {"setPreviousEdge", ( PyCFunction ) FEdge_setPreviousEdge, METH_VARARGS, "(FEdge e) Sets the pointer to the previous FEdge. "}, + {"setSmooth", ( PyCFunction ) FEdge_setSmooth, METH_VARARGS, "(bool b) Sets the flag telling whether this FEdge is smooth or sharp. true for Smooth, false for Sharp. "}, + {"setNature", ( PyCFunction ) FEdge_setNature, METH_VARARGS, "(Nature n) Sets the nature of this FEdge. "}, {NULL, NULL, 0, NULL} }; @@ -221,86 +221,86 @@ PyObject * FEdge_isSmooth( BPy_FEdge *self ) { return PyBool_from_bool( self->fe->isSmooth() ); } -PyObject *FEdge_SetVertexA( BPy_FEdge *self , PyObject *args) { +PyObject *FEdge_setVertexA( BPy_FEdge *self , PyObject *args) { PyObject *py_sv; if(!( PyArg_ParseTuple(args, "O", &py_sv) && BPy_SVertex_Check(py_sv) )) { - cout << "ERROR: FEdge_SetVertexA" << endl; + cout << "ERROR: FEdge_setVertexA" << endl; Py_RETURN_NONE; } - self->fe->SetVertexA( ((BPy_SVertex *) py_sv)->sv ); + self->fe->setVertexA( ((BPy_SVertex *) py_sv)->sv ); Py_RETURN_NONE; } -PyObject *FEdge_SetVertexB( BPy_FEdge *self , PyObject *args) { +PyObject *FEdge_setVertexB( BPy_FEdge *self , PyObject *args) { PyObject *py_sv; if(!( PyArg_ParseTuple(args, "O", &py_sv) && BPy_SVertex_Check(py_sv) )) { - cout << "ERROR: FEdge_SetVertexB" << endl; + cout << "ERROR: FEdge_setVertexB" << endl; Py_RETURN_NONE; } - self->fe->SetVertexB( ((BPy_SVertex *) py_sv)->sv ); + self->fe->setVertexB( ((BPy_SVertex *) py_sv)->sv ); Py_RETURN_NONE; } -PyObject *FEdge_SetId( BPy_FEdge *self , PyObject *args) { +PyObject *FEdge_setId( BPy_FEdge *self , PyObject *args) { PyObject *py_id; if(!( PyArg_ParseTuple(args, "O", &py_id) && BPy_Id_Check(py_id) )) { - cout << "ERROR: FEdge_SetId" << endl; + cout << "ERROR: FEdge_setId" << endl; Py_RETURN_NONE; } - self->fe->SetId(*( ((BPy_Id *) py_id)->id )); + self->fe->setId(*( ((BPy_Id *) py_id)->id )); Py_RETURN_NONE; } -PyObject *FEdge_SetNextEdge( BPy_FEdge *self , PyObject *args) { +PyObject *FEdge_setNextEdge( BPy_FEdge *self , PyObject *args) { PyObject *py_fe; if(!( PyArg_ParseTuple(args, "O", &py_fe) && BPy_FEdge_Check(py_fe) )) { - cout << "ERROR: FEdge_SetNextEdge" << endl; + cout << "ERROR: FEdge_setNextEdge" << endl; Py_RETURN_NONE; } - self->fe->SetNextEdge( ((BPy_FEdge *) py_fe)->fe ); + self->fe->setNextEdge( ((BPy_FEdge *) py_fe)->fe ); Py_RETURN_NONE; } -PyObject *FEdge_SetPreviousEdge( BPy_FEdge *self , PyObject *args) { +PyObject *FEdge_setPreviousEdge( BPy_FEdge *self , PyObject *args) { PyObject *py_fe; if(!( PyArg_ParseTuple(args, "O", &py_fe) && BPy_FEdge_Check(py_fe) )) { - cout << "ERROR: FEdge_SetPreviousEdge" << endl; + cout << "ERROR: FEdge_setPreviousEdge" << endl; Py_RETURN_NONE; } - self->fe->SetPreviousEdge( ((BPy_FEdge *) py_fe)->fe ); + self->fe->setPreviousEdge( ((BPy_FEdge *) py_fe)->fe ); Py_RETURN_NONE; } -PyObject *FEdge_SetSmooth( BPy_FEdge *self , PyObject *args) { +PyObject *FEdge_setSmooth( BPy_FEdge *self , PyObject *args) { int b; if(!( PyArg_ParseTuple(args, "i", &b) )) { - cout << "ERROR: FEdge_SetSmooth" << endl; + cout << "ERROR: FEdge_setSmooth" << endl; Py_RETURN_NONE; } - self->fe->SetSmooth( (bool) b ); + self->fe->setSmooth( (bool) b ); Py_RETURN_NONE; } -PyObject * FEdge_SetNature( BPy_FEdge *self, PyObject *args ) { +PyObject * FEdge_setNature( BPy_FEdge *self, PyObject *args ) { PyObject *py_n; if(!( PyArg_ParseTuple(args, "O", &py_n) && BPy_Nature_Check(py_n) )) { @@ -309,7 +309,7 @@ PyObject * FEdge_SetNature( BPy_FEdge *self, PyObject *args ) { } PyObject *i = (PyObject *) &( ((BPy_Nature *) py_n)->i ); - ((FEdge *) self->py_if1D.if1D)->SetNature( PyInt_AsLong(i) ); + ((FEdge *) self->py_if1D.if1D)->setNature( PyInt_AsLong(i) ); Py_RETURN_NONE; } diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge.h b/source/blender/freestyle/intern/python/Interface1D/FEdge.h index 39c9c56e391..230a5f36954 100644 --- a/source/blender/freestyle/intern/python/Interface1D/FEdge.h +++ b/source/blender/freestyle/intern/python/Interface1D/FEdge.h @@ -14,8 +14,7 @@ extern "C" { extern PyTypeObject FEdge_Type; -#define BPy_FEdge_Check(v) \ - ((v)->ob_type == &FEdge_Type) +#define BPy_FEdge_Check(v) (( (PyObject *) v)->ob_type == &FEdge_Type) /*---------------------------Python BPy_FEdge structure definition----------*/ typedef struct { diff --git a/source/blender/freestyle/intern/python/Nature.h b/source/blender/freestyle/intern/python/Nature.h index d0bc4de6fc0..7473869158f 100644 --- a/source/blender/freestyle/intern/python/Nature.h +++ b/source/blender/freestyle/intern/python/Nature.h @@ -13,8 +13,7 @@ extern "C" { extern PyTypeObject Nature_Type; -#define BPy_Nature_Check(v) \ - ((v)->ob_type == &Nature_Type) +#define BPy_Nature_Check(v) (( (PyObject *) v)->ob_type == &Nature_Type) /*---------------------------Python BPy_Nature structure definition----------*/ typedef struct { diff --git a/source/blender/freestyle/intern/python/StrokeAttribute.cpp b/source/blender/freestyle/intern/python/StrokeAttribute.cpp index c54eca16e11..5f7814ff4dd 100644 --- a/source/blender/freestyle/intern/python/StrokeAttribute.cpp +++ b/source/blender/freestyle/intern/python/StrokeAttribute.cpp @@ -1,112 +1,484 @@ - PyObject *_wrap_StrokeAttribute_getColor(PyObject *self , PyObject *args) { +#include "StrokeAttribute.h" + +#include "Convert.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +/*--------------- Python API function prototypes for StrokeAttribute instance -----------*/ +static int StrokeAttribute___init__(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds); +static void StrokeAttribute___dealloc__(BPy_StrokeAttribute *self); +static PyObject * StrokeAttribute___repr__(BPy_StrokeAttribute *self); + +static PyObject * StrokeAttribute_getColorR( BPy_StrokeAttribute *self ); +static PyObject * StrokeAttribute_getColorG( BPy_StrokeAttribute *self ); +static PyObject * StrokeAttribute_getColorB( BPy_StrokeAttribute *self ); +static PyObject * StrokeAttribute_getColorRGB( BPy_StrokeAttribute *self ); +static PyObject * StrokeAttribute_getAlpha( BPy_StrokeAttribute *self ); +static PyObject * StrokeAttribute_getThicknessR( BPy_StrokeAttribute *self ); +static PyObject * StrokeAttribute_getThicknessL( BPy_StrokeAttribute *self ); +static PyObject * StrokeAttribute_getThicknessRL( BPy_StrokeAttribute *self ); +static PyObject * StrokeAttribute_isVisible( BPy_StrokeAttribute *self ); +static PyObject * StrokeAttribute_getAttributeReal( BPy_StrokeAttribute *self, PyObject *args ); +static PyObject * StrokeAttribute_getAttributeVec2f( BPy_StrokeAttribute *self, PyObject *args ); +static PyObject * StrokeAttribute_getAttributeVec3f( BPy_StrokeAttribute *self, PyObject *args ); +static PyObject * StrokeAttribute_isAttributeAvailableReal( BPy_StrokeAttribute *self, PyObject *args ); +static PyObject * StrokeAttribute_isAttributeAvailableVec2f( BPy_StrokeAttribute *self, PyObject *args ); +static PyObject * StrokeAttribute_isAttributeAvailableVec3f( BPy_StrokeAttribute *self, PyObject *args ); +static int StrokeAttribute_setColor( BPy_StrokeAttribute *self, PyObject *args ); +static int StrokeAttribute_setAlpha( BPy_StrokeAttribute *self, PyObject *args ); +static int StrokeAttribute_setThickness( BPy_StrokeAttribute *self, PyObject *args ); +static int StrokeAttribute_setVisible( BPy_StrokeAttribute *self, PyObject *args ); +static int StrokeAttribute_setAttributeReal( BPy_StrokeAttribute *self, PyObject *args ); +static int StrokeAttribute_setAttributeVec2f( BPy_StrokeAttribute *self, PyObject *args ); +static int StrokeAttribute_setAttributeVec3f( BPy_StrokeAttribute *self, PyObject *args ); + + +/*----------------------StrokeAttribute instance definitions ----------------------------*/ +static PyMethodDef BPy_StrokeAttribute_methods[] = { + {"getColorR", ( PyCFunction ) StrokeAttribute_getColorR, METH_NOARGS, "Returns the R color component. "}, + {"getColorG", ( PyCFunction ) StrokeAttribute_getColorG, METH_NOARGS, "Returns the G color component. "}, + {"getColorB", ( PyCFunction ) StrokeAttribute_getColorB, METH_NOARGS, "Returns the B color component. "}, + {"getColorRGB", ( PyCFunction ) StrokeAttribute_getColorRGB, METH_NOARGS, "Returns the RGB color components."}, + {"getAlpha", ( PyCFunction ) StrokeAttribute_getAlpha, METH_NOARGS, "Returns the alpha color component."}, + {"getThicknessR", ( PyCFunction ) StrokeAttribute_getThicknessR, METH_NOARGS, "Returns the thickness on the right of the vertex when following the stroke. "}, + {"getThicknessL", ( PyCFunction ) StrokeAttribute_getThicknessL, METH_NOARGS, "Returns the thickness on the left of the vertex when following the stroke."}, + {"getThicknessRL", ( PyCFunction ) StrokeAttribute_getThicknessRL, METH_NOARGS, "Returns the thickness on the right and on the left of the vertex when following the stroke. "}, + {"isVisible", ( PyCFunction ) StrokeAttribute_isVisible, METH_NOARGS, "Returns true if the strokevertex is visible, false otherwise"}, + {"getAttributeReal", ( PyCFunction ) StrokeAttribute_getAttributeReal, METH_VARARGS, "(name) Returns an attribute of type real specified by name."}, + {"getAttributeVec2f", ( PyCFunction ) StrokeAttribute_getAttributeVec2f, METH_VARARGS, "(name) Returns an attribute of type Vec2f specified by name."}, + {"getAttributeVec3f", ( PyCFunction ) StrokeAttribute_getAttributeVec3f, METH_VARARGS, "(name) Returns an attribute of type Vec3f specified by name."}, + {"isAttributeAvailableReal", ( PyCFunction ) StrokeAttribute_isAttributeAvailableReal, METH_VARARGS, "(name) Checks whether the real attribute specified by name is available"}, + {"isAttributeAvailableVec2f", ( PyCFunction ) StrokeAttribute_isAttributeAvailableVec2f, METH_VARARGS, "(name) Checks whether the Vec2f attribute specified by name is available"}, + {"isAttributeAvailableVec3f", ( PyCFunction ) StrokeAttribute_isAttributeAvailableVec3f, METH_VARARGS, "(name) Checks whether the Vec3f attribute specified by name is available"}, + {"setColor", ( PyCFunction ) StrokeAttribute_setColor, METH_VARARGS, "(float a)Sets the attribute's alpha value. "}, + {"setAlpha", ( PyCFunction ) StrokeAttribute_setAlpha, METH_VARARGS, "(float a) Sets the attribute's alpha value."}, + {"setThickness", ( PyCFunction ) StrokeAttribute_setThickness, METH_VARARGS, ""}, + {"setVisible", ( PyCFunction ) StrokeAttribute_setVisible, METH_VARARGS, ""}, + {"setAttributeReal", ( PyCFunction ) StrokeAttribute_setAttributeReal, METH_VARARGS, "(name, float att) Adds a user defined attribute of type real. If there is no attribute of specified by name, it is added. Otherwise, the new value replaces the old one."}, + {"setAttributeVec2f", ( PyCFunction ) StrokeAttribute_setAttributeVec2f, METH_VARARGS, "(name, float att) Adds a user defined attribute of type Vec2f. If there is no attribute of specified by name, it is added. Otherwise, the new value replaces the old one."}, + {"setAttributeVec3f", ( PyCFunction ) StrokeAttribute_setAttributeVec3f, METH_VARARGS, "(name, float att) Adds a user defined attribute of type Vec4f. If there is no attribute of specified by name, it is added. Otherwise, the new value replaces the old one."}, + {NULL, NULL, 0, NULL} +}; + +/*-----------------------BPy_StrokeAttribute type definition ------------------------------*/ + +PyTypeObject StrokeAttribute_Type = { + PyObject_HEAD_INIT( NULL ) + 0, /* ob_size */ + "StrokeAttribute", /* tp_name */ + sizeof( BPy_StrokeAttribute ), /* tp_basicsize */ + 0, /* tp_itemsize */ + + /* methods */ + (destructor)StrokeAttribute___dealloc__, /* tp_dealloc */ + NULL, /* printfunc tp_print; */ + NULL, /* getattrfunc tp_getattr; */ + NULL, /* setattrfunc tp_setattr; */ + NULL, /* tp_compare */ + (reprfunc)StrokeAttribute___repr__, /* tp_repr */ + + /* Method suites for standard classes */ + + NULL, /* PyNumberMethods *tp_as_number; */ + NULL, /* PySequenceMethods *tp_as_sequence; */ + NULL, /* PyMappingMethods *tp_as_mapping; */ + + /* More standard operations (here for binary compatibility) */ + + NULL, /* hashfunc tp_hash; */ + NULL, /* ternaryfunc tp_call; */ + NULL, /* reprfunc tp_str; */ + NULL, /* getattrofunc tp_getattro; */ + NULL, /* setattrofunc tp_setattro; */ + + /* Functions to access object as input/output buffer */ + NULL, /* PyBufferProcs *tp_as_buffer; */ + + /*** Flags to define presence of optional/expanded features ***/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */ + + NULL, /* char *tp_doc; Documentation string */ + /*** Assigned meaning in release 2.0 ***/ + /* call function for all accessible objects */ + NULL, /* traverseproc tp_traverse; */ + + /* delete references to contained objects */ + NULL, /* inquiry tp_clear; */ + + /*** Assigned meaning in release 2.1 ***/ + /*** rich comparisons ***/ + NULL, /* richcmpfunc tp_richcompare; */ + + /*** weak reference enabler ***/ + 0, /* long tp_weaklistoffset; */ + + /*** Added in release 2.2 ***/ + /* Iterators */ + NULL, /* getiterfunc tp_iter; */ + NULL, /* iternextfunc tp_iternext; */ + + /*** Attribute descriptor and subclassing stuff ***/ + BPy_StrokeAttribute_methods, /* struct PyMethodDef *tp_methods; */ + NULL, /* struct PyMemberDef *tp_members; */ + NULL, /* struct PyGetSetDef *tp_getset; */ + NULL, /* struct _typeobject *tp_base; */ + NULL, /* PyObject *tp_dict; */ + NULL, /* descrgetfunc tp_descr_get; */ + NULL, /* descrsetfunc tp_descr_set; */ + 0, /* long tp_dictoffset; */ + (initproc)StrokeAttribute___init__, /* initproc tp_init; */ + NULL, /* allocfunc tp_alloc; */ + PyType_GenericNew, /* newfunc tp_new; */ + + /* Low-level free-memory routine */ + NULL, /* freefunc tp_free; */ + + /* For PyObject_IS_GC */ + NULL, /* inquiry tp_is_gc; */ + NULL, /* PyObject *tp_bases; */ + + /* method resolution order */ + NULL, /* PyObject *tp_mro; */ + NULL, /* PyObject *tp_cache; */ + NULL, /* PyObject *tp_subclasses; */ + NULL, /* PyObject *tp_weaklist; */ + NULL +}; + +//-------------------MODULE INITIALIZATION-------------------------------- +PyMODINIT_FUNC StrokeAttribute_Init( PyObject *module ) +{ + if( module == NULL ) + return; + + if( PyType_Ready( &StrokeAttribute_Type ) < 0 ) + return; + Py_INCREF( &StrokeAttribute_Type ); + PyModule_AddObject(module, "StrokeAttribute", (PyObject *)&StrokeAttribute_Type); + } +//------------------------INSTANCE METHODS ---------------------------------- + +int StrokeAttribute___init__(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds) +{ + + PyObject *obj1 = 0, *obj2 = 0 , *obj3 = 0, *obj4 = 0, *obj5 = 0 , *obj6 = 0; + + if (! PyArg_ParseTuple(args, "|OOOOOO", &obj1, &obj2, &obj3, &obj4, &obj5, &obj6) ) + return -1; + + if( !obj1 || !obj2 || !obj3 ){ + + self->sa = new StrokeAttribute(); + + } else if( BPy_StrokeAttribute_Check(obj1) && + BPy_StrokeAttribute_Check(obj2) && + PyFloat_Check(obj3) ) { + + self->sa = new StrokeAttribute( *( ((BPy_StrokeAttribute *) obj1)->sa ), + *( ((BPy_StrokeAttribute *) obj2)->sa ), + PyFloat_AsDouble( obj3 ) ); + + } else if( obj4 && obj5 && obj6 && + PyFloat_Check(obj1) && PyFloat_Check(obj2) && PyFloat_Check(obj2) && + PyFloat_Check(obj4) && PyFloat_Check(obj5) && PyFloat_Check(obj6) ) { + + self->sa = new StrokeAttribute( PyFloat_AsDouble( obj1 ), + PyFloat_AsDouble( obj2 ), + PyFloat_AsDouble( obj3 ), + PyFloat_AsDouble( obj4 ), + PyFloat_AsDouble( obj5 ), + PyFloat_AsDouble( obj6 ) ); + + } else { + return -1; + } + + + return 0; - PyObject *_wrap_StrokeAttribute_getColorR(PyObject *self , PyObject *args) { } - - PyObject *_wrap_StrokeAttribute_getColorG(PyObject *self , PyObject *args) { +void StrokeAttribute___dealloc__(BPy_StrokeAttribute* self) +{ + delete self->sa; + self->ob_type->tp_free((PyObject*)self); } - - PyObject *_wrap_StrokeAttribute_getColorB(PyObject *self , PyObject *args) { +PyObject * StrokeAttribute___repr__(BPy_StrokeAttribute* self) +{ + return PyString_FromFormat("StrokeAttribute: r:%f g:%f b:%f a:%f - R:%f L:%f", + self->sa->getColorR(), self->sa->getColorG(), self->sa->getColorB(), self->sa->getAlpha(), + self->sa->getThicknessR(), self->sa->getThicknessL() ); } - PyObject *_wrap_StrokeAttribute_getColorRGB(PyObject *self , PyObject *args) { +// PyObject *StrokeAttribute_getColor( BPy_StrokeAttribute *self ) { +// float *c = self->sa->getColor(); +// Vec3f v( c[0], c[1], c[2]); +// return Vector_from_Vec3f( v ); +// } + +PyObject *StrokeAttribute_getColorR( BPy_StrokeAttribute *self ) { + return PyFloat_FromDouble( self->sa->getColorR() ); } +PyObject *StrokeAttribute_getColorG( BPy_StrokeAttribute *self ) { + return PyFloat_FromDouble( self->sa->getColorG() ); +} - PyObject *_wrap_StrokeAttribute_getAlpha(PyObject *self , PyObject *args) { +PyObject *StrokeAttribute_getColorB( BPy_StrokeAttribute *self ) { + return PyFloat_FromDouble( self->sa->getColorB() ); } +PyObject *StrokeAttribute_getColorRGB( BPy_StrokeAttribute *self ) { + Vec3f v( self->sa->getColorRGB() ); + return Vector_from_Vec3f( v ); +} - PyObject *_wrap_StrokeAttribute_getThickness(PyObject *self , PyObject *args) { +PyObject *StrokeAttribute_getAlpha( BPy_StrokeAttribute *self ) { + return PyFloat_FromDouble( self->sa->getAlpha() ); } +// PyObject *StrokeAttribute_getThickness( BPy_StrokeAttribute *self ) { +// // vector +// return PyString_FromString( self->sa->getExactTypeName() ); +// } - PyObject *_wrap_StrokeAttribute_getThicknessR(PyObject *self , PyObject *args) { +PyObject *StrokeAttribute_getThicknessR( BPy_StrokeAttribute *self ) { + return PyFloat_FromDouble( self->sa->getThicknessR() ); +} +PyObject *StrokeAttribute_getThicknessL( BPy_StrokeAttribute *self ) { + return PyFloat_FromDouble( self->sa->getThicknessL() ); +} +PyObject *StrokeAttribute_getThicknessRL( BPy_StrokeAttribute *self ) { + Vec2f v( self->sa->getThicknessRL() ); + return Vector_from_Vec2f( v ); } - - PyObject *_wrap_StrokeAttribute_getThicknessL(PyObject *self , PyObject *args) { +PyObject *StrokeAttribute_isVisible( BPy_StrokeAttribute *self ) { + return PyBool_from_bool( self->sa->isVisible() ); } - PyObject *_wrap_StrokeAttribute_getThicknessRL(PyObject *self , PyObject *args) { -} +PyObject *StrokeAttribute_getAttributeReal( BPy_StrokeAttribute *self, PyObject *args ) { + char *attr; + if(!( PyArg_ParseTuple(args, "s", &attr) )) { + cout << "ERROR: StrokeAttribute_getAttributeReal" << endl; + Py_RETURN_NONE; + } - PyObject *_wrap_StrokeAttribute_isVisible(PyObject *self , PyObject *args) { + double a = self->sa->getAttributeReal( attr ); + return PyFloat_FromDouble( a ); } +PyObject *StrokeAttribute_getAttributeVec2f( BPy_StrokeAttribute *self, PyObject *args ) { + char *attr; - PyObject *_wrap_StrokeAttribute_getAttributeReal(PyObject *self , PyObject *args) { + if(!( PyArg_ParseTuple(args, "s", &attr) )) { + cout << "ERROR: StrokeAttribute_getAttributeVec2f" << endl; + Py_RETURN_NONE; + } + + Vec2f a = self->sa->getAttributeVec2f( attr ); + return Vector_from_Vec2f( a ); } - PyObject *_wrap_StrokeAttribute_getAttributeVec2f(PyObject *self , PyObject *args) { -} +PyObject *StrokeAttribute_getAttributeVec3f( BPy_StrokeAttribute *self, PyObject *args ) { + char *attr; + if(!( PyArg_ParseTuple(args, "s", &attr) )) { + cout << "ERROR: StrokeAttribute_getAttributeVec3f" << endl; + Py_RETURN_NONE; + } - PyObject *_wrap_StrokeAttribute_getAttributeVec3f(PyObject *self , PyObject *args) { + Vec3f a = self->sa->getAttributeVec3f( attr ); + return Vector_from_Vec3f( a ); } +PyObject *StrokeAttribute_isAttributeAvailableReal( BPy_StrokeAttribute *self, PyObject *args ) { + char *attr; + + if(!( PyArg_ParseTuple(args, "s", &attr) )) { + cout << "ERROR: StrokeAttribute_isAttributeAvailableReal" << endl; + Py_RETURN_NONE; + } - PyObject *_wrap_StrokeAttribute_isAttributeAvailableReal(PyObject *self , PyObject *args) { + return PyBool_from_bool( self->sa->isAttributeAvailableReal( attr ) ); } +PyObject *StrokeAttribute_isAttributeAvailableVec2f( BPy_StrokeAttribute *self, PyObject *args ) { + char *attr; - PyObject *_wrap_StrokeAttribute_isAttributeAvailableVec2f(PyObject *self , PyObject *args) { + if(!( PyArg_ParseTuple(args, "s", &attr) )) { + cout << "ERROR: StrokeAttribute_isAttributeAvailableVec2f" << endl; + Py_RETURN_NONE; + } + + return PyBool_from_bool( self->sa->isAttributeAvailableVec2f( attr ) ); } +PyObject *StrokeAttribute_isAttributeAvailableVec3f( BPy_StrokeAttribute *self, PyObject *args ) { + char *attr; + + if(!( PyArg_ParseTuple(args, "s", &attr) )) { + cout << "ERROR: StrokeAttribute_isAttributeAvailableVec3f" << endl; + Py_RETURN_NONE; + } - PyObject *_wrap_StrokeAttribute_isAttributeAvailableVec3f(PyObject *self , PyObject *args) { + return PyBool_from_bool( self->sa->isAttributeAvailableVec3f( attr ) ); } - PyObject *_wrap_StrokeAttribute_setColor__SWIG_0(PyObject *self , PyObject *args) { +int StrokeAttribute_setColor( BPy_StrokeAttribute *self, PyObject *args ) { + PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0 ; + + if(!( PyArg_ParseTuple(args, "O|OO", &obj1, &obj2, &obj3) )) { + cout << "ERROR: StrokeAttribute_setColor" << endl; + return -1; + } + + if( PyList_Check(obj1) && !obj2 && !obj3 ){ + + Vec3f v( PyFloat_AsDouble( PyList_GetItem(obj1, 0) ), + PyFloat_AsDouble( PyList_GetItem(obj1, 1) ), + PyFloat_AsDouble( PyList_GetItem(obj1, 2) ) ); + + self->sa->setColor( v ); + return 0; + + } else if( obj1 && PyFloat_Check(obj1) && + obj2 && PyFloat_Check(obj2) && + obj3 && PyFloat_Check(obj3) ){ + + self->sa->setColor( PyFloat_AsDouble(obj1), + PyFloat_AsDouble(obj2), + PyFloat_AsDouble(obj3) ); + return 0; + } + + return -1; } +int StrokeAttribute_setAlpha( BPy_StrokeAttribute *self, PyObject *args ){ + float f = 0; - PyObject *_wrap_StrokeAttribute_setColor__SWIG_1(PyObject *self , PyObject *args) { + if(!( PyArg_ParseTuple(args, "f", &f) )) { + cout << "ERROR: StrokeAttribute_setAlpha" << endl; + return -1; + } + + self->sa->setAlpha( f ); + return 0; } - - PyObject *_wrap_StrokeAttribute_setColor(PyObject *self, PyObject *args) { +int StrokeAttribute_setThickness( BPy_StrokeAttribute *self, PyObject *args ) { + PyObject *obj1 = 0, *obj2 = 0; + + if(!( PyArg_ParseTuple(args, "O|O", &obj1, &obj2) )) { + cout << "ERROR: StrokeAttribute_setThickness" << endl; + return -1; + } + + if( PyList_Check(obj1) && !obj2 ){ + + Vec2f v( PyFloat_AsDouble( PyList_GetItem(obj1, 0) ), + PyFloat_AsDouble( PyList_GetItem(obj1, 1) ) ); + + self->sa->setThickness( v ); + return 0; + + } else if( obj1 && PyFloat_Check(obj1) && + obj2 && PyFloat_Check(obj2) ){ + + self->sa->setThickness( PyFloat_AsDouble(obj1), + PyFloat_AsDouble(obj2) ); + return 0; + } + + return -1; } +int StrokeAttribute_setVisible( BPy_StrokeAttribute *self, PyObject *args ) { + int i = 0; - PyObject *_wrap_StrokeAttribute_setAlpha(PyObject *self , PyObject *args) { + if(!( PyArg_ParseTuple(args, "i", &i) )) { + cout << "ERROR: StrokeAttribute_setVisible" << endl; + return -1; + } + + self->sa->setVisible( i ); + return 0; } +int StrokeAttribute_setAttributeReal( BPy_StrokeAttribute *self, PyObject *args ) { + char *s = 0; + double d = 0; + + if(!( PyArg_ParseTuple(args, "sd", &s, &d) )) { + cout << "ERROR: StrokeAttribute_setAttributeReal" << endl; + return -1; + } - PyObject *_wrap_StrokeAttribute_setThickness__SWIG_0(PyObject *self , PyObject *args) { + self->sa->setAttributeReal( s, d ); + return 0; } +int StrokeAttribute_setAttributeVec2f( BPy_StrokeAttribute *self, PyObject *args ) { + char *s; + PyObject *obj = 0; - PyObject *_wrap_StrokeAttribute_setThickness__SWIG_1(PyObject *self , PyObject *args) { -} + if(!( PyArg_ParseTuple(args, "sO", &s, &obj) )) { + cout << "ERROR: StrokeAttribute_setAttributeVec2f" << endl; + return -1; + } + if( PyList_Check(obj) && PyList_Size(obj) > 1) { - PyObject *_wrap_StrokeAttribute_setThickness(PyObject *self, PyObject *args) { + Vec2f v( PyFloat_AsDouble( PyList_GetItem(obj, 0) ), + PyFloat_AsDouble( PyList_GetItem(obj, 1) ) ); + + self->sa->setAttributeVec2f( s, v ); + return 0; + + } + + return -1; } +int StrokeAttribute_setAttributeVec3f( BPy_StrokeAttribute *self, PyObject *args ) { + char *s; + PyObject *obj = 0; - PyObject *_wrap_StrokeAttribute_SetVisible(PyObject *self , PyObject *args) { -} + if(!( PyArg_ParseTuple(args, "sO", &s, &obj) )) { + cout << "ERROR: StrokeAttribute_setAttributeVec3f" << endl; + return -1; + } + if( PyList_Check(obj) && PyList_Size(obj) > 2 ) { - PyObject *_wrap_StrokeAttribute_setAttributeReal(PyObject *self , PyObject *args) { -} + Vec3f v( PyFloat_AsDouble( PyList_GetItem(obj, 0) ), + PyFloat_AsDouble( PyList_GetItem(obj, 1) ), + PyFloat_AsDouble( PyList_GetItem(obj, 2) ) ); + self->sa->setAttributeVec3f( s, v ); + return 0; - PyObject *_wrap_StrokeAttribute_setAttributeVec2f(PyObject *self , PyObject *args) { + } + + return -1; } +/////////////////////////////////////////////////////////////////////////////////////////// - PyObject *_wrap_StrokeAttribute_setAttributeVec3f(PyObject *self , PyObject *args) { +#ifdef __cplusplus } - +#endif diff --git a/source/blender/freestyle/intern/python/StrokeAttribute.h b/source/blender/freestyle/intern/python/StrokeAttribute.h new file mode 100644 index 00000000000..a0828e4f668 --- /dev/null +++ b/source/blender/freestyle/intern/python/StrokeAttribute.h @@ -0,0 +1,34 @@ +#ifndef FREESTYLE_PYTHON_STROKEATTRIBUTE_H +#define FREESTYLE_PYTHON_STROKEATTRIBUTE_H + +#include "../stroke/Stroke.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/////////////////////////////////////////////////////////////////////////////////////////// + +#include <Python.h> + +extern PyTypeObject StrokeAttribute_Type; + +#define BPy_StrokeAttribute_Check(v) (( (PyObject *) v)->ob_type == &StrokeAttribute_Type) + +/*---------------------------Python BPy_StrokeAttribute structure definition----------*/ +typedef struct { + PyObject_HEAD + StrokeAttribute *sa; +} BPy_StrokeAttribute; + +/*---------------------------Python BPy_StrokeAttribute visible prototypes-----------*/ + +PyMODINIT_FUNC StrokeAttribute_Init( PyObject *module ); + +/////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif /* FREESTYLE_PYTHON_STROKEATTRIBUTE_H */ diff --git a/source/blender/freestyle/intern/python/UnaryFunction0D.h b/source/blender/freestyle/intern/python/UnaryFunction0D.h index 365b340d96c..8f1935871ca 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction0D.h +++ b/source/blender/freestyle/intern/python/UnaryFunction0D.h @@ -13,8 +13,7 @@ extern "C" { extern PyTypeObject UnaryFunction0D_Type; -#define BPy_UnaryFunction0D_Check(v) \ - ((v)->ob_type == &UnaryFunction0D_Type) +#define BPy_UnaryFunction0D_Check(v) (( (PyObject *) v)->ob_type == &UnaryFunction0D_Type) /*---------------------------Python BPy_UnaryFunction0D structure definition----------*/ typedef struct { diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D.h b/source/blender/freestyle/intern/python/UnaryFunction1D.h index 2ad187ca81d..4c509f50b85 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D.h +++ b/source/blender/freestyle/intern/python/UnaryFunction1D.h @@ -13,8 +13,7 @@ extern "C" { extern PyTypeObject UnaryFunction1D_Type; -#define BPy_UnaryFunction1D_Check(v) \ - ((v)->ob_type == &UnaryFunction1D_Type) +#define BPy_UnaryFunction1D_Check(v) (( (PyObject *) v)->ob_type == &UnaryFunction1D_Type) /*---------------------------Python BPy_UnaryFunction1D structure definition----------*/ typedef struct { diff --git a/source/blender/freestyle/intern/python/UnaryPredicate0D.h b/source/blender/freestyle/intern/python/UnaryPredicate0D.h index c8b9008380a..1f72ba5e86b 100644 --- a/source/blender/freestyle/intern/python/UnaryPredicate0D.h +++ b/source/blender/freestyle/intern/python/UnaryPredicate0D.h @@ -13,8 +13,7 @@ extern "C" { extern PyTypeObject UnaryPredicate0D_Type; -#define BPy_UnaryPredicate0D_Check(v) \ - ((v)->ob_type == &UnaryPredicate0D_Type) +#define BPy_UnaryPredicate0D_Check(v) (( (PyObject *) v)->ob_type == &UnaryPredicate0D_Type) /*---------------------------Python BPy_UnaryPredicate0D structure definition----------*/ typedef struct { diff --git a/source/blender/freestyle/intern/python/UnaryPredicate1D.h b/source/blender/freestyle/intern/python/UnaryPredicate1D.h index 8bb33782133..509d81f6937 100644 --- a/source/blender/freestyle/intern/python/UnaryPredicate1D.h +++ b/source/blender/freestyle/intern/python/UnaryPredicate1D.h @@ -13,8 +13,7 @@ extern "C" { extern PyTypeObject UnaryPredicate1D_Type; -#define BPy_UnaryPredicate1D_Check(v) \ - ((v)->ob_type == &UnaryPredicate1D_Type) +#define BPy_UnaryPredicate1D_Check(v) (( (PyObject *) v)->ob_type == &UnaryPredicate1D_Type) /*---------------------------Python BPy_UnaryPredicate1D structure definition----------*/ typedef struct { |