diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-05-23 21:11:44 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-05-23 21:11:44 +0400 |
commit | 96e79172a010cba6bc826f570832ef4b355ea0cd (patch) | |
tree | 5e7bee49170faff126fa52d8fd389642876e4021 /source/blender/freestyle/intern/python | |
parent | 2212564f1804e3cc866003b226eac89575d53ade (diff) |
Made object names accessible from within style modules.
ViewShape objects in the view map, as well as SShape objects
that can be retrieved with ViewShape::sshape(), now have a
getName() method that returns the name of the object from
which each shape is created. For instance, visible feature
edges of specific mesh objects (e.g., Cube.001 and Cube.002)
can be selected using custom predicate ObjectNamesUP1D as
follows:
class ObjectNamesUP1D(UnaryPredicate1D):
def __init__(self, names):
UnaryPredicate1D.__init__(self)
self._names = names
def getName(self):
return "ObjectNamesUP1D"
def __call__(self, viewEdge):
return viewEdge.viewShape().getName() in self._names
upred = AndUP1D(QuantitativeInvisibilityUP1D(0),
ObjectNamesUP1D(["Cube.001", "Cube.002"]))
Operators.select(upred)
Diffstat (limited to 'source/blender/freestyle/intern/python')
-rw-r--r-- | source/blender/freestyle/intern/python/BPy_SShape.cpp | 33 | ||||
-rw-r--r-- | source/blender/freestyle/intern/python/BPy_ViewShape.cpp | 13 |
2 files changed, 46 insertions, 0 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_SShape.cpp b/source/blender/freestyle/intern/python/BPy_SShape.cpp index 512a19359a5..65951182f10 100644 --- a/source/blender/freestyle/intern/python/BPy_SShape.cpp +++ b/source/blender/freestyle/intern/python/BPy_SShape.cpp @@ -229,6 +229,37 @@ static PyObject * SShape_setId( BPy_SShape *self , PyObject *args) { Py_RETURN_NONE; } +static char SShape_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the SShape.\n" +"\n" +" :return: The name string.\n" +" :rtype: str\n"; + +static PyObject * SShape_getName( BPy_SShape *self ) { + return PyUnicode_FromString( self->ss->getName().c_str() ); +} + +static char SShape_setName___doc__[] = +".. method:: setName(name)\n" +"\n" +" Sets the name of the SShape.\n" +"\n" +" :arg name: A name string.\n" +" :type name: str\n"; + +static PyObject * SShape_setName( BPy_SShape *self , PyObject *args) { + char *s; + + if(!( PyArg_ParseTuple(args, "s", &s) )) + return NULL; + + self->ss->setName(s); + + Py_RETURN_NONE; +} + // const Material & material (unsigned i) const // const vector< Material > & materials () const // void SetMaterials (const vector< Material > &iMaterials) @@ -244,6 +275,8 @@ static PyMethodDef BPy_SShape_methods[] = { {"getEdgeList", ( PyCFunction ) SShape_getEdgeList, METH_NOARGS, SShape_getEdgeList___doc__}, {"getId", ( PyCFunction ) SShape_getId, METH_NOARGS, SShape_getId___doc__}, {"setId", ( PyCFunction ) SShape_setId, METH_VARARGS, SShape_setId___doc__}, + {"getName", ( PyCFunction ) SShape_getName, METH_NOARGS, SShape_getName___doc__}, + {"setName", ( PyCFunction ) SShape_setName, METH_VARARGS, SShape_setName___doc__}, {NULL, NULL, 0, NULL} }; diff --git a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp index 8849b6b3776..eebfa88773c 100644 --- a/source/blender/freestyle/intern/python/BPy_ViewShape.cpp +++ b/source/blender/freestyle/intern/python/BPy_ViewShape.cpp @@ -153,6 +153,18 @@ static PyObject * ViewShape_getId( BPy_ViewShape *self ) { return BPy_Id_from_Id( id ); } +static char ViewShape_getName___doc__[] = +".. method:: getName()\n" +"\n" +" Returns the name of the ViewShape.\n" +"\n" +" :return: The name string.\n" +" :rtype: str\n"; + +static PyObject * ViewShape_getName( BPy_ViewShape *self ) { + return PyUnicode_FromString( self->vs->getName().c_str() ); +} + static char ViewShape_setSShape___doc__[] = ".. method:: setSShape(iSShape)\n" "\n" @@ -282,6 +294,7 @@ static PyMethodDef BPy_ViewShape_methods[] = { {"vertices", ( PyCFunction ) ViewShape_vertices, METH_NOARGS, ViewShape_vertices___doc__}, {"edges", ( PyCFunction ) ViewShape_edges, METH_NOARGS, ViewShape_edges___doc__}, {"getId", ( PyCFunction ) ViewShape_getId, METH_NOARGS, ViewShape_getId___doc__}, + {"getName", ( PyCFunction ) ViewShape_getName, METH_NOARGS, ViewShape_getName___doc__}, {"setSShape", ( PyCFunction ) ViewShape_setSShape, METH_VARARGS, ViewShape_setSShape___doc__}, {"setVertices", ( PyCFunction ) ViewShape_setVertices, METH_VARARGS, ViewShape_setVertices___doc__}, {"setEdges", ( PyCFunction ) ViewShape_setEdges, METH_VARARGS, ViewShape_setEdges___doc__}, |