From bc3c9b0c5df706e584f9255e640fef2963356ba8 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 25 Oct 2017 22:52:39 +0200 Subject: [PATCH] override onExtendedDocumentRestored in AttachExtension --- src/Mod/Part/App/AttachExtension.cpp | 32 +++++++++++++++++++++++++++ src/Mod/Part/App/AttachExtension.h | 2 ++ src/Mod/Sketcher/App/SketchObject.cpp | 2 ++ 3 files changed, 36 insertions(+) diff --git a/src/Mod/Part/App/AttachExtension.cpp b/src/Mod/Part/App/AttachExtension.cpp index cf787dac62..45edc7130d 100644 --- a/src/Mod/Part/App/AttachExtension.cpp +++ b/src/Mod/Part/App/AttachExtension.cpp @@ -207,6 +207,38 @@ void AttachExtension::extensionOnChanged(const App::Property* prop) App::DocumentObjectExtension::extensionOnChanged(prop); } +void AttachExtension::onExtendedDocumentRestored() +{ + try { + bool bAttached = positionBySupport(); + + // 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 (_attacher && _attacher->references.getSubValues().size() == 1) { + hasOneRef = true; + } + + this->MapPathParameter.setStatus(App::Property::Status::Hidden, !bAttached || !(modeIsPointOnCurve && hasOneRef)); + this->MapReversed.setStatus(App::Property::Status::Hidden, !bAttached); + this->superPlacement.setStatus(App::Property::Status::Hidden, !bAttached); + getPlacement().setReadOnly(bAttached && mmode != mmTranslate); //for mmTranslate, orientation should remain editable even when attached. + } + catch (Base::Exception&) { + } + catch (Standard_Failure &) { + } +} + void AttachExtension::updateAttacherVals() { if (!_attacher) diff --git a/src/Mod/Part/App/AttachExtension.h b/src/Mod/Part/App/AttachExtension.h index c340c8f7a5..533b908541 100644 --- a/src/Mod/Part/App/AttachExtension.h +++ b/src/Mod/Part/App/AttachExtension.h @@ -103,6 +103,8 @@ public: virtual short int extensionMustExecute(void); virtual App::DocumentObjectExecReturn *extensionExecute(void); virtual PyObject* getExtensionPyObject(void); + virtual void onExtendedDocumentRestored(); + protected: virtual void extensionOnChanged(const App::Property* /*prop*/); diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 52c03cec61..f7757ca99b 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -5691,6 +5691,8 @@ void SketchObject::onDocumentRestored() if (this->solve(true) == 0) Shape.setValue(solvedSketch.toShape()); } + + Part::Part2DObject::onDocumentRestored(); } catch (...) { }