def init_entry_dialog(self): from qtvcp.widgets.dialog_widget import EntryDialog w = self.QTVCP_INSTANCE_ w.entryDialog_ = EntryDialog() w.entryDialog_.hal_init(HAL_NAME='') w.entryDialog_.soft_keyboard_option = self._entryDialogSoftkey w.entryDialog_.overlay_color = self._entryDialogColor
def init_entry_dialog(self): from qtvcp.widgets.dialog_widget import EntryDialog w = self.QTVCP_INSTANCE_ w.entryDialog_ = EntryDialog() w.entryDialog_.hal_init(self.HAL_GCOMP_, self.HAL_NAME_, w.entryDialog_, w, w.PATHS, self.PREFS_) w.entryDialog_.overlay_color = self._entryDialogColor
def __init__(self, parent=None): super(AxisToolButton, self).__init__(parent) self._joint = 0 self._last = 0 self._block_signal = False self._halpin_option = True SettingMenu = QMenu() exitButton = QAction(QIcon('exit24.png'), 'Zero', self) exitButton.triggered.connect(self.Zero) SettingMenu.addAction(exitButton) setlowButton = QAction(QIcon('exit24.png'), 'Set', self) setlowButton.triggered.connect(self.SetOrigin) SettingMenu.addAction(setlowButton) setlowButton = QAction(QIcon('exit24.png'), 'Divide By 2', self) setlowButton.triggered.connect(self.Divide) SettingMenu.addAction(setlowButton) setlowButton = QAction(QIcon('exit24.png'), 'Set To Last', self) setlowButton.triggered.connect(self.Last) SettingMenu.addAction(setlowButton) self.setMenu(SettingMenu) self.clicked.connect(self.SelectAxis) self.dialog = EntryDialog()
def __init__(self, parent=None): super(SystemToolButton, self).__init__(parent) self._joint = 0 self._last = 0 self._block_signal = False self._auto_label_flag = True SettingMenu = QMenu(self) for system in ('G54', 'G55', 'G56', 'G57', 'G58', 'G59', 'G59.1', 'G59.2', 'G59.3'): Button = QAction(QIcon('exit24.png'), system, self) Button.triggered.connect(self[system.replace('.', '_')]) SettingMenu.addAction(Button) self.setMenu(SettingMenu) self.dialog = EntryDialog()
def __init__(self, parent=None): super(AxisToolButton, self).__init__(parent) self._joint = 0 self._last = 0 self._block_signal = False self._halpin_option = True SettingMenu = QMenu() exitButton = QAction(QIcon('exit24.png'), 'Zero', self) exitButton.triggered.connect(self.Zero) SettingMenu.addAction(exitButton) setlowButton = QAction(QIcon('exit24.png'), 'Set', self) setlowButton.triggered.connect(self.SetOrigin) SettingMenu.addAction(setlowButton) setlowButton = QAction(QIcon('exit24.png'), 'Divide By 2', self) setlowButton.triggered.connect(self.Divide) SettingMenu.addAction(setlowButton) setlowButton = QAction(QIcon('exit24.png'), 'Set To Last', self) setlowButton.triggered.connect(self.Last) SettingMenu.addAction(setlowButton) self.setMenu(SettingMenu) self.clicked.connect(self.SelectAxis) self.dialog = EntryDialog()
class AxisToolButton(QToolButton, _HalWidgetBase): def __init__(self, parent=None): super(AxisToolButton, self).__init__(parent) self._joint = 0 self._last = 0 self._block_signal = False self._halpin_option = True SettingMenu = QMenu() exitButton = QAction(QIcon('exit24.png'), 'Zero', self) exitButton.triggered.connect(self.Zero) SettingMenu.addAction(exitButton) setlowButton = QAction(QIcon('exit24.png'), 'Set', self) setlowButton.triggered.connect(self.SetOrigin) SettingMenu.addAction(setlowButton) setlowButton = QAction(QIcon('exit24.png'), 'Divide By 2', self) setlowButton.triggered.connect(self.Divide) SettingMenu.addAction(setlowButton) setlowButton = QAction(QIcon('exit24.png'), 'Set To Last', self) setlowButton.triggered.connect(self.Last) SettingMenu.addAction(setlowButton) self.setMenu(SettingMenu) self.clicked.connect(self.SelectAxis) self.dialog = EntryDialog() #self.setPopupMode(QToolButton.DelayedPopup) def _hal_init(self): self.dialog.hal_init(self.HAL_GCOMP_, self.HAL_NAME_, self, self.QTVCP_INSTANCE_, self.PATHS_, self.PREFS_) def homed_on_test(): return (STATUS.machine_is_on() and (STATUS.is_all_homed() or INFO.NO_HOME_REQUIRED)) STATUS.connect('state-off', lambda w: self.setEnabled(False)) STATUS.connect('state-estop', lambda w: self.setEnabled(False)) STATUS.connect('interp-idle', lambda w: self.setEnabled(homed_on_test())) STATUS.connect('interp-run', lambda w: self.setEnabled(False)) STATUS.connect('all-homed', lambda w: self.setEnabled(True)) STATUS.connect('not-all-homed', lambda w, data: self.setEnabled(False)) STATUS.connect('interp-paused', lambda w: self.setEnabled(True)) STATUS.connect('axis-selection-changed', lambda w, x, data: self.ChangeState(data)) if self._halpin_option: self.hal_pin = self.HAL_GCOMP_.newpin(str(self.HAL_NAME_), hal.HAL_BIT, hal.HAL_OUT) def Zero(self): axis, now = self._a_from_j(self._joint) if axis: self._last = now ACTION.SET_AXIS_ORIGIN(axis, 0) STATUS.emit('update-machine-log', 'Zeroed Axis %s' % axis, 'TIME') def SetOrigin(self): axis, now = self._a_from_j(self._joint) if axis: num = self.dialog.showdialog() if num is None: return self._last = now ACTION.SET_AXIS_ORIGIN(axis, num) STATUS.emit('update-machine-log', 'Set Origin of Axis %s to %f' % (axis, num), 'TIME') def Divide(self): axis, now = self._a_from_j(self._joint) if axis: self._last = now try: x = now / 2.0 ACTION.SET_AXIS_ORIGIN(axis, x) text = 'Divided Axis %s in Half - %f' % (axis, x) STATUS.emit('update-machine-log', text, 'TIME') except ZeroDivisionError: pass def Last(self): axis, now = self._a_from_j(self._joint) if axis: ACTION.SET_AXIS_ORIGIN(axis, self._last) text = 'Reset Axis %s from %f to Last Value: %f' % (axis, now, self._last) STATUS.emit('update-machine-log', text, 'TIME') self._last = now def _a_from_j(self, jnum): j = "XYZABCUVW" try: axis = j[self._joint] except IndexError: LOG.error("can't zero origin for specified joint {}".format( self.joint_number)) return None, None p, r, d = STATUS.get_position() return axis, r[self._joint] def SelectAxis(self): if self._block_signal: return if self.isChecked() == True: ACTION.SET_SELECTED_AXIS(self._joint) self.hal_pin.set(self.isChecked()) def ChangeState(self, joint): if int(joint) != self._joint: self._block_signal = True self.setChecked(False) self._block_signal = False self.hal_pin.set(False) ######################################################################### # This is how designer can interact with our widget properties. # designer will show the pyqtProperty properties in the editor # it will use the get set and reset calls to do those actions # ######################################################################## def set_joint(self, data): self._joint = data def get_joint(self): return self._joint def reset_joint(self): self._joint = -1 def set_halpin_option(self, value): self._halpin_option = value def get_halpin_option(self): return self._halpin_option def reset_halpin_option(self): self._halpin_option = True joint_number = pyqtProperty(int, get_joint, set_joint, reset_joint) halpin_option = pyqtProperty(bool, get_halpin_option, set_halpin_option, reset_halpin_option)
class AxisToolButton(QToolButton, _HalWidgetBase): def __init__(self, parent=None): super(AxisToolButton, self).__init__(parent) self._joint = 0 self._last = 0 self._block_signal = False self._halpin_option = True SettingMenu = QMenu() exitButton = QAction(QIcon('exit24.png'), 'Zero', self) exitButton.triggered.connect(self.Zero) SettingMenu.addAction(exitButton) setlowButton = QAction(QIcon('exit24.png'), 'Set', self) setlowButton.triggered.connect(self.SetOrigin) SettingMenu.addAction(setlowButton) setlowButton = QAction(QIcon('exit24.png'), 'Divide By 2', self) setlowButton.triggered.connect(self.Divide) SettingMenu.addAction(setlowButton) setlowButton = QAction(QIcon('exit24.png'), 'Set To Last', self) setlowButton.triggered.connect(self.Last) SettingMenu.addAction(setlowButton) self.setMenu(SettingMenu) self.clicked.connect(self.SelectAxis) self.dialog = EntryDialog() #self.setPopupMode(QToolButton.DelayedPopup) def _hal_init(self): self.dialog.hal_init(self.HAL_GCOMP_, self.HAL_NAME_ ,self,self.QTVCP_INSTANCE_,self.PATHS_, self.PREFS_) def homed_on_test(): return (STATUS.machine_is_on() and (STATUS.is_all_homed() or INFO.NO_HOME_REQUIRED)) STATUS.connect('state-off', lambda w: self.setEnabled(False)) STATUS.connect('state-estop', lambda w: self.setEnabled(False)) STATUS.connect('interp-idle', lambda w: self.setEnabled(homed_on_test())) STATUS.connect('interp-run', lambda w: self.setEnabled(False)) STATUS.connect('all-homed', lambda w: self.setEnabled(True)) STATUS.connect('not-all-homed', lambda w, data: self.setEnabled(False)) STATUS.connect('interp-paused', lambda w: self.setEnabled(True)) STATUS.connect('axis-selection-changed', lambda w,x,data: self.ChangeState(data)) if self._halpin_option: self.hal_pin = self.HAL_GCOMP_.newpin(str(self.HAL_NAME_), hal.HAL_BIT, hal.HAL_OUT) def Zero(self): axis, now = self._a_from_j(self._joint) if axis: self._last = now ACTION.SET_AXIS_ORIGIN(axis, 0) STATUS.emit('update-machine-log', 'Zeroed Axis %s' % axis, 'TIME') def SetOrigin(self): axis, now = self._a_from_j(self._joint) if axis: num = self.dialog.showdialog() if num is None: return self._last = now ACTION.SET_AXIS_ORIGIN(axis, num) STATUS.emit('update-machine-log', 'Set Origin of Axis %s to %f' %(axis, num), 'TIME') def Divide(self): axis, now = self._a_from_j(self._joint) if axis: self._last = now try: x = now/2.0 ACTION.SET_AXIS_ORIGIN(axis, x) text = 'Divided Axis %s in Half - %f'% (axis, x) STATUS.emit('update-machine-log', text, 'TIME') except ZeroDivisionError: pass def Last(self): axis, now = self._a_from_j(self._joint) if axis: ACTION.SET_AXIS_ORIGIN(axis, self._last) text = 'Reset Axis %s from %f to Last Value: %f' %(axis, now, self._last) STATUS.emit('update-machine-log', text, 'TIME') self._last = now def _a_from_j(self, jnum): j = "XYZABCUVW" try: axis = j[self._joint] except IndexError: LOG.error("can't zero origin for specified joint {}".format(self.joint_number)) return None, None p,r,d = STATUS.get_position() return axis, r[self._joint] def SelectAxis(self): if self._block_signal: return if self.isChecked() == True: ACTION.SET_SELECTED_AXIS(self._joint) self.hal_pin.set(self.isChecked()) def ChangeState(self, joint): if int(joint) != self._joint: self._block_signal = True self.setChecked(False) self._block_signal = False self.hal_pin.set(False) ######################################################################### # This is how designer can interact with our widget properties. # designer will show the pyqtProperty properties in the editor # it will use the get set and reset calls to do those actions # ######################################################################## def set_joint(self, data): self._joint = data def get_joint(self): return self._joint def reset_joint(self): self._joint = -1 def set_halpin_option(self, value): self._halpin_option = value def get_halpin_option(self): return self._halpin_option def reset_halpin_option(self): self._halpin_option = True joint_number = pyqtProperty(int, get_joint, set_joint, reset_joint) halpin_option = pyqtProperty(bool, get_halpin_option, set_halpin_option, reset_halpin_option)