13#include "../generic/py_capi_utils.hh"
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__()\n"
45 " __init__(brother)\n"
46 " __init__(red, green, blue, alpha, thickness_right, thickness_left)\n"
47 " __init__(attribute1, attribute2, t)\n"
49 " Creates a :class:`StrokeAttribute` object using either a default constructor,\n"
50 " copy constructor, overloaded constructor, or and interpolation constructor\n"
51 " to interpolate between two :class:`StrokeAttribute` objects.\n"
53 " :arg brother: A StrokeAttribute object to be used as a copy constructor.\n"
54 " :type brother: :class:`StrokeAttribute`\n"
55 " :arg red: Red component of a stroke color.\n"
57 " :arg green: Green component of a stroke color.\n"
58 " :type green: float\n"
59 " :arg blue: Blue component of a stroke color.\n"
60 " :type blue: float\n"
61 " :arg alpha: Alpha component of a stroke color.\n"
62 " :type alpha: float\n"
63 " :arg thickness_right: Stroke thickness on the right.\n"
64 " :type thickness_right: float\n"
65 " :arg thickness_left: Stroke thickness on the left.\n"
66 " :type thickness_left: float\n"
67 " :arg attribute1: The first StrokeAttribute object.\n"
68 " :type attribute1: :class:`StrokeAttribute`\n"
69 " :arg attribute2: The second StrokeAttribute object.\n"
70 " :type attribute2: :class:`StrokeAttribute`\n"
71 " :arg t: The interpolation parameter (0 <= t <= 1).\n"
75 static const char *kwlist_1[] = {
"brother",
nullptr};
76 static const char *kwlist_2[] = {
"attribute1",
"attribute2",
"t",
nullptr};
77 static const char *kwlist_3[] = {
78 "red",
"green",
"blue",
"alpha",
"thickness_right",
"thickness_left",
nullptr};
79 PyObject *obj1 =
nullptr, *obj2 =
nullptr;
80 float red, green, blue, alpha, thickness_right, thickness_left, t;
82 if (PyArg_ParseTupleAndKeywords(
92 else if ((
void)PyErr_Clear(),
93 PyArg_ParseTupleAndKeywords(args,
106 else if ((
void)PyErr_Clear(),
107 PyArg_ParseTupleAndKeywords(args,
121 PyErr_SetString(PyExc_TypeError,
"invalid argument(s)");
124 self->borrowed =
false;
133 Py_TYPE(
self)->tp_free((PyObject *)
self);
138 stringstream repr(
"StrokeAttribute:");
139 repr <<
" r: " <<
self->sa->getColorR() <<
" g: " <<
self->sa->getColorG()
140 <<
" b: " <<
self->sa->getColorB() <<
" a: " <<
self->sa->getAlpha()
141 <<
" - R: " <<
self->sa->getThicknessR() <<
" L: " <<
self->sa->getThicknessL();
148 StrokeAttribute_get_attribute_real_doc,
149 ".. method:: get_attribute_real(name)\n"
151 " Returns an attribute of float type.\n"
153 " :arg name: The name of the attribute.\n"
155 " :return: The attribute value.\n"
161 static const char *kwlist[] = {
"name",
nullptr};
164 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"s", (
char **)kwlist, &attr)) {
167 double a =
self->sa->getAttributeReal(attr);
168 return PyFloat_FromDouble(
a);
173 StrokeAttribute_get_attribute_vec2_doc,
174 ".. method:: get_attribute_vec2(name)\n"
176 " Returns an attribute of two-dimensional vector type.\n"
178 " :arg name: The name of the attribute.\n"
180 " :return: The attribute value.\n"
181 " :rtype: :class:`mathutils.Vector`\n");
186 static const char *kwlist[] = {
"name",
nullptr};
189 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"s", (
char **)kwlist, &attr)) {
198 StrokeAttribute_get_attribute_vec3_doc,
199 ".. method:: get_attribute_vec3(name)\n"
201 " Returns an attribute of three-dimensional vector type.\n"
203 " :arg 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, kwds,
"s", (
char **)kwlist, &attr)) {
223 StrokeAttribute_has_attribute_real_doc,
224 ".. method:: has_attribute_real(name)\n"
226 " Checks whether the attribute name of float type is available.\n"
228 " :arg name: The name of the attribute.\n"
230 " :return: True if the attribute is available.\n"
236 static const char *kwlist[] = {
"name",
nullptr};
239 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"s", (
char **)kwlist, &attr)) {
247 StrokeAttribute_has_attribute_vec2_doc,
248 ".. method:: has_attribute_vec2(name)\n"
250 " Checks whether the attribute name of two-dimensional vector type\n"
253 " :arg name: The name of the attribute.\n"
255 " :return: True if the attribute is available.\n"
261 static const char *kwlist[] = {
"name",
nullptr};
264 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"s", (
char **)kwlist, &attr)) {
272 StrokeAttribute_has_attribute_vec3_doc,
273 ".. method:: has_attribute_vec3(name)\n"
275 " Checks whether the attribute name of three-dimensional vector\n"
276 " type is available.\n"
278 " :arg name: The name of the attribute.\n"
280 " :return: True if the attribute is available.\n"
286 static const char *kwlist[] = {
"name",
nullptr};
289 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"s", (
char **)kwlist, &attr)) {
297 StrokeAttribute_set_attribute_real_doc,
298 ".. method:: set_attribute_real(name, value)\n"
300 " Adds a user-defined attribute of float type. If there is no\n"
301 " attribute of the given name, it is added. Otherwise, the new value\n"
302 " replaces the old one.\n"
304 " :arg name: The name of the attribute.\n"
306 " :arg value: The attribute value.\n"
307 " :type value: float\n");
312 static const char *kwlist[] = {
"name",
"value",
nullptr};
316 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"sd", (
char **)kwlist, &s, &d)) {
319 self->sa->setAttributeReal(s, d);
325 StrokeAttribute_set_attribute_vec2_doc,
326 ".. method:: set_attribute_vec2(name, value)\n"
328 " Adds a user-defined attribute of two-dimensional vector type. If\n"
329 " there is no attribute of the given name, it is added. Otherwise,\n"
330 " the new value replaces the old one.\n"
332 " :arg name: The name of the attribute.\n"
334 " :arg value: The attribute value.\n"
335 " :type value: :class:`mathutils.Vector` | tuple[float, float, float] | list[float]\n");
340 static const char *kwlist[] = {
"name",
"value",
nullptr};
342 PyObject *obj =
nullptr;
345 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"sO", (
char **)kwlist, &s, &obj)) {
349 PyErr_SetString(PyExc_TypeError,
350 "argument 2 must be a 2D vector (either a list of 2 elements or Vector)");
353 self->sa->setAttributeVec2f(s, vec);
359 StrokeAttribute_set_attribute_vec3_doc,
360 ".. method:: set_attribute_vec3(name, value)\n"
362 " Adds a user-defined attribute of three-dimensional vector type.\n"
363 " If there is no attribute of the given name, it is added.\n"
364 " Otherwise, the new value replaces the old one.\n"
366 " :arg name: The name of the attribute.\n"
368 " :arg value: The attribute value as a 3D vector.\n"
369 " :type value: :class:`mathutils.Vector` | tuple[float, float, float] | list[float]\n");
374 static const char *kwlist[] = {
"name",
"value",
nullptr};
376 PyObject *obj =
nullptr;
379 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"sO", (
char **)kwlist, &s, &obj)) {
383 PyErr_SetString(PyExc_TypeError,
384 "argument 2 must be a 3D vector (either a list of 3 elements or Vector)");
387 self->sa->setAttributeVec3f(s, vec);
393# pragma clang diagnostic push
394# pragma clang diagnostic ignored "-Wcast-function-type"
396# pragma GCC diagnostic push
397# pragma GCC diagnostic ignored "-Wcast-function-type"
402 {
"get_attribute_real",
404 METH_VARARGS | METH_KEYWORDS,
405 StrokeAttribute_get_attribute_real_doc},
406 {
"get_attribute_vec2",
408 METH_VARARGS | METH_KEYWORDS,
409 StrokeAttribute_get_attribute_vec2_doc},
410 {
"get_attribute_vec3",
412 METH_VARARGS | METH_KEYWORDS,
413 StrokeAttribute_get_attribute_vec3_doc},
414 {
"has_attribute_real",
416 METH_VARARGS | METH_KEYWORDS,
417 StrokeAttribute_has_attribute_real_doc},
418 {
"has_attribute_vec2",
420 METH_VARARGS | METH_KEYWORDS,
421 StrokeAttribute_has_attribute_vec2_doc},
422 {
"has_attribute_vec3",
424 METH_VARARGS | METH_KEYWORDS,
425 StrokeAttribute_has_attribute_vec3_doc},
426 {
"set_attribute_real",
428 METH_VARARGS | METH_KEYWORDS,
429 StrokeAttribute_set_attribute_real_doc},
430 {
"set_attribute_vec2",
432 METH_VARARGS | METH_KEYWORDS,
433 StrokeAttribute_set_attribute_vec2_doc},
434 {
"set_attribute_vec3",
436 METH_VARARGS | METH_KEYWORDS,
437 StrokeAttribute_set_attribute_vec3_doc},
438 {
nullptr,
nullptr, 0,
nullptr},
443# pragma clang diagnostic pop
445# pragma GCC diagnostic pop
452#define MATHUTILS_SUBTYPE_COLOR 1
453#define MATHUTILS_SUBTYPE_THICKNESS 2
468 bmo->data[0] =
self->sa->getColorR();
469 bmo->data[1] =
self->sa->getColorG();
470 bmo->data[2] =
self->sa->getColorB();
473 bmo->data[0] =
self->sa->getThicknessR();
474 bmo->data[1] =
self->sa->getThicknessL();
487 self->sa->setColor(bmo->data[0], bmo->data[1], bmo->data[2]);
490 self->sa->setThickness(bmo->data[0], bmo->data[1]);
505 bmo->data[0] =
self->sa->getColorR();
508 bmo->data[1] =
self->sa->getColorG();
511 bmo->data[2] =
self->sa->getColorB();
520 bmo->data[0] =
self->sa->getThicknessR();
523 bmo->data[1] =
self->sa->getThicknessL();
540 float r = (index == 0) ? bmo->data[0] :
self->sa->getColorR();
541 float g = (index == 1) ? bmo->data[1] :
self->sa->getColorG();
542 float b = (index == 2) ? bmo->data[2] :
self->sa->getColorB();
543 self->sa->setColor(r, g,
b);
547 float tr = (index == 0) ? bmo->data[0] :
self->sa->getThicknessR();
548 float tl = (index == 1) ? bmo->data[1] :
self->sa->getThicknessL();
549 self->sa->setThickness(tr, tl);
577 StrokeAttribute_alpha_doc,
578 "Alpha component of the stroke color.\n"
583 return PyFloat_FromDouble(
self->sa->getAlpha());
591 if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) {
593 PyErr_SetString(PyExc_TypeError,
"value must be a number");
596 self->sa->setAlpha(scalar);
602 StrokeAttribute_color_doc,
603 "RGB components of the stroke color.\n"
605 ":type: :class:`mathutils.Color`\n");
620 self->sa->setColor(
v[0],
v[1],
v[2]);
626 StrokeAttribute_thickness_doc,
627 "Right and left components of the stroke thickness.\n"
628 "The right (left) component is the thickness on the right (left) of the vertex\n"
629 "when following the stroke.\n"
631 ":type: :class:`mathutils.Vector`\n");
646 self->sa->setThickness(
v[0],
v[1]);
652 StrokeAttribute_visible_doc,
653 "The visibility flag. True if the StrokeVertex is visible.\n"
665 if (!PyBool_Check(value)) {
666 PyErr_SetString(PyExc_TypeError,
"value must be boolean");
677 StrokeAttribute_alpha_doc,
682 StrokeAttribute_color_doc,
687 StrokeAttribute_thickness_doc,
692 StrokeAttribute_visible_doc,
694 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
700 PyVarObject_HEAD_INIT(
nullptr, 0)
719 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)
static int StrokeAttribute_alpha_set(BPy_StrokeAttribute *self, PyObject *value, void *)
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_set(BaseMathObject *bmo, int subtype)
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_get_index(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 Mathutils_Callback StrokeAttribute_mathutils_cb
static PyGetSetDef BPy_StrokeAttribute_getseters[]
static PyObject * StrokeAttribute_repr(BPy_StrokeAttribute *self)
static PyObject * StrokeAttribute_set_attribute_vec3(BPy_StrokeAttribute *self, PyObject *args, PyObject *kwds)
PyDoc_STRVAR(StrokeAttribute_doc, "Class to define a set of attributes associated with a :class:`StrokeVertex`.\n" "The attribute set stores the color, alpha and thickness values for a Stroke\n" "Vertex.\n" "\n" ".. method:: __init__()\n" " __init__(brother)\n" " __init__(red, green, blue, alpha, thickness_right, thickness_left)\n" " __init__(attribute1, attribute2, t)\n" "\n" " Creates a :class:`StrokeAttribute` object using either a default constructor,\n" " copy constructor, overloaded constructor, or and interpolation constructor\n" " to interpolate between two :class:`StrokeAttribute` objects.\n" "\n" " :arg brother: A StrokeAttribute object to be used as a copy constructor.\n" " :type brother: :class:`StrokeAttribute`\n" " :arg red: Red component of a stroke color.\n" " :type red: float\n" " :arg green: Green component of a stroke color.\n" " :type green: float\n" " :arg blue: Blue component of a stroke color.\n" " :type blue: float\n" " :arg alpha: Alpha component of a stroke color.\n" " :type alpha: float\n" " :arg thickness_right: Stroke thickness on the right.\n" " :type thickness_right: float\n" " :arg thickness_left: Stroke thickness on the left.\n" " :type thickness_left: float\n" " :arg attribute1: The first StrokeAttribute object.\n" " :type attribute1: :class:`StrokeAttribute`\n" " :arg attribute2: The second StrokeAttribute object.\n" " :type attribute2: :class:`StrokeAttribute`\n" " :arg t: The interpolation parameter (0 <= t <= 1).\n" " :type t: float\n")
static PyObject * StrokeAttribute_thickness_get(BPy_StrokeAttribute *self, void *)
static PyObject * StrokeAttribute_alpha_get(BPy_StrokeAttribute *self, void *)
static int StrokeAttribute_mathutils_check(BaseMathObject *bmo)
static int StrokeAttribute_mathutils_get(BaseMathObject *bmo, int subtype)
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 int StrokeAttribute_mathutils_set_index(BaseMathObject *bmo, int subtype, int index)
static uchar StrokeAttribute_mathutils_cb_index
static void StrokeAttribute_dealloc(BPy_StrokeAttribute *self)
int StrokeAttribute_Init(PyObject *module)
#define BPy_StrokeAttribute_Check(v)
ATTR_WARN_UNUSED_RESULT const BMVert * v
int mathutils_array_parse(float *array, int array_num_min, int array_num_max, PyObject *value, const char *error_prefix)
uchar Mathutils_RegisterCallback(Mathutils_Callback *cb)
PyObject * Color_CreatePyObject_cb(PyObject *cb_user, uchar cb_type, uchar cb_subtype)
PyObject * Vector_CreatePyObject_cb(PyObject *cb_user, int vec_num, uchar cb_type, uchar cb_subtype)
VecMat::Vec2< float > Vec2f
PyObject * PyC_UnicodeFromStdStr(const std::string &str)
static struct PyModuleDef module