Assembly: deleting a component deletes its joints.

This commit is contained in:
PaddleStroke
2024-06-11 15:37:52 +02:00
committed by Chris Hennes
parent f8027a16d0
commit 55dd8076cc
3 changed files with 33 additions and 0 deletions

View File

@@ -908,6 +908,32 @@ bool ViewProviderAssembly::onDelete(const std::vector<std::string>& subNames)
return ViewProviderPart::onDelete(subNames);
}
bool ViewProviderAssembly::canDelete(App::DocumentObject* obj) const
{
bool res = ViewProviderPart::canDelete(obj);
if (res) {
// If a component is deleted, then we delete the joints as well.
for (auto parent : obj->getInList()) {
if (!parent) {
continue;
}
auto* prop =
dynamic_cast<App::PropertyBool*>(parent->getPropertyByName("EnableLimits"));
auto* prop2 =
dynamic_cast<App::PropertyLink*>(parent->getPropertyByName("ObjectToGround"));
if (prop || prop2) {
Gui::Command::doCommand(Gui::Command::Doc,
"App.getDocument(\"%s\").removeObject(\"%s\")",
parent->getDocument()->getName(),
parent->getNameInDocument());
}
}
}
return res;
}
void ViewProviderAssembly::setDraggerVisibility(bool val)
{
asmDraggerSwitch->whichChild = val ? SO_SWITCH_ALL : SO_SWITCH_NONE;