Commit 655ab135 authored by kliment's avatar kliment

Fix permissions, allow commands when printer disconnected

parent bd640591
...@@ -8,10 +8,31 @@ class window(wx.Frame): ...@@ -8,10 +8,31 @@ class window(wx.Frame):
for i in f: for i in f:
self.p.addgcode(i) self.p.addgcode(i)
#print time.time()-s #print time.time()-s
self.initpos=[0,0]
self.p.Bind(wx.EVT_KEY_DOWN,self.key) self.p.Bind(wx.EVT_KEY_DOWN,self.key)
self.Bind(wx.EVT_KEY_DOWN,self.key) self.Bind(wx.EVT_KEY_DOWN,self.key)
self.p.Bind(wx.EVT_MOUSEWHEEL,self.zoom) self.p.Bind(wx.EVT_MOUSEWHEEL,self.zoom)
self.Bind(wx.EVT_MOUSEWHEEL,self.zoom) self.Bind(wx.EVT_MOUSEWHEEL,self.zoom)
self.p.Bind(wx.EVT_MOUSE_EVENTS,self.mouse)
self.Bind(wx.EVT_MOUSE_EVENTS,self.mouse)
def mouse(self,event):
if event.ButtonUp(wx.MOUSE_BTN_LEFT):
if(self.initpos is not None):
self.initpos=None
elif event.Dragging():
e=event.GetPositionTuple()
if(self.initpos is None):
self.initpos=e
self.basetrans=self.p.translate
#print self.p.translate,e,self.initpos
self.p.translate = [ self.basetrans[0]+(e[0]-self.initpos[0]),
self.basetrans[1]+(e[1]-self.initpos[1]) ]
self.p.repaint()
self.p.Refresh()
else:
event.Skip()
def key(self, event): def key(self, event):
x=event.GetKeyCode() x=event.GetKeyCode()
......
...@@ -53,10 +53,15 @@ class showstl(wx.Window): ...@@ -53,10 +53,15 @@ class showstl(wx.Window):
return return
path = os.path.split(name)[0] path = os.path.split(name)[0]
self.basedir=path self.basedir=path
t=time.time()
#print name
if name.lower().endswith(".stl"): if name.lower().endswith(".stl"):
self.models[name]=stltool.stl(name) self.models[name]=stltool.stl(name)
self.models[name].offsets=[0,0,0]
#print time.time()-t
self.l.Append([stlwrap(self.models[name],name)]) self.l.Append([stlwrap(self.models[name],name)])
self.Refresh() self.Refresh()
#print time.time()-t
def move(self,event): def move(self,event):
if event.ButtonUp(wx.MOUSE_BTN_LEFT): if event.ButtonUp(wx.MOUSE_BTN_LEFT):
...@@ -65,7 +70,11 @@ class showstl(wx.Window): ...@@ -65,7 +70,11 @@ class showstl(wx.Window):
if i != -1: if i != -1:
p=event.GetPositionTuple() p=event.GetPositionTuple()
#print (p[0]-self.initpos[0]),(p[1]-self.initpos[1]) #print (p[0]-self.initpos[0]),(p[1]-self.initpos[1])
self.models[self.l.GetItemText(i)]=self.models[self.l.GetItemText(i)].translate([0.5*(p[0]-self.initpos[0]),0.5*(p[1]-self.initpos[1]),0]) t=time.time()
m=self.models[self.l.GetItemText(i)]
m.offsets=[m.offsets[0]+0.5*(p[0]-self.initpos[0]),m.offsets[1]+0.5*(p[1]-self.initpos[1]),m.offsets[2]]
#self.models[self.l.GetItemText(i)]=self.models[self.l.GetItemText(i)].translate([0.5*(p[0]-self.initpos[0]),0.5*(p[1]-self.initpos[1]),0])
#print time.time()-t
self.Refresh() self.Refresh()
self.initpos=None self.initpos=None
elif event.ButtonDown(wx.MOUSE_BTN_RIGHT): elif event.ButtonDown(wx.MOUSE_BTN_RIGHT):
...@@ -84,7 +93,7 @@ class showstl(wx.Window): ...@@ -84,7 +93,7 @@ class showstl(wx.Window):
event.Skip() event.Skip()
def cr(self): def cr(self):
time.sleep(0.1) time.sleep(0.01)
if(self.i!=self.previ): if(self.i!=self.previ):
i=self.l.GetFirstSelected() i=self.l.GetFirstSelected()
if i != -1: if i != -1:
...@@ -98,7 +107,6 @@ class showstl(wx.Window): ...@@ -98,7 +107,6 @@ class showstl(wx.Window):
s=self.l.GetFirstSelected() s=self.l.GetFirstSelected()
if self.prevsel!=s: if self.prevsel!=s:
self.i=0 self.i=0
print "reset"
self.prevsel=s self.prevsel=s
if z > 0: if z > 0:
self.i-=1 self.i-=1
...@@ -114,28 +122,26 @@ class showstl(wx.Window): ...@@ -114,28 +122,26 @@ class showstl(wx.Window):
def paint(self,coord1="x",coord2="y",dc=None): def paint(self,coord1="x",coord2="y",dc=None):
coords={"x":0,"y":1,"z":2} coords={"x":0,"y":1,"z":2}
#s=stltool.stl("20cube.stl")
#print s.facets[0]
#s=self.s
#print self.i
#print s.facets[0]
if dc is None: if dc is None:
dc=wx.ClientDC(self) dc=wx.ClientDC(self)
#self.facet=[normal,[[0,0,0],[0,0,0],[0,0,0]]] offset=[0,0]
offset=200 scale=3
scale=2 dc.SetBrush(wx.Brush(wx.Colour(128,255,128)))
dc.SetPen(wx.Pen(wx.Colour(128,255,128)))
t=time.time()
for m in self.models.values(): for m in self.models.values():
for i in random.sample(m.facets,min(1000,len(m.facets))): for i in m.facets:#random.sample(m.facets,min(100000,len(m.facets))):
dc.DrawLine(offset+scale*i[1][0][coords[coord1]],offset+scale*i[1][0][coords[coord2]],offset+scale*i[1][1][coords[coord1]],offset+scale*i[1][1][coords[coord2]]) dc.DrawPolygon([wx.Point(offset[0]+scale*m.offsets[0]+scale*p[0],0-(offset[1]+scale*m.offsets[1]+scale*p[1])) for p in i[1]])
dc.DrawLine(offset+scale*i[1][2][coords[coord1]],offset+scale*i[1][2][coords[coord2]],offset+scale*i[1][1][coords[coord1]],offset+scale*i[1][1][coords[coord2]]) #if(time.time()-t)>5:
dc.DrawLine(offset+scale*i[1][0][coords[coord1]],offset+scale*i[1][0][coords[coord2]],offset+scale*i[1][2][coords[coord1]],offset+scale*i[1][2][coords[coord2]]) # break
del dc del dc
print time.time()-t
#s.export() #s.export()
class stlwin(wx.Frame): class stlwin(wx.Frame):
def __init__(self,size=(500,600)): def __init__(self,size=(600,700)):
wx.Frame.__init__(self,None,title="Right-click to add a file",size=size) wx.Frame.__init__(self,None,title="Right-click to add a file",size=size)
self.s=showstl(self,(500,600),(100,100)) self.s=showstl(self,(600,700),(0,0))
if __name__ == '__main__': if __name__ == '__main__':
app = wx.App(False) app = wx.App(False)
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
...@@ -304,11 +304,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -304,11 +304,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
lbrs=wx.BoxSizer(wx.HORIZONTAL) lbrs=wx.BoxSizer(wx.HORIZONTAL)
self.commandbox=wx.TextCtrl(self.panel,size=(250,30),pos=(440,420),style = wx.TE_PROCESS_ENTER) self.commandbox=wx.TextCtrl(self.panel,size=(250,30),pos=(440,420),style = wx.TE_PROCESS_ENTER)
self.commandbox.Bind(wx.EVT_TEXT_ENTER,self.sendline) self.commandbox.Bind(wx.EVT_TEXT_ENTER,self.sendline)
self.printerControls.append(self.commandbox) #self.printerControls.append(self.commandbox)
lbrs.Add(self.commandbox) lbrs.Add(self.commandbox)
self.sendbtn=wx.Button(self.panel,-1,"Send",pos=(700,420)) self.sendbtn=wx.Button(self.panel,-1,"Send",pos=(700,420))
self.sendbtn.Bind(wx.EVT_BUTTON,self.sendline) self.sendbtn.Bind(wx.EVT_BUTTON,self.sendline)
self.printerControls.append(self.sendbtn) #self.printerControls.append(self.sendbtn)
lbrs.Add(self.sendbtn) lbrs.Add(self.sendbtn)
lrs.Add(lbrs) lrs.Add(lbrs)
......
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