diff --git a/printrun/gui/viz.py b/printrun/gui/viz.py index 1eff17be6..8550880a2 100644 --- a/printrun/gui/viz.py +++ b/printrun/gui/viz.py @@ -81,6 +81,7 @@ def __init__(self, root, parentpanel = None): build_dimensions = root.build_dimensions_list, grid = (root.settings.preview_grid_step1, root.settings.preview_grid_step2), extrusion_width = root.settings.preview_extrusion_width, + center_origin = root.settings.circular_bed, bgcolor = root.bgcolor) root.gviz.SetToolTip(wx.ToolTip(_("Click to examine / edit\n layers of loaded file"))) root.gviz.showall = 1 @@ -103,6 +104,7 @@ def __init__(self, root, parentpanel = None): root.gwindow = gviz.GvizWindow(build_dimensions = root.build_dimensions_list, grid = (root.settings.preview_grid_step1, root.settings.preview_grid_step2), extrusion_width = root.settings.preview_extrusion_width, + center_origin = root.settings.circular_bed, bgcolor = root.bgcolor) root.gwindow.Bind(wx.EVT_CLOSE, lambda x: root.gwindow.Hide()) if not isinstance(root.gviz, NoViz): diff --git a/printrun/gviz.py b/printrun/gviz.py index df3ea71c2..712482adb 100644 --- a/printrun/gviz.py +++ b/printrun/gviz.py @@ -69,12 +69,12 @@ def process_slider(self, event): ID_ABOUT = 101 ID_EXIT = 110 class GvizWindow(GvizBaseFrame): - def __init__(self, f = None, size = (600, 600), build_dimensions = [200, 200, 100, 0, 0, 0], grid = (10, 50), extrusion_width = 0.5, bgcolor = "#000000"): + def __init__(self, f = None, size = (600, 600), build_dimensions = [200, 200, 100, 0, 0, 0], grid = (10, 50), extrusion_width = 0.5, center_origin=False, bgcolor = "#000000"): super(GvizWindow, self).__init__(None, title = _("Gcode view, shift to move view, mousewheel to set layer"), size = size) panel, vbox = self.create_base_ui() - self.p = Gviz(panel, size = size, build_dimensions = build_dimensions, grid = grid, extrusion_width = extrusion_width, bgcolor = bgcolor, realparent = self) + self.p = Gviz(panel, size = size, build_dimensions = build_dimensions, grid = grid, extrusion_width = extrusion_width, bgcolor = bgcolor, realparent = self, center_origin = center_origin) self.toolbar.Realize() vbox.Add(self.p, 1, wx.EXPAND) @@ -171,7 +171,7 @@ def _set_showall(self, showall): self._showall = showall showall = property(_get_showall, _set_showall) - def __init__(self, parent, size = (200, 200), build_dimensions = [200, 200, 100, 0, 0, 0], grid = (10, 50), extrusion_width = 0.5, bgcolor = "#000000", realparent = None): + def __init__(self, parent, size = (200, 200), build_dimensions = [200, 200, 100, 0, 0, 0], grid = (10, 50), extrusion_width = 0.5, bgcolor = "#000000", realparent = None, center_origin=False): wx.Panel.__init__(self, parent, -1) self.widget = self size = [max(1.0, x) for x in size] @@ -203,6 +203,7 @@ def __init__(self, parent, size = (200, 200), build_dimensions = [200, 200, 100, self.bgcolor.Set(bgcolor) self.blitmap = wx.Bitmap(self.GetClientSize()[0], self.GetClientSize()[1], -1) self.paint_overlay = None + self.center_origin = center_origin def inject(self): layer = self.layers[self.layerindex] @@ -410,6 +411,7 @@ def paint(self, event): dc.SetBackground(wx.Brush(self.bgcolor)) dc.Clear() dc.DrawBitmap(self.blitmap, self.translate[0], self.translate[1]) + #dc.DrawBitmap(self.blitmap, 100, -100) if self.paint_overlay: self.paint_overlay(dc) @@ -468,10 +470,16 @@ def _get_movement(self, start_pos, gline): return target, None, arc def _y(self, y): - return self.build_dimensions[1] - (y - self.build_dimensions[4]) + if self.center_origin: + return self.build_dimensions[1] - (y - self.build_dimensions[4]) - (self.build_dimensions[1]/2) + else: + return self.build_dimensions[1] - (y - self.build_dimensions[4]) def _x(self, x): - return x - self.build_dimensions[3] + if self.center_origin: + return x - self.build_dimensions[3] + (self.build_dimensions[0] / 2) + else: + return x - self.build_dimensions[3] def add_parsed_gcodes(self, gcode): start_time = time.time() @@ -549,6 +557,6 @@ def addgcodehighlight(self, gline): if __name__ == '__main__': import sys app = wx.App(False) - main = GvizWindow(open(sys.argv[1], "rU")) + main = GvizWindow(open(sys.argv[1], "rU"), build_dimensions = [200, 200, 100, 0, 0, 0], center_origin=True) main.Show() app.MainLoop() diff --git a/printrun/pronterface.py b/printrun/pronterface.py index e200a6a0f..5670434cc 100644 --- a/printrun/pronterface.py +++ b/printrun/pronterface.py @@ -572,9 +572,10 @@ def plate(self, e): def plate_gcode(self, e): from . import gcodeplater as plater self.log(_("G-Code plate function activated")) + bd = self.build_dimensions_list plater.GcodePlater(size = (800, 580), callback = self.platecb, parent = self, - build_dimensions = self.build_dimensions_list, + build_dimensions = bd, circular_platform = self.settings.circular_bed, antialias_samples = int(self.settings.antialias3dsamples)).Show()