Skip to content

Commit

Permalink
Allow to add singleton axes on export
Browse files Browse the repository at this point in the history
  • Loading branch information
k-dominik committed Apr 13, 2021
1 parent 2ba0494 commit bb8f14d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions volumina/widgets/dataExportOptionsDlg.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,9 @@ def eventFilter(self, watched, event):

class _AxisOrderValidator(QValidator):
def __init__(self, parent, inputSlot):
super(DataExportOptionsDlg._AxisOrderValidator, self).__init__(parent)
super().__init__(parent)
self._inputSlot = inputSlot
self._valid_axes = set("tzyxc")

def validate(self, userAxes, pos):
taggedShape = self._inputSlot.meta.getTaggedShape()
Expand All @@ -415,17 +416,16 @@ def validate(self, userAxes, pos):
userSet = set(str(userAxes))

# Ensure all user axes appear in the input
if not (userSet <= inputSet):
if not userSet.issubset(self._valid_axes):
return (QValidator.Invalid, userAxes, pos)

# Ensure no repeats
if len(userSet) != len(userAxes):
return (QValidator.Invalid, userAxes, pos)

# If missing non-singleton axes, maybe intermediate entry
# (It's okay to omit singleton axes)
for key in inputSet - userSet:
if taggedShape[key] != 1:
# Ensure no non-singleton axis was omitted:
for key in self._valid_axes - userSet:
if taggedShape.get(key, 1) != 1:
return (QValidator.Intermediate, userAxes, pos)

return (QValidator.Acceptable, userAxes, pos)
Expand Down

0 comments on commit bb8f14d

Please sign in to comment.