MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / onChanged

Method onChanged

src/Mod/PartDesign/App/Body.cpp:440–501  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

438}
439
440void Body::onChanged(const App::Property* prop)
441{
442 // we neither load a project nor perform undo/redo
443 if (!this->isRestoring() && this->getDocument()
444 && !this->getDocument()->isPerformingTransaction()) {
445 if (prop == &BaseFeature) {
446 FeatureBase* bf = nullptr;
447 auto first = Group.getValues().empty() ? nullptr : Group.getValues().front();
448
449 if (BaseFeature.getValue()) {
450 // setup the FeatureBase if needed
451 if (!first || !first->isDerivedFrom<FeatureBase>()) {
452 bf = getDocument()->addObject<FeatureBase>("BaseFeature");
453 insertObject(bf, first, false);
454
455 if (!Tip.getValue()) {
456 Tip.setValue(bf);
457 }
458 }
459 else {
460 bf = static_cast<FeatureBase*>(first);
461 }
462 }
463
464 if (bf && (bf->BaseFeature.getValue() != BaseFeature.getValue())) {
465 bf->BaseFeature.setValue(BaseFeature.getValue());
466 }
467 }
468 else if (prop == &Group) {
469 // if the FeatureBase was deleted we set the BaseFeature link to nullptr
470 if (BaseFeature.getValue()
471 && (Group.getValues().empty()
472 || !Group.getValues().front()->isDerivedFrom<FeatureBase>())) {
473 BaseFeature.setValue(nullptr);
474 }
475 }
476 else if (prop == &AllowCompound) {
477 // As disallowing compounds can break the model we need to recompute the whole tree.
478 // This will inform user about first place where there is more than one solid.
479 // On allowing compounds we must also recompute the entire feature tree
480 for (auto feature : getFullModel()) {
481 feature->enforceRecompute();
482 }
483 }
484 else if (prop == &ShapeMaterial) {
485 std::vector<App::DocumentObject*> features = Group.getValues();
486 if (!features.empty()) {
487 for (auto it : features) {
488 auto feature = dynamic_cast<Part::Feature*>(it);
489 if (feature) {
490 if (feature->ShapeMaterial.getValue().getUUID()
491 != ShapeMaterial.getValue().getUUID()) {
492 feature->ShapeMaterial.setValue(ShapeMaterial.getValue());
493 }
494 }
495 }
496 }
497 }

Callers

nothing calls this directly

Calls 13

getFullModelFunction · 0.85
onChangedFunction · 0.85
isRestoringMethod · 0.80
getDocumentFunction · 0.50
getDocumentMethod · 0.45
emptyMethod · 0.45
getValuesMethod · 0.45
frontMethod · 0.45
getValueMethod · 0.45
setValueMethod · 0.45
enforceRecomputeMethod · 0.45

Tested by

no test coverage detected