def __createPlot(self, parent): plot = silx.gui.plot.PlotWidget(parent=parent) plot.setKeepDataAspectRatio(True) plot.setDataMargins(0.1, 0.1, 0.1, 0.1) plot.setGraphXLabel("X") plot.setGraphYLabel("Y") colormap = CalibrationContext.instance().getRawColormap() plot.setDefaultColormap(colormap) from silx.gui.plot import tools toolBar = tools.InteractiveModeToolBar(parent=self, plot=plot) plot.addToolBar(toolBar) toolBar = tools.ImageToolBar(parent=self, plot=plot) colormapDialog = CalibrationContext.instance().getColormapDialog() toolBar.getColormapAction().setColorDialog(colormapDialog) plot.addToolBar(toolBar) toolBar = qt.QToolBar(self) plot3dAction = qt.QAction(self) plot3dAction.setIcon(icons.getQIcon("pyfai:gui/icons/3d")) plot3dAction.setText("3D visualization") plot3dAction.setToolTip("Display a 3D visualization of the detector") plot3dAction.triggered.connect(self.__display3dDialog) toolBar.addAction(plot3dAction) plot.addToolBar(toolBar) return plot
def __init__(self, parent=None): super(MyPlotWindow, self).__init__(parent) # Create a PlotWidget self._plot = PlotWidget(parent=self) # Create a colorbar linked with the PlotWidget colorBar = ColorBarWidget(parent=self, plot=self._plot) # Make ColorBarWidget background white by changing its palette colorBar.setAutoFillBackground(True) palette = colorBar.palette() palette.setColor(qt.QPalette.Background, qt.Qt.white) palette.setColor(qt.QPalette.Window, qt.Qt.white) colorBar.setPalette(palette) # Combine the ColorBarWidget and the PlotWidget as # this QMainWindow's central widget gridLayout = qt.QGridLayout() gridLayout.setSpacing(0) gridLayout.setContentsMargins(0, 0, 0, 0) gridLayout.addWidget(self._plot, 0, 0) gridLayout.addWidget(colorBar, 0, 1) gridLayout.setRowStretch(0, 1) gridLayout.setColumnStretch(0, 1) centralWidget = qt.QWidget(self) centralWidget.setLayout(gridLayout) self.setCentralWidget(centralWidget) # Add ready to use toolbar with zoom and pan interaction mode buttons interactionToolBar = tools.InteractiveModeToolBar(parent=self, plot=self._plot) self.addToolBar(interactionToolBar) # Add toolbar actions to activate keyboard shortcuts self.addActions(interactionToolBar.actions()) # Add a new toolbar toolBar = qt.QToolBar("Plot Tools", self) self.addToolBar(toolBar) # Add actions from silx.gui.plot.action to the toolbar resetZoomAction = actions.control.ResetZoomAction(parent=self, plot=self._plot) toolBar.addAction(resetZoomAction) # Add tool buttons from silx.gui.plot.PlotToolButtons aspectRatioButton = PlotToolButtons.AspectToolButton(parent=self, plot=self._plot) toolBar.addWidget(aspectRatioButton) # Add ready to use toolbar with copy, save and print buttons outputToolBar = tools.OutputToolBar(parent=self, plot=self._plot) self.addToolBar(outputToolBar) # Add toolbar actions to activate keyboard shortcuts self.addActions(outputToolBar.actions()) # Add limits tool bar from silx.gui.plot.PlotTools limitsToolBar = tools.LimitsToolBar(parent=self, plot=self._plot) self.addToolBar(qt.Qt.BottomToolBarArea, limitsToolBar)
def __createPlotToolBar(self, plot): from silx.gui.plot import tools toolBar = tools.InteractiveModeToolBar(parent=self, plot=plot) plot.addToolBar(toolBar) toolBar = tools.ImageToolBar(parent=self, plot=plot) colormapDialog = CalibrationContext.instance().getColormapDialog() toolBar.getColormapAction().setColorDialog(colormapDialog) plot.addToolBar(toolBar)
def _createToolBars(self, plot): """Create tool bars displayed by the widget""" toolBar = tools.InteractiveModeToolBar(parent=self, plot=plot) self._interactiveModeToolBar = toolBar toolBar = tools.ImageToolBar(parent=self, plot=plot) self._imageToolBar = toolBar toolBar = CompareImagesToolBar(self) toolBar.setCompareWidget(self) self._compareToolBar = toolBar
def __createPlots(self, parent): margin = 0.02 plot1d = silx.gui.plot.PlotWidget(parent) plot1d.setGraphXLabel("Radial unit") plot1d.setGraphYLabel("Intensity") plot1d.setGraphGrid(False) plot1d.setDataMargins(margin, margin, margin, margin) plot2d = silx.gui.plot.PlotWidget(parent) plot2d.setGraphXLabel("Radial unit") plot2d.setGraphYLabel(r"Azimuthal angle $\chi$ (°)") plot2d.sigInteractiveModeChanged.connect(self.__syncModeToPlot1d) plot2d.setDataMargins(margin, margin, margin, margin) handle = plot2d.getWidgetHandle() handle.setContextMenuPolicy(qt.Qt.CustomContextMenu) handle.customContextMenuRequested.connect(self.__plot2dContextMenu) from silx.gui.plot import tools toolBar = tools.InteractiveModeToolBar(parent=self, plot=plot2d) plot2d.addToolBar(toolBar) toolBar = tools.ImageToolBar(parent=self, plot=plot2d) colormapDialog = CalibrationContext.instance().getColormapDialog() toolBar.getColormapAction().setColorDialog(colormapDialog) previousResetZoomAction = toolBar.getResetZoomAction() resetZoomAction = qt.QAction(toolBar) resetZoomAction.triggered.connect(self.resetZoom) resetZoomAction.setIcon(previousResetZoomAction.icon()) resetZoomAction.setText(previousResetZoomAction.text()) resetZoomAction.setToolTip(previousResetZoomAction.toolTip()) toolBar.insertAction(previousResetZoomAction, resetZoomAction) previousResetZoomAction.setVisible(False) self.__resetZoomAction = resetZoomAction plot2d.addToolBar(toolBar) ownToolBar = qt.QToolBar(plot2d) from silx.gui.plot import actions logAction = actions.control.YAxisLogarithmicAction(parent=ownToolBar, plot=plot1d) logAction.setToolTip("Logarithmic y-axis intensity when checked") ownToolBar.addAction(logAction) plot2d.addToolBar(ownToolBar) action = qt.QAction(ownToolBar) action.setIcon(silx.gui.icons.getQIcon("document-save")) action.triggered.connect(self.__saveAsCsv) action.setToolTip("Save 1D integration as CSV file") self.__saveResult1dAction = action ownToolBar.addAction(action) return plot1d, plot2d
def __createPlotToolBar(self, plot): from silx.gui.plot import tools toolBar = tools.InteractiveModeToolBar(parent=self, plot=plot) plot.addToolBar(toolBar) toolBar = tools.ImageToolBar(parent=self, plot=plot) colormapDialog = CalibrationContext.instance().getColormapDialog() toolBar.getColormapAction().setColorDialog(colormapDialog) plot.addToolBar(toolBar) toolBar = qt.QToolBar(self) plot3dAction = qt.QAction(self) plot3dAction.setIcon(icons.getQIcon("pyfai:gui/icons/3d")) plot3dAction.setText("3D visualization") plot3dAction.setToolTip("Display a 3D visualization of the sample stage") plot3dAction.triggered.connect(self.__display3dDialog) toolBar.addAction(plot3dAction) plot.addToolBar(toolBar)
def __createPlot(self, parent): plot = silx.gui.plot.PlotWidget(parent=parent) plot.setKeepDataAspectRatio(True) plot.setDataMargins(0.1, 0.1, 0.1, 0.1) plot.setGraphXLabel("Y") plot.setGraphYLabel("X") colormap = CalibrationContext.instance().getRawColormap() plot.setDefaultColormap(colormap) from silx.gui.plot import tools toolBar = tools.InteractiveModeToolBar(parent=self, plot=plot) plot.addToolBar(toolBar) toolBar = tools.ImageToolBar(parent=self, plot=plot) colormapDialog = CalibrationContext.instance().getColormapDialog() toolBar.getColormapAction().setColorDialog(colormapDialog) plot.addToolBar(toolBar) return plot