Exemplo n.º 1
0
    def testCustomProfileWindow(self):
        from silx.gui.plot import ProfileMainWindow

        self.plot = PlotWindow()
        profileWindow = ProfileMainWindow.ProfileMainWindow(self.plot)
        toolBar = Profile.ProfileToolBar(parent=self.plot,
                                         plot=self.plot,
                                         profileWindow=profileWindow)

        self.plot.show()
        self.qWaitForWindowExposed(self.plot)
        profileWindow.show()
        self.qWaitForWindowExposed(profileWindow)
        self.qapp.processEvents()

        self.plot.addImage(numpy.arange(10 * 10).reshape(10, -1))
        profile = rois.ProfileImageHorizontalLineROI()
        profile.setPosition(5)
        toolBar.getProfileManager().getRoiManager().addRoi(profile)
        toolBar.getProfileManager().getRoiManager().setCurrentRoi(profile)

        for _ in range(20):
            self.qWait(200)
            if not toolBar.getProfileManager().hasPendingOperations():
                break

        # There is a displayed profile
        self.assertIsNotNone(profileWindow.getProfile())
        self.assertIs(toolBar.getProfileMainWindow(), profileWindow)

        # There is nothing anymore but the window is still there
        toolBar.getProfileManager().clearProfile()
        self.qapp.processEvents()
        self.assertIsNone(profileWindow.getProfile())
Exemplo n.º 2
0
    def setUp(self):
        super(TestProfileToolBar, self).setUp()
        self.plot = PlotWindow()
        self.toolBar = Profile.ProfileToolBar(plot=self.plot)
        self.plot.addToolBar(self.toolBar)

        self.plot.show()
        self.qWaitForWindowExposed(self.plot)

        self.mouseMove(self.plot)  # Move to center
        self.qapp.processEvents()
        deprecation.FORCE = True
Exemplo n.º 3
0
    def setUp(self):
        super(TestProfileToolBar, self).setUp()
        profileWindow = PlotWindow()
        self.plot = PlotWindow()
        self.toolBar = Profile.ProfileToolBar(
            plot=self.plot, profileWindow=profileWindow)
        self.plot.addToolBar(self.toolBar)

        self.plot.show()
        self.qWaitForWindowExposed(self.plot)
        profileWindow.show()
        self.qWaitForWindowExposed(profileWindow)

        self.mouseMove(self.plot)  # Move to center
        self.qapp.processEvents()
Exemplo n.º 4
0
    def __init__(self, parent=None, **kwargs):
        super(MainPlotWidget, self).__init__(parent=parent,
                                             backend=BackendMatplotlibQt,
                                             **kwargs)

        # Add a profile toolbar.
        self._profileWindow = ProfileWindow()
        self._profileToolBar = Profile.ProfileToolBar(
            plot=self, profileWindow=self._profileWindow)
        self._profileToolBar.actions()[-1].setVisible(False)

        self.removeToolBar(self._outputToolBar)
        self.addToolBar(self._profileToolBar)
        self.addToolBar(self._outputToolBar)
        self._outputToolBar.show()

        if sys.platform == 'darwin':
            self.setIconSize(QSize(24, 24))

        # Create QAction for the context menu once for all.
        self._zoomBackAction = actions.control.ZoomBackAction(plot=self,
                                                              parent=self)

        # Retrieve PlotWidget's plot area widget.
        plotArea = self.getWidgetHandle()

        # Set plot area custom context menu.
        plotArea.setContextMenuPolicy(Qt.CustomContextMenu)
        plotArea.customContextMenuRequested.connect(self._contextMenu)

        # Use the viridis color map by default.
        colormap = {
            'name': 'viridis',
            'normalization': 'linear',
            'autoscale': True,
            'vmin': 0.0,
            'vmax': 1.0
        }
        self.setDefaultColormap(colormap)