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.
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user