示例#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())
示例#2
0
    def testProfile1D(self):
        self.plot = Plot2D()
        self.plot.show()
        self.qWaitForWindowExposed(self.plot)
        self.plot.addImage([[0, 1], [2, 3]])

        toolBar = self.plot.getProfileToolbar()

        manager = toolBar.getProfileManager()
        roiManager = manager.getRoiManager()

        roi = rois.ProfileImageHorizontalLineROI()
        roi.setPosition(0.5)
        roiManager.addRoi(roi)
        roiManager.setCurrentRoi(roi)

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

        profileWindow = roi.getProfileWindow()
        self.assertIsInstance(roi.getProfileWindow(), qt.QMainWindow)
        self.assertIsInstance(profileWindow.getCurrentPlotWidget(), Plot1D)