def __norm_path(self) -> None: """Normalize current path.""" scale, ok = QInputDialog.getDouble(self, "Scale", "Length of unit vector:", 60, 0.01, 1000, 2) if ok: self.set_path(norm_path(self.current_path(), scale))
def point_alignment(self) -> None: """Alignment function.""" selected_rows = self.entities_point.selected_rows() if not selected_rows: QMessageBox.warning(self, "Points alignment", "No selected points with this operation.") return if self.alignment_mode == 0: axis = "x" elif self.alignment_mode == 1: axis = "y" else: raise ValueError("no such alignment option") value, ok = QInputDialog.getDouble( self, f"Set {axis} axis", f"Align the selected points into {axis} axis:", 0, -9999, 9999, 4) if not ok: return self.command_stack.beginMacro(f"Align points with {axis}") for row in selected_rows: args = self.entities_point.row_data(row) if self.alignment_mode == 0: args.x = value elif self.alignment_mode == 1: args.y = value else: raise ValueError("no such alignment option") self.command_stack.push( EditPointTable(row, self.vpoint_list, self.vlink_list, self.entities_point, self.entities_link, args)) self.command_stack.endMacro()
def _set_check_current(self): self.ok_ps.clear() self.nok_ps.clear() devices = self._get_selected_ps() if not devices: return value, ok = QInputDialog.getDouble(self, "Setpoint Input", "Insert current setpoint: ") if not ok: return task0 = CreateTesters(devices, parent=self) task1 = SetCurrent(devices, value=value, parent=self) task2 = CheckCurrent(devices, value=value, parent=self) task2.itemDone.connect(self._log) tasks = [task0, task1, task2] labels = [ 'Connecting to devices...', 'Setting current...', 'Checking current value...' ] dlg = ProgressDialog(labels, tasks, self) dlg.exec_()
def dialogPageStep(self, value): """Show dialog to set pageStep.""" mini = 10/self._scale maxi = (self.maximum - self.minimum) d, okPressed = QInputDialog.getDouble(self, "Page Step", "Page Step:", self.pageStep, mini, maxi, self._decimals) if okPressed: self.setPageStep(d)
def dialogSingleStep(self, value): """Show dialog to set singleStep.""" mini = 1/self._scale maxi = (self.maximum - self.minimum)/10 d, okPressed = QInputDialog.getDouble(self, "Single Step", "Single Step:", self.singleStep, mini, maxi, self._decimals) if okPressed: self.setSingleStep(d)
def _set_setpoint(self): """Set current setpoint for every visible widget.""" dlg = QInputDialog(self) dlg.setLocale(QLocale(QLocale.English)) new_value, ok = dlg.getDouble(self, "New setpoint", "Value") if ok: for dclink in self.dclink_widgets: sp = dclink.setpoint.sp_lineedit sp.setText(str(new_value)) try: sp.send_value() except TypeError: pass
def _set_current_sp(self): """Set current setpoint for every visible widget.""" dlg = QInputDialog(self) dlg.setLocale(QLocale(QLocale.English)) new_value, ok = dlg.getDouble(self, "Insert current setpoint", "Value") if ok: for key, widget in self.ps_widgets_dict.items(): if key in self.filtered_widgets: sp = widget.setpoint.sp_lineedit sp.setText(str(new_value)) try: sp.send_value() except TypeError: pass
def _applyconfig(self): sender_text = self.sender().text() if 'Standby' in sender_text: config_name = 'standby' elif 'TurnOff' in sender_text: config_name = 'turnoff' ans = QMessageBox.question( self, 'Are you Sure?', "Do you really want to apply the Configuration '" + config_name + "' to the machine?", QMessageBox.Yes, QMessageBox.Cancel) if ans != QMessageBox.Yes: return current, ok = QInputDialog.getDouble( self, 'Enter value: ', 'Enter FilaPS standby current [A]\n' 'or cancel to not set it: ', value=0.7, min=0.0, max=1.5, decimals=3) if ok: fila_pv = _PV(_prefix + 'LI-01:EG-FilaPS:currentoutsoft', connection_timeout=0.05) fila_pv.get() # force connection if fila_pv.connected: fila_pv.put(current) else: QMessageBox.warning( self, 'Message', 'Could not connect to LI-01:EG-FilaPS!') client = ConfigDBClient() WinClass = create_window_from_widget( SelectAndApplyPVsWidget, 'Select PVs to Apply Standby') wind = WinClass(self, client) wind.widget.settingFinished.connect(wind.close) wind.widget.fill_config('global_config', config_name) wind.exec_()
def cmd_set_current(self): """Set power supplies current.""" value, res = QInputDialog.getDouble( self._parent, "Insert current setpoint", "Value") if res: self.set_values('Current-SP', value)