Example #1
0
    def __init__(self):
        super(PeakPickingTask, self).__init__()
        qt.loadUi(pyFAI.utils.get_ui_file("calibration-peakpicking.ui"), self)
        self.initNextStep()
        self.__dialogState = None

        layout = qt.QVBoxLayout(self._imageHolder)
        self.__plot = _PeakPickingPlot(parent=self._imageHolder)
        toolBar = self.__createPlotToolBar(self.__plot)
        self.__plot.addToolBar(toolBar)
        statusBar = self.__createPlotStatusBar(self.__plot)
        self.__plot.setStatusBar(statusBar)

        layout.addWidget(self.__plot)
        layout.setContentsMargins(1, 1, 1, 1)
        self._imageHolder.setLayout(layout)

        self._ringSelectionMode.setIcon(icons.getQIcon("pyfai:gui/icons/search-ring"))
        self._peakSelectionMode.setIcon(icons.getQIcon("pyfai:gui/icons/search-peak"))
        self.__peakSelectionView = None
        self.__plot.sigPlotSignal.connect(self.__onPlotEvent)

        self.__undoStack = qt.QUndoStack(self)
        self._undoButton.setDefaultAction(self.__undoStack.createUndoAction(self, "Undo"))
        self._redoButton.setDefaultAction(self.__undoStack.createRedoAction(self, "Redo"))

        self.__mode = qt.QButtonGroup()
        self.__mode.setExclusive(True)
        self.__mode.addButton(self._peakSelectionMode)
        self.__mode.addButton(self._ringSelectionMode)
        self._ringSelectionMode.setChecked(True)

        self._extract.clicked.connect(self.__autoExtractRings)
Example #2
0
    def __init__(self):
        super(PeakPickingTask, self).__init__()
        qt.loadUi(pyFAI.utils.get_ui_file("calibration-peakpicking.ui"), self)
        self.initNextStep()

        # Insert the plot on the layout
        holder = self._plotHolder
        self.__plot = _PeakPickingPlot(parent=holder)
        holderLayout = qt.QVBoxLayout(holder)
        holderLayout.setContentsMargins(1, 1, 1, 1)
        holderLayout.addWidget(self.__plot)

        # Insert the peak view on the layout
        holder = self._peakSelectionDummy.parent()
        self.__peakSelectionView = _PeakSelectionTableView(holder)
        holderLayout = holder.layout()
        holderLayout.replaceWidget(self._peakSelectionDummy,
                                   self.__peakSelectionView)

        self.__createPlotToolBar(self.__plot)
        statusBar = self.__createPlotStatusBar(self.__plot)
        self.__plot.setStatusBar(statusBar)

        self._ringSelectionMode.setIcon(
            icons.getQIcon("pyfai:gui/icons/search-ring"))
        self._peakSelectionMode.setIcon(
            icons.getQIcon("pyfai:gui/icons/search-peak"))
        self.__plot.sigPlotSignal.connect(self.__onPlotEvent)

        self.__undoStack = qt.QUndoStack(self)
        undoAction = CustomProxyAction(
            self, self.__undoStack.createUndoAction(self, "Undo"))
        undoAction.forceText("Undo")
        undoAction.forceIconText("Undo")
        redoAction = CustomProxyAction(
            self, self.__undoStack.createRedoAction(self, "Redo"))
        redoAction.forceText("Redo")
        redoAction.forceIconText("Redo")
        self._undoButton.setDefaultAction(undoAction)
        self._redoButton.setDefaultAction(redoAction)

        self.__mode = qt.QButtonGroup()
        self.__mode.setExclusive(True)
        self.__mode.addButton(self._peakSelectionMode)
        self.__mode.addButton(self._ringSelectionMode)
        self._ringSelectionMode.setChecked(True)

        self._extract.clicked.connect(self.__autoExtractRingsLater)

        self.__synchronizeRawView = SynchronizeRawView()
        self.__synchronizeRawView.registerTask(self)
        self.__synchronizeRawView.registerPlot(self.__plot)
Example #3
0
    def createSizePanel(self, parent):
        group = qt.QButtonGroup()
        group.setExclusive(True)
        panel = qt.QWidget(parent)
        panel.setLayout(qt.QHBoxLayout())

        for size in [16, 24, 32]:
            button = qt.QPushButton("%spx" % size, panel)
            button.clicked.connect(functools.partial(self.setIconSize, size))
            button.setCheckable(True)
            panel.layout().addWidget(button)
            group.addButton(button)

        self.__sizeGroup = group
        button.setChecked(True)
        return panel
Example #4
0
    def createOptions(self):
        panel = qt.QGroupBox()
        panel.setTitle("Options")
        layout = qt.QVBoxLayout()
        panel.setLayout(layout)
        group = qt.QButtonGroup(panel)

        radio = qt.QRadioButton(panel)
        radio.setText("Qt QFileDialog")
        radio.setProperty("Mode", Mode.DEFAULT_FILEDIALOG)
        group.addButton(radio)
        layout.addWidget(radio)

        radio = qt.QRadioButton(panel)
        radio.setText("silx ImageFileDialog")
        radio.setProperty("Mode", Mode.IMAGEFILEDIALOG)
        group.addButton(radio)
        layout.addWidget(radio)

        radio = qt.QRadioButton(panel)
        radio.setChecked(True)
        radio.setText("silx DataFileDialog")
        radio.setProperty("Mode", Mode.DATAFILEDIALOG)
        group.addButton(radio)
        layout.addWidget(radio)

        radio = qt.QRadioButton(panel)
        radio.setText("silx DataFileDialog (filter=dataset)")
        radio.setProperty("Mode", Mode.DATAFILEDIALOG_DATASET)
        group.addButton(radio)
        layout.addWidget(radio)

        radio = qt.QRadioButton(panel)
        radio.setText("silx DataFileDialog (filter=group)")
        radio.setProperty("Mode", Mode.DATAFILEDIALOG_GROUP)
        group.addButton(radio)
        layout.addWidget(radio)

        radio = qt.QRadioButton(panel)
        radio.setText("silx DataFileDialog (filter=NXentry)")
        radio.setProperty("Mode", Mode.DATAFILEDIALOG_NXENTRY)
        group.addButton(radio)
        layout.addWidget(radio)

        self.__options = group
        return panel
    def __updateButtons(self):
        if self.__group is not None:
            self.__group.deleteLater()

        # Clean up
        for _, b in self.__buttons.items():
            b.deleteLater()
        if self.__buttonDummy is not None:
            self.__buttonDummy.deleteLater()
            self.__buttonDummy = None
        self.__buttons = {}
        self.__buttonDummy = None

        self.__group = qt.QButtonGroup(self)
        if self.__dataViewer is None:
            return

        iconSize = qt.QSize(16, 16)

        for view in self.__dataViewer.availableViews():
            label = view.label()
            icon = view.icon()
            button = qt.QPushButton(label)
            button.setIcon(icon)
            button.setIconSize(iconSize)
            button.setCheckable(True)
            # the weak objects are needed to be able to destroy the widget safely
            weakView = weakref.ref(view)
            weakMethod = silx.utils.weakref.WeakMethodProxy(
                self.__setDisplayedView)
            callback = functools.partial(weakMethod, weakView)
            button.clicked.connect(callback)
            self.__buttonLayout.addWidget(button)
            self.__group.addButton(button)
            self.__buttons[view] = button

        button = qt.QPushButton("Dummy")
        button.setCheckable(True)
        button.setVisible(False)
        self.__buttonLayout.addWidget(button)
        self.__group.addButton(button)
        self.__buttonDummy = button

        self.__updateButtonsVisibility()
        self.__displayedViewChanged(self.__dataViewer.displayedView())
Example #6
0
    def __init__(self, parent=None):
        super(OpenClDeviceDialog, self).__init__(parent)
        filename = get_ui_file("opencl-device-dialog.ui")
        qt.loadUi(filename, self)

        self.__availableIds = {}
        model = self.__createModel()
        self._deviceView.setModel(model)
        self._deviceView.setSelectionMode(qt.QAbstractItemView.SingleSelection)
        self._deviceView.setSelectionBehavior(qt.QAbstractItemView.SelectRows)

        header = self._deviceView.horizontalHeader()
        if qt.qVersion() < "5.0":
            header.setClickable(True)
            header.setMovable(True)
            header.setSectionResizeMode = self.setResizeMode
        else:
            header.setSectionsClickable(True)
            header.setSectionsMovable(True)
        header.setStretchLastSection(False)
        header.setSectionResizeMode(0, qt.QHeaderView.Stretch)
        header.setSectionResizeMode(1, qt.QHeaderView.Interactive)
        header.setSectionResizeMode(2, qt.QHeaderView.ResizeToContents)
        header.setSectionResizeMode(3, qt.QHeaderView.ResizeToContents)
        header.setSectionResizeMode(4, qt.QHeaderView.ResizeToContents)

        self._buttonBox.accepted.connect(self.accept)
        self._buttonBox.rejected.connect(self.reject)

        self._group = qt.QButtonGroup(self)
        self._group.setExclusive(True)
        self._group.addButton(self._anyDeviceButton)
        self._group.addButton(self._anyGpuButton)
        self._group.addButton(self._anyCpuButton)
        self._group.addButton(self._availableButton)
        self._group.addButton(self._customButton)
        self._group.buttonClicked.connect(self.__modeChanged)
        self._anyDeviceButton.setChecked(True)
        self.__modeChanged()

        if pyopencl is None:
            self._availableButton.setEnabled(False)
            self._availableButton.setToolTip(
                "PyOpenCL have to be installed to display available devices.")
Example #7
0
    def __createConfigurationPanel(self, parent):
        panel = qt.QWidget(parent=parent)
        layout = qt.QVBoxLayout()
        panel.setLayout(layout)

        self.__kind = qt.QButtonGroup(self)
        self.__kind.setExclusive(True)

        group = qt.QGroupBox(self)
        group.setTitle("Image")
        layout.addWidget(group)
        groupLayout = qt.QVBoxLayout(group)

        button = qt.QRadioButton(parent=panel)
        button.setText("Island")
        button.clicked.connect(self.generateIsland)
        button.setCheckable(True)
        button.setChecked(True)
        groupLayout.addWidget(button)
        self.__kind.addButton(button)

        button = qt.QRadioButton(parent=panel)
        button.setText("Gravity")
        button.clicked.connect(self.generateGravityField)
        button.setCheckable(True)
        groupLayout.addWidget(button)
        self.__kind.addButton(button)

        button = qt.QRadioButton(parent=panel)
        button.setText("Magnetic")
        button.clicked.connect(self.generateMagneticField)
        button.setCheckable(True)
        groupLayout.addWidget(button)
        self.__kind.addButton(button)

        button = qt.QRadioButton(parent=panel)
        button.setText("Spiral")
        button.clicked.connect(self.generateSpiral)
        button.setCheckable(True)
        groupLayout.addWidget(button)
        self.__kind.addButton(button)

        button = qt.QRadioButton(parent=panel)
        button.setText("Gradient")
        button.clicked.connect(self.generateGradient)
        button.setCheckable(True)
        groupLayout.addWidget(button)
        self.__kind.addButton(button)

        button = qt.QRadioButton(parent=panel)
        button.setText("Composite gradient")
        button.clicked.connect(self.generateCompositeGradient)
        button.setCheckable(True)
        groupLayout.addWidget(button)
        self.__kind.addButton(button)

        button = qt.QPushButton(parent=panel)
        button.setText("Generate a new image")
        button.clicked.connect(self.generate)
        groupLayout.addWidget(button)

        # Contours

        group = qt.QGroupBox(self)
        group.setTitle("Contours")
        layout.addWidget(group)
        groupLayout = qt.QVBoxLayout(group)

        button = qt.QCheckBox(parent=panel)
        button.setText("Use the plot's mask")
        button.setCheckable(True)
        button.setChecked(True)
        button.clicked.connect(self.updateContours)
        groupLayout.addWidget(button)
        self.__useMaskButton = button

        button = qt.QPushButton(parent=panel)
        button.setText("Update contours")
        button.clicked.connect(self.updateContours)
        groupLayout.addWidget(button)

        # Implementations

        group = qt.QGroupBox(self)
        group.setTitle("Implementation")
        layout.addWidget(group)
        groupLayout = qt.QVBoxLayout(group)

        self.__impl = qt.QButtonGroup(self)
        self.__impl.setExclusive(True)

        button = qt.QRadioButton(parent=panel)
        button.setText("silx")
        button.clicked.connect(self.updateContours)
        button.setCheckable(True)
        button.setChecked(True)
        groupLayout.addWidget(button)
        self.__implMerge = button
        self.__impl.addButton(button)

        button = qt.QRadioButton(parent=panel)
        button.setText("silx with cache")
        button.clicked.connect(self.updateContours)
        button.setCheckable(True)
        groupLayout.addWidget(button)
        self.__implMergeCache = button
        self.__impl.addButton(button)

        button = qt.QRadioButton(parent=panel)
        button.setText("skimage")
        button.clicked.connect(self.updateContours)
        button.setCheckable(True)
        groupLayout.addWidget(button)
        self.__implSkimage = button
        self.__impl.addButton(button)
        if MarchingSquaresSciKitImage is None:
            button.setEnabled(False)
            button.setToolTip("skimage is not installed or not compatible")

        # Processing

        group = qt.QGroupBox(self)
        group.setTitle("Processing")
        layout.addWidget(group)
        group.setLayout(self.__createInfoLayout(group))

        # Processing

        group = qt.QGroupBox(self)
        group.setTitle("Custom level")
        layout.addWidget(group)
        groupLayout = qt.QVBoxLayout(group)

        label = qt.QLabel(parent=panel)
        self.__value = qt.QSlider(panel)
        self.__value.setOrientation(qt.Qt.Horizontal)
        self.__value.sliderMoved.connect(self.__updateCustomContours)
        self.__value.valueChanged.connect(self.__updateCustomContours)
        groupLayout.addWidget(self.__value)

        return panel
    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
Example #9
0
    def __init__(self, parent=None):
        super(PrintGeometryWidget, self).__init__(parent)
        self.mainLayout = qt.QGridLayout(self)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.mainLayout.setSpacing(2)
        hbox = qt.QWidget()
        hboxLayout = qt.QHBoxLayout(hbox)
        hboxLayout.setContentsMargins(0, 0, 0, 0)
        hboxLayout.setSpacing(2)
        label = qt.QLabel(self)
        label.setText("Units")
        label.setAlignment(qt.Qt.AlignCenter)
        self._pageButton = qt.QRadioButton()
        self._pageButton.setText("Page")
        self._inchButton = qt.QRadioButton()
        self._inchButton.setText("Inches")
        self._cmButton = qt.QRadioButton()
        self._cmButton.setText("Centimeters")
        self._buttonGroup = qt.QButtonGroup(self)
        self._buttonGroup.addButton(self._pageButton)
        self._buttonGroup.addButton(self._inchButton)
        self._buttonGroup.addButton(self._cmButton)
        self._buttonGroup.setExclusive(True)

        # units
        self.mainLayout.addWidget(label, 0, 0, 1, 4)
        hboxLayout.addWidget(self._pageButton)
        hboxLayout.addWidget(self._inchButton)
        hboxLayout.addWidget(self._cmButton)
        self.mainLayout.addWidget(hbox, 1, 0, 1, 4)
        self._pageButton.setChecked(True)

        # xOffset
        label = qt.QLabel(self)
        label.setText("X Offset:")
        self.mainLayout.addWidget(label, 2, 0)
        self._xOffset = qt.QLineEdit(self)
        validator = qt.QDoubleValidator(None)
        self._xOffset.setValidator(validator)
        self._xOffset.setText("0.1")
        self.mainLayout.addWidget(self._xOffset, 2, 1)

        # yOffset
        label = qt.QLabel(self)
        label.setText("Y Offset:")
        self.mainLayout.addWidget(label, 2, 2)
        self._yOffset = qt.QLineEdit(self)
        validator = qt.QDoubleValidator(None)
        self._yOffset.setValidator(validator)
        self._yOffset.setText("0.1")
        self.mainLayout.addWidget(self._yOffset, 2, 3)

        # width
        label = qt.QLabel(self)
        label.setText("Width:")
        self.mainLayout.addWidget(label, 3, 0)
        self._width = qt.QLineEdit(self)
        validator = qt.QDoubleValidator(None)
        self._width.setValidator(validator)
        self._width.setText("0.9")
        self.mainLayout.addWidget(self._width, 3, 1)

        # height
        label = qt.QLabel(self)
        label.setText("Height:")
        self.mainLayout.addWidget(label, 3, 2)
        self._height = qt.QLineEdit(self)
        validator = qt.QDoubleValidator(None)
        self._height.setValidator(validator)
        self._height.setText("0.9")
        self.mainLayout.addWidget(self._height, 3, 3)

        # aspect ratio
        self._aspect = qt.QCheckBox(self)
        self._aspect.setText("Keep screen aspect ratio")
        self._aspect.setChecked(True)
        self.mainLayout.addWidget(self._aspect, 4, 1, 1, 2)