Skip to content

Commit

Permalink
fixup! source axistags from input, allow for singleton axes when chan…
Browse files Browse the repository at this point in the history
…ging order
  • Loading branch information
k-dominik committed Apr 12, 2021
1 parent 3f703cd commit e9db877
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions volumina/widgets/dataExportOptionsDlg.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ def _handleAxisOrderChecked(checked):

self.outputAxisOrderEdit.editingFinished.connect(_handleNewAxisOrder)
self.outputAxisOrderEdit.textChanged.connect(partial(self._updateAxisOrderColor, True))
self.outputAxisOrderEdit.setValidator(DataExportOptionsDlg._AxisOrderValidator(self, self._opDataExport.Input))
self.outputAxisOrderEdit.setValidator(
DataExportOptionsDlg._AxisOrderValidator(self, self._opDataExport.ConvertedImage)
)
self.outputAxisOrderEdit.installEventFilter(DataExportOptionsDlg._AxisOrderEventFilter(self))
self.axisOrderCheckbox.toggled.connect(_handleAxisOrderChecked)

Expand Down Expand Up @@ -403,18 +405,18 @@ 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()
originalAxes = self._inputSlot.meta.getOriginalAxisKeys()
inputAxes = list(originalAxes)
inputAxes = list(taggedShape.keys())
inputSet = set(inputAxes)
userSet = set(str(userAxes))

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

# Ensure no repeats
Expand Down

0 comments on commit e9db877

Please sign in to comment.