예제 #1
0
    def __updateView(self):
        """Display the data using the widget which fit the best"""
        data = self.__data

        # sort available views according to priority
        info = DataViews.DataInfo(data)
        priorities = [v.getDataPriority(data, info) for v in self.__views]
        views = zip(priorities, self.__views)
        views = filter(lambda t: t[0] > DataViews.DataView.UNSUPPORTED, views)
        views = sorted(views, reverse=True)

        # store available views
        if len(views) == 0:
            self.__setCurrentAvailableViews([])
            available = []
        else:
            available = [v[1] for v in views]
            self.__setCurrentAvailableViews(available)

        # display the view with the most priority (the default view)
        view = self.getDefaultViewFromAvailableViews(data, available)
        self.__clearCurrentView()
        try:
            self.setDisplayedView(view)
        except Exception as e:
            # in case there is a problem to read the data, try to use a safe
            # view
            view = self.getSafeViewFromAvailableViews(data, available)
            self.setDisplayedView(view)
            raise e
예제 #2
0
    def _getInfo(self):
        """Returns the DataInfo of the current selected data.

        This value is cached.

        :rtype: DataInfo
        """
        if self.__info is None:
            self.__info = DataViews.DataInfo(self.__data)
        return self.__info
예제 #3
0
    def __updateAvailableViews(self):
        """
        Update available views from the current data.
        """
        data = self.__data
        # sort available views according to priority
        info = DataViews.DataInfo(data)
        priorities = [v.getDataPriority(data, info) for v in self.__views]
        views = zip(priorities, self.__views)
        views = filter(lambda t: t[0] > DataViews.DataView.UNSUPPORTED, views)
        views = sorted(views, reverse=True)

        # store available views
        if len(views) == 0:
            self.__setCurrentAvailableViews([])
            available = []
        else:
            available = [v[1] for v in views]
            self.__setCurrentAvailableViews(available)
예제 #4
0
 def __updateNumpySelectionAxis(self):
     """
     Update the numpy-selector according to the needed axis names
     """
     previous = self.__numpySelection.blockSignals(True)
     self.__numpySelection.clear()
     info = DataViews.DataInfo(self.__data)
     axisNames = self.__currentView.axesNames(self.__data, info)
     if info.isArray and info.size != 0 and self.__data is not None and axisNames is not None:
         self.__useAxisSelection = True
         self.__numpySelection.setAxisNames(axisNames)
         self.__numpySelection.setCustomAxis(self.__currentView.customAxisNames())
         data = self.normalizeData(self.__data)
         self.__numpySelection.setData(data)
         if hasattr(data, "shape"):
             isVisible = not (len(axisNames) == 1 and len(data.shape) == 1)
         else:
             isVisible = True
         self.__axisSelection.setVisible(isVisible)
     else:
         self.__useAxisSelection = False
         self.__axisSelection.setVisible(False)
     self.__numpySelection.blockSignals(previous)