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

@@ -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}
};