Exemplo n.º 1
0
    def __createActions(self):
        style = Qt.QApplication.style()
        self.__actions = actions = {}

        # load
        icon = style.standardIcon(Qt.QStyle.SP_DialogOpenButton)
        openAct = Qt.QAction(icon, '&Open project', self)
        openAct.setShortcuts(Qt.QKeySequence.Open)
        openAct.setStatusTip('Open an existing project')
        openAct.triggered.connect(self.__openProject)
        actions['open'] = openAct

        # create
        icon = getXsocsIcon('create_project')
        createAct = Qt.QAction(icon, '&Create project', self)
        createAct.setShortcuts(Qt.QKeySequence.New)
        createAct.setStatusTip('Create a new project')
        createAct.triggered.connect(self.__createProject)
        actions['create'] = createAct

        # exit the application
        icon = style.standardIcon(Qt.QStyle.SP_DialogCancelButton)
        quitAct = Qt.QAction(icon, 'E&xit', self)
        quitAct.setShortcuts(Qt.QKeySequence.Quit)
        quitAct.setStatusTip('Exit the application')
        quitAct.triggered.connect(Qt.qApp.closeAllWindows)
        actions['quit'] = quitAct

        # "about" action
        aboutAct = Qt.QAction('&About', self)
        aboutAct.setStatusTip('Show the application\'s About box')
        actions['about'] = aboutAct
Exemplo n.º 2
0
    def __initContent(self):
        """Create all expected actions and set the content of this toolbar."""
        action = qt.QAction("Create a new custom NXdata", self)
        action.setIcon(icons.getQIcon("nxdata-create"))
        action.triggered.connect(self.__createNewNxdata)
        self.addAction(action)
        self.__addNxDataAction = action

        action = qt.QAction("Remove the selected NXdata", self)
        action.setIcon(icons.getQIcon("nxdata-remove"))
        action.triggered.connect(self.__removeSelectedNxdata)
        self.addAction(action)
        self.__removeNxDataAction = action

        self.addSeparator()

        action = qt.QAction("Create a new axis to the selected NXdata", self)
        action.setIcon(icons.getQIcon("nxdata-axis-add"))
        action.triggered.connect(self.__appendNewAxisToSelectedNxdata)
        self.addAction(action)
        self.__addNxDataAxisAction = action

        action = qt.QAction("Remove the selected NXdata axis", self)
        action.setIcon(icons.getQIcon("nxdata-axis-remove"))
        action.triggered.connect(self.__removeSelectedAxis)
        self.addAction(action)
        self.__removeNxDataAxisAction = action
Exemplo n.º 3
0
    def __init__(self, parent=None):
        super(ObjectView, self).__init__(parent=parent)

        if parent is None:
            self.setWindowTitle('comMapWidget')

        self.setKeepDataAspectRatio(True)
        self.setComplexMode(self.Mode.PHASE)
        self.getPlot().setGraphYLabel('micrometers')
        self.getPlot().setGraphXLabel('micrometers')

        # add a button to toggle positions
        self.positionsAction = qt.QAction('positions', self, checkable=True)
        self.getPlot().toolBar().addAction(self.positionsAction)

        # add a button to toggle phase ramp removal
        self.rampAction = qt.QAction('ramp', self, checkable=True)
        self.getPlot().toolBar().addAction(self.rampAction)
        self.rampAction.triggered.connect(self._toggleRamp)

        # add a phase shift number
        self.phaseShiftBox = qt.QDoubleSpinBox(
            toolTip='Phase shift everything')
        self.phaseShiftBox.setRange(-3.14, 3.14)
        self.phaseShiftBox.setSingleStep(.1)
        self.phaseShiftBox.setValue(0.)
        self.phaseShiftBox.setPrefix('phase shift: ')
        self.phaseShiftBox.valueChanged.connect(self._update)
        self.getPlot().toolBar().addWidget(self.phaseShiftBox)
Exemplo n.º 4
0
    def populateContextMenu(self, event):
        """Called to populate the context menu

        :param silx.gui.hdf5.Hdf5ContextMenuEvent event: Event
            containing expected information to populate the context menu
        """

        selectedObjects = list(event.source().selectedH5Nodes())
        if len(selectedObjects) == 0:
            return
        if len(selectedObjects) > 1:
            return
        obj = selectedObjects[0]
        # obj = event.hoveredObject()

        if obj.ntype is not h5py.Dataset:
            return

        menu = event.menu()

        isNumber = obj.shape == tuple() and numpy.issubdtype(obj.dtype, numpy.number)
        isImage = len(obj.shape) == 2 and numpy.issubdtype(obj.dtype, numpy.number)

        # Action to pick the image
        action = qt.QAction("Pick this value as background", event.source())
        action.triggered.connect(lambda: self.setBackground(obj.h5py_object))
        action.setEnabled(isImage)
        menu.addAction(action)

        # Action to pick the background
        action = qt.QAction("Pick this value as flat field", event.source())
        action.triggered.connect(lambda: self.setFlatField(obj.h5py_object))
        action.setEnabled(isImage)
        menu.addAction(action)
Exemplo n.º 5
0
    def closeAndSyncCustomContextMenu(self, event):
        """Called to populate the context menu

        :param silx.gui.hdf5.Hdf5ContextMenuEvent event: Event
            containing expected information to populate the context menu
        """
        selectedObjects = event.source().selectedH5Nodes(
            ignoreBrokenLinks=False)
        menu = event.menu()

        if len(menu.children()):
            menu.addSeparator()

        # Import it here to be sure to use the right logging level
        import h5py
        for obj in selectedObjects:
            if obj.ntype is h5py.File:
                action = qt.QAction("Remove %s" % obj.local_filename,
                                    event.source())
                action.triggered.connect(
                    lambda: self.__treeview.findHdf5TreeModel(
                    ).removeH5pyObject(obj.h5py_object))
                menu.addAction(action)
                action = qt.QAction("Synchronize %s" % obj.local_filename,
                                    event.source())
                action.triggered.connect(
                    lambda: self.__treeview.findHdf5TreeModel(
                    ).synchronizeH5pyObject(obj.h5py_object))
                menu.addAction(action)
Exemplo n.º 6
0
    def closeAndSyncCustomContextMenu(self, event):
        """Called to populate the context menu

        :param silx.gui.hdf5.Hdf5ContextMenuEvent event: Event
            containing expected information to populate the context menu
        """
        selectedObjects = event.source().selectedH5Nodes()
        menu = event.menu()

        if not menu.isEmpty():
            menu.addSeparator()

        for obj in selectedObjects:
            if obj.ntype is h5py.File:
                action = qt.QAction("Remove %s" % obj.local_filename,
                                    event.source())
                action.triggered.connect(
                    lambda: self.__treeview.findHdf5TreeModel(
                    ).removeH5pyObject(obj.h5py_object))
                menu.addAction(action)
                action = qt.QAction("Synchronize %s" % obj.local_filename,
                                    event.source())
                action.triggered.connect(
                    lambda: self.__treeview.findHdf5TreeModel(
                    ).synchronizeH5pyObject(obj.h5py_object))
                menu.addAction(action)
Exemplo n.º 7
0
    def __createOptionsWidget(self):
        menu = qt.QMenu(self)

        # Load peak selection as file
        loadPeaksFromFile = qt.QAction(self)
        icon = icons.getQIcon('document-open')
        loadPeaksFromFile.setIcon(icon)
        loadPeaksFromFile.setText("Load peak selection from file")
        loadPeaksFromFile.triggered.connect(self.__loadPeaksFromFile)
        loadPeaksFromFile.setIconVisibleInMenu(True)
        menu.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)
        menu.addAction(savePeaksAsFile)

        options = qt.QToolButton(self)
        icon = icons.getQIcon('pyfai:gui/icons/options')
        options.setIcon(icon)
        options.setPopupMode(qt.QToolButton.InstantPopup)
        options.setMenu(menu)
        return options
Exemplo n.º 8
0
    def __init__(self, parent=None, plot=None, stats=None, rois=None):
        qt.QMainWindow.__init__(self, parent)

        toolbar = qt.QToolBar(self)
        icon = icons.getQIcon('add')
        self._rois = list(rois) if rois is not None else []
        self._addAction = qt.QAction(icon, 'add item/roi', toolbar)
        self._addAction.triggered.connect(self._addRoiStatsItem)
        icon = icons.getQIcon('rm')
        self._removeAction = qt.QAction(icon, 'remove item/roi', toolbar)
        self._removeAction.triggered.connect(self._removeCurrentRow)

        toolbar.addAction(self._addAction)
        toolbar.addAction(self._removeAction)
        self.addToolBar(toolbar)

        self._plot = plot
        self._statsROITable = _StatsROITable(parent=self, plot=self._plot)
        self.setStats(stats=stats)
        self.setCentralWidget(self._statsROITable)
        self.setWindowFlags(qt.Qt.Widget)

        # expose API
        self._setUpdateMode = self._statsROITable.setUpdateMode
        self._updateAllStats = self._statsROITable._updateAllStats

        # setup
        self._statsROITable.setSelectionBehavior(qt.QTableWidget.SelectRows)
Exemplo n.º 9
0
    def __createTreeWindow(self, treeView):
        toolbar = qt.QToolBar(self)
        toolbar.setIconSize(qt.QSize(16, 16))
        toolbar.setStyleSheet("QToolBar { border: 0px }")

        action = qt.QAction(toolbar)
        action.setIcon(icons.getQIcon("view-refresh"))
        action.setText("Refresh")
        action.setToolTip("Refresh all selected items")
        action.triggered.connect(self.__refreshSelected)
        action.setShortcut(qt.QKeySequence(qt.Qt.Key_F5))
        toolbar.addAction(action)
        treeView.addAction(action)
        self.__refreshAction = action

        # Another shortcut for refresh
        action = qt.QAction(toolbar)
        action.setShortcut(qt.QKeySequence(qt.Qt.ControlModifier + qt.Qt.Key_R))
        treeView.addAction(action)
        action.triggered.connect(self.__refreshSelected)

        action = qt.QAction(toolbar)
        # action.setIcon(icons.getQIcon("view-refresh"))
        action.setText("Close")
        action.setToolTip("Close selected item")
        action.triggered.connect(self.__removeSelected)
        action.setShortcut(qt.QKeySequence(qt.Qt.Key_Delete))
        treeView.addAction(action)
        self.__closeAction = action

        toolbar.addSeparator()

        action = qt.QAction(toolbar)
        action.setIcon(icons.getQIcon("tree-expand-all"))
        action.setText("Expand all")
        action.setToolTip("Expand all selected items")
        action.triggered.connect(self.__expandAllSelected)
        action.setShortcut(qt.QKeySequence(qt.Qt.ControlModifier + qt.Qt.Key_Plus))
        toolbar.addAction(action)
        treeView.addAction(action)
        self.__expandAllAction = action

        action = qt.QAction(toolbar)
        action.setIcon(icons.getQIcon("tree-collapse-all"))
        action.setText("Collapse all")
        action.setToolTip("Collapse all selected items")
        action.triggered.connect(self.__collapseAllSelected)
        action.setShortcut(qt.QKeySequence(qt.Qt.ControlModifier + qt.Qt.Key_Minus))
        toolbar.addAction(action)
        treeView.addAction(action)
        self.__collapseAllAction = action

        widget = qt.QWidget(self)
        layout = qt.QVBoxLayout(widget)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        layout.addWidget(toolbar)
        layout.addWidget(treeView)
        return widget
Exemplo n.º 10
0
        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)
Exemplo n.º 11
0
    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
Exemplo n.º 12
0
    def customContextMenu(self, event):
        """Called to populate the context menu

        :param silx.gui.hdf5.Hdf5ContextMenuEvent event: Event
            containing expected information to populate the context menu
        """
        selectedObjects = event.source().selectedH5Nodes(
            ignoreBrokenLinks=False)
        menu = event.menu()

        if not menu.isEmpty():
            menu.addSeparator()

        for obj in selectedObjects:
            h5 = obj.h5py_object

            name = obj.name
            if name.startswith("/"):
                name = name[1:]
            if name == "":
                name = "the root"

            action = qt.QAction("Show %s" % name, event.source())
            action.triggered.connect(lambda: self.displayData(h5))
            menu.addAction(action)

            if silx.io.is_dataset(h5):
                action = qt.QAction("Use as a new custom signal",
                                    event.source())
                action.triggered.connect(lambda: self.useAsNewCustomSignal(h5))
                menu.addAction(action)

            if silx.io.is_group(h5) and silx.io.nxdata.is_valid_nxdata(h5):
                action = qt.QAction("Use as a new custom NXdata",
                                    event.source())
                action.triggered.connect(lambda: self.useAsNewCustomNxdata(h5))
                menu.addAction(action)

            if silx.io.is_file(h5):
                action = qt.QAction("Close %s" % obj.local_filename,
                                    event.source())
                action.triggered.connect(
                    lambda: self.__treeview.findHdf5TreeModel(
                    ).removeH5pyObject(h5))
                menu.addAction(action)
                action = qt.QAction("Synchronize %s" % obj.local_filename,
                                    event.source())
                action.triggered.connect(
                    lambda: self.__synchronizeH5pyObject(h5))
                menu.addAction(action)
Exemplo n.º 13
0
    def showContextMenu(self, position):
        menu = qt.QMenu('Horizontal Header View Menu', self)

        section = self.logicalIndexAt(position)

        action = qt.QAction('Add', self, triggered=self.append)
        menu.addAction(action)

        action = qt.QAction('Remove',
                            self,
                            triggered=lambda: self.remove(section))
        menu.addAction(action)

        menu.exec_(self.mapToGlobal(position))
Exemplo n.º 14
0
    def __popupUnitSelection(self, pos):
        """Display a popup list to allow to select a new unit"""
        currentUnit = self.usedUnit()
        if currentUnit is None:
            return

        unitList = units.Unit.get_units(currentUnit.dimensionality)
        if len(unitList) <= 1:
            return

        menu = qt.QMenu(self)
        menu.addSection("Unit for %s" %
                        currentUnit.dimensionality.fullname.lower())

        for unit in unitList:
            action = qt.QAction(menu)
            text = "%s: %s" % (unit.fullname, unit.symbol)
            if unit is currentUnit:
                text += " (current)"
            action.setText(text)
            action.triggered.connect(
                functools.partial(self.__unitSelected, unit))
            menu.addAction(action)

        menu.popup(pos)
Exemplo n.º 15
0
    def _initConsoleMenu(self):
        self._menuConsole = self._menuBar.addMenu("Console")

        self._newConsoleAction = qt.QAction("&New Qt Console",
                                            self, shortcut="Ctrl+K",
                                            triggered=self._ipykernel.new_qt_console)
        self._addMenuAction(self._menuConsole, self._newConsoleAction)
Exemplo n.º 16
0
    def addDefaultAction(self, action):
        """Add an action that can be selected to set the default action
        displayed by the tool button.

        :param qt.QAction action: An action to execute when selected on the
            menu and then clicked.
        :rtype: qt.QAction
        :returns: An action triggered when the provided action is selected.
        """
        default = self.defaultAction()
        if default is None:
            self.setDefaultAction(action)
        selectAction = qt.QAction(self)
        selectAction.setIcon(action.icon())
        selectAction.setToolTip(action.toolTip())
        selectAction.setText(action.text())

        action.setVisible(False)

        selectAction._action = weakref.ref(action)
        selectActionRef = weakref.ref(selectAction)

        selectAction.triggered.connect(
            lambda: self.__selectActionTriggered(selectActionRef))
        self.addAction(selectAction)
        return selectAction
Exemplo n.º 17
0
Arquivo: view.py Projeto: fangohr/silx
    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("&About", self)
        action.setStatusTip("Show the application's About box")
        action.triggered.connect(self.about)
        self._aboutAction = action
Exemplo n.º 18
0
    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
Exemplo n.º 19
0
 def createMarkGeometryAction(self, parent, mousePos):
     maskGeometryAction = qt.QAction(parent)
     maskGeometryAction.setText(u"Mark this χ/2θ coord")
     maskGeometryAction.triggered.connect(
         functools.partial(self.__createGeometryMarker, mousePos))
     maskGeometryAction.setEnabled(self.__geometry is not None)
     return maskGeometryAction
Exemplo n.º 20
0
 def _addAction(self, menu, text, slot, shortcut=None):
     action = qt.QAction(text, self)
     action.triggered.connect(slot)
     if shortcut:
         action.setShortcut(qt.QKeySequence(shortcut))
     action.setShortcutContext(qt.Qt.WidgetWithChildrenShortcut)
     menu.addAction(action)
     return action
Exemplo n.º 21
0
 def createMarkPixelAction(self, parent, mousePos):
     maskPixelAction = qt.QAction(parent)
     maskPixelAction.setText("Mark this pixel coord")
     maskPixelAction.triggered.connect(
         functools.partial(self.__createPixelMarker, mousePos))
     if not self.__pixelBasedPlot:
         maskPixelAction.setEnabled(self.__geometry is not None)
     return maskPixelAction
Exemplo n.º 22
0
    def _menu_file(self):
        # Drop-down file menu
        self.files_menu = qt.QMenu("Files")

        action_more = qt.QAction("add files", self.files)
        self.files_menu.addAction(action_more)
        action_more.triggered.connect(self.input_filer)

        action_sort = qt.QAction("sort files", self.files)
        self.files_menu.addAction(action_sort)
        action_sort.triggered.connect(self.sort_input)

        action_clear = qt.QAction("clear selected files", self.files)
        self.files_menu.addAction(action_clear)
        action_clear.triggered.connect(self.clear_selection)

        self.files.setMenu(self.files_menu)
Exemplo n.º 23
0
 def buildActions(self):
     action = qt.QAction("EXAFS", self)
     # action.triggered.connect(partial(self.setMode, mode='exafs'))
     action.setFont(self.font)
     # action.setProperty("isMode", True)
     action.setCheckable(True)
     action.setActionGroup(self.modeActionGroup)
     action.setChecked(True)
     self.addAction(action)
Exemplo n.º 24
0
 def __updateFileMenu(self):
     files = self.__context.getRecentFiles()
     self._openRecentMenu.clear()
     self._openRecentMenu.setEnabled(len(files) != 0)
     if len(files) != 0:
         for filePath in files:
             baseName = os.path.basename(filePath)
             action = qt.QAction(baseName, self)
             action.setToolTip(filePath)
             action.triggered.connect(
                 functools.partial(self.__openRecentFile, filePath))
             self._openRecentMenu.addAction(action)
         self._openRecentMenu.addSeparator()
         baseName = os.path.basename(filePath)
         action = qt.QAction("Clear history", self)
         action.setToolTip("Clear the history of the recent files")
         action.triggered.connect(self.__clearRecentFile)
         self._openRecentMenu.addAction(action)
Exemplo n.º 25
0
    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)
Exemplo n.º 26
0
    def __init__(self, parent=None, plot=None, title=''):
        super(_BaseProfileToolBar, self).__init__(title, parent)

        self.__profile = None
        self.__profileTitle = ''

        assert isinstance(plot, PlotWidget)
        self._plotRef = weakref.ref(plot,
                                    WeakMethodProxy(self.__plotDestroyed))

        self._profileWindow = None

        # Set-up interaction manager
        roiManager = RegionOfInterestManager(plot)
        self._roiManagerRef = weakref.ref(roiManager)

        roiManager.sigInteractiveModeFinished.connect(
            self.__interactionFinished)
        roiManager.sigRoiChanged.connect(self.updateProfile)
        roiManager.sigRoiAdded.connect(self.__roiAdded)

        # Add interactive mode actions
        for kind, icon, tooltip in (
            (roi_items.HorizontalLineROI, 'shape-horizontal',
             'Enables horizontal line profile selection mode'),
            (roi_items.VerticalLineROI, 'shape-vertical',
             'Enables vertical line profile selection mode'),
            (roi_items.LineROI, 'shape-diagonal',
             'Enables line profile selection mode')):
            action = roiManager.getInteractionModeAction(kind)
            action.setIcon(icons.getQIcon(icon))
            action.setToolTip(tooltip)
            self.addAction(action)

        # Add clear action
        action = qt.QAction(icons.getQIcon('profile-clear'), 'Clear Profile',
                            self)
        action.setToolTip('Clear the profile')
        action.setCheckable(False)
        action.triggered.connect(self.clearProfile)
        self.addAction(action)

        # Initialize color
        self._color = None
        self.setColor('red')

        # Listen to plot limits changed
        plot.getXAxis().sigLimitsChanged.connect(self.updateProfile)
        plot.getYAxis().sigLimitsChanged.connect(self.updateProfile)

        # Listen to plot scale
        plot.getXAxis().sigScaleChanged.connect(self.__plotAxisScaleChanged)
        plot.getYAxis().sigScaleChanged.connect(self.__plotAxisScaleChanged)

        self.setDefaultProfileWindowEnabled(True)
Exemplo n.º 27
0
    def __init__(self, parent=None, plot=None):
        self._bg_dialog = None
        self._scatter_dialog = None
        super(ColormapToolButton, self).__init__(parent)
        self.plot = plot

        icon = icons.getQIcon('colormap')
        self.setIcon(icon)

        bgImageCmapAction = qt.QAction("Background image colormap", self)
        bgImageCmapAction.triggered.connect(self._setBgCmap)

        scatterCmapAction = qt.QAction("Scatter colormap", self)
        scatterCmapAction.triggered.connect(self._setScatterCmap)

        menu = qt.QMenu(self)
        menu.addAction(bgImageCmapAction)
        menu.addAction(scatterCmapAction)
        self.setMenu(menu)
        self.setPopupMode(qt.QToolButton.InstantPopup)
Exemplo n.º 28
0
 def populateRedoMenu(self, menu):
     # menu = self.sender()
     for action in menu.actions():
         menu.removeAction(action)
     for ientry, entry in reversed(list(enumerate(csi.redo))):
         text = gur.getStrRepr(entry)
         subAction = qt.QAction(
             qt.QIcon(os.path.join(self.iconDir, "icon-redo.png")), text,
             self)
         subAction.triggered.connect(partial(self.slotRedo, ientry))
         menu.addAction(subAction)
Exemplo n.º 29
0
    def createRemoveClosestMaskerAction(self, parent, mousePos):
        action = qt.QAction(parent)

        marker = self.findClosestMarker(mousePos)
        if marker is None:
            return None

        action.setText("Remove marker '%s'" % marker.name())
        action.triggered.connect(functools.partial(self.__removeMarker,
                                                   marker))
        return action
Exemplo n.º 30
0
    def showContextMenu(self, position):
        menu = qt.QMenu('RixsPlotArea Menu', self)

        action = qt.QAction('Add RixsPlot2D Window',
                            self,
                            triggered=self.addRixsPlot2D)
        menu.addAction(action)

        menu.addSeparator()

        action = qt.QAction('Cascade Windows',
                            self,
                            triggered=self.cascadeSubWindows)
        menu.addAction(action)

        action = qt.QAction('Tile Windows',
                            self,
                            triggered=self.tileSubWindows)
        menu.addAction(action)

        menu.exec_(self.mapToGlobal(position))