def showAbout(qt_viewer):
     d = QDialog()
     d.setObjectName('QtAboutKeybindings')
     d.setStyleSheet(qt_viewer.styleSheet())
     d.setWindowTitle('Keybindings')
     qt_viewer._about_keybindings = QtAboutKeybindings(qt_viewer.viewer, d)
     d.show()
     d.setWindowModality(Qt.NonModal)
     d.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
     qt_viewer._about_keybindings_dialog = d
Exemple #2
0
    def _open_matrix_sel(self):
        wid = QDialog(self)
        wid.setObjectName(self._csorb.acc + 'App')
        wid.setLayout(QVBoxLayout())

        cbbox = QComboBox(wid)
        cbbox.setEditable(True)
        cbbox.setMaxVisibleItems(10)
        corrnames = self._csorb.ch_names + self._csorb.cv_names
        if self._csorb.acc in {'SI', 'BO'}:
            corrnames.append('RF')
        cbbox.addItems(corrnames)
        wid.layout().addWidget(QLabel('Choose the corrector:', wid))
        wid.layout().addWidget(cbbox)

        ledit = QDoubleSpinBoxPlus(wid)
        ledit.setMinimum(float('-inf'))
        ledit.setMaximum(float('inf'))
        ledit.setValue(1.0)
        wid.layout().addWidget(QLabel('Choose the Kick [urad]:', wid))
        wid.layout().addWidget(ledit)
        ledit.valueChanged.connect(_part(self._accept_mat_sel, ledit, cbbox))
        cbbox.currentIndexChanged.connect(
            _part(self._accept_mat_sel, ledit, cbbox))

        hlay = QHBoxLayout()
        cancel = QPushButton('Cancel', wid)
        confirm = QPushButton('Ok', wid)
        cancel.clicked.connect(wid.reject)
        confirm.clicked.connect(wid.accept)
        confirm.clicked.connect(_part(self._accept_mat_sel, ledit, cbbox))
        confirm.setDefault(True)
        hlay.addStretch()
        hlay.addWidget(cancel)
        hlay.addStretch()
        hlay.addWidget(confirm)
        hlay.addStretch()
        wid.layout().addItem(hlay)
        res = wid.exec_()

        if res != QDialog.Accepted:
            self._reset_orbit()
Exemple #3
0
    def _create_bump(self):
        def _add_entry(index):
            cbox = self.sender()
            text = cbox.itemText(index)
            if not text.startswith('other'):
                return
            win = LoadConfigDialog(self._config_type, self)
            confname, status = win.exec_()
            if not status:
                cbox.setCurrentIndex(0)
                return
            cbox.insertItem(index, confname)
            cbox.setCurrentIndex(index)

        wid = QDialog(self)
        wid.setObjectName(self._csorb.acc + 'App')
        lay = QGridLayout()
        wid.setLayout(lay)

        row = 0
        lay.addWidget(QLabel('Base Orbit ', wid), row, 0)
        orbcombo = QComboBox(wid)
        orbcombo.addItems(['Register', 'ref_orb', 'bba_orb', 'other...'])
        orbcombo.setCurrentIndex(1)
        orbcombo.activated.connect(_add_entry)
        lay.addWidget(orbcombo, row, 1)

        row += 1
        lay.addWidget(QLabel('Subsection', wid), row, 0)
        sscombo = QComboBox(wid)
        sub = ['SA', 'SB', 'SP', 'SB']
        ssnames = [f'{d+1:02d}{sub[d%len(sub)]}' for d in range(20)]
        bcnames = [f'{d+1:02d}BC' for d in range(20)]
        names = []
        for aaa, bbb in zip(ssnames, bcnames):
            names.extend([aaa, bbb])
        sscombo.addItems(names)
        lay.addWidget(sscombo, row, 1)

        row += 1
        lay.addWidget(QLabel('\u03B8<sub>x</sub> [urad]', wid), row, 0)
        angx = QLineEdit(wid)
        angx.setValidator(QDoubleValidator())
        angx.setText('0.0')
        angx.setAlignment(Qt.AlignCenter)
        angx.setStyleSheet('max-width:5em;')
        lay.addWidget(angx, row, 1)

        row += 1
        lay.addWidget(QLabel('X [um] ', wid), row, 0)
        posx = QLineEdit(wid)
        posx.setValidator(QDoubleValidator())
        posx.setText('0.0')
        posx.setAlignment(Qt.AlignCenter)
        posx.setStyleSheet('max-width:5em;')
        lay.addWidget(posx, row, 1)

        row += 1
        lay.addWidget(QLabel('\u03B8<sub>y</sub> [urad]', wid), row, 0)
        angy = QLineEdit(wid)
        angy.setValidator(QDoubleValidator())
        angy.setText('0.0')
        angy.setAlignment(Qt.AlignCenter)
        angy.setStyleSheet('max-width:5em;')
        lay.addWidget(angy, row, 1)

        row += 1
        lay.addWidget(QLabel('Y [um] ', wid), row, 0)
        posy = QLineEdit(wid)
        posy.setValidator(QDoubleValidator())
        posy.setText('0.0')
        posy.setAlignment(Qt.AlignCenter)
        posy.setStyleSheet('max-width:5em;')
        lay.addWidget(posy, row, 1)

        row += 1
        hlay = QHBoxLayout()
        cancel = QPushButton('Cancel', wid)
        confirm = QPushButton('Ok', wid)
        confirm.setDefault(True)
        cancel.clicked.connect(wid.reject)
        confirm.clicked.connect(wid.accept)
        hlay.addStretch()
        hlay.addWidget(cancel)
        hlay.addStretch()
        hlay.addWidget(confirm)
        hlay.addStretch()
        wid.layout().addItem(hlay, row, 0, 1, 2)
        res = wid.exec_()
        if res != QDialog.Accepted:
            return

        index = orbcombo.currentIndex()
        confname = orbcombo.itemText(index)
        if not index:
            orbx = _np.array(self.orbx)
            orby = _np.array(self.orby)
        elif index == orbcombo.count() - 1:
            return
        else:
            orbs = self._client.get_config_value(confname)
            orbx = _np.array(orbs['x'])
            orby = _np.array(orbs['y'])

        agx = float(angx.text())
        agy = float(angy.text())
        psx = float(posx.text())
        psy = float(posy.text())
        sub = sscombo.currentText()
        orbx, orby = _calculate_bump(orbx, orby, sub, agx, agy, psx, psy)

        txt = f'Bump@{sub}: ref={confname}\n'
        txt += f'ax={agx:.1f} ay={agy:.1f} dx={psx:.1f} dy={psy:.1f}'
        self._update_and_emit(txt, orbx, orby)
Exemple #4
0
    def _edit_orbit(self):
        orbx = self.orbx
        orby = self.orby

        wid = QDialog(self)
        wid.setObjectName(self._csorb.acc + 'App')
        wid.setLayout(QVBoxLayout())

        hbl = QHBoxLayout()
        wid.layout().addItem(hbl)
        hbl.addWidget(QLabel('X = ', wid))
        multx = QLineEdit(wid)
        multx.setValidator(QDoubleValidator())
        multx.setText('1.0')
        # multx.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
        multx.setAlignment(Qt.AlignCenter)
        multx.setStyleSheet('max-width:5em;')
        hbl.addWidget(multx)
        hbl.addWidget(QLabel('*X   +   ', wid))
        addx = QLineEdit(wid)
        addx.setValidator(QDoubleValidator())
        addx.setText('0.0')
        addx.setAlignment(Qt.AlignCenter)
        addx.setStyleSheet('max-width:5em;')
        hbl.addWidget(addx)
        hbl.addWidget(QLabel(' [um]', wid))

        hbl = QHBoxLayout()
        wid.layout().addItem(hbl)
        hbl.addWidget(QLabel('Y = ', wid))
        multy = QLineEdit(wid)
        multy.setValidator(QDoubleValidator())
        multy.setText('1.0')
        # multy.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
        multy.setAlignment(Qt.AlignCenter)
        multy.setStyleSheet('max-width:5em;')
        hbl.addWidget(multy)
        hbl.addWidget(QLabel('*Y   +   ', wid))
        addy = QLineEdit(wid)
        addy.setValidator(QDoubleValidator())
        addy.setText('0.0')
        addy.setAlignment(Qt.AlignCenter)
        addy.setStyleSheet('max-width:5em;')
        hbl.addWidget(addy)
        hbl.addWidget(QLabel(' [um]', wid))

        hlay = QHBoxLayout()
        cancel = QPushButton('Cancel', wid)
        confirm = QPushButton('Ok', wid)
        confirm.setDefault(True)
        cancel.clicked.connect(wid.reject)
        confirm.clicked.connect(wid.accept)
        hlay.addStretch()
        hlay.addWidget(cancel)
        hlay.addStretch()
        hlay.addWidget(confirm)
        hlay.addStretch()
        wid.layout().addItem(hlay)
        res = wid.exec_()

        if res != QDialog.Accepted:
            return
        mltx = float(multx.text())
        mlty = float(multy.text())
        plusx = float(addx.text())
        plusy = float(addy.text())
        orbx = mltx * orbx + plusx
        orby = mlty * orby + plusy
        txt = ''
        txt += f'multx = {mltx:5.1f} offx = {plusx:7.1f}\n'
        txt += f'multy = {mlty:5.1f} offy = {plusy:7.1f}'
        self._update_and_emit(txt, orbx, orby)