Freestyle: Expose the Operators.reset() function to Python.

The Operators.reset function is exposed to the Freestyle Python API, which makes
it possible to combine multiple style modules into one file.

Differential revision: https://developer.blender.org/D802

Author: flokkievids (Folkert de Vries)

Reviewed by: kjym3 (Tamito Kajiyama)
This commit is contained in:
Tamito Kajiyama 2014-09-28 11:05:19 +09:00
parent 21825c4359
commit c900cd3bd8
3 changed files with 29 additions and 9 deletions

View File

@ -548,6 +548,29 @@ static PyObject *Operators_create(BPy_Operators *self, PyObject *args, PyObject
Py_RETURN_NONE;
}
PyDoc_STRVAR(Operators_reset_doc,
".. staticmethod:: reset(delete_strokes=True)\n"
"\n"
" Resets the stroke selection (and therefore chaining, splitting, sorting and shading)\n"
"\n"
" :arg delete_strokes: Delete the strokes that are currently stored\n"
" :type delete_strokes: bool\n");
static PyObject *Operators_reset(BPy_Operators *self, PyObject *args, PyObject *kwds)
{
static const char *kwlist[] = {"delete_strokes", NULL};
PyObject *obj1 = 0;
if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &PyBool_Type, &obj1)) {
// true is the default
Operators::reset(obj1 ? bool_from_PyBool(obj1) : true);
}
else {
PyErr_SetString(PyExc_RuntimeError, "Operators.reset() failed");
return NULL;
}
Py_RETURN_NONE;
}
PyDoc_STRVAR(Operators_get_viewedge_from_index_doc,
".. staticmethod:: get_viewedge_from_index(i)\n"
"\n"
@ -671,6 +694,7 @@ static PyMethodDef BPy_Operators_methods[] = {
Operators_recursive_split_doc},
{"sort", (PyCFunction) Operators_sort, METH_VARARGS | METH_KEYWORDS | METH_STATIC, Operators_sort_doc},
{"create", (PyCFunction) Operators_create, METH_VARARGS | METH_KEYWORDS | METH_STATIC, Operators_create_doc},
{"reset", (PyCFunction) Operators_reset, METH_VARARGS | METH_KEYWORDS | METH_STATIC, Operators_reset_doc},
{"get_viewedge_from_index", (PyCFunction) Operators_get_viewedge_from_index,
METH_VARARGS | METH_KEYWORDS | METH_STATIC, Operators_get_viewedge_from_index_doc},
{"get_chain_from_index", (PyCFunction) Operators_get_chain_from_index, METH_VARARGS | METH_KEYWORDS | METH_STATIC,

View File

@ -1242,7 +1242,7 @@ error:
return -1;
}
void Operators::reset()
void Operators::reset(bool removeStrokes)
{
ViewMap *vm = ViewMap::getInstance();
if (!vm) {
@ -1253,11 +1253,7 @@ void Operators::reset()
for (I1DContainer::iterator it = _current_chains_set.begin(); it != _current_chains_set.end(); ++it)
delete *it;
_current_chains_set.clear();
#if 0
_current_view_edges_set.insert(_current_view_edges_set.begin(),
vm->ViewEdges().begin(),
vm->ViewEdges().end());
#else
ViewMap::viewedges_container& vedges = vm->ViewEdges();
ViewMap::viewedges_container::iterator ve = vedges.begin(), veend = vedges.end();
for (; ve != veend; ++ve) {
@ -1265,9 +1261,9 @@ void Operators::reset()
continue;
_current_view_edges_set.push_back(*ve);
}
#endif
_current_set = &_current_view_edges_set;
_current_strokes_set.clear();
if (removeStrokes)
_current_strokes_set.clear();
}
} /* namespace Freestyle */

View File

@ -259,7 +259,7 @@ public:
return &_current_strokes_set;
}
static void reset();
static void reset(bool removeStrokes=true);
private:
Operators() {}