Exemplo n.º 1
0
    def next(self, seeking=False):
        """Go to the next position (next iteration).

        Args:
            seeking: Boolean that indicates whether the explorer is calling
            next() from seek(). If True, the explorer should avoid unnecessary
            computation that would not affect the seek command. The last call
            to next() from seek() will be with seeking=False.
        """
        BaseExplorer.next(self)

        # If filters were changed, order may be invalid
        if self.order is None or \
            len([x for x in self.order if type(x) == int]) != self.numFilters:
            # If user did not set a custom order, just create new one automatically
            if not self.customOrder:
                self.order = ["image"]
                self.order.extend(range(self.numFilters))
                self.order += ["sweep"]
            # Otherwise, user needs to recreate the explorer with a new order
            else:
                raise RuntimeError(
                    "'order' is invalid. Must recreate explorer with "
                    "valid order after changing filters.")

        if self.position['reset'] and self.blankWithReset:
            # Last iteration was a blank, so don't increment the position
            self.position['reset'] = False
        else:
            self.position['reset'] = False
            for x in reversed(self.order):
                if x == 'image':  # Iterate the image
                    self.position['image'] += 1
                    if self.position['image'] == self.numImages:
                        self.position['image'] = 0
                        self.position['reset'] = True
                    else:
                        break
                elif x == 'sweep':  # Iterate the sweep position
                    nextImage = self._nextSweepPosition()
                    if not nextImage:
                        break
                else:  # Iterate the filter with index x
                    self.position['filters'][x] += 1
                    if self.position['filters'][x] == self.numFilterOutputs[x]:
                        self.position['filters'][x] = 0
                        self.position['reset'] = True
                    else:
                        break
            if nextImage:
                self._firstSweepPosition()
Exemplo n.º 2
0
    def next(self, seeking=False):
        """Go to the next position (next iteration).

        Args:
            seeking: Boolean that indicates whether the explorer is calling
            next() from seek(). If True, the explorer should avoid unnecessary
            computation that would not affect the seek command. The last call
            to next() from seek() will be with seeking=False.
        """
        BaseExplorer.next(self)

        # If filters were changed, order may be invalid
        if self.order is None or \
            len([x for x in self.order if type(x) == int]) != self.numFilters:
            # If user did not set a custom order, just create new one automatically
            if not self.customOrder:
                self.order = ["image"]
                self.order.extend(range(self.numFilters))
                self.order += ["sweep"]
            # Otherwise, user needs to recreate the explorer with a new order
            else:
                raise RuntimeError("'order' is invalid. Must recreate explorer with "
                  "valid order after changing filters.")

        if self.position['reset'] and self.blankWithReset:
            # Last iteration was a blank, so don't increment the position
            self.position['reset'] = False
        else:
            self.position['reset'] = False
            for x in reversed(self.order):
                if x == 'image':  # Iterate the image
                    self.position['image'] += 1
                    if self.position['image'] == self.numImages:
                        self.position['image'] = 0
                        self.position['reset'] = True
                    else:
                        break
                elif x == 'sweep':  # Iterate the sweep position
                    nextImage = self._nextSweepPosition()
                    if not nextImage:
                        break
                else:  # Iterate the filter with index x
                    self.position['filters'][x] += 1
                    if self.position['filters'][x] == self.numFilterOutputs[x]:
                        self.position['filters'][x] = 0
                        self.position['reset'] = True
                    else:
                        break
            if nextImage:
                self._firstSweepPosition()
Exemplo n.º 3
0
    def next(self, seeking=False):
        """Go to the next position (next iteration).

        Args:
            seeking: Boolean that indicates whether the explorer is calling
                     next() from seek(). If True, the explorer should avoid
                     unnecessary computation that would not affect the seek
                     command. The last call to next() from seek() will be with
                     seeking=False.
        """
        BaseExplorer.next(self)

        if self.position['reset'] and self.blankWithReset:
            # Last iteration was a blank, so don't increment the position
            self.position['reset'] = False
        else:
            self.position['reset'] = False
            self._nextSweepPosition()
            # Begin a new sweep if necessary
            if self.position['reset']:
                self.first()