PartDesign: Implement preview for Booleans

This commit is contained in:
Kacper Donat
2025-08-12 20:28:14 +02:00
parent 0aa95996d9
commit 18792297f6
7 changed files with 208 additions and 73 deletions

View File

@@ -164,21 +164,55 @@ App::DocumentObjectExecReturn *Boolean::execute()
}
this->Shape.setValue(getSolid(result));
return App::DocumentObject::StdReturn;
return StdReturn;
}
void Boolean::updatePreviewShape()
{
if (strcmp(Type.getValueAsString(), "Cut") == 0) {
TopoShape base = getBaseTopoShape(true).moved(getLocation().Inverted());
TopoShape result = Shape.getShape();
PreviewShape.setValue(base.makeElementCut(result.getShape()));
return;
}
if (strcmp(Type.getValueAsString(), "Fuse") == 0) {
std::vector<TopoShape> shapes;
for (auto& obj : Group.getValues()) {
shapes.push_back(getTopoShape(obj, Part::ShapeOption::ResolveLink | Part::ShapeOption::Transform));
}
TopoShape result;
result.makeCompound(shapes);
PreviewShape.setValue(result.getShape());
return;
}
PreviewShape.setValue(Shape.getShape());
}
void Boolean::onChanged(const App::Property* prop) {
if(strcmp(prop->getName(), "Group") == 0)
if (strcmp(prop->getName(), "Group") == 0) {
touch();
}
PartDesign::Feature::onChanged(prop);
if (strcmp(prop->getName(), "Shape") == 0) {
updatePreviewShape();
}
Feature::onChanged(prop);
}
void Boolean::handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName)
{
// The App::PropertyLinkList property was Bodies in the past
Base::Type type = Base::Type::fromName(TypeName);
if (Group.getClassTypeId() == type && strcmp(PropName, "Bodies") == 0) {
Group.Restore(reader);
}