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)
This commit is contained in:
2010-05-23 17:11:44 +00:00
parent 2212564f18
commit 96e79172a0
10 changed files with 75 additions and 8 deletions

View File

@@ -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__},