Merge pull request #19142 from hyarion/refactor/add-template-addobject

Add new addObject<T>() function
This commit is contained in:
Chris Hennes
2025-02-11 09:42:47 -06:00
committed by GitHub
95 changed files with 335 additions and 340 deletions

View File

@@ -228,8 +228,7 @@ private:
std::string gcode = buffer.str();
Path::Toolpath path;
path.setFromGCode(gcode);
Path::Feature* object = static_cast<Path::Feature*>(
pcDoc->addObject("Path::Feature", file.fileNamePure().c_str()));
auto* object = pcDoc->addObject<Path::Feature>(file.fileNamePure().c_str());
object->Path.setValue(path);
pcDoc->recompute();
}
@@ -254,9 +253,8 @@ private:
if (!pcDoc) {
pcDoc = App::GetApplication().newDocument();
}
Path::PathPy* pPath = static_cast<Path::PathPy*>(pcObj);
Path::Feature* pcFeature =
static_cast<Path::Feature*>(pcDoc->addObject("Path::Feature", name));
auto* pPath = static_cast<Path::PathPy*>(pcObj);
auto* pcFeature = pcDoc->addObject<Path::Feature>(name);
Path::Toolpath* pa = pPath->getToolpathPtr();
if (!pa) {
throw Py::Exception(PyExc_ReferenceError, "object doesn't reference a valid path");

View File

@@ -1452,8 +1452,7 @@ void Area::showShape(const TopoDS_Shape& shape, const char* name, const char* fm
va_end(args);
name = buf;
}
Part::Feature* pcFeature =
static_cast<Part::Feature*>(pcDoc->addObject("Part::Feature", name));
Part::Feature* pcFeature = pcDoc->addObject<Part::Feature>(name);
pcFeature->Shape.setValue(shape);
}
}