Merge pull request #15347 from bgbsww/bgbsww-toponamingFix14837

Toponaming: Restore code for instant sketch position updates
This commit is contained in:
Chris Hennes
2024-07-15 10:23:24 -05:00
committed by GitHub

View File

@@ -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;
@@ -305,6 +310,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 +403,44 @@ 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)){
bool bAttached = false;
try{
bAttached = 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());
}
// 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()));
}
@@ -465,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&) {
}