13#include "../generic/py_capi_utils.hh"
22 if (module ==
nullptr) {
40 "Class to define a set of attributes associated with a :class:`StrokeVertex`.\n"
41 "The attribute set stores the color, alpha and thickness values for a Stroke\n"
44 ".. method:: __init__(*args)\n"
46 " Accepted call signatures:\n"
49 " - ``__init__(brother)``\n"
50 " - ``__init__(red, green, blue, alpha, thickness_right, thickness_left)``\n"
51 " - ``__init__(attribute1, attribute2, t)``\n"
53 " Creates a :class:`StrokeAttribute` object using either a default constructor,\n"
54 " copy constructor, overloaded constructor, or and interpolation constructor\n"
55 " to interpolate between two :class:`StrokeAttribute` objects.\n"
57 " :param brother: A StrokeAttribute object to be used as a copy constructor.\n"
58 " :type brother: :class:`StrokeAttribute`\n"
59 " :param red: Red component of a stroke color.\n"
61 " :param green: Green component of a stroke color.\n"
62 " :type green: float\n"
63 " :param blue: Blue component of a stroke color.\n"
64 " :type blue: float\n"
65 " :param alpha: Alpha component of a stroke color.\n"
66 " :type alpha: float\n"
67 " :param thickness_right: Stroke thickness on the right.\n"
68 " :type thickness_right: float\n"
69 " :param thickness_left: Stroke thickness on the left.\n"
70 " :type thickness_left: float\n"
71 " :param attribute1: The first StrokeAttribute object.\n"
72 " :type attribute1: :class:`StrokeAttribute`\n"
73 " :param attribute2: The second StrokeAttribute object.\n"
74 " :type attribute2: :class:`StrokeAttribute`\n"
75 " :param t: The interpolation parameter (0 <= t <= 1).\n"
79 static const char *kwlist_1[] = {
"brother",
nullptr};
80 static const char *kwlist_2[] = {
"attribute1",
"attribute2",
"t",
nullptr};
81 static const char *kwlist_3[] = {
82 "red",
"green",
"blue",
"alpha",
"thickness_right",
"thickness_left",
nullptr};
83 PyObject *obj1 =
nullptr, *obj2 =
nullptr;
84 float red, green, blue, alpha, thickness_right, thickness_left, t;
86 if (PyArg_ParseTupleAndKeywords(args,
102 else if ((
void)PyErr_Clear(),
103 PyArg_ParseTupleAndKeywords(args,
119 else if ((
void)PyErr_Clear(),
120 PyArg_ParseTupleAndKeywords(args,
137 self->
sa =
new StrokeAttribute(red, green, blue, alpha, thickness_right, thickness_left);
140 PyErr_SetString(PyExc_TypeError,
"invalid argument(s)");
152 Py_TYPE(self)->tp_free((PyObject *)self);
157 stringstream repr(
"StrokeAttribute:");
167 StrokeAttribute_get_attribute_real_doc,
168 ".. method:: get_attribute_real(name)\n"
170 " Returns an attribute of float type.\n"
172 " :param name: The name of the attribute.\n"
174 " :return: The attribute value.\n"
180 static const char *kwlist[] = {
"name",
nullptr};
183 if (!PyArg_ParseTupleAndKeywords(args,
186 ":get_attribute_real",
193 return PyFloat_FromDouble(a);
198 StrokeAttribute_get_attribute_vec2_doc,
199 ".. method:: get_attribute_vec2(name)\n"
201 " Returns an attribute of two-dimensional vector type.\n"
203 " :param name: The name of the attribute.\n"
205 " :return: The attribute value.\n"
206 " :rtype: :class:`mathutils.Vector`\n");
211 static const char *kwlist[] = {
"name",
nullptr};
214 if (!PyArg_ParseTupleAndKeywords(args,
217 ":get_attribute_vec2",
229 StrokeAttribute_get_attribute_vec3_doc,
230 ".. method:: get_attribute_vec3(name)\n"
232 " Returns an attribute of three-dimensional vector type.\n"
234 " :param name: The name of the attribute.\n"
236 " :return: The attribute value.\n"
237 " :rtype: :class:`mathutils.Vector`\n");
242 static const char *kwlist[] = {
"name",
nullptr};
245 if (!PyArg_ParseTupleAndKeywords(args,
248 ":get_attribute_vec3",
260 StrokeAttribute_has_attribute_real_doc,
261 ".. method:: has_attribute_real(name)\n"
263 " Checks whether the attribute name of float type is available.\n"
265 " :param name: The name of the attribute.\n"
267 " :return: True if the attribute is available.\n"
273 static const char *kwlist[] = {
"name",
nullptr};
276 if (!PyArg_ParseTupleAndKeywords(args,
279 ":has_attribute_real",
290 StrokeAttribute_has_attribute_vec2_doc,
291 ".. method:: has_attribute_vec2(name)\n"
293 " Checks whether the attribute name of two-dimensional vector type\n"
296 " :param name: The name of the attribute.\n"
298 " :return: True if the attribute is available.\n"
304 static const char *kwlist[] = {
"name",
nullptr};
307 if (!PyArg_ParseTupleAndKeywords(args,
310 ":has_attribute_vec2",
321 StrokeAttribute_has_attribute_vec3_doc,
322 ".. method:: has_attribute_vec3(name)\n"
324 " Checks whether the attribute name of three-dimensional vector\n"
325 " type is available.\n"
327 " :param name: The name of the attribute.\n"
329 " :return: True if the attribute is available.\n"
335 static const char *kwlist[] = {
"name",
nullptr};
338 if (!PyArg_ParseTupleAndKeywords(args,
341 ":has_attribute_vec3",
352 StrokeAttribute_set_attribute_real_doc,
353 ".. method:: set_attribute_real(name, value)\n"
355 " Adds a user-defined attribute of float type. If there is no\n"
356 " attribute of the given name, it is added. Otherwise, the new value\n"
357 " replaces the old one.\n"
359 " :param name: The name of the attribute.\n"
361 " :param value: The attribute value.\n"
362 " :type value: float\n");
367 static const char *kwlist[] = {
"name",
"value",
nullptr};
371 if (!PyArg_ParseTupleAndKeywords(args,
375 ":set_attribute_real",
388 StrokeAttribute_set_attribute_vec2_doc,
389 ".. method:: set_attribute_vec2(name, value)\n"
391 " Adds a user-defined attribute of two-dimensional vector type. If\n"
392 " there is no attribute of the given name, it is added. Otherwise,\n"
393 " the new value replaces the old one.\n"
395 " :param name: The name of the attribute.\n"
397 " :param value: The attribute value.\n"
398 " :type value: :class:`mathutils.Vector` | tuple[float, float, float] | list[float]\n");
403 static const char *kwlist[] = {
"name",
"value",
nullptr};
405 PyObject *obj =
nullptr;
408 if (!PyArg_ParseTupleAndKeywords(args,
412 ":set_attribute_vec2",
420 PyErr_SetString(PyExc_TypeError,
421 "argument 2 must be a 2D vector (either a list of 2 elements or Vector)");
430 StrokeAttribute_set_attribute_vec3_doc,
431 ".. method:: set_attribute_vec3(name, value)\n"
433 " Adds a user-defined attribute of three-dimensional vector type.\n"
434 " If there is no attribute of the given name, it is added.\n"
435 " Otherwise, the new value replaces the old one.\n"
437 " :param name: The name of the attribute.\n"
439 " :param value: The attribute value as a 3D vector.\n"
440 " :type value: :class:`mathutils.Vector` | tuple[float, float, float] | list[float]\n");
445 static const char *kwlist[] = {
"name",
"value",
nullptr};
447 PyObject *obj =
nullptr;
450 if (!PyArg_ParseTupleAndKeywords(args,
454 ":set_attribute_vec3",
462 PyErr_SetString(PyExc_TypeError,
463 "argument 2 must be a 3D vector (either a list of 3 elements or Vector)");
472# pragma clang diagnostic push
473# pragma clang diagnostic ignored "-Wcast-function-type"
475# pragma GCC diagnostic push
476# pragma GCC diagnostic ignored "-Wcast-function-type"
481 {
"get_attribute_real",
483 METH_VARARGS | METH_KEYWORDS,
484 StrokeAttribute_get_attribute_real_doc},
485 {
"get_attribute_vec2",
487 METH_VARARGS | METH_KEYWORDS,
488 StrokeAttribute_get_attribute_vec2_doc},
489 {
"get_attribute_vec3",
491 METH_VARARGS | METH_KEYWORDS,
492 StrokeAttribute_get_attribute_vec3_doc},
493 {
"has_attribute_real",
495 METH_VARARGS | METH_KEYWORDS,
496 StrokeAttribute_has_attribute_real_doc},
497 {
"has_attribute_vec2",
499 METH_VARARGS | METH_KEYWORDS,
500 StrokeAttribute_has_attribute_vec2_doc},
501 {
"has_attribute_vec3",
503 METH_VARARGS | METH_KEYWORDS,
504 StrokeAttribute_has_attribute_vec3_doc},
505 {
"set_attribute_real",
507 METH_VARARGS | METH_KEYWORDS,
508 StrokeAttribute_set_attribute_real_doc},
509 {
"set_attribute_vec2",
511 METH_VARARGS | METH_KEYWORDS,
512 StrokeAttribute_set_attribute_vec2_doc},
513 {
"set_attribute_vec3",
515 METH_VARARGS | METH_KEYWORDS,
516 StrokeAttribute_set_attribute_vec3_doc},
517 {
nullptr,
nullptr, 0,
nullptr},
522# pragma clang diagnostic pop
524# pragma GCC diagnostic pop
531#define MATHUTILS_SUBTYPE_COLOR 1
532#define MATHUTILS_SUBTYPE_THICKNESS 2
566 self->
sa->
setColor(bmo->data[0], bmo->data[1], bmo->data[2]);
660 StrokeAttribute_alpha_doc,
661 "Alpha component of the stroke color.\n"
666 return PyFloat_FromDouble(self->
sa->
getAlpha());
674 if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) {
676 PyErr_SetString(PyExc_TypeError,
"value must be a number");
685 StrokeAttribute_color_doc,
686 "RGB components of the stroke color.\n"
688 ":type: :class:`mathutils.Color`\n");
710 StrokeAttribute_thickness_doc,
711 "Right and left components of the stroke thickness.\n"
712 "The right (left) component is the thickness on the right (left) of the vertex\n"
713 "when following the stroke.\n"
715 ":type: :class:`mathutils.Vector`\n");
737 StrokeAttribute_visible_doc,
738 "The visibility flag. True if the StrokeVertex is visible.\n"
750 if (!PyBool_Check(value)) {
751 PyErr_SetString(PyExc_TypeError,
"value must be boolean");
762 StrokeAttribute_alpha_doc,
767 StrokeAttribute_color_doc,
772 StrokeAttribute_thickness_doc,
777 StrokeAttribute_visible_doc,
779 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
785 PyVarObject_HEAD_INIT(
nullptr, 0)
804 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
bool bool_from_PyBool(PyObject *b)
bool Vec3f_ptr_from_PyObject(PyObject *obj, Vec3f &vec)
bool Vec2f_ptr_from_PyObject(PyObject *obj, Vec2f &vec)
PyObject * Vector_from_Vec3f(Vec3f &vec)
PyObject * Vector_from_Vec2f(Vec2f &vec)
PyObject * PyBool_from_bool(bool b)
PyDoc_STRVAR(FalseBP1D___doc__, "Class hierarchy: :class:`freestyle.types.BinaryPredicate1D` > :class:`FalseBP1D`\n" "\n" ".. method:: __call__(inter1, inter2)\n" "\n" " Always returns false.\n" "\n" " :param inter1: The first Interface1D object.\n" " :type inter1: :class:`freestyle.types.Interface1D`\n" " :param inter2: The second Interface1D object.\n" " :type inter2: :class:`freestyle.types.Interface1D`\n" " :return: False.\n" " :rtype: bool\n")
static int StrokeAttribute_alpha_set(BPy_StrokeAttribute *self, PyObject *value, void *)
static int StrokeAttribute_mathutils_set(blender::BaseMathObject *bmo, int subtype)
static blender::Mathutils_Callback StrokeAttribute_mathutils_cb
static int StrokeAttribute_init(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
static int StrokeAttribute_visible_set(BPy_StrokeAttribute *self, PyObject *value, void *)
static PyObject * StrokeAttribute_get_attribute_vec3(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
static int StrokeAttribute_thickness_set(BPy_StrokeAttribute *self, PyObject *value, void *)
static PyObject * StrokeAttribute_has_attribute_real(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
static int StrokeAttribute_mathutils_check(blender::BaseMathObject *bmo)
PyTypeObject StrokeAttribute_Type
static PyObject * StrokeAttribute_set_attribute_real(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
static PyObject * StrokeAttribute_has_attribute_vec2(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
#define MATHUTILS_SUBTYPE_THICKNESS
static PyObject * StrokeAttribute_visible_get(BPy_StrokeAttribute *self, void *)
static int StrokeAttribute_mathutils_set_index(blender::BaseMathObject *bmo, int subtype, int index)
static PyObject * StrokeAttribute_get_attribute_vec2(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
static PyObject * StrokeAttribute_color_get(BPy_StrokeAttribute *self, void *)
void StrokeAttribute_mathutils_register_callback()
static PyObject * StrokeAttribute_has_attribute_vec3(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
static PyMethodDef BPy_StrokeAttribute_methods[]
static PyGetSetDef BPy_StrokeAttribute_getseters[]
static int StrokeAttribute_mathutils_get(blender::BaseMathObject *bmo, int subtype)
static PyObject * StrokeAttribute_repr(BPy_StrokeAttribute *self)
static PyObject * StrokeAttribute_set_attribute_vec3(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
static PyObject * StrokeAttribute_thickness_get(BPy_StrokeAttribute *self, void *)
static PyObject * StrokeAttribute_alpha_get(BPy_StrokeAttribute *self, void *)
static int StrokeAttribute_mathutils_get_index(blender::BaseMathObject *bmo, int subtype, int index)
static int StrokeAttribute_color_set(BPy_StrokeAttribute *self, PyObject *value, void *)
static PyObject * StrokeAttribute_get_attribute_real(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
#define MATHUTILS_SUBTYPE_COLOR
static PyObject * StrokeAttribute_set_attribute_vec2(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
static uchar StrokeAttribute_mathutils_cb_index
static void StrokeAttribute_dealloc(BPy_StrokeAttribute *self)
int StrokeAttribute_Init(PyObject *module)
#define BPy_StrokeAttribute_Check(v)
void setVisible(bool iVisible)
bool isAttributeAvailableVec3f(const char *iName) const
void setThickness(float tr, float tl)
Vec3f getAttributeVec3f(const char *iName) const
void setAttributeReal(const char *iName, float att)
void setAttributeVec3f(const char *iName, const Vec3f &att)
float getThicknessR() const
void setColor(float r, float g, float b)
float getThicknessL() const
bool isAttributeAvailableVec2f(const char *iName) const
void setAlpha(float alpha)
Vec2f getAttributeVec2f(const char *iName) const
void setAttributeVec2f(const char *iName, const Vec2f &att)
bool isAttributeAvailableReal(const char *iName) const
float getAttributeReal(const char *iName) const
VecMat::Vec3< float > Vec3f
VecMat::Vec2< float > Vec2f
PyObject * Vector_CreatePyObject_cb(PyObject *cb_user, int vec_num, uchar cb_type, uchar cb_subtype)
int mathutils_array_parse(float *array, int array_num_min, int array_num_max, PyObject *value, const char *error_prefix)
PyObject * PyC_UnicodeFromStdStr(const std::string &str)
PyObject * Color_CreatePyObject_cb(PyObject *cb_user, uchar cb_type, uchar cb_subtype)
PyObject_HEAD Freestyle::StrokeAttribute * sa