def __init__(self, parent=None): qt.QToolBar.__init__(self, parent) self.setIconSize(qt.QSize(16, 16)) action = qt.QAction(self) action.setIcon(icons.getQIcon("stats-active-items")) action.setText("Active items only") action.setToolTip("Display stats for active items only.") action.setCheckable(True) action.setChecked(True) self.__displayActiveItems = action action = qt.QAction(self) action.setIcon(icons.getQIcon("stats-whole-items")) action.setText("All items") action.setToolTip("Display stats for all available items.") action.setCheckable(True) self.__displayWholeItems = action action = qt.QAction(self) action.setIcon(icons.getQIcon("stats-visible-data")) action.setText("Use the visible data range") action.setToolTip("Use the visible data range.<br/>" "If activated the data is filtered to only use" "visible data of the plot." "The filtering is a data sub-sampling." "No interpolation is made to fit data to" "boundaries.") action.setCheckable(True) self.__useVisibleData = action action = qt.QAction(self) action.setIcon(icons.getQIcon("stats-whole-data")) action.setText("Use the full data range") action.setToolTip("Use the full data range.") action.setCheckable(True) action.setChecked(True) self.__useWholeData = action self.addAction(self.__displayWholeItems) self.addAction(self.__displayActiveItems) self.addSeparator() self.addAction(self.__useVisibleData) self.addAction(self.__useWholeData) self.itemSelection = qt.QActionGroup(self) self.itemSelection.setExclusive(True) self.itemSelection.addAction(self.__displayActiveItems) self.itemSelection.addAction(self.__displayWholeItems) self.dataRangeSelection = qt.QActionGroup(self) self.dataRangeSelection.setExclusive(True) self.dataRangeSelection.addAction(self.__useWholeData) self.dataRangeSelection.addAction(self.__useVisibleData)
def __init__(self, parent=None, backend=None): super(MaskImageWidget, self).__init__(parent=parent, backend=backend) self._activeImageLegend = "active image" self._bgImageLegend = "background image" self._maskToolsDockWidget = None # Init actions self.group = qt.QActionGroup(self) self.group.setExclusive(False) self.resetZoomAction = self.group.addAction( PlotActions.ResetZoomAction(self)) self.addAction(self.resetZoomAction) self.zoomInAction = PlotActions.ZoomInAction(self) self.addAction(self.zoomInAction) self.zoomOutAction = PlotActions.ZoomOutAction(self) self.addAction(self.zoomOutAction) self.xAxisAutoScaleAction = self.group.addAction( PlotActions.XAxisAutoScaleAction(self)) self.addAction(self.xAxisAutoScaleAction) self.yAxisAutoScaleAction = self.group.addAction( PlotActions.YAxisAutoScaleAction(self)) self.addAction(self.yAxisAutoScaleAction) self.colormapAction = self.group.addAction( PlotActions.ColormapAction(self)) self.addAction(self.colormapAction) self.keepDataAspectRatioButton = PlotToolButtons.AspectToolButton( parent=self, plot=self) self.yAxisInvertedButton = PlotToolButtons.YAxisOriginToolButton( parent=self, plot=self) self.group.addAction(self.getMaskAction()) self._separator = qt.QAction('separator', self) self._separator.setSeparator(True) self.group.addAction(self._separator) self.copyAction = self.group.addAction(PlotActions.CopyAction(self)) self.addAction(self.copyAction) self.saveAction = self.group.addAction(PlotActions.SaveAction(self)) self.addAction(self.saveAction) self.printAction = self.group.addAction(PlotActions.PrintAction(self)) self.addAction(self.printAction) # Creating the toolbar also create actions for toolbuttons self._toolbar = self._createToolBar(title='Plot', parent=None) self.addToolBar(self._toolbar)
def __init__(self, parent=None, *args, **kwargs): super(MainToolBar, self).__init__(parent=parent, *args, **kwargs) # Setup font self.font = qt.QFont("Verdana") self.font.setPointSize(16) # Mode action group self.modeActionGroup = qt.QActionGroup(self) # Align right self.setLayoutDirection(qt.Qt.RightToLeft) # Build children self.buildActions()
def _createRoiActions(self): if self._roiActions: return self._roiActions # roi shapes self._roiActionGroup = roiActionGroup = qt.QActionGroup(self) self._roiActions = roiActions = OrderedDict() for name, klass in self._klassInfos.items(): try: qIcon = icons.getQIcon(klass.actionIcon) except: qIcon = qt.QIcon() text = klass.actionText if text is None: text = klass.roiName action = qt.QAction(qIcon, text, None) action.setCheckable(True) toolTip = klass.actionToolTip if toolTip is not None: action.setToolTip(toolTip) roiActions[name] = action roiActionGroup.addAction(action) if klass.roiName == self._currentKlass: action.setChecked(True) else: action.setChecked(False) roiActionGroup.triggered.connect(self._roiActionTriggered, qt.Qt.QueuedConnection) return roiActions
def _initInteractionToolBar(self): self._interactionToolbar = qt.QToolBar() self._interactionToolbar.setEnabled(False) group = qt.QActionGroup(self._interactionToolbar) group.setExclusive(True) self._cameraAction = qt.QAction(None) self._cameraAction.setText('camera') self._cameraAction.setCheckable(True) self._cameraAction.setToolTip('Control camera') self._cameraAction.setChecked(True) group.addAction(self._cameraAction) self._planeAction = qt.QAction(None) self._planeAction.setText('plane') self._planeAction.setCheckable(True) self._planeAction.setToolTip('Control cutting plane') group.addAction(self._planeAction) group.triggered.connect(self._interactionChanged) self._interactionToolbar.addActions(group.actions()) self.addToolBar(self._interactionToolbar)
def createActions(self): action = qt.QAction("E&xit", self) action.setShortcuts(qt.QKeySequence.Quit) action.setStatusTip("Exit the application") action.triggered.connect(self.close) self._exitAction = action action = qt.QAction("&Open...", self) action.setStatusTip("Open a file") action.triggered.connect(self.open) self._openAction = action action = qt.QAction("Open Recent", self) action.setStatusTip("Open a recently openned file") action.triggered.connect(self.open) self._openRecentAction = action action = qt.QAction("&About", self) action.setStatusTip("Show the application's About box") action.triggered.connect(self.about) self._aboutAction = action action = qt.QAction("&Documentation", self) action.setStatusTip("Show the Silx library's documentation") action.triggered.connect(self.showDocumentation) self._documentationAction = action # Plot backend action = qt.QAction("Plot rendering backend", self) action.setStatusTip("Select plot rendering backend") self._plotBackendSelection = action menu = qt.QMenu() action.setMenu(menu) group = qt.QActionGroup(self) group.setExclusive(True) action = qt.QAction("matplotlib", self) action.setStatusTip("Plot will be rendered using matplotlib") action.setCheckable(True) action.triggered.connect(self.__forceMatplotlibBackend) group.addAction(action) menu.addAction(action) self._usePlotWithMatplotlib = action action = qt.QAction("OpenGL", self) action.setStatusTip("Plot will be rendered using OpenGL") action.setCheckable(True) action.triggered.connect(self.__forceOpenglBackend) group.addAction(action) menu.addAction(action) self._usePlotWithOpengl = action # Plot image orientation action = qt.QAction("Default plot image y-axis orientation", self) action.setStatusTip("Select the default y-axis orientation used by plot displaying images") self._plotImageOrientation = action menu = qt.QMenu() action.setMenu(menu) group = qt.QActionGroup(self) group.setExclusive(True) action = qt.QAction("Downward, origin on top", self) action.setIcon(self._iconDownward) action.setStatusTip("Plot images will use a downward Y-axis orientation") action.setCheckable(True) action.triggered.connect(self.__forcePlotImageDownward) group.addAction(action) menu.addAction(action) self._useYAxisOrientationDownward = action action = qt.QAction("Upward, origin on bottom", self) action.setIcon(self._iconUpward) action.setStatusTip("Plot images will use a upward Y-axis orientation") action.setCheckable(True) action.triggered.connect(self.__forcePlotImageUpward) group.addAction(action) menu.addAction(action) self._useYAxisOrientationUpward = action # Windows action = qt.QAction("Show custom NXdata selector", self) action.setStatusTip("Show a widget which allow to create plot by selecting data and axes") action.setCheckable(True) action.setShortcut(qt.QKeySequence(qt.Qt.Key_F5)) action.toggled.connect(self.__toggleCustomNxdataWindow) self._displayCustomNxdataWindow = action
def __createRingToolBar(self): toolBar = qt.QToolBar(self) action = qt.QAction(self) action.setIcon(icons.getQIcon("pyfai:gui/icons/search-full-ring")) action.setText("Ring") action.setCheckable(True) action.setToolTip("Extract peaks, beyond masked values") toolBar.addAction(action) self.__ringSelectionMode = action action = qt.QAction(self) action.setIcon(icons.getQIcon("pyfai:gui/icons/search-ring")) action.setText("Arc") action.setCheckable(True) action.setToolTip("Extract contiguous peaks") toolBar.addAction(action) self.__arcSelectionMode = action action = qt.QAction(self) action.setIcon(icons.getQIcon("pyfai:gui/icons/search-peak")) action.setText("Arc") action.setCheckable(True) action.setToolTip("Extract contiguous peaks") toolBar.addAction(action) self.__peakSelectionMode = action mode = qt.QActionGroup(self) mode.setExclusive(True) mode.addAction(self.__ringSelectionMode) mode.addAction(self.__arcSelectionMode) mode.addAction(self.__peakSelectionMode) self.__arcSelectionMode.setChecked(True) toolBar.addSeparator() # Load peak selection as file loadPeaksFromFile = qt.QAction(self) icon = icons.getQIcon('document-open') self.__icon = icon loadPeaksFromFile.setIcon(icon) loadPeaksFromFile.setText("Load peak selection from file") loadPeaksFromFile.triggered.connect(self.__loadPeaksFromFile) loadPeaksFromFile.setIconVisibleInMenu(True) toolBar.addAction(loadPeaksFromFile) # Save peak selection as file savePeaksAsFile = qt.QAction(self) icon = icons.getQIcon('document-save') savePeaksAsFile.setIcon(icon) savePeaksAsFile.setText("Save peak selection as file") savePeaksAsFile.triggered.connect(self.__savePeaksAsFile) savePeaksAsFile.setIconVisibleInMenu(True) toolBar.addAction(savePeaksAsFile) toolBar.addSeparator() style = qt.QApplication.style() action = self.__undoStack.createUndoAction(self, "Undo") icon = style.standardIcon(qt.QStyle.SP_ArrowBack) action.setIcon(icon) toolBar.addAction(action) action = self.__undoStack.createRedoAction(self, "Redo") icon = style.standardIcon(qt.QStyle.SP_ArrowForward) action.setIcon(icon) toolBar.addAction(action) return toolBar
def _initThresholdGroupBox(self): """Init thresholding widgets""" self.belowThresholdAction = qt.QAction( icons.getQIcon('plot-roi-below'), 'Mask below threshold', None) self.belowThresholdAction.setToolTip( 'Mask image where values are below given threshold') self.belowThresholdAction.setCheckable(True) self.belowThresholdAction.setChecked(True) self.betweenThresholdAction = qt.QAction( icons.getQIcon('plot-roi-between'), 'Mask within range', None) self.betweenThresholdAction.setToolTip( 'Mask image where values are within given range') self.betweenThresholdAction.setCheckable(True) self.aboveThresholdAction = qt.QAction( icons.getQIcon('plot-roi-above'), 'Mask above threshold', None) self.aboveThresholdAction.setToolTip( 'Mask image where values are above given threshold') self.aboveThresholdAction.setCheckable(True) self.thresholdActionGroup = qt.QActionGroup(self) self.thresholdActionGroup.setExclusive(True) self.thresholdActionGroup.addAction(self.belowThresholdAction) self.thresholdActionGroup.addAction(self.betweenThresholdAction) self.thresholdActionGroup.addAction(self.aboveThresholdAction) self.thresholdActionGroup.triggered.connect( self._thresholdActionGroupTriggered) self.loadColormapRangeAction = qt.QAction( icons.getQIcon('view-refresh'), 'Set min-max from colormap', None) self.loadColormapRangeAction.setToolTip( 'Set min and max values from current colormap range') self.loadColormapRangeAction.setCheckable(False) self.loadColormapRangeAction.triggered.connect( self._loadRangeFromColormapTriggered) widgets = [] for action in self.thresholdActionGroup.actions(): btn = qt.QToolButton() btn.setDefaultAction(action) widgets.append(btn) spacer = qt.QWidget() spacer.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Preferred) widgets.append(spacer) loadColormapRangeBtn = qt.QToolButton() loadColormapRangeBtn.setDefaultAction(self.loadColormapRangeAction) widgets.append(loadColormapRangeBtn) toolBar = self._hboxWidget(*widgets, stretch=False) config = qt.QGridLayout() config.setContentsMargins(0, 0, 0, 0) self.minLineLabel = qt.QLabel("Min:", self) self.minLineEdit = FloatEdit(self, value=0) config.addWidget(self.minLineLabel, 0, 0) config.addWidget(self.minLineEdit, 0, 1) self.maxLineLabel = qt.QLabel("Max:", self) self.maxLineEdit = FloatEdit(self, value=0) config.addWidget(self.maxLineLabel, 1, 0) config.addWidget(self.maxLineEdit, 1, 1) self.applyMaskBtn = qt.QPushButton('Apply mask') self.applyMaskBtn.clicked.connect(self._maskBtnClicked) layout = qt.QVBoxLayout() layout.addWidget(toolBar) layout.addLayout(config) layout.addWidget(self.applyMaskBtn) self.thresholdGroup = qt.QGroupBox('Threshold') self.thresholdGroup.setLayout(layout) # Init widget state self._thresholdActionGroupTriggered(self.belowThresholdAction) return self.thresholdGroup
def _initDrawGroupBox(self): """Init drawing tools widgets""" layout = qt.QVBoxLayout() self.browseAction = PanModeAction(self.plot, self.plot) self.addAction(self.browseAction) # Draw tools self.rectAction = qt.QAction(icons.getQIcon('shape-rectangle'), 'Rectangle selection', None) self.rectAction.setToolTip( 'Rectangle selection tool: (Un)Mask a rectangular region <b>R</b>') self.rectAction.setShortcut(qt.QKeySequence(qt.Qt.Key_R)) self.rectAction.setCheckable(True) self.rectAction.triggered.connect(self._activeRectMode) self.addAction(self.rectAction) self.ellipseAction = qt.QAction(icons.getQIcon('shape-ellipse'), 'Circle selection', None) self.ellipseAction.setToolTip( 'Rectangle selection tool: (Un)Mask a circle region <b>R</b>') self.ellipseAction.setShortcut(qt.QKeySequence(qt.Qt.Key_R)) self.ellipseAction.setCheckable(True) self.ellipseAction.triggered.connect(self._activeEllipseMode) self.addAction(self.ellipseAction) self.polygonAction = qt.QAction(icons.getQIcon('shape-polygon'), 'Polygon selection', None) self.polygonAction.setShortcut(qt.QKeySequence(qt.Qt.Key_S)) self.polygonAction.setToolTip( 'Polygon selection tool: (Un)Mask a polygonal region <b>S</b><br>' 'Left-click to place new polygon corners<br>' 'Left-click on first corner to close the polygon') self.polygonAction.setCheckable(True) self.polygonAction.triggered.connect(self._activePolygonMode) self.addAction(self.polygonAction) self.pencilAction = qt.QAction(icons.getQIcon('draw-pencil'), 'Pencil tool', None) self.pencilAction.setShortcut(qt.QKeySequence(qt.Qt.Key_P)) self.pencilAction.setToolTip( 'Pencil tool: (Un)Mask using a pencil <b>P</b>') self.pencilAction.setCheckable(True) self.pencilAction.triggered.connect(self._activePencilMode) self.addAction(self.pencilAction) self.drawActionGroup = qt.QActionGroup(self) self.drawActionGroup.setExclusive(True) self.drawActionGroup.addAction(self.rectAction) self.drawActionGroup.addAction(self.ellipseAction) self.drawActionGroup.addAction(self.polygonAction) self.drawActionGroup.addAction(self.pencilAction) actions = (self.browseAction, self.rectAction, self.ellipseAction, self.polygonAction, self.pencilAction) drawButtons = [] for action in actions: btn = qt.QToolButton() btn.setDefaultAction(action) drawButtons.append(btn) container = self._hboxWidget(*drawButtons) layout.addWidget(container) # Mask/Unmask radio buttons maskRadioBtn = qt.QRadioButton('Mask') maskRadioBtn.setToolTip( 'Drawing masks with current level. Press <b>Ctrl</b> to unmask') maskRadioBtn.setChecked(True) unmaskRadioBtn = qt.QRadioButton('Unmask') unmaskRadioBtn.setToolTip( 'Drawing unmasks with current level. Press <b>Ctrl</b> to mask') self.maskStateGroup = qt.QButtonGroup() self.maskStateGroup.addButton(maskRadioBtn, 1) self.maskStateGroup.addButton(unmaskRadioBtn, 0) self.maskStateWidget = self._hboxWidget(maskRadioBtn, unmaskRadioBtn) layout.addWidget(self.maskStateWidget) self.maskStateWidget.setHidden(True) # Pencil settings self.pencilSetting = self._createPencilSettings(None) self.pencilSetting.setVisible(False) layout.addWidget(self.pencilSetting) layout.addStretch(1) drawGroup = qt.QGroupBox('Draw tools') drawGroup.setLayout(layout) return drawGroup
def __init__(self, parent=None): qt.QToolBar.__init__(self, parent) self.__compareWidget = None menu = qt.QMenu(self) self.__visualizationAction = qt.QAction(self) self.__visualizationAction.setMenu(menu) self.__visualizationAction.setCheckable(False) self.addAction(self.__visualizationAction) self.__visualizationGroup = qt.QActionGroup(self) self.__visualizationGroup.setExclusive(True) self.__visualizationGroup.triggered.connect( self.__visualizationModeChanged) icon = icons.getQIcon("compare-mode-a") action = qt.QAction(icon, "Display the first image only", self) action.setIconVisibleInMenu(True) action.setCheckable(True) action.setShortcut(qt.QKeySequence(qt.Qt.Key_A)) action.setProperty("mode", VisualizationMode.ONLY_A) menu.addAction(action) self.__aModeAction = action self.__visualizationGroup.addAction(action) icon = icons.getQIcon("compare-mode-b") action = qt.QAction(icon, "Display the second image only", self) action.setIconVisibleInMenu(True) action.setCheckable(True) action.setShortcut(qt.QKeySequence(qt.Qt.Key_B)) action.setProperty("mode", VisualizationMode.ONLY_B) menu.addAction(action) self.__bModeAction = action self.__visualizationGroup.addAction(action) icon = icons.getQIcon("compare-mode-vline") action = qt.QAction(icon, "Vertical compare mode", self) action.setIconVisibleInMenu(True) action.setCheckable(True) action.setShortcut(qt.QKeySequence(qt.Qt.Key_V)) action.setProperty("mode", VisualizationMode.VERTICAL_LINE) menu.addAction(action) self.__vlineModeAction = action self.__visualizationGroup.addAction(action) icon = icons.getQIcon("compare-mode-hline") action = qt.QAction(icon, "Horizontal compare mode", self) action.setIconVisibleInMenu(True) action.setCheckable(True) action.setShortcut(qt.QKeySequence(qt.Qt.Key_H)) action.setProperty("mode", VisualizationMode.HORIZONTAL_LINE) menu.addAction(action) self.__hlineModeAction = action self.__visualizationGroup.addAction(action) icon = icons.getQIcon("compare-mode-rb-channel") action = qt.QAction(icon, "Blue/red compare mode (additive mode)", self) action.setIconVisibleInMenu(True) action.setCheckable(True) action.setShortcut(qt.QKeySequence(qt.Qt.Key_C)) action.setProperty("mode", VisualizationMode.COMPOSITE_RED_BLUE_GRAY) menu.addAction(action) self.__brChannelModeAction = action self.__visualizationGroup.addAction(action) icon = icons.getQIcon("compare-mode-rbneg-channel") action = qt.QAction(icon, "Yellow/cyan compare mode (subtractive mode)", self) action.setIconVisibleInMenu(True) action.setCheckable(True) action.setShortcut(qt.QKeySequence(qt.Qt.Key_W)) action.setProperty("mode", VisualizationMode.COMPOSITE_RED_BLUE_GRAY_NEG) menu.addAction(action) self.__ycChannelModeAction = action self.__visualizationGroup.addAction(action) icon = icons.getQIcon("compare-mode-a-minus-b") action = qt.QAction(icon, "Raw A minus B compare mode", self) action.setIconVisibleInMenu(True) action.setCheckable(True) action.setShortcut(qt.QKeySequence(qt.Qt.Key_W)) action.setProperty("mode", VisualizationMode.COMPOSITE_A_MINUS_B) menu.addAction(action) self.__ycChannelModeAction = action self.__visualizationGroup.addAction(action) menu = qt.QMenu(self) self.__alignmentAction = qt.QAction(self) self.__alignmentAction.setMenu(menu) self.__alignmentAction.setIconVisibleInMenu(True) self.addAction(self.__alignmentAction) self.__alignmentGroup = qt.QActionGroup(self) self.__alignmentGroup.setExclusive(True) self.__alignmentGroup.triggered.connect(self.__alignmentModeChanged) icon = icons.getQIcon("compare-align-origin") action = qt.QAction(icon, "Align images on their upper-left pixel", self) action.setProperty("mode", AlignmentMode.ORIGIN) action.setIconVisibleInMenu(True) action.setCheckable(True) self.__originAlignAction = action menu.addAction(action) self.__alignmentGroup.addAction(action) icon = icons.getQIcon("compare-align-center") action = qt.QAction(icon, "Center images", self) action.setProperty("mode", AlignmentMode.CENTER) action.setIconVisibleInMenu(True) action.setCheckable(True) self.__centerAlignAction = action menu.addAction(action) self.__alignmentGroup.addAction(action) icon = icons.getQIcon("compare-align-stretch") action = qt.QAction(icon, "Stretch the second image on the first one", self) action.setProperty("mode", AlignmentMode.STRETCH) action.setIconVisibleInMenu(True) action.setCheckable(True) self.__stretchAlignAction = action menu.addAction(action) self.__alignmentGroup.addAction(action) icon = icons.getQIcon("compare-align-auto") action = qt.QAction(icon, "Auto-alignment of the second image", self) action.setProperty("mode", AlignmentMode.AUTO) action.setIconVisibleInMenu(True) action.setCheckable(True) self.__autoAlignAction = action menu.addAction(action) if sift is None: action.setEnabled(False) action.setToolTip("Sift module is not available") self.__alignmentGroup.addAction(action) icon = icons.getQIcon("compare-keypoints") action = qt.QAction(icon, "Display/hide alignment keypoints", self) action.setCheckable(True) action.triggered.connect(self.__keypointVisibilityChanged) self.addAction(action) self.__displayKeypoints = action
def __init__(self, parent=None): super(MapWidget, self).__init__(parent=parent, backend=None, resetzoom=True, autoScale=False, logScale=False, grid=False, curveStyle=False, colormap=True, aspectRatio=True, yInverted=True, copy=True, save=True, print_=False, control=False, roi=False, mask=True) if parent is None: self.setWindowTitle('comMapWidget') self.setGraphTitle('Scan map') self.setKeepDataAspectRatio(True) self.setYAxisInverted(True) # customize the mask tools for use as ROI selectors # unfortunately, tooltip and icon reset each other, so only changing the icon. self.getMaskToolsDockWidget().setWindowTitle('scan map ROI') roiAction = self.getMaskAction() roiAction.setToolTip('Select a scan map region of interest') roiAction.setIcon(getQIcon('image-select-box')) # Remove the mask action from where it was self.toolBar().removeAction(roiAction) # Rebuild the zoom/pan toolbar and add selection tools tb = self.getInteractiveModeToolBar() for w in tb.actions(): tb.removeAction(w) zoomAction = qt.QAction(getQIcon('zoom'), 'Zoom', parent=self, checkable=True) panAction = qt.QAction(getQIcon('pan'), 'Pan', parent=self, checkable=True) selectAction = qt.QAction(getQIcon('image-select-add'), 'Select single scan point', parent=self, checkable=True) clearAction = qt.QAction(getQIcon('image-select-erase'), 'Clear selections', parent=self, checkable=False) tb.addAction(zoomAction) tb.addAction(panAction) tb.addAction(selectAction) tb.addAction(roiAction) tb.addAction(clearAction) group = qt.QActionGroup(self) group.addAction(zoomAction) group.addAction(panAction) group.addAction(selectAction) group.addAction(roiAction) zoomAction.setChecked(True) def setZoomMode(active): if active: self.setInteractiveMode('zoom') def setPanMode(active): if active: self.setInteractiveMode('pan') def setSelectMode(active): if active: self.setInteractiveMode('select') zoomAction.toggled.connect(setZoomMode) panAction.toggled.connect(setPanMode) selectAction.toggled.connect(setSelectMode) self.selectAction = selectAction self.roiAction = roiAction self.clearAction = clearAction self.sigPlotSignal.connect(self.filterMouseEvents) clearAction.triggered.connect(self.selectionCleared) # Add the index clicker self.indexBox = qt.QSpinBox( toolTip='Select a specific position by index') self.indexBox.setMinimum(0) tb.addWidget(self.indexBox) self.indexBox.valueChanged.connect(self.indexSelectionChanged) # add a button to toggle positions self.positionsAction = qt.QAction('positions', self, checkable=True) self.toolBar().addAction(self.positionsAction) # add the interpolation button self.interpolToolbar = qt.QToolBar('Interpolation options') self.interpolBox = qt.QSpinBox( toolTip='Map oversampling relative to average step size') self.interpolBox.setRange(1, 50) self.interpolBox.setValue(5) self.interpolToolbar.addWidget(qt.QLabel(' N:')) self.interpolToolbar.addWidget(self.interpolBox) self.addToolBar(self.interpolToolbar) self.interpolToolbar.hide() a = self.interpolToolbar.toggleViewAction().setChecked(False) # add a profile tool self.profile = ProfileToolBar(plot=self) self.addToolBar(self.profile) # set default colormap self.setDefaultColormap({ 'name': 'gray', 'autoscale': True, 'normalization': 'linear' })
def _initThresholdGroupBox(self): """Init thresholding widgets""" layout = qt.QVBoxLayout() # Thresholing self.belowThresholdAction = qt.QAction( icons.getQIcon('plot-roi-below'), 'Mask below threshold', None) self.belowThresholdAction.setToolTip( 'Mask image where values are below given threshold') self.belowThresholdAction.setCheckable(True) self.belowThresholdAction.triggered[bool].connect( self._belowThresholdActionTriggered) self.betweenThresholdAction = qt.QAction( icons.getQIcon('plot-roi-between'), 'Mask within range', None) self.betweenThresholdAction.setToolTip( 'Mask image where values are within given range') self.betweenThresholdAction.setCheckable(True) self.betweenThresholdAction.triggered[bool].connect( self._betweenThresholdActionTriggered) self.aboveThresholdAction = qt.QAction( icons.getQIcon('plot-roi-above'), 'Mask above threshold', None) self.aboveThresholdAction.setToolTip( 'Mask image where values are above given threshold') self.aboveThresholdAction.setCheckable(True) self.aboveThresholdAction.triggered[bool].connect( self._aboveThresholdActionTriggered) self.thresholdActionGroup = qt.QActionGroup(self) self.thresholdActionGroup.setExclusive(False) self.thresholdActionGroup.addAction(self.belowThresholdAction) self.thresholdActionGroup.addAction(self.betweenThresholdAction) self.thresholdActionGroup.addAction(self.aboveThresholdAction) self.thresholdActionGroup.triggered.connect( self._thresholdActionGroupTriggered) self.loadColormapRangeAction = qt.QAction( icons.getQIcon('view-refresh'), 'Set min-max from colormap', None) self.loadColormapRangeAction.setToolTip( 'Set min and max values from current colormap range') self.loadColormapRangeAction.setCheckable(False) self.loadColormapRangeAction.triggered.connect( self._loadRangeFromColormapTriggered) widgets = [] for action in self.thresholdActionGroup.actions(): btn = qt.QToolButton() btn.setDefaultAction(action) widgets.append(btn) spacer = qt.QWidget() spacer.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Preferred) widgets.append(spacer) loadColormapRangeBtn = qt.QToolButton() loadColormapRangeBtn.setDefaultAction(self.loadColormapRangeAction) widgets.append(loadColormapRangeBtn) container = self._hboxWidget(*widgets, stretch=False) layout.addWidget(container) form = qt.QFormLayout() self.minLineEdit = qt.QLineEdit() self.minLineEdit.setText('0') self.minLineEdit.setValidator(qt.QDoubleValidator(self)) self.minLineEdit.setEnabled(False) form.addRow('Min:', self.minLineEdit) self.maxLineEdit = qt.QLineEdit() self.maxLineEdit.setText('0') self.maxLineEdit.setValidator(qt.QDoubleValidator(self)) self.maxLineEdit.setEnabled(False) form.addRow('Max:', self.maxLineEdit) self.applyMaskBtn = qt.QPushButton('Apply mask') self.applyMaskBtn.clicked.connect(self._maskBtnClicked) self.applyMaskBtn.setEnabled(False) form.addRow(self.applyMaskBtn) self.maskNanBtn = qt.QPushButton('Mask not finite values') self.maskNanBtn.setToolTip('Mask Not a Number and infinite values') self.maskNanBtn.clicked.connect(self._maskNotFiniteBtnClicked) form.addRow(self.maskNanBtn) thresholdWidget = qt.QWidget() thresholdWidget.setLayout(form) layout.addWidget(thresholdWidget) layout.addStretch(1) self.thresholdGroup = qt.QGroupBox('Threshold') self.thresholdGroup.setLayout(layout) return self.thresholdGroup
def __init__(self, parent=None, backend=None): super(MaskScatterWidget, self).__init__(parent=parent, backend=backend) self._activeScatterLegend = "active scatter" self._bgImageLegend = "background image" self._maskToolsDockWidget = None # Init actions self.group = qt.QActionGroup(self) self.group.setExclusive(False) self.resetZoomAction = self.group.addAction( PlotActions.ResetZoomAction(self)) self.addAction(self.resetZoomAction) self.zoomInAction = PlotActions.ZoomInAction(self) self.addAction(self.zoomInAction) self.zoomOutAction = PlotActions.ZoomOutAction(self) self.addAction(self.zoomOutAction) self.xAxisAutoScaleAction = self.group.addAction( PlotActions.XAxisAutoScaleAction(self)) self.addAction(self.xAxisAutoScaleAction) self.yAxisAutoScaleAction = self.group.addAction( PlotActions.YAxisAutoScaleAction(self)) self.addAction(self.yAxisAutoScaleAction) self.colormapButton = ColormapToolButton(parent=self, plot=self) self.keepDataAspectRatioButton = PlotToolButtons.AspectToolButton( parent=self, plot=self) self.yAxisInvertedButton = PlotToolButtons.YAxisOriginToolButton( parent=self, plot=self) self.group.addAction(self.getMaskAction()) self._separator = qt.QAction('separator', self) self._separator.setSeparator(True) self.group.addAction(self._separator) self.copyAction = self.group.addAction(PlotActions.CopyAction(self)) self.addAction(self.copyAction) self.saveAction = self.group.addAction(PlotActions.SaveAction(self)) self.addAction(self.saveAction) self.printAction = self.group.addAction(PlotActions.PrintAction(self)) self.addAction(self.printAction) self.alphaSlider = NamedScatterAlphaSlider(parent=self, plot=self) self.alphaSlider.setOrientation(qt.Qt.Horizontal) # Creating the toolbar also create actions for toolbuttons self._toolbar = self._createToolBar(title='Plot', parent=None) self.addToolBar(self._toolbar) self.setActiveCurveHandling( False) # avoids color change when selecting self.sigContentChanged.connect(self._onContentChanged)