本文整理汇总了Python中silx.gui.plot.PlotWindow类的典型用法代码示例。如果您正苦于以下问题:Python PlotWindow类的具体用法?Python PlotWindow怎么用?Python PlotWindow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PlotWindow类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: TestCurvesROIWidget
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 = CurvesROIWidget.CurvesROIDockWidget(plot=self.plot, name='TEST')
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 testEmptyPlot(self):
"""Empty plot, display ROI widget"""
pass
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.mouseClick(self.widget.roiWidget.addButton, qt.Qt.LeftButton)
# Change active curve
self.plot.setActiveCurve(str(1))
# Delete a ROI
self.mouseClick(self.widget.roiWidget.delButton, qt.Qt.LeftButton)
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))
# Reset ROIs
self.mouseClick(self.widget.roiWidget.resetButton,
qt.Qt.LeftButton)
# Load ROIs
self.widget.roiWidget.load(self.tmpFile)
del self.tmpFile
开发者ID:silx-kit,项目名称:silx,代码行数:60,代码来源:testCurvesROIWidget.py
示例2: setUp
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()
开发者ID:dnaudet,项目名称:silx,代码行数:15,代码来源:testProfile.py
示例3: setUp
def setUp(self):
super(TestPositionInfo, self).setUp()
self.plot = PlotWindow()
self.plot.show()
self.qWaitForWindowExposed(self.plot)
self.mouseMove(self.plot) # Move to center
self.qapp.processEvents()
开发者ID:FeodorFitsner,项目名称:silx,代码行数:7,代码来源:testPlotTools.py
示例4: setUp
def setUp(self):
super(TestCurvesROIWidget, self).setUp()
self.plot = PlotWindow()
self.plot.show()
self.qWaitForWindowExposed(self.plot)
self.widget = CurvesROIWidget.CurvesROIDockWidget(plot=self.plot, name='TEST')
self.widget.show()
self.qWaitForWindowExposed(self.widget)
开发者ID:silx-kit,项目名称:silx,代码行数:9,代码来源:testCurvesROIWidget.py
示例5: setUp
def setUp(self):
super(TestScatterProfileToolBar, self).setUp()
self.plot = PlotWindow()
self.profile = profile.ScatterProfileToolBar(plot=self.plot)
self.plot.addToolBar(self.profile)
self.plot.show()
self.qWaitForWindowExposed(self.plot)
开发者ID:dnaudet,项目名称:silx,代码行数:10,代码来源:testScatterProfileToolBar.py
示例6: setUp
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)
开发者ID:dnaudet,项目名称:silx,代码行数:10,代码来源:testCurvesROIWidget.py
示例7: __init__
def __init__(self, parent=None, initdict = None):
qt.QWidget.__init__(self, parent)
self.l = qt.QVBoxLayout(self)
self.l.setContentsMargins(0, 0, 0, 0)
self.l.setSpacing(0)
self.tubeWidget = TubeWidget(self, initdict = initdict)
self.setParameters = self.tubeWidget.setParameters
self.getParameters = self.tubeWidget.getParameters
label = qt.QLabel(self)
hbox = qt.QWidget(self)
hboxl = qt.QHBoxLayout(hbox)
hboxl.setContentsMargins(0, 0, 0, 0)
hboxl.setSpacing(0)
self.plotButton = qt.QPushButton(hbox)
self.plotButton.setText("Plot Continuum")
self.exportButton = qt.QPushButton(hbox)
self.exportButton.setText("Export to Fit")
#grid.addWidget(self.plotButton, 7, 1)
#grid.addWidget(self.exportButton, 7, 3)
hboxl.addWidget(self.plotButton)
hboxl.addWidget(self.exportButton)
self.l.addWidget(self.tubeWidget)
f = label.font()
f.setItalic(1)
label.setFont(f)
label.setAlignment(qt.Qt.AlignRight)
label.setText("H. Ebel, X-Ray Spectrometry 28 (1999) 255-266 ")
self.l.addWidget(label)
self.l.addWidget(hbox)
self.graph = PlotWindow(self, colormap=False, yInverted=False,
aspectRatio=False, control=False,
position=False, roi=False, mask=False,
fit=False)
self.pluginsToolButton = PluginsToolButton(plot=self.graph)
self.graph.toolBar().addWidget(self.pluginsToolButton)
self.graph.getInteractiveModeToolBar().getZoomModeAction().setVisible(False)
self.graph.getInteractiveModeToolBar().getPanModeAction().setVisible(False)
self.l.addWidget(self.graph)
self.graph.setGraphXLabel("Energy (keV)")
self.graph.setGraphYLabel("photons/sr/mA/keV/s")
self.plotButton.clicked.connect(self.plot)
self.exportButton.clicked.connect(self._export)
开发者ID:maurov,项目名称:pymca,代码行数:54,代码来源:QXTube.py
示例8: setUp
def setUp(self):
super(TestMaskToolsWidget, self).setUp()
self.plot = PlotWindow()
self.widget = MaskToolsWidget.MaskToolsDockWidget(self.plot, 'TEST')
self.plot.addDockWidget(qt.Qt.BottomDockWidgetArea, self.widget)
self.plot.show()
self.qWaitForWindowExposed(self.plot)
self.maskWidget = self.widget.widget()
开发者ID:PiRK,项目名称:silx,代码行数:11,代码来源:testMaskToolsWidget.py
示例9: setUp
def setUp(self):
super(TestRegionOfInterestManager, self).setUp()
self.plot = PlotWindow()
self.roiTableWidget = roi.RegionOfInterestTableWidget()
dock = qt.QDockWidget()
dock.setWidget(self.roiTableWidget)
self.plot.addDockWidget(qt.Qt.BottomDockWidgetArea, dock)
self.plot.show()
self.qWaitForWindowExposed(self.plot)
开发者ID:dnaudet,项目名称:silx,代码行数:11,代码来源:testROI.py
示例10: TestPlotWindow
class TestPlotWindow(TestCaseQt):
"""Base class for tests of PlotWindow."""
def setUp(self):
super(TestPlotWindow, self).setUp()
self.plot = PlotWindow()
self.plot.show()
self.qWaitForWindowExposed(self.plot)
def tearDown(self):
self.plot.setAttribute(qt.Qt.WA_DeleteOnClose)
self.plot.close()
del self.plot
super(TestPlotWindow, self).tearDown()
def testActions(self):
"""Test the actions QToolButtons"""
self.plot.setLimits(1, 100, 1, 100)
checkList = [ # QAction, Plot state getter
(self.plot.xAxisAutoScaleAction, self.plot.isXAxisAutoScale),
(self.plot.yAxisAutoScaleAction, self.plot.isYAxisAutoScale),
(self.plot.xAxisLogarithmicAction, self.plot.isXAxisLogarithmic),
(self.plot.yAxisLogarithmicAction, self.plot.isYAxisLogarithmic),
(self.plot.gridAction, self.plot.getGraphGrid),
(self.plot.keepDataAspectRatioAction,
self.plot.isKeepDataAspectRatio),
(self.plot.yAxisInvertedAction, self.plot.isYAxisInverted),
]
for action, getter in checkList:
self.mouseMove(self.plot)
initialState = getter()
toolButton = getQToolButtonFromAction(action)
self.assertIsNot(toolButton, None)
self.mouseClick(toolButton, qt.Qt.LeftButton)
self.assertNotEqual(getter(), initialState,
msg='"%s" state not changed' % action.text())
self.mouseClick(toolButton, qt.Qt.LeftButton)
self.assertEqual(getter(), initialState,
msg='"%s" state not changed' % action.text())
# Trigger a zoom reset
self.mouseMove(self.plot)
resetZoomAction = self.plot.resetZoomAction
toolButton = getQToolButtonFromAction(resetZoomAction)
self.assertIsNot(toolButton, None)
self.mouseClick(toolButton, qt.Qt.LeftButton)
开发者ID:andygotz,项目名称:silx,代码行数:49,代码来源:testPlotWindow.py
示例11: setUp
def setUp(self):
super(TestCurveLegendsWidget, self).setUp()
self.plot = PlotWindow()
self.legends = CurveLegendsWidget.CurveLegendsWidget()
self.legends.setPlotWidget(self.plot)
dock = qt.QDockWidget()
dock.setWindowTitle('Curve Legends')
dock.setWidget(self.legends)
self.plot.addTabbedDockWidget(dock)
self.plot.show()
self.qWaitForWindowExposed(self.plot)
开发者ID:dnaudet,项目名称:silx,代码行数:14,代码来源:testCurveLegendsWidget.py
示例12: __init__
def __init__(self, parent=None, backend=None):
super(RateLawMdiArea, self).__init__(parent)
self._windowDict = {}
self._windowList = ["Original", "Zero",
"First", "Second"]
self._windowList.reverse()
for title in self._windowList:
plot = PlotWindow(self,
position=True, backend=backend,
colormap=False, aspectRatio=False,
yInverted=False, roi=False, mask=False)
self.pluginsToolButton = PluginsToolButton(plot=plot)
plot.toolBar().addWidget(self.pluginsToolButton)
plot.setWindowTitle(title)
self.addSubWindow(plot)
self._windowDict[title] = plot
plot.setDataMargins(0, 0, 0.025, 0.025)
self._windowList.reverse()
self.setActivationOrder(qt.QMdiArea.StackingOrder)
self.tileSubWindows()
开发者ID:maurov,项目名称:pymca,代码行数:20,代码来源:RateLawWindow.py
示例13: __init__
def __init__(self, parent=None):
qt.QWidget.__init__(self, parent)
self.setWindowTitle("Strip and SNIP Configuration Window")
self.mainLayout = qt.QVBoxLayout(self)
self.mainLayout.setContentsMargins(0, 0, 0, 0)
self.mainLayout.setSpacing(2)
self.parametersWidget = StripParametersWidget(self)
self.graphWidget = PlotWindow(self, position=False, aspectRatio=False,
colormap=False, yInverted=False,
roi=False, mask=False, fit=False)
toolBar = self.graphWidget.getInteractiveModeToolBar()
toolBar.getZoomModeAction().setVisible(False)
toolBar.getPanModeAction().setVisible(False)
self.mainLayout.addWidget(self.parametersWidget)
self.mainLayout.addWidget(self.graphWidget)
self.getParameters = self.parametersWidget.getParameters
self.setParameters = self.parametersWidget.setParameters
self._x = None
self._y = None
self.parametersWidget.sigStripParametersWidgetSignal.connect( \
self._slot)
开发者ID:maurov,项目名称:pymca,代码行数:22,代码来源:StripBackgroundWidget.py
示例14: TestRegionOfInterestManager
class TestRegionOfInterestManager(TestCaseQt, ParametricTestCase):
"""Tests for RegionOfInterestManager class"""
def setUp(self):
super(TestRegionOfInterestManager, self).setUp()
self.plot = PlotWindow()
self.roiTableWidget = roi.RegionOfInterestTableWidget()
dock = qt.QDockWidget()
dock.setWidget(self.roiTableWidget)
self.plot.addDockWidget(qt.Qt.BottomDockWidgetArea, dock)
self.plot.show()
self.qWaitForWindowExposed(self.plot)
def tearDown(self):
del self.roiTableWidget
self.qapp.processEvents()
self.plot.setAttribute(qt.Qt.WA_DeleteOnClose)
self.plot.close()
del self.plot
super(TestRegionOfInterestManager, self).tearDown()
def test(self):
"""Test ROI of different shapes"""
tests = ( # shape, points=[list of (x, y), list of (x, y)]
('point', numpy.array(([(10., 15.)], [(20., 25.)]))),
('rectangle', numpy.array((((1., 10.), (11., 20.)),
((2., 3.), (12., 13.))))),
('polygon', numpy.array((((0., 1.), (0., 10.), (10., 0.)),
((5., 6.), (5., 16.), (15., 6.))))),
('line', numpy.array((((10., 20.), (10., 30.)),
((30., 40.), (30., 50.))))),
('hline', numpy.array((((10., 20.), (10., 30.)),
((30., 40.), (30., 50.))))),
('vline', numpy.array((((10., 20.), (10., 30.)),
((30., 40.), (30., 50.))))),
)
for kind, points in tests:
with self.subTest(kind=kind):
manager = roi.RegionOfInterestManager(self.plot)
self.roiTableWidget.setRegionOfInterestManager(manager)
manager.start(kind)
self.assertEqual(manager.getRegionOfInterests(), ())
finishListener = SignalListener()
manager.sigInteractiveModeFinished.connect(finishListener)
changedListener = SignalListener()
manager.sigRegionOfInterestChanged.connect(changedListener)
# Add a point
manager.createRegionOfInterest(kind, points[0])
self.qapp.processEvents()
self.assertTrue(numpy.all(numpy.equal(
manager.getRegionOfInterestPoints(), (points[0],))))
self.assertEqual(changedListener.callCount(), 1)
# Remove it
manager.removeRegionOfInterest(manager.getRegionOfInterests()[0])
self.assertEqual(manager.getRegionOfInterests(), ())
self.assertEqual(changedListener.callCount(), 2)
# Add two point
manager.createRegionOfInterest(kind, points[0])
self.qapp.processEvents()
manager.createRegionOfInterest(kind, points[1])
self.qapp.processEvents()
self.assertTrue(numpy.all(numpy.equal(
manager.getRegionOfInterestPoints(),
(points[0], points[1]))))
self.assertEqual(changedListener.callCount(), 4)
# Reset it
result = manager.clearRegionOfInterests()
self.assertTrue(result)
self.assertEqual(manager.getRegionOfInterests(), ())
self.assertEqual(changedListener.callCount(), 5)
changedListener.clear()
# Add two point
manager.createRegionOfInterest(kind, points[0])
self.qapp.processEvents()
manager.createRegionOfInterest(kind, points[1])
self.qapp.processEvents()
self.assertTrue(numpy.all(numpy.equal(
manager.getRegionOfInterestPoints(),
(points[0], points[1]))))
self.assertEqual(changedListener.callCount(), 2)
# stop
result = manager.stop()
self.assertTrue(result)
self.assertTrue(numpy.all(numpy.equal(
manager.getRegionOfInterestPoints(),
(points[0], points[1]))))
#.........这里部分代码省略.........
开发者ID:vallsv,项目名称:silx,代码行数:101,代码来源:testROI.py
示例15: __init__
def __init__(self, parent=None, fit=None, graph=None, actions=True):
qt.QWidget.__init__(self, parent)
self.setWindowTitle("SimpleFitGui")
if fit is None:
self.fitModule = SimpleFitModule.SimpleFit()
self.fitModule.importFunctions(SimpleFitUserEstimatedFunctions)
self.fitModule.loadUserFunctions()
else:
self.fitModule = fit
if graph is None:
self.__useTab = True
self.graph = PlotWindow(self,
aspectRatio=False, colormap=False,
yInverted=False, roi=False, mask=False,
fit=False, control=True, position=True)
self.graph.getInteractiveModeToolBar().setVisible(False)
# No context menu by default, execute zoomBack on right click
plotArea = self.graph.getWidgetHandle()
plotArea.setContextMenuPolicy(qt.Qt.CustomContextMenu)
plotArea.customContextMenuRequested.connect(self._zoomBack)
else:
self.__useTab = False
self.graph = graph
self._configurationDialog = None
self.mainLayout = qt.QVBoxLayout(self)
self.mainLayout.setContentsMargins(2, 2, 2, 2)
self.mainLayout.setSpacing(2)
self.topWidget = TopWidget(self)
config = self.fitModule.getConfiguration()
self.topWidget.setFunctions(config['fit']['functions'])
config = None
if self.__useTab:
self.mainTab = qt.QTabWidget(self)
self.mainLayout.addWidget(self.mainTab)
self.parametersTable = Parameters.Parameters()
self.mainTab.addTab(self.graph, 'GRAPH')
self.mainTab.addTab(self.parametersTable, 'FIT')
else:
self.parametersTable = Parameters.Parameters(self)
self.statusWidget = StatusWidget(self)
self.mainLayout.addWidget(self.topWidget)
if self.__useTab:
self.mainLayout.addWidget(self.mainTab)
else:
self.mainLayout.addWidget(self.parametersTable)
self.mainLayout.addWidget(self.statusWidget)
if actions:
#build the actions widget
self.fitActions = qt.QWidget(self)
self.fitActions.mainLayout = qt.QHBoxLayout(self.fitActions)
self.fitActions.mainLayout.setContentsMargins(2, 2, 2, 2)
self.fitActions.mainLayout.setSpacing(2)
self.fitActions.estimateButton = qt.QPushButton(self.fitActions)
self.fitActions.estimateButton.setText("Estimate")
self.fitActions.startFitButton = qt.QPushButton(self.fitActions)
self.fitActions.startFitButton.setText("Start Fit")
self.fitActions.dismissButton = qt.QPushButton(self.fitActions)
self.fitActions.dismissButton.setText("Dismiss")
self.fitActions.mainLayout.addWidget(self.fitActions.estimateButton)
self.fitActions.mainLayout.addWidget(self.fitActions.startFitButton)
self.fitActions.mainLayout.addWidget(self.fitActions.dismissButton)
self.mainLayout.addWidget(self.fitActions)
#connect top widget
self.topWidget.addFunctionButton.clicked.connect(\
self.importFunctions)
self.topWidget.fitFunctionCombo.currentIndexChanged[int].connect(\
self.fitFunctionComboSlot)
self.topWidget.backgroundCombo.currentIndexChanged[int].connect(\
self.backgroundComboSlot)
self.topWidget.configureButton.clicked.connect(\
self.configureButtonSlot)
if actions:
#connect actions
self.fitActions.estimateButton.clicked.connect(self.estimate)
self.fitActions.startFitButton.clicked.connect(self.startFit)
self.fitActions.dismissButton.clicked.connect(self.dismiss)
开发者ID:maurov,项目名称:pymca,代码行数:85,代码来源:SimpleFitGui.py
示例16: SimpleFitGui
class SimpleFitGui(qt.QWidget):
sigSimpleFitSignal = qt.pyqtSignal(object)
def __init__(self, parent=None, fit=None, graph=None, actions=True):
qt.QWidget.__init__(self, parent)
self.setWindowTitle("SimpleFitGui")
if fit is None:
self.fitModule = SimpleFitModule.SimpleFit()
self.fitModule.importFunctions(SimpleFitUserEstimatedFunctions)
self.fitModule.loadUserFunctions()
else:
self.fitModule = fit
if graph is None:
self.__useTab = True
self.graph = PlotWindow(self,
aspectRatio=False, colormap=False,
yInverted=False, roi=False, mask=False,
fit=False, control=True, position=True)
self.graph.getInteractiveModeToolBar().setVisible(False)
# No context menu by default, execute zoomBack on right click
plotArea = self.graph.getWidgetHandle()
plotArea.setContextMenuPolicy(qt.Qt.CustomContextMenu)
plotArea.customContextMenuRequested.connect(self._zoomBack)
else:
self.__useTab = False
self.graph = graph
self._configurationDialog = None
self.mainLayout = qt.QVBoxLayout(self)
self.mainLayout.setContentsMargins(2, 2, 2, 2)
self.mainLayout.setSpacing(2)
self.topWidget = TopWidget(self)
config = self.fitModule.getConfiguration()
self.topWidget.setFunctions(config['fit']['functions'])
config = None
if self.__useTab:
self.mainTab = qt.QTabWidget(self)
self.mainLayout.addWidget(self.mainTab)
self.parametersTable = Parameters.Parameters()
self.mainTab.addTab(self.graph, 'GRAPH')
self.mainTab.addTab(self.parametersTable, 'FIT')
else:
self.parametersTable = Parameters.Parameters(self)
self.statusWidget = StatusWidget(self)
self.mainLayout.addWidget(self.topWidget)
if self.__useTab:
self.mainLayout.addWidget(self.mainTab)
else:
self.mainLayout.addWidget(self.parametersTable)
self.mainLayout.addWidget(self.statusWidget)
if actions:
#build the actions widget
self.fitActions = qt.QWidget(self)
self.fitActions.mainLayout = qt.QHBoxLayout(self.fitActions)
self.fitActions.mainLayout.setContentsMargins(2, 2, 2, 2)
self.fitActions.mainLayout.setSpacing(2)
self.fitActions.estimateButton = qt.QPushButton(self.fitActions)
self.fitActions.estimateButton.setText("Estimate")
self.fitActions.startFitButton = qt.QPushButton(self.fitActions)
self.fitActions.startFitButton.setText("Start Fit")
self.fitActions.dismissButton = qt.QPushButton(self.fitActions)
self.fitActions.dismissButton.setText("Dismiss")
self.fitActions.mainLayout.addWidget(self.fitActions.estimateButton)
self.fitActions.mainLayout.addWidget(self.fitActions.startFitButton)
self.fitActions.mainLayout.addWidget(self.fitActions.dismissButton)
self.mainLayout.addWidget(self.fitActions)
#connect top widget
self.topWidget.addFunctionButton.clicked.connect(\
self.importFunctions)
self.topWidget.fitFunctionCombo.currentIndexChanged[int].connect(\
self.fitFunctionComboSlot)
self.topWidget.backgroundCombo.currentIndexChanged[int].connect(\
self.backgroundComboSlot)
self.topWidget.configureButton.clicked.connect(\
self.configureButtonSlot)
if actions:
#connect actions
self.fitActions.estimateButton.clicked.connect(self.estimate)
self.fitActions.startFitButton.clicked.connect(self.startFit)
self.fitActions.dismissButton.clicked.connect(self.dismiss)
def importFunctions(self, functionsfile=None):
if functionsfile is None:
fn = qt.QFileDialog.getOpenFileName()
if fn.isEmpty():
functionsfile = ""
else:
functionsfile= qt.safe_str(fn)
if not len(functionsfile):
return
try:
self.fitModule.importFunctions(functionsfile)
#.........这里部分代码省略.........
开发者ID:maurov,项目名称:pymca,代码行数:101,代码来源:SimpleFitGui.py
示例17: StripBackgroundWidget
class StripBackgroundWidget(qt.QWidget):
def __init__(self, parent=None):
qt.QWidget.__init__(self, parent)
self.setWindowTitle("Strip and SNIP Configuration Window")
self.mainLayout = qt.QVBoxLayout(self)
self.mainLayout.setContentsMargins(0, 0, 0, 0)
self.mainLayout.setSpacing(2)
self.parametersWidget = StripParametersWidget(self)
self.graphWidget = PlotWindow(self, position=False, aspectRatio=False,
colormap=False, yInverted=False,
roi=False, mask=False, fit=False)
toolBar = self.graphWidget.getInteractiveModeToolBar()
toolBar.getZoomModeAction().setVisible(False)
toolBar.getPanModeAction().setVisible(False)
self.mainLayout.addWidget(self.parametersWidget)
self.mainLayout.addWidget(self.graphWidget)
self.getParameters = self.parametersWidget.getParameters
self.setParameters = self.parametersWidget.setParameters
self._x = None
self._y = None
self.parametersWidget.sigStripParametersWidgetSignal.connect( \
self._slot)
def setData(self, x, y):
self._x = x
self._y = y
self.update()
self.graphWidget.resetZoom()
def _slot(self, ddict):
self.update()
def update(self):
if self._y is None:
return
pars = self.getParameters()
#smoothed data
y = numpy.ravel(numpy.array(self._y)).astype(numpy.float)
ysmooth = SpecfitFuns.SavitskyGolay(y, pars['stripfilterwidth'])
f=[0.25,0.5,0.25]
ysmooth[1:-1] = numpy.convolve(ysmooth,f,mode=0)
ysmooth[0] = 0.5 *(ysmooth[0] + ysmooth[1])
ysmooth[-1] = 0.5 * (ysmooth[-1] + ysmooth[-2])
#loop for anchors
x = self._x
niter = pars['stripiterations']
anchorslist = []
if pars['stripanchorsflag']:
if pars['stripanchorslist'] is not None:
ravelled = x
for channel in pars['stripanchorslist']:
if channel <= ravelled[0]:continue
index = numpy.nonzero(ravelled >= channel)[0]
if len(index):
index = min(index)
if index > 0:
anchorslist.append(index)
if niter > 1000:
stripBackground = SpecfitFuns.subac(ysmooth,
pars['stripconstant'],
niter,
pars['stripwidth'],
anchorslist)
#final smoothing
stripBackground = SpecfitFuns.subac(stripBackground,
pars['stripconstant'],
500,1,
anchorslist)
elif niter > 0:
stripBackground = SpecfitFuns.subac(ysmooth,
pars['stripconstant'],
niter,
pars['stripwidth'],
anchorslist)
else:
stripBackground = 0.0 * ysmooth + ysmooth.min()
if len(anchorslist) == 0:
anchorslist = [0, len(ysmooth)-1]
anchorslist.sort()
snipBackground = 0.0 * ysmooth
lastAnchor = 0
width = pars['snipwidth']
for anchor in anchorslist:
if (anchor > lastAnchor) and (anchor < len(ysmooth)):
snipBackground[lastAnchor:anchor] =\
SpecfitFuns.snip1d(ysmooth[lastAnchor:anchor], width, 0)
lastAnchor = anchor
if lastAnchor < len(ysmooth):
snipBackground[lastAnchor:] =\
SpecfitFuns.snip1d(ysmooth[lastAnchor:], width, 0)
self.graphWidget.addCurve(x, y,
legend='Input Data',
resetzoom=False)
self.graphWidget.addCurve(x, stripBackground,
#.........这里部分代码省略.........
开发者ID:maurov,项目名称:pymca,代码行数:101,代码来源:StripBackgroundWidget.py
示例18: TestCurvesROIWidget
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')
#.........这里部分代码省略.........
开发者ID:dnaudet,项目名称:silx,代码行数:101,代码来源:testCurvesROIWidget.py
示例19: setUp
def setUp(self):
super(TestPlotWindow, self).setUp()
self.plot = PlotWindow()
self.plot.show()
self.qWaitForWindowExposed(self.plot)
开发者ID:PiRK,项目名称:silx,代码行数:5,代码来源:testPlotWindow.py
示例20: TestProfileToolBar
class TestProfileToolBar(TestCaseQt, ParametricTestCase):
"""Tests for ProfileToolBar widget."""
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()
def tearDown(self):
self.qapp.processEvents()
self.plot.setAttribute(qt.Qt.WA_DeleteOnClose)
self.plot.close()
del self.plot
del self.toolBar
super(TestProfileToolBar, self).tearDown()
def testAlignedProfile(self):
"""Test horizontal and vertical profile, without and with image"""
# Use Plot backend widget to submit mouse events
widget = self.plot.getWidgetHandle()
for method in ('sum', 'mean'):
with self.subTest(method=method):
# 2 positions to use for mouse events
pos1 = widget.width() * 0.4, widget.height() * 0.4
pos2 = widget.width() * 0.6, widget.height() * 0.6
for action in (self.toolBar.hLineAction, self.toolBar.vLineAction):
with self.subTest(mode=action.text()):
# Trigger tool button for mode
toolButton = getQToolButtonFromAction(action)
self.assertIsNot(toolButton, None)
self.mouseMove(toolButton)
self.mouseClick(toolButton, qt.Qt.LeftButton)
# Without image
self.mouseMove(widget, pos=pos1)
self.mouseClick(widget, qt.Qt.LeftButton, pos=pos1)
# with image
self.plot.addImage(
numpy.arange(100 * 100).reshape(100, -1))
self.mousePress(widget, qt.Qt.LeftButton, pos=pos1)
self.mouseMove(widget, pos=pos2)
self.mouseRelease(widget, qt.Qt.LeftButton, pos=pos2)
self.mouseMove(widget)
self.mouseClick(widget, qt.Qt.LeftButton)
def testDiagonalProfile(self):
"""Test diagonal profile, without and with image"""
# Use Plot backend widget to submit mouse events
widget = self.plot.getWidgetHandle()
for method in ('sum', 'mean'):
with self.subTest(method=method):
self.toolBar.setProfileMethod(method)
# 2 positions to use for mouse events
pos1 = widget.width() * 0.4, widget.height() * 0.4
pos2 = widget.width() * 0.6, widget.height() * 0.6
for image in (False, True):
with self.subTest(image=image):
if image:
self.plot.addImage(
numpy.arange(100 * 100).reshape(100, -1))
# Trigger tool button for diagonal profile mode
toolButton = getQToolButtonFromAction(
self.toolBar.lineAction)
self.assertIsNot(toolButton, None)
self.mouseMove(toolButton)
self.mouseClick(toolButton, qt.Qt.LeftButton)
self.toolBar.lineWidthSpinBox.setValue(3)
# draw profile line
self.mouseMove(widget, pos=pos1)
self.mousePress(widget, qt.Qt.LeftButton, pos=pos1)
self.mouseMove(widget, pos=pos2)
self.mouseRelease(widget, qt.Qt.LeftButton, pos=pos2)
if image is True:
profileCurve = self.toolBar.getProfilePlot().getAllCurves()[0]
if method == 'sum':
self.assertTrue(profileCurve.getData()[1].max() > 10000)
elif method == 'mean':
self.assertTrue(profileCurve.getData()[1].max() < 10000)
self.plot.clear()
开发者ID:dnaudet,项目名称:silx,代码行 |
请发表评论