Skip to content

Commit

Permalink
Added tooltip support for PostProcessor scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
mlampert authored and wwmayer committed Nov 2, 2016
1 parent da94fb5 commit 67e3b13
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 7 deletions.
25 changes: 25 additions & 0 deletions src/Mod/Path/PathScripts/PathJob.py
Expand Up @@ -125,6 +125,13 @@ def onChanged(self, obj, prop):
obj.Y_Min = current_post.CORNER_MIN['y']
obj.Z_Min = current_post.CORNER_MIN['z']

self.tooltip = None
self.tooltipArgs = None
if hasattr(current_post, "TOOLTIP"):
self.tooltip = current_post.TOOLTIP
if hasattr(current_post, "TOOLTIP_ARGS"):
self.tooltipArgs = current_post.TOOLTIP_ARGS

# def getToolControllers(self, obj):
# '''returns a list of ToolControllers for the current job'''
# controllers = []
Expand Down Expand Up @@ -249,6 +256,8 @@ def __init__(self):
if hasattr(o, "Shape"):
self.form.cboBaseObject.addItem(o.Name)

self.postProcessorDefaultTooltip = self.form.cboPostProcessor.toolTip()
self.postProcessorDefaultArgsTooltip = self.form.cboPostProcessorArgs.toolTip()

def accept(self):
self.getFields()
Expand All @@ -260,6 +269,17 @@ def reject(self):
FreeCADGui.Control.closeDialog()
FreeCAD.ActiveDocument.recompute()

def updateTooltips(self):
if hasattr(self.obj, "Proxy") and hasattr(self.obj.Proxy, "tooltip") and self.obj.Proxy.tooltip:
self.form.cboPostProcessor.setToolTip(self.obj.Proxy.tooltip)
if hasattr(self.obj.Proxy, "tooltipArgs") and self.obj.Proxy.tooltipArgs:
self.form.cboPostProcessorArgs.setToolTip(self.obj.Proxy.tooltipArgs)
else:
self.form.cboPostProcessorArgs.setToolTip(self.postProcessorDefaultArgsTooltip)
else:
self.form.cboPostProcessor.setToolTip(self.postProcessorDefaultTooltip)
self.form.cboPostProcessorArgs.setToolTip(self.postProcessorDefaultArgsTooltip)

def getFields(self):
'''sets properties in the object to match the form'''
if self.obj:
Expand Down Expand Up @@ -288,6 +308,8 @@ def getFields(self):
selObj = Draft.clone(selObj)
self.obj.Base = selObj

self.updateTooltips()

self.obj.Proxy.execute(self.obj)

def setFields(self):
Expand All @@ -302,6 +324,9 @@ def setFields(self):
self.form.cboPostProcessor.blockSignals(True)
self.form.cboPostProcessor.setCurrentIndex(postindex)
self.form.cboPostProcessor.blockSignals(False)
# make sure the proxy loads post processor script values and settings
self.obj.Proxy.onChanged(self.obj, "PostProcessor")
self.updateTooltips()
self.form.cboPostProcessorArgs.displayText = self.obj.PostProcessorArgs

for child in self.obj.Group:
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Path/PathScripts/centroid_post.py
Expand Up @@ -21,7 +21,8 @@
#* USA *
#* *
#***************************************************************************
''' example post for Centroid CNC mill'''
TOOLTIP=''' example post for Centroid CNC mill'''

import FreeCAD
import datetime
now = datetime.datetime.now()
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Path/PathScripts/comparams_post.py
Expand Up @@ -21,7 +21,8 @@
#* USA *
#* *
#***************************************************************************
''' Example Post, using Path.Commands instead of Path.toGCode strings for Path gcode output. '''
TOOLTIP=''' Example Post, using Path.Commands instead of Path.toGCode strings for Path gcode output. '''

import FreeCAD
import Path, PathScripts
from PathScripts import PostUtils
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/dumper_post.py
Expand Up @@ -22,7 +22,7 @@
# ***************************************************************************/


'''
TOOLTIP='''
Dumper is an extremely simple postprocessor file for the Path workbench. It is used
to dump the command list from one or more Path objects for simple inspection. This post
doesn't do any manipulation of the path and doesn't write anything to disk. It just
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/example_post.py
Expand Up @@ -22,7 +22,7 @@
# ***************************************************************************/


'''
TOOLTIP='''
This is an example postprocessor file for the Path workbench. It is used
to save a list of FreeCAD Path objects to a file.
Expand Down
9 changes: 8 additions & 1 deletion src/Mod/Path/PathScripts/linuxcnc_post.py
Expand Up @@ -22,7 +22,7 @@
# ***************************************************************************/


'''
TOOLTIP='''
This is a postprocessor file for the Path workbench. It is used to
take a pseudo-gcode fragment outputted by a Path object, and output
real GCode suitable for a linuxcnc 3 axis mill. This postprocessor, once placed
Expand All @@ -33,6 +33,13 @@
linuxcnc_post.export(object,"/path/to/file.ncc")
'''

TOOLTIP_ARGS='''
Arguments for linuxcnc:
--header,--no-header ... output headers (--header)
--comments,--no-comments ... output comments (--comments)
--line-numbers,--no-line-numbers ... prefix with line numbers (--no-lin-numbers)
'''

import datetime
from PathScripts import PostUtils

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/opensbp_post.py
Expand Up @@ -25,7 +25,7 @@
# ***************************************************************************/


'''
TOOLTIP='''
This is an postprocessor file for the Path workbench. It will output path data
in a format suitable for OpenSBP controllers like shopbot. This postprocessor,
once placed in the appropriate PathScripts folder, can be used directly from
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Path/PathScripts/rml_post.py
Expand Up @@ -22,7 +22,7 @@
#***************************************************************************/


'''
TOOLTIP='''
FreeCAD Path post-processor to output code for the Roland Modela MDX-## machines.
The machine speaks RML-1, specified in 'Roland RML-1 Programming Guidelines'
Expand Down

0 comments on commit 67e3b13

Please sign in to comment.