Ejemplo n.º 1
0
    def set_validators(self):
        """
        Set all validators for text entries
        """
        npt_validator = qt.QIntValidator()
        npt_validator.setBottom(1)
        self.nbpt_rad.setValidator(npt_validator)
        self.nbpt_azim.setValidator(npt_validator)

        wl_validator = qt.QDoubleValidator(self)
        wl_validator.setBottom(1e-15)
        wl_validator.setTop(1e-6)
        self.wavelength.setValidator(wl_validator)

        distance_validator = qt.QDoubleValidator(self)
        distance_validator.setBottom(0)
        self.pixel1.setValidator(distance_validator)
        self.pixel2.setValidator(distance_validator)
        self.poni1.setValidator(distance_validator)
        self.poni2.setValidator(distance_validator)

        angle_validator = qt.QDoubleValidator(self)
        distance_validator.setBottom(-math.pi)
        distance_validator.setTop(math.pi)
        self.rot1.setValidator(angle_validator)
        self.rot2.setValidator(angle_validator)
        self.rot3.setValidator(angle_validator)
Ejemplo n.º 2
0
    def set_validator(self):
        validator = qt.QIntValidator(0, 999999, self)
        self.fastMotorPts.setValidator(validator)
        self.slowMotorPts.setValidator(validator)
        self.offset.setValidator(validator)

        float_valid = qt.QDoubleValidator(self)
        self.rMin.setValidator(float_valid)
        self.rMax.setValidator(float_valid)
Ejemplo n.º 3
0
    def __init__(self, **kwargs):
        super(ConversionParamsWidget, self).__init__(**kwargs)
        layout = Qt.QGridLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)

        # ===========
        # image binning
        # ===========
        row = 0
        layout.addWidget(Qt.QLabel('Img binning :'), row, 0)
        h_layout = Qt.QHBoxLayout()
        layout.addLayout(h_layout,
                         row,
                         1,
                         alignment=Qt.Qt.AlignLeft | Qt.Qt.AlignTop)
        imgbin_h_edit = StyledLineEdit(nChar=5)
        imgbin_h_edit.setValidator(Qt.QIntValidator(imgbin_h_edit))
        imgbin_h_edit.setAlignment(Qt.Qt.AlignRight)
        imgbin_h_edit.setText(str(_DEFAULT_IMG_BIN[0]))
        h_layout.addWidget(imgbin_h_edit, alignment=Qt.Qt.AlignLeft)
        h_layout.addWidget(Qt.QLabel(' x '))
        imgbin_v_edit = StyledLineEdit(nChar=5)
        imgbin_v_edit.setValidator(Qt.QIntValidator(imgbin_v_edit))
        imgbin_v_edit.setAlignment(Qt.Qt.AlignRight)
        imgbin_v_edit.setText(str(_DEFAULT_IMG_BIN[1]))
        h_layout.addWidget(imgbin_v_edit, alignment=Qt.Qt.AlignLeft)
        h_layout.addWidget(Qt.QLabel('px'))
        h_layout.addStretch(1)

        # ===========
        # qspace size
        # ===========

        row += 1
        layout.addWidget(Qt.QLabel('Q space size :'), row, 0)
        h_layout = Qt.QHBoxLayout()
        layout.addLayout(h_layout,
                         row,
                         1,
                         alignment=Qt.Qt.AlignLeft | Qt.Qt.AlignTop)
        qsize_x_edit = StyledLineEdit(nChar=5)
        qsize_x_edit.setValidator(Qt.QDoubleValidator(qsize_x_edit))
        qsize_x_edit.setAlignment(Qt.Qt.AlignRight)
        h_layout.addWidget(qsize_x_edit)
        h_layout.addWidget(Qt.QLabel(' x '))
        qsize_y_edit = StyledLineEdit(nChar=5)
        qsize_y_edit.setValidator(Qt.QDoubleValidator(qsize_y_edit))
        qsize_y_edit.setAlignment(Qt.Qt.AlignRight)
        h_layout.addWidget(qsize_y_edit)
        h_layout.addWidget(Qt.QLabel(' x '))
        qsize_z_edit = StyledLineEdit(nChar=5)
        qsize_z_edit.setValidator(Qt.QDoubleValidator(qsize_z_edit))
        qsize_z_edit.setAlignment(Qt.Qt.AlignRight)
        h_layout.addWidget(qsize_z_edit)
        h_layout.addWidget(Qt.QLabel('bins'))
        h_layout.addStretch(1)

        self.__imgbin_h_edit = imgbin_h_edit
        self.__imgbin_v_edit = imgbin_v_edit
        self.__qsize_x_edit = qsize_x_edit
        self.__qsize_y_edit = qsize_y_edit
        self.__qsize_z_edit = qsize_z_edit

        # ===========
        # size constraints
        # ===========
        self.setSizePolicy(
            Qt.QSizePolicy(Qt.QSizePolicy.Fixed, Qt.QSizePolicy.Fixed))
Ejemplo n.º 4
0
 def getEditor(self, parent, option, index):
     editor = qt.QLineEdit(parent)
     editor.setValidator(qt.QDoubleValidator(editor))
     return editor
Ejemplo n.º 5
0
    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
Ejemplo n.º 6
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)
Ejemplo n.º 7
0
    def __init__(self,
                 parent=None,
                 title="Subtract strip background prior to estimation"):
        super(BackgroundPage, self).__init__(parent)
        self.setTitle(title)
        self.setCheckable(True)
        self.setToolTip(
            "The strip algorithm strips away peaks to compute the " +
            "background signal.\nAt each iteration, a sample is compared " +
            "to the average of the two samples at a given distance in both" +
            " directions,\n and if its value is higher than the average,"
            "it is replaced by the average.")

        layout = qt.QGridLayout(self)
        self.setLayout(layout)

        for i, label_text in enumerate([
                "Strip width (in samples)", "Number of iterations",
                "Strip threshold factor"
        ]):
            label = qt.QLabel(label_text)
            layout.addWidget(label, i, 0)

        self.stripWidthSpin = qt.QSpinBox(self)
        self.stripWidthSpin.setToolTip(
            "Width, in number of samples, of the strip operator")
        self.stripWidthSpin.setRange(1, 999999)

        layout.addWidget(self.stripWidthSpin, 0, 1)

        self.numIterationsSpin = qt.QSpinBox(self)
        self.numIterationsSpin.setToolTip(
            "Number of iterations of the strip algorithm")
        self.numIterationsSpin.setRange(1, 999999)
        layout.addWidget(self.numIterationsSpin, 1, 1)

        self.thresholdFactorEntry = qt.QLineEdit(self)
        self.thresholdFactorEntry.setToolTip(
            "Factor used by the strip algorithm to decide whether a sample" +
            "value should be stripped.\nThe value must be higher than the " +
            "average of the 2 samples at +- w times this factor.\n")
        self.thresholdFactorEntry.setValidator(qt.QDoubleValidator(self))
        layout.addWidget(self.thresholdFactorEntry, 2, 1)

        self.smoothStripGB = qt.QGroupBox("Apply smoothing prior to strip",
                                          self)
        self.smoothStripGB.setCheckable(True)
        self.smoothStripGB.setToolTip(
            "Apply a smoothing before subtracting strip background" +
            " in fit and estimate processes")
        smoothlayout = qt.QHBoxLayout(self.smoothStripGB)
        label = qt.QLabel("Smoothing width (Savitsky-Golay)")
        smoothlayout.addWidget(label)
        self.smoothingWidthSpin = qt.QSpinBox(self)
        self.smoothingWidthSpin.setToolTip(
            "Width parameter for Savitsky-Golay smoothing (number of samples, must be odd)"
        )
        self.smoothingWidthSpin.setRange(3, 101)
        self.smoothingWidthSpin.setSingleStep(2)
        smoothlayout.addWidget(self.smoothingWidthSpin)

        layout.addWidget(self.smoothStripGB, 3, 0, 1, 2)

        layout.setRowStretch(4, 1)

        self.setDefault()
Ejemplo n.º 8
0
    def __init__(self, parent=None):
        super(SearchPage, self).__init__(parent)
        layout = qt.QVBoxLayout(self)

        self.manualFwhmGB = qt.QGroupBox("Define FWHM manually", self)
        self.manualFwhmGB.setCheckable(True)
        self.manualFwhmGB.setToolTip(
            "If disabled, the FWHM parameter used for peak search is " +
            "estimated based on the highest peak in the data")
        layout.addWidget(self.manualFwhmGB)
        # ------------ GroupBox fwhm--------------------------
        layout2 = qt.QHBoxLayout(self.manualFwhmGB)
        self.manualFwhmGB.setLayout(layout2)

        label = qt.QLabel("Fwhm Points", self.manualFwhmGB)
        layout2.addWidget(label)

        self.fwhmPointsSpin = qt.QSpinBox(self.manualFwhmGB)
        self.fwhmPointsSpin.setRange(0, 999999)
        self.fwhmPointsSpin.setToolTip(
            "Typical peak fwhm (number of data points)")
        layout2.addWidget(self.fwhmPointsSpin)
        # ----------------------------------------------------

        self.manualScalingGB = qt.QGroupBox("Define scaling manually", self)
        self.manualScalingGB.setCheckable(True)
        self.manualScalingGB.setToolTip(
            "If disabled, the Y scaling used for peak search is " +
            "estimated automatically")
        layout.addWidget(self.manualScalingGB)
        # ------------ GroupBox scaling-----------------------
        layout3 = qt.QHBoxLayout(self.manualScalingGB)
        self.manualScalingGB.setLayout(layout3)

        label = qt.QLabel("Y Scaling", self.manualScalingGB)
        layout3.addWidget(label)

        self.yScalingEntry = qt.QLineEdit(self.manualScalingGB)
        self.yScalingEntry.setToolTip(
            "Data values will be multiplied by this value prior to peak" +
            " search")
        self.yScalingEntry.setValidator(qt.QDoubleValidator(self))
        layout3.addWidget(self.yScalingEntry)
        # ----------------------------------------------------

        # ------------------- grid layout --------------------
        containerWidget = qt.QWidget(self)
        layout4 = qt.QHBoxLayout(containerWidget)
        containerWidget.setLayout(layout4)

        label = qt.QLabel("Sensitivity", containerWidget)
        layout4.addWidget(label)

        self.sensitivityEntry = qt.QLineEdit(containerWidget)
        self.sensitivityEntry.setToolTip(
            "Peak search sensitivity threshold, expressed as a multiple " +
            "of the standard deviation of the noise.\nMinimum value is 1 " +
            "(to be detected, peak must be higher than the estimated noise)")
        sensivalidator = qt.QDoubleValidator(self)
        sensivalidator.setBottom(1.0)
        self.sensitivityEntry.setValidator(sensivalidator)
        layout4.addWidget(self.sensitivityEntry)
        # ----------------------------------------------------
        layout.addWidget(containerWidget)

        self.forcePeakPresenceCB = qt.QCheckBox("Force peak presence", self)
        self.forcePeakPresenceCB.setToolTip(
            "If peak search algorithm is unsuccessful, place one peak " +
            "at the maximum of the curve")
        layout.addWidget(self.forcePeakPresenceCB)

        layout.addStretch()

        self.setDefault()
Ejemplo n.º 9
0
    def __init__(self, plot, curve, **kwargs):

        super(XsocsPlot2DColorDialog, self).__init__(plot, **kwargs)

        colormap = plot.getPlotColormap(curve)

        self.__plot = weakref.ref(plot)
        self.__curve = curve
        self.__histogram = histo = plot.getHistogram(curve, colormap.nColors)

        if colormap is None:
            minVal = histo.edges[0][0]
            maxVal = histo.edges[0][-1]
            cmap = cm.jet
            nColors = _defaultNColors
        else:
            minVal = colormap.minVal
            maxVal = colormap.maxVal
            cmap = colormap.colormap
            if cmap not in self.colormaps:
                self.colormaps[cmap.name] = cmap
            nColors = colormap.nColors
            if minVal is None:
                minVal = histo.edges[0][0]
            if maxVal is None:
                maxVal = histo.edges[0][-1]

        index = self.colormaps.keys().index(cmap.name)

        self.__colormap = XsocsPlot2DColormap(colormap=cmap,
                                              minVal=minVal,
                                              maxVal=maxVal,
                                              nColors=nColors)

        layout = Qt.QGridLayout(self)

        grpBox = GroupBox('Colormap')
        grpBoxLayout = Qt.QGridLayout(grpBox)
        self.__cmapCBox = cmapCBox = Qt.QComboBox()

        for key, value in self.colormaps.items():
            cmapCBox.addItem(key, userData=value)
        cmapCBox.setCurrentIndex(index)

        grpBoxLayout.addWidget(cmapCBox, 0, 0, Qt.Qt.AlignCenter)

        cmapCBox.currentIndexChanged.connect(self.__cmapCBoxChanged)

        self.__colorLabel = colorLabel = Qt.QLabel()
        colorLabel.setFrameStyle(Qt.QFrame.Panel | Qt.QFrame.Sunken)
        colorLabel.setLineWidth(2)
        colorLabel.setMidLineWidth(2)
        grpBoxLayout.addWidget(colorLabel, 1, 0)
        grpBox.setSizePolicy(Qt.QSizePolicy.Fixed, Qt.QSizePolicy.Fixed)
        layout.addWidget(grpBox, 0, 0)

        grpBox = GroupBox('Range')
        grpBoxLayout = Qt.QGridLayout(grpBox)
        self.__rngSlider = rngSlider = RangeSlider()
        grpBoxLayout.addWidget(rngSlider, 0, 0, 1, 2)

        self.__filledProfile = filledProfile = ColorFilledProfile()
        filledProfile.setFixedHeight(100)
        grpBoxLayout.addWidget(filledProfile, 1, 0, 1, 2)

        self.__minEdit = minEdit = StyledLineEdit(nChar=6)
        self.__maxEdit = maxEdit = StyledLineEdit(nChar=6)
        minEdit.setValidator(Qt.QDoubleValidator())
        maxEdit.setValidator(Qt.QDoubleValidator())
        minEdit.editingFinished.connect(self.__lineEditFinished)
        maxEdit.editingFinished.connect(self.__lineEditFinished)
        grpBoxLayout.addWidget(minEdit, 2, 0)
        grpBoxLayout.addWidget(maxEdit, 2, 1)
        grpBox.setSizePolicy(Qt.QSizePolicy.Fixed, Qt.QSizePolicy.Fixed)
        layout.addWidget(grpBox, 1, 0, Qt.Qt.AlignCenter)

        bnBox = Qt.QDialogButtonBox(Qt.QDialogButtonBox.Close)
        bnBox.button(Qt.QDialogButtonBox.Close).clicked.connect(self.accept)

        layout.addWidget(bnBox, 2, 0)

        self.__setupWidgets()

        rngSlider.sigSliderMoved.connect(self.__rngSliderMoved)