Пример #1
0
    def __init__(self, merger, **kwargs):
        super(_MergeProcessDialog, self).__init__(**kwargs)
        layout = Qt.QVBoxLayout(self)

        files = merger.summary()
        output_dir = merger.output_dir

        label = Qt.QLabel('<html><head/><body><p align="center">'
                          '<span style=" font-size:16pt; font-weight:600;">'
                          'Merge process</span></p></body></html>')
        label.setTextFormat(Qt.Qt.RichText)
        layout.addWidget(label, stretch=0, alignment=Qt.Qt.AlignHCenter)

        grp_box = GroupBox('Output directory :')
        grp_box.setLayout(Qt.QVBoxLayout())
        outdir_edit = Qt.QLineEdit(output_dir)
        fm = outdir_edit.fontMetrics()
        outdir_edit.setMinimumWidth(fm.width(' ' * 100))
        grp_box.layout().addWidget(outdir_edit)

        layout.addWidget(grp_box, stretch=0)
        grp_box = GroupBox('Files :')
        grp_box.setLayout(Qt.QVBoxLayout())
        tree_widget = Qt.QTreeWidget()
        tree_widget.setColumnCount(3)
        tree_widget.setColumnHidden(2, True)
        # TODO improve
        master_item = Qt.QTreeWidgetItem([files['master'], '', 'master'])
        for scan_id in sorted(files.keys()):
            if scan_id != 'master':
                master_item.addChild(
                    Qt.QTreeWidgetItem([files[scan_id], '', scan_id]))

        tree_widget.addTopLevelItem(master_item)
        tree_widget.setItemWidget(master_item, 1, Qt.QProgressBar())
        for i_child in range(master_item.childCount()):
            tree_widget.setItemWidget(master_item.child(i_child), 1,
                                      Qt.QProgressBar())

        master_item.setExpanded(True)
        tree_widget.resizeColumnToContents(0)
        tree_widget.resizeColumnToContents(1)
        width = (tree_widget.sizeHintForColumn(0) +
                 tree_widget.sizeHintForColumn(1) + 10)
        tree_widget.setMinimumWidth(width)
        layout.addWidget(tree_widget, stretch=1, alignment=Qt.Qt.AlignHCenter)

        bn_box = Qt.QDialogButtonBox(Qt.QDialogButtonBox.Ok
                                     | Qt.QDialogButtonBox.Cancel)
        bn_box.button(Qt.QDialogButtonBox.Ok).setText('Merge')
        layout.addWidget(bn_box)
        bn_box.accepted.connect(self.__onAccept)
        bn_box.rejected.connect(self.reject)
        self.__sigMergeDone.connect(self.__mergeDone)

        self.__tree_widget = tree_widget
        self.__bn_box = bn_box
        self.__abort_diag = None
        self.__merger = merger
        self.__status = False
Пример #2
0
    def __init__(self, parent=None):
        super(Detector3dDialog, self).__init__(parent=parent)
        self.setWindowTitle("Display sample stage")
        self.__plot = SceneWindow(self)
        self.__plot.setVisible(False)

        self.__process = qt.QProgressBar(self)
        self.__process.setFormat("Processing data")
        self.__process.setRange(0, 100)

        self.__buttons = qt.QDialogButtonBox(self)
        self.__buttons.addButton(qt.QDialogButtonBox.Cancel)
        self.__buttons.accepted.connect(self.accept)
        self.__buttons.rejected.connect(self.reject)

        layout = qt.QVBoxLayout(self)
        layout.addWidget(self.__plot)
        layout.addWidget(self.__process)
        layout.addWidget(self.__buttons)
Пример #3
0
    def _video360(self, nbFrames):
        """Run the video and provides the images

        :param int nbFrames: The number of frames to generate for
        :return: Iterator of QImage of the video sequence
        """
        plot3d = self.getPlot3DWidget()
        assert plot3d is not None

        angleStep = 360. / nbFrames

        # Create progress bar dialog
        dialog = qt.QDialog(plot3d)
        dialog.setWindowTitle('Record Video')
        layout = qt.QVBoxLayout(dialog)
        progress = qt.QProgressBar()
        progress.setRange(0, nbFrames)
        layout.addWidget(progress)

        btnBox = qt.QDialogButtonBox(qt.QDialogButtonBox.Abort)
        btnBox.rejected.connect(dialog.reject)
        layout.addWidget(btnBox)

        dialog.setModal(True)
        dialog.show()

        qapp = qt.QApplication.instance()

        for frame in range(nbFrames):
            progress.setValue(frame)
            image = plot3d.grabGL()
            yield image
            plot3d.viewport.orbitCamera('left', angleStep)
            qapp.processEvents()
            if not dialog.isVisible():
                break  # It as been rejected by the abort button
        else:
            dialog.accept()

        if dialog.result() == qt.QDialog.Rejected:
            raise GeneratorExit('Aborted')
Пример #4
0
    def __init__(self, converter, parent=None, **kwargs):
        """
        Simple widget displaying a progress bar and a info label during the
            conversion process.
        :param converter:
        :param parent:
        :param kwargs:
        """
        super(_ConversionProcessDialog, self).__init__(parent)
        layout = Qt.QVBoxLayout(self)

        progress_bar = Qt.QProgressBar()
        layout.addWidget(progress_bar)
        status_lab = Qt.QLabel('<font color="blue">Conversion '
                               'in progress</font>')
        status_lab.setFrameStyle(Qt.QFrame.Panel | Qt.QFrame.Sunken)
        layout.addWidget(status_lab)

        bn_box = Qt.QDialogButtonBox(Qt.QDialogButtonBox.Abort)
        layout.addWidget(bn_box)
        bn_box.accepted.connect(self.accept)
        bn_box.rejected.connect(self.__onAbort)

        self.__sigConvertDone.connect(self.__convertDone)

        self.__bn_box = bn_box
        self.__progress_bar = progress_bar
        self.__status_lab = status_lab
        self.__converter = converter
        self.__aborted = False

        self.__qtimer = Qt.QTimer()
        self.__qtimer.timeout.connect(self.__onProgress)

        converter.convert(blocking=False,
                          overwrite=True,
                          callback=self.__sigConvertDone.emit,
                          **kwargs)

        self.__qtimer.start(1000)
Пример #5
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)