Commit 5abf7b1f authored by Clarence Risher's avatar Clarence Risher

resolve merge conflicts

parents 8941eb74 7c9e076f
import wx,time
class window(wx.Frame):
def __init__(self,f,size=(600,600),bedsize=(200,200),grid=(10,50),extrusion_width=0.5):
def __init__(self,f,size=(600,600),build_dimensions=[200,200,100,0,0,0],grid=(10,50),extrusion_width=0.5):
wx.Frame.__init__(self,None,title="Gcode view, shift to move view, mousewheel to set layer",size=(size[0],size[1]))
self.p=gviz(self,size=size,bedsize=bedsize,grid=grid,extrusion_width=extrusion_width)
self.p=gviz(self,size=size,build_dimensions=build_dimensions,grid=grid,extrusion_width=extrusion_width)
s=time.time()
#print time.time()-s
self.initpos=[0,0]
......@@ -53,10 +51,10 @@ class window(wx.Frame):
elif z < 0: self.p.zoom(event.GetX(),event.GetY(),1/1.2)
class gviz(wx.Panel):
def __init__(self,parent,size=(200,200),bedsize=(200,200),grid=(10,50),extrusion_width=0.5):
def __init__(self,parent,size=(200,200),build_dimensions=[200,200,100,0,0,0],grid=(10,50),extrusion_width=0.5):
wx.Panel.__init__(self,parent,-1,size=(size[0],size[1]))
self.size=size
self.bedsize=bedsize
self.build_dimensions=build_dimensions
self.grid=grid
self.lastpos=[0,0,0,0,0,0,0]
self.hilightpos=self.lastpos[:]
......@@ -69,7 +67,7 @@ class gviz(wx.Panel):
self.layers=[]
self.layerindex=0
self.filament_width=extrusion_width # set it to 0 to disable scaling lines with zoom
self.basescale=[min(float(size[0])/bedsize[0],float(size[1])/bedsize[1])]*2
self.basescale=[min(float(size[0])/build_dimensions[0],float(size[1])/build_dimensions[1])]*2
self.scale=self.basescale
penwidth = max(1.0,self.filament_width*((self.scale[0]+self.scale[1])/2.0))
self.translate=[0.0,0.0]
......@@ -148,10 +146,10 @@ class gviz(wx.Panel):
dc.SetPen(wx.Pen(wx.Colour(180,180,150)))
for grid_unit in self.grid:
if grid_unit > 0:
for x in xrange(int(self.bedsize[0]/grid_unit)+1):
dc.DrawLine(self.translate[0]+x*self.scale[0]*grid_unit,self.translate[1],self.translate[0]+x*self.scale[0]*grid_unit,self.translate[1]+self.scale[1]*self.bedsize[1])
for y in xrange(int(self.bedsize[1]/grid_unit)+1):
dc.DrawLine(self.translate[0],self.translate[1]+y*self.scale[1]*grid_unit,self.translate[0]+self.scale[0]*self.bedsize[0],self.translate[1]+y*self.scale[1]*grid_unit)
for x in xrange(int(self.build_dimensions[0]/grid_unit)+1):
dc.DrawLine(self.translate[0]+x*self.scale[0]*grid_unit,self.translate[1],self.translate[0]+x*self.scale[0]*grid_unit,self.translate[1]+self.scale[1]*self.build_dimensions[1])
for y in xrange(int(self.build_dimensions[1]/grid_unit)+1):
dc.DrawLine(self.translate[0],self.translate[1]+y*self.scale[1]*grid_unit,self.translate[0]+self.scale[0]*self.build_dimensions[0],self.translate[1]+y*self.scale[1]*grid_unit)
dc.SetPen(wx.Pen(wx.Colour(0,0,0)))
if not self.showall:
self.size = self.GetSize()
......@@ -256,13 +254,15 @@ class gviz(wx.Panel):
return target
def _y(y):
return self.bedsize[1]-y
return self.build_dimensions[1]-(y-self.build_dimensions[4])
def _x(x):
return x-self.build_dimensions[3]
start_pos = self.hilightpos[:] if hilight else self.lastpos[:]
if gcode[0] == "g1":
target = _readgcode()
line = [ start_pos[0], _y(start_pos[1]), target[0], _y(target[1]) ]
line = [ _x(start_pos[0]), _y(start_pos[1]), _x(target[0]), _y(target[1]) ]
if not hilight:
self.lines[ target[2] ] += [line]
self.pens[ target[2] ] += [self.mainpen if target[3] != self.lastpos[3] else self.travelpen]
......@@ -275,9 +275,9 @@ class gviz(wx.Panel):
if gcode[0] in [ "g2", "g3" ]:
target = _readgcode()
arc = []
arc += [ start_pos[0], _y(start_pos[1]) ]
arc += [ target[0], _y(target[1]) ]
arc += [ start_pos[0] + target[5], _y(start_pos[1] + target[6]) ] # center
arc += [ _x(start_pos[0]), _y(start_pos[1]) ]
arc += [ _x(target[0]), _y(target[1]) ]
arc += [ _x(start_pos[0] + target[5]), _y(start_pos[1] + target[6]) ] # center
if gcode[0] == "g2": # clockwise, reverse endpoints
arc[0], arc[1], arc[2], arc[3] = arc[2], arc[3], arc[0], arc[1]
......
......@@ -58,8 +58,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.settings.last_file_path = ""
self.settings.last_temperature = 0.0
self.settings.last_bed_temperature = 0.0
self.settings.bed_size_x = 200.
self.settings.bed_size_y = 200.
#default build dimensions are 200x200x100 with 0,0,0 in the corner of the bed
self.settings.build_dimensions = '200x200x100+0+0+0'
self.settings.preview_grid_step1 = 10.
self.settings.preview_grid_step2 = 50.
self.settings.preview_extrusion_width = 0.5
......@@ -89,6 +89,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.custombuttons=[]
self.btndict={}
self.parse_cmdline(sys.argv[1:])
self.build_dimensions_list = self.get_build_dimensions(self.settings.build_dimensions)
customdict={}
try:
execfile("custombtn.txt",customdict)
......@@ -614,7 +615,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
# lls.Add((10,0),pos=(0,11),span=(1,1))
self.gviz=gviz.gviz(self.panel,(300,300),
bedsize=(self.settings.bed_size_x,self.settings.bed_size_y),
build_dimensions=self.build_dimensions_list,
grid=(self.settings.preview_grid_step1,self.settings.preview_grid_step2),
extrusion_width=self.settings.preview_extrusion_width)
self.gviz.showall=1
......@@ -624,7 +625,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
# self.gwindow=stlview.GCFrame(None, wx.ID_ANY, 'Gcode view, shift to move view, mousewheel to set layer', size=(600,600))
#except:
self.gwindow=gviz.window([],
bedsize=(self.settings.bed_size_x,self.settings.bed_size_y),
build_dimensions=self.build_dimensions_list,
grid=(self.settings.preview_grid_step1,self.settings.preview_grid_step2),
extrusion_width=self.settings.preview_extrusion_width)
self.gviz.Bind(wx.EVT_LEFT_DOWN,self.showwin)
......@@ -1514,6 +1515,28 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
wx.CallAfter(self.pausebtn.SetLabel, _("Pause"))
wx.CallAfter(self.printbtn.SetLabel, _("Print"))
self.paused=0
def get_build_dimensions(self,bdim):
import re
# a string containing up to six numbers delimited by almost anything
# first 0-3 numbers specify the build volume, no sign, always positive
# remaining 0-3 numbers specify the coordinates of the "southwest" corner of the build platform
# "XXX,YYY"
# "XXXxYYY+xxx-yyy"
# "XXX,YYY,ZZZ+xxx+yyy-zzz"
# etc
bdl = re.match(
"[^\d+-]*(\d+)?" + # X build size
"[^\d+-]*(\d+)?" + # Y build size
"[^\d+-]*(\d+)?" + # Z build size
"[^\d+-]*([+-]\d+)?" + # X corner coordinate
"[^\d+-]*([+-]\d+)?" + # Y corner coordinate
"[^\d+-]*([+-]\d+)?" # Z corner coordinate
,bdim).groups()
defaults = [200, 200, 100, 0, 0, 0]
bdl_float = [float(value) if value else defaults[i] for i, value in enumerate(bdl)]
return bdl_float
class macroed(wx.Dialog):
"""Really simple editor to edit macro definitions"""
......
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