本文整理汇总了Python中silx.gui.plot.PlotWindow.getCurvesRoiDockWidget方法的典型用法代码示例。如果您正苦于以下问题:Python PlotWindow.getCurvesRoiDockWidget方法的具体用法?Python PlotWindow.getCurvesRoiDockWidget怎么用?Python PlotWindow.getCurvesRoiDockWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类silx.gui.plot.PlotWindow
的用法示例。
在下文中一共展示了PlotWindow.getCurvesRoiDockWidget方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestCurvesROIWidget
# 需要导入模块: from silx.gui.plot import PlotWindow [as 别名]
# 或者: from silx.gui.plot.PlotWindow import getCurvesRoiDockWidget [as 别名]
class TestCurvesROIWidget(TestCaseQt):
"""Basic test for CurvesROIWidget"""
def setUp(self):
super(TestCurvesROIWidget, self).setUp()
self.plot = PlotWindow()
self.plot.show()
self.qWaitForWindowExposed(self.plot)
self.widget = self.plot.getCurvesRoiDockWidget()
self.widget.show()
self.qWaitForWindowExposed(self.widget)
def tearDown(self):
self.plot.setAttribute(qt.Qt.WA_DeleteOnClose)
self.plot.close()
del self.plot
self.widget.setAttribute(qt.Qt.WA_DeleteOnClose)
self.widget.close()
del self.widget
super(TestCurvesROIWidget, self).tearDown()
def testWithCurves(self):
"""Plot with curves: test all ROI widget buttons"""
for offset in range(2):
self.plot.addCurve(numpy.arange(1000),
offset + numpy.random.random(1000),
legend=str(offset))
# Add two ROI
self.mouseClick(self.widget.roiWidget.addButton, qt.Qt.LeftButton)
self.qWait(200)
self.mouseClick(self.widget.roiWidget.addButton, qt.Qt.LeftButton)
self.qWait(200)
# Change active curve
self.plot.setActiveCurve(str(1))
# Delete a ROI
self.mouseClick(self.widget.roiWidget.delButton, qt.Qt.LeftButton)
self.qWait(200)
with temp_dir() as tmpDir:
self.tmpFile = os.path.join(tmpDir, 'test.ini')
# Save ROIs
self.widget.roiWidget.save(self.tmpFile)
self.assertTrue(os.path.isfile(self.tmpFile))
self.assertTrue(len(self.widget.getRois()) is 2)
# Reset ROIs
self.mouseClick(self.widget.roiWidget.resetButton,
qt.Qt.LeftButton)
self.qWait(200)
rois = self.widget.getRois()
self.assertTrue(len(rois) is 1)
print(rois)
roiID = list(rois.keys())[0]
self.assertTrue(rois[roiID].getName() == 'ICR')
# Load ROIs
self.widget.roiWidget.load(self.tmpFile)
self.assertTrue(len(self.widget.getRois()) is 2)
del self.tmpFile
def testMiddleMarker(self):
"""Test with middle marker enabled"""
self.widget.roiWidget.roiTable.setMiddleROIMarkerFlag(True)
# Add a ROI
self.mouseClick(self.widget.roiWidget.addButton, qt.Qt.LeftButton)
for roiID in self.widget.roiWidget.roiTable._markersHandler._roiMarkerHandlers:
handler = self.widget.roiWidget.roiTable._markersHandler._roiMarkerHandlers[roiID]
assert handler.getMarker('min')
xleftMarker = handler.getMarker('min').getXPosition()
xMiddleMarker = handler.getMarker('middle').getXPosition()
xRightMarker = handler.getMarker('max').getXPosition()
thValue = xleftMarker + (xRightMarker - xleftMarker) / 2.
self.assertAlmostEqual(xMiddleMarker, thValue)
def testAreaCalculation(self):
"""Test result of area calculation"""
x = numpy.arange(100.)
y = numpy.arange(100.)
# Add two curves
self.plot.addCurve(x, y, legend="positive")
self.plot.addCurve(-x, y, legend="negative")
# Make sure there is an active curve and it is the positive one
self.plot.setActiveCurve("positive")
# Add two ROIs
roi_neg = CurvesROIWidget.ROI(name='negative', fromdata=-20,
todata=-10, type_='X')
#.........这里部分代码省略.........