Пример #1
0
    def __customDetector(self):
        settings = self.model().experimentSettingsModel()
        detector = settings.detectorModel().detector()
        popup = DetectorSelectorDrop(self)
        popupParent = self._customDetector
        pos = popupParent.mapToGlobal(popupParent.rect().bottomRight())
        pos = pos + popup.rect().topLeft() - popup.rect().topRight()
        popup.move(pos)
        popup.show()

        dialog = qt.QDialog(self)
        dialog.setWindowTitle("Detector selection")
        layout = qt.QVBoxLayout(dialog)
        layout.addWidget(popup)

        buttonBox = qt.QDialogButtonBox(qt.QDialogButtonBox.Ok |
                                        qt.QDialogButtonBox.Cancel)
        buttonBox.accepted.connect(dialog.accept)
        buttonBox.rejected.connect(dialog.reject)
        layout.addWidget(buttonBox)

        # It have to be here to set the focus on the right widget
        popup.setDetector(detector)
        result = dialog.exec_()
        if result:
            newDetector = popup.detector()
            settings.detectorModel().setDetector(newDetector)
Пример #2
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')
Пример #3
0
def getIntensity(projectFile, pathTpl, view=None):
    xsocsH5 = ProjectItem(projectFile).xsocsH5

    with xsocsH5:
        entries = xsocsH5.entries()

    subject = ProgressSubject()
    tree = TreeView(view)
    tree.setShowUniqueGroup(True)
    model = Model()

    progressGroup = ProgressGroup(subject=subject, nodeName='Intensity')
    progressGroup.start()
    progressGroup.setEntries(entries)
    model.appendGroup(progressGroup)

    app = Qt.qApp

    mw = Qt.QDialog(view)
    mw.setModal(True)
    mw.setWindowTitle('Setting up data.')
    layout = Qt.QVBoxLayout(mw)
    tree.setModel(model)
    layout.addWidget(tree)
    mw.show()
    app.processEvents()

    manager = Manager()
    projectLock = manager.Lock()
    queue = manager.Queue()

    n_proc = cpu_count()

    pool = Pool(n_proc,
                maxtasksperchild=2)
    results = OrderedDict()

    for entry in entries:

        entry_f = xsocsH5.object_filename(entry)

        args = (entry,
                entry_f,
                projectLock,
                projectFile,
                pathTpl,
                queue,)

        results[entry] = pool.apply_async(_getIntensity,
                                          args)
    pool.close()

    while results:
        try:
            msg = queue.get(True, 0.01)
            if msg['done']:
                del results[msg['id']]
            subject.sigStateChanged.emit(msg)
        except queues.Empty:
            pass
        app.processEvents()

    pool.join()

    mw.close()
    mw.deleteLater()