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"
76 static const char *kwlist_1[] = {
"brother",
nullptr};
77 static const char *kwlist_2[] = {
"attribute1",
"attribute2",
"t",
nullptr};
78 static const char *kwlist_3[] = {
79 "red",
"green",
"blue",
"alpha",
"thickness_right",
"thickness_left",
nullptr};
80 PyObject *obj1 =
nullptr, *obj2 =
nullptr;
81 float red, green, blue, alpha, thickness_right, thickness_left, t;
83 if (PyArg_ParseTupleAndKeywords(
93 else if ((
void)PyErr_Clear(),
94 PyArg_ParseTupleAndKeywords(args,
107 else if ((
void)PyErr_Clear(),
108 PyArg_ParseTupleAndKeywords(args,
122 PyErr_SetString(PyExc_TypeError,
"invalid argument(s)");
125 self->borrowed =
false;
134 Py_TYPE(
self)->tp_free((PyObject *)
self);
139 stringstream repr(
"StrokeAttribute:");
140 repr <<
" r: " <<
self->sa->getColorR() <<
" g: " <<
self->sa->getColorG()
141 <<
" b: " <<
self->sa->getColorB() <<
" a: " <<
self->sa->getAlpha()
142 <<
" - R: " <<
self->sa->getThicknessR() <<
" L: " <<
self->sa->getThicknessL();
149 StrokeAttribute_get_attribute_real_doc,
150 ".. method:: get_attribute_real(name)\n"
152 " Returns an attribute of float type.\n"
154 " :arg name: The name of the attribute.\n"
156 " :return: The attribute value.\n"
163 static const char *kwlist[] = {
"name",
nullptr};
166 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"s", (
char **)kwlist, &attr)) {
169 double a =
self->sa->getAttributeReal(attr);
170 return PyFloat_FromDouble(
a);
175 StrokeAttribute_get_attribute_vec2_doc,
176 ".. method:: get_attribute_vec2(name)\n"
178 " Returns an attribute of two-dimensional vector type.\n"
180 " :arg name: The name of the attribute.\n"
182 " :return: The attribute value.\n"
183 " :rtype: :class:`mathutils.Vector`\n");
189 static const char *kwlist[] = {
"name",
nullptr};
192 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"s", (
char **)kwlist, &attr)) {
201 StrokeAttribute_get_attribute_vec3_doc,
202 ".. method:: get_attribute_vec3(name)\n"
204 " Returns an attribute of three-dimensional vector type.\n"
206 " :arg name: The name of the attribute.\n"
208 " :return: The attribute value.\n"
209 " :rtype: :class:`mathutils.Vector`\n");
215 static const char *kwlist[] = {
"name",
nullptr};
218 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"s", (
char **)kwlist, &attr)) {
227 StrokeAttribute_has_attribute_real_doc,
228 ".. method:: has_attribute_real(name)\n"
230 " Checks whether the attribute name of float type is available.\n"
232 " :arg name: The name of the attribute.\n"
234 " :return: True if the attribute is available.\n"
241 static const char *kwlist[] = {
"name",
nullptr};
244 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"s", (
char **)kwlist, &attr)) {
252 StrokeAttribute_has_attribute_vec2_doc,
253 ".. method:: has_attribute_vec2(name)\n"
255 " Checks whether the attribute name of two-dimensional vector type\n"
258 " :arg name: The name of the attribute.\n"
260 " :return: True if the attribute is available.\n"
267 static const char *kwlist[] = {
"name",
nullptr};
270 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"s", (
char **)kwlist, &attr)) {
278 StrokeAttribute_has_attribute_vec3_doc,
279 ".. method:: has_attribute_vec3(name)\n"
281 " Checks whether the attribute name of three-dimensional vector\n"
282 " type is available.\n"
284 " :arg name: The name of the attribute.\n"
286 " :return: True if the attribute is available.\n"
293 static const char *kwlist[] = {
"name",
nullptr};
296 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"s", (
char **)kwlist, &attr)) {
304 StrokeAttribute_set_attribute_real_doc,
305 ".. method:: set_attribute_real(name, value)\n"
307 " Adds a user-defined attribute of float type. If there is no\n"
308 " attribute of the given name, it is added. Otherwise, the new value\n"
309 " replaces the old one.\n"
311 " :arg name: The name of the attribute.\n"
313 " :arg value: The attribute value.\n"
314 " :type value: float\n");
320 static const char *kwlist[] = {
"name",
"value",
nullptr};
324 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"sd", (
char **)kwlist, &s, &d)) {
327 self->sa->setAttributeReal(s, d);
333 StrokeAttribute_set_attribute_vec2_doc,
334 ".. method:: set_attribute_vec2(name, value)\n"
336 " Adds a user-defined attribute of two-dimensional vector type. If\n"
337 " there is no attribute of the given name, it is added. Otherwise,\n"
338 " the new value replaces the old one.\n"
340 " :arg name: The name of the attribute.\n"
342 " :arg value: The attribute value.\n"
343 " :type value: :class:`mathutils.Vector` | tuple[float, float, float] | list[float]\n");
349 static const char *kwlist[] = {
"name",
"value",
nullptr};
351 PyObject *obj =
nullptr;
354 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"sO", (
char **)kwlist, &s, &obj)) {
358 PyErr_SetString(PyExc_TypeError,
359 "argument 2 must be a 2D vector (either a list of 2 elements or Vector)");
362 self->sa->setAttributeVec2f(s, vec);
368 StrokeAttribute_set_attribute_vec3_doc,
369 ".. method:: set_attribute_vec3(name, value)\n"
371 " Adds a user-defined attribute of three-dimensional vector type.\n"
372 " If there is no attribute of the given name, it is added.\n"
373 " Otherwise, the new value replaces the old one.\n"
375 " :arg name: The name of the attribute.\n"
377 " :arg value: The attribute value as a 3D vector.\n"
378 " :type value: :class:`mathutils.Vector` | tuple[float, float, float] | list[float]\n");
384 static const char *kwlist[] = {
"name",
"value",
nullptr};
386 PyObject *obj =
nullptr;
389 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"sO", (
char **)kwlist, &s, &obj)) {
393 PyErr_SetString(PyExc_TypeError,
394 "argument 2 must be a 3D vector (either a list of 3 elements or Vector)");
397 self->sa->setAttributeVec3f(s, vec);
403# pragma clang diagnostic push
404# pragma clang diagnostic ignored "-Wcast-function-type"
406# pragma GCC diagnostic push
407# pragma GCC diagnostic ignored "-Wcast-function-type"
412 {
"get_attribute_real",
414 METH_VARARGS | METH_KEYWORDS,
415 StrokeAttribute_get_attribute_real_doc},
416 {
"get_attribute_vec2",
418 METH_VARARGS | METH_KEYWORDS,
419 StrokeAttribute_get_attribute_vec2_doc},
420 {
"get_attribute_vec3",
422 METH_VARARGS | METH_KEYWORDS,
423 StrokeAttribute_get_attribute_vec3_doc},
424 {
"has_attribute_real",
426 METH_VARARGS | METH_KEYWORDS,
427 StrokeAttribute_has_attribute_real_doc},
428 {
"has_attribute_vec2",
430 METH_VARARGS | METH_KEYWORDS,
431 StrokeAttribute_has_attribute_vec2_doc},
432 {
"has_attribute_vec3",
434 METH_VARARGS | METH_KEYWORDS,
435 StrokeAttribute_has_attribute_vec3_doc},
436 {
"set_attribute_real",
438 METH_VARARGS | METH_KEYWORDS,
439 StrokeAttribute_set_attribute_real_doc},
440 {
"set_attribute_vec2",
442 METH_VARARGS | METH_KEYWORDS,
443 StrokeAttribute_set_attribute_vec2_doc},
444 {
"set_attribute_vec3",
446 METH_VARARGS | METH_KEYWORDS,
447 StrokeAttribute_set_attribute_vec3_doc},
448 {
nullptr,
nullptr, 0,
nullptr},
453# pragma clang diagnostic pop
455# pragma GCC diagnostic pop
462#define MATHUTILS_SUBTYPE_COLOR 1
463#define MATHUTILS_SUBTYPE_THICKNESS 2
478 bmo->data[0] =
self->sa->getColorR();
479 bmo->data[1] =
self->sa->getColorG();
480 bmo->data[2] =
self->sa->getColorB();
483 bmo->data[0] =
self->sa->getThicknessR();
484 bmo->data[1] =
self->sa->getThicknessL();
497 self->sa->setColor(bmo->data[0], bmo->data[1], bmo->data[2]);
500 self->sa->setThickness(bmo->data[0], bmo->data[1]);
515 bmo->data[0] =
self->sa->getColorR();
518 bmo->data[1] =
self->sa->getColorG();
521 bmo->data[2] =
self->sa->getColorB();
530 bmo->data[0] =
self->sa->getThicknessR();
533 bmo->data[1] =
self->sa->getThicknessL();
550 float r = (index == 0) ? bmo->data[0] :
self->sa->getColorR();
551 float g = (index == 1) ? bmo->data[1] :
self->sa->getColorG();
552 float b = (index == 2) ? bmo->data[2] :
self->sa->getColorB();
553 self->sa->setColor(r, g,
b);
557 float tr = (index == 0) ? bmo->data[0] :
self->sa->getThicknessR();
558 float tl = (index == 1) ? bmo->data[1] :
self->sa->getThicknessL();
559 self->sa->setThickness(tr, tl);
587 StrokeAttribute_alpha_doc,
588 "Alpha component of the stroke color.\n"
594 return PyFloat_FromDouble(
self->sa->getAlpha());
602 if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) {
604 PyErr_SetString(PyExc_TypeError,
"value must be a number");
607 self->sa->setAlpha(scalar);
613 StrokeAttribute_color_doc,
614 "RGB components of the stroke color.\n"
616 ":type: :class:`mathutils.Color`");
632 self->sa->setColor(
v[0],
v[1],
v[2]);
638 StrokeAttribute_thickness_doc,
639 "Right and left components of the stroke thickness.\n"
640 "The right (left) component is the thickness on the right (left) of the vertex\n"
641 "when following the stroke.\n"
643 ":type: :class:`mathutils.Vector`");
659 self->sa->setThickness(
v[0],
v[1]);
665 StrokeAttribute_visible_doc,
666 "The visibility flag. True if the StrokeVertex is visible.\n"
679 if (!PyBool_Check(value)) {
680 PyErr_SetString(PyExc_TypeError,
"value must be boolean");
691 StrokeAttribute_alpha_doc,
696 StrokeAttribute_color_doc,
701 StrokeAttribute_thickness_doc,
706 StrokeAttribute_visible_doc,
708 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
714 PyVarObject_HEAD_INIT(
nullptr, 0)
733 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