Assembly: deleting a component deletes its joints.
This commit is contained in:
committed by
Chris Hennes
parent
99aebd8a33
commit
3052760541
@@ -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;
|
||||
|
||||
@@ -72,6 +72,7 @@ public:
|
||||
|
||||
bool doubleClicked() override;
|
||||
bool onDelete(const std::vector<std::string>& subNames) override;
|
||||
bool canDelete(App::DocumentObject* obj) const override;
|
||||
|
||||
/** @name enter/exit edit mode */
|
||||
//@{
|
||||
|
||||
@@ -941,6 +941,9 @@ class ViewProviderJoint:
|
||||
|
||||
return True
|
||||
|
||||
def canDelete(self, _obj):
|
||||
return True
|
||||
|
||||
|
||||
################ Grounded Joint object #################
|
||||
|
||||
@@ -1143,6 +1146,9 @@ class ViewProviderGroundedJoint:
|
||||
Since no data were serialized nothing needs to be done here."""
|
||||
return None
|
||||
|
||||
def canDelete(self, _obj):
|
||||
return True
|
||||
|
||||
|
||||
class MakeJointSelGate:
|
||||
def __init__(self, taskbox, assembly):
|
||||
|
||||
Reference in New Issue
Block a user