From f1bcffbc160c04868ff6db04dfdebac41a34802d Mon Sep 17 00:00:00 2001 From: vocx-fc Date: Fri, 29 May 2020 19:48:28 -0500 Subject: [PATCH] Draft: hide properties not used in the PathArray Certain properties do not need to be shown in the property editor when a particular `AlignMode` is chosen. This keeps the number of properties displayed organized and easy to manage. --- src/Mod/Draft/draftobjects/patharray.py | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/Mod/Draft/draftobjects/patharray.py b/src/Mod/Draft/draftobjects/patharray.py index d0175e2abf..37646f0bd6 100644 --- a/src/Mod/Draft/draftobjects/patharray.py +++ b/src/Mod/Draft/draftobjects/patharray.py @@ -236,6 +236,8 @@ class PathArray(DraftLink): obj.AlignMode = ['Original', 'Frenet', 'Tangent'] obj.AlignMode = 'Original' + # The Align property must be attached after other align properties + # so that onChanged works properly if "Align" not in properties: _tip = _tr("Orient the copies along the path depending " "on the 'Align Mode'.\n" @@ -312,6 +314,41 @@ class PathArray(DraftLink): sl.append(e) return Part.Wire(sl) + def onChanged(self, obj, prop): + """Execute when a property is changed.""" + super(PathArray, self).onChanged(obj, prop) + self.show_and_hide(obj, prop) + + def show_and_hide(self, obj, prop): + """Show and hide the properties depending on the touched property.""" + # The minus sign removes the Hidden property (show) + if prop == "Align": + if obj.Align: + for pr in ("AlignMode", "ForceVertical", "VerticalVector", + "TangentVector"): + obj.setPropertyStatus(pr, "-Hidden") + else: + for pr in ("AlignMode", "ForceVertical", "VerticalVector", + "TangentVector"): + obj.setPropertyStatus(pr, "Hidden") + + if prop == "AlignMode": + if obj.AlignMode == "Original": + for pr in ("ForceVertical", "VerticalVector"): + obj.setPropertyStatus(pr, "-Hidden") + + obj.setPropertyStatus("TangentVector", "Hidden") + + elif obj.AlignMode == "Frenet": + for pr in ("ForceVertical", "VerticalVector", + "TangentVector"): + obj.setPropertyStatus(pr, "Hidden") + + elif obj.AlignMode == "Tangent": + for pr in ("ForceVertical", "VerticalVector", + "TangentVector"): + obj.setPropertyStatus(pr, "-Hidden") + def onDocumentRestored(self, obj): """Execute code when the document is restored.