MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / PyInit

Method PyInit

src/Base/RotationPyImp.cpp:62–148  ·  view source on GitHub ↗

clang-format off constructor method

Source from the content-addressed store, hash-verified

60// clang-format off
61// constructor method
62int RotationPy::PyInit(PyObject* args, PyObject* kwds)
63{
64 PyObject* o {};
65 if (PyArg_ParseTuple(args, "")) {
66 return 0;
67 }
68
69 PyErr_Clear();
70 if (PyArg_ParseTuple(args, "O!", &(RotationPy::Type), &o)) {
71 Rotation* rot = static_cast<RotationPy*>(o)->getRotationPtr();
72 getRotationPtr()->setValue(rot->getValue());
73 return 0;
74 }
75
76 PyErr_Clear();
77 double angle {};
78 static const std::array<const char*, 3> kw_deg {"Axis", "Degree", nullptr};
79 if (Wrapped_ParseTupleAndKeywords(args,
80 kwds,
81 "O!d",
82 kw_deg,
83 &(VectorPy::Type),
84 &o,
85 &angle)) {
86 // NOTE: The last parameter defines the rotation angle in degree.
87 getRotationPtr()->setValue(static_cast<VectorPy*>(o)->value(),
88 toRadians<double>(angle));
89 return 0;
90 }
91
92 PyErr_Clear();
93 static const std::array<const char*, 3> kw_rad {"Axis", "Radian", nullptr};
94 if (Wrapped_ParseTupleAndKeywords(args,
95 kwds,
96 "O!d",
97 kw_rad,
98 &(VectorPy::Type),
99 &o,
100 &angle)) {
101 getRotationPtr()->setValue(static_cast<VectorPy*>(o)->value(), angle);
102 return 0;
103 }
104
105 PyErr_Clear();
106 if (PyArg_ParseTuple(args, "O!", &(MatrixPy::Type), &o)) {
107 try {
108 getRotationPtr()->setValue(static_cast<MatrixPy*>(o)->value());
109 return 0;
110 }
111 catch (const Exception& e) {
112 PyErr_SetString(e.getPyExceptionType(), e.what());
113 return -1;
114 }
115 }
116
117 PyErr_Clear();
118 double q0 {};
119 double q1 {};

Callers

nothing calls this directly

Calls 8

getPyExceptionTypeMethod · 0.80
setValueMethod · 0.45
getValueMethod · 0.45
valueMethod · 0.45
whatMethod · 0.45
setYawPitchRollMethod · 0.45
setEulerAnglesMethod · 0.45

Tested by

no test coverage detected