Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QtVcp: adds tool chooser widget and dialog, add new logging severity and MachineLog view. #3351

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/src/gui/images/qtvcp_machinelog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/gui/images/qtvcp_machinelog_plain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/gui/images/qtvcp_toolChooser.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 46 additions & 3 deletions docs/src/gui/qtvcp-widgets.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@ It is a comma separated list of keyword and data:
[[sub:qtvcp:widgets:operatorvalueline]]
=== `OperatorValueLine` - Operator Value Line Entry Widget

The operator enters values into this widget, which will be applied to a template and then optionally issued to the MDI either immediately or applied at a later time. The widget supports the optional popup calculator or keyboard for touchscreen-friendly entry.
The operator enters values into this widget, which will be applied to a template and then optionally issued to the MDI either immediately or applied at a later time. The widget supports the optional popup calculator, keyboard, or tool chooser for touchscreen-friendly entry by setting the `dialog_keyboard_option`. To change which type of dialog is presented, edit the `dialog_code_option`.

image::images/qtvcp_operator_value.png["QtVCP OperatorValueLine",scale="25%"]

Expand Down Expand Up @@ -2642,11 +2642,54 @@ When using `STATUS` 's `request-dialog` function, the default launch name is *`T

It is based on PyQt's _QDialog_.

[[sub:qtvcp:widgets:toolchooserdialog]]
=== `ToolChooserDialog` - Tool Chooser Dialog Widget

.QtVCP `ToolChooserDialog`: Tool Chooser Dialog Widget
image::images/qtvcp_toolChooser.png["QtVCP `ToolChooserDialog`: Tool Chooser Dialog Widget",scale="25%"]

This widget allows the operator to select one of the tools defined in the tool table. If a tool is selected and 'Apply' is pressed or the tool is double-clicked, the dialog will return the tool number selected. This can be used in conjunction with the `OperatorValueLine` widget to create a tool change widget, for example.

If there is an Focus Overlay widget present, it will signal it to display.

When using `STATUS` 's `request-dialog` function, the default launch name is *`TOOLCHOOSER`*.

It is based on PyQt's _QDialog_.


[[sub:qtvcp:widgets:machinelog]]
=== `MachineLog` - Machine Events Journal Display Widget

//TODO MachineLog widget capture/example
FIXME MachineLog documentation
This widget displays various *log event messages* that have been output by the system during the current session. This includes informational messages as well as errors.

.QtVCP `MachineLog`: Machine Events Log in `machine_log` (plain) mode
image::images/qtvcp_machinelog_plain.png["QtVCP `MachineLog`: Machine Log Widget",scale="25%"]


.QtVCP `MachineLog`: Machine Events Log in `machine_log_severity` mode
image::images/qtvcp_machinelog.png["QtVCP `MachineLog`: Machine Log Widget",scale="25%"]

Two distinct types of logs may be displayed:

- machine log (plain text or severity highlighted)
- integrator log (plain text only)

The type of log shown by the widget is controlled by the option properties of the widget. By selecting `machine_log_option` or `integrator_log_option` the appropriate log will be displayed. These options will display plain styled logs in a Qt `QTextEdit` widget.

Additionally, there is a `machine_log_severity_option` property that may be chosen that will display the machine log in a variety of colors depending on the severity of the message, by using a `QTableWidget`. The colors may be configured with the properties of the widget.

==== Emitting Log messages with Severity

Severity is conveyed via the `option` value sent along with the `STATUS` signal called `update-machine-log`. The `option` parameter is a comma-delimited list, containing typically

```
text = 'an error has occurred.'
STATUS.emit('update-machine-log', text, 'TIME,ERROR')
```

==== Clearing the Log

The log may be cleared by calling the `clear()` method of the widget.

[[sub:qtvcp:widgets:macrotabdialog]]
=== `MacroTabDialog` - Macro Launch Dialog Widget
Expand Down
6 changes: 3 additions & 3 deletions lib/python/qtvcp/lib/machine_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def log_it(self, w, message, option=None):
return
try:
message = message.rstrip('\n')
if option == 'TIME':
if 'TIME' in option:
self.log_message_time(message)
elif option == 'DATE':
elif 'DATE' in option:
self.log_message_date(message)
elif option == 'INITIAL':
elif 'INITIAL' in option:
self.initial_greeting()
else:
self.log_message(message)
Expand Down
11 changes: 8 additions & 3 deletions lib/python/qtvcp/lib/toolbar_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ def update_selected(line):
function = (self.actOnSystemShutdown)
elif action == 'tooloffsetdialog':
function = (self.actOnToolOffsetDialog)
elif action == 'toolchooserdialog':
function = (self.actOnToolChooserDialog)
elif action == 'originoffsetdialog':
function = (self.actOnOriginOffsetDialog)
elif action == 'calculatordialog':
Expand Down Expand Up @@ -584,13 +586,16 @@ def actOnRunFromLine(self, widget, state=False):
STATUS.emit('dialog-request', {'NAME': 'RUNFROMLINE', 'LINE':self.selected_line})
#ACTION.RUN(self.selected_line)

def actOnToolOffsetDialog(self, wudget, state=None):
def actOnToolChooserDialog(self, widget, state=None):
STATUS.emit('dialog-request', {'NAME': 'TOOLCHOOSER'})

def actOnToolOffsetDialog(self, widget, state=None):
STATUS.emit('dialog-request', {'NAME': 'TOOLOFFSET'})

def actOnOriginOffsetDialog(self, wudget, state=None):
def actOnOriginOffsetDialog(self, widget, state=None):
STATUS.emit('dialog-request', {'NAME': 'ORIGINOFFSET'})

def actOnCalculatorDialog(self, wudget, state=None):
def actOnCalculatorDialog(self, widget, state=None):
STATUS.emit('dialog-request', {'NAME': 'CALCULATOR'})

def actOnAlphaMode(self, widget, state):
Expand Down
3 changes: 2 additions & 1 deletion lib/python/qtvcp/plugins/actionbutton_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ def buildtab1(self):
('CamView Dialog', ['camview_dialog', 0], []),
('Machine Log Dialog', ['machine_log_dialog', 0], []),
('Origin Offset Dialog', ['origin_offset_dialog', 0], []),
('Tool Offset Dialog', ['tool_offset_dialog', 0], []))
('Tool Offset Dialog', ['tool_offset_dialog', 0], []),
('Tool Chooser Dialog', ['tool_chooser_dialog', 0], []))
node_4 = (('Launch HALmeter', ['launch_halmeter', 0], []),
('Launch Status', ['launch_status', 0], []),
('Launch HALshow', ['launch_halshow', 0], []),
Expand Down
46 changes: 46 additions & 0 deletions lib/python/qtvcp/plugins/dialog_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,52 @@ def includeFile(self):
return "qtvcp.widgets.dialog_widget"


###############################################################################
# ToolChooser Dialog
###############################################################################
class ToolChooserDialogPlugin(QPyDesignerCustomWidgetPlugin):

def __init__(self, parent=None):
super(ToolChooserDialogPlugin, self).__init__(parent)

self.initialized = False

def initialize(self, core):
if self.initialized:
return

self.initialized = True

def isInitialized(self):
return self.initialized

def createWidget(self, parent):
return ToolChooserDialog(parent)

def name(self):
return "ToolChooserDialog"

def group(self):
return "Linuxcnc - Dialogs"

def icon(self):
return QIcon(QPixmap(ICON.get_path('Toolchooserdialog')))

def toolTip(self):
return "Tool Chooser Dialog"

def whatsThis(self):
return ""

def isContainer(self):
return False

def domXml(self):
return '<widget class="ToolChooserDialog" name="toolchooserdialog" />\n'

def includeFile(self):
return "qtvcp.widgets.dialog_widget"

###############################################################################
# ToolOffset Dialog
###############################################################################
Expand Down
45 changes: 45 additions & 0 deletions lib/python/qtvcp/plugins/widgets_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from qtvcp.widgets.dro_widget import DROLabel
from qtvcp.widgets.mdi_line import MDILine
from qtvcp.widgets.operator_value_line import OperatorValueLine
from qtvcp.widgets.tool_chooser import ToolChooser
from qtvcp.widgets.mdi_history import MDIHistory
from qtvcp.widgets.mdi_touchy import MDITouchy
from qtvcp.widgets.gcode_editor import GcodeEditor, GcodeDisplay
Expand Down Expand Up @@ -108,6 +109,50 @@ def includeFile(self):
return "qtvcp.widgets.mdi_line"


####################################
# Tool Chooser
####################################
class ToolChooserPlugin(QPyDesignerCustomWidgetPlugin):
def __init__(self, parent=None):
super(ToolChooserPlugin, self).__init__(parent)
self.initialized = False

def initialize(self, formEditor):
if self.initialized:
return
self.initialized = True

def isInitialized(self):
return self.initialized

def createWidget(self, parent):
return ToolChooser(parent)

def name(self):
return "ToolChooser"

def group(self):
return "Linuxcnc - Controller"

def icon(self):
return QtGui.QIcon(QtGui.QPixmap(ICON.get_path('toolchooser')))

def toolTip(self):
return "Tool chooser Widget"

def whatsThis(self):
return ""

def isContainer(self):
return True

def domXml(self):
return '<widget class="ToolChooser" name="toolchooser" />\n'

def includeFile(self):
return "qtvcp.widgets.tool_chooser"


####################################
# Operator Value edit line
####################################
Expand Down
14 changes: 10 additions & 4 deletions lib/python/qtvcp/qt_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def SAVE_PROGRAM(self, source, fname, ending = '.ngc'):
try:
outfile = open(npath, 'w')
outfile.write(source)
STATUS.emit('update-machine-log', 'Saved: ' + npath, 'TIME')
STATUS.emit('update-machine-log', 'Saved: ' + npath, 'TIME,SUCCESS')
except Exception as e:
print(e)
STATUS.emit('error', linuxcnc.OPERATOR_ERROR, e)
Expand Down Expand Up @@ -728,9 +728,15 @@ def SHUT_SYSTEM_DOWN_NOW(self):
subprocess.call('shutdown now')

def UPDATE_MACHINE_LOG(self, text, option=None):
if option not in ('TIME', 'DATE', 'DELETE', None):
LOG.warning("Machine_log option not recognized: {}".format(option))
STATUS.emit('update-machine-log', text, option)
valid_options = {'INITIAL', 'TIME', 'DATE', 'DELETE', 'CRITICAL', 'ERROR', 'WARNING', 'SUCCESS', 'DEBUG'}
options = set(option.split(',')) if option else {None}

if not options.issubset(valid_options):
invalid_options = options - valid_options
LOG.warning("Machine_log option(s) not recognized: {}".format(', '.join(invalid_options)))
options = None

STATUS.emit('update-machine-log', text, options)

def CALL_DIALOG(self, command):
try:
Expand Down
2 changes: 1 addition & 1 deletion lib/python/qtvcp/widgets/action_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ def action(self, state=None):
except IndexError:
LOG.error("can't zero origin for specified joint {}".format(self.joint))
ACTION.SET_AXIS_ORIGIN(axis, 0)
STATUS.emit('update-machine-log', 'Zeroed Axis %s' % axis, 'TIME')
STATUS.emit('update-machine-log', 'Zeroed Axis %s' % axis, 'TIME,SUCCESS')
elif self.zero_g5x:
ACTION.ZERO_G5X_OFFSET(0)
elif self.zero_g92:
Expand Down
12 changes: 6 additions & 6 deletions lib/python/qtvcp/widgets/axis_tool_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def Zero(self):
axis, now = self._a_from_j(self._axis)
if axis:
ACTION.SET_AXIS_ORIGIN(axis, 0)
STATUS.emit('update-machine-log', 'Zeroed Axis %s' % axis, 'TIME')
STATUS.emit('update-machine-log', 'Zeroed Axis %s' % axis, 'TIME,SUCCESS')

def SetOrigin(self):
axis, now = self._a_from_j(self._axis)
Expand All @@ -168,7 +168,7 @@ def return_value(self, w, message):
LOG.debug('message return:{}'.format (message))
axis = message.get('AXIS')
ACTION.SET_AXIS_ORIGIN(axis, num)
STATUS.emit('update-machine-log', 'Set Origin of Axis %s to %f' %(axis, num), 'TIME')
STATUS.emit('update-machine-log', 'Set Origin of Axis %s to %f' %(axis, num), 'TIME,SUCCESS')

def Divide(self):
axis, now = self._a_from_j(self._axis)
Expand All @@ -177,7 +177,7 @@ def Divide(self):
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')
STATUS.emit('update-machine-log', text, 'TIME,SUCCESS')
except ZeroDivisionError:
pass

Expand All @@ -187,19 +187,19 @@ def Last(self):
last = ACTION.GET_LAST_RECORDED_ORIGIN(axis)
ACTION.SET_AXIS_ORIGIN(axis, last)
text = 'Reset Axis %s from %f to Last Value: %f' %(axis, now, last)
STATUS.emit('update-machine-log', text, 'TIME')
STATUS.emit('update-machine-log', text, 'TIME,SUCCESS')

def Home(self):
#axis, now = self._a_from_j(self._axis)
#if axis:
ACTION.SET_MACHINE_HOMING(self._joint)
STATUS.emit('update-machine-log', 'Homed Axis %s' % self._joint, 'TIME')
STATUS.emit('update-machine-log', 'Homed Axis %s' % self._joint, 'TIME,SUCCESS')

def Unhome(self):
#axis, now = self._a_from_j(self._axis)
#if axis:
ACTION.SET_MACHINE_UNHOMED(self._joint)
STATUS.emit('update-machine-log', 'Unhomed Axis %s' % self._joint, 'TIME')
STATUS.emit('update-machine-log', 'Unhomed Axis %s' % self._joint, 'TIME,WARNING')

def goToG53(self):
ACTION.CALL_MDI('G53 G0 {}0'.format(self._axis))
Expand Down
2 changes: 1 addition & 1 deletion lib/python/qtvcp/widgets/basic_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def start_probe(self, cmd):
if t != STATUS.get_current_tool():
msg = "Probe tool # {}. not mounted in spindle".format(t)
if not self.set_statusbar(msg,CRITICAL):
STATUS.emit('update-machine-log', msg, 'TIME')
STATUS.emit('update-machine-log', msg, 'TIME,CRITICAL')
ACTION.SET_ERROR_MESSAGE(msg)
return

Expand Down
Loading
Loading