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-02-15 03:48:34 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-02-15 03:48:34 +0400
commit731d08d4974ce695e7d1446b934d0656a4d82942 (patch)
tree6568f2d1befa6c4cac0005bc4dcf3e239363757f /source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
parent9e3bf44011285917db1e1061a2f459722674b1b9 (diff)
Freestyle Python API improvements - part 3.
Major API updates were made to address code review comments. This revision mostly focuses on Python wrappers of C++ 0D and 1D elements (i.e., Interface0D and Interface1D, as well as their subclasses). * Most getter/setter methods were reimplemented as attributes using PyGetSetDef. Vector attributes are now implemented based on mathutils callbacks. Boolean attributes now only accept boolean values. * The __getitem__ method was removed and the Sequence protocol was used instead. * The naming of methods and attributes was fixed to follow the naming conventions of the Blender Python API (i.e., lower case + underscores for methods and attributes, and CamelCase for classes). Some naming inconsistency within the Freestyle Python API was also addressed. * The Freestyle API had a number of method names including prefix/suffix "A" and "B", and their meanings were inconsistent (i.e., referring to different things depending on the classes). The names with these two letters were replaced with more straightforward names. Also some attribute names were changed so as to indicate the type of the value (e.g., FEdge.next_fedge instead of FEdge.next_edge) in line with other names explicitly indicating what the value is (e.g., SVertex.viewvertex). * In addition, some code clean-up was done in both C++ and Python. Notes: In summary, the following irregular naming changes were made through this revision (those resulting from regular changes of naming conventions are not listed): - CurvePoint: {A,B} --> {first,second}_svertex - FEdge: vertex{A,B} --> {first,second}_svertex - FEdge: {next,previous}Edge --> {next,previous}_fedge - FEdgeSharp: normal{A,B} --> normal_{right,left} - FEdgeSharp: {a,b}FaceMark --> face_mark_{right,left} - FEdgeSharp: {a,b}Material --> material_{right,left} - FEdgeSharp: {a,b}MaterialIndex --> material_index_{right,left} - FrsCurve: empty --> is_empty - FrsCurve: nSegments --> segments_size - TVertex: mate() --> get_mate() - ViewEdge: fedge{A,B} --> {first,last}_fedge - ViewEdge: setaShape, aShape --> occlude - ViewEdge: {A,B} --> {first,last}_viewvertex - ViewMap: getScene3dBBox --> scene_bbox
Diffstat (limited to 'source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp')
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp112
1 files changed, 57 insertions, 55 deletions
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
index 5b20db3a267..e5b984e41bd 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
@@ -11,9 +11,9 @@ extern "C" {
///////////////////////////////////////////////////////////////////////////////////////////
-//------------------------INSTANCE METHODS ----------------------------------
+/*----------------------CurvePoint methods ----------------------------*/
-static char FrsCurve___doc__[] =
+PyDoc_STRVAR(FrsCurve_doc,
"Class hierarchy: :class:`Interface1D` > :class:`Curve`\n"
"\n"
"Base class for curves made of CurvePoints. :class:`SVertex` is the\n"
@@ -36,25 +36,25 @@ static char FrsCurve___doc__[] =
" Builds a Curve from its Id.\n"
"\n"
" :arg iId: An Id object.\n"
-" :type iId: :class:`Id`\n";
+" :type iId: :class:`Id`");
-static int FrsCurve___init__(BPy_FrsCurve *self, PyObject *args, PyObject *kwds)
+static int FrsCurve_init(BPy_FrsCurve *self, PyObject *args, PyObject *kwds)
{
PyObject *obj = 0;
- if (! PyArg_ParseTuple(args, "|O", &obj) )
- return -1;
+ if (!PyArg_ParseTuple(args, "|O", &obj))
+ return -1;
- if( !obj ){
+ if (!obj) {
self->c = new Curve();
-
- } else if( BPy_FrsCurve_Check(obj) ) {
+
+ } else if (BPy_FrsCurve_Check(obj)) {
self->c = new Curve(*( ((BPy_FrsCurve *) obj)->c ));
-
- } else if( BPy_Id_Check(obj) ) {
+
+ } else if (BPy_Id_Check(obj)) {
self->c = new Curve(*( ((BPy_Id *) obj)->id ));
-
+
} else {
PyErr_SetString(PyExc_TypeError, "invalid argument");
return -1;
@@ -66,24 +66,25 @@ static int FrsCurve___init__(BPy_FrsCurve *self, PyObject *args, PyObject *kwds)
return 0;
}
-static char FrsCurve_push_vertex_back___doc__[] =
+PyDoc_STRVAR(FrsCurve_push_vertex_back_doc,
".. method:: push_vertex_back(iVertex)\n"
"\n"
" Adds a single vertex at the end of the Curve.\n"
"\n"
" :arg iVertex: A vertex object.\n"
-" :type iVertex: :class:`SVertex` or :class:`CurvePoint`\n";
+" :type iVertex: :class:`SVertex` or :class:`CurvePoint`");
-static PyObject * FrsCurve_push_vertex_back( BPy_FrsCurve *self, PyObject *args ) {
+static PyObject * FrsCurve_push_vertex_back( BPy_FrsCurve *self, PyObject *args )
+{
PyObject *obj;
- if(!( PyArg_ParseTuple(args, "O", &obj) ))
+ if (!PyArg_ParseTuple(args, "O", &obj))
return NULL;
- if( BPy_CurvePoint_Check(obj) ) {
- self->c->push_vertex_back( ((BPy_CurvePoint *) obj)->cp );
- } else if( BPy_SVertex_Check(obj) ) {
- self->c->push_vertex_back( ((BPy_SVertex *) obj)->sv );
+ if (BPy_CurvePoint_Check(obj)) {
+ self->c->push_vertex_back(((BPy_CurvePoint *)obj)->cp);
+ } else if (BPy_SVertex_Check(obj)) {
+ self->c->push_vertex_back(((BPy_SVertex *)obj)->sv);
} else {
PyErr_SetString(PyExc_TypeError, "invalid argument");
return NULL;
@@ -92,24 +93,25 @@ static PyObject * FrsCurve_push_vertex_back( BPy_FrsCurve *self, PyObject *args
Py_RETURN_NONE;
}
-static char FrsCurve_push_vertex_front___doc__[] =
+PyDoc_STRVAR(FrsCurve_push_vertex_front_doc,
".. method:: push_vertex_front(iVertex)\n"
"\n"
" Adds a single vertex at the front of the Curve.\n"
"\n"
" :arg iVertex: A vertex object.\n"
-" :type iVertex: :class:`SVertex` or :class:`CurvePoint`\n";
+" :type iVertex: :class:`SVertex` or :class:`CurvePoint`");
-static PyObject * FrsCurve_push_vertex_front( BPy_FrsCurve *self, PyObject *args ) {
+static PyObject * FrsCurve_push_vertex_front( BPy_FrsCurve *self, PyObject *args )
+{
PyObject *obj;
- if(!( PyArg_ParseTuple(args, "O", &obj) ))
+ if (!PyArg_ParseTuple(args, "O", &obj))
return NULL;
- if( BPy_CurvePoint_Check(obj) ) {
- self->c->push_vertex_front( ((BPy_CurvePoint *) obj)->cp );
- } else if( BPy_SVertex_Check(obj) ) {
- self->c->push_vertex_front( ((BPy_SVertex *) obj)->sv );
+ if (BPy_CurvePoint_Check(obj)) {
+ self->c->push_vertex_front(((BPy_CurvePoint *)obj)->cp);
+ } else if( BPy_SVertex_Check(obj)) {
+ self->c->push_vertex_front(((BPy_SVertex *)obj)->sv);
} else {
PyErr_SetString(PyExc_TypeError, "invalid argument");
return NULL;
@@ -118,38 +120,38 @@ static PyObject * FrsCurve_push_vertex_front( BPy_FrsCurve *self, PyObject *args
Py_RETURN_NONE;
}
-static char FrsCurve_empty___doc__[] =
-".. method:: empty()\n"
-"\n"
-" Returns true if the Curve doesn't have any Vertex yet.\n"
+static PyMethodDef BPy_FrsCurve_methods[] = {
+ {"push_vertex_back", (PyCFunction)FrsCurve_push_vertex_back, METH_VARARGS, FrsCurve_push_vertex_back_doc},
+ {"push_vertex_front", (PyCFunction)FrsCurve_push_vertex_front, METH_VARARGS, FrsCurve_push_vertex_front_doc},
+ {NULL, NULL, 0, NULL}
+};
+
+/*----------------------CurvePoint get/setters ----------------------------*/
+
+PyDoc_STRVAR(FrsCurve_is_empty_doc,
+"True if the Curve doesn't have any Vertex yet.\n"
"\n"
-" :return: True if the Curve has no vertices.\n"
-" :rtype: bool\n";
+":type: bool");
-static PyObject * FrsCurve_empty( BPy_FrsCurve *self ) {
- return PyBool_from_bool( self->c->empty() );
+static PyObject *FrsCurve_is_empty_get(BPy_FrsCurve *self, void *UNUSED(closure))
+{
+ return PyBool_from_bool(self->c->empty());
}
-static char FrsCurve_nSegments___doc__[] =
-".. method:: nSegments()\n"
+PyDoc_STRVAR(FrsCurve_segments_size_doc,
+"The number of segments in the polyline constituing the Curve.\n"
"\n"
-" Returns the number of segments in the polyline constituing the\n"
-" Curve.\n"
-"\n"
-" :return: The number of segments.\n"
-" :rtype: int\n";
+":type: int");
-static PyObject * FrsCurve_nSegments( BPy_FrsCurve *self ) {
- return PyLong_FromLong( self->c->nSegments() );
+static PyObject *FrsCurve_segments_size_get(BPy_FrsCurve *self, void *UNUSED(closure))
+{
+ return PyLong_FromLong(self->c->nSegments());
}
-/*----------------------FrsCurve instance definitions ----------------------------*/
-static PyMethodDef BPy_FrsCurve_methods[] = {
- {"push_vertex_back", ( PyCFunction ) FrsCurve_push_vertex_back, METH_VARARGS, FrsCurve_push_vertex_back___doc__},
- {"push_vertex_front", ( PyCFunction ) FrsCurve_push_vertex_front, METH_VARARGS, FrsCurve_push_vertex_front___doc__},
- {"empty", ( PyCFunction ) FrsCurve_empty, METH_NOARGS, FrsCurve_empty___doc__},
- {"nSegments", ( PyCFunction ) FrsCurve_nSegments, METH_NOARGS, FrsCurve_nSegments___doc__},
- {NULL, NULL, 0, NULL}
+static PyGetSetDef BPy_FrsCurve_getseters[] = {
+ {(char *)"is_empty", (getter)FrsCurve_is_empty_get, (setter)NULL, (char *)FrsCurve_is_empty_doc, NULL},
+ {(char *)"segments_size", (getter)FrsCurve_segments_size_get, (setter)NULL, (char *)FrsCurve_segments_size_doc, NULL},
+ {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};
/*-----------------------BPy_FrsCurve type definition ------------------------------*/
@@ -175,7 +177,7 @@ PyTypeObject FrsCurve_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- FrsCurve___doc__, /* tp_doc */
+ FrsCurve_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
@@ -184,13 +186,13 @@ PyTypeObject FrsCurve_Type = {
0, /* tp_iternext */
BPy_FrsCurve_methods, /* tp_methods */
0, /* tp_members */
- 0, /* tp_getset */
+ BPy_FrsCurve_getseters, /* tp_getset */
&Interface1D_Type, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
- (initproc)FrsCurve___init__, /* tp_init */
+ (initproc)FrsCurve_init, /* tp_init */
0, /* tp_alloc */
0, /* tp_new */
};