[TD]fix hatch fail due to missing translate method

This commit is contained in:
wandererfan
2023-09-14 11:06:42 -04:00
committed by WandererFan
parent 10b3ae382f
commit 1b64b265ae
8 changed files with 114 additions and 0 deletions

View File

@@ -34,10 +34,48 @@ std::string DrawGeomHatchPy::representation() const
return std::string("<DrawGeomHatch object>");
}
//! replace the current Label with a translated version
PyObject* DrawGeomHatchPy::translateLabel(PyObject *args)
{
PyObject* pyContext;
PyObject* pyBaseName;
PyObject* pyUniqueName;
std::string context;
std::string baseName;
std::string uniqueName;
if (!PyArg_ParseTuple(args, "OOO", &pyContext, &pyBaseName, &pyUniqueName)) {
throw Py::TypeError("Could not translate label - bad parameters.");
}
Py_ssize_t size = 0;
const char* cContext = PyUnicode_AsUTF8AndSize(pyContext, &size);
if (cContext) {
context = std::string(cContext, size);
} else {
throw Py::TypeError("Could not translate label - context not available.");
}
const char* cBaseName = PyUnicode_AsUTF8AndSize(pyBaseName, &size);
if (cBaseName) {
baseName = std::string(cBaseName, size);
} else {
throw Py::TypeError("Could not translate label - base name not available.");
}
const char* cUniqueName = PyUnicode_AsUTF8AndSize(pyUniqueName, &size);
if (cUniqueName) {
uniqueName = std::string(cUniqueName, size);
} else {
throw Py::TypeError("Could not translate label - unique name not available.");
}
// we have the 3 parameters we need for DrawView::translateLabel
DrawGeomHatch* dgh = getDrawGeomHatchPtr();
dgh->translateLabel(context, baseName, uniqueName);
Py_Return;
}
PyObject *DrawGeomHatchPy::getCustomAttributes(const char* /*attr*/) const