[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54771] branches/soc-2008-mxcurioni: Freestyle Python API improvements - part 7.
Tamito Kajiyama
rd6t-kjym at asahi-net.or.jp
Sat Feb 23 02:12:25 CET 2013
Revision: 54771
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54771
Author: kjym3
Date: 2013-02-23 01:12:23 +0000 (Sat, 23 Feb 2013)
Log Message:
-----------
Freestyle Python API improvements - part 7.
Fix for PyGetSetDef and proper handling of keyword arguments were done in
UnaryPredicate0D, UnaryPredicate1D, BinaryPredicate1D, and StrokeShader classes.
Style modules were updated accordingly. Additional code clean-up was also made.
Modified Paths:
--------------
branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/anisotropic_diffusion.py
branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/curvature2d.py
branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/sketchy_multiple_parameterization.py
branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/sketchy_topology_broken.py
branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/sketchy_topology_preserved.py
branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/stroke_texture.py
branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/uniformpruning_zsort.py
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_BinaryPredicate1D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_StrokeShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_UnaryPredicate0D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_UnaryPredicate1D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_FalseBP1D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_Length2DBP1D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_SameShapeIdBP1D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_TrueBP1D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BinaryPredicate1D/BPy_ViewMapGradientNormBP1D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_BackboneStretcherShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_BezierCurveShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorNoiseShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_ColorVariationPatternShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantColorShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstantThicknessShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_ConstrainedIncreasingThicknessShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_GuidingLinesShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingColorShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_IncreasingThicknessShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_PolygonalizationShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_SamplingShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_SmoothingShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_SpatialNoiseShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_StrokeTextureShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_TextureAssignerShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessNoiseShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_ThicknessVariationPatternShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_TipRemoverShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_fstreamShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/StrokeShader/BPy_streamShader.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_FalseUP0D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryPredicate0D/BPy_TrueUP0D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ContourUP1D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_DensityLowerThanUP1D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToChainingTimeStampUP1D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_EqualToTimeStampUP1D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ExternalContourUP1D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_FalseUP1D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_QuantitativeInvisibilityUP1D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_ShapeUP1D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_TrueUP1D.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryPredicate1D/BPy_WithinImageBoundaryUP1D.cpp
Modified: branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/anisotropic_diffusion.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/anisotropic_diffusion.py 2013-02-23 00:52:59 UTC (rev 54770)
+++ branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/anisotropic_diffusion.py 2013-02-23 01:12:23 UTC (rev 54771)
@@ -39,7 +39,7 @@
Operators.bidirectionalChain(ChainPredicateIterator(upred, bpred), NotUP1D(upred) )
shaders_list = [
ConstantThicknessShader(4),
- StrokeTextureShader("smoothAlpha.bmp", Stroke.OPAQUE_MEDIUM, 0),
+ StrokeTextureShader("smoothAlpha.bmp", Stroke.OPAQUE_MEDIUM, False),
SamplingShader(2),
pyDiffusion2Shader(offset, nbIter),
IncreasingColorShader(1, 0, 0, 1, 0, 1, 0, 1)
Modified: branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/curvature2d.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/curvature2d.py 2013-02-23 00:52:59 UTC (rev 54770)
+++ branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/curvature2d.py 2013-02-23 01:12:23 UTC (rev 54771)
@@ -33,7 +33,7 @@
Operators.select(QuantitativeInvisibilityUP1D(0))
Operators.bidirectionalChain(ChainSilhouetteIterator(), NotUP1D(QuantitativeInvisibilityUP1D(0)))
shaders_list = [
- StrokeTextureShader("smoothAlpha.bmp", Stroke.OPAQUE_MEDIUM, 0),
+ StrokeTextureShader("smoothAlpha.bmp", Stroke.OPAQUE_MEDIUM, False),
ConstantThicknessShader(5),
py2DCurvatureColorShader()
]
Modified: branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/sketchy_multiple_parameterization.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/sketchy_multiple_parameterization.py 2013-02-23 00:52:59 UTC (rev 54770)
+++ branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/sketchy_multiple_parameterization.py 2013-02-23 01:12:23 UTC (rev 54771)
@@ -38,7 +38,7 @@
Operators.bidirectionalChain(pySketchyChainSilhouetteIterator(3,0))
shaders_list = [
SamplingShader(2),
- SpatialNoiseShader(15, 120, 2, 1, 1),
+ SpatialNoiseShader(15, 120, 2, True, True),
IncreasingThicknessShader(5, 30),
SmoothingShader(100, 0.05, 0, 0.2, 0, 0, 0, 1),
IncreasingColorShader(0,0.2,0,1,0.2,0.7,0.2,1),
Modified: branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/sketchy_topology_broken.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/sketchy_topology_broken.py 2013-02-23 00:52:59 UTC (rev 54770)
+++ branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/sketchy_topology_broken.py 2013-02-23 01:12:23 UTC (rev 54771)
@@ -38,7 +38,7 @@
Operators.bidirectionalChain(pySketchyChainingIterator(3))
shaders_list = [
SamplingShader(4),
- SpatialNoiseShader(6, 120, 2, 1, 1),
+ SpatialNoiseShader(6, 120, 2, True, True),
IncreasingThicknessShader(4, 10),
SmoothingShader(100, 0.1, 0, 0.2, 0, 0, 0, 1),
pyBackboneStretcherNoCuspShader(20),
Modified: branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/sketchy_topology_preserved.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/sketchy_topology_preserved.py 2013-02-23 00:52:59 UTC (rev 54770)
+++ branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/sketchy_topology_preserved.py 2013-02-23 01:12:23 UTC (rev 54771)
@@ -38,7 +38,7 @@
Operators.bidirectionalChain(pySketchyChainSilhouetteIterator(3,1))
shaders_list = [
SamplingShader(4),
- SpatialNoiseShader(20, 220, 2, 1, 1),
+ SpatialNoiseShader(20, 220, 2, True, True),
IncreasingThicknessShader(4, 8),
SmoothingShader(300, 0.05, 0, 0.2, 0, 0, 0, 0.5),
ConstantColorShader(0.6,0.2,0.0),
Modified: branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/stroke_texture.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/stroke_texture.py 2013-02-23 00:52:59 UTC (rev 54770)
+++ branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/stroke_texture.py 2013-02-23 01:12:23 UTC (rev 54771)
@@ -36,7 +36,7 @@
shaders_list = [
SamplingShader(3),
BezierCurveShader(4),
- StrokeTextureShader("washbrushAlpha.bmp", Stroke.DRY_MEDIUM, 1),
+ StrokeTextureShader("washbrushAlpha.bmp", Stroke.DRY_MEDIUM, True),
ConstantThicknessShader(40),
ConstantColorShader(0,0,0,1),
]
Modified: branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/uniformpruning_zsort.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/uniformpruning_zsort.py 2013-02-23 00:52:59 UTC (rev 54770)
+++ branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/uniformpruning_zsort.py 2013-02-23 01:12:23 UTC (rev 54771)
@@ -12,7 +12,7 @@
#Operators.sequentialSplit(pyVertexNatureUP0D(Nature.VIEW_VERTEX), 2)
Operators.sort(pyZBP1D())
shaders_list = [
- StrokeTextureShader("smoothAlpha.bmp", Stroke.OPAQUE_MEDIUM, 0),
+ StrokeTextureShader("smoothAlpha.bmp", Stroke.OPAQUE_MEDIUM, False),
ConstantThicknessShader(3),
SamplingShader(5.0),
ConstantColorShader(0,0,0,1)
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp 2013-02-23 00:52:59 UTC (rev 54770)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_BinaryPredicate0D.cpp 2013-02-23 01:12:23 UTC (rev 54771)
@@ -10,15 +10,15 @@
///////////////////////////////////////////////////////////////////////////////////////////
//-------------------MODULE INITIALIZATION--------------------------------
-int BinaryPredicate0D_Init( PyObject *module )
+int BinaryPredicate0D_Init(PyObject *module)
{
- if( module == NULL )
+ if (module == NULL)
return -1;
- if( PyType_Ready( &BinaryPredicate0D_Type ) < 0 )
+ if (PyType_Ready(&BinaryPredicate0D_Type) < 0)
return -1;
- Py_INCREF( &BinaryPredicate0D_Type );
+ Py_INCREF(&BinaryPredicate0D_Type);
PyModule_AddObject(module, "BinaryPredicate0D", (PyObject *)&BinaryPredicate0D_Type);
return 0;
}
@@ -50,11 +50,12 @@
static int BinaryPredicate0D___init__(BPy_BinaryPredicate0D *self, PyObject *args, PyObject *kwds)
{
- if ( !PyArg_ParseTuple(args, "") )
- return -1;
+ static const char *kwlist[] = {NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
+ return -1;
self->bp0D = new BinaryPredicate0D();
- self->bp0D->py_bp0D = (PyObject *) self;
-
+ self->bp0D->py_bp0D = (PyObject *)self;
return 0;
}
@@ -62,58 +63,53 @@
{
if (self->bp0D)
delete self->bp0D;
- Py_TYPE(self)->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
-
static PyObject * BinaryPredicate0D___repr__(BPy_BinaryPredicate0D* self)
{
- return PyUnicode_FromFormat("type: %s - address: %p", self->bp0D->getName().c_str(), self->bp0D );
+ return PyUnicode_FromFormat("type: %s - address: %p", Py_TYPE(self)->tp_name, self->bp0D);
}
-static char BinaryPredicate0D_getName___doc__[] =
-".. method:: getName()\n"
-"\n"
-" Returns the name of the binary 0D predicate.\n"
-"\n"
-" :return: The name of the binary 0D predicate.\n"
-" :rtype: str\n";
-
-static PyObject * BinaryPredicate0D_getName( BPy_BinaryPredicate0D *self, PyObject *args)
+static PyObject * BinaryPredicate0D___call__(BPy_BinaryPredicate0D *self, PyObject *args, PyObject *kwds)
{
- return PyUnicode_FromString( self->bp0D->getName().c_str() );
-}
-
-static PyObject * BinaryPredicate0D___call__( BPy_BinaryPredicate0D *self, PyObject *args, PyObject *kwds)
-{
+ static const char *kwlist[] = {"inter1", "inter2", NULL};
BPy_Interface0D *obj1, *obj2;
- if( kwds != NULL ) {
- PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported");
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!O!", (char **)kwlist,
+ &Interface0D_Type, &obj1, &Interface0D_Type, &obj2))
+ {
return NULL;
}
- if( !PyArg_ParseTuple(args, "O!O!", &Interface0D_Type, &obj1, &Interface0D_Type, &obj2) )
- return NULL;
-
- if( typeid(*(self->bp0D)) == typeid(BinaryPredicate0D) ) {
+ if (typeid(*(self->bp0D)) == typeid(BinaryPredicate0D)) {
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
return NULL;
}
- if (self->bp0D->operator()( *(obj1->if0D) , *(obj2->if0D) ) < 0) {
+ if (self->bp0D->operator()(*(obj1->if0D) , *(obj2->if0D)) < 0) {
if (!PyErr_Occurred()) {
- string msg(self->bp0D->getName() + " __call__ method failed");
- PyErr_SetString(PyExc_RuntimeError, msg.c_str());
+ string class_name(Py_TYPE(self)->tp_name);
+ PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
}
return NULL;
}
- return PyBool_from_bool( self->bp0D->result );
+ return PyBool_from_bool(self->bp0D->result);
+}
+/*----------------------BinaryPredicate0D get/setters ----------------------------*/
+
+PyDoc_STRVAR(BinaryPredicate0D_name_doc,
+"The name of the binary 0D predicate.\n"
+"\n"
+":type: str");
+
+static PyObject *BinaryPredicate0D_name_get(BPy_BinaryPredicate0D *self, void *UNUSED(closure))
+{
+ return PyUnicode_FromString(Py_TYPE(self)->tp_name);
}
-/*----------------------BinaryPredicate0D instance definitions ----------------------------*/
-static PyMethodDef BPy_BinaryPredicate0D_methods[] = {
- {"getName", ( PyCFunction ) BinaryPredicate0D_getName, METH_NOARGS, BinaryPredicate0D_getName___doc__},
- {NULL, NULL, 0, NULL}
+static PyGetSetDef BPy_BinaryPredicate0D_getseters[] = {
+ {(char *)"name", (getter)BinaryPredicate0D_name_get, (setter)NULL, (char *)BinaryPredicate0D_name_doc, NULL},
+ {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};
/*-----------------------BPy_BinaryPredicate0D type definition ------------------------------*/
@@ -146,9 +142,9 @@
0, /* tp_weaklistoffset */
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list