CAM: Fix origin indicator for Job

This commit fixes how origin (coordinate system) indicator looks. Before
it showed as disc, and now it shows as point which is more approperiate
given the context.
This commit is contained in:
Kacper Donat
2025-07-05 18:46:01 +02:00
parent f72397ce19
commit 38ec685f2d
4 changed files with 56 additions and 27 deletions

View File

@@ -527,6 +527,44 @@ inline void PyTypeCheck(PyObject** ptr, int (*method)(PyObject*), const char* ms
}
}
/**
* @brief Registers a C++ enum as a Python IntEnum in the specified module.
*
* This function dynamically creates a Python `IntEnum` class using the provided
* C++ enum entries and registers it under the given name within the specified
* Python module. It allows seamless integration of C++ enums into Python, making
* them accessible and usable in Python scripts.
*
* @tparam T The type of the enum values.
* @param module The Python module where the enum will be registered.
* @param name The name to be given to the Python IntEnum.
* @param entries A map of string keys to enum values, representing the enum definition.
*/
template <typename T>
void PyRegisterEnum(PyObject* module, const char* name, const std::map<const char*, T>& entries)
{
PyObject* pyEnumModule = PyImport_ImportModule("enum");
if (!pyEnumModule) {
return;
}
PyObject* pyConstantsDict = PyDict_New();
// Populate dictionary
for (const auto& [key, value] : entries) {
PyDict_SetItemString(pyConstantsDict, key, PyLong_FromLong(static_cast<int>(value)));
}
PyObject* pyEnumClass = PyObject_CallMethod(pyEnumModule, "IntEnum", "sO", name, pyConstantsDict);
Py_CLEAR(pyConstantsDict);
Py_CLEAR(pyEnumModule);
if (pyEnumClass && PyModule_AddObject(module, name, pyEnumClass) < 0) {
Py_CLEAR(pyEnumClass);
}
}
} // namespace Base