Commit 28a3df5e authored by D1plo1d's avatar D1plo1d

Merge branch 'experimental' of github.com:kliment/Printrun into experimental

parents 99747933 ddf5eff7
......@@ -119,7 +119,7 @@ To use pronterface, you need:
* numpy (for 3D view)
* pyreadline (not needed on Linux) and
* argparse (installed by default with python >= 2.7)
* wxPython
* wxPython (some features such as Tabbed mode work better with wx 2.9)
* pycairo (to use Projector feature)
Please see specific instructions for Windows and Mac OS X below. Under Linux, you should use your package manager directly (see the "GETTING PRINTRUN" section)
......
* Rework gcview zooming/rotation/move behavior
* Improve stlview
* Add tool to select gcode area to ignore
* Add calibration helper
* Improve tabbed mode for wx 2.8 ? (the main toolbar is not wrapping as in 2.9)
This diff is collapsed.
......@@ -51,6 +51,7 @@ class GCodeAnalyzer():
self.eOffset = 0
self.lastZPrint = 0
self.layerZ = 0
self.imperial = False
self.relative = False
self.eRelative = False
self.homeX = 0
......@@ -69,6 +70,7 @@ class GCodeAnalyzer():
def Analyze(self, gcode):
gline = gcoder.Line(gcode)
if gline.command.startswith(";@"): return # code is a host command
gline.parse_coordinates(self.imperial)
code_g = int(gline.command[1:]) if gline.command.startswith("G") else None
code_m = int(gline.command[1:]) if gline.command.startswith("M") else None
......@@ -97,7 +99,7 @@ class GCodeAnalyzer():
eChanged = True
self.e += code_e
else:
#absolute coordinates
# absolute coordinates
if code_x != None: self.x = self.xOffset + code_x
if code_y != None: self.y = self.yOffset + code_y
if code_z != None: self.z = self.zOffset + code_z
......@@ -112,6 +114,7 @@ class GCodeAnalyzer():
eChanged = True
self.e = self.eOffset + code_e
#limit checking
"""
if self.x < self.minX: self.x = self.minX
if self.y < self.minY: self.y = self.minY
if self.z < self.minZ: self.z = self.minZ
......@@ -119,7 +122,10 @@ class GCodeAnalyzer():
if self.x > self.maxX: self.x = self.maxX
if self.y > self.maxY: self.y = self.maxY
if self.z > self.maxZ: self.z = self.maxZ
"""
#Repetier has a bunch of limit-checking code here and time calculations: we are leaving them for now
elif code_g == 20: self.imperial = True
elif code_g == 21: self.imperial = False
elif code_g == 28 or code_g == 161:
self.lastX = self.x
self.lastY = self.y
......@@ -189,7 +195,6 @@ class GCodeAnalyzer():
self.e = self.eOffset
#End code_g != None
if code_m != None:
code_m = int(code_m)
if code_m == 82: self.eRelative = False
elif code_m == 83: self.eRelative = True
......
#!/usr/bin/python
#!/usr/bin/env python
# This file is part of the Printrun suite.
#
# Printrun is free software: you can redistribute it and/or modify
......
#!/usr/bin/python
#!/usr/bin/env python
# This file is part of the Printrun suite.
#
......
#!/usr/bin/python
#!/usr/bin/env python
# This file is part of the Printrun suite.
#
......
......@@ -165,11 +165,12 @@ def add_extra_controls(self, root, parentpanel, extra_buttons = None):
else:
self.Add(root.tempdisp, pos = (gauges_base_line + 0, 0), span = (1, 6))
root.graph = Graph(parentpanel, wx.ID_ANY, root)
if standalone_mode:
self.Add(root.graph, pos = (base_line + 5, 0), span = (3, 6))
else:
self.Add(root.graph, pos = (base_line + 2, 5), span = (3, 1))
if root.display_graph:
root.graph = Graph(parentpanel, wx.ID_ANY, root)
if standalone_mode:
self.Add(root.graph, pos = (base_line + 5, 0), span = (3, 6))
else:
self.Add(root.graph, pos = (base_line + 2, 5), span = (3, 1))
if extra_buttons:
pos_mapping = {
......@@ -292,9 +293,7 @@ class VizPane(wx.BoxSizer):
extrusion_width = root.settings.preview_extrusion_width)
root.gwindow.Bind(wx.EVT_CLOSE, lambda x: root.gwindow.Hide())
if not isinstance(root.gviz, NoViz):
self.Add(root.gviz.widget, 1, flag = wx.SHAPED)
root.centersizer = wx.GridBagSizer()
self.Add(root.centersizer, 0, flag = wx.EXPAND)
self.Add(root.gviz.widget, 1, flag = wx.SHAPED | wx.ALIGN_CENTER_HORIZONTAL)
class LogPane(wx.BoxSizer):
......@@ -390,7 +389,8 @@ class MainWindow(wx.Frame):
rightsizer = wx.BoxSizer(wx.VERTICAL)
extracontrols = wx.GridBagSizer()
add_extra_controls(extracontrols, self, page1panel2, left_pane.extra_buttons)
rightsizer.Add(extracontrols, 1, wx.ALIGN_CENTER)
rightsizer.AddStretchSpacer()
rightsizer.Add(extracontrols, 0, wx.ALIGN_CENTER)
self.lowersizer.Add(leftsizer, 1, wx.ALIGN_CENTER)
self.lowersizer.Add(rightsizer, 1, wx.ALIGN_CENTER)
self.mainsizer_page1.Add(page1panel2, 1, wx.EXPAND)
......@@ -414,13 +414,17 @@ class MainWindow(wx.Frame):
self.notebook.AddPage(page1panel, _("Commands"))
self.notebook.AddPage(page2panel, _("Status"))
self.panel.SetSizer(self.notesizer)
self.status = self.CreateStatusBar()
self.status.SetStatusText(_("Not connected to printer."))
self.statusbar = self.CreateStatusBar()
self.statusbar.SetStatusText(_("Not connected to printer."))
self.panel.Bind(wx.EVT_MOUSE_EVENTS, self.editbutton)
self.Bind(wx.EVT_CLOSE, self.kill)
vizpane.Detach(self.centersizer)
rightsizer.Add(self.centersizer, 0, wx.EXPAND)
# Custom buttons
self.centersizer = wx.GridBagSizer()
self.centerpanel = self.newPanel(page1panel2)
self.centerpanel.SetSizer(self.centersizer)
rightsizer.Add(self.centerpanel, 0, wx.ALIGN_CENTER)
rightsizer.AddStretchSpacer()
self.panel.SetSizerAndFit(self.notesizer)
......@@ -430,22 +434,42 @@ class MainWindow(wx.Frame):
for i in self.printerControls:
i.Disable()
#self.panel.Fit()
self.cbuttons_panel = page1panel
self.cbuttons_reload()
def createGui(self):
def createGui(self, compact = False):
self.mainsizer = wx.BoxSizer(wx.VERTICAL)
self.uppersizer = MainToolbar(self)
self.lowersizer = wx.BoxSizer(wx.HORIZONTAL)
self.lowersizer.Add(LeftPane(self), 0)
self.lowersizer.Add(VizPane(self), 1, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL)
self.lowersizer.Add(LogPane(self), 1, wx.EXPAND)
self.mainsizer.Add(self.uppersizer, 0)
self.mainsizer.Add(self.lowersizer, 1, wx.EXPAND)
upperpanel = self.newPanel(self.panel)
self.uppersizer = MainToolbar(self, upperpanel)
lowerpanel = self.newPanel(self.panel)
upperpanel.SetSizer(self.uppersizer)
lowerpanel.SetSizer(self.lowersizer)
left_pane = LeftPane(self, lowerpanel)
left_pane.Layout() # required to get correct rows/cols counts
left_sizer = wx.BoxSizer(wx.VERTICAL)
left_sizer.Add(left_pane, 0)
self.lowersizer.Add(left_sizer, 0, wx.EXPAND)
vizpanel = self.newPanel(lowerpanel)
viz_pane = VizPane(self, vizpanel)
# Custom buttons
self.centersizer = wx.GridBagSizer()
self.centerpanel = self.newPanel(vizpanel)
self.centerpanel.SetSizer(self.centersizer)
viz_pane.Add(self.centerpanel, 0, flag = wx.ALIGN_CENTER)
vizpanel.SetSizer(viz_pane)
self.lowersizer.Add(vizpanel, 1, wx.EXPAND | wx.ALIGN_CENTER)
logpanel = self.newPanel(lowerpanel)
log_pane = LogPane(self, logpanel)
logpanel.SetSizer(log_pane)
if compact:
left_sizer.Add(logpanel, 1, wx.EXPAND)
else:
self.lowersizer.Add(logpanel, 1, wx.EXPAND)
self.mainsizer.Add(upperpanel, 0)
self.mainsizer.Add(lowerpanel, 1, wx.EXPAND)
self.panel.SetSizer(self.mainsizer)
self.status = self.CreateStatusBar()
self.status.SetStatusText(_("Not connected to printer."))
self.statusbar = self.CreateStatusBar()
self.statusbar.SetStatusText(_("Not connected to printer."))
self.panel.Bind(wx.EVT_MOUSE_EVENTS, self.editbutton)
self.Bind(wx.EVT_CLOSE, self.kill)
......@@ -464,5 +488,4 @@ class MainWindow(wx.Frame):
for i in self.printerControls:
i.Disable()
#self.panel.Fit()
self.cbuttons_panel = self.panel
self.cbuttons_reload()
......@@ -120,8 +120,7 @@ class MacroEditor(wx.Dialog):
reindented += self.indent_chars + line + "\n"
return reindented
SETTINGS_GROUPS = {"General": _("General"),
"Printer": _("Printer settings"),
SETTINGS_GROUPS = {"Printer": _("Printer settings"),
"UI": _("User interface"),
"External": _("External commands")}
......@@ -136,7 +135,7 @@ class PronterOptionsDialog(wx.Dialog):
all_settings = pronterface.settings._all_settings()
group_list = []
groups = {}
for group in ["General", "UI", "Printer"]:
for group in ["Printer", "UI", "External"]:
group_list.append(group)
groups[group] = []
for setting in all_settings:
......@@ -153,8 +152,13 @@ class PronterOptionsDialog(wx.Dialog):
grid.AddGrowableCol(1)
grid.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)
for setting in settings:
grid.Add(setting.get_label(grouppanel), 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.ALIGN_RIGHT)
grid.Add(setting.get_widget(grouppanel), 1, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND)
label,widget = setting.get_label(grouppanel),setting.get_widget(grouppanel)
grid.Add(label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.ALIGN_RIGHT)
grid.Add(widget, 1, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND)
if hasattr(label,"set_default"):
label.Bind(wx.EVT_MOUSE_EVENTS, label.set_default)
if hasattr(widget,"Bind"):
widget.Bind(wx.EVT_MOUSE_EVENTS, label.set_default)
grouppanel.SetSizer(grid)
sbox.Add(notebook, 1, wx.EXPAND)
panel.SetSizer(sbox)
......
#!/usr/bin/python
#!/usr/bin/env python
# This file is part of the Printrun suite.
#
......
......@@ -60,14 +60,28 @@ def setting_add_tooltip(func):
@wraps(func)
def decorator(self, *args, **kwargs):
widget = func(self, *args, **kwargs)
if self.help:
widget.SetToolTipString(self.help)
helptxt = self.help or ""
sep,deftxt = "",""
if len(helptxt):
sep = "\n"
if helptxt.find("\n") >= 0:
sep = "\n\n"
if self.default is not "":
deftxt = _("Default: ")
resethelp = _("(Control-doubleclick to reset to default value)")
if len(repr(self.default)) > 10:
deftxt += "\n " + repr(self.default).strip("'") + "\n" + resethelp
else:
deftxt += repr(self.default) + " " + resethelp
helptxt += sep + deftxt
if len(helptxt):
widget.SetToolTipString(helptxt)
return widget
return decorator
class Setting(object):
DEFAULT_GROUP = "General"
DEFAULT_GROUP = "Printer"
hidden = False
......@@ -85,10 +99,20 @@ class Setting(object):
raise NotImplementedError
value = property(_get_value, _set_value)
def set_default(self, e):
import wx
if e.CmdDown() and e.ButtonDClick() and self.default is not "":
confirmation = wx.MessageDialog(None,_("Are you sure you want to reset the setting to the default value: {0!r} ?").format(self.default),_("Confirm set default"),wx.ICON_EXCLAMATION|wx.YES_NO|wx.NO_DEFAULT)
if confirmation.ShowModal() == wx.ID_YES:
self._set_value(self.default)
else:
e.Skip()
@setting_add_tooltip
def get_label(self, parent):
import wx
widget = wx.StaticText(parent, -1, self.label or self.name)
widget.set_default = self.set_default
return widget
@setting_add_tooltip
......@@ -98,12 +122,6 @@ class Setting(object):
def get_specific_widget(self, parent):
raise NotImplementedError
def set(self, value):
raise NotImplementedError
def get(self):
raise NotImplementedError
def update(self):
raise NotImplementedError
......@@ -178,6 +196,9 @@ class BooleanSetting(wxSetting):
return bool(self._value)
def _set_value(self, value):
self._value = value
if self.widget:
self.widget.SetValue(bool(value))
value = property(_get_value, _set_value)
def get_specific_widget(self, parent):
......@@ -186,6 +207,23 @@ class BooleanSetting(wxSetting):
self.widget.SetValue(bool(self.value))
return self.widget
class StaticTextSetting(wxSetting):
def __init__(self, name, label = " ", text = "", help = None, group = None):
super(StaticTextSetting, self).__init__(name, "", label, help, group)
self.text = text
def update(self):
pass
def _get_value(self):
return ""
def _set_value(self, value):
pass
def get_specific_widget(self, parent):
import wx
self.widget = wx.StaticText(parent, -1, self.text)
return self.widget
class Settings(object):
#def _temperature_alias(self): return {"pla":210, "abs":230, "off":0}
#def _temperature_validate(self, v):
......@@ -196,16 +234,16 @@ class Settings(object):
# defaults here.
# the initial value determines the type
self._add(StringSetting("port", "", _("Serial port"), _("Port used to communicate with printer")))
self._add(ComboSetting("baudrate", 115200, self._baudrate_list(), _("Baud rate"), _("Communications Speed (default: 115200)")))
self._add(SpinSetting("bedtemp_abs", 110, 0, 400, _("Bed temperature for ABS"), _("Heated Build Platform temp for ABS (default: 110 deg C)"), "Printer"))
self._add(SpinSetting("bedtemp_pla", 60, 0, 400, _("Bed temperature for PLA"), _("Heated Build Platform temp for PLA (default: 60 deg C)"), "Printer"))
self._add(SpinSetting("temperature_abs", 230, 0, 400, _("Extruder temperature for ABS"), _("Extruder temp for ABS (default: 230 deg C)"), "Printer"))
self._add(SpinSetting("temperature_pla", 185, 0, 400, _("Extruder temperature for PLA"), _("Extruder temp for PLA (default: 185 deg C)"), "Printer"))
self._add(SpinSetting("xy_feedrate", 3000, 0, 50000, _("X && Y manual feedrate"), _("Feedrate for Control Panel Moves in X and Y (default: 3000mm/min)"), "Printer"))
self._add(SpinSetting("z_feedrate", 200, 0, 50000, _("Z manual feedrate"), _("Feedrate for Control Panel Moves in Z (default: 200mm/min)"), "Printer"))
self._add(SpinSetting("e_feedrate", 100, 0, 1000, _("E manual feedrate"), _("Feedrate for Control Panel Moves in Extrusions (default: 300mm/min)"), "Printer"))
self._add(StringSetting("slicecommand", "python skeinforge/skeinforge_application/skeinforge_utilities/skeinforge_craft.py $s", _("Slice command"), _("Slice command\n default:\n python skeinforge/skeinforge_application/skeinforge_utilities/skeinforge_craft.py $s)"), "External"))
self._add(StringSetting("sliceoptscommand", "python skeinforge/skeinforge_application/skeinforge.py", _("Slicer options command"), _("Slice settings command\n default:\n python skeinforge/skeinforge_application/skeinforge.py"), "External"))
self._add(ComboSetting("baudrate", 115200, self._baudrate_list(), _("Baud rate"), _("Communications Speed")))
self._add(SpinSetting("bedtemp_abs", 110, 0, 400, _("Bed temperature for ABS"), _("Heated Build Platform temp for ABS (deg C)"), "Printer"))
self._add(SpinSetting("bedtemp_pla", 60, 0, 400, _("Bed temperature for PLA"), _("Heated Build Platform temp for PLA (deg C)"), "Printer"))
self._add(SpinSetting("temperature_abs", 230, 0, 400, _("Extruder temperature for ABS"), _("Extruder temp for ABS (deg C)"), "Printer"))
self._add(SpinSetting("temperature_pla", 185, 0, 400, _("Extruder temperature for PLA"), _("Extruder temp for PLA (deg C)"), "Printer"))
self._add(SpinSetting("xy_feedrate", 3000, 0, 50000, _("X && Y manual feedrate"), _("Feedrate for Control Panel Moves in X and Y (mm/min)"), "Printer"))
self._add(SpinSetting("z_feedrate", 200, 0, 50000, _("Z manual feedrate"), _("Feedrate for Control Panel Moves in Z (mm/min)"), "Printer"))
self._add(SpinSetting("e_feedrate", 100, 0, 1000, _("E manual feedrate"), _("Feedrate for Control Panel Moves in Extrusions (mm/min)"), "Printer"))
self._add(StringSetting("slicecommand", "python skeinforge/skeinforge_application/skeinforge_utilities/skeinforge_craft.py $s", _("Slice command"), _("Slice command"), "External"))
self._add(StringSetting("sliceoptscommand", "python skeinforge/skeinforge_application/skeinforge.py", _("Slicer options command"), _("Slice settings command"), "External"))
self._add(StringSetting("final_command", "", _("Final command"), _("Executable to run when the print is finished"), "External"))
self._add(HiddenSetting("project_offset_x", 0.0))
......@@ -241,8 +279,10 @@ class Settings(object):
return object.__getattribute__(self, name)
return getattr(self, "_" + name).value
def _add(self, setting):
def _add(self, setting, callback = None):
setattr(self, setting.name, setting)
if callback:
setattr(self, "_" + setting.name + "_cb", callback)
def _set(self, key, value):
try:
......@@ -479,6 +519,9 @@ class pronsole(cmd.Cmd):
self.log("Empty macro - cancelled")
del self.cur_macro_name, self.cur_macro_def
def parseusercmd(self, line):
pass
def compile_macro_line(self, line):
line = line.rstrip()
ls = line.lstrip()
......@@ -487,7 +530,8 @@ class pronsole(cmd.Cmd):
if ls.startswith('!'):
return ws + ls[1:] + "\n" # python mode
else:
return ws + 'self.onecmd("'+ls+'".format(*arg))\n' # parametric command mode
ret = ws + 'self.parseusercmd("'+ls+'".format(*arg))\n' # parametric command mode
return ret + ws + 'self.onecmd("'+ls+'".format(*arg))\n'
def compile_macro(self, macro_name, macro_def):
if macro_def.strip() == "":
......@@ -1157,7 +1201,7 @@ class pronsole(cmd.Cmd):
self.log("Printer is not online. Unable to extrude.")
return
if self.p.printing:
self.log("Printer is currently printing. Please pause the print before you issue manual commands.")
self.log(_("Printer is currently printing. Please pause the print before you issue manual commands."))
return
ls = l.split()
if len(ls):
......
This diff is collapsed.
#!/usr/bin/env python2.7
#!/usr/bin/env python
import tornado.ioloop
import tornado.web
......
......@@ -144,8 +144,8 @@ setup (
url = "http://github.com/kliment/Printrun/",
license = "GPLv3",
data_files = data_files,
packages = ["printrun", "printrun.svg"],
scripts = ["pronsole.py", "pronterface.py", "plater.py", "printcore.py", "pronserve.py"],
packages = ["printrun", "printrun.cairosvg"],
scripts = ["pronsole.py", "pronterface.py", "plater.py", "printcore.py", "prontserve.py"],
cmdclass = {"uninstall" : uninstall,
"install" : install,
"install_data" : install_data}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment