Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-01-28 00:17:49 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-01-28 00:17:49 +0400
commit156acd3370a4f9090dc1507f275bf2cb695ac371 (patch)
treef19c6234d4ddb2bbf193f49cda2b224fc62d64fb /source/blender
parent39f8b95443f5dc83a24fb2c85847ea45e018925e (diff)
Freestyle Python API improvements - part 1.
* The API syntax of StrokeVertex and StrokeAttribute was updated by means of getter/setter properties instead of class methods. Python style modules (including the Parameter Editor implementation) were updated accordingly. * Code clean-up was done for a few Python style modules, mostly by removing duplicated definitions of stroke shaders and fixing indentation.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/freestyle/intern/python/BPy_Convert.cpp62
-rw-r--r--source/blender/freestyle/intern/python/BPy_Convert.h2
-rw-r--r--source/blender/freestyle/intern/python/BPy_Interface0D.cpp2
-rw-r--r--source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp484
-rw-r--r--source/blender/freestyle/intern/python/BPy_StrokeAttribute.h1
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp343
-rw-r--r--source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.h4
7 files changed, 401 insertions, 497 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp
index 01567b18142..87f7c3a6beb 100644
--- a/source/blender/freestyle/intern/python/BPy_Convert.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp
@@ -483,6 +483,8 @@ Vec3f * Vec3f_ptr_from_PyObject( PyObject* obj ) {
Vec3f *v;
if( (v = Vec3f_ptr_from_Vector( obj )) )
return v;
+ if( (v = Vec3f_ptr_from_Color( obj )) )
+ return v;
if( (v = Vec3f_ptr_from_PyList( obj )) )
return v;
if( (v = Vec3f_ptr_from_PyTuple( obj )) )
@@ -494,6 +496,8 @@ Vec3r * Vec3r_ptr_from_PyObject( PyObject* obj ) {
Vec3r *v;
if( (v = Vec3r_ptr_from_Vector( obj )) )
return v;
+ if( (v = Vec3r_ptr_from_Color( obj )) )
+ return v;
if( (v = Vec3r_ptr_from_PyList( obj )) )
return v;
if( (v = Vec3r_ptr_from_PyTuple( obj )) )
@@ -502,53 +506,49 @@ Vec3r * Vec3r_ptr_from_PyObject( PyObject* obj ) {
}
Vec2f * Vec2f_ptr_from_Vector( PyObject* obj ) {
- PyObject *v;
if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 2)
return NULL;
- v = PyObject_GetAttrString(obj,"x");
- float x = PyFloat_AsDouble( v );
- Py_DECREF( v );
- v = PyObject_GetAttrString(obj,"y");
- float y = PyFloat_AsDouble( v );
- Py_DECREF( v );
-
- return new Vec2f(x,y);
+ float x = ((VectorObject *)obj)->vec[0];
+ float y = ((VectorObject *)obj)->vec[1];
+ return new Vec2f(x, y);
}
Vec3f * Vec3f_ptr_from_Vector( PyObject* obj ) {
- PyObject *v;
if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 3)
return NULL;
- v = PyObject_GetAttrString(obj,"x");
- float x = PyFloat_AsDouble( v );
- Py_DECREF( v );
- v = PyObject_GetAttrString(obj,"y");
- float y = PyFloat_AsDouble( v );
- Py_DECREF( v );
- v = PyObject_GetAttrString(obj,"z");
- float z = PyFloat_AsDouble( v );
- Py_DECREF( v );
-
+ float x = ((VectorObject *)obj)->vec[0];
+ float y = ((VectorObject *)obj)->vec[1];
+ float z = ((VectorObject *)obj)->vec[2];
return new Vec3f(x,y,z);
}
Vec3r * Vec3r_ptr_from_Vector( PyObject* obj ) {
- PyObject *v;
if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 3)
return NULL;
- v = PyObject_GetAttrString(obj,"x");
- double x = PyFloat_AsDouble( v );
- Py_DECREF( v );
- v = PyObject_GetAttrString(obj,"y");
- double y = PyFloat_AsDouble( v );
- Py_DECREF( v );
- v = PyObject_GetAttrString(obj,"z");
- double z = PyFloat_AsDouble( v );
- Py_DECREF( v );
-
+ real x = ((VectorObject *)obj)->vec[0];
+ real y = ((VectorObject *)obj)->vec[1];
+ real z = ((VectorObject *)obj)->vec[2];
return new Vec3r(x,y,z);
}
+Vec3f * Vec3f_ptr_from_Color( PyObject* obj ) {
+ if (!ColorObject_Check(obj))
+ return NULL;
+ float r = ((ColorObject *)obj)->col[0];
+ float g = ((ColorObject *)obj)->col[1];
+ float b = ((ColorObject *)obj)->col[2];
+ return new Vec3f(r,g,b);
+}
+
+Vec3r * Vec3r_ptr_from_Color( PyObject* obj ) {
+ if (!ColorObject_Check(obj))
+ return NULL;
+ real r = ((ColorObject *)obj)->col[0];
+ real g = ((ColorObject *)obj)->col[1];
+ real b = ((ColorObject *)obj)->col[2];
+ return new Vec3r(r,g,b);
+}
+
Vec2f * Vec2f_ptr_from_PyList( PyObject* obj ) {
if( !PyList_Check(obj) || PyList_Size(obj) != 2 )
return NULL;
diff --git a/source/blender/freestyle/intern/python/BPy_Convert.h b/source/blender/freestyle/intern/python/BPy_Convert.h
index ef5a64bde3f..178301262ff 100644
--- a/source/blender/freestyle/intern/python/BPy_Convert.h
+++ b/source/blender/freestyle/intern/python/BPy_Convert.h
@@ -128,6 +128,8 @@ Vec3r * Vec3r_ptr_from_PyObject( PyObject* obj );
Vec2f * Vec2f_ptr_from_Vector( PyObject* obj );
Vec3f * Vec3f_ptr_from_Vector( PyObject* obj );
Vec3r * Vec3r_ptr_from_Vector( PyObject* obj );
+Vec3f * Vec3f_ptr_from_Color( PyObject* obj );
+Vec3r * Vec3r_ptr_from_Color( PyObject* obj );
Vec2f * Vec2f_ptr_from_PyList( PyObject* obj );
Vec3f * Vec3f_ptr_from_PyList( PyObject* obj );
Vec3r * Vec3r_ptr_from_PyList( PyObject* obj );
diff --git a/source/blender/freestyle/intern/python/BPy_Interface0D.cpp b/source/blender/freestyle/intern/python/BPy_Interface0D.cpp
index 11af30439cf..be8b87cd1bc 100644
--- a/source/blender/freestyle/intern/python/BPy_Interface0D.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Interface0D.cpp
@@ -57,6 +57,8 @@ int Interface0D_Init( PyObject *module )
Py_INCREF( &TVertex_Type );
PyModule_AddObject(module, "TVertex", (PyObject *)&TVertex_Type);
+ StrokeVertex_mathutils_register_callback();
+
return 0;
}
diff --git a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
index 9e723d4236b..c1937bdf5f0 100644
--- a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
+++ b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.cpp
@@ -18,6 +18,8 @@ int StrokeAttribute_Init( PyObject *module )
return -1;
Py_INCREF( &StrokeAttribute_Type );
PyModule_AddObject(module, "StrokeAttribute", (PyObject *)&StrokeAttribute_Type);
+
+ StrokeAttribute_mathutils_register_callback();
return 0;
}
@@ -132,122 +134,6 @@ static PyObject * StrokeAttribute___repr__(BPy_StrokeAttribute* self)
return PyUnicode_FromString( repr.str().c_str() );
}
-
-static char StrokeAttribute_getColorR___doc__[] =
-".. method:: getColorR()\n"
-"\n"
-" Returns the red component of the stroke color.\n"
-"\n"
-" :return: Red component of the stroke color.\n"
-" :rtype: float\n";
-
-static PyObject *StrokeAttribute_getColorR( BPy_StrokeAttribute *self ) {
- return PyFloat_FromDouble( self->sa->getColorR() );
-}
-
-static char StrokeAttribute_getColorG___doc__[] =
-".. method:: getColorG()\n"
-"\n"
-" Returns the green component of the stroke color.\n"
-"\n"
-" :return: Green component of the stroke color.\n"
-" :rtype: float\n";
-
-static PyObject *StrokeAttribute_getColorG( BPy_StrokeAttribute *self ) {
- return PyFloat_FromDouble( self->sa->getColorG() );
-}
-
-static char StrokeAttribute_getColorB___doc__[] =
-".. method:: getColorB()\n"
-"\n"
-" Returns the blue component of the stroke color.\n"
-"\n"
-" :return: Blue component of the stroke color.\n"
-" :rtype: float\n";
-
-static PyObject *StrokeAttribute_getColorB( BPy_StrokeAttribute *self ) {
- return PyFloat_FromDouble( self->sa->getColorB() );
-}
-
-static char StrokeAttribute_getColorRGB___doc__[] =
-".. method:: getColorRGB()\n"
-"\n"
-" Returns the RGB components of the stroke color.\n"
-"\n"
-" :return: RGB components of the stroke color.\n"
-" :rtype: :class:`mathutils.Vector`\n";
-
-static PyObject *StrokeAttribute_getColorRGB( BPy_StrokeAttribute *self ) {
- Vec3f v( self->sa->getColorRGB() );
- return Vector_from_Vec3f( v );
-}
-
-static char StrokeAttribute_getAlpha___doc__[] =
-".. method:: getAlpha()\n"
-"\n"
-" Returns the alpha component of the stroke color.\n"
-"\n"
-" :return: Alpha component of the stroke color.\n"
-" :rtype: float\n";
-
-static PyObject *StrokeAttribute_getAlpha( BPy_StrokeAttribute *self ) {
- return PyFloat_FromDouble( self->sa->getAlpha() );
-}
-
-static char StrokeAttribute_getThicknessR___doc__[] =
-".. method:: getThicknessR()\n"
-"\n"
-" Returns the thickness on the right of the vertex when following\n"
-" the stroke.\n"
-"\n"
-" :return: The thickness on the right of the vertex.\n"
-" :rtype: float\n";
-
-static PyObject *StrokeAttribute_getThicknessR( BPy_StrokeAttribute *self ) {
- return PyFloat_FromDouble( self->sa->getThicknessR() );
-}
-
-static char StrokeAttribute_getThicknessL___doc__[] =
-".. method:: getThicknessL()\n"
-"\n"
-" Returns the thickness on the left of the vertex when following\n"
-" the stroke.\n"
-"\n"
-" :return: The thickness on the left of the vertex.\n"
-" :rtype: float\n";
-
-static PyObject *StrokeAttribute_getThicknessL( BPy_StrokeAttribute *self ) {
- return PyFloat_FromDouble( self->sa->getThicknessL() );
-}
-
-static char StrokeAttribute_getThicknessRL___doc__[] =
-".. method:: getThicknessRL()\n"
-"\n"
-" Returns the thickness on the right and on the left of the vertex\n"
-" when following the stroke.\n"
-"\n"
-" :return: A two-dimensional vector. The first value is the\n"
-" thickness on the right of the vertex when following the stroke,\n"
-" and the second one is the thickness on the left.\n"
-" :rtype: :class:`mathutils.Vector`\n";
-
-static PyObject *StrokeAttribute_getThicknessRL( BPy_StrokeAttribute *self ) {
- Vec2f v( self->sa->getThicknessRL() );
- return Vector_from_Vec2f( v );
-}
-
-static char StrokeAttribute_isVisible___doc__[] =
-".. method:: isVisible()\n"
-"\n"
-" Returns true if the StrokeVertex is visible, false otherwise.\n"
-"\n"
-" :return: True if the StrokeVertex is visible, false otherwise.\n"
-" :rtype: bool\n";
-
-static PyObject *StrokeAttribute_isVisible( BPy_StrokeAttribute *self ) {
- return PyBool_from_bool( self->sa->isVisible() );
-}
-
static char StrokeAttribute_getAttributeReal___doc__[] =
".. method:: getAttributeReal(iName)\n"
"\n"
@@ -367,142 +253,6 @@ static PyObject *StrokeAttribute_isAttributeAvailableVec3f( BPy_StrokeAttribute
return PyBool_from_bool( self->sa->isAttributeAvailableVec3f( attr ) );
}
-
-static char StrokeAttribute_setColor___doc__[] =
-".. method:: setColor(r, g, b)\n"
-"\n"
-" Sets the stroke color.\n"
-"\n"
-" :arg r: Red component of the stroke color.\n"
-" :type r: float\n"
-" :arg g: Green component of the stroke color.\n"
-" :type g: float\n"
-" :arg b: Blue component of the stroke color.\n"
-" :type b: float\n"
-"\n"
-".. method:: setColor(iRGB)\n"
-"\n"
-" Sets the stroke color.\n"
-"\n"
-" :arg iRGB: The new RGB values.\n"
-" :type iRGB: :class:`mathutils.Vector`, list or tuple of 3 real numbers\n";
-
-static PyObject * StrokeAttribute_setColor( BPy_StrokeAttribute *self, PyObject *args ) {
- PyObject *obj1 = 0, *obj2 = 0, *obj3 = 0 ;
-
- if(!( PyArg_ParseTuple(args, "O|OO", &obj1, &obj2, &obj3) ))
- return NULL;
-
- if( obj1 && !obj2 && !obj3 ){
-
- Vec3f *v = Vec3f_ptr_from_PyObject(obj1);
- if( !v ) {
- PyErr_SetString(PyExc_TypeError, "argument 1 must be a 3D vector (either a list of 3 elements or Vector)");
- return NULL;
- }
- self->sa->setColor( *v );
- delete v;
-
- } else if( obj1 && obj2 && obj3 ){
-
- self->sa->setColor( PyFloat_AsDouble(obj1),
- PyFloat_AsDouble(obj2),
- PyFloat_AsDouble(obj3) );
-
- } else {
- PyErr_SetString(PyExc_TypeError, "invalid arguments");
- return NULL;
- }
-
- Py_RETURN_NONE;
-}
-
-static char StrokeAttribute_setAlpha___doc__[] =
-".. method:: setAlpha(alpha)\n"
-"\n"
-" Sets the alpha component of the stroke color.\n"
-"\n"
-" :arg alpha: The new alpha value.\n"
-" :type alpha: float\n";
-
-static PyObject * StrokeAttribute_setAlpha( BPy_StrokeAttribute *self, PyObject *args ){
- float f = 0;
-
- if(!( PyArg_ParseTuple(args, "f", &f) ))
- return NULL;
-
- self->sa->setAlpha( f );
- Py_RETURN_NONE;
-}
-
-static char StrokeAttribute_setThickness___doc__[] =
-".. method:: setThickness(tr, tl)\n"
-"\n"
-" Sets the stroke thickness.\n"
-"\n"
-" :arg tr: The thickness on the right of the vertex when following\n"
-" the stroke.\n"
-" :type tr: float\n"
-" :arg tl: The thickness on the left of the vertex when following\n"
-" the stroke.\n"
-" :type tl: float\n"
-"\n"
-".. method:: setThickness(tRL)\n"
-"\n"
-" Sets the stroke thickness.\n"
-"\n"
-" :arg tRL: The thickness on the right and on the left of the vertex\n"
-" when following the stroke.\n"
-" :type tRL: :class:`mathutils.Vector`, list or tuple of 2 real numbers\n";
-
-static PyObject * StrokeAttribute_setThickness( BPy_StrokeAttribute *self, PyObject *args ) {
- PyObject *obj1 = 0, *obj2 = 0;
-
- if(!( PyArg_ParseTuple(args, "O|O", &obj1, &obj2) ))
- return NULL;
-
- if( obj1 && !obj2 ){
-
- Vec2f *v = Vec2f_ptr_from_PyObject(obj1);
- if( !v ) {
- PyErr_SetString(PyExc_TypeError, "argument 1 must be a 2D vector (either a list of 2 elements or Vector)");
- return NULL;
- }
- self->sa->setThickness( *v );
- delete v;
-
- } else if( obj1 && obj2 ){
-
- self->sa->setThickness( PyFloat_AsDouble(obj1),
- PyFloat_AsDouble(obj2) );
-
- } else {
- PyErr_SetString(PyExc_TypeError, "invalid arguments");
- return NULL;
- }
-
- Py_RETURN_NONE;
-}
-
-static char StrokeAttribute_setVisible___doc__[] =
-".. method:: setVisible(iVisible)\n"
-"\n"
-" Sets the visibility flag. True means the StrokeVertex is visible.\n"
-"\n"
-" :arg iVisible: True if the StrokeVertex is visible.\n"
-" :type iVisible: bool\n";
-
-static PyObject * StrokeAttribute_setVisible( BPy_StrokeAttribute *self, PyObject *args ) {
- PyObject *py_b;
-
- if(!( PyArg_ParseTuple(args, "O", &py_b) ))
- return NULL;
-
- self->sa->setVisible( bool_from_PyBool(py_b) );
-
- Py_RETURN_NONE;
-}
-
static char StrokeAttribute_setAttributeReal___doc__[] =
".. method:: setAttributeReal(iName, att)\n"
"\n"
@@ -586,31 +336,233 @@ static PyObject * StrokeAttribute_setAttributeVec3f( BPy_StrokeAttribute *self,
/*----------------------StrokeAttribute instance definitions ----------------------------*/
static PyMethodDef BPy_StrokeAttribute_methods[] = {
- {"getColorR", ( PyCFunction ) StrokeAttribute_getColorR, METH_NOARGS, StrokeAttribute_getColorR___doc__},
- {"getColorG", ( PyCFunction ) StrokeAttribute_getColorG, METH_NOARGS, StrokeAttribute_getColorG___doc__},
- {"getColorB", ( PyCFunction ) StrokeAttribute_getColorB, METH_NOARGS, StrokeAttribute_getColorB___doc__},
- {"getColorRGB", ( PyCFunction ) StrokeAttribute_getColorRGB, METH_NOARGS, StrokeAttribute_getColorRGB___doc__},
- {"getAlpha", ( PyCFunction ) StrokeAttribute_getAlpha, METH_NOARGS, StrokeAttribute_getAlpha___doc__},
- {"getThicknessR", ( PyCFunction ) StrokeAttribute_getThicknessR, METH_NOARGS, StrokeAttribute_getThicknessR___doc__},
- {"getThicknessL", ( PyCFunction ) StrokeAttribute_getThicknessL, METH_NOARGS, StrokeAttribute_getThicknessL___doc__},
- {"getThicknessRL", ( PyCFunction ) StrokeAttribute_getThicknessRL, METH_NOARGS, StrokeAttribute_getThicknessRL___doc__},
- {"isVisible", ( PyCFunction ) StrokeAttribute_isVisible, METH_NOARGS, StrokeAttribute_isVisible___doc__},
{"getAttributeReal", ( PyCFunction ) StrokeAttribute_getAttributeReal, METH_VARARGS, StrokeAttribute_getAttributeReal___doc__},
{"getAttributeVec2f", ( PyCFunction ) StrokeAttribute_getAttributeVec2f, METH_VARARGS, StrokeAttribute_getAttributeVec2f___doc__},
{"getAttributeVec3f", ( PyCFunction ) StrokeAttribute_getAttributeVec3f, METH_VARARGS, StrokeAttribute_getAttributeVec3f___doc__},
{"isAttributeAvailableReal", ( PyCFunction ) StrokeAttribute_isAttributeAvailableReal, METH_VARARGS, StrokeAttribute_isAttributeAvailableReal___doc__},
{"isAttributeAvailableVec2f", ( PyCFunction ) StrokeAttribute_isAttributeAvailableVec2f, METH_VARARGS, StrokeAttribute_isAttributeAvailableVec2f___doc__},
{"isAttributeAvailableVec3f", ( PyCFunction ) StrokeAttribute_isAttributeAvailableVec3f, METH_VARARGS, StrokeAttribute_isAttributeAvailableVec3f___doc__},
- {"setColor", ( PyCFunction ) StrokeAttribute_setColor, METH_VARARGS, StrokeAttribute_setColor___doc__},
- {"setAlpha", ( PyCFunction ) StrokeAttribute_setAlpha, METH_VARARGS, StrokeAttribute_setAlpha___doc__},
- {"setThickness", ( PyCFunction ) StrokeAttribute_setThickness, METH_VARARGS, StrokeAttribute_setThickness___doc__},
- {"setVisible", ( PyCFunction ) StrokeAttribute_setVisible, METH_VARARGS, StrokeAttribute_setVisible___doc__},
{"setAttributeReal", ( PyCFunction ) StrokeAttribute_setAttributeReal, METH_VARARGS, StrokeAttribute_setAttributeReal___doc__},
{"setAttributeVec2f", ( PyCFunction ) StrokeAttribute_setAttributeVec2f, METH_VARARGS, StrokeAttribute_setAttributeVec2f___doc__},
{"setAttributeVec3f", ( PyCFunction ) StrokeAttribute_setAttributeVec3f, METH_VARARGS, StrokeAttribute_setAttributeVec3f___doc__},
{NULL, NULL, 0, NULL}
};
+/*----------------------mathutils callbacks ----------------------------*/
+
+/* subtype */
+#define MATHUTILS_SUBTYPE_COLOR 1
+#define MATHUTILS_SUBTYPE_THICKNESS 2
+
+static int StrokeAttribute_mathutils_check(BaseMathObject *bmo)
+{
+ if (!BPy_StrokeAttribute_Check(bmo->cb_user))
+ return -1;
+ return 0;
+}
+
+static int StrokeAttribute_mathutils_get(BaseMathObject *bmo, int subtype)
+{
+ BPy_StrokeAttribute *self = (BPy_StrokeAttribute *)bmo->cb_user;
+ switch (subtype) {
+ case MATHUTILS_SUBTYPE_COLOR:
+ bmo->data[0] = self->sa->getColorR();
+ bmo->data[1] = self->sa->getColorG();
+ bmo->data[2] = self->sa->getColorB();
+ break;
+ case MATHUTILS_SUBTYPE_THICKNESS:
+ bmo->data[0] = self->sa->getThicknessR();
+ bmo->data[1] = self->sa->getThicknessL();
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+static int StrokeAttribute_mathutils_set(BaseMathObject *bmo, int subtype)
+{
+ BPy_StrokeAttribute *self = (BPy_StrokeAttribute *)bmo->cb_user;
+ switch (subtype) {
+ case MATHUTILS_SUBTYPE_COLOR:
+ self->sa->setColor(bmo->data[0], bmo->data[1], bmo->data[1]);
+ break;
+ case MATHUTILS_SUBTYPE_THICKNESS:
+ self->sa->setThickness(bmo->data[0], bmo->data[1]);
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+static int StrokeAttribute_mathutils_get_index(BaseMathObject *bmo, int subtype, int index)
+{
+ BPy_StrokeAttribute *self = (BPy_StrokeAttribute *)bmo->cb_user;
+ switch (subtype) {
+ case MATHUTILS_SUBTYPE_COLOR:
+ switch (index) {
+ case 0: bmo->data[0] = self->sa->getColorR(); break;
+ case 1: bmo->data[1] = self->sa->getColorG(); break;
+ case 2: bmo->data[2] = self->sa->getColorB(); break;
+ default:
+ return -1;
+ }
+ break;
+ case MATHUTILS_SUBTYPE_THICKNESS:
+ switch (index) {
+ case 0: bmo->data[0] = self->sa->getThicknessR(); break;
+ case 1: bmo->data[1] = self->sa->getThicknessL(); break;
+ default:
+ return -1;
+ }
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+static int StrokeAttribute_mathutils_set_index(BaseMathObject *bmo, int subtype, int index)
+{
+ BPy_StrokeAttribute *self = (BPy_StrokeAttribute *)bmo->cb_user;
+ switch (subtype) {
+ case MATHUTILS_SUBTYPE_COLOR:
+ {
+ float r = (index == 0) ? bmo->data[0] : self->sa->getColorR();
+ float g = (index == 1) ? bmo->data[1] : self->sa->getColorG();
+ float b = (index == 2) ? bmo->data[2] : self->sa->getColorB();
+ self->sa->setColor(r, g, b);
+ }
+ break;
+ case MATHUTILS_SUBTYPE_THICKNESS:
+ {
+ float tr = (index == 0) ? bmo->data[0] : self->sa->getThicknessR();
+ float tl = (index == 1) ? bmo->data[1] : self->sa->getThicknessL();
+ self->sa->setThickness(tr, tl);
+ }
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+static Mathutils_Callback StrokeAttribute_mathutils_cb = {
+ StrokeAttribute_mathutils_check,
+ StrokeAttribute_mathutils_get,
+ StrokeAttribute_mathutils_set,
+ StrokeAttribute_mathutils_get_index,
+ StrokeAttribute_mathutils_set_index
+};
+
+static unsigned char StrokeAttribute_mathutils_cb_index = -1;
+
+void StrokeAttribute_mathutils_register_callback()
+{
+ StrokeAttribute_mathutils_cb_index = Mathutils_RegisterCallback(&StrokeAttribute_mathutils_cb);
+}
+
+/*----------------------StrokeAttribute get/setters ----------------------------*/
+
+PyDoc_STRVAR(StrokeAttribute_alpha_doc,
+"Alpha component of the stroke color.\n"
+"\n"
+":type: float"
+);
+
+static PyObject *StrokeAttribute_alpha_get(BPy_StrokeAttribute *self, void *UNUSED(closure))
+{
+ return PyFloat_FromDouble(self->sa->getAlpha());
+}
+
+static int StrokeAttribute_alpha_set(BPy_StrokeAttribute *self, PyObject *value, void *UNUSED(closure))
+{
+ float scalar;
+ if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */
+ PyErr_SetString(PyExc_TypeError, "value must be a number");
+ return -1;
+ }
+ self->sa->setAlpha(scalar);
+ return 0;
+}
+
+PyDoc_STRVAR(StrokeAttribute_color_doc,
+"RGB components of the stroke color.\n"
+"\n"
+":type: mathutils.Color"
+);
+
+static PyObject *StrokeAttribute_color_get(BPy_StrokeAttribute *self, void *UNUSED(closure))
+{
+ return Color_CreatePyObject_cb((PyObject *)self, StrokeAttribute_mathutils_cb_index, MATHUTILS_SUBTYPE_COLOR);
+}
+
+static int StrokeAttribute_color_set(BPy_StrokeAttribute *self, PyObject *value, void *UNUSED(closure))
+{
+ Vec3f *v = Vec3f_ptr_from_PyObject(value);
+ if (!v) {
+ PyErr_SetString(PyExc_ValueError, "value must be a 3-dimensional vector");
+ return -1;
+ }
+ self->sa->setColor(v->x(), v->y(), v->z());
+ return 0;
+}
+
+PyDoc_STRVAR(StrokeAttribute_thickness_doc,
+"Right and left components of the stroke thickness.\n"
+"The right (left) component is the thickness on the right (left) of the vertex\n"
+"when following the stroke.\n"
+"\n"
+":type: mathutils.Vector"
+);
+
+static PyObject *StrokeAttribute_thickness_get(BPy_StrokeAttribute *self, void *UNUSED(closure))
+{
+ return Vector_CreatePyObject_cb((PyObject *)self, 2, StrokeAttribute_mathutils_cb_index, MATHUTILS_SUBTYPE_THICKNESS);
+}
+
+static int StrokeAttribute_thickness_set(BPy_StrokeAttribute *self, PyObject *value, void *UNUSED(closure))
+{
+ Vec2f *v = Vec2f_ptr_from_PyObject(value);
+ if (!v) {
+ PyErr_SetString(PyExc_ValueError, "value must be a 2-dimensional vector");
+ return -1;
+ }
+ self->sa->setThickness(v->x(), v->y());
+ return 0;
+}
+
+PyDoc_STRVAR(StrokeAttribute_visible_doc,
+"visible component of the stroke color.\n"
+"\n"
+":type: float"
+);
+
+static PyObject *StrokeAttribute_visible_get(BPy_StrokeAttribute *self, void *UNUSED(closure))
+{
+ return PyBool_from_bool(self->sa->isVisible());
+}
+
+static int StrokeAttribute_visible_set(BPy_StrokeAttribute *self, PyObject *value, void *UNUSED(closure))
+{
+ float scalar;
+ if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */
+ PyErr_SetString(PyExc_TypeError, "value must be a number");
+ return -1;
+ }
+ self->sa->setVisible(scalar);
+ return 0;
+}
+
+static PyGetSetDef BPy_StrokeAttribute_getseters[] = {
+ {(char *)"alpha", (getter)StrokeAttribute_alpha_get, (setter)StrokeAttribute_alpha_set, (char *)StrokeAttribute_alpha_doc, NULL},
+ {(char *)"color", (getter)StrokeAttribute_color_get, (setter)StrokeAttribute_color_set, (char *)StrokeAttribute_color_doc, NULL},
+ {(char *)"thickness", (getter)StrokeAttribute_thickness_get, (setter)StrokeAttribute_thickness_set, (char *)StrokeAttribute_thickness_doc, NULL},
+ {(char *)"visible", (getter)StrokeAttribute_visible_get, (setter)StrokeAttribute_visible_set, (char *)StrokeAttribute_visible_doc, NULL},
+ {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+};
+
/*-----------------------BPy_StrokeAttribute type definition ------------------------------*/
PyTypeObject StrokeAttribute_Type = {
@@ -643,7 +595,7 @@ PyTypeObject StrokeAttribute_Type = {
0, /* tp_iternext */
BPy_StrokeAttribute_methods, /* tp_methods */
0, /* tp_members */
- 0, /* tp_getset */
+ BPy_StrokeAttribute_getseters, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
diff --git a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h
index 51e18c0a96f..c108ed7bf04 100644
--- a/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h
+++ b/source/blender/freestyle/intern/python/BPy_StrokeAttribute.h
@@ -25,6 +25,7 @@ typedef struct {
/*---------------------------Python BPy_StrokeAttribute visible prototypes-----------*/
int StrokeAttribute_Init( PyObject *module );
+void StrokeAttribute_mathutils_register_callback();
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp
index 80b9defd95e..3d7a29a540d 100644
--- a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp
+++ b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp
@@ -1,5 +1,6 @@
#include "BPy_StrokeVertex.h"
+#include "../../BPy_Freestyle.h"
#include "../../BPy_Convert.h"
#include "../../BPy_StrokeAttribute.h"
#include "../../Interface0D/BPy_SVertex.h"
@@ -8,6 +9,8 @@
extern "C" {
#endif
+#include "../../../python/mathutils/mathutils.h" /* for Vector callbacks */
+
///////////////////////////////////////////////////////////////////////////////////////////
//------------------------INSTANCE METHODS ----------------------------------
@@ -108,247 +111,187 @@ static int StrokeVertex___init__(BPy_StrokeVertex *self, PyObject *args, PyObjec
return 0;
}
-static char StrokeVertex_x___doc__[] =
-".. method:: x()\n"
-"\n"
-" Returns the 2D point X coordinate.\n"
-"\n"
-" :return: The X coordinate.\n"
-" :rtype: float\n";
-
-static PyObject * StrokeVertex_x( BPy_StrokeVertex *self ) {
- return PyFloat_FromDouble( self->sv->x() );
-}
-
-static char StrokeVertex_y___doc__[] =
-".. method:: y()\n"
-"\n"
-" Returns the 2D point Y coordinate.\n"
-"\n"
-" :return: The Y coordinate.\n"
-" :rtype: float\n";
+// real operator[] (const int i) const
+// real & operator[] (const int i)
-static PyObject * StrokeVertex_y( BPy_StrokeVertex *self ) {
- return PyFloat_FromDouble( self->sv->y() );
-}
+/*----------------------StrokeVertex instance definitions ----------------------------*/
+static PyMethodDef BPy_StrokeVertex_methods[] = {
+ {NULL, NULL, 0, NULL}
+};
-static char StrokeVertex_getPoint___doc__[] =
-".. method:: getPoint()\n"
-"\n"
-" Returns the 2D point coordinates as a two-dimensional vector.\n"
-"\n"
-" :return: The 2D coordinates.\n"
-" :rtype: :class:`mathutils.Vector`\n";
+/*----------------------mathutils callbacks ----------------------------*/
-static PyObject * StrokeVertex_getPoint( BPy_StrokeVertex *self ) {
- Vec2f v( self->sv->getPoint() );
- return Vector_from_Vec2f( v );
+static int StrokeVertex_mathutils_check(BaseMathObject *bmo)
+{
+ if (!BPy_StrokeVertex_Check(bmo->cb_user))
+ return -1;
+ return 0;
}
-static char StrokeVertex_attribute___doc__[] =
-".. method:: attribute()\n"
-"\n"
-" Returns the StrokeAttribute for this StrokeVertex.\n"
-"\n"
-" :return: The StrokeAttribute object.\n"
-" :rtype: :class:`StrokeAttribute`\n";
-
-static PyObject * StrokeVertex_attribute( BPy_StrokeVertex *self ) {
- return BPy_StrokeAttribute_from_StrokeAttribute( self->sv->attribute() );
+static int StrokeVertex_mathutils_get(BaseMathObject *bmo, int subtype)
+{
+ BPy_StrokeVertex *self = (BPy_StrokeVertex *)bmo->cb_user;
+ bmo->data[0] = (float)self->sv->x();
+ bmo->data[1] = (float)self->sv->y();
+ return 0;
}
-static char StrokeVertex_curvilinearAbscissa___doc__[] =
-".. method:: curvilinearAbscissa()\n"
-"\n"
-" Returns the curvilinear abscissa.\n"
-"\n"
-" :return: The curvilinear abscissa.\n"
-" :rtype: float\n";
-
-static PyObject * StrokeVertex_curvilinearAbscissa( BPy_StrokeVertex *self ) {
- return PyFloat_FromDouble( self->sv->curvilinearAbscissa() );
+static int StrokeVertex_mathutils_set(BaseMathObject *bmo, int subtype)
+{
+ BPy_StrokeVertex *self = (BPy_StrokeVertex *)bmo->cb_user;
+ self->sv->setX((real)bmo->data[0]);
+ self->sv->setY((real)bmo->data[1]);
+ return 0;
}
-static char StrokeVertex_strokeLength___doc__[] =
-".. method:: strokeLength()\n"
-"\n"
-" Returns the length of the Stroke to which this StrokeVertex belongs\n"
-"\n"
-" :return: The stroke length.\n"
-" :rtype: float\n";
-
-static PyObject * StrokeVertex_strokeLength( BPy_StrokeVertex *self ) {
- return PyFloat_FromDouble( self->sv->strokeLength() );
+static int StrokeVertex_mathutils_get_index(BaseMathObject *bmo, int subtype, int index)
+{
+ BPy_StrokeVertex *self = (BPy_StrokeVertex *)bmo->cb_user;
+ switch (index) {
+ case 0: bmo->data[0] = (float)self->sv->x(); break;
+ case 1: bmo->data[1] = (float)self->sv->y(); break;
+ default:
+ return -1;
+ }
+ return 0;
}
-static char StrokeVertex_u___doc__[] =
-".. method:: u()\n"
-"\n"
-" Returns the curvilinear abscissa of this StrokeVertex in the Stroke\n"
-"\n"
-" :return: The curvilinear abscissa.\n"
-" :rtype: float\n";
-
-static PyObject * StrokeVertex_u( BPy_StrokeVertex *self ) {
- return PyFloat_FromDouble( self->sv->u() );
+static int StrokeVertex_mathutils_set_index(BaseMathObject *bmo, int subtype, int index)
+{
+ BPy_StrokeVertex *self = (BPy_StrokeVertex *)bmo->cb_user;
+ switch (index) {
+ case 0: self->sv->setX((real)bmo->data[0]); break;
+ case 1: self->sv->setY((real)bmo->data[1]); break;
+ default:
+ return -1;
+ }
+ return 0;
}
-static char StrokeVertex_setX___doc__[] =
-".. method:: setX(x)\n"
-"\n"
-" Sets the 2D point X coordinate.\n"
-"\n"
-" :arg x: The X coordinate.\n"
-" :type x: float\n";
-
-static PyObject *StrokeVertex_setX( BPy_StrokeVertex *self , PyObject *args) {
- double r;
-
- if(!( PyArg_ParseTuple(args, "d", &r) ))
- return NULL;
+static Mathutils_Callback StrokeVertex_mathutils_cb = {
+ StrokeVertex_mathutils_check,
+ StrokeVertex_mathutils_get,
+ StrokeVertex_mathutils_set,
+ StrokeVertex_mathutils_get_index,
+ StrokeVertex_mathutils_set_index
+};
- self->sv->setX( r );
+static unsigned char StrokeVertex_mathutils_cb_index = -1;
- Py_RETURN_NONE;
+void StrokeVertex_mathutils_register_callback()
+{
+ StrokeVertex_mathutils_cb_index = Mathutils_RegisterCallback(&StrokeVertex_mathutils_cb);
}
-static char StrokeVertex_setY___doc__[] =
-".. method:: setY(y)\n"
-"\n"
-" Sets the 2D point Y coordinate.\n"
-"\n"
-" :arg y: The Y coordinate.\n"
-" :type y: float\n";
-
-static PyObject *StrokeVertex_setY( BPy_StrokeVertex *self , PyObject *args) {
- double r;
+/*----------------------StrokeVertex get/setters ----------------------------*/
- if(!( PyArg_ParseTuple(args, "d", &r) ))
- return NULL;
+PyDoc_STRVAR(StrokeVertex_attribute_doc,
+"StrokeAttribute for this StrokeVertex.\n"
+"\n"
+":type: StrokeAttribute"
+);
- self->sv->setY( r );
+static PyObject *StrokeVertex_attribute_get(BPy_StrokeVertex *self, void *UNUSED(closure))
+{
+ return BPy_StrokeAttribute_from_StrokeAttribute(self->sv->attribute());
+}
- Py_RETURN_NONE;
+static int StrokeVertex_attribute_set(BPy_StrokeVertex *self, PyObject *value, void *UNUSED(closure))
+{
+ if (!BPy_StrokeAttribute_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "value must be a StrokeAttribute object");
+ return -1;
+ }
+ self->sv->setAttribute(*(((BPy_StrokeAttribute *)value)->sa));
+ return 0;
}
-static char StrokeVertex_setPoint___doc__[] =
-".. method:: setPoint(x, y)\n"
-"\n"
-" Sets the 2D point X and Y coordinates.\n"
-"\n"
-" :arg x: The X coordinate.\n"
-" :type x: float\n"
-" :arg y: The Y coordinate.\n"
-" :type y: float\n"
+PyDoc_STRVAR(StrokeVertex_curvilinear_abscissa_doc,
+"Curvilinear abscissa of this StrokeVertex in the Stroke.\n"
"\n"
-".. method:: setPoint(p)\n"
-"\n"
-" Sets the 2D point X and Y coordinates.\n"
-"\n"
-" :arg p: A two-dimensional vector.\n"
-" :type p: :class:`mathutils.Vector`, list or tuple of 2 real numbers\n";
+":type: float"
+);
-static PyObject *StrokeVertex_setPoint( BPy_StrokeVertex *self , PyObject *args) {
- PyObject *obj1 = 0, *obj2 = 0;
+static PyObject *StrokeVertex_curvilinear_abscissa_get(BPy_StrokeVertex *self, void *UNUSED(closure))
+{
+ return PyFloat_FromDouble(self->sv->curvilinearAbscissa());
+}
- if(!( PyArg_ParseTuple(args, "O|O", &obj1, &obj2) ))
- return NULL;
-
- if( obj1 && !obj2 ){
- Vec2f *v = Vec2f_ptr_from_PyObject(obj1);
- if( !v ) {
- PyErr_SetString(PyExc_TypeError, "argument 1 must be a 2D vector (either a list of 2 elements or Vector)");
- return NULL;
- }
- self->sv->setPoint( *v );
- delete v;
- } else if( PyFloat_Check(obj1) && obj2 && PyFloat_Check(obj2) ){
- self->sv->setPoint( PyFloat_AsDouble(obj1), PyFloat_AsDouble(obj2) );
- } else {
- PyErr_SetString(PyExc_TypeError, "invalid arguments");
- return NULL;
+static int StrokeVertex_curvilinear_abscissa_set(BPy_StrokeVertex *self, PyObject *value, void *UNUSED(closure))
+{
+ float scalar;
+ if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */
+ PyErr_SetString(PyExc_TypeError, "value must be a number");
+ return -1;
}
-
- Py_RETURN_NONE;
+ self->sv->setCurvilinearAbscissa(scalar);
+ return 0;
}
-static char StrokeVertex_setAttribute___doc__[] =
-".. method:: setAttribute(iAttribute)\n"
-"\n"
-" Sets the attribute.\n"
+PyDoc_STRVAR(StrokeVertex_point_doc,
+"2D point coordinates.\n"
"\n"
-" :arg iAttribute: A StrokeAttribute object.\n"
-" :type iAttribute: :class:`StrokeAttribute`\n";
-
-static PyObject *StrokeVertex_setAttribute( BPy_StrokeVertex *self , PyObject *args) {
- PyObject *py_sa;
-
- if(!( PyArg_ParseTuple(args, "O!", &StrokeAttribute_Type, &py_sa) ))
- return NULL;
+":type: mathutils.Vector"
+);
- self->sv->setAttribute(*( ((BPy_StrokeAttribute *) py_sa)->sa ));
+static PyObject *StrokeVertex_point_get(BPy_StrokeVertex *self, void *UNUSED(closure))
+{
+ return Vector_CreatePyObject_cb((PyObject *)self, 2, StrokeVertex_mathutils_cb_index, 0);
+}
- Py_RETURN_NONE;
+static int StrokeVertex_point_set(BPy_StrokeVertex *self, PyObject *value, void *UNUSED(closure))
+{
+ Vec2f *v = Vec2f_ptr_from_PyObject(value);
+ if (!v) {
+ PyErr_SetString(PyExc_ValueError, "value must be a 2-dimensional vector");
+ return -1;
+ }
+ self->sv->setX(v->x());
+ self->sv->setY(v->y());
+ return 0;
}
-static char StrokeVertex_setCurvilinearAbscissa___doc__[] =
-".. method:: setCurvilinearAbscissa(iAbscissa)\n"
-"\n"
-" Sets the curvilinear abscissa of this StrokeVertex in the Stroke\n"
+PyDoc_STRVAR(StrokeVertex_stroke_length_doc,
+"Stroke length (it is only a value retained by the StrokeVertex,\n"
+"and it won't change the real stroke length).\n"
"\n"
-" :arg iAbscissa: The curvilinear abscissa.\n"
-" :type iAbscissa: float\n";
+":type: float"
+);
-static PyObject *StrokeVertex_setCurvilinearAbscissa( BPy_StrokeVertex *self , PyObject *args) {
- double r;
-
- if(!( PyArg_ParseTuple(args, "d", &r) ))
- return NULL;
-
- self->sv->setCurvilinearAbscissa( r );
+static PyObject *StrokeVertex_stroke_length_get(BPy_StrokeVertex *self, void *UNUSED(closure))
+{
+ return PyFloat_FromDouble(self->sv->strokeLength());
+}
- Py_RETURN_NONE;
+static int StrokeVertex_stroke_length_set(BPy_StrokeVertex *self, PyObject *value, void *UNUSED(closure))
+{
+ float scalar;
+ if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */
+ PyErr_SetString(PyExc_TypeError, "value must be a number");
+ return -1;
+ }
+ self->sv->setStrokeLength(scalar);
+ return 0;
}
-static char StrokeVertex_setStrokeLength___doc__[] =
-".. method:: setStrokeLength(iLength)\n"
+PyDoc_STRVAR(StrokeVertex_u_doc,
+"Curvilinear abscissa of this StrokeVertex in the Stroke.\n"
"\n"
-" Sets the stroke length (it is only a value retained by the\n"
-" StrokeVertex, and it won't change the real stroke length).\n"
-"\n"
-" :arg iLength: The stroke length.\n"
-" :type iLength: float\n";
-
-static PyObject *StrokeVertex_setStrokeLength( BPy_StrokeVertex *self , PyObject *args) {
- double r;
+":type: float"
+);
- if(!( PyArg_ParseTuple(args, "d", &r) ))
- return NULL;
-
- self->sv->setStrokeLength( r );
-
- Py_RETURN_NONE;
+static PyObject *StrokeVertex_u_get(BPy_StrokeVertex *self, void *UNUSED(closure))
+{
+ return PyFloat_FromDouble(self->sv->u());
}
-// real operator[] (const int i) const
-// real & operator[] (const int i)
-
-/*----------------------StrokeVertex instance definitions ----------------------------*/
-static PyMethodDef BPy_StrokeVertex_methods[] = {
- {"x", ( PyCFunction ) StrokeVertex_x, METH_NOARGS, StrokeVertex_x___doc__},
- {"y", ( PyCFunction ) StrokeVertex_y, METH_NOARGS, StrokeVertex_y___doc__},
- {"getPoint", ( PyCFunction ) StrokeVertex_getPoint, METH_NOARGS, StrokeVertex_getPoint___doc__},
- {"attribute", ( PyCFunction ) StrokeVertex_attribute, METH_NOARGS, StrokeVertex_attribute___doc__},
- {"curvilinearAbscissa", ( PyCFunction ) StrokeVertex_curvilinearAbscissa, METH_NOARGS, StrokeVertex_curvilinearAbscissa___doc__},
- {"strokeLength", ( PyCFunction ) StrokeVertex_strokeLength, METH_NOARGS, StrokeVertex_strokeLength___doc__},
- {"u", ( PyCFunction ) StrokeVertex_u, METH_NOARGS, StrokeVertex_u___doc__},
- {"setX", ( PyCFunction ) StrokeVertex_setX, METH_VARARGS, StrokeVertex_setX___doc__},
- {"setY", ( PyCFunction ) StrokeVertex_setY, METH_VARARGS, StrokeVertex_setY___doc__},
- {"setPoint", ( PyCFunction ) StrokeVertex_setPoint, METH_VARARGS, StrokeVertex_setPoint___doc__},
- {"setAttribute", ( PyCFunction ) StrokeVertex_setAttribute, METH_VARARGS, StrokeVertex_setAttribute___doc__},
- {"setCurvilinearAbscissa", ( PyCFunction ) StrokeVertex_setCurvilinearAbscissa, METH_VARARGS, StrokeVertex_setCurvilinearAbscissa___doc__},
- {"setStrokeLength", ( PyCFunction ) StrokeVertex_setStrokeLength, METH_VARARGS, StrokeVertex_setStrokeLength___doc__},
- {NULL, NULL, 0, NULL}
+static PyGetSetDef BPy_StrokeVertex_getseters[] = {
+ {(char *)"attribute", (getter)StrokeVertex_attribute_get, (setter)StrokeVertex_attribute_set, (char *)StrokeVertex_attribute_doc, NULL},
+ {(char *)"curvilinear_abscissa", (getter)StrokeVertex_curvilinear_abscissa_get, (setter)StrokeVertex_curvilinear_abscissa_set, (char *)StrokeVertex_curvilinear_abscissa_doc, NULL},
+ {(char *)"point", (getter)StrokeVertex_point_get, (setter)StrokeVertex_point_set, (char *)StrokeVertex_point_doc, NULL},
+ {(char *)"stroke_length", (getter)StrokeVertex_stroke_length_get, (setter)StrokeVertex_stroke_length_set, (char *)StrokeVertex_stroke_length_doc, NULL},
+ {(char *)"u", (getter)StrokeVertex_u_get, (setter)NULL, (char *)StrokeVertex_u_doc, NULL},
+ {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};
/*-----------------------BPy_StrokeVertex type definition ------------------------------*/
@@ -382,7 +325,7 @@ PyTypeObject StrokeVertex_Type = {
0, /* tp_iternext */
BPy_StrokeVertex_methods, /* tp_methods */
0, /* tp_members */
- 0, /* tp_getset */
+ BPy_StrokeVertex_getseters, /* tp_getset */
&CurvePoint_Type, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
diff --git a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.h b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.h
index 2a84e2480f0..a1cf3e80662 100644
--- a/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.h
+++ b/source/blender/freestyle/intern/python/Interface0D/CurvePoint/BPy_StrokeVertex.h
@@ -22,6 +22,10 @@ typedef struct {
StrokeVertex *sv;
} BPy_StrokeVertex;
+/*---------------------------Python BPy_StrokeVertex visible prototypes-----------*/
+
+void StrokeVertex_mathutils_register_callback();
+
///////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus