From 6025ebd4beef57b41e4cbf2b80676cdc6de41028 Mon Sep 17 00:00:00 2001 From: bgbsww Date: Wed, 10 Jul 2024 09:50:44 -0400 Subject: [PATCH 1/2] Toponaming: Restore code for instant sketch position updates --- src/Mod/Part/App/AttachExtension.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Mod/Part/App/AttachExtension.cpp b/src/Mod/Part/App/AttachExtension.cpp index 10d86d6bf8..56acb340bc 100644 --- a/src/Mod/Part/App/AttachExtension.cpp +++ b/src/Mod/Part/App/AttachExtension.cpp @@ -305,6 +305,7 @@ bool AttachExtension::positionBySupport() throw Base::RuntimeError( "AttachExtension: can't positionBySupport, because no AttachEngine is set."); } + updateAttacherVals(); Base::Placement plaOriginal = getPlacement().getValue(); try { if (_props.attacher->mapMode == mmDeactivated) { @@ -397,6 +398,24 @@ App::DocumentObjectExecReturn* AttachExtension::extensionExecute() void AttachExtension::extensionOnChanged(const App::Property* prop) { if (!getExtendedObject()->isRestoring()) { + // If we change anything that affects our position, update it immediately so you can see it + // interactively. + if ((prop == &AttachmentSupport + || prop == &MapMode + || prop == &MapPathParameter + || prop == &MapReversed + || prop == &AttachmentOffset)){ + try{ + positionBySupport(); + } catch (Base::Exception &e) { + getExtendedObject()->setStatus(App::Error, true); + Base::Console().Error("PositionBySupport: %s\n",e.what()); + //set error message - how? + } catch (Standard_Failure &e){ + getExtendedObject()->setStatus(App::Error, true); + Base::Console().Error("PositionBySupport: %s\n",e.GetMessageString()); + } + } if (prop == &AttacherEngine) { AttacherType.setValue(enumToClass(AttacherEngine.getValueAsString())); } From 65155936a6cc3e9f9f72a13c356d9fec94f83f33 Mon Sep 17 00:00:00 2001 From: bgbsww Date: Wed, 10 Jul 2024 10:53:20 -0400 Subject: [PATCH 2/2] Toponaming: Restore hiding of unused properties --- src/Mod/Part/App/AttachExtension.cpp | 49 +++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/src/Mod/Part/App/AttachExtension.cpp b/src/Mod/Part/App/AttachExtension.cpp index 56acb340bc..2d80745bc4 100644 --- a/src/Mod/Part/App/AttachExtension.cpp +++ b/src/Mod/Part/App/AttachExtension.cpp @@ -140,6 +140,11 @@ AttachExtension::AttachExtension() App::Prop_None, "Extra placement to apply in addition to attachment (in local coordinates)"); + // Only show these properties when applicable. Controlled by extensionOnChanged + this->MapPathParameter.setStatus(App::Property::Status::Hidden, true); + this->MapReversed.setStatus(App::Property::Status::Hidden, true); + this->AttachmentOffset.setStatus(App::Property::Status::Hidden, true); + _props.attacherType = &AttacherType; _props.attachment = &AttachmentSupport; _props.mapMode = &MapMode; @@ -405,8 +410,9 @@ void AttachExtension::extensionOnChanged(const App::Property* prop) || prop == &MapPathParameter || prop == &MapReversed || prop == &AttachmentOffset)){ + bool bAttached = false; try{ - positionBySupport(); + bAttached = positionBySupport(); } catch (Base::Exception &e) { getExtendedObject()->setStatus(App::Error, true); Base::Console().Error("PositionBySupport: %s\n",e.what()); @@ -415,6 +421,25 @@ void AttachExtension::extensionOnChanged(const App::Property* prop) getExtendedObject()->setStatus(App::Error, true); Base::Console().Error("PositionBySupport: %s\n",e.GetMessageString()); } + // Hide properties when not applicable to reduce user confusion + + eMapMode mmode = eMapMode(this->MapMode.getValue()); + + bool modeIsPointOnCurve = mmode == mmNormalToPath || + mmode == mmFrenetNB || mmode == mmFrenetTN || mmode == mmFrenetTB || + mmode == mmRevolutionSection || mmode == mmConcentric; + + // MapPathParameter is only used if there is a reference to one edge and not edge + vertex + bool hasOneRef = false; + if (_props.attacher && _props.attacher->subnames.size() == 1) { + hasOneRef = true; + } + + this->MapPathParameter.setStatus(App::Property::Status::Hidden, !bAttached || !(modeIsPointOnCurve && hasOneRef)); + this->MapReversed.setStatus(App::Property::Status::Hidden, !bAttached); + this->AttachmentOffset.setStatus(App::Property::Status::Hidden, !bAttached); + getPlacement().setReadOnly(bAttached && mmode != mmTranslate); //for mmTranslate, orientation should remain editable even when attached. + } if (prop == &AttacherEngine) { AttacherType.setValue(enumToClass(AttacherEngine.getValueAsString())); @@ -484,6 +509,28 @@ void AttachExtension::onExtendedDocumentRestored() updatePropertyStatus(isAttacherActive()); restoreAttacherEngine(this); + + // Hide properties when not applicable to reduce user confusion + bool bAttached = positionBySupport(); + eMapMode mmode = eMapMode(this->MapMode.getValue()); + bool modeIsPointOnCurve = + (mmode == mmNormalToPath || + mmode == mmFrenetNB || + mmode == mmFrenetTN || + mmode == mmFrenetTB || + mmode == mmRevolutionSection || + mmode == mmConcentric); + + // MapPathParameter is only used if there is a reference to one edge and not edge + vertex + bool hasOneRef = false; + if (_props.attacher && _props.attacher->subnames.size() == 1) { + hasOneRef = true; + } + + this->MapPathParameter.setStatus(App::Property::Status::Hidden, !bAttached || !(modeIsPointOnCurve && hasOneRef)); + this->MapReversed.setStatus(App::Property::Status::Hidden, !bAttached); + this->AttachmentOffset.setStatus(App::Property::Status::Hidden, !bAttached); + getPlacement().setReadOnly(bAttached && mmode != mmTranslate); //for mmTranslate, orientation should remain editable even when attached. } catch (Base::Exception&) { }