Exemple #1
0
    def __init__(self, parent=None, plot=None, rois=None):
        qt.QDialog.__init__(self, parent=parent)
        assert plot is not None
        assert rois is not None
        self._plot = plot
        self._rois = rois

        self.setLayout(qt.QVBoxLayout())

        # define the selection widget
        self._selection_widget = qt.QWidget()
        self._selection_widget.setLayout(qt.QHBoxLayout())
        self._kindCB = qt.QComboBox(parent=self)
        self._selection_widget.layout().addWidget(self._kindCB)
        self._itemCB = qt.QComboBox(parent=self)
        self._selection_widget.layout().addWidget(self._itemCB)
        self._roiCB = qt.QComboBox(parent=self)
        self._selection_widget.layout().addWidget(self._roiCB)
        self.layout().addWidget(self._selection_widget)

        # define modal buttons
        types = qt.QDialogButtonBox.Ok | qt.QDialogButtonBox.Cancel
        self._buttonsModal = qt.QDialogButtonBox(parent=self)
        self._buttonsModal.setStandardButtons(types)
        self.layout().addWidget(self._buttonsModal)
        self._buttonsModal.accepted.connect(self.accept)
        self._buttonsModal.rejected.connect(self.reject)

        # connect signal / slot
        self._kindCB.currentIndexChanged.connect(self._updateValidItemAndRoi)
    def __init__(self, parent=None):
        qt.QWidget.__init__(self, parent)

        self.setWindowTitle("FitConfigGUI")

        layout = qt.QGridLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(6)

        self.FunLabel = qt.QLabel(self)
        self.FunLabel.setText("Function")
        layout.addWidget(self.FunLabel, 0, 0)

        self.FunComBox = qt.QComboBox(self)
        self.FunComBox.addItem("Add Function(s)")
        self.FunComBox.setItemData(self.FunComBox.findText("Add Function(s)"),
                                   "Load fit theories from a file",
                                   qt.Qt.ToolTipRole)
        layout.addWidget(self.FunComBox, 0, 1)

        self.BkgLabel = qt.QLabel(self)
        self.BkgLabel.setText("Background")
        layout.addWidget(self.BkgLabel, 1, 0)

        self.BkgComBox = qt.QComboBox(self)
        self.BkgComBox.addItem("Add Background(s)")
        self.BkgComBox.setItemData(
            self.BkgComBox.findText("Add Background(s)"),
            "Load background theories from a file", qt.Qt.ToolTipRole)
        layout.addWidget(self.BkgComBox, 1, 1)

        self.FunConfigureButton = qt.QPushButton(self)
        self.FunConfigureButton.setText("Configure")
        self.FunConfigureButton.setToolTip(
            "Open a configuration dialog for the selected function")
        layout.addWidget(self.FunConfigureButton, 0, 2)

        self.BgConfigureButton = qt.QPushButton(self)
        self.BgConfigureButton.setText("Configure")
        self.BgConfigureButton.setToolTip(
            "Open a configuration dialog for the selected background")
        layout.addWidget(self.BgConfigureButton, 1, 2)

        self.WeightCheckBox = qt.QCheckBox(self)
        self.WeightCheckBox.setText("Weighted fit")
        self.WeightCheckBox.setToolTip(
            "Enable usage of weights in the least-square problem.\n Use" +
            " the uncertainties (sigma) if provided, else use sqrt(y).")

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

        layout.setColumnStretch(4, 1)
Exemple #3
0
    def __init__(self, parent):
        super(PlanesWidget, self).__init__(parent)

        self.setSizePolicy(qt.QSizePolicy.Minimum, qt.QSizePolicy.Minimum)
        layout0 = qt.QHBoxLayout()
        self.setLayout(layout0)
        layout0.setContentsMargins(0, 0, 0, 0)

        layout0.addWidget(qt.QLabel("Axes selection:"))

        # By default, the first dimension (dim0) is the frame index/depth/z,
        # the second dimension is the image row number/y axis
        # and the third dimension is the image column index/x axis

        # 1
        # | 0
        # |/__2

        self.qcbAxisSelection = qt.QComboBox(self)
        self.qcbAxisSelection.addItem(icons.getQIcon("cube-front"),
                                      'Dim1-Dim2')
        self.qcbAxisSelection.addItem(icons.getQIcon("cube-bottom"),
                                      'Dim0-Dim2')
        self.qcbAxisSelection.addItem(icons.getQIcon("cube-left"),
                                      'Dim0-Dim1')
        self.qcbAxisSelection.currentIndexChanged[int].connect(
            self.__planeSelectionChanged)

        layout0.addWidget(self.qcbAxisSelection)
Exemple #4
0
    def _buildName(self):
        wName = qt.QWidget(self)
        wName.setLayout(qt.QHBoxLayout())

        wName.layout().addWidget(qt.QLabel('name'))
        self._qcbName = qt.QComboBox(wName)
        for val in Colormap.Colormap.getSupportedColormaps():
            self._qcbName.addItem(val)
Exemple #5
0
    def getEditor(self, parent, option, index):
        editor = qt.QComboBox(parent)
        for iconName, text, tooltip, normal in self._PLANE_ACTIONS:
            editor.addItem(getQIcon(iconName), text)

        # Wrapping call in lambda is a workaround for PySide with Python 3
        editor.currentIndexChanged[int].connect(
            lambda index: self.__editorChanged(index))
        return editor
Exemple #6
0
    def getEditor(self, parent, option, index):
        editor = qt.QComboBox(parent)
        editor.addItems(self.listValues)

        # Wrapping call in lambda is a workaround for PySide with Python 3
        editor.currentIndexChanged[int].connect(
            lambda index: self.__editorChanged(index))

        return editor
    def __init__(self, parent=None, n=None):
        qt.QWidget.__init__(self, parent)
        self.layout = qt.QHBoxLayout(self)
        self.layout.setContentsMargins(0, 2, 0, 2)
        self.layout.setSpacing(10)

        self.rowsCB = qt.QComboBox(self)
        self.columnsCB = qt.QComboBox(self)

        self.layout.addWidget(qt.QLabel("Rows dimension", self))
        self.layout.addWidget(self.rowsCB)
        self.layout.addWidget(qt.QLabel("    ", self))
        self.layout.addWidget(qt.QLabel("Columns dimension", self))
        self.layout.addWidget(self.columnsCB)
        self.layout.addStretch(1)

        self._slotsAreConnected = False
        if n is not None:
            self.setNDimensions(n)
Exemple #8
0
    def makeCombineDataGroup(self):
        self.combineType = qt.QComboBox()
        self.combineType.addItems(csp.combineNames)
        self.combineType.currentIndexChanged.connect(self.combineTypeChanged)
        self.combineNLabel = qt.QLabel("N=")
        self.combineN = qt.QSpinBox()
        self.combineN.setMinimum(1)
        self.combineStopCB = qt.QCheckBox(
            u"stop propagation of\ncontributing data at:")
        self.combineStopCB.stateChanged.connect(self.combineStopCBChanged)
        self.combineStop = qt.QComboBox()
        self.combineStop.addItems(csi.nodes.keys())
        self.combineMoveToGroupCB = qt.QCheckBox(
            u"move selected data to a new group")
        self.combineDo = qt.QPushButton("Combine")
        self.combineDo.clicked.connect(self.createCombined)

        #        layout = qt.QVBoxLayout()
        #        layout.addWidget(self.combineType)
        #        layout.addWidget(self.combineStopCB)
        #        layout.addWidget(self.combineStop)
        #        layout.addWidget(self.combineDo)
        #        layout.addStretch()
        layout = qt.QGridLayout()
        layout.setContentsMargins(2, 0, 2, 2)
        layout.addWidget(self.combineType, 0, 0)
        layoutN = qt.QHBoxLayout()
        layoutN.addStretch()
        layoutN.addWidget(self.combineNLabel)
        layoutN.addWidget(self.combineN)
        layout.addLayout(layoutN, 0, 1)
        layout.addWidget(self.combineStopCB, 1, 0)
        layout.addWidget(self.combineStop, 1, 1)
        layout.addWidget(self.combineMoveToGroupCB, 2, 0, 1, 2)
        layout.addWidget(self.combineDo, 3, 0, 1, 2)

        group = qt.QGroupBox('combine selected data')
        group.setLayout(layout)
        # group.setSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Fixed)
        return group
Exemple #9
0
 def __init__(self, parent=None):
     super(Histogram, self).__init__(parent=parent,
                                     resetzoom=True, autoScale=True,
                                     logScale=True, grid=True,
                                     curveStyle=True, colormap=False,
                                     aspectRatio=False, yInverted=False,
                                     copy=True, save=True, print_=True,
                                     control=True, position=True,
                                     roi=False, mask=False, fit=False)
     # add a POI/reconstruction chooser
     self.chooserToolbar = self.addToolBar('Interpolation')
     self.chooserMenu = qt.QComboBox(
         toolTip='Choose whether to display probe at the plane of interest of in the sample plane')
     self.chooserMenu.insertItems(1, ['Plane of interest', 'Sample plane'])
     self.chooserToolbar.addWidget(self.chooserMenu)
    def __init__(self, parent=None):
        """Constructor

        :param parent: Parent of the widget
        """
        super(_Axis, self).__init__(parent)
        self.__axisNumber = None
        self.__customAxisNames = set([])
        self.__label = qt.QLabel(self)
        self.__axes = qt.QComboBox(self)
        self.__axes.currentIndexChanged[int].connect(self.__axisMappingChanged)
        self.__slider = HorizontalSliderWithBrowser(self)
        self.__slider.valueChanged[int].connect(self.__sliderValueChanged)
        layout = qt.QHBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.__label)
        layout.addWidget(self.__axes)
        layout.addWidget(self.__slider, 10000)
        layout.addStretch(1)
        self.setLayout(layout)
Exemple #11
0
    def createTreeViewConfigurationPanel(self, parent, treeview):
        """Create a configuration panel to allow to play with widget states"""
        panel = qt.QWidget(parent)
        panel.setLayout(qt.QHBoxLayout())

        content = qt.QGroupBox("Create HDF5", panel)
        content.setLayout(qt.QVBoxLayout())
        panel.layout().addWidget(content)

        combo = qt.QComboBox()
        combo.addItem("Containing all types", get_hdf5_with_all_types)
        combo.activated.connect(self.__hdf5ComboChanged)
        content.layout().addWidget(combo)

        button = ThreadPoolPushButton(content, text="Create")
        button.setCallable(combo.itemData(combo.currentIndex()))
        button.succeeded.connect(self.__fileCreated)
        content.layout().addWidget(button)

        self.__hdf5Combo = combo
        self.__createHdf5Button = button

        content.layout().addStretch(1)

        option = qt.QGroupBox("Custom model", panel)
        option.setLayout(qt.QVBoxLayout())
        panel.layout().addWidget(option)

        button = qt.QPushButton("Original model")
        button.clicked.connect(self.__useOriginalModel)
        option.layout().addWidget(button)

        button = qt.QPushButton("Custom tooltips by composition")
        button.clicked.connect(self.__useCustomLabel)
        option.layout().addWidget(button)

        option.layout().addStretch(1)

        panel.layout().addStretch(1)
        return panel
    def __init__(self, parent=None):

        super(ComWidget, self).__init__(parent=parent)
        self.setLayout(qt.QVBoxLayout())

        # the direction menu
        hbox = qt.QHBoxLayout()
        self.directionCombo = qt.QComboBox()
        self.directionCombo.insertItems(
            1, ['', 'horizontal', 'vertical', 'magnitude'])
        self.directionCombo.currentIndexChanged.connect(self.updateMap)
        hbox.addWidget(qt.QLabel('COM direction:'))
        hbox.addWidget(self.directionCombo)
        hbox.addStretch(1)
        self.layout().addLayout(hbox)

        # the image and map parts
        splitter = qt.QSplitter()
        self.map = MapWidget(self)
        self.image = ImageWidget(self)
        splitter.addWidget(self.image)
        splitter.addWidget(self.map)
        self.layout().addWidget(splitter)

        # gray out useless buttons
        self.map.selectAction.setEnabled(False)
        self.map.roiAction.setEnabled(False)
        self.map.clearAction.setEnabled(False)
        self.map.indexBox.setEnabled(False)

        # connect the positions button
        self.map.positionsAction.triggered.connect(self.togglePositions)

        # connect the mask widget to the update
        self.image.getMaskToolsDockWidget().widget()._mask.sigChanged.connect(
            self.updateMap)
Exemple #13
0
    def populateOptions(self):
        grid = self.ui.optionsGrid
        # remove all old options
        for i in reversed(range(grid.count())):
            grid.itemAt(i).widget().setParent(None)

        # add new ones
        opts = self._current_subclass_opts()
        self.formWidgets = {}
        i = 0
        for name, opt in opts.items():
            # special: the options scanNr and fileName (or path) have their input
            # widgets at the top of the GUI for convenience, while dataSource is
            # handled per tab.
            if name in ('dataSource', 'scanNr', 'path', 'fileName'):
                continue
            grid.addWidget(qt.QLabel(name), i, 0)
            grid.addWidget(qt.QLabel(opt['doc']), i, 2)
            if opt['type'] == int:
                w = qt.QSpinBox()
                w.setMaximum(9999)
                w.setValue(opt['value'])
            elif opt['type'] == float:
                w = qt.QDoubleSpinBox()
                w.setValue(opt['value'])
            elif opt['type'] == bool:
                w = qt.QCheckBox()
                w.setChecked(opt['value'])
            elif opt['type'] in (list, tuple):
                w = qt.QLineEdit()
                w.setText(str(opt['value']))
                w.evaluate_me = True
            elif type(opt['type']) in (list, tuple):
                w = qt.QComboBox()
                defaultindex = 0
                for j, item in enumerate(opt['type']):
                    w.addItem(item)
                    if item == opt['value']:
                        defaultindex = j
                w.setCurrentIndex(defaultindex)
            else:
                w = qt.QLineEdit()
                w.setText(opt['value'])
                w.evaluate_me = False
            grid.addWidget(w, i, 1)
            # save a dict of the options widgets, to parse when loading
            self.formWidgets[name] = w
            i += 1

        # add a vertical spacer on the last line to make the table more compact
        grid.setRowStretch(i, 1)

        # special treatment
        oldtext = str(self.ui.filenameBox.text())
        if 'path' in opts.keys() and oldtext.startswith('<'):
            self.ui.filenameBox.setText('<data path>')
        elif 'fileName' in opts.keys() and oldtext.startswith('<'):
            self.ui.filenameBox.setText('<input file>')
        self.ui.filenameBox.setDisabled(not (
            'path' in opts.keys() or 'fileName' in opts.keys()))
        self.ui.browseButton.setDisabled(not (
            'path' in opts.keys() or 'fileName' in opts.keys()))
        self.ui.scanNumberBox.setDisabled('scanNr' not in opts.keys())

        # per-tab dataSource option
        boxes = {
            self.ui.dataSource2dBox: 2,
            self.ui.dataSource1dBox: 1,
            self.ui.dataSource0dBox: 0
        }
        subclass_ = str(self.ui.scanClassBox.currentText())
        try:
            subclass = getattr(nmutils.core, subclass_)
        except AttributeError:
            subclass = None

        for box, dim in boxes.items():
            box.clear()
            if subclass is not None:
                for name in opts['dataSource']['type']:
                    if hasattr(subclass, 'sourceDims'
                               ) and not subclass.sourceDims[name] == dim:
                        continue
                    box.addItem(name)
                box.addItem('')
Exemple #14
0
    def createTreeViewConfigurationPanel(self, parent, treeview):
        """Create a configuration panel to allow to play with widget states"""
        panel = qt.QWidget(parent)
        panel.setLayout(qt.QHBoxLayout())

        content = qt.QGroupBox("Create HDF5", panel)
        content.setLayout(qt.QVBoxLayout())
        panel.layout().addWidget(content)

        combo = qt.QComboBox()
        combo.addItem("Containing all types", get_hdf5_with_all_types)
        combo.addItem("Containing all links", get_hdf5_with_all_links)
        combo.addItem("Containing 1000 datasets", get_hdf5_with_1000_datasets)
        combo.addItem("Containing 10000 datasets",
                      get_hdf5_with_10000_datasets)
        combo.addItem("Containing 100000 datasets",
                      get_hdf5_with_100000_datasets)
        combo.addItem("Containing recursive links",
                      get_hdf5_with_recursive_links)
        combo.addItem("Containing external recursive links",
                      get_hdf5_with_external_recursive_links)
        combo.addItem("Containing NXdata groups", get_hdf5_with_nxdata)
        combo.activated.connect(self.__hdf5ComboChanged)
        content.layout().addWidget(combo)

        button = ThreadPoolPushButton(content, text="Create")
        button.setCallable(combo.itemData(combo.currentIndex()))
        button.succeeded.connect(self.__fileCreated)
        content.layout().addWidget(button)

        self.__hdf5Combo = combo
        self.__createHdf5Button = button

        asyncload = qt.QCheckBox("Async load", content)
        asyncload.setChecked(self.__asyncload)
        asyncload.toggled.connect(
            lambda: self.useAsyncLoad(asyncload.isChecked()))
        content.layout().addWidget(asyncload)

        content.layout().addStretch(1)

        content = qt.QGroupBox("Create EDF", panel)
        content.setLayout(qt.QVBoxLayout())
        panel.layout().addWidget(content)

        combo = qt.QComboBox()
        combo.addItem("Containing all types", get_edf_with_all_types)
        combo.addItem("Containing 100000 datasets", get_edf_with_100000_frames)
        combo.activated.connect(self.__edfComboChanged)
        content.layout().addWidget(combo)

        button = ThreadPoolPushButton(content, text="Create")
        button.setCallable(combo.itemData(combo.currentIndex()))
        button.succeeded.connect(self.__fileCreated)
        content.layout().addWidget(button)

        self.__edfCombo = combo
        self.__createEdfButton = button

        content.layout().addStretch(1)

        option = qt.QGroupBox("Tree options", panel)
        option.setLayout(qt.QVBoxLayout())
        panel.layout().addWidget(option)

        sorting = qt.QCheckBox("Enable sorting", option)
        sorting.setChecked(
            treeview.selectionMode() == qt.QAbstractItemView.MultiSelection)
        sorting.toggled.connect(
            lambda: treeview.setSortingEnabled(sorting.isChecked()))
        option.layout().addWidget(sorting)

        multiselection = qt.QCheckBox("Multi-selection", option)
        multiselection.setChecked(
            treeview.selectionMode() == qt.QAbstractItemView.MultiSelection)
        switch_selection = lambda: treeview.setSelectionMode(
            qt.QAbstractItemView.MultiSelection if multiselection.isChecked(
            ) else qt.QAbstractItemView.SingleSelection)
        multiselection.toggled.connect(switch_selection)
        option.layout().addWidget(multiselection)

        filedrop = qt.QCheckBox("Drop external file", option)
        filedrop.setChecked(treeview.findHdf5TreeModel().isFileDropEnabled())
        filedrop.toggled.connect(lambda: treeview.findHdf5TreeModel().
                                 setFileDropEnabled(filedrop.isChecked()))
        option.layout().addWidget(filedrop)

        filemove = qt.QCheckBox("Reorder files", option)
        filemove.setChecked(treeview.findHdf5TreeModel().isFileMoveEnabled())
        filemove.toggled.connect(lambda: treeview.findHdf5TreeModel().
                                 setFileMoveEnabled(filedrop.isChecked()))
        option.layout().addWidget(filemove)

        option.layout().addStretch(1)

        option = qt.QGroupBox("Header options", panel)
        option.setLayout(qt.QVBoxLayout())
        panel.layout().addWidget(option)

        autosize = qt.QCheckBox("Auto-size headers", option)
        autosize.setChecked(treeview.header().hasAutoResizeColumns())
        autosize.toggled.connect(lambda: treeview.header().
                                 setAutoResizeColumns(autosize.isChecked()))
        option.layout().addWidget(autosize)

        columnpopup = qt.QCheckBox("Popup to hide/show columns", option)
        columnpopup.setChecked(treeview.header().hasHideColumnsPopup())
        columnpopup.toggled.connect(lambda: treeview.header(
        ).setEnableHideColumnsPopup(columnpopup.isChecked()))
        option.layout().addWidget(columnpopup)

        define_columns = qt.QComboBox()
        define_columns.addItem("Default columns",
                               treeview.findHdf5TreeModel().COLUMN_IDS)
        define_columns.addItem("Only name and Value", [
            treeview.findHdf5TreeModel().NAME_COLUMN,
            treeview.findHdf5TreeModel().VALUE_COLUMN
        ])
        define_columns.activated.connect(lambda index: treeview.header(
        ).setSections(define_columns.itemData(index)))
        option.layout().addWidget(define_columns)

        option.layout().addStretch(1)

        panel.layout().addStretch(1)

        return panel
Exemple #15
0
    def getEditor(self, parent, option, index):
        editor = qt.QComboBox(parent)
        editor.addItems(self.listValues)
        editor.currentIndexChanged[int].connect(self.__editorChanged)

        return editor
Exemple #16
0
 def getEditor(self, parent, option, index):
     editor = qt.QComboBox(parent)
     for iconName, text, tooltip, normal in self._PLANE_ACTIONS:
         editor.addItem(getQIcon(iconName), text)
     editor.currentIndexChanged[int].connect(self.__editorChanged)
     return editor
Exemple #17
0
 def createEditor(self, parent, option, index):
     combo = qt.QComboBox(parent)
     combo.addItems(list(xrt.crystals.keys()) + ['none'])
     combo.currentIndexChanged.connect(
         partial(self.currentIndexChanged, combo))
     return combo
Exemple #18
0
    def __init__(self,
                 spec_file=None,
                 img_dir=None,
                 spec_version=1,
                 output_dir=None,
                 tmp_dir=None,
                 **kwargs):
        super(MergeWidget, self).__init__(**kwargs)

        Qt.QGridLayout(self)

        # ################
        # input QGroupBox
        # ################

        if spec_file is not None:
            specFile = spec_file
        else:
            specFile = ''

        if img_dir is not None:
            imgDir = img_dir
        else:
            imgDir = ''

        if spec_version is not None:
            specVersion = spec_version
        else:
            specVersion = self._defaultVersion

        if output_dir is not None:
            outputDir = output_dir
        else:
            outputDir = ''

        # parameters
        self.__input = {
            'specfile': specFile,
            'imgdir': imgDir,
            'version': specVersion,
            'padding': None,
            'offset': None
        }

        self.__output = {'outdir': outputDir, 'prefix': ''}

        inputGbx = GroupBox("Input")
        layout = Qt.QGridLayout(inputGbx)
        self.layout().addWidget(inputGbx, 0, 0, Qt.Qt.AlignTop)

        first_col = 0
        file_bn_col = 4
        last_col = file_bn_col + 1

        spec_row = 0
        img_path_row = 1
        version_row = 2
        apply_bn_row = 3

        # spec file input
        specFileChooser = FileChooser(fileMode=Qt.QFileDialog.ExistingFile,
                                      noLabel=True)
        specFileChooser.lineEdit.setText(specFile)
        specFileChooser.sigSelectionChanged.connect(self.__slotSpecFileChanged)
        layout.addWidget(Qt.QLabel('Spec file :'), spec_row, 0)
        layout.addWidget(specFileChooser, spec_row, 1)

        # image folder input
        imgDirChooser = FileChooser(fileMode=Qt.QFileDialog.Directory,
                                    noLabel=True)
        imgDirChooser.lineEdit.setText(imgDir)
        imgDirChooser.sigSelectionChanged.connect(self.__slotImgDirChanged)
        layout.addWidget(Qt.QLabel('Img dir. :'), img_path_row, 0)
        layout.addWidget(imgDirChooser, img_path_row, 1)

        # version selection
        optionLayout = Qt.QHBoxLayout()
        optionLayout.addStretch(1)

        lab = Qt.QLabel('Version :')
        self.__versionCBx = versionCBx = Qt.QComboBox()

        for version in range(len(self._versions)):
            versionCBx.addItem(str(version))
        versionCBx.addItem('')
        optionLayout.addWidget(lab, Qt.Qt.AlignLeft)
        optionLayout.addWidget(versionCBx, Qt.Qt.AlignLeft)

        # filename padding for the nextNr counter
        self.__padSpinBox = padSpinBox = Qt.QSpinBox()
        optionLayout.addWidget(_vLine())
        optionLayout.addWidget(Qt.QLabel('nextNr padding:'))
        optionLayout.addWidget(padSpinBox, Qt.Qt.AlignLeft)
        padSpinBox.valueChanged[int].connect(self.__slotPaddingValueChanged)

        # filename offset for the nextNr counter
        self.__nextNrSpinBox = nextNrSpinBox = Qt.QSpinBox()
        nextNrSpinBox.setMinimum(-100)
        nextNrSpinBox.setMaximum(100)
        optionLayout.addWidget(_vLine())
        optionLayout.addWidget(Qt.QLabel('nextNr offset:'))
        optionLayout.addWidget(nextNrSpinBox, Qt.Qt.AlignLeft)
        nextNrSpinBox.valueChanged[int].connect(self.__slotNextNrValueChanged)

        optionLayout.addStretch(100)
        layout.addLayout(optionLayout, version_row, 0, 1, layout.columnCount(),
                         Qt.Qt.AlignLeft)

        # last row : apply button
        self.__parseBn = parseBn = FixedSizePushButon('Parse file')
        parseBn.clicked.connect(self.__slotParseBnClicked,
                                Qt.Qt.QueuedConnection)
        layout.addWidget(parseBn, apply_bn_row, 0, 1, last_col - first_col,
                         Qt.Qt.AlignHCenter)

        # ################
        # scans + edf QGroupBox
        # ################
        self.__scansGbx = scansGbx = GroupBox("Spec + EDF")
        grpLayout = Qt.QHBoxLayout(scansGbx)
        self.layout().addWidget(scansGbx, 1, 0,
                                Qt.Qt.AlignLeft | Qt.Qt.AlignTop)

        # ===========
        # valid scans
        # ===========
        scanLayout = Qt.QGridLayout()
        grpLayout.addLayout(scanLayout)

        hLayout = Qt.QHBoxLayout()
        label = Qt.QLabel('<span style=" font-weight:600; color:#00916a;">'
                          'Matched scans</span>')
        label.setTextFormat(Qt.Qt.RichText)
        editScansBn = FixedSizePushButon('Edit')
        editScansBn.clicked.connect(self.__slotEditScansClicked)
        hLayout.addWidget(label)
        hLayout.addWidget(editScansBn)
        scanLayout.addLayout(hLayout, 0, 0, 1, 2)

        label = Qt.QLabel('Total :')
        self.__totalScansEdit = totalScansEdit = Qt.QLineEdit('0')
        totalScansEdit.setReadOnly(True)
        fm = totalScansEdit.fontMetrics()
        width = (fm.boundingRect('0123456').width() +
                 fm.boundingRect('00').width())
        totalScansEdit.setMaximumWidth(width)
        totalScansEdit.setAlignment(Qt.Qt.AlignRight)

        scanLayout.addWidget(label, 1, 0, Qt.Qt.AlignLeft)
        scanLayout.addWidget(totalScansEdit, 1, 1, Qt.Qt.AlignLeft)

        # ====

        label = Qt.QLabel('Selected :')
        self.__selectedScansEdit = selectedScansEdit = Qt.QLineEdit('0')
        selectedScansEdit.setReadOnly(True)
        fm = selectedScansEdit.fontMetrics()
        width = (fm.boundingRect('0123456').width() +
                 fm.boundingRect('00').width())
        selectedScansEdit.setMaximumWidth(width)
        selectedScansEdit.setAlignment(Qt.Qt.AlignRight)

        scanLayout.addWidget(label, 2, 0, Qt.Qt.AlignLeft)
        scanLayout.addWidget(selectedScansEdit, 2, 1, Qt.Qt.AlignLeft)

        # ===

        grpLayout.addWidget(_vLine())

        # ===========
        # "other" scans
        # ===========

        scanLayout = Qt.QGridLayout()
        grpLayout.addLayout(scanLayout)

        hLayout = Qt.QHBoxLayout()
        label = Qt.QLabel('<span style=" font-weight:600; color:#ff6600;">'
                          'Other scans</span>')
        otherScansBn = FixedSizePushButon('View')
        otherScansBn.clicked.connect(self.__slotOtherScansClicked)
        hLayout.addWidget(label)
        hLayout.addWidget(otherScansBn)

        scanLayout.addLayout(hLayout, 0, 0, 1, 2)

        label = Qt.QLabel('No match :')
        self.__noMatchScansEdit = noMatchScansEdit = Qt.QLineEdit('0')
        noMatchScansEdit.setReadOnly(True)
        fm = noMatchScansEdit.fontMetrics()
        width = (fm.boundingRect('0123456').width() +
                 fm.boundingRect('00').width())
        noMatchScansEdit.setMaximumWidth(width)
        noMatchScansEdit.setAlignment(Qt.Qt.AlignRight)

        scanLayout.addWidget(label, 1, 0, Qt.Qt.AlignLeft)
        scanLayout.addWidget(noMatchScansEdit, 1, 1, Qt.Qt.AlignLeft)

        # ====

        label = Qt.QLabel('No img info :')
        self.__noImgInfoEdit = noImgInfoEdit = Qt.QLineEdit('0')
        noImgInfoEdit.setReadOnly(True)
        fm = noImgInfoEdit.fontMetrics()
        width = (fm.boundingRect('0123456').width() +
                 fm.boundingRect('00').width())
        noImgInfoEdit.setMaximumWidth(width)
        noImgInfoEdit.setAlignment(Qt.Qt.AlignRight)

        scanLayout.addWidget(label, 2, 0, Qt.Qt.AlignLeft)
        scanLayout.addWidget(noImgInfoEdit, 2, 1, Qt.Qt.AlignLeft)

        # ===

        grpLayout.addWidget(_vLine())

        # ################
        # parameters
        # ################
        self.__acqParamsGbx = acqParamsGbx = GroupBox("Acq. Parameters")
        grpLayout = Qt.QVBoxLayout(acqParamsGbx)

        self.__acqParamWid = acqParamWid = AcqParamsWidget()
        self.layout().addWidget(acqParamsGbx, 2, 0,
                                Qt.Qt.AlignLeft | Qt.Qt.AlignTop)
        grpLayout.addWidget(acqParamWid)

        # ################
        # output options
        # ################

        self.__outputGbx = outputGbx = GroupBox("Output")
        layout = Qt.QGridLayout(outputGbx)
        self.layout().addWidget(outputGbx, 3, 0, Qt.Qt.AlignTop)

        # ===========
        # master
        # ===========

        lab = Qt.QLabel('Prefix :')
        self.__prefixEdit = prefixEdit = StyledLineEdit(nChar=20)
        prefixEdit.textChanged.connect(self.__slotPrefixChanged)
        hLayout = Qt.QHBoxLayout()
        layout.addLayout(hLayout, 0, 1, Qt.Qt.AlignLeft)
        resetPrefixBn = Qt.QToolButton()
        icon = Qt.qApp.style().standardIcon(Qt.QStyle.SP_BrowserReload)
        resetPrefixBn.setIcon(icon)
        resetPrefixBn.clicked.connect(self.__slotResetPrefixClicked)
        layout.addWidget(lab, 0, 0, Qt.Qt.AlignLeft)
        sp = prefixEdit.sizePolicy()
        sp.setHorizontalPolicy(Qt.QSizePolicy.Maximum)
        prefixEdit.setSizePolicy(sp)
        hLayout.addWidget(prefixEdit, Qt.Qt.AlignLeft)
        hLayout.addWidget(resetPrefixBn, Qt.Qt.AlignLeft)

        # ===========
        # output folder
        # ===========

        outDirChooser = FileChooser(fileMode=Qt.QFileDialog.Directory,
                                    noLabel=True)
        outDirChooser.lineEdit.setText(outputDir)
        outDirChooser.sigSelectionChanged.connect(self.__slotOutDirChanged)
        layout.addWidget(Qt.QLabel('Output directory :'), 1, 0)
        layout.addWidget(outDirChooser, 1, 1)

        # ################
        # merge button
        # ################

        self.__mergeBn = mergeBn = Qt.QPushButton('Merge')
        cancelBn = Qt.QPushButton('Cancel')
        hLayout = Qt.QHBoxLayout()
        self.layout().addLayout(hLayout, 4, 0, 1, 1,
                                Qt.Qt.AlignHCenter | Qt.Qt.AlignTop)
        hLayout.addWidget(mergeBn)
        hLayout.addWidget(cancelBn)
        mergeBn.clicked.connect(self.__slotMergeBnClicked)
        cancelBn.clicked.connect(self.reject)

        # #################
        # setting initial state
        # #################

        # scansGbx.setEnabled(False)
        # acqParamsGbx.setEnabled(False)
        # outputGbx.setEnabled(False)
        # mergeBn.setEnabled(False)
        parseBn.setEnabled(False)

        self.__merger = None
        self.__parser = None
        self.info_wid = None

        if tmp_dir is None:
            tmp_dir, delete_tmp, q_tmp_dir = _create_tmp_dir()
        else:
            delete_tmp = False
            q_tmp_dir = None

        self.__tmp_root = tmp_dir
        self.__delete_tmp_root = delete_tmp
        self.__q_tmp_dir = q_tmp_dir

        tmp_dir = os.path.join(self.__tmp_root, 'xsocs_merge')
        if not os.path.exists(tmp_dir):
            os.makedirs(tmp_dir)

        self.__tmp_dir_merge = tmp_dir

        print('Using temporary folder : {0}.'.format(tmp_dir))

        self.__widgetIsSetup = False

        self.__xsocs_h5 = None

        versionCBx.setCurrentIndex(spec_version)
        self.__slotVersionChanged(spec_version)
        versionCBx.currentIndexChanged[int].connect(self.__slotVersionChanged)

        self.__resetState()

        self.__sigParsed.connect(self.__slotParsed, Qt.Qt.QueuedConnection)
Exemple #19
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self.pv = loadPV()

        bigBoldFont = qt.QFont()
        bigBoldFont.setPointSize(9)
        bigBoldFont.setBold(True)

        self.engineLabel = qt.QLabel("State : ")
        self.engineLabel.setMinimumHeight(50)
        self.engineLabel.setMaximumHeight(50)

        self.engineStatus = qt.QLabel("EngineStatus")
        self.engineStatus.setFrameShape(qt.QFrame.Box)
        self.engineStatus.setFrameShadow(qt.QFrame.Sunken)
        self.engineStatus.setAlignment(qt.Qt.AlignCenter)
        self.engineStatus.setMinimumSize(qt.QSize(150, 50))
        self.engineStatus.setMaximumSize(qt.QSize(150, 50))

        self.abortButton = qt.QPushButton(self)
        self.abortButton.setText("Scan Abort")
        self.abortButton.setMinimumSize(qt.QSize(130, 50))
        self.abortButton.setMaximumSize(qt.QSize(115, 50))

        # high limit for scaler counts
        limit_hi = 900000

        self.I0_rbv = CounterRbvLabel(pv=self.pv['Scaler']['I0_counter_cal'],
                                      scaler_pv=self.pv['Scaler']['scaler'],
                                      limit_hi=limit_hi)

        self.It_rbv = CounterRbvLabel(pv=self.pv['Scaler']['It_counter_cal'],
                                      scaler_pv=self.pv['Scaler']['scaler'],
                                      limit_hi=limit_hi)

        self.If_rbv = CounterRbvLabel(pv=self.pv['Scaler']['If_counter_cal'],
                                      scaler_pv=self.pv['Scaler']['scaler'],
                                      limit_hi=limit_hi)

        self.Ir_rbv = CounterRbvLabel(pv=self.pv['Scaler']['Ir_counter_cal'],
                                      scaler_pv=self.pv['Scaler']['scaler'],
                                      limit_hi=limit_hi)

        self.theta_angle_label = EpicsValueLabel(
            self.pv['DCM']['mono_theta'] + '.RBV',
            moving_pv=self.pv['DCM']['mono_theta_dmov'])
        self.theta_angle_label.setMinimumSize(qt.QSize(130, 30))
        self.theta_angle_label.setMaximumSize(qt.QSize(130, 30))

        self.theta_energy_label = EpicsValueLabel(
            self.pv['DCM']['mono_theta'] + '.RBV',
            moving_pv=self.pv['DCM']['mono_theta_dmov'],
            convert=angle_to_energy)

        self.theta_energy_label.setMinimumSize(qt.QSize(130, 30))
        self.theta_energy_label.setMaximumSize(qt.QSize(130, 30))

        self.life_time_label = EpicsValueLabel(self.pv['Beam']['LifeTime'],
                                               precision=2,
                                               convert=lambda x: x / 3600.)
        self.life_time_label.setMinimumSize(qt.QSize(100, 30))
        self.life_time_label.setFrameShape(qt.QFrame.Panel)
        self.life_time_label.setFrameShadow(qt.QFrame.Sunken)
        self.life_time_label.setAlignment(qt.Qt.AlignCenter)

        self.topup_label = EpicsValueLabel(self.pv['Beam']['TopUpCount'],
                                           precision=2)
        self.topup_label.setMinimumSize(qt.QSize(100, 30))
        self.topup_label.setFrameShape(qt.QFrame.Panel)
        self.topup_label.setFrameShadow(qt.QFrame.Sunken)
        self.topup_label.setAlignment(qt.Qt.AlignCenter)

        self.beam_current_label = EpicsValueLabel(self.pv['Beam']['Current'],
                                                  precision=2)
        self.beam_current_label.setMinimumSize(qt.QSize(100, 30))
        self.beam_current_label.setMaximumSize(qt.QSize(100, 30))
        self.beam_current_label.setFrameShape(qt.QFrame.Panel)
        self.beam_current_label.setFrameShadow(qt.QFrame.Sunken)
        self.beam_current_label.setAlignment(qt.Qt.AlignCenter)

        self.num_of_steps_label = qt.QLabel("not conn.")
        self.num_of_steps_label.setMinimumSize(qt.QSize(100, 30))
        self.num_of_steps_label.setMaximumSize(qt.QSize(100, 30))
        self.num_of_steps_label.setFrameShape(qt.QFrame.Panel)
        self.num_of_steps_label.setFrameShadow(qt.QFrame.Sunken)
        self.num_of_steps_label.setAlignment(qt.Qt.AlignCenter)

        self.scan_point_label = qt.QLabel("not conn.")
        self.scan_point_label.setMinimumSize(qt.QSize(90, 30))
        self.scan_point_label.setMaximumSize(qt.QSize(90, 30))
        self.scan_point_label.setFrameShape(qt.QFrame.Panel)
        self.scan_point_label.setFrameShadow(qt.QFrame.Sunken)
        self.scan_point_label.setAlignment(qt.Qt.AlignCenter)

        self.scanInfoLoopTimeLabel = qt.QLabel('LoopTime : ')

        self.loop_time_label = qt.QLabel("not conn.")
        self.loop_time_label.setMinimumSize(qt.QSize(90, 30))
        self.loop_time_label.setMaximumSize(qt.QSize(90, 30))
        self.loop_time_label.setFrameShape(qt.QFrame.Panel)
        self.loop_time_label.setFrameShadow(qt.QFrame.Sunken)
        self.loop_time_label.setAlignment(qt.Qt.AlignCenter)

        self.num_of_history_spin_box = qt.QDoubleSpinBox(self)
        self.num_of_history_spin_box.setMinimumSize(qt.QSize(220, 30))
        self.num_of_history_spin_box.setMaximumSize(qt.QSize(220, 30))
        self.num_of_history_spin_box.setAlignment(qt.Qt.AlignCenter)
        self.num_of_history_spin_box.setDecimals(0)
        self.num_of_history_spin_box.setMinimum(1.0)
        self.num_of_history_spin_box.setMaximum(10.0)
        self.num_of_history_spin_box.setSingleStep(1.0)
        self.num_of_history_spin_box.setProperty("value", 1.0)

        self.x_axis_type_combo_box = qt.QComboBox(self)
        self.x_axis_type_combo_box.setMinimumSize(qt.QSize(220, 30))
        self.x_axis_type_combo_box.setMaximumSize(qt.QSize(220, 30))
        self.x_axis_type_combo_box.addItem("")
        self.x_axis_type_combo_box.addItem("")
        self.x_axis_type_combo_box.setItemText(0, "Delta(E-E0)")
        self.x_axis_type_combo_box.setItemText(1, "Energy(eV)")

        self.y_axis_type_combo_box = qt.QComboBox(self)
        self.y_axis_type_combo_box.setMinimumSize(qt.QSize(130, 30))
        self.y_axis_type_combo_box.setMaximumSize(qt.QSize(130, 30))
        self.y_axis_type_combo_box.addItem("")
        self.y_axis_type_combo_box.addItem("")
        self.y_axis_type_combo_box.addItem("")
        self.y_axis_type_combo_box.addItem("")
        self.y_axis_type_combo_box.addItem("")
        self.y_axis_type_combo_box.addItem("")
        self.y_axis_type_combo_box.addItem("")
        self.y_axis_type_combo_box.setItemText(0, "Transmittance")
        self.y_axis_type_combo_box.setItemText(1, "Fluorescence")
        self.y_axis_type_combo_box.setItemText(2, "Reference")
        self.y_axis_type_combo_box.setItemText(3, "View I0(1) Only")
        self.y_axis_type_combo_box.setItemText(4, "View IT(2) Only")
        self.y_axis_type_combo_box.setItemText(5, "View IF(3) Only")
        self.y_axis_type_combo_box.setItemText(6, "View IR(4) Only")

        self.derivativeCB = qt.QCheckBox(self)
        self.derivativeCB.setText('deriv.')

        main_panel = qt.QWidget(self)
        main_panel.setLayout(qt.QHBoxLayout())
        self.setCentralWidget(main_panel)

        REWidget = qt.QWidget(self)
        REWidget.setLayout(qt.QFormLayout())
        REWidget.layout().setLabelAlignment(qt.Qt.AlignRight)
        REWidget.layout().setFormAlignment(qt.Qt.AlignBottom)
        REWidget.layout().setContentsMargins(0, 0, 0, 0)
        REWidget.layout().addWidget(self.engineStatus)
        REWidget.layout().addWidget(self.abortButton)

        REWidget.layout().addRow(
            self.engineLabel, addWidgets([self.engineStatus,
                                          self.abortButton]))

        counterGB = qt.QGroupBox("Counters", main_panel)
        counterGB.setLayout(qt.QHBoxLayout())
        counterGB.layout().setSpacing(20)
        counterGB.layout().addWidget(addLabelWidgetVert('I0', self.I0_rbv))
        counterGB.layout().addWidget(addLabelWidgetVert('It', self.It_rbv))
        counterGB.layout().addWidget(addLabelWidgetVert('Ir', self.Ir_rbv))
        counterGB.layout().addWidget(addLabelWidgetVert('If', self.If_rbv))

        dcmGB = qt.QGroupBox("Monochromator", main_panel)
        dcmGB.setLayout(qt.QFormLayout())
        dcmGB.layout().setLabelAlignment(qt.Qt.AlignRight)
        dcmGB.layout().addRow('Angle [Deg.] : ', self.theta_angle_label)
        dcmGB.layout().addRow('Energy [eV]: ', self.theta_energy_label)

        beamGB = qt.QGroupBox("Beam", main_panel)
        beamGB.setLayout(qt.QFormLayout())
        beamGB.layout().setLabelAlignment(qt.Qt.AlignRight)
        beamGB.layout().addRow('Life Time [hours] : ', self.life_time_label)
        beamGB.layout().addRow('TopUp Count [sec.] : ', self.topup_label)
        beamGB.layout().addRow('Current [mA] : ', self.beam_current_label)

        scanInfoGB = qt.QGroupBox("Scan Info", main_panel)
        scanInfoGB.setLayout(qt.QFormLayout())
        scanInfoGB.layout().setLabelAlignment(qt.Qt.AlignRight)
        scanInfoGB.layout().addRow('NoOfSteps : ', self.num_of_steps_label)
        scanInfoGB.layout().addRow('ScanPoint : ', self.scan_point_label)
        scanInfoGB.layout().addRow(self.scanInfoLoopTimeLabel,
                                   self.loop_time_label)

        plotControlGB = qt.QGroupBox("Plot Control", main_panel)
        plotControlGB.setLayout(qt.QFormLayout())
        plotControlGB.layout().setLabelAlignment(qt.Qt.AlignRight)
        plotControlGB.layout().addRow('# Of History : ',
                                      self.num_of_history_spin_box)
        plotControlGB.layout().addRow('X-axis type : ',
                                      self.x_axis_type_combo_box)
        plotControlGB.layout().addRow(
            'Y-axis type : ',
            addWidgets([self.y_axis_type_combo_box, self.derivativeCB]))

        main_panel.layout().addWidget(addStretchWidget(REWidget))
        main_panel.layout().addStretch(1)
        main_panel.layout().addWidget(addStretchWidget(dcmGB))
        main_panel.layout().addWidget(addStretchWidget(counterGB))
        main_panel.layout().addWidget(addStretchWidget(beamGB))
        main_panel.layout().addWidget(addStretchWidget(scanInfoGB))
        main_panel.layout().addWidget(addStretchWidget(plotControlGB))
Exemple #20
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)
Exemple #21
0
    def __init__(self, qspaceFile, **kwargs):
        super(FitWidget, self).__init__(**kwargs)

        self.__qspaceH5 = qspaceH5 = QSpaceH5(qspaceFile)
        self.__progTimer = None

        self.__outputFile = None

        self.__nPeaks = 1

        layout = Qt.QGridLayout(self)

        self.__roiWidget = roiWidget = Roi3DSelectorWidget()

        layout.addWidget(roiWidget)

        fileLayout = Qt.QHBoxLayout()
        self.__fileEdit = fileEdit = StyledLineEdit(nChar=20, readOnly=True)
        fileLayout.addWidget(Qt.QLabel('File :'))
        fileLayout.addWidget(fileEdit)
        layout.addLayout(fileLayout, 1, 0)

        fitLayout = Qt.QHBoxLayout()
        self.__fitTypeCb = fitTypeCb = Qt.QComboBox()
        fitTypeCb.addItems(list(FitWidget.FitTypes.keys()))
        fitTypeCb.setCurrentIndex(0)
        fitLayout.addWidget(Qt.QLabel('Fit :'))
        fitLayout.addWidget(fitTypeCb)
        fitTypeCb.currentIndexChanged[str].connect(
            self.__slotCurrentTextChanged)

        layout.addLayout(fitLayout, 2, 0, alignment=Qt.Qt.AlignLeft)

        self.__nPeaksSpinBox = spinbox = Qt.QSpinBox()
        # spinbox.setMinimum(1)
        # spinbox.setMaximum(20)
        # spinbox.setValue(self.__nPeaks)
        # spinbox.setToolTip('Max. number of expected peaks.')
        # spinbox.valueChanged.connect(self.__slotValueChanged)
        # fitLayout.addWidget(spinbox)
        # fitLayout.addWidget(Qt.QLabel('peak(s)'))

        runLayout = Qt.QHBoxLayout()
        self.__runButton = runButton = Qt.QPushButton('Run')
        runButton.setEnabled(False)
        runButton.clicked.connect(self.__slotRunClicked)
        runLayout.addWidget(runButton)

        self.__progBar = progBar = Qt.QProgressBar()
        runLayout.addWidget(progBar)
        layout.addLayout(runLayout, 3, 0, alignment=Qt.Qt.AlignCenter)

        self.__statusLabel = statusLabel = Qt.QLabel('Ready')
        statusLabel.setFrameStyle(Qt.QFrame.Panel | Qt.QFrame.Sunken)
        layout.addWidget(statusLabel, 4, 0)

        with qspaceH5:
            qx = qspaceH5.qx
            qy = qspaceH5.qy
            qz = qspaceH5.qz

        roiWidget.xSlider().setRange([qx[0], qx[-1]])
        roiWidget.ySlider().setRange([qy[0], qy[-1]])
        roiWidget.zSlider().setRange([qz[0], qz[-1]])

        self.__sigFitDone.connect(self.__slotFitDone)

        layout.setRowStretch(layout.rowCount(), 1)
        layout.setColumnStretch(layout.columnCount(), 1)
Exemple #22
0
    def __init__(self, parent=None):
        qt.QWidget.__init__(self, parent)

        self.mainLayout = qt.QGridLayout(self)
        self.mainLayout.setColumnStretch(1, 1)

        # Algorithm choice ---------------------------------------------------
        self.algorithmComboLabel = qt.QLabel(self)
        self.algorithmComboLabel.setText("Background algorithm")
        self.algorithmCombo = qt.QComboBox(self)
        self.algorithmCombo.addItem("Strip")
        self.algorithmCombo.addItem("Snip")
        self.algorithmCombo.activated[int].connect(
                self._algorithmComboActivated)

        # Strip parameters ---------------------------------------------------
        self.stripWidthLabel = qt.QLabel(self)
        self.stripWidthLabel.setText("Strip Width")

        self.stripWidthSpin = qt.QSpinBox(self)
        self.stripWidthSpin.setMaximum(100)
        self.stripWidthSpin.setMinimum(1)
        self.stripWidthSpin.valueChanged[int].connect(self._emitSignal)

        self.stripIterLabel = qt.QLabel(self)
        self.stripIterLabel.setText("Strip Iterations")
        self.stripIterValue = qt.QLineEdit(self)
        validator = qt.QIntValidator(self.stripIterValue)
        self.stripIterValue._v = validator
        self.stripIterValue.setText("0")
        self.stripIterValue.editingFinished[()].connect(self._emitSignal)
        self.stripIterValue.setToolTip(
                "Number of iterations for strip algorithm.\n" +
                "If greater than 999, an 2nd pass of strip filter is " +
                "applied to remove artifacts created by first pass.")

        # Snip parameters ----------------------------------------------------
        self.snipWidthLabel = qt.QLabel(self)
        self.snipWidthLabel.setText("Snip Width")

        self.snipWidthSpin = qt.QSpinBox(self)
        self.snipWidthSpin.setMaximum(300)
        self.snipWidthSpin.setMinimum(0)
        self.snipWidthSpin.valueChanged[int].connect(self._emitSignal)


        # Smoothing parameters -----------------------------------------------
        self.smoothingFlagCheck = qt.QCheckBox(self)
        self.smoothingFlagCheck.setText("Smoothing Width (Savitsky-Golay)")
        self.smoothingFlagCheck.toggled.connect(self._smoothingToggled)

        self.smoothingSpin = qt.QSpinBox(self)
        self.smoothingSpin.setMinimum(3)
        #self.smoothingSpin.setMaximum(40)
        self.smoothingSpin.setSingleStep(2)
        self.smoothingSpin.valueChanged[int].connect(self._emitSignal)

        # Anchors ------------------------------------------------------------

        self.anchorsGroup = qt.QWidget(self)
        anchorsLayout = qt.QHBoxLayout(self.anchorsGroup)
        anchorsLayout.setSpacing(2)
        anchorsLayout.setContentsMargins(0, 0, 0, 0)

        self.anchorsFlagCheck = qt.QCheckBox(self.anchorsGroup)
        self.anchorsFlagCheck.setText("Use anchors")
        self.anchorsFlagCheck.setToolTip(
                "Define X coordinates of points that must remain fixed")
        self.anchorsFlagCheck.stateChanged[int].connect(
                self._anchorsToggled)
        anchorsLayout.addWidget(self.anchorsFlagCheck)

        maxnchannel = 16384 * 4    # Fixme ?
        self.anchorsList = []
        num_anchors = 4
        for i in range(num_anchors):
            anchorSpin = qt.QSpinBox(self.anchorsGroup)
            anchorSpin.setMinimum(0)
            anchorSpin.setMaximum(maxnchannel)
            anchorSpin.valueChanged[int].connect(self._emitSignal)
            anchorsLayout.addWidget(anchorSpin)
            self.anchorsList.append(anchorSpin)

        # Layout ------------------------------------------------------------
        self.mainLayout.addWidget(self.algorithmComboLabel, 0, 0)
        self.mainLayout.addWidget(self.algorithmCombo, 0, 2)
        self.mainLayout.addWidget(self.stripWidthLabel, 1, 0)
        self.mainLayout.addWidget(self.stripWidthSpin, 1, 2)
        self.mainLayout.addWidget(self.stripIterLabel, 2, 0)
        self.mainLayout.addWidget(self.stripIterValue, 2, 2)
        self.mainLayout.addWidget(self.snipWidthLabel, 3, 0)
        self.mainLayout.addWidget(self.snipWidthSpin, 3, 2)
        self.mainLayout.addWidget(self.smoothingFlagCheck, 4, 0)
        self.mainLayout.addWidget(self.smoothingSpin, 4, 2)
        self.mainLayout.addWidget(self.anchorsGroup, 5, 0, 1, 4)

        # Initialize interface -----------------------------------------------
        self._setAlgorithm("strip")
        self.smoothingFlagCheck.setChecked(False)
        self._smoothingToggled(is_checked=False)
        self.anchorsFlagCheck.setChecked(False)
        self._anchorsToggled(is_checked=False)
Exemple #23
0
 def createEditor(self, parent, option, index):
     editor = qt.QComboBox(parent)
     editor.setMinimumHeight(25)
     editor.currentIndexChanged.connect(self.commitDataAndClose)
     return editor