dodalem sidebar z przyciskami
czesc relative jeszcze nie dziala
This commit is contained in:
@@ -3,10 +3,12 @@ import linuxcnc
|
|||||||
|
|
||||||
from qtpy import uic
|
from qtpy import uic
|
||||||
from qtpy.QtCore import Qt
|
from qtpy.QtCore import Qt
|
||||||
from qtpy.QtWidgets import QWidget
|
from qtpy.QtWidgets import QWidget, QPushButton
|
||||||
|
|
||||||
|
from qtpyvcp.actions import machine, machine_actions
|
||||||
from qtpyvcp.plugins import getPlugin
|
from qtpyvcp.plugins import getPlugin
|
||||||
from qtpyvcp.utilities import logger
|
from qtpyvcp.utilities import logger
|
||||||
|
from widgets.conversational.float_line_edit import FloatLineEdit
|
||||||
|
|
||||||
LOG = logger.getLogger(__name__)
|
LOG = logger.getLogger(__name__)
|
||||||
|
|
||||||
@@ -14,6 +16,7 @@ STATUS = getPlugin('status')
|
|||||||
TOOL_TABLE = getPlugin('tooltable')
|
TOOL_TABLE = getPlugin('tooltable')
|
||||||
|
|
||||||
INI_FILE = linuxcnc.ini(os.getenv('INI_FILE_NAME'))
|
INI_FILE = linuxcnc.ini(os.getenv('INI_FILE_NAME'))
|
||||||
|
CMD = linuxcnc.command()
|
||||||
|
|
||||||
|
|
||||||
class UserTab(QWidget):
|
class UserTab(QWidget):
|
||||||
@@ -21,3 +24,131 @@ class UserTab(QWidget):
|
|||||||
super(UserTab, self).__init__(parent)
|
super(UserTab, self).__init__(parent)
|
||||||
ui_file = os.path.splitext(os.path.basename(__file__))[0] + ".ui"
|
ui_file = os.path.splitext(os.path.basename(__file__))[0] + ".ui"
|
||||||
uic.loadUi(os.path.join(os.path.dirname(__file__), ui_file), self)
|
uic.loadUi(os.path.join(os.path.dirname(__file__), ui_file), self)
|
||||||
|
|
||||||
|
STATUS.on.notify(self._update_controls)
|
||||||
|
STATUS.all_axes_homed.notify(self._update_controls)
|
||||||
|
|
||||||
|
STATUS.g5x_index.notify(self.update_wcs_label)
|
||||||
|
self.update_wcs_label()
|
||||||
|
|
||||||
|
# self.btn_wcs_x.clicked.connect(lambda: self.move_wcs(x=self.fle_wcs_x.value()))
|
||||||
|
# self.btn_wcs_y.clicked.connect(lambda: self.move_wcs(y=self.fle_wcs_y.value()))
|
||||||
|
# self.fle_wcs_x.editingFinished.connect(self._format_x)
|
||||||
|
|
||||||
|
self.edits: list[FloatLineEdit] = self.findChildren(FloatLineEdit)
|
||||||
|
|
||||||
|
for fle in self.edits:
|
||||||
|
fle.setEnabled(False)
|
||||||
|
fle.editingFinished.connect(self.format_float)
|
||||||
|
|
||||||
|
self.buttons: list[QPushButton] = self.findChildren(QPushButton)
|
||||||
|
|
||||||
|
for btn in self.buttons:
|
||||||
|
btn.setEnabled(False)
|
||||||
|
btn.clicked.connect(self.move_axis)
|
||||||
|
|
||||||
|
def format_float(self):
|
||||||
|
if not isinstance(self.sender(), FloatLineEdit):
|
||||||
|
return
|
||||||
|
|
||||||
|
w: FloatLineEdit = self.sender()
|
||||||
|
if w is None:
|
||||||
|
LOG.debug(f"fn _format_float, sender None")
|
||||||
|
return
|
||||||
|
LOG.debug(f"fn: _format_float, sender name: {w.objectName()}")
|
||||||
|
|
||||||
|
value = w.value()
|
||||||
|
fmt = w.format_string
|
||||||
|
val_fmt = fmt.format(value)
|
||||||
|
w.setText(val_fmt)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def update_wcs_label(self):
|
||||||
|
idx = STATUS.g5x_index
|
||||||
|
self.statuslabel_wcs.setText(f"WCS {idx}")
|
||||||
|
# 'G54' if ch[0] == 1 else 'G55' if ch[0] == 2 else 'G56' if ch[0] == 3 else 'none'
|
||||||
|
|
||||||
|
def move_x(self):
|
||||||
|
machine_actions.jog.axis(axis='x', direction=1, distance=0.5)
|
||||||
|
LOG.debug(f"fn: move_x. fle_wcs_x:{self.fle_wcs_x.value()}")
|
||||||
|
|
||||||
|
|
||||||
|
def move_axis(self):
|
||||||
|
if not isinstance(self.sender(), QPushButton):
|
||||||
|
return
|
||||||
|
|
||||||
|
sender: QPushButton = self.sender()
|
||||||
|
btn_name = sender.objectName()
|
||||||
|
LOG.debug(f"fn: move_axis. sender:{btn_name}")
|
||||||
|
|
||||||
|
if "abs" in btn_name:
|
||||||
|
dest_x = self.fle_abs_x.value()
|
||||||
|
dest_y = self.fle_abs_y.value()
|
||||||
|
dest_z = self.fle_abs_z.value()
|
||||||
|
if "_x" in btn_name:
|
||||||
|
self.move_wcs(x=dest_x, abs=True)
|
||||||
|
return
|
||||||
|
if "_y" in btn_name:
|
||||||
|
self.move_wcs(y=dest_y, abs=True)
|
||||||
|
return
|
||||||
|
if "_z" in btn_name:
|
||||||
|
self.move_wcs(z=dest_z, abs=True)
|
||||||
|
return
|
||||||
|
self.move_wcs(dest_x, dest_y, dest_z, abs=True)
|
||||||
|
LOG.debug(f"fn: move_wcs[ABS] x:{dest_x}, y:{dest_y}, z:{dest_z}")
|
||||||
|
|
||||||
|
if "wcs" in btn_name:
|
||||||
|
dest_x = self.fle_wcs_x.value()
|
||||||
|
dest_y = self.fle_wcs_y.value()
|
||||||
|
dest_z = self.fle_wcs_z.value()
|
||||||
|
if "_x" in btn_name:
|
||||||
|
self.move_wcs(x=dest_x)
|
||||||
|
return
|
||||||
|
if "_y" in btn_name:
|
||||||
|
self.move_wcs(y=dest_y)
|
||||||
|
return
|
||||||
|
if "_z" in btn_name:
|
||||||
|
self.move_wcs(z=dest_z)
|
||||||
|
return
|
||||||
|
|
||||||
|
self.move_wcs(dest_x, dest_y, dest_z)
|
||||||
|
LOG.debug(f"fn: move_wcs[WCS] x:{dest_x}, y:{dest_y}, z:{dest_z}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def move_wcs(self, x=None, y=None, z=None, abs=False):
|
||||||
|
|
||||||
|
if abs:
|
||||||
|
mdi_cmd = "G53 G0"
|
||||||
|
else:
|
||||||
|
mdi_cmd = "G0"
|
||||||
|
|
||||||
|
if x is not None:
|
||||||
|
mdi_cmd += f" X{x}"
|
||||||
|
if y is not None:
|
||||||
|
mdi_cmd += f" Y{y}"
|
||||||
|
if z is not None:
|
||||||
|
mdi_cmd += f" Z{z}"
|
||||||
|
|
||||||
|
LOG.debug(f"fn: move_wcs. MDI:{mdi_cmd}")
|
||||||
|
machine_actions.issue_mdi(mdi_cmd)
|
||||||
|
|
||||||
|
def _machine_ready(self) -> bool:
|
||||||
|
LOG.debug(f"fn: machine_ready, on:{STATUS.on()}")
|
||||||
|
LOG.debug(f"fn: machine_ready, all_axes_homed:{STATUS.all_axes_homed()}")
|
||||||
|
return (
|
||||||
|
STATUS.on()
|
||||||
|
and STATUS.all_axes_homed()
|
||||||
|
)
|
||||||
|
|
||||||
|
def _update_controls(self, *args):
|
||||||
|
ready = self._machine_ready()
|
||||||
|
LOG.debug(f"Machine ready: {ready}")
|
||||||
|
|
||||||
|
for btn in self.buttons:
|
||||||
|
btn.setEnabled(ready)
|
||||||
|
|
||||||
|
for fle in self.edits:
|
||||||
|
fle.setEnabled(ready)
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,336 @@
|
|||||||
<property name="sidebar" stdset="0">
|
<property name="sidebar" stdset="0">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_abs">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QLabel{
|
||||||
|
color: rgb(238, 238, 236);
|
||||||
|
font: 16pt "Bebas Kai";
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>ABSOLUTE</string>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="FloatLineEdit" name="fle_abs_x">
|
||||||
|
<property name="text">
|
||||||
|
<string>1.1234</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="security" stdset="0">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rules" stdset="0">
|
||||||
|
<string>[{"name": "postion_x", "property": "Text", "expression": "ch[0]", "channels": [{"url": "position:abs?string&axis=x", "trigger": true}]}]</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_abs_x">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>GO X</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="FloatLineEdit" name="fle_abs_y">
|
||||||
|
<property name="text">
|
||||||
|
<string> 0.0000</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="rules" stdset="0">
|
||||||
|
<string>[{"name": "position_y", "property": "Text", "expression": "ch[0]", "channels": [{"url": "position:abs?string&axis=y", "trigger": true}]}]</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_abs_y">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>GO Y</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="FloatLineEdit" name="fle_abs_z">
|
||||||
|
<property name="text">
|
||||||
|
<string> 0.0000</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="rules" stdset="0">
|
||||||
|
<string>[{"name": "position_z", "property": "Text", "expression": "ch[0]", "channels": [{"url": "position:abs?string&axis=z", "trigger": true}]}]</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_abs_z">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>GO Z</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_abs_all">
|
||||||
|
<property name="text">
|
||||||
|
<string>GO XYZ</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="StatusLabel" name="statuslabel_wcs">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QLabel{
|
||||||
|
color: rgb(238, 238, 236);
|
||||||
|
font: 16pt "Bebas Kai";
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<property name="rules" stdset="0">
|
||||||
|
<string>[]</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="FloatLineEdit" name="fle_wcs_x">
|
||||||
|
<property name="text">
|
||||||
|
<string> 0.0000</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="security" stdset="0">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rules" stdset="0">
|
||||||
|
<string>[{"name": "postion_x", "property": "Text", "expression": "ch[0]", "channels": [{"url": "position:Relative?string&axis=x", "trigger": true}]}]</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_wcs_x">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>GO X</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
|
<item>
|
||||||
|
<widget class="FloatLineEdit" name="fle_wcs_y">
|
||||||
|
<property name="text">
|
||||||
|
<string> 0.0000</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="rules" stdset="0">
|
||||||
|
<string>[{"name": "position_y", "property": "Text", "expression": "ch[0]", "channels": [{"url": "position:Relative?string&axis=y", "trigger": true}]}]</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_wcs_y">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>GO Y</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="FloatLineEdit" name="fle_wcs_z">
|
||||||
|
<property name="text">
|
||||||
|
<string> 0.0000</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="rules" stdset="0">
|
||||||
|
<string>[{"name": "position_z", "property": "Text", "expression": "ch[0]", "channels": [{"url": "position:Relative?string&axis=z", "trigger": true}]}]</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_wcs_z">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>GO Z</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_wcs_all">
|
||||||
|
<property name="text">
|
||||||
|
<string>GO XYZ</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>StatusLabel</class>
|
||||||
|
<extends>QLabel</extends>
|
||||||
|
<header>qtpyvcp.widgets.display_widgets.status_label</header>
|
||||||
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>VCPLineEdit</class>
|
||||||
|
<extends>QLineEdit</extends>
|
||||||
|
<header>qtpyvcp.widgets.input_widgets.line_edit</header>
|
||||||
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>FloatLineEdit</class>
|
||||||
|
<extends>VCPLineEdit</extends>
|
||||||
|
<header>widgets.conversational.float_line_edit</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
Reference in New Issue
Block a user