Commit 0301ad79 authored by Guillaume Seguin's avatar Guillaume Seguin

Fix #534: add a "Tabbed with platers" mode

parent 87991a2e
......@@ -22,6 +22,6 @@ from printrun.gcodeplater import GcodePlater
if __name__ == '__main__':
app = wx.App(False)
main = GcodePlater(sys.argv[1:])
main = GcodePlater(filenames = sys.argv[1:])
main.Show()
app.MainLoop()
......@@ -22,6 +22,6 @@ from printrun.stlplater import StlPlater
if __name__ == '__main__':
app = wx.App(False)
main = StlPlater(sys.argv[1:])
main = StlPlater(filenames = sys.argv[1:])
main.Show()
app.MainLoop()
......@@ -30,7 +30,7 @@ import math
import logging
from printrun import gcoder
from printrun.objectplater import Plater
from printrun.objectplater import make_plater, PlaterPanel
from printrun.gl.libtatlin import actors
import printrun.gui.viz # NOQA
from printrun import gcview
......@@ -72,13 +72,15 @@ def rewrite_gline(centeroffset, gline, cosr, sinr):
else:
return gline.raw
class GcodePlater(Plater):
class GcodePlaterPanel(PlaterPanel):
load_wildcard = _("GCODE files (*.gcode;*.GCODE;*.g)") + "|*.gcode;*.gco;*.g"
save_wildcard = _("GCODE files (*.gcode;*.GCODE;*.g)") + "|*.gcode;*.gco;*.g"
def __init__(self, filenames = [], size = (800, 580), callback = None, parent = None, build_dimensions = None, circular_platform = False, antialias_samples = 0):
super(GcodePlater, self).__init__(filenames, size, callback, parent, build_dimensions)
def prepare_ui(self, filenames = [], callback = None,
parent = None, build_dimensions = None,
circular_platform = False, antialias_samples = 0):
super(GcodePlaterPanel, self).prepare_ui(filenames, callback, parent, build_dimensions)
viewer = gcview.GcodeViewPanel(self, build_dimensions = self.build_dimensions,
antialias_samples = antialias_samples)
self.set_viewer(viewer)
......@@ -119,7 +121,8 @@ class GcodePlater(Plater):
self.export_to(name)
if cb is not None:
cb(name)
self.Destroy()
if self.destroy_on_done:
self.Destroy()
# What's hard in there ?
# 1) [x] finding the order in which the objects are printed
......@@ -229,9 +232,11 @@ class GcodePlater(Plater):
break
logging.info(_("Exported merged G-Codes to %s") % name)
GcodePlater = make_plater(GcodePlaterPanel)
if __name__ == '__main__':
app = wx.App(False)
main = GcodePlater(sys.argv[1:])
main = GcodePlater(filenames = sys.argv[1:])
for fn in main.filenames:
main.load_file(fn)
main.filenames = None
......
......@@ -126,9 +126,12 @@ class MainWindow(wx.Frame):
def newPanel(self, parent, add_to_list = True):
panel = wx.Panel(parent)
self.registerPanel(panel, add_to_list)
return panel
def registerPanel(self, panel, add_to_list = True):
panel.SetBackgroundColour(self.bgcolor)
if add_to_list: self.panels.append(panel)
return panel
def createTabbedGui(self):
self.notesizer = wx.BoxSizer(wx.VERTICAL)
......@@ -176,6 +179,24 @@ class MainWindow(wx.Frame):
self.notesizer.Add(self.notebook, 1, wx.EXPAND)
self.notebook.AddPage(page1panel, _("Commands"))
self.notebook.AddPage(page2panel, _("Status"))
if self.settings.uimode == _("Tabbed with platers"):
from printrun.stlplater import StlPlaterPanel
from printrun.gcodeplater import GcodePlaterPanel
page3panel = StlPlaterPanel(parent = self.notebook,
callback = self.platecb,
build_dimensions = self.build_dimensions_list,
circular_platform = self.settings.circular_bed,
simarrange_path = self.settings.simarrange_path,
antialias_samples = int(self.settings.antialias3dsamples))
page4panel = GcodePlaterPanel(parent = self.notebook,
callback = self.platecb,
build_dimensions = self.build_dimensions_list,
circular_platform = self.settings.circular_bed,
antialias_samples = int(self.settings.antialias3dsamples))
self.registerPanel(page3panel)
self.registerPanel(page4panel)
self.notebook.AddPage(page3panel, _("Plater"))
self.notebook.AddPage(page4panel, _("G-Code Plater"))
self.panel.SetSizer(self.notesizer)
self.panel.Bind(wx.EVT_MOUSE_EVENTS, self.editbutton)
self.Bind(wx.EVT_CLOSE, self.kill)
......
......@@ -31,11 +31,15 @@ def patch_method(obj, method, replacement):
return replacement(*a, **kwargs)
setattr(obj, method, types.MethodType(wrapped, obj))
class Plater(wx.Frame):
def __init__(self, filenames = [], size = (800, 580), callback = None, parent = None, build_dimensions = None):
super(Plater, self).__init__(parent, title = _("Plate building tool"), size = size)
class PlaterPanel(wx.Panel):
def __init__(self, **kwargs):
self.destroy_on_done = False
parent = kwargs.get("parent", None)
super(PlaterPanel, self).__init__(parent = parent)
self.prepare_ui(**kwargs)
def prepare_ui(self, filenames = [], callback = None, parent = None, build_dimensions = None):
self.filenames = filenames
self.SetIcon(wx.Icon(iconfile("plater.png"), wx.BITMAP_TYPE_PNG))
self.mainsizer = wx.BoxSizer(wx.HORIZONTAL)
panel = self.menupanel = wx.Panel(self, -1)
sizer = self.menusizer = wx.GridBagSizer()
......@@ -279,3 +283,16 @@ class Plater(wx.Frame):
def export_to(self, name):
raise NotImplementedError
class Plater(wx.Frame):
def __init__(self, **kwargs):
self.destroy_on_done = True
parent = kwargs.get("parent", None)
size = kwargs.get("size", (800, 580))
wx.Frame.__init__(self, parent, title = _("Plate building tool"), size = size)
self.SetIcon(wx.Icon(iconfile("plater.png"), wx.BITMAP_TYPE_PNG))
self.prepare_ui(**kwargs)
def make_plater(panel_class):
name = panel_class.__name__.replace("Panel", "")
return type(name, (Plater, panel_class), {})
......@@ -270,10 +270,10 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.reset_ui()
# Create UI
if self.settings.uimode == "Tabbed":
if self.settings.uimode in (_("Tabbed"), _("Tabbed with platers")):
self.createTabbedGui()
else:
self.createGui(self.settings.uimode == "Compact",
self.createGui(self.settings.uimode == _("Compact"),
self.settings.controlsmode == "Mini")
if hasattr(self, "splitterwindow"):
......@@ -523,6 +523,9 @@ class PronterWindow(MainWindow, pronsole.pronsole):
def platecb(self, name):
self.log(_("Plated %s") % name)
self.loadfile(None, name)
if self.settings.uimode in (_("Tabbed"), _("Tabbed with platers")):
# Switch to page 1 (Status tab)
self.notebook.SetSelection(1)
def do_editgcode(self, e = None):
if self.filename is not None:
......@@ -821,7 +824,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
self.settings._add(BooleanSetting("circular_bed", False, _("Circular build platform"), _("Draw a circular (or oval) build platform instead of a rectangular one"), "Printer"), self.update_bed_viz)
self.settings._add(SpinSetting("extruders", 0, 1, 5, _("Extruders count"), _("Number of extruders"), "Printer"))
self.settings._add(BooleanSetting("clamp_jogging", False, _("Clamp manual moves"), _("Prevent manual moves from leaving the specified build dimensions"), "Printer"))
self.settings._add(ComboSetting("uimode", "Standard", ["Standard", "Compact", "Tabbed"], _("Interface mode"), _("Standard interface is a one-page, three columns layout with controls/visualization/log\nCompact mode is a one-page, two columns layout with controls + log/visualization\nTabbed mode is a two-pages mode, where the first page shows controls and the second one shows visualization and log."), "UI"), self.reload_ui)
self.settings._add(ComboSetting("uimode", _("Standard"), [_("Standard"), _("Compact"), _("Tabbed"), _("Tabbed with platers")], _("Interface mode"), _("Standard interface is a one-page, three columns layout with controls/visualization/log\nCompact mode is a one-page, two columns layout with controls + log/visualization\nTabbed mode is a two-pages mode, where the first page shows controls and the second one shows visualization and log.\nTabbed with platers mode is the same as Tabbed, but with two extra pages for the STL and G-Code platers."), "UI"), self.reload_ui)
self.settings._add(ComboSetting("controlsmode", "Standard", ["Standard", "Mini"], _("Controls mode"), _("Standard controls include all controls needed for printer setup and calibration, while Mini controls are limited to the ones needed for daily printing"), "UI"), self.reload_ui)
self.settings._add(BooleanSetting("slic3rintegration", False, _("Enable Slic3r integration"), _("Add a menu to select Slic3r profiles directly from Pronterface"), "UI"), self.reload_ui)
self.settings._add(BooleanSetting("slic3rupdate", False, _("Update Slic3r default presets"), _("When selecting a profile in Slic3r integration menu, also save it as the default Slic3r preset"), "UI"))
......
......@@ -34,7 +34,7 @@ import subprocess
from copy import copy
from printrun import stltool
from printrun.objectplater import Plater
from printrun.objectplater import make_plater, PlaterPanel
glview = False
if "-nogl" not in sys.argv:
......@@ -216,15 +216,15 @@ class showstl(wx.Window):
dc.Blit(scale * m.offsets[0] - bsz[0] / 2, 400 - (scale * m.offsets[1] + bsz[1] / 2), bsz[0], bsz[1], dcs, 0, 0, useMask = 1)
del dc
class StlPlater(Plater):
class StlPlaterPanel(PlaterPanel):
load_wildcard = _("STL files (*.stl;*.STL)|*.stl;*.STL|OpenSCAD files (*.scad)|*.scad")
save_wildcard = _("STL files (*.stl;*.STL)|*.stl;*.STL")
def __init__(self, filenames = [], size = (800, 580), callback = None,
parent = None, build_dimensions = None, circular_platform = False,
simarrange_path = None, antialias_samples = 0):
super(StlPlater, self).__init__(filenames, size, callback, parent, build_dimensions)
def prepare_ui(self, filenames = [], callback = None,
parent = None, build_dimensions = None, circular_platform = False,
simarrange_path = None, antialias_samples = 0):
super(StlPlaterPanel, self).prepare_ui(filenames, callback, parent, build_dimensions)
self.cutting = False
self.cutting_axis = None
self.cutting_dist = None
......@@ -368,7 +368,8 @@ class StlPlater(Plater):
self.export_to(name)
if cb is not None:
cb(name)
self.Destroy()
if self.destroy_on_done:
self.Destroy()
def load_file(self, filename):
if filename.lower().endswith(".stl"):
......@@ -516,3 +517,5 @@ class StlPlater(Plater):
break
if p.wait() != 0:
raise RuntimeError(_("simarrange failed"))
StlPlater = make_plater(StlPlaterPanel)
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