Esempio n. 1
0
class SlicesMode(VisualizationMode):
    def __init__(self, parent, visualizer):
        """
		Initialization
		"""
        VisualizationMode.__init__(self, parent, visualizer)
        self.parent = parent
        self.visualizer = visualizer
        self.dataUnit = None

    def showSliceSlider(self):
        """
		Method that is queried to determine whether
					 to show the zslider
		"""
        return True

    def showSideBar(self):
        """
		Method that is queried to determine whether
					 to show the sidebar
		"""
        return False

    def Render(self):
        """
		Update the rendering
		"""
        self.iactivePanel.updatePreview(renew=False)

    def updateRendering(self):
        """
		Update the rendering
		"""
        Logging.info("Updating rendering", kw="preview")
        self.iactivePanel.updatePreview(renew=True)

    def setBackground(self, red, green, blue):
        """
		Set the background color
		"""
        if self.iactivePanel:
            self.iactivePanel.setBackgroundColor((red, green, blue))

    def activate(self, sidebarwin):
        """
		Set the mode of visualization
		"""
        scripting.wantWholeDataset = 0
        if not self.iactivePanel:
            self.iactivePanel = PreviewFrame(self.parent, scrollbars=True)
        return self.iactivePanel

    def setDataUnit(self, dataUnit):
        """
		Set the dataunit to be visualized
		"""
        self.iactivePanel.setDataUnit(dataUnit, 0)

    def setTimepoint(self, timePoint):
        """
		Set the timepoint to be visualized
		"""
        Logging.info("Setting timepoint to ", timePoint, kw="visualizer")
        self.iactivePanel.setTimepoint(timePoint)

    def deactivate(self, newmode=None):
        """
		Unset the mode of visualization
		"""
        self.iactivePanel.Show(0)
        self.iactivePanel.onDeactivate()
        self.iactivePanel.Destroy()
        del self.iactivePanel
        self.iactivePanel = None

    def saveSnapshot(self, filename):
        """
		Save a snapshot of the scene
		"""
        self.iactivePanel.saveSnapshot(filename)